出入库单修改

master
ljw 2025-12-29 17:04:25 +08:00
parent ca407c5f07
commit ad8281da87
9 changed files with 153 additions and 86 deletions

View File

@ -5,8 +5,6 @@ import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/** /**
* *
* @author ljw * @author ljw
@ -16,10 +14,6 @@ import java.time.LocalDateTime;
@ToString @ToString
@Accessors(chain = true) @Accessors(chain = true)
public class AddOutOrderParam { public class AddOutOrderParam {
/**
*
*/
private String sn;
/** /**
* Idsys_user.id * Idsys_user.id
@ -36,11 +30,6 @@ public class AddOutOrderParam {
*/ */
private String location; private String location;
/**
*
*/
private LocalDateTime outTime;
/** /**
* Idwh_sales_order.id * Idwh_sales_order.id
*/ */

View File

@ -7,6 +7,7 @@ import lombok.experimental.Accessors;
/** /**
* *
*
* @author ljw * @author ljw
*/ */
@Getter @Getter
@ -14,20 +15,25 @@ import lombok.experimental.Accessors;
@ToString @ToString
@Accessors(chain = true) @Accessors(chain = true)
public class SearchInOrderParam { public class SearchInOrderParam {
/** /**
* *
*/
private String orderSn;
/**
*
*/ */
private String sn; private String sn;
/** /**
* Idwh_warehouse.id *
*/ */
private Long warehouseId; private String warehouseName;
/** /**
* Id *
*/ */
private Long goodsId; private String goodsName;
private String keywords;
} }

View File

@ -14,20 +14,25 @@ import lombok.experimental.Accessors;
@ToString @ToString
@Accessors(chain = true) @Accessors(chain = true)
public class SearchOutOrderParam { public class SearchOutOrderParam {
/** /**
* *
*/
private String orderSn;
/**
*
*/ */
private String sn; private String sn;
/** /**
* Idwh_warehouse.id *
*/ */
private Long warehouseId; private String warehouseName;
/** /**
* Id *
*/ */
private Long goodsId; private String goodsName;
private String keywords;
} }

View File

