Procházet zdrojové kódy

1.新增承运订单导入功能
2.新增企业查询接口
3.新增物流合同唯一校验

lengfaqiang před 2 roky
rodič
revize
479a4dd72e
20 změnil soubory, kde provedl 705 přidání a 57 odebrání
  1. 15 0
      sckw-common/sckw-common-stream/src/main/java/com/sckw/stream/enums/MessageEnum.java
  2. 8 1
      sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/RemoteContractService.java
  3. 5 0
      sckw-modules-api/sckw-manage-api/src/main/java/com/sckw/manage/api/RemoteManageService.java
  4. 36 0
      sckw-modules-api/sckw-manage-api/src/main/java/com/sckw/manage/api/model/dto/res/FindCooperateByEntReqVo.java
  5. 95 0
      sckw-modules-api/sckw-manage-api/src/main/java/com/sckw/manage/api/model/dto/res/FindCooperateByEntResVo.java
  6. 11 0
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dao/KwcContractLogisticsMapper.java
  7. 16 7
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dubbo/RemoteContractServiceImpl.java
  8. 14 6
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsService.java
  9. 28 0
      sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractLogisticsMapper.xml
  10. 123 2
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/dubbo/RemoteManageServiceImpl.java
  11. 6 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/KwpGoods.java
  12. 4 2
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java
  13. 1 1
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwWorkService.java
  14. 10 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java
  15. 12 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/res/EntFindPageResVo.java
  16. 36 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java
  17. 15 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderImportMapper.java
  18. 30 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtLogisticsOrderImport.java
  19. 208 37
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/Import/KwtAcceptCarriageOrderImportService.java
  20. 32 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtCommonService.java

+ 15 - 0
sckw-common/sckw-common-stream/src/main/java/com/sckw/stream/enums/MessageEnum.java

@@ -160,6 +160,13 @@ public enum MessageEnum {
     NEW_LOGISTICS_ORDER("BUSINESS", "BUSINESS_NEW_LOGISTICS_ORDER", "自建物流订单",
             "贵司通过自建物流订单,发起了对【${companyName}】的物流分配计划,请留意后续消息;订单号:${orderNo}", "terminal,ios,android", "托运订单-自建物流订单"),
 
+    /**
+     * 托运订单-承运商批量导入订单
+     */
+    ACCEPT_CARRIAGE_IMPORT_EXCEL("BUSINESS", "ACCEPT_CARRIAGE_IMPORT_EXCEL", "承运商批量导入订单",
+            "【${companyName}】通过批量操作生成了【${number}】条物流订单,请及时确认", "terminal,ios,android", "托运订单-承运商批量导入"),
+
+
     /**
      * 托运订单-撤回物流分配计划
      */
@@ -171,6 +178,14 @@ public enum MessageEnum {
      */
     REJECT_ORDER("BUSINESS", "BUSINESS_REJECT_ORDER", "承运方拒绝订单",
             "你的物流托运任务被【【${companyName}】拒绝接单,请及时查看;订单号:${orderNo}", "terminal,ios,android", "托运订单-承运方拒绝订单"),
+
+    /**
+     * 承运订单-批量导入承运订单
+     */
+    CONSIGN_IMPORT_EXCEL("BUSINESS", "CONSIGN_IMPORT_EXCEL", "批量导入承运订单",
+            "贵司通过批量操作导入了【${number}】条物流订单,请及时确认", "terminal,ios,android", "承运订单-批量导入承运订单"),
+
+
     /**
      * 承运订单-有新分配的承运任务
      */

+ 8 - 1
sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/RemoteContractService.java

@@ -41,5 +41,12 @@ public interface RemoteContractService {
     Map<Integer, Integer> queryContractValidCount(Long entId,List<Long> enterpriseIds);
 
 
-    ContractLogisticsOrderResDto getContractByContractNo(String contractNo);
+    /**
+     *
+     * @param contractNo
+     * @param acceptId 承运企业id
+     * @param consignId 托运企业id
+     * @return
+     */
+    ContractLogisticsOrderResDto getContractByContractNo(String contractNo, Long acceptId, Long consignId);
 }

+ 5 - 0
sckw-modules-api/sckw-manage-api/src/main/java/com/sckw/manage/api/RemoteManageService.java

@@ -1,6 +1,8 @@
 package com.sckw.manage.api;
 
 import com.sckw.manage.api.model.dto.res.EntAddressResDto;
+import com.sckw.manage.api.model.dto.res.FindCooperateByEntReqVo;
+import com.sckw.manage.api.model.dto.res.FindCooperateByEntResVo;
 import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
 
 import java.util.List;
@@ -40,4 +42,7 @@ public interface RemoteManageService {
      */
     List<FindEntCooperateResVo> findAllCooperateEnt(Long entId);
 
+
+    List<FindCooperateByEntResVo> findCooperateByEnt(FindCooperateByEntReqVo reqVo);
+
 }

+ 36 - 0
sckw-modules-api/sckw-manage-api/src/main/java/com/sckw/manage/api/model/dto/res/FindCooperateByEntReqVo.java

@@ -0,0 +1,36 @@
+package com.sckw.manage.api.model.dto.res;
+
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 通过企业查合作信息
+ * @date 2023/8/1
+ */
+@Data
+public class FindCooperateByEntReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -8336489430768187668L;
+
+    /**
+     * 当前企业
+     */
+    @NotNull(message = "当前企业不能为空")
+    private Long entId;
+
+    /**
+     * 对方企业
+     */
+    private Long targetEntId;
+
+    /**
+     * 合作属性 1供应商,2采购商,3托运商,4承运商
+     */
+    private Integer cooperateType;
+
+}

+ 95 - 0
sckw-modules-api/sckw-manage-api/src/main/java/com/sckw/manage/api/model/dto/res/FindCooperateByEntResVo.java

@@ -0,0 +1,95 @@
+package com.sckw.manage.api.model.dto.res;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 通过企业查合作信息
+ * @date 2023/8/1
+ */
+@Data
+public class FindCooperateByEntResVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 6831940531630253367L;
+
+    /**
+     * 合作id
+     */
+    private Long id;
+
+    /**
+     * 合作类型
+     */
+    private String cooperateTypes;
+
+    /**
+     * 我方企业id
+     */
+    private Long entId;
+
+    /**
+     * 我方企业名
+     */
+    private String entName;
+
+    /**
+     * 对方企业id
+     */
+    private Long targetEntId;
+
+    /**
+     * 对方企业名
+     */
+    private String targetEntName;
+
+    /**
+     * 发起方企业id
+     */
+    private Long initiateEntId;
+
+    /**
+     * 发起方企业名
+     */
+    private String initiateEntName;
+
+    /**
+     * 我方联系人id
+     */
+    private Long contactsId;
+
+    /**
+     * 我方联系人姓名
+     */
+    private String contacts;
+
+    /**
+     * 我方联系电话
+     */
+    private String phone;
+
+    /**
+     * 对方联系人id
+     */
+    private Long targetContactsId;
+
+    /**
+     * 对方联系人姓名
+     */
+    private String targetContacts;
+
+    /**
+     * 对方联系电话
+     */
+    private String targetPhone;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+}
+

