Commit 69d28df1 authored by fangxinjiang's avatar fangxinjiang

实缴查询优化-fxj

parent 79e2e312
...@@ -403,12 +403,12 @@ public interface TPaymentInfoMapper extends BaseMapper<TPaymentInfo> { ...@@ -403,12 +403,12 @@ public interface TPaymentInfoMapper extends BaseMapper<TPaymentInfo> {
* 实缴查询社保合计查询 * 实缴查询社保合计查询
* @return * @return
*/ */
List<TPaymentInfoExportVo> getSumByKeyGroupSocial(@Param("keyGroups") List<String> keyGroups); TPaymentInfoExportVo getSumByKeyGroupSocial(@Param("empIdcard") String empIdcard,@Param("payMonth") String payMonth,@Param("createMonth") String createMonth);
/** /**
* 实缴查询公积金合计查询 * 实缴查询公积金合计查询
* @return * @return
*/ */
List<TPaymentInfoExportVo> getSumByKeyGroupFund(@Param("keyGroups") List<String> keyGroups); TPaymentInfoExportVo getSumByKeyGroupFund(@Param("empIdcard") String empIdcard,@Param("payMonth") String payMonth,@Param("createMonth") String createMonth);
} }
...@@ -180,6 +180,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -180,6 +180,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
*/ */
@Override @Override
public IPage<TPaymentInfoNewVo> getTPaymentInfoNewPage(Page<TPaymentInfo> page, TPaymentInfoSearchVo tPaymentInfo) { public IPage<TPaymentInfoNewVo> getTPaymentInfoNewPage(Page<TPaymentInfo> page, TPaymentInfoSearchVo tPaymentInfo) {
//如果是含身份证查询直接查询走索引,无需走特殊处理逻辑,身份证查询量不会大
if (Common.isNotNull(tPaymentInfo.getEmpIdcard())){
return baseMapper.getTPaymentInfoNewPage(page, tPaymentInfo);
}
Page<TPaymentInfoNewVo> pageNew = new Page<>(); Page<TPaymentInfoNewVo> pageNew = new Page<>();
pageNew.setSize(page.getSize()); pageNew.setSize(page.getSize());
pageNew.setCurrent(page.getCurrent()); pageNew.setCurrent(page.getCurrent());
...@@ -218,18 +222,32 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -218,18 +222,32 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
pageData = baseMapper.getTPaymentInfoNewPageSocial(searchVo, (pageNew.getCurrent() - 1) * pageNew.getSize(), pageNew.getSize()); pageData = baseMapper.getTPaymentInfoNewPageSocial(searchVo, (pageNew.getCurrent() - 1) * pageNew.getSize(), pageNew.getSize());
//封装对应的社保及公积金的合计数据处理 //封装对应的社保及公积金的合计数据处理
if (Common.isNotNull(pageData)){ if (Common.isNotNull(pageData)){
List<String> keyGroup = new ArrayList<>();
HashMap<String,TPaymentInfoNewVo> newVoHashMap = new HashMap<>(); HashMap<String,TPaymentInfoNewVo> newVoHashMap = new HashMap<>();
String key; String key;
TPaymentInfoExportVo newVo;
for (TPaymentInfoNewVo vo:pageData){ for (TPaymentInfoNewVo vo:pageData){
key = vo.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING key = vo.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ vo.getSocialPayMonth()+ CommonConstants.DOWN_LINE_STRING + vo.getSocialPayMonth()+ CommonConstants.DOWN_LINE_STRING
+ vo.getSocialCreateMonth(); + vo.getSocialCreateMonth();
keyGroup.add(key); newVo = baseMapper.getSumByKeyGroupSocial(vo.getEmpIdcard(),vo.getSocialPayMonth(),vo.getSocialCreateMonth());
if (null != newVo){
vo.setSumAll(BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(newVo.getSumAll()),BigDecimalUtils.isNullToZero(newVo.getSocialSum())));
vo.setSocialSum(newVo.getSocialSum());
vo.setSocialPayAddr(newVo.getSocialPayAddr());
vo.setSocialHousehold(newVo.getSocialHousehold());
}
newVo = baseMapper.getSumByKeyGroupFund(vo.getEmpIdcard(),vo.getSocialPayMonth(),vo.getSocialCreateMonth());
if (null != newVo){
vo.setSumAll(BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(newVo.getSumAll()),BigDecimalUtils.isNullToZero(newVo.getProvidentSum())));
vo.setProvidentSum(newVo.getProvidentSum());
vo.setProvidentHousehold(newVo.getProvidentHousehold());
vo.setProvidentPayAddr(newVo.getProvidentPayAddr());
}
newVoHashMap.put(key,vo); newVoHashMap.put(key,vo);
} }
List<TPaymentInfoExportVo> pageDataSumSocial = baseMapper.getSumByKeyGroupSocial(keyGroup);
List<TPaymentInfoNewVo> pageDataHandle = new ArrayList<>(); List<TPaymentInfoNewVo> pageDataHandle = new ArrayList<>();
/*
List<TPaymentInfoExportVo> pageDataSumSocial = baseMapper.getSumByKeyGroupSocial(keyGroup);
if (Common.isNotNull(pageDataSumSocial)){ if (Common.isNotNull(pageDataSumSocial)){
TPaymentInfoNewVo newVo; TPaymentInfoNewVo newVo;
for (TPaymentInfoExportVo exportVo:pageDataSumSocial){ for (TPaymentInfoExportVo exportVo:pageDataSumSocial){
...@@ -257,7 +275,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -257,7 +275,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
newVoHashMap.put(exportVo.getKeyGroup(),newVo); newVoHashMap.put(exportVo.getKeyGroup(),newVo);
} }
} }*/
if (Common.isNotNull(newVoHashMap)){ if (Common.isNotNull(newVoHashMap)){
for (TPaymentInfoNewVo k:newVoHashMap.values()){ for (TPaymentInfoNewVo k:newVoHashMap.values()){
pageDataHandle.add(k); pageDataHandle.add(k);
......
...@@ -1524,32 +1524,6 @@ ...@@ -1524,32 +1524,6 @@
<!--tPaymentInfo简单分页查询 fxj 2024-08-08 调整--> <!--tPaymentInfo简单分页查询 fxj 2024-08-08 调整-->
<select id="getTPaymentInfoNewPageSocial" resultMap="tPaymentInfoNewMap"> <select id="getTPaymentInfoNewPageSocial" resultMap="tPaymentInfoNewMap">
SELECT SELECT
c.keyGroup,
c.EMP_IDCARD,
c.EMP_NAME,
c.UNIT_NAME,
c.SETTLE_DOMAIN_NAME,
c.SETTLE_DOMAIN_CODE,
c.SECOND_INDICATOR_BELONG,
c.SOCIAL_HOUSEHOLD,
c.SOCIAL_PAY_ADDR,
c.SOCIAL_PAY_MONTH,
c.SOCIAL_CREATE_MONTH,
c.PROVIDENT_HOUSEHOLD AS PROVIDENT_HOUSEHOLD,
c.PROVIDENT_PAY_ADDR AS PROVIDENT_PAY_ADDR,
c.SOCIAL_SUM,
c.PROVIDENT_SUM AS PROVIDENT_SUM
from (SELECT
<!--<if test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
CONCAT( a.EMP_IDCARD, '_', a.PROVIDENT_PAY_MONTH, '_', a.PROVIDENT_CREATE_MONTH) AS keyGroup,
a.PROVIDENT_PAY_MONTH as SOCIAL_PAY_MONTH,
a.PROVIDENT_CREATE_MONTH as SOCIAL_CREATE_MONTH,
</if>
<if test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''">
CONCAT( a.EMP_IDCARD, '_', a.SOCIAL_PAY_MONTH, '_', a.SOCIAL_CREATE_MONTH) AS keyGroup,
a.SOCIAL_PAY_MONTH,
a.SOCIAL_CREATE_MONTH,
</if>-->
<choose> <choose>
<when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null"> <when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
CONCAT( a.EMP_IDCARD, '_', a.PROVIDENT_PAY_MONTH, '_', a.PROVIDENT_CREATE_MONTH) AS keyGroup, CONCAT( a.EMP_IDCARD, '_', a.PROVIDENT_PAY_MONTH, '_', a.PROVIDENT_CREATE_MONTH) AS keyGroup,
...@@ -1585,12 +1559,6 @@ ...@@ -1585,12 +1559,6 @@
<where> <where>
<include refid="tPaymentInfo_export_social_where_diy"/> <include refid="tPaymentInfo_export_social_where_diy"/>
</where> </where>
<!--<if test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
GROUP BY a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH
</if>
<if test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''">
GROUP BY a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH
</if>-->
<choose> <choose>
<when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null"> <when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
GROUP BY a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH GROUP BY a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH
...@@ -1603,7 +1571,6 @@ ...@@ -1603,7 +1571,6 @@
</otherwise> </otherwise>
</choose> </choose>
) c
<if test="null != page and null != size"> <if test="null != page and null != size">
limit #{page},#{size} limit #{page},#{size}
</if> </if>
...@@ -3554,69 +3521,57 @@ ...@@ -3554,69 +3521,57 @@
</select> </select>
<select id="selectCountPaymentSearchInfoSocial" resultType="java.lang.Integer"> <select id="selectCountPaymentSearchInfoSocial" resultType="java.lang.Integer">
SELECT SELECT
count(1)
FROM (
select
1
from (
(SELECT
<!--<if test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null"> <!--<if test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
distinct a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH,a.SETTLE_DOMAIN_CODE distinct a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH,a.SETTLE_DOMAIN_CODE
</if> </if>
<if test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''"> <if test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''">
distinct a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH,a.SETTLE_DOMAIN_CODE distinct a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH,a.SETTLE_DOMAIN_CODE
</if>--> </if>-->
<choose> <choose>
<when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null"> <when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
distinct a.EMP_IDCARD,IFNULL(a.PROVIDENT_PAY_MONTH,a.SOCIAL_PAY_MONTH),IFNULL(a.PROVIDENT_CREATE_MONTH,a.SOCIAL_CREATE_MONTH) COUNT(DISTINCT CONCAT(a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH)) as 'count'
</when> </when>
<when test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''"> <when test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''">
distinct a.EMP_IDCARD,IFNULL(a.SOCIAL_PAY_MONTH,a.PROVIDENT_PAY_MONTH),IFNULL(a.SOCIAL_CREATE_MONTH,a.PROVIDENT_CREATE_MONTH) COUNT(DISTINCT CONCAT(a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH)) as 'count'
</when> </when>
<otherwise> <otherwise>
distinct a.EMP_IDCARD,IFNULL(a.SOCIAL_PAY_MONTH,a.PROVIDENT_PAY_MONTH),IFNULL(a.SOCIAL_CREATE_MONTH,a.PROVIDENT_CREATE_MONTH) COUNT(DISTINCT CONCAT(a.EMP_IDCARD,IFNULL(a.SOCIAL_PAY_MONTH,a.PROVIDENT_PAY_MONTH),IFNULL(a.SOCIAL_CREATE_MONTH,a.PROVIDENT_CREATE_MONTH))) as 'count'
</otherwise> </otherwise>
</choose> </choose>
FROM t_payment_info a FROM t_payment_info a
<where> <where>
<include refid="tPaymentInfo_export_count_where"/> <include refid="tPaymentInfo_export_count_where"/>
</where> </where>
)
) w ) c
</select> </select>
<select id="selectCountPaymentSearchInfoSocialByLimit" resultType="java.lang.Integer"> <select id="selectCountPaymentSearchInfoSocialByLimit" resultType="java.lang.Integer">
SELECT SELECT
count(1)
FROM (
select
1
from (
(SELECT
<!--<if test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null"> <!--<if test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
distinct a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH distinct a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH
</if> </if>
<if test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''"> <if test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''">
distinct a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH distinct a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH
</if>--> </if>-->
<choose> <choose>
<when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null"> <when test="tPaymentInfo.providentHousehold != null and tPaymentInfo.providentHousehold.trim() != '' and tPaymentInfo.socialHousehold == null">
distinct a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH COUNT(DISTINCT CONCAT(a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH)) as 'count'
</when> </when>
<when test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''"> <when test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''">
distinct a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH COUNT(DISTINCT CONCAT(a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH)) as 'count'
</when> </when>
<otherwise> <otherwise>
1 COUNT(DISTINCT CONCAT(a.EMP_IDCARD,IFNULL(a.SOCIAL_PAY_MONTH,a.PROVIDENT_PAY_MONTH),IFNULL(a.SOCIAL_CREATE_MONTH,a.PROVIDENT_CREATE_MONTH))) as 'count'
</otherwise> </otherwise>
</choose> </choose>
FROM t_payment_info a FROM t_payment_info a
<where> <where>
<include refid="tPaymentInfo_export_count_where"/> <include refid="tPaymentInfo_export_count_where"/>
</where> </where>
limit 20001 limit 20001
)
) w ) c
</select> </select>
<select id="selectCountPaymentSearchInfoFund" resultType="java.lang.Integer"> <select id="selectCountPaymentSearchInfoFund" resultType="java.lang.Integer">
SELECT SELECT
...@@ -3649,17 +3604,27 @@ ...@@ -3649,17 +3604,27 @@
null PROVIDENT_PAY_ADDR null PROVIDENT_PAY_ADDR
FROM t_payment_info a FROM t_payment_info a
<where> <where>
<if test="keyGroups != null and keyGroups.size() > 0"> <if test="empIdcard != null and empIdcard !=''">
CONCAT( a.EMP_IDCARD, '_', a.SOCIAL_PAY_MONTH, '_', a.SOCIAL_CREATE_MONTH ) in AND a.EMP_IDCARD = #{empIdcard}
<foreach collection="keyGroups" index="index" item="item" open="(" separator="," close=")"> </if>
#{item} <if test="empIdcard == null or empIdcard ==''">
</foreach> AND a.EMP_IDCARD is null
</if>
<if test="payMonth != null and payMonth !=''">
AND a.SOCIAL_PAY_MONTH = #{payMonth}
</if> </if>
<if test="keyGroups == null or keyGroups.size() == 0"> <if test="payMonth == null or payMonth ==''">
1=2 AND a.SOCIAL_PAY_MONTH is null
</if>
<if test="createMonth != null and createMonth !=''">
AND a.SOCIAL_CREATE_MONTH = #{createMonth}
</if>
<if test="createMonth == null or createMonth ==''">
AND a.SOCIAL_CREATE_MONTH is null
</if> </if>
</where> </where>
GROUP BY a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH GROUP BY a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH
limit 1
</select> </select>
<!--tPaymentInfo合并查询 通过keygroup获取对应数据--> <!--tPaymentInfo合并查询 通过keygroup获取对应数据-->
<select id="getSumByKeyGroupFund" resultMap="tPaymentInfoSumMap"> <select id="getSumByKeyGroupFund" resultMap="tPaymentInfoSumMap">
...@@ -3674,16 +3639,26 @@ ...@@ -3674,16 +3639,26 @@
a.PROVIDENT_PAY_ADDR a.PROVIDENT_PAY_ADDR
FROM t_payment_info a FROM t_payment_info a
<where> <where>
<if test="keyGroups != null and keyGroups.size() > 0"> <if test="empIdcard != null and empIdcard !=''">
CONCAT( a.EMP_IDCARD, '_', a.PROVIDENT_PAY_MONTH, '_', a.PROVIDENT_CREATE_MONTH ) in AND a.EMP_IDCARD = #{empIdcard}
<foreach collection="keyGroups" index="index" item="item" open="(" separator="," close=")"> </if>
#{item} <if test="empIdcard == null or empIdcard ==''">
</foreach> AND a.EMP_IDCARD is null
</if>
<if test="payMonth != null and payMonth !=''">
AND a.PROVIDENT_PAY_MONTH = #{payMonth}
</if>
<if test="payMonth == null or payMonth ==''">
AND a.PROVIDENT_PAY_MONTH is null
</if>
<if test="createMonth != null and createMonth !=''">
AND a.PROVIDENT_CREATE_MONTH = #{createMonth}
</if> </if>
<if test="keyGroups == null or keyGroups.size() == 0"> <if test="createMonth == null or createMonth ==''">
1=2 AND a.PROVIDENT_CREATE_MONTH is null
</if> </if>
</where> </where>
GROUP BY a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH GROUP BY a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH
limit 1
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment