devicesmgt/sgzb-modules/sgzb-material/src/main/resources/mapper/material/WorkSiteDirectManageMapper.xml

462 lines
17 KiB
XML
Raw Normal View History

2024-03-05 16:53:10 +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.material.mapper.WorkSiteDirectManageMapper">
2024-03-11 18:45:55 +08:00
<insert id="saveDirectApplyInfo" parameterType="com.bonus.sgzb.base.api.domain.DirectApplyInfo" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
2024-03-05 16:53:10 +08:00
insert into direct_apply_info
(
<if test="code != null and code != ''">
code,
</if>
<if test="backAgreementId != null">
back_agreement_id,
</if>
<if test="backMan != null and backMan != ''">
back_man,
</if>
<if test="backPhone != null and backPhone != ''">
back_phone,
</if>
<if test="backRemark != null and backRemark != ''">
back_remark,
</if>
<if test="leaseAgreementId != null">
lease_agreement_id,
</if>
<if test="leaseMan != null and leaseMan != ''">
lease_man,
</if>
<if test="leasePhone != null and leasePhone != ''">
lease_phone,
</if>
<if test="dirUrl != null and dirUrl != ''">
dir_url,
</if>
<if test="status != null and status != ''">
status,
</if>
<if test="auditor != null and auditor != ''">
auditor,
</if>
<if test="auditTime != null and auditTime != ''">
audit_time,
</if>
<if test="auditRemark != null and auditRemark != ''">
audit_remark,
</if>
create_time
) values (
<if test="code != null and code != ''">
#{code},
</if>
<if test="backAgreementId != null">
#{backAgreementId},
</if>
<if test="backMan != null and backMan != ''">
#{backMan},
</if>
<if test="backPhone != null and backPhone != ''">
#{backPhone},
</if>
<if test="backRemark != null and backRemark != ''">
#{backRemark},
</if>
<if test="leaseAgreementId != null">
#{leaseAgreementId},
</if>
<if test="leaseMan != null and leaseMan != ''">
#{leaseMan},
</if>
<if test="leasePhone != null and leasePhone != ''">
#{leasePhone},
</if>
<if test="dirUrl != null and dirUrl != ''">
#{dirUrl},
</if>
<if test="status != null and status != ''">
#{status},
</if>
<if test="auditor != null and auditor != ''">
#{auditor},
</if>
<if test="auditTime != null and auditTime != ''">
#{auditTime},
</if>
<if test="auditRemark != null and auditRemark != ''">
#{auditRemark},
</if>
NOW()
)
</insert>
<insert id="saveDirectApplyDetails" parameterType="com.bonus.sgzb.base.api.domain.DirectApplyDetails">
2024-03-12 15:14:02 +08:00
insert into direct_apply_details(direct_id,type_id,ma_id,direct_num)
2024-03-05 16:53:10 +08:00
values (#{directId},#{typeId},#{maId}, #{directNum})
</insert>
2024-03-12 13:52:31 +08:00
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.material.domain.LeaseApplyInfo" useGeneratedKeys="true">
<!--@mbg.generated-->
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 and leasePerson != ''">
lease_person,
</if>
<if test="phone != null and phone != ''">
phone,
</if>
<if test="type != null and type != ''">
`type`,
</if>
<if test="companyAuditBy != null">
company_audit_by,
</if>
<if test="companyAuditTime != null and companyAuditTime != ''">
company_audit_time,
</if>
<if test="companyAuditRemark != null and companyAuditRemark != ''">
company_audit_remark,
</if>
<if test="deptAuditBy != null">
dept_audit_by,
</if>
<if test="deptAuditTime != null and deptAuditTime != ''">
dept_audit_time,
</if>
<if test="deptAuditRemark != null and deptAuditRemark != ''">
dept_audit_remark,
</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>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="taskId != null">
#{taskId,jdbcType=INTEGER},
</if>
<if test="leasePerson != null and leasePerson != ''">
#{leasePerson,jdbcType=VARCHAR},
</if>
<if test="phone != null and phone != ''">
#{phone,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
#{type,jdbcType=VARCHAR},
</if>
<if test="companyAuditBy != null">
#{companyAuditBy,jdbcType=INTEGER},
</if>
<if test="companyAuditTime != null and companyAuditTime != ''">
#{companyAuditTime,jdbcType=VARCHAR},
</if>
<if test="companyAuditRemark != null and companyAuditRemark != ''">
#{companyAuditRemark,jdbcType=VARCHAR},
</if>
<if test="deptAuditBy != null">
#{deptAuditBy,jdbcType=INTEGER},
</if>
<if test="deptAuditTime != null and deptAuditTime != ''">
#{deptAuditTime,jdbcType=VARCHAR},
</if>
<if test="deptAuditRemark != null and deptAuditRemark != ''">
#{deptAuditRemark,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>
</insert>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into lease_apply_details
(parennt_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by,
update_time, remark, company_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.parenntId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=FLOAT},
#{item.alNum,jdbcType=FLOAT}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(),
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER})
</foreach>
</insert>
2024-03-12 15:14:02 +08:00
<insert id="insertLeaseOutDetails">
insert into lease_out_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
parent_id,
</if>
<if test="typeId!= null">
type_id,
</if>
<if test="maId!= null">
ma_id,
</if>
<if test="outNum!= null">
out_num,
</if>
<if test="outType!= null">
out_type,
</if>
<if test="createBy!= null">
create_by,
</if>
<if test="updateBy!= null">
update_by,
</if>
<if test="remark!= null">
remark,
</if>
<if test="companyId!= null">
company_id,
</if>
<if test="carCode!= null">
car_code,
</if>
create_time,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
#{parentId},
</if>
<if test="typeId!= null">
#{typeId},
</if>
<if test="maId!= null">
#{maId},
</if>
<if test="outNum!= null">
#{outNum},
</if>
<if test="outType!= null">
#{outType},
</if>
<if test="createBy!= null">
#{createBy},
</if>
<if test="updateBy!= null">
#{updateBy},
</if>
<if test="remark!= null">
#{remark},
</if>
<if test="companyId!= null">
#{companyId},
</if>
<if test="carCode!= null">
#{carCode},
</if>
NOW(),
NOW()
</trim>
</insert>
2024-03-13 10:56:43 +08:00
<insert id="insertBackApplyInfo" keyColumn="task_id" keyProperty="taskId" parameterType="com.bonus.sgzb.material.domain.BackApplyInfo" useGeneratedKeys="true">
insert into tm_task (
<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="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>
create_time
) values (
<if test="taskType != null">#{taskType}, </if>
<if test="taskStatus != null">#{taskStatus}, </if>
<if test="code != null and code != ''">#{code}, </if>
<if test="createBy != null and createBy != ''">#{createBy}, </if>
<if test="updateBy != null and updateBy != ''">#{updateBy}, </if>
<if test="updateTime != null">#{updateTime}, </if>
<if test="remark != null and remark != ''">#{remark}, </if>
<if test="companyId != null">#{companyId}, </if>
NOW()
)
</insert>
2024-03-05 16:53:10 +08:00
<update id="refuseDirectApplyInfo">
update direct_apply_info set status = #{status} where id = #{id}
</update>
2024-03-12 15:14:02 +08:00
<update id="updateLeaseApplyDetailsOutNum">
UPDATE
lease_apply_details
SET
al_num = IF(al_num IS NULL, #{record.outNum}, al_num + #{record.outNum}),
<if test="record.updateBy != null and record.updateBy!= '' ">
update_by = #{record.updateBy},
</if>
update_time = now(),
status = '2'
WHERE
parennt_id = #{record.parentId} and type_id = #{record.typeId}
</update>
2024-03-12 17:33:43 +08:00
<update id="updateMaTypeStockNum">
UPDATE
ma_type
SET
num = num - #{record.outNum} ,update_time = NOW()
WHERE
type_id = #{record.typeId}
</update>
<update id="updateMaMachineStatus">
UPDATE
ma_machine
SET
ma_status = '16' , create_time = NOW()
<where>
type_id = #{record.typeId}
<if test="record.maId != null and record.maId != ''">
and ma_id = #{record.maId}
</if>
</where>
</update>
2024-03-12 13:52:31 +08:00
<delete id="batchDel">
delete
from lease_user_book
where id in
<foreach close=")" collection="ids" item="id" open="(" separator=", ">
#{id}
</foreach>
</delete>
2024-03-05 16:53:10 +08:00
<select id="getUseringData" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
2024-03-11 18:45:55 +08:00
SELECT
sai.*,
mt.type_name AS typeModelName,
mt2.type_name AS typeName,
mm.ma_code AS maCode,
sum(sai.num) AS useNum
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt on sai.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_machine mm on sai.ma_id = mm.ma_id
where sai.agreement_id = #{agreementId} and sai.status = '0'
GROUP BY
2024-03-14 17:58:50 +08:00
sai.ma_id,sai.type_id
2024-03-06 15:29:22 +08:00
</select>
<select id="getList" resultType="com.bonus.sgzb.base.api.domain.DirectApplyInfo">
2024-03-12 17:33:43 +08:00
SELECT DISTINCT
dai.*,
bpl.lot_id AS backProId,
bpl.lot_name AS backProName,
bui.unit_id AS backUnitId,
bui.unit_name AS backUnitName,
bpl1.lot_id AS leaseProId,
bpl1.lot_name AS leaseProName,
bui1.unit_id AS leaseUnitId,
bui1.unit_name AS leaseUnitName
FROM
direct_apply_info dai
LEFT JOIN bm_agreement_info bai ON dai.back_agreement_id = bai.agreement_id
LEFT JOIN bm_agreement_info bai1 ON dai.lease_agreement_id = bai1.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_project_lot bpl1 ON bpl1.lot_id = bai1.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN bm_unit_info bui1 ON bui1.unit_id = bai1.unit_id
2024-03-05 16:53:10 +08:00
</select>
2024-03-12 13:52:31 +08:00
<select id="getDirectApplyInfoById" resultType="com.bonus.sgzb.base.api.domain.DirectApplyInfo">
select * from direct_apply_info where id = #{id}
</select>
2024-03-12 15:14:02 +08:00
<select id="getMachineStatus" resultType="java.lang.String">
select ma_status
from ma_machine
where ma_id = #{maId}
</select>
2024-03-12 17:33:43 +08:00
<select id="getListLease" resultType="com.bonus.sgzb.base.api.domain.DirectApplyInfo">
SELECT DISTINCT
bpl.lot_id as backProId,bpl.lot_name as backProName,
bui.unit_id as backUnitId,bui.unit_name as backUnitName
FROM
direct_apply_info dai
LEFT JOIN bm_agreement_info bai ON dai.agreement_id = bai.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
</select>
2024-03-13 18:16:50 +08:00
<select id="getInfoById" resultType="com.bonus.sgzb.base.api.domain.DirectApplyInfo">
SELECT
dai.*,
2024-03-14 17:58:50 +08:00
bai.agreement_code as backAgreementCode,
bai1.agreement_code as leaseAgreementCode,
2024-03-13 18:16:50 +08:00
bpl.lot_id AS backProId,
bpl.lot_name AS backProName,
bui.unit_id AS backUnitId,
bui.unit_name AS backUnitName,
bpl1.lot_id AS leaseProId,
bpl1.lot_name AS leaseProName,
bui1.unit_id AS leaseUnitId,
bui1.unit_name AS leaseUnitName
FROM
direct_apply_info dai
LEFT JOIN direct_apply_details dad ON dai.id = dad.direct_id
LEFT JOIN bm_agreement_info bai ON dai.back_agreement_id = bai.agreement_id
LEFT JOIN bm_agreement_info bai1 ON dai.lease_agreement_id = bai1.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_project_lot bpl1 ON bpl1.lot_id = bai1.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN bm_unit_info bui1 ON bui1.unit_id = bai1.unit_id
2024-03-14 17:58:50 +08:00
WHERE
dai.id = #{id} GROUP BY dai.id
</select>
<select id="getDetailById" resultType="com.bonus.sgzb.base.api.domain.DirectApplyDetails">
SELECT
dad.direct_num AS directNum,
dad.type_id AS typeId,
mt3.type_name AS typeName,
mt2.type_name AS kindName,
mt.type_name AS modelName,
mt.unit_name AS unitName,
sum( sai.num ) AS useNum,
mm.ma_code AS maCode
FROM
direct_apply_info dai
LEFT JOIN direct_apply_details dad ON dai.id = dad.direct_id
LEFT JOIN slt_agreement_info sai ON dai.back_agreement_id = sai.agreement_id
AND sai.type_id = dad.type_id
LEFT JOIN ma_type mt ON mt.type_id = dad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_machine mm ON dad.ma_id = mm.ma_id
2024-03-13 18:16:50 +08:00
WHERE
dai.id = #{id}
2024-03-14 17:58:50 +08:00
AND sai.STATUS = '0'
GROUP BY
dad.id,sai.ma_id,sai.type_id
2024-03-13 18:16:50 +08:00
</select>
2024-03-05 16:53:10 +08:00
</mapper>