出入库单修改
parent
ca407c5f07
commit
ad8281da87
|
|
@ -5,8 +5,6 @@ import lombok.Setter;
|
|||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 出库单
|
||||
* @author ljw
|
||||
|
|
@ -16,10 +14,6 @@ import java.time.LocalDateTime;
|
|||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class AddOutOrderParam {
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 责任人 Id;sys_user.id
|
||||
|
|
@ -36,11 +30,6 @@ public class AddOutOrderParam {
|
|||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 出库时间
|
||||
*/
|
||||
private LocalDateTime outTime;
|
||||
|
||||
/**
|
||||
* 销售单 Id;wh_sales_order.id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import lombok.experimental.Accessors;
|
|||
|
||||
/**
|
||||
* 入库单
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Getter
|
||||
|
|
@ -14,20 +15,25 @@ import lombok.experimental.Accessors;
|
|||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class SearchInOrderParam {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
* 采购单号
|
||||
*/
|
||||
private String orderSn;
|
||||
|
||||
/**
|
||||
* 入库编号
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 仓库 Id;wh_warehouse.id
|
||||
* 仓库名称
|
||||
*/
|
||||
private Long warehouseId;
|
||||
private String warehouseName;
|
||||
|
||||
/**
|
||||
* 产品 Id
|
||||
* 产品名称
|
||||
*/
|
||||
private Long goodsId;
|
||||
private String goodsName;
|
||||
|
||||
private String keywords;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,20 +14,25 @@ import lombok.experimental.Accessors;
|
|||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class SearchOutOrderParam {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
* 出库单号
|
||||
*/
|
||||
private String orderSn;
|
||||
|
||||
/**
|
||||
* 出库编号
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 仓库 Id;wh_warehouse.id
|
||||
* 仓库名称
|
||||
*/
|
||||
private Long warehouseId;
|
||||
private String warehouseName;
|
||||
|
||||
/**
|
||||
* 产品 Id
|
||||
* 产品名称
|
||||
*/
|
||||
private Long goodsId;
|
||||
private String goodsName;
|
||||
|
||||
private String keywords;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import java.time.LocalDateTime;
|
|||
|
||||
/**
|
||||
* 入库单
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Getter
|
||||
|
|
@ -35,11 +36,21 @@ public class SearchInOrderResult {
|
|||
*/
|
||||
private Long responsibleId;
|
||||
|
||||
/**
|
||||
* 责任人名称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 仓库 Id;wh_warehouse.id
|
||||
*/
|
||||
private Long warehouseId;
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
private String warehouseName;
|
||||
|
||||
/**
|
||||
* 存放位置
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,11 +35,21 @@ public class SearchOutOrderResult {
|
|||
*/
|
||||
private Long responsibleId;
|
||||
|
||||
/**
|
||||
* 责任人名称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 仓库 Id;wh_warehouse.id
|
||||
*/
|
||||
private Long warehouseId;
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
private String warehouseName;
|
||||
|
||||
/**
|
||||
* 存放位置
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import com.njzscloud.common.mp.support.PageParam;
|
|||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.common.sn.support.SnUtil;
|
||||
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.InventoryEntity;
|
||||
import com.njzscloud.dispose.wh.pojo.param.AddInOrderParam;
|
||||
import com.njzscloud.dispose.wh.pojo.param.SearchInOrderParam;
|
||||
import com.njzscloud.dispose.wh.pojo.result.SearchInOrderResult;
|
||||
|
|
@ -30,6 +32,8 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
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.setInTime(LocalDateTime.now());
|
||||
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) {
|
||||
String sn = searchInOrderParam.getSn();
|
||||
Long warehouseId = searchInOrderParam.getWarehouseId();
|
||||
Long goodsId = searchInOrderParam.getGoodsId();
|
||||
String keywords = searchInOrderParam.getKeywords();
|
||||
public PageResult<SearchInOrderResult> paging(PageParam pageParam, SearchInOrderParam param) {
|
||||
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query()
|
||||
.eq("a.deleted", 0)
|
||||
.eq(StrUtil.isNotBlank(sn), "a.sn", sn)
|
||||
.eq(warehouseId != null, "a.warehouse_id", warehouseId)
|
||||
.eq(goodsId != null, "a.goods_id", goodsId)
|
||||
.and(StrUtil.isNotBlank(keywords), it -> it
|
||||
.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)
|
||||
)
|
||||
.eq("wio.deleted", 0)
|
||||
.eq(StrUtil.isNotBlank(param.getSn()), "wio.sn", param.getSn())
|
||||
.eq(StrUtil.isNotBlank(param.getOrderSn()), "wio.order_sn", param.getOrderSn())
|
||||
.eq(StrUtil.isNotBlank(param.getWarehouseName()), "ww.warehouse_name", param.getWarehouseName())
|
||||
.eq(StrUtil.isNotBlank(param.getGoodsName()), "wio.goods_name", param.getGoodsName())
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
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.pojo.entity.InventoryEntity;
|
||||
import com.njzscloud.dispose.wh.pojo.entity.OutOrderEntity;
|
||||
import com.njzscloud.dispose.wh.pojo.param.AddOutOrderParam;
|
||||
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.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -28,13 +32,33 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
public class OutOrderService extends ServiceImpl<OutOrderMapper, OutOrderEntity> {
|
||||
|
||||
private final InventoryMapper inventoryMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(AddOutOrderParam addOutOrderParam) {
|
||||
OutOrderEntity entity = BeanUtil.copyProperties(addOutOrderParam, OutOrderEntity.class);
|
||||
entity.setSn(this.generateSn());
|
||||
entity.setOutTime(LocalDateTime.now());
|
||||
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) {
|
||||
String sn = searchOutOrderParam.getSn();
|
||||
Long warehouseId = searchOutOrderParam.getWarehouseId();
|
||||
Long goodsId = searchOutOrderParam.getGoodsId();
|
||||
String keywords = searchOutOrderParam.getKeywords();
|
||||
public PageResult<SearchOutOrderResult> paging(PageParam pageParam, SearchOutOrderParam param) {
|
||||
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query()
|
||||
.eq("a.deleted", 0)
|
||||
.eq(StrUtil.isNotBlank(sn), "a.sn", sn)
|
||||
.eq(warehouseId != null, "a.warehouse_id", warehouseId)
|
||||
.eq(goodsId != null, "a.goods_id", goodsId)
|
||||
.and(StrUtil.isNotBlank(keywords), it -> it
|
||||
.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)
|
||||
)
|
||||
.eq("woo.deleted", 0)
|
||||
.eq(StrUtil.isNotBlank(param.getSn()), "woo.sn", param.getSn())
|
||||
.eq(StrUtil.isNotBlank(param.getOrderSn()), "woo.order_sn", param.getOrderSn())
|
||||
.eq(StrUtil.isNotBlank(param.getWarehouseName()), "ww.warehouse_name", param.getWarehouseName())
|
||||
.eq(StrUtil.isNotBlank(param.getGoodsName()), "woo.goods_name", param.getGoodsName())
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成入库单号
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
<id column="id" property="id"/>
|
||||
<result column="sn" property="sn"/>
|
||||
<result column="responsible_id" property="responsibleId"/>
|
||||
<result column="nickname" property="nickname"/>
|
||||
<result column="warehouse_id" property="warehouseId"/>
|
||||
<result column="warehouse_name" property="warehouseName"/>
|
||||
<result column="location" property="location"/>
|
||||
<result column="in_time" property="inTime"/>
|
||||
<result column="order_category" property="orderCategory"/>
|
||||
<result column="order_id" property="orderId"/>
|
||||
<result column="order_sn" property="orderSn"/>
|
||||
<result column="goods_category_id" property="goodsCategoryId"/>
|
||||
|
|
@ -30,7 +31,9 @@
|
|||
wio.id AS id,
|
||||
wio.sn AS sn,
|
||||
wio.responsible_id AS responsible_id,
|
||||
su.nickname,
|
||||
wio.warehouse_id AS warehouse_id,
|
||||
ww.warehouse_name,
|
||||
wio.location AS location,
|
||||
wio.in_time AS in_time,
|
||||
wio.order_id AS order_id,
|
||||
|
|
@ -54,13 +57,17 @@
|
|||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
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}
|
||||
</select>
|
||||
|
||||
<select id="paging" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<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 != ''">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -1,29 +1,32 @@
|
|||
<?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">
|
||||
<mapper namespace="com.njzscloud.dispose.wh.mapper.OutOrderMapper">
|
||||
|
||||
<sql id="searchOutOrder">
|
||||
SELECT id,
|
||||
sn,
|
||||
responsible_id,
|
||||
warehouse_id,
|
||||
location,
|
||||
out_time,
|
||||
order_id,
|
||||
order_sn,
|
||||
goods_category_id,
|
||||
goods_category_name,
|
||||
goods_id,
|
||||
goods_name,
|
||||
good_sn,
|
||||
quantity,
|
||||
unit,
|
||||
memo,
|
||||
creator_id,
|
||||
modifier_id,
|
||||
create_time,
|
||||
modify_time
|
||||
FROM wh_out_order
|
||||
SELECT woo.id,
|
||||
woo.sn,
|
||||
woo.responsible_id,
|
||||
su.nickname,
|
||||
woo.warehouse_id,
|
||||
ww.warehouse_name,
|
||||
woo.location,
|
||||
woo.out_time,
|
||||
woo.order_id,
|
||||
woo.order_sn,
|
||||
woo.goods_category_id,
|
||||
woo.goods_category_name,
|
||||
woo.goods_id,
|
||||
woo.goods_name,
|
||||
woo.good_sn,
|
||||
woo.quantity,
|
||||
woo.unit,
|
||||
woo.memo,
|
||||
woo.creator_id,
|
||||
woo.modifier_id,
|
||||
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>
|
||||
|
||||
<resultMap id="searchOutOrderResultMap" autoMapping="true" type="com.njzscloud.dispose.wh.pojo.result.SearchOutOrderResult">
|
||||
|
|
@ -31,16 +34,13 @@
|
|||
|
||||
<select id="paging" resultMap="searchOutOrderResultMap">
|
||||
<include refid="searchOutOrder"/>
|
||||
<where>
|
||||
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="searchOutOrderResultMap">
|
||||
<include refid="searchOutOrder"/>
|
||||
WHERE deleted = 0
|
||||
AND id = #{id}
|
||||
WHERE woo.id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue