库存管理

This commit is contained in:
gaowdong 2025-07-11 13:02:59 +08:00
parent ba3489dc8c
commit e5af4fa564
13 changed files with 130 additions and 44 deletions

View File

@ -65,9 +65,6 @@ public class ImsIntoInventoryController extends BaseController
@PostMapping("/warehouse/materials")
public TableDataInfo selectDetailListByWarehouseIdAndMaterialId(@RequestBody ImsIntoInventoryQuery imsIntoInventoryQuery)
{
if(Objects.isNull(imsIntoInventoryQuery.getMaterialId()) || Objects.isNull(imsIntoInventoryQuery.getWarehouseId())) {
throw new ServiceException("参数错误");
}
startPage();
List<ImsIntoInventoryDetail> list = imsIntoInventoryService.
selectDetailListByWarehouseIdAndMaterialId(imsIntoInventoryQuery);

View File

@ -117,6 +117,24 @@ public class ImsIntoInventory extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
@ApiModelProperty(value = "供应商id")
private Long supplierId;
@ApiModelProperty(value = "材料名称")
@Excel(name = "材料名称")
private String materialName;
@ApiModelProperty(value = "货品编码")
@Excel(name = "货品编码")
private String materialCode;
@ApiModelProperty(value = "条码")
@Excel(name = "条码")
private String barCode;
@ApiModelProperty(value = "货品名称")
private List<Long> materialTypeIds;
/** 入库记录明细信息 */
private List<ImsIntoInventoryDetail> imsIntoInventoryDetailList;

View File

@ -131,4 +131,8 @@ public class ImsOutInventoryDetail extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "到期时间(保质期)", width = 30, dateFormat = "yyyy-MM-dd")
private LocalDate expireTime;
@ApiModelProperty(value = "库存数量")
@Excel(name = "库存数量")
private BigDecimal materialNum;
}

View File

@ -3,6 +3,8 @@ package com.bonus.canteen.core.ims.domain.param;
import java.math.BigDecimal;
import java.util.List;
import java.time.LocalDateTime;
import com.bonus.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
@ -93,4 +95,22 @@ public class ImsIntoInventoryQuery implements Serializable
@ApiModelProperty(value = "原料id")
private Long materialId;
@ApiModelProperty(value = "供应商id")
private Long supplierId;
@ApiModelProperty(value = "材料名称")
@Excel(name = "材料名称")
private String materialName;
@ApiModelProperty(value = "货品编码")
@Excel(name = "货品编码")
private String materialCode;
@ApiModelProperty(value = "条码")
@Excel(name = "条码")
private String barCode;
@ApiModelProperty(value = "货品名称")
private List<Long> materialTypeIds;
}

View File

@ -12,7 +12,6 @@ import lombok.ToString;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 入库记录对象 ims_into_inventory
@ -94,6 +93,6 @@ public class ImsIntoInventoryUpdate implements Serializable
/** 入库记录明细信息 */
@Valid
private List<ImsIntoInventoryDetailAdd> imsIntoInventoryDetailUpdateList;
private List<ImsIntoInventoryDetailAdd> imsIntoInventoryDetailAddList;
}

View File

@ -10,9 +10,7 @@ import lombok.Data;
import lombok.ToString;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 出库记录对象 ims_out_inventory
@ -90,6 +88,6 @@ public class ImsOutInventoryUpdate implements Serializable
/** 出库记录明细信息 */
@Valid
private List<ImsOutInventoryDetailAdd> imsOutInventoryDetailUpdateList;
private List<ImsOutInventoryDetailAdd> imsOutInventoryDetailAddList;
}

View File

@ -129,4 +129,8 @@ public class ImsOutInventoryDetailVO extends BaseEntity
@Excel(name = "到期时间(保质期)", width = 30, dateFormat = "yyyy-MM-dd")
private LocalDate expireTime;
@ApiModelProperty(value = "库存数量")
@Excel(name = "库存数量")
private BigDecimal materialNum;
}

View File

