459242451@qq.com 3 years ago
parent
commit
9ccd7539ac

+ 26 - 13
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/PlanTask.java

@@ -1,8 +1,10 @@
 package com.ruoyi.web.controller.task;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.qdtl.domain.PlanUser;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
 import com.ruoyi.qdtl.domain.TlInspectionPlan;
@@ -65,6 +67,11 @@ public class PlanTask {
         if (planList != null && planList.size() > 0) {
             List<TlPlanRecord> planRecords = new ArrayList<>();
             for (TlInspectionPlan inspectionPlan : planList) {
+                // 查询是否满足日期的要求
+                int week = DateUtil.dayOfWeek(DateUtil.parseDate(queryDate));
+                if (!CollUtil.contains(StrUtil.split(inspectionPlan.getWeeks(), ","), Convert.toStr(week))) {
+                    continue;
+                }
                 // 查询计划的人员.根据计划id查询人员以及设备号
                 List<PlanUser> userList = planService.queryPlanUser(inspectionPlan.getId());
                 // 查询计划的线路及点位
@@ -73,19 +80,25 @@ public class PlanTask {
                     // 组装计划数据
                     for (PlanUser planUser : userList) {
                         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());
-                            planRecord.setLineId(inspectionPlan.getLineId());
-                            planRecord.setLineName("");
-                            planRecord.setAreaId(lineLocation.getAreaId());
-                            planRecords.add(planRecord);
+                            for (String s : StrUtil.split(inspectionPlan.getTimeUnit(), ",")) {
+                                for (int i = 0; i < inspectionPlan.getXunNum(); i++) {
+                                    TlPlanRecord planRecord = new TlPlanRecord();
+                                    planRecord.setPlanId(planUser.getPlanId());
+                                    planRecord.setPlanDate(queryDate);
+                                    planRecord.setStartTime(s.split("~")[0] + ":00");
+                                    planRecord.setEndTime(s.split("~")[1] + ":59");
+                                    planRecord.setPlanName(inspectionPlan.getPlanName());
+                                    planRecord.setUserId(planUser.getUserId());
+                                    planRecord.setNickName(planUser.getNickName());
+                                    planRecord.setCard(planUser.getCard());
+                                    planRecord.setScore(inspectionPlan.getScore());
+                                    planRecord.setCheckpointCard(lineLocation.getLocationCode());
+                                    planRecord.setLineId(inspectionPlan.getLineId());
+                                    planRecord.setLineName("");
+                                    planRecord.setAreaId(lineLocation.getAreaId());
+                                    planRecords.add(planRecord);
+                                }
+                            }
                         }
                     }
                 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlPlanRecord.java

@@ -33,6 +33,9 @@ public class TlPlanRecord extends BaseEntity {
     @Excel(name = "计划日期")
     private String planDate;
 
+    private String startTime;
+    private String endTime;
+
     /**
      * 名称
      */

+ 11 - 1
ruoyi-system/src/main/resources/mapper/qdtl/TlPlanRecordMapper.xml

@@ -8,6 +8,8 @@
         <result property="id" column="id"/>
         <result property="planId" column="plan_id"/>
         <result property="planDate" column="plan_date"/>
+        <result property="startTime" column="start_time"/>
+        <result property="endTime" column="end_time"/>
         <result property="planName" column="plan_name"/>
         <result property="userId" column="user_id"/>
         <result property="nickName" column="nick_name"/>
@@ -26,6 +28,8 @@
         select id,
                plan_id,
                plan_date,
+               start_time,
+               end_time,
                plan_name,
                user_id,
                nick_name,
@@ -73,6 +77,8 @@
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="planId != null">plan_id,</if>
             <if test="planDate != null">plan_date,</if>
+            <if test="startTime != null">start_time,</if>
+            <if test="endTime != null">end_time,</if>
             <if test="planName != null">plan_name,</if>
             <if test="userId != null">user_id,</if>
             <if test="nickName != null">nick_name,</if>
@@ -86,6 +92,8 @@
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="planId != null">#{planId},</if>
             <if test="planDate != null">#{planDate},</if>
+            <if test="startTime != null">#{startTime},</if>
+            <if test="endTime != null">#{endTime},</if>
             <if test="planName != null">#{planName},</if>
             <if test="userId != null">#{userId},</if>
             <if test="nickName != null">#{nickName},</if>
@@ -100,12 +108,14 @@
 
     <insert id="batchInsert">
         insert into tl_plan_record
-        (plan_id, plan_date, plan_name, user_id, nick_name, card, checkpoint_card, score, line_id, line_name)
+        (plan_id, plan_date, start_time, end_time, plan_name, user_id, nick_name, card, checkpoint_card, score, line_id, line_name)
         values
         <foreach collection="list" item="item" separator=",">
             (
             #{item.planId},
             #{item.planDate},
+            #{item.startTime},
+            #{item.endTime},
             #{item.planName},
             #{item.userId},
             #{item.nickName},