Bläddra i källkod

fix:社保人员确认,公积金人员确认,删除状态

ly 1 år sedan
förälder
incheckning
2eb71a9ac7

+ 13 - 21
src/main/java/cn/ezhizao/project/business/housingFund/controller/BizHousingFundConfirmController.java

@@ -242,30 +242,22 @@ public class BizHousingFundConfirmController extends BaseController {
         List<BizHousingFundConfirmDetailEmployee> employees = detail.getDetails().stream().filter(v ->  v.getChangeStatus()==null||v.getChangeStatus() != 2).collect(Collectors.toList());;
         BizHousingFundConfirmDetail old = housingFundConfirmDetailService.query()
                 .eq("housing_fund_confirm_id", detail.getHousingFundConfirmId()).lt("concat(year,month)", detail.getYear() + detail.getMonth()).orderByDesc("concat(year, month)").last("limit 1").one();
+        List<BizHousingFundConfirmDetailEmployee> oldEmployees;
         if (old != null) {
-            List<BizHousingFundConfirmDetailEmployee> oldEmployees = housingFundConfirmDetailEmployeeService.query()
+            oldEmployees = housingFundConfirmDetailEmployeeService.query()
                     .eq("housing_fund_confirm_detail_id", old.getId()).ne("change_status", 2).list();
-            employees.forEach(l -> {
-                // 判断是新增还是不变
-                if (oldEmployees.stream().anyMatch(v -> v.getPhone().equals(l.getPhone()) && v.getEmployeeName().equals(l.getEmployeeName()))) {
-                    l.setChangeStatus(0);
-                }
-                if (oldEmployees.stream().noneMatch(v -> v.getPhone().equals(l.getPhone()) && v.getEmployeeName().equals(l.getEmployeeName()))) {
-                    l.setChangeStatus(1);
+        } else {
+            oldEmployees = new ArrayList<>();
+        }
+
+        for (BizHousingFundConfirmDetailEmployee employee : detail.getDetails()) {
+            if (oldEmployees.stream().noneMatch(v -> v.getPhone().equals(employee.getPhone()) && v.getEmployeeName().equals(employee.getEmployeeName()))) {
+                if (employee.getChangeStatus() == 2) {
+                    employee.setDeleted(1);
+                } else {
+                    employee.setChangeStatus(1);
                 }
-            });
-            oldEmployees.stream().filter(v -> employees.stream().noneMatch(l -> v.getPhone().equals(l.getPhone()) && v.getEmployeeName().equals(l.getEmployeeName()))).forEach(l -> {
-                BizHousingFundConfirmDetailEmployee item = new BizHousingFundConfirmDetailEmployee();
-                item.setChangeStatus(2);
-                item.setCompanyId(detail.getCompanyId());
-                item.setPhone(l.getPhone());
-                item.setEmployeeName(l.getEmployeeName());
-                item.setCardinalNumber(l.getCardinalNumber());
-                item.setIdCardImage(l.getIdCardImage());
-                item.setIdCardImageBack(l.getIdCardImageBack());
-                item.setRatio(l.getRatio());
-                employees.add(item);
-            });
+            }
         }
         return toAjax(housingFundConfirmDetailService.updateById(detail) && addRecord(detail.getHousingFundConfirmId(), detail.getYear(), detail.getMonth(), SecurityUtils.getUserId(), "修改公积金人员信息"));
     }

+ 26 - 0
src/main/java/cn/ezhizao/project/business/socialSecurity/controller/SocialSecurityConfirmController.java

@@ -346,6 +346,32 @@ public class SocialSecurityConfirmController extends BaseController {
     @PostMapping("/updateDetail")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult updateDetail(@RequestBody BizSocialSecurityConfirmDetail detail) {
+
+        BizSocialSecurityConfirmDetail oldDetail = socialSecurityConfirmDetailService.query()
+                .eq("social_security_confirm_id", detail.getSocialSecurityConfirmId())
+                .lt("concat(year,month)", detail.getYear() + detail.getMonth())
+                .orderByDesc("concat(year, month)")
+                .last("limit 1").one();
+
+        List<BizSocialSecurityConfirmDetailEmployee> employees;
+        if (oldDetail != null) {
+            employees = socialSecurityConfirmDetailEmployeeService.query()
+                    .eq("social_security_confirm_detail_id", oldDetail.getId())
+                    .ne("change_status",2)
+                    .list();
+        } else {
+            employees = new ArrayList<>();
+        }
+
+        for (BizSocialSecurityConfirmDetailEmployee employee : detail.getDetails()) {
+            if (employee.getChangeStatus() == 2) {
+                Boolean deleted = employees.stream()
+                        .noneMatch(e -> e.getEmployeeName().equals(employee.getEmployeeName())
+                                && e.getPhone().equals(employee.getPhone()));
+                employee.setDeleted(deleted ? 1 : 0);
+            }
+        }
+
         BizCompany company = companyService.getById(detail.getCompanyId());
 //        if (company.getIsFirstSocialSecurity() == 0) {
         company.setGovernmentAccountNo(detail.getGovernmentAccountNo());

+ 1 - 1
src/main/resources/mybatis/business/BizHousingFundConfirmDetailMapper.xml

@@ -16,7 +16,7 @@
     <select id="getEmployees" resultMap="EmployeeResult">
         select *
         from biz_housing_fund_confirm_detail_employee
-        where housing_fund_confirm_detail_id = #{id}
+        where housing_fund_confirm_detail_id = #{id} and deleted = 0
     </select>
     <!--带条件的List查询-->
     <select id="getList" resultMap="BaseResultMap">

+ 1 - 1
src/main/resources/mybatis/business/BizSocialSecurityConfirmDetailMapper.xml

@@ -19,7 +19,7 @@
     <select id="getEmployees" resultMap="EmployeeResult">
         select *
         from biz_social_security_confirm_detail_employee
-        where social_security_confirm_detail_id = #{id}
+        where social_security_confirm_detail_id = #{id} and deleted = 0
     </select>
     <!--带条件的List查询-->
     <select id="getList" resultMap="BaseResultMap">