Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml

260 lines
12 KiB
XML
Raw Normal View History

2024-09-27 15:48:39 +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.task.mapper.TmTaskMapper">
<resultMap type="com.bonus.material.task.domain.TmTask" id="TmTaskResult">
<result property="taskId" column="task_id" />
<result property="taskType" column="task_type" />
<result property="taskStatus" column="task_status" />
<result property="code" column="code" />
<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" />
<result property="status" column="status" />
<result property="monthOrder" column="month_order" />
2024-09-27 15:48:39 +08:00
</resultMap>
<sql id="selectTmTaskVo">
select task_id, task_type, task_status, code, create_by, create_time,
2024-11-10 21:41:12 +08:00
update_by, update_time, remark, company_id, status, month_order
from tm_task
2024-09-27 15:48:39 +08:00
</sql>
2024-10-23 17:54:39 +08:00
2024-09-27 15:48:39 +08:00
<select id="selectTmTaskList" parameterType="com.bonus.material.task.domain.TmTask" resultMap="TmTaskResult">
<include refid="selectTmTaskVo"/>
<where>
<if test="taskType != null "> and task_type = #{taskType}</if>
<if test="taskStatus != null "> and task_status = #{taskStatus}</if>
<if test="code != null and code != ''"> and code = #{code}</if>
2024-11-10 21:41:12 +08:00
<if test="monthOrder != null and code != ''"> and month_order = #{monthOrder}</if>
2024-09-27 15:48:39 +08:00
<if test="companyId != null "> and company_id = #{companyId}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectTmTaskByTaskId" parameterType="Long" resultMap="TmTaskResult">
<include refid="selectTmTaskVo"/>
where task_id = #{taskId}
</select>
<insert id="insertTmTask" parameterType="com.bonus.material.task.domain.TmTask" useGeneratedKeys="true" keyProperty="taskId">
insert into tm_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskType != null">task_type,</if>
<if test="taskStatus != null">task_status,</if>
<if test="code != null">`code`,</if>
2024-11-10 21:41:12 +08:00
<if test="monthOrder != null">month_order,</if>
2024-09-27 15:48:39 +08:00
<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>
<if test="status != null">`status`,</if>
2024-09-27 15:48:39 +08:00
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskType != null">#{taskType},</if>
<if test="taskStatus != null">#{taskStatus},</if>
<if test="code != null">#{code},</if>
2024-11-10 21:41:12 +08:00
<if test="monthOrder != null">#{monthOrder},</if>
2024-09-27 15:48:39 +08:00
<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>
<if test="status != null">#{status},</if>
</trim>
</insert>
<update id="updateTmTask" parameterType="com.bonus.material.task.domain.TmTask">
update tm_task
<trim prefix="SET" suffixOverrides=",">
<if test="taskType != null">task_type = #{taskType},</if>
<if test="taskStatus != null">task_status = #{taskStatus},</if>
<if test="code != null">code = #{code},</if>
2024-11-10 21:41:12 +08:00
<if test="monthOrder != null">month_order = #{monthOrder},</if>
2024-09-27 15:48:39 +08:00
<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>
<if test="status != null">`status` = #{status},</if>
2024-09-27 15:48:39 +08:00
</trim>
where task_id = #{taskId}
</update>
2024-10-21 18:40:35 +08:00
<update id="updateStatusById">
2024-10-23 14:57:50 +08:00
update tm_task set task_status = #{updatedStatus} where task_id = #{id}
2024-10-21 18:40:35 +08:00
</update>
2024-09-27 15:48:39 +08:00
<delete id="deleteTmTaskByTaskId" parameterType="Long">
delete from tm_task where task_id = #{taskId}
</delete>
<delete id="deleteTmTaskByTaskIds" parameterType="String">
delete from tm_task where task_id in
<foreach item="taskId" collection="array" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
2024-11-13 09:57:43 +08:00
select COALESCE(max(month_order), 0) from tm_task
where
month(create_time) = #{month} and year(create_time) = #{year}
2024-11-10 21:41:12 +08:00
<if test="taskType != null and taskType !=''">
and task_type = #{taskType}
</if>
</select>
<update id="updateTmTaskStatusByTaskId">
update tm_task set task_status = #{newTaskStatus}
2024-11-08 12:24:25 +08:00
where task_id = #{taskId}
</update>
2024-11-10 21:41:12 +08:00
<delete id="deleteTmTaskByPurchaseIds" parameterType="String">
delete from tm_task where task_id in
(
select task_id from purchase_check_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
)
</delete>
2024-11-13 10:19:50 +08:00
<select id="getAuditListByLeaseTmTask" resultType="com.bonus.material.task.domain.vo.TmTaskRequestVo">
SELECT DISTINCT
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,
bpl.lot_id as proId,bpl.lot_name as proName,
bui.unit_id as unitId,bui.unit_name as unitName,
lai.lease_person as leasePerson, lai.phone as leasePhone, tt.create_by as applyFor,d.`name` as taskName,lai.lease_type as leaseType,lai.estimate_lease_time as estimateLeaseTime,
case when d.id = '31' then lai.company_audit_remark
when d.id = '32' then lai.dept_audit_remark
when d.id = '33' then lai.direct_audit_remark
when d.id = '98' then lai.company_audit_remark
when d.id = '99' then lai.dept_audit_remark
when d.id = '100' then lai.direct_audit_remark
end examineStatus,
d.id as examineStatusId,
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
LEFT JOIN sys_user su ON tt.create_by = su.user_name
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1'
<if test="record.taskId != null and record.taskId != '' ">
AND tt.task_id = #{record.taskId}
</if>
<if test="record.startTime != null and record.startTime != '' and record.endTime != null and record.endTime != '' ">
AND tt.update_time BETWEEN CONCAT(#{record.startTime}, ' 00:00:00') AND CONCAT(#{record.endTime}, ' 23:59:59')
</if>
<if test="record.unitId != null and record.unitId != ''">
AND bui.unit_id = #{record.unitId}
</if>
<if test="record.projectId != null and record.projectId != ''">
AND bpl.lot_id = #{record.projectId}
</if>
<if test="record.keyWord != null and record.keyWord != ''">
AND (bai.agreement_code like concat('%', #{record.keyWord}, '%') or
tt.code like concat('%', #{record.keyWord}, '%'))
</if>
GROUP BY tt.task_id
ORDER BY tt.update_time DESC
</select>
<select id="getAuditListByLeaseTmTaskByPeople" resultType="com.bonus.material.task.domain.vo.TmTaskRequestVo">
SELECT DISTINCT
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,
bpl.lot_id as proId,bpl.lot_name as proName,
bui.unit_id as unitId,bui.unit_name as unitName,
lai.lease_person as leasePerson, lai.phone as leasePhone, tt.create_by as applyFor,d.`name` as taskName,lai.lease_type as leaseType,lai.estimate_lease_time as estimateLeaseTime,
case when d.id = '31' then lai.company_audit_remark
when d.id = '32' then lai.dept_audit_remark
when d.id = '33' then lai.direct_audit_remark
when d.id = '98' then lai.company_audit_remark
when d.id = '99' then lai.dept_audit_remark
when d.id = '100' then lai.direct_audit_remark
end examineStatus ,
d.id as examineStatusId,
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
LEFT JOIN sys_user su ON tt.create_by = su.user_name
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1' and tt.create_by = #{record.createBy}
<if test="record.taskId != null and record.taskId != '' ">
AND tt.task_id = #{record.taskId}
</if>
<if test="record.startTime != null and record.startTime != '' and record.endTime != null and record.endTime != '' ">
AND tt.update_time BETWEEN CONCAT(#{record.startTime}, ' 00:00:00') AND CONCAT(#{record.endTime}, ' 23:59:59')
</if>
<if test="record.unitId != null and record.unitId != ''">
AND bui.unit_id = #{record.unitId}
</if>
<if test="record.projectId != null and record.projectId != ''">
AND bpl.lot_id = #{record.projectId}
</if>
<if test="record.keyWord != null and record.keyWord != ''">
AND (bai.agreement_code like concat('%', #{record.keyWord}, '%') or
tt.code like concat('%', #{record.keyWord}, '%'))
</if>
GROUP BY tt.task_id
ORDER BY tt.update_time DESC
</select>
<select id="getAuditListByLeaseInfo" resultType="com.bonus.material.lease.domain.LeaseApplyInfo">
SELECT
lai.*
FROM
lease_apply_info lai
WHERE
lai.task_id = #{record.taskId} AND lai.`code` = #{record.code}
</select>
<select id="getLeaseApplyDetails" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
lad.*, mt.type_name AS typeModelName, mt1.type_name AS typeName,mt.unit_name as unitName, mt.manage_type as manageType,
case WHEN mt.manage_type = '0' then '编号' else '计数' end manageTypeName,
mt.num, (lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,mm.ma_code as maCode
FROM
lease_apply_details lad
LEFT JOIN ma_type mt ON lad.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN ma_machine mm ON lad.type_id = mm.type_id
WHERE
lad.parent_id = #{record.id} AND lad.company_id = #{record.companyId}
GROUP BY
lad.id
</select>
2024-09-27 15:48:39 +08:00
</mapper>