|
|
@@ -1,6 +1,5 @@
|
|
|
package com.sckw.report.service;
|
|
|
|
|
|
-import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.model.vo.TableBottom;
|
|
|
@@ -12,11 +11,14 @@ import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.mongo.model.SckwTradeOrder;
|
|
|
+import com.sckw.report.enums.TOrderStatusEnum;
|
|
|
import com.sckw.report.service.param.*;
|
|
|
import com.sckw.report.service.vo.OrderListRes;
|
|
|
import com.sckw.report.service.vo.TradeOrderAppStatisticVO;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
|
|
@@ -43,6 +45,9 @@ public class KwOrderService {
|
|
|
|
|
|
private final MongoTemplate mongoTemplate;
|
|
|
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
/**
|
|
|
* @desc: 贸易订单详情
|
|
|
* @author: yzc
|
|
|
@@ -69,7 +74,8 @@ public class KwOrderService {
|
|
|
*/
|
|
|
public PageResult tradeOrderSelect(TradeOrderListSelectParam params) {
|
|
|
Criteria criteria = buildCriteria(params, false);
|
|
|
- return getResult(criteria, params.getPage(), params.getPageSize());
|
|
|
+ Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
|
|
|
+ return getResult(criteria, sort, params.getPage(), params.getPageSize());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -77,18 +83,43 @@ public class KwOrderService {
|
|
|
* @author: yzc
|
|
|
* @date: 2023-07-20 15:02
|
|
|
* @Param criteria:
|
|
|
+ * @Param sort:
|
|
|
* @Param page:
|
|
|
* @Param pageSize:
|
|
|
* @return: com.sckw.core.model.page.PageResult
|
|
|
*/
|
|
|
- public PageResult getResult(Criteria criteria, Integer page, Integer pageSize) {
|
|
|
+ public PageResult getResult(Criteria criteria, Sort sort, Integer page, Integer pageSize) {
|
|
|
Query query = new Query();
|
|
|
query.addCriteria(criteria);
|
|
|
long count = mongoTemplate.count(query, SckwTradeOrder.class);
|
|
|
- Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
|
|
|
SpringDataPageAble pageAble = new SpringDataPageAble(page, pageSize, sort);
|
|
|
query.with(pageAble);
|
|
|
List<SckwTradeOrder> list = mongoTemplate.find(query, SckwTradeOrder.class);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return PageResult.build(page, pageSize, count, Collections.emptyList());
|
|
|
+ }
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(
|
|
|
+ DictTypeEnum.TORDER_STATUS.getType(), DictTypeEnum.TRADE_TYPE.getType(), DictTypeEnum.DELIVERY_TYPE.getType(),
|
|
|
+ DictTypeEnum.PICKUP_TYPE.getType(), DictTypeEnum.TORDER_SOURCE.getType()));
|
|
|
+ Map<String, String> statusMap, tradeMap, deliveryMap, pickupMap, sourceMap;
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
+ statusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_STATUS.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.TORDER_STATUS.getType()) : new HashMap<>();
|
|
|
+ tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
|
|
|
+ deliveryMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.DELIVERY_TYPE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.DELIVERY_TYPE.getType()) : new HashMap<>();
|
|
|
+ pickupMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.PICKUP_TYPE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.PICKUP_TYPE.getType()) : new HashMap<>();
|
|
|
+ sourceMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_SOURCE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.TORDER_SOURCE.getType()) : new HashMap<>();
|
|
|
+ } else {
|
|
|
+ statusMap = new HashMap<>();
|
|
|
+ tradeMap = new HashMap<>();
|
|
|
+ deliveryMap = new HashMap<>();
|
|
|
+ pickupMap = new HashMap<>();
|
|
|
+ sourceMap = new HashMap<>();
|
|
|
+ }
|
|
|
List<OrderListRes> result = new ArrayList<>();
|
|
|
list.forEach(e -> {
|
|
|
BigDecimal actualAmount = Objects.isNull(e.getActualAmount()) ? BigDecimal.ZERO : BigDecimal.valueOf(e.getActualAmount());
|
|
|
@@ -98,14 +129,14 @@ public class KwOrderService {
|
|
|
String unloadCityName = Objects.isNull(e.getUnloadCityName()) ? "" : e.getUnloadCityName();
|
|
|
String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
|
|
|
String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
|
|
|
- order.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
|
|
|
- .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
|
|
|
- .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
|
|
|
- .setDeliveryTypeLabel(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
|
|
|
- .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
|
|
|
- .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
|
|
|
- .setSourceLabel(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
|
|
|
- .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
|
|
|
+ order.setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
|
|
|
+ .setTradingLabel(tradeMap.get(e.getTrading()))
|
|
|
+ .setTrading(tradeMap.get(e.getTrading()))
|
|
|
+ .setDeliveryTypeLabel(deliveryMap.get(e.getDeliveryType()))
|
|
|
+ .setDeliveryType(deliveryMap.get(e.getDeliveryType()))
|
|
|
+ .setPickupTypeLabel(pickupMap.get(e.getPickupType()))
|
|
|
+ .setSourceLabel(sourceMap.get(e.getSource()))
|
|
|
+ .setSource(sourceMap.get(e.getSource()))
|
|
|
.setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
|
|
|
.setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
|
|
|
.setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount()))
|
|
|
@@ -255,7 +286,7 @@ public class KwOrderService {
|
|
|
*/
|
|
|
public TableStatisticRes tradeOrderStatistic(TradeOrderListStatisticParam params) {
|
|
|
Criteria criteria = buildCriteria(params, true);
|
|
|
- return getTableStatistic(criteria, DictEnum.getEnumsByType(DictTypeEnum.TORDER_STATUS.getType()));
|
|
|
+ return getTableStatistic(criteria, TOrderStatusEnum.getSortList());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -266,7 +297,7 @@ public class KwOrderService {
|
|
|
* @Param enums:
|
|
|
* @return: com.sckw.core.model.vo.TableStatisticRes
|
|
|
*/
|
|
|
- public TableStatisticRes getTableStatistic(Criteria criteria, List<DictEnum> enums) {
|
|
|
+ public TableStatisticRes getTableStatistic(Criteria criteria, List<TOrderStatusEnum> enums) {
|
|
|
TableStatisticRes res = new TableStatisticRes();
|
|
|
Aggregation aggregation = Aggregation.newAggregation(
|
|
|
Aggregation.match(criteria),
|
|
|
@@ -283,11 +314,11 @@ public class KwOrderService {
|
|
|
}
|
|
|
List<TableTop> list = new ArrayList<>();
|
|
|
int count = 0;
|
|
|
- for (DictEnum e : enums) {
|
|
|
- Integer value = Integer.valueOf(e.getValue());
|
|
|
+ for (TOrderStatusEnum e : enums) {
|
|
|
+ Integer value = e.getCode();
|
|
|
int total = Objects.isNull(map.get(value)) ? 0 : map.get(value);
|
|
|
TableTop tableTop = new TableTop();
|
|
|
- tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
|
|
|
+ tableTop.setName(e.getMsg()).setValue(value).setTotal(total);
|
|
|
list.add(tableTop);
|
|
|
count = count + total;
|
|
|
}
|
|
|
@@ -373,6 +404,28 @@ public class KwOrderService {
|
|
|
if (CollectionUtils.isEmpty(orders)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(
|
|
|
+ DictTypeEnum.TORDER_STATUS.getType(), DictTypeEnum.PICKUP_TYPE.getType(), DictTypeEnum.DELIVERY_TYPE.getType(),
|
|
|
+ DictTypeEnum.TORDER_SOURCE.getType(), DictTypeEnum.TRADE_TYPE.getType()));
|
|
|
+ Map<String, String> statusMap, pickupMap, deliveryMap, sourceMap, tradeMap;
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
+ statusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_STATUS.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.TORDER_STATUS.getType()) : new HashMap<>();
|
|
|
+ pickupMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.PICKUP_TYPE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.PICKUP_TYPE.getType()) : new HashMap<>();
|
|
|
+ deliveryMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.DELIVERY_TYPE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.DELIVERY_TYPE.getType()) : new HashMap<>();
|
|
|
+ sourceMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_SOURCE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.TORDER_SOURCE.getType()) : new HashMap<>();
|
|
|
+ tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
|
|
|
+ dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
|
|
|
+ } else {
|
|
|
+ statusMap = new HashMap<>();
|
|
|
+ pickupMap = new HashMap<>();
|
|
|
+ deliveryMap = new HashMap<>();
|
|
|
+ sourceMap = new HashMap<>();
|
|
|
+ tradeMap = new HashMap<>();
|
|
|
+ }
|
|
|
List<TradeOrderListExport> list = new ArrayList<>();
|
|
|
AtomicInteger i = new AtomicInteger(1);
|
|
|
orders.forEach(e -> {
|
|
|
@@ -383,17 +436,17 @@ public class KwOrderService {
|
|
|
String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
|
|
|
TradeOrderListExport export = BeanUtils.copyProperties(e, TradeOrderListExport.class);
|
|
|
export.setSerialNumber(String.valueOf(i.getAndIncrement()))
|
|
|
- .setStatus(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
|
|
|
+ .setStatus(statusMap.get(String.valueOf(e.getStatus())))
|
|
|
.setUnitPrice(Objects.isNull(e.getUnitPrice()) ? "0.00" : String.valueOf(e.getUnitPrice()))
|
|
|
.setAmount(Objects.isNull(e.getAmount()) ? "0.00" : String.valueOf(e.getAmount()))
|
|
|
.setPrice(Objects.isNull(e.getPrice()) ? "0.00" : String.valueOf(e.getPrice()))
|
|
|
.setEntrustAmount(Objects.isNull(e.getEntrustAmount()) ? "0.00" : String.valueOf(e.getEntrustAmount()))
|
|
|
.setActualAmount(Objects.isNull(e.getActualAmount()) ? "0.00" : String.valueOf(e.getActualAmount()))
|
|
|
.setWaitEntrustAmount(Objects.isNull(waitEntrustAmount) ? "0.00" : String.valueOf(waitEntrustAmount))
|
|
|
- .setPickupType(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
|
|
|
- .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
|
|
|
- .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
|
|
|
- .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
|
|
|
+ .setPickupType(pickupMap.get(e.getPickupType()))
|
|
|
+ .setDeliveryType(deliveryMap.get(e.getDeliveryType()))
|
|
|
+ .setSource(sourceMap.get(e.getSource()))
|
|
|
+ .setTrading(tradeMap.get(e.getTrading()))
|
|
|
.setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
|
|
|
.setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
|
|
|
.setStartTime(Objects.isNull(e.getStartTime()) ? null : DateUtil.dateToStr(e.getStartTime()))
|
|
|
@@ -415,7 +468,7 @@ public class KwOrderService {
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
Criteria criteria = new Criteria();
|
|
|
String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
|
|
|
- criteria.and(topEnt).is(entId).and("status").is(Integer.valueOf(DictEnum.TORDER_STATUS_5.getValue()))
|
|
|
+ criteria.and(topEnt).is(entId).and("status").is(TOrderStatusEnum.FINISHED.getCode())
|
|
|
.and("associateStatement").ne(1).and("delFlag").is(0);
|
|
|
//排除订单ids
|
|
|
if (StringUtils.isNotBlank(params.getExcludeIds())) {
|
|
|
@@ -447,7 +500,8 @@ public class KwOrderService {
|
|
|
Pattern pattern = Pattern.compile("^.*" + params.getGoodsName() + ".*$", Pattern.CASE_INSENSITIVE);
|
|
|
criteria.and("goodsName").regex(pattern);
|
|
|
}
|
|
|
- return getResult(criteria, params.getPage(), params.getPageSize());
|
|
|
+ Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
|
|
|
+ return getResult(criteria, sort, params.getPage(), params.getPageSize());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -463,46 +517,8 @@ public class KwOrderService {
|
|
|
String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
|
|
|
List<Long> ids = StringUtils.splitStrToList(params.getContractIds(), ",", Long.class);
|
|
|
criteria.and("contractId").in(ids).and(topEnt).is(entId).and("delFlag").is(0);
|
|
|
- return getContractResult(criteria, params.getPage(), params.getPageSize());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc: 获取关联合同结果
|
|
|
- * @author: yzc
|
|
|
- * @date: 2023-09-14 14:58
|
|
|
- * @Param criteria:
|
|
|
- * @Param page:
|
|
|
- * @Param pageSize:
|
|
|
- * @return: com.sckw.core.model.page.PageResult
|
|
|
- */
|
|
|
- public PageResult getContractResult(Criteria criteria, Integer page, Integer pageSize) {
|
|
|
- Query query = new Query();
|
|
|
- query.addCriteria(criteria);
|
|
|
- long count = mongoTemplate.count(query, SckwTradeOrder.class);
|
|
|
Sort sort = Sort.by(Sort.Direction.DESC, "contractId", "createTime");
|
|
|
- SpringDataPageAble pageAble = new SpringDataPageAble(page, pageSize, sort);
|
|
|
- query.with(pageAble);
|
|
|
- List<SckwTradeOrder> list = mongoTemplate.find(query, SckwTradeOrder.class);
|
|
|
- List<OrderListRes> result = new ArrayList<>();
|
|
|
- list.forEach(e -> {
|
|
|
- String loadCityName = Objects.isNull(e.getLoadCityName()) ? "" : e.getLoadCityName();
|
|
|
- String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
|
|
|
- String unloadCityName = Objects.isNull(e.getUnloadCityName()) ? "" : e.getUnloadCityName();
|
|
|
- String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
|
|
|
- OrderListRes order = BeanUtils.copyProperties(e, OrderListRes.class);
|
|
|
- order.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
|
|
|
- .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
|
|
|
- .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
|
|
|
- .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
|
|
|
- .setDeliveryTypeLabel(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
|
|
|
- .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
|
|
|
- .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
|
|
|
- .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
|
|
|
- .setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getActualAmount()))
|
|
|
- .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
|
|
|
- .setSourceLabel(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()));
|
|
|
- result.add(order);
|
|
|
- });
|
|
|
- return PageResult.build(page, pageSize, count, result);
|
|
|
+ return getResult(criteria, sort, params.getPage(), params.getPageSize());
|
|
|
}
|
|
|
+
|
|
|
}
|