Răsfoiți Sursa

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

xucaiqin 2 ani în urmă
părinte
comite
28daf5659b

+ 4 - 0
sckw-modules/sckw-contract/pom.xml

@@ -85,6 +85,10 @@
             <groupId>com.sckw</groupId>
             <artifactId>sckw-transport-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-stream</artifactId>
+        </dependency>
 
     </dependencies>
     <build>

+ 40 - 21
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/CommonBusinessService.java

@@ -12,9 +12,14 @@ import com.sckw.contract.model.entity.KwcContractLogistics;
 import com.sckw.contract.model.entity.KwcContractTrade;
 import com.sckw.contract.model.vo.req.ESignCallBackReqVo;
 import com.sckw.core.exception.SystemException;
+import com.sckw.core.utils.AsyncThreadUtils;
 import com.sckw.core.utils.BeanUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.cloud.stream.function.StreamBridge;
 import com.sckw.core.utils.OkHttpUtils;
+import com.sckw.core.utils.UUIDUtils;
 import com.sckw.core.web.constant.HttpStatus;
+import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.ContractSignCompletedParam;
 import com.sckw.system.api.RemoteSystemService;
@@ -28,7 +33,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-
+import com.sckw.stream.enums.MessageEnum;
+import com.sckw.stream.model.SckwMessage;
+import com.sckw.stream.model.UserInfo;
 import java.io.*;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
@@ -37,8 +44,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
+
 @Slf4j
 @Service
