Переглянути джерело

巡视计划管理:添加巡视任务,添加编辑抽查任务,打卡巡视点,结案归档,设置延期,计划抽查详情,计划抽查列表

zhj 2 роки тому
батько
коміт
0eb3055868

+ 6 - 0
pom.xml

@@ -140,6 +140,12 @@
             <version>20230227</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.gavaghan</groupId>
+            <artifactId>geodesy</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+
     </dependencies>
 
     <repositories>  <!-- 配置阿里云镜像仓库 -->

+ 7 - 0
src/main/java/com/welampiot/common/InterfaceResultEnum.java

@@ -107,6 +107,13 @@ public enum InterfaceResultEnum {
     LACK_PATROL_TIME_ERROR("0300","巡视计划时间不能为空","Patrol plan time can't be empty","Время обхода не должно быть пустым"),
     LACK_PATROL_SPOT_NAME_ERROR("0301","巡视点名称不能为空","The patrol point name cannot be empty","Название места обхода не может быть пустым"),
     TIME_EXCEPTION_ERROR("0302","开始时间不能大于结束时间","The start time cannot be later than the end time","Время начала не может быть больше времени конца"),
+    LACK_PATROL_MANAGE_ID_ERROR("0303","巡视计划id不能为空","The patrol plan id can not be empty","Программа обхода не может быть пустой"),
+    LACK_PATROL_WORK_ID_ERROR("0304","巡视人id不能为空","The inspector id cannot be empty","Удостоверение инспектора не должно быть пустым"),
+    LACK_PATROL_OBJECT_ERROR("0305","巡视对象不能为空","The patrol objects cannot be empty","Объект обхода не может быть пустым"),
+    LACK_PATROL_TYPE_ERROR("0306","巡视计划类型不能为空","The tour plan type cannot be empty","Тип программы не может быть пустым"),
+    LACK_PATROL_START_TIME_ERROR("0307","巡视计划开始时间不能为空","The start time of the inspection schedule cannot be empty","Время начала обхода не должно быть пустым"),
+    LACK_PATROL_END_TIME_ERROR("0308","巡视计划结束时间不能为空","The tour schedule end time cannot be empty","Время окончания обхода не должно быть пустым"),
+    PATROL_TASK_SPOT_DISTANCE_ERROR("0309","距离太远,打卡失败","The distance is so far that the punch card fails","Слишком далеко, чтобы пробить пропуск"),
     ;
     private String code;
     private String msgCn;

+ 227 - 7
src/main/java/com/welampiot/controller/PatrolManageController.java

@@ -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);
+    }
 }

+ 28 - 0
src/main/java/com/welampiot/dao/PatrolCheckPlanDao.java

@@ -0,0 +1,28 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.PatrolCheckPlanDTO;
+import com.welampiot.vo.PatrolCheckPlanVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * ClassName: PatrolCheckPlanDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 10:39
+ * @Version: v1.0
+ */
+public interface PatrolCheckPlanDao {
+    List<PatrolCheckPlanDTO> getPatrolCheckPlanList(PatrolCheckPlanVO vo);
+
+    Integer getPatrolCheckPlanTotal(PatrolCheckPlanVO vo);
+
+    PatrolCheckPlanDTO getPatrolCheckPlanInfo(@Param("id") Integer id);
+
+    void addPatrolCheckPlanData(PatrolCheckPlanDTO dto);
+
+    void updatePatrolCheckPlanData(PatrolCheckPlanDTO dto);
+}

+ 4 - 0
src/main/java/com/welampiot/dao/PatrolTaskDao.java

@@ -18,4 +18,8 @@ public interface PatrolTaskDao {
     List<PatrolTaskDTO> getPatrolTaskList(PatrolTaskVO vo);
 
     Integer getPatrolTaskTotal(PatrolTaskVO vo);
+
+    void addPatrolTaskData(PatrolTaskDTO dto);
+
+    void updatePatrolTaskStatus(PatrolTaskDTO dto);
 }

+ 4 - 0
src/main/java/com/welampiot/dao/PatrolTaskSpotDao.java

@@ -16,4 +16,8 @@ import java.util.List;
  */
 public interface PatrolTaskSpotDao {
     List<PatrolTaskSpotDTO> getPatrolTaskSpotList(@Param("id") Integer id);
+
+    PatrolTaskSpotDTO getPatrolTaskSpotLocationById(@Param("id") Integer id);
+
+    void updatePatrolTaskSpotStatus(PatrolTaskSpotDTO dto);
 }

