|  | @@ -4,14 +4,18 @@ import cn.hutool.core.collection.ListUtil;
 | 
	
		
			
				|  |  |  import cn.hutool.core.date.DateField;
 | 
	
		
			
				|  |  |  import cn.hutool.core.date.DateTime;
 | 
	
		
			
				|  |  |  import cn.hutool.core.date.DateUtil;
 | 
	
		
			
				|  |  | +import cn.hutool.core.io.unit.DataUnit;
 | 
	
		
			
				|  |  |  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.DateRange;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.enums.CycleCommonEnum;
 | 
	
		
			
				|  |  | +import com.xunmei.common.core.utils.DateUtils;
 | 
	
		
			
				|  |  | +import com.xunmei.common.core.utils.ResumptionType;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.utils.Ymd;
 | 
	
		
			
				|  |  |  import com.xunmei.core.TaskCreatingServiceImplBase;
 | 
	
		
			
				|  |  |  import com.xunmei.core.resumption.domain.AppPlan;
 | 
	
	
		
			
				|  | @@ -20,101 +24,157 @@ import com.xunmei.core.resumption.domain.Resumption;
 | 
	
		
			
				|  |  |  import com.xunmei.core.resumption.mapper.AppPlanMapper;
 | 
	
		
			
				|  |  |  import com.xunmei.core.resumption.mapper.AppPlanToRoleMapper;
 | 
	
		
			
				|  |  |  import com.xunmei.core.resumption.mapper.ResumptionMapper;
 | 
	
		
			
				|  |  | +import com.xunmei.core.resumption.service.AppPlanService;
 | 
	
		
			
				|  |  | +import com.xunmei.core.resumption.service.IAppRulePointService;
 | 
	
		
			
				|  |  | +import com.xunmei.core.resumption.vo.AppRulePointTaskVo;
 | 
	
		
			
				|  |  |  import com.xunmei.system.api.RemoteOrgService;
 | 
	
		
			
				|  |  |  import com.xunmei.system.api.domain.SysOrg;
 | 
	
		
			
				|  |  | +import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  | +import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Component
 | 
	
		
			
				|  |  | +@Slf4j
 | 
	
		
			
				|  |  |  public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<ResumptionMapper, Resumption> {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private AppPlanMapper appPlanMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private AppPlanToRoleMapper appPlanToRoleMapper;
 | 
	
		
			
				|  |  | +    private RemoteOrgService remoteOrgService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private RemoteOrgService remoteOrgService;
 | 
	
		
			
				|  |  | +    private IAppRulePointService appRulePointService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private AppPlanService appPlanService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * 按计划重新生成。为保持通用,参数使用object.只支持同属一个父计划的子计划
 | 
	
		
			
				|  |  | +     * */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public void rebuildDayTask(List<Long> orgIds, SysWorkTime workTime) {
 | 
	
		
			
				|  |  | -        try {
 | 
	
		
			
				|  |  | -            List<Resumption> resumptionList = queryTask(workTime.getYmdDate(), CycleCommonEnum.DAILY, orgIds);
 | 
	
		
			
				|  |  | -            List<Resumption> resumptionListYlz = resumptionList.stream().filter(item -> item.getStatus() == 3).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -            if (CollectionUtils.isNotEmpty(resumptionList)) {
 | 
	
		
			
				|  |  | -                //取出未履职的数据(待履职,进行中)
 | 
	
		
			
				|  |  | -                List<Resumption> resumptionListWlz = resumptionList.stream().filter(item -> item.getStatus() == 1 || item.getStatus() == 2).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -                //删除这些数据
 | 
	
		
			
				|  |  | -                if (CollectionUtils.isNotEmpty(resumptionListWlz)) {
 | 
	
		
			
				|  |  | -                    baseMapper.deleteBatchIds(resumptionListWlz.stream().map(Resumption::getId).collect(Collectors.toList()));
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public void rebuildCurrentCycleTask(List<Object> plans) {
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(plans)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<AppPlan> appPlans = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (Object plan : plans) {
 | 
	
		
			
				|  |  | +            if (plan.getClass() == AppPlan.class) {
 | 
	
		
			
				|  |  | +                appPlans.add((AppPlan) plan);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(appPlans)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        AppPlan plan = appPlans.get(0);
 | 
	
		
			
				|  |  | +        CycleCommonEnum cycle = CycleCommonEnum.getEnum(plan.getPlanCycle());
 | 
	
		
			
				|  |  | +        DateRange range = DateUtils.getStartAndEnd(new Date(), cycle);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            //营业重新生成任务
 | 
	
		
			
				|  |  | -            if (workTime.getIsEnable() == 1) {
 | 
	
		
			
				|  |  | -                List<Long> hsOrgIds = remoteOrgService.selectParentHs(orgIds, SecurityConstants.INNER)
 | 
	
		
			
				|  |  | -                        .stream().map(SysOrg::getId)
 | 
	
		
			
				|  |  | -                        .collect(Collectors.toList());
 | 
	
		
			
				|  |  | -                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());
 | 
	
		
			
				|  |  | -                    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<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())
 | 
	
		
			
				|  |  | -                                    && item1.getRoleId().equals(item.getRoleId())).findFirst().isPresent()).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -                            if (CollectionUtils.isNotEmpty(resumptionListb)) {
 | 
	
		
			
				|  |  | -                                newResumptionList.addAll(resumptionListb);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    this.saveBatch(newResumptionList);
 | 
	
		
			
				|  |  | +        List<Resumption> resumptionList = queryTask(range.getStartTime(), cycle, null, appPlans.stream().map(AppPlan::getId).collect(Collectors.toList()));
 | 
	
		
			
				|  |  | +        List<Long> deleteIds = resumptionList.stream()
 | 
	
		
			
				|  |  | +                .filter(r -> (ObjectUtil.equal(r.getStatus(), 1) || ObjectUtil.equal(r.getStatus(), 2)))
 | 
	
		
			
				|  |  | +                .map(Resumption::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(deleteIds)) {
 | 
	
		
			
				|  |  | +            baseMapper.deleteBatchIds(deleteIds);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        createTask(appPlans);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void createTask(List<AppPlan> appPlanList) {
 | 
	
		
			
				|  |  | +        List<Resumption> resumptions = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (AppPlan appPlan : appPlanList) {
 | 
	
		
			
				|  |  | +            //获取履职计划中对应的检查要点
 | 
	
		
			
				|  |  | +            List<AppRulePointTaskVo> pointList = appRulePointService.findPointByPlan(appPlan.getId());
 | 
	
		
			
				|  |  | +            if (pointList.size() <= 0) {//没有检查项不生成履职任务
 | 
	
		
			
				|  |  | +                log.info("error:该计划ID:" + appPlan.getId() + "没有检查项");
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<Long> orgIdList = getPlanOrgIds(appPlan);
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isEmpty(orgIdList)) {//没有检查项不生成履职任务
 | 
	
		
			
				|  |  | +                log.info("error:该计划ID:{}没有执行机构", appPlan.getId());
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //获取履职角色
 | 
	
		
			
				|  |  | +            List<Long> roleIds = appPlanService.findRoleByPlan(appPlan.getId());
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isEmpty(roleIds)) {//没有检查项不生成履职任务
 | 
	
		
			
				|  |  | +                log.info("error:该计划ID:{}没有履职角色", appPlan.getId());
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            CycleCommonEnum cycleCommonEnum=CycleCommonEnum.getEnum(appPlan.getPlanCycle());
 | 
	
		
			
				|  |  | +            DateRange range=  DateUtils.getStartAndEnd(new Date(), cycleCommonEnum);
 | 
	
		
			
				|  |  | +            Map<Long, SysWorkTime> workTimes = orgSingleWorkTimeMap(new Date(), cycleCommonEnum, orgIdList);
 | 
	
		
			
				|  |  | +            for (Long orgId : orgIdList) {
 | 
	
		
			
				|  |  | +                if (!workTimes.containsKey(orgId) || ObjectUtil.isNull(workTimes.get(orgId)) || ObjectUtil.notEqual(workTimes.get(orgId).getIsEnable(), 1)) {
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                SysWorkTime workTime = workTimes.get(orgId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                List<Resumption> tasks;
 | 
	
		
			
				|  |  | +                if(ObjectUtil.equal(CycleCommonEnum.DAILY.getCode(),appPlan.getPlanCycle())){
 | 
	
		
			
				|  |  | +                    tasks= buildResumptions(appPlan, orgId, workTime);
 | 
	
		
			
				|  |  | +                }else{
 | 
	
		
			
				|  |  | +                    tasks=buildResumptions(appPlan,orgId,range.getStartTime(),range.getEndTime(),0L);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isNotEmpty(tasks)) {
 | 
	
		
			
				|  |  | +                    resumptions.addAll(tasks);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        } catch (Exception e) {
 | 
	
		
			
				|  |  | -            e.printStackTrace();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        this.saveBatch(resumptions);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void rebuildDayTask(List<Long> orgIds, SysWorkTime workTime) {
 | 
	
		
			
				|  |  | +        rebuildTask(orgIds, workTime.getYmdDate(), workTime.getYmdDate(), CycleCommonEnum.DAILY, workTime);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void rebuildWeeklyTask(List<Long> orgIds, Date startDate, Date endDate) {
 | 
	
		
			
				|  |  | -        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.WEEKLY);
 | 
	
		
			
				|  |  | +        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.WEEKLY, null);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void rebuildMonthTask(List<Long> orgIds, Date startDate, Date endDate) {
 | 
	
		
			
				|  |  | -        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.MONTHLY);
 | 
	
		
			
				|  |  | +        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.MONTHLY, null);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void rebuildQuarterTask(List<Long> orgIds, Date startDate, Date endDate) {
 | 
	
		
			
				|  |  | -        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.QUARTERLY);
 | 
	
		
			
				|  |  | +        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.QUARTERLY, null);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @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, null);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void rebuildYearTask(List<Long> orgIds, Date startDate, Date endDate) {
 | 
	
		
			
				|  |  | -        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.YEARLY);
 | 
	
		
			
				|  |  | +        rebuildTask(orgIds, startDate, endDate, CycleCommonEnum.YEARLY, null);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private void rebuildTask(List<Long> orgIds, Date startDate, Date endDate, CycleCommonEnum cycle) {
 | 
	
		
			
				|  |  | -        List<Resumption> resumptionList = queryTask(startDate, cycle, orgIds);
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * @param orgIds
 | 
	
		
			
				|  |  | +     * @param startDate
 | 
	
		
			
				|  |  | +     * @param endDate
 | 
	
		
			
				|  |  | +     * @param cycle
 | 
	
		
			
				|  |  | +     * @param workTime  周期为每日时,使用该值
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public void rebuildTask(List<Long> orgIds, Date startDate, Date endDate, CycleCommonEnum cycle, SysWorkTime workTime) {
 | 
	
		
			
				|  |  | +        List<Resumption> resumptionList = queryTask(startDate, 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());
 | 
	
	
		
			
				|  | @@ -130,7 +190,7 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<SysOrg> orgs = remoteOrgService.selectByOrgIdList(orgIds, SecurityConstants.INNER);
 | 
	
		
			
				|  |  |          for (SysOrg org : orgs) {
 | 
	
		
			
				|  |  | -            if(ObjectUtil.isNull(org.getType())){
 | 
	
		
			
				|  |  | +            if (ObjectUtil.isNull(org.getType())) {
 | 
	
		
			
				|  |  |                  continue;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -154,24 +214,27 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
 | 
	
		
			
				|  |  |              for (AppPlan plan : listPlans) {
 | 
	
		
			
				|  |  |                  //根据计划获取角色
 | 
	
		
			
				|  |  |  //                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, startDate, endDate, executedCount);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                List<Resumption> planResumptionList;
 | 
	
		
			
				|  |  | +                if (ObjectUtil.equal(cycle, CycleCommonEnum.DAILY)) {
 | 
	
		
			
				|  |  | +                    planResumptionList = this.buildResumptions(plan, orgId, workTime);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    planResumptionList = this.buildResumptions(plan, orgId, 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())
 | 
	
		
			
				|  |  | -//                            && item1.getRoleId().equals(item.getRoleId())).findFirst().isPresent()).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -//                    if (CollectionUtils.isNotEmpty(resumptionListb)) {
 | 
	
		
			
				|  |  |                      newResumptionList.addAll(planResumptionList);
 | 
	
		
			
				|  |  | -//                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              this.saveBatch(newResumptionList);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private List<Resumption> buildResumptions(AppPlan appPlan, SysWorkTime workTime) {
 | 
	
		
			
				|  |  | +    private List<Resumption> buildResumptions(AppPlan appPlan, Long execOrgId, SysWorkTime workTime) {
 | 
	
		
			
				|  |  |          DateTime dateTime = new DateTime(workTime.getYmdDate());
 | 
	
		
			
				|  |  |          String opentime = workTime.getOpenTime();//营业时间
 | 
	
		
			
				|  |  |          String closetime = workTime.getCloseTime();//营业终了
 | 
	
	
		
			
				|  | @@ -197,10 +260,10 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
 | 
	
		
			
				|  |  |              planendTime = DateUtil.endOfDay(time2).setField(DateField.MILLISECOND, 0);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        return buildResumptions(appPlan, planstartTime, planendTime, 0L);
 | 
	
		
			
				|  |  | +        return buildResumptions(appPlan, execOrgId, planstartTime, planendTime, 0L);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private List<Resumption> buildResumptions(AppPlan appPlan, Date planStartTime, Date planEndTime, Long executedCount) {
 | 
	
		
			
				|  |  | +    private List<Resumption> buildResumptions(AppPlan appPlan, Long execOrgId, Date planStartTime, Date planEndTime, Long executedCount) {
 | 
	
		
			
				|  |  |          List<Resumption> resumptionList = new ArrayList<>();
 | 
	
		
			
				|  |  |          Long count = 1L;
 | 
	
		
			
				|  |  |          if (NumberUtil.isNumber(appPlan.getCount())) {
 | 
	
	
		
			
				|  | @@ -221,8 +284,9 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
 | 
	
		
			
				|  |  |              resumption.setYmdHour(Long.valueOf(ymd.getHour()));
 | 
	
		
			
				|  |  |              resumption.setYmdQuarter(Long.valueOf(ymd.getQuarter()));
 | 
	
		
			
				|  |  |              resumption.setYmdHalfyear(Long.valueOf(ymd.getHalfyear()));
 | 
	
		
			
				|  |  | -            resumption.setPlanId((ObjectUtil.equal(appPlan.getParentId(), -1L) || ObjectUtil.isNull(appPlan.getParentId())) ? appPlan.getId() : appPlan.getParentId());
 | 
	
		
			
				|  |  | -            resumption.setOrgId(appPlan.getPlanOfOrgId());
 | 
	
		
			
				|  |  | +            resumption.setParentPlanId((ObjectUtil.equal(appPlan.getParentId(), -1L) || ObjectUtil.isNull(appPlan.getParentId())) ? appPlan.getId() : appPlan.getParentId());
 | 
	
		
			
				|  |  | +            resumption.setPlanId(appPlan.getId());
 | 
	
		
			
				|  |  | +            resumption.setOrgId(execOrgId);
 | 
	
		
			
				|  |  |              resumption.setType(appPlan.getPlanCycle());
 | 
	
		
			
				|  |  |              resumption.setPlanStartTime(planStartTime);
 | 
	
		
			
				|  |  |              resumption.setPlanEndTime(planEndTime);
 | 
	
	
		
			
				|  | @@ -233,10 +297,15 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
 | 
	
		
			
				|  |  |          return resumptionList;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private List<Resumption> queryTask(Date ymdDate, CycleCommonEnum cycle, List<Long> orgIds) {
 | 
	
		
			
				|  |  | +    private List<Resumption> queryTask(Date ymdDate, CycleCommonEnum cycle, List<Long> orgIds, List<Long> planIds) {
 | 
	
		
			
				|  |  |          QueryWrapper<Resumption> queryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  |          queryWrapper.lambda().eq(Resumption::getYmdDate, ymdDate);
 | 
	
		
			
				|  |  | -        queryWrapper.lambda().in(Resumption::getOrgId, orgIds);
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(orgIds)) {
 | 
	
		
			
				|  |  | +            queryWrapper.lambda().in(Resumption::getOrgId, orgIds);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(planIds)) {
 | 
	
		
			
				|  |  | +            queryWrapper.lambda().in(Resumption::getPlanId, planIds);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          queryWrapper.lambda().eq(Resumption::getType, cycle.getCode());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<Resumption> resumptionList = baseMapper.selectList(queryWrapper);
 | 
	
	
		
			
				|  | @@ -250,7 +319,7 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
 | 
	
		
			
				|  |  |       * @param cycle
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    private List<AppPlan> queryPlans(List<Long> planOfOrgId, CycleCommonEnum cycle,List<Integer> execOrgTypes) {
 | 
	
		
			
				|  |  | +    private List<AppPlan> queryPlans(List<Long> planOfOrgId, CycleCommonEnum cycle, List<Integer> execOrgTypes) {
 | 
	
		
			
				|  |  |          if (CollectionUtils.isEmpty(planOfOrgId)) {
 | 
	
		
			
				|  |  |              return new ArrayList<>();
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -259,8 +328,8 @@ public class RebuildResumptionTaskBusiness extends TaskCreatingServiceImplBase<R
 | 
	
		
			
				|  |  |          qw.lambda().eq(AppPlan::getPlanCycle, cycle.getCode());
 | 
	
		
			
				|  |  |          qw.lambda().in(AppPlan::getPlanOfOrgId, planOfOrgId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if(CollectionUtils.isNotEmpty(execOrgTypes)){
 | 
	
		
			
				|  |  | -            qw.lambda().in(AppPlan::getExecOrgType,execOrgTypes);
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(execOrgTypes)) {
 | 
	
		
			
				|  |  | +            qw.lambda().in(AppPlan::getExecOrgType, execOrgTypes);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<AppPlan> listPlans = appPlanMapper.selectList(qw);
 | 
	
		
			
				|  |  |  
 |