+@RequiredArgsConstructor
 public class CommonBusinessService {
 
     @DubboReference(version = "1.0.0", group = "design", check = false)
@@ -68,6 +77,8 @@ public class CommonBusinessService {
     @Autowired
     private KwcContractTradeTrackService kwcContractTradeTrackService;
 
+    private  final StreamBridge streamBridge;
+
     @Value("${eSignUrl}")
     private String eSignUrl;
 
@@ -149,26 +160,34 @@ public class CommonBusinessService {
     }
 
 
-    public static void main(String[] args) throws Exception {
-//        String fileName = "车企合同.docx";
-//        System.out.println(new String(fileName.getBytes(), StandardCharsets.UTF_8));
-//        String url = "https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230823/67189e3e9284951c9cf434cacef7c4c4.docx";
-//        File file = getFileByHttpURL(url, fileName);
-//        List<Long> entIds = new ArrayList<>(2);
-//        entIds.add(123123L);
-//        entIds.add(512414L);
-//        EsignGetFlowReqDto esignGetFlowReqDto = new EsignGetFlowReqDto();
-//        esignGetFlowReqDto.setFile(file);
-//        esignGetFlowReqDto.setSeqId(String.valueOf(11234125L));
-//        esignGetFlowReqDto.setSignFlowTitle("测试Title");
-//        esignGetFlowReqDto.setOrgFirstName("测试企业2");
-//        esignGetFlowReqDto.setPsnFirstAccount("13900001112");
-//        esignGetFlowReqDto.setOrgSecondName("测试企业1");
-//        esignGetFlowReqDto.setPsnSecondAccount("13900001111");
-//        Map<String, Object> map = BeanUtils.convertToMap(esignGetFlowReqDto);
-//        String res = OkHttpUtils.doPostUploadFile("http://10.10.10.224:8840/v1/sign/getFlow", map);
-////        String res = OkHttpUtils.doPostUploadFile("http://10.10.10.70:27802/openapi/vehicleLocate/fileUpload", map);
-//        log.info("E签宝返参:{}", res);
+
+
+    public void sendSystemMessage(List<UserInfo> userInfos, MessageEnum messageEnum, Map<String, Object> map, String msgUrl) {
+        SckwMessage msg = new SckwMessage();
+        msg.setRequestId(UUIDUtils.get32UUID())
+                .setMessageEnum(messageEnum)
+                .setParams(map)
+                .setMsgUrl(msgUrl)
+                .setUserInfos(userInfos)
+                .setCreateBy(LoginUserHolder.getUserId());
+        AsyncThreadUtils.submit(new AsyncProcessMessage(msg, streamBridge));
+    }
+
+    static class AsyncProcessMessage implements Runnable {
+
+        private SckwMessage sckwMessage;
+
+        private StreamBridge streamBridge;
+
+        AsyncProcessMessage(SckwMessage sckwMessage, StreamBridge streamBridge) {
+            this.sckwMessage = sckwMessage;
+            this.streamBridge = streamBridge;
+        }
+
+        @Override
+        public void run() {
+            streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
+        }
     }
 
     static class AsyncProcess implements Runnable {

+ 57 - 3
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsService.java

@@ -12,6 +12,7 @@ import com.sckw.contract.model.dto.res.QueryListResDto;
 import com.sckw.contract.model.entity.KwcContractLogistics;
 import com.sckw.contract.model.entity.KwcContractLogisticsGoods;
 import com.sckw.contract.model.entity.KwcContractLogisticsUnit;
+import com.sckw.contract.model.entity.KwcContractTrade;
 import com.sckw.contract.model.report.LogisticsListExport;
 import com.sckw.contract.model.vo.req.*;
 import com.sckw.contract.model.vo.res.*;
@@ -31,6 +32,8 @@ import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.excel.utils.EasyExcelUtil;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.product.api.dubbo.GoodsInfoService;
+import com.sckw.stream.enums.MessageEnum;
+import com.sckw.stream.model.UserInfo;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteUserService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
@@ -40,6 +43,7 @@ import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -69,8 +73,8 @@ public class KwcContractLogisticsService {
     @Autowired
     private KwcContractLogisticsUnitService kwcContractLogisticsUnitService;
 
-    @Autowired
-    private RemoteContractServiceImpl remoteContractService;
+    //@Autowired
+    //private RemoteContractServiceImpl remoteContractService;
 
     @Autowired
     private CommonBusinessService commonBusinessService;
@@ -84,6 +88,9 @@ public class KwcContractLogisticsService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private GoodsInfoService goodsInfoService;
 
+    @Value(value = "${jumpUrl.tradeSendContract}")
+    private String  tradeSendContract;
+
     /**
      * @param reqVo 新增入参
      * @desc: 新增托运合同
@@ -118,6 +125,24 @@ public class KwcContractLogisticsService {
 
         //存单位信息
         kwcContractLogisticsUnitService.saveContractLogisticsUnit(kwcContractLogistics.getId(), baseInfo);
+
+        //发送消息
+        Long entId = kwcContractLogistics.getEntId();
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("entName", entCacheResDto.getFirmName());
+        map.put("contract_no", baseInfo.getContractCode());
+        map.put("name", baseInfo.getContractName());
+        MessageEnum messageEnum;
+        if (Objects.nonNull(reqVo.getPid())) {
+            messageEnum = MessageEnum.SAELCONTRACT_SUBMIT_DATA;//检测到PID时为补充合同
+        }else{
+            messageEnum = MessageEnum.SAELCONTRACT_SEND_CONTRACT;
+        }
+        commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractLogistics.getCreateBy()).setEntId(entId)),
+                messageEnum,
+                map,
+                tradeSendContract);
         return contactId;
     }
 
@@ -384,6 +409,21 @@ public class KwcContractLogisticsService {
             eSignCallBackReqVo.setContractId(id);
             eSignCallBackReqVo.setStatus(ContractStatusEnum.SIGNED.getCode());
             commonBusinessService.approval(eSignCallBackReqVo);
+
+            //发送消息
+            KwcContractLogistics kwcContractLogistic = kwcContractLogisticsMapper.selectById(id);
+            Long entId = kwcContractLogistic.getEntId();
+            EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
+            Map<String, Object> map = new HashMap<>();
+            map.put("entName", entCacheResDto.getFirmName());
+            map.put("contract_no", kwcContractLogistic.getContractNo());
+            map.put("name", kwcContractLogistic.getName());
+            MessageEnum messageEnum = MessageEnum.SAELCONTRACT_COMPLETE_CONTRACT;
+
+            commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractLogistic.getCreateBy()).setEntId(entId)),
+                    messageEnum,
+                    map,
+                    tradeSendContract);
         }
     }
 
@@ -504,9 +544,23 @@ public class KwcContractLogisticsService {
         if (kwcContractLogisticsMapper.updateById(kwcContractLogistic) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
         }
-
         kwcContractLogisticsTrackService.saveContractLogisticsTrack(kwcContractLogistic.getId(), ContractTrackEnum.OVER.getCode());
 
+
+        //发送消息
+        Long entId = kwcContractLogistic.getEntId();
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("entName", entCacheResDto.getFirmName());
+        map.put("contract_no", kwcContractLogistic.getContractNo());
+        map.put("name", kwcContractLogistic.getName());
+        MessageEnum messageEnum = MessageEnum.SAELCONTRACT_COMPLETE_CONTRACT;
+
+        commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractLogistic.getCreateBy()).setEntId(entId)),
+                messageEnum,
+                map,
+                tradeSendContract);
+
     }
 
 

+ 59 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractTradeService.java

@@ -33,6 +33,8 @@ import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.ContractSignCompletedParam;
 import com.sckw.product.api.dubbo.GoodsInfoService;
 import com.sckw.product.api.model.KwpGoods;
+import com.sckw.stream.enums.MessageEnum;
+import com.sckw.stream.model.UserInfo;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
@@ -40,6 +42,7 @@ import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import com.sckw.system.api.RemoteSystemService;
@@ -84,6 +87,11 @@ public class KwcContractTradeService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private TradeOrderInfoService tradeOrderInfoService;
 
+    @Value(value = "${jumpUrl.saleSendContract}")
+    private String saleSendContract;
+
+
+
     /**
      * @return PageResult
      * @desc: 分页查询
@@ -190,6 +198,23 @@ public class KwcContractTradeService {
 
         //存单位信息
         kwcContractTradeUnitService.saveContractTradeUnit(contactId, baseInfo);
+        //发送消息
+        Long entId = kwcContractTrade.getEntId();
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("entName", entCacheResDto.getFirmName());
+        map.put("contract_no", baseInfo.getContractCode());
+        map.put("name", baseInfo.getContractName());
+        MessageEnum messageEnum;
+        if (Objects.nonNull(reqVo.getPid())) {
+            messageEnum = MessageEnum.SAELCONTRACT_SUBMIT_DATA;//检测到PID时为补充合同
+        }else{
+            messageEnum = MessageEnum.SAELCONTRACT_SEND_CONTRACT;
+        }
+        commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractTrade.getCreateBy()).setEntId(entId)),
+                messageEnum,
+                map,
+                saleSendContract);
         return contactId;
     }
 
@@ -450,6 +475,19 @@ public class KwcContractTradeService {
             eSignCallBackReqVo.setContractId(id);
             eSignCallBackReqVo.setStatus(ContractStatusEnum.SIGNED.getCode());
             commonBusinessService.approval(eSignCallBackReqVo);
+            //发送消息
+            Long entId = reqVo.getBaseInfo().getProvideEntId();
+            EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
+            Map<String, Object> map = new HashMap<>();
+            map.put("entName", entCacheResDto.getFirmName());
+            map.put("contract_no", reqVo.getBaseInfo().getContractCode());
+            map.put("name", reqVo.getBaseInfo().getContractName());
+            MessageEnum messageEnum = MessageEnum.SAELCONTRACT_SUCCESS_CONTRACT;
+            KwcContractTrade kwcContractTrade = kwcContractTradeMapper.selectById(id);
+            commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractTrade.getCreateBy()).setEntId(entId)),
+                    messageEnum,
+                    map,
+                    saleSendContract);
         }
     }
 
@@ -569,8 +607,28 @@ public class KwcContractTradeService {
         if (kwcContractTradeMapper.updateById(kwcContractTrade) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
         }
-
         kwcContractTradeTrackService.saveContractTradeTrack(kwcContractTrade.getId(), ContractTrackEnum.OVER.getCode());
+
+        //完结相关订单
+        ContractSignCompletedParam contractSignCompletedParam = new ContractSignCompletedParam();
+        contractSignCompletedParam.setContractId(kwcContractTrade.getContractPid());
+        contractSignCompletedParam.setUpdateBy(LoginUserHolder.getUserId());
+        contractSignCompletedParam.setUpdateByName(LoginUserHolder.getUserName());
+        tradeOrderInfoService.contractSignCompleted(contractSignCompletedParam);
+
+        //发送消息
+        Long entId = kwcContractTrade.getEntId();
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("entName", entCacheResDto.getFirmName());
+        map.put("contract_no", kwcContractTrade.getContractNo());
+        map.put("name", kwcContractTrade.getName());
+        MessageEnum messageEnum = MessageEnum.SAELCONTRACT_COMPLETE_CONTRACT;
+
+        commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractTrade.getCreateBy()).setEntId(entId)),
+                messageEnum,
+                map,
+                saleSendContract);
     }