demand: 合并进仓相关代码

This commit is contained in:
aike 2026-03-19 09:09:33 +08:00
parent ab8b095703
commit d2a9458b30
8 changed files with 238 additions and 52 deletions

View File

@ -1371,7 +1371,7 @@ public class EmisCommonController extends EmisBaseController
@RequestMapping("/reCalcWareHouseInTotalInfo")
public void reCalcWareHouseInTotalInfo(String settleBillNo) {
try{
emisWarehouseInBatchService.reCalcWareHouseInTotalInfo(settleBillNo);
emisWarehouseInBatchService.reCalcWareHouseInTotalInfo(settleBillNo,null);
}
catch (Exception ex){
ex.printStackTrace();

View File

@ -11,6 +11,7 @@
package com.xdadan.erp.web.emis;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@ -27,14 +28,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xdadan.erp.common.annotation.Log;
import com.xdadan.erp.common.core.controller.BaseController;
import com.xdadan.erp.common.core.domain.AjaxResult;
import com.xdadan.erp.common.core.page.TableDataInfo;
import com.xdadan.erp.common.enums.BusinessType;
import com.xdadan.erp.common.utils.StringUtils;
import com.xdadan.erp.common.utils.poi.ExcelUtil;
import com.xdadan.erp.emis.domain.EmisWarehouseIn;
import com.xdadan.erp.emis.domain.EmisWarehouseInBatch;
import com.xdadan.erp.emis.service.IEmisWarehouseInService;
import com.xdadan.erp.emis.service.IEmisWarehouseInBatchService;
/**
@ -50,6 +52,9 @@ public class EmisWarehouseInBatchController extends EmisBaseController
@Autowired
private IEmisWarehouseInBatchService emisWarehouseInBatchService;
@Autowired
private IEmisWarehouseInService emisWarehouseInService;
/**
* 查询进仓单批次列表
*/
@ -113,6 +118,88 @@ public class EmisWarehouseInBatchController extends EmisBaseController
}
}
/**
* 合并进仓登记
*/
@PreAuthorize("@ss.hasPermi('emis:emisWarehouseInBatch:mergeRegisterWarehouseInInfo')")
@Log(title = "合并进仓登记", businessType = BusinessType.INSERT)
@RequestMapping("/mergeRegisterWarehouseInInfo")
public AjaxResult mergeRegisterWarehouseInInfo(@RequestBody List<EmisWarehouseInBatch> batchList)
{
if (batchList == null || batchList.isEmpty()) {
return AjaxResult.error("进仓批次列表不能为空");
}
int successCount = 0;
try {
// 1) 基于 inNo 查询进仓单状态
// - stockInFlag=1:已入仓,不可合并
// - stockInFlag=2:必须保证 warehouseInBatchNo 全部一致,否则不可合并
String expectedWarehouseInBatchNo = null;
for (EmisWarehouseInBatch item : batchList) {
if (item == null || StringUtils.isEmpty(item.getInNo())) {
throw new EmisBizError("进仓单号不能为空");
}
EmisWarehouseIn warehouseIn = emisWarehouseInService.selectEmisWarehouseInByInNo(item.getInNo());
if (warehouseIn == null) {
throw new EmisBizError("进仓单不存在");
}
if ("1".equals(warehouseIn.getStockInFlag())) {
return AjaxResult.error(warehouseIn.getBillCode() + "已入仓,不可合并入仓");
}
if ("2".equals(warehouseIn.getStockInFlag())) {
String curBatchNo = warehouseIn.getWarehouseInBatchNo();
if (StringUtils.isEmpty(expectedWarehouseInBatchNo)) {
expectedWarehouseInBatchNo = curBatchNo;
} else if (!StringUtils.equals(expectedWarehouseInBatchNo, curBatchNo)) {
return AjaxResult.error("不同批次的进仓单,无法合并进仓");
}
}
}
// 2) 合并进仓的 warehouseInBatchNo 保持一致
// - 若存在部分入仓(stockInFlag=2),沿用其 warehouseInBatchNo
// - 否则优先取第一条的 inBatchNo(前端传入),为空则生成一个新的
String mergeInBatchNo = expectedWarehouseInBatchNo;
if (StringUtils.isEmpty(mergeInBatchNo)) {
mergeInBatchNo = batchList.get(0).getInBatchNo();
}
if (StringUtils.isEmpty(mergeInBatchNo)) {
mergeInBatchNo = "JC" + System.currentTimeMillis();
}
for (EmisWarehouseInBatch item : batchList) {
item.getParams().put("warehouseInBatchNo",mergeInBatchNo);
successCount += emisWarehouseInBatchService.insertEmisWarehouseInBatch(item);
}
return toAjax(successCount);
} catch (EmisBizError emisBizError) {
emisBizError.printStackTrace();
return AjaxResult.error(emisBizError.getMessage());
}
}
/**
* 确认进仓完成(仅允许部分入仓 stockInFlag=2 的运单)
* 前端传一个或多个 EmisWarehouseIn.id
*/
@PreAuthorize("@ss.hasPermi('emis:emisWarehouseInBatch:confirmStockInComplete')")
@Log(title = "确认进仓完成", businessType = BusinessType.UPDATE)
@GetMapping("/confirmStockInComplete/{ids}")
public AjaxResult confirmStockInComplete(@PathVariable Long[] ids)
{
try {
int rows = emisWarehouseInService.confirmStockInCompleteByIds(Arrays.asList(ids));
return toAjax(rows);
} catch (EmisBizError emisBizError) {
emisBizError.printStackTrace();
return AjaxResult.error(emisBizError.getMessage());
}
}
/**
* 修改进仓单批次

View File

@ -14,17 +14,13 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xdadan.erp.common.annotation.Excel;
import com.xdadan.erp.common.core.domain.BaseEntity;
import com.xdadan.erp.common.core.domain.TreeEntity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
@ -33,7 +29,8 @@ import lombok.Data;
* @author linfso
* @date 2024-05-22 00:20:31
*/
@Data
@Data
@EqualsAndHashCode(callSuper = true)
public class EmisWarehouseIn extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -45,6 +42,8 @@ public class EmisWarehouseIn extends BaseEntity
private String serialNo;
/* 进仓单号 */
private String inNo;
/* 进仓批次号 */
private String warehouseInBatchNo;
/* 订单号 */
private String orderSn;
/* 运单号 */
@ -78,6 +77,7 @@ public class EmisWarehouseIn extends BaseEntity
// --------- 扩展参数
@TableField(exist = false)
private EmisWaybill waybillDetail;
// 是否已锁单 T,锁单原因
@ -87,5 +87,6 @@ public class EmisWarehouseIn extends BaseEntity
private String lockReason;
// 入仓批次信息
@TableField(exist = false)
private List<EmisWarehouseInBatch> stockInBatchList;
}

