Просмотр исходного кода

运单看板/运单列表bug-fix
承运订单/托运订单逻辑优化

lengfaqiang 2 лет назад
Родитель
Сommit
5a54970fbd

+ 9 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillEnum.java

@@ -52,7 +52,7 @@ public enum CarWaybillEnum {
     /**
      * 已撤销
      */
-    REVOKED(11, "revoked", "11", "已撤销"),
+    REVOKED(11, "revoked", "11", "单趟撤回"),
     /**
      * 已核单-不通过
      */
@@ -122,6 +122,14 @@ public enum CarWaybillEnum {
         return codes;
     }
 
+    public static List<String> getStringCodes() {
+        List<String> codes = new ArrayList<>();
+        for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
+            codes.add(waybillEnum.getStatus());
+        }
+        return codes;
+    }
+
     /**
      * @param code 状态码
      * @desc 是否可以变更司机/车辆

+ 5 - 0
sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/TableTops.java

@@ -21,4 +21,9 @@ public class TableTops {
      * 数量
      */
     private Integer total;
+
+    /**
+     * 数量
+     */
+    private Integer sort;
 }

+ 120 - 42
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java

@@ -39,10 +39,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -200,14 +197,17 @@ public class KwTransportService {
                 statuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
                 statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
                 statuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
-                statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
+//                statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
                 criteria.and("status").in(statuses);
             } else if (query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode()))) {
                 List<Long> statuses = new ArrayList<>();
                 statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
                 statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
                 criteria.and("status").in(statuses);
-            } else if (!query.getStatus().equals("all")) {
+            } else if (!query.getStatus().equals("all")
+                    && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))
+                    && (!query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO)))
+            ) {
                 criteria.and("status").is(Integer.valueOf(query.getStatus()));
             }
         }
