|
@@ -152,49 +152,69 @@ public class KwcContractTradeService {
|
|
|
* @date 2023/7/17
|
|
* @date 2023/7/17
|
|
|
*/
|
|
*/
|
|
|
public PageResult queryListByPage(QueryListReqVo reqVo) {
|
|
public PageResult queryListByPage(QueryListReqVo reqVo) {
|
|
|
- PageHelper.startPage(reqVo.getPage(), reqVo.getPageSize());
|
|
|
|
|
- QueryListReqDto queryListReqDto = new QueryListReqDto();
|
|
|
|
|
- BeanUtils.copyProperties(reqVo, queryListReqDto);
|
|
|
|
|
- List<Long> allEnt = new ArrayList<>();
|
|
|
|
|
- if (Objects.isNull(reqVo.getEntId())) {
|
|
|
|
|
- queryListReqDto.setEntId(LoginUserHolder.getEntId());
|
|
|
|
|
- }
|
|
|
|
|
- allEnt.add(queryListReqDto.getEntId());
|
|
|
|
|
|
|
|
|
|
- EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(queryListReqDto.getEntId());
|
|
|
|
|
- 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());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- queryListReqDto.setAllEnt(allEnt);
|
|
|
|
|
-
|
|
|
|
|
- if (StringUtils.isNotBlank(reqVo.getKeywords())) {
|
|
|
|
|
- List<KwsUserResDto> userByName = remoteUserService.getUserByName(reqVo.getKeywords());
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(userByName)) {
|
|
|
|
|
- queryListReqDto.setInitiateList(userByName.stream().map(KwsUserResDto::getId).toList());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- List<QueryListResDto> queryListResDtos = kwcContractTradeMapper.queryList1(queryListReqDto);
|
|
|
|
|
- if (CollectionUtils.isEmpty(queryListResDtos)) {
|
|
|
|
|
- return PageHelperUtil.getPageResult(new PageInfo<>());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //获取贸易合同id
|
|
|
|
|
- Set<Long> tradeContractIds =
|
|
|
|
|
- queryListResDtos.stream().map(QueryListResDto::getId).collect(Collectors.toSet());
|
|
|
|
|
- //查询贸易合同关联商品
|
|
|
|
|
- List<KwcContractTradeGoods> tradeContractGoods = kwcContractTradeGoodsRepository.queryByContractIds(tradeContractIds);
|
|
|
|
|
- Map<Long, List<KwcContractTradeGoods>> contractIdGoodsIdKeyAndGoodsMap = Maps.newHashMap();
|
|
|
|
|
- if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tradeContractGoods)){
|
|
|
|
|
- contractIdGoodsIdKeyAndGoodsMap =
|
|
|
|
|
- tradeContractGoods.stream().collect(Collectors.groupingBy(KwcContractTradeGoods::getContractId));
|
|
|
|
|
- }
|
|
|
|
|
- List<QueryListResVo> list = getQueryListResVos(queryListResDtos, contractIdGoodsIdKeyAndGoodsMap);
|
|
|
|
|
- return PageHelperUtil.getPageResult(new PageInfo<>(list), queryListResDtos, reqVo.getPageSize());
|
|
|
|
|
|
|
+ QueryTradeReq queryTradeReq = new QueryTradeReq();
|
|
|
|
|
+ queryTradeReq.setContractCode(reqVo.getContractCode());
|
|
|
|
|
+ queryTradeReq.setContractName(reqVo.getContractName());
|
|
|
|
|
+ queryTradeReq.setSupplementCode(reqVo.getSupplementCode());
|
|
|
|
|
+ queryTradeReq.setPurchaseEntId(reqVo.getPurchaseEntId());
|
|
|
|
|
+ queryTradeReq.setSupplyEntId(reqVo.getSupplyEntId());
|
|
|
|
|
+ queryTradeReq.setStatus(reqVo.getStatus());
|
|
|
|
|
+ queryTradeReq.setEntId(String.valueOf(reqVo.getEntId()));
|
|
|
|
|
+ queryTradeReq.setPageNum(reqVo.getPage());
|
|
|
|
|
+ queryTradeReq.setPageSize(reqVo.getPageSize());
|
|
|
|
|
+
|
|
|
|
|
+ List<QueryListResVo> queryListResVoPageDataResult = queryTradeListByPage(queryTradeReq);
|
|
|
|
|
+ // List<QueryListResVo> list1 = queryListResVoPageDataResult.getList();
|
|
|
|
|
+// QueryListReqDto queryListReqDto = new QueryListReqDto();
|
|
|
|
|
+// BeanUtils.copyProperties(reqVo, queryListReqDto);
|
|
|
|
|
+// List<Long> allEnt = new ArrayList<>();
|
|
|
|
|
+// if (Objects.isNull(reqVo.getEntId())) {
|
|
|
|
|
+// queryListReqDto.setEntId(LoginUserHolder.getEntId());
|
|
|
|
|
+// }
|
|
|
|
|
+// allEnt.add(queryListReqDto.getEntId());
|
|
|
|
|
+//
|
|
|
|
|
+// EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(queryListReqDto.getEntId());
|
|
|
|
|
+// 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());
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// queryListReqDto.setAllEnt(allEnt);
|
|
|
|
|
+//
|
|
|
|
|
+// if (StringUtils.isNotBlank(reqVo.getKeywords())) {
|
|
|
|
|
+// List<KwsUserResDto> userByName = remoteUserService.getUserByName(reqVo.getKeywords());
|
|
|
|
|
+// if (CollectionUtils.isNotEmpty(userByName)) {
|
|
|
|
|
+// queryListReqDto.setInitiateList(userByName.stream().map(KwsUserResDto::getId).toList());
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// List<QueryListResDto> queryListResDtos = kwcContractTradeMapper.queryList1(queryListReqDto);
|
|
|
|
|
+// if (CollectionUtils.isEmpty(queryListResDtos)) {
|
|
|
|
|
+// return PageHelperUtil.getPageResult(new PageInfo<>());
|
|
|
|
|
+// }
|
|
|
|
|
+// //查询公司信息
|
|
|
|
|
+// Set<Long> tradeContractIds = queryListResDtos.stream().map(QueryListResDto::getId).collect(Collectors.toSet());
|
|
|
|
|
+// List<KwcContractTradeUnit> tradeUnits = kwcContractTradeUnitRepository.queryByContractIds(tradeContractIds);
|
|
|
|
|
+// Map<String, KwcContractTradeUnit> contractUnitTypeKeyAndUnitMap = Maps.newHashMap();
|
|
|
|
|
+// if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tradeUnits)){
|
|
|
|
|
+// contractUnitTypeKeyAndUnitMap = tradeUnits.stream()
|
|
|
|
|
+// .peek(x -> x.setContractIdUniTypeKey(x.getContractId() + "-" + x.getUnitType()))
|
|
|
|
|
+// .collect(Collectors.toMap(KwcContractTradeUnit::getContractIdUniTypeKey, Function.identity(), (v1
|
|
|
|
|
+// , v2) -> v1));
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// //查询贸易合同关联商品
|
|
|
|
|
+// List<KwcContractTradeGoods> tradeContractGoods = kwcContractTradeGoodsRepository.queryByContractIds(tradeContractIds);
|
|
|
|
|
+// Map<Long, List<KwcContractTradeGoods>> contractIdGoodsIdKeyAndGoodsMap = Maps.newHashMap();
|
|
|
|
|
+// if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tradeContractGoods)){
|
|
|
|
|
+// contractIdGoodsIdKeyAndGoodsMap =
|
|
|
|
|
+// tradeContractGoods.stream().collect(Collectors.groupingBy(KwcContractTradeGoods::getContractId));
|
|
|
|
|
+// }
|
|
|
|
|
+// List<QueryListResVo> list = getQueryListResVos(queryListResDtos, contractIdGoodsIdKeyAndGoodsMap,contractUnitTypeKeyAndUnitMap);
|
|
|
|
|
+ return PageHelperUtil.getPageResult(new PageInfo<>(queryListResVoPageDataResult), queryListResVoPageDataResult, reqVo.getPageSize());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -205,7 +225,8 @@ public class KwcContractTradeService {
|
|
|
* @author: czh
|
|
* @author: czh
|
|
|
* @date: 2023/7/18
|
|
* @date: 2023/7/18
|
|
|
*/
|
|
*/
|
|
|
- private List<QueryListResVo> getQueryListResVos(List<QueryListResDto> queryListResDtos,Map<Long, List<KwcContractTradeGoods>> contractIdGoodsIdKeyAndGoodsMap ) {
|
|
|
|
|
|
|
+ private List<QueryListResVo> getQueryListResVos(List<QueryListResDto> queryListResDtos,Map<Long,
|
|
|
|
|
+ List<KwcContractTradeGoods>> contractIdGoodsIdKeyAndGoodsMap,Map<String, KwcContractTradeUnit> contractUnitTypeKeyAndUnitMap ) {
|
|
|
Map<Long, UserCacheResDto> longUserCacheResDtoMap = new HashMap<>(8);
|
|
Map<Long, UserCacheResDto> longUserCacheResDtoMap = new HashMap<>(8);
|
|
|
List<Long> initiateByList = queryListResDtos.stream().map(QueryListResDto::getInitiateBy).toList();
|
|
List<Long> initiateByList = queryListResDtos.stream().map(QueryListResDto::getInitiateBy).toList();
|
|
|
if (CollectionUtils.isNotEmpty(initiateByList)) {
|
|
if (CollectionUtils.isNotEmpty(initiateByList)) {
|
|
@@ -233,6 +254,19 @@ public class KwcContractTradeService {
|
|
|
queryListResVo.setInitiateName(userCacheResDto.getName());
|
|
queryListResVo.setInitiateName(userCacheResDto.getName());
|
|
|
queryListResVo.setInitiateEntName(Objects.isNull(userCacheResDto.getEntInfo()) ? "" : userCacheResDto.getEntInfo().getFirmName());
|
|
queryListResVo.setInitiateEntName(Objects.isNull(userCacheResDto.getEntInfo()) ? "" : userCacheResDto.getEntInfo().getFirmName());
|
|
|
}
|
|
}
|
|
|
|
|
+ if (MapUtils.isNotEmpty(contractUnitTypeKeyAndUnitMap)){
|
|
|
|
|
+ KwcContractTradeUnit kwcContractTradeUnit =
|
|
|
|
|
+ contractUnitTypeKeyAndUnitMap.getOrDefault(queryListResDto.getId() + "-" + EntTypeEnum.SUPPLIER.getCode()
|
|
|
|
|
+ , new KwcContractTradeUnit());
|
|
|
|
|
+ KwcContractTradeUnit contractTradeUnit =
|
|
|
|
|
+ contractUnitTypeKeyAndUnitMap.getOrDefault(queryListResDto.getId() + "-" + EntTypeEnum.PURCHASER.getCode()
|
|
|
|
|
+ , new KwcContractTradeUnit());
|
|
|
|
|
+ queryListResVo.setProvideEntId(String.valueOf(kwcContractTradeUnit.getEntId()));
|
|
|
|
|
+ queryListResVo.setPurchaseEntId(String.valueOf(contractTradeUnit.getEntId()));
|
|
|
|
|
+ queryListResVo.setProvideEntName(kwcContractTradeUnit.getFirmName());
|
|
|
|
|
+ queryListResVo.setPurchaseEntName(contractTradeUnit.getFirmName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
queryListResVo.setTradingName(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), String.valueOf(queryListResDto.getTrading())));
|
|
queryListResVo.setTradingName(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), String.valueOf(queryListResDto.getTrading())));
|
|
|
queryListResVo.setStatusName(Objects.requireNonNull(ContractStatusEnum.getName(queryListResDto.getStatus())).getName());
|
|
queryListResVo.setStatusName(Objects.requireNonNull(ContractStatusEnum.getName(queryListResDto.getStatus())).getName());
|
|
|
queryListResVo.setSigningWayName(DictEnum.getLabel(DictTypeEnum.SIGNING_TYPE.getType(), queryListResDto.getSigningWay()));
|
|
queryListResVo.setSigningWayName(DictEnum.getLabel(DictTypeEnum.SIGNING_TYPE.getType(), queryListResDto.getSigningWay()));
|
|
@@ -892,7 +926,7 @@ public class KwcContractTradeService {
|
|
|
throw new SystemException(HttpStatus.SUCCESS_CODE, "暂无数据,请确认!");
|
|
throw new SystemException(HttpStatus.SUCCESS_CODE, "暂无数据,请确认!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- List<QueryListResVo> list = getQueryListResVos(queryListResDtos,null);
|
|
|
|
|
|
|
+ List<QueryListResVo> list = getQueryListResVos(queryListResDtos,null,null);
|
|
|
List<TradeListExport> dataList = BeanUtils.copyToList(list, TradeListExport.class);
|
|
List<TradeListExport> dataList = BeanUtils.copyToList(list, TradeListExport.class);
|
|
|
ExcelUtil.downData(response, TradeListExport.class, dataList);
|
|
ExcelUtil.downData(response, TradeListExport.class, dataList);
|
|
|
}
|
|
}
|
|
@@ -913,7 +947,7 @@ public class KwcContractTradeService {
|
|
|
if (CollectionUtils.isEmpty(queryListResDtos)) {
|
|
if (CollectionUtils.isEmpty(queryListResDtos)) {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
- return getQueryListResVos(queryListResDtos,null);
|
|
|
|
|
|
|
+ return getQueryListResVos(queryListResDtos,null,null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1458,7 +1492,7 @@ public class KwcContractTradeService {
|
|
|
return tradeBaseInfo;
|
|
return tradeBaseInfo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public PageDataResult<QueryListResVo> queryTradeListByPage(QueryTradeReq req) {
|
|
|
|
|
|
|
+ public List<QueryListResVo> queryTradeListByPage(QueryTradeReq req) {
|
|
|
|
|
|
|
|
Long entId = StringUtils.isNotBlank(req.getEntId()) ? Long.valueOf(req.getEntId()) : null;
|
|
Long entId = StringUtils.isNotBlank(req.getEntId()) ? Long.valueOf(req.getEntId()) : null;
|
|
|
Set<Long> entIds = Sets.newHashSet();
|
|
Set<Long> entIds = Sets.newHashSet();
|
|
@@ -1469,7 +1503,7 @@ public class KwcContractTradeService {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getSupplyEntId())) {
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getSupplyEntId())) {
|
|
|
entIds.add(Long.valueOf(req.getSupplyEntId()));
|
|
entIds.add(Long.valueOf(req.getSupplyEntId()));
|
|
|
}
|
|
}
|
|
|
- Set<Long> contractIds = Sets.newHashSet();
|
|
|
|
|
|
|
+ Set<Long> contractIds = null;
|
|
|
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)){
|
|
@@ -1479,6 +1513,7 @@ public class KwcContractTradeService {
|
|
|
List<Long> allEnt = Lists.newArrayList();
|
|
List<Long> allEnt = Lists.newArrayList();
|
|
|
if (StringUtils.isBlank(req.getEntId())) {
|
|
if (StringUtils.isBlank(req.getEntId())) {
|
|
|
req.setEntId(String.valueOf(LoginUserHolder.getEntId()));
|
|
req.setEntId(String.valueOf(LoginUserHolder.getEntId()));
|
|
|
|
|
+ allEnt.add(LoginUserHolder.getEntId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (Objects.nonNull(entId)) {
|
|
if (Objects.nonNull(entId)) {
|
|
@@ -1492,15 +1527,16 @@ public class KwcContractTradeService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ PageHelper.startPage(req.getPageNum(), req.getPageSize());
|
|
|
//分页查询合同信息
|
|
//分页查询合同信息
|
|
|
- IPage<KwcContractTrade> page = kwcContractTradeRepository.queryTradeListByPage(allEnt,
|
|
|
|
|
|
|
+ List<KwcContractTrade> records = kwcContractTradeRepository.queryTradeListByPageList(allEnt,
|
|
|
req.getContractCode(),
|
|
req.getContractCode(),
|
|
|
req.getContractName(),
|
|
req.getContractName(),
|
|
|
|
|
+ req.getSupplementCode(),
|
|
|
contractIds, req.getStatus(), req.getPageNum(), req.getPageSize());
|
|
contractIds, req.getStatus(), req.getPageNum(), req.getPageSize());
|
|
|
- List<KwcContractTrade> records = page.getRecords();
|
|
|
|
|
|
|
+ // List<KwcContractTrade> records = page.getRecords();
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isEmpty(records)){
|
|
if (org.apache.commons.collections4.CollectionUtils.isEmpty(records)){
|
|
|
- return PageDataResult.empty(req.getPageNum(), req.getPageSize());
|
|
|
|
|
|
|
+ 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
|
|
@@ -1534,10 +1570,18 @@ public class KwcContractTradeService {
|
|
|
List<QueryListResVo> queryListResVos = records.stream()
|
|
List<QueryListResVo> queryListResVos = records.stream()
|
|
|
.map(t -> getQueryListResVo(t, finalContractUnitTypeKeyAndUnitMap, finalPidIdAndTradeMap, longUserCacheResDtoMap))
|
|
.map(t -> getQueryListResVo(t, finalContractUnitTypeKeyAndUnitMap, finalPidIdAndTradeMap, longUserCacheResDtoMap))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getPurchaseEntId())){
|
|
|
|
|
+ queryListResVos = queryListResVos.stream()
|
|
|
|
|
+ .filter(x-> org.apache.commons.lang3.StringUtils.equals(x.getPurchaseEntId(), req.getPurchaseEntId()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- return PageDataResult.of(page, queryListResVos);
|
|
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getSupplyEntId())){
|
|
|
|
|
+ queryListResVos = queryListResVos.stream()
|
|
|
|
|
+ .filter(x-> org.apache.commons.lang3.StringUtils.equals(x.getProvideEntId(), req.getSupplyEntId()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ return queryListResVos;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@NotNull
|
|
@NotNull
|