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

优化同步会修改其他纳税单位问题

“luojun” пре 1 година
родитељ
комит
627c755013

+ 77 - 6
websrc/com/kingdee/eas/custom/individualback/TaxPersonRecordListHandlerExEx.java

@@ -37,6 +37,8 @@ import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 
+import static org.hsqldb.types.IntervalSecondData.oneDay;
+
 /**
  * @author qingwu
  * @date 2024/9/4
@@ -125,20 +127,25 @@ public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandlerEx
         //上个月数据
         //TaxPersonRecordEntryCollection taxPersonRecordEntryCollUp = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.* where  taxUnit = '" + taxUnitId + "' and lastReportMonth = '" + previousMonth + "' ");
         //人员报税信息数据
-        TaxPersonRecordEntryCollection taxPersonRecordEntryCollDn = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.*  where  taxUnit = '" + taxUnitId + "' ");
+        //TaxPersonRecordEntryCollection taxPersonRecordEntryCollDn = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.*  where  taxUnit = '" + taxUnitId + "' and  personStatus = '1' ");
+        TaxPersonRecordEntryCollection taxPersonRecordEntryCollDn = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.*  where personStatus = '1' ");
         //保存上个月的核算人员
         //List<String> listUp = new ArrayList<>();
         //for (int i = 0; i < personIds.size(); i++) {
         //    listUp.add(personIds.get(i));
         //}
+        //保存人员纳税信息纳税单位
+        Map<String, String> taxUnitMap = new HashMap();
         //保存当前月的核算人员
         List<String> list = new ArrayList<>();
         for (int i = 0; i < taxPersonRecordEntryCollDn.size(); i++) {
             String personId = taxPersonRecordEntryCollDn.get(i).getPerson().getId().toString();
+            String taxPersonTaxUnitId = taxPersonRecordEntryCollDn.get(i).getTaxUnit().getId().toString();
             TaxPersonRecordCollection taxPersonRecordCollection = iTaxPersonRecord.getTaxPersonRecordCollection("where person = '" + personId + "'");
             if (taxPersonRecordCollection.size() > 0) {
                 logger.error("comparison--personId--------------" + personId);
                 list.add(personId);
+                taxUnitMap.put(personId, taxPersonTaxUnitId);
             }
         }
         //人员报税
@@ -164,6 +171,13 @@ public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandlerEx
         updateSic.add("personStatus");
         updateSic.add("departureDate");
 
+        //获取当前月的最后一天转成Date类型
+        Date departureDate = Date.from(date.withDayOfMonth(date.lengthOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
+        //获取年月第一天
+        LocalDate currentDate = LocalDate.of(periodYear, periodMonth, 1);
+        Date oneDay = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+        logger.error("comparison--currentDate--------------" + currentDate);
+        logger.error("comparison--oneDay--------------" + oneDay);
         if (pseronIdsUp.size() > 0) {
             //获取任职受雇从业信息   修改人员纳税信息的 人员状态为非正常  离职日期为当前月最后一天
             TaxPersonRecordEntryCollection taxPersonRecordEntryCollUp2 = getTaxPersonRecordEntryColl(pseronIdsUp, iTaxPersonRecordEntry);
@@ -172,8 +186,6 @@ public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandlerEx
                     TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxPersonRecordEntryCollUp2.get(i);
                     //人员状态
                     taxPersonRecordEntryInfo.setPersonStatus(PersonStatusEnum.NotNormal);
-                    //获取当前月的最后一天转成Date类型
-                    Date departureDate = Date.from(date.withDayOfMonth(date.lengthOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
                     //离职日期为当前月最后一天
                     taxPersonRecordEntryInfo.setDepartureDate(departureDate);
                     iTaxPersonRecordEntry.updatePartial(taxPersonRecordEntryInfo, updateSic);
@@ -181,12 +193,64 @@ public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandlerEx
             }
         }
         if (pseronIds.size() > 0) {
-            //获取年月第一天
-            LocalDate currentDate = LocalDate.of(periodYear, periodMonth, 1);
-            Date oneDay = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
             //保存人员纳税信息
             addTaxPersonRecord(pseronIds, oneDay, taxUnitId, yearMonth);
         }
+
+        //对比人员纳税单位是否一致 获取薪酬核算和人员纳税信息相同人员
+        Set<String> sameData = new HashSet<>();
+        for (String item : setUp) {
+            if (set.contains(item)) {
+                sameData.add(item);
+            }
+        }
+        //判断同步的纳税单位是否与人员纳税信息的纳税单位一致
+        for (String personId : sameData) {
+            String taxPersonTaxUnitId = taxUnitMap.get(personId);
+            //不一致 需要更新任职受雇从业信息 把之前的改为非正常
+            if (!taxPersonTaxUnitId.equals(taxUnitId)) {
+                //departureDate 离职日期 获取离职日期为空的那个条数据
+                //TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.*  where departureDate is null ").get(0);
+                TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.*  where personStatus = '1' and  taxUnit = '" + taxPersonTaxUnitId + "'").get(0);
+                logger.error("taxPersonRecordEntryInfo------" + taxPersonRecordEntryInfo);
+                //人员状态
+                taxPersonRecordEntryInfo.setPersonStatus(PersonStatusEnum.NotNormal);
+                //离职日期为当前月最后一天   LocalDate.of(periodYear, periodMonth, 1)
+                LocalDate dateTime = LocalDate.of(periodYear, periodMonth - 1, 1);
+                taxPersonRecordEntryInfo.setDepartureDate(Date.from(dateTime.withDayOfMonth(dateTime.lengthOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant()));
+                iTaxPersonRecordEntry.updatePartial(taxPersonRecordEntryInfo, updateSic);
+
+
+                //新增一条新的数据
+                TaxPersonRecordEntryInfo taxPersonRecordEntryInfoNew = new TaxPersonRecordEntryInfo();
+                taxPersonRecordEntryInfoNew.setPerson(taxPersonRecordEntryInfo.getPerson());
+                TaxPersonRecordInfo taxPersonRecordInfo = iTaxPersonRecord.getTaxPersonRecordCollection("where person = '" + personId + "'").get(0);
+                logger.error("taxPersonRecordInfo--------" + taxPersonRecordInfo);
+
+                taxPersonRecordEntryInfoNew.setBill(taxPersonRecordInfo);
+                //获取纳税单位
+                ITaxUnit iTaxUnit = TaxUnitFactory.getLocalInstance(ctx);
+                TaxUnitInfo taxUnitInfo = iTaxUnit.getTaxUnitInfo("where id = '" + taxUnitId + "'");
+                logger.error("taxUnitInfo--------" + taxUnitInfo);
+                taxPersonRecordEntryInfoNew.setTaxUnit(taxUnitInfo);
+                //人员状态
+                taxPersonRecordEntryInfoNew.setPersonStatus(PersonStatusEnum.Normal);
+                //获取当前月的最后一天转成Date类型 //任职受雇从业日期为当前月第一天
+                taxPersonRecordEntryInfoNew.setEmployedDate(oneDay);
+                taxPersonRecordEntryInfoNew.setPayerType(taxPersonRecordEntryInfo.getPayerType());
+                //报送状态
+                taxPersonRecordEntryInfoNew.setSubmitStatus(SubmitStatusEnum.NotSubmit);
+                taxPersonRecordEntryInfoNew.setLastReportMonth(yearMonth);
+                //任职受雇从业类型  默认雇员
+                taxPersonRecordEntryInfoNew.setEmployedType(EmployedTypeEnum.Employee);
+                //是否扣除减除费用 默认是
+                taxPersonRecordEntryInfoNew.setDeductFees(DeductFeesEnum.Deduct);
+                IObjectPK saveEntry = iTaxPersonRecordEntry.save(taxPersonRecordEntryInfoNew);
+                logger.error("saveEntry--------分录新增返回ID" + saveEntry);
+            }
+        }
+
+
     }
 
     /**
@@ -223,6 +287,7 @@ public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandlerEx
 
         SelectorItemCollection sic = new SelectorItemCollection();
         sic.add("*");
+        sic.add("person.*");
         FilterInfo filterInfo = new FilterInfo();
         filterInfo.getFilterItems().add(new FilterItemInfo("id", pseronIds, CompareType.INCLUDE));
         EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
@@ -237,6 +302,8 @@ public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandlerEx
                     TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = new TaxPersonRecordEntryInfo();
                     //人员
                     taxPersonRecordInfo.setPerson(personInfo);
+                    //报税姓名
+                    taxPersonRecordInfo.setReportName("测试" + personInfo.getName());
                     //证件类型
                     if (personInfo.getIdCardNO() != null || personInfo.getPassportNO() != null) {
                         if (null == personInfo.getIdCardNO()) {
@@ -283,6 +350,10 @@ public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandlerEx
                         //报送状态
                         taxPersonRecordEntryInfo.setSubmitStatus(SubmitStatusEnum.NotSubmit);
                         taxPersonRecordEntryInfo.setLastReportMonth(yearMonth);
+                        //任职受雇从业类型  默认雇员
+                        taxPersonRecordEntryInfo.setEmployedType(EmployedTypeEnum.Employee);
+                        //是否扣除减除费用 默认是
+                        taxPersonRecordEntryInfo.setDeductFees(DeductFeesEnum.Deduct);
                         IObjectPK saveEntry = iTaxPersonRecordEntry.save(taxPersonRecordEntryInfo);
                         logger.error("saveEntry--------分录新增返回ID" + saveEntry);
                     }