@@ -293,45 +293,122 @@ public class KwTransportService {
         topTotal.setName("全部");
         topTotal.setValue("all");
         topTotal.setTotal(0);
-        list.add(topTotal);
+
 
         TableTops topExpired = new TableTops();
         topExpired.setName("已作废");
         topExpired.setValue(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
+        topExpired.setSort(NumberConstant.ONE_ZERO_ZERO);
         topExpired.setTotal(0);
-        ArrayList<Long> expiredStatuses = new ArrayList<>();
-        expiredStatuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
-        expiredStatuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
-        expiredStatuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
-        expiredStatuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
-        for (CarWaybillEnum status : CarWaybillEnum.values()) {
-            boolean expiredFlag = expiredStatuses.contains(status.getCode().longValue());
+
+        list.addAll(results);
+        list.add(topExpired);
+//        ArrayList<Long> expiredStatuses = new ArrayList<>();
+//        expiredStatuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
+//        expiredStatuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
+//        expiredStatuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
+//        expiredStatuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
+//        for (CarWaybillEnum status : CarWaybillEnum.values()) {
+//            boolean expiredFlag = expiredStatuses.contains(status.getCode().longValue());
+//            TableTops top = new TableTops();
+//            top.setName(status.getDestination());
+//            top.setValue(String.valueOf(status.getCode()));
+//            top.setTotal(0);
+//            if (CollectionUtils.isNotEmpty(results)) {
+//                for (TableTops result : results) {
+//                    if (StringUtils.isNotEmpty(result.getValue())
+//                            && String.valueOf(result.getValue()).equals(String.valueOf(status.getCode()))) {
+//                        if (expiredFlag) {
+//                            topExpired.setTotal(topExpired.getTotal() + result.getTotal());
+//                        } else {
+//                            top.setTotal(result.getTotal());
+//                        }
+//                        break;
+//                    }
+//                }
+//            }
+//            if (!expiredFlag) {
+//                list.add(top);
+//            }
+//        }
+        /**数据统计计算*/
+        orderNumberCount(list);
+        /**补齐全部状态值*/
+        List<String> codeList = CarWaybillEnum.getStringCodes();
+        List<String> collect = list.stream().map(e -> e.getValue()).collect(Collectors.toList());
+        List<String> diffrentList = getDiffrentList(collect, codeList);
+        for (String s : diffrentList) {
             TableTops top = new TableTops();
-            top.setName(status.getDestination());
-            top.setValue(String.valueOf(status.getCode()));
-            top.setTotal(0);
-            if (CollectionUtils.isNotEmpty(results)) {
-                for (TableTops result : results) {
-                    if (StringUtils.isNotEmpty(result.getValue())
-                            && String.valueOf(result.getValue()).equals(String.valueOf(status.getCode()))) {
-                        if (expiredFlag) {
-                            topExpired.setTotal(topExpired.getTotal() + result.getTotal());
-                        } else {
-                            top.setTotal(result.getTotal());
-                        }
-                        break;
-                    }
+            top.setValue(s);
+            top.setTotal(NumberConstant.ZERO);
+            top.setSort(Integer.valueOf(s));
+            list.add(top);
+        }
+        /**状态赋值翻译*/
+        for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
+            for (TableTops tops : list) {
+                if (waybillEnum.getStatus().equals(tops.getValue())) {
+                    tops.setName(waybillEnum.getDestination());
+                    tops.setSort(waybillEnum.getCode());
+                    continue;
                 }
             }
-            if (!expiredFlag) {
-                list.add(top);
+        }
+//        list.add(topExpired);
+        /**去除不展示统计字段*/
+        List<TableTops> returnList = new ArrayList<>();
+        for (TableTops tops : list) {
+            if ((!CarWaybillEnum.REFUSE_TRAFFIC.getStatus().equals(tops.getValue()))
+                    && (!CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(tops.getValue()))
+                    && (!CarWaybillEnum.REVOKED.getStatus().equals(tops.getValue()))
+                    && (!CarWaybillEnum.REJECT_ORDER.getStatus().equals(tops.getValue()))
+            ) {
+                returnList.add(tops);
             }
         }
-        list.add(topExpired);
+        /**排序*/
+        returnList = returnList.stream().sorted(Comparator.comparing(TableTops::getSort)).collect(Collectors.toList());
+        returnList.add(0,topTotal);
         // 总计
-        topTotal.setTotal(list.parallelStream().mapToInt(item -> item.getTotal()).sum());
+        topTotal.setTotal(returnList.parallelStream().mapToInt(item -> item.getTotal()).sum());
         // 查询结果
-        return HttpResult.ok(list);
+        return HttpResult.ok(returnList);
+    }
+
+    /**
+     * 统计top计算
+     *
+     * @param results
+     */
+    private void orderNumberCount(List<TableTops> results) {
+        if (!org.springframework.util.CollectionUtils.isEmpty(results)) {
+            //已卸货包含本身以及审核不通过
+            Integer orderCancel = 0;
+            //已作废包含本身以及拒绝出车、已撤销、拒绝接单
+            Integer orderCancellation = 0;
+            for (TableTops result : results) {
+                if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())
+                        || CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())) {
+                    orderCancel = orderCancel + result.getTotal();
+                }
+                if (CarWaybillEnum.REJECT_ORDER.getStatus().equals(result.getValue())
+                        || CarWaybillEnum.REVOKED.getStatus().equals(result.getValue())
+                        || CarWaybillEnum.REFUSE_TRAFFIC.getStatus().equals(result.getValue())
+                ) {
+                    orderCancellation = orderCancellation + result.getTotal();
+                }
+            }
+            for (TableTops result : results) {
+                if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())) {
+                    result.setTotal(orderCancel);
+                    result.setSort(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
+                }
+                if (String.valueOf(NumberConstant.ONE_ZERO_ZERO).equals(result.getValue())) {
+                    result.setTotal(orderCancellation);
+                    result.setSort(NumberConstant.ONE_ZERO_ZERO);
+                }
+            }
+        }
     }
 
     /**
@@ -383,7 +460,7 @@ public class KwTransportService {
                 typeString = "循环";
             }
             vo.setTypeLabel(typeString);
-            if(status.equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
+            if (status.equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
                 vo.setStatus(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
             } else {
                 vo.setStatus(waybillOrder.getStatus() == null ?
@@ -424,12 +501,12 @@ public class KwTransportService {
             // 存在装卸货差时 计算扣亏量
             BigDecimal lossAmount = BigDecimal.valueOf(0);
             BigDecimal loss = waybillOrder.getLoss() == null ? new BigDecimal("0.00") : waybillOrder.getLoss();
-            if(deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
+            if (deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
                 String lossUnit = waybillOrder.getLossUnit();
                 Map<String, SysDictResDto> LossUnitType = remoteSystemService.queryDictMapByType(DictTypeEnum.TAX_RATE_TYPE.getType());
                 SysDictResDto sysDictRes = LossUnitType.get(lossUnit);
 
-                if(sysDictRes.getLabel().equals("%")) {
+                if (sysDictRes.getLabel().equals("%")) {
                     // 百分比
                     lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(100));
                 } else {
@@ -437,7 +514,7 @@ public class KwTransportService {
                     lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(1000));
                 }
                 lossAmount = deficitAmount.subtract(lossAmount);
-                if(lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
+                if (lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
                     lossAmount = new BigDecimal("0.00");
                 }
             }
@@ -500,16 +577,16 @@ public class KwTransportService {
     public HttpResult getLogisticsOrderByContractId(ContractParam contractParam) {
         HttpResult result = new HttpResult();
         if (String.valueOf(NumberConstant.ONE).equals(contractParam.getContractType())) {
-            result = getLogisticsOrderContract(contractParam,"1");
+            result = getLogisticsOrderContract(contractParam, "1");
         } else if (String.valueOf(NumberConstant.TWO).equals(contractParam.getContractType())) {
-            result = getLogisticsOrderContract(contractParam,"2");
+            result = getLogisticsOrderContract(contractParam, "2");
         } else {
             return HttpResult.error("合同类型错误");
         }
         return result;
     }
 
-    private HttpResult getLogisticsOrderContract(ContractParam contractParam,String unitType) {
+    private HttpResult getLogisticsOrderContract(ContractParam contractParam, String unitType) {
         String contractIds = contractParam.getContractIds();
         int page = contractParam.getPage();
         int pageSize = contractParam.getPageSize();
@@ -550,7 +627,7 @@ public class KwTransportService {
         // 12. 总记录数
         long total = mongoTemplate.count(query1, SckwLogisticsOrder.class);
         // 10. 分页
-        query1.with(PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC,"contractId","createTime")));
+        query1.with(PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC, "contractId", "createTime")));
         // 执行查询
         List<SckwLogisticsOrder> list = mongoTemplate.find(query1, SckwLogisticsOrder.class);
         //字典等数据转换
@@ -610,7 +687,8 @@ public class KwTransportService {
     }
 
     /**
-     *  运单列表导出
+     * 运单列表导出
+     *
      * @param query
      * @return
      */

