2023-12-13 19:29:50 +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.app.mapper.TmTaskMapper" >
2024-01-16 20:06:21 +08:00
<resultMap id= "BaseResultMap" type= "com.bonus.sgzb.app.domain.TmTask" >
2023-12-13 19:29:50 +08:00
<!-- @Table tm_task -->
<id column= "task_id" jdbcType= "BIGINT" property= "taskId" />
<result column= "task_type" jdbcType= "INTEGER" property= "taskType" />
<result column= "task_status" jdbcType= "INTEGER" property= "taskStatus" />
<result column= "code" jdbcType= "VARCHAR" property= "code" />
<result column= "create_by" jdbcType= "VARCHAR" property= "createBy" />
<result column= "create_time" jdbcType= "TIMESTAMP" property= "createTime" />
<result column= "update_by" jdbcType= "VARCHAR" property= "updateBy" />
<result column= "update_time" jdbcType= "TIMESTAMP" property= "updateTime" />
<result column= "remark" jdbcType= "VARCHAR" property= "remark" />
<result column= "company_id" jdbcType= "INTEGER" property= "companyId" />
</resultMap>
2024-04-22 18:58:46 +08:00
<resultMap id= "ResultMap" type= "com.bonus.sgzb.app.domain.TmTask" >
<!-- @Table tm_task -->
<id column= "task_id" jdbcType= "BIGINT" property= "taskId" />
<result column= "task_type" jdbcType= "INTEGER" property= "taskType" />
<result column= "task_status" jdbcType= "INTEGER" property= "taskStatus" />
<result column= "code" jdbcType= "VARCHAR" property= "code" />
<result column= "create_by" jdbcType= "VARCHAR" property= "createBy" />
<result column= "create_time" jdbcType= "TIMESTAMP" property= "createTime" />
<result column= "update_by" jdbcType= "VARCHAR" property= "updateBy" />
<result column= "update_time" jdbcType= "TIMESTAMP" property= "updateTime" />
<result column= "remark" jdbcType= "VARCHAR" property= "remark" />
<result column= "company_id" jdbcType= "INTEGER" property= "companyId" />
<collection property= "leaseApplyDetails" ofType= "com.bonus.sgzb.app.domain.TmTask" >
<id column= "dId" property= "id" jdbcType= "INTEGER" />
<result column= "code" jdbcType= "VARCHAR" property= "code" />
<result column= "create_by" jdbcType= "VARCHAR" property= "createBy" />
<result column= "create_time" jdbcType= "TIMESTAMP" property= "createTime" />
<result column= "update_by" jdbcType= "VARCHAR" property= "updateBy" />
<result column= "update_time" jdbcType= "TIMESTAMP" property= "updateTime" />
<result column= "remark" jdbcType= "VARCHAR" property= "remark" />
<result column= "company_id" jdbcType= "INTEGER" property= "companyId" />
</collection>
</resultMap>
2023-12-13 19:29:50 +08:00
<sql id= "Base_Column_List" >
task_id, task_type, task_status, code, create_by, create_time, update_by, update_time,
remark, company_id
</sql>
<select id= "selectByPrimaryKey" parameterType= "java.lang.Long" resultMap= "BaseResultMap" >
select
<include refid= "Base_Column_List" />
from tm_task
where task_id = #{taskId,jdbcType=BIGINT}
</select>
2023-12-21 12:04:38 +08:00
2023-12-22 20:17:22 +08:00
<update id= "deleteTaskByPrimaryKey" >
2023-12-22 14:52:51 +08:00
update tm_task set `status` = '0'
2023-12-22 20:17:22 +08:00
where task_id = #{taskId}
2023-12-22 14:52:51 +08:00
</update>
2023-12-22 20:17:22 +08:00
<update id= "deleteTaskInfoByTaskId" >
2024-03-07 16:30:39 +08:00
delete from lease_apply_info
2023-12-22 14:52:51 +08:00
where task_id = #{taskId}
</update>
<delete id= "deleteDetailsByTaskId" parameterType= "java.lang.String" >
delete from lease_apply_details where id = #{id}
</delete>
2023-12-22 16:24:25 +08:00
<delete id= "deleteDetailsByParentId" parameterType= "java.lang.String" >
delete from lease_apply_details where parennt_id = #{parentId}
</delete>
2024-04-25 13:08:53 +08:00
<delete id= "deleteTaskAgreementByTaskId" >
delete from tm_task_agreement where task_id = #{taskId}
</delete>
2023-12-22 16:24:25 +08:00
2024-01-16 20:06:21 +08:00
<insert id= "insert" keyColumn= "task_id" keyProperty= "taskId" parameterType= "com.bonus.sgzb.app.domain.TmTask" useGeneratedKeys= "true" >
2023-12-13 19:29:50 +08:00
insert into tm_task (task_type, task_status, code, create_by, create_time, update_by, update_time, remark, company_id)
values (#{taskType,jdbcType=INTEGER}, #{taskStatus,jdbcType=INTEGER}, #{code,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER})
</insert>
2024-01-16 20:06:21 +08:00
<insert id= "insertSelective" keyColumn= "task_id" keyProperty= "id" parameterType= "com.bonus.sgzb.app.domain.TmTask" useGeneratedKeys= "true" >
2023-12-13 19:29:50 +08:00
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 and code != ''" >
code,
</if>
<if test= "createBy != null and createBy != ''" >
create_by,
</if>
create_time,
<if test= "updateBy != null and updateBy != ''" >
update_by,
</if>
update_time,
<if test= "remark != null and remark != ''" >
remark,
</if>
<if test= "companyId != null" >
company_id,
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "taskType != null" >
#{taskType,jdbcType=INTEGER},
</if>
<if test= "taskStatus != null" >
#{taskStatus,jdbcType=INTEGER},
</if>
<if test= "code != null and code != ''" >
#{code,jdbcType=VARCHAR},
</if>
<if test= "createBy != null and createBy != ''" >
#{createBy,jdbcType=VARCHAR},
</if>
2023-12-19 00:53:49 +08:00
now(),
2023-12-13 19:29:50 +08:00
<if test= "updateBy != null and updateBy != ''" >
#{updateBy,jdbcType=VARCHAR},
</if>
2023-12-22 14:52:51 +08:00
now(),
2023-12-13 19:29:50 +08:00
<if test= "remark != null and remark != ''" >
#{remark,jdbcType=VARCHAR},
</if>
<if test= "companyId != null" >
#{companyId,jdbcType=INTEGER},
</if>
</trim>
</insert>
2024-01-16 20:06:21 +08:00
<update id= "updateByPrimaryKeySelective" parameterType= "com.bonus.sgzb.app.domain.TmTask" >
2023-12-13 19:29:50 +08:00
update tm_task
<set >
<if test= "taskType != null" >
task_type = #{taskType,jdbcType=INTEGER},
</if>
<if test= "taskStatus != null" >
task_status = #{taskStatus,jdbcType=INTEGER},
</if>
<if test= "updateBy != null and updateBy != ''" >
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test= "updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test= "remark != null and remark != ''" >
remark = #{remark,jdbcType=VARCHAR},
</if>
</set>
where task_id = #{taskId,jdbcType=BIGINT}
</update>
2024-01-16 20:06:21 +08:00
<update id= "updateByPrimaryKey" parameterType= "com.bonus.sgzb.app.domain.TmTask" >
2023-12-13 19:29:50 +08:00
update tm_task
set task_type = #{taskType,jdbcType=INTEGER},
task_status = #{taskStatus,jdbcType=INTEGER},
code = #{code,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR},
company_id = #{companyId,jdbcType=INTEGER}
where task_id = #{taskId,jdbcType=BIGINT}
</update>
<update id= "updateBatch" parameterType= "java.util.List" >
<!-- @mbg.generated -->
update tm_task
<trim prefix= "set" suffixOverrides= "," >
<trim prefix= "task_type = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.taskType,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix= "task_status = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.taskStatus,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix= "code = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.code,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix= "create_by = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.createBy,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix= "create_time = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix= "update_by = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.updateBy,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix= "update_time = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.updateTime,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix= "remark = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.remark,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix= "company_id = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.companyId,jdbcType=INTEGER}
</foreach>
</trim>
</trim>
where task_id in
<foreach close= ")" collection= "list" item= "item" open= "(" separator= ", " >
#{item.taskId,jdbcType=BIGINT}
</foreach>
</update>
<update id= "updateBatchSelective" parameterType= "java.util.List" >
<!-- @mbg.generated -->
update tm_task
<trim prefix= "set" suffixOverrides= "," >
<trim prefix= "task_type = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.taskType != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.taskType,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix= "task_status = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.taskStatus != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.taskStatus,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix= "code = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.code != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.code,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix= "create_by = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.createBy != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.createBy,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix= "create_time = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.createTime != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix= "update_by = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.updateBy != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.updateBy,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix= "update_time = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.updateTime != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.updateTime,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix= "remark = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.remark != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.remark,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix= "company_id = case" suffix= "end," >
<foreach collection= "list" index= "index" item= "item" >
<if test= "item.companyId != null" >
when task_id = #{item.taskId,jdbcType=BIGINT} then #{item.companyId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
</trim>
where task_id in
<foreach close= ")" collection= "list" item= "item" open= "(" separator= ", " >
#{item.taskId,jdbcType=BIGINT}
</foreach>
</update>
<insert id= "batchInsert" keyColumn= "task_id" keyProperty= "taskId" parameterType= "map" useGeneratedKeys= "true" >
<!-- @mbg.generated -->
insert into tm_task
2024-01-11 13:40:03 +08:00
(task_type, task_status, code, create_by, create_time, update_by, update_time, remark,
2023-12-13 19:29:50 +08:00
company_id)
values
<foreach collection= "list" item= "item" separator= "," >
2024-01-11 13:40:03 +08:00
(#{item.taskType,jdbcType=INTEGER}, #{item.taskStatus,jdbcType=INTEGER}, #{item.code,jdbcType=VARCHAR},
#{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR},
2023-12-13 19:29:50 +08:00
#{item.updateTime,jdbcType=TIMESTAMP}, #{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER}
)
</foreach>
</insert>
2024-01-16 20:06:21 +08:00
<insert id= "insertOrUpdate" keyColumn= "task_id" keyProperty= "taskId" parameterType= "com.bonus.sgzb.app.domain.TmTask" useGeneratedKeys= "true" >
2023-12-13 19:29:50 +08:00
<!-- @mbg.generated -->
insert into tm_task
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "taskId != null" >
task_id,
</if>
task_type,
task_status,
code,
create_by,
create_time,
update_by,
update_time,
remark,
company_id,
</trim>
values
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "taskId != null" >
#{taskId,jdbcType=BIGINT},
</if>
#{taskType,jdbcType=INTEGER},
#{taskStatus,jdbcType=INTEGER},
#{code,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP},
#{updateBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP},
#{remark,jdbcType=VARCHAR},
#{companyId,jdbcType=INTEGER},
</trim>
2024-01-11 13:40:03 +08:00
on duplicate key update
2023-12-13 19:29:50 +08:00
<trim suffixOverrides= "," >
<if test= "taskId != null" >
task_id = #{taskId,jdbcType=BIGINT},
</if>
task_type = #{taskType,jdbcType=INTEGER},
task_status = #{taskStatus,jdbcType=INTEGER},
code = #{code,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR},
company_id = #{companyId,jdbcType=INTEGER},
</trim>
</insert>
2024-01-16 20:06:21 +08:00
<insert id= "insertOrUpdateSelective" keyColumn= "task_id" keyProperty= "taskId" parameterType= "com.bonus.sgzb.app.domain.TmTask" useGeneratedKeys= "true" >
2023-12-13 19:29:50 +08:00
<!-- @mbg.generated -->
insert into tm_task
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "taskId != null" >
task_id,
</if>
<if test= "taskType != null" >
task_type,
</if>
<if test= "taskStatus != null" >
task_status,
</if>
<if test= "code != null and code != ''" >
code,
</if>
<if test= "createBy != null and createBy != ''" >
create_by,
</if>
<if test= "createTime != null" >
create_time,
</if>
<if test= "updateBy != null and updateBy != ''" >
update_by,
</if>
<if test= "updateTime != null" >
update_time,
</if>
<if test= "remark != null and remark != ''" >
remark,
</if>
<if test= "companyId != null" >
company_id,
</if>
</trim>
values
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "taskId != null" >
#{taskId,jdbcType=BIGINT},
</if>
<if test= "taskType != null" >
#{taskType,jdbcType=INTEGER},
</if>
<if test= "taskStatus != null" >
#{taskStatus,jdbcType=INTEGER},
</if>
<if test= "code != null and code != ''" >
#{code,jdbcType=VARCHAR},
</if>
<if test= "createBy != null and createBy != ''" >
#{createBy,jdbcType=VARCHAR},
</if>
<if test= "createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test= "updateBy != null and updateBy != ''" >
#{updateBy,jdbcType=VARCHAR},
</if>
<if test= "updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test= "remark != null and remark != ''" >
#{remark,jdbcType=VARCHAR},
</if>
<if test= "companyId != null" >
#{companyId,jdbcType=INTEGER},
</if>
</trim>
2024-01-11 13:40:03 +08:00
on duplicate key update
2023-12-13 19:29:50 +08:00
<trim suffixOverrides= "," >
<if test= "taskId != null" >
task_id = #{taskId,jdbcType=BIGINT},
</if>
<if test= "taskType != null" >
task_type = #{taskType,jdbcType=INTEGER},
</if>
<if test= "taskStatus != null" >
task_status = #{taskStatus,jdbcType=INTEGER},
</if>
<if test= "code != null and code != ''" >
code = #{code,jdbcType=VARCHAR},
</if>
<if test= "createBy != null and createBy != ''" >
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test= "createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test= "updateBy != null and updateBy != ''" >
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test= "updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test= "remark != null and remark != ''" >
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test= "companyId != null" >
company_id = #{companyId,jdbcType=INTEGER},
</if>
</trim>
</insert>
2023-12-22 14:52:51 +08:00
<insert id= "insertAgreement" >
INSERT INTO tm_task_agreement ( `task_id`, `agreement_id`, `create_by`, `create_time`, `company_id` )
VALUES(#{id},#{agreementId},#{createBy},NOW(),#{companyId})
</insert>
2023-12-21 18:35:36 +08:00
2023-12-22 20:27:35 +08:00
<update id= "updateAgreementByTask" >
update tm_task_agreement set agreement_id = #{agreementId}, update_time = now()
where task_id = #{taskId}
</update>
2024-01-16 20:06:21 +08:00
<select id= "getAuditListByLeaseTmTask" resultType= "com.bonus.sgzb.app.domain.TmTask" >
2023-12-23 13:33:03 +08:00
SELECT DISTINCT
2024-05-30 17:55:01 +08:00
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,su.nick_name as nickName,
2024-01-10 09:03:26 +08:00
bpl.lot_id as proId,bpl.lot_name as proName,
2023-12-22 14:52:51 +08:00
bui.unit_id as unitId,bui.unit_name as unitName,
2024-06-18 10:11:30 +08:00
lai.lease_person as leasePerson, lai.phone as leasePhone, su.user_name as applyFor,d.`name` as taskName,lai.lease_type as leaseType,lai.estimate_lease_time as estimateLeaseTime,
2024-04-10 17:48:09 +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
2024-01-10 09:03:26 +08:00
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
2024-03-22 17:38:48 +08:00
end examineStatus,
2024-01-10 09:03:26 +08:00
d.id as examineStatusId,
2023-12-22 14:52:51 +08:00
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
2023-12-19 00:53:49 +08:00
tm_task tt
2024-06-18 10:11:30 +08:00
LEFT JOIN sys_user su ON tt.create_by = su.user_id
2023-12-19 00:53:49 +08:00
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
2023-12-24 16:16:15 +08:00
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
2023-12-21 18:35:36 +08:00
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
2023-12-22 14:52:51 +08:00
WHERE
2023-12-21 12:04:38 +08:00
tt.task_type = '29' and tt.status = '1'
2023-12-19 00:53:49 +08:00
<if test= "record.taskId != null and record.taskId != '' " >
2023-12-22 14:52:51 +08:00
AND tt.task_id = #{record.taskId}
2023-12-19 00:53:49 +08:00
</if>
2023-12-21 18:35:36 +08:00
2023-12-22 14:52:51 +08:00
<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>
2023-12-21 18:35:36 +08:00
2023-12-22 14:52:51 +08:00
<if test= "record.unitId != null and record.unitId != ''" >
AND bui.unit_id = #{record.unitId}
</if>
2023-12-21 18:35:36 +08:00
2023-12-22 14:52:51 +08:00
<if test= "record.projectId != null and record.projectId != ''" >
2024-03-22 17:38:48 +08:00
AND bpl.lot_id = #{record.projectId}
2023-12-22 14:52:51 +08:00
</if>
2023-12-21 18:35:36 +08:00
2024-06-18 10:58:07 +08:00
<if test= "record.taskStatus != null and record.taskStatus != ''" >
AND tt.task_status = #{record.taskStatus}
</if>
2023-12-22 14:52:51 +08:00
<if test= "record.keyWord != null and record.keyWord != ''" >
2024-03-22 17:38:48 +08:00
AND (bai.agreement_code like concat('%', #{record.keyWord}, '%') or
tt.code like concat('%', #{record.keyWord}, '%'))
2023-12-22 14:52:51 +08:00
</if>
2024-04-30 14:09:40 +08:00
GROUP BY tt.task_id
2024-01-10 09:03:26 +08:00
ORDER BY tt.update_time DESC
2023-12-17 18:01:20 +08:00
</select>
2024-02-20 18:04:13 +08:00
<select id= "getAuditManageListByLeaseTmTask" resultType= "com.bonus.sgzb.app.domain.TmTask" >
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,
2024-06-17 17:03:40 +08:00
lai.lease_person as leasePerson, lai.phone as leasePhone,lai.lease_type as leaseType, lai.estimate_lease_time as estimateLeaseTime,su.nick_name as applyFor,d.`name` as taskName,
2024-04-10 17:48:09 +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
2024-02-20 18:04:13 +08:00
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
2024-04-10 17:48:09 +08:00
end examineStatus,
2024-02-20 18:04:13 +08:00
d.id as examineStatusId,
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
2024-06-14 13:48:18 +08:00
LEFT JOIN sys_user su ON tt.create_by = su.user_id
2024-02-20 18:04:13 +08:00
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'
2024-05-14 16:44:16 +08:00
<if test= "record.deptId != null and record.deptId != '' " >
AND su.dept_id = #{record.deptId}
</if>
2024-05-27 20:45:12 +08:00
<if test= "record.companyId != null " >
2024-06-12 16:56:36 +08:00
AND lai.company_id = #{record.companyId}
2024-05-27 20:45:12 +08:00
</if>
2024-02-20 18:04:13 +08:00
<if test= "record.taskId != null and record.taskId != '' " >
AND tt.task_id = #{record.taskId}
</if>
2024-06-12 16:56:36 +08:00
<if test= "record.taskStatus != null" >
AND tt.task_status = #{record.taskStatus}
</if>
2024-02-20 18:04:13 +08:00
<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-03-22 17:38:48 +08:00
AND bpl.lot_id = #{record.projectId}
2024-02-20 18:04:13 +08:00
</if>
<if test= "record.keyWord != null and record.keyWord != ''" >
2024-05-16 10:59:01 +08:00
AND (bai.agreement_code like concat('%', #{record.keyWord}, '%') or tt.code like concat('%', #{record.keyWord}, '%'))
2024-02-20 18:04:13 +08:00
</if>
2024-02-27 13:20:31 +08:00
GROUP BY tt.task_id
2024-06-05 17:48:30 +08:00
ORDER BY tt.task_status,tt.update_time DESC
2024-02-20 18:04:13 +08:00
</select>
2024-01-16 20:06:21 +08:00
<select id= "getAuditListByLeaseInfo" resultType= "com.bonus.sgzb.app.domain.LeaseApplyInfo" >
2023-12-17 18:01:20 +08:00
SELECT
lai.*
FROM
lease_apply_info lai
WHERE
2024-01-11 13:40:03 +08:00
lai.task_id = #{record.taskId} AND lai.`code` = #{record.code}
2023-12-17 18:01:20 +08:00
</select>
2024-02-20 18:04:13 +08:00
<select id= "getAuditManageListByLeaseInfo" resultType= "com.bonus.sgzb.app.domain.LeaseApplyInfo" >
SELECT
lai.*
FROM
lease_apply_info lai
WHERE
lai.task_id = #{record.taskId} AND lai.`code` = #{record.code}
</select>
2023-12-17 18:01:20 +08:00
2024-01-16 20:06:21 +08:00
<select id= "getLeaseApplyDetails" resultType= "com.bonus.sgzb.app.domain.LeaseApplyDetails" >
2023-12-17 18:01:20 +08:00
SELECT
2024-06-04 13:04:54 +08:00
lad.*,
CASE
WHEN lad.`status` = 0 THEN
'待出库'
WHEN lad.`status` = 1 THEN
'出库进行中'
WHEN lad.`status` = 2 THEN
'已出库'
END statusName,
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
2023-12-17 18:01:20 +08:00
FROM
2024-06-04 13:04:54 +08:00
lease_apply_details lad
2023-12-19 00:53:49 +08:00
LEFT JOIN ma_type mt ON lad.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
2024-01-30 13:21:41 +08:00
LEFT JOIN ma_machine mm ON lad.type_id = mm.type_id
2023-12-17 18:01:20 +08:00
WHERE
2024-06-04 13:04:54 +08:00
lad.parennt_id = #{record.id}
2024-02-20 18:04:13 +08:00
GROUP BY
lad.id
</select>
<select id= "getLeaseApplyManageDetails" resultType= "com.bonus.sgzb.app.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.parennt_id = #{record.id} AND lad.company_id = #{record.companyId}
2024-02-20 13:57:26 +08:00
GROUP BY
lad.id
2023-12-17 18:01:20 +08:00
</select>
2023-12-22 14:52:51 +08:00
<select id= "selectNumByMonth" resultType= "java.lang.Integer" >
select count(*) from tm_task where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m') AND task_type='29'
</select>
2023-12-22 14:48:58 +08:00
2024-01-16 20:06:21 +08:00
<select id= "getLeaseListTmTask" resultType= "com.bonus.sgzb.app.domain.TmTask" >
2023-12-23 18:32:23 +08:00
SELECT DISTINCT
2023-12-22 14:52:51 +08:00
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,
2024-01-14 14:01:56 +08:00
bpi.lot_id as proId, bpi.pro_id as projectId,bpi.lot_name as proName,
2023-12-22 14:52:51 +08:00
bui.unit_id as unitId,bui.unit_name as unitName,
2024-06-18 14:49:37 +08:00
su.nick_name as applyFor,d.`name` as taskName,
2023-12-23 18:32:23 +08:00
su2.user_name as companyAuditBy,
lai.company_audit_time as companyAuditTime,
lai.company_audit_remark as companyAuditRemark,
su3.user_name as deptAuditBy,
lai.dept_audit_time as deptAuditTime,
lai.dept_audit_remark as deptAuditRemark,
su4.user_name as directAuditBy,
lai.direct_audit_time as directAuditTime,
lai.direct_audit_remark as directAuditRemark,
2024-03-16 15:33:49 +08:00
lai.lease_type as leaseType,
2024-03-22 17:38:48 +08:00
lai.estimate_lease_time as estimateLeaseTime,
2023-12-23 18:32:23 +08:00
2023-12-22 14:52:51 +08:00
d.id as examineStatusId,
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes,
bai.agreement_id as agreementId
2023-12-23 18:32:23 +08:00
FROM
2023-12-22 14:52:51 +08:00
tm_task tt
2024-06-18 14:49:37 +08:00
LEFT JOIN sys_user su ON tt.create_by = su.user_id
2023-12-23 18:32:23 +08:00
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-01-14 14:01:56 +08:00
LEFT JOIN bm_project_lot bpi ON bpi.lot_id = bai.project_id
2023-12-23 18:32:23 +08:00
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_user su2 ON lai.company_audit_by = su2.user_id
LEFT JOIN sys_user su3 ON lai.dept_audit_by = su3.user_id
LEFT JOIN sys_user su4 ON lai.direct_audit_by = su4.user_id
2024-02-21 19:24:08 +08:00
WHERE tt.task_id = #{taskId} limit 1
2023-12-22 14:52:51 +08:00
</select>
2023-12-22 14:48:58 +08:00
2024-01-16 20:06:21 +08:00
<select id= "getLeaseListByLeaseInfo" resultType= "com.bonus.sgzb.app.domain.LeaseApplyInfo" >
2023-12-22 20:17:22 +08:00
SELECT
lai.*
FROM
lease_apply_info lai
WHERE
lai.task_id = #{taskId}
</select>
2023-12-22 14:48:58 +08:00
2023-12-17 18:01:20 +08:00
<update id= "updateTmTaskAuditStatus" >
UPDATE tm_task SET task_status = #{record.taskStatus} WHERE task_id = #{record.taskId}
</update>
<update id= "updateLeaseApplyInfoAuditInfo" >
UPDATE
lease_apply_info
set
<trim suffixOverrides= "," >
2023-12-23 21:49:43 +08:00
<if test= "record.examineStatusId == 30 and record.examineStatusId == '30'" >
2023-12-17 18:01:20 +08:00
company_audit_by = #{record.companyAuditBy},
2023-12-19 00:53:49 +08:00
company_audit_time = now(),
2023-12-17 18:01:20 +08:00
company_audit_remark = #{record.companyAuditRemark},
</if>
2023-12-23 21:49:43 +08:00
<if test= "record.examineStatusId == 31 and record.examineStatusId == '31'" >
2023-12-17 18:01:20 +08:00
dept_audit_by = #{record.companyAuditBy},
2023-12-19 00:53:49 +08:00
dept_audit_time = now(),
2023-12-17 18:01:20 +08:00
dept_audit_remark = #{record.companyAuditRemark},
2024-02-27 13:20:31 +08:00
status = #{record.status},
2023-12-17 18:01:20 +08:00
</if>
2023-12-23 21:49:43 +08:00
<if test= "record.examineStatusId == 32 and record.examineStatusId == '32'" >
direct_audit_by = #{record.companyAuditBy},
direct_audit_time = now(),
direct_audit_remark = #{record.companyAuditRemark},
2024-01-24 18:44:10 +08:00
status = #{record.status},
2023-12-17 18:01:20 +08:00
</if>
2024-01-05 10:09:07 +08:00
<if test= "record.examineStatusId == 33 and record.examineStatusId == '33'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
<if test= "record.examineStatusId == 34 and record.examineStatusId == '34'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
2024-01-10 09:03:26 +08:00
<if test= "record.examineStatusId == 35 and record.examineStatusId == '35'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
2024-04-22 11:19:06 +08:00
<if test= "record.examineStatusId == 117 and record.examineStatusId == '117'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
2023-12-17 18:01:20 +08:00
</trim>
WHERE
2024-02-21 19:24:08 +08:00
task_id = #{record.taskId} and company_id = #{record.companyId}
2023-12-17 18:01:20 +08:00
</update>
2024-01-10 09:03:26 +08:00
<update id= "updateLeaseApplyInfoRejectInfo" >
UPDATE
lease_apply_info
set
<trim suffixOverrides= "," >
<if test= "record.examineStatusId == 98 and record.examineStatusId == '98'" >
company_audit_by = #{record.companyAuditBy},
company_audit_time = now(),
company_audit_remark = #{record.companyAuditRemark},
2024-03-22 17:38:48 +08:00
status = #{record.status},
2024-01-10 09:03:26 +08:00
</if>
<if test= "record.examineStatusId == 99 and record.examineStatusId == '99'" >
dept_audit_by = #{record.companyAuditBy},
dept_audit_time = now(),
dept_audit_remark = #{record.companyAuditRemark},
2024-02-27 13:20:31 +08:00
status = #{record.status},
2024-01-10 09:03:26 +08:00
</if>
<if test= "record.examineStatusId == 100 and record.examineStatusId == '100'" >
direct_audit_by = #{record.companyAuditBy},
direct_audit_time = now(),
direct_audit_remark = #{record.companyAuditRemark},
2024-01-24 18:44:10 +08:00
status = #{record.status},
2024-01-10 09:03:26 +08:00
</if>
</trim>
WHERE
2024-02-27 16:02:01 +08:00
task_id = #{record.taskId} and company_id = #{record.companyId}
2024-01-10 09:03:26 +08:00
</update>
2023-12-17 18:01:20 +08:00
<update id= "updateLeaseApplyDetailsAuditInfo" >
update
lease_apply_details
set
<trim suffixOverrides= "," >
<if test= "record.auditNum != null and record.auditNum != '' " >
audit_num = #{record.auditNum},
</if>
<if test= "record.alNum != null and record.alNum != '' " >
al_num = #{record.alNum},
</if>
<if test= "record.status!= null and record.status!= '' " >
status = #{record.status},
</if>
<if test= "record.updateBy != null and record.updateBy != '' " >
update_by = #{record.updateBy},
</if>
2023-12-19 00:53:49 +08:00
update_time = now()
2023-12-17 18:01:20 +08:00
</trim>
where
parennt_id = #{record.parenntId}
</update>
2023-12-22 20:27:35 +08:00
2024-01-10 09:03:26 +08:00
<update id= "updateLeaseApplyDetailsRejectInfo" >
update
lease_apply_details
set
<trim suffixOverrides= "," >
<if test= "record.auditNum != null and record.auditNum != '' " >
audit_num = #{record.auditNum},
</if>
<if test= "record.alNum != null and record.alNum != '' " >
al_num = #{record.alNum},
</if>
<if test= "record.status!= null and record.status!= '' " >
status = #{record.status},
</if>
<if test= "record.updateBy != null and record.updateBy != '' " >
update_by = #{record.updateBy},
</if>
update_time = now()
</trim>
where
parennt_id = #{record.parenntId}
</update>
2023-12-23 18:32:23 +08:00
<update id= "updateLeaseInfo" >
UPDATE lease_apply_info SET lease_person = #{leasePerson}, phone = #{phone}, remark = #{remark}
WHERE task_id = #{taskId}
</update>
2024-04-30 11:23:49 +08:00
<update id= "updateLeaseApplyInfoRejectInfoCq" >
UPDATE
lease_apply_info
set
<trim suffixOverrides= "," >
<if test= "record.examineStatusId == 98 and record.examineStatusId == '98'" >
company_audit_by = #{record.companyAuditBy},
company_audit_time = now(),
company_audit_remark = #{record.companyAuditRemark},
status = #{record.status},
</if>
<if test= "record.examineStatusId == 99 and record.examineStatusId == '99'" >
dept_audit_by = #{record.companyAuditBy},
dept_audit_time = now(),
dept_audit_remark = #{record.companyAuditRemark},
status = #{record.status},
</if>
<if test= "record.examineStatusId == 100 and record.examineStatusId == '100'" >
direct_audit_by = #{record.companyAuditBy},
direct_audit_time = now(),
direct_audit_remark = #{record.companyAuditRemark},
status = #{record.status},
</if>
</trim>
WHERE
task_id = #{record.taskId} and company_id is null
</update>
<update id= "updateLeaseApplyInfoAuditInfoCq" >
UPDATE
lease_apply_info
set
<trim suffixOverrides= "," >
<if test= "record.examineStatusId == 30 and record.examineStatusId == '30'" >
company_audit_by = #{record.companyAuditBy},
company_audit_time = now(),
company_audit_remark = #{record.companyAuditRemark},
</if>
<if test= "record.examineStatusId == 31 and record.examineStatusId == '31'" >
dept_audit_by = #{record.companyAuditBy},
dept_audit_time = now(),
dept_audit_remark = #{record.companyAuditRemark},
status = #{record.status},
</if>
<if test= "record.examineStatusId == 32 and record.examineStatusId == '32'" >
direct_audit_by = #{record.companyAuditBy},
direct_audit_time = now(),
direct_audit_remark = #{record.companyAuditRemark},
status = #{record.status},
</if>
<if test= "record.examineStatusId == 33 and record.examineStatusId == '33'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
<if test= "record.examineStatusId == 34 and record.examineStatusId == '34'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
<if test= "record.examineStatusId == 35 and record.examineStatusId == '35'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
<if test= "record.examineStatusId == 117 and record.examineStatusId == '117'" >
update_by = #{record.companyAuditBy},
update_time = now(),
</if>
</trim>
WHERE
task_id = #{record.taskId} and company_id is null
</update>
2024-06-05 13:15:29 +08:00
<update id= "updateLeaseAuditListByOne" >
UPDATE lease_apply_details
SET `status` = 2
WHERE
parennt_id = #{id}
AND type_id = #{typeId}
</update>
2023-12-23 18:32:23 +08:00
2023-12-22 20:27:35 +08:00
<select id= "getAgreementIdByUnit" resultType= "java.lang.Integer" >
select agreement_id from bm_agreement_info
where unit_id = #{unitId} and project_id = #{projectId}
</select>
2024-01-16 20:06:21 +08:00
<select id= "getListSome" resultType= "com.bonus.sgzb.app.domain.LeaseApplyInfo" >
2023-12-23 18:32:23 +08:00
SELECT * FROM `lease_apply_info`
2024-02-27 13:20:31 +08:00
WHERE task_id = #{taskId}
2023-12-23 18:32:23 +08:00
</select>
2024-01-16 20:06:21 +08:00
<select id= "getListSomeol" resultType= "com.bonus.sgzb.app.domain.LeaseApplyInfo" >
2023-12-23 18:32:23 +08:00
SELECT * FROM `lease_apply_info`
WHERE task_id = #{taskId} AND `status` ='1' and company_id = #{id}
</select>
2024-01-16 20:06:21 +08:00
<select id= "getKgByMaType" resultType= "java.lang.Integer" >
select mtk.user_id as userId
from ma_type_keeper mtk
where mtk.type_id = #{typeId}
</select>
2024-02-21 19:24:08 +08:00
<select id= "getLeaseApplyInfo" resultType= "com.bonus.sgzb.app.domain.LeaseApplyInfo" >
SELECT * FROM `lease_apply_info`
2024-02-22 17:02:04 +08:00
WHERE task_id = #{taskId}
</select>
<select id= "getAuditListByLeaseTmTaskByPeople" resultType= "com.bonus.sgzb.app.domain.TmTask" >
SELECT DISTINCT
2024-06-06 17:59:23 +08:00
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,su.nick_name as nickName,su.user_id as userId,
2024-02-22 17:02:04 +08:00
bpl.lot_id as proId,bpl.lot_name as proName,
bui.unit_id as unitId,bui.unit_name as unitName,
2024-06-14 13:48:18 +08:00
lai.lease_person as leasePerson, lai.phone as leasePhone, su.user_name as applyFor,d.`name` as taskName,lai.lease_type as leaseType,lai.estimate_lease_time as estimateLeaseTime,
2024-04-10 17:48:09 +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
2024-02-22 17:02:04 +08:00
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
2024-06-14 13:48:18 +08:00
LEFT JOIN sys_user su ON tt.create_by = su.user_id
2024-02-22 17:02:04 +08:00
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
2024-05-14 16:44:16 +08:00
tt.task_type = '29' and tt.status = '1'
<if test= "record.createBy != null and record.createBy != '' " >
AND tt.create_by = #{record.createBy}
</if>
<if test= "record.companyId != null and record.companyId != '' " >
2024-05-27 16:30:00 +08:00
AND lai.company_id = #{record.companyId} or su.dept_id = #{record.companyId}
2024-05-14 16:44:16 +08:00
</if>
2024-02-22 17:02:04 +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-03-22 17:38:48 +08:00
AND bpl.lot_id = #{record.projectId}
2024-02-22 17:02:04 +08:00
</if>
<if test= "record.keyWord != null and record.keyWord != ''" >
2024-03-22 17:38:48 +08:00
AND (bai.agreement_code like concat('%', #{record.keyWord}, '%') or
tt.code like concat('%', #{record.keyWord}, '%'))
2024-02-22 17:02:04 +08:00
</if>
2024-04-30 14:09:40 +08:00
GROUP BY tt.task_id
2024-02-22 17:02:04 +08:00
ORDER BY tt.update_time DESC
2024-02-21 19:24:08 +08:00
</select>
2024-02-27 13:20:31 +08:00
<select id= "getLeaseApplyDetailsByApply" resultType= "com.bonus.sgzb.app.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-03-27 18:15:32 +08:00
IFNULL(mt.num,0) AS num, (lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,mm.ma_code as maCode
2024-02-27 13:20:31 +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.parennt_id = #{record.id}
GROUP BY
lad.id
</select>
2024-03-16 15:33:49 +08:00
<select id= "getLeaseApplyDetailsCq" resultType= "com.bonus.sgzb.app.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.parennt_id = #{record.id}
GROUP BY
lad.id
</select>
2024-03-16 18:44:04 +08:00
<select id= "getLeaseOutListByUser" resultType= "com.bonus.sgzb.app.domain.TmTask" >
2024-06-17 16:30:46 +08:00
SELECT
tt.*,
lai.id AS id,
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,
d.id AS examineStatusId,
bai.agreement_code AS agreementCode,
tt.create_time AS createTimes,
IFNULL( sum( lad.pre_num ), 0 ) AS preCountNum,
IFNULL( sum( lad.al_num ), 0 ) AS alNum,
tt.update_time AS updateTimes
FROM
lease_apply_info lai
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
LEFT JOIN tm_task_agreement tta ON lai.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_details lad ON lai.id = lad.parennt_id
LEFT JOIN ( SELECT mtk.type_id, mtk.user_id FROM ma_type_keeper mtk LEFT JOIN lease_apply_details lad1 ON lad1.type_id = mtk.type_id LIMIT 1 ) aa ON lad.type_id = aa.type_id
WHERE
tt.task_status IN ( 33, 34, 35 )
<if test= "userId != 1" >
and aa.user_id = #{userId}
</if>
<if test= "code != null and code != ''" >
and tt.code like concat('%', #{code}, '%')
</if>
<if test= "unitId != null" >
and bui.unit_id = #{unitId}
</if>
<if test= "proId != null" >
and bpl.lot_id = #{proId}
</if>
<if test= "taskStatus != null" >
and tt.task_status = #{taskStatus}
</if>
GROUP BY
lai.id
ORDER BY
tt.task_status,
tt.create_time DESC
2024-03-16 18:44:04 +08:00
</select>
<select id= "getLeaseDetailByParentId" resultType= "com.bonus.sgzb.app.domain.TmTask" >
SELECT
2024-04-28 16:16:29 +08:00
lai.task_id as taskId,
lad.id as id,
lad.parennt_id as parentId,
lad.pre_num - ifnull(lad.al_num,0) as outNum,
lad.pre_num as preCountNum,
ifnull(lad.al_num,0) as alNum,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.manage_type as manageType,
mt.num as num,
2024-06-06 17:59:23 +08:00
GROUP_CONCAT(su.user_name) as userName,
2024-06-05 13:15:29 +08:00
lad.status as status,
2024-04-28 16:16:29 +08:00
lad.type_id as typeId
2024-03-16 18:44:04 +08:00
FROM
2024-04-28 16:16:29 +08:00
lease_apply_details lad
LEFT JOIN lease_apply_info lai on lad.parennt_id = lai.id
LEFT JOIN ma_type mt on lad.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN ma_type_keeper mtk on lad.type_id = mtk.type_id
LEFT JOIN sys_user su on mtk.user_id = su.user_id
2024-03-16 18:44:04 +08:00
WHERE
2024-04-28 16:16:29 +08:00
lad.parennt_id = #{id}
2024-03-22 17:38:48 +08:00
<if test= "userId != 1" >
2024-03-16 18:44:04 +08:00
and mtk.user_id = #{userId}
</if>
2024-04-01 15:43:18 +08:00
<if test= "userName != null and userName != ''" >
2024-04-02 13:57:55 +08:00
and su.user_name like concat('%', #{userName}, '%')
2024-04-01 15:43:18 +08:00
</if>
<if test= "typeId != null and typeId != ''" >
and lad.type_id = #{typeId}
</if>
2024-06-06 17:59:23 +08:00
GROUP BY lad.type_id
2024-03-16 18:44:04 +08:00
</select>
2024-04-15 16:03:44 +08:00
<select id= "getMaTypeDetails" resultType= "com.bonus.sgzb.app.domain.TmTask" >
2024-04-17 10:26:01 +08:00
SELECT
mws2.type_id AS typeId,
mws2.part_num AS partNum
FROM
ma_type mt1
LEFT JOIN ma_whole_set mws2 ON mt1.type_id = mws2.parent_id
WHERE
mt1.type_id = #{typeId}
</select>
<select id= "getMachineParts" resultType= "com.bonus.sgzb.app.domain.MachinePart" >
SELECT
mt.type_name AS typeModelName,
2024-04-20 10:42:49 +08:00
mt.type_id as modelId,
2024-04-17 10:26:01 +08:00
mt.unit_name as unitName,
m2.type_name As typeName
FROM
ma_type mt
LEFT JOIN ma_type m2 ON mt.parent_id = m2.type_id
WHERE
mt.type_id = #{typeId}
2024-04-15 16:03:44 +08:00
</select>
2024-04-20 10:42:49 +08:00
<select id= "getMaTypeDetailsByTypeId" resultType= "com.bonus.sgzb.app.domain.TmTask" >
SELECT
mws2.type_id AS typeId,
mws2.part_num AS partNum
FROM
ma_type mt1
LEFT JOIN ma_whole_set mws2 ON mt1.type_id = mws2.parent_id
WHERE
mt1.type_id = #{modelId}
</select>
<select id= "getManageTypeByTypeId" resultType= "com.bonus.sgzb.app.domain.TmTask" >
SELECT
mt2.manage_type as manageType,
mws.type_id as typeId,
mt2.type_name as typeModelName,
mt3.type_name as typeName,
(lad.pre_num - ifnull(lad.al_num,0)) * mws.part_num as outNum,
ifnull(lad.al_num,0) * mws.part_num as alNum
FROM
ma_whole_set mws
LEFT JOIN lease_apply_details lad on lad.type_id = mws.parent_id
LEFT JOIN lease_apply_info lai on lad.parennt_id = lai.id
LEFT JOIN ma_type mt ON mt.type_id = mws.parent_id
LEFT JOIN ma_type mt2 on mws.type_id = mt2.type_id
LEFT JOIN ma_type mt3 on mt3.type_id = mt2.parent_id
WHERE
mt.type_id = #{typeId} and lad.parennt_id = #{parentId}
</select>
<select id= "getCountMachine" resultType= "java.lang.Integer" >
SELECT
ifnull(sum( back_num ),0)
FROM
back_check_details
WHERE
parent_id = #{id}
</select>
<select id= "getCountMachineByPidAndTid" resultType= "java.lang.Integer" >
SELECT
ifnull(sum( back_num ),0)
FROM
back_check_details
WHERE
parent_id = #{parentId} and type_id = #{modelId}
</select>
2024-04-20 11:23:08 +08:00
<select id= "selectTaskNumByMonths" resultType= "java.lang.String" >
SELECT SUBSTRING(`code`, - 4) as code
FROM tm_task
WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
AND task_type = #{taskType}
ORDER BY create_time DESC LIMIT 1
</select>
2024-05-29 09:12:30 +08:00
<select id= "getDeptId" resultType= "java.lang.Integer" >
select dept_id from sys_user where user_id = #{createBy}
</select>
2024-06-03 18:45:24 +08:00
<select id= "getLeaseOutListByjjbz" resultType= "com.bonus.sgzb.app.domain.TmTask" >
SELECT
tt.*,
lai.id AS id,
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,
d.id AS examineStatusId,
bai.agreement_code AS agreementCode,
tt.create_time AS createTimes,
IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(sum(lad.al_num),0) as alNum,
tt.update_time AS updateTimes
from
lease_apply_info lai
LEFT JOIN tm_task tt on lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
LEFT JOIN tm_task_agreement tta ON lai.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_details lad on lai.id = lad.parennt_id
LEFT JOIN ma_type_keeper mtk on lad.type_id = mtk.type_id
WHERE tt.task_status in(33,34,35)
<if test= "code != null and code != ''" >
and tt.code like concat('%', #{code}, '%')
</if>
<if test= "unitId != null" >
and bui.unit_id = #{unitId}
</if>
<if test= "proId != null" >
and bpl.lot_id = #{proId}
</if>
<if test= "taskStatus != null" >
and tt.task_status = #{taskStatus}
</if>
and lai.company_id = 101
GROUP BY lai.id
ORDER BY tt.task_status,tt.create_time desc
</select>
2024-06-05 13:15:29 +08:00
<select id= "getleaseDetailsStatus" resultType= "com.bonus.sgzb.app.domain.LeaseApplyDetails" >
SELECT
lad.`status` status,
tt.task_id taskId
FROM
tm_task tt
LEFT JOIN lease_apply_info lai ON tt.task_id = lai.task_id
LEFT JOIN lease_apply_details lad ON lai.id = lad.parennt_id
WHERE
lai.id = #{id}
</select>
2024-06-19 09:52:03 +08:00
<select id= "getUserByParenntId" resultType= "com.bonus.sgzb.app.domain.TmTask" >
SELECT
lad.id as id,
lad.parennt_id as parentId,
GROUP_CONCAT(su.user_name) as userName,
GROUP_CONCAT(su.phonenumber) as phoneNumber,
lad.status as status,
lad.type_id as typeId
FROM
lease_apply_details lad
LEFT JOIN ma_type_keeper mtk on lad.type_id = mtk.type_id
LEFT JOIN sys_user su on mtk.user_id = su.user_id
WHERE
lad.parennt_id = #{id}
GROUP BY lad.type_id
</select>
2024-01-11 13:40:03 +08:00
</mapper>