2024-09-27 15:38:58 +08:00
<?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.bonus.material.purchase.mapper.PurchaseMacodeInfoMapper" >
<resultMap type= "com.bonus.material.purchase.domain.PurchaseMacodeInfo" id= "PurchaseMacodeInfoResult" >
<result property= "id" column= "id" />
<result property= "taskId" column= "task_id" />
<result property= "typeId" column= "type_id" />
<result property= "maCode" column= "ma_code" />
<result property= "qrCode" column= "qr_code" />
<result property= "fixCode" column= "fix_code" />
<result property= "codeType" column= "code_type" />
<result property= "status" column= "status" />
<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= "companyId" column= "company_id" />
2024-11-15 16:41:54 +08:00
<result property= "outFacCode" column= "out_fac_code" />
2024-11-15 16:21:59 +08:00
<result property= "unitName" column= "unit_name" />
<result property= "typeName" column= "type_name" />
<result property= "maTypeName" column= "ma_type_name" />
<result property= "productionTime" column= "production_time" />
2024-09-27 15:38:58 +08:00
</resultMap>
<sql id= "selectPurchaseMacodeInfoVo" >
2024-12-24 19:30:58 +08:00
select pmi.id, pmi.task_id, pmi.type_id, pmi.ma_code, pmi.qr_code, if(mm.ma_status = '0' or mm.ma_status = '5' or mm.ma_status = '9', 0, 1) as status,
2025-02-20 21:33:52 +08:00
su.nick_name as createBy, pmi.create_time, pmi.update_by, pmi.update_time, pmi.remark, pmi.company_id, pmi.out_fac_code,
2024-11-15 16:41:54 +08:00
mt.type_name, mt.unit_name, mtp.type_name as ma_type_name, pcd.production_time
2024-12-24 10:59:54 +08:00
from bm_qrcode_info pmi
2024-11-15 16:21:59 +08:00
left join ma_type mt on pmi.type_id = mt.type_id
left join ma_type mtp on mt.parent_id = mtp.type_id
2024-11-15 16:41:54 +08:00
left join purchase_check_details pcd on pmi.task_id = pcd.task_id and pmi.type_id = pcd.type_id
2024-12-24 19:30:58 +08:00
left join ma_machine mm on pmi.type_id = mm.type_id and pmi.ma_code = mm.ma_code
2025-02-20 21:33:52 +08:00
left join sys_user su on pmi.bind_user = su.user_id
2024-09-27 15:38:58 +08:00
</sql>
2025-03-17 16:28:08 +08:00
<select id= "selectPurchaseMacodeInfoList" parameterType= "com.bonus.material.purchase.domain.PurchaseMacodeInfo" resultType= "com.bonus.material.purchase.domain.PurchaseMacodeInfo" >
select pmi.id, pmi.task_id as taskId, pmi.type_id as typeId, pmi.ma_code as maCode, pmi.qr_code as qrCode, if(mm.ma_status = '0' or mm.ma_status = '5' or mm.ma_status = '9', 0, 1) as status,
su.nick_name as createBy, pmi.create_time as createTime, pmi.update_by as updateBy, pmi.update_time as updateTime, pmi.remark, pmi.company_id as companyId, pmi.out_fac_code as outFacCode,
mt.type_name as typeName, mt.unit_name as unitName, mtp.type_name as maTypeName, pcd.production_time as productionTime
from bm_qrcode_info pmi
left join ma_type mt on pmi.type_id = mt.type_id
left join ma_type mtp on mt.parent_id = mtp.type_id
left join purchase_check_details pcd on pmi.task_id = pcd.task_id and pmi.type_id = pcd.type_id
left join ma_machine mm on pmi.type_id = mm.type_id and pmi.ma_code = mm.ma_code
left join sys_user su on pmi.bind_user = su.user_id
where
1=1
<if test= "taskId != null " > and pmi.task_id = #{taskId}</if>
2024-11-15 16:21:59 +08:00
<if test= "typeId != null " > and pmi.type_id = #{typeId}</if>
<if test= "maCode != null and maCode != ''" > and pmi.ma_code = #{maCode}</if>
2024-11-15 16:41:54 +08:00
<if test= "outFacCode != null and outFacCode != ''" > and pmi.out_fac_code = #{outFacCode}</if>
2024-11-15 16:21:59 +08:00
<if test= "qrCode != null and qrCode != ''" > and pmi.qr_code = #{qrCode}</if>
<if test= "fixCode != null and fixCode != ''" > and pmi.fix_code = #{fixCode}</if>
<if test= "codeType != null and codeType != ''" > and pmi.code_type = #{codeType}</if>
<if test= "status != null and status != ''" > and pmi.status = #{status}</if>
<if test= "companyId != null " > and pmi.company_id = #{companyId}</if>
2024-12-24 19:30:58 +08:00
<if test= "keyWord != null and keyWord != ''" >
and (pmi.ma_code like concat('%', #{keyWord}, '%') or pmi.qr_code like concat('%', #{keyWord}, '%'))
</if>
and pmi.ma_code is not null
2025-03-17 16:28:08 +08:00
2024-09-27 15:38:58 +08:00
</select>
<select id= "selectPurchaseMacodeInfoById" parameterType= "Long" resultMap= "PurchaseMacodeInfoResult" >
<include refid= "selectPurchaseMacodeInfoVo" />
2024-11-15 16:21:59 +08:00
where pmi.id = #{id}
2024-09-27 15:38:58 +08:00
</select>
<insert id= "insertPurchaseMacodeInfo" parameterType= "com.bonus.material.purchase.domain.PurchaseMacodeInfo" useGeneratedKeys= "true" keyProperty= "id" >
2024-12-24 10:59:54 +08:00
insert into bm_qrcode_info
2024-09-27 15:38:58 +08:00
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "taskId != null" > task_id,</if>
<if test= "typeId != null" > type_id,</if>
<if test= "maCode != null" > ma_code,</if>
2024-11-15 16:41:54 +08:00
<if test= "outFacCode != null" > out_fac_code,</if>
2024-09-27 15:38:58 +08:00
<if test= "qrCode != null" > qr_code,</if>
<if test= "fixCode != null" > fix_code,</if>
<if test= "codeType != null" > code_type,</if>
<if test= "status != null" > status,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "remark != null" > remark,</if>
<if test= "companyId != null" > company_id,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "taskId != null" > #{taskId},</if>
<if test= "typeId != null" > #{typeId},</if>
<if test= "maCode != null" > #{maCode},</if>
2024-11-15 16:41:54 +08:00
<if test= "outFacCode != null" > #{outFacCode},</if>
2024-09-27 15:38:58 +08:00
<if test= "qrCode != null" > #{qrCode},</if>
<if test= "fixCode != null" > #{fixCode},</if>
<if test= "codeType != null" > #{codeType},</if>
<if test= "status != null" > #{status},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "companyId != null" > #{companyId},</if>
</trim>
</insert>
<update id= "updatePurchaseMacodeInfo" parameterType= "com.bonus.material.purchase.domain.PurchaseMacodeInfo" >
2024-12-24 10:59:54 +08:00
update bm_qrcode_info
2024-09-27 15:38:58 +08:00
<trim prefix= "SET" suffixOverrides= "," >
<if test= "taskId != null" > task_id = #{taskId},</if>
<if test= "typeId != null" > type_id = #{typeId},</if>
<if test= "maCode != null" > ma_code = #{maCode},</if>
2024-11-15 16:41:54 +08:00
<if test= "outFacCode != null" > out_fac_code = #{outFacCode},</if>
2024-09-27 15:38:58 +08:00
<if test= "qrCode != null" > qr_code = #{qrCode},</if>
<if test= "fixCode != null" > fix_code = #{fixCode},</if>
<if test= "codeType != null" > code_type = #{codeType},</if>
<if test= "status != null" > status = #{status},</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= "remark != null" > remark = #{remark},</if>
<if test= "companyId != null" > company_id = #{companyId},</if>
</trim>
where id = #{id}
</update>
<delete id= "deletePurchaseMacodeInfoById" parameterType= "Long" >
2024-12-24 10:59:54 +08:00
delete from bm_qrcode_info where id = #{id}
2024-09-27 15:38:58 +08:00
</delete>
<delete id= "deletePurchaseMacodeInfoByIds" parameterType= "String" >
2024-12-24 10:59:54 +08:00
delete from bm_qrcode_info where id in
2024-12-24 19:30:58 +08:00
<foreach item= "id" collection= "ids" open= "(" separator= "," close= ")" >
2024-09-27 15:38:58 +08:00
#{id}
</foreach>
</delete>
2024-11-18 11:24:36 +08:00
2024-12-24 19:30:58 +08:00
<update id= "updatePurchaseMacodeInfoByIds" parameterType= "String" >
update bm_qrcode_info set ma_code = null where id in
<foreach item= "id" collection= "ids" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</update>
2024-11-18 11:24:36 +08:00
<select id= "getPurchaseMaCodeCount" resultType= "Integer" >
2024-12-24 10:59:54 +08:00
select count(1) from bm_qrcode_info where task_id = #{taskId} and type_id = #{typeId}
2024-11-18 11:24:36 +08:00
</select>
2024-09-27 15:38:58 +08:00
</mapper>