2025-02-17 17:43:58 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
<!DOCTYPE mapper
|
2025-02-18 18:58:20 +08:00
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2025-02-17 17:43:58 +08:00
|
|
|
<mapper namespace="com.bonus.material.lease.mapper.LeaseTaskMapper">
|
|
|
|
|
<resultMap type="com.bonus.common.biz.domain.lease.LeaseApplyInfo" id="LeaseApplyInfoResult">
|
2025-02-18 18:58:20 +08:00
|
|
|
<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"/>
|
2025-02-20 20:40:53 +08:00
|
|
|
<result property="agreementId" column="agreement_id"/>
|
2025-02-18 18:58:20 +08:00
|
|
|
<result property="agreementCode" column="agreement_code"/>
|
|
|
|
|
<result property="leaseSignUrl" column="lease_sign_url"/>
|
|
|
|
|
<result property="leaseSignType" column="lease_sign_type"/>
|
|
|
|
|
<result property="applyCode" column="apply_code"/>
|
2025-02-17 17:43:58 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<resultMap type="com.bonus.material.lease.domain.LeaseApplyDetails" id="LeaseApplyDetailsResult">
|
2025-02-18 18:58:20 +08:00
|
|
|
<result property="id" column="id"/>
|
|
|
|
|
<result property="parentId" column="parent_id"/>
|
|
|
|
|
<result property="typeId" column="type_id"/>
|
|
|
|
|
<result property="typeName" column="type_name"/>
|
|
|
|
|
<result property="maTypeName" column="ma_type_name"/>
|
|
|
|
|
<result property="unitName" column="unit_name"/>
|
|
|
|
|
<result property="unitValue" column="unit_value"/>
|
|
|
|
|
<result property="storageNum" column="storage_num"/>
|
|
|
|
|
<result property="preNum" column="pre_num"/>
|
|
|
|
|
<result property="auditNum" column="audit_num"/>
|
|
|
|
|
<result property="alNum" column="al_num"/>
|
|
|
|
|
<result property="status" column="status"/>
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
<resultMap type="com.bonus.material.ma.domain.Type" id="TypeResult">
|
|
|
|
|
<result property="typeId" column="type_id"/>
|
|
|
|
|
<result property="typeName" column="type_name"/>
|
|
|
|
|
<result property="parentId" column="parent_id"/>
|
|
|
|
|
<result property="keeperNickName" column="keeper_nick_name"/>
|
|
|
|
|
<result property="repairNickName" column="repair_nick_name"/>
|
|
|
|
|
<result property="houseId" column="house_id"/>
|
|
|
|
|
<result property="houseName" column="house_name"/>
|
|
|
|
|
<result property="storageNum" column="storage_num"/>
|
|
|
|
|
<result property="typeCode" column="type_code"/>
|
|
|
|
|
<result property="modelCode" column="model_code"/>
|
|
|
|
|
<result property="unitId" column="unit_id"/>
|
|
|
|
|
<result property="unitName" column="unit_name"/>
|
|
|
|
|
<result property="unitValue" column="unit_value"/>
|
|
|
|
|
<result property="sortNum" column="sort_num"/>
|
|
|
|
|
<result property="manageType" column="manage_type"/>
|
|
|
|
|
<result property="leasePrice" column="lease_price"/>
|
|
|
|
|
<result property="effTime" column="eff_time"/>
|
|
|
|
|
<result property="rentPrice" column="rent_price"/>
|
|
|
|
|
<result property="buyPrice" column="buy_price"/>
|
|
|
|
|
<result property="payRatio" column="pay_ratio"/>
|
|
|
|
|
<result property="payPrice" column="pay_price"/>
|
|
|
|
|
<result property="taxRatio" column="tax_ratio"/>
|
|
|
|
|
<result property="level" column="level"/>
|
|
|
|
|
<result property="ratedLoad" column="rated_load"/>
|
|
|
|
|
<result property="testLoad" column="test_load"/>
|
|
|
|
|
<result property="holdingTime" column="holding_time"/>
|
|
|
|
|
<result property="warnNum" column="warn_num"/>
|
|
|
|
|
<result property="delFlag" column="del_flag"/>
|
|
|
|
|
<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="isPlan" column="is_plan"/>
|
|
|
|
|
<result property="isAncuo" column="is_ancuo"/>
|
|
|
|
|
<result property="remark" column="remark"/>
|
|
|
|
|
<result property="facModel" column="fac_model"/>
|
|
|
|
|
<result property="intelligentCode" column="intelligent_code"/>
|
|
|
|
|
<result property="isTest" column="is_test"/>
|
2025-02-17 17:43:58 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
2025-02-28 18:20:55 +08:00
|
|
|
|
|
|
|
|
|
2025-02-17 17:43:58 +08:00
|
|
|
<sql id="selectLeaseApplyInfoVo">
|
|
|
|
|
select
|
2025-02-18 18:58:20 +08:00
|
|
|
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
|
|
|
|
|
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,
|
2025-02-20 22:35:19 +08:00
|
|
|
lai.lease_sign_type,tt.task_id as taskId,
|
2025-02-20 20:40:53 +08:00
|
|
|
bai.unit_id,bai.project_id,bu.unit_name, bp.pro_name,bai.agreement_id, bai.agreement_code, tt.task_status as taskStatus,
|
2025-02-20 22:35:19 +08:00
|
|
|
|
2025-02-19 20:29:20 +08:00
|
|
|
case tt.task_status
|
|
|
|
|
when 0 then '待审核'
|
|
|
|
|
when 1 then '待审核'
|
|
|
|
|
when 2 then '审核中'
|
|
|
|
|
when 3 then '已完成'
|
|
|
|
|
when 4 then '已完成'
|
|
|
|
|
end as taskStatusName,
|
2025-02-18 18:58:20 +08:00
|
|
|
IFNULL(sum(lad.pre_num),0) as preCountNum,
|
|
|
|
|
IFNULL(sum(lad.al_num),0) as alNum,
|
|
|
|
|
GROUP_CONCAT(DISTINCT mt1.type_name) AS maTypeNames,
|
|
|
|
|
bp.contract_part as contractPart,
|
|
|
|
|
sd.dept_name as impUnitName
|
2025-02-17 17:43:58 +08:00
|
|
|
from
|
2025-02-18 18:58:20 +08:00
|
|
|
lease_apply_info lai
|
2025-02-17 17:43:58 +08:00
|
|
|
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'
|
2025-02-18 18:58:20 +08:00
|
|
|
<!-- <if test="userId != null">-->
|
|
|
|
|
<!-- JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}-->
|
|
|
|
|
<!-- </if>-->
|
2025-02-17 17:43:58 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<sql id="selectLeaseApplyDetailsVo">
|
|
|
|
|
select
|
|
|
|
|
lad.id, lad.parent_id, mt.type_id, mt.type_name, mt2.type_name as ma_type_name,
|
|
|
|
|
CASE mt.manage_type
|
|
|
|
|
WHEN 0 THEN
|
|
|
|
|
IFNULL(subquery0.num, 0)
|
|
|
|
|
ELSE
|
|
|
|
|
IFNULL(mt.storage_num, 0)
|
|
|
|
|
END as storage_num,
|
|
|
|
|
mt.manage_type as manageType,
|
|
|
|
|
(lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,
|
|
|
|
|
IFNULL(lad.pre_num,0) as pre_num,
|
|
|
|
|
IFNULL(lad.audit_num,0) as audit_num,
|
|
|
|
|
IFNULL(lad.al_num,0) as al_num,
|
|
|
|
|
IFNULL(lad.status,0) as status, mt.unit_name,mt.unit_value,
|
|
|
|
|
lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark, lad.company_id
|
|
|
|
|
from
|
|
|
|
|
lease_apply_details lad
|
|
|
|
|
left join
|
2025-02-18 18:58:20 +08:00
|
|
|
ma_type mt on lad.type_id = mt.type_id and mt.`level` = '4' and mt.del_flag = '0'
|
2025-02-17 17:43:58 +08:00
|
|
|
left join
|
|
|
|
|
ma_type mt2 on mt2.type_id = mt.parent_id and mt2.`level` = '3' and mt2.del_flag = '0'
|
|
|
|
|
left join (SELECT mt.type_id,
|
2025-02-18 18:58:20 +08:00
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt.type_name AS typeModelName,
|
2025-02-17 17:43:58 +08:00
|
|
|
count(mm.ma_id) num
|
|
|
|
|
FROM ma_machine mm
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
WHERE mm.ma_code is not null and mm.ma_status in (1)
|
|
|
|
|
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
2025-02-18 18:58:20 +08:00
|
|
|
<!-- <if test="userId != null">-->
|
|
|
|
|
<!-- JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}-->
|
|
|
|
|
<!-- </if>-->
|
2025-02-17 17:43:58 +08:00
|
|
|
</sql>
|
|
|
|
|
|
2025-02-18 18:58:20 +08:00
|
|
|
<insert id="insertLeaseApplyInfo" parameterType="com.bonus.common.biz.domain.lease.LeaseApplyInfo"
|
|
|
|
|
useGeneratedKeys="true" keyProperty="id">
|
2025-02-17 17:43:58 +08:00
|
|
|
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>
|
|
|
|
|
<if test="applyCode != null">apply_code,</if>
|
2025-02-28 18:20:55 +08:00
|
|
|
<if test="supplierTime != null">supplier_time,</if>
|
|
|
|
|
<if test="supplierPlace != null">supplier_place,</if>
|
|
|
|
|
<if test="unitId != null">unit_id,</if>
|
|
|
|
|
<if test="projectId != null">project_id,</if>
|
2025-02-17 17:43:58 +08:00
|
|
|
</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>
|
|
|
|
|
<if test="applyCode != null">#{applyCode},</if>
|
2025-02-28 18:20:55 +08:00
|
|
|
<if test="supplierTime != null">#{supplierTime},</if>
|
|
|
|
|
<if test="supplierPlace != null">#{supplierPlace},</if>
|
|
|
|
|
<if test="unitId != null">#{unitId},</if>
|
|
|
|
|
<if test="projectId != null">#{projectId},</if>
|
2025-02-17 17:43:58 +08:00
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2025-02-18 18:58:20 +08:00
|
|
|
<insert id="insertLeaseApplyDetailsList" keyColumn="id" keyProperty="id" parameterType="map"
|
|
|
|
|
useGeneratedKeys="true">
|
2025-02-17 17:43:58 +08:00
|
|
|
insert into lease_apply_details
|
|
|
|
|
(parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by,
|
2025-02-28 18:20:55 +08:00
|
|
|
update_time, remark, company_id,ma_type_ids,is_manual)
|
2025-02-17 17:43:58 +08:00
|
|
|
values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.parentId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=INTEGER},
|
|
|
|
|
#{item.alNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
|
|
|
|
|
NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(),
|
2025-02-28 18:20:55 +08:00
|
|
|
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER},#{item.maTypeIdsStr,jdbcType=VARCHAR},
|
|
|
|
|
#{item.isManual,jdbcType=INTEGER})
|
2025-02-17 17:43:58 +08:00
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateLeaseApplyInfo">
|
|
|
|
|
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>
|
|
|
|
|
<if test="applyCode != null">apply_code = #{applyCode},</if>
|
2025-02-28 18:20:55 +08:00
|
|
|
<if test="supplierTime != null">supplier_time = #{supplierTime},</if>
|
|
|
|
|
<if test="supplierPlace != null">supplier_place = #{supplierPlace},</if>
|
2025-02-17 17:43:58 +08:00
|
|
|
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>
|
|
|
|
|
|
2025-02-18 18:58:20 +08:00
|
|
|
<select id="selectLeaseApplyInfoList" parameterType="com.bonus.common.biz.domain.lease.LeaseApplyInfo"
|
|
|
|
|
resultMap="LeaseApplyInfoResult">
|
2025-02-28 18:20:55 +08:00
|
|
|
select
|
|
|
|
|
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
|
|
|
|
|
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,tt.task_id as taskId,
|
|
|
|
|
lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus,
|
|
|
|
|
|
|
|
|
|
case tt.task_status
|
|
|
|
|
when 0 then '待审核'
|
|
|
|
|
when 1 then '待审核'
|
|
|
|
|
when 2 then '审核中'
|
|
|
|
|
when 3 then '已完成'
|
|
|
|
|
when 4 then '已完成'
|
|
|
|
|
end as taskStatusName,
|
|
|
|
|
IFNULL(sum(lad.pre_num),0) as preCountNum,
|
|
|
|
|
IFNULL(sum(lad.al_num),0) as alNum,
|
|
|
|
|
GROUP_CONCAT(DISTINCT 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_unit bu on bu.unit_id = lai.unit_id
|
|
|
|
|
left join bm_project bp on bp.pro_id = lai.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'
|
2025-03-04 17:31:59 +08:00
|
|
|
where tt.task_type = '19'
|
2025-02-18 18:58:20 +08:00
|
|
|
<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>
|
2025-02-17 17:43:58 +08:00
|
|
|
<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 != ''">
|
2025-02-19 20:29:20 +08:00
|
|
|
AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
|
2025-02-17 17:43:58 +08:00
|
|
|
</if>
|
2025-02-18 18:58:20 +08:00
|
|
|
<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>
|
2025-02-19 20:29:20 +08:00
|
|
|
<if test="isApp != null and taskStatus==1">and (tt.task_status = 0 or tt.task_status = 1 or tt.task_status = 2) </if>
|
|
|
|
|
<if test="isApp != null and taskStatus==3">and (tt.task_status = 3 or tt.task_status = 4)</if>
|
2025-02-17 17:43:58 +08:00
|
|
|
GROUP BY lai.id
|
|
|
|
|
ORDER BY tt.task_status,tt.create_time desc
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-02-18 18:58:20 +08:00
|
|
|
<select id="selectLeaseApplyDetailsList" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails"
|
|
|
|
|
resultMap="LeaseApplyDetailsResult">
|
2025-02-17 17:43:58 +08:00
|
|
|
<include refid="selectLeaseApplyDetailsVo"/>
|
|
|
|
|
<where>
|
2025-02-18 18:58:20 +08:00
|
|
|
<if test="parentId != null ">and lad.parent_id = #{parentId}</if>
|
2025-02-17 17:43:58 +08:00
|
|
|
<if test="keyword != null and keyword != ''">
|
|
|
|
|
AND (mt.type_name LIKE CONCAT('%', #{keyword}, '%')
|
|
|
|
|
OR mt2.type_name LIKE CONCAT('%', #{keyword}, '%'))
|
|
|
|
|
</if>
|
2025-02-18 18:58:20 +08:00
|
|
|
<if test="typeId != null ">and lad.type_id = #{typeId}</if>
|
|
|
|
|
<if test="preNum != null ">and lad.pre_num = #{preNum}</if>
|
|
|
|
|
<if test="auditNum != null ">and lad.audit_num = #{auditNum}</if>
|
|
|
|
|
<if test="alNum != null ">and lad.al_num = #{alNum}</if>
|
|
|
|
|
<if test="status != null and status != ''">and lad.status = #{status}</if>
|
|
|
|
|
<if test="companyId != null ">and lad.company_id = #{companyId}</if>
|
2025-02-17 17:43:58 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectLeaseApplyInfoById" parameterType="Long" resultMap="LeaseApplyInfoResult">
|
2025-02-28 18:20:55 +08:00
|
|
|
select
|
|
|
|
|
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
|
|
|
|
|
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,tt.task_id as taskId,
|
|
|
|
|
lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus,
|
|
|
|
|
lai.supplier_time as supplierTime,
|
|
|
|
|
lai.supplier_place as supplierPlace,
|
|
|
|
|
case tt.task_status
|
|
|
|
|
when 0 then '待审核'
|
|
|
|
|
when 1 then '待审核'
|
|
|
|
|
when 2 then '审核中'
|
|
|
|
|
when 3 then '已完成'
|
|
|
|
|
when 4 then '已完成'
|
|
|
|
|
end as taskStatusName,
|
|
|
|
|
IFNULL(sum(lad.pre_num),0) as preCountNum,
|
|
|
|
|
IFNULL(sum(lad.al_num),0) as alNum,
|
|
|
|
|
GROUP_CONCAT(DISTINCT 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_unit bu on bu.unit_id = lai.unit_id
|
|
|
|
|
left join bm_project bp on bp.pro_id = lai.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'
|
2025-02-17 17:43:58 +08:00
|
|
|
where lai.id = #{id}
|
|
|
|
|
</select>
|
2025-02-18 18:58:20 +08:00
|
|
|
|
|
|
|
|
<select id="getTypeDataList" resultType="com.bonus.material.ma.domain.Type">
|
|
|
|
|
SELECT DISTINCT m.type_id as typeId,
|
|
|
|
|
m.type_name as typeName,
|
|
|
|
|
m2.type_name as maTypeName,
|
|
|
|
|
m.parent_id as parentId,
|
|
|
|
|
m.unit_name as unitName,
|
|
|
|
|
m.manage_type as manageType,
|
|
|
|
|
m.lease_price as leasePrice,
|
|
|
|
|
m.LEVEL,
|
|
|
|
|
CASE m.manage_type
|
|
|
|
|
WHEN 0 THEN
|
|
|
|
|
IFNULL(subquery0.num, 0)
|
|
|
|
|
ELSE
|
|
|
|
|
IFNULL(m.storage_num, 0)
|
|
|
|
|
END as storageNum
|
|
|
|
|
from ma_type m
|
|
|
|
|
LEFT JOIN ma_type m2 on m2.type_id = m.parent_id and m2.del_flag = 0
|
|
|
|
|
left join (SELECT mt.type_id,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
count(mm.ma_id) num
|
|
|
|
|
FROM ma_machine mm
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
WHERE mm.ma_code is not null
|
|
|
|
|
and mm.ma_status in (1)
|
|
|
|
|
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = m.type_id
|
|
|
|
|
where m.del_flag = '0'
|
|
|
|
|
and m.parent_id = #{typeId}
|
|
|
|
|
</select>
|
2025-02-21 02:26:37 +08:00
|
|
|
<select id="selectAuditLeaseApplyInfoList" resultMap="LeaseApplyInfoResult">
|
2025-02-20 22:35:19 +08:00
|
|
|
select
|
|
|
|
|
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
|
|
|
|
|
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,tt.task_id as taskId,
|
|
|
|
|
bai.unit_id,bai.project_id,bu.unit_name, bp.pro_name,bai.agreement_id, bai.agreement_code, swr.workflow_status as taskStatus,
|
|
|
|
|
|
|
|
|
|
case tt.task_status
|
|
|
|
|
when 0 then '待审核'
|
|
|
|
|
when 1 then '执行中'
|
|
|
|
|
when 2 then '执行完成'
|
|
|
|
|
when 3 then '执行中断'
|
|
|
|
|
end as taskStatusName,
|
|
|
|
|
IFNULL(sum(lad.pre_num),0) as preCountNum,
|
|
|
|
|
IFNULL(sum(lad.al_num),0) as alNum,
|
|
|
|
|
GROUP_CONCAT(DISTINCT 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'
|
2025-02-20 21:32:29 +08:00
|
|
|
left join sys_workflow_record swr on tt.task_id = swr.task_id
|
|
|
|
|
left join sys_workflow_type swt on swr.workflow_id = swt.id
|
|
|
|
|
left join sys_workflow_node swn on swt.id = swn.type_id
|
|
|
|
|
left join sys_workflow_config swc on swn.id = swc.node_id
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="userId != null and userId != ''">and swc.config_value = #{userId}</if>
|
|
|
|
|
<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="keyWord != null and keyWord != ''">
|
|
|
|
|
and (bu.unit_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
bp.pro_name like concat('%', #{keyWord}, '%') or
|
|
|
|
|
lai.code like concat('%', #{keyWord}, '%') or
|
|
|
|
|
lai.create_by like concat('%', #{keyWord}, '%') or
|
|
|
|
|
lai.lease_person like concat('%', #{keyWord}, '%') or
|
|
|
|
|
lai.phone like concat('%', #{keyWord}, '%') or
|
|
|
|
|
bp.contract_part like concat('%', #{keyWord}, '%') or
|
|
|
|
|
sd.dept_name like concat('%', #{keyWord}, '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
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 lai.apply_code is not null
|
|
|
|
|
<if test="isApp != null and taskStatus==1">and (tt.task_status = 0 or tt.task_status = 1 or tt.task_status = 2) </if>
|
|
|
|
|
<if test="isApp != null and taskStatus==3">and (tt.task_status = 3 or tt.task_status = 4)</if>
|
|
|
|
|
GROUP BY lai.id
|
|
|
|
|
ORDER BY tt.task_status,tt.create_time desc
|
|
|
|
|
</select>
|
2025-02-28 18:20:55 +08:00
|
|
|
|
|
|
|
|
<select id="getDeptIdByUserId" resultType="long">
|
|
|
|
|
select
|
|
|
|
|
dept_id as deptId
|
|
|
|
|
from sys_user su
|
|
|
|
|
where user_id = #{userId} and del_flag = 0
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getDeptIdByParentId" resultType="com.bonus.material.lease.domain.vo.LeaseDeptInfo">
|
|
|
|
|
select
|
|
|
|
|
dept_id as deptId,
|
|
|
|
|
parent_id as parentId,
|
|
|
|
|
dept_name as deptName,
|
|
|
|
|
ancestors as ancestors,
|
|
|
|
|
company_sx as companySx
|
|
|
|
|
from sys_dept
|
|
|
|
|
where dept_id = #{deptId} and del_flag = 0
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectMaTypeThreeLists" resultMap="TypeResult">
|
|
|
|
|
SELECT m.type_id,
|
|
|
|
|
m.type_name,
|
|
|
|
|
m.parent_id,
|
|
|
|
|
m.manage_type,
|
|
|
|
|
m.LEVEL,
|
|
|
|
|
m.type_id AS id,
|
|
|
|
|
m.type_name AS label
|
|
|
|
|
FROM ma_type m
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-03-04 15:07:41 +08:00
|
|
|
<select id="selectParentId" resultType="com.bonus.material.ma.domain.vo.MaTypeVoLevelTwo">
|
2025-02-28 18:20:55 +08:00
|
|
|
SELECT DISTINCT
|
2025-03-04 15:07:41 +08:00
|
|
|
mt.type_name AS typeName,
|
|
|
|
|
mt2.type_name AS materialName,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt4.type_name AS itemType,
|
|
|
|
|
mt.manage_type as manageType,
|
|
|
|
|
mt.unit_name as unitName,
|
|
|
|
|
mt.lease_price as leasePrice,
|
|
|
|
|
mt.rent_price as rentPrice,
|
|
|
|
|
mt.LEVEL as level,
|
|
|
|
|
mt.storage_num as storageNum
|
2025-02-28 18:20:55 +08:00
|
|
|
FROM
|
2025-03-04 15:07:41 +08:00
|
|
|
ma_type mt
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
|
|
|
|
|
where mt2.type_id is not null and mt.del_flag = '0'
|
|
|
|
|
and mt.`level` = 4 and mt2.`level` = 3 and mt3.`level` = 2 and mt4.`level` = 1
|
2025-02-28 18:20:55 +08:00
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<update id="updateLeaseTaskStatus">
|
|
|
|
|
update tm_task
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="taskStatus != null">task_status = #{taskStatus},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where task_Id = #{taskId}
|
|
|
|
|
</update>
|
2025-03-04 08:55:10 +08:00
|
|
|
|
|
|
|
|
<select id="getApplyInfo" resultType="com.bonus.common.biz.domain.lease.LeaseApplyInfo">
|
|
|
|
|
select
|
|
|
|
|
lai.code as code,lai.lease_person as leasePerson,lai.phone as phone,lai.create_by as createBy,
|
|
|
|
|
lai.create_time as createTime,lai.supplier_time as supplierTime,lai.supplier_place as supplierPlace,
|
|
|
|
|
bu.unit_name as unitName,bp.pro_name as projectName,lai.company_id as companyId,sd.dept_name as companyName
|
|
|
|
|
|
|
|
|
|
from lease_apply_info lai
|
|
|
|
|
left join bm_unit bu on lai.unit_id = bu.unit_id
|
|
|
|
|
left join bm_project bp on lai.project_id = bp.pro_id
|
|
|
|
|
left join sys_dept sd on lai.company_id = sd.dept_id and sd.del_flag = 0
|
|
|
|
|
where task_id = #{taskId} and bu.del_flag = 0 and bp.del_flag = 0
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getApplyDetails" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
|
|
|
|
|
select
|
|
|
|
|
lad.pre_num as preNum,lad.remark as remark,ma1.unit_name as unitName,ma1.type_name as typeName,
|
|
|
|
|
ma2.type_name as maTypeName
|
|
|
|
|
|
|
|
|
|
from lease_apply_details lad
|
|
|
|
|
left join lease_apply_info lai on lad.parent_id = lai.id
|
|
|
|
|
left join ma_type ma1 on lad.type_id = ma1.type_id
|
|
|
|
|
left join ma_type ma2 on ma1.parent_id = ma2.type_id
|
|
|
|
|
where lai.task_id = #{taskId} and ma1.del_flag = 0 and ma2.del_flag = 0
|
|
|
|
|
</select>
|
2025-03-04 15:41:14 +08:00
|
|
|
|
|
|
|
|
<select id="selectPublishDetails" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
|
|
|
|
|
SELECT
|
|
|
|
|
lad.id AS id,
|
|
|
|
|
lad.parent_id AS parentId,
|
|
|
|
|
mt.type_id AS typeId,
|
|
|
|
|
mt.type_name AS typeName,
|
2025-03-04 17:31:59 +08:00
|
|
|
mt2.type_id AS thirdTypeId,
|
2025-03-04 15:41:14 +08:00
|
|
|
mt2.type_name AS maTypeName,
|
|
|
|
|
CASE
|
|
|
|
|
mt.manage_type
|
|
|
|
|
WHEN 0 THEN
|
|
|
|
|
IFNULL( subquery0.num, 0 ) ELSE IFNULL( mt.storage_num, 0 )
|
|
|
|
|
END AS storageNum,
|
|
|
|
|
mt.manage_type AS manageType,
|
|
|
|
|
IFNULL( lad.pre_num, 0 ) AS preNum,
|
|
|
|
|
mt.unit_name AS unitName,
|
|
|
|
|
IFNULL( a.num, 0 ) AS publishNum,
|
|
|
|
|
IFNULL( b.num, 0 ) AS outNum,
|
|
|
|
|
IFNULL( lad.pre_num, 0 ) - IFNULL( a.num, 0 ) AS pendingNum
|
|
|
|
|
FROM
|
|
|
|
|
lease_apply_details lad
|
|
|
|
|
LEFT JOIN ma_type mt ON lad.type_id = mt.type_id
|
|
|
|
|
AND mt.`level` = '4'
|
|
|
|
|
AND mt.del_flag = '0'
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
AND mt2.`level` = '3'
|
|
|
|
|
AND mt2.del_flag = '0'
|
|
|
|
|
LEFT JOIN ( SELECT parent_id, type_id, sum( num ) AS num FROM lease_publish_details GROUP BY parent_id, type_id ) a
|
|
|
|
|
ON a.parent_id = lad.parent_id AND a.type_id = lad.type_id
|
|
|
|
|
LEFT JOIN ( SELECT parent_id, type_id, sum( out_num ) AS num FROM lease_out_details GROUP BY parent_id, type_id ) b
|
|
|
|
|
ON b.parent_id = lad.parent_id AND b.type_id = lad.type_id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
count( mm.ma_id ) num
|
|
|
|
|
FROM
|
|
|
|
|
ma_machine mm
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
WHERE
|
|
|
|
|
mm.ma_code IS NOT NULL
|
|
|
|
|
AND mm.ma_status IN ( 1 )
|
|
|
|
|
GROUP BY
|
|
|
|
|
mt.type_id
|
|
|
|
|
) AS subquery0 ON subquery0.type_id = mt.type_id
|
|
|
|
|
WHERE
|
|
|
|
|
lad.parent_id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getPublishList" resultType="com.bonus.common.biz.domain.lease.LeasePublishInfo"
|
|
|
|
|
resultMap="LeaseApplyInfoResult">
|
|
|
|
|
select
|
|
|
|
|
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
|
|
|
|
|
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,tt.task_id as taskId,
|
|
|
|
|
lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus,
|
|
|
|
|
|
|
|
|
|
case tt.task_status
|
|
|
|
|
when 0 then '待审核'
|
|
|
|
|
when 1 then '待审核'
|
|
|
|
|
when 2 then '审核中'
|
|
|
|
|
when 3 then '已完成'
|
|
|
|
|
when 4 then '已完成'
|
|
|
|
|
end as taskStatusName,
|
|
|
|
|
IFNULL(sum(lad.pre_num),0) as preCountNum,
|
|
|
|
|
IFNULL(sum(lad.al_num),0) as alNum,
|
|
|
|
|
GROUP_CONCAT(DISTINCT 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_unit bu on bu.unit_id = lai.unit_id
|
|
|
|
|
left join bm_project bp on bp.pro_id = lai.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'
|
2025-03-04 17:31:59 +08:00
|
|
|
where tt.task_type = '19'
|
|
|
|
|
and tt.task_status = '1'
|
2025-03-04 15:41:14 +08:00
|
|
|
<if test="taskId != null ">and lai.task_id = #{taskId}</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 != ''">
|
|
|
|
|
AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="isApp != null and taskStatus==1">and (tt.task_status = 0 or tt.task_status = 1 or tt.task_status = 2) </if>
|
|
|
|
|
<if test="isApp != null and taskStatus==3">and (tt.task_status = 3 or tt.task_status = 4)</if>
|
|
|
|
|
GROUP BY lai.id
|
|
|
|
|
ORDER BY tt.task_status,tt.create_time desc
|
|
|
|
|
</select>
|
2025-02-20 21:32:29 +08:00
|
|
|
</mapper>
|