@ -11,6 +11,7 @@ import java.time.LocalDateTime;
/** /**
* *
*
* @author ljw * @author ljw
*/ */
@Getter @Getter
@ -35,11 +36,21 @@ public class SearchInOrderResult {
*/ */
private Long responsibleId; private Long responsibleId;
/**
*
*/
private String nickname;
/** /**
* Idwh_warehouse.id * Idwh_warehouse.id
*/ */
private Long warehouseId; private Long warehouseId;
/**
*
*/
private String warehouseName;
/** /**
* *
*/ */

View File

@ -35,11 +35,21 @@ public class SearchOutOrderResult {
*/ */
private Long responsibleId; private Long responsibleId;
/**
*
*/
private String nickname;
/** /**
* Idwh_warehouse.id * Idwh_warehouse.id
*/ */
private Long warehouseId; private Long warehouseId;
/**
*
*/
private String warehouseName;
/** /**
* *
*/ */

View File

@ -8,7 +8,9 @@ import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult; import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.common.sn.support.SnUtil; import com.njzscloud.common.sn.support.SnUtil;
import com.njzscloud.dispose.wh.mapper.InOrderMapper; import com.njzscloud.dispose.wh.mapper.InOrderMapper;
import com.njzscloud.dispose.wh.mapper.InventoryMapper;
import com.njzscloud.dispose.wh.pojo.entity.InOrderEntity; import com.njzscloud.dispose.wh.pojo.entity.InOrderEntity;
import com.njzscloud.dispose.wh.pojo.entity.InventoryEntity;
import com.njzscloud.dispose.wh.pojo.param.AddInOrderParam; import com.njzscloud.dispose.wh.pojo.param.AddInOrderParam;
import com.njzscloud.dispose.wh.pojo.param.SearchInOrderParam; import com.njzscloud.dispose.wh.pojo.param.SearchInOrderParam;
import com.njzscloud.dispose.wh.pojo.result.SearchInOrderResult; import com.njzscloud.dispose.wh.pojo.result.SearchInOrderResult;
@ -30,6 +32,8 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class InOrderService extends ServiceImpl<InOrderMapper, InOrderEntity> { public class InOrderService extends ServiceImpl<InOrderMapper, InOrderEntity> {
private final InventoryMapper inventoryMapper;
/** /**
* *
*/ */
@ -39,6 +43,23 @@ public class InOrderService extends ServiceImpl<InOrderMapper, InOrderEntity> {
entity.setSn(this.generateSn()); entity.setSn(this.generateSn());
entity.setInTime(LocalDateTime.now()); entity.setInTime(LocalDateTime.now());
this.save(entity); this.save(entity);
// 更新库存信息
InventoryEntity inventory = inventoryMapper.selectOne(Wrappers.<InventoryEntity>lambdaQuery()
.eq(InventoryEntity::getGoodsId, entity.getGoodsId())
.eq(InventoryEntity::getWarehouseId, entity.getWarehouseId())
.eq(InventoryEntity::getDeleted, Boolean.FALSE));
if (inventory != null) {
// 更新当前库存数量
inventory.setStockQuantity(inventory.getStockQuantity() + entity.getQuantity());
// 计算剩余量 = 总量 - 当前库存数量
inventory.setRemainingQuantity(inventory.getTotalQuantity() - inventory.getStockQuantity());
inventoryMapper.updateById(inventory);
} else {
log.info("通过仓库id: {}和产品id: {}未查询到库存信息,无法处理库存", entity.getWarehouseId(), entity.getGoodsId());
}
} }
/** /**
@ -66,23 +87,13 @@ public class InOrderService extends ServiceImpl<InOrderMapper, InOrderEntity> {
/** /**
* *
*/ */
public PageResult<SearchInOrderResult> paging(PageParam pageParam, SearchInOrderParam searchInOrderParam) { public PageResult<SearchInOrderResult> paging(PageParam pageParam, SearchInOrderParam param) {
String sn = searchInOrderParam.getSn();
Long warehouseId = searchInOrderParam.getWarehouseId();
Long goodsId = searchInOrderParam.getGoodsId();
String keywords = searchInOrderParam.getKeywords();
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query() return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query()
.eq("a.deleted", 0) .eq("wio.deleted", 0)
.eq(StrUtil.isNotBlank(sn), "a.sn", sn) .eq(StrUtil.isNotBlank(param.getSn()), "wio.sn", param.getSn())
.eq(warehouseId != null, "a.warehouse_id", warehouseId) .eq(StrUtil.isNotBlank(param.getOrderSn()), "wio.order_sn", param.getOrderSn())
.eq(goodsId != null, "a.goods_id", goodsId) .eq(StrUtil.isNotBlank(param.getWarehouseName()), "ww.warehouse_name", param.getWarehouseName())
.and(StrUtil.isNotBlank(keywords), it -> it .eq(StrUtil.isNotBlank(param.getGoodsName()), "wio.goods_name", param.getGoodsName())
.like("a.location", keywords)
.or().like("a.order_sn", keywords)
.or().like("a.goods_name", keywords)
.or().like("a.good_sn", keywords)
.or().like("a.memo", keywords)
)
)); ));
} }

View File

