|
@@ -1495,8 +1495,14 @@ public class KwcContractTradeService {
|
|
|
|
|
|
|
|
public List<QueryListResVo> queryTradeListByPage(QueryTradeReq req) {
|
|
public List<QueryListResVo> queryTradeListByPage(QueryTradeReq req) {
|
|
|
|
|
|
|
|
- Long entId = StringUtils.isNotBlank(req.getEntId()) ? Long.valueOf(req.getEntId()) : null;
|
|
|
|
|
|
|
+ Long entId;
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getEntId())){
|
|
|
|
|
+ entId =Long.valueOf(req.getEntId());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ entId = LoginUserHolder.getEntId();
|
|
|
|
|
+ }
|
|
|
Set<Long> entIds = Sets.newHashSet();
|
|
Set<Long> entIds = Sets.newHashSet();
|
|
|
|
|
+ entIds.add(entId);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getPurchaseEntId())) {
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getPurchaseEntId())) {
|
|
|
//查询企业 信息
|
|
//查询企业 信息
|
|
|
entIds.add(Long.valueOf(req.getPurchaseEntId()));
|
|
entIds.add(Long.valueOf(req.getPurchaseEntId()));
|
|
@@ -1508,29 +1514,17 @@ public class KwcContractTradeService {
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(entIds)){
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(entIds)){
|
|
|
List<KwcContractTradeUnit> units = kwcContractTradeUnitRepository.queryByEntIds(entIds);
|
|
List<KwcContractTradeUnit> units = kwcContractTradeUnitRepository.queryByEntIds(entIds);
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(units)){
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(units)){
|
|
|
- contractIds = units.stream().map(KwcContractTradeUnit::getContractId).collect(Collectors.toSet());
|
|
|
|
|
|
|
+ contractIds = units.stream()
|
|
|
|
|
+ .map(KwcContractTradeUnit::getContractId)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- List<Long> allEnt = Lists.newArrayList();
|
|
|
|
|
- if (StringUtils.isBlank(req.getEntId())) {
|
|
|
|
|
- req.setEntId(String.valueOf(LoginUserHolder.getEntId()));
|
|
|
|
|
- allEnt.add(LoginUserHolder.getEntId());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (Objects.nonNull(entId)) {
|
|
|
|
|
- allEnt.add(entId);
|
|
|
|
|
- EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
|
|
|
|
|
- if (Objects.nonNull(entCacheResDto)) {
|
|
|
|
|
- EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntTreeById(entCacheResDto.getId());
|
|
|
|
|
- List<EntCacheResDto> child = entCacheResDto1.getChild();
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(child)) {
|
|
|
|
|
- allEnt.addAll(child.stream().map(EntCacheResDto::getId).toList());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(contractIds)){
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
PageHelper.startPage(req.getPageNum(), req.getPageSize());
|
|
PageHelper.startPage(req.getPageNum(), req.getPageSize());
|
|
|
//分页查询合同信息
|
|
//分页查询合同信息
|
|
|
- List<KwcContractTrade> records = kwcContractTradeRepository.queryTradeListByPageList(allEnt,
|
|
|
|
|
|
|
+ List<KwcContractTrade> records = kwcContractTradeRepository.queryTradeListByPageList(
|
|
|
req.getContractCode(),
|
|
req.getContractCode(),
|
|
|
req.getContractName(),
|
|
req.getContractName(),
|
|
|
req.getSupplementCode(),
|
|
req.getSupplementCode(),
|
|
@@ -1539,6 +1533,49 @@ public class KwcContractTradeService {
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isEmpty(records)){
|
|
if (org.apache.commons.collections4.CollectionUtils.isEmpty(records)){
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
|
|
+ entIds.addAll(records.stream().map(KwcContractTrade::getEntId).collect(Collectors.toSet()));
|
|
|
|
|
+ List<EntTypeResDto> ents = remoteSystemService.queryEntTypeByIds(entIds);
|
|
|
|
|
+ Map<Long, EntTypeResDto> entIdAndEntMap = Maps.newHashMap() ;
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(ents)){
|
|
|
|
|
+ entIdAndEntMap =
|
|
|
|
|
+ ents.stream().collect(Collectors.toMap(EntTypeResDto::getEntId, Function.identity(), (v1, v2) -> v1));
|
|
|
|
|
+ }
|
|
|
|
|
+ //如果登录方是采购方,创建方是提供方,那么采购方只能看到已经签约的合同
|
|
|
|
|
+ EntTypeResDto entTypeResDto = entIdAndEntMap.getOrDefault(entId, new EntTypeResDto());
|
|
|
|
|
+ //如果登录方是采购商,创建方是供应方,那么采购商只能看到已经签约的合同
|
|
|
|
|
+ List<KwcContractTrade> contractTrades = Lists.newArrayList();
|
|
|
|
|
+ List<KwcContractTrade> contractTrades1 = Lists.newArrayList();
|
|
|
|
|
+ if (entTypeResDto.getType().equals(EntTypeEnum.PURCHASER.getCode())){
|
|
|
|
|
+ List<Integer> statusList = Arrays.asList(ContractStatusEnum.SIGNED.getCode(), ContractStatusEnum.COMPLETE.getCode());
|
|
|
|
|
+ Map<Long, EntTypeResDto> finalEntIdAndEntMap1 = entIdAndEntMap;
|
|
|
|
|
+
|
|
|
|
|
+ records.forEach(record -> {
|
|
|
|
|
+ EntTypeResDto orDefault = finalEntIdAndEntMap1.getOrDefault(record.getEntId(), new EntTypeResDto());
|
|
|
|
|
+ if (Objects.equals(orDefault.getType(),EntTypeEnum.SUPPLIER.getCode()) && statusList.contains(record.getStatus())){
|
|
|
|
|
+ contractTrades.add(record);
|
|
|
|
|
+ }else if (Objects.equals(orDefault.getType(),EntTypeEnum.PURCHASER.getCode())) {
|
|
|
|
|
+ contractTrades1.add(record);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //如果登录方是供应方,创建方是采购方,那么供应方不能看到已作废的 合同
|
|
|
|
|
+ if (entTypeResDto.getType().equals(EntTypeEnum.SUPPLIER.getCode())){
|
|
|
|
|
+ Map<Long, EntTypeResDto> finalEntIdAndEntMap = entIdAndEntMap;
|
|
|
|
|
+ records.forEach(record -> {
|
|
|
|
|
+ EntTypeResDto orDefault = finalEntIdAndEntMap.getOrDefault(record.getEntId(), new EntTypeResDto());
|
|
|
|
|
+ if (Objects.equals(orDefault.getType(),EntTypeEnum.PURCHASER.getCode()) && !Objects.equals(record.getStatus(),ContractStatusEnum.CANNEL.getCode())){
|
|
|
|
|
+ contractTrades.add(record);
|
|
|
|
|
+ }else if (Objects.equals(orDefault.getType(),EntTypeEnum.SUPPLIER.getCode())){
|
|
|
|
|
+ contractTrades1.add(record);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ contractTrades.addAll(contractTrades1);
|
|
|
|
|
+ records = contractTrades;
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(records)){
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Set<Long> tradeContractIds = records.stream().map(KwcContractTrade::getId).collect(Collectors.toSet());
|
|
Set<Long> tradeContractIds = records.stream().map(KwcContractTrade::getId).collect(Collectors.toSet());
|
|
|
//获取父id
|
|
//获取父id
|
|
|
Set<Long> contractPids = records.stream().map(KwcContractTrade::getContractPid).collect(Collectors.toSet());
|
|
Set<Long> contractPids = records.stream().map(KwcContractTrade::getContractPid).collect(Collectors.toSet());
|
|
@@ -1887,8 +1924,14 @@ public class KwcContractTradeService {
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
ContractStatusCountResp contractStatusCountResp = new ContractStatusCountResp();
|
|
ContractStatusCountResp contractStatusCountResp = new ContractStatusCountResp();
|
|
|
contractStatusCountResp.setTotalNum("0");
|
|
contractStatusCountResp.setTotalNum("0");
|
|
|
- Long entId = StringUtils.isNotBlank(req.getEntId()) ? Long.valueOf(req.getEntId()) : null;
|
|
|
|
|
|
|
+ Long entId;
|
|
|
|
|
+ if (Objects.nonNull(req.getEntId())){
|
|
|
|
|
+ entId =req.getEntId();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ entId = LoginUserHolder.getEntId();
|
|
|
|
|
+ }
|
|
|
Set<Long> entIds = Sets.newHashSet();
|
|
Set<Long> entIds = Sets.newHashSet();
|
|
|
|
|
+ entIds.add(entId);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getPurchaseEntId())) {
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getPurchaseEntId())) {
|
|
|
//查询企业 信息
|
|
//查询企业 信息
|
|
|
entIds.add(Long.valueOf(req.getPurchaseEntId()));
|
|
entIds.add(Long.valueOf(req.getPurchaseEntId()));
|
|
@@ -1913,24 +1956,7 @@ public class KwcContractTradeService {
|
|
|
return contractStatusCountResp;
|
|
return contractStatusCountResp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- List<Long> allEnt = Lists.newArrayList();
|
|
|
|
|
- if (StringUtils.isBlank(req.getEntId())) {
|
|
|
|
|
- req.setEntId(LoginUserHolder.getEntId());
|
|
|
|
|
- allEnt.add(LoginUserHolder.getEntId());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (Objects.nonNull(entId)) {
|
|
|
|
|
- allEnt.add(entId);
|
|
|
|
|
- EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
|
|
|
|
|
- if (Objects.nonNull(entCacheResDto)) {
|
|
|
|
|
- EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntTreeById(entCacheResDto.getId());
|
|
|
|
|
- List<EntCacheResDto> child = entCacheResDto1.getChild();
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(child)) {
|
|
|
|
|
- allEnt.addAll(child.stream().map(EntCacheResDto::getId).toList());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- List<KwcContractTrade> kwcContractTrades = kwcContractTradeRepository.queryTradeListByPageList(allEnt,
|
|
|
|
|
|
|
+ List<KwcContractTrade> kwcContractTrades = kwcContractTradeRepository.queryTradeListByPageList(
|
|
|
req.getContractCode(),
|
|
req.getContractCode(),
|
|
|
req.getContractName(),
|
|
req.getContractName(),
|
|
|
req.getSupplementCode(),
|
|
req.getSupplementCode(),
|
|
@@ -1946,6 +1972,54 @@ public class KwcContractTradeService {
|
|
|
contractStatusCountResp.setContractStatusInfo(statusCounts);
|
|
contractStatusCountResp.setContractStatusInfo(statusCounts);
|
|
|
return contractStatusCountResp;
|
|
return contractStatusCountResp;
|
|
|
}
|
|
}
|
|
|
|
|
+ entIds.addAll(kwcContractTrades.stream().map(KwcContractTrade::getEntId).collect(Collectors.toSet()));
|
|
|
|
|
+ List<EntTypeResDto> ents = remoteSystemService.queryEntTypeByIds(entIds);
|
|
|
|
|
+ Map<Long, EntTypeResDto> entIdAndEntMap = Maps.newHashMap() ;
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(ents)){
|
|
|
|
|
+ entIdAndEntMap =
|
|
|
|
|
+ ents.stream().collect(Collectors.toMap(EntTypeResDto::getEntId, Function.identity(), (v1, v2) -> v1));
|
|
|
|
|
+ }
|
|
|
|
|
+ //如果登录方是采购方,创建方是提供方,那么采购方只能看到已经签约的合同
|
|
|
|
|
+ EntTypeResDto entTypeResDto = entIdAndEntMap.getOrDefault(entId, new EntTypeResDto());
|
|
|
|
|
+ //如果登录方是采购商,创建方是供应方,那么采购商只能看到已经签约的合同
|
|
|
|
|
+ List<KwcContractTrade> contractTrades = Lists.newArrayList();
|
|
|
|
|
+ List<KwcContractTrade> contractTrades1 = Lists.newArrayList();
|
|
|
|
|
+ if (entTypeResDto.getType().equals(EntTypeEnum.PURCHASER.getCode())){
|
|
|
|
|
+
|
|
|
|
|
+ List<Integer> statusList = Arrays.asList(ContractStatusEnum.SIGNED.getCode(), ContractStatusEnum.COMPLETE.getCode());
|
|
|
|
|
+ Map<Long, EntTypeResDto> finalEntIdAndEntMap1 = entIdAndEntMap;
|
|
|
|
|
+
|
|
|
|
|
+ kwcContractTrades.forEach(record -> {
|
|
|
|
|
+ EntTypeResDto orDefault = finalEntIdAndEntMap1.getOrDefault(record.getEntId(), new EntTypeResDto());
|
|
|
|
|
+ if (Objects.equals(orDefault.getType(),EntTypeEnum.SUPPLIER.getCode()) && statusList.contains(record.getStatus())){
|
|
|
|
|
+ contractTrades.add(record);
|
|
|
|
|
+ }else if (Objects.equals(orDefault.getType(),EntTypeEnum.PURCHASER.getCode())){
|
|
|
|
|
+ contractTrades1.add(record);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ kwcContractTrades = contractTrades;
|
|
|
|
|
+ }
|
|
|
|
|
+ //如果登录方是供应方,创建方是采购方,那么供应方不能看到已作废的 合同
|
|
|
|
|
+ if (entTypeResDto.getType().equals(EntTypeEnum.SUPPLIER.getCode())){
|
|
|
|
|
+ Map<Long, EntTypeResDto> finalEntIdAndEntMap = entIdAndEntMap;
|
|
|
|
|
+ kwcContractTrades.forEach(record -> {
|
|
|
|
|
+ EntTypeResDto orDefault = finalEntIdAndEntMap.getOrDefault(record.getEntId(), new EntTypeResDto());
|
|
|
|
|
+ if (Objects.equals(orDefault.getType(),EntTypeEnum.PURCHASER.getCode()) && !Objects.equals(record.getStatus(),ContractStatusEnum.CANNEL.getCode())){
|
|
|
|
|
+ contractTrades.add(record);
|
|
|
|
|
+ }else if (Objects.equals(orDefault.getType(),EntTypeEnum.SUPPLIER.getCode())){
|
|
|
|
|
+ contractTrades1.add(record);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ kwcContractTrades = contractTrades;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(kwcContractTrades)){
|
|
|
|
|
+ Map<Integer, List<KwcContractTrade>> statusAndLogOrdersMap = new HashMap<>();
|
|
|
|
|
+ List<ContractStatusCountResp.ContractStatusCount> statusCounts = statusEnums.stream()
|
|
|
|
|
+ .map(x -> getContractStatusCount(x, statusAndLogOrdersMap))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ contractStatusCountResp.setContractStatusInfo(statusCounts);
|
|
|
|
|
+ return contractStatusCountResp;
|
|
|
|
|
+ }
|
|
|
Map<Integer, List<KwcContractTrade>> statusAndLogOrdersMap = kwcContractTrades.stream().collect(Collectors.groupingBy(KwcContractTrade::getStatus));
|
|
Map<Integer, List<KwcContractTrade>> statusAndLogOrdersMap = kwcContractTrades.stream().collect(Collectors.groupingBy(KwcContractTrade::getStatus));
|
|
|
return getContractStatusCountResp(statusEnums, statusAndLogOrdersMap, contractStatusCountResp, kwcContractTrades);
|
|
return getContractStatusCountResp(statusEnums, statusAndLogOrdersMap, contractStatusCountResp, kwcContractTrades);
|
|
|
}
|
|
}
|