Commit 59739efc authored by hongguangwu's avatar hongguangwu

预估库

parent 57f9fff6
......@@ -494,6 +494,12 @@ public class TForecastLibrary extends BaseEntity {
@ExcelAttribute(name = "数据同步:0未同步;1已同步")
@ExcelProperty("数据同步:0未同步;1已同步")
private Integer dataPush;
/**
* 类型:0社保;1公积金
*/
@ExcelAttribute(name = "类型:0社保;1公积金")
@ExcelProperty("类型:0社保;1公积金")
private Integer dataType;
@TableField(exist = false)
private List<String> idList;
......
......@@ -191,9 +191,13 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
@Override
public R<Boolean> createForecastlibary(String payMonths, String empIdCard, String settleDomainIds) {
//定义未推送的按条件查询得到的预估数据
List<TForecastLibrary> libraryList = null;
List<TForecastLibrary> librarySocialList = null;
//定义已推送的按条件查询得到的预估数据
List<TForecastLibrary> libraryListTemp = null;
List<TForecastLibrary> librarySocialListTemp = null;
//定义未推送的按条件查询得到的预估数据
List<TForecastLibrary> libraryFundList = null;
//定义已推送的按条件查询得到的预估数据
List<TForecastLibrary> libraryFundListTemp = null;
List<String> settleDomainIdList = Common.initStrToList(settleDomainIds, CommonConstants.COMMA_STRING);
List<String> payMonthList = Common.initStrToList(payMonths, CommonConstants.COMMA_STRING);
if (Common.isEmpty(payMonths) || payMonthList == null) {
......@@ -211,29 +215,50 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
//查询出所有对应条件的预估数、社保数据、公积金数据据用于重新生成
if (Common.isNotNull(empIdCard)) {
libraryList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
librarySocialList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
librarySocialListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.and(obj1 -> obj1.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.or()
.in(TForecastLibrary::getProvidentPayMonth, payMonthList))
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
libraryFundList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
libraryListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
libraryFundListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.and(obj1 -> obj1.in(TForecastLibrary::getSocialPayMonth, payMonthList).or().in(TForecastLibrary::getProvidentPayMonth, payMonthList))
.ne(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
socialInfoList = socialFundInfoMapper.getSocialList(empIdCard, null);
fundList = socialFundInfoMapper.getFundList(empIdCard, null);
} else {
libraryList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
librarySocialList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.and(obj1 -> obj1.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.or()
.in(TForecastLibrary::getProvidentPayMonth, payMonthList))
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
libraryListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
librarySocialListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
libraryFundList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.and(obj1 -> obj1.in(TForecastLibrary::getSocialPayMonth, payMonthList).or().in(TForecastLibrary::getProvidentPayMonth, payMonthList))
.ne(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
libraryFundListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
socialInfoList = socialFundInfoMapper.getSocialList(null, settleDomainIdList);
fundList = socialFundInfoMapper.getFundList(null, settleDomainIdList);
}
......@@ -242,38 +267,42 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
return R.failed("无需要重新生成的数据(无数据或数据已结算不可重新生成!)");
}
//先删除然后重新生成
if (Common.isNotNull(libraryList)) {
baseMapper.deleteBatchIds(libraryList);
if (Common.isNotNull(librarySocialList)) {
baseMapper.deleteBatchIds(librarySocialList);
}
if (Common.isNotNull(libraryFundList)) {
baseMapper.deleteBatchIds(libraryFundList);
}
boolean flag;
// 已推送的预估明细Map
HashMap<String, TForecastLibrary> libraryHashMapTemp = new HashMap<>();
HashMap<String, TForecastLibrary> socialPushMap = new HashMap<>();
HashMap<String, TForecastLibrary> fundPushMap = new HashMap<>();
// Map的key
StringBuilder sfMapKey;
StringBuilder initKey;
if (Common.isNotNull(libraryListTemp)) {
String sfMapKey;
if (Common.isNotNull(librarySocialListTemp)) {
TForecastLibrary libraryOld;
for (TForecastLibrary library : libraryListTemp) {
sfMapKey = new StringBuilder(library.getEmpIdcard());
// 获取key
if (Common.isNotNull(library.getSocialProvince())) {
this.getMapKey(sfMapKey, library.getSocialProvince(), library.getSocialCity(), library.getSocialTown());
} else {
this.getMapKey(sfMapKey, library.getFundProvince(), library.getFundCity(), library.getFundTown());
for (TForecastLibrary library : librarySocialListTemp) {
sfMapKey = this.getMapKey(library.getEmpIdcard(), library.getSettleDomainId(), library.getSocialPayMonth(), library.getSocialCreateMonth());
libraryOld = socialPushMap.get(sfMapKey);
if (libraryOld != null) {
this.getChangeAddData(libraryOld, library);
}
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(library.getSocialPayMonth());
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(library.getSocialCreateMonth());
libraryOld = libraryHashMapTemp.get(sfMapKey.toString());
socialPushMap.put(sfMapKey, library);
}
}
if (Common.isNotNull(libraryFundListTemp)) {
TForecastLibrary libraryOld;
for (TForecastLibrary library : libraryFundListTemp) {
sfMapKey = this.getMapKey(library.getEmpIdcard(), library.getSettleDomainId(), library.getProvidentPayMonth(), library.getProvidentCreateMonth());
libraryOld = fundPushMap.get(sfMapKey);
if (libraryOld != null) {
this.getChangeAddData(libraryOld, library);
}
libraryHashMapTemp.put(sfMapKey.toString(), library);
fundPushMap.put(sfMapKey, library);
}
}
HashMap<String, TForecastLibrary> libraryHashMap = new HashMap<>();
Map<String, TForecastLibrary> saveLibraryMap = new HashMap<>();
TForecastLibrary tForecastLibrary;
// Map的key转String
String mapKeyStr;
String createMonth;
boolean isReduceSocial = false;
boolean isReduceFund = false;
......@@ -282,21 +311,12 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
if (Common.isNotNull(socialInfoList)) {
for (TSocialFundInfo tSocialInfo : socialInfoList) {
createMonth = ServiceUtil.initCreateMonth(tSocialInfo.getCreateTime(), payMonth);
sfMapKey = new StringBuilder(tSocialInfo.getEmpIdcard());
// 获取key
this.getMapKey(sfMapKey, tSocialInfo.getSocialProvince(), tSocialInfo.getSocialCity(), tSocialInfo.getSocialTown());
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(payMonth);
// 不可调换位置
initKey = new StringBuilder();
initKey.append(sfMapKey);
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(createMonth);
mapKeyStr = sfMapKey.toString();
sfMapKey = this.getMapKey(tSocialInfo.getEmpIdcard(), tSocialInfo.getSettleDomain(), payMonth, createMonth);
// 变更:已推送的,计算变更值
tForecastLibrary = libraryHashMapTemp.get(mapKeyStr);
tForecastLibrary = socialPushMap.get(sfMapKey);
if (null != tForecastLibrary) {
this.getChangeReduceData(tSocialInfo, tForecastLibrary);
libraryHashMap.put(sfMapKey.toString(), tForecastLibrary);
}
//起缴月份在要生成的月份前不处理
if (Integer.parseInt(payMonth) < DateUtil.formatDateInt(tSocialInfo.getSocialStartDate())) {
......@@ -307,27 +327,18 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
return R.failed("员工" + tSocialInfo.getEmpName() + ":" + tSocialInfo.getEmpIdcard() + SocialConstants.SOCIAL_SET_ERROR);
}
// 初始化社保
initSocialLibary(payMonth, libraryHashMap, tSocialInfo, isReduceFund, agentConfigHashMap, initKey);
initSocialLibary(payMonth, saveLibraryMap, tSocialInfo, isReduceFund, agentConfigHashMap, tForecastLibrary, sfMapKey);
}
}
//封装公积金预估数据
if (Common.isNotNull(fundList)) {
for (TSocialFundInfo providentFund : fundList) {
createMonth = ServiceUtil.initCreateMonth(providentFund.getCreateTime(), payMonth);
sfMapKey = new StringBuilder(providentFund.getEmpIdcard());
// 获取key
this.getMapKey(sfMapKey, providentFund.getFundProvince(), providentFund.getFundCity(), providentFund.getFundTown());
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(payMonth);
// 不可调换位置
initKey = new StringBuilder();
initKey.append(sfMapKey);
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(createMonth);
mapKeyStr = sfMapKey.toString();
sfMapKey = this.getMapKey(providentFund.getEmpIdcard(), providentFund.getSettleDomain(), payMonth, createMonth);
// 变更:已推送的,计算变更值
tForecastLibrary = libraryHashMapTemp.get(mapKeyStr);
tForecastLibrary = fundPushMap.get(sfMapKey);
if (null != tForecastLibrary) {
this.getChangeReduceData(providentFund, tForecastLibrary);
libraryHashMap.put(sfMapKey.toString(), tForecastLibrary);
}
//起缴月份在要生成的月份后不处理
if (Integer.parseInt(payMonth) < DateUtil.formatDateInt(providentFund.getProvidentStart())) {
......@@ -338,12 +349,12 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
return R.failed("员工" + providentFund.getEmpName() + ":" + providentFund.getEmpIdcard() + SocialConstants.SOCIAL_SET_ERROR);
}
// 初始化公积金
initFundLibary(payMonth, libraryHashMap, providentFund, isReduceSocial, initKey);
initFundLibary(payMonth, saveLibraryMap, providentFund, isReduceSocial, tForecastLibrary, sfMapKey);
}
}
}
boolean isSaveAndUpdate = false;
for (TForecastLibrary library : libraryHashMap.values()) {
for (TForecastLibrary library : saveLibraryMap.values()) {
if (Common.isEmpty(library.getSocialId()) && Common.isEmpty(library.getProvidentId())) {
continue;
}
......@@ -362,6 +373,17 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
}
private String getMapKey(String empIdcard, String settleDomainId
, String socialPayMonth, String socialCreateMonth) {
StringBuilder sfMapKey;
sfMapKey = new StringBuilder(empIdcard);
// 获取key
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(settleDomainId);
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(socialPayMonth);
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(socialCreateMonth);
return sfMapKey.toString();
}
/**
* @param libraryOld
* @param library
......@@ -460,19 +482,19 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
}
private void initSocialLibary(String payMonth, HashMap<String, TForecastLibrary> libraryHashMap
, TSocialFundInfo tSocialInfo, boolean isReduceFund, HashMap<String, TAgentConfig> agentConfigMap, StringBuilder mapKeyStr) {
mapKeyStr.append(CommonConstants.DOWN_LINE_STRING).append(ServiceUtil.initCreateMonth(tSocialInfo.getCreateTime(), payMonth));
TForecastLibrary lib = libraryHashMap.get(mapKeyStr.toString());
private void initSocialLibary(String payMonth, Map<String, TForecastLibrary> saveLibraryMap
, TSocialFundInfo tSocialInfo, boolean isReduceFund, HashMap<String, TAgentConfig> agentConfigMap
, TForecastLibrary lib, String sfMapKey) {
if (null == lib) {
lib = new TForecastLibrary();
}
lib.setDataType(CommonConstants.ZERO_INT);
lib.setEmpId(tSocialInfo.getEmpId());
lib.setEmpIdcard(tSocialInfo.getEmpIdcard());
lib.setEmpName(tSocialInfo.getEmpName());
lib.setEmpNo(tSocialInfo.getEmpNo());
lib.setSocialCreateMonth(ServiceUtil.initCreateMonth(tSocialInfo.getCreateTime(), payMonth));
lib.setProvidentCreateMonth(lib.getSocialCreateMonth());
}
lib.setSocialPayMonth(payMonth);
//同时处理公积金日期
lib.setProvidentPayMonth(payMonth);
......@@ -493,7 +515,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
isReduceSocial = false;
}
lib = initForecastLibrary(lib, tSocialInfo, null, monthT, isReduceFund, isReduceSocial, agentConfigMap);
libraryHashMap.put(mapKeyStr.toString(), lib);
saveLibraryMap.put(sfMapKey, lib);
}
/**
......@@ -1112,26 +1134,25 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
* 初始化公积金预估信息
*
* @param payMonth
* @param libraryHashMap
* @param saveLibraryMap
* @param providentFund
* @param isReduceSocial
* @return
* @Author fxj
* @Date 2020-07-21
**/
private void initFundLibary(String payMonth, HashMap<String, TForecastLibrary> libraryHashMap
, TSocialFundInfo providentFund, boolean isReduceSocial, StringBuilder mapKeyStr) {
mapKeyStr.append(CommonConstants.DOWN_LINE_STRING).append(ServiceUtil.initCreateMonth(providentFund.getCreateTime(), payMonth));
TForecastLibrary lib = libraryHashMap.get(mapKeyStr.toString());
if (null == lib) {
private void initFundLibary(String payMonth, Map<String, TForecastLibrary> saveLibraryMap
, TSocialFundInfo providentFund, boolean isReduceSocial, TForecastLibrary lib, String mapKeyStr) {
if (lib == null) {
lib = new TForecastLibrary();
}
lib.setDataType(CommonConstants.ONE_INT);
lib.setEmpId(providentFund.getEmpId());
lib.setEmpIdcard(providentFund.getEmpIdcard());
lib.setEmpName(providentFund.getEmpName());
lib.setEmpNo(providentFund.getEmpNo());
lib.setProvidentCreateMonth(ServiceUtil.initCreateMonth(providentFund.getCreateTime(), payMonth));
lib.setSocialCreateMonth(lib.getProvidentCreateMonth());
}
//同时处理社保日期
lib.setSocialPayMonth(payMonth);
lib.setProvidentPayMonth(payMonth);
......@@ -1161,7 +1182,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
isReduceFund = false;
}
lib = initForecastLibrary(lib, null, providentFund, monthT, isReduceFund, isReduceSocial, null);
libraryHashMap.put(mapKeyStr.toString(), lib);
saveLibraryMap.put(mapKeyStr, lib);
}
}
......@@ -94,6 +94,7 @@
<result property="providentHouseholdName" column="PROVIDENT_HOUSEHOLD_NAME"/>
<result property="providentNo" column="PROVIDENT_NO"/>
<result property="dataPush" column="DATA_PUSH"/>
<result property="dataType" column="DATA_TYPE"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
......@@ -101,10 +102,7 @@
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a
.
ID
,
a.ID,
a.EMP_ID,
a.EMP_NO,
a.EMP_NAME,
......@@ -174,6 +172,7 @@
a.PROVIDENT_HOUSEHOLD_NAME,
a.PROVIDENT_NO,
a.DATA_PUSH,
a.DATA_TYPE,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
......@@ -398,6 +397,9 @@
<if test="tForecastLibrary.dataPush != null">
AND a.DATA_PUSH = #{tForecastLibrary.dataPush}
</if>
<if test="tForecastLibrary.dataType != null">
AND a.DATA_TYPE = #{tForecastLibrary.dataType}
</if>
<if test="tForecastLibrary.createBy != null and tForecastLibrary.createBy.trim() != ''">
AND a.CREATE_BY = #{tForecastLibrary.createBy}
</if>
......
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