|
|
@@ -0,0 +1,175 @@
|
|
|
+package com.sckw.report.service;
|
|
|
+
|
|
|
+import com.sckw.contract.api.RemoteContractService;
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.enums.CooperateTypeEnum;
|
|
|
+import com.sckw.core.model.enums.EntTypeEnum;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.web.context.LoginUserHolder;
|
|
|
+import com.sckw.order.api.dubbo.TradeOrderStatisticsService;
|
|
|
+import com.sckw.order.api.model.TradeOrderCountStatisticsDTO;
|
|
|
+import com.sckw.payment.api.dubbo.PaymentDubboService;
|
|
|
+import com.sckw.payment.api.model.dto.LedgerCount;
|
|
|
+import com.sckw.report.service.vo.QueryBusinessStatisticsResVo;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import com.sckw.transport.api.dubbo.TransportStatisticsService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author czh
|
|
|
+ * @desc 工作台
|
|
|
+ * @date 2023/9/11
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class KwWorkService {
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private TransportStatisticsService transportStatisticsService;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private PaymentDubboService paymentDubboService;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteContractService remoteContractService;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private TradeOrderStatisticsService tradeOrderStatisticsService;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return QueryBusinessStatisticsResVo
|
|
|
+ * @desc: 业务数据数量统计
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/9/11
|
|
|
+ */
|
|
|
+ public List<QueryBusinessStatisticsResVo> queryBusinessStatistics() {
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
|
|
|
+ if(Objects.isNull(entCacheResDto)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ String entTypes = entCacheResDto.getEntTypes();
|
|
|
+ //承运
|
|
|
+ Boolean hasCarrier = entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS4.getCode())) || entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS3.getCode()));
|
|
|
+ //托运
|
|
|
+ Boolean hasCheck = entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS3.getCode()));
|
|
|
+ //采购
|
|
|
+ Boolean hasPurchase = entTypes.contains(String.valueOf(EntTypeEnum.PURCHASER.getCode()));
|
|
|
+ //供应
|
|
|
+ Boolean hasSupplier = entTypes.contains(String.valueOf(EntTypeEnum.SUPPLIER.getCode()));
|
|
|
+
|
|
|
+ List<QueryBusinessStatisticsResVo> list = new ArrayList<>();
|
|
|
+ //合同部分
|
|
|
+ Map<Integer, Integer> contractMap = remoteContractService.queryContractValidCount(entCacheResDto.getId());
|
|
|
+ if (!contractMap.isEmpty()) {
|
|
|
+ if (hasPurchase) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("采购合同");
|
|
|
+ queryBusinessStatisticsResVo.setNum(contractMap.getOrDefault(CooperateTypeEnum.PURCHASER.getCode(), Global.NUMERICAL_ZERO));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hasSupplier) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("销售合同");
|
|
|
+ queryBusinessStatisticsResVo.setNum(contractMap.getOrDefault(CooperateTypeEnum.SUPPLIER.getCode(), Global.NUMERICAL_ZERO));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hasCarrier) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("承运合同");
|
|
|
+ queryBusinessStatisticsResVo.setNum(contractMap.getOrDefault(CooperateTypeEnum.CARRIAGE.getCode(), Global.NUMERICAL_ZERO));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hasCheck) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("托运合同");
|
|
|
+ queryBusinessStatisticsResVo.setNum(contractMap.getOrDefault(CooperateTypeEnum.CONSIGN.getCode(), Global.NUMERICAL_ZERO));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //订单部分
|
|
|
+ List<TradeOrderCountStatisticsDTO> orderNumByTopEntId = tradeOrderStatisticsService.getOrderNumByTopEntId(entCacheResDto.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(orderNumByTopEntId)) {
|
|
|
+ Map<Integer, Integer> collect = orderNumByTopEntId.stream().collect(Collectors.toMap(TradeOrderCountStatisticsDTO::getOrderType, TradeOrderCountStatisticsDTO::getNum, (o, n) -> n));
|
|
|
+ if (hasSupplier) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("销售订单");
|
|
|
+ queryBusinessStatisticsResVo.setNum(collect.getOrDefault(Global.NUMERICAL_TWO, Global.NUMERICAL_ZERO));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hasPurchase) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("采购订单");
|
|
|
+ queryBusinessStatisticsResVo.setNum(collect.getOrDefault(Global.NUMERICAL_ONE, Global.NUMERICAL_ZERO));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //承运订单
|
|
|
+ Integer integer = transportStatisticsService.statisticsLogistics(entCacheResDto.getId());
|
|
|
+ if (hasCarrier) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("承运订单");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(integer) ? Global.NUMERICAL_ZERO : integer);
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //托运订单
|
|
|
+ Integer integer1 = transportStatisticsService.statisticsPendingVerificationWaybill(entCacheResDto.getId());
|
|
|
+ if (hasCheck) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("托运订单");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(integer1) ? Global.NUMERICAL_ZERO : integer1);
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ LedgerCount ledgerCount = paymentDubboService.countLedger(entCacheResDto.getId());
|
|
|
+ if (Objects.nonNull(ledgerCount)) {
|
|
|
+
|
|
|
+ if (hasSupplier) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("销售对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.sell()) ? Global.NUMERICAL_ZERO : ledgerCount.sell());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hasPurchase) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("采购对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.purchase()) ? Global.NUMERICAL_ZERO : ledgerCount.purchase());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hasCarrier) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("承运对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.carrier()) ? Global.NUMERICAL_ZERO : ledgerCount.carrier());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hasCheck) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("托运对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.shipper()) ? Global.NUMERICAL_ZERO : ledgerCount.shipper());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|