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

Merge remote-tracking branch 'origin/dev' into dev

xucaiqin 2 лет назад
Родитель
Сommit
b610449ac8
15 измененных файлов с 215 добавлено и 199 удалено
  1. 0 89
      sckw-auth/src/main/java/com/sckw/auth/controller/AuthController.java
  2. 4 8
      sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java
  3. 9 0
      sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/RemoteContractService.java
  4. 27 2
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dubbo/RemoteContractServiceImpl.java
  5. 0 1
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmAddressController.java
  6. 0 1
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmCooperateApplyController.java
  7. 0 1
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmCooperateManageController.java
  8. 5 0
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/dto/req/CooperateManageQueryReqDto.java
  9. 3 9
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java
  10. 12 13
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java
  11. 9 4
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java
  12. 87 32
      sckw-modules/sckw-manage/src/main/resources/mapper/KwmCooperateMapper.xml
  13. 2 0
      sckw-modules/sckw-report/src/main/java/com/sckw/report/consumer/SckwBusSumConsumer.java
  14. 57 35
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java
  15. 0 4
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java

+ 0 - 89
sckw-auth/src/main/java/com/sckw/auth/controller/AuthController.java

@@ -3,7 +3,6 @@ package com.sckw.auth.controller;
 import com.sckw.auth.model.vo.req.*;
 import com.sckw.auth.service.IAuthService;
 import com.sckw.core.common.enums.enums.DictEnum;
-import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.enums.LoginMethodEnum;
 import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.utils.RegularUtils;
