123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- <?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.ruoyi.oa.mapper.CmcContractMapper">
-
- <resultMap type="CmcContract" id="CmcContractResult">
- <result property="contractId" column="contract_id" />
- <result property="contractName" column="contract_name" />
- <result property="contractCode" column="contract_code" />
- <result property="contractNumber" column="contract_number" />
- <result property="tenderId" column="tender_id" />
- <result property="partyAId" column="party_a_id" />
- <result property="amount" column="amount" />
- <result property="subAmount" column="sub_amount" />
- <result property="budgetAmount" column="budget_amount" />
- <result property="borrowAmount" column="borrow_amount" />
- <result property="settleAmount" column="settle_amount" />
- <result property="paidAmount" column="paid_amount" />
- <result property="deposit" column="deposit" />
- <result property="contractDocument" column="contract_document" />
- <result property="drafter" column="drafter" />
- <result property="draftTime" column="draft_time" />
- <result property="remark" column="remark" />
- <result property="signDate" column="sign_date" />
- <result property="signRemark" column="sign_remark" />
- <result property="signScan" column="sign_scan" />
- <result property="commentType" column="comment_type" />
- <result property="managerComment" column="manager_comment" />
- <result property="managerUserId" column="manager_user_id" />
- <result property="managerTime" column="manager_time" />
- <result property="gmUserId" column="gm_user_id" />
- <result property="gmTime" column="gm_time" />
- <result property="gmComment" column="gm_comment" />
- <result property="projectSource" column="project_source" />
- <association property="draftUser" javaType="SysUser" resultMap="DraftUserResult" />
- <association property="managerUser" javaType="SysUser" resultMap="ManagerUserResult" />
- <association property="gmUser" javaType="SysUser" resultMap="GmUserResult" />
- <association property="tender" javaType="CmcTender" resultMap="CmcTenderResult" />
- <association property="partyA" javaType="CmcPartyA" resultMap="CmcPartyAResult" />
- <association property="project" javaType="CmcProject" resultMap="CmcProjectResult" />
- </resultMap>
-
- <resultMap type="CmcTender" id="CmcTenderResult">
- <result property="tenderId" column="tender_id" />
- <result property="projectName" column="t_project_name" />
- </resultMap>
-
- <resultMap type="SysUser" id="DraftUserResult">
- <result property="userId" column="user_id" />
- <result property="nickName" column="draft_nick_name" />
- </resultMap>
-
- <resultMap type="SysUser" id="ManagerUserResult">
- <result property="userId" column="user_id" />
- <result property="nickName" column="manager_nick_name" />
- </resultMap>
-
- <resultMap type="SysUser" id="GmUserResult">
- <result property="userId" column="user_id" />
- <result property="nickName" column="gm_nick_name" />
- </resultMap>
-
- <resultMap type="CmcPartyA" id="CmcPartyAResult">
- <result property="partyAId" column="party_a_id" />
- <result property="partyAName" column="party_a_name" />
- </resultMap>
-
- <resultMap type="CmcProject" id="CmcProjectResult">
- <result property="projectId" column="project_id" />
- <result property="projectNumber" column="project_number" />
- <result property="projectName" column="project_name" />
- <result property="projectType" column="project_type" />
- </resultMap>
-
- <sql id="selectCmcContractVo">
- select distinct c.contract_id, c.contract_code, c.contract_name, c.contract_number, c.tender_id, t.project_name as t_project_name, p.project_number, p.project_name,
- p.project_source, c.party_a_id, pa.party_a_name, t.a_person as a_person, t.a_phone as a_phone, t.agent as agent, t.agent_person as agent_person, sum(cp.paid_amount) as paid_amount,
- t.agent_phone as agent_phone, c.amount, c.deposit, c.contract_document, c.drafter, u.nick_name as draft_nick_name, c.draft_time, c.remark, c.sign_date, c.sign_remark, c.sign_scan,
- c.comment_type, c.manager_comment, c.manager_user_id, u1.nick_name as manager_nick_name, c.manager_time, c.gm_user_id, u2.nick_name as gm_nick_name, c.gm_time, c.gm_comment from cmc_contract as c
- left join sys_user as u on u.user_id = c.drafter
- left join sys_user as u1 on u1.user_id = c.manager_user_id
- left join sys_user as u2 on u2.user_id = c.gm_user_id
- left join cmc_tender as t on t.tender_id = c.tender_id
- left join cmc_party_a as pa on pa.party_a_id = c.party_a_id
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on pc.project_id = p.project_id
- left join cmc_contract_paid as cp on cp.contract_id = c.contract_id
- </sql>
-
- <select id="selectCmcContractList" parameterType="CmcContract" resultMap="CmcContractResult">
- <include refid="selectCmcContractVo"/>
- <where>
- <if test="contractId != null and contractId != ''"> and c.contract_id like concat('%', #{contractId}, '%')</if>
- <if test="contractName!= null and contractName != ''"> and c.contract_name like concat('%', #{contractName}, '%')</if>
- <if test="contractCode!= null and contractCode != ''"> and c.contract_code like concat('%', #{contractCode}, '%')</if>
- <if test="tenderId != null and tenderId != ''"> and c.tender_id = #{tenderId}</if>
- <if test="contractNumber != null and contractNumber != ''"> and c.contract_number = #{contractNumber}</if>
- <if test="partyAId != null and partyAId != ''"> and c.party_a_id = #{partyAId}</if>
- <if test="amount != null "> and c.amount = #{amount}</if>
- <if test="deposit != null "> and c.deposit = #{deposit}</if>
- <if test="contractDocument != null and contractDocument != ''"> and c.contract_document = #{contractDocument}</if>
- <if test="drafter != null "> and c.drafter = #{drafter}</if>
- <if test="draftTime != null "> and c.draft_time = #{draftTime}</if>
- <if test="signDate != null "> and YEAR(c.sign_date) = YEAR(#{signDate})</if>
- <if test="signRemark != null and signRemark != ''"> and c.sign_remark = #{signRemark}</if>
- <if test="signScan != null and signScan != ''"> and c.sign_scan = #{signScan}</if>
- <if test="commentType != null and commentType != ''"> and c.comment_type = #{commentType}</if>
- <if test="projectSource != null and projectSource != ''"> and p.project_source = #{projectSource}</if>
- <if test="projectName != null and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
- <if test="partyAName != null and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
- </where>
- group by c.contract_id
- order by c.draft_time desc
- </select>
-
- <select id="selectCmcContractListFuzzy" parameterType="CmcContract" resultMap="CmcContractResult">
- select distinct c.contract_id, c.contract_code, c.contract_name, c.contract_number, c.tender_id, t.project_name as t_project_name, p.project_number, p.project_name,
- p.project_source, c.party_a_id, pa.party_a_name, t.a_person as a_person, t.a_phone as a_phone, t.agent as agent, t.agent_person as agent_person, sum(cp.paid_amount) as paid_amount,
- t.agent_phone as agent_phone, c.amount, c.deposit, c.contract_document, c.drafter, u.nick_name as draft_nick_name, c.draft_time, c.remark, c.sign_date, c.sign_remark, c.sign_scan,
- c.comment_type, c.manager_comment, c.manager_user_id, u1.nick_name as manager_nick_name, c.manager_time, c.gm_user_id, u2.nick_name as gm_nick_name, c.gm_time, c.gm_comment from cmc_contract as c
- left join sys_user as u on u.user_id = c.drafter
- left join sys_user as u1 on u1.user_id = c.manager_user_id
- left join sys_user as u2 on u2.user_id = c.gm_user_id
- left join cmc_tender as t on t.tender_id = c.tender_id
- left join cmc_party_a as pa on pa.party_a_id = c.party_a_id
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on pc.project_id = p.project_id
- left join cmc_contract_paid as cp on cp.contract_id = c.contract_id
- left join cmc_contract_work as cw on cw.contract_id = c.contract_id
- <where>
- cw.content like concat('%', #{queryString}, '%')
- <if test="contractId != null and contractId != ''"> and c.contract_id like concat('%', #{contractId}, '%')</if>
- <if test="contractName!= null and contractName != ''"> and c.contract_name like concat('%', #{contractName}, '%')</if>
- <if test="contractCode!= null and contractCode != ''"> and c.contract_code like concat('%', #{contractCode}, '%')</if>
- <if test="tenderId != null and tenderId != ''"> and c.tender_id = #{tenderId}</if>
- <if test="contractNumber != null and contractNumber != ''"> and c.contract_number = #{contractNumber}</if>
- <if test="partyAId != null and partyAId != ''"> and c.party_a_id = #{partyAId}</if>
- <if test="amount != null "> and c.amount = #{amount}</if>
- <if test="deposit != null "> and c.deposit = #{deposit}</if>
- <if test="contractDocument != null and contractDocument != ''"> and c.contract_document = #{contractDocument}</if>
- <if test="drafter != null "> and c.drafter = #{drafter}</if>
- <if test="draftTime != null "> and c.draft_time = #{draftTime}</if>
- <if test="signDate != null "> and YEAR(c.sign_date) = YEAR(#{signDate})</if>
- <if test="signRemark != null and signRemark != ''"> and c.sign_remark = #{signRemark}</if>
- <if test="signScan != null and signScan != ''"> and c.sign_scan = #{signScan}</if>
- <if test="commentType != null and commentType != ''"> and c.comment_type = #{commentType}</if>
- <if test="projectSource != null and projectSource != ''"> and p.project_source = #{projectSource}</if>
- <if test="projectName != null and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
- <if test="partyAName != null and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
- </where>
- group by c.contract_id
- order by c.draft_time desc
- </select>
-
- <select id="selectCmcContractListByRange" parameterType="CmcContract" resultMap="CmcContractResult">
- <include refid="selectCmcContractVo"/>
- <where>
- <if test="contractId != null and contractId != ''"> and c.contract_id like concat('%', #{contractId}, '%')</if>
- <if test="contractName!= null and contractName != ''"> and c.contract_name like concat('%', #{contractName}, '%')</if>
- <if test="contractCode!= null and contractCode != ''"> and c.contract_code like concat('%', #{contractCode}, '%')</if>
- <if test="tenderId != null and tenderId != ''"> and c.tender_id = #{tenderId}</if>
- <if test="contractNumber != null and contractNumber != ''"> and c.contract_number = #{contractNumber}</if>
- <if test="partyAId != null and partyAId != ''"> and c.party_a_id = #{partyAId}</if>
- <if test="amount != null "> and c.amount = #{amount}</if>
- <if test="deposit != null "> and c.deposit = #{deposit}</if>
- <if test="contractDocument != null and contractDocument != ''"> and c.contract_document = #{contractDocument}</if>
- <if test="drafter != null "> and c.drafter = #{drafter}</if>
- <if test="draftTime != null "> and c.draft_time = #{draftTime}</if>
- <if test="signDate != null"> and YEAR(c.sign_date) = YEAR(#{signDate})</if>
- <if test="signRemark != null and signRemark != ''"> and c.sign_remark = #{signRemark}</if>
- <if test="signScan != null and signScan != ''"> and c.sign_scan = #{signScan}</if>
- <if test="commentType != null and commentType != ''"> and c.comment_type = #{commentType}</if>
- <if test="projectSource != null and projectSource != ''"> and p.project_source = #{projectSource}</if>
- <if test="projectName != null and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
- <if test="partyAName != null and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
- and date_format(c.sign_date,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
- </if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
- and date_format(c.sign_date,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
- </if>
- </where>
- group by c.contract_id
- order by c.draft_time desc
- </select>
-
- <select id="selectCmcContractStatistic" resultMap="CmcContractResult" >
- select t1.contract_id, t1.contract_name, t1.project_type, t1.project_number, IFNULL(t1.amount, 0) as amount, IFNULL(t2.sub_amount, 0) as sub_amount, IFNULL(t3.budget_amount, 0) as budget_amount, IFNULL(t4.borrow_amount, 0) as borrow_amount, IFNULL(t5.settle_amount, 0) as settle_amount from
- (select distinct c.contract_id, c.contract_name, p.project_type, p.project_number, c.amount from cmc_contract as c
- left join cmc_contract_sub_contract as csc on csc.contract_id = c.contract_id
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- group by c.contract_id
- order by c.draft_time desc) as t1
- left join
- (select distinct c.contract_id, sum(sc.sub_amount) as sub_amount from cmc_contract as c
- left join cmc_contract_sub_contract as csc on csc.contract_id = c.contract_id
- left join cmc_sub_contract as sc on sc.sub_contract_id = csc.sub_contract_id
- group by c.contract_id) as t2
- on t1.contract_id = t2.contract_id
- left join
- (select distinct c.contract_id, sum(b.total_budget) as budget_amount from cmc_contract as c
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- left join cmc_budget as b on b.project_id = p.project_id
- group by c.contract_id) as t3
- on t1.contract_id = t3.contract_id
- left join
- (select distinct c.contract_id, sum(b.manager_amount) as borrow_amount from cmc_contract as c
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- left join cmc_borrow as b on b.project_id = p.project_id
- group by c.contract_id) as t4
- on t1.contract_id = t4.contract_id
- left join
- (select distinct c.contract_id, sum(ss.amount) as settle_amount from cmc_contract as c
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- left join cmc_settle as s on s.project_id = p.project_id
- left join cmc_settle_summary as ss on ss.settle_id = s.settle_id
- where ss.content = '实际结算总金额'
- group by c.contract_id) as t5
- on t1.contract_id = t5.contract_id
- </select>
-
- <select id="selectCmcContractStatisticByContractId" parameterType="String" resultMap="CmcContractResult" >
- select t1.contract_id, t1.contract_name, t1.project_type, t1.project_number, IFNULL(t1.amount, 0) as amount, IFNULL(t2.sub_amount, 0) as sub_amount, IFNULL(t3.budget_amount, 0) as budget_amount, IFNULL(t4.borrow_amount, 0) as borrow_amount, IFNULL(t5.settle_amount, 0) as settle_amount from
- (select distinct c.contract_id, c.contract_name, p.project_type, p.project_number, c.amount from cmc_contract as c
- left join cmc_contract_sub_contract as csc on csc.contract_id = c.contract_id
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- group by c.contract_id
- order by c.draft_time desc) as t1
- left join
- (select distinct c.contract_id, sum(sc.sub_amount) as sub_amount from cmc_contract as c
- left join cmc_contract_sub_contract as csc on csc.contract_id = c.contract_id
- left join cmc_sub_contract as sc on sc.sub_contract_id = csc.sub_contract_id
- group by c.contract_id) as t2
- on t1.contract_id = t2.contract_id
- left join
- (select distinct c.contract_id, sum(b.total_budget) as budget_amount from cmc_contract as c
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- left join cmc_budget as b on b.project_id = p.project_id
- group by c.contract_id) as t3
- on t1.contract_id = t3.contract_id
- left join
- (select distinct c.contract_id, sum(b.manager_amount) as borrow_amount from cmc_contract as c
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- left join cmc_borrow as b on b.project_id = p.project_id
- group by c.contract_id) as t4
- on t1.contract_id = t4.contract_id
- left join
- (select distinct c.contract_id, sum(ss.amount) as settle_amount from cmc_contract as c
- left join cmc_project_contract as pc on pc.contract_id = c.contract_id
- left join cmc_project as p on p.project_id = pc.project_id
- left join cmc_settle as s on s.project_id = p.project_id
- left join cmc_settle_summary as ss on ss.settle_id = s.settle_id
- where ss.content = '实际结算总金额'
- group by c.contract_id) as t5
- on t1.contract_id = t5.contract_id
- where t1.contract_id = #{param}
- </select>
-
- <select id="selectCmcContractByContractId" parameterType="String" resultMap="CmcContractResult">
- <include refid="selectCmcContractVo"/>
- where c.contract_id = #{contractId}
- group by c.contract_id
- </select>
-
- <insert id="insertCmcContract" parameterType="CmcContract">
- insert into cmc_contract
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="contractId != null">contract_id,</if>
- <if test="contractName != null">contract_name,</if>
- <if test="contractCode != null">contract_code,</if>
- <if test="tenderId != null">tender_id,</if>
- <if test="partyAId != null">party_a_id,</if>
- <if test="contractNumber != null">contract_number,</if>
- <if test="amount != null">amount,</if>
- <if test="deposit != null">deposit,</if>
- <if test="contractDocument != null">contract_document,</if>
- <if test="drafter != null">drafter,</if>
- <if test="draftTime != null">draft_time,</if>
- <if test="remark != null">remark,</if>
- <if test="signDate != null">sign_date,</if>
- <if test="signRemark != null">sign_remark,</if>
- <if test="signScan != null">sign_scan,</if>
- <if test="commentType != null">comment_type,</if>
- <if test="managerComment != null">manager_comment,</if>
- <if test="managerUserId != null">manager_user_id,</if>
- <if test="managerTime != null">manager_time,</if>
- <if test="gmUserId != null">gm_user_id,</if>
- <if test="gmTime != null">gm_time,</if>
- <if test="gmComment != null">gm_comment,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="contractId != null">#{contractId},</if>
- <if test="contractName != null">#{contractName},</if>
- <if test="contractCode != null">#{contractCode},</if>
- <if test="tenderId != null">#{tenderId},</if>
- <if test="partyAId != null">#{partyAId},</if>
- <if test="contractNumber != null">#{contractNumber},</if>
- <if test="amount != null">#{amount},</if>
- <if test="deposit != null">#{deposit},</if>
- <if test="contractDocument != null">#{contractDocument},</if>
- <if test="drafter != null">#{drafter},</if>
- <if test="draftTime != null">#{draftTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="signDate != null">#{signDate},</if>
- <if test="signRemark != null">#{signRemark},</if>
- <if test="signScan != null">#{signScan},</if>
- <if test="commentType != null">#{commentType},</if>
- <if test="managerComment != null">#{managerComment},</if>
- <if test="managerUserId != null">#{managerUserId},</if>
- <if test="managerTime != null">#{managerTime},</if>
- <if test="gmUserId != null">#{gmUserId},</if>
- <if test="gmTime != null">#{gmTime},</if>
- <if test="gmComment != null">#{gmComment},</if>
- </trim>
- </insert>
-
- <update id="updateCmcContract" parameterType="CmcContract">
- update cmc_contract
- <trim prefix="SET" suffixOverrides=",">
- <if test="contractCode != null">contract_code = #{contractCode},</if>
- <if test="contractName != null">contract_name = #{contractName},</if>
- <if test="tenderId != null">tender_id = #{tenderId},</if>
- <if test="partyAId != null">party_a_id = #{partyAId},</if>
- <if test="contractNumber != null">contract_number = #{contractNumber},</if>
- <if test="amount != null">amount = #{amount},</if>
- <if test="deposit != null">deposit = #{deposit},</if>
- <if test="contractDocument != null">contract_document = #{contractDocument},</if>
- <if test="drafter != null">drafter = #{drafter},</if>
- <if test="draftTime != null">draft_time = #{draftTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="signDate != null">sign_date = #{signDate},</if>
- <if test="signRemark != null">sign_remark = #{signRemark},</if>
- <if test="signScan != null">sign_scan = #{signScan},</if>
- <if test="commentType != null">comment_type = #{commentType},</if>
- <if test="managerComment != null">manager_comment = #{managerComment},</if>
- <if test="managerUserId != null">manager_user_id = #{managerUserId},</if>
- <if test="managerTime != null">manager_time = #{managerTime},</if>
- <if test="gmUserId != null">gm_user_id = #{gmUserId},</if>
- <if test="gmTime != null">gm_time = #{gmTime},</if>
- <if test="gmComment != null">gm_comment = #{gmComment},</if>
- </trim>
- where contract_id = #{contractId}
- </update>
-
- <delete id="deleteCmcContractByContractId" parameterType="String">
- delete from cmc_contract where contract_id = #{contractId}
- </delete>
-
- <delete id="deleteCmcContractByContractIds" parameterType="String">
- delete from cmc_contract where contract_id in
- <foreach item="contractId" collection="array" open="(" separator="," close=")">
- #{contractId}
- </foreach>
- </delete>
- </mapper>
|