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

254 lines
13 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.PurchaseCheckInfoMapper">
<resultMap type="com.bonus.sgzb.material.domain.PurchaseCheckInfo" id="PurchaseCheckInfoResult">
2023-12-15 15:29:41 +08:00
<result property="id" column="id" />
2023-12-10 17:30:51 +08:00
<result property="taskId" column="task_id" />
<result property="purchaseTime" column="purchase_time" />
<result property="arrivalTime" column="arrival_time" />
<result property="purchaser" column="purchaser" />
<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="selectPurchaseCheckInfoVo">
2023-12-15 15:29:41 +08:00
select id,task_id, purchase_time, arrival_time, purchaser, create_by, create_time, update_by, update_time, remark, company_id from purchase_check_info
2023-12-10 17:30:51 +08:00
</sql>
<select id="selectPurchaseCheckInfoList" parameterType="com.bonus.sgzb.material.domain.PurchaseCheckInfo" resultMap="PurchaseCheckInfoResult">
2024-03-06 17:59:51 +08:00
select pci.id,pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.create_by, pci.create_time,
pci.update_by,
pci.update_time, pci.remark, pci.company_id ,dict.name purchasingStatus,tk.code,su.user_name
purchaserName,tk.task_status taskStatus
2023-12-13 18:08:38 +08:00
from purchase_check_info pci
left join tm_task tk on pci.task_id = tk.task_id
left join (select id,name from sys_dic where p_id = 23) dict on tk.task_status = dict.id
2023-12-21 20:28:01 +08:00
left join sys_user su on pci.purchaser = su.user_id
2024-03-06 17:59:51 +08:00
LEFT JOIN purchase_check_details pcd on pcd.task_id=pci.task_id
2023-12-23 14:31:54 +08:00
where task_type = 23
2024-03-06 17:59:51 +08:00
<if test="keyWord != null and keyWord != ''">
and (tk.code like concat('%',#{keyWord},'%') or
su.user_name like concat('%',#{keyWord},'%')
)
</if>
<if test="purchaseTime != null and purchaseTime != ''">and pci.purchase_time = #{purchaseTime}</if>
<if test="arrivalTime != null and arrivalTime != ''">and pci.arrival_time = #{arrivalTime}</if>
<if test="purchaser != null ">and pci.purchaser = #{purchaser}</if>
<if test="companyId != null ">and pci.company_id = #{companyId}</if>
<if test="typeId != null">AND #{typeId} IN (SELECT mt2.type_id
FROM purchase_check_details pcd
LEFT JOIN ma_type mt on mt.type_id=pcd.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
WHERE pcd.task_id = pci.task_id
)
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND ((pci.purchase_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59'))
or (pci.arrival_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')))
</if>
GROUP BY pcd.task_id
2023-12-21 20:28:01 +08:00
order by pci.create_time desc
2023-12-10 17:30:51 +08:00
</select>
<select id="selectPurchaseCheckInfoByTaskId" parameterType="Long" resultMap="PurchaseCheckInfoResult">
2023-12-16 20:55:40 +08:00
select pci.id,pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.create_by, pci.create_time,
pci.update_by, pci.update_time, pci.remark, pci.company_id, tk.code
from purchase_check_info pci
left join tm_task tk on pci.task_id = tk.task_id
where pci.task_id = #{taskId}
2023-12-10 17:30:51 +08:00
</select>
<insert id="insertPurchaseCheckInfo" parameterType="com.bonus.sgzb.material.domain.PurchaseCheckInfo" useGeneratedKeys="true" keyProperty="taskId">
insert into purchase_check_info
<trim prefix="(" suffix=")" suffixOverrides=",">
2023-12-13 18:08:38 +08:00
<if test="taskId != null">task_id,</if>
2023-12-10 17:30:51 +08:00
<if test="purchaseTime != null and purchaseTime != ''">purchase_time,</if>
<if test="arrivalTime != null">arrival_time,</if>
<if test="purchaser != null">purchaser,</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-13 18:08:38 +08:00
<if test="taskId != null">#{taskId},</if>
2023-12-10 17:30:51 +08:00
<if test="purchaseTime != null and purchaseTime != ''">#{purchaseTime},</if>
<if test="arrivalTime != null">#{arrivalTime},</if>
<if test="purchaser != null">#{purchaser},</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="updatePurchaseCheckInfo" parameterType="com.bonus.sgzb.material.domain.PurchaseCheckInfo">
update purchase_check_info
<trim prefix="SET" suffixOverrides=",">
<if test="purchaseTime != null and purchaseTime != ''">purchase_time = #{purchaseTime},</if>
<if test="arrivalTime != null">arrival_time = #{arrivalTime},</if>
<if test="purchaser != null">purchaser = #{purchaser},</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 task_id = #{taskId}
</update>
<delete id="deletePurchaseCheckInfoByTaskId" parameterType="Long">
delete from purchase_check_info where task_id = #{taskId}
</delete>
<delete id="deletePurchaseCheckInfoByTaskIds" parameterType="String">
delete from purchase_check_info where task_id in
<foreach item="taskId" collection="array" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
2023-12-13 18:08:38 +08:00
<select id="selectTypeNameByTaskId" resultType="java.lang.String">
select GROUP_CONCAT(type_name) typeName from
2024-02-01 10:00:10 +08:00
(select distinct pcd.task_id, mt1.type_name
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
where pcd.task_id = #{taskId}
<if test="type == 2">and pcd.`status`!=3</if>
) t
2023-12-13 18:08:38 +08:00
GROUP BY task_id
</select>
2023-12-15 09:16:47 +08:00
<insert id="insertBmNoticeInfo" parameterType="com.bonus.sgzb.material.domain.BmNoticeInfo" useGeneratedKeys="true" keyProperty="id">
insert into bm_notice_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">task_id,</if>
<if test="content != null and content != ''">content,</if>
<if test="noticeUser != null">notice_user,</if>
<if test="phone != null">phone,</if>
<if test="modelName != null">model_name,</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="content != null and content != ''">#{content},</if>
<if test="noticeUser != null">#{noticeUser},</if>
<if test="phone != null">#{phone},</if>
<if test="modelName != null">#{modelName},</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-15 15:29:41 +08:00
<select id="selectPutInListList" resultMap="PurchaseCheckInfoResult">
select pci.id,pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.create_by, pci.create_time, pci.update_by,
2023-12-23 15:57:50 +08:00
pci.update_time, pci.remark, pci.company_id ,dict.name purchasingStatus,tk.code,tk.task_status taskStatus,su.user_name purchaserName,
2024-01-22 19:56:33 +08:00
tk.create_by,
CASE tk.task_status
WHEN 28 THEN
tk.update_time
ELSE
''
END as inputTime,
CASE tk.task_status
WHEN 28 THEN
us.user_name
ELSE
''
END as inputUser
2023-12-15 15:29:41 +08:00
from purchase_check_info pci
left join tm_task tk on pci.task_id = tk.task_id
left join (select id,name from sys_dic where p_id = 50) dict on tk.task_status = dict.id
2023-12-23 11:45:38 +08:00
left join sys_user su on pci.purchaser = su.user_id
2024-01-22 19:56:33 +08:00
LEFT JOIN sys_user us on us.user_id = tk.update_by
2023-12-21 20:28:01 +08:00
where task_type = 23 and tk.task_status in (26,28)
2023-12-24 17:45:49 +08:00
<if test="keyWord != null and keyWord != ''"> and tk.code like concat('%',#{keyWord},'%')</if>
2023-12-15 15:29:41 +08:00
<if test="purchaseTime != null and purchaseTime != ''"> and pci.purchase_time = #{purchaseTime}</if>
<if test="arrivalTime != null and arrivalTime != ''"> and pci.arrival_time = #{arrivalTime}</if>
<if test="purchaser != null "> and pci.purchaser = #{purchaser}</if>
<if test="companyId != null "> and pci.company_id = #{companyId}</if>
2023-12-22 19:14:59 +08:00
order by pci.id desc
2023-12-15 15:29:41 +08:00
</select>
2024-01-08 14:17:38 +08:00
<select id="exportList" resultType="com.bonus.sgzb.material.domain.PurchaseCheckInfo">
SELECT
tk.CODE,
pci.purchase_time as purchaseTime,
pci.arrival_time as arrivalTime,
su.user_name purchaserName,
mt1.type_name as purchasingTypeName,
mt.type_name AS purchasingTypeCode,
mt.manage_type as manageType,
msi.supplier,
pcd.purchase_num as purchaseNum,
pcd.check_num as checkNum,
dict.NAME AS purchasingStatus,
tk.task_status as taskStatus
FROM
purchase_check_details pcd
LEFT JOIN purchase_check_info pci ON pci.task_id = pcd.task_id
LEFT JOIN tm_task tk ON pci.task_id = tk.task_id
LEFT JOIN ( SELECT id, NAME FROM sys_dic WHERE p_id = 23 ) dict ON tk.task_status = dict.id
LEFT JOIN sys_user su ON pci.purchaser = su.user_id
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 ma_supplier_info msi ON msi.supplier_id = pcd.supplier_id
WHERE
task_type = 23
<if test="keyWord != null and keyWord != ''"> and tk.code like concat('%',#{keyWord},'%')</if>
<if test="purchaseTime != null and purchaseTime != ''"> and pci.purchase_time = #{purchaseTime}</if>
<if test="arrivalTime != null and arrivalTime != ''"> and pci.arrival_time = #{arrivalTime}</if>
<if test="purchaser != null "> and pci.purchaser = #{purchaser}</if>
<if test="companyId != null "> and pci.company_id = #{companyId}</if>
ORDER BY
pcd.task_id DESC
</select>
<select id="putInExportList" resultType="com.bonus.sgzb.material.domain.PurchaseInput">
SELECT pcd.task_id as taskId,
tk.`code`,
pci.purchase_time as purchaseTime,
pci.arrival_time as arrivalTime,
pci.purchaser,
su.user_name purchaserName,
mt1.type_name as purchasingTypeName,
mt.type_name as purchasingTypeCode,
pcd.input_time as inputTime,
su.user_name as inputUser,
pcd.input_status as inputStatus
FROM purchase_check_details pcd
LEFT JOIN purchase_check_info pci on pci.task_id = pcd.task_id
left join tm_task tk on pcd.task_id = tk.task_id
left join sys_user su on pci.purchaser = su.user_id
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 task_type = 23
and tk.task_status in (26, 28)
<if test="keyWord != null and keyWord != ''"> and tk.code like concat('%',#{keyWord},'%')</if>
<if test="purchaseTime != null and purchaseTime != ''"> and pci.purchase_time = #{purchaseTime}</if>
<if test="arrivalTime != null and arrivalTime != ''"> and pci.arrival_time = #{arrivalTime}</if>
<if test="purchaser != null "> and pci.purchaser = #{purchaser}</if>
<if test="companyId != null "> and pci.company_id = #{companyId}</if>
ORDER BY pcd.task_id desc
</select>
2023-12-10 17:30:51 +08:00
</mapper>