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" />
|
2024-10-18 13:54:24 +08:00
|
|
|
<result property="monthOrder" column="month_order" />
|
2024-09-27 15:48:39 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectTmTaskVo">
|
2024-10-18 13:54:24 +08:00
|
|
|
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
|
2024-10-18 13:54:24 +08:00
|
|
|
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>
|
2024-10-18 13:54:24 +08:00
|
|
|
<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>
|
2024-10-18 13:54:24 +08:00
|
|
|
<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>
|
2024-10-18 13:54:24 +08:00
|
|
|
<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>
|
2024-10-18 13:54:24 +08:00
|
|
|
|
|
|
|
|
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
|
2024-11-13 09:57:43 +08:00
|
|
|
select COALESCE(max(month_order), 0) from tm_task
|
2024-10-18 13:54:24 +08:00
|
|
|
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}
|
2024-10-18 13:54:24 +08:00
|
|
|
</if>
|
|
|
|
|
</select>
|
2024-10-23 13:46:01 +08:00
|
|
|
|
|
|
|
|
<update id="updateTmTaskStatusByTaskId">
|
|
|
|
|
update tm_task set task_status = #{newTaskStatus}
|
2024-11-08 12:24:25 +08:00
|
|
|
where task_id = #{taskId}
|
2024-10-23 13:46:01 +08:00
|
|
|
</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
|
2024-11-13 14:01:49 +08:00
|
|
|
tt.task_id as taskId, tt.task_type as taskType, tt.task_status as taskStatus, tt.status, tt.code,
|
|
|
|
|
su.phonenumber AS phoneNumber, sd.dept_name as deptName,
|
2024-11-13 10:37:17 +08:00
|
|
|
bpl.pro_id as proId,bpl.pro_name as projectName,
|
2024-11-13 10:19:50 +08:00
|
|
|
bui.unit_id as unitId,bui.unit_name as unitName,
|
2024-11-13 10:45:03 +08:00
|
|
|
lai.lease_person as leasePerson, lai.phone as leasePhone, tt.create_by as applyFor,
|
|
|
|
|
lai.lease_type as leaseType,lai.estimate_lease_time as estimateLeaseTime,
|
2024-11-13 10:19:50 +08:00
|
|
|
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
|
2024-11-13 10:35:12 +08:00
|
|
|
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
|
|
|
|
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
2024-11-13 10:19:50 +08:00
|
|
|
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
|
|
|
|
|
WHERE
|
2024-11-13 10:48:38 +08:00
|
|
|
tt.task_type = 2 and tt.status = '1'
|
2024-11-13 10:19:50 +08:00
|
|
|
<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 != ''">
|
2024-11-13 10:35:12 +08:00
|
|
|
AND bpl.pro_id = #{record.projectId}
|
2024-11-13 10:19:50 +08:00
|
|
|
</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,
|
2024-11-13 10:37:17 +08:00
|
|
|
bpl.pro_id as proId,bpl.pro_name as projectName,
|
2024-11-13 10:19:50 +08:00
|
|
|
bui.unit_id as unitId,bui.unit_name as unitName,
|
2024-11-13 10:45:03 +08:00
|
|
|
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,
|
2024-11-13 10:42:01 +08:00
|
|
|
-- 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,
|
2024-11-13 10:19:50 +08:00
|
|
|
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
|
2024-11-13 10:35:12 +08:00
|
|
|
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
|
|
|
|
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
2024-11-13 10:19:50 +08:00
|
|
|
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
|
2024-11-13 10:42:01 +08:00
|
|
|
-- LEFT JOIN sys_dic d ON d.id = tt.task_status
|
2024-11-13 10:19:50 +08:00
|
|
|
WHERE
|
2024-11-13 10:48:38 +08:00
|
|
|
tt.task_type = 2 and tt.status = '1' and tt.create_by = #{record.createBy}
|
2024-11-13 10:19:50 +08:00
|
|
|
<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 != ''">
|
2024-11-13 10:35:12 +08:00
|
|
|
AND bpl.pro_id = #{record.projectId}
|
2024-11-13 10:19:50 +08:00
|
|
|
</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,
|
2024-11-13 14:01:49 +08:00
|
|
|
mt.storage_num, (lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,mm.ma_code as maCode
|
2024-11-13 10:19:50 +08:00
|
|
|
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>
|