@@ -28,62 +27,6 @@ public class AuthController {
     @Autowired
     private IAuthService authService;
 
-    @PostMapping("/auth")
-    public HttpResult auth(@RequestHeader(name = "System-Type") int systemType,
-                            @RequestHeader(name = "Client-Type") String clientType,
-                            @RequestBody @Valid LoginBase loginBase) {
-        loginBase.setSystemType(systemType);
-        loginBase.setClientType(clientType);
-        loginBase.setLoginMethod(LoginMethodEnum.ORDINARY.getValue());
-
-        /**参数校验**/
-        HttpResult result = checkParams(loginBase);
-        if (result.getCode() != HttpStatus.SUCCESS_CODE) {
-            return result;
-        }
-
-        /**运营端/企业端登录(PC/APP)**/
-        if (loginBase.getSystemType() == SystemTypeEnum.MANAGE.getCode()
-                || loginBase.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
-            return authService.commonAuth(loginBase);
-        }
-
-        /**司机端**/
-        if (loginBase.getSystemType() == SystemTypeEnum.DRIVER.getCode()) {
-            return authService.driverAuth(loginBase);
-        }
-
-        return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
-    }
-
-    @PostMapping("/smsAuth")
-    public HttpResult smsAuth(@RequestHeader(name = "System-Type") int systemType,
-                            @RequestHeader(name = "Client-Type") String clientType,
-                            @RequestBody @Valid LoginBase loginBase) {
-        loginBase.setSystemType(systemType);
-        loginBase.setClientType(clientType);
-        loginBase.setLoginMethod(LoginMethodEnum.SMS.getValue());
-
-        /**参数校验**/
-        HttpResult result = checkParams(loginBase);
-        if (result.getCode() != HttpStatus.SUCCESS_CODE) {
-            return result;
-        }
-
-        /**运营端/企业端登录(PC/APP)**/
-        if (loginBase.getSystemType() == SystemTypeEnum.MANAGE.getCode()
-                || loginBase.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
-            return authService.commonAuth(loginBase);
-        }
-
-        /**司机端**/
-        if (loginBase.getSystemType() == SystemTypeEnum.DRIVER.getCode()) {
-            return authService.driverAuth(loginBase);
-        }
-
-        return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
-    }
-
     /**
      * @param
      * @return
@@ -172,41 +115,9 @@ public class AuthController {
         }
 
         return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
-//        reqVo.setSystemType(systemType);
-//        reqVo.setClientType(clientType);
-//        return HttpResult.ok(authService.login(reqVo));
     }
 
 
-    /**
-     * @param reqVo 注册
-     * @return HttpResult
-     * @desc: 用户注册
-     * @author: czh
-     * @date: 2023/6/16
-     */
-    @PostMapping("/register")
-    public HttpResult register(@Valid @RequestBody RegisterReqVo reqVo,
-                               @RequestHeader(name = "System-Type", required = true) int systemType) {
-        reqVo.setSystemType(systemType);
-        authService.register(reqVo);
-        return HttpResult.ok(HttpStatus.MSG_007);
-    }
-
-    /**
-     * @param reqVo 忘记密码入参
-     * @return HttpResult
-     * @desc: 忘记密码
-     * @author: czh
-     * @date: 2023/6/19
-     */
-    @PostMapping("/forgetPassword")
-    public HttpResult forgetPassword(@Valid @RequestBody ForgetPasswordReqVo reqVo,
-                                     @RequestHeader(name = "System-Type", required = true) int systemType) {
-        reqVo.setSystemType(systemType);
-        authService.forgetPassword(reqVo);
-        return HttpResult.ok(HttpStatus.MSG_002);
-    }
 
 
     /**

+ 4 - 8
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -19,7 +19,6 @@ import com.sckw.core.web.model.LoginUserInfo;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.fleet.api.RemoteFleetService;
 import com.sckw.fleet.api.model.vo.RDriverDetailVo;
-import com.sckw.message.api.dubbo.SmsInfoService;
 import com.sckw.redis.constant.RedisConstant;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.req.*;
@@ -53,9 +52,6 @@ public class AuthServiceImpl implements IAuthService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService systemService;
 
-    /*@DubboReference(version = "1.0.0", group = "design", check = false)
-    private SmsInfoService smsInfoService;*/
-
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteFleetService fleetService;
 
@@ -382,9 +378,9 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setPhone(driver.getPhone());
         loginRes.setStatus(driver.getStatus());
         loginRes.setEntId(driver.getEntId());
-        loginRes.setFirmName(enterprise == null ? enterprise.getFirmName() : null);
-        loginRes.setApproval(enterprise == null ? enterprise.getApproval() : null);
-        loginRes.setEntTypeNames(enterprise == null ? enterprise.getEntTypeNames() : null);
+        loginRes.setFirmName(enterprise != null ? enterprise.getFirmName() : null);
+        loginRes.setApproval(enterprise != null ? enterprise.getApproval() : null);
+        loginRes.setEntTypeNames(enterprise != null ? enterprise.getEntTypeNames() : null);
         loginRes.setClientType(loginBase.getClientType());
         loginRes.setSystemType(loginBase.getSystemType());
         loginRes.setToken(token);
@@ -466,7 +462,7 @@ public class AuthServiceImpl implements IAuthService {
         info.put("account", loginBase.getAccount());
         info.put("clientType", loginBase.getClientType());
         info.put("systemType", loginBase.getSystemType());
-        info.put("timestamp", System.currentTimeMillis());
+//        info.put("timestamp", System.currentTimeMillis());
         String key = Global.getFullUserTokenKey(loginBase.getClientType(), userId);
         String token = EncryUtil.encryV1(Global.PRI_KEY, JSON.toJSONString(info));
         int expireTime = ClientTypeEnum.expireTime(loginBase.getClientType());

+ 9 - 0
sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/RemoteContractService.java

@@ -2,6 +2,7 @@ package com.sckw.contract.api;
 
 import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -20,4 +21,12 @@ public interface RemoteContractService {
      * @date: 2023/7/20
      */
     Map<Long, ContractCommonInfoResDto> queryContractBaseInfo(List<Long> contractId);
+
+    /**
+     * @param contractId 合同id  performedAmount履约量
+     * @desc: 更新已履约量
+     * @author: czh
+     * @date: 2023/8/31
+     */
+    void updatePerformed(Long contractId, BigDecimal performedAmount);
 }

+ 27 - 2
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dubbo/RemoteContractServiceImpl.java

@@ -15,6 +15,8 @@ import com.sckw.core.model.enums.SigningWayEnum;
 import com.sckw.core.utils.CollectionUtils;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.beans.factory.annotation.Autowired;
+
+import java.math.BigDecimal;
 import java.util.*;
 
 /**
@@ -42,7 +44,7 @@ public class RemoteContractServiceImpl implements RemoteContractService {
             if (Objects.nonNull(kwcContractLogistics)) {
                 Integer status = kwcContractLogistics.getStatus();
                 Integer delFlag = kwcContractLogistics.getDelFlag();
-                if (Objects.equals(status, ContractStatusEnum.SAVE.getCode()) || Objects.equals(status, ContractStatusEnum.COMPLETE.getCode()) || delFlag.equals(Global.YES)) {
+                if (Objects.equals(status, ContractStatusEnum.SAVE.getCode()) || delFlag.equals(Global.YES)) {
                     continue;
                 }
                 map.put(contractId, fillContractLogistics(kwcContractLogistics));
@@ -53,7 +55,7 @@ public class RemoteContractServiceImpl implements RemoteContractService {
             if (Objects.nonNull(kwcContractTrade)) {
                 Integer status = kwcContractTrade.getStatus();
                 Integer delFlag = kwcContractTrade.getDelFlag();
-                if (Objects.equals(status, ContractStatusEnum.SAVE.getCode()) || Objects.equals(status, ContractStatusEnum.COMPLETE.getCode()) || delFlag.equals(Global.YES)) {
+                if (Objects.equals(status, ContractStatusEnum.SAVE.getCode()) || delFlag.equals(Global.YES)) {
                     continue;
                 }
                 map.put(contractId, fillContractTrade(kwcContractTrade));
@@ -62,6 +64,29 @@ public class RemoteContractServiceImpl implements RemoteContractService {
         return map;
     }
 
+
+    /**
+     * @param contractId 合同id  performedAmount履约量
+     * @desc: 更新已履约量
+     * @author: czh
+     * @date: 2023/8/31
+     */
+    @Override
+    public void updatePerformed(Long contractId, BigDecimal performedAmount) {
+        KwcContractLogistics kwcContractLogistics = kwcContractLogisticsMapper.selectById(contractId);
+        if (Objects.nonNull(kwcContractLogistics)) {
+            kwcContractLogistics.setPerformedAmount(kwcContractLogistics.getPerformedAmount().add(performedAmount));
+            kwcContractLogisticsMapper.updateById(kwcContractLogistics);
+            return;
+        }
+
+        KwcContractTrade kwcContractTrade = kwcContractTradeMapper.selectById(contractId);
+        if (Objects.nonNull(kwcContractTrade)) {
+            kwcContractTrade.setPerformedAmount(kwcContractTrade.getPerformedAmount().add(performedAmount));
+            kwcContractTradeMapper.updateById(kwcContractTrade);
+        }
+    }
+
     private ContractCommonInfoResDto fillContractLogistics(KwcContractLogistics kwcContractLogistics) {
         ContractCommonInfoResDto contractCommonInfoResDto = new ContractCommonInfoResDto();
         List<EntInfo> entList = new ArrayList<>();

+ 0 - 1
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmAddressController.java

@@ -1,6 +1,5 @@
 package com.sckw.manage.controller;
 
-import com.sckw.core.exception.SystemException;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.manage.model.vo.req.*;

+ 0 - 1
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmCooperateApplyController.java

@@ -1,6 +1,5 @@
 package com.sckw.manage.controller;
 
-import com.sckw.core.exception.SystemException;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.manage.model.vo.req.CooperateApplyQueryReqVo;

+ 0 - 1
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmCooperateManageController.java

@@ -1,6 +1,5 @@
 package com.sckw.manage.controller;
 
-import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.enums.CooperateStatusEnum;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;

+ 5 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/dto/req/CooperateManageQueryReqDto.java

@@ -48,6 +48,11 @@ public class CooperateManageQueryReqDto {
      */
     private List<Long> currentEntIdList;
 
+    /**
+     * 对方企业id
+     */
+    private List<Long> targetEntIdList;
+
     /**
      * 申请状态
      */

+ 3 - 9
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java

@@ -145,17 +145,17 @@ public class CommonBusinessService {
             return Collections.emptyList();
         }
 
-        return getCooperateManageQueryResVos(reqDto, list);
+        return getCooperateManageQueryResVos(list);
     }
 
     /**
-     * @param reqDto 入参  list数据
+     * @param list 数据
      * @return CooperateManageQueryResVo
      * @desc: 组装返参
      * @author: czh
      * @date: 2023/8/2
      */
-    public List<CooperateManageQueryResVo> getCooperateManageQueryResVos(CooperateManageQueryReqDto reqDto, List<CooperateManageQueryResDto> list) {
+    public List<CooperateManageQueryResVo> getCooperateManageQueryResVos(List<CooperateManageQueryResDto> list) {
         //dubbo接口查用户和企业
         Long entId = LoginUserHolder.getEntId();
         List<Long> userIds = list.stream().map(CooperateManageQueryResDto::getCreateBy).distinct().toList();
@@ -179,12 +179,6 @@ public class CommonBusinessService {
         for (CooperateManageQueryResDto cooperateManageQueryResDto : list) {
             Long targetEntId = cooperateManageQueryResDto.getTargetEntId();
             String targetEntName = entMap.get(targetEntId);
-            String keywords = reqDto.getKeywords();
-            if (StringUtils.isNotBlank(keywords)) {
-                if (StringUtils.isBlank(targetEntName) || (!targetEntName.contains(keywords) && !matchContacts(keywords, cooperateManageQueryResDto))) {
-                    continue;
-                }
-            }
 
             CooperateManageQueryResVo cooperateManageQueryResVo = new CooperateManageQueryResVo();
             cooperateManageQueryResVo.setId(cooperateManageQueryResDto.getId());

+ 12 - 13
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java

@@ -79,19 +79,19 @@ public class KwmCooperateApplyService {
             return PageHelperUtil.getPageResult(new PageInfo<>());
         }
 
-        List<CooperateManageQueryResVo> cooperateManageQueryResVos = getCooperateManageQueryResVos(reqDto, list);
+        List<CooperateManageQueryResVo> cooperateManageQueryResVos = getCooperateManageQueryResVos(list);
         return PageHelperUtil.getPageResult(new PageInfo<>(cooperateManageQueryResVos), list, reqVo.getPageSize());
     }
 
 
     /**
-     * @param reqDto 入参  list数据
+     * @param   list 数据
      * @return CooperateManageQueryResVo
      * @desc: 组装返参
      * @author: czh
      * @date: 2023/8/2
      */
-    public List<CooperateManageQueryResVo> getCooperateManageQueryResVos(CooperateManageQueryReqDto reqDto, List<CooperateManageQueryResDto> list) {
+    public List<CooperateManageQueryResVo> getCooperateManageQueryResVos(List<CooperateManageQueryResDto> list) {
         //dubbo接口查用户和企业
         Long entId = LoginUserHolder.getEntId();
         List<Long> userIds = list.stream().map(CooperateManageQueryResDto::getCreateBy).distinct().toList();
@@ -115,12 +115,6 @@ public class KwmCooperateApplyService {
         for (CooperateManageQueryResDto cooperateManageQueryResDto : list) {
             Long targetEntId = cooperateManageQueryResDto.getTargetEntId();
             String targetEntName = entMap.get(targetEntId);
-            String keywords = reqDto.getKeywords();
-            if (StringUtils.isNotBlank(keywords)) {
-                if (StringUtils.isBlank(targetEntName) || (!targetEntName.contains(keywords) && !commonBusinessService.matchContacts(keywords, cooperateManageQueryResDto))) {
-                    continue;
-                }
-            }
 
             CooperateManageQueryResVo cooperateManageQueryResVo = new CooperateManageQueryResVo();
             cooperateManageQueryResVo.setId(cooperateManageQueryResDto.getId());
@@ -209,6 +203,13 @@ public class KwmCooperateApplyService {
             }
         }
         cooperateManageQueryReqDto.setCurrentEntIdList(currentEntIdList);
+
+        if (StringUtils.isNotBlank(reqVo.getKeywords())) {
+            List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByName(reqVo.getKeywords());
+            if (CollectionUtils.isNotEmpty(entCacheResDtos)) {
+                cooperateManageQueryReqDto.setTargetEntIdList(entCacheResDtos.stream().map(EntCacheResDto::getId).toList());
+            }
+        }
         return cooperateManageQueryReqDto;
     }
 
@@ -512,7 +513,7 @@ public class KwmCooperateApplyService {
         if (CollectionUtils.isEmpty(list)) {
             return;
         }
-        List<CooperateManageQueryResVo> cooperateManageQueryResVos = getCooperateManageQueryResVos(reqDto, list);
+        List<CooperateManageQueryResVo> cooperateManageQueryResVos = getCooperateManageQueryResVos(list);
         if (CollectionUtils.isEmpty(cooperateManageQueryResVos)) {
             return;
         }
@@ -535,14 +536,12 @@ public class KwmCooperateApplyService {
     public List<FindListGroupResVo> findListGroup(CooperateApplyQueryReqVo reqVo) {
         //初始化分组返参
         List<FindListGroupResVo> result = commonBusinessService.init();
-
-        CooperateManageQueryReqDto reqDto = buildQueryParam(reqVo);
         List<CooperateManageQueryResDto> list = kwmCooperateMapper.findList(buildQueryParam(reqVo));
         if (CollectionUtils.isEmpty(list)) {
             return result;
         }
 
-        List<CooperateManageQueryResVo> cooperateManageQueryResVos = getCooperateManageQueryResVos(reqDto, list);
+        List<CooperateManageQueryResVo> cooperateManageQueryResVos = getCooperateManageQueryResVos(list);
         if (CollectionUtils.isEmpty(cooperateManageQueryResVos)) {
             return result;
         }

+ 9 - 4
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -41,7 +41,6 @@ import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.Assert;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -90,7 +89,7 @@ public class KwmCooperateManageService {
         if (CollectionUtils.isEmpty(list)) {
             return PageHelperUtil.getPageResult(new PageInfo<>());
         }
-        List<CooperateManageQueryResVo> cooperateManageQueryResVos = commonBusinessService.getCooperateManageQueryResVos(reqDto, list);
+        List<CooperateManageQueryResVo> cooperateManageQueryResVos = commonBusinessService.getCooperateManageQueryResVos(list);
         return PageHelperUtil.getPageResult(new PageInfo<>(cooperateManageQueryResVos), list, reqVo.getPageSize());
     }
 
@@ -145,6 +144,12 @@ public class KwmCooperateManageService {
         }
         cooperateManageQueryReqDto.setCurrentEntIdList(currentEntIdList);
 
+        if (StringUtils.isNotBlank(reqVo.getKeywords())) {
+            List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByName(reqVo.getKeywords());
+            if (CollectionUtils.isNotEmpty(entCacheResDtos)) {
+                cooperateManageQueryReqDto.setTargetEntIdList(entCacheResDtos.stream().map(EntCacheResDto::getId).toList());
+            }
+        }
         return cooperateManageQueryReqDto;
     }
 
@@ -292,7 +297,7 @@ public class KwmCooperateManageService {
         if (CollectionUtils.isEmpty(list)) {
             return ;
         }
-        List<CooperateManageQueryResVo> cooperateManageQueryResVos = commonBusinessService.getCooperateManageQueryResVos(reqDto, list);
+        List<CooperateManageQueryResVo> cooperateManageQueryResVos = commonBusinessService.getCooperateManageQueryResVos(list);
         if (CollectionUtils.isEmpty(cooperateManageQueryResVos)) {
             return;
         }
@@ -321,7 +326,7 @@ public class KwmCooperateManageService {
         if (CollectionUtils.isEmpty(list)) {
             return result;
         }
-        List<CooperateManageQueryResVo> cooperateManageQueryResVos = commonBusinessService.getCooperateManageQueryResVos(reqDto, list);
+        List<CooperateManageQueryResVo> cooperateManageQueryResVos = commonBusinessService.getCooperateManageQueryResVos(list);
         if (CollectionUtils.isEmpty(cooperateManageQueryResVos)) {
             return result;
         }

+ 87 - 32
sckw-modules/sckw-manage/src/main/resources/mapper/KwmCooperateMapper.xml

@@ -33,36 +33,58 @@
     <select id="findList" parameterType="com.sckw.manage.model.dto.req.CooperateManageQueryReqDto"
             resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">
         SELECT a.id,
-               b.status,
-               group_concat(b.type) types,
-               min(a.ent_id) entId,
-               min(a.invitee_ent_id) inviteeEntId,
-               min(a.inviter_ent_id) inviterEntId,
-               min(a.invitee_contacts) inviteeContacts,
-               min(a.inviter_contacts) inviterContacts,
-               min(a.invitee_contacts_id) inviteeContactsId,
-               min(a.inviter_contacts_id) inviterContactsId,
-               min(a.invitee_phone) inviteePhone,
-               min(a.inviter_phone) inviterPhone,
-               min(b.create_time) createTime,
-               min(b.create_by) createBy,
-               min(a.remark) remark,
-               min(a.approval_remark) approvalRemark,
-               case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.invitee_ent_id) else min(a.inviter_ent_id) end targetEntId,
-               case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.inviter_ent_id) else min(a.invitee_ent_id) end ourEntId,
-               case when min(a.ent_id) = #{reqDto.currentEntId} then 1 else 2 end applyTypeCode
-          FROM kwm_cooperate a
-          LEFT JOIN kwm_cooperate_type b ON a.id = b.cooperate_id
-         WHERE a.del_flag = 0
-           and (a.invitee_ent_id in
+        b.status,
+        group_concat(b.type) types,
+        min(a.ent_id) entId,
+        min(a.invitee_ent_id) inviteeEntId,
+        min(a.inviter_ent_id) inviterEntId,
+        min(a.invitee_contacts) inviteeContacts,
+        min(a.inviter_contacts) inviterContacts,
+        min(a.invitee_contacts_id) inviteeContactsId,
+        min(a.inviter_contacts_id) inviterContactsId,
+        min(a.invitee_phone) inviteePhone,
+        min(a.inviter_phone) inviterPhone,
+        min(b.create_time) createTime,
+        min(b.create_by) createBy,
+        min(a.remark) remark,
+        min(a.approval_remark) approvalRemark,
+        case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.invitee_ent_id) else min(a.inviter_ent_id) end
+        targetEntId,
+        case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.inviter_ent_id) else min(a.invitee_ent_id) end
+        ourEntId,
+        case when min(a.ent_id) = #{reqDto.currentEntId} then 1 else 2 end applyTypeCode
+        FROM kwm_cooperate a
+        LEFT JOIN kwm_cooperate_type b ON a.id = b.cooperate_id
+        WHERE a.del_flag = 0
+          and ((a.invitee_ent_id in
                 <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
-                OR a.inviter_ent_id in
+
+                <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
+                    and (a.inviter_ent_id in
+                    <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                          or a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
+                            a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
+                        )
+                </if>
+                ) OR
+               (a.inviter_ent_id in
                 <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
-               )
+                <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
+                    and (a.invitee_ent_id in
+                    <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                        or a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
+                        a.invitee_phone like concat('%', #{reqDto.keywords}, '%')
+                        )
+                </if>
+               ))
            <if test="reqDto.startTime != null">
                and b.create_time >= #{reqDto.startTime}
            </if>
@@ -93,6 +115,13 @@
                  #{item}
              </foreach>
          </if>
+        <if test="reqDto.keywords != null and reqDto.keywords != ''">
+            and (a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
+                 a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
+                 a.invitee_phone like concat('%', #{reqDto.keywords}, '%') or
+                 a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
+                )
+        </if>
          <if test="reqDto.ids != null and reqDto.ids.size() > 0">
              and a.id in
              <foreach collection="reqDto.ids" item="item" open="(" close=")" separator=",">
@@ -153,15 +182,34 @@
         FROM kwm_cooperate a
         LEFT JOIN kwm_cooperate_type b ON a.id = b.cooperate_id and b.status = 1 and b.del_flag = 0
         WHERE a.del_flag = 0
-        and (a.invitee_ent_id in
-            <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
-                #{item}
-            </foreach>
-            OR a.inviter_ent_id in
-            <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
-                #{item}
-            </foreach>
+        and ((a.invitee_ent_id in
+                <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
+                  #{item}
+                </foreach>
+                <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
+                    and (a.inviter_ent_id in
+                    <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                            or a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
+                            a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
+                            )
+                </if>
             )
+            OR (a.inviter_ent_id in
+                <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+                <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
+                    and (a.invitee_ent_id in
+                    <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                        or a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
+                        a.invitee_phone like concat('%', #{reqDto.keywords}, '%')
+                       )
+                </if>
+            ))
         <if test="reqDto.startTime != null">
             and b.create_time >= #{reqDto.startTime}
         </if>
@@ -192,6 +240,13 @@
                 #{item}
             </foreach>
         </if>
+        <if test="reqDto.keywords != null">
+            and (a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
+                 a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
+                 a.invitee_phone like concat('%', #{reqDto.keywords}, '%') or
+                 a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
+                )
+        </if>
         <if test="reqDto.ids != null and reqDto.ids.size() > 0">
             and a.id in
             <foreach collection="reqDto.ids" item="item" open="(" close=")" separator=",">

+ 2 - 0
sckw-modules/sckw-report/src/main/java/com/sckw/report/consumer/SckwBusSumConsumer.java

@@ -145,6 +145,8 @@ public class SckwBusSumConsumer {
                 BeanUtils.copyPropertiesValue(order, order1);
                 order1.setWOrderId(null);
                 order1.setWOrderNo(null);
+                order1.setLoadTime(null);
+                order1.setUnloadTime(null);
                 waybillOrderRepository.insert(order1);
             }
         }

+ 57 - 35
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java

@@ -19,6 +19,8 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
+import org.springframework.data.mongodb.core.aggregation.AggregationResults;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
@@ -66,20 +68,22 @@ public class KwOrderService {
      * @return: com.sckw.core.model.page.PageResult
      */
     public PageResult tradeOrderSelect(TradeOrderListSelectParam params) {
-        Query query = getQuery(params, false);
-        return getResult(query, params.getPage(), params.getPageSize());
+        Criteria criteria = buildCriteria(params, false);
+        return getResult(criteria, params.getPage(), params.getPageSize());
     }
 
     /**
      * @desc: 获取分页结果
      * @author: yzc
      * @date: 2023-07-20 15:02
-     * @Param query:
+     * @Param criteria:
      * @Param page:
      * @Param pageSize:
      * @return: com.sckw.core.model.page.PageResult
      */
-    private PageResult getResult(Query query, int page, int pageSize) {
+    private PageResult getResult(Criteria criteria, int page, int 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);
@@ -121,17 +125,16 @@ public class KwOrderService {
     }
 
     /**
-     * @desc: 组装query
+     * @desc: 组装Criteria
      * @author: yzc
      * @date: 2023-07-17 18:08
      * @Param params:
      * @Param isStatistic:
-     * @return: org.springframework.data.mongodb.core.query.Query
+     * @return: org.springframework.data.mongodb.core.query.Criteria
      */
-    private Query getQuery(TradeOrderListStatisticParam params, Boolean isStatistic) {
+    private Criteria buildCriteria(TradeOrderListStatisticParam params, Boolean isStatistic) {
         Long entId = LoginUserHolder.getEntId();
         Long userId = LoginUserHolder.getUserId();
-        Query query = new Query();
         Criteria criteria = new Criteria();
         String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
         criteria.and(topEnt).is(entId).and("delFlag").is(0);
@@ -207,7 +210,7 @@ public class KwOrderService {
         if (CollectionUtils.isNotEmpty(orOperators)) {
             criteria.andOperator(orOperators);
         }
-        return query.addCriteria(criteria);
+        return criteria;
     }
 
     /**
@@ -219,25 +222,37 @@ public class KwOrderService {
      */
     public TableStatisticRes tradeOrderStatistic(TradeOrderListStatisticParam params) {
         TableStatisticRes res = new TableStatisticRes();
-        Query query = getQuery(params, true);
-        List<SckwTradeOrder> orders = mongoTemplate.find(query, SckwTradeOrder.class);
-        Map<Integer, List<SckwTradeOrder>> map = orders.stream().collect(Collectors.groupingBy(SckwTradeOrder::getStatus));
-        List<TableTop> tableTops = new ArrayList<>();
-        TableTop all = new TableTop();
-        all.setName("全部").setTotal(CollectionUtils.isEmpty(orders) ? 0 : orders.size());
-        tableTops.add(all);
+        Criteria criteria = buildCriteria(params, true);
+        Aggregation aggregation = Aggregation.newAggregation(
+                Aggregation.match(criteria),
+                Aggregation.group("status").count().as("total"),
+                Aggregation.project("total").and("value").previousOperation()
+        );
+        AggregationResults<TableTop> aggregate = mongoTemplate
+                .aggregate(aggregation, SckwTradeOrder.class, TableTop.class);
+        List<TableTop> tableTops = aggregate.getMappedResults();
+        Map<Integer, Integer> map = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(tableTops)) {
+            map = tableTops.stream().collect(Collectors.toMap
+                    (TableTop::getValue, TableTop::getTotal, (k1, k2) -> k2));
+        }
+        List<TableTop> list = new ArrayList<>();
         List<DictEnum> tOrderStatusEnums = DictEnum.getEnumsByType(DictTypeEnum.TORDER_STATUS.getType());
-        tOrderStatusEnums.forEach(e -> {
+        int count = 0;
+        for (DictEnum e : tOrderStatusEnums) {
             Integer value = Integer.valueOf(e.getValue());
-            List<SckwTradeOrder> list = map.get(value);
-            int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
+            int total = Objects.isNull(map.get(value)) ? 0 : map.get(value);
             TableTop tableTop = new TableTop();
             tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
-            tableTops.add(tableTop);
-        });
+            list.add(tableTop);
+            count = count + total;
+        }
+        TableTop all = new TableTop();
+        all.setName("全部").setTotal(count);
+        list.add(all);
         TableBottom tableBottom = new TableBottom();
-        tableBottom.setTotal(CollectionUtils.isEmpty(orders) ? 0 : orders.size());
-        res.setTableTops(tableTops).setTableBottom(tableBottom);
+        tableBottom.setTotal(count);
+        res.setTableTops(list).setTableBottom(tableBottom);
         return res;
     }
 
@@ -255,17 +270,26 @@ public class KwOrderService {
         Query query = new Query();
         Criteria criteria = new Criteria();
         criteria.and(topEnt).is(entId).and("status").in(status).and("delFlag").is(0);
-        query.addCriteria(criteria);
-        List<SckwTradeOrder> orders = mongoTemplate.find(query, SckwTradeOrder.class);
-        Map<Integer, List<SckwTradeOrder>> map = orders.stream().collect(Collectors.groupingBy(SckwTradeOrder::getStatus));
+        Aggregation aggregation = Aggregation.newAggregation(
+                Aggregation.match(criteria),
+                Aggregation.group("status").count().as("total"),
+                Aggregation.project("total").and("value").previousOperation()
+        );
+        AggregationResults<TradeOrderAppStatisticVO> aggregate = mongoTemplate
+                .aggregate(aggregation, SckwTradeOrder.class, TradeOrderAppStatisticVO.class);
+        List<TradeOrderAppStatisticVO> tableTops = aggregate.getMappedResults();
+        Map<Integer, Integer> map = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(tableTops)) {
+            map = tableTops.stream().collect(Collectors.toMap
+                    (TradeOrderAppStatisticVO::getValue, TradeOrderAppStatisticVO::getTotal, (k1, k2) -> k2));
+        }
         List<TradeOrderAppStatisticVO> statistics = new ArrayList<>();
-        status.forEach(e -> {
-            List<SckwTradeOrder> list = map.get(e);
-            int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
+        for (Integer e : status) {
+            int total = Objects.isNull(map.get(e)) ? 0 : map.get(e);
             TradeOrderAppStatisticVO statistic = new TradeOrderAppStatisticVO();
             statistic.setValue(e).setTotal(total);
             statistics.add(statistic);
-        });
+        }
         return statistics;
     }
 
@@ -287,7 +311,7 @@ public class KwOrderService {
             criteria.and("_id").in(ids).and(topEnt).is(entId).and("delFlag").is(0);
             query.addCriteria(criteria);
         } else {
-            query = getQuery(params, false);
+            query.addCriteria(buildCriteria(params, false));
         }
         query.with(Sort.by(Sort.Order.desc("createTime")));
         List<SckwTradeOrder> orders = mongoTemplate.find(query, SckwTradeOrder.class);
@@ -333,7 +357,6 @@ public class KwOrderService {
      * @return: com.sckw.core.model.page.PageResult
      */
     public PageResult tradeOrderStatementList(TradeOrderStatementList params) {
-        Query query = new Query();
         Long entId = LoginUserHolder.getEntId();
         Criteria criteria = new Criteria();
         String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
@@ -349,7 +372,7 @@ public class KwOrderService {
             criteria.and("procureEntId").is(params.getProcureEntId());
         }
         //交易方式
-        if(StringUtils.isNotBlank(params.getTrading())){
+        if (StringUtils.isNotBlank(params.getTrading())) {
             criteria.and("trading").is(params.getTrading());
         }
         //计划开始时间
@@ -369,8 +392,7 @@ public class KwOrderService {
             Pattern pattern = Pattern.compile("^.*" + params.getGoodsName() + ".*$", Pattern.CASE_INSENSITIVE);
             criteria.and("goodsName").regex(pattern);
         }
-        query.addCriteria(criteria);
-        return getResult(query, params.getPage(), params.getPageSize());
+        return getResult(criteria, params.getPage(), params.getPageSize());
     }
 
     /**

+ 0 - 4
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java

@@ -708,8 +708,6 @@ public class KwtWaybillOrderService {
         order.setDriverIdcard(sendCarDto.getDriverIdcard());
 
         //运输信息
-        order.setLoadTime(sendCarDto.getLoadDateTime());
-        order.setUnloadTime(sendCarDto.getUnloadDateTime());
         order.setType(sendCarDto.getType());
         order.setStartTime(sendCarDto.getLoadDateTime());
         order.setEndTime(sendCarDto.getUnloadDateTime());
@@ -794,8 +792,6 @@ public class KwtWaybillOrderService {
         order.setWOrderNo(null);
 
         //运输信息
-        order.setLoadTime(circulate.getStartTime());
-        order.setUnloadTime(circulate.getEndTime());
         order.setLoadAmount(new BigDecimal(Global.AMOUNT));
         order.setLoadTareAmount(new BigDecimal(Global.AMOUNT));
         order.setLoadGrossAmount(new BigDecimal(Global.AMOUNT));