Преглед изворни кода

Merge remote-tracking branch 'origin/master'

turborao пре 2 дана
родитељ
комит
f2d67cd9c9

+ 74 - 9
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/business/annualincome/AnnualIncomeCalculateService.java

@@ -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;
     }
 

+ 4 - 1
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/utils/SITCoordinationUtils.java

@@ -186,7 +186,9 @@ public class SITCoordinationUtils {
 
     /**
      * 根据员工获取所有参保中的险种基数
-     *
+     * 社保基数.开始日期 <= 当前日期 <= 社保基数.结束日期
+     * 社保基数.是否参保 = 是
+     * 社保基数.社保档案.社保状态 = 正常缴纳
      * @param employeeId
      * @return
      */
@@ -195,6 +197,7 @@ public class SITCoordinationUtils {
         filter.and("insured", QCP.equals, true);
         filter.and("startdate", QCP.less_equals, new Date());
         filter.and("enddate", QCP.large_equals, new Date());
+        filter.and("sinsurfile.sinsurstatus", QCP.equals, "normal");
         String selectFields = "startdate,enddate,insured,welfaretype,paybaseofemployee,paybaseofcompany,nckd_sinsurdimension,welfarepayer,nckd_welfarepayertheory,description";
         DynamicObject[] sibaseCols = SitConstant.SIBASE_HELPER.load(selectFields, filter.toArray());
         return sibaseCols;

+ 7 - 1
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/hsas/business/outdata/OutImportTaskGuideImportService.java

@@ -184,7 +184,7 @@ public class OutImportTaskGuideImportService {
             successCount = 0;
             failCount = dataRowList.size();
             errDataList.clear();
-            // TODO this.setErrorData(dataRowList.size(), lineIndexVer, errDataList, e.getMessage());
+            this.setErrorData(dataRowList.size(), lineIndexVer, errDataList, e.getMessage());
             return;
         } finally {
             allErrDataList.addAll(errDataList);
@@ -283,6 +283,12 @@ public class OutImportTaskGuideImportService {
         return value;
     }
 
+    private void setErrorData(int size, int lineIndexVer, List<Map<String, String>> errDataList, String errorMsg) {
+        for(int i = 0; i < size; ++i) {
+            errDataList.add(this.assembleErrMap(lineIndexVer, false, errorMsg));
+            ++lineIndexVer;
+        }
+    }
 
     private boolean checkFieldRequriedForCommon(Map<Integer, List<Map<String, String>>> commonColumnIndexMap, Map<Integer, String> rowMap, List<Map<String, String>> errDataList, int lineIndex, Map<Integer, Object> passRowMap) {
         String msg = ResManager.loadKDString("请填写“{0}”。", "ImportTaskGuideImportService_2", "swc-hsas-business", new Object[0]);

+ 22 - 1
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/hsas/formplugin/web/outdata/bill/OutTempDataListPlugin.java

@@ -94,8 +94,9 @@ public class OutTempDataListPlugin extends AbstractListPlugin implements Plugin
     public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
         super.closedCallBack(closedCallBackEvent);
         String actionId = closedCallBackEvent.getActionId();
+        Map returnData;
         if ("importData".equals(actionId)) {
-            Map<String, Object> returnData = (Map)closedCallBackEvent.getReturnData();
+            returnData = (Map)closedCallBackEvent.getReturnData();
             if (returnData == null) {
                 return;
             }
@@ -107,6 +108,14 @@ public class OutTempDataListPlugin extends AbstractListPlugin implements Plugin
                 this.openProgressPage(totalCount, importTaskId, "22", "importingData", caption, cacheKey);
             }
         }
+        else if ("importingData".equals(actionId)) {
+            returnData = (Map)closedCallBackEvent.getReturnData();
+            if (returnData != null && !returnData.isEmpty()) {
+                this.openImportingView(returnData);
+            } else {
+                this.getView().invokeOperation("refresh");
+            }
+        }
         else {
             this.getView().invokeOperation("refresh");
         }
@@ -126,4 +135,16 @@ public class OutTempDataListPlugin extends AbstractListPlugin implements Plugin
         this.getView().showForm(formShowParameter);
     }
 
+    private void openImportingView(Map<String, Object> dataMap) {
+        FormShowParameter formShowParameter = new FormShowParameter();
+        formShowParameter.setFormId("hsas_taskguideimportret");
+        formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
+        formShowParameter.setCustomParam("importTaskId", dataMap.get("importTaskId"));
+        formShowParameter.setCustomParam("successCout", dataMap.get("successCout"));
+        formShowParameter.setCustomParam("failCout", dataMap.get("failCout"));
+        formShowParameter.setCustomParam("cacheKey", dataMap.get("cacheKey"));
+        formShowParameter.setCloseCallBack(new CloseCallBack(this, "importErrorData"));
+        this.getView().showForm(formShowParameter);
+    }
+
 }