|
|
@@ -9,15 +9,20 @@ import com.hz.pm.api.projectlib.handle.AbstractProcessHandle; |
|
|
|
import com.hz.pm.api.projectlib.handle.HandleParamContext; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; |
|
|
|
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessDetailVO; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessInfoVO; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessProgressVo; |
|
|
|
import com.wflow.workflow.enums.StepStatusEnum; |
|
|
|
import com.wflow.workflow.service.ProcessInstanceService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import static com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus.ON_PURCHASING; |
|
|
|
import static com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus.TO_BE_PURCHASED; |
|
|
|
|
|
|
|
/** |
|
|
@@ -30,9 +35,9 @@ import static com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus.TO |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class ProjectPurchaseHandle extends AbstractProcessHandle { |
|
|
|
|
|
|
|
private final IProjectStatusChangeService projectStatusChangeService; |
|
|
|
private final IPurchaseService purchaseService; |
|
|
|
private final IPurchaseInstService purchaseInstService; |
|
|
|
private final ProcessInstanceService processInstanceService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getOrder() { |
|
|
@@ -56,22 +61,37 @@ public class ProjectPurchaseHandle extends AbstractProcessHandle { |
|
|
|
Project project = ctx.getProject(); |
|
|
|
if (TO_BE_PURCHASED.eq(project.getStatus())) { |
|
|
|
detail.setStepStatus(StepStatusEnum.NOT_START); |
|
|
|
} else if (ON_PURCHASING.eq(project.getStatus())) { |
|
|
|
detail.setStepStatus(StepStatusEnum.ON_GOING); |
|
|
|
} else { |
|
|
|
// 根据采购备案的时间获取 |
|
|
|
ProjectStatusChange change = ctx.getProjectStateChange(ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD); |
|
|
|
if (change == null) { |
|
|
|
List<Purchase> purchases = purchaseService.listByProjectId(project.getId()); |
|
|
|
ctx.setPurchases(purchases); |
|
|
|
if (purchases.isEmpty()) { |
|
|
|
detail.setStepStatus(StepStatusEnum.NOT_START); |
|
|
|
} else { |
|
|
|
detail.setStepStatus(StepStatusEnum.COMPLETED); |
|
|
|
detail.setFinishTime(change.getCreateOn()); |
|
|
|
List<Purchase> purchases = purchaseService.listByProjectId(project.getId()); |
|
|
|
ctx.setPurchases(purchases); |
|
|
|
// 根据采购备案的时间获取 |
|
|
|
ProjectStatusChange change = ctx.getProjectStateChange(ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD); |
|
|
|
if (change != null) { |
|
|
|
detail.setStepStatus(StepStatusEnum.COMPLETED); |
|
|
|
detail.setFinishTime(change.getCreateOn()); |
|
|
|
} else { |
|
|
|
detail.setStepStatus(StepStatusEnum.ON_GOING); |
|
|
|
} |
|
|
|
List<PurchaseInst> purchaseInstList = purchaseInstService.listByProjectId(project.getId()); |
|
|
|
ctx.setPurchaseInstList(purchaseInstList); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!StepStatusEnum.NOT_START.equals(detail.getStepStatus())) { |
|
|
|
Map<Long, Purchase> purchaseMap = CollUtils.listToMap(ctx.getPurchases(), Purchase::getId); |
|
|
|
Map<Long, PurchaseInst> instMap = purchaseInstService.listNewest(purchaseMap.keySet(), InstTypeEnum.PURCHASE_NOTICE.getCode()); |
|
|
|
List<ProcessInfoVO> processes = new ArrayList<>(); |
|
|
|
instMap.forEach((bidId, inst) -> { |
|
|
|
ProcessProgressVo instDetail = processInstanceService.getProgressInstanceDetail(null, inst.getInstCode()); |
|
|
|
ProcessInfoVO tenderProgress = new ProcessInfoVO(); |
|
|
|
tenderProgress.setProcessName(purchaseMap.get(bidId).getBidName()); |
|
|
|
tenderProgress.setProcessProgressVo(instDetail); |
|
|
|
processes.add(tenderProgress); |
|
|
|
}); |
|
|
|
detail.setProcessInfoList(processes); |
|
|
|
} |
|
|
|
ctx.setPreStepStatus(detail.getStepStatus()); |
|
|
|
} |
|
|
|
|
|
|
|