@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam; import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult; import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.common.sn.support.SnUtil;
import com.njzscloud.dispose.wh.mapper.InventoryMapper;
import com.njzscloud.dispose.wh.mapper.OutOrderMapper; import com.njzscloud.dispose.wh.mapper.OutOrderMapper;
import com.njzscloud.dispose.wh.pojo.entity.InventoryEntity;
import com.njzscloud.dispose.wh.pojo.entity.OutOrderEntity; import com.njzscloud.dispose.wh.pojo.entity.OutOrderEntity;
import com.njzscloud.dispose.wh.pojo.param.AddOutOrderParam; import com.njzscloud.dispose.wh.pojo.param.AddOutOrderParam;
import com.njzscloud.dispose.wh.pojo.param.SearchOutOrderParam; import com.njzscloud.dispose.wh.pojo.param.SearchOutOrderParam;
@ -16,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@ -28,13 +32,33 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class OutOrderService extends ServiceImpl<OutOrderMapper, OutOrderEntity> { public class OutOrderService extends ServiceImpl<OutOrderMapper, OutOrderEntity> {
private final InventoryMapper inventoryMapper;
/** /**
* *
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void add(AddOutOrderParam addOutOrderParam) { public void add(AddOutOrderParam addOutOrderParam) {
OutOrderEntity entity = BeanUtil.copyProperties(addOutOrderParam, OutOrderEntity.class); OutOrderEntity entity = BeanUtil.copyProperties(addOutOrderParam, OutOrderEntity.class);
entity.setSn(this.generateSn());
entity.setOutTime(LocalDateTime.now());
this.save(entity); this.save(entity);
// 更新库存信息
InventoryEntity inventory = inventoryMapper.selectOne(Wrappers.<InventoryEntity>lambdaQuery()
.eq(InventoryEntity::getGoodsId, entity.getGoodsId())
.eq(InventoryEntity::getWarehouseId, entity.getWarehouseId())
.eq(InventoryEntity::getDeleted, Boolean.FALSE));
if (inventory != null) {
// 更新当前库存数量
inventory.setStockQuantity(inventory.getStockQuantity() - entity.getQuantity());
// 计算剩余量 = 总量 - 当前库存数量
inventory.setRemainingQuantity(inventory.getTotalQuantity() - inventory.getStockQuantity());
inventoryMapper.updateById(inventory);
} else {
log.info("通过仓库id: {}和产品id: {}未查询到库存信息,无法处理库存", entity.getWarehouseId(), entity.getGoodsId());
}
} }
/** /**
@ -62,24 +86,28 @@ public class OutOrderService extends ServiceImpl<OutOrderMapper, OutOrderEntity>
/** /**
* *
*/ */
public PageResult<SearchOutOrderResult> paging(PageParam pageParam, SearchOutOrderParam searchOutOrderParam) { public PageResult<SearchOutOrderResult> paging(PageParam pageParam, SearchOutOrderParam param) {
String sn = searchOutOrderParam.getSn();
Long warehouseId = searchOutOrderParam.getWarehouseId();
Long goodsId = searchOutOrderParam.getGoodsId();
String keywords = searchOutOrderParam.getKeywords();
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query() return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query()
.eq("a.deleted", 0) .eq("woo.deleted", 0)
.eq(StrUtil.isNotBlank(sn), "a.sn", sn) .eq(StrUtil.isNotBlank(param.getSn()), "woo.sn", param.getSn())
.eq(warehouseId != null, "a.warehouse_id", warehouseId) .eq(StrUtil.isNotBlank(param.getOrderSn()), "woo.order_sn", param.getOrderSn())
.eq(goodsId != null, "a.goods_id", goodsId) .eq(StrUtil.isNotBlank(param.getWarehouseName()), "ww.warehouse_name", param.getWarehouseName())
.and(StrUtil.isNotBlank(keywords), it -> it .eq(StrUtil.isNotBlank(param.getGoodsName()), "woo.goods_name", param.getGoodsName())
.like("a.location", keywords)
.or().like("a.order_sn", keywords)
.or().like("a.goods_name", keywords)
.or().like("a.good_sn", keywords)
.or().like("a.memo", keywords)
)
)); ));
} }
/**
*
*
* @return sn
*/
public String generateSn() {
String sn = SnUtil.next("In-Order-SN");
if (this.exists(Wrappers.<OutOrderEntity>lambdaQuery().eq(OutOrderEntity::getSn, sn)
.eq(OutOrderEntity::getDeleted, Boolean.FALSE))) {
this.generateSn();
}
return sn;
}
} }

View File