+ 37 - 0
src/main/java/com/welampiot/dto/PatrolCheckPlanDTO.java

@@ -0,0 +1,37 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: PatrolCheckPlanDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 10:23
+ * @Version: v1.0
+ */
+@Data
+public class PatrolCheckPlanDTO implements Serializable {
+    private Integer id;
+
+    private Integer sectionId;
+
+    private Integer count; // 抽查次数
+
+    private String checkBeginTime; // 计划开始时间
+
+    private String checkEndTime; // 计划结束时间
+
+    private Integer comCount; // 实际抽查次数
+
+    private String createTime;
+
+    private Integer createId; // 创建人员
+
+    private String number; // 巡视计划编号
+
+    private static final long serialVersionUID = 1L;
+}

+ 2 - 0
src/main/java/com/welampiot/dto/PatrolTaskSpotDTO.java

@@ -29,5 +29,7 @@ public class PatrolTaskSpotDTO implements Serializable {
 
     private String image; // 巡视点图片
 
+    private String clockTime; // 打卡时间
+
     private static final long serialVersionUID = 1L;
 }

+ 27 - 0
src/main/java/com/welampiot/service/PatrolCheckPlanService.java

@@ -0,0 +1,27 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.PatrolCheckPlanDTO;
+import com.welampiot.vo.PatrolCheckPlanVO;
+
+import java.util.List;
+
+/**
+ * ClassName: PatrolCheckPlanService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 10:40
+ * @Version: v1.0
+ */
+public interface PatrolCheckPlanService {
+    List<PatrolCheckPlanDTO> getPatrolCheckPlanList(PatrolCheckPlanVO vo);
+
+    Integer getPatrolCheckPlanTotal(PatrolCheckPlanVO vo);
+
+    PatrolCheckPlanDTO getPatrolCheckPlanInfo(Integer id);
+
+    void addPatrolCheckPlanData(PatrolCheckPlanDTO dto);
+
+    void updatePatrolCheckPlanData(PatrolCheckPlanDTO dto);
+}

+ 4 - 0
src/main/java/com/welampiot/service/PatrolTaskService.java

@@ -18,4 +18,8 @@ public interface PatrolTaskService {
     List<PatrolTaskDTO> getPatrolTaskList(PatrolTaskVO vo);
 
     Integer getPatrolTaskTotal(PatrolTaskVO vo);
+
+    void addPatrolTaskData(PatrolTaskDTO dto);
+
+    void updatePatrolTaskStatus(PatrolTaskDTO dto);
 }

+ 4 - 0
src/main/java/com/welampiot/service/PatrolTaskSpotService.java

@@ -15,4 +15,8 @@ import java.util.List;
  */
 public interface PatrolTaskSpotService {
     List<PatrolTaskSpotDTO> getPatrolTaskSpotList(Integer id);
+
+    PatrolTaskSpotDTO getPatrolTaskSpotLocationById(Integer id);
+
+    void updatePatrolTaskSpotStatus(PatrolTaskSpotDTO dto);
 }

+ 50 - 0
src/main/java/com/welampiot/service/impl/PatrolCheckPlanServiceImpl.java

@@ -0,0 +1,50 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.PatrolCheckPlanDao;
+import com.welampiot.dto.PatrolCheckPlanDTO;
+import com.welampiot.service.PatrolCheckPlanService;
+import com.welampiot.vo.PatrolCheckPlanVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ClassName: PatrolCheckPlanServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 10:40
+ * @Version: v1.0
+ */
+@Service
+public class PatrolCheckPlanServiceImpl implements PatrolCheckPlanService {
+    @Autowired
+    private PatrolCheckPlanDao patrolCheckPlanDao;
+
+    @Override
+    public List<PatrolCheckPlanDTO> getPatrolCheckPlanList(PatrolCheckPlanVO vo) {
+        return patrolCheckPlanDao.getPatrolCheckPlanList(vo);
+    }
+
+    @Override
+    public Integer getPatrolCheckPlanTotal(PatrolCheckPlanVO vo) {
+        return patrolCheckPlanDao.getPatrolCheckPlanTotal(vo);
+    }
+
+    @Override
+    public PatrolCheckPlanDTO getPatrolCheckPlanInfo(Integer id) {
+        return patrolCheckPlanDao.getPatrolCheckPlanInfo(id);
+    }
+
+    @Override
+    public void addPatrolCheckPlanData(PatrolCheckPlanDTO dto) {
+        patrolCheckPlanDao.addPatrolCheckPlanData(dto);
+    }
+
+    @Override
+    public void updatePatrolCheckPlanData(PatrolCheckPlanDTO dto) {
+        patrolCheckPlanDao.updatePatrolCheckPlanData(dto);
+    }
+}

