|
|
@@ -4,6 +4,7 @@ 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.model.enums.SystemTypeEnum;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderStatisticsService;
|
|
|
@@ -53,76 +54,77 @@ public class KwWorkService {
|
|
|
* @date: 2023/9/11
|
|
|
*/
|
|
|
public List<QueryBusinessStatisticsResVo> queryBusinessStatistics() {
|
|
|
- EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
|
|
|
- if(Objects.isNull(entCacheResDto)) {
|
|
|
- return Collections.emptyList();
|
|
|
+ boolean isSystem = LoginUserHolder.getSystemType().equals(SystemTypeEnum.MANAGE.getCode());
|
|
|
+ Long entId = null;
|
|
|
+ String entTypes = "";
|
|
|
+
|
|
|
+ if (!isSystem) {
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
|
|
|
+ if (Objects.isNull(entCacheResDto)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ entId = entCacheResDto.getId();
|
|
|
+ entTypes = entCacheResDto.getEntTypes();
|
|
|
}
|
|
|
-
|
|
|
- String entTypes = entCacheResDto.getEntTypes();
|
|
|
//承运
|
|
|
- Boolean hasCarrier = entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS4.getCode())) || entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS3.getCode()));
|
|
|
+ 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 hasCheck = entTypes.contains(String.valueOf(EntTypeEnum.LOGISTICS3.getCode()));
|
|
|
//采购
|
|
|
- Boolean hasPurchase = entTypes.contains(String.valueOf(EntTypeEnum.PURCHASER.getCode()));
|
|
|
+ boolean hasPurchase = entTypes.contains(String.valueOf(EntTypeEnum.PURCHASER.getCode()));
|
|
|
//供应
|
|
|
- Boolean hasSupplier = entTypes.contains(String.valueOf(EntTypeEnum.SUPPLIER.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);
|
|
|
- }
|
|
|
+ Map<Integer, Integer> contractMap = remoteContractService.queryContractValidCount(entId);
|
|
|
+ if (hasPurchase || isSystem) {
|
|
|
+ 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 (hasSupplier || isSystem) {
|
|
|
+ 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 (hasCarrier || isSystem) {
|
|
|
+ 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);
|
|
|
- }
|
|
|
+ if (hasCheck || isSystem) {
|
|
|
+ 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);
|
|
|
- }
|
|
|
+ Map<Integer, Integer> orderNumByTopEntId = tradeOrderStatisticsService.getOrderNumByTopEntId(entId);
|
|
|
+ if (hasSupplier || isSystem) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("销售订单");
|
|
|
+ queryBusinessStatisticsResVo.setNum(orderNumByTopEntId.get(Global.NUMERICAL_TWO));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
|
|
|
- if (hasPurchase) {
|
|
|
- QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
- queryBusinessStatisticsResVo.setType("采购订单");
|
|
|
- queryBusinessStatisticsResVo.setNum(collect.getOrDefault(Global.NUMERICAL_ONE, Global.NUMERICAL_ZERO));
|
|
|
- list.add(queryBusinessStatisticsResVo);
|
|
|
- }
|
|
|
+ if (hasPurchase || isSystem) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("采购订单");
|
|
|
+ queryBusinessStatisticsResVo.setNum(orderNumByTopEntId.get(Global.NUMERICAL_ONE));
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
}
|
|
|
|
|
|
//承运订单
|
|
|
- Integer integer = transportStatisticsService.statisticsLogistics(entCacheResDto.getId());
|
|
|
- if (hasCarrier) {
|
|
|
+ Integer integer = transportStatisticsService.statisticsLogistics(entId);
|
|
|
+ if (hasCarrier || isSystem) {
|
|
|
QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
queryBusinessStatisticsResVo.setType("承运订单");
|
|
|
queryBusinessStatisticsResVo.setNum(Objects.isNull(integer) ? Global.NUMERICAL_ZERO : integer);
|
|
|
@@ -130,44 +132,41 @@ public class KwWorkService {
|
|
|
}
|
|
|
|
|
|
//托运订单
|
|
|
- Integer integer1 = transportStatisticsService.statisticsPendingVerificationWaybill(entCacheResDto.getId());
|
|
|
- if (hasCheck) {
|
|
|
+ Integer integer1 = transportStatisticsService.statisticsPendingVerificationWaybill(entId);
|
|
|
+ if (hasCheck || isSystem) {
|
|
|
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.getSell()) ? Global.NUMERICAL_ZERO : ledgerCount.getSell());
|
|
|
- list.add(queryBusinessStatisticsResVo);
|
|
|
- }
|
|
|
+ LedgerCount ledgerCount = paymentDubboService.countLedger(entId);
|
|
|
+ if (hasSupplier || isSystem) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("销售对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getSell()) ? Global.NUMERICAL_ZERO : ledgerCount.getSell());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
|
|
|
- if (hasPurchase) {
|
|
|
- QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
- queryBusinessStatisticsResVo.setType("采购对账");
|
|
|
- queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getPurchase()) ? Global.NUMERICAL_ZERO : ledgerCount.getPurchase());
|
|
|
- list.add(queryBusinessStatisticsResVo);
|
|
|
- }
|
|
|
+ if (hasPurchase || isSystem) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("采购对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getPurchase()) ? Global.NUMERICAL_ZERO : ledgerCount.getPurchase());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
|
|
|
- if (hasCarrier) {
|
|
|
- QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
- queryBusinessStatisticsResVo.setType("承运对账");
|
|
|
- queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getCarrier()) ? Global.NUMERICAL_ZERO : ledgerCount.getCarrier());
|
|
|
- list.add(queryBusinessStatisticsResVo);
|
|
|
- }
|
|
|
+ if (hasCarrier || isSystem) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("承运对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getCarrier()) ? Global.NUMERICAL_ZERO : ledgerCount.getCarrier());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
+ }
|
|
|
|
|
|
- if (hasCheck) {
|
|
|
- QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
- queryBusinessStatisticsResVo.setType("托运对账");
|
|
|
- queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getShipper()) ? Global.NUMERICAL_ZERO : ledgerCount.getShipper());
|
|
|
- list.add(queryBusinessStatisticsResVo);
|
|
|
- }
|
|
|
+ if (hasCheck || isSystem) {
|
|
|
+ QueryBusinessStatisticsResVo queryBusinessStatisticsResVo = new QueryBusinessStatisticsResVo();
|
|
|
+ queryBusinessStatisticsResVo.setType("托运对账");
|
|
|
+ queryBusinessStatisticsResVo.setNum(Objects.isNull(ledgerCount.getShipper()) ? Global.NUMERICAL_ZERO : ledgerCount.getShipper());
|
|
|
+ list.add(queryBusinessStatisticsResVo);
|
|
|
}
|
|
|
return list;
|
|
|
}
|