+ 13 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -198,7 +198,9 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
     List<AcceptCarriageOrderVO> selectLogisticsOrderList(@Param("query") AcceptCarriageOrderQuery query,
                                                          @Param("orderList") List<Integer> orderList,
                                                          @Param("type") String type,
-                                                         @Param("entId") Long entId
+                                                         @Param("entId") Long entId,
+                                                         @Param("contactsIds") List<Long> contactsIds,
+                                                         @Param("userIds") List<Long> userIds
     );
 
     /**
@@ -211,7 +213,9 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
     List<ConsignOrderVO> selectConsignLogisticsOrderList(@Param("query") ConsignOrderQuery query,
                                                          @Param("orderList") List<Integer> orderList,
                                                          @Param("type") String type,
-                                                         @Param("entId") Long entId
+                                                         @Param("entId") Long entId,
+                                                         @Param("contactsIds") List<Long> contactsIds,
+                                                         @Param("userIds") List<Long> userIds
     );
 
     /**
@@ -232,15 +236,18 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     /**
      * @param query
-     * @param orderList
-     * @param type
-     * @param entId
+     * @param orderList 单据状态
+     * @param type      代表承运或者托运
+     * @param entId 企业id
+     * @param contactsIds 联系人id
      * @return
      */
     List<TableTops> countLogisticsOrderListByStatus(@Param("query") AcceptCarriageOrderQuery query,
                                                     @Param("orderList") List<Integer> orderList,
                                                     @Param("type") String type,
-                                                    @Param("entId") Long entId
+                                                    @Param("entId") Long entId,
+                                                    @Param("contactsIds") List<Long> contactsIds,
+                                                    @Param("userIds") List<Long> userIds
     );
 
     /**

+ 4 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/AcceptCarriageOrderVO.java

@@ -286,4 +286,8 @@ public class AcceptCarriageOrderVO /*extends PageRequest*/ {
      */
     private BigDecimal totalUnloadAmount;
 
+    /**
+     * 订单主体企业id
+     */
+    private  Long entId;
 }