+ 10 - 0
src/main/java/com/welampiot/service/impl/PatrolTaskServiceImpl.java

@@ -32,4 +32,14 @@ public class PatrolTaskServiceImpl implements PatrolTaskService {
     public Integer getPatrolTaskTotal(PatrolTaskVO vo) {
         return patrolTaskDao.getPatrolTaskTotal(vo);
     }
+
+    @Override
+    public void addPatrolTaskData(PatrolTaskDTO dto) {
+        patrolTaskDao.addPatrolTaskData(dto);
+    }
+
+    @Override
+    public void updatePatrolTaskStatus(PatrolTaskDTO dto) {
+        patrolTaskDao.updatePatrolTaskStatus(dto);
+    }
 }

+ 10 - 0
src/main/java/com/welampiot/service/impl/PatrolTaskSpotServiceImpl.java

@@ -26,4 +26,14 @@ public class PatrolTaskSpotServiceImpl implements PatrolTaskSpotService {
     public List<PatrolTaskSpotDTO> getPatrolTaskSpotList(Integer id) {
         return patrolTaskSpotDao.getPatrolTaskSpotList(id);
     }
+
+    @Override
+    public PatrolTaskSpotDTO getPatrolTaskSpotLocationById(Integer id) {
+        return patrolTaskSpotDao.getPatrolTaskSpotLocationById(id);
+    }
+
+    @Override
+    public void updatePatrolTaskSpotStatus(PatrolTaskSpotDTO dto) {
+        patrolTaskSpotDao.updatePatrolTaskSpotStatus(dto);
+    }
 }

+ 19 - 1
src/main/java/com/welampiot/utils/ToolUtils.java

@@ -18,6 +18,10 @@ import org.eclipse.paho.client.mqttv3.MqttClient;
 import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
 import org.eclipse.paho.client.mqttv3.MqttMessage;
 import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.gavaghan.geodesy.Ellipsoid;
+import org.gavaghan.geodesy.GeodeticCalculator;
+import org.gavaghan.geodesy.GeodeticCurve;
+import org.gavaghan.geodesy.GlobalCoordinates;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +29,8 @@ import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
-import java.net.*;
+import java.net.URL;
+import java.net.URLConnection;
 import java.text.DecimalFormat;
 import java.util.*;
 import java.util.zip.CRC32;
@@ -517,4 +522,17 @@ public class ToolUtils {
             return null;
         }
     }
+
+    /**
+     * 计算两个经纬度之间的距离
+     * @param gpsFrom 第一个经纬度坐标点
+     * @param gpsTo 第二个经纬度坐标点
+     * @param ellipsoid 坐标系
+     * @return 返回两者之间的距离
+     */
+    public static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid) {
+        //创建GeodeticCalculator,调用计算方法,传入坐标系,经纬度用于计算距离
+        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo);
+        return geoCurve.getEllipsoidalDistance();
+    }
 }

+ 37 - 0
src/main/java/com/welampiot/vo/PatrolCheckPlanInfoVO.java

@@ -0,0 +1,37 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: PatrolCheckPlanInfoVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 11:06
+ * @Version: v1.0
+ */
+@Data
+public class PatrolCheckPlanInfoVO implements Serializable {
+    private Integer id;
+
+    private Integer sectionId;
+
+    private Integer count; // 抽查次数
+
+    private String checkBeginTime; // 计划开始时间
+
+    private String checkEndTime; // 计划结束时间
+
+    private Integer comCount; // 实际抽查次数
+
+    private String createTime;
+
+    private Integer createId; // 创建人员
+
+    private String number; // 巡视计划编号
+
+    private static final long serialVersionUID = 1L;
+}

+ 39 - 0
src/main/java/com/welampiot/vo/PatrolCheckPlanVO.java