+ 11 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dao/KwcContractLogisticsMapper.java

@@ -37,6 +37,17 @@ public interface KwcContractLogisticsMapper extends BaseMapper<KwcContractLogist
      */
     List<QueryListResDto> queryLogisticsList(@Param("reqVo") QueryListReqVo reqVo, @Param("authEntIdList") List<Long> authEntIdList);
 
+    /**
+     * 判断合同是否唯一
+     *
+     * @param contractCode 合同编号
+     * @param carrierEntId 承运企业id
+     * @param checkedEntId 托运企业id
+     * @return
+     */
+    List<String> checkContractIsSole(@Param("contractCode") String contractCode, @Param("carrierEntId") Long carrierEntId, @Param("checkedEntId") Long checkedEntId);
+
+    List<KwcContractLogistics> selectIsSole(@Param("contractNo") String contractNo, @Param("acceptId") Long acceptId, @Param("consignId") Long consignId);
 }
 
 

+ 16 - 7
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dubbo/RemoteContractServiceImpl.java

@@ -1,11 +1,11 @@
 package com.sckw.contract.dubbo;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.contract.api.RemoteContractService;
 import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
 import com.sckw.contract.api.model.dto.res.ContractLogisticsOrderResDto;
 import com.sckw.contract.api.model.dto.res.EntInfo;
 import com.sckw.contract.dao.KwcContractLogisticsMapper;
+import com.sckw.contract.dao.KwcContractLogisticsUnitMapper;
 import com.sckw.contract.dao.KwcContractTradeMapper;
 import com.sckw.contract.model.dto.res.QueryContractValidCountResDto;
 import com.sckw.contract.model.entity.KwcContractLogistics;
@@ -37,13 +37,16 @@ public class RemoteContractServiceImpl implements RemoteContractService {
     @Autowired
     private KwcContractLogisticsMapper kwcContractLogisticsMapper;
 
+    @Autowired
+    private KwcContractLogisticsUnitMapper kwcContractLogisticsUnitMapper;
+
     @Autowired
     private KwcContractLogisticsUnitService kwcContractLogisticsUnitService;
 
     @Autowired
     private KwcContractTradeMapper kwcContractTradeMapper;
 
-    @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 8000)
+    @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
     private RemoteSystemService remoteSystemService;
 
     @Override
@@ -153,12 +156,18 @@ public class RemoteContractServiceImpl implements RemoteContractService {
         return queryContractValidCountResDtos.stream().collect(Collectors.toMap(QueryContractValidCountResDto::getUnitType, QueryContractValidCountResDto::getCnt, (o, n) -> n));
     }
 
+    /**
+     * @param contractNo 合同编号
+     * @param acceptId   承运企业id
+     * @param consignId  托运企业id
+     * @return
+     */
     @Override
