devicesmgt/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml

267 lines
15 KiB
XML
Raw Normal View History

2023-12-10 17:30:51 +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.sgzb.material.mapper.PurchaseMacodeInfoMapper">
<resultMap type="com.bonus.sgzb.material.domain.PurchaseMacodeInfo" id="PurchaseMacodeInfoResult">
<result property="taskId" column="task_id" />
<result property="typeId" column="type_id" />
<result property="maCode" column="ma_code" />
2023-12-15 15:29:41 +08:00
<result property="qrCode" column="qr_code" />
2023-12-10 17:30:51 +08:00
<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" />
</resultMap>
<sql id="selectPurchaseMacodeInfoVo">
2023-12-15 15:29:41 +08:00
select task_id, type_id, ma_code, qr_code, fix_code, code_type, status, create_by, create_time, update_by, update_time, remark, company_id from purchase_macode_info
2023-12-10 17:30:51 +08:00
</sql>
<select id="selectPurchaseMacodeInfoList" parameterType="com.bonus.sgzb.material.domain.PurchaseMacodeInfo" resultMap="PurchaseMacodeInfoResult">
2023-12-21 20:28:01 +08:00
select distinct pcd.task_id, pcd.type_id, pmi.qr_code, pmi.fix_code, pmi.code_type, pmi.status,
pmi.remark, pmi.company_id, mt.type_name specificationType,
mt1.type_name typeName, pcd.check_num checkNum, pcd.purchase_num purchaseNum ,
IFNULL(pcd.bind_num,0) bindNum, mt.code typeCode,mt.model_code specsCode,pt.purchase_time purchaseTime
from purchase_check_details pcd
left join ma_type mt on pcd.type_id = mt.type_id
2023-12-19 09:01:17 +08:00
left join ma_type mt1 on mt.parent_id = mt1.type_id
2023-12-21 20:28:01 +08:00
left join purchase_macode_info pmi on pmi.task_id = pcd.task_id and pmi.type_id = pcd.type_id
left join purchase_check_info pt on pcd.task_id = pt.task_id
where pcd.task_id = #{taskId}
2023-12-15 15:29:41 +08:00
<if test="typeId != null "> and pmi.type_id = #{typeId}</if>
2023-12-21 20:28:01 +08:00
<if test="keyWord != null and keyWord != ''">(mt.type_name like concat('%',#{keyWord},'%') or mt1.type_name like concat('%',#{keyWord})</if>
2023-12-15 15:29:41 +08:00
<if test="typeName != null and typeName != ''"> and mt1.type_name = #{typeName}</if>
<if test="specificationType != null and specificationType != ''"> and mt.type_name = #{specificationType}</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>
2023-12-10 17:30:51 +08:00
</select>
<select id="selectPurchaseMacodeInfoByTaskId" parameterType="Long" resultMap="PurchaseMacodeInfoResult">
<include refid="selectPurchaseMacodeInfoVo"/>
where task_id = #{taskId}
</select>
<insert id="insertPurchaseMacodeInfo" parameterType="com.bonus.sgzb.material.domain.PurchaseMacodeInfo" useGeneratedKeys="true" keyProperty="taskId">
insert into purchase_macode_info
<trim prefix="(" suffix=")" suffixOverrides=",">
2023-12-15 15:29:41 +08:00
<if test="taskId != null">task_id,</if>
2023-12-10 17:30:51 +08:00
<if test="typeId != null">type_id,</if>
<if test="maCode != null">ma_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=",">
2023-12-15 15:29:41 +08:00
<if test="taskId != null">#{taskId},</if>
2023-12-10 17:30:51 +08:00
<if test="typeId != null">#{typeId},</if>
<if test="maCode != null">#{maCode},</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.sgzb.material.domain.PurchaseMacodeInfo">
update purchase_macode_info
<trim prefix="SET" suffixOverrides=",">
2023-12-15 15:29:41 +08:00
<if test="taskId != null">task_id = #{taskId},</if>
2023-12-10 17:30:51 +08:00
<if test="typeId != null">type_id = #{typeId},</if>
<if test="maCode != null">ma_code = #{maCode},</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>
2023-12-15 15:29:41 +08:00
where id = #{id}
2023-12-10 17:30:51 +08:00
</update>
<delete id="deletePurchaseMacodeInfoByTaskId" parameterType="Long">
delete from purchase_macode_info where task_id = #{taskId}
</delete>
<delete id="deletePurchaseMacodeInfoByTaskIds" parameterType="String">
delete from purchase_macode_info where task_id in
<foreach item="taskId" collection="array" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
2023-12-15 09:16:47 +08:00
<select id="getTypeByTypeId" resultType="com.alibaba.fastjson.JSONObject">
2023-12-21 20:28:01 +08:00
select code specsCode,model_code modelCode,type_name specsName from ma_type
where type_id = #{typeId}
2023-12-15 09:16:47 +08:00
</select>
<select id="getSerialNumber" resultType="int">
select count(*) from ma_machine where type_id = #{typeId} and DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{nowDate},'%y%m')
</select>
2023-12-15 15:29:41 +08:00
<select id="getTypeNameByTypeId" resultType="com.alibaba.fastjson.JSONObject">
select mt.type_name specsName,mt1.type_name typeName,mt2.type_name itemTypeName from ma_type mt
left join (select type_id,type_name,parent_id from ma_type
where type_id in (select parent_id from ma_type where type_id = #{typeId})) mt1 on mt.parent_id = mt1.type_id
left join (select type_id,type_name from ma_type
where type_id in
(select parent_id from ma_type
where type_id in (select parent_id from ma_type where type_id = #{typeId}))) mt2 on mt1.parent_id = mt2.type_id
where mt.type_id = #{typeId}
</select>
<delete id="deletePurchaseMacodeInfoById">
delete from purchase_macode_info where id = #{id}
</delete>
2023-12-21 20:28:01 +08:00
<delete id="deletePurchaseMacodeInfoByMaCode">
delete from purchase_macode_info where ma_code = #{maCode}
</delete>
<delete id="deleteMaMachineInfoByMaCode">
delete from ma_machine where ma_code = #{maCode}
</delete>
2023-12-15 15:29:41 +08:00
<select id="selectMachineByAssetsCode" resultType="com.bonus.sgzb.base.api.domain.MaMachine">
select ma_id, type_id, ma_code, pre_code, ma_status, qr_code, buy_price, ma_vender, out_fac_time, out_fac_code,
assets_code, check_man, this_check_time, next_check_time, gps_code, rfid_code, erp_code, transfer_code,
in_out_num, buy_task, own_house ,company_id
from ma_machine
where assets_code = #{fixCode}
</select>
<insert id="maMachineAdd">
insert into ma_machine (
<if test="typeId != null and typeId != '' ">type_id,</if>
<if test="maCode != null and maCode != '' ">ma_code,</if>
<if test="preCode != null and preCode != '' ">pre_code,</if>
<if test="maStatus != null and maStatus != '' ">ma_status,</if>
<if test="qrCode != null and qrCode != ''">qr_code,</if>
<if test="buyPrice != null and buyPrice != ''">buy_price,</if>
<if test="maVender != null and maVender != ''">ma_vender,</if>
<if test="outFacTime != null and outFacTime != ''">out_fac_time,</if>
<if test="outFacCode != null and outFacCode != ''">out_fac_code,</if>
<if test="assetsCode != null and assetsCode != ''">assets_code,</if>
<if test="checkMan != null and checkMan != ''">check_man,</if>
<if test="thisCheckTime != null and thisCheckTime != ''">this_check_time,</if>
<if test="nextCheckTime != null and nextCheckTime != ''">next_check_time,</if>
<if test="gpsCode != null and gpsCode != ''">gps_code,</if>
<if test="rfidCode != null and rfidCode != ''">rfid_code,</if>
<if test="erpCode != null and erpCode != ''">erp_code,</if>
<if test="transferCode != null and transferCode != ''">transfer_code,</if>
<if test="inOutNum != null and inOutNum != ''">in_out_num,</if>
<if test="buyTask != null and buyTask != ''">buy_task,</if>
<if test="ownHouse != null and ownHouse != ''">own_house,</if>
2023-12-21 20:28:01 +08:00
<if test="companyId != null and companyId != ''">company_id,</if>
<if test="createTime != null">create_time</if>
2023-12-15 15:29:41 +08:00
)values(
<if test="typeId != null and typeId != ''">#{typeId},</if>
<if test="maCode != null and maCode != ''">#{maCode},</if>
<if test="preCode != null and preCode != ''">#{preCode},</if>
<if test="maStatus != null and maStatus != ''">#{maStatus},</if>
<if test="qrCode != null and qrCode != ''">#{qrCode},</if>
<if test="buyPrice != null and buyPrice != ''">#{buyPrice},</if>
<if test="maVender != null and maVender != ''">#{maVender},</if>
<if test="outFacTime != null and outFacTime != ''">#{outFacTime},</if>
<if test="outFacCode != null and outFacCode != ''">#{outFacCode},</if>
<if test="assetsCode != null and assetsCode != ''">#{assetsCode},</if>
<if test="checkMan != null and checkMan != ''">#{checkMan},</if>
<if test="thisCheckTime != null and thisCheckTime != ''">#{thisCheckTime},</if>
<if test="nextCheckTime != null and nextCheckTime != ''">#{nextCheckTime},</if>
<if test="gpsCode != null and gpsCode != ''">#{gpsCode},</if>
<if test="rfidCode != null and rfidCode != ''">#{rfidCode},</if>
<if test="erpCode != null and erpCode != ''">#{erpCode},</if>
<if test="transferCode != null and transferCode != ''">#{transferCode},</if>
<if test="inOutNum != null and inOutNum != ''">#{inOutNum},</if>
<if test="buyTask != null and buyTask != ''">#{buyTask},</if>
<if test="ownHouse != null and ownHouse != ''">#{ownHouse},</if>
2023-12-21 20:28:01 +08:00
<if test="companyId != null and companyId != ''">#{companyId},</if>
<if test="createTime != null">#{createTime}</if>
2023-12-15 15:29:41 +08:00
)
</insert>
<select id="selectMacodeInfoStatusByTaskId" resultType="java.lang.Integer">
select count(*) from purchase_macode_info where task_id = #{taskId} and status != '54'
</select>
<insert id="insertMaInputRecord" parameterType="com.bonus.sgzb.material.domain.MaInputRecord" useGeneratedKeys="true" keyProperty="id">
insert into ma_input_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">task_id,</if>
<if test="typeId != null">type_id,</if>
<if test="maId != null">ma_id,</if>
<if test="inputType != null">input_type,</if>
<if test="inputNum != null">input_num,</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="maId != null">#{maId},</if>
<if test="inputType != null">#{inputType},</if>
<if test="inputNum != null">#{inputNum},</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>
2023-12-16 20:55:40 +08:00
<select id="selectTypeByTypeId" resultType="com.bonus.sgzb.base.api.domain.MaType">
select type_id typeId, type_name, parent_id, status, num, unit_id, manage_type, lease_price, buy_price, pay_price,
level, rated_load, test_load, holding_time, warn_num, del_flag, create_by,
create_time, remark, company_id
from ma_type where type_id = #{typeId}
</select>
2023-12-21 20:28:01 +08:00
<select id="selectMachineByMaCode" resultType="java.lang.Integer">
select count(*) from ma_machine where ma_code = #{codingRule}
</select>
<select id="selectPurchaseMacodeInfo" resultType="com.bonus.sgzb.material.domain.PurchaseMacodeInfo">
select pcd.production_time productionTime,mt.type_name specificationType, mt1.type_name typeName, pmi.ma_code maCode,
mm.assets_code assetsCode ,pmi.fix_code fixCode,pcd.type_id typeId,pcd.task_id taskId, mt.code specsCode,mt1.code typeCode
from purchase_macode_info pmi
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.ma_code = mm.ma_code
left join ma_type mt on pcd.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where pmi.task_id = #{taskId} and pmi.type_id = #{typeId}
<if test="productionTime != null">pcd.production_time = #{productionTime}</if>
</select>
2023-12-16 20:55:40 +08:00
<update id="updateTypeByTypeId">
update ma_type set num = #{num} where type_id = #{typeId}
</update>
<update id="updateMaMachine">
update ma_machine set ma_status = #{maStatus} where ma_id = #{maId}
</update>
2023-12-10 17:30:51 +08:00
</mapper>