@@ -0,0 +1,39 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.PatrolCheckPlanDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: PatrolCheckPlanVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/6/30 - 18:28
+ * @Version: v1.0
+ */
+@Data
+public class PatrolCheckPlanVO implements Serializable {
+    private Integer page;
+
+    private Integer count;
+
+    private String keyword;
+
+    private Integer areaId;
+
+    private Integer cityId;
+
+    private Integer sectionId;
+
+    private Integer provinceId;
+
+    private Integer total;
+
+    private List<PatrolCheckPlanDTO> list;
+
+    private List<Integer> sectionList;
+}

+ 74 - 0
src/main/resources/mapper/PatrolCheckPlanMapper.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.welampiot.dao.PatrolCheckPlanDao">
+
+    <select id="getPatrolCheckPlanList" resultType="PatrolCheckPlanDTO">
+        select p.id,p.sectionId,p.count,p.check_begin_time checkBeginTime,
+               p.com_count comCount,p.check_end_time checkEndTime
+        from patrol_check_plan p
+        left join section s on p.sectionId = s.id
+        left join global_location gl on s.pid = gl.id
+        left join global_location gl1 on gl.pid = gl1.id
+        left join global_location gl2 on gl1.pid = gl2.id
+        where 1=1
+        <if test="keyword != null and keyword != ''">
+            and p.number like '%${keyword}%'
+        </if>
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and p.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and gl.id = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and p.sectionId = #{sectionId}
+        </if>
+        <if test="cityId != null and cityId != 0">
+            and gl1.id = #{cityId}
+        </if>
+        <if test="provinceId != null and provinceId != 0">
+            and gl2.id = #{provinceId}
+        </if>
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getPatrolCheckPlanTotal" resultType="Integer">
+        select count(p.id)
+        from patrol_check_plan p
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where p.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getPatrolCheckPlanInfo" resultType="PatrolCheckPlanDTO">
+        select p.sectionId,p.count,p.check_begin_time checkBeginTime,
+               p.check_end_time checkEndTime
+        from patrol_check_plan p
+        where p.id = #{id}
+    </select>
+
+    <insert id="addPatrolCheckPlanData" keyProperty="id" useGeneratedKeys="true" parameterType="PatrolCheckPlanDTO">
+        insert into patrol_check_plan(sectionId,count,check_begin_time,check_end_time,create_time,create_id)
+        values
+            (#{sectionId},#{count},#{checkBeginTime},#{checkEndTime},#{createTime},#{createId})
+    </insert>
+    
+    <update id="updatePatrolCheckPlanData" parameterType="PatrolCheckPlanDTO">
+        update patrol_check_plan p
+        set
+            p.sectionId = #{sectionId},
+            p.count = #{count},
+            p.check_begin_time = #{checkBeginTime},
+            p.check_end_time = #{checkEndTime}
+        where p.id = #{id}
+    </update>
+
+</mapper>

+ 13 - 0
src/main/resources/mapper/PatrolTaskMapper.xml

@@ -74,5 +74,18 @@
             </foreach>
         </if>
     </select>
+    
+    <insert id="addPatrolTaskData" parameterType="PatrolTaskDTO" useGeneratedKeys="true" keyProperty="id">
+        insert into patrol_task(patrol_manage_id,`time`,work_id,plan_end_time,type,patrol_object,user_id,create_time)
+        values
+            (#{patrolManageId},#{time},#{workId},#{planEndTime},#{type},#{patrolObject},#{userid},#{createTime})
+    </insert>
+
+    <update id="updatePatrolTaskStatus" parameterType="PatrolTaskDTO">
+        update patrol_task p
+        set
+            p.status = #{status}
+        where p.id = #{id}
+    </update>
 
 </mapper>

+ 15 - 0
src/main/resources/mapper/PatrolTaskSpotMapper.xml

@@ -8,4 +8,19 @@
         where p.patrol_task_id = #{id}
     </select>
 
+    <select id="getPatrolTaskSpotLocationById" resultType="PatrolTaskSpotDTO">
+        select p.longitude,latitude
+        from patrol_task_spot p
+        where p.id = #{id}
+    </select>
+
+    <update id="updatePatrolTaskSpotStatus" parameterType="PatrolTaskSpotDTO">
+        update patrol_task_spot p
+        set
+            p.is_clock = 1,
+            p.image = #{image},
+            p.clock_time = #{clockTime}
+        where p.id = #{id}
+    </update>
+
 </mapper>