Commit 69d28df1 authored by fangxinjiang's avatar fangxinjiang

实缴查询优化-fxj

parent 79e2e312
......@@ -403,12 +403,12 @@ public interface TPaymentInfoMapper extends BaseMapper<TPaymentInfo> {
* 实缴查询社保合计查询
* @return
*/
List<TPaymentInfoExportVo> getSumByKeyGroupSocial(@Param("keyGroups") List<String> keyGroups);
TPaymentInfoExportVo getSumByKeyGroupSocial(@Param("empIdcard") String empIdcard,@Param("payMonth") String payMonth,@Param("createMonth") String createMonth);
/**
* 实缴查询公积金合计查询
* @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
*/
@Override
public IPage<TPaymentInfoNewVo> getTPaymentInfoNewPage(Page<TPaymentInfo> page, TPaymentInfoSearchVo tPaymentInfo) {
//如果是含身份证查询直接查询走索引,无需走特殊处理逻辑,身份证查询量不会大
if (Common.isNotNull(tPaymentInfo.getEmpIdcard())){
return baseMapper.getTPaymentInfoNewPage(page, tPaymentInfo);
}
Page<TPaymentInfoNewVo> pageNew = new Page<>();
pageNew.setSize(page.getSize());
pageNew.setCurrent(page.getCurrent());
......@@ -218,18 +222,32 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
pageData = baseMapper.getTPaymentInfoNewPageSocial(searchVo, (pageNew.getCurrent() - 1) * pageNew.getSize(), pageNew.getSize());
//封装对应的社保及公积金的合计数据处理
if (Common.isNotNull(pageData)){
List<String> keyGroup = new ArrayList<>();
HashMap<String,TPaymentInfoNewVo> newVoHashMap = new HashMap<>();
String key;
TPaymentInfoExportVo newVo;
for (TPaymentInfoNewVo vo:pageData){
key = vo.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ vo.getSocialPayMonth()+ CommonConstants.DOWN_LINE_STRING
+ 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);
}
List<TPaymentInfoExportVo> pageDataSumSocial = baseMapper.getSumByKeyGroupSocial(keyGroup);
List<TPaymentInfoNewVo> pageDataHandle = new ArrayList<>();
/*
List<TPaymentInfoExportVo> pageDataSumSocial = baseMapper.getSumByKeyGroupSocial(keyGroup);
if (Common.isNotNull(pageDataSumSocial)){
TPaymentInfoNewVo newVo;
for (TPaymentInfoExportVo exportVo:pageDataSumSocial){
......@@ -257,7 +275,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
newVoHashMap.put(exportVo.getKeyGroup(),newVo);
}
}
}*/
if (Common.isNotNull(newVoHashMap)){
for (TPaymentInfoNewVo k:newVoHashMap.values()){
pageDataHandle.add(k);
......
......@@ -1524,32 +1524,6 @@
<!--tPaymentInfo简单分页查询 fxj 2024-08-08 调整-->
<select id="getTPaymentInfoNewPageSocial" resultMap="tPaymentInfoNewMap">
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>
<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,
......@@ -1585,12 +1559,6 @@
<where>
<include refid="tPaymentInfo_export_social_where_diy"/>
</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>
<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
......@@ -1603,7 +1571,6 @@
</otherwise>
</choose>
) c
<if test="null != page and null != size">
limit #{page},#{size}
</if>
......@@ -3554,69 +3521,57 @@
</select>
<select id="selectCountPaymentSearchInfoSocial" resultType="java.lang.Integer">
SELECT
count(1)
FROM (
select
1
from (
(SELECT
<!--<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
</if>
<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
</if>-->
<choose>
<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 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>
<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>
</choose>
FROM t_payment_info a
<where>
<include refid="tPaymentInfo_export_count_where"/>
</where>
)
) w ) c
</select>
<select id="selectCountPaymentSearchInfoSocialByLimit" resultType="java.lang.Integer">
SELECT
count(1)
FROM (
select
1
from (
(SELECT
<!--<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
</if>
<if test="tPaymentInfo.socialHousehold != null and tPaymentInfo.socialHousehold.trim() != ''">
distinct a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH
</if>-->
<choose>
<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 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>
<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>
</choose>
FROM t_payment_info a
<where>
<include refid="tPaymentInfo_export_count_where"/>
</where>
limit 20001
)
) w ) c
</select>
<select id="selectCountPaymentSearchInfoFund" resultType="java.lang.Integer">
SELECT
......@@ -3649,17 +3604,27 @@
null PROVIDENT_PAY_ADDR
FROM t_payment_info a
<where>
<if test="keyGroups != null and keyGroups.size() > 0">
CONCAT( a.EMP_IDCARD, '_', a.SOCIAL_PAY_MONTH, '_', a.SOCIAL_CREATE_MONTH ) in
<foreach collection="keyGroups" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="empIdcard != null and empIdcard !=''">
AND a.EMP_IDCARD = #{empIdcard}
</if>
<if test="empIdcard == null or empIdcard ==''">
AND a.EMP_IDCARD is null
</if>
<if test="payMonth != null and payMonth !=''">
AND a.SOCIAL_PAY_MONTH = #{payMonth}
</if>
<if test="keyGroups == null or keyGroups.size() == 0">
1=2
<if test="payMonth == null or payMonth ==''">
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>
</where>
GROUP BY a.EMP_IDCARD,a.SOCIAL_PAY_MONTH,a.SOCIAL_CREATE_MONTH
limit 1
</select>
<!--tPaymentInfo合并查询 通过keygroup获取对应数据-->
<select id="getSumByKeyGroupFund" resultMap="tPaymentInfoSumMap">
......@@ -3674,16 +3639,26 @@
a.PROVIDENT_PAY_ADDR
FROM t_payment_info a
<where>
<if test="keyGroups != null and keyGroups.size() > 0">
CONCAT( a.EMP_IDCARD, '_', a.PROVIDENT_PAY_MONTH, '_', a.PROVIDENT_CREATE_MONTH ) in
<foreach collection="keyGroups" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="empIdcard != null and empIdcard !=''">
AND a.EMP_IDCARD = #{empIdcard}
</if>
<if test="empIdcard == null or empIdcard ==''">
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 test="keyGroups == null or keyGroups.size() == 0">
1=2
<if test="createMonth == null or createMonth ==''">
AND a.PROVIDENT_CREATE_MONTH is null
</if>
</where>
GROUP BY a.EMP_IDCARD,a.PROVIDENT_PAY_MONTH,a.PROVIDENT_CREATE_MONTH
limit 1
</select>
</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