入库模块代码

This commit is contained in:
2026-04-03 15:32:45 +08:00
parent 3ee2ca5eb7
commit 7b10eff9c8
23 changed files with 1376 additions and 80 deletions

View File

@@ -156,7 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
<select id="selectDeptAndChildren" resultType="com.shzg.project.system.domain.SysDept">
<select id="selectDeptAndChildren" resultMap="SysDeptResult">
SELECT *
FROM sys_dept
WHERE

View File

@@ -19,7 +19,22 @@
<result property="remark" column="remark" />
<result property="isDelete" column="is_delete" />
</resultMap>
<resultMap id="WornInboundItemDTOResult" type="com.shzg.project.worn.domain.dto.WornInboundItemDTO">
<result property="id" column="id"/>
<result property="materialId" column="materialId"/>
<result property="materialName" column="materialName"/>
<result property="quantity" column="quantity"/>
<result property="remark" column="remark"/>
<result property="uniqueCode" column="uniqueCode"/>
<result property="isDelete" column="isDelete"/>
<result property="status" column="status" />
<result property="materialCode" column="materialCode"/>
<result property="materialShortName" column="materialShortName"/>
<result property="specification" column="specification"/>
<result property="model" column="model"/>
<result property="typeName" column="typeName"/>
<result property="typeParentNames" column="typeParentNames"/>
</resultMap>
<sql id="selectWornUniqueCodeVo">
select id, code, bill_no, project_id, status, rfid_code, print_count, create_by, create_time, update_by, update_time, remark, is_delete
from worn_unique_code
@@ -49,6 +64,7 @@
AND t.rfid_code = #{rfidCode}
</if>
</where>
order by t.create_time desc, t.id desc
</select>
<select id="selectWornUniqueCodeById" parameterType="Long" resultMap="WornUniqueCodeResult">
@@ -60,6 +76,7 @@
select id
from worn_unique_code
where code = #{code}
AND (is_delete = '0' OR is_delete IS NULL)
</select>
<insert id="insertWornUniqueCode" parameterType="WornUniqueCode" useGeneratedKeys="true" keyProperty="id">
@@ -127,4 +144,80 @@
#{id}
</foreach>
</delete>
<select id="selectByCode" resultType="com.shzg.project.unique.domain.WornUniqueCode">
SELECT
id,
code,
bill_no,
project_id,
status,
rfid_code,
print_count,
create_by,
create_time,
update_by,
update_time,
remark,
is_delete
FROM worn_unique_code
WHERE code = #{code}
AND (is_delete = '0' OR is_delete IS NULL)
LIMIT 1
</select>
<select id="selectMaterialInfoByCode" resultMap="WornInboundItemDTOResult">
SELECT
ucm.id AS id,
ucm.material_id AS materialId,
ucm.quantity AS quantity,
ucm.remark AS remark,
uc.code AS uniqueCode,
COALESCE(ucm.is_delete, '0') AS isDelete,
m.material_name AS materialName,
m.material_code AS materialCode,
m.material_short_name AS materialShortName,
m.specification AS specification,
m.model AS model,
uc.status,
mt.type_name AS typeName,
(
SELECT GROUP_CONCAT(t2.type_name ORDER BY t2.id SEPARATOR '/')
FROM worn_material_type t2
WHERE FIND_IN_SET(t2.id, mt.ancestors) OR t2.id = mt.id
) AS typeParentNames
FROM worn_unique_code uc
LEFT JOIN worn_unique_code_material ucm
ON uc.id = ucm.unique_code_id
LEFT JOIN worn_material m
ON ucm.material_id = m.id
LEFT JOIN worn_material_type mt
ON m.type_id = mt.id
WHERE uc.code = #{code}
AND (uc.is_delete = '0' OR uc.is_delete IS NULL)
AND (ucm.is_delete = '0' OR ucm.is_delete IS NULL)
AND (m.is_delete = '0' OR m.is_delete IS NULL)
ORDER BY ucm.id ASC
</select>
<update id="updateInboundStatusByCode"
parameterType="com.shzg.project.unique.domain.WornUniqueCode">
UPDATE worn_unique_code
SET status = #{status},
update_by = #{updateBy},
update_time = #{updateTime}
WHERE code = #{code}
AND status = '1'
AND (is_delete = '0' OR is_delete IS NULL)
</update>
<update id="updateVoidStatusByCode">
update worn_unique_code
set status = '9',
update_by = #{updateBy},
update_time = #{updateTime}
where code = #{code}
and (is_delete = '0' or is_delete is null)
</update>
</mapper>

