Quellcode durchsuchen

履职实现非营业时间、值班打卡

jiawuxian vor 1 Jahr
Ursprung
Commit
309f3aaf03

+ 39 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/TaskCreatingServiceImplBase.java

@@ -235,6 +235,45 @@ public abstract class TaskCreatingServiceImplBase<M extends BaseMapper<T>, T> ex
     }
 
     /**
+     * 返回机构的值班打卡时间作息
+     *
+     * @param now
+     * @param cycle
+     * @param orgIds
+     * @return
+     */
+    protected Map<Long, List<SysWorkTime>> orgDutyTimes(Date now, CycleCommonEnum cycle, List<Long> orgIds) {
+        List<SysWorkTime> times = selectWorkTimeList(now, cycle, orgIds);
+        if (CollectionUtil.isEmpty(times)) {
+            return new HashMap<>();
+        }
+        Map<Long, List<SysWorkTime>> map = times.stream()
+                .filter(t -> ObjectUtil.equal(t.getIsDuty(), 1L))
+                .collect(Collectors.groupingBy(t -> t.getOrgId()));
+        return map;
+    }
+
+
+    /**
+     * 返回机构的值班打卡时间作息
+     *
+     * @param now
+     * @param cycle
+     * @param orgIds
+     * @return
+     */
+    protected Map<Long, List<SysWorkTime>> orgDutyOrWorkTimes(Date now, CycleCommonEnum cycle, List<Long> orgIds) {
+        List<SysWorkTime> times = selectWorkTimeList(now, cycle, orgIds);
+        if (CollectionUtil.isEmpty(times)) {
+            return new HashMap<>();
+        }
+        Map<Long, List<SysWorkTime>> map = times.stream()
+                .filter(t -> ObjectUtil.equal(t.getIsDuty(), 1L) || ObjectUtil.equal(t.getIsEnable(), 1L))
+                .collect(Collectors.groupingBy(t -> t.getOrgId()));
+        return map;
+    }
+
+    /**
      * 获取机构在某个周期第一天营业的作息配置。没有营业则不包含该机构或value为空
      *
      * @param now

+ 54 - 21
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusiness.java

@@ -118,7 +118,12 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 
             CycleCommonEnum cycleCommonEnum = CycleCommonEnum.getEnum(appPlan.getPlanCycle());
             DateRange range = DateUtils.getStartAndEnd(date, cycleCommonEnum);
-            Map<Long, List<SysWorkTime>> workTimes = orgWorkingTimes(new Date(), cycleCommonEnum, orgs.stream().map(SysOrg::getId).collect(Collectors.toList()));
+            Map<Long, List<SysWorkTime>> workTimes = null;
+            if (ObjectUtil.equal(appPlan.getPlanExec(), 5)) {
+                workTimes = orgDutyTimes(new Date(), cycleCommonEnum, orgs.stream().map(SysOrg::getId).collect(Collectors.toList()));
+            } else {
+                workTimes = orgWorkingTimes(new Date(), cycleCommonEnum, orgs.stream().map(SysOrg::getId).collect(Collectors.toList()));
+            }
 
             for (SysOrg org : orgs) {
                 Long orgId = org.getId();
@@ -175,7 +180,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
             if (!hsOrgIds.contains(p.getPlanOfOrgId())) {
                 continue;
             }
-            if(ObjectUtil.equal(p.getTaskHasCompleted(),1)){
+            if (ObjectUtil.equal(p.getTaskHasCompleted(), 1)) {
                 continue;
             }
 
@@ -188,8 +193,8 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 
 
         //删除没有已完成计划下的所有任务
-        LambdaUpdateWrapper<Resumption> wrapper=new LambdaUpdateWrapper<>();
-        wrapper.in(Resumption::getPlanId,appPlans.stream().map(p->p.getId()).collect(Collectors.toList()));
+        LambdaUpdateWrapper<Resumption> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.in(Resumption::getPlanId, appPlans.stream().map(p -> p.getId()).collect(Collectors.toList()));
         baseMapper.delete(wrapper);
 
 //        AppPlan plan = appPlans.get(0);
@@ -300,7 +305,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
      */
     @Transactional
     public void rebuildTask(List<Long> orgIds, Date startDate, Date endDate, CycleCommonEnum cycle, SysWorkTime workTime) {
-        List<Resumption> resumptionList = queryTask(startDate,endDate, cycle, orgIds, null);
+        List<Resumption> resumptionList = queryTask(startDate, endDate, cycle, orgIds, null);
         List<Long> deleteIds = resumptionList.stream()
                 .filter(r -> (ObjectUtil.equal(r.getStatus(), 1) || ObjectUtil.equal(r.getStatus(), 2)))
                 .map(Resumption::getId).collect(Collectors.toList());
@@ -311,7 +316,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         List<Resumption> executedResumptionList = resumptionList.stream()
                 .filter(r -> ObjectUtil.equal(r.getStatus(), 3))
                 .collect(Collectors.toList());
-        Map<Long, List<SysWorkTime>> workingMap = orgWorkingTimes(startDate, cycle, orgIds);
+        Map<Long, List<SysWorkTime>> workingMap = orgDutyOrWorkTimes(startDate, cycle, orgIds);// orgWorkingTimes(startDate, cycle, orgIds);
 //        List<Long> deleteTaskIds = new ArrayList<>();
 
         List<SysOrg> orgs = remoteOrgService.selectByOrgIdList(orgIds, SecurityConstants.INNER);
@@ -346,11 +351,23 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
                         .map(Resumption::getTimes)
                         .collect(Collectors.toList());
 
+
+                List<SysWorkTime> workTimes = new ArrayList<>();
+                if (ObjectUtil.equal(plan.getPlanExec(), 5)) {
+                    workTimes = workingMap.get(orgId).stream().filter(wt -> ObjectUtil.equal(wt.getIsDuty(), 1L)).collect(Collectors.toList());
+                } else {
+                    workTimes = workingMap.get(orgId).stream().filter(wt -> ObjectUtil.equal(wt.getIsEnable(), 1L)).collect(Collectors.toList());
+                }
+
+                if (CollectionUtils.isEmpty(workTimes)) {
+                    continue;
+                }
+
                 List<Resumption> planResumptionList;
                 if (ObjectUtil.equal(cycle, CycleCommonEnum.DAILY)) {
-                    planResumptionList = this.buildResumptions(plan, org, workTime, executedOrders, workingMap.get(orgId));
+                    planResumptionList = this.buildResumptions(plan, org, workTime, executedOrders, workTimes);
                 } else {
-                    planResumptionList = this.buildResumptions(plan, org, startDate, endDate, executedOrders, workingMap.get(orgId));
+                    planResumptionList = this.buildResumptions(plan, org, startDate, endDate, executedOrders, workTimes);
                 }
 
                 if (CollectionUtils.isNotEmpty(planResumptionList)) {
@@ -380,7 +397,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         DateTime planendTime = null;
 
 
-        if (StringUtils.isEmpty(opentime) || StringUtils.isEmpty(closetime)) {
+        if (ObjectUtil.notEqual(appPlan.getPlanExec(), 5) && (StringUtils.isEmpty(opentime) || StringUtils.isEmpty(closetime))) {
             log.error("作息" + workTime.getId() + "缺少营业开始或结束时间");
             return new ArrayList<>();
         }
@@ -401,17 +418,33 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         } else if (appPlan.getPlanExec() == 4) {//营业终 营业终了-23.59.59
             planstartTime = time1.setField(DateField.HOUR_OF_DAY, Integer.parseInt(closetime.split(":")[0])).setField(DateField.MINUTE, Integer.parseInt(closetime.split(":")[1])).setField(DateField.SECOND, 0).setField(DateField.MILLISECOND, 0);
             planendTime = DateUtil.endOfDay(time2).setField(DateField.MILLISECOND, 0);
-        }else if (appPlan.getPlanExec() == 5){ //非营业时间
+        } else if (appPlan.getPlanExec() == 5) { //非营业时间
+            //如果是歇业,时间为晚8点至24点
+            //如果是营业,时间为下班时间至24点
+            //如果没有值班打卡,则不生成任务
+            if (ObjectUtil.notEqual(workTime.getIsDuty(), 1L)) {
+                return new ArrayList<>();
+            }
+
+            String startTime = "20:00";
+            if (ObjectUtil.equal(workTime.getIsEnable(), 1L)) {
+                startTime = workTime.getWorkOffTime();
+            }
+            if (StringUtils.isEmpty(startTime)) {
+                log.error("作息" + workTime.getId() + "缺少下班时间");
+                return new ArrayList<>();
+            }
+
             planstartTime = time1
-                    .setField(DateField.HOUR_OF_DAY, Integer.parseInt(closetime.split(":")[0]))
-                    .setField(DateField.MINUTE, Integer.parseInt(closetime.split(":")[1]))
+                    .setField(DateField.HOUR_OF_DAY, Integer.parseInt(startTime.split(":")[0]))
+                    .setField(DateField.MINUTE, Integer.parseInt(startTime.split(":")[1]))
                     .setField(DateField.SECOND, 0)
                     .setField(DateField.MILLISECOND, 0);
             planendTime = DateUtil.endOfDay(time2).setField(DateField.MILLISECOND, 0);
-        }else if (appPlan.getPlanExec() == 6) {//工作时间
-            String workStart=workTime.getWorkTime();
-            String workEnd=workTime.getWorkOffTime();
-            if(StringUtils.isEmpty(workStart) || StringUtils.isEmpty(workEnd)){
+        } else if (appPlan.getPlanExec() == 6) {//工作时间
+            String workStart = workTime.getWorkTime();
+            String workEnd = workTime.getWorkOffTime();
+            if (StringUtils.isEmpty(workStart) || StringUtils.isEmpty(workEnd)) {
                 log.error("作息" + workTime.getId() + "缺少上班开始或结束时间");
                 return new ArrayList<>();
             }
@@ -427,8 +460,8 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
     }
 
     private List<Resumption> buildResumptions(AppPlan appPlan, SysOrg execOrg, Date planStartTime, Date planEndTime, List<Short> executedOrders, List<SysWorkTime> workTimes) {
-        if(ObjectUtil.equal(execOrg.getIsLock(),1)){
-            return  new ArrayList<>();
+        if (ObjectUtil.equal(execOrg.getIsLock(), 1)) {
+            return new ArrayList<>();
         }
 
         List<Resumption> resumptionList = new ArrayList<>();
@@ -481,10 +514,10 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         return resumptionList;
     }
 
-    private List<Resumption> queryTask(Date startDate,Date endDate, CycleCommonEnum cycle, List<Long> orgIds, List<Long> planIds) {
+    private List<Resumption> queryTask(Date startDate, Date endDate, CycleCommonEnum cycle, List<Long> orgIds, List<Long> planIds) {
         QueryWrapper<Resumption> queryWrapper = new QueryWrapper<>();
-        Date start=DateUtil.beginOfDay(startDate);
-        Date end=DateUtil.endOfDay(endDate);
+        Date start = DateUtil.beginOfDay(startDate);
+        Date end = DateUtil.endOfDay(endDate);
         queryWrapper.lambda().le(Resumption::getYmdDate, end);
         queryWrapper.lambda().ge(Resumption::getYmdDate, start);
         if (CollectionUtils.isNotEmpty(orgIds)) {

+ 43 - 2
soc-modules/soc-modules-core/src/main/resources/mapper/board/AppCockpitMapper.xml

@@ -39,8 +39,8 @@
                                    IF
                                        (standard = 2, IF(date_of_compliance &lt; #{date}, 1, 0), 0) AS ga382015prev
                             FROM sys_org_physical_defense_construction
-                            WHERE type = 4
-                               OR type = 5
+                            WHERE type = 1
+                               OR type = 3
                             GROUP BY org_id) m on o.id = m.org_id
         WHERE o.deleted = 0
           and o.is_lock = 0
@@ -104,4 +104,45 @@
         WHERE submit_time >= #{date}
           and org_path like concat(#{orgPath}, '%')
     </select>
+
+    <select id="selectOrgBaseInfo">
+        SELECT
+            count(0) as total,
+            sum(if(oh.org_id is null,1,0)) as unreachedCount,
+            sum(if(o.type=4,1,0)) as bankingCount,
+            sum(if(o.type=5,1,0)) as offATMCount,
+            sum(if(o.type=4 and oh.ga382021 is not null,1,0)) as bankingGA382021 ,
+            sum(if(o.type=4 and oh.ga382015 is not null,1,0)) as bankingGA382015 ,
+            sum(if(o.type=5 and oh.ga382021 is not null,1,0)) as offATMGA382021 ,
+            sum(if(o.type=5 and oh.ga382015 is not null,1,0)) as offATMGA382015,
+            sum(if(oe.business_library_type=1,1,0)) as businessLibraryOne,
+            sum(if(oe.business_library_type=2,1,0)) as businessLibraryTwo,
+            sum(if(oe.business_library_type=3,1,0)) as businessLibraryThree,
+            sum(if(oe.business_library_type=4,1,0)) as businessLibraryFour,
+            sum(if(oe.askari=1,1,0)) as orgWithSecurityCount,
+            sum(if(o.type=4 and oe.lobby_equipment is not null,oe.lobby_equipment,0)) as bankingObbyDeviceCount,
+            sum(if(o.type=4 and oe.wall_penetrating_equipment is not null,oe.wall_penetrating_equipment,0)) as bankingWallDeviceCount,
+            sum(if(o.type=5 and oe.lobby_equipment is not null,oe.lobby_equipment,0)) as offATMObbyDeviceCount,
+            sum(if(o.type=5 and oe.wall_penetrating_equipment is not null,oe.wall_penetrating_equipment,0)) as offATMWallDeviceCount
+        FROM
+            sys_org o
+                LEFT  JOIN (SELECT org_id,
+                                   IF
+                                       (standard = 1, 1, 0)                                         AS ga382021,
+
+
+                                   IF
+                                       (standard = 2, 1, 0)                                         AS ga382015
+
+                            FROM sys_org_physical_defense_construction
+                            WHERE type = 1
+                               OR type = 3
+                            GROUP BY org_id) oh ON o.id = oh.org_id
+                LEFT JOIN sys_org_extend oe on o.id=oe.org_id
+        WHERE
+            o.deleted = 0 and org_path like concat(#{orgPath}, '%')
+          AND (
+                    o.type = 4
+                OR o.type = 5)
+    </select>
 </mapper>

+ 8 - 1
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysWorkTimeServiceImpl.java

@@ -455,7 +455,14 @@ public class SysWorkTimeServiceImpl extends ServiceImpl<SysWorkTimeMapper, SysWo
                 .ge(SysWorkTime::getYmdDate, workTimeDto.getStartTime())
                 .le(SysWorkTime::getYmdDate, workTimeDto.getEndTime())
                 .in(SysWorkTime::getOrgId, workTimeDto.getOrgIdList())
-                .select(SysWorkTime::getId, SysWorkTime::getIsEnable, SysWorkTime::getYmdDate, SysWorkTime::getOrgId,SysWorkTime::getOpenTime,SysWorkTime::getCloseTime)
+                .select(SysWorkTime::getId,
+                        SysWorkTime::getIsEnable,
+                        SysWorkTime::getYmdDate,
+                        SysWorkTime::getOrgId,SysWorkTime::getOpenTime,
+                        SysWorkTime::getCloseTime,
+                        SysWorkTime::getWorkTime,
+                        SysWorkTime::getWorkOffTime,
+                        SysWorkTime::getIsDuty)
                 .list();
 
     }