@ -3,18 +3,18 @@ package com.bonus.canteen.core.ims.mapper;
import java.util.List;
import com.bonus.canteen.core.ims.domain.ImsOutInventory;
import com.bonus.canteen.core.ims.domain.ImsOutInventoryDetail;
import org.apache.ibatis.annotations.Param;
/**
* 出库记录Mapper接口
*
*
* @author gaowdong
* @date 2025-07-07
*/
public interface ImsOutInventoryMapper
{
public interface ImsOutInventoryMapper {
/**
* 查询出库记录
*
*
* @param outId 出库记录主键
* @return 出库记录
*/
@ -22,7 +22,7 @@ public interface ImsOutInventoryMapper
/**
* 查询出库记录列表
*
*
* @param imsOutInventory 出库记录
* @return 出库记录集合
*/
@ -30,7 +30,7 @@ public interface ImsOutInventoryMapper
/**
* 新增出库记录
*
*
* @param imsOutInventory 出库记录
* @return 结果
*/
@ -38,7 +38,7 @@ public interface ImsOutInventoryMapper
/**
* 修改出库记录
*
*
* @param imsOutInventory 出库记录
* @return 结果
*/
@ -46,7 +46,7 @@ public interface ImsOutInventoryMapper
/**
* 删除出库记录
*
*
* @param outId 出库记录主键
* @return 结果
*/
@ -54,7 +54,7 @@ public interface ImsOutInventoryMapper
/**
* 批量删除出库记录
*
*
* @param outIds 需要删除的数据主键集合
* @return 结果
*/
@ -62,26 +62,30 @@ public interface ImsOutInventoryMapper
/**
* 批量删除出库记录明细
*
*
* @param outIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteImsOutInventoryDetailByOutIds(Long[] outIds);
/**
* 批量新增出库记录明细
*
*
* @param imsOutInventoryDetailList 出库记录明细列表
* @return 结果
*/
public int batchImsOutInventoryDetail(List<ImsOutInventoryDetail> imsOutInventoryDetailList);
/**
* 通过出库记录主键删除出库记录明细信息
*
*
* @param outId 出库记录ID
* @return 结果
*/
public int deleteImsOutInventoryDetailByOutId(Long outId);
public List<ImsOutInventoryDetail> selectImsOutInventoryDetailList(@Param("outId") Long outId);
public List<ImsOutInventoryDetail> selectImsOutInventoryDetailListWithoutIntoId(@Param("outId") Long outId);
}

View File

@ -1,7 +1,6 @@
package com.bonus.canteen.core.ims.service.impl;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import cn.hutool.core.collection.CollUtil;
@ -15,7 +14,6 @@ import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.common.security.utils.SecurityUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -137,7 +135,7 @@ public class ImsIntoInventoryServiceImpl implements IImsIntoInventoryService
imsIntoInventory.setUpdateBy(SecurityUtils.getUsername());
imsIntoInventory.setIntoCode(imsIntoInventoryVO.getIntoCode());
imsIntoInventoryMapper.deleteImsIntoInventoryDetailByIntoId(imsIntoInventory.getIntoId());
insertImsIntoInventoryDetail(imsIntoInventoryUpdate.getImsIntoInventoryDetailUpdateList(), imsIntoInventory);
insertImsIntoInventoryDetail(imsIntoInventoryUpdate.getImsIntoInventoryDetailAddList(), imsIntoInventory);
return imsIntoInventoryMapper.updateImsIntoInventory(imsIntoInventory);
}

View File