View File

@@ -38,7 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="inboundTime != null "> and inbound_time = #{inboundTime}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
<if test="isDelete == null or isDelete == ''">and is_delete = '0'</if>
<if test="billNo == null or billNo == ''">
and bill_no like 'WR%'
</if>
</where>
order by create_time desc, id desc
</select>
<select id="selectWornInboundBillById" parameterType="Long" resultMap="WornInboundBillResult">
@@ -85,22 +90,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateWornInboundBill" parameterType="WornInboundBill">
update worn_inbound_bill
<trim prefix="SET" suffixOverrides=",">
<if test="billNo != null and billNo != ''">bill_no = #{billNo},</if>
<if test="billType != null">bill_type = #{billType},</if>
<if test="warehouseCode != null">warehouse_code = #{warehouseCode},</if>
<if test="warehouseName != null">warehouse_name = #{warehouseName},</if>
<if test="areaCode != null">area_code = #{areaCode},</if>
<if test="areaName != null">area_name = #{areaName},</if>
<if test="warehouseCode != null and warehouseCode != ''">warehouse_code = #{warehouseCode},</if>
<if test="warehouseName != null and warehouseName != ''">warehouse_name = #{warehouseName},</if>
<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
<if test="areaName != null and areaName != ''">area_name = #{areaName},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="inboundTime != null">inbound_time = #{inboundTime},</if>
<if test="status != null">status = #{status},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="status != null and status != ''">status = #{status},</if>
update_by = #{updateBy},
update_time = #{updateTime}
</trim>
where id = #{id}
where bill_no = #{billNo}
</update>
<delete id="deleteWornInboundBillById" parameterType="Long">
@@ -113,4 +113,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="selectWornInboundBillByBillNo"
parameterType="String"
resultMap="WornInboundBillResult">
<include refid="selectWornInboundBillVo"/>
<where>
bill_no = #{billNo}
AND (is_delete = '0' OR is_delete IS NULL)
</where>
LIMIT 1
</select>
<update id="updateWornInboundBillById"
parameterType="com.shzg.project.worn.domain.WornInboundBill">
UPDATE worn_inbound_bill
<trim prefix="SET" suffixOverrides=",">
<if test="billNo != null">bill_no = #{billNo},</if>
<if test="billType != null">bill_type = #{billType},</if>
<if test="warehouseCode != null">warehouse_code = #{warehouseCode},</if>
<if test="warehouseName != null">warehouse_name = #{warehouseName},</if>
<if test="areaCode != null">area_code = #{areaCode},</if>
<if test="areaName != null">area_name = #{areaName},</if>
<if test="inboundTime != null">inbound_time = #{inboundTime},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
</trim>
WHERE id = #{id}
</update>
</mapper>

View File

