|  | @@ -14,6 +14,7 @@ import com.xunmei.common.core.domain.DateRange;
 | 
											
												
													
														|  |  import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
 |  |  import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
 | 
											
												
													
														|  |  import com.xunmei.common.core.enums.CycleCommonEnum;
 |  |  import com.xunmei.common.core.enums.CycleCommonEnum;
 | 
											
												
													
														|  |  import com.xunmei.common.core.enums.ExecTimeCommonEnum;
 |  |  import com.xunmei.common.core.enums.ExecTimeCommonEnum;
 | 
											
												
													
														|  | 
 |  | +import com.xunmei.common.core.enums.OrgTypeEnum;
 | 
											
												
													
														|  |  import com.xunmei.common.core.utils.DateUtils;
 |  |  import com.xunmei.common.core.utils.DateUtils;
 | 
											
												
													
														|  |  import com.xunmei.common.core.utils.StringUtils;
 |  |  import com.xunmei.common.core.utils.StringUtils;
 | 
											
												
													
														|  |  import com.xunmei.common.core.utils.Ymd;
 |  |  import com.xunmei.common.core.utils.Ymd;
 | 
											
										
											
												
													
														|  | @@ -118,25 +119,25 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |              CycleCommonEnum cycleCommonEnum = CycleCommonEnum.getEnum(appPlan.getPlanCycle());
 |  |              CycleCommonEnum cycleCommonEnum = CycleCommonEnum.getEnum(appPlan.getPlanCycle());
 | 
											
												
													
														|  |              DateRange range = DateUtils.getStartAndEnd(date, cycleCommonEnum);
 |  |              DateRange range = DateUtils.getStartAndEnd(date, cycleCommonEnum);
 | 
											
												
													
														|  | -            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()));
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | 
 |  | +            Map<Long, List<SysWorkTime>> workTimes = orgDutyOrWorkTimes(new Date(), cycleCommonEnum, orgs.stream().map(SysOrg::getId).collect(Collectors.toList()));
 | 
											
												
													
														|  | 
 |  | +//            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) {
 |  |              for (SysOrg org : orgs) {
 | 
											
												
													
														|  | -                Long orgId = org.getId();
 |  | 
 | 
											
												
													
														|  | -                if (!workTimes.containsKey(orgId) || ObjectUtil.isNull(workTimes.get(orgId)) || CollectionUtils.isEmpty(workTimes.get(orgId))) {
 |  | 
 | 
											
												
													
														|  | -                    continue;
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | 
 |  | +//                Long orgId = org.getId();
 | 
											
												
													
														|  | 
 |  | +//                if (!workTimes.containsKey(orgId) || ObjectUtil.isNull(workTimes.get(orgId)) || CollectionUtils.isEmpty(workTimes.get(orgId))) {
 | 
											
												
													
														|  | 
 |  | +//                    continue;
 | 
											
												
													
														|  | 
 |  | +//                }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  List<Resumption> tasks;
 |  |                  List<Resumption> tasks;
 | 
											
												
													
														|  |                  if (ObjectUtil.equal(CycleCommonEnum.DAILY.getCode(), appPlan.getPlanCycle())) {
 |  |                  if (ObjectUtil.equal(CycleCommonEnum.DAILY.getCode(), appPlan.getPlanCycle())) {
 | 
											
												
													
														|  | -                    SysWorkTime workTime = workTimes.get(orgId).get(0);
 |  | 
 | 
											
												
													
														|  | -                    tasks = buildResumptions(appPlan, org, workTime, null, workTimes.get(orgId));
 |  | 
 | 
											
												
													
														|  | 
 |  | +//                    SysWorkTime workTime = workTimes.get(orgId).get(0);
 | 
											
												
													
														|  | 
 |  | +                    tasks = buildResumptions(appPlan, org, null, new Date(), workTimes);
 | 
											
												
													
														|  |                  } else {
 |  |                  } else {
 | 
											
												
													
														|  | -                    tasks = buildResumptions(appPlan, org, range.getStartTime(), range.getEndTime(), null, workTimes.get(orgId));
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    tasks = buildResumptions(appPlan, org, range.getStartTime(), range.getEndTime(), null, workTimes);
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  if (CollectionUtils.isNotEmpty(tasks)) {
 |  |                  if (CollectionUtils.isNotEmpty(tasks)) {
 | 
											
										
											
												
													
														|  | @@ -351,23 +352,23 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 | 
											
												
													
														|  |                          .map(Resumption::getTimes)
 |  |                          .map(Resumption::getTimes)
 | 
											
												
													
														|  |                          .collect(Collectors.toList());
 |  |                          .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<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;
 |  |                  List<Resumption> planResumptionList;
 | 
											
												
													
														|  |                  if (ObjectUtil.equal(cycle, CycleCommonEnum.DAILY)) {
 |  |                  if (ObjectUtil.equal(cycle, CycleCommonEnum.DAILY)) {
 | 
											
												
													
														|  | -                    planResumptionList = this.buildResumptions(plan, org, workTime, executedOrders, workTimes);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    planResumptionList = this.buildResumptions(plan, org, executedOrders, new Date(), workingMap);
 | 
											
												
													
														|  |                  } else {
 |  |                  } else {
 | 
											
												
													
														|  | -                    planResumptionList = this.buildResumptions(plan, org, startDate, endDate, executedOrders, workTimes);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    planResumptionList = this.buildResumptions(plan, org, startDate, endDate, executedOrders, workingMap);
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  if (CollectionUtils.isNotEmpty(planResumptionList)) {
 |  |                  if (CollectionUtils.isNotEmpty(planResumptionList)) {
 | 
											
										
											
												
													
														|  | @@ -389,12 +390,36 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 | 
											
												
													
														|  |          return resumptionService.update(wrapper);
 |  |          return resumptionService.update(wrapper);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private List<Resumption> buildResumptions(AppPlan appPlan, SysOrg execOrg, SysWorkTime workTime, List<Short> executedOrders, List<SysWorkTime> workTimes) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private List<Resumption> buildResumptions(AppPlan appPlan, SysOrg execOrg, List<Short> executedOrders, Date date, Map<Long, List<SysWorkTime>> workTimes) {
 | 
											
												
													
														|  | 
 |  | +        DateTime planstartTime = null;
 | 
											
												
													
														|  | 
 |  | +        DateTime planendTime = null;
 | 
											
												
													
														|  | 
 |  | +        if (!ObjectUtil.equal(execOrg.getType(), OrgTypeEnum.YINGYE_WANGDIAN.getCode())) {
 | 
											
												
													
														|  | 
 |  | +            //非营业网点的机构,与作息无关
 | 
											
												
													
														|  | 
 |  | +            planstartTime = DateUtil.beginOfDay(date);
 | 
											
												
													
														|  | 
 |  | +            planendTime = DateUtil.endOfDay(date);
 | 
											
												
													
														|  | 
 |  | +            return buildResumptions(appPlan, execOrg, planstartTime, planendTime, executedOrders, workTimes);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        //营业网点没有作息
 | 
											
												
													
														|  | 
 |  | +        if (!workTimes.containsKey(execOrg.getId()) || CollectionUtils.isEmpty(workTimes.get(execOrg.getId()))) {
 | 
											
												
													
														|  | 
 |  | +            return null;
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        Optional<SysWorkTime> workTimeOptional = workTimes.get(execOrg.getId()).stream().filter(t -> DateUtil.isSameDay(t.getYmdDate(), date)).findFirst();
 | 
											
												
													
														|  | 
 |  | +        if (!workTimeOptional.isPresent()) {
 | 
											
												
													
														|  | 
 |  | +            return null; //没有找到某天的作息
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        if ((ObjectUtil.equal(appPlan.getPlanExec(), ExecTimeCommonEnum.NoBusiness.getCode()) && ObjectUtil.notEqual(workTimeOptional.get().getIsDuty(), 1L)) ||
 | 
											
												
													
														|  | 
 |  | +                (ObjectUtil.notEqual(appPlan.getPlanExec(), ExecTimeCommonEnum.NoBusiness.getCode()) && ObjectUtil.notEqual(workTimeOptional.get().getIsEnable(), 1L))) {
 | 
											
												
													
														|  | 
 |  | +            //非营业时间没有值班打卡或其它时刻没有营业,不生成任务
 | 
											
												
													
														|  | 
 |  | +            return null;
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        SysWorkTime workTime = workTimeOptional.get();
 | 
											
												
													
														|  |          DateTime dateTime = new DateTime(workTime.getYmdDate());
 |  |          DateTime dateTime = new DateTime(workTime.getYmdDate());
 | 
											
												
													
														|  |          String opentime = workTime.getOpenTime();//营业时间
 |  |          String opentime = workTime.getOpenTime();//营业时间
 | 
											
												
													
														|  |          String closetime = workTime.getCloseTime();//营业终了
 |  |          String closetime = workTime.getCloseTime();//营业终了
 | 
											
												
													
														|  | -        DateTime planstartTime = null;
 |  | 
 | 
											
												
													
														|  | -        DateTime planendTime = null;
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          if (ObjectUtil.notEqual(appPlan.getPlanExec(), 5) && (StringUtils.isEmpty(opentime) || StringUtils.isEmpty(closetime))) {
 |  |          if (ObjectUtil.notEqual(appPlan.getPlanExec(), 5) && (StringUtils.isEmpty(opentime) || StringUtils.isEmpty(closetime))) {
 | 
											
										
											
												
													
														|  | @@ -459,10 +484,12 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 | 
											
												
													
														|  |          return buildResumptions(appPlan, execOrg, planstartTime, planendTime, executedOrders, workTimes);
 |  |          return buildResumptions(appPlan, execOrg, planstartTime, planendTime, executedOrders, workTimes);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private List<Resumption> buildResumptions(AppPlan appPlan, SysOrg execOrg, Date planStartTime, Date planEndTime, List<Short> executedOrders, List<SysWorkTime> workTimes) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private List<Resumption> buildResumptions(AppPlan appPlan, SysOrg execOrg, Date planStartTime, Date planEndTime, List<Short> executedOrders, Map<Long, List<SysWorkTime>> allWorkTimes) {
 | 
											
												
													
														|  |          if (ObjectUtil.equal(execOrg.getIsLock(), 1)) {
 |  |          if (ObjectUtil.equal(execOrg.getIsLock(), 1)) {
 | 
											
												
													
														|  |              return new ArrayList<>();
 |  |              return new ArrayList<>();
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | 
 |  | +        Map<Short, StartEndTime> rangeMap = null;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          List<Resumption> resumptionList = new ArrayList<>();
 |  |          List<Resumption> resumptionList = new ArrayList<>();
 | 
											
												
													
														|  |          Short count = 1;
 |  |          Short count = 1;
 | 
											
										
											
												
													
														|  | @@ -470,8 +497,23 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 | 
											
												
													
														|  |              count = Short.parseShort(appPlan.getCount());
 |  |              count = Short.parseShort(appPlan.getCount());
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        Map<Short, StartEndTime> rangeMap = splitTaskTime(count, CycleCommonEnum.getEnum(appPlan.getPlanCycle()),
 |  | 
 | 
											
												
													
														|  | -                planStartTime, planEndTime, workTimes);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (ObjectUtil.equal(execOrg.getType(), OrgTypeEnum.YINGYE_WANGDIAN.getCode())) {
 | 
											
												
													
														|  | 
 |  | +            List<SysWorkTime> workTimes = null;
 | 
											
												
													
														|  | 
 |  | +            //营业网点,取作息
 | 
											
												
													
														|  | 
 |  | +            if (ObjectUtil.equal(appPlan.getPlanExec(), ExecTimeCommonEnum.NoBusiness.getCode())) {
 | 
											
												
													
														|  | 
 |  | +                //非营业时间,取值班打卡
 | 
											
												
													
														|  | 
 |  | +                workTimes = allWorkTimes.get(execOrg.getId()).stream().filter(e -> ObjectUtil.equal(e.getIsDuty(), 1L)).collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                workTimes = allWorkTimes.get(execOrg.getId()).stream().filter(e -> ObjectUtil.equal(e.getIsEnable(), 1L)).collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            rangeMap = splitTaskTime(count, CycleCommonEnum.getEnum(appPlan.getPlanCycle()),
 | 
											
												
													
														|  | 
 |  | +                    planStartTime, planEndTime, workTimes);
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            //非营业网点,认为全是营业
 | 
											
												
													
														|  | 
 |  | +            rangeMap = splitTaskTime(count, CycleCommonEnum.getEnum(appPlan.getPlanCycle()),
 | 
											
												
													
														|  | 
 |  | +                    planStartTime, planEndTime, null);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          short realOrder = 0;
 |  |          short realOrder = 0;
 | 
											
												
													
														|  |          for (Short i = 1; i <= count; i++) {
 |  |          for (Short i = 1; i <= count; i++) {
 | 
											
												
													
														|  |              if (!rangeMap.containsKey(i)) {
 |  |              if (!rangeMap.containsKey(i)) {
 |