|
|
@@ -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)) {
|