|
@@ -89,4 +89,97 @@ public class LoopController {
|
|
|
return BaseResult.success(loopDropDownList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加编辑回路
|
|
|
+ * @param request 要添加编辑回路的属性
|
|
|
+ * @return 更新回路数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
+ public BaseResult save(HttpServletRequest request){
|
|
|
+ int version = (int) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ int id = (int) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ int areaId = (int) toolUtils.getRequestContent(request,"areaId",1);
|
|
|
+ int sectionId = (int) toolUtils.getRequestContent(request,"sectionId",1);
|
|
|
+ int devType = (int) toolUtils.getRequestContent(request,"devType",1);
|
|
|
+ int rateId = (int) toolUtils.getRequestContent(request,"rateId",1);
|
|
|
+ int lampPoleId = (int) toolUtils.getRequestContent(request,"lampPoleId",1);
|
|
|
+ int proType = (int) toolUtils.getRequestContent(request,"proType",1);
|
|
|
+ int controlType = (int) toolUtils.getRequestContent(request,"controlType",1);
|
|
|
+ float longitude = request.getParameter("longitude") == null || request.getParameter("longitude").length() == 0 ? 0 : Float.parseFloat(request.getParameter("longitude"));
|
|
|
+ float latitude = request.getParameter("latitude") == null || request.getParameter("latitude").length() == 0 ? 0 : Float.parseFloat(request.getParameter("latitude"));
|
|
|
+ String number = request.getParameter("number");
|
|
|
+ String name = request.getParameter("name");
|
|
|
+ String sn = request.getParameter("sn");
|
|
|
+
|
|
|
+ LoopDTO dto = new LoopDTO();
|
|
|
+ dto.setAreaId(areaId);
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ dto.setRateId(rateId);
|
|
|
+ dto.setLampPoleId(lampPoleId);
|
|
|
+ dto.setLongitude(longitude);
|
|
|
+ dto.setLatitude(latitude);
|
|
|
+ dto.setName(name);
|
|
|
+ dto.setNumber(number);
|
|
|
+ dto.setSn(sn);
|
|
|
+ dto.setDevType(devType);
|
|
|
+ dto.setProType(proType);
|
|
|
+ dto.setControlType(controlType);
|
|
|
+
|
|
|
+ if (id == 0) { // 添加
|
|
|
+ if (number == null || number.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LOOP_NUMBER_ERROR,version);
|
|
|
+ if (name == null || name.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LOOP_NAME_ERROR,version);
|
|
|
+ if (sn == null || sn.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LOOP_SN_ERROR,version);
|
|
|
+ if (areaId == 0) return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR,version);
|
|
|
+ if (sectionId == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,version);
|
|
|
+
|
|
|
+ LoopDTO loopDTO = new LoopDTO();
|
|
|
+ loopDTO.setName(name);
|
|
|
+ loopDTO.setSectionId(sectionId);
|
|
|
+ if (loopService.findByLoopDTO(loopDTO) > 0) return toolUtils.response(InterfaceResultEnum.LOOP_NAME_UNIQUE_ERROR,version);
|
|
|
+ loopDTO = new LoopDTO();
|
|
|
+ loopDTO.setNumber(number);
|
|
|
+ loopDTO.setSectionId(sectionId);
|
|
|
+ if (loopService.findByLoopDTO(loopDTO) > 0) return toolUtils.response(InterfaceResultEnum.LOOP_NUMBER_UNIQUE_ERROR,version);
|
|
|
+ loopDTO = new LoopDTO();
|
|
|
+ loopDTO.setSn(sn);
|
|
|
+ if (loopService.findSNByLoopDTO(loopDTO) > 0) return toolUtils.response(InterfaceResultEnum.LOOP_SN_UNIQUE_ERROR,version);
|
|
|
+ loopService.addLoopDataByDTO(dto);
|
|
|
+ } else { // 编辑
|
|
|
+ dto.setId(id);
|
|
|
+ LoopDTO loopDTO = new LoopDTO();
|
|
|
+ loopDTO.setId(id);
|
|
|
+ loopDTO.setName(name);
|
|
|
+ loopDTO.setSectionId(sectionId);
|
|
|
+ if (loopService.findByLoopDTO(loopDTO) > 0) return toolUtils.response(InterfaceResultEnum.LOOP_NAME_UNIQUE_ERROR,version);
|
|
|
+ loopDTO = new LoopDTO();
|
|
|
+ loopDTO.setId(id);
|
|
|
+ loopDTO.setNumber(number);
|
|
|
+ loopDTO.setSectionId(sectionId);
|
|
|
+ if (loopService.findByLoopDTO(loopDTO) > 0) return toolUtils.response(InterfaceResultEnum.LOOP_NUMBER_UNIQUE_ERROR,version);
|
|
|
+ loopDTO = new LoopDTO();
|
|
|
+ loopDTO.setId(id);
|
|
|
+ loopDTO.setSn(sn);
|
|
|
+ if (loopService.findSNByLoopDTO(loopDTO) > 0) return toolUtils.response(InterfaceResultEnum.LOOP_SN_UNIQUE_ERROR,version);
|
|
|
+ loopService.updateLoopDataByDTO(dto);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除回路数据以及回路日志表数据
|
|
|
+ * @param request 要删除的回路id
|
|
|
+ * @return 操作成功
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/del", method = RequestMethod.POST)
|
|
|
+ public BaseResult del(HttpServletRequest request){
|
|
|
+ int version = (int) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ String id = request.getParameter("id");
|
|
|
+ if (id == null || id.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ String[] split = id.split(",");
|
|
|
+ for (String loopId : split) {
|
|
|
+ int l = Integer.parseInt(loopId);
|
|
|
+ loopService.deleteLoopDataById(l);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|