|
|
@@ -9,9 +9,14 @@ import com.sckw.contract.factory.AsyncFactory;
|
|
|
import com.sckw.contract.model.dto.req.EsignGetFlowReqDto;
|
|
|
import com.sckw.contract.model.dto.res.ESignSubmitResDto;
|
|
|
import com.sckw.contract.model.entity.KwcContractLogistics;
|
|
|
+import com.sckw.contract.model.entity.KwcContractLogisticsUnit;
|
|
|
import com.sckw.contract.model.entity.KwcContractTrade;
|
|
|
+import com.sckw.contract.model.entity.KwcContractTradeUnit;
|
|
|
import com.sckw.contract.model.vo.req.ESignCallBackReqVo;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.enums.ClientTypeEnum;
|
|
|
+import com.sckw.core.model.enums.CooperateTypeEnum;
|
|
|
import com.sckw.core.utils.AsyncThreadUtils;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -39,10 +44,9 @@ import com.sckw.stream.model.UserInfo;
|
|
|
import java.io.*;
|
|
|
import java.net.URL;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
@@ -77,11 +81,50 @@ public class CommonBusinessService {
|
|
|
@Autowired
|
|
|
private KwcContractTradeTrackService kwcContractTradeTrackService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KwcContractLogisticsUnitService kwcContractLogisticsUnitService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KwcContractTradeUnitService kwcContractTradeUnitService;
|
|
|
+
|
|
|
private final StreamBridge streamBridge;
|
|
|
|
|
|
@Value("${eSignUrl}")
|
|
|
private String eSignUrl;
|
|
|
|
|
|
+ /**销售合同*/
|
|
|
+ @Value(value = "${jumpUrl.saleSendContract}")
|
|
|
+ private String saleSendContract;
|
|
|
+
|
|
|
+ /**采购合同*/
|
|
|
+ @Value(value = "${jumpUrl.purchaseSendContract}")
|
|
|
+ private String purchaseSendContract;
|
|
|
+
|
|
|
+ /**托运合同*/
|
|
|
+ @Value(value = "${jumpUrl.consignmentSendContract}")
|
|
|
+ private String consignmentSendContract;
|
|
|
+
|
|
|
+ /**承运合同*/
|
|
|
+ @Value(value = "${jumpUrl.acceptanceSendContract}")
|
|
|
+ private String acceptanceSendContract;
|
|
|
+
|
|
|
+ /**app销售合同*/
|
|
|
+ @Value(value = "${jumpUrl.appSaleSendContract}")
|
|
|
+ private String appSaleSendContract;
|
|
|
+
|
|
|
+ /**app采购合同*/
|
|
|
+ @Value(value = "${jumpUrl.appPurchaseSendContract}")
|
|
|
+ private String appPurchaseSendContract;
|
|
|
+
|
|
|
+ /**app托运合同*/
|
|
|
+ @Value(value = "${jumpUrl.appConsignmentSendContract}")
|
|
|
+ private String appConsignmentSendContract;
|
|
|
+
|
|
|
+ /**app承运合同*/
|
|
|
+ @Value(value = "${jumpUrl.appAcceptanceSendContract}")
|
|
|
+ private String appAcceptanceSendContract;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @return Map
|
|
|
* @desc: 查企业
|
|
|
@@ -107,6 +150,7 @@ public class CommonBusinessService {
|
|
|
kwcContractTradeService.approval(reqVo.getContractId(), reqVo.getStatus(), reqVo.getRemark());
|
|
|
kwcContractTradeTrackService.saveContractTradeTrack(contractId, reqVo.getStatus());
|
|
|
notifyOrder(contractId, kwcContractTrade.getCreateBy());
|
|
|
+ sendTradePassMessage(kwcContractTrade);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -115,11 +159,73 @@ public class CommonBusinessService {
|
|
|
kwcContractLogisticsService.approval(reqVo.getContractId(), reqVo.getStatus(), reqVo.getRemark());
|
|
|
kwcContractLogisticsTrackService.saveContractLogisticsTrack(contractId, reqVo.getStatus());
|
|
|
notifyOrder(contractId, kwcContractLogistics.getCreateBy());
|
|
|
+ sendLogisticsPassMessage(kwcContractLogistics);
|
|
|
return;
|
|
|
}
|
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.CONTRACT_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public void sendLogisticsPassMessage(KwcContractLogistics kwcContractLogistics) {
|
|
|
+ List<KwcContractLogisticsUnit> kwcContractLogisticsUnits = kwcContractLogisticsUnitService.queryByContractId(kwcContractLogistics.getId());
|
|
|
+ Map<Integer, KwcContractLogisticsUnit> collect = kwcContractLogisticsUnits.stream().collect(Collectors.toMap(KwcContractLogisticsUnit::getUnitType, Function.identity()));
|
|
|
+
|
|
|
+ KwcContractLogisticsUnit kwcContractLogisticsUnit = collect.get(CooperateTypeEnum.CARRIAGE.getCode());
|
|
|
+ Long entId1 = kwcContractLogisticsUnit.getEntId();
|
|
|
+
|
|
|
+ EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntCacheById(entId1);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("entName", entCacheResDto1.getFirmName());
|
|
|
+ map.put("contract_no", kwcContractLogistics.getContractNo());
|
|
|
+ map.put("name", kwcContractLogistics.getName());
|
|
|
+ sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractLogistics.getCreateBy()).setEntId(kwcContractLogistics.getEntId())),
|
|
|
+ MessageEnum.SAELCONTRACT_SUCCESS_CONTRACT,
|
|
|
+ map,
|
|
|
+ consignmentSendContract,
|
|
|
+ appConsignmentSendContract);
|
|
|
+
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId1);
|
|
|
+ KwcContractLogisticsUnit kwcContractLogisticsUnit2 = collect.get(CooperateTypeEnum.CONSIGN.getCode());
|
|
|
+ EntCacheResDto entCacheResDto2 = remoteSystemService.queryEntCacheById(kwcContractLogisticsUnit2.getEntId());
|
|
|
+ map.put("entName", entCacheResDto2.getFirmName());
|
|
|
+ sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(entCacheResDto.getContactsId()).setEntId(entCacheResDto.getId())),
|
|
|
+ MessageEnum.BUYCONTRACT_SUCCESS_CONTRACT,
|
|
|
+ map,
|
|
|
+ acceptanceSendContract,
|
|
|
+ appAcceptanceSendContract);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void sendTradePassMessage(KwcContractTrade kwcContractTrade) {
|
|
|
+ List<KwcContractTradeUnit> kwcContractTradeUnits = kwcContractTradeUnitService.queryByContractId(kwcContractTrade.getId());
|
|
|
+ Map<Integer, KwcContractTradeUnit> collect = kwcContractTradeUnits.stream().collect(Collectors.toMap(KwcContractTradeUnit::getUnitType, Function.identity()));
|
|
|
+
|
|
|
+ KwcContractTradeUnit kwcContractTradeUnit = collect.get(CooperateTypeEnum.PURCHASER.getCode());
|
|
|
+ Long entId1 = kwcContractTradeUnit.getEntId();
|
|
|
+
|
|
|
+ EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntCacheById(entId1);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("entName", entCacheResDto1.getFirmName());
|
|
|
+ map.put("contract_no", kwcContractTrade.getContractNo());
|
|
|
+ map.put("name", kwcContractTrade.getName());
|
|
|
+ sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(kwcContractTrade.getCreateBy()).setEntId(kwcContractTrade.getEntId())),
|
|
|
+ MessageEnum.SAELCONTRACT_SUCCESS_CONTRACT,
|
|
|
+ map,
|
|
|
+ saleSendContract,
|
|
|
+ appSaleSendContract);
|
|
|
+
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId1);
|
|
|
+ KwcContractTradeUnit kwcContractTradeUnit2 = collect.get(CooperateTypeEnum.SUPPLIER.getCode());
|
|
|
+ EntCacheResDto entCacheResDto2 = remoteSystemService.queryEntCacheById(kwcContractTradeUnit2.getEntId());
|
|
|
+ map.put("entName", entCacheResDto2.getFirmName());
|
|
|
+ sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(entCacheResDto.getContactsId()).setEntId(entCacheResDto.getId())),
|
|
|
+ MessageEnum.BUYCONTRACT_SUCCESS_CONTRACT,
|
|
|
+ map,
|
|
|
+ purchaseSendContract,
|
|
|
+ appPurchaseSendContract);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param contractId 合同id userId用户id
|
|
|
* @desc: 通知订单模块更新状态
|
|
|
@@ -155,19 +261,22 @@ public class CommonBusinessService {
|
|
|
* @author: czh
|
|
|
* @date: 2023/8/14
|
|
|
*/
|
|
|
- public void postToEsign(String firstAccount, String secondAccount, Long orgFirst, Long orgSeconId, String contractFile, Long id, String contractName) {
|
|
|
- AsyncFactory.execute(new AsyncProcess(firstAccount, secondAccount, orgFirst, orgSeconId, contractFile, id, contractName, remoteSystemService, eSignUrl, kwcContractLogisticsMapper, kwcContractTradeMapper));
|
|
|
+ public void postToEsign(String firstAccount, String secondAccount, Long orgFirst, Long orgSeconId, String contractFile, Long id, String contractName, String filePathPrefix) {
|
|
|
+ AsyncFactory.execute(new AsyncProcess(firstAccount, secondAccount, orgFirst, orgSeconId, contractFile, id, contractName, remoteSystemService, eSignUrl, kwcContractLogisticsMapper, kwcContractTradeMapper, filePathPrefix));
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public void sendSystemMessage(List<UserInfo> userInfos, MessageEnum messageEnum, Map<String, Object> map, String msgUrl) {
|
|
|
+ public void sendSystemMessage(List<UserInfo> userInfos, MessageEnum messageEnum, Map<String, Object> map, String msgUrl, String appMsgUrl) {
|
|
|
SckwMessage msg = new SckwMessage();
|
|
|
+ Map<String, String> msgUrls = new HashMap<>(Global.NUMERICAL_FOUR);
|
|
|
+ msgUrls.put(ClientTypeEnum.pc.getValue(), msgUrl);
|
|
|
+ msgUrls.put(ClientTypeEnum.app.getValue(), appMsgUrl);
|
|
|
msg.setRequestId(UUIDUtils.get32UUID())
|
|
|
.setMessageEnum(messageEnum)
|
|
|
.setParams(map)
|
|
|
- .setMsgUrl(msgUrl)
|
|
|
+ .setMsgUrls(msgUrls)
|
|
|
.setUserInfos(userInfos)
|
|
|
.setCreateBy(LoginUserHolder.getUserId());
|
|
|
AsyncThreadUtils.submit(new AsyncProcessMessage(msg, streamBridge));
|
|
|
@@ -199,6 +308,7 @@ public class CommonBusinessService {
|
|
|
private final String contractFile;
|
|
|
private final Long id;
|
|
|
private final String contractName;
|
|
|
+ private final String filePathPrefix;
|
|
|
|
|
|
private RemoteSystemService remoteSystemService;
|
|
|
private String eSignUrl;
|
|
|
@@ -215,7 +325,8 @@ public class CommonBusinessService {
|
|
|
RemoteSystemService remoteSystemService,
|
|
|
String eSignUrl,
|
|
|
KwcContractLogisticsMapper kwcContractLogisticsMapper,
|
|
|
- KwcContractTradeMapper kwcContractTradeMapper) {
|
|
|
+ KwcContractTradeMapper kwcContractTradeMapper,
|
|
|
+ String filePathPrefix) {
|
|
|
this.firstAccount = firstAccount;
|
|
|
this.secondAccount = secondAccount;
|
|
|
this.orgFirst = orgFirst;
|
|
|
@@ -227,6 +338,7 @@ public class CommonBusinessService {
|
|
|
this.eSignUrl = eSignUrl;
|
|
|
this.kwcContractLogisticsMapper = kwcContractLogisticsMapper;
|
|
|
this.kwcContractTradeMapper = kwcContractTradeMapper;
|
|
|
+ this.filePathPrefix = filePathPrefix;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -235,7 +347,7 @@ public class CommonBusinessService {
|
|
|
JSONArray jsonArray = JSONArray.parseArray(contractFile);
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
|
|
String fileName = jsonObject.getString("name");
|
|
|
- String url = jsonObject.getString("url");
|
|
|
+ String url = filePathPrefix + jsonObject.getString("url");
|
|
|
File file = getFileByHttpURL(url, fileName);
|
|
|
List<Long> entIds = new ArrayList<>(2);
|
|
|
entIds.add(orgFirst);
|