@@ -14,21 +14,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="inboundTime" column="inbound_time" />
<!-- 扩展查询字段 -->
<result property="warehouseCode" column="warehouse_code"/>
<result property="warehouseName" column="warehouse_name"/>
<result property="areaCode" column="area_code"/>
<result property="areaName" column="area_name"/>
<result property="materialName" column="material_name"/>
<result property="materialShortName" column="material_short_name"/>
<result property="materialCode" column="material_code"/>
<result property="specification" column="specification"/>
<result property="model" column="model"/>
<result property="weight" column="weight"/>
<result property="billRemark" column="bill_remark"/>
<result property="billStatus" column="bill_status"/>
<result property="billType" column="bill_type"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="typeName" column="type_name"/>
<result property="typeParentNames" column="type_parent_names"/>
<result property="unitId" column="unit_id"/>
<result property="unitName" column="unit_name"/>
</resultMap>
<sql id="selectWornInboundItemVo">
select id, bill_id, bill_no, material_id, quantity, unique_code, remark, create_by, create_time from worn_inbound_item
</sql>
<select id="selectWornInboundItemList" parameterType="WornInboundItem" resultMap="WornInboundItemResult">
<include refid="selectWornInboundItemVo"/>
<where>
<if test="billId != null "> and bill_id = #{billId}</if>
<if test="billNo != null and billNo != ''"> and bill_no = #{billNo}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="quantity != null "> and quantity = #{quantity}</if>
<if test="uniqueCode != null"> and unique_code = #{uniqueCode}</if>
</where>
<select id="selectWornInboundItemList" parameterType="com.shzg.project.worn.domain.WornInboundItem" resultMap="WornInboundItemResult">
SELECT
-- ===== 主表bill=====
b.id AS bill_id,
b.bill_no AS bill_no,
b.bill_type ,
b.warehouse_code ,
b.warehouse_name ,
b.area_code ,
b.area_name ,
b.remark AS bill_remark,
b.inbound_time ,
b.status AS bill_status,
b.update_by ,
b.update_time ,
-- ===== 明细item=====
i.id AS id,
i.material_id,
i.quantity ,
i.unique_code ,
i.remark ,
i.is_delete ,
i.create_by ,
i.create_time ,
i.status,
-- ===== 物料material=====
m.material_name ,
m.material_code ,
m.material_short_name ,
m.specification ,
m.model ,
m.weight,
m.unit_id,
mu.unit_name,
-- ===== 类型material_type=====
mt.type_name AS type_name,
(
SELECT GROUP_CONCAT(t2.type_name ORDER BY t2.id SEPARATOR '/')
FROM worn_material_type t2
WHERE FIND_IN_SET(t2.id, mt.ancestors) OR t2.id = mt.id
) AS type_parent_names
FROM worn_inbound_bill b
LEFT JOIN worn_inbound_item i
ON b.id = i.bill_id
LEFT JOIN worn_material m
ON i.material_id = m.id
LEFT JOIN worn_material_type mt ON m.type_id = mt.id
LEFT JOIN worn_material_unit mu ON m.unit_id = mu.id
WHERE b.bill_no = #{billNo}
AND b.is_delete = '0'
AND (i.is_delete = '0' OR i.is_delete IS NULL)
ORDER BY i.id ASC
</select>
<select id="selectWornInboundItemById" parameterType="Long" resultMap="WornInboundItemResult">
@@ -47,6 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="isDelete != null">is_delete,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="billId != null">#{billId},</if>
@@ -57,6 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="isDelete != null">#{isDelete},</if>
</trim>
</insert>
@@ -69,8 +137,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="quantity != null">quantity = #{quantity},</if>
<if test="uniqueCode != null">unique_code = #{uniqueCode},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="isDelete != null and isDelete != ''">is_delete = #{isDelete},</if>
</trim>
where id = #{id}
</update>
@@ -85,4 +153,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<update id="updateUniqueCodeByBillNoAndMaterialId">
update worn_inbound_item
set unique_code = #{uniqueCode}
where bill_no = #{billNo}
and material_id = #{materialId}
and (is_delete = '0' or is_delete is null)
</update>
<update id="updateInboundItemStatus"
parameterType="com.shzg.project.worn.domain.WornInboundItem">
UPDATE worn_inbound_item
SET status = #{status},
remark = #{remark},
update_by = #{updateBy},
update_time = #{updateTime}
WHERE id = #{id}
AND status = '0'
AND (is_delete = '0' OR is_delete IS NULL)
</update>
<select id="countNotInboundByBillId"
parameterType="Long"
resultType="int">
SELECT COUNT(1)
FROM worn_inbound_item
WHERE bill_id = #{billId}
AND (is_delete = '0' OR is_delete IS NULL)
AND (status IS NULL OR status != '1')
</select>
<update id="updateItemToVoid">
update worn_inbound_item
set status = '2',
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
and (is_delete = '0' or is_delete is null)
</update>
<select id="selectWornInboundItemByBillId"
parameterType="Long"
resultMap="WornInboundItemResult">
SELECT
id,
bill_id,
bill_no,
material_id,
quantity,
unique_code,
remark,
status,
create_by,
create_time,
update_by,
update_time,
is_delete
FROM worn_inbound_item
WHERE bill_id = #{billId}
AND (is_delete = '0' OR is_delete IS NULL)
ORDER BY id ASC
</select>
</mapper>