304 lines
17 KiB
XML
304 lines
17 KiB
XML
<?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.lease.mapper.LeaseApplyInfoMapper">
|
|
<resultMap type="com.bonus.common.biz.domain.lease.LeaseApplyInfo" id="LeaseApplyInfoResult">
|
|
<result property="id" column="id" />
|
|
<result property="code" column="code" />
|
|
<result property="taskId" column="task_id" />
|
|
<result property="leasePerson" column="lease_person" />
|
|
<result property="phone" column="phone" />
|
|
<result property="type" column="type" />
|
|
<result property="companyAuditBy" column="company_audit_by" />
|
|
<result property="companyAuditTime" column="company_audit_time" />
|
|
<result property="companyAuditRemark" column="company_audit_remark" />
|
|
<result property="deptAuditBy" column="dept_audit_by" />
|
|
<result property="deptAuditTime" column="dept_audit_time" />
|
|
<result property="deptAuditRemark" column="dept_audit_remark" />
|
|
<result property="directAuditBy" column="direct_audit_by" />
|
|
<result property="directAuditTime" column="direct_audit_time" />
|
|
<result property="directAuditRemark" column="direct_audit_remark" />
|
|
<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="directId" column="direct_id" />
|
|
<result property="leaseType" column="lease_type" />
|
|
<result property="estimateLeaseTime" column="estimate_lease_time" />
|
|
<result property="costBearingParty" column="cost_bearing_party" />
|
|
<result property="leaseProject" column="pro_name" />
|
|
<result property="leaseProjectId" column="project_id" />
|
|
<result property="leaseUnit" column="unit_name" />
|
|
<result property="leaseUnitId" column="unit_id" />
|
|
<result property="agreementCode" column="agreement_code" />
|
|
<result property="leaseSignUrl" column="lease_sign_url" />
|
|
<result property="leaseSignType" column="lease_sign_type" />
|
|
</resultMap>
|
|
|
|
<sql id="selectLeaseApplyInfoVo">
|
|
select
|
|
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,
|
|
lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
|
|
lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
|
|
lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
|
|
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url, lai.lease_sign_type,
|
|
bai.unit_id,bai.project_id,bu.unit_name, bp.pro_name, bai.agreement_code, tt.task_status as taskStatus,
|
|
sda.dict_label as taskStatusName,
|
|
IFNULL(sum(lad.pre_num),0) as preCountNum,
|
|
IFNULL(sum(lad.al_num),0) as alNum,
|
|
GROUP_CONCAT(mt1.type_name) as maTypeNames,
|
|
bp.contract_part as contractPart,
|
|
sd.dept_name as impUnitName
|
|
from
|
|
lease_apply_info lai
|
|
left join tm_task tt on lai.task_id = tt.task_id
|
|
left join lease_apply_details lad on lai.id = lad.parent_id
|
|
left join tm_task_agreement tta on lai.task_id = tta.task_id
|
|
left join bm_agreement_info bai on tta.agreement_id = bai.agreement_id
|
|
left join bm_unit bu on bu.unit_id = bai.unit_id
|
|
left join bm_project bp on bp.pro_id = bai.project_id
|
|
left join sys_dept sd on sd.dept_id = bp.imp_unit
|
|
left join sys_dict_data sda on tt.task_status = sda.dict_value
|
|
and sda.dict_type = 'lease_task_status'
|
|
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
|
|
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
|
<if test="userId != null">
|
|
JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="selectLeaseApplyInfoList" parameterType="com.bonus.common.biz.domain.lease.LeaseApplyInfo" resultMap="LeaseApplyInfoResult">
|
|
<include refid="selectLeaseApplyInfoVo"/>
|
|
<where>
|
|
<if test="code != null and code != ''"> and lai.code = #{code}</if>
|
|
<if test="taskId != null "> and lai.task_id = #{taskId}</if>
|
|
<if test="leasePerson != null and leasePerson != ''"> and lai.lease_person = #{leasePerson}</if>
|
|
<if test="phone != null and phone != ''"> and lai.phone = #{phone}</if>
|
|
<if test="type != null and type != ''"> and lai.type = #{type}</if>
|
|
<if test="companyAuditBy != null "> and lai.company_audit_by = #{companyAuditBy}</if>
|
|
<if test="companyAuditTime != null "> and lai.company_audit_time = #{companyAuditTime}</if>
|
|
<if test="companyAuditRemark != null and companyAuditRemark != ''"> and lai.company_audit_remark = #{companyAuditRemark}</if>
|
|
<if test="deptAuditBy != null "> and lai.dept_audit_by = #{deptAuditBy}</if>
|
|
<if test="deptAuditTime != null "> and lai.dept_audit_time = #{deptAuditTime}</if>
|
|
<if test="deptAuditRemark != null and deptAuditRemark != ''"> and lai.dept_audit_remark = #{deptAuditRemark}</if>
|
|
<if test="directAuditBy != null "> and lai.direct_audit_by = #{directAuditBy}</if>
|
|
<if test="directAuditTime != null "> and lai.direct_audit_time = #{directAuditTime}</if>
|
|
<if test="directAuditRemark != null and directAuditRemark != ''"> and lai.direct_audit_remark = #{directAuditRemark}</if>
|
|
<if test="companyId != null "> and lai.company_id = #{companyId}</if>
|
|
<if test="statusList != null and statusList.size() > 0">
|
|
and tt.task_status in
|
|
<foreach item="item" collection="statusList" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
<![CDATA[ AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
|
</if>
|
|
<if test="directId != null "> and lai.direct_id = #{directId}</if>
|
|
<if test="leaseType != null and leaseType != ''"> and lai.lease_type = #{leaseType}</if>
|
|
<if test="estimateLeaseTime != null "> and lai.estimate_lease_time = #{estimateLeaseTime}</if>
|
|
<if test="costBearingParty != null and costBearingParty != ''"> and lai.cost_bearing_party = #{costBearingParty}</if>
|
|
and tt.task_type = '2'
|
|
</where>
|
|
GROUP BY lai.id
|
|
ORDER BY tt.task_status,tt.create_time desc
|
|
</select>
|
|
|
|
<select id="selectLeaseApplyInfoById" parameterType="Long" resultMap="LeaseApplyInfoResult">
|
|
<include refid="selectLeaseApplyInfoVo"/>
|
|
where lai.id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertLeaseApplyInfo" parameterType="com.bonus.common.biz.domain.lease.LeaseApplyInfo" useGeneratedKeys="true" keyProperty="id">
|
|
insert into lease_apply_info
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="code != null">code,</if>
|
|
<if test="taskId != null">task_id,</if>
|
|
<if test="leasePerson != null">lease_person,</if>
|
|
<if test="phone != null">phone,</if>
|
|
<if test="type != null">type,</if>
|
|
<if test="companyAuditBy != null">company_audit_by,</if>
|
|
<if test="companyAuditTime != null">company_audit_time,</if>
|
|
<if test="companyAuditRemark != null">company_audit_remark,</if>
|
|
<if test="deptAuditBy != null">dept_audit_by,</if>
|
|
<if test="deptAuditTime != null">dept_audit_time,</if>
|
|
<if test="deptAuditRemark != null">dept_audit_remark,</if>
|
|
<if test="directAuditBy != null">direct_audit_by,</if>
|
|
<if test="directAuditTime != null">direct_audit_time,</if>
|
|
<if test="directAuditRemark != null">direct_audit_remark,</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>
|
|
<if test="directId != null">direct_id,</if>
|
|
<if test="leaseType != null">lease_type,</if>
|
|
<if test="estimateLeaseTime != null">estimate_lease_time,</if>
|
|
<if test="costBearingParty != null">cost_bearing_party,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="code != null">#{code},</if>
|
|
<if test="taskId != null">#{taskId},</if>
|
|
<if test="leasePerson != null">#{leasePerson},</if>
|
|
<if test="phone != null">#{phone},</if>
|
|
<if test="type != null">#{type},</if>
|
|
<if test="companyAuditBy != null">#{companyAuditBy},</if>
|
|
<if test="companyAuditTime != null">#{companyAuditTime},</if>
|
|
<if test="companyAuditRemark != null">#{companyAuditRemark},</if>
|
|
<if test="deptAuditBy != null">#{deptAuditBy},</if>
|
|
<if test="deptAuditTime != null">#{deptAuditTime},</if>
|
|
<if test="deptAuditRemark != null">#{deptAuditRemark},</if>
|
|
<if test="directAuditBy != null">#{directAuditBy},</if>
|
|
<if test="directAuditTime != null">#{directAuditTime},</if>
|
|
<if test="directAuditRemark != null">#{directAuditRemark},</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>
|
|
<if test="directId != null">#{directId},</if>
|
|
<if test="leaseType != null">#{leaseType},</if>
|
|
<if test="estimateLeaseTime != null">#{estimateLeaseTime},</if>
|
|
<if test="costBearingParty != null">#{costBearingParty},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateLeaseApplyInfo" parameterType="com.bonus.common.biz.domain.lease.LeaseApplyInfo">
|
|
update lease_apply_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="code != null">code = #{code},</if>
|
|
<if test="taskId != null">task_id = #{taskId},</if>
|
|
<if test="leasePerson != null">lease_person = #{leasePerson},</if>
|
|
<if test="phone != null">phone = #{phone},</if>
|
|
<if test="type != null">`type` = #{type},</if>
|
|
<if test="companyAuditBy != null">company_audit_by = #{companyAuditBy},</if>
|
|
<if test="companyAuditTime != null">company_audit_time = #{companyAuditTime},</if>
|
|
<if test="companyAuditRemark != null">company_audit_remark = #{companyAuditRemark},</if>
|
|
<if test="deptAuditBy != null">dept_audit_by = #{deptAuditBy},</if>
|
|
<if test="deptAuditTime != null">dept_audit_time = #{deptAuditTime},</if>
|
|
<if test="deptAuditRemark != null">dept_audit_remark = #{deptAuditRemark},</if>
|
|
<if test="directAuditBy != null">direct_audit_by = #{directAuditBy},</if>
|
|
<if test="directAuditTime != null">direct_audit_time = #{directAuditTime},</if>
|
|
<if test="directAuditRemark != null">direct_audit_remark = #{directAuditRemark},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
update_time = now(),
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="companyId != null">company_id = #{companyId},</if>
|
|
<if test="directId != null">direct_id = #{directId},</if>
|
|
<if test="leaseType != null">lease_type = #{leaseType},</if>
|
|
<if test="estimateLeaseTime != null">estimate_lease_time = #{estimateLeaseTime},</if>
|
|
<if test="costBearingParty != null">cost_bearing_party = #{costBearingParty},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteLeaseApplyInfoById" parameterType="Long">
|
|
delete from lease_apply_info where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteLeaseApplyInfoByIds" parameterType="String">
|
|
delete from lease_apply_info where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="getTaskId" resultType="java.lang.String">
|
|
select task_id
|
|
from lease_apply_info
|
|
where id = #{parentId}
|
|
</select>
|
|
|
|
<update id="updateLeaseApplyInfoSign">
|
|
update lease_apply_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="leaseSignUrl != null and leaseSignUrl != '' ">lease_sign_url = #{leaseSignUrl},</if>
|
|
<if test="leaseSignType != null">lease_sign_type = #{leaseSignType},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!-- 设置审批人为默认的董班长 防止代码冲突-->
|
|
<select id="getDirectAuditBy" resultType="Long">
|
|
select
|
|
sc.people_id as peopleId
|
|
from sign_config sc
|
|
where sc.process_id = 0 and sc.sign_type = 0 and sc.del_flag = 0
|
|
</select>
|
|
|
|
<!-- 设置审批人签名url 防止代码冲突-->
|
|
<select id="getDirectAuditUrl" resultType="java.lang.String">
|
|
select
|
|
su.sign_url as directAuditSignUrl
|
|
from sys_user su
|
|
where su.user_id = #{directAuditBy} and su.del_flag = 0
|
|
</select>
|
|
|
|
<!-- 设置发料单位 防止代码冲突-->
|
|
<select id="getSendUnit" resultType="java.lang.String">
|
|
select
|
|
sd.dept_name as sendUnit
|
|
from sys_user su
|
|
left join sys_dept sd on su.dept_id = sd.dept_id and sd.del_flag = 0
|
|
where su.user_id = #{directAuditBy} and su.del_flag = 0
|
|
</select>
|
|
|
|
<select id="selectPublishList" resultType="com.bonus.common.biz.domain.lease.LeaseApplyInfo">
|
|
SELECT
|
|
lai.id AS id,
|
|
lai.code AS code,
|
|
lai.create_by AS createBy,
|
|
lai.create_time AS createTime,
|
|
sd.dept_name AS impUnitName,
|
|
bp.contract_part AS contractPart,
|
|
lpd.lease_person AS leasePerson,
|
|
lpd.phone AS phone,
|
|
lpd.unit_id AS leaseUnitId,
|
|
lpd.project_id AS leaseProjectId,
|
|
bu.unit_name AS leaseUnit,
|
|
bp.pro_name AS leaseProject,
|
|
bai.agreement_code AS agreementCode,
|
|
IFNULL( sum( lpd.num ), 0 ) AS preCountNum,
|
|
IFNULL(lod.num, 0) AS alNum,
|
|
GROUP_CONCAT( DISTINCT mt1.type_name ) AS maTypeNames,
|
|
lpd.publish_task AS publishTask
|
|
FROM
|
|
lease_publish_details lpd
|
|
LEFT JOIN lease_apply_info lai ON lai.id = lpd.parent_id
|
|
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
|
|
LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task from lease_out_details
|
|
GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id
|
|
AND lpd.publish_task = lod.publish_task
|
|
LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id
|
|
LEFT JOIN bm_project bp ON bp.pro_id = lpd.project_id
|
|
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
|
LEFT JOIN ma_type mt ON lpd.new_type = mt.type_id
|
|
AND mt.del_flag = '0'
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
AND mt1.del_flag = '0'
|
|
LEFT JOIN bm_agreement_info bai ON lpd.unit_id = bai.unit_id
|
|
AND lpd.project_id = bai.project_id
|
|
<if test="userId != null">
|
|
JOIN ma_type_keeper mtk ON mtk.type_id = lpd.type_id AND mtk.user_id = #{userId}
|
|
</if>
|
|
where 1 = 1
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
<![CDATA[ AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
|
</if>
|
|
<if test="id != null ">
|
|
AND lai.id = #{id}
|
|
</if>
|
|
<if test="publishTask != null and publishTask != ''">
|
|
AND lpd.publish_task = #{publishTask}
|
|
</if>
|
|
GROUP BY
|
|
lpd.publish_task
|
|
ORDER BY
|
|
lpd.create_time DESC
|
|
</select>
|
|
</mapper> |