-    public ContractLogisticsOrderResDto getContractByContractNo(String contractNo) {
-        ContractLogisticsOrderResDto logisticsOrderResDto = new ContractLogisticsOrderResDto();
-        KwcContractLogistics contractLogistics = kwcContractLogisticsMapper.selectOne(new LambdaQueryWrapper<KwcContractLogistics>()
-                .eq(KwcContractLogistics::getContractNo, contractNo));
-        if (contractLogistics != null) {
+    public ContractLogisticsOrderResDto getContractByContractNo(String contractNo, Long acceptId, Long consignId) {
+        ContractLogisticsOrderResDto logisticsOrderResDto = null;
+        List<KwcContractLogistics> list = kwcContractLogisticsMapper.selectIsSole(contractNo, acceptId, consignId);
+        if (list.size() > 0) {
+            KwcContractLogistics contractLogistics = list.get(0);
             logisticsOrderResDto.setId(contractLogistics.getId());
             logisticsOrderResDto.setContactName(contractLogistics.getName());
             logisticsOrderResDto.setContractNo(contractLogistics.getContractNo());

+ 14 - 6
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsService.java

@@ -17,6 +17,7 @@ import com.sckw.contract.model.vo.req.*;
 import com.sckw.contract.model.vo.res.*;
 import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.exception.BusinessException;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.ContractStatusEnum;
@@ -134,7 +135,15 @@ public class KwcContractLogisticsService {
             update(reqVo);
             return id;
         }
-
+        //合同编号+企业双方判定唯一
+        String contractCode = baseInfo.getContractCode();
+        String key = contractCode + baseInfo.getCarrierEntId() + baseInfo.getCheckedEntId();
+        List<String> isSoleKey = kwcContractLogisticsMapper.checkContractIsSole(contractCode, baseInfo.getCarrierEntId(), baseInfo.getCheckedEntId());
+        if (isSoleKey.size() > 0) {
+            if (isSoleKey.contains(key)) {
+                throw new BusinessException("新增合同时,合同编号一致时,双方已存在合同,不可重复创建!");
+            }
+        }
         //创建合同
         KwcContractLogistics kwcContractLogistics = getKwcContractLogistics(baseInfo, goodsInfo, reqVo.getRemark(), reqVo.getPid());
         long contactId = new IdWorker(1L).nextId();
@@ -457,7 +466,6 @@ public class KwcContractLogisticsService {
     }
 
 
-
     private void sendLogisticsMessage(KwcContractLogistics kwcContractLogistics) {
         try {
             List<KwcContractLogisticsUnit> kwcContractLogisticsUnits = kwcContractLogisticsUnitService.queryByContractId(kwcContractLogistics.getId());
@@ -653,7 +661,7 @@ public class KwcContractLogisticsService {
                     acceptanceSendContract,
                     appAcceptanceSendContract);
         } catch (Exception e) {
-           log.error("完结合同消息出错:", e);
+            log.error("完结合同消息出错:", e);
         }
     }
 
@@ -911,7 +919,7 @@ public class KwcContractLogisticsService {
             authEntIdList.addAll(ids);
         }
 
-        List<QueryListResDto> queryListResDtos = kwcContractLogisticsMapper.queryLogisticsList(reqVo,authEntIdList);
+        List<QueryListResDto> queryListResDtos = kwcContractLogisticsMapper.queryLogisticsList(reqVo, authEntIdList);
         if (CollectionUtils.isEmpty(queryListResDtos)) {
             return PageHelperUtil.getPageResult(new PageInfo<>());
         }
@@ -978,7 +986,7 @@ public class KwcContractLogisticsService {
             }
             authEntIdList.addAll(ids);
         }
-        List<QueryListResDto> queryListResDtoList = kwcContractLogisticsMapper.queryLogisticsList(reqVo,authEntIdList);
+        List<QueryListResDto> queryListResDtoList = kwcContractLogisticsMapper.queryLogisticsList(reqVo, authEntIdList);
         if (CollectionUtils.isNotEmpty(queryListResDtoList)) {
             Map<Integer, List<QueryListResDto>> collect = queryListResDtoList.stream().collect(Collectors.groupingBy(QueryListResDto::getStatus));
             for (FindListGroupResVo findListGroupResVo : list) {
@@ -1009,7 +1017,7 @@ public class KwcContractLogisticsService {
             }
             authEntIdList.addAll(ids);
         }
-        List<QueryListResDto> queryListResDtos = kwcContractLogisticsMapper.queryLogisticsList(reqVo,authEntIdList);
+        List<QueryListResDto> queryListResDtos = kwcContractLogisticsMapper.queryLogisticsList(reqVo, authEntIdList);
         if (CollectionUtils.isEmpty(queryListResDtos)) {
             throw new SystemException(HttpStatus.SUCCESS_CODE, "暂无数据,请确认!");
         }

+ 28 - 0
sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractLogisticsMapper.xml

@@ -160,4 +160,32 @@
         order by a.create_time desc
     </select>
 
+    <select id="checkContractIsSole" resultType="java.lang.String">
+        SELECT
+            DISTINCT CONCAT(a.contract_no,b.ent_id,c.ent_id)  as isSole
+        FROM
+            kwc_contract_logistics a
+                LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
+                LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
+        WHERE
+            a.del_flag = 0
+          AND b.unit_type = 4
+          AND c.unit_type = 3
+    </select>
+
+    <select id="selectIsSole" resultType="com.sckw.contract.model.entity.KwcContractLogistics">
+        SELECT
+            a.*
+        FROM
+            kwc_contract_logistics a
+                LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
+                LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
+        WHERE
+            a.del_flag = 0
+          AND b.unit_type = 4
+          AND c.unit_type = 3
+        and b.ent_id =#{acceptId}
+        and c.ent_id =#{consignId}
+        and a.contract_no=#{contractNo}
+    </select>
 </mapper>

+ 123 - 2
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/dubbo/RemoteManageServiceImpl.java

@@ -2,23 +2,27 @@ package com.sckw.manage.dubbo;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.CooperateStatusEnum;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.manage.api.RemoteManageService;
 import com.sckw.manage.api.model.dto.res.EntAddressResDto;
 import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
 import com.sckw.manage.dao.KwmAddressMapper;
+import com.sckw.manage.dao.KwmCooperateMapper;
+import com.sckw.manage.dao.KwmCooperateTypeMapper;
 import com.sckw.manage.model.entity.KwmAddress;
 import com.sckw.manage.model.entity.KwmCooperate;
+import com.sckw.manage.model.entity.KwmCooperateType;
 import com.sckw.manage.model.vo.req.FindCooperateByEntReqVo;
 import com.sckw.manage.model.vo.req.FindEntCooperateReqVo;
 import com.sckw.manage.model.vo.res.FindCooperateByEntResVo;
+import com.sckw.manage.service.CommonBusinessService;
 import com.sckw.manage.service.KwmCooperateManageService;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.dubbo.config.annotation.DubboService;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.*;
@@ -38,6 +42,15 @@ public class RemoteManageServiceImpl implements RemoteManageService {
     @Autowired
     private KwmCooperateManageService kwmCooperateManageService;
 
+    @Autowired
+    private CommonBusinessService commonBusinessService;
+
+    @Autowired
+    private KwmCooperateMapper kwmCooperateMapper;
+
+    @Autowired
+    private KwmCooperateTypeMapper kwmCooperateTypeMapper;
+
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
 
@@ -76,7 +89,6 @@ public class RemoteManageServiceImpl implements RemoteManageService {
         return BeanUtils.copyToList(entCooperate, FindEntCooperateResVo.class);
     }
 
-
     /**
      * @param entId 集团企业id
      * @return FindEntCooperateResVo
@@ -128,4 +140,113 @@ public class RemoteManageServiceImpl implements RemoteManageService {
 
         return findEntCooperateResVoList;
     }
+
+    @Override
+    public List<com.sckw.manage.api.model.dto.res.FindCooperateByEntResVo> findCooperateByEnt(com.sckw.manage.api.model.dto.res.FindCooperateByEntReqVo reqVo) {
+        FindCooperateByEntReqVo byEntReqVo=new FindCooperateByEntReqVo();
+        org.springframework.beans.BeanUtils.copyProperties(reqVo,byEntReqVo);
+        List<KwmCooperate> kwmCooperates = kwmCooperateMapper.findCooperateByEnt(byEntReqVo);
+        if (CollectionUtils.isEmpty(kwmCooperates)) {
+            return Collections.emptyList();
+        }
+
+        Long entId = reqVo.getEntId();
+        Map<Long, EntCacheResDto> entCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(entId));
+        Long topId = entCacheResDtoMap.get(entId).getId();
+
+        //获取合作属性
+        List<Long> cooperateIdList = kwmCooperates.stream().map(KwmCooperate::getId).toList();
+        LambdaQueryWrapper<KwmCooperateType> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(KwmCooperateType::getCooperateId, cooperateIdList);
+        wrapper.eq(KwmCooperateType::getDelFlag, Global.NO);
+        wrapper.eq(KwmCooperateType::getStatus, CooperateStatusEnum.OK.getCode());
+        List<KwmCooperateType> kwmCooperateTypes = kwmCooperateTypeMapper.selectList(wrapper);
+        Map<Long, List<KwmCooperateType>> collect = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        if (CollectionUtils.isNotEmpty(kwmCooperateTypes)) {
+            collect = kwmCooperateTypes.stream().collect(Collectors.groupingBy(KwmCooperateType::getCooperateId));
+        }
+
+        //获取所有企业信息
+        List<Long> allEntIdList = new ArrayList<>();
+        kwmCooperates.forEach(item -> {
+            allEntIdList.add(item.getEntId());
+            allEntIdList.add(item.getInviterEntId());
+            allEntIdList.add(item.getInviteeEntId());
+        });
+        List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByIds(allEntIdList);
+        Map<Long, EntCacheResDto> entMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        if (CollectionUtils.isNotEmpty(entCacheResDtos)) {
+            entMap = entCacheResDtos.stream().collect(Collectors.toMap(EntCacheResDto::getId, e -> e, (n, o) -> n));
+        }
+
+        List<com.sckw.manage.api.model.dto.res.FindCooperateByEntResVo> list = new ArrayList<>();
+        List<Integer> cooperateTypeList = new ArrayList<>();
+        for (KwmCooperate kwmCooperate : kwmCooperates) {
+            com.sckw.manage.api.model.dto.res.FindCooperateByEntResVo findCooperateByEntResVo = new com.sckw.manage.api.model.dto.res.FindCooperateByEntResVo();
+            findCooperateByEntResVo.setId(kwmCooperate.getId());
+            findCooperateByEntResVo.setRemark(kwmCooperate.getRemark());
+            //设置发起企业
+            EntCacheResDto entCacheResDto = entMap.get(kwmCooperate.getEntId());
+            findCooperateByEntResVo.setInitiateEntId(kwmCooperate.getEntId());
+            if (Objects.nonNull(entCacheResDto)) {
+                findCooperateByEntResVo.setInitiateEntName(entCacheResDto.getFirmName());
+            }
+
+            EntCacheResDto inviterEntCacheResDto = entMap.get(kwmCooperate.getInviterEntId());
+            EntCacheResDto inviteeEntCacheResDto = entMap.get(kwmCooperate.getInviteeEntId());
+            String inviterEntName = Objects.isNull(inviterEntCacheResDto) ? null : inviterEntCacheResDto.getFirmName();
+            String inviteeEntName = Objects.isNull(inviteeEntCacheResDto) ? null : inviteeEntCacheResDto.getFirmName();
+
+            //设置合作属性
+            List<KwmCooperateType> kwmCooperateTypeList = collect.get(kwmCooperate.getId());
+            for (KwmCooperateType kwmCooperateType : kwmCooperateTypeList) {
+                Integer type;
+                if (kwmCooperate.getEntId().equals(topId)) {
+                    type = kwmCooperateType.getType();
+                } else {
+                    type = commonBusinessService.changeCooperateType(kwmCooperateType.getType());
+                }
+
+                if (Objects.isNull(reqVo.getCooperateType())) {
+                    cooperateTypeList.add(type);
+                } else if (reqVo.getCooperateType().equals(type)) {
+                    cooperateTypeList.add(type);
+                }
+            }
+
+            if (CollectionUtils.isEmpty(cooperateTypeList)) {
+                continue;
+            }
+
+            String cooperateTypes = String.join(Global.COMMA, cooperateTypeList.stream().map(String::valueOf).distinct().toList());
+            findCooperateByEntResVo.setCooperateTypes(cooperateTypes);
+            //设置我方和对方企业信息、联系人
+            if (topId.equals(kwmCooperate.getEntId())) {
+                findCooperateByEntResVo.setEntId(kwmCooperate.getInviterEntId());
+                findCooperateByEntResVo.setEntName(inviterEntName);
+                findCooperateByEntResVo.setContactsId(kwmCooperate.getInviterContactsId());
+                findCooperateByEntResVo.setContacts(kwmCooperate.getInviterContacts());
+                findCooperateByEntResVo.setPhone(kwmCooperate.getInviterPhone());
+                findCooperateByEntResVo.setTargetEntId(kwmCooperate.getInviteeEntId());
+                findCooperateByEntResVo.setTargetEntName(inviteeEntName);
+                findCooperateByEntResVo.setTargetContactsId(kwmCooperate.getInviteeContactsId());
+                findCooperateByEntResVo.setTargetContacts(kwmCooperate.getInviteeContacts());
+                findCooperateByEntResVo.setTargetPhone(kwmCooperate.getInviteePhone());
+            } else {
+                findCooperateByEntResVo.setEntId(kwmCooperate.getInviteeEntId());
+                findCooperateByEntResVo.setEntName(inviteeEntName);
+                findCooperateByEntResVo.setContactsId(kwmCooperate.getInviteeContactsId());
+                findCooperateByEntResVo.setContacts(kwmCooperate.getInviteeContacts());
+                findCooperateByEntResVo.setPhone(kwmCooperate.getInviteePhone());
+                findCooperateByEntResVo.setTargetEntId(kwmCooperate.getInviterEntId());
+                findCooperateByEntResVo.setTargetEntName(inviterEntName);
+                findCooperateByEntResVo.setTargetContactsId(kwmCooperate.getInviterContactsId());
+                findCooperateByEntResVo.setTargetContacts(kwmCooperate.getInviterContacts());
+                findCooperateByEntResVo.setTargetPhone(kwmCooperate.getInviterPhone());
+            }
+            list.add(findCooperateByEntResVo);
+            cooperateTypeList.clear();
+        }
+        return list;
+    }
 }

+ 6 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/KwpGoods.java

@@ -107,6 +107,12 @@ public class KwpGoods extends BaseModel implements Serializable {
      */
     private String thumb;
 
+
+    /**
+     * 缩略图
+     */
+    private Integer delFlag;
+
     /**
      * 上架时间
      */

+ 4 - 2
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -1300,9 +1300,11 @@ public class KwpGoodsService {
 
     public com.sckw.product.api.model.KwpGoods getGoodsByGoodsName(String goodsName) {
         KwpGoods kwpGoods = kwpGoodsMapper.selectOne(
-                new LambdaQueryWrapper<KwpGoods>().eq(KwpGoods::getName, goodsName));
+                new LambdaQueryWrapper<KwpGoods>().eq(KwpGoods::getName, goodsName).eq(KwpGoods::getDelFlag, 0));
         com.sckw.product.api.model.KwpGoods goods = new com.sckw.product.api.model.KwpGoods();
-        BeanUtils.copyPropertiesValue(kwpGoods, goods);
+        if (kwpGoods != null) {
+            org.springframework.beans.BeanUtils.copyProperties(kwpGoods, goods);
+        }
         return goods;
     }
 }

+ 1 - 1
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwWorkService.java

@@ -32,7 +32,7 @@ public class KwWorkService {
     @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 8000)
     private TransportStatisticsService transportStatisticsService;
 
-    @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 8000)
+    @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 80000)
     private PaymentDubboService paymentDubboService;
 
     @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 80000)

+ 10 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -312,6 +312,16 @@ public class KwsEnterpriseController {
         return HttpResult.ok(kwsEntService.queryCustomerGroup(reqVo));
     }
 
+    /**
+     * @param id 企业信息
+     * @desc 企业联系人信息
+     * @author zk
+     * @date 2023/9/1
+     **/
+    @GetMapping("/findAllEnterprise")
+    public HttpResult findAllEnterprise() {
+        return kwsEntService.findAllEnterprise();
+    }
     /**
      * @desc: 入驻认证/客户列表导出
      * @author: czh

+ 12 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/res/EntFindPageResVo.java

@@ -127,6 +127,18 @@ public class EntFindPageResVo implements Serializable {
      * 客户经理
      */
     private String managerName;
+    /**
+     * 专场id
+     */
+    private Long special;
+    /**
+     * 专场名称
+     */
+    private String specialName;
+    /**
+     * 是否是专场组
+     */
+    private boolean specialGroup;
 
     /**
      * 创建时间

+ 36 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -1,6 +1,7 @@
 package com.sckw.system.service;
 
 import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
@@ -13,6 +14,7 @@ import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.model.EntCertificateInfo;
+import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.stream.enums.MessageEnum;
@@ -97,6 +99,12 @@ public class KwsEnterpriseService {
     @Autowired
     private SysAreaDao sysAreaDao;
 
+    @Autowired
+    private KwsEntSpecialDao entSpecialDao;
+
+    @Autowired
+    private KwsSpecialDao specialDao;
+
     @Value(value = "${jumpUrl.entCertificate}")
     private String entCertificateUrl;
 
@@ -249,6 +257,28 @@ public class KwsEnterpriseService {
                 KwsUser kwsUser = userDao.selectByKey(entFindPageResVo.getManager());
                 entFindPageResVo.setManagerName(kwsUser == null ? null : kwsUser.getName());
             }
+            Long id = item.getId();
+            List<KwsEntSpecial> entSpecials = entSpecialDao.findList(new HashMap<>() {{
+                put("entId", id);
+            }});
+            if (CollectionUtils.isNotEmpty(entSpecials)) {
+                KwsEntSpecial kwsEntSpecial = entSpecials.get(0);
+                entFindPageResVo.setSpecial(kwsEntSpecial.getId().longValue());
+                Long specialId = kwsEntSpecial.getSpecialId();
+                KwsSpecial kwsSpecial = specialDao.selectOne(new LambdaQueryWrapper<KwsSpecial>()
+                        .eq(KwsSpecial::getId, specialId).eq(KwsSpecial::getDelFlag, NumberConstant.ZERO)
+                );
+                entFindPageResVo.setSpecialName(kwsSpecial == null ? null : kwsSpecial.getName());
+                entFindPageResVo.setSpecialGroup(false);
+            }
+            List<KwsSpecial> kwsSpecials = specialDao.selectList(new LambdaQueryWrapper<KwsSpecial>()
+                    .eq(KwsSpecial::getEntId, id).eq(KwsSpecial::getDelFlag, NumberConstant.ZERO)
+            );
+            if (kwsSpecials.size() > 0) {
+                KwsSpecial kwsSpecial = kwsSpecials.get(0);
+                entFindPageResVo.setSpecialName(kwsSpecial.getName());
+                entFindPageResVo.setSpecialGroup(true);
+            }
             result.add(entFindPageResVo);
         }
         return PageHelperUtil.getPageResult(new PageInfo<>(result), list, reqVo.getPageSize());
@@ -1104,7 +1134,7 @@ public class KwsEnterpriseService {
             if (CollectionUtils.isEmpty(entIds)) {
                 return Collections.emptyList();
             }
-            kwsEnterprises = kwsEnterprises.stream() .filter(item -> !entIds.contains(item.getId())) .collect(Collectors.toList());
+            kwsEnterprises = kwsEnterprises.stream().filter(item -> !entIds.contains(item.getId())).collect(Collectors.toList());
         }
 
         //过滤除了当前企业的其他企业
@@ -1429,4 +1459,9 @@ public class KwsEnterpriseService {
         List<KwsUserSystemTypeVo> list = userDao.selectUserBySystemTypeAndMain(SystemTypeEnum.MANAGE.getCode(), NumberConstant.ZERO);
         return list;
     }
+
+    public HttpResult findAllEnterprise() {
+        List<KwsEnterprise> enterprises = kwsEnterpriseDao.findAllEnterprise();
+        return HttpResult.ok(enterprises);
+    }
 }

+ 15 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderImportMapper.java

@@ -0,0 +1,15 @@
+package com.sckw.transport.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.transport.model.KwtLogisticsOrderImport;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @desc 物流订单导入记录 Mapper 接口
+ * @author lfdc
+ * @date 2023-12-19 14:00:02
+ */
+@Mapper
+public interface KwtLogisticsOrderImportMapper extends BaseMapper<KwtLogisticsOrderImport> {
+
+}

+ 30 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtLogisticsOrderImport.java

@@ -0,0 +1,30 @@
+package com.sckw.transport.model;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.sckw.core.model.base.BaseModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * @desc 物流订单导入记录
+ * @author lfdc
+ * @date 2023-12-19 14:00:02
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("kwt_logistics_order_import")
+public class KwtLogisticsOrderImport extends BaseModel {
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 导入文件oss地址
+     */
+    private String url;
+
+}

+ 208 - 37
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/Import/KwtAcceptCarriageOrderImportService.java

@@ -3,16 +3,16 @@ package com.sckw.transport.service.Import;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
 import com.alibaba.excel.read.metadata.ReadSheet;
+import com.alibaba.fastjson.JSON;
 import com.sckw.contract.api.RemoteContractService;
 import com.sckw.contract.api.model.dto.res.ContractLogisticsOrderResDto;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.common.enums.enums.FileEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.*;
-import com.sckw.core.utils.CollectionUtils;
-import com.sckw.core.utils.IdWorker;
-import com.sckw.core.utils.OrderGenerateSeqNoUtils;
-import com.sckw.core.utils.StringUtils;
+import com.sckw.core.model.file.FileInfo;
+import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
@@ -23,12 +23,15 @@ import com.sckw.excel.utils.ValidUtil;
 import com.sckw.fleet.api.RemoteFleetService;
 import com.sckw.manage.api.RemoteManageService;
 import com.sckw.manage.api.model.dto.res.EntAddressResDto;
+import com.sckw.manage.api.model.dto.res.FindCooperateByEntReqVo;
+import com.sckw.manage.api.model.dto.res.FindCooperateByEntResVo;
 import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.payment.api.dubbo.PaymentDubboService;
 import com.sckw.product.api.dubbo.GoodsInfoService;
 import com.sckw.product.api.model.KwpGoods;
 import com.sckw.redis.config.RedisLockUtil;
+import com.sckw.stream.enums.MessageEnum;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.KwsEnterpriseResDto;
@@ -80,7 +83,7 @@ public class KwtAcceptCarriageOrderImportService {
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
     RemoteContractService remoteContractService;
 
-    @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
+    @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
     RemoteManageService remoteManageService;
 
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
@@ -134,6 +137,9 @@ public class KwtAcceptCarriageOrderImportService {
     @Autowired
     public KwtLogisticsOrderGoodsMapper goodsMapper;
 
+    @Autowired
+    public KwtLogisticsOrderImportMapper logisticsOrderImportMapper;
+
 
     private final RedisLockUtil redisLockUtil;
 
@@ -147,6 +153,7 @@ public class KwtAcceptCarriageOrderImportService {
     public HttpResult externalImportExcel(MultipartFile file) {
 
         /**文件存储至oss*/
+//        saveImportExcel(file);
 
         /**文件必填写校验*/
         HttpResult result = this.checkImportExcel(file);
@@ -155,11 +162,76 @@ public class KwtAcceptCarriageOrderImportService {
         }
         /**文件填写数据校验*/
         List<LogisticsOrderExcelImportDTO> driverExcels = (List) result.getData();
-        checkDataFormat(driverExcels);
+        List<Map<String, Object>> messageList = new ArrayList<>();
+        checkDataFormat(driverExcels, messageList);
 
         /**数据存储*/
         saveExternalImportExcel(driverExcels);
-        return null;
+
+        /**导入数据推送至消息列表*/
+        pushMessage(messageList, driverExcels.size());
+        return HttpResult.ok("导入文件成功");
+    }
+
+    private void saveImportExcel(MultipartFile file) {
+        FileInfo fileInfo = FileUtils.getFileDataList(file);
+        fileInfo.setType(FileEnum.FILE_STORE_TYPE_OSS.getFileType());
+        FileInfo returnFileInfo = FileUtils.uploadFileInfo(file, fileInfo, FileEnum.FILE_STORE_TYPE_OSS);
+        Date date = new Date();
+        KwtLogisticsOrderImport anImport = new KwtLogisticsOrderImport();
+        anImport.setEntId(LoginUserHolder.getEntId());
+        anImport.setUrl(returnFileInfo.getFilePath());
+        anImport.setId(new IdWorker(NumberConstant.ONE).nextId());
+        anImport.setRemark(JSON.toJSONString(returnFileInfo));
+        anImport.setStatus(0);
+        anImport.setCreateBy(LoginUserHolder.getUserId());
+        anImport.setCreateTime(date);
+        anImport.setUpdateBy(LoginUserHolder.getUserId());
+        anImport.setUpdateTime(date);
+        anImport.setDelFlag(0);
+        logisticsOrderImportMapper.insert(anImport);
+    }
+
+    private void pushMessage(List<Map<String, Object>> messageList, Integer number) {
+        for (Map<String, Object> objectMap : messageList) {
+            //托运
+            String consignId = objectMap.get("consignId").toString();
+            String consignName = objectMap.get("consignName").toString();
+            String consignContactsId = objectMap.get("consignContactsId").toString();
+            String consignContacts = objectMap.get("consignContacts").toString();
+            String consignPhone = objectMap.get("consignPhone").toString();
+            //承运
+            String acceptId = objectMap.get("acceptId").toString();
+            String acceptName = objectMap.get("acceptName").toString();
+            String acceptContactsId = objectMap.get("acceptContactsId").toString();
+            String acceptContacts = objectMap.get("acceptContacts").toString();
+            String acceptPhone = objectMap.get("acceptPhone").toString();
+            /**发送信息至消息列表*/
+
+            //托运单位
+            EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(Long.parseLong(consignId));
+            KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit();
+            consignUnit.setUnitType(NumberConstant.ONE);
+            consignUnit.setEntId(Long.parseLong(consignId));
+            consignUnit.setTopEntId(entCacheResDto == null ? null : entCacheResDto.getId());
+            consignUnit.setFirmName(consignName);
+            consignUnit.setContactsId(Long.parseLong(consignContactsId));
+
+            //承运单位
+            EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntCacheById(Long.parseLong(acceptId));
+            KwtLogisticsOrderUnit carriageUnit = new KwtLogisticsOrderUnit();
+            carriageUnit.setUnitType(NumberConstant.TWO);
+            carriageUnit.setEntId(Long.parseLong(acceptId));
+            carriageUnit.setTopEntId(entCacheResDto1 == null ? null : entCacheResDto1.getId());
+            carriageUnit.setFirmName(acceptName);
+            carriageUnit.setContactsId(Long.parseLong(acceptContactsId));
+            commonService.importExcelToMessage(consignUnit, carriageUnit, String.valueOf(number), LoginUserHolder.getUserId(), LoginUserHolder.getEntId()
+                    , messageUrlConfig.getPc().getConsignLogisticsAddOrderUrl(), messageUrlConfig.getApp().getConsignLogisticsAddOrderUrl()
+                    , messageUrlConfig.getPc().getCarriageLogisticsAddOrderUrl(), messageUrlConfig.getApp().getCarriageLogisticsAddOrderUrl()
+                    , MessageEnum.ACCEPT_CARRIAGE_IMPORT_EXCEL, MessageEnum.CONSIGN_IMPORT_EXCEL
+                    , "1"
+            );
+        }
     }
 
     /**
@@ -216,7 +288,7 @@ public class KwtAcceptCarriageOrderImportService {
             /**根据合同计算当前单据状态*/
             /**判断生成物流订单应生成哪一种单据状态*/
             String contractNo = excelImport.getContract().trim();
-            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo);
+            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo,acceptCarriageEnterprise.getId(),consignEnterprise.getId());
             /**状态判断
              * 是否是已签约合同
              * */
@@ -237,6 +309,7 @@ public class KwtAcceptCarriageOrderImportService {
             saveLogisticsOrderContract(excelImport, lOrderId, commonInfoResDto);
             saveLogisticsOrderTrack(lOrderId, orderStatus);
             saveLogisticsOrderUnit(excelImport, lOrderId);
+            //目前物流订单未使用MongoDB
 //            saveMongoDb(excelImport, orderStatus, lOrderId, lOrderNo, commonInfoResDto);
 //            /**发送信息至消息列表*/
 //            //托运单位
@@ -268,6 +341,7 @@ public class KwtAcceptCarriageOrderImportService {
 
     /**
      * 物流订单单位
+     *
      * @param excelImport
      * @param lOrderId
      */
@@ -293,11 +367,19 @@ public class KwtAcceptCarriageOrderImportService {
         if (Objects.isNull(ent)) {
             throw new BusinessException("企业:" + excelImport.getConsignCompany() + "的一级企业信息不存在!");
         }
-//        consignUnit.setContactsId(Long.parseLong(orderDTO.getConsignContactsId()));
-//        consignUnit.setTopEntId(ent.getId());
-//        consignUnit.setFirmName(excelImport.getConsignCompany());
-//        consignUnit.setContacts(orderDTO.getConsignContacts());
-//        consignUnit.setPhone(orderDTO.getConsignContactPhone());
+        FindCooperateByEntReqVo vo = new FindCooperateByEntReqVo();
+        vo.setEntId(acceptCarriageEnterprise.getId());
+        vo.setTargetEntId(consignEnterprise.getId());
+        vo.setCooperateType(3);
+        List<FindCooperateByEntResVo> cooperateByEnt = remoteManageService.findCooperateByEnt(vo);
+        if (cooperateByEnt.size() > 0 && cooperateByEnt.size() == 1) {
+            FindCooperateByEntResVo findCooperateByEntResVo = cooperateByEnt.get(0);
+            consignUnit.setContacts(findCooperateByEntResVo.getTargetContacts());
+            consignUnit.setPhone(findCooperateByEntResVo.getTargetPhone());
+            consignUnit.setContactsId(findCooperateByEntResVo.getTargetContactsId());
+        }
+        consignUnit.setTopEntId(ent.getId());
+        consignUnit.setFirmName(excelImport.getConsignCompany());
         consignUnit.setStatus(NumberConstant.ZERO);
         consignUnit.setCreateBy(LoginUserHolder.getUserId());
         consignUnit.setCreateTime(new Date());
@@ -313,12 +395,15 @@ public class KwtAcceptCarriageOrderImportService {
         if (Objects.isNull(ent1)) {
             throw new BusinessException("企业:" + excelImport.getAcceptCarriageCompany() + "的一级企业信息不存在!");
         }
-//        unit.setContactsId(Long.parseLong(orderDTO.getAcceptContactsId()));
-//        unit.setTopEntId(ent1.getId());
-//        unit.setFirmName(orderDTO.getAcceptCompany());
-//        unit.setContacts(orderDTO.getAcceptContacts());
-//        unit.setPhone(orderDTO.getAcceptContactPhone());
-//        unit.setRemark(orderDTO.getRemark());
+        if (cooperateByEnt.size() > 0 && cooperateByEnt.size() == 1) {
+            FindCooperateByEntResVo findCooperateByEntResVo = cooperateByEnt.get(0);
+            unit.setContacts(findCooperateByEntResVo.getContacts());
+            unit.setPhone(findCooperateByEntResVo.getPhone());
+            unit.setContactsId(findCooperateByEntResVo.getContactsId());
+        }
+        unit.setTopEntId(ent1.getId());
+        unit.setFirmName(acceptCarriageEnterprise.getFirmName());
+        unit.setRemark("");
         unit.setStatus(NumberConstant.ZERO);
         unit.setCreateBy(LoginUserHolder.getUserId());
         unit.setCreateTime(new Date());
@@ -328,7 +413,9 @@ public class KwtAcceptCarriageOrderImportService {
         logisticsOrderUnitMapper.insert(unit);
     }
 
-    /** 物流订单-状态信息
+    /**
+     * 物流订单-状态信息
+     *
      * @param lOrderId
      * @param orderStatus
      */
@@ -346,6 +433,7 @@ public class KwtAcceptCarriageOrderImportService {
 
     /**
      * 保存合同信息
+     *
      * @param excelImport
      * @param lOrderId
      * @param commonInfoResDto
@@ -368,6 +456,7 @@ public class KwtAcceptCarriageOrderImportService {
 
     /**
      * 保存商品信息
+     *
      * @param excelImport
      * @param lOrderId
      * @param lOrderNo
@@ -391,6 +480,7 @@ public class KwtAcceptCarriageOrderImportService {
 
     /**
      * 保存地址信息
+     *
      * @param excelImport
      * @param lOrderId
      */
@@ -430,8 +520,8 @@ public class KwtAcceptCarriageOrderImportService {
             if (loadAddressMap != null || allAddressResMap != null) {
                 EntAddressResDto entAddressResDto = loadAddressMap.get(loadAddressName);
                 EntAddressResDto entAddressResDto1 = allAddressResMap.get(loadAddressName);
-                if (entAddressResDto == null){
-                    if (entAddressResDto1.getName().equals(loadAddressName)){
+                if (entAddressResDto == null) {
+                    if (entAddressResDto1.getName().equals(loadAddressName)) {
                         loadAddress.setName(entAddressResDto1.getName());
                         loadAddress.setContacts(entAddressResDto1.getContacts());
                         loadAddress.setPhone(entAddressResDto1.getPhone());
@@ -441,8 +531,8 @@ public class KwtAcceptCarriageOrderImportService {
                         loadAddress.setLat(entAddressResDto1.getLat());
                         loadAddress.setLng(entAddressResDto1.getLng());
                     }
-                }else {
-                    if (entAddressResDto.getName().equals(loadAddressName)){
+                } else {
+                    if (entAddressResDto.getName().equals(loadAddressName)) {
                         loadAddress.setName(entAddressResDto.getName());
                         loadAddress.setContacts(entAddressResDto.getContacts());
                         loadAddress.setPhone(entAddressResDto.getPhone());
@@ -471,8 +561,8 @@ public class KwtAcceptCarriageOrderImportService {
             if (unloadAddressMap != null || allAddressResMap != null) {
                 EntAddressResDto entAddressResDto = unloadAddressMap.get(unloadAddressName);
                 EntAddressResDto entAddressResDto1 = allAddressResMap.get(unloadAddressName);
-                if (entAddressResDto == null){
-                    if (entAddressResDto1.getName().equals(loadAddressName)){
+                if (entAddressResDto == null) {
+                    if (entAddressResDto1.getName().equals(loadAddressName)) {
                         unloadAddress.setName(entAddressResDto1.getName());
                         unloadAddress.setContacts(entAddressResDto1.getContacts());
                         unloadAddress.setPhone(entAddressResDto1.getPhone());
@@ -482,8 +572,8 @@ public class KwtAcceptCarriageOrderImportService {
                         unloadAddress.setLat(entAddressResDto1.getLat());
                         unloadAddress.setLng(entAddressResDto1.getLng());
                     }
-                }else {
-                    if (entAddressResDto.getName().equals(loadAddressName)){
+                } else {
+                    if (entAddressResDto.getName().equals(loadAddressName)) {
                         unloadAddress.setName(entAddressResDto.getName());
                         unloadAddress.setContacts(entAddressResDto.getContacts());
                         unloadAddress.setPhone(entAddressResDto.getPhone());
@@ -578,7 +668,7 @@ public class KwtAcceptCarriageOrderImportService {
      *
      * @param driverExcels 导入文件数据检验
      */
-    private void checkDataFormat(List<LogisticsOrderExcelImportDTO> driverExcels) {
+    private void checkDataFormat(List<LogisticsOrderExcelImportDTO> driverExcels, List<Map<String, Object>> messageList) {
         //商品分类
         Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.INDUSTRY_TYPE.getType());
         List<String> goodsModel = dictResDtoMap.values().stream().map(SysDictResDto::getLabel).distinct().collect(Collectors.toList());
@@ -618,18 +708,28 @@ public class KwtAcceptCarriageOrderImportService {
             if (acceptCarriageEnterprise == null) {
                 throw new RuntimeException("第" + number + "行承运企业不存在!");
             }
-            String goodsName = excelImport.getGoodsName().trim();
-            KwpGoods goods = goodsInfoService.getGoodsByGoodsName(goodsName);
-            if (goods == null) {
-                throw new RuntimeException("第" + number + "行货物信息不存在");
+
+            FindCooperateByEntReqVo vo = new FindCooperateByEntReqVo();
+            vo.setEntId(acceptCarriageEnterprise.getId());
+            vo.setTargetEntId(consignEnterprise.getId());
+            vo.setCooperateType(3);
+            List<FindCooperateByEntResVo> cooperateByEnt = remoteManageService.findCooperateByEnt(vo);
+            if (cooperateByEnt.size() < 1) {
+                throw new RuntimeException("第" + number + "行承运企业与托运企业不存在合作关系!");
             }
+
+//            String goodsName = excelImport.getGoodsName().trim();
+//            KwpGoods goods = goodsInfoService.getGoodsByGoodsName(goodsName);
+//            if (goods == null) {
+//                throw new RuntimeException("第" + number + "行货物信息不存在");
+//            }
             String goodsModelType = excelImport.getGoodsModel().trim();
             if (!goodsModel.contains(goodsModelType)) {
                 throw new RuntimeException("第" + number + "行商品分类信息不存在");
             }
             String contractNo = excelImport.getContract().trim();
-            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo);
-            if (commonInfoResDto == null) {
+            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo,acceptCarriageEnterprise.getId(),consignEnterprise.getId());
+            if (commonInfoResDto == null ) {
                 throw new RuntimeException("第" + number + "行合同信息不存在");
             }
             if (commonInfoResDto.getConsignEntName() == null) {
@@ -711,10 +811,81 @@ public class KwtAcceptCarriageOrderImportService {
                 throw new RuntimeException("第" + number + "行承运企业系统中并未维护装货地址或卸货地址");
             }
         }
+        /**验证承运企业是否与当前登录账号是同一个主体机构*/
+        List<Long> ids = new ArrayList<>();
+        driverExcels.forEach(importExcel -> {
+            String acceptCarriageCompany = importExcel.getAcceptCarriageCompany().trim();
+            KwsEnterpriseResDto acceptCarriageEnterprise = remoteSystemService.findEnterpriseByName(acceptCarriageCompany);
+            if (acceptCarriageEnterprise != null) {
+                Long id = acceptCarriageEnterprise.getId();
+                ids.add(id);
+            }
+        });
+        if (ids.size() > 0) {
+            Map<Long, EntCacheResDto> longEntCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(LoginUserHolder.getEntId()));
+            if (longEntCacheResDtoMap != null) {
+                List<Long> entIds = longEntCacheResDtoMap.values().stream().map(EntCacheResDto::getId).distinct().collect(Collectors.toList());
+                Map<Long, EntCacheResDto> map = remoteSystemService.queryEntTreeByIds(Collections.singletonList(LoginUserHolder.getEntId()));
+                if (map != null) {
+                    Long loginEntId = map.get(LoginUserHolder.getEntId()).getId();
+                    if (entIds.size() != 1 || (entIds.get(0) != loginEntId)) {
+                        throw new RuntimeException("存在有承运单位与登录账号不属于同单位!");
+                    }
+                } else {
+                    throw new RuntimeException("存在有承运单位与登录账号不属于同单位!");
+                }
+            } else {
+                throw new RuntimeException("存在有承运单位与登录账号不属于同单位!");
+            }
+        } else {
+            throw new RuntimeException("存在有承运单位与登录账号不属于同单位!");
+        }
 
         /**获取需要发送工作台消息数据*/
-        List<String> acceptCarriageCompanyList = driverExcels.stream().map(LogisticsOrderExcelImportDTO::getAcceptCarriageCompany).distinct().collect(Collectors.toList());
-        List<String> consignCompanyList = driverExcels.stream().map(LogisticsOrderExcelImportDTO::getConsignCompany).distinct().collect(Collectors.toList());
+        driverExcels.forEach(importExcel -> {
+            Map<String, String> map = new HashMap<>();
+            String consignCompany = importExcel.getConsignCompany().trim();
+            KwsEnterpriseResDto consignEnterprise = remoteSystemService.findEnterpriseByName(consignCompany);
+
+            String acceptCarriageCompany = importExcel.getAcceptCarriageCompany().trim();
+            KwsEnterpriseResDto acceptCarriageEnterprise = remoteSystemService.findEnterpriseByName(acceptCarriageCompany);
+            String key = String.valueOf(acceptCarriageEnterprise.getId()) + String.valueOf(consignEnterprise.getId());
+            if (map.get(key) == null) {
+                FindCooperateByEntReqVo vo = new FindCooperateByEntReqVo();
+                vo.setEntId(acceptCarriageEnterprise.getId());
+                vo.setTargetEntId(consignEnterprise.getId());
+                vo.setCooperateType(3);
+                List<FindCooperateByEntResVo> cooperateByEnt = remoteManageService.findCooperateByEnt(vo);
+                if (cooperateByEnt.size() > 0) {
+                    FindCooperateByEntResVo findCooperateByEntResVo = cooperateByEnt.get(0);
+                    Map<String, Object> objectMap = new HashMap<>();
+                    //托运
+                    objectMap.put("consignId", consignEnterprise.getId());
+                    Map<Long, EntCacheResDto> entCarrierMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(consignEnterprise.getId()));
+                    entCarrierMap.get(consignEnterprise.getId());
+                    objectMap.put("consignTopId", entCarrierMap == null ? null :
+                            (entCarrierMap.get(consignEnterprise.getId())) == null ? consignEnterprise.getId() :
+                                    (entCarrierMap.get(consignEnterprise.getId())).getId());
+                    objectMap.put("consignName", consignEnterprise.getFirmName());
+                    objectMap.put("consignContactsId", findCooperateByEntResVo.getTargetContactsId());
+                    objectMap.put("consignContacts", findCooperateByEntResVo.getTargetContacts());
+                    objectMap.put("consignPhone", findCooperateByEntResVo.getTargetPhone());
+
+                    //承运
+                    objectMap.put("acceptId", acceptCarriageEnterprise.getId());
+                    Map<Long, EntCacheResDto> entTreeByIds = remoteSystemService.queryEntTreeByIds(Collections.singletonList(acceptCarriageEnterprise.getId()));
+                    objectMap.put("acceptTopId", entTreeByIds == null ? null :
+                            (entTreeByIds.get(acceptCarriageEnterprise.getId())) == null ? acceptCarriageEnterprise.getId() :
+                                    (entTreeByIds.get(acceptCarriageEnterprise.getId())).getId());
+                    objectMap.put("acceptName", acceptCarriageEnterprise.getFirmName());
+                    objectMap.put("acceptContactsId", findCooperateByEntResVo.getContactsId());
+                    objectMap.put("acceptContacts", findCooperateByEntResVo.getContacts());
+                    objectMap.put("acceptPhone", findCooperateByEntResVo.getPhone());
+                    messageList.add(objectMap);
+                    map.put(key, key);
+                }
+            }
+        });
     }
 
     /**

+ 32 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtCommonService.java

@@ -251,6 +251,38 @@ public class KwtCommonService {
     }
 
 
+
+
+
+    public void importExcelToMessage(KwtLogisticsOrderUnit consignUnit, KwtLogisticsOrderUnit carriageUnit,
+                                               String number, Long createBy, Long entId,
+                                               String pcConsignUrl, String appConsignUrl,
+                                               String pcCarriageUrl, String appCarriageUrl,
+                                               MessageEnum consignMessageEnum,
+                                               MessageEnum carriageMessageEnum,
+                                               String type) {
+        boolean flag = createBy.equals(consignUnit.getContactsId()) || createBy.equals(carriageUnit.getContactsId());
+        Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
+        map.put("number", number);
+        if (flag && createBy.equals(consignUnit.getContactsId())) {
+            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
+            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
+        } else if (flag && createBy.equals(carriageUnit.getContactsId())) {
+            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
+            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
+        } else {
+            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
+            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
+            if ("1".equals(type)) {
+                map.put("companyName", consignUnit.getFirmName());
+                sendLogisticsCreateByMessage(createBy, entId, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
+            } else {
+                map.put("companyName", carriageUnit.getFirmName());
+                sendLogisticsCreateByMessage(createBy, entId, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
+            }
+        }
+    }
+
     /**
      * 发起物流托运-[贸易订单物流托运确认/承运订单分包托运确认]
      * @param consignUnit    托运单位