459242451@qq.com 3 rokov pred
rodič
commit
3edc894470

+ 8 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlCommonController.java

@@ -14,11 +14,13 @@ import com.ruoyi.qdtl.domain.TlArea;
 import com.ruoyi.qdtl.domain.TlInspectionDeviceTrail;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+import com.ruoyi.qdtl.domain.UserCheckPoint;
 import com.ruoyi.qdtl.service.ITlAreaService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceTrailService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import com.ruoyi.qdtl.service.ITlMonitorService;
+import com.ruoyi.qdtl.service.ITlPlanRecordService;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.service.ISysConfigService;
 import lombok.RequiredArgsConstructor;
@@ -55,6 +57,7 @@ public class TlCommonController extends BaseController {
     private final ITlInspectionDeviceTrailService tlInspectionDeviceTrailService;
     private final ITlInspectionLocationLogService tlInspectionLocationLogService;
     private final ITlMonitorService tlMonitorService;
+    private final ITlPlanRecordService planRecordService;
 
 
     /**
@@ -148,6 +151,11 @@ public class TlCommonController extends BaseController {
         // 视频资源统计
         List<MonitorStatic> cameraslist = tlMonitorService.queryMonitorStatic();
         map.put("cameraslist", cameraslist);
+        // 巡检考核
+        List<UserCheckPoint> checkStatic = tlInspectionLocationLogService.queryUserGroup();
+        map.put("checkStatic", checkStatic);
+        // 当日巡检完成率(总以及各个镇)
+        Map<String, Object> checkPercent = planRecordService.queryCheckPercent(date);
 
         return AjaxResult.success(map);
     }

+ 18 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/PlanTask.java

@@ -4,8 +4,10 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.qdtl.domain.PlanUser;
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
 import com.ruoyi.qdtl.domain.TlInspectionPlan;
 import com.ruoyi.qdtl.domain.TlPlanRecord;
+import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import com.ruoyi.qdtl.service.ITlInspectionPlanService;
 import com.ruoyi.qdtl.service.ITlPlanRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +32,8 @@ public class PlanTask {
     @Autowired
     private ITlPlanRecordService planRecordService;
     @Autowired
+    private ITlInspectionLocationService locationService;
+    @Autowired
     private RedisCache redisCache;
 
     /**
@@ -63,18 +67,23 @@ public class PlanTask {
             for (TlInspectionPlan inspectionPlan : planList) {
                 // 查询计划的人员.根据计划id查询人员以及设备号
                 List<PlanUser> userList = planService.queryPlanUser(inspectionPlan.getId());
+                // 查询计划的线路及点位
+                List<TlInspectionLocation> lineLocations = locationService.queryLocationByLineId(inspectionPlan.getLineId());
                 if (userList != null && userList.size() > 0) {
                     // 组装计划数据
                     for (PlanUser planUser : userList) {
-                        TlPlanRecord planRecord = new TlPlanRecord();
-                        planRecord.setPlanId(planUser.getPlanId());
-                        planRecord.setPlanDate(queryDate);
-                        planRecord.setPlanName(inspectionPlan.getPlanName());
-                        planRecord.setUserId(planUser.getUserId());
-                        planRecord.setNickName(planUser.getNickName());
-                        planRecord.setCard(planUser.getCard());
-                        planRecord.setScore(inspectionPlan.getScore());
-                        planRecords.add(planRecord);
+                        for (TlInspectionLocation lineLocation : lineLocations) {
+                            TlPlanRecord planRecord = new TlPlanRecord();
+                            planRecord.setPlanId(planUser.getPlanId());
+                            planRecord.setPlanDate(queryDate);
+                            planRecord.setPlanName(inspectionPlan.getPlanName());
+                            planRecord.setUserId(planUser.getUserId());
+                            planRecord.setNickName(planUser.getNickName());
+                            planRecord.setCard(planUser.getCard());
+                            planRecord.setScore(inspectionPlan.getScore());
+                            planRecord.setCheckpointCard(lineLocation.getLocationCode());
+                            planRecords.add(planRecord);
+                        }
                     }
                 }
             }

+ 22 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/UserCheckPoint.java

@@ -0,0 +1,22 @@
+package com.ruoyi.qdtl.domain;
+
+import lombok.Data;
+
+/**
+ * @Description: TODO
+ * @Author: huangcheng
+ * @Date: 2022/3/30
+ * @Version V1.0
+ */
+@Data
+public class UserCheckPoint {
+    // 巡检卡号
+    private String patrolmanCard;
+    // 巡检员
+    private String nickName;
+    // 巡检次数
+    private String checkCount;
+    // 综合分数
+    private String score = "100";
+
+}

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionLocationLogMapper.java

@@ -1,6 +1,7 @@
 package com.ruoyi.qdtl.mapper;
 
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+import com.ruoyi.qdtl.domain.UserCheckPoint;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
@@ -64,4 +65,6 @@ public interface TlInspectionLocationLogMapper {
     Date queryMaxDate();
 
     List<TlInspectionLocationLog> queryByCondition(@Param("date") String date, @Param("checkpointCard") String checkpointCard, @Param("deviceId") String deviceId);
+
+    List<UserCheckPoint> queryUserGroup();
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionLocationMapper.java

@@ -74,4 +74,6 @@ public interface TlInspectionLocationMapper {
     int queryMaxVsersion();
 
     void deleteLocationByVersion(@Param("version") int version);
+
+    List<TlInspectionLocation> queryLocationByLineId(@Param("lineId") Long lineId);
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlPlanRecordMapper.java

@@ -63,4 +63,6 @@ public interface TlPlanRecordMapper {
     void batchInsert(@Param("list") List<TlPlanRecord> planRecords);
 
     void updateRecordByDateAndCard(TlPlanRecord tlPlanRecord);
+
+    List<TlPlanRecord> selectTlPlanRecordListByDate(@Param("date") String date);
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlInspectionLocationLogService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.qdtl.service;
 
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+import com.ruoyi.qdtl.domain.UserCheckPoint;
 
 import java.util.Date;
 import java.util.List;
@@ -64,4 +65,5 @@ public interface ITlInspectionLocationLogService {
 
     List<TlInspectionLocationLog> queryByCondition(String date, String checkpointCard, String deviceId);
 
+    List<UserCheckPoint> queryUserGroup();
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlInspectionLocationService.java

@@ -71,4 +71,6 @@ public interface ITlInspectionLocationService {
     int queryMaxVsersion();
 
     void deleteLocationByVersion(int version);
+
+    List<TlInspectionLocation> queryLocationByLineId(Long lineId);
 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlPlanRecordService.java

@@ -3,6 +3,7 @@ package com.ruoyi.qdtl.service;
 import com.ruoyi.qdtl.domain.TlPlanRecord;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 巡检计划记录Service接口
@@ -62,4 +63,6 @@ public interface ITlPlanRecordService {
     void batchInsert(List<TlPlanRecord> planRecords);
 
     void updateRecordByDateAndCard(TlPlanRecord tlPlanRecord);
+
+    Map<String, Object> queryCheckPercent(String date);
 }

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionLocationLogServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.qdtl.service.impl;
 import cn.hutool.core.util.ObjectUtil;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
+import com.ruoyi.qdtl.domain.UserCheckPoint;
 import com.ruoyi.qdtl.mapper.TlInspectionLocationLogMapper;
 import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -100,4 +101,14 @@ public class TlInspectionLocationLogServiceImpl implements ITlInspectionLocation
     public List<TlInspectionLocationLog> queryByCondition(String date, String checkpointCard, String deviceId) {
         return tlInspectionLocationLogMapper.queryByCondition(date, checkpointCard, deviceId);
     }
+
+    /**
+     * 根据人员统计巡检次数
+     *
+     * @return
+     */
+    @Override
+    public List<UserCheckPoint> queryUserGroup() {
+        return tlInspectionLocationLogMapper.queryUserGroup();
+    }
 }

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionLocationServiceImpl.java

@@ -148,4 +148,15 @@ public class TlInspectionLocationServiceImpl implements ITlInspectionLocationSer
     public void deleteLocationByVersion(int version) {
         tlInspectionLocationMapper.deleteLocationByVersion(version);
     }
+
+    /**
+     * 获取线路的点位
+     *
+     * @param lineId
+     * @return
+     */
+    @Override
+    public List<TlInspectionLocation> queryLocationByLineId(Long lineId) {
+        return tlInspectionLocationMapper.queryLocationByLineId(lineId);
+    }
 }

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlPlanRecordServiceImpl.java

@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 巡检计划记录Service业务层处理
@@ -96,4 +97,17 @@ public class TlPlanRecordServiceImpl implements ITlPlanRecordService {
     public void updateRecordByDateAndCard(TlPlanRecord tlPlanRecord) {
         tlPlanRecordMapper.updateRecordByDateAndCard(tlPlanRecord);
     }
+
+    /**
+     * 查询巡查完成率
+     *
+     * @param date
+     * @return
+     */
+    @Override
+    public Map<String, Object> queryCheckPercent(String date) {
+        List<TlPlanRecord> planRecords = tlPlanRecordMapper.selectTlPlanRecordListByDate(date);
+        
+        return null;
+    }
 }

+ 12 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionLocationLogMapper.xml

@@ -79,6 +79,18 @@
         </where>
     </select>
 
+    <select id="queryUserGroup" resultType="com.ruoyi.qdtl.domain.UserCheckPoint">
+        select t1.nick_name nickName, t2.*
+        from sys_user t1
+                 left join (
+            select t1.patrolman_card patrolmanCard, count(1) checkCount
+            from tl_inspection_location_log t1
+            where patrolman_card is not null
+            group by t1.patrolman_card) t2 on t1.patrolman = t2.patrolmanCard
+        where patrolman != ''
+        order by t2.checkCount desc
+    </select>
+
     <insert id="insertTlInspectionLocationLog" parameterType="TlInspectionLocationLog" useGeneratedKeys="true" keyProperty="id">
         insert into tl_inspection_location_log
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 9 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionLocationMapper.xml

@@ -109,6 +109,15 @@
         from tl_inspection_location
     </select>
 
+    <select id="queryLocationByLineId" resultMap="TlInspectionLocationResult">
+        select t2.*
+        from tl_inspection_line_location t1
+                 join tl_inspection_location t2 on t1.location_id = t2.id
+        where t1.line_id = #{lineId}
+          and t2.del_flag = '0'
+        order by t1.sort_no
+    </select>
+
     <insert id="insertTlInspectionLocation" parameterType="TlInspectionLocation" useGeneratedKeys="true" keyProperty="id">
         insert into tl_inspection_location
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 7 - 2
ruoyi-system/src/main/resources/mapper/qdtl/TlPlanRecordMapper.xml

@@ -56,6 +56,12 @@
         where id = #{id}
     </select>
 
+    <select id="selectTlPlanRecordListByDate" resultMap="TlPlanRecordResult">
+        <include refid="selectTlPlanRecordVo"/>
+        where plan_date = #{date}
+        order by create_time
+    </select>
+
     <insert id="insertTlPlanRecord" parameterType="TlPlanRecord" useGeneratedKeys="true" keyProperty="id">
         insert into tl_plan_record
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -124,12 +130,11 @@
     <update id="updateRecordByDateAndCard">
         update tl_plan_record
         <trim prefix="SET" suffixOverrides=",">
-            <if test="checkpointCard != null">checkpoint_card = #{checkpointCard},</if>
             <if test="deviceCode != null">device_code = #{deviceCode},</if>
             <if test="fence != null">fence = #{fence},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
         </trim>
-        where plan_date = #{planDate} and card = #{card}
+        where plan_date = #{planDate} and card = #{card} and checkpoint_card = #{checkpointCard}
     </update>
 
     <delete id="deleteTlPlanRecordById" parameterType="Long">

+ 3 - 0
sql/ry_20210908.sql

@@ -1017,6 +1017,9 @@ alter table sys_user
     add patrolman varchar(20) null comment '巡检员绑定的卡号';
 
 -- 已同步
+alter table tl_plan_record
+    add line_id bigint null comment '线路id';
+