/** 提交并保存支路信息 */ @ResourceMapping(value = "submitCircuitinfoForm") public Resultmsg onSubmitCircuitinfoForm( @ModelAttribute("circuitinfo") Circuitinfo circuitinfo, BindingResult result, SessionStatus status, ResourceRequest request, ResourceResponse response) { Resultmsg msg = new Resultmsg(); boolean isnew = true; if (request.getParameter("isnew") == null) { msg.setMsg("页面缺少新增或编辑标记 isnew"); } else { isnew = Boolean.valueOf(request.getParameter("isnew")); } new CircuitinfoValidator().validate(circuitinfo, result); if (result.hasErrors()) { logger.error(result); msg.setMsg(result.toString()); } else { try { if (isnew) { circuitinfoService.addCircuitinfo(circuitinfo); } else { circuitinfoService.updateCircuitinfo(circuitinfo); } status.setComplete(); msg.setMsg(circuitinfo.getCircuitId()); msg.setSuccess("true"); } catch (Exception e) { logger.error(e); msg.setMsg(e.getMessage()); } } return msg; }
@ResourceMapping(value = "submitMeteruseinfoForm") public Resultmsg onSubmitMeteruseinfoForm( @ModelAttribute("meteruseinfo") Meteruseinfo meteruseinfo, BindingResult result, SessionStatus status, ResourceRequest request, ResourceResponse response) { Resultmsg msg = new Resultmsg(); boolean isnew = true; if (request.getParameter("isnew") == null) { msg.setMsg("页面缺少新增或编辑标记 isnew"); } else { isnew = Boolean.valueOf(request.getParameter("isnew")); } new MeteruseinfoValidator().validate(meteruseinfo, result); if (result.hasErrors()) { logger.error(result); StringBuilder sb = new StringBuilder(); for (ObjectError err : result.getAllErrors()) { sb.append(err.getDefaultMessage()); } msg.setMsg(sb.toString()); } else { try { if (!StringUtils.hasLength(meteruseinfo.getBuildregioninfo().getRegionId())) { meteruseinfo.setBuildregioninfo(null); } Circuitinfo circuitinfo = circuitinfoService.getCircuitinfo(meteruseinfo.getCircuitinfo().getCircuitId()); meteruseinfo.setCircuitinfo(circuitinfo); if ("系统生成".equals(meteruseinfo.getMeterId()) || "".equals(meteruseinfo.getMeterId())) { meteruseinfoService.addMeteruseinfo(meteruseinfo); } else { meteruseinfoService.updateMeteruseinfo(meteruseinfo); } // meteruseinfoService.saveOrUpdateMeteruseinfo(meteruseinfo); // 保存分类分项与装表关系数据 if (StringUtils.hasLength(request.getParameter("energyItemcode"))) { String energyItemcode = request.getParameter("energyItemcode").trim(); String resultId = request.getParameter("resultId").trim(); Energyitemresult energyitemresult = new Energyitemresult(); energyitemresult.setResultId(resultId); energyitemresult.setMeteruseinfo(meteruseinfo); Energyitemdict energyitemdict = energyitemdictService.getEnergyitemdict(energyItemcode); energyitemresult.setEnergyitemdict(energyitemdict); energyitemresultService.saveOrUpdateEnergyitemresult(energyitemresult); } status.setComplete(); msg.setMsg(meteruseinfo.getMeterId()); msg.setSuccess("true"); } catch (Exception e) { msg.setMsg(e.getMessage()); logger.error(e); } } return msg; }
/** 删除仪表信息 */ @ResourceMapping(value = "removeMeteruseinfo") public Resultmsg onRemoveMeteruseinfo(@RequestParam("meterId") String meterId) { Resultmsg msg = new Resultmsg(); if (StringUtils.hasLength(meterId)) { try { meteruseinfoService.deleteMeteruseinfo(meterId); msg.setSuccess("true"); } catch (Exception e) { msg.setMsg(e.getMessage()); } } else { msg.setMsg("仪表ID为空"); } return msg; }
/** * 删除支路信息 * * @param circuitId 支路ID */ @ResourceMapping(value = "removeCircuitinfo") public Resultmsg onRemoveCircuitinfo(@RequestParam("circuitId") String circuitId) { Resultmsg msg = new Resultmsg(); if (StringUtils.hasLength(circuitId)) { try { circuitinfoService.deleteCircuitinfo(circuitId); msg.setSuccess("true"); } catch (Exception e) { logger.error(e); msg.setMsg(e.getMessage()); } } else { msg.setMsg("支路ID为空"); } return msg; }
/** * 删除指定的仪表属性 * * @param meterId 仪表ID * @param meterattrName 属性名称 * @return 成功或失败消息 */ @ResourceMapping(value = "removeAttribute") public Resultmsg onRemoveAttribute( @RequestParam("meterId") String meterId, @RequestParam("meterattrName") String meterattrName) { Resultmsg msg = new Resultmsg(); if (!StringUtils.hasLength(meterId)) { msg.setMsg("未能获取到仪表ID"); } else if (!StringUtils.hasLength(meterattrName)) { msg.setMsg("未能获取到属性名称"); } else { try { meteruseinfoService.deleteMeteruseattribute(meterattrName, meterId); msg.setSuccess("true"); } catch (Exception e) { msg.setMsg(e.getMessage()); } } return msg; }
/** 执行仪表属性提交 */ @ResourceMapping(value = "submitMeteruseattributeForm") public Resultmsg onSubmitMeteruseattributeForm( @ModelAttribute("meteruseattribute") Meteruseattribute meteruseattribute, BindingResult result, SessionStatus status, ResourceRequest request, ResourceResponse response) { Resultmsg msg = new Resultmsg(); String meterId = ""; if (request.getParameter("meterId") != null) { meterId = request.getParameter("meterId"); MeteruseattributeId id = new MeteruseattributeId(); id.setMeterId(meterId); id.setMeterattrName(meteruseattribute.getId().getMeterattrName()); meteruseattribute.setId(id); } new MeteruseattributeValidator().validate(meteruseattribute, result); if (result.hasErrors()) { logger.error(result); StringBuilder sb = new StringBuilder(); for (ObjectError err : result.getAllErrors()) { sb.append(err.getDefaultMessage()); } msg.setMsg(sb.toString()); } else { try { meteruseinfoService.saveOrUpdateMeteruseattribute(meteruseattribute); status.setComplete(); msg.setSuccess("true"); } catch (Exception e) { logger.error(e); msg.setMsg(e.getMessage()); } } return msg; }