|
|
@@ -23,8 +23,12 @@ import com.sckw.order.model.vo.req.UpdateWantBuyParam;
|
|
|
import com.sckw.order.model.vo.req.WantBuyDels;
|
|
|
import com.sckw.order.model.vo.req.WantBuySelectParam;
|
|
|
import com.sckw.order.model.vo.res.*;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -41,6 +45,9 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
|
public class KwpWantBuyService {
|
|
|
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
private final KwpWantBuyMapper kwpWantBuyMapper;
|
|
|
|
|
|
private final KwpWantBuyTradingMapper kwpWantBuyTradingMapper;
|
|
|
@@ -49,65 +56,108 @@ public class KwpWantBuyService {
|
|
|
private final KwoWantBuyTradingService kwoWantBuyTradingService;
|
|
|
|
|
|
public PageRes<WantBuySelectRes> buyHallList(WantBuySelectParam wantBuySelectParam){
|
|
|
- //如果有求购方式的查询条件,需要先查询出求购方式的id
|
|
|
+ // 如果有求购方式的查询条件,需要先查询出求购方式的id
|
|
|
if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
|
|
|
- List<Long> longList = stringToLongList(wantBuySelectParam.getTrading());
|
|
|
+ List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
|
|
|
wantBuySelectParam.setTradings(longList);
|
|
|
}
|
|
|
+ // 商品分类筛选处理
|
|
|
+ if (StringUtils.isNotBlank(wantBuySelectParam.getGoodsType()) && StringUtils.isNotBlank(wantBuySelectParam.getGoodsTypeValue())) {
|
|
|
+ List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
|
|
|
+ wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 分页查询求购列表
|
|
|
PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
|
|
|
List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.queryBuyHallList(wantBuySelectParam);
|
|
|
+
|
|
|
if (CollectionUtils.isEmpty(wantBuyDto)) {
|
|
|
return new PageRes<>();
|
|
|
}
|
|
|
+
|
|
|
+ // 获取供应企业信息
|
|
|
+ List<Long> supplyEntIds = wantBuyDto.stream()
|
|
|
+ .map(WantBuySelectRes::getEntId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ // 通过企业id查询企业信息
|
|
|
+ List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
+ Map<Long, String> entMap = entList.stream()
|
|
|
+ .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
+
|
|
|
+ // 对求购列表进行数据处理
|
|
|
wantBuyDto.forEach(wantBuySelectRes -> {
|
|
|
List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
|
|
|
.map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
|
|
|
.collect(Collectors.toList());
|
|
|
- String tradingsString = String.join(Global.COMMA, tradings);
|
|
|
- wantBuySelectRes.setTradings(tradingsString);
|
|
|
-
|
|
|
- String statusLabel = DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus()));
|
|
|
- wantBuySelectRes.setStatusLabel(statusLabel);
|
|
|
+ wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
|
|
|
+ wantBuySelectRes.setGoodsType(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), wantBuySelectRes.getGoodsType()));
|
|
|
+ wantBuySelectRes.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus())));
|
|
|
+ wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
|
|
|
});
|
|
|
+
|
|
|
return new PageRes<>(new PageInfo<>(wantBuyDto));
|
|
|
}
|
|
|
|
|
|
public PageRes<WantBuySelectRes> select(WantBuySelectParam wantBuySelectParam) {
|
|
|
+
|
|
|
if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
|
|
|
- List<Long> longList = stringToLongList(wantBuySelectParam.getTrading());
|
|
|
+ List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
|
|
|
wantBuySelectParam.setTradings(longList);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(wantBuySelectParam.getStatus())) {
|
|
|
- List<String> stringList = Arrays.asList(wantBuySelectParam.getStatus().split(","));
|
|
|
- wantBuySelectParam.setStatuss(stringList);
|
|
|
+ wantBuySelectParam.setStatus(wantBuySelectParam.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ //商品分类筛选处理
|
|
|
+ if (StringUtils.isNotBlank(wantBuySelectParam.getGoodsType()) && StringUtils.isNotBlank(wantBuySelectParam.getGoodsTypeValue())) {
|
|
|
+ List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
|
|
|
+ wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
|
|
|
}
|
|
|
PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
|
|
|
List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.pageSelect(wantBuySelectParam);
|
|
|
+ System.out.println(wantBuyDto);
|
|
|
if (CollectionUtils.isEmpty(wantBuyDto)) {
|
|
|
return new PageRes<>();
|
|
|
}
|
|
|
+ // 获取供应企业信息
|
|
|
+ List<Long> supplyEntIds = wantBuyDto.stream()
|
|
|
+ .map(WantBuySelectRes::getEntId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ // 通过企业id查询企业信息
|
|
|
+ List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
+ Map<Long, String> entMap = entList.stream()
|
|
|
+ .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
//把查询出来的集合wantBuyTradings里面对的tranding 转成字符串放在String里面
|
|
|
wantBuyDto.forEach(wantBuySelectRes -> {
|
|
|
List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
|
|
|
.map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
|
|
|
.collect(Collectors.toList());
|
|
|
- String tradingsString = String.join(Global.COMMA, tradings);
|
|
|
- wantBuySelectRes.setTradings(tradingsString);
|
|
|
-
|
|
|
- String statusLabel = DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus()));
|
|
|
- wantBuySelectRes.setStatusLabel(statusLabel);
|
|
|
+ wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
|
|
|
+ wantBuySelectRes.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), wantBuySelectRes.getGoodsType()));
|
|
|
+ wantBuySelectRes.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus())));
|
|
|
+ wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
|
|
|
});
|
|
|
|
|
|
return new PageRes<>(new PageInfo<>(wantBuyDto));
|
|
|
}
|
|
|
|
|
|
- private List<Long> stringToLongList(String str) {
|
|
|
+ private List<String> goodsTypeHandle(WantBuySelectParam wantBuySelectParam)
|
|
|
+ {
|
|
|
+ List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(wantBuySelectParam.getGoodsType(), wantBuySelectParam.getGoodsTypeValue());
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsTypeList)) {
|
|
|
+ return goodsTypeList.stream().map(SysDictResDto::getValue).toList();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> stringToLongList(String str) {
|
|
|
if (StringUtils.isBlank(str)) {
|
|
|
return null;
|
|
|
}
|
|
|
- return Arrays.stream(str.split(","))
|
|
|
- .map(Long::parseLong)
|
|
|
- .collect(Collectors.toList());
|
|
|
+// 使用逗号分隔字符串,并去除两端空格
|
|
|
+ String[] stringArray = str.split(Global.COMMA);
|
|
|
+ return Arrays.asList(stringArray);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -376,12 +426,16 @@ public class KwpWantBuyService {
|
|
|
*/
|
|
|
public Map statistic(WantBuySelectParam params) {
|
|
|
if (StringUtils.isNotBlank(params.getTrading())) {
|
|
|
- List<Long> longList = stringToLongList(params.getTrading());
|
|
|
+ List<String> longList = stringToLongList(params.getTrading());
|
|
|
params.setTradings(longList);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(params.getStatus())) {
|
|
|
- List<String> stringList = Arrays.asList(params.getStatus().split(","));
|
|
|
- params.setStatuss(stringList);
|
|
|
+ params.setStatus(params.getStatus());
|
|
|
+ }
|
|
|
+ //商品分类筛选处理
|
|
|
+ if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
|
|
|
+ List<String> goodsTypes = goodsTypeHandle(params);
|
|
|
+ params.setGoodsTypeValueSearch(goodsTypes);
|
|
|
}
|
|
|
/**统计数据**/
|
|
|
List<TableTopRes> counts = kwpWantBuyMapper.statisticsCount(params);
|