@ -6,7 +6,6 @@ import java.util.List;
import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.ims.domain.*;
import com.bonus.canteen.core.ims.domain.param.*;
import com.bonus.canteen.core.ims.domain.vo.ImsIntoInventoryVO;
import com.bonus.canteen.core.ims.domain.vo.ImsOutInventoryDetailVO;
import com.bonus.canteen.core.ims.domain.vo.ImsOutInventoryVO;
import com.bonus.canteen.core.ims.mapper.ImsIntoInventoryMapper;
@ -61,7 +60,13 @@ public class ImsOutInventoryServiceImpl implements IImsOutInventoryService
if(Objects.nonNull(imsOutInventory)) {
imsOutInventoryVO = new ImsOutInventoryVO();
BeanUtils.copyProperties(imsOutInventory, imsOutInventoryVO);
List<ImsOutInventoryDetail> imsOutInventoryDetails = imsOutInventory.getImsOutInventoryDetailList();
List<ImsOutInventoryDetail> imsOutInventoryDetails;
if(imsOutInventory.getStatus() == 1) {
imsOutInventoryDetails = imsOutInventoryMapper.selectImsOutInventoryDetailListWithoutIntoId(outId);
}else{
imsOutInventoryDetails = imsOutInventoryMapper.selectImsOutInventoryDetailList(outId);
}
if(CollUtil.isNotEmpty(imsOutInventoryDetails)) {
List<ImsOutInventoryDetailVO> imsOutInventoryDetailVOList = new ArrayList<>();
for(ImsOutInventoryDetail detail : imsOutInventoryDetails) {
@ -144,8 +149,7 @@ public class ImsOutInventoryServiceImpl implements IImsOutInventoryService
imsOutInventory.setUpdateBy(SecurityUtils.getUsername());
imsOutInventory.setOutCode(imsOutInventoryVO.getOutCode());
imsOutInventoryMapper.deleteImsOutInventoryDetailByOutId(imsOutInventory.getOutId());
insertImsOutInventoryDetail(imsOutInventoryUpdate.getImsOutInventoryDetailUpdateList(), imsOutInventory);
return imsOutInventoryMapper.updateImsOutInventory(imsOutInventory);
return insertImsOutInventoryDetail(imsOutInventoryUpdate.getImsOutInventoryDetailAddList(), imsOutInventory);
}
/**
@ -181,7 +185,7 @@ public class ImsOutInventoryServiceImpl implements IImsOutInventoryService
*
* @param imsOutInventory 出库记录对象
*/
public void insertImsOutInventoryDetail(List<ImsOutInventoryDetailAdd> imsOutInventoryDetailAddList, ImsOutInventory imsOutInventory)
public int insertImsOutInventoryDetail(List<ImsOutInventoryDetailAdd> imsOutInventoryDetailAddList, ImsOutInventory imsOutInventory)
{
Long outId = imsOutInventory.getOutId();
if (StringUtils.isNotNull(imsOutInventoryDetailAddList))
@ -295,17 +299,17 @@ public class ImsOutInventoryServiceImpl implements IImsOutInventoryService
}
}
updateFetchMaterialOrderStatus(imsOutInventory);
}else {
list.add(imsOutInventoryDetail);
}
}
if (list.size() > 0)
{
imsOutInventoryMapper.batchImsOutInventoryDetail(list);
ImsOutInventory imsOutInventoryUpdate = new ImsOutInventory();
imsOutInventoryUpdate.setOutId(outId);
imsOutInventoryUpdate.setTotalAmount(totalPriceSum);
imsOutInventoryMapper.updateImsOutInventory(imsOutInventoryUpdate);
imsOutInventory.setTotalAmount(totalPriceSum);
}
}
return imsOutInventoryMapper.updateImsOutInventory(imsOutInventory);
}
private void updateFetchMaterialOrderStatus(ImsOutInventory imsOutInventory) {

View File

@ -189,14 +189,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join cook_material_type cmt on cm.material_type_id = cmt.material_type_id
left join ims_unit iu on iiid.unit_id = iu.unit_id
left join ims_warehouse_info iwi on iii.warehouse_id = iwi.warehouse_id
where iiid.material_id = #{materialId}
and iii.warehouse_id = #{warehouseId}
where iii.warehouse_id = #{warehouseId}
and iii.status = '2'
and iiid.inventory_num > 0
and iiid.del_flag = '0'
<if test="materialTypeIds != null and materialTypeIds.size() > 0">
and cmt.material_type_id in
<foreach collection="materialTypeIds" item="materialTypeId" separator="," open="(" close=")">
#{materialTypeId}
</foreach>
</if>
<if test="materialName != null and materialName != ''">
and cm.material_name like CONCAT('%',#{materialName},'%')
</if>
<if test="materialCode != null and materialCode != ''">
and cm.material_code = #{materialCode}
</if>
<if test="barCode != null and barCode != ''">
and cm.bar_code = #{barCode}
</if>
<if test="materialId != null">
and iiid.material_id = #{materialId}
</if>
<if test="intoCode != null and intoCode != ''">
and iii.into_code = #{intoCode}
</if>
<if test="supplierId != null">
and iiid.supplier_id = #{supplierId}
</if>
<if test="startDateTime != null">
and iii.into_date <![CDATA[ >= ]]> #{startDateTime}
</if>

View File

@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectImsInventoryVo"/>
<where>
ii.del_flag = '0'
<if test="inventoryId != null "> and ii.inventory_id = #{inventoryId}</if>
<if test="areaId != null "> and ba.area_id = #{areaId}</if>
<if test="warehouseId != null "> and ii.warehouse_id = #{warehouseId}</if>
<if test="materialId != null "> and ii.material_id = #{materialId}</if>
@ -61,11 +62,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{materialTypeId}
</foreach>
</if>
<if test="materialName != null">
<if test="materialName != null and materialName != ''">
and cm.material_name like CONCAT('%',#{materialName},'%')
</if>
<if test="barCode != null">
and cm.bar_code like CONCAT('%',#{barCode},'%')
<if test="materialCode != null and materialCode != ''">
and cm.material_code = #{materialCode}
</if>
<if test="barCode != null and barCode != ''">
and cm.bar_code = #{barCode}
</if>
<if test="startDateTime != null">
and ii.create_time <![CDATA[ >= ]]> #{startDateTime}

View File

@ -30,9 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="areaId" column="area_id" />
</resultMap>
<resultMap id="ImsOutInventoryImsOutInventoryDetailResult" type="com.bonus.canteen.core.ims.domain.ImsOutInventory" extends="ImsOutInventoryResult">
<collection property="imsOutInventoryDetailList" ofType="com.bonus.canteen.core.ims.domain.ImsOutInventoryDetail" column="out_id" select="selectImsOutInventoryDetailList" />
</resultMap>
<!-- <resultMap id="ImsOutInventoryImsOutInventoryDetailResult" type="com.bonus.canteen.core.ims.domain.ImsOutInventory" extends="ImsOutInventoryResult">-->
<!-- <collection property="imsOutInventoryDetailList" ofType="com.bonus.canteen.core.ims.domain.ImsOutInventoryDetail" column="out_id" select="selectImsOutInventoryDetailList" />-->
<!-- </resultMap>-->
<resultMap type="com.bonus.canteen.core.ims.domain.ImsOutInventoryDetail" id="ImsOutInventoryDetailResult">
<result property="outDetailId" column="out_detail_id" />
@ -65,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="inventoryNum" column="inventory_num" />
<result property="intoCode" column="into_code" />
<result property="intoDate" column="into_date" />
<result property="materialNum" column="material_num" />
</resultMap>
<sql id="selectImsOutInventoryVo">
@ -106,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by ioi.out_date desc
</select>
<select id="selectImsOutInventoryByOutId" parameterType="Long" resultMap="ImsOutInventoryImsOutInventoryDetailResult">
<select id="selectImsOutInventoryByOutId" parameterType="Long" resultMap="ImsOutInventoryResult">
select out_id, out_code, ioi.warehouse_id, out_date, ioi.fetch_user_id, total_num, out_type,
ioi.status, order_id, total_amount, plan_id, fetch_material_id, goods_allocation_id,
ioi.remark, ioi.del_flag, ioi.create_by, ioi.create_time, ioi.update_by, ioi.update_time,
@ -131,7 +132,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join cook_material cm on iiid.material_id = cm.material_id
left join cook_material_type cmt on cm.material_type_id = cmt.material_type_id
left join ims_unit iu on iiid.unit_id = iu.unit_id
where out_id = #{out_id} and ioid.del_flag = '0'
where out_id = #{outId} and ioid.del_flag = '0'
order by ioid.out_detail_id
</select>
<select id="selectImsOutInventoryDetailListWithoutIntoId" resultMap="ImsOutInventoryDetailResult">
select out_detail_id, out_id, out_code, ioid.inventory_id, fetch_num, ioid.total_price,
ioid.into_detail_id, interval_id, ioid.size, ioid.img_url, if_overdraft, ioid.remark, ioid.del_flag,
ioid.create_by, ioid.create_time, ioid.update_by, ioid.update_time,
cm.material_name, cmt.material_type_name, iu.unit_name, cm.bar_code,
cm.size AS material_size, cm.material_code, ii.material_num
from ims_out_inventory_detail ioid
left join ims_inventory ii on ioid.inventory_id = ii.inventory_id
left join cook_material cm on ii.material_id = cm.material_id
left join cook_material_type cmt on cm.material_type_id = cmt.material_type_id
left join ims_unit iu on cm.unit_id = iu.unit_id
where out_id = #{outId} and ioid.del_flag = '0'
order by ioid.out_detail_id
</select>