View File

@ -63,7 +63,7 @@ public interface IEmisWarehouseInBatchService
* 重新计算总重量和总体积
* @param inNo
*/
public void reCalcWareHouseInTotalInfo(String inNo);
public void reCalcWareHouseInTotalInfo(String inNo,String warehouseInBatchNo) throws EmisBizError;
/**
* 批量删除进仓单批次

View File

@ -77,4 +77,12 @@ public interface IEmisWarehouseInService
* 根据进仓单号列表查询导出数据
*/
List<WarehouseInExport> selectWarehouseInExportData(List<String> inNos) throws EmisBizError;
/**
* 手动确认进仓完成(仅允许部分入仓 stockInFlag=2 的运单)
*
* @param ids EmisWarehouseIn 主键集合
* @return 更新成功条数
*/
int confirmStockInCompleteByIds(List<Long> ids) throws EmisBizError;
}

View File

@ -11,11 +11,9 @@
package com.xdadan.erp.emis.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cn.hutool.core.collection.CollectionUtil;
import com.xdadan.erp.common.utils.StringUtils;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
@ -160,14 +158,20 @@ public class EmisWarehouseInBatchServiceImpl extends EmisBaseService implements
}
// 重新计算入仓状态
this.reCalcWareHouseInTotalInfo(emisWarehouseInBatch.getInNo());
this.reCalcWareHouseInTotalInfo(emisWarehouseInBatch.getInNo(), (String) emisWarehouseInBatch.getParams().get("warehouseInBatchNo"));
return 1;
}
// 重新计算总重量,总件数,总体积
@Override
public void reCalcWareHouseInTotalInfo(String inNo){
public void reCalcWareHouseInTotalInfo(String inNo, String warehouseInBatchNo) throws EmisBizError {
// 查询进仓单(包含 waybillDetail),用于生成 inBatchNo & 设置 stock_in_flag
EmisWarehouseIn warehouseInDetail = emisWarehouseInMapper.selectEmisWarehouseInByInNo(inNo);
if (warehouseInDetail == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "进仓单不存在");
}
// 获取入库列表
List<EmisWarehouseInBatch> batchList=emisWarehouseInBatchMapper.selectInBatchListByInNo(inNo);
@ -208,6 +212,44 @@ public class EmisWarehouseInBatchServiceImpl extends EmisBaseService implements
emisWarehouseIn.setTotalParcelQty(totalAllParcelQty);
emisWarehouseIn.setInNo(inNo);
emisWarehouseIn.setBlUploadPic(blUploadPic);
// 1) warehouseInBatchNo 不存在则按 JC + 时间戳生成
if (StringUtils.isEmpty(warehouseInDetail.getWarehouseInBatchNo())) {
emisWarehouseIn.setWarehouseInBatchNo("JC" + System.currentTimeMillis());
if (StringUtils.isNotBlank(warehouseInBatchNo)) {
emisWarehouseIn.setWarehouseInBatchNo(warehouseInBatchNo);
}
}
// 2) stock_in_flag:总量与运单信息对比
// - 如果累计入仓超过运单(件数/重量/体积重量)则报错
// - 如果三项都相等 => '1',否则 => '2'
String stockInFlag = "2";
EmisWaybill waybillDetail = warehouseInDetail.getWaybillDetail();
if (waybillDetail != null) {
Integer planParcelQty = waybillDetail.getParcelQty();
BigDecimal planBillWeight = waybillDetail.getBillWeight();
BigDecimal planVolume = waybillDetail.getTotalVolume();
// if (planParcelQty != null && totalAllParcelQty != null && totalAllParcelQty > planParcelQty) {
// throw new EmisBizError(EmisBizErrorType.FAIL, "入仓总件数超过运单件数");
// }
// if (planBillWeight != null && totalAllWeight != null && totalAllWeight.compareTo(planBillWeight) > 0) {
// throw new EmisBizError(EmisBizErrorType.FAIL, "入仓总重量超过运单重量");
// }
// if (planVolumeWeight != null && totalAllVolume != null && totalAllVolume.compareTo(planVolumeWeight) > 0) {
// throw new EmisBizError(EmisBizErrorType.FAIL, "入仓总体积超过运单体积重量");
// }
boolean eqParcel = planParcelQty != null && totalAllParcelQty != null && totalAllParcelQty >= planParcelQty;
// boolean eqWeight = planBillWeight != null && totalAllWeight != null && totalAllWeight.compareTo(planBillWeight) >= 0;
// boolean eqVolume = planVolume != null && totalAllVolume != null && totalAllVolume.compareTo(planVolume) >= 0;
if (eqParcel) {
stockInFlag = "1";
}
}
emisWarehouseIn.setStockInFlag(stockInFlag);
// 更新入库状态
emisWarehouseInMapper.updateTotalWeightInfo(emisWarehouseIn);
}

