<?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.apply.ApplyMergeMapper">
|
|
<sql id="selectApplySql">
|
select
|
main.DATAROWNUM
|
, main.number_apply <!-- 申请编号 -->
|
, main.applicationCurrencyAmount <!-- 申请金额 -->
|
, main.exchangeRate <!-- 汇率 -->
|
, main.applicationCurrency <!-- 申请币种 -->
|
, main.reimburseMan <!-- 申请人 -->
|
, main.budgetStartDate <!-- 申请日期 -->
|
, main.apply_department <!-- 申请部门 -->
|
, main.loanAmount <!-- 借款金额 -->
|
, sum(journey.daysOfTravel) sumDays <!-- 出差天数 -->
|
, GROUP_CONCAT(journey.countries) countries <!-- 出差国家 -->
|
, GROUP_CONCAT(journey.placeOfTravel) placeOfTravel <!-- 出差地点 -->
|
, GROUP_CONCAT(DATE_FORMAT(journey.ToDate, '%Y-%m-%d')) ToDate <!-- 出差时间 -->
|
, main.solidification
|
from formdata_{tenantId}_${formId} main
|
left join formdata_{tenantId}_${formId}_journey journey on main.DATAROWNUM = journey.PARENTDATAROWNUM
|
where main.DELETEFLG = 0
|
and main.loanAmount > 0
|
and main.processState = 20
|
</sql>
|
|
<select id="selectApplyInfo" resultType="java.util.Map">
|
<include refid="selectApplySql"/>
|
and main.DATAROWNUM = #{dataRowNum}
|
GROUP BY main.DATAROWNUM
|
</select>
|
|
<select id="selectApplyMergeList" parameterType="java.util.Map" resultType="java.util.Map">
|
select * from (
|
<include refid="selectApplySql"/>
|
and main.apply_department = #{info.apply_department}
|
and main.applicationCurrency = #{info.applicationCurrency}
|
and main.DATAROWNUM != #{info.DATAROWNUM}
|
GROUP BY main.DATAROWNUM
|
) m
|
left join apply_merge_{rule} am on m.dataRowNum = am.apply_id and am.data_start = 0
|
where m.placeOfTravel = #{info.placeOfTravel}
|
and m.ToDate = #{info.ToDate}
|
and am.apply_id is null
|
</select>
|
|
<resultMap id="selectApplyMergeListByIdsResultMap" type="java.util.Map">
|
<id column="DATAROWNUM" property="DATAROWNUM"/>
|
<result column="number_apply" property="number_apply"/>
|
<result column="applicationCurrencyAmount" property="applicationCurrencyAmount"/>
|
<result column="exchangeRate" property="exchangeRate"/>
|
<result column="applicationCurrency" property="applicationCurrency"/>
|
<result column="reimburseMan" property="reimburseMan"/>
|
<result column="budgetStartDate" property="budgetStartDate"/>
|
<result column="apply_department" property="apply_department"/>
|
<result column="loanAmount" property="loanAmount"/>
|
<result column="sumDays" property="sumDays"/>
|
<result column="placeOfTravel" property="placeOfTravel"/>
|
<result column="countries" property="countries"/>
|
<result column="ToDate" property="ToDate"/>
|
<result column="solidification" property="solidification"/>
|
</resultMap>
|
|
<select id="selectApplyMergeListByIds" resultMap="selectApplyMergeListByIdsResultMap">
|
<include refid="selectApplySql"/>
|
<if test="ids != null and ids.size() > 0">
|
<foreach collection="ids" item="id" open="and main.DATAROWNUM in (" close=")" separator=",">
|
#{id}
|
</foreach>
|
</if>
|
GROUP BY main.DATAROWNUM
|
order by main.DATAROWNUM
|
</select>
|
|
<select id="selectApplyMergeChildList" parameterType="java.util.Map" resultType="java.util.Map">
|
select *
|
from formdata_{tenantId}_${formId}_journey
|
<where>
|
<foreach collection="ids" item="id" open="and PARENTDATAROWNUM in (" close=")" separator=",">
|
#{id}
|
</foreach>
|
</where>
|
order by PARENTDATAROWNUM
|
</select>
|
|
<delete id="deleteByDataRowNum" parameterType="int" >
|
update apply_merge_{rule}
|
set data_start = 99
|
where group_id in (
|
select c.group_id from (
|
select group_id from apply_merge_{rule} where apply_id = #{dataRowNum} and data_start = 0
|
) c
|
)
|
</delete>
|
|
<select id="countOverApply" parameterType="com.changhong.epc.bean.form.apply.ApplyMergeDto" resultType="int">
|
SELECT
|
count(0)
|
FROM
|
formdata_{tenantId}_${formId}
|
WHERE
|
dataRowNum IN (
|
SELECT apply_id
|
FROM apply_merge_{rule}
|
WHERE group_id IN ( SELECT group_id FROM apply_merge_{rule} WHERE apply_id = #{dataRowNum} AND data_start = 0 )
|
)
|
AND processState = 30
|
</select>
|
</mapper>
|