+ 14 - 4
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java

@@ -1322,7 +1322,7 @@ public class AcceptCarriageOrderService {
         /**订单状态验证*/
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
-            throw new RuntimeException("当前单并不属于【待派车】,【运输中】状态");
+            throw new RuntimeException("当前单并不属于【待派车】,【运输中】状态");
         }
         /**完结拦截*/
         List<Integer> statusList = new ArrayList<>();
@@ -2221,7 +2221,11 @@ public class AcceptCarriageOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
         }
-        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+//        LoginUserHolder.getIsMain()
+        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId,longList,longList);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
@@ -2326,7 +2330,10 @@ public class AcceptCarriageOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
         }
-        List<TableTops> list = logisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<TableTops> list = logisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId,longList,longList);
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);
         /**补全数据状态不齐的情况*/
@@ -2443,7 +2450,10 @@ public class AcceptCarriageOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
         }
-        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId,longList,longList);
         /**计费方式*/
         Map<String, String> chargingDictData = getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/

+ 13 - 4
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -770,7 +770,7 @@ public class ConsignOrderService {
         /**订单状态验证*/
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
-            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
+            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
         }
         //验证当前物流订单是否还存在进行的车辆运单
         boolean flag = judgmentWaybillOrderIsFinish(id);
@@ -1629,7 +1629,10 @@ public class ConsignOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
         }
-        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId,longList,longList);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
@@ -1735,7 +1738,10 @@ public class ConsignOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
         }
-        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId,longList,longList);
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);
         /**补全数据状态不齐的情况*/
@@ -1826,7 +1832,10 @@ public class ConsignOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
         }
-        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId,longList,longList);
         /**计费方式*/
         Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java

@@ -1177,7 +1177,7 @@ public class LogisticsConsignmentService {
         /**订单状态验证*/
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
-            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
+            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
         }
         //验证当前物流订单是否还存在进行的车辆运单
         boolean flag = judgmentWaybillOrderIsFinish(id);

+ 34 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -360,6 +360,7 @@ public class WaybillManagementService {
         // mongo查询列数据,不足的数据单独关联表查询
         // 状态查询 status [2-8]
         List<Integer> statuses = initWaybillIndexStatus();
+//        List<Integer> statuses = CarWaybillEnum.getCodes();
         // 初始化各状态
         List<WaybillStatusVO> statusVOS = new ArrayList<>();
         statuses.forEach(e -> {
@@ -461,6 +462,7 @@ public class WaybillManagementService {
         statuses.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
         statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
         statuses.add(CarWaybillEnum.APPROVAL_PASS.getCode());
+//        List<Integer> statuses = CarWaybillEnum.getCodes();
         return statuses;
     }
 
@@ -485,7 +487,16 @@ public class WaybillManagementService {
                 _statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
                 _statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
                 criteria.and("status").in(_statuses);
-            } else if (!query.getStatus().equals("all") && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))) {
+            } else if (query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
+                List<Integer> _statuses = new ArrayList<>();
+                _statuses.add(CarWaybillEnum.REJECT_ORDER.getCode());
+                _statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode());
+                _statuses.add(CarWaybillEnum.REVOKED.getCode());
+                criteria.and("status").in(_statuses);
+            } else if (!query.getStatus().equals("all")
+                    && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))
+                    && (!query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO)))
+            ) {
                 criteria.and("status").is(Integer.valueOf(query.getStatus()));
             }
         }
@@ -582,6 +593,7 @@ public class WaybillManagementService {
             top.setName(CarWaybillEnum.getName(e));
             listMap.put(String.valueOf(e), top);
         });