View File

@ -13,6 +13,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.io.InputStream;
import java.net.HttpURLConnection;
@ -35,6 +36,7 @@
import com.xdadan.erp.emis.mapper.EmisWarehouseInMapper;
import com.xdadan.erp.emis.service.IEmisWarehouseInService;
import org.springframework.util.CollectionUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 进仓单Service业务层处理
@ -357,5 +359,44 @@ public class EmisWarehouseInServiceImpl implements IEmisWarehouseInService
return exportList;
}
/**
* 手动确认进仓完成(仅允许部分入仓 stockInFlag=2 的运单)
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int confirmStockInCompleteByIds(List<Long> ids) throws EmisBizError {
List<Long> distinctIds = ids.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(distinctIds)) {
throw new EmisBizError(EmisBizErrorType.FAIL, "id不能为空");
}
List<EmisWarehouseIn> warehouseInList = emisWarehouseInMapper.selectBatchIds(distinctIds);
if (CollectionUtils.isEmpty(warehouseInList) || warehouseInList.size() != distinctIds.size()) {
throw new EmisBizError(EmisBizErrorType.FAIL, "进仓单不存在");
}
for (EmisWarehouseIn warehouseIn : warehouseInList) {
if (warehouseIn == null) {
continue;
}
if (!"2".equals(warehouseIn.getStockInFlag())) {
throw new EmisBizError(
EmisBizErrorType.FAIL,
"只有部分入仓的运单可手动确认,运单号" + warehouseIn.getBillCode() + "进仓状态不符合要求"
);
}
}
int successCount = 0;
for (Long id : distinctIds) {
EmisWarehouseIn update = new EmisWarehouseIn();
update.setId(id);
update.setStockInFlag("1");
successCount += emisWarehouseInMapper.updateById(update);
}
return successCount;
}
}

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" />
<result property="serialNo" column="serial_no" />
<result property="inNo" column="in_no" />
<result property="warehouseInBatchNo" column="warehouse_in_batch_no" />
<result property="orderSn" column="order_sn" />
<result property="billCode" column="bill_code" />
<result property="customerCode" column="customer_code" />
@ -75,11 +76,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectEmisWarehouseInVo">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_warehouse_in
select id, serial_no, in_no, warehouse_in_batch_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_warehouse_in
</sql>
<select id="selectEmisWarehouseInListByOms" parameterType="EmisWarehouseIn" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, serial_no, in_no, warehouse_in_batch_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
<where>
del_flag='0'
@ -156,7 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectEmisWarehouseInList" parameterType="EmisWarehouseIn" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, serial_no, in_no, warehouse_in_batch_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
<where>
del_flag='0'
@ -297,13 +298,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectEmisWarehouseInById" parameterType="Long" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, serial_no, in_no, warehouse_in_batch_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
where a.id = #{id}
</select>
<select id="selectEmisWarehouseInByInNo" parameterType="String" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, serial_no, in_no, warehouse_in_batch_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
where a.in_no = #{inNo} limit 1
</select>
@ -348,6 +349,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="serialNo != null and serialNo != ''">serial_no,</if>
<if test="inNo != null and inNo != ''">in_no,</if>
<if test="warehouseInBatchNo != null and warehouseInBatchNo != ''">warehouse_in_batch_no,</if>
<if test="orderSn != null and orderSn != ''">order_sn,</if>
<if test="billCode != null and billCode != ''">bill_code,</if>
<if test="customerCode != null and customerCode != ''">customer_code,</if>
@ -375,6 +377,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="serialNo != null and serialNo != ''">#{serialNo},</if>
<if test="inNo != null and inNo != ''">#{inNo},</if>
<if test="warehouseInBatchNo != null and warehouseInBatchNo != ''">#{warehouseInBatchNo},</if>
<if test="orderSn != null and orderSn != ''">#{orderSn},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
@ -406,6 +409,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="serialNo != null and serialNo != ''">serial_no = #{serialNo},</if>
<if test="inNo != null and inNo != ''">in_no = #{inNo},</if>
<if test="warehouseInBatchNo != null and warehouseInBatchNo != ''">warehouse_in_batch_no = #{warehouseInBatchNo},</if>
<if test="orderSn != null and orderSn != ''">order_sn = #{orderSn},</if>
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="customerCode != null and customerCode != ''">customer_code = #{customerCode},</if>
@ -459,7 +463,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateTotalWeightInfo" parameterType="EmisWarehouseIn">
update emis_warehouse_in
set stock_in_flag = '1',
set stock_in_flag = #{stockInFlag},
<if test="warehouseInBatchNo != null and warehouseInBatchNo != ''">
warehouse_in_batch_no=#{warehouseInBatchNo},
</if>
total_parcel_qty=#{totalParcelQty},
total_volume=#{totalVolume},
total_weight=#{totalWeight},