<?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.changhong.epc.form.mapper.tenant.FormDataMapper">
|
|
<resultMap type="com.changhong.epc.form.service.budget.department.util.AddMoney" id="resultMoney">
|
<result property="dataRowNum" column="DATAROWNUM"/>
|
<result property="costType" column="C_Type"/>
|
<result property="budgetItemBalance" column="budget_itemBalance"/>
|
<result property="budgetAdditionalMoney" column="budget_AdditionalMoney"/>
|
<result property="budgetItemMoney" column="budget_itemMoney"/>
|
<result property="org" column="budget_itemDepartment"/>
|
<result property="chooseSuperBudget" column="chooseSuperBudget"/>
|
<result property="superDep" column="budget_superDepartement"/>
|
</resultMap>
|
|
|
<resultMap type="com.changhong.epc.form.service.budget.department.util.ContractStage" id="Sonresult">
|
<result property="dataRowNum" column="DATAROWNUM"/>
|
<result property="paymentMoney" column="payment_money"/>
|
<result property="alreadyPaid" column="already_paid"/>
|
<result property="fukuanjine" column="fukuanjine"/>
|
<result property="paymentStage" column="payment_stage"/>
|
</resultMap>
|
|
<resultMap type="com.changhong.epc.form.service.budget.department.util.ContractStage" id="Sonsresult">
|
<result property="dataRowNum" column="DATAROWNUM"/>
|
<result property="paymentMoney" column="payment_money"/>
|
<result property="alreadyPaid" column="already_paid"/>
|
<result property="paymentStage" column="payment_stage"/>
|
</resultMap>
|
|
<resultMap type="com.changhong.epc.bean.form.ProcessState" id="stateResult">
|
<result property="processState" column="processState"/>
|
<result property="processLog" column="processLog"/>
|
<result property="processTask" column="processTask"/>
|
<result property="processUser" column="processUser"/>
|
<result property="orderStatus" column="orderStatus"/>
|
<result property="orderCode" column="orderCode"/>
|
<result property="createUser" column="createUser"/>
|
</resultMap>
|
|
<update id="updataFormByCustom">
|
|
update ${formName}
|
set
|
<foreach collection="fields" index="index" item="item" separator=",">
|
`${index}` = #{item}
|
</foreach>
|
|
where dataRowNum = #{dataRowNum}
|
|
</update>
|
|
<delete id="deleteFormData" parameterType="com.changhong.epc.bean.form.FormDataEntity">
|
delete from
|
${formName} where PARENTDATAROWNUM = #{dataRowNum}
|
</delete>
|
|
<insert id="insertFormData" parameterType="com.changhong.epc.bean.form.FormDataEntity"
|
useGeneratedKeys="true" keyProperty="dataRowNum">
|
insert into ${formName}
|
<foreach collection="map" index="key" item="val" separator="," open="(" close=")">
|
${key}
|
</foreach>
|
values
|
<foreach collection="map" index="key" item="val" separator="," open="(" close=")">
|
#{val}
|
</foreach>
|
</insert>
|
|
<update id="updateExpendFormIfHaveOrderCode">
|
update ${formName}
|
set
|
<!-- 暂时打开orderCode,不知道为什么注释了-->
|
orderCode = #{orderCode},
|
orderStatus = 10
|
where
|
dataRowNum = #{dataRowNum}
|
|
</update>
|
|
<update id="updateFormData" parameterType="com.changhong.epc.bean.form.FormDataEntity">
|
update ${formName} set
|
<foreach collection="map" index="key" item="value" separator=",">
|
${key} = #{value}
|
</foreach>
|
where DATAROWNUM = #{dataRowNum}
|
</update>
|
<update id="updateExpendFormState" parameterType="java.lang.Integer">
|
update ${formName} set
|
orderStatus = #{status}
|
<if test="voucherCode != null">
|
,voucherCode = #{voucherCode}
|
</if>
|
where
|
datarowNum = #{dataRowNum}
|
</update>
|
|
|
<select id="searchFormData" parameterType="com.changhong.epc.bean.form.FormDataEntity" resultType="Map">
|
select * from ${formName}
|
where
|
DELETEFLG = 0
|
<if test="parentDataRowNum != null">
|
AND parentDataRowNum = #{parentDataRowNum}
|
</if>
|
<if test="dataRowNum != null">
|
AND datarownum = #{dataRowNum}
|
</if>
|
|
</select>
|
|
<select id="searchSubFormDataList" parameterType="com.changhong.epc.bean.form.FormDataEntity" resultType="Map">
|
select * from ${formName}
|
<where>
|
<if test="parentDataRowNum != null">
|
parentDataRowNum = #{parentDataRowNum}
|
</if>
|
</where>
|
</select>
|
|
|
<select id="searchBudgetSubForm" parameterType="com.changhong.epc.bean.form.FormDataEntity" resultType="com.changhong.epc.bean.form.BugetSubForm">
|
select
|
*
|
FROM ${formName}
|
where
|
parentDataRowNum = #{parentDataRowNum}
|
<if test=" set != null">
|
and C_Type in
|
<foreach collection="set" index="index" item="item" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
|
</if>
|
|
|
</select>
|
|
<select id="selectRangeByIds" resultType="int">
|
select DATAROWNUM from ${formName}
|
<!-- > -->
|
where
|
processState = '30' AND
|
DATE(budgetStartDate) <= #{formDate}
|
<choose>
|
<when test="budgetProject != null">
|
AND budget_type = #{budProject}
|
</when>
|
<!-- <![CDATA[>]]> -->
|
<otherwise>
|
AND budget_type = #{budDep}
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="toDate != null">
|
AND DATE(budgetEndDate) >= #{toDate}
|
</when>
|
<otherwise>
|
AND budgetEndDate >= #{formDate}
|
</otherwise>
|
</choose>
|
<if test="conditionMap != null">
|
<foreach collection="conditionMap" index="key" item="value" separator=" ">
|
AND ${key} = #{value}
|
</foreach>
|
</if>
|
<if test="occupy != null">
|
and occupy = #{occupy}
|
</if>
|
AND currency = #{currency}
|
and DELETEFLG = 0
|
ORDER BY DATAROWNUM DESC
|
<!-- LIMIT #{pageNum}, #{pageSize} -->
|
</select>
|
|
<select id="selectMainIdBySubIds" resultType="int">
|
SELECT
|
DATAROWNUM
|
FROM
|
${formName}
|
WHERE
|
PARENTDATAROWNUM = #{dataRowNumber}
|
AND
|
DELETEFLG = 0;
|
|
</select>
|
|
|
<select id="searchFormDataList" parameterType="com.changhong.epc.bean.form.FormDataEntity" resultType="Map">
|
select * from ${formName} where DELETEFLG = 0 AND
|
<choose>
|
<when test="childAlias != null">
|
PARENTDATAROWNUM = #{dataRowNum}
|
</when>
|
<otherwise>
|
DATAROWNUM = #{dataRowNum}
|
</otherwise>
|
</choose>
|
<if test="costType !=null ">
|
and C_Type = #{costType}
|
</if>
|
|
<if test="NowDepartment !=null " >
|
and budget_itemDepartment = #{NowDepartment}
|
</if>
|
|
<if test="budgetProject !=null " >
|
and budget_project = #{budgetProject}
|
</if>
|
<if test="dimensions != null">
|
<foreach collection="dimensions" item="dimension" >
|
<if test="dimension.value != null and dimension.value != ''">
|
AND ${dimension.column} = #{dimension.value}
|
</if>
|
</foreach>
|
</if>
|
</select>
|
|
<select id="searchSubFormIds" resultType="java.lang.Integer">
|
select
|
DATAROWNUM
|
from ${formName}
|
where PARENTDATAROWNUM = #{dataRowNum}
|
</select>
|
|
<select id="searchFormDataLists" parameterType="com.changhong.epc.bean.form.FormDataEntity" resultType="Map">
|
select * from ${formName} where
|
<choose>
|
<when test="childAlias != null">
|
PARENTDATAROWNUM = #{dataRowNum}
|
</when>
|
<otherwise>
|
DATAROWNUM = #{dataRowNum}
|
</otherwise>
|
</choose>
|
<if test="costType !=null ">
|
and C_Type = #{costType}
|
</if>
|
|
<if test="department !=null " >
|
and budget_itemDepartment in
|
<foreach collection="department" item="item" index="index" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
</if>
|
|
<if test="budgetProject !=null " >
|
and budget_project = #{budgetProject}
|
</if>
|
<if test="dimensions != null">
|
<foreach collection="dimensions" item="dimension" >
|
<if test="dimension.value != null and dimension.value != ''">
|
AND ${dimension.column} = #{dimension.value}
|
</if>
|
</foreach>
|
</if>
|
</select>
|
|
<select id="searchExtendFormData" resultMap="resultMoney">
|
select * from ${formName} where DELETEFLG = 0 and
|
<choose>
|
<when test="parentDataRowNum != null">
|
PARENTDATAROWNUM = #{parentDataRowNum}
|
</when>
|
<otherwise>
|
DATAROWNUM = #{dataRowNum}
|
</otherwise>
|
</choose>
|
</select>
|
|
<update id="updateItemBalance">
|
UPDATE
|
${formName}
|
<trim prefix="set" suffixOverrides=",">
|
<if test="add.budgetItemBalance != null">
|
budget_itemBalance = #{add.budgetItemBalance},
|
</if>
|
<if test="add.budgetItemMoney !=null">
|
budget_itemMoney = #{add.budgetItemMoney},
|
</if>
|
|
<if test="add.budgetSuperMoney !=null">
|
budget_superMoney = #{add.budgetSuperMoney}
|
</if>
|
|
|
|
</trim>
|
WHERE
|
DATAROWNUM = #{add.dataRowNum}
|
</update>
|
|
<update id="updaterepayment">
|
UPDATE
|
${formName}
|
<trim prefix="set" suffixOverrides=",">
|
<if test="OutstandingAmount != null">
|
OUTSTANDINGAMOUNT = #{OutstandingAmount},
|
</if>
|
<if test="alreadyRepaid !=null">
|
ALREADYREPAID = #{alreadyRepaid}
|
</if>
|
</trim>
|
WHERE
|
DATAROWNUM = #{dataRowNum}
|
</update>
|
|
<select id="checkDate" resultType="java.lang.Integer">
|
|
SELECT
|
DATAROWNUM
|
FROM
|
${formName}
|
WHERE
|
DATE(budgetStartDate) <![CDATA[ != ]]> #{startDate}
|
|
AND DATE(budgetEndDate) <![CDATA[ != ]]> #{endDate}
|
<!-- OR (
|
|
DATE(budgetEndDate) <![CDATA[ <= ]]> #{endDate}
|
AND DATE(budgetEndDate) <![CDATA[ >= ]]> #{endDate}
|
|
) -->
|
AND currency = #{currency}
|
|
</select>
|
|
<select id="queryFormByDataRowNum" resultType="java.util.Map">
|
SELECT
|
C_Type budget_itemCostType,
|
`budget_itemDepartment`
|
FROM
|
${formName}
|
<if test=" dataRowNum != null ">
|
WHERE
|
PARENTDATAROWNUM IN
|
<foreach item="item" index="index" collection="dataRowNum" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
|
</if>
|
|
</select>
|
|
<select id="selectBudget" resultType="java.util.Map">
|
SELECT
|
*
|
FROM
|
${formName}
|
WHERE
|
BUDGET_ITEMDEPARTMENT = #{orgs}
|
AND
|
C_Type = #{budget_itemCostType}
|
AND
|
DELETEFLG = 0
|
LIMIT 1
|
</select>
|
|
<select id="selectSonForm" resultMap="Sonresult">
|
|
select * from ${name}
|
where PARENTDATAROWNUM = #{num}
|
|
</select>
|
|
<select id="selectSonsForm" resultMap="Sonsresult">
|
|
select * from ${name}
|
where PARENTDATAROWNUM = #{num}
|
|
</select>
|
|
<update id="updateContract">
|
update ${name} set
|
alreadyPaid = #{son.alreadyPaid}
|
where DATAROWNUM = #{son.dataRowNum}
|
</update>
|
|
<select id="selectDataRowNum" resultType="java.lang.Integer">
|
SELECT
|
datarownum
|
FROM
|
formdata_{tenantId}_${formId}
|
WHERE
|
ORDERCODE = #{orderCode}
|
AND TENANTID = #{tenantId}
|
|
</select>
|
|
<update id ="updateState">
|
update formdata_${pro.tenantId}_${pro.formId}
|
<trim prefix="set" suffixOverrides="," >
|
<if test="pro.processState !=null">
|
processState = #{pro.processState},
|
</if>
|
<if test="pro.processLog !=null">
|
processLog = #{pro.processLog},
|
</if>
|
<if test="pro.processTask !=null">
|
processTask = #{pro.processTask},
|
</if>
|
<if test="pro.processUser !=null">
|
processUser = #{pro.processUser},
|
</if>
|
<if test="pro.solidification !=null">
|
solidification = #{pro.solidification},
|
</if>
|
<if test="pro.orderStatus !=null">
|
orderStatus = #{pro.orderStatus},
|
</if>
|
<if test="pro.voucherno !=null">
|
voucherno = #{pro.voucherno},
|
</if>
|
<if test="pro.conformingstate !=null">
|
conformingstate = #{pro.conformingstate},
|
</if>
|
<if test="pro.tradeNumber !=null">
|
tradeNumber = #{pro.tradeNumber},
|
</if>
|
<if test="pro.htmlUrl !=null">
|
htmlUrl = #{pro.htmlUrl},
|
</if>
|
</trim>
|
where dataRowNum = #{pro.dataRowNum}
|
</update>
|
|
<select id="selectState" resultMap="stateResult">
|
SELECT
|
processState,
|
processLog,
|
processTask,
|
processUser,
|
orderStatus,
|
orderCode,
|
createUser
|
FROM
|
formdata_${pro.tenantId}_${pro.formId}
|
WHERE
|
dataRowNum = #{pro.dataRowNum}
|
</select>
|
|
<select id="searchFormData1" parameterType="com.changhong.epc.bean.form.FormDataEntity" resultType="Map">
|
select * from ${formName}
|
where processState = '30'
|
<if test="parentDataRowNum != null">
|
and parentDataRowNum = #{parentDataRowNum}
|
</if>
|
<if test="dataRowNum != null">
|
and datarownum = #{dataRowNum}
|
</if>
|
|
</select>
|
|
<select id="selectRangeById" resultType="int">
|
select DATAROWNUM from ${formName}
|
<!-- > -->
|
where
|
<!-- processState = '30' AND -->
|
DATE(budgetStartDate) <= #{formDate}
|
<if test="budgetProject != null">
|
AND budget_type = #{budgetProject}
|
</if>
|
<if test="toDate != null">
|
AND DATE(budgetEndDate) >= #{toDate}
|
</if>
|
<if test="currency != null">
|
and currency = #{currency}
|
</if>
|
<if test="occupy != null">
|
and occupy = #{occupy}
|
</if>
|
and DELETEFLG = 0
|
|
</select>
|
<select id="selectRangeByIdOnlyOne" resultType="int">
|
select DATAROWNUM from ${formName}
|
<!-- > -->
|
where
|
<!-- processState = '30' AND -->
|
DATE(budgetStartDate) <= #{formDate}
|
<if test="budgetProject != null">
|
AND budget_type = #{budgetProject}
|
</if>
|
<if test="toDate != null">
|
AND DATE(budgetEndDate) >= #{toDate}
|
</if>
|
<if test="currency != null">
|
and currency = #{currency}
|
</if>
|
<if test="occupy != null">
|
and occupy = #{occupy}
|
</if>
|
and DELETEFLG = '0'
|
and DATAROWNUM not in
|
(
|
select PARENTDATAROWNUM from ${subFormName} where DATAROWNUM in
|
<foreach item="item" index="index" collection="dataRowNum" open="(" close=")" separator=",">
|
#{item.DATAROWNUM}
|
</foreach>
|
|
)
|
</select>
|
|
<select id="selectRangeByNumber" resultType="java.lang.String">
|
select PARENTDATAROWNUM from ${formName}
|
where
|
PARENTDATAROWNUM in
|
<foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
<if test="C_Type != null">
|
AND C_Type = #{C_Type}
|
</if>
|
<if test="dep != null">
|
AND budget_itemDepartment = #{dep}
|
</if>
|
<if test=" budget_project != null">
|
AND budget_project = #{budget_project}
|
</if>
|
LIMIT 1
|
</select>
|
|
<select id="selectByNumber" resultType="java.lang.String">
|
select ${number} from ${formName}
|
where DATAROWNUM = #{id}
|
</select>
|
|
|
|
|
<select id="selectAssetOri" resultType="java.util.Map">
|
select
|
originalMoney
|
from
|
formdata_{tenantId}_${formId}
|
where
|
DATAROWNUM = #{assetId}
|
and
|
DELETEFLG = 0
|
</select>
|
|
|
<update id="saveOccupant" parameterType="com.changhong.autoform.entity.FormData">
|
UPDATE
|
formdata_{tenantId}_${formId}
|
SET
|
occupant = #{reimbursement}
|
WHERE
|
DATAROWNUM = #{dataRowNum}
|
AND
|
DELETEFLG = 0
|
</update>
|
|
|
|
<update id="delteOccupant" parameterType="com.changhong.autoform.entity.FormData">
|
UPDATE
|
formdata_{tenantId}_${formId}
|
SET
|
occupant = NULL
|
WHERE
|
DATAROWNUM = #{dataRowNum}
|
AND
|
DELETEFLG = 0
|
</update>
|
|
|
<select id="selectToWriteBudgetByDataRowNum" resultType="java.util.Map">
|
SELECT
|
*
|
FROM
|
${formName}
|
WHERE
|
DATAROWNUM = #{dataRowNum}
|
|
</select>
|
|
|
<select id="selectSQFormId" resultType="java.util.Map">
|
SELECT
|
a.*
|
FROM
|
epc_cost_from_mapping_{rule} a
|
WHERE
|
a.ct_id IN (
|
SELECT
|
b.ct_id
|
FROM
|
epc_cost_from_mapping_{rule} b
|
WHERE
|
b.f_id = #{fId}
|
AND b.ct_id =#{cId}
|
AND b.data_start = 0
|
)
|
AND type = 'SQ'
|
AND a.data_start = 0
|
|
|
</select>
|
|
<select id="selectNumber" resultType="java.util.LinkedHashMap">
|
SELECT
|
*
|
FROM
|
${formName}
|
WHERE
|
DATAROWNUM = #{dataRowNum}
|
|
</select>
|
|
|
|
<select id="selectDataCountByUser" resultType="int">
|
SELECT
|
COUNT(1)
|
FROM
|
formdata_{tenantId}_${formId}
|
WHERE
|
DELETEFLG = 0
|
AND CREATEUSER = #{openId}
|
AND C_Type = #{costType}
|
</select>
|
|
|
<select id="selectDataListByUser" resultType="java.util.Map">
|
(
|
SELECT
|
*
|
FROM
|
formdata_{tenantId}_${formId}
|
WHERE
|
DELETEFLG = 0
|
AND occupant IS NULL
|
AND CREATEUSER = #{openId}
|
AND C_Type = #{costType}
|
ORDER BY
|
CREATEDATETIME DESC,
|
C_Type ASC
|
)
|
UNION ALL
|
(
|
SELECT
|
*
|
FROM
|
formdata_{tenantId}_${formId}
|
WHERE
|
DELETEFLG = 0
|
AND occupant IS NOT NULL
|
AND CREATEUSER = #{openId}
|
AND C_Type = #{costType}
|
ORDER BY
|
CREATEDATETIME DESC,
|
C_Type ASC
|
)
|
LIMIT ${begin},${size}
|
</select>
|
|
|
<select id="selectFormIdByCostTypeAndFormType" resultType="java.util.Map">
|
SELECT
|
*
|
FROM
|
epc_cost_from_mapping_{rule}
|
WHERE
|
data_start = 0
|
AND ct_id = #{costType}
|
AND type = #{formType}
|
</select>
|
|
<select id="selectDataBybussinessNumber" resultType="java.util.Map">
|
SELECT
|
*
|
FROM
|
formdata_{tenantId}_${formId}
|
WHERE
|
DELETEFLG = 0
|
AND
|
number_expend = #{bussinessNumber}
|
</select>
|
|
<select id="getSumAlreadyPaid" resultType="java.util.Map">
|
SELECT
|
payment_stage,
|
sum(paidMoney) as alreadypaid
|
FROM
|
${formName}
|
WHERE
|
PARENTDATAROWNUM in
|
<foreach collection="list" item="dataRowNum" separator="," open="(" close=")" >
|
#{dataRowNum}
|
</foreach>
|
GROUP BY payment_stage
|
</select>
|
|
<select id="selectDataRows" resultType="java.lang.Integer">
|
SELECT
|
dataRowNum
|
FROM
|
${formName}
|
WHERE
|
processState = '30'
|
AND
|
selectContracts = #{num}
|
<if test="currDataRowNum !=null">
|
AND dataRowNum != #{currDataRowNum}
|
</if>
|
</select>
|
|
<select id="getPersionCostReturn" resultType="java.util.Map">
|
select
|
*
|
from
|
formdata_{tenantId}_${formName} as f1
|
left join
|
formdata_{tenantId}_${formName2} as f2 on(f1.DATAROWNUM=f2.PARENTDATAROWNUM)
|
where
|
f1.DATAROWNUM=#{dateNum}
|
and f1.DELETEFLG=0
|
and f2.DELETEFLG=0
|
|
|
</select>
|
|
<select id="getBorrowMoney" resultType="java.util.Map">
|
select *
|
from formdata_{tenantId}_${forName}
|
where OutstandingAmount>0
|
and reimburseMan=#{openId} and DELETEFLG=0 and processState = '30'
|
</select>
|
|
<select id="selectTableExist" resultType="java.lang.Integer">
|
select count(1)
|
from information_schema.tables
|
where table_name="formdata_{tenantId}_${formName}"
|
|
</select>
|
|
<select id="selectApply" parameterType="com.changhong.epc.bean.form.ApplyCostForm" resultType="java.util.Map">
|
|
<foreach collection="costformMapping" close=" order by `CREATEDATETIME` DESC" item="data" separator="UNION ALL">
|
SELECT
|
dataRowNum,number_apply,reimburseMan,C_Type,applyDate,processLog,applyUseMoney,#{data.fName} formName
|
, #{data.formId} formId,
|
CREATEDATETIME
|
FROM
|
formdata_{tenantId}_${data.formId}
|
WHERE
|
processState = '30'
|
and C_Type = #{data.ctId}
|
AND ISNULL(processFlag)
|
AND CREATEUSER = #{insP}
|
AND DELETEFLG = 0
|
AND (select count(0)
|
from formdata_{tenantId}_${data.expenseFormId}
|
where toWriteBudget = formdata_{tenantId}_${data.formId}.datarownum and deleteflg = 0) = 0
|
-- 是否借款
|
AND ((accountFlag = 'A000001' and orderStatus = '45')or (accountFlag = 'A000002' and processState = '30'))
|
</foreach>
|
|
</select>
|
|
<select id="selectValueCount" resultType="java.lang.Integer">
|
select count(*) from ${formName}
|
where DELETEFLG = 0
|
AND ${fieKey} = #{fieValue}
|
<if test="dataRowNum != null">
|
AND DATAROWNUM != #{dataRowNum}
|
</if>
|
</select>
|
|
<resultMap id="searchSuperBudgetMap" type="java.util.Map">
|
<id column="DATAROWNUM" property="DATAROWNUM"/>
|
<result column="budgetStatement" property="budgetStatement"/>
|
<result column="number_budget" property="number_budget"/>
|
<result column="budgetStartDate" property="budgetStartDate"/>
|
<result column="budgetEndDate" property="budgetEndDate"/>
|
<result column="budget_type" property="budget_type"/>
|
<result column="solidification" property="solidification"/>
|
<collection property="budget_subFrom" ofType="java.util.Map" javaType="java.util.List">
|
<id column="SUB_DATAROWNUM" property="DATAROWNUM"/>
|
<result column="budget_superDepartement" property="budget_superDepartement"/>
|
<result column="C_Type" property="C_Type"/>
|
<result column="budget_itemBalance" property="budget_itemBalance"/>
|
<result column="budget_itemMoney" property="budget_itemMoney"/>
|
<result column="budget_project" property="budget_project"/>
|
<result column="budget_itemDepartment" property="budget_itemDepartment"/>
|
<result column="budget_superMoney" property="budget_superMoney"/>
|
</collection>
|
</resultMap>
|
|
<select id="searchSuperBudget" parameterType="java.util.Map" resultMap="searchSuperBudgetMap">
|
select
|
b.DATAROWNUM,
|
b.budgetStatement,
|
b.number_budget,
|
b.budgetStartDate,
|
b.budgetEndDate,
|
b.budget_type,
|
b.solidification,
|
bs.DATAROWNUM SUB_DATAROWNUM,
|
bs.budget_superDepartement,
|
bs.C_Type,
|
bs.budget_itemBalance,
|
bs.budget_itemMoney,
|
bs.budget_project,
|
bs.budget_itemDepartment,
|
bs.budget_superMoney
|
from (
|
select
|
DISTINCT
|
b.DATAROWNUM
|
from formdata_{tenantId}_${formId} b
|
left join formdata_{tenantId}_${formId}_budget_subfrom bs on b.DATAROWNUM = bs.PARENTDATAROWNUM
|
WHERE budgetStartDate <= #{budgetStartDate}
|
and budgetEndDate >= #{budgetEndDate}
|
and currency = #{currency}
|
and occupy != #{occupy}
|
and budget_type = #{budgetType}
|
and b.processState = 30
|
<if test="subData.size() != null">
|
<foreach collection="subData" item="data" open="and (" close=")" separator=" or ">
|
<trim prefixOverrides="and">
|
<if test="data.C_Type != null">
|
and C_Type = #{data.C_Type}
|
</if>
|
<if test="data.budget_itemDepartment_crossLevel and data.budget_itemDepartment != null and data.budget_itemDepartment != ''">
|
and budget_itemDepartment like concat(#{data.budget_itemDepartment}, '%')
|
and length(budget_itemDepartment) <= (#{data.budget_itemDepartment_length} - 4)
|
</if>
|
<if test="!data.budget_itemDepartment_crossLevel and data.budget_itemDepartment != null and data.budget_itemDepartment != ''">
|
and budget_itemDepartment = #{data.budget_itemDepartment}
|
</if>
|
</trim>
|
</foreach>
|
</if>
|
order by b.DATAROWNUM desc
|
LIMIT #{pageN}, #{pageS}
|
) pageInfo
|
left join formdata_{tenantId}_${formId} b on pageInfo.DATAROWNUM = b.DATAROWNUM
|
left join formdata_{tenantId}_${formId}_budget_subfrom bs on b.DATAROWNUM = bs.PARENTDATAROWNUM
|
order by b.DATAROWNUM desc
|
</select>
|
|
<select id="searchBudget" parameterType="java.util.Map" resultMap="searchSuperBudgetMap">
|
select
|
b.DATAROWNUM,
|
b.number_budget,
|
b.budgetStartDate,
|
b.budgetEndDate,
|
b.budget_type,
|
b.solidification
|
from formdata_{tenantId}_${formId} b
|
where b.DATAROWNUM = #{dataRowNum}
|
</select>
|
|
<select id="selectRepayment" resultType="java.lang.Integer">
|
select
|
count(0)
|
from formdata_{tenantId}_${loanFormId} j
|
LEFT JOIN formdata_{tenantId}_${repaymentFormId} h on j.DATAROWNUM = h.repaymentSuperLoan and h.processState = 30
|
where j.processState = 30
|
and h.DATAROWNUM is null
|
and j.LoanPeople = #{borrowMoneyUser}
|
and DATE_ADD(STR_TO_DATE(j.createDatetime, '%Y-%m-%d'), interval #{day} DAY) < now()
|
</select>
|
|
<select id="selectApplyFormIds" resultType="com.changhong.epc.bean.tenant.cost.CostFromMapping">
|
select
|
DISTINCT
|
f_id
|
from epc_cost_from_mapping_100000001_7
|
where type = 'SQ'
|
</select>
|
|
<select id="selectApplyRepayment" resultType="java.lang.Integer">
|
|
select
|
count(0)
|
from (
|
<foreach collection="formIds" item="formId" separator="union all">
|
select alreadyRepaid, loanAmount
|
from formdata_{tenantId}_${formId}
|
where accountFlag = 'A000001'
|
and processState = 30
|
and reimburseMan = #{borrowMoneyUser}
|
</foreach>
|
) a
|
where alreadyRepaid < loanAmount
|
|
</select>
|
|
<select id="searchSuperBudgetCount" parameterType="java.util.Map" resultType="java.lang.Long">
|
select
|
count(0)
|
from (
|
select
|
DISTINCT
|
b.DATAROWNUM
|
from formdata_{tenantId}_${formId} b
|
left join formdata_{tenantId}_${formId}_budget_subfrom bs on b.DATAROWNUM = bs.PARENTDATAROWNUM
|
WHERE budgetStartDate <= #{budgetStartDate}
|
and budgetEndDate >= #{budgetEndDate}
|
and currency = #{currency}
|
and occupy != #{occupy}
|
and budget_type = #{budgetType}
|
and b.processState = 30
|
<if test="subData.size() != null">
|
<foreach collection="subData" item="data" open="and (" close=")" separator=" or ">
|
C_Type = #{data.C_Type}
|
<if test="data.budget_itemDepartment_crossLevel">
|
and budget_itemDepartment like concat(#{data.budget_itemDepartment}, '%')
|
and length(budget_itemDepartment) <= #{data.budget_itemDepartment_length} - 4
|
</if>
|
<if test="!data.budget_itemDepartment_crossLevel">
|
and budget_itemDepartment = #{data.budget_itemDepartment}
|
</if>
|
</foreach>
|
</if>
|
) pageInfo
|
</select>
|
|
</mapper>
|