229 lines
12 KiB
XML
229 lines
12 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.basic.mapper.BmAgreementInfoMapper">
|
|
<resultMap type="com.bonus.material.basic.domain.BmAgreementInfo" id="BmAgreementInfoResult">
|
|
<result property="agreementId" column="agreement_id" />
|
|
<result property="agreementCode" column="agreement_code" />
|
|
<result property="signTime" column="sign_time" />
|
|
<result property="unitId" column="unit_id" />
|
|
<result property="projectUnitId" column="project_unit_id" />
|
|
<result property="unitName" column="unit_name" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="leaseDay" column="lease_day" />
|
|
<result property="planStartTime" column="plan_start_time" />
|
|
<result property="contractCode" column="contract_code" />
|
|
<result property="authPerson" column="auth_person" />
|
|
<result property="phone" column="phone" />
|
|
<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="status" column="status" />
|
|
<result property="protocol" column="protocol" />
|
|
<result property="isSlt" column="is_slt" />
|
|
<result property="taskId" column="task_id" />
|
|
</resultMap>
|
|
|
|
<select id="selectBmAgreementInfoList" parameterType="com.bonus.material.basic.domain.BmAgreementInfo" resultMap="BmAgreementInfoResult">
|
|
SELECT bai.agreement_id, bai.agreement_code , contract_code,sign_time,
|
|
bu.unit_id, bai.project_unit_id, bu.unit_name , bp.pro_id as projectId , bp.pro_name as projectName,
|
|
plan_start_time,lease_day,auth_person,phone,bai.remark,bai.protocol,bai.branch_project as branchProIdsStr
|
|
FROM bm_agreement_info bai
|
|
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
|
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
|
|
where bai.status = '1'
|
|
<if test="keyWord != null and keyWord != ''">
|
|
and (bai.contract_code like concat('%', #{keyWord}, '%') or
|
|
bai.agreement_code like concat('%', #{keyWord}, '%') or
|
|
auth_person like concat('%', #{keyWord}, '%') or
|
|
phone like concat('%', #{keyWord}, '%') or
|
|
bu.unit_name like concat('%', #{keyWord}, '%') or
|
|
bp.pro_name like concat('%', #{keyWord}, '%')
|
|
)
|
|
</if>
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
<![CDATA[ AND DATE_FORMAT( bai.plan_start_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
AND bai.`status` = #{status}
|
|
</if>
|
|
<if test="agreementCode != null and agreementCode != ''">
|
|
and bai.agreement_code like concat('%', #{agreementCode}, '%')
|
|
</if>
|
|
<if test="unitId != null and unitId != ''">
|
|
and bu.unit_id = #{unitId}
|
|
</if>
|
|
<if test="projectId != null and projectId != ''">
|
|
and bp.pro_id = #{projectId}
|
|
</if>
|
|
<if test="companyId != null ">
|
|
and bai.company_id = #{companyId}
|
|
</if>
|
|
ORDER BY bai.create_time DESC
|
|
</select>
|
|
|
|
<select id="selectBmAgreementInfoByAgreementId" parameterType="Long" resultMap="BmAgreementInfoResult">
|
|
SELECT bai.agreement_id, bai.agreement_code , contract_code,sign_time,
|
|
bu.unit_id, bai.project_unit_id,bu2.unit_name as projectUnitName, bu.unit_name , bp.pro_id as projectId , bp.pro_name as projectName,
|
|
plan_start_time,lease_day,auth_person,phone,bai.remark,bai.protocol,tta.task_id,bai.branch_project as branchProIdsStr
|
|
FROM bm_agreement_info bai
|
|
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
|
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
|
|
LEFT JOIN bm_unit bu2 on bu2.unit_id=bai.project_unit_id
|
|
LEFT JOIN (select MIN(task_id) as task_id,agreement_id from tm_task_agreement
|
|
where agreement_id = #{agreementId}) tta on bai.agreement_id = tta.agreement_id
|
|
where bai.status = '1' and bai.agreement_id = #{agreementId}
|
|
</select>
|
|
|
|
<insert id="insertBmAgreementInfo" parameterType="com.bonus.material.basic.domain.BmAgreementInfo" useGeneratedKeys="true" keyProperty="agreementId">
|
|
insert into bm_agreement_info (agreement_code, sign_time, unit_id, project_unit_id,
|
|
project_id, create_by, lease_day,
|
|
plan_start_time, contract_code, auth_person,
|
|
phone, create_time, update_by,
|
|
update_time, remark, company_id, protocol,
|
|
branch_project, company_id
|
|
)
|
|
values (#{agreementCode,jdbcType=VARCHAR}, #{signTime,jdbcType=VARCHAR}, #{unitId,jdbcType=INTEGER}, #{projectUnitId,jdbcType=INTEGER},
|
|
#{projectId,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, #{leaseDay,jdbcType=INTEGER},
|
|
#{planStartTime,jdbcType=TIMESTAMP}, #{contractCode,jdbcType=VARCHAR}, #{authPerson,jdbcType=VARCHAR},
|
|
#{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
|
|
#{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, #{protocol,jdbcType=VARCHAR},
|
|
#{branchProIdsStr,jdbcType=VARCHAR}, #{companyId}
|
|
)
|
|
</insert>
|
|
|
|
<insert id="insertBmAgreementInfoClz" parameterType="com.bonus.material.basic.domain.BmAgreementInfo" useGeneratedKeys="true" keyProperty="agreementId">
|
|
insert into clz_bm_agreement_info (agreement_code, sign_time, unit_id,
|
|
project_id, create_by, lease_day,
|
|
plan_start_time, contract_code, auth_person,
|
|
phone, create_time, update_by,
|
|
update_time, remark, company_id, protocol,
|
|
branch_project
|
|
)
|
|
values (#{agreementCode,jdbcType=VARCHAR}, #{signTime,jdbcType=VARCHAR}, #{unitId,jdbcType=INTEGER},
|
|
#{projectId,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, #{leaseDay,jdbcType=INTEGER},
|
|
#{planStartTime,jdbcType=TIMESTAMP}, #{contractCode,jdbcType=VARCHAR}, #{authPerson,jdbcType=VARCHAR},
|
|
#{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
|
|
#{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, #{protocol,jdbcType=VARCHAR},
|
|
#{branchProIdsStr,jdbcType=VARCHAR}
|
|
)
|
|
</insert>
|
|
|
|
<update id="updateBmAgreementInfo" parameterType="com.bonus.material.basic.domain.BmAgreementInfo">
|
|
update bm_agreement_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="agreementCode != null">agreement_code = #{agreementCode},</if>
|
|
<if test="signTime != null">sign_time = #{signTime},</if>
|
|
<if test="unitId != null">unit_id = #{unitId},</if>
|
|
<if test="projectUnitId != null">project_unit_id = #{projectUnitId},</if>
|
|
<if test="projectId != null">project_id = #{projectId},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="leaseDay != null">lease_day = #{leaseDay},</if>
|
|
<if test="planStartTime != null">plan_start_time = #{planStartTime},</if>
|
|
<if test="contractCode != null">contract_code = #{contractCode},</if>
|
|
<if test="authPerson != null">auth_person = #{authPerson},</if>
|
|
<if test="phone != null">phone = #{phone},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="companyId != null">company_id = #{companyId},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="protocol != null">protocol = #{protocol},</if>
|
|
<if test="isSlt != null">is_slt = #{isSlt},</if>
|
|
<if test="branchProIdsStr != null">branch_project = #{branchProIdsStr},</if>
|
|
</trim>
|
|
where agreement_id = #{agreementId}
|
|
</update>
|
|
|
|
<delete id="deleteBmAgreementInfoByAgreementId" parameterType="Long">
|
|
delete from bm_agreement_info where agreement_id = #{agreementId}
|
|
</delete>
|
|
|
|
<delete id="deleteBmAgreementInfoByAgreementIds" parameterType="String">
|
|
delete from bm_agreement_info where agreement_id in
|
|
<foreach item="agreementId" collection="array" open="(" separator="," close=")">
|
|
#{agreementId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectNumByMonth" resultType="java.lang.Integer">
|
|
select count(*) from bm_agreement_info where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m')
|
|
</select>
|
|
|
|
<select id="getProtocol" resultType="java.lang.String">
|
|
select protocol
|
|
from bm_agreement_info
|
|
where agreement_id = #{agreementId}
|
|
</select>
|
|
|
|
<select id="selectByagreementId" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
tm_task_agreement
|
|
WHERE
|
|
agreement_id = #{agreementId}
|
|
</select>
|
|
|
|
<select id="getDictLabel" resultType="java.lang.String">
|
|
select dict_label as dictLabel
|
|
from sys_dict_data sdd
|
|
where sdd.dict_type="branch_project" and sdd.dict_value = #{id} and sdd.`status` = 0
|
|
</select>
|
|
|
|
<select id="queryByTeamIdAndProjectId" resultType="com.bonus.material.basic.domain.BmAgreementInfo">
|
|
SELECT
|
|
agreement_id as agreementId,
|
|
agreement_code as agreementCode,
|
|
unit_id as teamId,
|
|
project_id as projectId
|
|
FROM
|
|
bm_agreement_info
|
|
WHERE
|
|
unit_id = #{unitId}
|
|
and project_id = #{projectId}
|
|
LIMIT 1
|
|
</select>
|
|
|
|
<select id="queryByTeamIdAndProjectIdCl" resultType="com.bonus.material.basic.domain.BmAgreementInfo">
|
|
SELECT
|
|
agreement_id as agreementId,
|
|
agreement_code as agreementCode,
|
|
unit_id as teamId,
|
|
project_id as projectId
|
|
FROM
|
|
clz_bm_agreement_info
|
|
WHERE
|
|
unit_id = #{unitId}
|
|
and project_id = #{projectId}
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="selectNumByMonthClz" resultType="java.lang.Integer">
|
|
select count(*) from clz_bm_agreement_info where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m')
|
|
</select>
|
|
<select id="selectProjectUnitAgreementIdByTeamAndProject" resultType="java.lang.Long">
|
|
SELECT
|
|
baii.agreement_id AS projectUnitAgreementId
|
|
FROM
|
|
bm_agreement_info bai
|
|
LEFT JOIN bm_agreement_info baii ON baii.unit_id = bai.project_unit_id AND baii.project_id = #{projectId}
|
|
AND baii.status = '1'
|
|
WHERE
|
|
bai.unit_id = #{teamId} AND bai.project_id = #{projectId}
|
|
LIMIT 1
|
|
</select>
|
|
<select id="selectSltInfoByagreementId" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
slt_agreement_info
|
|
WHERE
|
|
agreement_id = #{agreementId}
|
|
</select>
|
|
</mapper>
|