demand: 新增/编辑货物组批次增加修改运单件数、重量、体积功能 新增/编辑货物组批次增加校验件数、重量、体积是否符合规范功能。 运单修改、网点费用申请增加校验运单组批次是否分批

committer: heyu
This commit is contained in:
aike 2025-08-01 16:51:43 +08:00
parent a7cc7d4eb5
commit d586d7ab85
11 changed files with 338 additions and 51 deletions

View File

@ -197,9 +197,11 @@ public class EmisWaybillController extends EmisBaseController
}
// 获取取件员电话
if(!StringUtils.isEmpty(waybillOrder.getTakePieceEmployeeCode())){
SysUser user= sysUserService.selectUserByUserName(waybillOrder.getTakePieceEmployeeCode());
waybillOrder.setTakePieceEmployeePhone(user.getPhonenumber());
if (!StringUtils.isEmpty(waybillOrder.getTakePieceEmployeeCode())) {
SysUser user = sysUserService.selectUserByUserName(waybillOrder.getTakePieceEmployeeCode());
if (Objects.nonNull(user)) {
waybillOrder.setTakePieceEmployeePhone(user.getPhonenumber());
}
}
return AjaxResult.success("获取成功",waybillOrder);

View File

@ -57,6 +57,14 @@ public class EmisTmsSiteBatchDtl extends BaseEntity
private String scanMan;
/* 扫描站点 */
private String scanSite;
/* 分批体积 */
private BigDecimal batchVolume;
/* 分批件数 */
private Integer batchParcelQty;
/* 分批重量 */
private BigDecimal batchWeight;
/* 运单分批状态 1-已分批 0-未分批,默认为0 */
private String blBatch;
// 扩展参数
private EmisWaybill waybillDetail;

View File

@ -15,9 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.common.annotation.audit.DataAuditLog;
import com.xdadan.erp.common.annotation.audit.OperateType;
import com.xdadan.erp.emis.domain.EmisTmsSiteBatch;
import com.xdadan.erp.emis.domain.EmisWaybill;
import com.xdadan.erp.emis.service.impl.EmisTmsSiteBatchServiceImpl;
import com.xdadan.erp.emis.service.impl.EmisWaybillServiceImpl;
import org.apache.ibatis.annotations.Param;
/**
@ -119,6 +117,19 @@ public interface EmisTmsSiteBatchMapper extends BaseMapper<EmisTmsSiteBatch>
*/
List<EmisTmsSiteBatch> selectEmisTmsSiteBatchListByBillCodes(@Param("billCodes") List<String> billCodes);
/**
* 根据起始网点、下一网点和运单号查询TMS组批次
*
* @param startSiteCode 起始网点编码
* @param nextSiteCode 下一网点编码
* @param billCode 运单号
* @param id
* @return TMS组批次列表
*/
List<EmisTmsSiteBatch> selectTmsSiteBatchBySiteAndBillCode(@Param("startSiteCode") String startSiteCode,
@Param("nextSiteCode") String nextSiteCode,
@Param("billCode") String billCode, @Param("id")Long id);
/**
* 验重
*

View File

@ -193,6 +193,9 @@ public class EmisBaseService {
@Autowired
private EmisTmsSiteBatchMissRecordMapper emisTmsSiteBatchMissRecordMapper;
@Autowired
private EmisTmsSiteBatchDtlMapper emisTmsSiteBatchDtlMapper;
private static SysUser emptySysUser = new SysUser();
static {
@ -5315,6 +5318,41 @@ public class EmisBaseService {
masterBillCode, virtualBillCode, newVirtualRemark);
}
/**
* 检查运单是否已分批
*
* @param emisWaybillSave 保存的运单信息
* @param emisWaybillOld 原运单信息
* @throws EmisBizError 业务异常
*/
public void checkBatch(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) throws EmisBizError {
// 检查运单号是否为空
if (StringUtils.isBlank(emisWaybillSave.getBillCode())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "运单号不能为空");
}
if (emisWaybillSave.getParcelQty().equals(emisWaybillOld.getParcelQty())
&& emisWaybillSave.getBillWeight().equals(emisWaybillOld.getBillWeight())
&& emisWaybillSave.getTotalVolume().equals(emisWaybillOld.getTotalVolume())) {
return;
}
// 构建查询条件:根据运单号和bl_batch=1查询批次详情
EmisTmsSiteBatchDtl queryCondition = new EmisTmsSiteBatchDtl();
queryCondition.setBillCode(emisWaybillSave.getBillCode());
queryCondition.setBlBatch("1"); // 已分批状态
// 查询批次详情表
List<EmisTmsSiteBatchDtl> batchDtlList = emisTmsSiteBatchDtlMapper
.selectEmisTmsSiteBatchDtlList(queryCondition);
// 如果查询结果数量大于0,说明该运单已分批,抛出业务异常
if (batchDtlList != null && batchDtlList.size() > 0) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
"运单[" + emisWaybillSave.getBillCode() + "]已分批,不允许修改件数、重量、体积");
}
}
public static void main(String[] args) throws ParseException {
// Date startDate = new Date("202");
Date startDate= new SimpleDateFormat("yyyy-MM-dd").parse("2025-05-11");

View File

@ -41,6 +41,18 @@ public interface IEmisTmsSiteBatchService extends IDataAuditService
*/
public List<EmisTmsSiteBatch> selectTmsSiteBatchBySupplerAndCarNo(String supplierCode, String carNo, Date etd);
/**
* 根据起始网点、下一网点和运单号查询TMS组批次
*
* @param startSiteCode 起始网点编码
* @param nextSiteCode 下一网点编码
* @param billCode 运单号
* @param id
* @return TMS组批次列表
*/
public List<EmisTmsSiteBatch> selectTmsSiteBatchBySiteAndBillCode(String startSiteCode, String nextSiteCode,
String billCode, Long id);
/**
* 查询一级网点TMS组批次列表
*
@ -67,9 +79,9 @@ public interface IEmisTmsSiteBatchService extends IDataAuditService
/**
*
* @param oldSiteBatch
* @param billCode
* @param itemDtl
*/
public void checkSiteBatch(EmisTmsSiteBatch oldSiteBatch, String billCode) throws EmisBizError;
public void checkSiteBatch(EmisTmsSiteBatch oldSiteBatch, EmisTmsSiteBatchDtl itemDtl) throws EmisBizError;
/**
* 修改一级网点TMS组批次

View File

@ -82,7 +82,7 @@ public class EmisTmsSiteBatchDtlServiceImpl implements IEmisTmsSiteBatchDtlServi
@Override
public int insertEmisTmsSiteBatchDtl(EmisTmsSiteBatchDtl emisTmsSiteBatchDtl) throws EmisBizError {
EmisTmsSiteBatch oldSiteBatch = emisTmsSiteBatchMapper.selectTmsSiteBatchByBatchNo(emisTmsSiteBatchDtl.getBatchNo());
emisTmsSiteBatchService.checkSiteBatch(oldSiteBatch, emisTmsSiteBatchDtl.getBillCode());
emisTmsSiteBatchService.checkSiteBatch(oldSiteBatch, emisTmsSiteBatchDtl);
return emisTmsSiteBatchDtlMapper.insertEmisTmsSiteBatchDtl(emisTmsSiteBatchDtl);
}

View File

@ -10,14 +10,13 @@
package com.xdadan.erp.emis.service.impl;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import cn.hutool.core.collection.CollectionUtil;
import com.xdadan.erp.common.core.redis.RedissonService;
import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.common.utils.SecurityUtils;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
@ -27,7 +26,6 @@ import com.xdadan.erp.emis.mapper.EmisTransPlanRuleMapper;
import com.xdadan.erp.emis.mapper.EmisTmsSiteBatchLogMapper;
import com.xdadan.erp.emis.mapper.EmisWaybillMapper;
import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.service.IEmisTmsSiteBatchDtlService;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -39,7 +37,7 @@ import com.xdadan.erp.emis.service.IEmisTmsSiteBatchService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/**
/**
* 一级网点TMS组批次Service业务层处理
*
* @author linfso
@ -47,8 +45,7 @@ import org.springframework.util.CollectionUtils;
*/
@Service
@Slf4j
public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmisTmsSiteBatchService
{
public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmisTmsSiteBatchService {
@Autowired
private EmisTmsSiteBatchMapper emisTmsSiteBatchMapper;
@ -105,6 +102,11 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
return emisTmsSiteBatchMapper.selectTmsSiteBatchBySupplerAndCarNo(emisTmsSiteBatch);
}
@Override
public List<EmisTmsSiteBatch> selectTmsSiteBatchBySiteAndBillCode(String startSiteCode, String nextSiteCode,
String billCode, Long id) {
return emisTmsSiteBatchMapper.selectTmsSiteBatchBySiteAndBillCode(startSiteCode, nextSiteCode, billCode,id);
}
/**
* 查询一级网点TMS组批次列表
@ -113,8 +115,7 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
* @return 一级网点TMS组批次
*/
@Override
public List<EmisTmsSiteBatch> selectEmisTmsSiteBatchList(EmisTmsSiteBatch emisTmsSiteBatch)
{
public List<EmisTmsSiteBatch> selectEmisTmsSiteBatchList(EmisTmsSiteBatch emisTmsSiteBatch) {
return emisTmsSiteBatchMapper.selectEmisTmsSiteBatchList(emisTmsSiteBatch);
}
@ -125,8 +126,7 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
* @return
*/
@Override
public List<EmisTmsSiteBatch> selectEmisTmsSiteBatchDtlList(EmisTmsSiteBatch emisTmsSiteBatch)
{
public List<EmisTmsSiteBatch> selectEmisTmsSiteBatchDtlList(EmisTmsSiteBatch emisTmsSiteBatch) {
return emisTmsSiteBatchMapper.selectEmisTmsSiteBatchDtlList(emisTmsSiteBatch);
}
@ -138,11 +138,10 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
*/
@Transactional
@Override
public int insertEmisTmsSiteBatch(EmisTmsSiteBatch emisTmsSiteBatch)
{
public int insertEmisTmsSiteBatch(EmisTmsSiteBatch emisTmsSiteBatch) {
// 插入明细数据
if(!CollectionUtils.isEmpty(emisTmsSiteBatch.getBatchDtlList())){
for (EmisTmsSiteBatchDtl itemDtl:emisTmsSiteBatch.getBatchDtlList()) {
if (!CollectionUtils.isEmpty(emisTmsSiteBatch.getBatchDtlList())) {
for (EmisTmsSiteBatchDtl itemDtl : emisTmsSiteBatch.getBatchDtlList()) {
itemDtl.setId(null);
itemDtl.setBatchNo(emisTmsSiteBatch.getBatchNo());
emisTmsSiteBatchDtlMapper.insertEmisTmsSiteBatchDtl(itemDtl);
@ -155,11 +154,119 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
return 1;
}
public void checkSiteBatch(EmisTmsSiteBatch oldSiteBatch, String billCode) throws EmisBizError {
EmisWaybill emisWaybill = emisWaybillMapper.selectEmisWaybillByBillCode(billCode);
checkVirtual(billCode, emisWaybill);
checkTransPlanRule(oldSiteBatch, emisWaybill);
checkUnique(oldSiteBatch, billCode);
public void checkSiteBatch(EmisTmsSiteBatch oldSiteBatch, EmisTmsSiteBatchDtl itemDtl) throws EmisBizError {
EmisWaybill emisWaybill = emisWaybillMapper.selectEmisWaybillByBillCode(itemDtl.getBillCode());
checkVirtual(itemDtl.getBillCode(), emisWaybill);
EmisTransPlanRule rule = checkTransPlanRule(oldSiteBatch, emisWaybill);
checkItemDtl(oldSiteBatch, itemDtl, emisWaybill, rule);
}
private void checkItemDtl(EmisTmsSiteBatch oldSiteBatch, EmisTmsSiteBatchDtl itemDtl, EmisWaybill emisWaybill,
EmisTransPlanRule rule) throws EmisBizError {
if (emisWaybill.getParcelQty().equals(itemDtl.getBatchParcelQty())
&& emisWaybill.getBillWeight().equals(itemDtl.getBatchWeight())
&& emisWaybill.getTotalVolume().equals(itemDtl.getBatchVolume())) {
checkUnique(oldSiteBatch, itemDtl.getBillCode());
return;
}
itemDtl.setBlBatch("1");
// 校验批次重量、件数、体积都得大于0
if (itemDtl.getBatchWeight() == null || itemDtl.getBatchWeight().compareTo(BigDecimal.ZERO) <= 0) {
throw new EmisBizError(EmisBizErrorType.FAIL, itemDtl.getBillCode() + "的批次重量必须大于0");
}
if (itemDtl.getBatchParcelQty() == null || itemDtl.getBatchParcelQty() <= 0) {
throw new EmisBizError(EmisBizErrorType.FAIL, itemDtl.getBillCode() + "的批次件数必须大于0");
}
if (itemDtl.getBatchVolume() == null || itemDtl.getBatchVolume().compareTo(BigDecimal.ZERO) <= 0) {
throw new EmisBizError(EmisBizErrorType.FAIL, itemDtl.getBillCode() + "的批次体积必须大于0");
}
// 根据起始网点、下一网点和运单号查询TMS组批次
List<EmisTmsSiteBatch> existingBatches = selectTmsSiteBatchBySiteAndBillCode(
oldSiteBatch.getStartSiteCode(),
oldSiteBatch.getNextSiteCode(),
itemDtl.getBillCode(),itemDtl.getId());
// 创建包含当前批次的临时批次列表用于分组去重
List<EmisTmsSiteBatch> allBatches = new ArrayList<>(existingBatches);
// 创建当前批次的临时对象用于分组计算
EmisTmsSiteBatch currentBatch = new EmisTmsSiteBatch();
currentBatch.setStartSiteCode(oldSiteBatch.getStartSiteCode());
currentBatch.setNextSiteCode(oldSiteBatch.getNextSiteCode());
currentBatch.setTotalWeight(itemDtl.getBatchWeight());
currentBatch.setTotalParcelQty(itemDtl.getBatchParcelQty());
currentBatch.setTotalVolume(itemDtl.getBatchVolume());
allBatches.add(currentBatch);
// 将allBatches根据起始网点、下一网点、批次重量、件数、体积分组去重
Map<String, List<EmisTmsSiteBatch>> groupedBatches = allBatches.stream()
.collect(Collectors.groupingBy(batch -> batch.getStartSiteCode() + "_" + batch.getNextSiteCode() + "_" +
batch.getTotalWeight() + "_" + batch.getTotalParcelQty() + "_" + batch.getTotalVolume()));
// 计算去重后的批次总重量、总件数、总体积
BigDecimal totalWeight = groupedBatches.values().stream()
.map(batchList -> batchList.get(0).getTotalWeight())
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
Integer totalParcelQty = groupedBatches.values().stream()
.map(batchList -> batchList.get(0).getTotalParcelQty())
.filter(Objects::nonNull)
.reduce(0, Integer::sum);
BigDecimal totalVolume = groupedBatches.values().stream()
.map(batchList -> batchList.get(0).getTotalVolume())
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 校验总重量、总件数、总体积不能超过运单数据
if (totalWeight.compareTo(emisWaybill.getBillWeight()) > 0) {
throw new EmisBizError(EmisBizErrorType.FAIL,
itemDtl.getBillCode() + "的批次总重量(" + totalWeight + ")超过运单重量(" + emisWaybill.getBillWeight() + ")");
}
if (totalParcelQty > emisWaybill.getParcelQty()) {
throw new EmisBizError(EmisBizErrorType.FAIL,
itemDtl.getBillCode() + "的批次总件数(" + totalParcelQty + ")超过运单件数(" + emisWaybill.getParcelQty() + ")");
}
if (totalVolume.compareTo(emisWaybill.getTotalVolume()) > 0) {
throw new EmisBizError(EmisBizErrorType.FAIL,
itemDtl.getBillCode() + "的批次总体积(" + totalVolume + ")超过运单体积(" + emisWaybill.getTotalVolume() + ")");
}
// 检查rule.supplierCode是否包含多个供应商编码(用逗号隔开)
if (StringUtils.isNotBlank(rule.getSupplierCode()) && rule.getSupplierCode().contains(",")) {
// 将supplierCode按逗号分割成数组
String[] supplierCodes = rule.getSupplierCode().split(",");
List<String> supplierCodeList = Arrays.asList(supplierCodes);
// 检查现有批次中是否有supplierCode在rule.supplierCode内
boolean hasMatchingSupplier = existingBatches.stream()
.anyMatch(batch -> supplierCodeList.contains(batch.getSupplierCode()));
if (hasMatchingSupplier) {
// 找到匹配的批次,检查重量、体积、件数是否一致
EmisTmsSiteBatch matchingBatch = existingBatches.stream()
.filter(batch -> supplierCodeList.contains(batch.getSupplierCode()))
.findFirst()
.orElse(null);
if (matchingBatch != null) {
// 检查批次重量、体积、件数是否一致
if (!Objects.equals(matchingBatch.getTotalWeight(), itemDtl.getBatchWeight()) ||
!Objects.equals(matchingBatch.getTotalVolume(), itemDtl.getBatchVolume()) ||
!Objects.equals(matchingBatch.getTotalParcelQty(), itemDtl.getBatchParcelQty())) {
throw new EmisBizError(EmisBizErrorType.FAIL,
itemDtl.getBillCode() + "的批次重量、体积、件数与批次" + matchingBatch.getBatchNo() + "不一致,请检查后重新录入");
}
}
}
}
}
private static void checkVirtual(String billCode, EmisWaybill emisWaybill) throws EmisBizError {
@ -176,7 +283,8 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
}
}
private void checkTransPlanRule(EmisTmsSiteBatch oldSiteBatch, EmisWaybill emisWaybill) throws EmisBizError {
private EmisTransPlanRule checkTransPlanRule(EmisTmsSiteBatch oldSiteBatch, EmisWaybill emisWaybill)
throws EmisBizError {
EmisTransPlanRule emisTransPlanRule = new EmisTransPlanRule();
emisTransPlanRule.setStartSiteCode(oldSiteBatch.getStartSiteCode());
emisTransPlanRule.setNextSiteCode(oldSiteBatch.getNextSiteCode());
@ -185,8 +293,9 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
emisTransPlanRule.setProductType(emisWaybill.getProductType());
List<EmisTransPlanRule> list = emisTransPlanRuleMapper.checkTransPlanRule(emisTransPlanRule);
if (CollectionUtil.isEmpty(list)) {
throw new EmisBizError(EmisBizErrorType.FAIL, emisWaybill.getBillCode()+"组批次起始网点、下一网点、供应商与规则不匹配");
throw new EmisBizError(EmisBizErrorType.FAIL, emisWaybill.getBillCode() + "组批次起始网点、下一网点、供应商与规则不匹配");
}
return list.get(0);
}
private void checkUnique(EmisTmsSiteBatch emisTmsSiteBatch, String billCode) throws EmisBizError {
@ -266,12 +375,13 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
.collect(Collectors.toList());
for (EmisTmsSiteBatchDtl itemDtl : distinctBatchDtlList) {
checkSiteBatch(emisTmsSiteBatch, itemDtl.getBillCode());
checkSiteBatch(emisTmsSiteBatch, itemDtl);
itemDtl.setBatchNo(emisTmsSiteBatch.getBatchNo());
emisTmsSiteBatchDtlMapper.insertEmisTmsSiteBatchDtl(itemDtl);
}
List<String> billCodes = distinctBatchDtlList.stream().map(EmisTmsSiteBatchDtl::getBillCode).distinct().collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(billCodes)) {
List<String> billCodes = distinctBatchDtlList.stream().map(EmisTmsSiteBatchDtl::getBillCode).distinct()
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(billCodes)) {
setOperateLog(emisTmsSiteBatch, "1", "新增运单", billCodes);
}
}
@ -308,9 +418,6 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
.values()
.stream()
.collect(Collectors.toList());
for (EmisTmsSiteBatchDtl itemDtl : distinctBatchDtlList) {
checkSiteBatch(emisTmsSiteBatch, itemDtl.getBillCode());
}
}
emisTmsSiteBatchMapper.updateEmisTmsSiteBatch(emisTmsSiteBatch);
emisTmsSiteBatchLoadingMapper.updateDelFlagByBatchNo(emisTmsSiteBatch.getBatchNo());
@ -337,16 +444,68 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
(existing, replacement) -> existing))
: new HashMap<>();
// 分离插入和删除的数据
List<EmisTmsSiteBatchDtl> insertList = new ArrayList<>();
List<EmisTmsSiteBatchDtl> deleteList = new ArrayList<>();
// 处理需要插入的新数据
if (CollectionUtil.isNotEmpty(distinctBatchDtlList)) {
List<String> newBillCodes = new ArrayList<>();
for (EmisTmsSiteBatchDtl itemDtl : distinctBatchDtlList) {
// 如果历史数据中不存在该billCode,则插入新数据
// 如果历史数据中不存在该billCode,则加入插入列表
if (!historyBatchDtlMap.containsKey(itemDtl.getBillCode())) {
emisTmsSiteBatchDtlMapper.insertEmisTmsSiteBatchDtl(itemDtl);
newBillCodes.add(itemDtl.getBillCode());
insertList.add(itemDtl);
}
}
}
// 处理需要软删除的历史数据
if (CollectionUtil.isNotEmpty(historyBatchDtlList)) {
for (EmisTmsSiteBatchDtl historyDtl : historyBatchDtlList) {
// 如果新数据中不存在该billCode,则加入删除列表
if (!newBatchDtlMap.containsKey(historyDtl.getBillCode())) {
deleteList.add(historyDtl);
}
}
}
// 从distinctBatchDtlList中剔除insertList和deleteList中的数据
List<EmisTmsSiteBatchDtl> remainingList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(distinctBatchDtlList)) {
Set<String> insertBillCodes = insertList.stream()
.map(EmisTmsSiteBatchDtl::getBillCode)
.collect(Collectors.toSet());
Set<String> deleteBillCodes = deleteList.stream()
.map(EmisTmsSiteBatchDtl::getBillCode)
.collect(Collectors.toSet());
remainingList = distinctBatchDtlList.stream()
.filter(item -> !insertBillCodes.contains(item.getBillCode()) &&
!deleteBillCodes.contains(item.getBillCode()))
.collect(Collectors.toList());
}
// 对剩余数据调用checkSiteBatch
if (CollectionUtil.isNotEmpty(remainingList)) {
for (EmisTmsSiteBatchDtl itemDtl : remainingList) {
checkSiteBatch(emisTmsSiteBatch, itemDtl);
emisTmsSiteBatchDtlMapper.updateEmisTmsSiteBatchDtl(itemDtl);
}
}
// 对插入列表中的数据调用checkItemDtl
if (CollectionUtil.isNotEmpty(insertList)) {
for (EmisTmsSiteBatchDtl itemDtl : insertList) {
checkSiteBatch(emisTmsSiteBatch, itemDtl);
}
}
// 执行新增操作
if (CollectionUtil.isNotEmpty(insertList)) {
List<String> newBillCodes = new ArrayList<>();
for (EmisTmsSiteBatchDtl itemDtl : insertList) {
emisTmsSiteBatchDtlMapper.insertEmisTmsSiteBatchDtl(itemDtl);
newBillCodes.add(itemDtl.getBillCode());
}
// 记录新增运单日志
if (!newBillCodes.isEmpty()) {
@ -354,15 +513,12 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
}
}
// 处理需要软删除的历史数据
if (CollectionUtil.isNotEmpty(historyBatchDtlList)) {
// 执行删除操作
if (CollectionUtil.isNotEmpty(deleteList)) {
List<String> deletedBillCodes = new ArrayList<>();
for (EmisTmsSiteBatchDtl historyDtl : historyBatchDtlList) {
// 如果新数据中不存在该billCode,则软删除历史数据
if (!newBatchDtlMap.containsKey(historyDtl.getBillCode())) {
emisTmsSiteBatchDtlMapper.deleteEmisTmsSiteBatchDtlById(historyDtl.getId());
deletedBillCodes.add(historyDtl.getBillCode());
}
for (EmisTmsSiteBatchDtl historyDtl : deleteList) {
emisTmsSiteBatchDtlMapper.deleteEmisTmsSiteBatchDtlById(historyDtl.getId());
deletedBillCodes.add(historyDtl.getBillCode());
}
// 记录删除运单日志
@ -381,7 +537,8 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
return 1;
}
private void setOperateLog(EmisTmsSiteBatch emisTmsSiteBatch, String number, String 删除运单, List<String> deletedBillCodes) {
private void setOperateLog(EmisTmsSiteBatch emisTmsSiteBatch, String number, String 删除运单,
List<String> deletedBillCodes) {
EmisTmsSiteBatchLog log = new EmisTmsSiteBatchLog();
log.setBatchNo(emisTmsSiteBatch.getBatchNo());
log.setOpType(number);

View File

@ -370,6 +370,9 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements
// 处理虚拟件逻辑
handleVirtualForUpdate(emisWaybillSave, emisWaybillOld);
// 校验运单是否分批
checkBatch(emisWaybillSave, emisWaybillOld);
recordWaybillOperLog(
emisWaybillAjustApply.getBillCode(),
WaybillOperLogType.SITE_MODIFY_APPLY,

View File

@ -1521,6 +1521,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
// 处理虚拟件逻辑
handleVirtualForUpdate(emisWaybillSave, emisWaybillOld);
// 校验运单是否分批
checkBatch(emisWaybillSave, emisWaybillOld);
// 修改运单
reUpdateWayBill(emisWaybillOld, emisWaybillSave,true,false);

View File

@ -13,6 +13,10 @@
<result property="groupStatus" column="group_status" />
<result property="scanMan" column="scan_man" />
<result property="scanSite" column="scan_site" />
<result property="batchVolume" column="batch_volume" />
<result property="batchParcelQty" column="batch_parcel_qty" />
<result property="batchWeight" column="batch_weight" />
<result property="blBatch" column="bl_batch" />
</resultMap>
@ -26,7 +30,7 @@
</resultMap>
<sql id="selectEmisTmsSiteBatchDtlVo">
select id, bill_code, batch_no, scan_date, scan_status, group_status, scan_man, scan_site, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_site_batch_dtl
select id, bill_code, batch_no, scan_date, scan_status, group_status, scan_man, scan_site, batch_volume, batch_parcel_qty, batch_weight, bl_batch, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_site_batch_dtl
</sql>
<select id="selectEmisTmsSiteBatchDtlList" parameterType="EmisTmsSiteBatchDtl" resultMap="EmisTmsSiteBatchDtlResult">
@ -41,6 +45,10 @@
<if test="groupStatus != null and groupStatus != ''"> and group_status=#{groupStatus}</if>
<if test="scanMan != null and scanMan != ''"> and scan_man like concat('%', #{scanMan}, '%')</if>
<if test="scanSite != null and scanSite != ''"> and scan_site =#{scanSite}</if>
<if test="batchVolume != null"> and batch_volume = #{batchVolume}</if>
<if test="batchParcelQty != null"> and batch_parcel_qty = #{batchParcelQty}</if>
<if test="batchWeight != null"> and batch_weight = #{batchWeight}</if>
<if test="blBatch != null and blBatch != ''"> and bl_batch = #{blBatch}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id like concat('%', #{tenantId}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
@ -85,6 +93,10 @@
and group_status = #{groupStatus}
and scan_man = #{scanMan}
and scan_site = #{scanSite}
and batch_volume = #{batchVolume}
and batch_parcel_qty = #{batchParcelQty}
and batch_weight = #{batchWeight}
and bl_batch = #{blBatch}
and remark = #{remark}
and tenant_id = #{tenantId}
and del_flag = #{delFlag}
@ -98,7 +110,7 @@
</select>
<select id="selectEmisTmsSiteBatchDtlById" parameterType="Long" resultMap="EmisTmsSiteBatchDtlResult">
select id, bill_code, batch_no, scan_date, scan_status, group_status, scan_man, scan_site, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, bill_code, batch_no, scan_date, scan_status, group_status, scan_man, scan_site, batch_volume, batch_parcel_qty, batch_weight, bl_batch, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_site_batch_dtl a
where a.id = #{id}
</select>
@ -113,6 +125,10 @@
<if test="groupStatus != null and groupStatus != ''">group_status,</if>
<if test="scanMan != null and scanMan != ''">scan_man,</if>
<if test="scanSite != null and scanSite != ''">scan_site,</if>
<if test="batchVolume != null">batch_volume,</if>
<if test="batchParcelQty != null">batch_parcel_qty,</if>
<if test="batchWeight != null">batch_weight,</if>
<if test="blBatch != null and blBatch != ''">bl_batch,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
@ -131,6 +147,10 @@
<if test="groupStatus != null and groupStatus != ''">#{groupStatus},</if>
<if test="scanMan != null and scanMan != ''">#{scanMan},</if>
<if test="scanSite != null and scanSite != ''">#{scanSite},</if>
<if test="batchVolume != null">#{batchVolume},</if>
<if test="batchParcelQty != null">#{batchParcelQty},</if>
<if test="batchWeight != null">#{batchWeight},</if>
<if test="blBatch != null and blBatch != ''">#{blBatch},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
@ -153,6 +173,10 @@
<if test="groupStatus != null and groupStatus != ''">group_status = #{groupStatus},</if>
<if test="scanMan != null and scanMan != ''">scan_man = #{scanMan},</if>
<if test="scanSite != null and scanSite != ''">scan_site = #{scanSite},</if>
<if test="batchVolume != null">batch_volume = #{batchVolume},</if>
<if test="batchParcelQty != null">batch_parcel_qty = #{batchParcelQty},</if>
<if test="batchWeight != null">batch_weight = #{batchWeight},</if>
<if test="blBatch != null and blBatch != ''">bl_batch = #{blBatch},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
@ -179,7 +203,7 @@
<!-- 根据批次号查询批次明细 -->
<select id="selectEmisTmsSiteBatchDtlByBatchNo" parameterType="String" resultMap="EmisTmsSiteBatchDtlResult">
select id, bill_code, batch_no, scan_date, scan_status, group_status, scan_man, scan_site, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, bill_code, batch_no, scan_date, scan_status, group_status, scan_man, scan_site, batch_volume, batch_parcel_qty, batch_weight, bl_batch, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_site_batch_dtl
where batch_no = #{batchNo}
and del_flag = '0'

View File

@ -536,4 +536,33 @@
and b.del_flag = '0'
and d.del_flag = '0'
</select>
<!-- 根据起始网点、下一网点和运单号查询TMS组批次 -->
<select id="selectTmsSiteBatchBySiteAndBillCode" resultMap="EmisTmsSiteBatchResult">
select distinct b.id, b.batch_no, b.batch_name, b.batch_date, b.supplier_code, b.trans_line_type,
b.product_type, b.batch_type, b.trans_type, b.start_site_code, b.send_country,
b.next_site_code, b.air_billl_no, b.etd, b.eta, b.car_no, b.ship_no,
b.clearance_res_status, b.declare_res_status, b.dest_country, b.dest_country_name,
b.trans_weight, b.pack_num, b.total_waybill_qty, b.total_settlement_weight,
b.op_man, b.remark, b.tenant_id, b.del_flag, b.create_by, b.create_time,
b.update_by, b.update_time, b.create_site, b.update_site, b.bl_entering,
COALESCE(SUM(d.batch_volume), 0) as total_volume,
COALESCE(SUM(d.batch_parcel_qty), 0) as total_parcel_qty,
COALESCE(SUM(d.batch_weight), 0) as total_weight
from emis_tms_site_batch b
inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no
where b.start_site_code = #{startSiteCode}
and b.next_site_code = #{nextSiteCode}
and d.bill_code = #{billCode}
and b.del_flag = '0'
and d.del_flag = '0'
<if test="id != null">AND d.id != #{id}</if>
group by b.id, b.batch_no, b.batch_name, b.batch_date, b.supplier_code, b.trans_line_type,
b.product_type, b.batch_type, b.trans_type, b.start_site_code, b.send_country,
b.next_site_code, b.air_billl_no, b.etd, b.eta, b.car_no, b.ship_no,
b.clearance_res_status, b.declare_res_status, b.dest_country, b.dest_country_name,
b.trans_weight, b.pack_num, b.total_waybill_qty, b.total_settlement_weight,
b.op_man, b.remark, b.tenant_id, b.del_flag, b.create_by, b.create_time,
b.update_by, b.update_time, b.create_site, b.update_site, b.bl_entering
</select>
</mapper>