|
|
@@ -8,6 +8,7 @@ import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
|
|
|
import com.xunmei.common.core.enums.CycleCommonEnum;
|
|
|
@@ -57,7 +58,7 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
List<Long> hsOrgIds = remoteOrgService.selectParentHs(orgIds, SecurityConstants.INNER)
|
|
|
.stream().map(SysOrg::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
- List<AppPlan> listPlans = queryPlans(hsOrgIds, CycleCommonEnum.DAILY);
|
|
|
+ List<AppPlan> listPlans = queryPlans(hsOrgIds, CycleCommonEnum.DAILY,new ArrayList<>());
|
|
|
//通过计划id获取计划关系的角色
|
|
|
if (CollectionUtils.isNotEmpty(listPlans)) {
|
|
|
List<Long> planIds = listPlans.stream().map(AppPlan::getId).collect(Collectors.toList());
|
|
|
@@ -65,8 +66,8 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
List<Resumption> newResumptionList = new ArrayList<>();
|
|
|
for (AppPlan plan : listPlans) {
|
|
|
//根据计划获取角色
|
|
|
- List<AppPlanToRole> planToRoles = appPlanToRoles.stream().filter(item -> item.getPlanId().equals(plan.getId())).collect(Collectors.toList());
|
|
|
- List<Resumption> resumptionLista = this.buildResumptions(plan, planToRoles, workTime);
|
|
|
+// List<AppPlanToRole> planToRoles = appPlanToRoles.stream().filter(item -> item.getPlanId().equals(plan.getId())).collect(Collectors.toList());
|
|
|
+ List<Resumption> resumptionLista = this.buildResumptions(plan, workTime);
|
|
|
if (CollectionUtils.isNotEmpty(resumptionLista)) {
|
|
|
//根据planId和roleId是否判断resumptionLista中的数据是否在resumptionListYlz中
|
|
|
List<Resumption> resumptionListb = resumptionLista.stream().filter(item -> !resumptionListYlz.stream().filter(item1 -> item1.getPlanId().equals(item.getPlanId())
|
|
|
@@ -88,29 +89,30 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
|
|
|
@Override
|
|
|
public void rebuildWeeklyTask(List<Long> orgIds, Date startDate, Date endDate) {
|
|
|
- rebuildTask(orgIds,startDate,endDate,CycleCommonEnum.WEEKLY);
|
|
|
+ rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.WEEKLY);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void rebuildMonthTask(List<Long> orgIds, Date startDate, Date endDate) {
|
|
|
- rebuildTask(orgIds,startDate,endDate,CycleCommonEnum.MONTHLY);
|
|
|
+ rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.MONTHLY);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void rebuildQuarterTask(List<Long> orgIds, Date startDate, Date endDate) {
|
|
|
- rebuildTask(orgIds,startDate,endDate,CycleCommonEnum.QUARTERLY);
|
|
|
+ rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.QUARTERLY);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void rebuildHalfYearTask(List<Long> orgIds, Date startDate, Date endDate) {
|
|
|
- rebuildTask(orgIds,startDate,endDate,CycleCommonEnum.HALF_YEARLY);
|
|
|
+ rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.HALF_YEARLY);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void rebuildYearTask(List<Long> orgIds, Date startDate, Date endDate) {
|
|
|
- rebuildTask(orgIds,startDate,endDate,CycleCommonEnum.YEARLY);
|
|
|
+ rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.YEARLY);
|
|
|
}
|
|
|
+
|
|
|
private void rebuildTask(List<Long> orgIds, Date startDate, Date endDate, CycleCommonEnum cycle) {
|
|
|
List<Resumption> resumptionList = queryTask(startDate, cycle, orgIds);
|
|
|
List<Long> deleteIds = resumptionList.stream()
|
|
|
@@ -126,7 +128,13 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
Map<Long, Boolean> workingMap = orgWorkTimeStatusMap(startDate, cycle, orgIds);
|
|
|
// List<Long> deleteTaskIds = new ArrayList<>();
|
|
|
|
|
|
- for (Long orgId : orgIds) {
|
|
|
+ List<SysOrg> orgs = remoteOrgService.selectByOrgIdList(orgIds, SecurityConstants.INNER);
|
|
|
+ for (SysOrg org : orgs) {
|
|
|
+ if(ObjectUtil.isNull(org.getType())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Long orgId = org.getId();
|
|
|
if (!workingMap.containsKey(orgId) || workingMap.get(orgId) == false) {
|
|
|
//当前作息周期已经歇业
|
|
|
continue;
|
|
|
@@ -135,21 +143,21 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
List<Long> hsOrgIds = remoteOrgService.selectParentHs(ListUtil.toList(orgId), SecurityConstants.INNER)
|
|
|
.stream().map(SysOrg::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
- List<AppPlan> listPlans = queryPlans(hsOrgIds, CycleCommonEnum.DAILY);
|
|
|
+ List<AppPlan> listPlans = queryPlans(hsOrgIds, cycle, ListUtil.toList(org.getType()));
|
|
|
if (CollectionUtils.isEmpty(listPlans)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- List<Long> planIds = listPlans.stream().map(AppPlan::getId).collect(Collectors.toList());
|
|
|
- List<AppPlanToRole> appPlanToRoles = appPlanToRoleMapper.selectList(new QueryWrapper<AppPlanToRole>().lambda().in(AppPlanToRole::getPlanId, planIds));
|
|
|
+// List<Long> planIds = listPlans.stream().map(AppPlan::getId).collect(Collectors.toList());
|
|
|
+// List<AppPlanToRole> appPlanToRoles = appPlanToRoleMapper.selectList(new QueryWrapper<AppPlanToRole>().lambda().in(AppPlanToRole::getPlanId, planIds));
|
|
|
List<Resumption> newResumptionList = new ArrayList<>();
|
|
|
for (AppPlan plan : listPlans) {
|
|
|
//根据计划获取角色
|
|
|
- List<AppPlanToRole> planToRoles = appPlanToRoles.stream().filter(item -> item.getPlanId().equals(plan.getId())).collect(Collectors.toList());
|
|
|
+// List<AppPlanToRole> planToRoles = appPlanToRoles.stream().filter(item -> item.getPlanId().equals(plan.getId())).collect(Collectors.toList());
|
|
|
Long executedCount = executedResumptionList.stream()
|
|
|
.filter(r -> ObjectUtil.equal(r.getOrgId(), orgId) && ObjectUtil.equal(r.getPlanId(), plan.getParentId()))
|
|
|
.count();
|
|
|
- List<Resumption> planResumptionList = this.buildResumptions(plan, planToRoles, startDate, endDate, executedCount);
|
|
|
+ List<Resumption> planResumptionList = this.buildResumptions(plan, startDate, endDate, executedCount);
|
|
|
if (CollectionUtils.isNotEmpty(planResumptionList)) {
|
|
|
//根据planId和roleId是否判断resumptionLista中的数据是否在resumptionListYlz中
|
|
|
// List<Resumption> resumptionListb = resumptionLista.stream().filter(item -> !resumptionListYlz.stream().filter(item1 -> item1.getPlanId().equals(item.getPlanId())
|
|
|
@@ -163,7 +171,7 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<Resumption> buildResumptions(AppPlan appPlan, List<AppPlanToRole> planToRoles, SysWorkTime workTime) {
|
|
|
+ private List<Resumption> buildResumptions(AppPlan appPlan, SysWorkTime workTime) {
|
|
|
DateTime dateTime = new DateTime(workTime.getYmdDate());
|
|
|
String opentime = workTime.getOpenTime();//营业时间
|
|
|
String closetime = workTime.getCloseTime();//营业终了
|
|
|
@@ -189,14 +197,10 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
planendTime = DateUtil.endOfDay(time2).setField(DateField.MILLISECOND, 0);
|
|
|
}
|
|
|
|
|
|
- return buildResumptions(appPlan, planToRoles, planstartTime, planendTime, 0L);
|
|
|
+ return buildResumptions(appPlan, planstartTime, planendTime, 0L);
|
|
|
}
|
|
|
|
|
|
- private List<Resumption> buildResumptions(AppPlan appPlan, List<AppPlanToRole> planToRoles, Date planStartTime, Date planEndTime, Long executedCount) {
|
|
|
- if (CollectionUtils.isEmpty(planToRoles)) {
|
|
|
- return new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
+ private List<Resumption> buildResumptions(AppPlan appPlan, Date planStartTime, Date planEndTime, Long executedCount) {
|
|
|
List<Resumption> resumptionList = new ArrayList<>();
|
|
|
Long count = 1L;
|
|
|
if (NumberUtil.isNumber(appPlan.getCount())) {
|
|
|
@@ -220,7 +224,6 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
resumption.setPlanId((ObjectUtil.equal(appPlan.getParentId(), -1L) || ObjectUtil.isNull(appPlan.getParentId())) ? appPlan.getId() : appPlan.getParentId());
|
|
|
resumption.setOrgId(appPlan.getPlanOfOrgId());
|
|
|
resumption.setType(appPlan.getPlanCycle());
|
|
|
- resumption.setRoleId(planToRoles.get(0).getRoleId());
|
|
|
resumption.setPlanStartTime(planStartTime);
|
|
|
resumption.setPlanEndTime(planEndTime);
|
|
|
resumption.setCreateTime(new Date());
|
|
|
@@ -247,12 +250,18 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
|
|
|
* @param cycle
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<AppPlan> queryPlans(List<Long> planOfOrgId, CycleCommonEnum cycle) {
|
|
|
+ private List<AppPlan> queryPlans(List<Long> planOfOrgId, CycleCommonEnum cycle,List<Integer> execOrgTypes) {
|
|
|
+ if (CollectionUtils.isEmpty(planOfOrgId)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
QueryWrapper<AppPlan> qw = new QueryWrapper<>();
|
|
|
qw.lambda().eq(AppPlan::getPlanStatus, 1);
|
|
|
qw.lambda().eq(AppPlan::getPlanCycle, cycle.getCode());
|
|
|
qw.lambda().in(AppPlan::getPlanOfOrgId, planOfOrgId);
|
|
|
|
|
|
+ if(CollectionUtils.isNotEmpty(execOrgTypes)){
|
|
|
+ qw.lambda().in(AppPlan::getExecOrgType,execOrgTypes);
|
|
|
+ }
|
|
|
List<AppPlan> listPlans = appPlanMapper.selectList(qw);
|
|
|
|
|
|
return listPlans;
|