@ -5,10 +5,11 @@
<id column="id" property="id"/> <id column="id" property="id"/>
<result column="sn" property="sn"/> <result column="sn" property="sn"/>
<result column="responsible_id" property="responsibleId"/> <result column="responsible_id" property="responsibleId"/>
<result column="nickname" property="nickname"/>
<result column="warehouse_id" property="warehouseId"/> <result column="warehouse_id" property="warehouseId"/>
<result column="warehouse_name" property="warehouseName"/>
<result column="location" property="location"/> <result column="location" property="location"/>
<result column="in_time" property="inTime"/> <result column="in_time" property="inTime"/>
<result column="order_category" property="orderCategory"/>
<result column="order_id" property="orderId"/> <result column="order_id" property="orderId"/>
<result column="order_sn" property="orderSn"/> <result column="order_sn" property="orderSn"/>
<result column="goods_category_id" property="goodsCategoryId"/> <result column="goods_category_id" property="goodsCategoryId"/>
@ -30,7 +31,9 @@
wio.id AS id, wio.id AS id,
wio.sn AS sn, wio.sn AS sn,
wio.responsible_id AS responsible_id, wio.responsible_id AS responsible_id,
su.nickname,
wio.warehouse_id AS warehouse_id, wio.warehouse_id AS warehouse_id,
ww.warehouse_name,
wio.location AS location, wio.location AS location,
wio.in_time AS in_time, wio.in_time AS in_time,
wio.order_id AS order_id, wio.order_id AS order_id,
@ -54,13 +57,17 @@
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM wh_in_order wio FROM wh_in_order wio
LEFT JOIN sys_user su ON su.id = wio.responsible_id
LEFT JOIN wh_warehouse ww ON ww.id = wio.warehouse_id
WHERE wio.id = #{id} WHERE wio.id = #{id}
</select> </select>
<select id="paging" resultMap="BaseResultMap"> <select id="paging" resultMap="BaseResultMap">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM wh_in_order wio a FROM wh_in_order wio
LEFT JOIN sys_user su ON su.id = wio.responsible_id
LEFT JOIN wh_warehouse ww ON ww.id = wio.warehouse_id
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment} ${ew.customSqlSegment}
</if> </if>

View File

@ -1,29 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njzscloud.dispose.wh.mapper.OutOrderMapper"> <mapper namespace="com.njzscloud.dispose.wh.mapper.OutOrderMapper">
<sql id="searchOutOrder"> <sql id="searchOutOrder">
SELECT id, SELECT woo.id,
sn, woo.sn,
responsible_id, woo.responsible_id,
warehouse_id, su.nickname,
location, woo.warehouse_id,
out_time, ww.warehouse_name,
order_id, woo.location,
order_sn, woo.out_time,
goods_category_id, woo.order_id,
goods_category_name, woo.order_sn,
goods_id, woo.goods_category_id,
goods_name, woo.goods_category_name,
good_sn, woo.goods_id,
quantity, woo.goods_name,
unit, woo.good_sn,
memo, woo.quantity,
creator_id, woo.unit,
modifier_id, woo.memo,
create_time, woo.creator_id,
modify_time woo.modifier_id,
FROM wh_out_order woo.create_time,
woo.modify_time
FROM wh_out_order woo
LEFT JOIN sys_user su ON su.id = woo.responsible_id
LEFT JOIN wh_warehouse ww ON ww.id = woo.warehouse_id
</sql> </sql>
<resultMap id="searchOutOrderResultMap" autoMapping="true" type="com.njzscloud.dispose.wh.pojo.result.SearchOutOrderResult"> <resultMap id="searchOutOrderResultMap" autoMapping="true" type="com.njzscloud.dispose.wh.pojo.result.SearchOutOrderResult">
@ -31,16 +34,13 @@
<select id="paging" resultMap="searchOutOrderResultMap"> <select id="paging" resultMap="searchOutOrderResultMap">
<include refid="searchOutOrder"/> <include refid="searchOutOrder"/>
<where> <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> ${ew.customSqlSegment}
${ew.customSqlSegment} </if>
</if>
</where>
</select> </select>
<select id="detail" resultMap="searchOutOrderResultMap"> <select id="detail" resultMap="searchOutOrderResultMap">
<include refid="searchOutOrder"/> <include refid="searchOutOrder"/>
WHERE deleted = 0 WHERE woo.id = #{id}
AND id = #{id}
</select> </select>
</mapper> </mapper>