|
@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
|
/**
|
|
|
* ClassName: ManholeController
|
|
@@ -88,4 +90,97 @@ public class ManholeController {
|
|
|
ManholeVO vo = manholeService.getHistoryListByDTO(dto);
|
|
|
return BaseResult.success(vo);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加编辑井盖设备信息
|
|
|
+ * @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 model = (int) toolUtils.getRequestContent(request,"model",1);
|
|
|
+ double longitude = request.getParameter("longitude") == null || request.getParameter("longitude").length() == 0 ? 0 : Double.parseDouble(request.getParameter("longitude"));
|
|
|
+ double latitude = request.getParameter("latitude") == null || request.getParameter("latitude").length() == 0 ? 0 : Double.parseDouble(request.getParameter("latitude"));
|
|
|
+ String address = request.getParameter("address");
|
|
|
+ String name = request.getParameter("name");
|
|
|
+ String installDate = request.getParameter("installDate");
|
|
|
+ String expirationDate = request.getParameter("expirationDate");
|
|
|
+
|
|
|
+ ManholeDTO dto = new ManholeDTO();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ dto.setAreaId(areaId);
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ dto.setModel(model);
|
|
|
+ dto.setLongitude(longitude);
|
|
|
+ dto.setLatitude(latitude);
|
|
|
+ dto.setAddress(address);
|
|
|
+ dto.setName(name);
|
|
|
+ if (installDate != null && !installDate.equals("")) {
|
|
|
+ try {
|
|
|
+ dto.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(installDate)));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (expirationDate != null && !expirationDate.equals("")) {
|
|
|
+ try {
|
|
|
+ dto.setExpirationDate(simpleDateFormat.format(simpleDateFormat.parse(expirationDate)));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (id == 0) { // 添加
|
|
|
+ if (name == null || name.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_MANHOLE_NAME_ERROR,version);
|
|
|
+ if (address == null || address.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_MANHOLE_ADDRESS_ERROR,version);
|
|
|
+ if (String.valueOf(model).length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_MANHOLE_MODEL_ERROR,version);
|
|
|
+ if (areaId == 0) return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR,version);
|
|
|
+ if (sectionId == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,version);
|
|
|
+
|
|
|
+ ManholeDTO manholeDTO = new ManholeDTO();
|
|
|
+ manholeDTO.setName(name);
|
|
|
+ manholeDTO.setSectionId(sectionId);
|
|
|
+ if (manholeService.findByManholeDTO(manholeDTO) > 0) return toolUtils.response(InterfaceResultEnum.MANHOLE_NAME_UNIQUE_ERROR,version);
|
|
|
+ manholeDTO = new ManholeDTO();
|
|
|
+ manholeDTO.setAddress(address);
|
|
|
+ manholeDTO.setSectionId(sectionId);
|
|
|
+ if (manholeService.findByManholeDTO(manholeDTO) > 0) return toolUtils.response(InterfaceResultEnum.MANHOLE_ADDRESS_UNIQUE_ERROR,version);
|
|
|
+ manholeService.addManholeDataByDTO(dto);
|
|
|
+ } else { // 编辑
|
|
|
+ dto.setId(id);
|
|
|
+ ManholeDTO manholeDTO = new ManholeDTO();
|
|
|
+ manholeDTO.setId(id);
|
|
|
+ manholeDTO.setName(name);
|
|
|
+ manholeDTO.setSectionId(sectionId);
|
|
|
+ if (manholeService.findByManholeDTO(manholeDTO) > 0) return toolUtils.response(InterfaceResultEnum.MANHOLE_NAME_UNIQUE_ERROR,version);
|
|
|
+ manholeDTO = new ManholeDTO();
|
|
|
+ manholeDTO.setId(id);
|
|
|
+ manholeDTO.setAddress(address);
|
|
|
+ manholeDTO.setSectionId(sectionId);
|
|
|
+ if (manholeService.findByManholeDTO(manholeDTO) > 0) return toolUtils.response(InterfaceResultEnum.MANHOLE_ADDRESS_UNIQUE_ERROR,version);
|
|
|
+ manholeService.updateManholeDataByDTO(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 manHoleId : split) {
|
|
|
+ int l = Integer.parseInt(manHoleId);
|
|
|
+ manholeService.deleteManholeDataById(l);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|