+        /**计算总条数*/
         if (CollectionUtils.isNotEmpty(results)) {
             for (TableTops result : results) {
                 if (listMap.containsKey(result.getValue())) {
@@ -590,7 +602,28 @@ public class WaybillManagementService {
                 allTotal += result.getTotal();
             }
         }
+       // allTotal= Math.toIntExact(results.stream().filter(item -> ObjectUtil.isNotEmpty(item.getTotal())).collect(Collectors.summarizingInt(item -> item.getTotal())).getSum());
         listMap.get("all").setTotal(allTotal);
+
+        /**数据状态整合做计算
+         * 整合页面数据状态查询*/
+        if (CollectionUtils.isNotEmpty(results)) {
+            //已卸货包含本身以及审核不通过
+            Integer number = 0;
+            for (TableTops result : results) {
+                if (CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())) {
+                    Integer total = result.getTotal();
+                    number = number + total;
+                }
+            }
+            for (TableTops result : results) {
+                if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())) {
+                    result.setTotal(result.getTotal() + number);
+                    listMap.put(result.getValue(),result);
+                }
+            }
+        }
+
         return HttpResult.ok(listMap.values());
     }
 

+ 107 - 6
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -791,7 +791,6 @@
         g.goods_type AS goodsType,
         f.contract_id AS contractId,
         f.contract_no AS contractNo,
-        <!--        f.contract_name AS contractName,-->
         f.signing_way AS signing,
         d.ent_id AS consignCompanyId,
         d.top_ent_id AS consignTopEntId,
@@ -851,14 +850,44 @@
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
 <!--                AND (-->
-<!--                a.ent_id = 156382319450525696-->
-<!--                AND a.create_by IN ( 156382319433748480 ))-->
+<!--                a.ent_id = #{entId}-->
+<!--                <if test="userIds != null and userIds.size()>0">-->
+<!--                    AND a.create_by IN-->
+<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
 <!--                OR (-->
-<!--                ( d.top_ent_id = 156382319450525696 OR d.ent_id = 156382319450525696 )-->
-<!--                AND d.contacts_id IN ( 156382319433748480, 156382319433748480 ))-->
+<!--                d.top_ent_id = #{entId}-->
+<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+<!--                    AND d.contacts_id IN-->
+<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                 )-->
             </if>
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
+<!--                AND (-->
+<!--                a.ent_id = #{entId}-->
+<!--                <if test="userIds != null and userIds.size()>0">-->
+<!--                    AND a.create_by IN-->
+<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
+<!--                OR (-->
+<!--                d.top_ent_id = #{entId}-->
+<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+<!--                    AND d.contacts_id IN-->
+<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
             </if>
             <if test="query.keywords != null and query.keywords != ''">
                 and (
@@ -902,7 +931,7 @@
                 and a.billing_mode =#{query.billingMode}
             </if>
         </where>
-        ORDER BY a.id DESC
+        ORDER BY a.create_time DESC
         <!--               ,a.create_time-->
     </select>
     <select id="countLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
@@ -925,9 +954,45 @@
             a.del_flag = 0
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
+<!--                AND (-->
+<!--                a.ent_id = #{entId}-->
+<!--                <if test="userIds != null and userIds.size()>0">-->
+<!--                    AND a.create_by IN-->
+<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
+<!--                OR (-->
+<!--                d.top_ent_id = #{entId}-->
+<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+<!--                    AND d.contacts_id IN-->
+<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
             </if>
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
+<!--                AND (-->
+<!--                a.ent_id = #{entId}-->
+<!--                <if test="userIds != null and userIds.size()>0">-->
+<!--                    AND a.create_by IN-->
+<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
+<!--                OR (-->
+<!--                d.top_ent_id = #{entId}-->
+<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+<!--                    AND d.contacts_id IN-->
+<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
             </if>
             <if test="query.keywords != null and query.keywords != ''">
                 and (
@@ -1104,9 +1169,45 @@
             a.del_flag = 0
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
+<!--                AND (-->
+<!--                a.ent_id = #{entId}-->
+<!--                <if test="userIds != null and userIds.size()>0">-->
+<!--                    AND a.create_by IN-->
+<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
+<!--                OR (-->
+<!--                d.top_ent_id = #{entId}-->
+<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+<!--                    AND d.contacts_id IN-->
+<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
             </if>
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
+<!--                AND (-->
+<!--                a.ent_id = #{entId}-->
+<!--                <if test="userIds != null and userIds.size()>0">-->
+<!--                    AND a.create_by IN-->
+<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
+<!--                OR (-->
+<!--                d.top_ent_id = #{entId}-->
+<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+<!--                    AND d.contacts_id IN-->
+<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+<!--                        #{item}-->
+<!--                    </foreach>-->
+<!--                </if>-->
+<!--                )-->
             </if>
             <if test="query.keywords != null and query.keywords != ''">
                 and (