|
@@ -2,16 +2,18 @@ package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
-import com.welampiot.dto.PatrolManageDTO;
|
|
|
-import com.welampiot.dto.PatrolSpotDTO;
|
|
|
-import com.welampiot.dto.PatrolTaskDTO;
|
|
|
-import com.welampiot.dto.PatrolTaskSpotDTO;
|
|
|
+import com.welampiot.dto.*;
|
|
|
import com.welampiot.service.*;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.vo.PatrolCheckPlanInfoVO;
|
|
|
+import com.welampiot.vo.PatrolCheckPlanVO;
|
|
|
import com.welampiot.vo.PatrolManageVO;
|
|
|
import com.welampiot.vo.PatrolTaskVO;
|
|
|
+import org.gavaghan.geodesy.Ellipsoid;
|
|
|
+import org.gavaghan.geodesy.GlobalCoordinates;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -56,6 +58,9 @@ public class PatrolManageController {
|
|
|
@Autowired
|
|
|
private PatrolTaskSpotService patrolTaskSpotService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PatrolCheckPlanService patrolCheckPlanService;
|
|
|
+
|
|
|
/**
|
|
|
* 巡视计划列表
|
|
|
* @param request 分页、路段筛选、关键字搜索
|
|
@@ -203,8 +208,6 @@ public class PatrolManageController {
|
|
|
@RequestMapping(value = "/patrolTaskList", method = RequestMethod.POST)
|
|
|
public BaseResult<?> patrolTaskList(HttpServletRequest request) throws ParseException {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
- Integer page = (Integer) toolUtils.getRequestContent(request,"page",1);
|
|
|
- Integer count = (Integer) toolUtils.getRequestContent(request,"count",1);
|
|
|
Integer status = (Integer) toolUtils.getRequestContent(request,"status",1);
|
|
|
Integer areaId = (Integer) toolUtils.getRequestContent(request,"areaId",1);
|
|
|
Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
|
|
@@ -213,6 +216,8 @@ public class PatrolManageController {
|
|
|
String username = (String) toolUtils.getRequestContent(request,"username",2);
|
|
|
String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
|
|
|
String date = (String) toolUtils.getRequestContent(request,"date",2);
|
|
|
+ int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
|
|
|
+ int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
|
|
|
if (username == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
String startDate = "", endDate = "";
|
|
|
if (date.length() != 0) {
|
|
@@ -222,7 +227,7 @@ public class PatrolManageController {
|
|
|
}
|
|
|
|
|
|
PatrolTaskVO patrolTaskVO = new PatrolTaskVO();
|
|
|
- patrolTaskVO.setPage(page);
|
|
|
+ patrolTaskVO.setPage(count * (page - 1));
|
|
|
patrolTaskVO.setCount(count);
|
|
|
patrolTaskVO.setStatus(status);
|
|
|
patrolTaskVO.setAreaId(areaId);
|
|
@@ -248,4 +253,219 @@ public class PatrolManageController {
|
|
|
vo.setTotal(patrolTaskService.getPatrolTaskTotal(patrolTaskVO));
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加巡视任务
|
|
|
+ * @param request 巡视任务属性
|
|
|
+ * @return 更新巡视任务数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/savePatrolTask", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> savePatrolTask(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ Integer workId = (Integer) toolUtils.getRequestContent(request,"workId",1);
|
|
|
+ Integer type = (Integer) toolUtils.getRequestContent(request,"type",1);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request,"username",2);
|
|
|
+ String time = (String) toolUtils.getRequestContent(request,"time",2);
|
|
|
+ String planEndTime = (String) toolUtils.getRequestContent(request,"planEndTime",2);
|
|
|
+ String patrolObject = (String) toolUtils.getRequestContent(request,"patrolObject",2);
|
|
|
+ if (username == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ Integer userid = repairPersonnelService.getUserIdByUsername(username);
|
|
|
+
|
|
|
+ if (id == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_MANAGE_ID_ERROR,version);
|
|
|
+ if (workId == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_WORK_ID_ERROR,version);
|
|
|
+ if (String.valueOf(type).length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_TYPE_ERROR,version);
|
|
|
+ if (time.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_START_TIME_ERROR,version);
|
|
|
+ if (planEndTime.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_END_TIME_ERROR,version);
|
|
|
+ if (patrolObject.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_OBJECT_ERROR,version);
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
+ PatrolTaskDTO patrolTaskDTO = new PatrolTaskDTO();
|
|
|
+ patrolTaskDTO.setPatrolManageId(id);
|
|
|
+ patrolTaskDTO.setWorkId(workId);
|
|
|
+ patrolTaskDTO.setType(type);
|
|
|
+ patrolTaskDTO.setTime(time);
|
|
|
+ patrolTaskDTO.setPlanEndTime(planEndTime);
|
|
|
+ patrolTaskDTO.setPatrolObject(patrolObject);
|
|
|
+ patrolTaskDTO.setUserid(userid);
|
|
|
+ patrolTaskDTO.setCreateTime(format);
|
|
|
+ patrolTaskService.addPatrolTaskData(patrolTaskDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计划抽查列表
|
|
|
+ * @param request 分页,关键字搜素,路段筛选
|
|
|
+ * @return 计划抽查列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/patrolCheckPlanList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> patrolCheckPlanList(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer areaId = (Integer) toolUtils.getRequestContent(request,"areaId",1);
|
|
|
+ Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
|
|
|
+ Integer provinceId = (Integer) toolUtils.getRequestContent(request,"provinceId",1);
|
|
|
+ Integer cityId = (Integer) toolUtils.getRequestContent(request,"cityId",1);
|
|
|
+ String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
|
|
|
+ int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
|
|
|
+ int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
|
|
|
+
|
|
|
+ PatrolCheckPlanVO patrolCheckPlanVO = new PatrolCheckPlanVO();
|
|
|
+ patrolCheckPlanVO.setPage(count * (page - 1));
|
|
|
+ patrolCheckPlanVO.setCount(count);
|
|
|
+ patrolCheckPlanVO.setAreaId(areaId);
|
|
|
+ patrolCheckPlanVO.setSectionId(sectionId);
|
|
|
+ patrolCheckPlanVO.setProvinceId(provinceId);
|
|
|
+ patrolCheckPlanVO.setCityId(cityId);
|
|
|
+ patrolCheckPlanVO.setKeyword(keyword);
|
|
|
+ patrolCheckPlanVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<PatrolCheckPlanDTO> patrolCheckPlanList = patrolCheckPlanService.getPatrolCheckPlanList(patrolCheckPlanVO);
|
|
|
+ List<PatrolCheckPlanDTO> list = new ArrayList<>();
|
|
|
+ patrolCheckPlanList.forEach(dto -> {
|
|
|
+ if (dto.getComCount() == null) {
|
|
|
+ dto.setComCount(0);
|
|
|
+ }
|
|
|
+ list.add(dto);
|
|
|
+ });
|
|
|
+ PatrolCheckPlanVO vo = new PatrolCheckPlanVO();
|
|
|
+ vo.setList(list);
|
|
|
+ vo.setTotal(patrolCheckPlanService.getPatrolCheckPlanTotal(vo));
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计划抽查详情
|
|
|
+ * @param request 抽查id
|
|
|
+ * @return 计划抽查详情
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/patrolCheckPlanInfo", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> patrolCheckPlanInfo(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ PatrolCheckPlanDTO patrolCheckPlanDTO = patrolCheckPlanService.getPatrolCheckPlanInfo(id);
|
|
|
+ if (patrolCheckPlanDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ PatrolCheckPlanInfoVO patrolCheckPlanInfoVO = new PatrolCheckPlanInfoVO();
|
|
|
+ BeanUtils.copyProperties(patrolCheckPlanDTO,patrolCheckPlanInfoVO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,patrolCheckPlanInfoVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加编辑计划抽查任务
|
|
|
+ * @param request 计划抽查任务属性
|
|
|
+ * @return 更新计划抽查任务数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/savePatrolCheckPlan", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> savePatrolCheckPlan(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
|
|
|
+ Integer count = (Integer) toolUtils.getRequestContent(request,"count",1);
|
|
|
+ String checkBeginTime = (String) toolUtils.getRequestContent(request,"checkBeginTime",2);
|
|
|
+ String checkEndTime = (String) toolUtils.getRequestContent(request,"checkEndTime",2);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request,"username",2);
|
|
|
+ if (username.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+
|
|
|
+ if (sectionId == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,version);
|
|
|
+ if (checkBeginTime.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_START_TIME_ERROR,version);
|
|
|
+ if (checkEndTime.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PATROL_END_TIME_ERROR,version);
|
|
|
+ PatrolCheckPlanDTO patrolCheckPlanDTO = new PatrolCheckPlanDTO();
|
|
|
+ patrolCheckPlanDTO.setCount(count);
|
|
|
+ patrolCheckPlanDTO.setCheckBeginTime(checkBeginTime);
|
|
|
+ patrolCheckPlanDTO.setCheckEndTime(checkEndTime);
|
|
|
+ patrolCheckPlanDTO.setSectionId(sectionId);
|
|
|
+ if (id == 0) { // 添加
|
|
|
+ Integer userid = repairPersonnelService.getUserIdByUsername(username);
|
|
|
+ patrolCheckPlanDTO.setCreateId(userid);
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
+ patrolCheckPlanDTO.setCreateTime(format);
|
|
|
+ patrolCheckPlanService.addPatrolCheckPlanData(patrolCheckPlanDTO);
|
|
|
+ } else { // 编辑
|
|
|
+ patrolCheckPlanDTO.setId(id);
|
|
|
+ patrolCheckPlanService.updatePatrolCheckPlanData(patrolCheckPlanDTO);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打卡巡视点
|
|
|
+ * @param request 巡视点id,经纬度,图片
|
|
|
+ * @return 更新巡视点状态
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/patrolTaskClock", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> patrolTaskClock(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ String longitude = (String) toolUtils.getRequestContent(request,"longitude",2);
|
|
|
+ String latitude = (String) toolUtils.getRequestContent(request,"latitude",2);
|
|
|
+ String image = (String) toolUtils.getRequestContent(request,"image",2);
|
|
|
+ if (id == 0 || longitude.length() == 0 || latitude.length() == 0 || image.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ PatrolTaskSpotDTO dto = patrolTaskSpotService.getPatrolTaskSpotLocationById(id);
|
|
|
+ if (dto == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ double latitude1 = Double.parseDouble(dto.getLatitude());
|
|
|
+ double longitude1 = Double.parseDouble(dto.getLongitude());
|
|
|
+ GlobalCoordinates gpsFrom = new GlobalCoordinates(latitude1, longitude1);
|
|
|
+ GlobalCoordinates gpsTo = new GlobalCoordinates(Double.parseDouble(latitude),Double.parseDouble(longitude));
|
|
|
+ double distanceMeter = ToolUtils.getDistanceMeter(gpsFrom, gpsTo, Ellipsoid.Sphere);
|
|
|
+ System.out.println("distanceMeter:" + distanceMeter);
|
|
|
+ if (distanceMeter < 10) {
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
+ PatrolTaskSpotDTO patrolTaskSpotDTO = new PatrolTaskSpotDTO();
|
|
|
+ patrolTaskSpotDTO.setImage(image);
|
|
|
+ patrolTaskSpotDTO.setClockTime(format);
|
|
|
+ patrolTaskSpotDTO.setId(id);
|
|
|
+ patrolTaskSpotService.updatePatrolTaskSpotStatus(patrolTaskSpotDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ } else {
|
|
|
+ return toolUtils.response(InterfaceResultEnum.PATROL_TASK_SPOT_DISTANCE_ERROR,version);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 结案归档
|
|
|
+ * @param request 巡视任务id
|
|
|
+ * @return 更新巡视任务状态为结案归档
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/filePatrolTask", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> filePatrolTask(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ PatrolTaskDTO patrolTaskDTO = new PatrolTaskDTO();
|
|
|
+ patrolTaskDTO.setStatus(3);
|
|
|
+ patrolTaskDTO.setId(id);
|
|
|
+ patrolTaskService.updatePatrolTaskStatus(patrolTaskDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置延期
|
|
|
+ * @param request 巡视任务id
|
|
|
+ * @return 更新巡视任务状态为延期
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/patrolTaskDelay", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> patrolTaskDelay(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ PatrolTaskDTO patrolTaskDTO = new PatrolTaskDTO();
|
|
|
+ patrolTaskDTO.setStatus(4);
|
|
|
+ patrolTaskDTO.setId(id);
|
|
|
+ patrolTaskService.updatePatrolTaskStatus(patrolTaskDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|