zhongrj
2024-04-22 2423ac966273e5b7530b140cc6ed28d36e42d4d3
src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java
@@ -1,27 +1,8 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.flow.business.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.flowable.engine.HistoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
@@ -29,7 +10,6 @@
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
@@ -42,16 +22,10 @@
import org.springblade.flow.engine.constant.FlowEngineConstant;
import org.springblade.flow.engine.entity.FlowProcess;
import org.springblade.flow.engine.utils.FlowCache;
import org.springblade.modules.district.entity.DistrictEntity;
import org.springblade.modules.district.service.IDistrictService;
import org.springblade.modules.property.entity.PropertyCapitalApplyEntity;
import org.springblade.modules.property.service.IPropertyCapitalApplyService;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * 流程业务实现类
@@ -247,16 +221,43 @@
               flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
            }
         }
         IPropertyCapitalApplyService bean = SpringUtils.getBean(IPropertyCapitalApplyService.class);
         PropertyCapitalApplyEntity capitalApplyEntity = bean.getOne(Wrappers.<PropertyCapitalApplyEntity>lambdaQuery().eq(PropertyCapitalApplyEntity::getProcessInstanceId, historicTaskInstance.getProcessInstanceId()));
         if (capitalApplyEntity != null) {
            flow.setName(capitalApplyEntity.getName());
            flow.setDistrictId(capitalApplyEntity.getDistrictId());
            flow.setLinkman(capitalApplyEntity.getLinkman());
            flow.setLinkPhone(capitalApplyEntity.getLinkPhone());
         }
//         IPropertyCapitalApplyService bean = SpringUtils.getBean(IPropertyCapitalApplyService.class);
//         PropertyCapitalApplyEntity capitalApplyEntity = bean.getOne(Wrappers.<PropertyCapitalApplyEntity>lambdaQuery().eq(PropertyCapitalApplyEntity::getProcessInstanceId, historicTaskInstance.getProcessInstanceId()));
//         if (capitalApplyEntity != null) {
//            flow.setName(capitalApplyEntity.getName());
//            flow.setDistrictId(capitalApplyEntity.getDistrictId());
//            flow.setLinkman(capitalApplyEntity.getLinkman());
//            flow.setLinkPhone(capitalApplyEntity.getLinkPhone());
//         }
         flow.setStatus(FlowEngineConstant.STATUS_FINISH);
         flowList.add(flow);
//         flowList.add(flow);
         Boolean districtNameFlag = true;
         Boolean nameFlag = true;
         Boolean dateFlag = true;
         Boolean isFilter = false;
         if (StringUtils.isNotBlank(bladeFlow.getDistrictName())) {
            isFilter = true;
            // 小区、项目名称、申请时间
            districtNameFlag = flow.getDistrictName().contains(bladeFlow.getDistrictName());
         } else if (StringUtils.isNotBlank(bladeFlow.getName())) {
            isFilter = true;
            // 小区、项目名称、申请时间
            nameFlag = flow.getName().contains(bladeFlow.getName());
         } else if (bladeFlow.getStartTimes() != null && bladeFlow.getEndTimes() != null) {
            isFilter = true;
            // 小区、项目名称、申请时间
            dateFlag = flow.getCreateTime().after(bladeFlow.getStartTimes())
               && flow.getCreateTime().before(bladeFlow.getEndTimes());
         }
         if (isFilter ) {
            if(districtNameFlag && nameFlag && dateFlag){
               flowList.add(flow);
            }
         } else {
            flowList.add(flow);
         }
      });
      // 计算总数
      long count = doneQuery.count();
@@ -324,19 +325,6 @@
            flow.setBusinessTable(businessKey[0]);
            flow.setBusinessId(businessKey[1]);
         }
         IPropertyCapitalApplyService bean = SpringUtils.getBean(IPropertyCapitalApplyService.class);
         PropertyCapitalApplyEntity capitalApplyEntity = bean.getOne(Wrappers.<PropertyCapitalApplyEntity>lambdaQuery().eq(PropertyCapitalApplyEntity::getProcessInstanceId, task.getProcessInstanceId()));
         if (capitalApplyEntity != null) {
            flow.setName(capitalApplyEntity.getName());
            flow.setDistrictId(capitalApplyEntity.getDistrictId());
            IDistrictService bean1 = SpringUtils.getBean(IDistrictService.class);
            DistrictEntity one = bean1.getOne(Wrappers.<DistrictEntity>lambdaQuery().eq(DistrictEntity::getId, capitalApplyEntity.getDistrictId()));
            if (one != null) {
               flow.setDistrictName(one.getName());
            }
            flow.setLinkman(capitalApplyEntity.getLinkman());
            flow.setLinkPhone(capitalApplyEntity.getLinkPhone());
         }
         FlowProcess processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
         flow.setCategory(processDefinition.getCategory());
@@ -347,9 +335,9 @@
         flow.setProcessDefinitionVersion(processDefinition.getVersion());
         flow.setProcessInstanceId(task.getProcessInstanceId());
         flow.setStatus(status);
         Boolean districtNameFlag = false;
         Boolean nameFlag = false;
         Boolean dateFlag = false;
         Boolean districtNameFlag = true;
         Boolean nameFlag = true;
         Boolean dateFlag = true;
         Boolean isFilter = false;
         if (StringUtils.isNotBlank(bladeFlow.getDistrictName())) {
@@ -367,7 +355,7 @@
               && flow.getCreateTime().before(bladeFlow.getEndTimes());
         }
         if (isFilter ) {
            if(districtNameFlag || nameFlag || dateFlag){
            if(districtNameFlag && nameFlag && dateFlag){
               flowList.add(flow);
            }
         } else {