唯一码逻辑修改
This commit is contained in:
@@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
FROM worn_unique_code t
|
||||
LEFT JOIN sys_dept d ON t.project_id = d.dept_id
|
||||
<where>
|
||||
<if test="code != null and code != ''"> and t.code = #{code}</if>
|
||||
<if test="code != null"> and t.code = #{code}</if>
|
||||
<if test="billNo != null and billNo != ''"> and t.bill_no = #{billNo}</if>
|
||||
<if test="projectId != null "> and t.project_id = #{projectId}</if>
|
||||
<if test="status != null and status != ''"> and t.status = #{status}</if>
|
||||
@@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="insertWornUniqueCode" parameterType="WornUniqueCode" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into worn_unique_code
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="code != null and code != ''">code,</if>
|
||||
<if test="code != null">code,</if>
|
||||
<if test="billNo != null">bill_no,</if>
|
||||
<if test="projectId != null">project_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="code != null and code != ''">#{code},</if>
|
||||
<if test="code != null">#{code},</if>
|
||||
<if test="billNo != null">#{billNo},</if>
|
||||
<if test="projectId != null">#{projectId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
@@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateWornUniqueCode" parameterType="WornUniqueCode">
|
||||
update worn_unique_code
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="code != null and code != ''">code = #{code},</if>
|
||||
<if test="code != null">code = #{code},</if>
|
||||
<if test="billNo != null">bill_no = #{billNo},</if>
|
||||
<if test="projectId != null">project_id = #{projectId},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
@@ -93,9 +93,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteWornUniqueCodeByIds" parameterType="String">
|
||||
delete from worn_unique_code where id in
|
||||
<delete id="deleteWornUniqueCodeByIds" parameterType="Long">
|
||||
delete from worn_unique_code where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
@@ -1,21 +1,56 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.shzg.project.unique.mapper.WornUniqueCodeMaterialMapper">
|
||||
|
||||
|
||||
<!-- ================= 原有 resultMap ================= -->
|
||||
<resultMap type="WornUniqueCodeMaterial" id="WornUniqueCodeMaterialResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="uniqueCodeId" column="unique_code_id" />
|
||||
<result property="materialId" column="material_id" />
|
||||
<result property="unitId" column="unit_id" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="isDelete" column="is_delete" />
|
||||
<result property="id" column="id"/>
|
||||
<result property="uniqueCodeId" column="unique_code_id"/>
|
||||
<result property="materialId" column="material_id"/>
|
||||
<result property="unitId" column="unit_id"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="isDelete" column="is_delete"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- ================= 联表 resultMap ================= -->
|
||||
<resultMap id="materialWithWornMaterial" type="com.shzg.project.unique.domain.WornUniqueCodeMaterial">
|
||||
<id property="id" column="id"/>
|
||||
<result property="uniqueCodeId" column="unique_code_id"/>
|
||||
<result property="materialId" column="material_id"/>
|
||||
<result property="unitId" column="unit_id"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="isDelete" column="is_delete"/>
|
||||
|
||||
<!-- 嵌套物料 -->
|
||||
<association property="wornMaterial" javaType="com.shzg.project.worn.domain.WornMaterial">
|
||||
<id property="id" column="wm_id"/>
|
||||
<result property="materialName" column="material_name"/>
|
||||
<result property="materialShortName" column="material_short_name"/>
|
||||
<result property="materialCode" column="material_code"/>
|
||||
<result property="typeId" column="type_id"/>
|
||||
<result property="unitId" column="unit_id"/>
|
||||
<result property="materialCategory" column="material_category"/>
|
||||
<result property="kgFactor" column="kg_factor"/>
|
||||
<result property="specification" column="specification"/>
|
||||
<result property="model" column="model"/>
|
||||
<result property="barcode" column="barcode"/>
|
||||
<result property="weight" column="weight"/>
|
||||
<result property="description" column="description"/>
|
||||
|
||||
<!-- 扩展字段 -->
|
||||
<result property="typeName" column="type_name"/>
|
||||
<result property="typeAncestors" column="type_ancestors"/>
|
||||
<result property="typeParentNames" column="type_parent_names"/>
|
||||
<result property="unitName" column="unit_name"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectWornUniqueCodeMaterialVo">
|
||||
@@ -24,19 +59,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectWornUniqueCodeMaterialList" parameterType="WornUniqueCodeMaterial" resultMap="WornUniqueCodeMaterialResult">
|
||||
<include refid="selectWornUniqueCodeMaterialVo"/>
|
||||
<where>
|
||||
<if test="uniqueCodeId != null "> and unique_code_id = #{uniqueCodeId}</if>
|
||||
<if test="materialId != null "> and material_id = #{materialId}</if>
|
||||
<if test="unitId != null "> and unit_id = #{unitId}</if>
|
||||
<if test="quantity != null "> and quantity = #{quantity}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
<where>
|
||||
<if test="uniqueCodeId != null"> and unique_code_id = #{uniqueCodeId}</if>
|
||||
<if test="materialId != null"> and material_id = #{materialId}</if>
|
||||
<if test="unitId != null"> and unit_id = #{unitId}</if>
|
||||
<if test="quantity != null"> and quantity = #{quantity}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectWornUniqueCodeMaterialById" parameterType="Long" resultMap="WornUniqueCodeMaterialResult">
|
||||
<include refid="selectWornUniqueCodeMaterialVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- ================= 核心:联表查询 ================= -->
|
||||
<select id="selectWithMaterialByUniqueCodeId"
|
||||
parameterType="java.lang.Long"
|
||||
resultMap="materialWithWornMaterial">
|
||||
|
||||
SELECT
|
||||
m.*,
|
||||
|
||||
wm.id AS wm_id,
|
||||
wm.material_name,
|
||||
wm.material_short_name,
|
||||
wm.material_code,
|
||||
wm.type_id,
|
||||
wm.unit_id,
|
||||
wm.material_category,
|
||||
wm.kg_factor,
|
||||
wm.specification,
|
||||
wm.model,
|
||||
wm.barcode,
|
||||
wm.weight,
|
||||
wm.description,
|
||||
|
||||
wt.type_name,
|
||||
wt.ancestors AS type_ancestors,
|
||||
|
||||
wu.unit_name,
|
||||
|
||||
GROUP_CONCAT(wt_parent.type_name ORDER BY wt_parent.id SEPARATOR '/') AS type_parent_names
|
||||
|
||||
FROM worn_unique_code_material m
|
||||
|
||||
LEFT JOIN worn_material wm ON m.material_id = wm.id
|
||||
LEFT JOIN worn_material_type wt ON wm.type_id = wt.id
|
||||
LEFT JOIN worn_material_type wt_parent ON FIND_IN_SET(wt_parent.id, wt.ancestors)
|
||||
LEFT JOIN worn_material_unit wu ON wm.unit_id = wu.id
|
||||
|
||||
WHERE m.unique_code_id = #{uniqueCodeId}
|
||||
|
||||
GROUP BY m.id
|
||||
</select>
|
||||
|
||||
<insert id="insertWornUniqueCodeMaterial" parameterType="WornUniqueCodeMaterial" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into worn_unique_code_material
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -50,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="uniqueCodeId != null">#{uniqueCodeId},</if>
|
||||
<if test="materialId != null">#{materialId},</if>
|
||||
@@ -62,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateWornUniqueCodeMaterial" parameterType="WornUniqueCodeMaterial">
|
||||
@@ -86,16 +163,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
delete from worn_unique_code_material where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteWornUniqueCodeMaterialByIds" parameterType="String">
|
||||
delete from worn_unique_code_material where id in
|
||||
<delete id="deleteWornUniqueCodeMaterialByIds" parameterType="Long">
|
||||
delete from worn_unique_code_material where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="selectByUniqueCodeId" resultType="com.shzg.project.unique.domain.WornUniqueCodeMaterial">
|
||||
SELECT *
|
||||
FROM worn_unique_code_material
|
||||
WHERE unique_code_id = #{uniqueCodeId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user