1.盘点单据码详情,添加扫码数量字段

2.重写盘点单据转扫码单逻辑
feature-order-fix
x_z 2 years ago
parent 29a33df20e
commit 2cd2d87ed1

@ -35,4 +35,9 @@ public class InvCountCodes {
*/
private String batchNo;
/**
*
*/
private Integer count;
}

@ -58,16 +58,20 @@ public class InvCountCodesServiceImpl implements InvCountCodesService {
UdiEntity udi = FilterUdiUtils.getUdi(list.get(0).getCode());
InvCountOrderDetail invCountOrderDetail = invCountOrderDetailDao.selectOrderDetail(list.get(0).getOrderIdFk(), udi.getUdi(), udi.getBatchNo(), udi.getProduceDate(), udi.getExpireDate());
if (invCountOrderDetail.getCountNum() == 1) {
//条码数量为1删除此产品的盘点单据详情
invCountOrderDetailDao.deleteByPrimaryKey(invCountOrderDetail.getId());
InvCountCodes countCodes = list.get(0);
if (countCodes.getCount() == 1) {
//条码数量等于1删除条码
invCountCodesDao.deleteByPrimaryKey(list.get(0).getId());
} else {
//条码数量大于1将此单据详情的盘点数量 - 1
invCountOrderDetail.setCountNum(invCountOrderDetail.getCountNum() - getActCount(udi.getUdi()));
invCountOrderDetailDao.updateByPrimaryKey(invCountOrderDetail);
//条码数量大于1条码数量 -1
countCodes.setCount(countCodes.getCount() - 1);
invCountCodesDao.updateByPrimaryKey(countCodes);
}
//删除此条码
invCountCodesDao.deleteByPrimaryKey(list.get(0).getId());
//将此单据详情的盘点数量 - 1
invCountOrderDetail.setCountNum(invCountOrderDetail.getCountNum() - getActCount(udi.getUdi()));
invCountOrderDetailDao.updateByPrimaryKey(invCountOrderDetail);
return ResultVOUtils.success();
}
@ -76,24 +80,32 @@ public class InvCountCodesServiceImpl implements InvCountCodesService {
//解析条码
UdiEntity udi = FilterUdiUtils.getUdi(invCountCodes.getCode());
//查询此条码是否重复
//查询单据详情,是否包含此产品
InvCountOrderDetail invCountOrderDetail = invCountOrderDetailDao.selectOrderDetail(invCountCodes.getOrderIdFk(), udi.getUdi(), udi.getBatchNo(), udi.getProduceDate(), udi.getExpireDate());
if (null == invCountOrderDetail) {
return ResultVOUtils.error(ResultEnum.DATA_NOT, "当前仓库或货位不存在此产品");
}
//判断此产品是否有批次号如果没有批次号则直接在单据详情的盘点数量上加1
if (StrUtil.isNotBlank(udi.getBatchNo()) && StrUtil.isNotBlank(udi.getSerialNo())) {
Long count = invCountCodesDao.selectCountByCodeAndOrderId(invCountCodes.getCode(), invCountCodes.getOrderIdFk());
if (count > 0) {
//判断条码是否重复
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
codesRequest.setOrderIdFk(invCountCodes.getOrderIdFk());
codesRequest.setCode(invCountCodes.getCode());
List<InvCountCodes> codesList = invCountCodesDao.filterList(codesRequest);
if (CollUtil.isEmpty(codesList)) {
//新增条码
invCountCodes.setProductId(invCountOrderDetail.getProductId());
invCountCodes.setBatchNo(udi.getBatchNo());
invCountCodes.setCount(1);
invCountCodesDao.insert(invCountCodes);
} else {
if (StrUtil.isNotBlank(udi.getBatchNo()) && StrUtil.isNotBlank(udi.getSerialNo())) {
//条码为标准条码,批次号和序列号都存在,条码重复
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "条码重复!");
} else {
//新增条码
invCountCodes.setProductId(invCountOrderDetail.getProductId());
invCountCodes.setBatchNo(udi.getBatchNo());
invCountCodesDao.insert(invCountCodes);
//批次号或序列号,其中一个字段为空,直接修改数量
InvCountCodes countCodes = codesList.get(0);
countCodes.setCount(countCodes.getCount() + 1);
invCountCodesDao.updateByPrimaryKey(countCodes);
}
}

@ -167,23 +167,6 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
//平衡
invCountOrderDetail.setStatus(2);
}
//查询此产品的条码列表,判断此产品在库存中是多还是少
List<InvCountCodes> codesList = invCountCodesDao.selectByOrderIdAndProductId(invCountOrderDetail.getOrderIdFk(), invCountOrderDetail.getProductId());
//判断盘点的码中是否有次产品的码
if (CollUtil.isNotEmpty(codesList)) {
//查询库存中此产品的码数据,用来判断盘单据条码是多码还是少码
List<String> invDetailCodes = invProductDetailDao.selectCodeByInvCodeAndProductId(invCountOrder.getInvStorageCode(), invCountOrder.getInvWarehouseCode(), invCountOrder.getInvSpaceCode(), invCountOrderDetail.getProductId());
for (InvCountCodes invCountCodes : codesList) {
//查询此条码在库存中是否存在
boolean contains = invDetailCodes.contains(invCountCodes.getCode());
if (!contains) {
invCountCodes.setStatus(1);
}
}
//批量更新条码信息
invCountCodesDao.updateBatch(codesList);
}
}
//更新单据信息
invCountOrderDao.updateByPrimaryKey(invCountOrder);
@ -203,8 +186,6 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
//审核不通过
//查询盘点单据详情,清空盘盈/盘亏数值
invCountOrderDetailDao.resetCountFiledValue(invCountOrder.getOrderId());
//清空条码的状态
invCountCodesDao.resetCountFiledValue(invCountOrder.getOrderId());
} else {
//审核通过
//根据单据详情生成相关单据
@ -236,8 +217,6 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
/**
*
*
* @param invCountOrder
*/
private void countOrderTransfer(InvCountOrder invCountOrder) {
List<InvCountSettingEntity> list = invCountSettingDao.filterList(null);
@ -250,28 +229,43 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
List<WarehouseEntity> inOrderCodes = new ArrayList<>();
List<WarehouseEntity> outOrderCodes = new ArrayList<>();
/**
*
* 1
* 2 / =
* 3
*
* 1
* 2 / =
* 3
*/
//构造库存详情查询参数
FilterInvProductDetailRequest invProductDetailRequest = new FilterInvProductDetailRequest();
invProductDetailRequest.setInvStorageCode(invCountOrder.getInvStorageCode());
invProductDetailRequest.setInvWarehouseCode(invCountOrder.getInvWarehouseCode());
//库存早于或等于盘点时间的库存数据,锁库存
invProductDetailRequest.setUpdateTime(invCountOrder.getCreateTime());
if (invCountOrder.getCountType() == 1) {
//按照货位盘点,查询库存详情添加货位条件
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvSpaceCode());
}
FilterInvCountOrderDetailRequest detailRequest = new FilterInvCountOrderDetailRequest();
detailRequest.setOrderIdFk(invCountOrder.getOrderId());
//查询亏损单据详情
detailRequest.setStatus(0);
List<InvCountOrderDetail> detailList = invCountOrderDetailDao.selectDetailList(detailRequest);
if (CollUtil.isNotEmpty(detailList)) {
List<InvCountOrderDetail> lossDetailList = invCountOrderDetailDao.selectDetailList(detailRequest);
if (CollUtil.isNotEmpty(lossDetailList)) {
log.info("开始生成盘亏单据码明细");
log.info("查询盘亏产品码详情");
FilterInvProductDetailRequest invProductDetailRequest = new FilterInvProductDetailRequest();
invProductDetailRequest.setInvStorageCode(invCountOrder.getInvStorageCode());
invProductDetailRequest.setInvWarehouseCode(invCountOrder.getInvWarehouseCode());
if (invCountOrder.getCountType() == 1) {
//按照货位盘点,查询库存详情添加货位条件
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvSpaceCode());
}
for (InvCountOrderDetail invCountOrderDetail : detailList) {
for (InvCountOrderDetail invCountOrderDetail : lossDetailList) {
//查询库存详情
invProductDetailRequest.setProductIdFk(invCountOrderDetail.getProductId());
invProductDetailRequest.setBatchNo(invCountOrderDetail.getBatchNo());
//库存早于或等于盘点时间的库存数据,锁库存
invProductDetailRequest.setUpdateTime(invCountOrder.getCreateTime());
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetail(invProductDetailRequest);
//查询盘点码明细
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
@ -281,33 +275,65 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
List<String> countCodesList = invCountCodesDao.selectCodes(codesRequest);
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
if (!countCodesList.contains(invProductDetailEntity.getOriginCode()) && !verifyCodeExist(outOrderCodes, invProductDetailEntity.getCode())) {
//生成码详情
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, invProductDetailEntity.getCode(), invProductDetailEntity.getProductIdFk());
//判断此条码,是否有批次号和序列号
UdiEntity udi = FilterUdiUtils.getUdi(invProductDetailEntity.getOriginCode());
if (StrUtil.isBlank(udi.getBatchNo()) || StrUtil.isBlank(udi.getSerialNo())) {
//修改码数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
int codeNum = invCountOrderDetail.getLossNum() / actCount;
warehouseEntity.setCount(codeNum);
warehouseEntity.setReCount(codeNum);
}
outOrderCodes.add(warehouseEntity);
}
}
}
log.info("盘亏单据码明细生成完毕");
}
//查询盘盈的条码明细
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
codesRequest.setOrderIdFk(invCountOrder.getOrderId());
//码状态标记为多码的数据
codesRequest.setStatus(1);
List<InvCountCodes> invCountCodesList = invCountCodesDao.filterList(codesRequest);
if (CollUtil.isNotEmpty(invCountCodesList)) {
//生成盘盈单据的条码
//查询盘盈的单据详情
detailRequest.setStatus(1);
List<InvCountOrderDetail> profitDetailList = invCountOrderDetailDao.selectDetailList(detailRequest);
if (CollUtil.isNotEmpty(profitDetailList)) {
log.info("开始生成盘盈单据码明细");
for (InvCountCodes invCountCodes : invCountCodesList) {
if (!verifyCodeExist(inOrderCodes, invCountCodes.getCode())) {
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, invCountCodes.getCode(), invCountCodes.getProductId());
inOrderCodes.add(warehouseEntity);
//查询盘盈产品的库存详情
for (InvCountOrderDetail invCountOrderDetail : profitDetailList) {
//查询库存详情
invProductDetailRequest.setProductIdFk(invCountOrderDetail.getProductId());
invProductDetailRequest.setBatchNo(invCountOrderDetail.getBatchNo());
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetail(invProductDetailRequest);
//查询盘点码明细
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
codesRequest.setOrderIdFk(invCountOrder.getOrderId());
codesRequest.setProductId(invCountOrderDetail.getProductId());
codesRequest.setBatchNo(invCountOrderDetail.getBatchNo());
List<String> countCodesList = invCountCodesDao.selectCodes(codesRequest);
List<String> invProductCodeList = invProductDetailEntities.stream().map(InvProductDetailEntity::getOriginCode).collect(Collectors.toList());
for (String code : countCodesList) {
if (!invProductCodeList.contains(code) && !verifyCodeExist(inOrderCodes, code)) {
//生成码详情
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, code, invCountOrderDetail.getProductId());
//判断此条码,是否有批次号和序列号
UdiEntity udi = FilterUdiUtils.getUdi(code);
if (StrUtil.isBlank(udi.getBatchNo()) || StrUtil.isBlank(udi.getSerialNo())) {
//修改码数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
int codeNum = invCountOrderDetail.getProfitNum() / actCount;
warehouseEntity.setCount(codeNum);
warehouseEntity.setReCount(codeNum);
}
inOrderCodes.add(warehouseEntity);
}
}
}
log.info("盘盈单据码明细生成完毕");
log.info("盘盈单据码详情生成完毕");
}
InvCountSettingEntity invCountSettingEntity = list.get(0);
if (CollUtil.isNotEmpty(inOrderCodes)) {

@ -8,6 +8,7 @@
<result column="code" jdbcType="VARCHAR" property="code"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="batchNo" jdbcType="VARCHAR" property="batchNo"/>
<result column="count" jdbcType="INTEGER" property="count"/>
</resultMap>
<sql id="Base_Column_List">
@ -16,7 +17,8 @@
productId,
code,
`status`,
batchNo
batchNo,
count
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
@ -35,9 +37,9 @@
<insert id="insert" keyColumn="id" keyProperty="id"
parameterType="com.glxp.api.admin.entity.inventory.InvCountCodes" useGeneratedKeys="true">
insert into inv_count_codes (orderIdFk, productId, code,
`status`, batchNo)
`status`, batchNo, count)
values (#{orderIdFk,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{batchNo,jdbcType=VARCHAR})
#{status,jdbcType=INTEGER}, #{batchNo,jdbcType=VARCHAR}, #{count,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id"
@ -59,6 +61,9 @@
<if test="batchNo != null and batchNo != ''">
batchNo,
</if>
<if test="count != null">
count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderIdFk != null">
@ -76,6 +81,9 @@
<if test="batchNo != null and batchNo != ''">
#{batchNo,jdbcType=VARCHAR},
</if>
<if test="count != null">
#{count,jdbcType=INTEGER},
</if>
</trim>
</insert>
@ -97,6 +105,9 @@
<if test="batchNo != null and batchNo != ''">
batchNo = #{batchNo,jdbcType=VARCHAR},
</if>
<if test="count != null">
count = #{count,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
@ -107,7 +118,8 @@
productId = #{productId,jdbcType=VARCHAR},
code = #{code,jdbcType=VARCHAR},
`status` = #{status,jdbcType=INTEGER},
batchNo = #{batchNo,jdbcType=VARCHAR}
batchNo = #{batchNo,jdbcType=VARCHAR},
count = #{count,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
@ -139,6 +151,11 @@
when id = #{item.id,jdbcType=INTEGER} then #{item.batchNo,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="count = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.count,jdbcType=INTEGER}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
@ -148,11 +165,11 @@
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
insert into inv_count_codes
(orderIdFk, productId, code, `status`, batchNo)
(orderIdFk, productId, code, `status`, batchNo, count)
values
<foreach collection="list" item="item" separator=",">
(#{item.orderIdFk,jdbcType=VARCHAR}, #{item.productId,jdbcType=VARCHAR}, #{item.code,jdbcType=VARCHAR},
#{item.status,jdbcType=INTEGER}, #{item.batchNo,jdbcType=VARCHAR})
#{item.status,jdbcType=INTEGER}, #{item.batchNo,jdbcType=VARCHAR}, #{item.count,jdbcType=INTEGER})
</foreach>
</insert>
@ -192,7 +209,7 @@
</select>
<select id="countByOrderId" resultType="java.lang.Long">
select count(*)
select sum(count)
from inv_count_codes
where orderIdFk = #{orderIdFk}
</select>
@ -218,7 +235,8 @@
</select>
<select id="selectCodes" resultType="java.lang.String">
select code from inv_count_codes
select code
from inv_count_codes
<where>
<if test="orderIdFk != null and orderIdFk != ''">
AND orderIdFk = #{orderIdFk}

@ -92,3 +92,6 @@ SET FOREIGN_KEY_CHECKS = 1;
# 盘点码表添加批次号字段
ALTER TABLE `udiwms`.`inv_count_codes`
ADD COLUMN `batchNo` varchar(255) NULL COMMENT '批次号' AFTER `status`;
ALTER TABLE `udiwms`.`inv_count_codes`
ADD COLUMN `count` int NULL COMMENT '扫码数量' AFTER `batchNo`;

Loading…
Cancel
Save