|
|
@@ -37,6 +37,7 @@ public class AnnualIncomeCalculateService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 已确认的数据不做调整,未确认的数据更新
|
|
|
* 计算步骤:
|
|
|
* 1.根据参保单位获取到人员
|
|
|
* 2.根据1获取到的人员去取薪酬模块-年收入统计中的薪酬数据
|
|
|
@@ -49,6 +50,9 @@ public class AnnualIncomeCalculateService {
|
|
|
Map<Long, DynamicObject> fileMap = getSinSurFile();
|
|
|
// 根据参保单位获取人员
|
|
|
Set<Long> employeeIds = fileMap.keySet();
|
|
|
+ // 根据参保单位+年度获取到现在已经生成数据的人员,用于排除
|
|
|
+ Set<Long> excludeEmployee = getExcludeEmployee();
|
|
|
+ employeeIds.removeAll(excludeEmployee);
|
|
|
// 取薪酬-年收入统计单中的数据
|
|
|
Map<Long, Map> incomeBillData = getSalIncomeBillData(employeeIds);
|
|
|
// 业务项目
|
|
|
@@ -63,6 +67,41 @@ public class AnnualIncomeCalculateService {
|
|
|
return successCount;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据参保单位+年度获取已确认的年收入证明单数据
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Set<Long> getExcludeEmployee() {
|
|
|
+ QFilter filter = new QFilter("nckd_year", QCP.equals, year);
|
|
|
+ filter.and("nckd_welfarepayer", QCP.equals, welfarePayer.getLong("id"));
|
|
|
+ filter.and("billstatus", QCP.in, new String[]{"C", "H"});
|
|
|
+ String selectFields = "nckd_employee.id";
|
|
|
+ DynamicObjectCollection cols = SitConstant.SITINCOMEBILL_HELPER.queryOriginalCollection(selectFields, new QFilter[]{filter});
|
|
|
+ return cols.stream().map(dyx -> dyx.getLong("nckd_employee.id")).collect(Collectors.toSet());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据参保单位+年度获取需要更新的单据数据
|
|
|
+ * k = employee.id , v = 单据数据包
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<Long, DynamicObject> getExistBillInfos() {
|
|
|
+ QFilter filter = new QFilter("nckd_year", QCP.equals, year);
|
|
|
+ filter.and("nckd_welfarepayer", QCP.equals, welfarePayer.getLong("id"));
|
|
|
+ filter.and("billstatus", QCP.in, new String[]{"A", "B"});
|
|
|
+ String selectFields = "billstatus,auditstatus,nckd_year,nckd_employee,nckd_datastatus,nckd_welfarepayer,nckd_sinsurfile,org,billno,nckd_sysmonth,nckd_sysyearamount,nckd_outmonth,nckd_outyearamount,nckd_totalamount";
|
|
|
+ DynamicObject[] cols = SitConstant.SITINCOMEBILL_HELPER.load(selectFields, new QFilter[]{filter});
|
|
|
+ return Arrays.stream(cols).collect(Collectors.toMap((dyx) -> {
|
|
|
+ return dyx.getLong("nckd_employee.id");
|
|
|
+ }, (dyx) -> {
|
|
|
+ return dyx;
|
|
|
+ }, (key1, key2) -> {
|
|
|
+ return key2;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更新年收入统计单状态
|
|
|
* @param employeeIds
|
|
|
@@ -93,19 +132,32 @@ public class AnnualIncomeCalculateService {
|
|
|
* @return
|
|
|
*/
|
|
|
public int dealData(Map<Long, DynamicObject> fileMap, Set<Long> employeeIds, Map<Long, Map> incomeBillData, Map<Long, DynamicObject> bizItemMap, Map<Long, Map<Long, String>> bizData) {
|
|
|
- DynamicObjectCollection billCols = new DynamicObjectCollection();
|
|
|
+ //DynamicObjectCollection billCols = new DynamicObjectCollection();
|
|
|
+ List<DynamicObject> addnewCols = new ArrayList<>();
|
|
|
+ List<DynamicObject> updateCols = new ArrayList<>();
|
|
|
+ Map<Long, DynamicObject> existBillInfosMap = getExistBillInfos();
|
|
|
+ Set<Long> existEmployeeIds = existBillInfosMap.keySet();
|
|
|
for(Long employeeId : employeeIds) {
|
|
|
- DynamicObject dyn = SitConstant.SITINCOMEBILL_HELPER.generateEmptyDynamicObject();
|
|
|
+ DynamicObject dyn;
|
|
|
+ boolean exists = false;
|
|
|
+ if(existEmployeeIds.contains(employeeId)) {
|
|
|
+ exists = true;
|
|
|
+ dyn = existBillInfosMap.get(employeeId);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ exists = false;
|
|
|
+ dyn = SitConstant.SITINCOMEBILL_HELPER.generateEmptyDynamicObject();
|
|
|
+ dyn.set("billstatus", "A");
|
|
|
+ dyn.set("auditstatus", "A");
|
|
|
+ dyn.set("nckd_datastatus", "A");
|
|
|
+ dyn.set("billno", UUID.randomUUID().toString().substring(0,29));
|
|
|
+ }
|
|
|
// 默认值字段
|
|
|
- dyn.set("billstatus", "A");
|
|
|
- dyn.set("auditstatus", "A");
|
|
|
dyn.set("nckd_year", year);
|
|
|
dyn.set("nckd_employee", employeeId);
|
|
|
- dyn.set("nckd_datastatus", "A");
|
|
|
dyn.set("nckd_welfarepayer", welfarePayer);
|
|
|
dyn.set("nckd_sinsurfile", fileMap.get(employeeId).getLong("id"));
|
|
|
dyn.set("org", fileMap.get(employeeId).getLong("org.id"));
|
|
|
- dyn.set("billno", UUID.randomUUID().toString().substring(0,29));
|
|
|
|
|
|
BigDecimal amount1 = BigDecimal.ZERO;
|
|
|
BigDecimal amount2 = BigDecimal.ZERO;
|
|
|
@@ -140,11 +192,24 @@ public class AnnualIncomeCalculateService {
|
|
|
// 申报年度社保缴费基数 = (江铜内年度收入 + 江铜外年度收入) / (江铜内发放月数 + 外单位发放月数)
|
|
|
BigDecimal totalAmount = calculateTotalAmount(amount1, amount2, month1, month2);
|
|
|
dyn.set("nckd_totalamount", totalAmount);
|
|
|
- billCols.add(dyn);
|
|
|
+ if(exists) {
|
|
|
+ updateCols.add(dyn);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ addnewCols.add(dyn);
|
|
|
+ }
|
|
|
}
|
|
|
// 保存数据
|
|
|
- Object[] saveDyns = SaveServiceHelper.save(billCols.stream().toArray(DynamicObject[]::new));
|
|
|
- int successCount = saveDyns.length;
|
|
|
+ int successCount = 0;
|
|
|
+ if(addnewCols.size() > 0) {
|
|
|
+ Object[] addnewDyns = SaveServiceHelper.save(addnewCols.stream().toArray(DynamicObject[]::new));
|
|
|
+ successCount += addnewDyns.length;
|
|
|
+ }
|
|
|
+ // 更新数据
|
|
|
+ if(updateCols.size() > 0) {
|
|
|
+ Object[] updateDyns = SaveServiceHelper.save(updateCols.stream().toArray(DynamicObject[]::new));
|
|
|
+ successCount += updateDyns.length;
|
|
|
+ }
|
|
|
return successCount;
|
|
|
}
|
|
|
|