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

571 lines
28 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">
2024-04-26 17:58:14 +08:00
select pcd.task_id, pcd.type_id, pmi.qr_code, pmi.fix_code, pmi.code_type, pmi.status,
2023-12-22 19:14:59 +08:00
pmi.remark, pmi.company_id, mt.type_name specificationType, pt.arrival_time arrivalTime,
2023-12-21 20:28:01 +08:00
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-22 19:14:59 +08:00
and mt.manage_type = '0'
2024-02-01 10:00:10 +08:00
and pcd.`status`!=3
and pcd.`status`!=5
2023-12-15 15:29:41 +08:00
<if test="typeId != null "> and pmi.type_id = #{typeId}</if>
2023-12-24 17:45:49 +08:00
<if test="keyWord != null and keyWord != ''">and (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
2024-02-01 10:00:10 +08:00
<delete id="deleteMaMachineInfoByMaId">
delete from ma_machine where ma_id = #{maId}
</delete>
<update id="updatetePurchaseMaCodeInfoByMaCodeAndTaskIdAndTypeId">
update
purchase_macode_info
set status='2'
where ma_code = #{maCode}
and task_id = #{taskId}
and type_id = #{typeId}
</update>
<delete id="deleteMaMachineLabelByMaId">
delete from ma_machine_label where ma_id = #{maId}
</delete>
<delete id="deleteMaLabelBindByMaId">
delete from ma_label_bind where ma_id = #{maId}
</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>
2023-12-23 20:52:59 +08:00
<insert id="maMachineAdd" parameterType="com.bonus.sgzb.base.api.domain.MaMachine" useGeneratedKeys="true" keyProperty="maId">
2023-12-15 15:29:41 +08:00
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">
2024-02-20 14:01:15 +08:00
select count(*) from purchase_check_details where task_id = #{taskId} and status ='1'
2023-12-15 15:29:41 +08:00
</select>
2024-08-06 17:05:54 +08:00
<insert id="insertMaInputRecord" parameterType="com.bonus.sgzb.base.api.domain.MaInputRecord" useGeneratedKeys="true" keyProperty="id">
2023-12-15 15:29:41 +08:00
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-23 14:31:54 +08:00
<insert id="insertMaMachineLabel" parameterType="com.bonus.sgzb.base.api.domain.MaMachineLabel" useGeneratedKeys="true" keyProperty="labelId">
insert into ma_machine_label
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="labelCode != null">label_code,</if>
<if test="maId != null">ma_id,</if>
<if test="isBind != null">is_bind,</if>
<if test="labelType != null">label_type,</if>
<if test="companyId != null">company_id,</if>
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="labelCode != null">#{labelCode},</if>
<if test="maId != null">#{maId},</if>
<if test="isBind != null">#{isBind},</if>
<if test="labelType != null">#{labelType},</if>
<if test="companyId != null">#{companyId},</if>
now()
</trim>
</insert>
2023-12-23 20:52:59 +08:00
<insert id="insertMaLabelBind">
insert into ma_label_bind
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="maId != null">ma_id,</if>
<if test="labelCode != null">label_code,</if>
<if test="typeId != null">type_id,</if>
<if test="binder != null">binder,</if>
<if test="labelType != null">label_type,</if>
<if test="companyId != null">company_id,</if>
2023-12-23 21:31:33 +08:00
<if test="bindTime != null">bind_time,</if>
2023-12-23 20:52:59 +08:00
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="maId != null">#{maId},</if>
<if test="labelCode != null">#{labelCode},</if>
<if test="typeId != null">#{typeId},</if>
<if test="binder != null">#{binder},</if>
<if test="labelType != null">#{labelType},</if>
<if test="companyId != null">#{companyId},</if>
<if test="bindTime != null">#{bindTime},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
2023-12-24 00:13:14 +08:00
<insert id="insertInputApplyDetails" parameterType="com.bonus.sgzb.material.domain.InputApplyDetails" useGeneratedKeys="true" keyProperty="id">
insert into input_apply_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">task_id,</if>
<if test="maId != null">ma_id,</if>
<if test="typeId != null">type_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="inputNum != null">input_num,</if>
<if test="inputType != null">input_type,</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="maId != null">#{maId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="inputNum != null">#{inputNum},</if>
<if test="inputType != null">#{inputType},</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-22 19:14:59 +08:00
<select id="selectPutinDetails" resultType="com.bonus.sgzb.material.domain.PurchaseMacodeInfo">
2024-08-07 17:12:40 +08:00
select pcd.production_time as productionTime,
mt.type_name as specificationType,
mt1.type_name as typeName,
2024-04-07 15:52:57 +08:00
mt.manage_type as manageType,
2024-08-07 17:12:40 +08:00
pmi.ma_code as maCode,
mm.assets_code as assetsCode,
pmi.fix_code as fixCode,
pcd.type_id as typeId,
pcd.task_id as taskId,
mt.code as specsCode,
mt.num as num,
mt1.code as typeCode,
2024-02-20 14:01:15 +08:00
CASE
WHEN pmi.ma_code is null THEN
CASE
WHEN pcd.status = 4 THEN 1
WHEN pcd.status = 5 THEN 2
ELSE 0
END
ELSE pmi.status
2024-08-07 17:12:40 +08:00
END AS status,
mm.qr_code as qrCode,
mm.ma_id as maId,
2024-02-20 14:01:15 +08:00
if(pmi.ma_code is not null, 1, pcd.check_num) checkNum
2023-12-22 19:14:59 +08:00
from purchase_check_details pcd
2024-08-07 17:12:40 +08:00
left join purchase_macode_info pmi on pmi.task_id = pcd.task_id and pmi.type_id = pcd.type_id
LEFT JOIN ma_type_keeper mtk on pcd.type_id = mtk.type_id
2024-02-20 14:01:15 +08:00
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
2023-12-22 19:14:59 +08:00
where pcd.task_id = #{taskId}
2024-03-20 11:17:46 +08:00
and pcd.`status`!=3 and pcd.`status`!=7
2024-08-07 17:12:40 +08:00
<if test="userId != 1">
and mtk.user_id = #{userId}
</if>
2024-02-20 14:01:15 +08:00
<if test="dictName != null and dictName != ''">
and (mt.type_name like concat('%',#{dictName},'%') or
mt1.type_name like concat('%',#{dictName},'%'))
</if>
2024-04-30 14:32:17 +08:00
order by status, pmi.id
2023-12-22 19:14:59 +08:00
</select>
<select id="selectMaCode" resultType="java.lang.Integer">
select count(ma_id) from ma_machine where ma_code = #{maCode}
</select>
2023-12-23 14:31:54 +08:00
<select id="selectLableNumByMonth" resultType="java.lang.Integer">
select count(*)
from ma_machine_label
where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{nowDate},'%y%m')
</select>
2024-02-20 14:01:15 +08:00
<select id="warehousingEntry" resultType="com.bonus.sgzb.material.domain.PurchaseMacodeInfo">
SELECT
*
FROM
(
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,
2024-04-20 11:23:08 +08:00
pci.remark remark,
2024-02-20 14:01:15 +08:00
mt.CODE specsCode,
2024-04-03 17:20:33 +08:00
mt.unit_name unitName,
2024-02-20 14:01:15 +08:00
mt1.CODE typeCode,
CASE
WHEN pmi.ma_code IS NULL THEN
CASE
WHEN pcd.STATUS = 4 THEN
1
WHEN pcd.STATUS = 5 THEN
2 ELSE 0
END ELSE pmi.STATUS
END AS STATUS,
mm.qr_code qrCode,
mm.ma_id maId,
IF
( pmi.ma_code IS NOT NULL, 1, pcd.check_num ) checkNum
FROM
purchase_check_details pcd
2024-04-20 11:23:08 +08:00
LEFT JOIN purchase_check_info pci on pci.task_id=pcd.task_id
2024-02-20 14:01:15 +08:00
LEFT JOIN purchase_macode_info pmi 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
pcd.task_id = #{taskId}
AND pcd.`status` != 3
<if test="dictName != null and dictName != ''">
and (mt.type_name like concat('%',#{dictName},'%') or
mt1.type_name like concat('%',#{dictName},'%'))
</if>
ORDER BY
STATUS
) aa
WHERE
`status` != 0
AND `status` !=2
</select>
2024-03-20 14:10:41 +08:00
<select id="selectPutinDetailsAddTypeId" resultType="com.bonus.sgzb.material.domain.PurchaseMacodeInfo">
select pcd.production_time productionTime,
2024-03-20 14:14:49 +08:00
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,
CASE
WHEN pmi.ma_code is null THEN
CASE
WHEN pcd.status = 4 THEN 1
WHEN pcd.status = 5 THEN 2
ELSE 0
END
ELSE pmi.status
END AS status,
mm.qr_code qrCode,
mm.ma_id maId,
if(pmi.ma_code is not null, 1, pcd.check_num) checkNum
2024-03-20 14:10:41 +08:00
from purchase_check_details pcd
2024-03-20 14:14:49 +08:00
left join purchase_macode_info pmi 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 pcd.task_id = #{taskId} and mt.type_id = #{typeId}
and pcd.`status`!=3 and pcd.`status`!=7
<if test="dictName != null and dictName != ''">
and (mt.type_name like concat('%',#{dictName},'%') or
mt1.type_name like concat('%',#{dictName},'%'))
</if>
2024-03-20 14:10:41 +08:00
order by status
</select>
2024-03-22 18:00:57 +08:00
<select id="isOperateAll" resultType="java.lang.Integer">
2024-04-11 18:28:20 +08:00
SELECT count(*)
FROM (SELECT CASE
WHEN
pmi.ma_code IS NOT NULL THEN
CASE
WHEN pmi.STATUS = 0 THEN
1
WHEN pmi.STATUS = 1 THEN
4
WHEN pmi.STATUS = 2 THEN
5
ELSE 1
END
ELSE pcd.STATUS
END AS STATUS
FROM purchase_check_details pcd
LEFT JOIN purchase_macode_info pmi 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
WHERE pcd.task_id = #{taskId}) aa
WHERE (STATUS = 1 OR STATUS = 6)
2024-03-22 18:00:57 +08:00
</select>
<select id="selectPurchaseCheckDetailsStatus" resultType="java.lang.Integer">
SELECT
count(*)
FROM
purchase_check_details
WHERE
task_id = #{taskId} and status =4
</select>
2024-04-30 09:09:34 +08:00
<select id="selectPurchaseMacodeInfoListDetails" resultType="com.bonus.sgzb.material.domain.PurchaseMacodeInfo">
SELECT
mt.type_name specificationType,
mt1.type_name typeName,
pmi.ma_code maCode,
mm.assets_code assetsCode
FROM
purchase_check_details pcd
LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN purchase_macode_info pmi ON pmi.task_id = pcd.task_id
2024-06-13 17:52:10 +08:00
and pmi.type_id = pcd.type_id
2024-04-30 09:09:34 +08:00
LEFT JOIN ma_machine mm on mm.ma_code = pmi.ma_code
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}
2024-06-13 17:52:10 +08:00
AND pcd.type_id = #{typeId}
2024-04-30 09:09:34 +08:00
AND mt.manage_type = '0'
AND pcd.`status` != 3
AND pcd.`status` != 5
</select>
2024-06-12 17:43:04 +08:00
<select id="selectKeepUser" resultType="java.lang.String">
SELECT user_id FROM ma_type_keeper WHERE type_id = #{typeId}
</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-22 19:14:59 +08:00
<update id="updateMacodeByType">
2024-04-20 16:58:15 +08:00
update purchase_macode_info
set status = #{status}
where task_id = #{taskId}
and type_id = #{typeId}
and ma_code = #{maCode}
2023-12-22 19:14:59 +08:00
</update>
2024-04-23 17:36:00 +08:00
<update id="updateMaTypeNum">
UPDATE ma_type
SET num = ifnull( num, 0 ) + #{partNum} WHERE type_id = #{typeId}
</update>
2023-12-10 17:30:51 +08:00
</mapper>