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,
lai.material_man, lai.confirm_time, lai.is_confirm, lai.confirm_remark,
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(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'
JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}
insert into lease_apply_info
code,
task_id,
lease_person,
phone,
type,
company_audit_by,
company_audit_time,
company_audit_remark,
dept_audit_by,
dept_audit_time,
dept_audit_remark,
direct_audit_by,
direct_audit_time,
direct_audit_remark,
create_by,
create_time,
update_by,
update_time,
remark,
company_id,
direct_id,
lease_type,
estimate_lease_time,
cost_bearing_party,
#{code},
#{taskId},
#{leasePerson},
#{phone},
#{type},
#{companyAuditBy},
#{companyAuditTime},
#{companyAuditRemark},
#{deptAuditBy},
#{deptAuditTime},
#{deptAuditRemark},
#{directAuditBy},
#{directAuditTime},
#{directAuditRemark},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
#{companyId},
#{directId},
#{leaseType},
#{estimateLeaseTime},
#{costBearingParty},
update lease_apply_info
code = #{code},
task_id = #{taskId},
lease_person = #{leasePerson},
phone = #{phone},
`type` = #{type},
company_audit_by = #{companyAuditBy},
company_audit_time = #{companyAuditTime},
company_audit_remark = #{companyAuditRemark},
dept_audit_by = #{deptAuditBy},
dept_audit_time = #{deptAuditTime},
dept_audit_remark = #{deptAuditRemark},
direct_audit_by = #{directAuditBy},
direct_audit_time = #{directAuditTime},
direct_audit_remark = #{directAuditRemark},
update_by = #{updateBy},
update_time = now(),
remark = #{remark},
company_id = #{companyId},
direct_id = #{directId},
lease_type = #{leaseType},
estimate_lease_time = #{estimateLeaseTime},
cost_bearing_party = #{costBearingParty},
where id = #{id}
delete from lease_apply_info where id = #{id}
delete from lease_apply_info where id in
#{id}
update lease_apply_info
lease_sign_url = #{leaseSignUrl},
lease_sign_type = #{leaseSignType},
where id = #{id}
update
lease_apply_info
set
material_man = #{materialMan}, confirm_time = #{confirmTime}, is_confirm = #{isConfirm},
confirm_remark = #{confirmRemark}
where
id = #{id}