|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.hz.pm.api.projectdeclared.manage; |
|
|
|
|
|
|
|
import cn.dev33.satoken.fun.SaParamRetFunction; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
@@ -16,6 +17,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; |
|
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
|
import com.hz.pm.api.common.statemachine.event.*; |
|
|
|
import com.hz.pm.api.common.statemachine.util.*; |
|
|
|
import com.hz.pm.api.common.util.BizUtils; |
|
|
|
import com.hz.pm.api.common.util.EnvironmentUtil; |
|
|
@@ -46,6 +48,7 @@ import com.hz.pm.api.projectdeclared.service.IOperationService; |
|
|
|
import com.hz.pm.api.projectdeclared.service.IPurchaseInstService; |
|
|
|
import com.hz.pm.api.projectdeclared.service.IPurchaseService; |
|
|
|
import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; |
|
|
|
import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; |
|
|
|
import com.hz.pm.api.projectlib.helper.ProjectHelper; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectInst; |
|
|
@@ -55,6 +58,7 @@ import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; |
|
|
|
import com.hz.pm.api.projectlib.model.vo.TenderListInfoVO; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectInstService; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectService; |
|
|
|
import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; |
|
|
|
import com.hz.pm.api.sys.manage.ProcessModelManage; |
|
|
|
import com.hz.pm.api.user.helper.MhUnitCache; |
|
|
|
import com.hz.pm.api.user.security.model.UserFullInfoDTO; |
|
|
@@ -121,6 +125,7 @@ public class PurchaseManage { |
|
|
|
private final IPurchaseInstService purchaseInstService; |
|
|
|
private final IProjectInstService projectInstService; |
|
|
|
private final EnvironmentUtil environmentUtil; |
|
|
|
private final IPurchaseStatusChangeService purchaseStatusChangeService; |
|
|
|
|
|
|
|
private boolean buildPurchaseQueryPermission(LambdaQueryWrapper<Purchase> query, UserFullInfoDTO user) { |
|
|
|
boolean queryState = true; |
|
|
@@ -443,7 +448,8 @@ public class PurchaseManage { |
|
|
|
.eq(req.getStatus() != null, function, req.getStatus()) |
|
|
|
.isNotNull(function) |
|
|
|
.orderByDesc(Purchase::getCreateOn); |
|
|
|
if (!Boolean.FALSE.equals(req.getDisplay())) { |
|
|
|
boolean display = !Boolean.FALSE.equals(req.getDisplay()); |
|
|
|
if (display) { |
|
|
|
query.and(q1 -> q1.eq(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()) |
|
|
|
.or(q2 -> q2.exists(String.format("select 1 from nd_project_operation no" + |
|
|
|
" where no.bid_id = nd_purchase.id and no.%s is not null", actualTimeColumn)))); |
|
|
@@ -461,6 +467,37 @@ public class PurchaseManage { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<Purchase> records = page.getRecords(); |
|
|
|
Map<Long, LocalDateTime> createOnMap = new HashMap<>(); |
|
|
|
if (display) { |
|
|
|
List<Long> bidIds = CollUtils.fieldList(records, Purchase::getId); |
|
|
|
AbstractStateChangeEvent event; |
|
|
|
if ("actual_test_valid_time".equals(actualTimeColumn)) { |
|
|
|
event = TestValidStateChangeEvent.SUBMIT_TEST_VALID_INFO; |
|
|
|
} else if ("actual_adaption_time".equals(actualTimeColumn)) { |
|
|
|
event = AdaptStateChangeEvent.SUBMIT_ADAPT_INFO; |
|
|
|
} else { |
|
|
|
event = SelfTestStateChangeEvent.SUBMIT_SELF_TEST_INFO; |
|
|
|
} |
|
|
|
Wrapper<PurchaseStatusChange> pscQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) |
|
|
|
.in(PurchaseStatusChange::getEvent, event.name(), TenderStateChangeEvent.SUBMIT_OPERATION_PLAN) |
|
|
|
.in(PurchaseStatusChange::getBidId, bidIds) |
|
|
|
.orderByAsc(PurchaseStatusChange::getCreateOn); |
|
|
|
List<PurchaseStatusChange> changes = purchaseStatusChangeService.list(pscQuery); |
|
|
|
Map<Long, List<PurchaseStatusChange>> mapByBidId = CollUtils.group(changes, PurchaseStatusChange::getBidId); |
|
|
|
records.forEach(w -> { |
|
|
|
List<PurchaseStatusChange> tmpChanges = mapByBidId.get(w.getId()); |
|
|
|
if (tmpChanges == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
Map<String, LocalDateTime> changeMap = CollUtils.listToMap(tmpChanges, |
|
|
|
PurchaseStatusChange::getEvent, PurchaseStatusChange::getCreateOn); |
|
|
|
if (BidTypeEnum.BUILD_APP.getCode().equals(w.getBidType())) { |
|
|
|
createOnMap.put(w.getId(), changeMap.get(TenderStateChangeEvent.SUBMIT_OPERATION_PLAN.name())); |
|
|
|
} else { |
|
|
|
createOnMap.put(w.getId(), changeMap.get(event.name())); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
List<Long> projectIds = CollUtils.fieldList(records, Purchase::getProjectId); |
|
|
|
Map<Long, Contract> contractMap = contractService.listByProjectIds(projectIds); |
|
|
|
List<TestValidListVO> data = records.stream().map(w -> { |
|
|
@@ -473,6 +510,9 @@ public class PurchaseManage { |
|
|
|
Contract contract = contractMap.get(w.getId()); |
|
|
|
item.setContractAmount(contract.getTotalAmount()); |
|
|
|
item.setStatus(function.apply(w)); |
|
|
|
if (display) { |
|
|
|
item.setCreateOn(createOnMap.getOrDefault(w.getId(), w.getCreateOn())); |
|
|
|
} |
|
|
|
return item; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return PageVo.of(data, page.getTotal()); |
|
|
|