@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 = "getMeteruseattributes") public JsonResult getMeteruseattributes(@RequestParam("meterId") String meterId) { JsonResult result = new JsonResult(); Set<Meteruseattribute> attrs = meteruseinfoService.getMeteruseattributeByMeterId(meterId); result.setData(new ArrayList<Meteruseattribute>(attrs)); return result; }
/** * 获取指定支路的安装仪表 * * @param circuitid 支路ID * @param page 当前页码 * @param rows 显示条数 */ @ResourceMapping(value = "getMeteruseinfosByCircuitid") public Page getMeteruseinfosByCircuitid( @RequestParam("circuitId") String circuitId, @RequestParam("page") Integer page, @RequestParam("rows") Integer rows, ResourceRequest request, ResourceResponse response) { Map<String, Object> mapParams = new HashMap<String, Object>(); mapParams.put("circuit_Id", circuitId); return meteruseinfoService.getMeteruseinfos(page, rows, mapParams); }
/** 删除仪表信息 */ @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 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; }