|
|
@@ -22,6 +22,9 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.springblade.client.entity.Message;
|
|
|
+import org.springblade.client.feign.IMessageClient;
|
|
|
import org.springblade.core.excel.util.ExcelUtil;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
@@ -65,13 +68,20 @@ import org.springblade.los.business.sea.mapper.BillsMapper;
|
|
|
import org.springblade.los.business.sea.service.IContainersService;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
+import org.springblade.los.ftp.dto.ApiItem;
|
|
|
+import org.springblade.los.ftp.dto.ApiRequest;
|
|
|
+import org.springblade.los.ftp.dto.ContainerMovement;
|
|
|
import org.springblade.resource.feign.IOssClient;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.InputStreamReader;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.rmi.RemoteException;
|
|
|
@@ -82,6 +92,8 @@ import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -98,6 +110,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
|
|
|
private final ISysClient sysClient;
|
|
|
|
|
|
+ private final IUserClient userClient;
|
|
|
+
|
|
|
private final IOssClient ossClient;
|
|
|
|
|
|
private final IBCorpsService bCorpsService;
|
|
|
@@ -136,6 +150,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
|
|
|
private final IBCntrTypesService cntrTypesService;
|
|
|
|
|
|
+ private final IMessageClient messageClient;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<BoxDynamicsRecordVO> selectBoxDynamicsRecordPage(IPage<BoxDynamicsRecordVO> page, BoxDynamicsRecordVO boxDynamicsRecord) {
|
|
|
return page.setRecords(baseMapper.selectBoxDynamicsRecordPage(page, boxDynamicsRecord));
|
|
|
@@ -299,7 +315,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
if ("JC".equals(boxDynamicsRecord.getApproachExit())) {
|
|
|
List<BoxDynamicsRecordItems> itemsListJC = itemsList.stream().filter(e -> !"C,ZJ".contains(e.getObjective())).collect(Collectors.toList());
|
|
|
- if (!itemsListJC.isEmpty()) {
|
|
|
+ /*if (!itemsListJC.isEmpty()) {
|
|
|
List<String> boxCodeList = itemsListJC.stream().map(BoxDynamicsRecordItems::getBoxCode).filter(Objects::nonNull)
|
|
|
.distinct().collect(Collectors.toList());
|
|
|
//箱档案数据
|
|
|
@@ -633,10 +649,10 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
if (!putBoxes.isEmpty()) {
|
|
|
for (PutBox item : putBoxes) {
|
|
|
long count = 0;
|
|
|
- if (ObjectUtils.isNotNull(item.getCode())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
count = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()) &&
|
|
|
!item.getCode().contains(e.getBoxCode())).count();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
count = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())).count();
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
@@ -666,10 +682,10 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
TradingBox tradingBox = tradingBoxes.stream().filter(e -> e.getId().equals(item.getSrcId())).findFirst().orElse(null);
|
|
|
if (tradingBox != null) {
|
|
|
long count1 = 0;
|
|
|
- if (ObjectUtils.isNotNull(tradingBox.getCode())){
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getCode())) {
|
|
|
count1 = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()) &&
|
|
|
!tradingBox.getCode().contains(e.getBoxCode())).count();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
count1 = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())).count();
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
@@ -761,6 +777,9 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
if (!tradingBoxItems.isEmpty()) {
|
|
|
tradingBoxItemService.saveOrUpdateBatch(tradingBoxItems);
|
|
|
}
|
|
|
+ }*/
|
|
|
+ if (!itemsListJC.isEmpty()){
|
|
|
+ this.synchronization(itemsListJC);
|
|
|
}
|
|
|
List<BoxDynamicsRecordItems> itemsListFC = itemsList.stream().filter(e -> "C".equals(e.getObjective())).collect(Collectors.toList());
|
|
|
if (!itemsListFC.isEmpty()) {
|
|
|
@@ -876,16 +895,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
if (recordItems == null) {
|
|
|
throw new RuntimeException("未查到对应箱号记录");
|
|
|
}
|
|
|
- item.setPodStationId(recordItems.getStationId());
|
|
|
- item.setPodStationCname(recordItems.getStationCname());
|
|
|
- item.setPodStationEname(recordItems.getStationEname());
|
|
|
- item.setPodStationCode(recordItems.getStationCode());
|
|
|
- item.setPodEmptyContainerReturnDate(recordItems.getApproachExitDate());
|
|
|
- item.setWhetherFee("1");
|
|
|
- item.setUpdateTime(new Date());
|
|
|
- item.setUpdateUser(AuthUtil.getUserId());
|
|
|
- item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- containersListNew.add(item);
|
|
|
//进口分单配箱信息处理
|
|
|
//箱档案信息处理
|
|
|
Archives archives = archivesList.stream().filter(e -> e.getCode().equals(item.getCntrNo())).findFirst().orElse(null);
|
|
|
@@ -1161,7 +1170,18 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
} else {
|
|
|
throw new RuntimeException("放箱号:" + archives.getContainerNumberOw() + "单据类型错误,请联系管理员");
|
|
|
}
|
|
|
+ item.setBoxSrcType(putBox1.getBoxClass());
|
|
|
}
|
|
|
+ item.setPodStationId(recordItems.getStationId());
|
|
|
+ item.setPodStationCname(recordItems.getStationCname());
|
|
|
+ item.setPodStationEname(recordItems.getStationEname());
|
|
|
+ item.setPodStationCode(recordItems.getStationCode());
|
|
|
+ item.setPodEmptyContainerReturnDate(recordItems.getApproachExitDate());
|
|
|
+ item.setWhetherFee("1");
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ containersListNew.add(item);
|
|
|
}
|
|
|
if (!containersListNew.isEmpty()) {
|
|
|
containersService.updateBatchById(containersListNew);
|
|
|
@@ -1674,10 +1694,10 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
if (!putBoxes.isEmpty()) {
|
|
|
for (PutBox item : putBoxes) {
|
|
|
long count = 0;
|
|
|
- if (ObjectUtils.isNotNull(item.getCode())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
count = itemsListZJ.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()) &&
|
|
|
!item.getCode().contains(e.getBoxCode())).count();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
count = itemsListZJ.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())).count();
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
@@ -1707,10 +1727,10 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
TradingBox tradingBox = tradingBoxes.stream().filter(e -> e.getId().equals(item.getSrcId())).findFirst().orElse(null);
|
|
|
if (tradingBox != null) {
|
|
|
long count1 = 0;
|
|
|
- if (ObjectUtils.isNotNull(tradingBox.getCode())){
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getCode())) {
|
|
|
count1 = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()) &&
|
|
|
!tradingBox.getCode().contains(e.getBoxCode())).count();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
count1 = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())).count();
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
@@ -2886,6 +2906,695 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R cyctnrItem(ApiRequest apiRequest) throws IOException {
|
|
|
+ StringBuilder msg = new StringBuilder();
|
|
|
+ // 1. 执行基础参数校验
|
|
|
+ validateBasicParams(apiRequest, msg);
|
|
|
+ // 2. 场站代码有效性校验
|
|
|
+ BCorps bCorps = bCorpsService.getOne(new LambdaQueryWrapper<BCorps>()
|
|
|
+ .eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCorps::getIsDeleted, 0)
|
|
|
+ .eq(BCorps::getCode, apiRequest.getStationCode())
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (bCorps == null) {
|
|
|
+ msg.append("场站代码:").append(apiRequest.getStationCode()).append("不正确;");
|
|
|
+ }
|
|
|
+ // 3. 港口代码有效性校验
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .in(BPorts::getUnCode, apiRequest.getPortNo())
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (ports == null) {
|
|
|
+ msg.append("港口代码:").append(apiRequest.getPortNo()).append("不正确;");
|
|
|
+ }
|
|
|
+ // 4. 箱型代码有效性校验
|
|
|
+ List<String> boxType = apiRequest.getItem().stream().map(ApiItem::getCtnrType).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ List<BCntrTypes> boxTypeList = new ArrayList<>();
|
|
|
+ if (!boxType.isEmpty()) {
|
|
|
+ boxTypeList = cntrTypesService.list(new LambdaQueryWrapper<BCntrTypes>()
|
|
|
+ .eq(BCntrTypes::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCntrTypes::getIsDeleted, 0)
|
|
|
+ .in(BCntrTypes::getCode95, boxType));
|
|
|
+ if (boxTypeList.isEmpty()) {
|
|
|
+ msg.append("箱型").append(String.join(",", boxType)).append("不正确;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> boxCodeList = apiRequest.getItem().stream().map(ApiItem::getCtnrNo).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ // 5. 放箱号有效性校验
|
|
|
+ List<String> releaseNoList = apiRequest.getItem().stream().map(ApiItem::getReleaseNo).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ List<PutBox> putBoxList = new ArrayList<>();
|
|
|
+ if (!releaseNoList.isEmpty()) {
|
|
|
+ putBoxList = putBoxService.list(new LambdaQueryWrapper<PutBox>()
|
|
|
+ .eq(PutBox::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PutBox::getIsDeleted, 0)
|
|
|
+ .in(PutBox::getContainerNumber, releaseNoList));
|
|
|
+ if (putBoxList.isEmpty()) {
|
|
|
+ msg.append("放箱号").append(String.join(",", releaseNoList)).append("不存在;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 6.提单号有效性校验
|
|
|
+ List<String> mblnoList = apiRequest.getItem().stream().map(ApiItem::getMblno).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ List<Bills> billsList = new ArrayList<>();
|
|
|
+ if (!mblnoList.isEmpty()) {
|
|
|
+ billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(bill_type,'DD,MH')")
|
|
|
+ .and(i -> i.in(Bills::getHblno, mblnoList).or().in(Bills::getMblno, mblnoList)));
|
|
|
+ if (billsList.isEmpty()) {
|
|
|
+ msg.append("提单号").append(String.join(",", mblnoList)).append("不存在;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BoxDynamicsRecord boxDynamicsRecord = new BoxDynamicsRecord();
|
|
|
+ // 7.设置基础信息
|
|
|
+ boxDynamicsRecord.setCreateTime(new Date());
|
|
|
+ boxDynamicsRecord.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ boxDynamicsRecord.setCreateUser(AuthUtil.getUserId());
|
|
|
+ boxDynamicsRecord.setBranchId(AuthUtil.getDeptId());
|
|
|
+ boxDynamicsRecord.setFileType("edi");
|
|
|
+ boxDynamicsRecord.setImportDate(new Date());
|
|
|
+ // 8.处理进出场类型
|
|
|
+ if ("JC".equals(apiRequest.getApproachExit())) {
|
|
|
+ boxDynamicsRecord.setBoxDynamics("进场");
|
|
|
+ boxDynamicsRecord.setApproachExit("JC");
|
|
|
+ } else {
|
|
|
+ boxDynamicsRecord.setBoxDynamics("出场");
|
|
|
+ boxDynamicsRecord.setApproachExit("CC");
|
|
|
+ }
|
|
|
+ boxDynamicsRecord.setBoxCode(String.join(",", boxCodeList));
|
|
|
+ boxDynamicsRecord.setContainerNumber(String.join(",", releaseNoList));
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ List<BoxDynamicsRecordItems> itemsList = new ArrayList<>();
|
|
|
+ // 9. 执行明细参数校验
|
|
|
+ validateBasicParamsItem(apiRequest, msg, billsList, putBoxList, boxTypeList);
|
|
|
+ for (ApiItem item : apiRequest.getItem()) {
|
|
|
+ // 10.构建明细记录对象
|
|
|
+ BoxDynamicsRecordItems recordItems = new BoxDynamicsRecordItems();
|
|
|
+ // 1).明细设置基础信息
|
|
|
+ recordItems.setCreateTime(new Date());
|
|
|
+ recordItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ recordItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ recordItems.setBranchId(AuthUtil.getDeptId());
|
|
|
+ recordItems.setContainerNumber(item.getReleaseNo());
|
|
|
+ recordItems.setBoxCode(item.getCtnrNo());
|
|
|
+ recordItems.setObjective(item.getObjective());
|
|
|
+ // 2).明细处理箱类型
|
|
|
+ if ("1".equals(item.getBoxStatus())) {
|
|
|
+ recordItems.setBoxStatus("坏箱");
|
|
|
+ } else {
|
|
|
+ recordItems.setBoxStatus("好箱");
|
|
|
+ }
|
|
|
+ // 3).明细港口数据赋值
|
|
|
+ if (ports != null) {
|
|
|
+ recordItems.setPortCode(ports.getCode());
|
|
|
+ recordItems.setPortCname(ports.getCnName());
|
|
|
+ recordItems.setPortEname(ports.getEnName());
|
|
|
+ recordItems.setPortId(ports.getId());
|
|
|
+ }
|
|
|
+ // 4).明细箱型数据赋值
|
|
|
+ if (!boxTypeList.isEmpty()) {
|
|
|
+ boxTypeList.stream().filter(e -> e.getCode95().equals(item.getCtnrType())).findFirst().ifPresent(cntrTypes -> recordItems.setBoxType(cntrTypes.getCnName()));
|
|
|
+ }
|
|
|
+ // 5).明细场站数据赋值
|
|
|
+ if (bCorps != null) {
|
|
|
+ recordItems.setStationCname(bCorps.getCnName());
|
|
|
+ recordItems.setStationEname(bCorps.getEnName());
|
|
|
+ recordItems.setStationCode(bCorps.getCode());
|
|
|
+ recordItems.setStationId(bCorps.getId());
|
|
|
+ }
|
|
|
+ recordItems.setHblno(item.getMblno());
|
|
|
+ // 6).明细日期字段处理
|
|
|
+ try {
|
|
|
+ recordItems.setApproachExitDate(formatter.parse(item.getApproachExitDate()));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ msg.append("进出场日期格式不正确,请传入格式为‘yyyy-MM-dd’正确格式日期;");
|
|
|
+ }
|
|
|
+ itemsList.add(recordItems);
|
|
|
+ }
|
|
|
+ // 11.主表港口数据赋值
|
|
|
+ if (ports != null) {
|
|
|
+ boxDynamicsRecord.setPortCode(ports.getCode());
|
|
|
+ boxDynamicsRecord.setPortCname(ports.getCnName());
|
|
|
+ boxDynamicsRecord.setPortEname(ports.getEnName());
|
|
|
+ boxDynamicsRecord.setPortId(ports.getId());
|
|
|
+ }
|
|
|
+ // 12.主表场站数据赋值
|
|
|
+ if (bCorps != null) {
|
|
|
+ boxDynamicsRecord.setStationCname(bCorps.getCnName());
|
|
|
+ boxDynamicsRecord.setStationEname(bCorps.getEnName());
|
|
|
+ boxDynamicsRecord.setStationCode(bCorps.getCode());
|
|
|
+ boxDynamicsRecord.setStationId(bCorps.getId());
|
|
|
+ }
|
|
|
+ boxDynamicsRecord.setReason(msg.toString());
|
|
|
+ boxDynamicsRecord.setRequestContent(apiRequest.toString());
|
|
|
+ if (ObjectUtils.isNotNull(msg.toString())) {
|
|
|
+ boxDynamicsRecord.setType("2");
|
|
|
+ boxDynamicsRecord.setDescription("接收失败");
|
|
|
+ } else {
|
|
|
+ boxDynamicsRecord.setType("1");
|
|
|
+ boxDynamicsRecord.setDescription("接收成功");
|
|
|
+ }
|
|
|
+ //发送消息
|
|
|
+ R<String> res = sysClient.getRoleIds(bCorps.getTenantId(), "箱管");
|
|
|
+ if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
|
|
|
+ R<List<User>> userListR = userClient.listUserByRoleIds(res.getData());
|
|
|
+ if (userListR.isSuccess() && ObjectUtils.isNotNull(userListR.getData())) {
|
|
|
+ for (User item : userListR.getData()) {
|
|
|
+ Message sendMessage = new Message();
|
|
|
+ sendMessage.setParameter(boxDynamicsRecord.getId() + "");
|
|
|
+ sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
+ sendMessage.setUserId(null);
|
|
|
+ sendMessage.setToUserId(item.getId());
|
|
|
+ sendMessage.setToUserName(item.getName());
|
|
|
+ sendMessage.setMessageType(1);
|
|
|
+ sendMessage.setTenantId(AuthUtil.getTenantId());
|
|
|
+ sendMessage.setCreateUser(null);
|
|
|
+ sendMessage.setCreateTime(new Date());
|
|
|
+ sendMessage.setPageLabel("");
|
|
|
+ sendMessage.setPageStatus("");
|
|
|
+ sendMessage.setMessageBody(boxDynamicsRecord.getStationCname() + "场站已推送" + boxDynamicsRecord.getBoxDynamics()
|
|
|
+ + "记录,推送时间:" + formatter.format(boxDynamicsRecord.getImportDate()) + ",推送结果:" + boxDynamicsRecord.getDescription());
|
|
|
+ messageClient.save(sendMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 13. 数据保存处理
|
|
|
+ baseMapper.insert(boxDynamicsRecord);
|
|
|
+ // 14. 错误处理:如果有错误信息则直接返回
|
|
|
+ if (ObjectUtils.isNotNull(msg.toString())) {
|
|
|
+ return R.fail(500, msg + " 请联系相关人员!");
|
|
|
+ } else {
|
|
|
+ for (BoxDynamicsRecordItems item : itemsList) {
|
|
|
+ item.setPid(boxDynamicsRecord.getId());
|
|
|
+ boxDynamicsRecordItemsService.save(item);
|
|
|
+ }
|
|
|
+ // 创建线程池
|
|
|
+ ExecutorService executor = Executors.newSingleThreadExecutor();
|
|
|
+ // 启动任务并提交给线程池
|
|
|
+ executor.submit(() -> {
|
|
|
+ try {
|
|
|
+ if ("JC".equals(boxDynamicsRecord.getApproachExit())) {
|
|
|
+ List<BoxDynamicsRecordItems> itemsListJC = itemsList.stream().filter(e -> !"C,ZJ".contains(e.getObjective())).collect(Collectors.toList());
|
|
|
+ if (!itemsListJC.isEmpty()) {
|
|
|
+ this.synchronization(itemsListJC);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("业务处理成功,发送消息异常,时间:" + new Date());
|
|
|
+ System.out.println(e.getMessage());
|
|
|
+ // 关闭线程池
|
|
|
+ executor.shutdown();
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } finally {
|
|
|
+ // 关闭线程池
|
|
|
+ executor.shutdown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 关闭线程池
|
|
|
+ executor.shutdown();
|
|
|
+ return R.success("成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void synchronization(List<BoxDynamicsRecordItems> itemsListJC) throws IOException {
|
|
|
+ if (itemsListJC.stream().anyMatch(e -> ObjectUtils.isNull(e.getObjective()))) {
|
|
|
+ throw new RemoteException("进出场目的不能为空");
|
|
|
+ }
|
|
|
+ if (!itemsListJC.isEmpty()) {
|
|
|
+ List<String> boxCodeList = itemsListJC.stream().map(BoxDynamicsRecordItems::getBoxCode).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ //箱档案数据
|
|
|
+ List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
|
|
|
+ .eq(Archives::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Archives::getIsDeleted, 0)
|
|
|
+ .in(Archives::getCode, boxCodeList));
|
|
|
+ List<String> containerNumberList = itemsListJC.stream().map(BoxDynamicsRecordItems::getContainerNumber)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ List<PutBox> putBoxList = putBoxService.list(new LambdaQueryWrapper<PutBox>()
|
|
|
+ .eq(PutBox::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PutBox::getIsDeleted, 0)
|
|
|
+ .in(PutBox::getContainerNumber, containerNumberList));
|
|
|
+ if (putBoxList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到放箱号单据");
|
|
|
+ }
|
|
|
+ List<Long> putBoxIdList = putBoxList.stream().map(PutBox::getId).collect(Collectors.toList());
|
|
|
+ List<PutBoxItems> putBoxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
|
|
|
+ .eq(PutBoxItems::getIsDeleted, 0)
|
|
|
+ .eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(PutBoxItems::getPid, putBoxIdList));
|
|
|
+ String blacklist = sysClient.getParamService("box.blacklist");
|
|
|
+ if (ObjectUtils.isNotNull(blacklist)) {
|
|
|
+ StringBuilder text = new StringBuilder();
|
|
|
+ for (String item : boxCodeList) {
|
|
|
+ if (item.length() > 3) {
|
|
|
+ String head = item.substring(0, 4);
|
|
|
+ if (blacklist.contains(head)) {
|
|
|
+ text.append(item).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(text.toString())) {
|
|
|
+ throw new RuntimeException("箱号:" + text + "为黑名单箱,请修改数据后再操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Long> srcIdList = putBoxList.stream().map(PutBox::getSrcId).collect(Collectors.toList());
|
|
|
+ List<TradingBox> tradingBoxList = new ArrayList<>();
|
|
|
+ if (!srcIdList.isEmpty()) {
|
|
|
+ tradingBoxList = tradingBoxMapper.selectList(new LambdaQueryWrapper<TradingBox>()
|
|
|
+ .eq(TradingBox::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBox::getIsDeleted, 0)
|
|
|
+ .in(TradingBox::getId, srcIdList));
|
|
|
+ }
|
|
|
+ List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
|
|
|
+ if (!tradingBoxList.isEmpty()) {
|
|
|
+ List<Long> tradingBoxIdList = tradingBoxList.stream().map(TradingBox::getId).collect(Collectors.toList());
|
|
|
+ tradingBoxItemList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
|
|
|
+ .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(TradingBoxItem::getPid, tradingBoxIdList));
|
|
|
+ }
|
|
|
+ List<PutBoxItems> putBoxItems = new ArrayList<>();
|
|
|
+ List<TradingBoxItem> tradingBoxItems = new ArrayList<>();
|
|
|
+ List<Archives> archivesArrayList = new ArrayList<>();
|
|
|
+ List<PutBox> putBoxes = new ArrayList<>();
|
|
|
+ List<TradingBox> tradingBoxes = new ArrayList<>();
|
|
|
+ for (BoxDynamicsRecordItems item : itemsListJC) {
|
|
|
+ PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())
|
|
|
+ && ObjectUtils.isNotNull(e.getPolId()) && e.getPolId().equals(item.getPortId())
|
|
|
+ && ObjectUtils.isNotNull(e.getPolStationId()) && e.getPolStationId().equals(item.getStationId())).findFirst().orElse(null);
|
|
|
+ if (putBox != null) {
|
|
|
+ if (!putBoxes.isEmpty()) {
|
|
|
+ if (!putBoxes.stream().map(PutBox::getId).collect(Collectors.toList()).contains(putBox.getId())) {
|
|
|
+ putBoxes.add(putBox);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ putBoxes.add(putBox);
|
|
|
+ }
|
|
|
+ //箱档案数据处理
|
|
|
+ Archives archives = archivesList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
|
|
|
+ if (archives != null) {
|
|
|
+ archives.setContainerNumberOw(item.getContainerNumber());
|
|
|
+ archives.setContainerNumberTypeOw(putBox.getBusType());
|
|
|
+ if (!archives.getTypeName().equals(item.getBoxType())) {
|
|
|
+ throw new RuntimeException("箱号:" + item.getBoxCode() + "与箱档案中箱型不符");
|
|
|
+ }
|
|
|
+ if ("使用中".equals(archives.getStatus())) {
|
|
|
+ throw new RuntimeException("箱号:" + item.getBoxCode() + "状态为使用中");
|
|
|
+ }
|
|
|
+ archives.setBoxStatus(item.getBoxStatus());
|
|
|
+ archives.setUpdateTime(new Date());
|
|
|
+ archives.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ archives.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ archives.setStatus("待使用");
|
|
|
+ archives.setNewDate(item.getApproachExitDate());
|
|
|
+ archives.setBoxDynamics("空箱提箱进场");
|
|
|
+ archives.setAddressId(item.getPortId());
|
|
|
+ archives.setAddressCode(item.getPortCode());
|
|
|
+ archives.setAddressCname(item.getPortCname());
|
|
|
+ archives.setAddressEname(item.getPortEname());
|
|
|
+ archives.setStationId(item.getStationId());
|
|
|
+ archives.setStationCode(item.getStationCode());
|
|
|
+ archives.setStationCname(item.getStationCname());
|
|
|
+ archives.setStationEname(item.getStationEname());
|
|
|
+ } else {
|
|
|
+ if (!"OW(拿)".equals(putBox.getBusType())) {
|
|
|
+ throw new RuntimeException("箱档案中未查到箱号:" + item.getBoxCode());
|
|
|
+ }
|
|
|
+ archives = new Archives();
|
|
|
+ archives.setCode(item.getBoxCode());
|
|
|
+ archives.setCreateTime(new Date());
|
|
|
+ archives.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archives.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archives.setStatus("待使用");
|
|
|
+ archives.setBoxStatus(item.getBoxStatus());
|
|
|
+ archives.setNewDate(item.getApproachExitDate());
|
|
|
+ archives.setBoxDynamics("空箱提箱进场");
|
|
|
+ archives.setBoxBelongsTo("SOC");
|
|
|
+ archives.setContainerNumber(item.getContainerNumber());
|
|
|
+ archives.setContainerNumberType(putBox.getBusType());
|
|
|
+ archives.setContainerNumberOw(item.getContainerNumber());
|
|
|
+ archives.setContainerNumberTypeOw(putBox.getBusType());
|
|
|
+ archives.setTypeName(item.getBoxType());
|
|
|
+ archives.setBoxType(putBox.getBusType());
|
|
|
+ archives.setAddressId(item.getPortId());
|
|
|
+ archives.setAddressCode(item.getPortCode());
|
|
|
+ archives.setAddressCname(item.getPortCname());
|
|
|
+ archives.setAddressEname(item.getPortEname());
|
|
|
+ archives.setStationId(item.getStationId());
|
|
|
+ archives.setStationCode(item.getStationCode());
|
|
|
+ archives.setStationCname(item.getStationCname());
|
|
|
+ archives.setStationEname(item.getStationEname());
|
|
|
+ }
|
|
|
+ archivesArrayList.add(archives);
|
|
|
+ if (ObjectUtils.isNotNull(putBox.getBoxType()) && !putBox.getBoxType().equals(item.getBoxType())) {
|
|
|
+ throw new RuntimeException("放箱号:" + item.getContainerNumber() + "箱型不符合");
|
|
|
+ }
|
|
|
+ //放箱号明细数据处理
|
|
|
+ PutBoxItems putBoxItem;
|
|
|
+ if (!putBoxItemsList.isEmpty()) {
|
|
|
+ putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (putBoxItem != null) {
|
|
|
+ putBoxItem.setPid(putBox.getId());
|
|
|
+ putBoxItem.setMblno(item.getMblno());
|
|
|
+ putBoxItem.setBoxDynamics("空箱提箱进场");
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setPolCyId(item.getStationId());
|
|
|
+ putBoxItem.setPolCyCode(item.getStationCode());
|
|
|
+ putBoxItem.setPolCyCname(item.getStationCname());
|
|
|
+ putBoxItem.setPolCyEname(item.getPortEname());
|
|
|
+ putBoxItem.setPolPickUpDate(item.getApproachExitDate());
|
|
|
+ putBoxItem.setPolPreAppearanceDate(item.getApproachExitDate());
|
|
|
+ putBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ } else {
|
|
|
+ putBoxItem = new PutBoxItems();
|
|
|
+ putBoxItem.setBoxClass(putBox.getBusType());
|
|
|
+ putBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ putBoxItem.setBoxCondition("新");
|
|
|
+ putBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setPid(putBox.getId());
|
|
|
+ putBoxItem.setContainerNumber(item.getContainerNumber());
|
|
|
+ putBoxItem.setBoxCode(item.getBoxCode());
|
|
|
+ putBoxItem.setBoxType(item.getBoxType());
|
|
|
+ putBoxItem.setBoxClass(putBox.getBusType());
|
|
|
+ putBoxItem.setMblno(item.getMblno());
|
|
|
+ putBoxItem.setBoxDynamics("空箱提箱进场");
|
|
|
+ putBoxItem.setPolCyId(item.getStationId());
|
|
|
+ putBoxItem.setPolCyCode(item.getStationCode());
|
|
|
+ putBoxItem.setPolCyCname(item.getStationCname());
|
|
|
+ putBoxItem.setPolCyEname(item.getPortEname());
|
|
|
+ putBoxItem.setPolPickUpDate(item.getApproachExitDate());
|
|
|
+ putBoxItem.setPolPreAppearanceDate(item.getApproachExitDate());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ putBoxItem = new PutBoxItems();
|
|
|
+ putBoxItem.setBoxClass(putBox.getBusType());
|
|
|
+ putBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ putBoxItem.setBoxCondition("新");
|
|
|
+ putBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setBoxClass(putBox.getBusType());
|
|
|
+ putBoxItem.setPid(putBox.getId());
|
|
|
+ putBoxItem.setContainerNumber(item.getContainerNumber());
|
|
|
+ putBoxItem.setBoxCode(item.getBoxCode());
|
|
|
+ putBoxItem.setBoxType(item.getBoxType());
|
|
|
+ putBoxItem.setMblno(item.getMblno());
|
|
|
+ putBoxItem.setBoxDynamics("空箱提箱进场");
|
|
|
+ putBoxItem.setPolCyId(item.getStationId());
|
|
|
+ putBoxItem.setPolCyCode(item.getStationCode());
|
|
|
+ putBoxItem.setPolCyCname(item.getStationCname());
|
|
|
+ putBoxItem.setPolCyEname(item.getPortEname());
|
|
|
+ putBoxItem.setPolPickUpDate(item.getApproachExitDate());
|
|
|
+ putBoxItem.setPolPreAppearanceDate(item.getApproachExitDate());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(putBox.getBoxEastId()) && !"null".equals(putBox.getBoxEastId())) {
|
|
|
+ putBoxItem.setBoxEastId(Long.parseLong(putBox.getBoxEastId()));
|
|
|
+ putBoxItem.setBoxEastName(putBox.getBoxEastName());
|
|
|
+ }
|
|
|
+ putBoxItems.add(putBoxItem);
|
|
|
+ if ("OW(拿),OW(放)".contains(putBox.getBusType())) {
|
|
|
+ if (!tradingBoxList.isEmpty()) {
|
|
|
+ TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(putBox.getSrcId()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBox != null) {
|
|
|
+ if (!tradingBoxes.isEmpty()) {
|
|
|
+ if (!tradingBoxes.stream().map(TradingBox::getId).collect(Collectors.toList()).contains(tradingBox.getId())) {
|
|
|
+ tradingBoxes.add(tradingBox);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tradingBoxes.add(tradingBox);
|
|
|
+ }
|
|
|
+ TradingBoxItem tradingBoxItem;
|
|
|
+ if (!tradingBoxItemList.isEmpty()) {
|
|
|
+ tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getBoxCode()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem != null) {
|
|
|
+// throw new RemoteException("箱号:" + item.getBoxCode() + "在放箱号:" + item.getContainerNumber() + "单据中已存在,不能重复导入");
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItem.setMblno(item.getMblno());
|
|
|
+ tradingBoxItem.setBoxDynamics("空箱提箱进场");
|
|
|
+ tradingBoxItem.setPortId(item.getPortId());
|
|
|
+ tradingBoxItem.setPortCode(item.getPortCode());
|
|
|
+ tradingBoxItem.setPortCname(item.getPortCname());
|
|
|
+ tradingBoxItem.setPortEname(item.getPortEname());
|
|
|
+ tradingBoxItem.setStationId(item.getStationId());
|
|
|
+ tradingBoxItem.setStationCode(item.getStationCode());
|
|
|
+ tradingBoxItem.setStationCname(item.getStationCname());
|
|
|
+ tradingBoxItem.setStationEname(item.getStationEname());
|
|
|
+ tradingBoxItem.setPolCyId(item.getStationId());
|
|
|
+ tradingBoxItem.setPolCyCode(item.getStationCode());
|
|
|
+ tradingBoxItem.setPolCyCname(item.getStationCname());
|
|
|
+ tradingBoxItem.setPolCyEname(item.getStationEname());
|
|
|
+ if (ObjectUtils.isNotNull(item.getApproachExitDate())) {
|
|
|
+ tradingBoxItem.setRentEndDate(item.getApproachExitDate());
|
|
|
+ tradingBoxItem.setPolPickUpDate(item.getApproachExitDate());
|
|
|
+ tradingBoxItem.setPolPreAppearanceDate(item.getApproachExitDate());
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setRentEndDate(new Date());
|
|
|
+ tradingBoxItem.setPolPickUpDate(new Date());
|
|
|
+ tradingBoxItem.setPolPreAppearanceDate(new Date());
|
|
|
+ }
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ } else {
|
|
|
+ tradingBoxItem = new TradingBoxItem();
|
|
|
+ tradingBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ if ("OW-N".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("OW(拿)");
|
|
|
+ } else if ("OW-F".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("OW(放)");
|
|
|
+ }
|
|
|
+ putBoxItem.setBoxClass(putBox.getBusType());
|
|
|
+ tradingBoxItem.setBoxCondition("新");
|
|
|
+ tradingBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItem.setContainerNumber(item.getContainerNumber());
|
|
|
+ tradingBoxItem.setCode(item.getBoxCode());
|
|
|
+ tradingBoxItem.setMblno(item.getMblno());
|
|
|
+ tradingBoxItem.setBoxDynamics("空箱提箱进场");
|
|
|
+ tradingBoxItem.setBoxType(item.getBoxType());
|
|
|
+ tradingBoxItem.setPortId(item.getPortId());
|
|
|
+ tradingBoxItem.setPortCode(item.getPortCode());
|
|
|
+ tradingBoxItem.setPortCname(item.getPortCname());
|
|
|
+ tradingBoxItem.setPortEname(item.getPortEname());
|
|
|
+ tradingBoxItem.setStationId(item.getStationId());
|
|
|
+ tradingBoxItem.setStationCode(item.getStationCode());
|
|
|
+ tradingBoxItem.setStationCname(item.getStationCname());
|
|
|
+ tradingBoxItem.setStationEname(item.getStationEname());
|
|
|
+ tradingBoxItem.setPolCyId(item.getStationId());
|
|
|
+ tradingBoxItem.setPolCyCode(item.getStationCode());
|
|
|
+ tradingBoxItem.setPolCyCname(item.getStationCname());
|
|
|
+ tradingBoxItem.setPolCyEname(item.getStationEname());
|
|
|
+ tradingBoxItem.setActivationDate(tradingBox.getActivationDate());
|
|
|
+ if (ObjectUtils.isNotNull(item.getApproachExitDate())) {
|
|
|
+ tradingBoxItem.setRentEndDate(item.getApproachExitDate());
|
|
|
+ tradingBoxItem.setPolPickUpDate(item.getApproachExitDate());
|
|
|
+ tradingBoxItem.setPolPreAppearanceDate(item.getApproachExitDate());
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setRentEndDate(new Date());
|
|
|
+ tradingBoxItem.setPolPickUpDate(new Date());
|
|
|
+ tradingBoxItem.setPolPreAppearanceDate(new Date());
|
|
|
+ }
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tradingBoxItem = new TradingBoxItem();
|
|
|
+ if ("OW-N".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("OW(拿)");
|
|
|
+ } else if ("OW-F".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxCategory("OW(放)");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ tradingBoxItem.setBoxCondition("新");
|
|
|
+ tradingBoxItem.setBoxStatus(item.getBoxStatus());
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItem.setContainerNumber(item.getContainerNumber());
|
|
|
+ tradingBoxItem.setCode(item.getBoxCode());
|
|
|
+ tradingBoxItem.setMblno(item.getMblno());
|
|
|
+ tradingBoxItem.setBoxDynamics("空箱提箱进场");
|
|
|
+ tradingBoxItem.setBoxType(item.getBoxType());
|
|
|
+ tradingBoxItem.setPortId(item.getPortId());
|
|
|
+ tradingBoxItem.setPortCode(item.getPortCode());
|
|
|
+ tradingBoxItem.setPortCname(item.getPortCname());
|
|
|
+ tradingBoxItem.setPortEname(item.getPortEname());
|
|
|
+ tradingBoxItem.setStationId(item.getStationId());
|
|
|
+ tradingBoxItem.setStationCode(item.getStationCode());
|
|
|
+ tradingBoxItem.setStationCname(item.getStationCname());
|
|
|
+ tradingBoxItem.setStationEname(item.getStationEname());
|
|
|
+ tradingBoxItem.setPolCyId(item.getStationId());
|
|
|
+ tradingBoxItem.setPolCyCode(item.getStationCode());
|
|
|
+ tradingBoxItem.setPolCyCname(item.getStationCname());
|
|
|
+ tradingBoxItem.setPolCyEname(item.getStationEname());
|
|
|
+ tradingBoxItem.setActivationDate(tradingBox.getActivationDate());
|
|
|
+ if (ObjectUtils.isNotNull(item.getApproachExitDate())) {
|
|
|
+ tradingBoxItem.setRentEndDate(item.getApproachExitDate());
|
|
|
+ tradingBoxItem.setPolPickUpDate(item.getApproachExitDate());
|
|
|
+ tradingBoxItem.setPolPreAppearanceDate(item.getApproachExitDate());
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setRentEndDate(new Date());
|
|
|
+ tradingBoxItem.setPolPickUpDate(new Date());
|
|
|
+ tradingBoxItem.setPolPreAppearanceDate(new Date());
|
|
|
+ }
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
|
|
|
+ tradingBoxItems.add(tradingBoxItem);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("放箱号:" + item.getContainerNumber() + "未查到OW单据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("放箱号:" + item.getContainerNumber() + "未查到OW单据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到放箱号:" + item.getContainerNumber() + "单据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!putBoxes.isEmpty()) {
|
|
|
+ for (PutBox item : putBoxes) {
|
|
|
+ long count;
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
+ count = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()) &&
|
|
|
+ !item.getCode().contains(e.getBoxCode())).count();
|
|
|
+ } else {
|
|
|
+ count = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())).count();
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
+ for (BoxDynamicsRecordItems e : itemsListJC) {
|
|
|
+ if (e.getContainerNumber().equals(item.getContainerNumber()) && ObjectUtils.isNotNull(item.getCode())
|
|
|
+ && !item.getCode().contains(e.getBoxCode())) {
|
|
|
+ item.setCode(item.getCode() + "," + e.getBoxCode());
|
|
|
+ } else {
|
|
|
+ item.setCode(e.getBoxCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.setCode(itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()))
|
|
|
+ .map(BoxDynamicsRecordItems::getBoxCode).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ if ("0".equals(item.getWhetherManuallyCreate())) {
|
|
|
+ item.setTotalNum(item.getTotalNum() + Integer.parseInt(count + ""));
|
|
|
+ item.setRemainingNum(item.getRemainingNum() + Integer.parseInt(count + ""));
|
|
|
+ item.setStorageNum(item.getStorageNum() + Integer.parseInt(count + ""));
|
|
|
+ }
|
|
|
+ if ("OW(拿)".equals(item.getBusType())) {
|
|
|
+ item.setSuitcaseNum(item.getSuitcaseNum() + Integer.parseInt(count + ""));
|
|
|
+ item.setNotSuitcaseNum(item.getTotalNum() - item.getSuitcaseNum());
|
|
|
+ item.setStorageNum(item.getStorageNum() + Integer.parseInt(count + ""));
|
|
|
+ }
|
|
|
+ if (!tradingBoxes.isEmpty()) {
|
|
|
+ TradingBox tradingBox = tradingBoxes.stream().filter(e -> e.getId().equals(item.getSrcId())).findFirst().orElse(null);
|
|
|
+ if (tradingBox != null) {
|
|
|
+ long count1;
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getCode())) {
|
|
|
+ count1 = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()) &&
|
|
|
+ !tradingBox.getCode().contains(e.getBoxCode())).count();
|
|
|
+ } else {
|
|
|
+ count1 = itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())).count();
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getCode())) {
|
|
|
+ for (BoxDynamicsRecordItems e : itemsListJC) {
|
|
|
+ if (e.getContainerNumber().equals(item.getContainerNumber()) && ObjectUtils.isNotNull(tradingBox.getCode())
|
|
|
+ && !tradingBox.getCode().contains(e.getBoxCode())) {
|
|
|
+ tradingBox.setCode(tradingBox.getCode() + "," + e.getBoxCode());
|
|
|
+ } else {
|
|
|
+ tradingBox.setCode(e.getBoxCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tradingBox.setCode(itemsListJC.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()))
|
|
|
+ .map(BoxDynamicsRecordItems::getBoxCode).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ if ("OW(拿)".contains(item.getBusType())) {
|
|
|
+ tradingBox.setSuitcaseNum(tradingBox.getSuitcaseNum() + Integer.parseInt(count1 + ""));
|
|
|
+ tradingBox.setNotSuitcaseNum(tradingBox.getBoxNumber() - tradingBox.getSuitcaseNum());
|
|
|
+ }
|
|
|
+ tradingBoxMapper.updateById(tradingBox);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ putBoxService.saveOrUpdateBatch(putBoxes);
|
|
|
+ }
|
|
|
+ if (!putBoxItems.isEmpty()) {
|
|
|
+ putBoxItemsService.saveOrUpdateBatch(putBoxItems);
|
|
|
+ for (PutBoxItems item : putBoxItems) {
|
|
|
+ PutBox tradingBox = putBoxes.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
+ if (tradingBox != null) {
|
|
|
+ //记录箱轨迹信息
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ archivesTrajectory.setPortId(tradingBox.getPolId());
|
|
|
+ archivesTrajectory.setPortCode(tradingBox.getPolCode());
|
|
|
+ archivesTrajectory.setPortCname(tradingBox.getPodCname());
|
|
|
+ archivesTrajectory.setPortEname(tradingBox.getPodEname());
|
|
|
+ archivesTrajectory.setStationId(tradingBox.getPolStationId());
|
|
|
+ archivesTrajectory.setStationCode(tradingBox.getPolStationCode());
|
|
|
+ archivesTrajectory.setStationCname(tradingBox.getPolStationCname());
|
|
|
+ archivesTrajectory.setStationEname(tradingBox.getPolStationEname());
|
|
|
+ archivesTrajectory.setContainerNumber(item.getContainerNumber());
|
|
|
+ archivesTrajectory.setBoxType(item.getBoxType());
|
|
|
+ archivesTrajectory.setBoxCategory(item.getBoxClass());
|
|
|
+ archivesTrajectory.setBoxEastId(item.getBoxEastId());
|
|
|
+ archivesTrajectory.setBoxEastName(item.getBoxEastName());
|
|
|
+ archivesTrajectory.setMblno(item.getMblno());
|
|
|
+ archivesTrajectory.setBoxDynamics("空箱进场");
|
|
|
+ archivesTrajectory.setStatus(tradingBox.getBusType());
|
|
|
+ archivesTrajectory.setCorpId(item.getBoxEastId());
|
|
|
+ archivesTrajectory.setCorpName(item.getBoxEastName());
|
|
|
+ archivesTrajectory.setBillType(tradingBox.getBoxType());
|
|
|
+ archivesTrajectory.setCode(item.getBoxCode());
|
|
|
+ archivesTrajectory.setNewDate(new Date());
|
|
|
+ archivesTrajectory.setCreateTime(new Date());
|
|
|
+ archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesTrajectory.setSrcId(tradingBox.getId());
|
|
|
+ archivesTrajectory.setEtd(item.getEtd());
|
|
|
+ archivesTrajectory.setPolCyId(item.getPolCyId());
|
|
|
+ archivesTrajectory.setPolCyCode(item.getPolCyCode());
|
|
|
+ archivesTrajectory.setPolCyCname(item.getPolCyCname());
|
|
|
+ archivesTrajectory.setPolCyEname(item.getPolCyEname());
|
|
|
+ archivesTrajectory.setPolFreeBoxUseDays(item.getPolFreeBoxUseDays());
|
|
|
+ archivesTrajectory.setPolPreAppearanceDate(item.getPolPreAppearanceDate());
|
|
|
+ archivesTrajectory.setPolStationEmptyContainerExitDate(item.getPolStationEmptyContainerExitDate());
|
|
|
+ archivesTrajectory.setPolReturnDate(item.getPolReturnDate());
|
|
|
+ archivesTrajectory.setPolOverdueBoxUseDays(item.getPolOverdueBoxUseDays());
|
|
|
+ archivesTrajectory.setEta(item.getEta());
|
|
|
+ archivesTrajectory.setPodEmptyContainerReturnDate(item.getPodEmptyContainerReturnDate());
|
|
|
+ archivesTrajectory.setPodStationId(item.getPodStationId());
|
|
|
+ archivesTrajectory.setPodStationCode(item.getPodStationCode());
|
|
|
+ archivesTrajectory.setPodStationCname(item.getPodStationCname());
|
|
|
+ archivesTrajectory.setPodStationEname(item.getPodStationEname());
|
|
|
+ archivesTrajectory.setPodFreeBoxUseDays(item.getPodFreeBoxUseDays());
|
|
|
+ archivesTrajectory.setPodBoxUseDays(item.getPodBoxUseDays());
|
|
|
+ archivesTrajectory.setShipNameId(item.getShipNameId());
|
|
|
+ archivesTrajectory.setShipCname(item.getShipCname());
|
|
|
+ archivesTrajectory.setShipEname(item.getShipEname());
|
|
|
+ archivesTrajectory.setShipCode(item.getShipCode());
|
|
|
+ archivesTrajectory.setVoyage(item.getVoyage());
|
|
|
+ archivesTrajectoryMapper.insert(archivesTrajectory);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!archivesArrayList.isEmpty()) {
|
|
|
+ archivesService.saveOrUpdateBatch(archivesArrayList);
|
|
|
+ }
|
|
|
+ if (!tradingBoxItems.isEmpty()) {
|
|
|
+ tradingBoxItemService.saveOrUpdateBatch(tradingBoxItems);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (BoxDynamicsRecordItems item : itemsListJC) {
|
|
|
+ item.setWhetherSynchronous("1");
|
|
|
+ }
|
|
|
+ boxDynamicsRecordItemsService.updateBatchById(itemsListJC);
|
|
|
+ }
|
|
|
+
|
|
|
private void countOverdueFee(List<PutBox> putBoxList, List<TradingBox> tradingBoxList, List<TradingBoxItem> tradingBoxItemOldList,
|
|
|
List<Containers> containersListNew, List<PutBoxItems> putBoxItems) {
|
|
|
List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
@@ -3294,4 +4003,188 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 明细参数校验方法
|
|
|
+ *
|
|
|
+ * @param apiRequest 请求对象
|
|
|
+ * @param msg 错误信息收集器
|
|
|
+ */
|
|
|
+ private void validateBasicParamsItem(ApiRequest apiRequest, StringBuilder msg, List<Bills> billsList,
|
|
|
+ List<PutBox> putBoxList, List<BCntrTypes> boxTypeList) {
|
|
|
+ for (ApiItem item : apiRequest.getItem()) {
|
|
|
+ if (ObjectUtils.isNull(item.getReleaseNo())) {
|
|
|
+ msg.append("放箱号不能为空;");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getCtnrNo())) {
|
|
|
+ msg.append("箱号不能为空;");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getCtnrType())) {
|
|
|
+ msg.append("箱型不能为空;");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getApproachExitDate())) {
|
|
|
+ msg.append("进出场日期不能为空;");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(item.getObjective())) {
|
|
|
+ msg.append("进出场目的不能为空;");
|
|
|
+ }
|
|
|
+ if ("CC".equals(apiRequest.getApproachExit())) {
|
|
|
+ if (ObjectUtils.isNull(item.getMblno())) {
|
|
|
+ msg.append("提单号不能为空;");
|
|
|
+ }
|
|
|
+ if (!billsList.isEmpty()) {
|
|
|
+ List<Bills> bills = billsList.stream().filter(e -> e.getMblno().equals(item.getMblno()) ||
|
|
|
+ e.getHblno().equals(item.getMblno())).collect(Collectors.toList());
|
|
|
+ if (bills.isEmpty()) {
|
|
|
+ msg.append("提单号:").append(item.getMblno()).append("不存在;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!boxTypeList.isEmpty()) {
|
|
|
+ BCntrTypes cntrTypes = boxTypeList.stream().filter(e -> e.getCode95().equals(item.getCtnrType())).findFirst().orElse(null);
|
|
|
+ if (cntrTypes == null) {
|
|
|
+ msg.append("箱型:").append(item.getCtnrType()).append("不正确;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!putBoxList.isEmpty()) {
|
|
|
+ PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getReleaseNo())).findFirst().orElse(null);
|
|
|
+ if (putBox == null) {
|
|
|
+ msg.append("放箱号:").append(item.getReleaseNo()).append("不存在;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 基础参数校验方法
|
|
|
+ *
|
|
|
+ * @param apiRequest 请求对象
|
|
|
+ * @param msg 错误信息收集器
|
|
|
+ */
|
|
|
+ private void validateBasicParams(ApiRequest apiRequest, StringBuilder msg) {
|
|
|
+ // 校验明细数据不能为空
|
|
|
+ if (apiRequest.getItem() == null || apiRequest.getItem().isEmpty()) {
|
|
|
+ msg.append("集装箱明细不能为空;");
|
|
|
+ }
|
|
|
+ // 校验港口代码不能为空
|
|
|
+ if (apiRequest.getPortNo() == null) {
|
|
|
+ msg.append("港口代码不能为空;");
|
|
|
+ }
|
|
|
+ // 校验场站代码不能为空
|
|
|
+ if (ObjectUtils.isNull(apiRequest.getStationCode())) {
|
|
|
+ msg.append("场站代码不能为空;");
|
|
|
+ }
|
|
|
+ // 校验进出场类型不能为空
|
|
|
+ if (ObjectUtils.isNull(apiRequest.getApproachExit())) {
|
|
|
+ msg.append("进出场类型不能为空;");
|
|
|
+ }
|
|
|
+ // 校验推送时间不能为空
|
|
|
+ if (ObjectUtils.isNull(apiRequest.getImportDate())) {
|
|
|
+ msg.append("推送时间不能为空;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<ContainerMovement> parseEdifactMessage(InputStream inputStream) throws IOException {
|
|
|
+ List<ContainerMovement> movements = new ArrayList<>();
|
|
|
+ if (inputStream == null) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+// String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
|
|
+ InputStreamReader reader = new InputStreamReader(inputStream, "GBK"); // 根据实际编码调整
|
|
|
+ String content = IOUtils.toString(reader);
|
|
|
+
|
|
|
+ // 分割每个消息(以UNH开头,UNT结尾)
|
|
|
+ String[] messages = content.split("(?=UNH\\+)");
|
|
|
+
|
|
|
+ for (String message : messages) {
|
|
|
+ if (message.trim().isEmpty()) continue;
|
|
|
+
|
|
|
+ ContainerMovement movement = new ContainerMovement();
|
|
|
+ String[] segments = message.split("'\\s*");
|
|
|
+
|
|
|
+ for (String segment : segments) {
|
|
|
+ if (segment.isEmpty()) continue;
|
|
|
+
|
|
|
+ String[] elements = segment.split("\\+");
|
|
|
+ String segmentTag = elements[0];
|
|
|
+
|
|
|
+ switch (segmentTag) {
|
|
|
+ case "UNH":
|
|
|
+ movement.setMessageReference(elements[1]);
|
|
|
+ break;
|
|
|
+ case "BGM":
|
|
|
+ movement.setMessageType(elements[1]);
|
|
|
+ movement.setMovementNumber(elements[2]);
|
|
|
+ break;
|
|
|
+ case "TDT":
|
|
|
+ if (elements.length > 2 && elements[1].equals("20")) {
|
|
|
+ movement.setVesselName(elements[2]);
|
|
|
+ if (elements.length > 6) {
|
|
|
+ movement.setVoyageNumber(elements[6].split(":")[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "NAD":
|
|
|
+ if (elements.length > 2 && elements[1].equals("MS")) {
|
|
|
+ movement.setYardCode(elements[2].split(":")[0]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "EQD":
|
|
|
+ if (elements.length > 2) {
|
|
|
+ movement.setContainerNumber(elements[2]);
|
|
|
+ movement.setContainerType(elements[3].split(":")[0]);
|
|
|
+ movement.setContainerSize(elements[4]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "RFF":
|
|
|
+ if (elements.length > 1) {
|
|
|
+ if (elements[1].startsWith("BM:")) {
|
|
|
+ movement.setBillOfLading(elements[1].substring(3));
|
|
|
+ } else if (elements[1].startsWith("BN:")) {
|
|
|
+ movement.setBookingNumber(elements[1].substring(3));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "DTM":
|
|
|
+ if (elements.length > 1 && elements[1].startsWith("7")) {
|
|
|
+ String[] dateParts = elements[1].split(":");
|
|
|
+ movement.setMovementDateTime(dateParts[1]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "LOC":
|
|
|
+ if (elements.length > 2) {
|
|
|
+ if (elements[1].equals("9")) {
|
|
|
+ movement.setFromLocation(elements[2].split(":")[0]);
|
|
|
+ } else if (elements[1].equals("11")) {
|
|
|
+ movement.setToLocation(elements[2].split(":")[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "MEA":
|
|
|
+ if (elements.length > 1 && elements[1].equals("AAE")) {
|
|
|
+ movement.setCargoWeight(elements[3]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "SEL":
|
|
|
+ if (elements.length > 1) {
|
|
|
+ movement.setSealNumber(elements[1]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "FTX":
|
|
|
+ if (elements.length > 1) {
|
|
|
+ movement.setObjective(elements[1]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "DAM":
|
|
|
+ if (elements.length > 1) {
|
|
|
+ movement.setBoxGoodBad(elements[1]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ movements.add(movement);
|
|
|
+ }
|
|
|
+
|
|
|
+ return movements;
|
|
|
+ }
|
|
|
+
|
|
|
}
|