use of com.itrus.portal.mobile.entity.AppserviceChargingList in project portal by ixinportal.
the class MobileAppserviceChargingController method show.
// 根据应用id,查询应用下的所有计费规则信息
@RequestMapping(value = "/show/{id}")
public String show(@PathVariable("id") Long id, Model uiModel, HttpServletRequest request) {
ApplicationInfo applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByPrimaryKey", id);
uiModel.addAttribute("applicationInfo", applicationInfo);
// 系统配置的实名认证服务集合
// List<AppService> appServices = new ArrayList<AppService>();
// AppServiceExample appServiceExample = new AppServiceExample();
// AppServiceExample.Criteria criteria = appServiceExample.or();
// criteria.andTypeEqualTo(ComNames.SERVICE_TYPE_CERTIFICATION);
// appServices = sqlSession.selectList(
// "com.itrus.portal.db.AppServiceMapper.selectByExample", appServiceExample);
// uiModel.addAttribute("appServices", appServices);
List<MobileAppserviceCharging> appserviceChargings = new ArrayList<MobileAppserviceCharging>();
appserviceChargings = appserviceChargingService.selectList(id);
AppserviceChargingWrap appserviceChargingWrap = new AppserviceChargingWrap();
List<AppserviceChargingList> appserviceChargingLists = new ArrayList<AppserviceChargingList>();
for (int i = 0; i < appserviceChargings.size(); i++) {
AppserviceChargingList appserviceChargingList = new AppserviceChargingList();
List<MobileAppserviceName> serviceNames = new ArrayList<MobileAppserviceName>();
serviceNames = appserviceNameService.selectListByAppserviceCharging(appserviceChargings.get(i));
List<AppserviceNameList> serviceNameLists = new ArrayList<AppserviceNameList>();
for (int j = 0; j < serviceNames.size(); j++) {
List<MobileChargingPrice> chargingPrices = chargingPriceService.selectListByOneAppserviceName(serviceNames.get(j));
AppserviceNameList appserviceNameList = new AppserviceNameList();
ChargingPriceList chargingPriceList = new ChargingPriceList();
// 1
chargingPriceList.setChargingPriceLists(chargingPrices);
// 2
appserviceNameList.setAppserviceName(serviceNames.get(j));
appserviceNameList.setChargingPriceList(chargingPriceList);
serviceNameLists.add(appserviceNameList);
}
appserviceChargingList.setAppserviceCharging(appserviceChargings.get(i));
appserviceChargingList.setAppserviceNameLists(serviceNameLists);
appserviceChargingLists.add(appserviceChargingList);
}
appserviceChargingWrap.setAppserviceChargingLists(appserviceChargingLists);
System.out.println(appserviceChargingWrap);
uiModel.addAttribute("acw", appserviceChargingWrap);
Map<Long, AppService> appServiceMap = sqlSession.selectMap("com.itrus.portal.db.AppServiceMapper.selectByExample", null, "id");
uiModel.addAttribute("appServiceMap", appServiceMap);
// 返回页面上的表单数据
returnParam(request, uiModel);
return "appservicecharging/show";
}
use of com.itrus.portal.mobile.entity.AppserviceChargingList in project portal by ixinportal.
the class MobileAppserviceChargingController method update.
// 返回修改页面
@RequestMapping(value = "/update/{id}")
public String update(@PathVariable("id") Long id, Model uiModel, HttpServletRequest request) {
ApplicationInfo applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByPrimaryKey", id);
uiModel.addAttribute("applicationInfo", applicationInfo);
List<MobileAppserviceCharging> appserviceChargings = new ArrayList<MobileAppserviceCharging>();
appserviceChargings = appserviceChargingService.selectList(id);
AppserviceChargingWrap appserviceChargingWrap = new AppserviceChargingWrap();
List<AppserviceChargingList> appserviceChargingLists = new ArrayList<AppserviceChargingList>();
for (int i = 0; i < appserviceChargings.size(); i++) {
AppserviceChargingList appserviceChargingList = new AppserviceChargingList();
List<MobileAppserviceName> appserviceNames = new ArrayList<MobileAppserviceName>();
appserviceNames = appserviceNameService.selectListByAppserviceCharging(appserviceChargings.get(i));
List<AppserviceNameList> appserviceNameLists = new ArrayList<AppserviceNameList>();
for (int j = 0; j < appserviceNames.size(); j++) {
List<MobileChargingPrice> chargingPrices = chargingPriceService.selectListByOneAppserviceName(appserviceNames.get(j));
AppserviceNameList appserviceNameList = new AppserviceNameList();
ChargingPriceList chargingPriceList = new ChargingPriceList();
// 1
chargingPriceList.setChargingPriceLists(chargingPrices);
// 2
appserviceNameList.setAppserviceName(appserviceNames.get(j));
appserviceNameList.setChargingPriceList(chargingPriceList);
appserviceNameLists.add(appserviceNameList);
}
appserviceChargingList.setAppserviceCharging(appserviceChargings.get(i));
appserviceChargingList.setAppserviceNameLists(appserviceNameLists);
appserviceChargingLists.add(appserviceChargingList);
}
appserviceChargingWrap.setAppserviceChargingLists(appserviceChargingLists);
uiModel.addAttribute("acw", appserviceChargingWrap);
// Map<Long, AppService> appServiceMap = sqlSession.selectMap(
// "com.itrus.portal.db.AppServiceMapper.selectByExample", null,
// "id");
// uiModel.addAttribute("appServiceMap", appServiceMap);
returnParam(request, uiModel);
return "appservicecharging/update";
}
use of com.itrus.portal.mobile.entity.AppserviceChargingList in project portal by ixinportal.
the class MobileAppserviceChargingController method createOrUpdate.
// 新建和修改处理
@RequestMapping(value = "/createOrUpdate", method = RequestMethod.POST, produces = "text/html")
@ResponseBody
public synchronized Map<String, Object> createOrUpdate(@RequestParam("appserviceChargingStr") String appserviceChargingStr) {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("flag", false);
DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
// 事物的传播行为,使用同一个事物
dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(dtd);
try {
AppserviceChargingWrap acw = jsonTool.readValue(appserviceChargingStr, AppserviceChargingWrap.class);
List<AppserviceChargingList> appserviceChargingLists = acw.getAppserviceChargingLists();
for (int i = 0; i < appserviceChargingLists.size(); i++) {
// 取出单个的服务名称主表对象和服务名封装list
MobileAppserviceCharging appCharging = appserviceChargingLists.get(i).getAppserviceCharging();
// if (null == appCharging.getChargingType()) {
// cc.setChargingType(ComNames.CHARGING_TYPE_SMRZ_1);
// }
List<AppserviceNameList> appserviceNameLists = appserviceChargingLists.get(i).getAppserviceNameLists();
Map<String, Object> mapAC = new HashMap<String, Object>();
mapAC = appserviceChargingService.saveOrUpdateAppserviceCharging(appCharging);
boolean retCodeAC = false;
retCodeAC = (boolean) mapAC.get("flag");
// 新增或修改MobileAppserviceCharging成功
if (retCodeAC) {
appCharging = (MobileAppserviceCharging) mapAC.get("appserviceCharging");
MobileAppserviceCharging oldAC = (MobileAppserviceCharging) mapAC.get("oldAppserviceCharging");
// 将MobileAppserviceCharging的id值赋值给serviceNameList中新增的服务
appserviceNameLists = appserviceNameService.insertIdIntoAppserviceName(appCharging, appserviceNameLists);
// 2.新增或修改ServiceName
for (int j = 0; j < appserviceNameLists.size(); j++) {
MobileAppserviceName appserviceName = appserviceNameLists.get(j).getAppserviceName();
ChargingPriceList chargingPriceList = appserviceNameLists.get(j).getChargingPriceList();
boolean retCodeSN = false;
Map<String, Object> mapAppserviceName = new HashMap<String, Object>();
mapAppserviceName = appserviceNameService.saveOrUpdateServiceName(appserviceName, appCharging, oldAC);
retCodeSN = (boolean) mapAppserviceName.get("flag");
// 新增或修改ServiceName成功
if (retCodeSN) {
appserviceName = (MobileAppserviceName) mapAppserviceName.get("appserviceName");
MobileAppserviceName oldAppserviceName = (MobileAppserviceName) mapAppserviceName.get("oldAppserviceName");
List<MobileAppserviceName> oldAppserviceNames = (List<MobileAppserviceName>) mapAppserviceName.get("appserviceNames");
// 将serviceNameId,CertificationCharging的id值赋值给chargingPriceList中计费以及价格区间
chargingPriceList = chargingPriceService.insertIdIntoChargingPrice(appserviceName, chargingPriceList);
List<MobileChargingPrice> chargingPrices = chargingPriceList.getChargingPriceLists();
// 3.charprice新增或修改
for (int k = 0; k < chargingPrices.size(); k++) {
Map<String, Object> mapChargingPrice = new HashMap<String, Object>();
mapChargingPrice = chargingPriceService.saveOrUpdateChargingPrice(appCharging, appserviceName, chargingPrices.get(k), oldAC, oldAppserviceName, oldAppserviceNames);
boolean retCodeChargingPrice = false;
retCodeChargingPrice = (boolean) mapChargingPrice.get("flag");
// 新增或修改ChargingPrice失败
if (!retCodeChargingPrice) {
transactionManager.rollback(status);
retMap = mapChargingPrice;
return retMap;
}
}
} else {
// TODO 新增或修改ServiceName错误,返回异常信息
transactionManager.rollback(status);
retMap = mapAppserviceName;
return retMap;
}
}
} else {
// TODO 新增或修改CertificationCharging错误,返回异常信息
transactionManager.rollback(status);
retMap = mapAC;
return retMap;
}
}
LogUtil.adminlog(sqlSession, "新增计费规则", "新增了计费规则");
transactionManager.commit(status);
retMap.put("flag", true);
// 修改应用对应的服务:将应用和服务关联起来
// Set<Long> set = appserviceChargingService.getAllAppId();
// if (null != set && set.size() >0) {
// for (Long long1 : set) {
// Set<Long> AppserviceIDs = appserviceChargingService.getAppserviceIDsByAppId(long1);
// applicationInfoService.addServiceByAppInfo(long1,AppserviceIDs);
// }
// }
// 通知其他机器,加载缓存
CertificationChargingHandler cch = new CertificationChargingHandler();
QueueThread.buildCertificationTask(cch);
// cacheCustomer.initChargeRule();
return retMap;
} catch (JsonParseException e) {
transactionManager.rollback(status);
e.printStackTrace();
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (JsonMappingException e) {
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
e.printStackTrace();
return retMap;
} catch (IOException e) {
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
e.printStackTrace();
return retMap;
} catch (Exception e) {
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
e.printStackTrace();
return retMap;
}
}
Aggregations