|
|
@@ -1,19 +1,39 @@
|
|
|
package com.sckw.order.serivce;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
+import com.sckw.core.exception.BusinessException;
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
+import com.sckw.core.model.vo.TableBottom;
|
|
|
import com.sckw.core.model.vo.TableStatisticRes;
|
|
|
+import com.sckw.core.model.vo.TableTop;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
+import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.order.dao.KwoTransportDemandMapper;
|
|
|
import com.sckw.order.model.KwoTransportDemand;
|
|
|
import com.sckw.order.model.dto.TransportDemandExport;
|
|
|
import com.sckw.order.model.vo.req.*;
|
|
|
import com.sckw.order.model.vo.res.TransportDemandDetailRes;
|
|
|
+import com.sckw.order.model.vo.res.TransportDemandListRes;
|
|
|
+import com.sckw.order.model.vo.res.TransportDemandSquaresListRes;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @desc: 运需service
|
|
|
@@ -27,6 +47,9 @@ public class KwoTransportDemandService {
|
|
|
|
|
|
private final KwoTransportDemandMapper kwoTransportDemandMapper;
|
|
|
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @desc: 添加草稿
|
|
|
@@ -37,7 +60,7 @@ public class KwoTransportDemandService {
|
|
|
*/
|
|
|
public void addDraft(AddTransportDemandDraftParam param) {
|
|
|
KwoTransportDemand transportDemand = BeanUtils.copyProperties(param, KwoTransportDemand.class);
|
|
|
- transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(0);
|
|
|
+ transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_0.getValue()));
|
|
|
kwoTransportDemandMapper.insert(transportDemand);
|
|
|
}
|
|
|
|
|
|
@@ -49,7 +72,9 @@ public class KwoTransportDemandService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void addShelves(AddTransportDemandParam param) {
|
|
|
-
|
|
|
+ KwoTransportDemand transportDemand = BeanUtils.copyProperties(param, KwoTransportDemand.class);
|
|
|
+ transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()));
|
|
|
+ kwoTransportDemandMapper.insert(transportDemand);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -60,7 +85,28 @@ public class KwoTransportDemandService {
|
|
|
* @return: com.sckw.order.model.vo.res.TransportDemandDetailRes
|
|
|
*/
|
|
|
public TransportDemandDetailRes detail(Long id) {
|
|
|
- return null;
|
|
|
+ KwoTransportDemand transportDemand = getById(id);
|
|
|
+ if (Objects.isNull(transportDemand)) {
|
|
|
+ throw new BusinessException("数据不存在!");
|
|
|
+ }
|
|
|
+ TransportDemandDetailRes res = BeanUtils.copyProperties(transportDemand, TransportDemandDetailRes.class);
|
|
|
+ res.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), res.getGoodsType()))
|
|
|
+ .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), res.getTrading()))
|
|
|
+ .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(res.getStatus())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 根据id获取
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-26 11:27
|
|
|
+ * @Param id:
|
|
|
+ * @return: com.sckw.order.model.KwoTransportDemand
|
|
|
+ */
|
|
|
+ private KwoTransportDemand getById(Long id) {
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwoTransportDemand::getId, id).eq(KwoTransportDemand::getDelFlag, Global.NO).last("LIMIT 1");
|
|
|
+ return kwoTransportDemandMapper.selectOne(wrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -71,7 +117,55 @@ public class KwoTransportDemandService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void update(UpdateTransportDemandParam param) {
|
|
|
+ KwoTransportDemand demand = getById(param.getId());
|
|
|
+ if (Objects.isNull(demand)) {
|
|
|
+ throw new BusinessException("数据不存在!");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(demand.getEntId(), LoginUserHolder.getEntId())) {
|
|
|
+ throw new BusinessException("无操作权限!");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(String.valueOf(demand.getStatus()), DictEnum.TRANSPORT_DEMAND_STATUS_0.getValue())) {
|
|
|
+ checkParams(param);
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, demand);
|
|
|
+ kwoTransportDemandMapper.updateById(demand);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc: 参数校验
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-26 11:30
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ private void checkParams(UpdateTransportDemandParam param) {
|
|
|
+ if (StringUtils.isBlank(param.getName())) {
|
|
|
+ throw new BusinessException("商品名称不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getPrice())) {
|
|
|
+ throw new BusinessException("运需单价不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getAmount())) {
|
|
|
+ throw new BusinessException("运输总量不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getContacts())) {
|
|
|
+ throw new BusinessException("联系人姓名不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getPhone())) {
|
|
|
+ throw new BusinessException("联系人电话不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getLoadAreaCode())) {
|
|
|
+ throw new BusinessException("装货区域code不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getLoadAreaName())) {
|
|
|
+ throw new BusinessException("装货区域名称不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getUnloadAreaCode())) {
|
|
|
+ throw new BusinessException("卸货区域code不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getUnloadAreaName())) {
|
|
|
+ throw new BusinessException("卸货区域名称不能为空");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -82,7 +176,68 @@ public class KwoTransportDemandService {
|
|
|
* @return: com.sckw.core.model.page.PageResult
|
|
|
*/
|
|
|
public PageResult select(SelectTransportDemandParam param) {
|
|
|
- return null;
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(BeanUtils.copyProperties(param, ExportTransportDemandParam.class));
|
|
|
+ IPage<KwoTransportDemand> page = new Page<>(param.getPage(), param.getPageSize());
|
|
|
+ IPage<KwoTransportDemand> demandPage = kwoTransportDemandMapper.selectPage(page, wrapper);
|
|
|
+ List<KwoTransportDemand> list = demandPage.getRecords();
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return PageResult.build(param.getPage(), param.getPageSize(), demandPage.getTotal(), Collections.emptyList());
|
|
|
+ }
|
|
|
+ List<TransportDemandListRes> result = Lists.newArrayList();
|
|
|
+ list.forEach(e -> {
|
|
|
+ TransportDemandListRes demand = BeanUtils.copyProperties(e, TransportDemandListRes.class);
|
|
|
+ demand.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
|
|
|
+ .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
|
|
|
+ .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(e.getStatus())))
|
|
|
+ .setLoadAddress(e.getLoadAreaName() + e.getLoadDetailAddress())
|
|
|
+ .setUnloadAddress(e.getUnloadAreaName() + e.getUnloadDetailAddress());
|
|
|
+ result.add(demand);
|
|
|
+ });
|
|
|
+ return PageResult.build(param.getPage(), param.getPageSize(), demandPage.getTotal(), result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 构建wrapper
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-26 14:00
|
|
|
+ * @Param param:
|
|
|
+ * @return: com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.sckw.order.model.KwoTransportDemand>
|
|
|
+ */
|
|
|
+ private LambdaQueryWrapper<KwoTransportDemand> buildWrapper(ExportTransportDemandParam param) {
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
|
|
|
+ if (StringUtils.isNotBlank(param.getIds())) {
|
|
|
+ List<Long> ids = StringUtils.splitStrToList(param.getIds(), ",", Long.class);
|
|
|
+ wrapper.in(KwoTransportDemand::getId, ids).orderByDesc(KwoTransportDemand::getCreateTime);
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(param.getEndCreateTime())) {
|
|
|
+ wrapper.le(KwoTransportDemand::getCreateTime, DateUtil.offsetDay(param.getEndCreateTime(), 1));
|
|
|
+ }
|
|
|
+ wrapper.ge(Objects.nonNull(param.getStartCreateTime()), KwoTransportDemand::getCreateTime, param.getStartCreateTime())
|
|
|
+ .eq(Objects.nonNull(param.getStatus()), KwoTransportDemand::getStatus, param.getStatus())
|
|
|
+ .like(Objects.nonNull(param.getKeywords()), KwoTransportDemand::getName, param.getKeywords());
|
|
|
+ Integer loadCode = param.getLoadAreaCode();
|
|
|
+ if (Objects.nonNull(loadCode) && Objects.nonNull(param.getLoadAreaLevel())) {
|
|
|
+ switch (param.getLoadAreaLevel()) {
|
|
|
+ case 1 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getLoadAreaCode, Integer.valueOf(String.valueOf(loadCode).substring(0, 2)));
|
|
|
+ case 2 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getLoadAreaCode, Integer.valueOf(String.valueOf(loadCode).substring(0, 4)));
|
|
|
+ case 3 -> wrapper.eq(KwoTransportDemand::getLoadAreaCode, loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer unloadCode = param.getUnloadAreaCode();
|
|
|
+ if (Objects.nonNull(unloadCode) && Objects.nonNull(param.getLoadAreaLevel())) {
|
|
|
+ switch (param.getUnloadAreaLevel()) {
|
|
|
+ case 1 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getUnloadAreaCode, Integer.valueOf(String.valueOf(unloadCode).substring(0, 2)));
|
|
|
+ case 2 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getUnloadAreaCode, Integer.valueOf(String.valueOf(unloadCode).substring(0, 4)));
|
|
|
+ case 3 -> wrapper.eq(KwoTransportDemand::getUnloadAreaCode, unloadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return wrapper.orderByDesc(KwoTransportDemand::getCreateTime);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -93,7 +248,24 @@ public class KwoTransportDemandService {
|
|
|
* @return: com.sckw.core.model.vo.TableStatisticRes
|
|
|
*/
|
|
|
public TableStatisticRes statistic(StatisticTransportDemandParam param) {
|
|
|
- return null;
|
|
|
+ TableStatisticRes res = new TableStatisticRes();
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(BeanUtils.copyProperties(param, ExportTransportDemandParam.class));
|
|
|
+ List<KwoTransportDemand> demands = kwoTransportDemandMapper.selectList(wrapper);
|
|
|
+ Map<Integer, List<KwoTransportDemand>> map = demands.stream().collect(Collectors.groupingBy(KwoTransportDemand::getStatus));
|
|
|
+ List<TableTop> tableTops = new ArrayList<>();
|
|
|
+ List<DictEnum> enums = DictEnum.getEnumsByType(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType());
|
|
|
+ enums.forEach(e -> {
|
|
|
+ Integer value = Integer.valueOf(e.getValue());
|
|
|
+ List<KwoTransportDemand> list = map.get(value);
|
|
|
+ int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
|
|
|
+ TableTop tableTop = new TableTop();
|
|
|
+ tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
|
|
|
+ tableTops.add(tableTop);
|
|
|
+ });
|
|
|
+ TableBottom tableBottom = new TableBottom();
|
|
|
+ tableBottom.setTotal(CollectionUtils.isEmpty(demands) ? 0 : demands.size());
|
|
|
+ res.setTableTops(tableTops).setTableBottom(tableBottom);
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -104,7 +276,24 @@ public class KwoTransportDemandService {
|
|
|
* @return: java.util.List<com.sckw.order.model.dto.TransportDemandExport>
|
|
|
*/
|
|
|
public List<TransportDemandExport> export(ExportTransportDemandParam param) {
|
|
|
- return null;
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(param);
|
|
|
+ List<KwoTransportDemand> demands = kwoTransportDemandMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(demands)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<TransportDemandExport> result = Lists.newArrayList();
|
|
|
+ demands.forEach(e -> {
|
|
|
+ TransportDemandExport export = BeanUtils.copyProperties(e, TransportDemandExport.class);
|
|
|
+ export.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
|
|
|
+ .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(e.getStatus())))
|
|
|
+ .setLoadAddress(e.getLoadAreaName() + e.getLoadDetailAddress())
|
|
|
+ .setUnloadAddress(e.getUnloadAreaName() + e.getUnloadDetailAddress())
|
|
|
+ .setDeadline(Objects.isNull(e.getDeadline()) ? null : DateUtil.dateToStr(e.getDeadline()))
|
|
|
+ .setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()))
|
|
|
+ .setUpdateTime(Objects.isNull(e.getUpdateTime()) ? null : DateUtil.getDateTime(e.getUpdateTime()));
|
|
|
+ result.add(export);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -115,7 +304,22 @@ public class KwoTransportDemandService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void putOnShelves(Long id) {
|
|
|
-
|
|
|
+ KwoTransportDemand demand = getById(id);
|
|
|
+ if (Objects.isNull(demand)) {
|
|
|
+ throw new BusinessException("数据不存在!");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(demand.getEntId(), LoginUserHolder.getEntId())) {
|
|
|
+ throw new BusinessException("无操作权限!");
|
|
|
+ }
|
|
|
+ if (Objects.equals(String.valueOf(demand.getStatus()), DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue())) {
|
|
|
+ throw new BusinessException("上架操作仅针对“已下架”“草稿”状态的单据!");
|
|
|
+ }
|
|
|
+ if (Objects.equals(String.valueOf(demand.getStatus()), DictEnum.TRANSPORT_DEMAND_STATUS_0.getValue())) {
|
|
|
+ UpdateTransportDemandParam param = BeanUtils.copyProperties(demand, UpdateTransportDemandParam.class);
|
|
|
+ checkParams(param);
|
|
|
+ }
|
|
|
+ demand.setStatus(Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()));
|
|
|
+ kwoTransportDemandMapper.updateById(demand);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -126,7 +330,18 @@ public class KwoTransportDemandService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void batchTakeOffShelves(List<Long> ids) {
|
|
|
-
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(KwoTransportDemand::getId, ids)
|
|
|
+ .eq(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
|
|
|
+ .eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
|
|
|
+ List<KwoTransportDemand> list = kwoTransportDemandMapper.selectList(wrapper);
|
|
|
+ if (!Objects.equals(ids.size(), list.size())) {
|
|
|
+ throw new BusinessException("下架操作仅针对“已上架”状态的单据");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<KwoTransportDemand> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_2.getValue()))
|
|
|
+ .in(KwoTransportDemand::getId, ids);
|
|
|
+ kwoTransportDemandMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -137,7 +352,16 @@ public class KwoTransportDemandService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void batchDelete(List<Long> ids) {
|
|
|
-
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(KwoTransportDemand::getId, ids).in(KwoTransportDemand::getStatus, 0, 2)
|
|
|
+ .eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
|
|
|
+ List<KwoTransportDemand> list = kwoTransportDemandMapper.selectList(wrapper);
|
|
|
+ if (!Objects.equals(ids.size(), list.size())) {
|
|
|
+ throw new BusinessException("删除操作仅针对“已下架”“草稿”状态的单据");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<KwoTransportDemand> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(KwoTransportDemand::getDelFlag, Global.YES).in(KwoTransportDemand::getId, ids);
|
|
|
+ kwoTransportDemandMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -148,6 +372,59 @@ public class KwoTransportDemandService {
|
|
|
* @return: com.sckw.core.model.page.PageResult
|
|
|
*/
|
|
|
public PageResult demandSquaresList(TransportDemandSquaresParam param) {
|
|
|
- return null;
|
|
|
+ Page<KwoTransportDemand> page = new Page<>(param.getPage(), param.getPageSize());
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(CollectionUtils.isNotEmpty(param.getGoodsTypes()), KwoTransportDemand::getGoodsType, param.getGoodsTypes())
|
|
|
+ .eq(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
|
|
|
+ .eq(KwoTransportDemand::getDelFlag, Global.NO);
|
|
|
+ Integer loadCode = param.getLoadAreaCode();
|
|
|
+ if (Objects.nonNull(loadCode) && Objects.nonNull(param.getLoadAreaLevel())) {
|
|
|
+ switch (param.getLoadAreaLevel()) {
|
|
|
+ case 1 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getLoadAreaCode, Integer.valueOf(String.valueOf(loadCode).substring(0, 2)));
|
|
|
+ case 2 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getLoadAreaCode, Integer.valueOf(String.valueOf(loadCode).substring(0, 4)));
|
|
|
+ case 3 -> wrapper.eq(KwoTransportDemand::getLoadAreaCode, loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer unloadCode = param.getUnloadAreaCode();
|
|
|
+ if (Objects.nonNull(unloadCode) && Objects.nonNull(param.getLoadAreaLevel())) {
|
|
|
+ switch (param.getUnloadAreaLevel()) {
|
|
|
+ case 1 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getUnloadAreaCode, Integer.valueOf(String.valueOf(unloadCode).substring(0, 2)));
|
|
|
+ case 2 ->
|
|
|
+ wrapper.likeRight(KwoTransportDemand::getUnloadAreaCode, Integer.valueOf(String.valueOf(unloadCode).substring(0, 4)));
|
|
|
+ case 3 -> wrapper.eq(KwoTransportDemand::getUnloadAreaCode, unloadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(param.getKeywords())) {
|
|
|
+ List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByName(param.getKeywords());
|
|
|
+ List<Long> entIds = entList.stream().map(EntCacheResDto::getId).toList();
|
|
|
+ if (CollectionUtils.isNotEmpty(entIds)) {
|
|
|
+ wrapper.and(e -> e.in(KwoTransportDemand::getEntId, entIds).or().like(KwoTransportDemand::getName, param.getKeywords()));
|
|
|
+ } else {
|
|
|
+ wrapper.like(KwoTransportDemand::getName, param.getKeywords());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(KwoTransportDemand::getCreateTime);
|
|
|
+ Page<KwoTransportDemand> kwpGoodsPage = kwoTransportDemandMapper.selectPage(page, wrapper);
|
|
|
+ List<KwoTransportDemand> list = kwpGoodsPage.getRecords();
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return PageResult.build(param.getPage(), param.getPageSize(), kwpGoodsPage.getTotal(), Collections.emptyList());
|
|
|
+ }
|
|
|
+ List<Long> entIds = list.stream().map(KwoTransportDemand::getEntId).toList();
|
|
|
+ Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(entIds);
|
|
|
+ List<TransportDemandSquaresListRes> result = Lists.newArrayList();
|
|
|
+ list.forEach(e -> {
|
|
|
+ TransportDemandSquaresListRes res = BeanUtils.copyProperties(e, TransportDemandSquaresListRes.class);
|
|
|
+ EntCacheResDto ent = entMap.get(e.getEntId());
|
|
|
+ res.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
|
|
|
+ .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
|
|
|
+ .setLoadAddress(e.getLoadAreaName() + e.getLoadDetailAddress())
|
|
|
+ .setUnloadAddress(e.getUnloadAreaName() + e.getUnloadDetailAddress())
|
|
|
+ .setDemandUnit(Objects.nonNull(ent) ? ent.getFirmName() : null);
|
|
|
+ result.add(res);
|
|
|
+ });
|
|
|
+ return PageResult.build(param.getPage(), param.getPageSize(), kwpGoodsPage.getTotal(), result);
|
|
|
}
|
|
|
}
|