|
|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|