Selaa lähdekoodia

人员纳税信息同步 -- 个税反算

“luojun” 1 vuosi sitten
vanhempi
commit
ece8b71c04

+ 1054 - 0
websrc/com/kingdee/eas/custom/compensation/handler/CmpCalDynamicListHandlerExExEx.java

@@ -0,0 +1,1054 @@
+package com.kingdee.eas.custom.compensation.handler;
+
+import cn.com.servyou.dto.ApiResponse;
+import cn.com.servyou.dto.AsyncResult;
+import cn.com.servyou.dto.tax.*;
+import cn.com.servyou.rmi.client.ClientProxyFactory;
+import cn.com.servyou.service.TaxRequest;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.IObjectPK;
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.metadata.entity.EntityViewInfo;
+import com.kingdee.bos.metadata.entity.FilterInfo;
+import com.kingdee.bos.metadata.entity.FilterItemInfo;
+import com.kingdee.bos.metadata.entity.SelectorItemCollection;
+import com.kingdee.bos.metadata.query.util.CompareType;
+import com.kingdee.eas.basedata.hraux.NationalityInfo;
+import com.kingdee.eas.basedata.person.IPerson;
+import com.kingdee.eas.basedata.person.PersonFactory;
+import com.kingdee.eas.basedata.person.PersonInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.compensation.vo.TaxUnitAndPerson;
+import com.kingdee.eas.custom.individualback.ITaxPaymentBackCalculate;
+import com.kingdee.eas.custom.individualback.TaxPaymentBackCalculateCollection;
+import com.kingdee.eas.custom.individualback.TaxPaymentBackCalculateFactory;
+import com.kingdee.eas.custom.individualback.TaxPaymentBackCalculateInfo;
+import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoFactory;
+import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoInfo;
+import com.kingdee.eas.custom.shuiyou.six.osf.vo.SixTConfirmInfo;
+import com.kingdee.eas.custom.shuiyou.task.TaskCatalogEnum;
+import com.kingdee.eas.custom.shuiyou.uitls.ISYUtilsFacade;
+import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacadeFactory;
+import com.kingdee.eas.custom.shuiyou.utils.ClientProxyFactoryUtils;
+import com.kingdee.eas.hr.emp.IPersonPosition;
+import com.kingdee.eas.hr.emp.PersonPositionCollection;
+import com.kingdee.eas.hr.emp.PersonPositionFactory;
+import com.kingdee.eas.hr.emp.PersonPositionInfo;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
+import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
+import com.kingdee.shr.compensation.*;
+import com.kingdee.shr.compensation.app.incomeTax.*;
+import com.kingdee.shr.compensation.app.tax.ITaxUnit;
+import com.kingdee.shr.compensation.app.tax.TaxItemPlanInfo;
+import com.kingdee.shr.compensation.app.tax.TaxUnitFactory;
+import com.kingdee.shr.compensation.app.tax.TaxUnitInfo;
+import com.kingdee.shr.custom.compensation.accrue.handler.CmpCalDynamicListHandlerExEx;
+import com.kingdee.util.StringUtils;
+import org.apache.log4j.Logger;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
+/**
+ * @author qingwu
+ * @date 2024/8/30
+ * @apiNote BackCalculateService 反算服务  TaxPaymentBackCalculate
+ */
+public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx {
+    private Context ctx = SHRContext.getInstance().getContext();
+    Logger logger = Logger.getLogger("com.kingdee.eas.custom.compensation.handler.CmpCalDynamicListHandlerExExEx");
+
+    /**
+     * 税款反算
+     *
+     * @param request
+     * @param response
+     * @param modelMap
+     * @throws ShrWebBizException
+     * @throws BOSException
+     */
+    public void taxPaymentBackCalculateAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException, BOSException, EASBizException {
+        //计算规则ID
+        String cmpschemeid = request.getParameter("cmpschemeid");
+        if (StringUtils.isEmpty(cmpschemeid)) {
+            throw new ShrWebBizException("计算规则ID不可为空!!");
+        }
+        Map rseMap = new HashMap();
+        List resList = new ArrayList();
+        //接口日志实体
+        LogInfoInfo logInfo = new LogInfoInfo();
+        //入口
+        logInfo.setEntrance(this.getClass().getName());
+        logInfo.setBizDate(new Date());
+        try {
+            //计算规则
+            ICalScheme iCalScheme = CalSchemeFactory.getLocalInstance(ctx);
+            ITaxUnit iTaxUnit = TaxUnitFactory.getLocalInstance(ctx);
+            IPerson iPerson = PersonFactory.getLocalInstance(ctx);
+            SelectorItemCollection sic = new SelectorItemCollection();
+            sic.add("taxItemPlanList.taxItemPlan.name");
+            sic.add("taxItemPlanList.taxItemPlan.number");
+            sic.add("*");
+            FilterInfo filterInfo = new FilterInfo();
+            filterInfo.getFilterItems().add(new FilterItemInfo("id", cmpschemeid, CompareType.EQUALS));
+            EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
+            CalSchemeInfo calSchemeInfo = iCalScheme.getCalSchemeCollection(entityViewInfo).get(0);
+            //获取当前的薪酬核算
+            CmpCalTableCollection cmpCalTableCollection = getCalSchemeColl(calSchemeInfo.getId().toString(), calSchemeInfo.getPeriodYear(), calSchemeInfo.getPeriodMonth());
+            logger.error("cmpCalTableCollection--------" + cmpCalTableCollection.size());
+            //获取所有人和纳税单位
+            List<TaxUnitAndPerson> taxUnitAndPeople = new ArrayList();
+            if (cmpCalTableCollection.size() > 0) {
+                for (int i = 0; i < cmpCalTableCollection.size(); i++) {
+                    String personId = cmpCalTableCollection.get(i).getPerson().getId().toString();
+                    //获取纳税单位
+                    String sql = getSalaryOrgMappingByPersonId(personId);
+                    logger.error("getSalaryOrgMappingByPersonId--------" + sql);
+                    IRowSet iRowSet = DbUtil.executeQuery(ctx, sql);
+                    if (iRowSet.size() <= 0) {
+                        throw new ShrWebBizException("员工ID:" + personId + "未获取到纳税单位!!");
+                    }
+                    String taxUnitId = null;
+                    while (iRowSet.next()) {
+                        taxUnitId = iRowSet.getString("taxunit");
+                    }
+                    TaxUnitAndPerson taxUnitAndPerson = new TaxUnitAndPerson(taxUnitId, personId);
+                    taxUnitAndPeople.add(taxUnitAndPerson);
+                }
+            }
+            logger.error("taxUnitAndPeople-----------" + taxUnitAndPeople);
+            //    通过纳税单位分组
+            Map<String, List<TaxUnitAndPerson>> groupedPeople = new HashMap<>();
+            for (TaxUnitAndPerson taxUnitAndPerson : taxUnitAndPeople) {
+                String taxunitId = taxUnitAndPerson.getTaxunitId();
+                if (!groupedPeople.containsKey(taxunitId)) {
+                    groupedPeople.put(taxunitId, new ArrayList<>());
+                }
+                groupedPeople.get(taxunitId).add(taxUnitAndPerson);
+            }
+            logger.error("groupedPeople-----------" + groupedPeople);
+            // 输出分组结果
+            for (Map.Entry<String, List<TaxUnitAndPerson>> entry : groupedPeople.entrySet()) {
+                logger.error("输出分组结果------------start");
+                logger.error("taxunitId: " + entry.getKey());
+                //自定义类 反算服务
+                SixTConfirmInfo sixTConfirmInfo = new SixTConfirmInfo();
+                //外部业务编号
+                sixTConfirmInfo.setBizNo(UUID.randomUUID().toString().replace("-", ""));
+                //纳税单位
+                String taxunitId = entry.getKey();
+                TaxUnitInfo taxUnitInfo = iTaxUnit.getTaxUnitInfo("where id = '" + taxunitId + "'");
+                //个税方案
+                TaxItemPlanInfo taxItemPlan = calSchemeInfo.getTaxItemPlanList().get(0).getTaxItemPlan();
+                String taxItemPlanNumber = taxItemPlan.getNumber();
+                String taxItemPlanName = taxItemPlan.getName();
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("periodYear", calSchemeInfo.getPeriodYear());
+                jsonObject.put("periodMonth", calSchemeInfo.getPeriodMonth());
+                jsonObject.put("cmpschemeid", cmpschemeid);
+                jsonObject.put("taxItemPlanName", taxItemPlanName);
+                jsonObject.put("taxItemPlanNumber", taxItemPlanNumber);
+                logger.error("jsonObject-------------" + jsonObject);
+                //反算服务
+                ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
+                //算税请求接口
+                TaxRequest taxRequest = clientProxyFactory.getTaxRequest();
+                //获取请求参数
+                CalculateIndividualIncomeTaxRequest calculateIndividualIncomeTaxRequest = getCalculateIndividualIncomeTaxRequest(entry, taxUnitInfo, taxItemPlanNumber, taxItemPlanName, cmpschemeid, logInfo);
+                //调用反算服务接口
+                ApiResponse<AsyncResult> asyncResultApiResponse = clientProxyFactory.getTaxRequest().reverseCalculateASynIndividualIncomeTax(calculateIndividualIncomeTaxRequest);
+                logger.error("asyncResultApiResponse-----getCode-------" + asyncResultApiResponse.getHead().getCode());
+                logger.error("asyncResultApiResponse-----getMsg--------" + asyncResultApiResponse.getHead().getMsg());
+                if (asyncResultApiResponse.getHead().getCode().equals("00000000")) {
+                    AsyncResult body = asyncResultApiResponse.getBody();
+                    String requestId = body.getRequestId();
+                    logger.error("requestId-----" + requestId);
+                    //查询反算反馈结果
+                    ISYUtilsFacade isyUtilsFacade = SYUtilsFacadeFactory.getLocalInstance(ctx);
+                    //backTask(url,requestId,回调osf服务,自定义参数,任务类型)
+                    //isyUtilsFacade.backTask(isyUtilsFacade.getConfig().get("ip") + "/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", jsonObject.toString(), TaskCatalogEnum.CAL_GET);
+                    JSONObject json = new JSONObject();
+                    json.put("requestId", requestId);
+                    json.put("param", jsonObject.toString());
+                    isyUtilsFacade.addTask("synIndividualIncomeTaxService", json.toJSONString(), TaskCatalogEnum.PERSON, "");
+                    //isyUtilsFacade.backTask("https://test-openapi.17win.com/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", jsonObject.toString(), TaskCatalogEnum.CAL_GET);
+                    //查询反算反馈结果
+                    //ISYUtilsFacade isyUtilsFacade = SYUtilsFacadeFactory.getLocalInstance(ctx);
+                    //backTask(url,requestId,回调osf服务,自定义参数,任务类型)
+                    //isyUtilsFacade.backTask(isyUtilsFacade.getConfig().get("ip") + "/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", "", TaskCatalogEnum.CAL_GET);
+                    //isyUtilsFacade.backTask("https://test-openapi.17win.com/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", jsonObject.toString(), TaskCatalogEnum.CAL_GET);
+                    //ApiResponse<CalculateTaxResultRequest> aSynIndividualIncomeTaxFeedback = null;
+                    //boolean istrue = true;
+                    //while (istrue) {
+                    //    //ApiResponse<CalculateTaxResultRequest> aSynIndividualIncomeTaxFeedback = taxRequest.getReverseASynIndividualIncomeTaxFeedback(requestId);
+                    //    aSynIndividualIncomeTaxFeedback = taxRequest.getReverseASynIndividualIncomeTaxFeedback(requestId);
+                    //    //ApiResponse<CalculateTaxResultRequest> aSynIndividualIncomeTaxFeedback =taxRequest.getReverseASynIndividualIncomeTaxFeedback("9a538f46af784ec6b78fa6e2e10e7037");
+                    //    String code = aSynIndividualIncomeTaxFeedback.getHead().getCode();
+                    //    if (!"100004".equals(code)) {
+                    //        istrue = false;
+                    //    }
+                    //    logger.error("getCode---" + aSynIndividualIncomeTaxFeedback.getHead().getCode());
+                    //    logger.error("getMsg---" + aSynIndividualIncomeTaxFeedback.getHead().getMsg());
+                    //    // 等待一段时间再进行下一次轮询,这里设置为 5 秒(5000 毫秒)
+                    //    Thread.sleep(3000);
+                    //}
+                    //CalculateTaxResultRequest resBody = aSynIndividualIncomeTaxFeedback.getBody();
+                    ////个税反算保存方法
+                    //String saveId = addTaxPaymentBackCalculate(resBody, jsonObject);
+                    //resList.add(saveId);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            logInfo.setErrorInfo(e.getMessage());//错误信息
+            LogInfoFactory.getLocalInstance(ctx).save(logInfo);
+            throw new SHRWebException(e);
+        }
+        JSONUtils.writeJson(response, "已增加至后台事务中执行!");
+    }
+
+    /**
+     * 获取请求参数
+     *
+     * @param entry
+     * @param taxUnitInfo
+     * @param taxItemPlanNumber
+     * @param taxItemPlanName
+     * @param cmpschemeid
+     * @param logInfo
+     * @throws BOSException
+     * @throws EASBizException
+     * @throws SQLException
+     * @throws JsonProcessingException
+     */
+    private CalculateIndividualIncomeTaxRequest getCalculateIndividualIncomeTaxRequest(Map.Entry<String, List<TaxUnitAndPerson>> entry, TaxUnitInfo taxUnitInfo, String taxItemPlanNumber, String taxItemPlanName, String cmpschemeid, LogInfoInfo logInfo) throws BOSException, EASBizException, SQLException, JsonProcessingException {
+        CalculateIndividualIncomeTaxRequest calculateIndividualIncomeTaxRequest = new CalculateIndividualIncomeTaxRequest();
+        //外部业务编号
+        String replace = UUID.randomUUID().toString().replace("-", "");
+        logger.error("BizNo" + replace);
+        calculateIndividualIncomeTaxRequest.setBizNo(replace);
+        //企业名称(纳税单位)
+        calculateIndividualIncomeTaxRequest.setName(taxUnitInfo.getName());
+        //calculateIndividualIncomeTaxRequest.setName("荆州九州通医药有限公司00");
+        //申报密码
+        String sbmm = new String(Base64.getDecoder().decode(taxUnitInfo.getDeclPassword()));
+        //String sbmm = new String(Base64.getDecoder().decode("QWExMjM0NTY="));
+        logger.error("sbmm----" + sbmm);
+        calculateIndividualIncomeTaxRequest.setDeclarePassword(sbmm);
+        //密码类型
+        calculateIndividualIncomeTaxRequest.setPasswordType(null);
+        //实名账号
+        calculateIndividualIncomeTaxRequest.setRealNameAccount(null);
+        //实名密码
+        calculateIndividualIncomeTaxRequest.setRealNamePassword(null);
+        //加密实名密码
+        calculateIndividualIncomeTaxRequest.setEncryptedRealNamePassword(null);
+        //登记序号
+        calculateIndividualIncomeTaxRequest.setRegistrationNumber(taxUnitInfo.getRegNumber());
+        //calculateIndividualIncomeTaxRequest.setRegistrationNumber("10117310124834931897");
+        //税号
+        calculateIndividualIncomeTaxRequest.setTaxNo(taxUnitInfo.getTaxNumber());
+        //calculateIndividualIncomeTaxRequest.setTaxNo("91310124834931897I");
+        //地区编号
+        calculateIndividualIncomeTaxRequest.setArea(taxUnitInfo.getAreaCode());
+        //calculateIndividualIncomeTaxRequest.setArea("310101");
+        //部门编号
+        calculateIndividualIncomeTaxRequest.setDeptNo(null);
+        //部门名称
+        calculateIndividualIncomeTaxRequest.setDeptName(null);
+        //税款所属期
+        //获取当前年月
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
+        String formattedDate = now.format(formatter);
+        calculateIndividualIncomeTaxRequest.setMonth(formattedDate);
+        //获取员工数据
+        IPersonPosition iPersonPosition = PersonPositionFactory.getLocalInstance(ctx);
+        Set personIds = new HashSet();
+        for (TaxUnitAndPerson taxUnitAndPerson : entry.getValue()) {
+            logger.error("personId" + taxUnitAndPerson.getPersonId());
+            String personId = taxUnitAndPerson.getPersonId();
+            personIds.add(personId);
+        }
+        FilterInfo personFilterInfo = new FilterInfo();
+        personFilterInfo.getFilterItems().add(new FilterItemInfo("person.id", personIds, CompareType.INCLUDE));
+        SelectorItemCollection personSic = new SelectorItemCollection();
+        personSic.add("*");
+        personSic.add("person.*");
+        personSic.add("person.employeeType.*");
+        personSic.add("person.nationality.*");
+        EntityViewInfo personEntityViewInfo = EntityViewInfo.getInstance(personFilterInfo, personSic, null);
+        PersonPositionCollection personPositionCollection = iPersonPosition.getPersonPositionCollection(personEntityViewInfo);
+        logger.error("personPositionCollection------------size" + personPositionCollection.size());
+        //综合所得对象
+        ComplexIncomeRequest complexIncomeRequest = getComplexIncomeRequest(taxItemPlanNumber, taxItemPlanName, personPositionCollection, cmpschemeid);
+        logger.error("complexIncomeRequest------------" + complexIncomeRequest);
+        //综合所得
+        calculateIndividualIncomeTaxRequest.setComplexIncomeRequest(complexIncomeRequest);
+        //非居民所得
+        //NonResidentsIncomeRequest nonResidentsIncomeRequest = getNonResidentsIncomeRequest(taxItemPlanName, personInfo, cmpschemeid);
+        logger.error("输出分组结果------------end");
+        logInfo.setInterfaceAddress("gateway/iit/reverseCalculateTax/calculateASynIndividualIncomeTax");//接口地址
+        logInfo.setInterfaceName("calculateASynIndividualIncomeTax");//接口名
+        ObjectMapper mapper = new ObjectMapper();
+        logInfo.setInParameter(mapper.writeValueAsString(calculateIndividualIncomeTaxRequest));//入参
+        return calculateIndividualIncomeTaxRequest;
+    }
+    ///**
+    // * 税款反算
+    // *
+    // * @param request
+    // * @param response
+    // * @param modelMap
+    // * @throws ShrWebBizException
+    // * @throws BOSException
+    // */
+    //public void taxPaymentBackCalculateAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException, BOSException, SQLException, EASBizException, InterruptedException {
+    //    //计算规则ID
+    //    String cmpschemeid = request.getParameter("cmpschemeid");
+    //    if (StringUtils.isEmpty(cmpschemeid)) {
+    //        throw new ShrWebBizException("计算规则ID不可为空!!");
+    //    }
+    //    //计算规则
+    //    ICalScheme iCalScheme = CalSchemeFactory.getLocalInstance(ctx);
+    //    ITaxUnit iTaxUnit = TaxUnitFactory.getLocalInstance(ctx);
+    //    IPerson iPerson = PersonFactory.getLocalInstance(ctx);
+    //    SelectorItemCollection sic = new SelectorItemCollection();
+    //    sic.add("taxItemPlanList.taxItemPlan.name");
+    //    sic.add("taxItemPlanList.taxItemPlan.number");
+    //    sic.add("*");
+    //    FilterInfo filterInfo = new FilterInfo();
+    //    filterInfo.getFilterItems().add(new FilterItemInfo("id", cmpschemeid, CompareType.EQUALS));
+    //    EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
+    //    CalSchemeInfo calSchemeInfo = iCalScheme.getCalSchemeCollection(entityViewInfo).get(0);
+    //    //获取当前的薪酬核算
+    //    CmpCalTableCollection cmpCalTableCollection = getCalSchemeColl(calSchemeInfo.getId().toString(), calSchemeInfo.getPeriodYear(), calSchemeInfo.getPeriodMonth());
+    //    logger.error("cmpCalTableCollection--------" + cmpCalTableCollection.size());
+    //    Map rseMap = new HashMap();
+    //    List resList = new ArrayList();
+    //    if (cmpCalTableCollection.size() > 0) {
+    //        for (int i = 0; i < cmpCalTableCollection.size(); i++) {
+    //            String personId = cmpCalTableCollection.get(i).getPerson().getId().toString();
+    //            //自定义类 反算服务
+    //            SixTConfirmInfo sixTConfirmInfo = new SixTConfirmInfo();
+    //            //外部业务编号
+    //            sixTConfirmInfo.setBizNo(UUID.randomUUID().toString().replace("-", ""));
+    //            //获取纳税单位
+    //            String sql = getSalaryOrgMappingByPersonId(personId);
+    //            logger.error("getSalaryOrgMappingByPersonId--------" + sql);
+    //            IRowSet iRowSet = DbUtil.executeQuery(ctx, sql);
+    //            if (iRowSet.size() <= 0) {
+    //                throw new ShrWebBizException("员工ID:" + personId + "未获取到纳税单位!!");
+    //            }
+    //            TaxUnitInfo taxUnitInfo = null;
+    //            while (iRowSet.next()) {
+    //                taxUnitInfo = iTaxUnit.getTaxUnitInfo("where id = '" + iRowSet.getString("taxunit") + "'");
+    //            }
+    //            //个税方案
+    //            TaxItemPlanInfo taxItemPlan = calSchemeInfo.getTaxItemPlanList().get(0).getTaxItemPlan();
+    //            String taxItemPlanNumber = taxItemPlan.getNumber();
+    //            String taxItemPlanName = taxItemPlan.getName();
+    //            //String taxItemPlanNumber = "2024083001";
+    //            JSONObject jsonObject = new JSONObject();
+    //            jsonObject.put("personId", personId);
+    //            jsonObject.put("periodYear", calSchemeInfo.getPeriodYear());
+    //            jsonObject.put("periodMonth", calSchemeInfo.getPeriodMonth());
+    //            jsonObject.put("cmpschemeid", cmpschemeid);
+    //            jsonObject.put("taxItemPlanName", taxItemPlanName);
+    //            jsonObject.put("taxItemPlanNumber", taxItemPlanNumber);
+    //            logger.error("jsonObject-------------" + jsonObject);
+    //            ClientProxyFactory clientProxyFactory = new ClientProxyFactory(
+    //                    "46639607259987202405271637080",
+    //                    "oTmd/QGL2xOfIKItqFGKnw==",
+    //                    "https://test-openapi.17win.com");
+    //            //反算服务
+    //            //算税请求接口
+    //            TaxRequest taxRequest = clientProxyFactory.getTaxRequest();
+    //            CalculateIndividualIncomeTaxRequest calculateIndividualIncomeTaxRequest = new CalculateIndividualIncomeTaxRequest();
+    //            //外部业务编号
+    //            String replace = UUID.randomUUID().toString().replace("-", "");
+    //            logger.error("BizNo" + replace);
+    //            calculateIndividualIncomeTaxRequest.setBizNo(replace);
+    //            //企业名称(纳税单位)
+    //            calculateIndividualIncomeTaxRequest.setName(taxUnitInfo.getName());
+    //            //calculateIndividualIncomeTaxRequest.setName("荆州九州通医药有限公司00");
+    //            //申报密码
+    //            String sbmm = new String(Base64.getDecoder().decode(taxUnitInfo.getDeclPassword()));
+    //            //String sbmm = new String(Base64.getDecoder().decode("QWExMjM0NTY="));
+    //            logger.error("sbmm----" + sbmm);
+    //            calculateIndividualIncomeTaxRequest.setDeclarePassword(sbmm);
+    //            //密码类型
+    //            calculateIndividualIncomeTaxRequest.setPasswordType(null);
+    //            //实名账号
+    //            calculateIndividualIncomeTaxRequest.setRealNameAccount(null);
+    //            //实名密码
+    //            calculateIndividualIncomeTaxRequest.setRealNamePassword(null);
+    //            //加密实名密码
+    //            calculateIndividualIncomeTaxRequest.setEncryptedRealNamePassword(null);
+    //            //登记序号
+    //            calculateIndividualIncomeTaxRequest.setRegistrationNumber(taxUnitInfo.getRegNumber());
+    //            //calculateIndividualIncomeTaxRequest.setRegistrationNumber("10117310124834931897");
+    //            //税号
+    //            calculateIndividualIncomeTaxRequest.setTaxNo(taxUnitInfo.getTaxNumber());
+    //            //calculateIndividualIncomeTaxRequest.setTaxNo("91310124834931897I");
+    //            //地区编号
+    //            calculateIndividualIncomeTaxRequest.setArea(taxUnitInfo.getAreaCode());
+    //            //calculateIndividualIncomeTaxRequest.setArea("310101");
+    //            //部门编号
+    //            calculateIndividualIncomeTaxRequest.setDeptNo(null);
+    //            //部门名称
+    //            calculateIndividualIncomeTaxRequest.setDeptName(null);
+    //            //税款所属期
+    //            //获取当前年月
+    //            LocalDateTime now = LocalDateTime.now();
+    //            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
+    //            String formattedDate = now.format(formatter);
+    //            calculateIndividualIncomeTaxRequest.setMonth(formattedDate);
+    //            //获取员工数据
+    //            IPersonPosition iPersonPosition = PersonPositionFactory.getLocalInstance(ctx);
+    //            PersonPositionInfo personPositionInfo = iPersonPosition.getPersonPositionInfo("select *,person.*,person.employeeType.* ,person.nationality.* where person.id = '" + personId + "'");
+    //            //PersonInfo personInfo = iPerson.getPersonInfo(new ObjectUuidPK(personId));
+    //            PersonInfo personInfo = personPositionInfo.getPerson();
+    //            //综合所得对象
+    //            ComplexIncomeRequest complexIncomeRequest = getComplexIncomeRequest(taxItemPlanNumber, taxItemPlanName, personInfo, cmpschemeid);
+    //            //综合所得
+    //            calculateIndividualIncomeTaxRequest.setComplexIncomeRequest(complexIncomeRequest);
+    //            //非居民所得
+    //            NonResidentsIncomeRequest nonResidentsIncomeRequest = getNonResidentsIncomeRequest(taxItemPlanName, personInfo, cmpschemeid);
+    //            calculateIndividualIncomeTaxRequest.setNonResidentsIncomeRequest(nonResidentsIncomeRequest);
+    //
+    //            ApiResponse<AsyncResult> asyncResultApiResponse = clientProxyFactory.getTaxRequest().reverseCalculateASynIndividualIncomeTax(calculateIndividualIncomeTaxRequest);
+    //            logger.error("asyncResultApiResponse-----getCode-------" + asyncResultApiResponse.getHead().getCode());
+    //            logger.error("asyncResultApiResponse-----getMsg--------" + asyncResultApiResponse.getHead().getMsg());
+    //            if (asyncResultApiResponse.getHead().getCode().equals("00000000")) {
+    //                AsyncResult body = asyncResultApiResponse.getBody();
+    //                String requestId = body.getRequestId();
+    //                logger.error("requestId-----" + requestId);
+    //                //查询反算反馈结果
+    //                //ISYUtilsFacade isyUtilsFacade = SYUtilsFacadeFactory.getLocalInstance(ctx);
+    //                //backTask(url,requestId,回调osf服务,自定义参数,任务类型)
+    //                //isyUtilsFacade.backTask(isyUtilsFacade.getConfig().get("ip") + "/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", "", TaskCatalogEnum.CAL_GET);
+    //                //isyUtilsFacade.backTask("https://test-openapi.17win.com/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", jsonObject.toString(), TaskCatalogEnum.CAL_GET);
+    //                ApiResponse<CalculateTaxResultRequest> aSynIndividualIncomeTaxFeedback = null;
+    //                boolean istrue = true;
+    //                while (istrue) {
+    //                    //ApiResponse<CalculateTaxResultRequest> aSynIndividualIncomeTaxFeedback = taxRequest.getReverseASynIndividualIncomeTaxFeedback(requestId);
+    //                    aSynIndividualIncomeTaxFeedback = taxRequest.getReverseASynIndividualIncomeTaxFeedback(requestId);
+    //                    //ApiResponse<CalculateTaxResultRequest> aSynIndividualIncomeTaxFeedback =taxRequest.getReverseASynIndividualIncomeTaxFeedback("9a538f46af784ec6b78fa6e2e10e7037");
+    //                    String code = aSynIndividualIncomeTaxFeedback.getHead().getCode();
+    //                    if (!"100004".equals(code)) {
+    //                        istrue = false;
+    //                    }
+    //                    logger.error("getCode---" + aSynIndividualIncomeTaxFeedback.getHead().getCode());
+    //                    logger.error("getMsg---" + aSynIndividualIncomeTaxFeedback.getHead().getMsg());
+    //                    // 等待一段时间再进行下一次轮询,这里设置为 5 秒(5000 毫秒)
+    //                    Thread.sleep(3000);
+    //                }
+    //                CalculateTaxResultRequest resBody = aSynIndividualIncomeTaxFeedback.getBody();
+    //                //个税反算保存方法
+    //                String saveId = addTaxPaymentBackCalculate(resBody, jsonObject);
+    //                resList.add(saveId);
+    //            }
+    //        }
+    //        rseMap.put("resListSize", resList.size());
+    //        rseMap.put("resList", resList);
+    //        JSONUtils.writeJson(response, rseMap);
+    //    }
+    //}
+
+    /**
+     * 添加个税反算数据
+     *
+     * @param resBody 查询反算反馈结果接口返回结果
+     * @param param   员工ID
+     * @return
+     */
+    public String addTaxPaymentBackCalculate(CalculateTaxResultRequest resBody, com.alibaba.fastjson.JSONObject param) throws BOSException, EASBizException {
+        logger.error("addTaxPaymentBackCalculate============Start===============");
+        String personId = param.getString("personId");//员工ID
+        String periodYear = param.getString("periodYear");//统计年
+        String periodMonth = param.getString("periodMonth");//统计月
+        String cmpschemeid = param.getString("cmpschemeid");//计算规则ID
+        String taxItemPlanName = param.getString("taxItemPlanName");//个税项目方案
+        String taxItemPlanNumber = param.getString("taxItemPlanNumber");//个税项目方案
+        //查询税款反算表是否存在该数据
+        ITaxPaymentBackCalculate iTaxPaymentBackCalculate = TaxPaymentBackCalculateFactory.getLocalInstance(ctx);
+        FilterInfo filterInfo = new FilterInfo();
+        filterInfo.getFilterItems().add(new FilterItemInfo("person", personId, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("periodMonth", periodMonth, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("periodYear", periodYear, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("cmpscheme", cmpschemeid, CompareType.EQUALS));
+        EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
+        TaxPaymentBackCalculateCollection taxPaymentBackCalculateCollection = iTaxPaymentBackCalculate.getTaxPaymentBackCalculateCollection(entityViewInfo);
+        TaxPaymentBackCalculateInfo taxPaymentBackCalculateInfo = new TaxPaymentBackCalculateInfo();
+        if (taxPaymentBackCalculateCollection.size() > 0) {
+            taxPaymentBackCalculateInfo = taxPaymentBackCalculateCollection.get(0);
+            taxPaymentBackCalculateInfo.setId(taxPaymentBackCalculateCollection.get(0).getId());
+        }
+        //员工
+        taxPaymentBackCalculateInfo.setPerson(PersonFactory.getLocalInstance(ctx).getPersonInfo(new ObjectUuidPK(personId)));
+        //统计年
+        taxPaymentBackCalculateInfo.setPeriodYear(periodYear);
+        //统计月
+        taxPaymentBackCalculateInfo.setPeriodMonth(periodMonth);
+        //计算规则
+        taxPaymentBackCalculateInfo.setCmpscheme(CalSchemeFactory.getLocalInstance(ctx).getCalSchemeInfo(new ObjectUuidPK(cmpschemeid)));
+        //个税项目方案
+        taxPaymentBackCalculateInfo.setTaxItemPlan(taxItemPlanName);
+        ComplexTaxCalculateResult complexTaxCalculateResult = null;
+        //zhsd   综合所得
+        ComplexIncomeResultRequest complexIncomeResultRequest = resBody.getComplexIncomeResultRequest();
+        //全年一次性奖金
+        if ("2024083001".equals(taxItemPlanNumber)) {
+            //qnycxjjsslb  全年一次性奖金
+            complexTaxCalculateResult = complexIncomeResultRequest.getAnnualOneTimeBonusIncome();
+        }
+        //一般劳务报酬所得列表
+        if ("2024083003".equals(taxItemPlanNumber)) {
+            //lwbclb  一般劳务报酬所得列表
+            complexTaxCalculateResult = complexIncomeResultRequest.getLaborRemunerationIncome();
+        }
+        //正常工资薪金对象
+        if ("2024083004".equals(taxItemPlanNumber)) {
+            //zcgzxj  正常工资薪金对象
+            complexTaxCalculateResult = complexIncomeResultRequest.getNormalSalarySpecIncome();
+        }
+        List<ComplexIncome> successComplexIncomes = complexTaxCalculateResult.getSuccessComplexIncomes();
+        ComplexIncome complexIncome = successComplexIncomes.get(0);
+        //sre  收入额
+        BigDecimal income = complexIncome.getIncome();
+        taxPaymentBackCalculateInfo.setSalarySum(income);
+        //ybtse refundTax  应补退税额
+        BigDecimal refundTax = complexIncome.getRefundTax();
+        taxPaymentBackCalculateInfo.setIndividual(refundTax);
+        IObjectPK save = iTaxPaymentBackCalculate.save(taxPaymentBackCalculateInfo);
+        logger.error("addTaxPaymentBackCalculate============end===============");
+        return save.toString();
+    }
+
+
+    /**
+     * 获取非居民所得	对象
+     *
+     * @return
+     */
+    public NonResidentsIncomeRequest getNonResidentsIncomeRequest(String taxItemPlanName, PersonInfo personInfo, String cmpschemeid) throws SQLException, BOSException {
+        NonResidentsIncomeRequest nonResidentsIncomeRequest = new NonResidentsIncomeRequest();
+        List<NonResidentsIncome> foreignerWagesSalaryIncomes = new ArrayList();
+        NonResidentsIncome nonResidentsIncome = getNonResidentsIncome(taxItemPlanName, personInfo, cmpschemeid);
+        foreignerWagesSalaryIncomes.add(nonResidentsIncome);
+        nonResidentsIncomeRequest.setForeignerWagesSalaryIncomes(foreignerWagesSalaryIncomes);
+        return nonResidentsIncomeRequest;
+    }
+
+    /**
+     * 非居民所得-无住所个人正常工资薪金
+     * * taxItemPlanName   个税项目名称
+     * * personInfo 员工信息
+     * * cmpschemeid 计算规则ID
+     */
+    public NonResidentsIncome getNonResidentsIncome(String taxItemPlanName, PersonInfo personInfo, String cmpschemeid) throws SQLException, BOSException {
+        NonResidentsIncome nonResidentsIncome = new NonResidentsIncome();
+        //nonResidentsIncome.setName("何云");
+        //nonResidentsIncome.setLicenseType("居民身份证");
+        //nonResidentsIncome.setLicenseNumber("429004198601085125");
+        //nonResidentsIncome.setAbroadIncome(new BigDecimal("8000"));
+        //nonResidentsIncome.setIncomeItemName("无住所个人正常工资薪金");
+
+        //姓名
+        nonResidentsIncome.setName(personInfo.getName());
+        //complexIncome.setName("何云");
+        //居民身份证
+        if (personInfo.getIdCardNO() != null) {
+            //证照号码
+            nonResidentsIncome.setLicenseNumber(personInfo.getIdCardNO());
+            //证照类型
+            nonResidentsIncome.setLicenseType("居民身份证");
+        }
+        //中国护照不
+        if (personInfo.getPassportNO() != null) {
+            //证照类型
+            nonResidentsIncome.setLicenseType("中国护照");
+            //证照号码
+            nonResidentsIncome.setLicenseNumber(personInfo.getPassportNO());
+        }
+        Integer abroadIncome = getAbroadIncome(personInfo.getId().toString(), cmpschemeid);
+        //complexIncome.setLicenseNumber("429004198601085125");
+        //税后收入额
+        nonResidentsIncome.setAbroadIncome(new BigDecimal(abroadIncome));
+        nonResidentsIncome.setIncomeItemName(taxItemPlanName);
+        return nonResidentsIncome;
+    }
+
+    /**
+     * 获取综合所得
+     * taxItemPlanNumber   个税项目编码
+     * taxItemPlanName   个税项目名称
+     * personInfo 员工信息
+     * cmpschemeid 计算规则ID
+     *
+     * @return
+     */
+    public ComplexIncomeRequest getComplexIncomeRequest(String taxItemPlanNumber, String taxItemPlanName, PersonPositionCollection personPositionCollection, String cmpschemeid) throws BOSException, EASBizException, SQLException {
+        logger.error("getComplexIncomeRequest-----" + taxItemPlanNumber + "---" + taxItemPlanName + "---" + personPositionCollection + "---" + cmpschemeid);
+        ComplexIncomeRequest complexIncomeRequest = new ComplexIncomeRequest();
+        //全年一次性奖金
+        if (taxItemPlanNumber.equals("2024083001")) {
+            List<ComplexIncome> aOneBonusIncomeList = new ArrayList();
+            for (int i = 0; i < personPositionCollection.size(); i++) {
+                PersonPositionInfo personPositionInfo = personPositionCollection.get(i);
+                PersonInfo personInfo = personPositionInfo.getPerson();
+                ComplexIncome annualOneTimeBonusIncome = getAnnualOneTimeBonusIncome(personInfo, taxItemPlanName, cmpschemeid);
+                aOneBonusIncomeList.add(annualOneTimeBonusIncome);
+                complexIncomeRequest.setAnnualOneTimeBonusIncome(aOneBonusIncomeList);
+            }
+        }
+        //一般劳务报酬所得列表
+        if (taxItemPlanNumber.equals("2024083003")) {
+            List<ComplexIncome> complexIncomeList = new ArrayList();
+            for (int i = 0; i < personPositionCollection.size(); i++) {
+                PersonPositionInfo personPositionInfo = personPositionCollection.get(i);
+                PersonInfo personInfo = personPositionInfo.getPerson();
+                ComplexIncome laborRemunerationIncome = getLaborRemunerationIncome(personInfo, taxItemPlanName, cmpschemeid);
+                complexIncomeList.add(laborRemunerationIncome);
+                complexIncomeRequest.setLaborRemunerationIncome(complexIncomeList);
+            }
+        }
+        //正常工资薪金对象
+        if (taxItemPlanNumber.equals("2024083004")) {
+            NormalSalarySpecIncome normalSalarySpecIncome = getNormalSalarySpecIncome(personPositionCollection);
+            complexIncomeRequest.setNormalSalarySpecIncome(normalSalarySpecIncome);
+        }
+        return complexIncomeRequest;
+    }
+
+
+    /**
+     * 获取全年一次性奖金
+     * taxItemPlanName  个税项目名称
+     * cmpschemeid 计算规则ID
+     *
+     * @return
+     */
+    public ComplexIncome getAnnualOneTimeBonusIncome(PersonInfo personInfo, String taxItemPlanName, String cmpschemeid) throws SQLException, BOSException {
+        ComplexIncome complexIncome = new ComplexIncome();
+        //姓名
+        complexIncome.setName(personInfo.getName());
+        //complexIncome.setName("何云");
+        //居民身份证
+        if (personInfo.getIdCardNO() != null) {
+            //证照号码
+            complexIncome.setLicenseNumber(personInfo.getIdCardNO());
+            //证照类型
+            complexIncome.setLicenseType("居民身份证");
+        }
+        //中国护照不
+        if (personInfo.getPassportNO() != null) {
+            //证照类型
+            complexIncome.setLicenseType("中国护照");
+            //证照号码
+            complexIncome.setLicenseNumber(personInfo.getPassportNO());
+        }
+        Integer abroadIncome = getAbroadIncome(personInfo.getId().toString(), cmpschemeid);
+        //complexIncome.setLicenseNumber("429004198601085125");
+        //税后收入额
+        complexIncome.setAbroadIncome(new BigDecimal(abroadIncome));
+        complexIncome.setIncomeItemName(taxItemPlanName);
+        return complexIncome;
+    }
+
+    /**
+     * 获取一般劳务报酬所得
+     * taxItemPlanName  个税项目名称
+     * cmpschemeid 计算规则ID
+     *
+     * @return
+     */
+    public ComplexIncome getLaborRemunerationIncome(PersonInfo personInfo, String taxItemPlanName, String cmpschemeid) throws SQLException, BOSException {
+        ComplexIncome complexIncome = new ComplexIncome();
+        //姓名
+        complexIncome.setName(personInfo.getName());
+        //complexIncome.setName("何云");
+        //居民身份证
+        if (personInfo.getIdCardNO() != null) {
+            //证照号码
+            complexIncome.setLicenseNumber(personInfo.getIdCardNO());
+            //证照类型
+            complexIncome.setLicenseType("居民身份证");
+        }
+        //中国护照不
+        if (personInfo.getPassportNO() != null) {
+            //证照类型
+            complexIncome.setLicenseType("中国护照");
+            //证照号码
+            complexIncome.setLicenseNumber(personInfo.getPassportNO());
+        }
+        Integer abroadIncome = getAbroadIncome(personInfo.getId().toString(), cmpschemeid);
+        //complexIncome.setLicenseNumber("429004198601085125");
+        //税后收入额
+        complexIncome.setAbroadIncome(new BigDecimal(abroadIncome));
+        complexIncome.setIncomeItemName(taxItemPlanName);
+        return complexIncome;
+    }
+
+    /**
+     * 获取正常工资薪金对象
+     *
+     * @return
+     */
+    public NormalSalarySpecIncome getNormalSalarySpecIncome(PersonPositionCollection personPositionCollection) throws BOSException, EASBizException {
+        //正常工资薪金对象
+        NormalSalarySpecIncome normalSalarySpecIncome = new NormalSalarySpecIncome();
+        //人员列表
+        List<DetailCompanyEmployee> companyEmployeeList = new ArrayList();
+        for (int i = 0; i < personPositionCollection.size(); i++) {
+            PersonPositionInfo personPositionInfo = personPositionCollection.get(i);
+            PersonInfo personInfo = personPositionInfo.getPerson();
+            //获取人员数据
+            DetailCompanyEmployee detailCompanyEmployee = getDetailCompanyEmployee(personInfo);
+            companyEmployeeList.add(detailCompanyEmployee);
+        }
+        normalSalarySpecIncome.setCompanyEmployeeList(companyEmployeeList);
+        return normalSalarySpecIncome;
+    }
+
+    /**
+     * 人员
+     *
+     * @return
+     */
+    public DetailCompanyEmployee getDetailCompanyEmployee(PersonInfo personInfo) throws BOSException, EASBizException {
+
+        //人员对象
+        DetailCompanyEmployee detailCompanyEmployee = new DetailCompanyEmployee();
+        ////姓名
+        //detailCompanyEmployee.setName("何云");
+        ////证件类型
+        //detailCompanyEmployee.setLicenseType("居民身份证");
+        ////证照号码
+        //detailCompanyEmployee.setLicenseNumber("429004198601085125");
+        //姓名
+        detailCompanyEmployee.setName(personInfo.getName());
+        //complexIncome.setName("何云");
+        //居民身份证
+        if (personInfo.getIdCardNO() != null) {
+            //证照号码
+            detailCompanyEmployee.setLicenseNumber(personInfo.getIdCardNO());
+            //证照类型
+            detailCompanyEmployee.setLicenseType("居民身份证");
+            //人员地区
+            detailCompanyEmployee.setArea("境内");
+        }
+        //中国护照
+        if (personInfo.getPassportNO() != null) {
+            //证照类型
+            detailCompanyEmployee.setLicenseType("中国护照");
+            //证照号码
+            detailCompanyEmployee.setLicenseNumber(personInfo.getPassportNO());
+            //人员地区
+            detailCompanyEmployee.setArea("境外");
+        }
+        //电话号码
+        detailCompanyEmployee.setPhone(personInfo.getCell());
+
+        //人员状态
+        detailCompanyEmployee.setState(personInfo.getEmployeeType().getName());
+        //人员报税信息->任职受雇从业信息
+        ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
+        TaxPersonRecordEntryCollection taxPersonRecordEntryCollection = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("where person.id = '" + personInfo.getId() + "'");
+        TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxPersonRecordEntryCollection.get(0);
+        //任职受雇类型  可选择雇员、保险营销员、证券经纪人、其他、实习学生(全日制学历教育)
+        //detailCompanyEmployee.setIsEmployee("其他");
+        detailCompanyEmployee.setIsEmployee(taxPersonRecordEntryInfo.getEmployedType().getAlias());
+        //受雇日期  YYYY-MM-DD,不能大于当前时间,任职受雇类型选择雇员、保险营销员、证券经纪人时必录
+        SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
+        detailCompanyEmployee.setEmployedDate(inputFormat.format(taxPersonRecordEntryInfo.getEmployedDate()));
+        //性别
+        detailCompanyEmployee.setGender(personInfo.getGender().getAlias());
+        //出生日期
+        detailCompanyEmployee.setBirthday(inputFormat.format(personInfo.getBirthday()));
+        //国籍 nationality
+        NationalityInfo nationality = personInfo.getNationality();
+        detailCompanyEmployee.setNationality(nationality.getName());
+
+        return detailCompanyEmployee;
+    }
+
+    /**
+     * 获取税后收入额  系统字段=税后保实发
+     *
+     * @param perosnId
+     * @param cmpschemeid
+     * @return
+     */
+    public Integer getAbroadIncome(String perosnId, String cmpschemeid) throws BOSException, SQLException {
+        String sql = String.format("select S336  from  T_HR_SCmpCalTable where FPERSONID = '%s' and  FCALSCHEMEID = '%s'", perosnId, cmpschemeid);
+        logger.error("getAbroadIncomeSql---------------" + sql);
+        IRowSet iRowSet = DbUtil.executeQuery(ctx, sql);
+        Integer abroadIncome = null;
+        while (iRowSet.next()) {
+            abroadIncome = iRowSet.getInt("S336");
+        }
+        return abroadIncome;
+    }
+
+
+    /**
+     * 获取纳税单元
+     *
+     * @param personId
+     * @return
+     */
+    public String getSalaryOrgMappingByPersonId(String personId) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("select top 1 ").append("\n");
+        sb.append("cmpOrgUnitCus.FTAXUNITID as taxunit").append("\n");
+        sb.append("from CT_COM_CmpOrgUnitCus cmpOrgUnitCus").append("\n");
+        sb.append("left join T_HR_SPersonCmp personCmp on personCmp.Fid = cmpOrgUnitCus.FPERSONCMPID").append("\n");
+        sb.append("left join T_bd_person person on person.Fid = personCmp.FPERSONID").append("\n");
+        sb.append("where").append("\n");
+        sb.append("person.Fid = '").append(personId).append("'").append("\n");
+        sb.append("order by cmpOrgUnitCus.FLEFFECTTIME desc ").append("\n");
+        return sb.toString();
+
+    }
+
+
+    ///**
+    // * 同步人员纳税信息
+    // *
+    // * @param request
+    // * @param response
+    // * @param modelMap
+    // * @throws ShrWebBizException
+    // * @throws BOSException
+    // */
+    //public void synTaxPersonRecordAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws ShrWebBizException, BOSException {
+    //    //计算规则ID
+    //    String cmpschemeid = request.getParameter("cmpschemeid");
+    //    if (StringUtils.isEmpty(cmpschemeid)) {
+    //        throw new ShrWebBizException("计算规则ID不可为空!!");
+    //    }
+    //    //计算规则
+    //    ICalScheme iCalScheme = CalSchemeFactory.getLocalInstance(ctx);
+    //    try {
+    //        CalSchemeInfo calSchemeInfo = iCalScheme.getCalSchemeInfo(new ObjectUuidPK(cmpschemeid));
+    //        //获取上一个月的计算规则  统计年:periodYear   统计月:periodMonth
+    //        LocalDate date = LocalDate.of(calSchemeInfo.getPeriodYear(), calSchemeInfo.getPeriodMonth(), 1);
+    //        LocalDate previousMonthDate = date.minusMonths(1);
+    //        //获取上个月的薪酬核算
+    //        //CalSchemeInfo calSchemeUp = iCalScheme.getCalSchemeInfo("where periodYear = '" + previousMonthDate.getYear() + "' and  periodMonth = '" + previousMonthDate.getMonthValue() + "'");
+    //        CmpCalTableCollection cmpCalTableCollectionUp = getCalSchemeColl(calSchemeInfo.getId().toString(), previousMonthDate.getYear(), previousMonthDate.getMonthValue());
+    //        logger.error("cmpCalTableCollectionUp--------" + cmpCalTableCollectionUp.size());
+    //
+    //        //获取当前的薪酬核算
+    //        CmpCalTableCollection cmpCalTableCollection = getCalSchemeColl(calSchemeInfo.getId().toString(), calSchemeInfo.getPeriodYear(), calSchemeInfo.getPeriodMonth());
+    //        logger.error("cmpCalTableCollection--------" + cmpCalTableCollection.size());
+    //
+    //        //保存上个月的核算人员
+    //        List<String> listUp = new ArrayList<>();
+    //        for (int i = 0; i < cmpCalTableCollectionUp.size(); i++) {
+    //            listUp.add(cmpCalTableCollectionUp.get(i).getPerson().getId().toString());
+    //        }
+    //
+    //        //保存当前月的核算人员
+    //        List<String> list = new ArrayList<>();
+    //        for (int i = 0; i < cmpCalTableCollection.size(); i++) {
+    //            list.add(cmpCalTableCollection.get(i).getPerson().getId().toString());
+    //        }
+    //
+    //        Set<String> setUp = new HashSet<>(listUp);
+    //        Set<String> set = new HashSet<>(list);
+    //
+    //        // 找出 上个月核算人员 中比 当前月核算人员 多的数据 为离职人员 修改人员纳税信息的 人员状态为非正常  离职日期为当前月最后一天
+    //        Set<String> pseronIdsUp = new HashSet<>(setUp);
+    //        pseronIdsUp.removeAll(set);
+    //
+    //        // 找出 当前月核算人员 中比 上个月核算人员 多的数据 为新增人员 创建人员纳税信息和任职受雇从业信息 人员状态为正常 任职受雇从业日期为当前月1号
+    //        Set<String> pseronIds = new HashSet<>(set);
+    //        pseronIds.removeAll(setUp);
+    //
+    //        SelectorItemCollection updateSic = new SelectorItemCollection();
+    //        updateSic.add("personStatus");
+    //        updateSic.add("departureDate");
+    //        //处理修改的人员纳税信息
+    //        ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
+    //        //判断修改人员ID大于0 则修改人员纳税信息
+    //        if (pseronIdsUp.size() > 0) {
+    //            //获取任职受雇从业信息   修改人员纳税信息的 人员状态为非正常  离职日期为当前月最后一天
+    //            TaxPersonRecordEntryCollection taxPersonRecordEntryCollUp = getTaxPersonRecordEntryColl(pseronIdsUp, iTaxPersonRecordEntry);
+    //            if (taxPersonRecordEntryCollUp.size() > 0) {
+    //                for (int i = 0; i < taxPersonRecordEntryCollUp.size(); i++) {
+    //                    TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxPersonRecordEntryCollUp.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);
+    //                }
+    //            }
+    //        }
+    //        //调用新增人员纳税信息方法
+    //        if (pseronIds.size() > 0) {
+    //            //Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()) 当前月第一天
+    //            addTaxPersonRecord(pseronIds, Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+    //        }
+    //        Map res = new HashMap();
+    //        res.put("update", pseronIdsUp.size());
+    //        res.put("add", pseronIds.size());
+    //        JSONUtils.writeJson(response, res);
+    //    } catch (EASBizException e) {
+    //        e.printStackTrace();
+    //        throw new ShrWebBizException("计算规则ID【" + cmpschemeid + "】未获取到,请联系管理员!!");
+    //    } catch (SQLException e) {
+    //        throw new ShrWebBizException(e);
+    //    } catch (SHRWebException e) {
+    //        throw new ShrWebBizException(e);
+    //    }
+    //
+    //}
+
+    ///**
+    // * 新增人员纳税信息
+    // *
+    // * @param pseronIds
+    // */
+    //public void addTaxPersonRecord(Set<String> pseronIds, Date oneDay) throws BOSException, EASBizException, SQLException {
+    //    logger.error("addTaxPersonRecord--------新增开始");
+    //    //pseronIds.forEach(id -> {});
+    //    ITaxPersonRecord iTaxPersonRecord = TaxPersonRecordFactory.getLocalInstance(ctx);
+    //    IPerson iPerson = PersonFactory.getLocalInstance(ctx);
+    //    ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
+    //    //人员纳税分录对象
+    //    TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = new TaxPersonRecordEntryInfo();
+    //    SelectorItemCollection sic = new SelectorItemCollection();
+    //    sic.add("*");
+    //    FilterInfo filterInfo = new FilterInfo();
+    //    filterInfo.getFilterItems().add(new FilterItemInfo("id", pseronIds, CompareType.INCLUDE));
+    //    EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
+    //    PersonCollection personCollection = iPerson.getPersonCollection(entityViewInfo);
+    //    if (personCollection.size() > 0) {
+    //        for (int i = 0; i < personCollection.size(); i++) {
+    //            PersonInfo personInfo = personCollection.get(i);
+    //            boolean exists = iTaxPersonRecordEntry.exists("where person = '" + personInfo.getId().toString() + "'");
+    //            if (!exists) {
+    //
+    //                TaxPersonRecordInfo taxPersonRecordInfo = new TaxPersonRecordInfo();
+    //                //人员
+    //                taxPersonRecordInfo.setPerson(personInfo);
+    //                //证件类型
+    //                if (personInfo.getIdCardNO() != null || personInfo.getPassportNO() != null) {
+    //                    if (null == personInfo.getIdCardNO()) {
+    //                        //护照
+    //                        taxPersonRecordInfo.setCardType(CardTypeEnum.Passport);
+    //                        taxPersonRecordInfo.setCardNumber(personInfo.getPassportNO());
+    //                        //纳税人类型
+    //                        taxPersonRecordEntryInfo.setPayerType(PayerTypeEnum.NotResident);
+    //                    }
+    //                    if (null == personInfo.getPassportNO()) {
+    //                        //证件号
+    //                        taxPersonRecordInfo.setCardType(CardTypeEnum.IdCard);
+    //                        taxPersonRecordInfo.setCardNumber(personInfo.getIdCardNO());
+    //                        //纳税人类型
+    //                        taxPersonRecordEntryInfo.setPayerType(PayerTypeEnum.Resident);
+    //
+    //                    }
+    //                } else {
+    //                    logger.error(personInfo.getName() + "护照和身份证为空,证件类型保存失败!");
+    //                }
+    //                //性别
+    //                taxPersonRecordInfo.setGender(personInfo.getGender());
+    //                //出生日期
+    //                taxPersonRecordInfo.setBirthday(personInfo.getBirthday());
+    //                //国籍
+    //                taxPersonRecordInfo.setNationality(personInfo.getNationality());
+    //                //是否境外人员
+    //                taxPersonRecordInfo.setIsOversea(IsOverseaEnum.NotOversea);
+    //                //手机号码
+    //                taxPersonRecordInfo.setPhoneNumber(personInfo.getCell());
+    //                iTaxPersonRecord.save(taxPersonRecordInfo);
+    //                //保存分录数据
+    //                taxPersonRecordEntryInfo.setPerson(personInfo);
+    //                taxPersonRecordEntryInfo.setBill(taxPersonRecordInfo);
+    //                //获取纳税单位
+    //                String sql = getSalaryOrgMappingByPersonId(personInfo.getId().toString());
+    //                IRowSet iRowSet = DbUtil.executeQuery(ctx, sql);
+    //                ITaxUnit iTaxUnit = TaxUnitFactory.getLocalInstance(ctx);
+    //                if (iRowSet.size() > 0) {
+    //                    while (iRowSet.next()) {
+    //                        TaxUnitInfo taxUnitInfo = iTaxUnit.getTaxUnitInfo("where number = '" + iRowSet.getString("nsdwmc") + "'");
+    //                        taxPersonRecordEntryInfo.setTaxUnit(taxUnitInfo);
+    //                        //人员状态
+    //                        taxPersonRecordEntryInfo.setPersonStatus(PersonStatusEnum.Normal);
+    //                        //获取当前月的最后一天转成Date类型 //任职受雇从业日期为当前月第一天
+    //                        taxPersonRecordEntryInfo.setEmployedDate(oneDay);
+    //                        //报送状态
+    //                        taxPersonRecordEntryInfo.setSubmitStatus(SubmitStatusEnum.NotSubmit);
+    //                        iTaxPersonRecordEntry.save(taxPersonRecordEntryInfo);
+    //                    }
+    //                } else {
+    //                    logger.error("iRowSet-----Sql---" + sql);
+    //                    logger.error("iRowSet--------" + personInfo.getName() + "未获取到纳税单位,字段保存失败!!");
+    //                }
+    //            }
+    //        }
+    //    }
+    //    logger.error("addTaxPersonRecord--------新增结束");
+    //}
+
+
+    ///**
+    // * 获取任职受雇从业信息
+    // *
+    // * @param pseronIds 员工ID集合
+    // * @return
+    // * @throws BOSException
+    // */
+    //public TaxPersonRecordEntryCollection getTaxPersonRecordEntryColl(Set<String> pseronIds, ITaxPersonRecordEntry iTaxPersonRecordEntry) throws BOSException {
+    //    //获取当前月的薪酬计算
+    //    FilterInfo filterInfo = new FilterInfo();
+    //    filterInfo.getFilterItems().add(new FilterItemInfo("bill.person", pseronIds, CompareType.INCLUDE));
+    //    EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
+    //    return iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection(entityViewInfo);
+    //}
+
+    /**
+     * 通过计算规则id获取薪酬核算数据
+     *
+     * @param cmpschemeid
+     * @throws BOSException
+     */
+    public CmpCalTableCollection getCalSchemeColl(String cmpschemeid, int year, int month) throws BOSException {
+        ICmpCalTable iCmpCalTable = CmpCalTableFactory.getLocalInstance(ctx);
+        SelectorItemCollection sic = new SelectorItemCollection();
+        sic.add("*");
+        sic.add("calScheme.*");
+        sic.add("person.*");
+        //获取当前月的薪酬计算
+        FilterInfo filterInfo = new FilterInfo();
+        filterInfo.getFilterItems().add(new FilterItemInfo("calScheme", cmpschemeid, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("periodYear", year, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("periodMonth", month, CompareType.EQUALS));
+        EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
+        CmpCalTableCollection cmpCalTableCollection = iCmpCalTable.getCmpCalTableCollection(entityViewInfo);
+        return cmpCalTableCollection;
+    }
+}

+ 810 - 0
websrc/com/kingdee/eas/custom/compensation/handler/IncomeTaxDeclareListHandlerEx.java

@@ -0,0 +1,810 @@
+package com.kingdee.eas.custom.compensation.handler;
+
+import cn.com.servyou.dto.ApiResponse;
+import cn.com.servyou.dto.AsyncResult;
+import cn.com.servyou.dto.declare.CompanyDeclareRequest;
+import cn.com.servyou.dto.tax.*;
+import cn.com.servyou.rmi.client.ClientProxyFactory;
+import cn.com.servyou.service.DeclarationRequest;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.eas.basedata.hraux.NationalityInfo;
+import com.kingdee.eas.basedata.person.PersonInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.shuiyou.task.TaskCatalogEnum;
+import com.kingdee.eas.custom.shuiyou.uitls.ISYUtilsFacade;
+import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacadeFactory;
+import com.kingdee.eas.custom.shuiyou.utils.ClientProxyFactoryUtils;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
+import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
+import com.kingdee.shr.compensation.app.tax.*;
+import com.kingdee.shr.compensation.util.Base64Utils;
+import com.kingdee.shr.compensation.web.handler.tax.IncomeTaxDeclareListHandler;
+import com.kingdee.util.StringUtils;
+import org.apache.log4j.Logger;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author qingwu
+ * @date 2024/9/18
+ * @apiNote 个税申报扩展
+ */
+public class IncomeTaxDeclareListHandlerEx extends IncomeTaxDeclareListHandler {
+    Logger logger = Logger.getLogger("com.kingdee.eas.custom.compensation.handler.IncomeTaxDeclareListHandlerEx");
+    String personName = "测试姜凌";
+    String cardType = "居民身份证";
+    String cardNumber = "828888201005039412";
+    /**
+     * 个税申报
+     *
+     * @param request
+     * @param response
+     * @param modelMap
+     */
+    public void taxDeclaresAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SHRWebException {
+        logger.error("taxDeclareAction-----start-------");
+
+        Context ctx = SHRContext.getInstance().getContext();
+        //个税申报
+        //String selectedId = request.getParameter("selectedId");
+        //String sqlInString = CmpUtils.spiltToSqlString(selectedId);
+        //if (StringUtils.isEmpty(sqlInString)) {
+        //    sqlInString = "''";
+        //}
+        try {
+            //String oqlBuffer = "select id,yearMonth,totalPerson,totalMoney,taxRebate,declareStatus,versionCode,yearMonthDate,tbType,taxUnit.id,taxUnit.name,taxUnit.taxNumber,taxUnit.regNumber,taxUnit.areaCode,taxUnit.declPassword, batchNo where id in ( " + sqlInString + " )";
+            //IncomeTaxDeclarCollection declareCollection = IncomeTaxDeclarFactory.getLocalInstance(ctx).getIncomeTaxDeclarCollection(oqlBuffer);
+            IncomeTaxDeclarCollection declareCollection = new IncomeTaxDeclarCollection();
+            Map<String, List<Map<String, Object>>> declareDataMap = null;
+            List<Map<String, Object>> list = new ArrayList<>();
+            Map<String, Object> map = new HashMap<>();
+            map.put("personName", personName);
+            map.put("cardType", cardType);
+            map.put("cardNumber",cardNumber);
+
+            if (declareCollection.size() == 0) {
+                declareCollection.add(new IncomeTaxDeclarInfo());
+            }
+            ApiResponse<AsyncResult> apiResponse = null;
+            ObjectMapper mapper = new ObjectMapper();
+            for (int i = 0; i < declareCollection.size(); i++) {
+                IncomeTaxDeclarInfo incomeTaxDeclarInfo = declareCollection.get(i);
+                //纳税单位
+                //TaxUnitInfo taxUnitInfo = incomeTaxDeclarInfo.getTaxUnit();
+                TaxUnitInfo taxUnitInfo = TaxUnitFactory.getLocalInstance(ctx).getTaxUnitInfo(new ObjectUuidPK("FqEAAACXVqyPHZiq"));
+                //年月
+                //String yearMonth = incomeTaxDeclarInfo.getYearMonth();
+                //反算服务
+                ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
+                //算税请求接口
+                DeclarationRequest declarationRequest = clientProxyFactory.getDeclarationRequest();
+                //获取请求参数
+                //获取请求参数
+                CompanyDeclareRequest declareRequestParameter = getDeclareRequestParameter(taxUnitInfo, declareDataMap, "202408");
+                //申报数据报送
+                apiResponse = declarationRequest.send(declareRequestParameter);
+                logger.error("asyncResultApiResponse-----getCode-------" + apiResponse.getHead().getCode());
+                logger.error("asyncResultApiResponse-----getMsg--------" + apiResponse.getHead().getMsg());
+                if (apiResponse.getHead().getCode().equals("00000000")) {
+                    AsyncResult body = apiResponse.getBody();
+                    String requestId = body.getRequestId();
+                    logger.error("requestId-----" + requestId);
+                    logger.error("apiResponse-----" + mapper.writeValueAsString(apiResponse));
+                    //查询反算反馈结果
+                    ISYUtilsFacade isyUtilsFacade = SYUtilsFacadeFactory.getLocalInstance(ctx);
+                    //backTask(url,requestId,回调osf服务,自定义参数,任务类型)
+                    //isyUtilsFacade.backTask(isyUtilsFacade.getConfig().get("ip") + "/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", jsonObject.toString(), TaskCatalogEnum.CAL_GET);
+                    JSONObject json = new JSONObject();
+                    json.put("requestId", requestId);
+                    //json.put("param", jsonObject.toString());
+                    isyUtilsFacade.addTask("synIncomeTaxDeclareService", json.toJSONString(), TaskCatalogEnum.TAX, "");
+                }
+            }
+            JSONUtils.writeJson(response, mapper.writeValueAsString(apiResponse));
+            logger.error("taxDeclareAction-----end-------");
+
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (EASBizException e) {
+            throw new RuntimeException(e);
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    ///**
+    // * 个税申报
+    // *
+    // * @param request
+    // * @param response
+    // * @param modelMap
+    // */
+    //@Override
+    //public void taxDeclareAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SHRWebException {
+    //    super.taxDeclareAction(request, response, modelMap);
+    //    logger.error("taxDeclareAction-----start-------");
+    //
+    //    Context ctx = SHRContext.getInstance().getContext();
+    //    //个税申报
+    //    String selectedId = request.getParameter("selectedId");
+    //    String sqlInString = CmpUtils.spiltToSqlString(selectedId);
+    //    if (StringUtils.isEmpty(sqlInString)) {
+    //        sqlInString = "''";
+    //    }
+    //    try {
+    //        String oqlBuffer = "select id,yearMonth,totalPerson,totalMoney,taxRebate,declareStatus,versionCode,yearMonthDate,tbType,taxUnit.id,taxUnit.name,taxUnit.taxNumber,taxUnit.regNumber,taxUnit.areaCode,taxUnit.declPassword, batchNo where id in ( " + sqlInString + " )";
+    //        IncomeTaxDeclarCollection declareCollection = IncomeTaxDeclarFactory.getLocalInstance(ctx).getIncomeTaxDeclarCollection(oqlBuffer);
+    //        Map<String, List<Map<String, Object>>> declareDataMap = null;
+    //        if (declareCollection.size() == 0) {
+    //            declareCollection.add(new IncomeTaxDeclarInfo());
+    //        }
+    //        for (int i = 0; i < declareCollection.size(); i++) {
+    //            IncomeTaxDeclarInfo incomeTaxDeclarInfo = declareCollection.get(i);
+    //            //纳税单位
+    //            //TaxUnitInfo taxUnitInfo = incomeTaxDeclarInfo.getTaxUnit();
+    //            TaxUnitInfo taxUnitInfo = TaxUnitFactory.getLocalInstance(ctx).getTaxUnitInfo(new ObjectUuidPK("FqEAAACXVqyPHZiq"));
+    //            //年月
+    //            //String yearMonth = incomeTaxDeclarInfo.getYearMonth();
+    //            //反算服务
+    //            ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
+    //            //算税请求接口
+    //            DeclarationRequest declarationRequest = clientProxyFactory.getDeclarationRequest();
+    //            //获取请求参数
+    //            //获取请求参数
+    //            CompanyDeclareRequest declareRequestParameter = getDeclareRequestParameter(taxUnitInfo, declareDataMap, "202408");
+    //            //申报数据报送
+    //            ApiResponse<AsyncResult> apiResponse = declarationRequest.send(declareRequestParameter);
+    //            logger.error("asyncResultApiResponse-----getCode-------" + apiResponse.getHead().getCode());
+    //            logger.error("asyncResultApiResponse-----getMsg--------" + apiResponse.getHead().getMsg());
+    //            if (apiResponse.getHead().getCode().equals("00000000")) {
+    //                AsyncResult body = apiResponse.getBody();
+    //                String requestId = body.getRequestId();
+    //                logger.error("requestId-----" + requestId);
+    //                //查询反算反馈结果
+    //                ISYUtilsFacade isyUtilsFacade = SYUtilsFacadeFactory.getLocalInstance(ctx);
+    //                //backTask(url,requestId,回调osf服务,自定义参数,任务类型)
+    //                //isyUtilsFacade.backTask(isyUtilsFacade.getConfig().get("ip") + "/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", jsonObject.toString(), TaskCatalogEnum.CAL_GET);
+    //                JSONObject json = new JSONObject();
+    //                json.put("requestId", requestId);
+    //                //json.put("param", jsonObject.toString());
+    //                isyUtilsFacade.addTask("synIncomeTaxDeclareService", json.toJSONString(), TaskCatalogEnum.TAX, "");
+    //            }
+    //        }
+    //        logger.error("taxDeclareAction-----end-------");
+    //
+    //    } catch (IOException e) {
+    //        throw new RuntimeException(e);
+    //    } catch (EASBizException e) {
+    //        throw new RuntimeException(e);
+    //    }
+    //}
+
+    /**
+     * 获取请求参数
+     * 注意:
+     * 1.解除劳动合同一次性补偿金、全年一次性奖金所得,不能单独申报,需要同正常工资薪金一起申报。
+     * 2.解除劳动合同一次性补偿金、稿酬所得,由于税务规则需要,解除劳动合同一次性补偿金、稿酬所得必须填写免税附表。
+     *
+     * @param taxUnitInfo
+     * @param declareDataMap
+     * @param yearMonth
+     * @return
+     */
+    private CompanyDeclareRequest getDeclareRequestParameter(TaxUnitInfo taxUnitInfo,
+                                                             Map<String, List<Map<String, Object>>> declareDataMap,
+                                                             String yearMonth) throws BOSException, SQLException, EASBizException {
+        CompanyDeclareRequest declareRequestPara = new CompanyDeclareRequest();
+        //随机id
+        String bizNo = UUID.randomUUID().toString();
+        logger.error("bizNo:" + bizNo);
+        //外部业务订单号*
+        declareRequestPara.setBizNo(bizNo);
+        //企业名称*
+        declareRequestPara.setName(taxUnitInfo.getName());
+        //税号*
+        declareRequestPara.setTaxNo(taxUnitInfo.getTaxNumber());
+        //行政区划代码*
+        declareRequestPara.setArea(taxUnitInfo.getAreaCode());
+        //登记序号
+        declareRequestPara.setRegistrationNumber(taxUnitInfo.getRegNumber());
+        //部门编号
+        //declareRequestPara.setDeptNo("");
+        //部门名称
+        //declareRequestPara.setDeptName("");
+        //税款所属期YYYYMM*
+        declareRequestPara.setMonth(yearMonth);
+        //实名账号
+        //declareRequestPara.setRealNameAccount();
+        //实名密码
+        //declareRequestPara.setRealNamePassword();
+        //加密实名密码
+        //declareRequestPara.setEncryptedRealNamePassword();
+        //申报密码
+        //declareRequestPara.setDeclarePassword("Aa123456");
+        String declPassword = taxUnitInfo.getDeclPassword();
+        if (StringUtils.isEmpty(declPassword)) {
+            throw new BOSException("申报密码不能为空!");
+        }
+        declareRequestPara.setDeclarePassword(Base64Utils.decode(declPassword));
+        //加密申报密码
+        //taxRequestPara.setEncryptedDeclarePassword();
+        //密码类型*
+        declareRequestPara.setPasswordType("0");
+        //离职日期处理策略 1、不传或传1,代表离职日期自动清空,即人员状态由“非正常”变更为“正常”时,离职日期字段自动清空,默认逻辑。
+        //2、传2离职日期不自动清空,即人员状态由“非正常”变更为“正常”时,离职日期不自动清空,客户如需清空需对离职日期字段传入空字符串。
+        //declareRequestPara.setResignDateStrategy();
+        //企业员工列表
+        List<DetailCompanyEmployee> companyEmployeeList = getCompanyEmployeeList();
+        declareRequestPara.setCompanyEmployeeList(companyEmployeeList);
+        //综合所得
+        //综合所得对象
+        ComplexIncomeRequest complexIncomeRequest = new ComplexIncomeRequest();
+        //纳税人次
+        //complexIncomeRequest.setTaxCount();
+        //应扣缴税额
+        //complexIncomeRequest.setRefundTax();
+        //减免方式
+        //complexIncomeRequest.setDeductionMode();
+        //减免比例
+        //complexIncomeRequest.setRatio();
+        //减免限额
+        //complexIncomeRequest.setLimitAmount();
+        ////正常工资薪金对象
+        //NormalSalarySpecIncome normalSalarySpecIncome = getNormalSalarySpecIncome(declareDataMap);
+        //complexIncomeRequest.setNormalSalarySpecIncome(normalSalarySpecIncome);
+        //全年一次性奖金收入列表
+        //List<ComplexIncome> annualOneTimeBonusIncomeList = getAnnualOneTimeBonusIncomeList(declareDataMap);
+        //List<ComplexIncome> annualOneTimeBonusIncomeList = new ArrayList();
+        //ComplexIncome annualOneTimeBonusIncome = getAnnualOneTimeBonusIncome();
+        //annualOneTimeBonusIncomeList.add(annualOneTimeBonusIncome);
+        //complexIncomeRequest.setAnnualOneTimeBonusIncome(annualOneTimeBonusIncomeList);
+        //一般劳务报酬所得列表
+        //List<ComplexIncome> laborRemunerationIncome = getLaborRemunerationIncome(declareDataMap);
+        ////解除劳动合同一次性补偿金列表
+        //List<ComplexIncome> compensateIncome = getCompensateIncome(declareDataMap);
+        //complexIncomeRequest.setCompensateIncome(compensateIncome);
+        //测试 正常工资薪金对象
+        NormalSalarySpecIncome normalSalarySpecIncome = getNormalSalarySpecIncomes();
+        complexIncomeRequest.setNormalSalarySpecIncome(normalSalarySpecIncome);
+        //测试 全年一次性奖金
+        List<ComplexIncome> annualOneTimeBonusIncome = getAnnualOneTimeBonusIncomes();
+        complexIncomeRequest.setAnnualOneTimeBonusIncome(annualOneTimeBonusIncome);
+        ////测试 一般劳务报酬所得列表
+        //List<ComplexIncome> laborRemunerationIncome = getLaborRemunerationIncomes();
+        //complexIncomeRequest.setLaborRemunerationIncome(laborRemunerationIncome);
+
+        declareRequestPara.setComplexIncomeRequest(complexIncomeRequest);
+        return declareRequestPara;
+    }
+
+    /**
+     * 获取一般劳务报酬所得
+     * taxItemPlanName  个税项目名称
+     * cmpschemeid 计算规则ID
+     *
+     * @return
+     */
+    public List<ComplexIncome> getLaborRemunerationIncomes() {
+        List<ComplexIncome> complexIncomeList = new ArrayList();
+        ComplexIncome complexIncome = new ComplexIncome();
+        //姓名
+        complexIncome.setName(personName);
+        //证照类型
+        complexIncome.setLicenseType(cardType);
+        complexIncome.setLicenseNumber(cardNumber);
+        //税后收入额
+        complexIncome.setAbroadIncome(new BigDecimal("123123"));
+        //收入额
+        complexIncome.setIncome(new BigDecimal("10000"));
+        //所得项目名称
+        complexIncome.setIncomeItemName("一般劳务报酬所得");
+        complexIncomeList.add(complexIncome);
+        return complexIncomeList;
+    }
+
+    /**
+     * 获取全年一次性奖金
+     * taxItemPlanName  个税项目名称
+     * cmpschemeid 计算规则ID
+     *
+     * @return
+     */
+    public List<ComplexIncome> getAnnualOneTimeBonusIncomes() {
+        List<ComplexIncome> complexIncomeList = new ArrayList();
+        ComplexIncome complexIncome = new ComplexIncome();
+        //姓名
+        complexIncome.setName(personName);
+        //证照类型
+        complexIncome.setLicenseType(cardType);
+        complexIncome.setLicenseNumber(cardNumber);
+        //税后收入额
+        complexIncome.setAbroadIncome(new BigDecimal("123123"));
+        //收入额
+        complexIncome.setIncome(new BigDecimal("10000"));
+        //所得项目名称
+        complexIncome.setIncomeItemName("全年一次性奖金收入");
+        complexIncomeList.add(complexIncome);
+        return complexIncomeList;
+    }
+
+    /**
+     * 企业员工列表*
+     *
+     * @return
+     */
+    private List<DetailCompanyEmployee> getCompanyEmployeeList() {
+        List<DetailCompanyEmployee> companyEmployeeList = new ArrayList<DetailCompanyEmployee>();
+        //获取人员数据
+        DetailCompanyEmployee detailCompanyEmployee = getDetailCompanyEmployee();
+        companyEmployeeList.add(detailCompanyEmployee);
+        return companyEmployeeList;
+    }
+
+    /**
+     * 解除劳动合同一次性补偿金列表
+     *
+     * @param caluDataMap
+     * @return
+     */
+    private List<ComplexIncome> getCompensateIncome(
+            Map<String, List<Map<String, Object>>> caluDataMap) {
+        List<ComplexIncome> compensateIncome = new ArrayList<ComplexIncome>();
+        List<Map<String, Object>> list = caluDataMap.get("jcldhtlb");
+        for (int i = 0; list != null && i < list.size(); i++) {
+            //个税应用+税款计算初算明细表
+            Map<String, Object> map = list.get(i);
+            ComplexIncome complexIncome = new ComplexIncome();
+            //姓名*
+            complexIncome.setName((String) map.get("personName"));
+            //证件类型名称*
+            complexIncome.setLicenseType((String) map.get("cardType"));
+            //证件号码*
+            complexIncome.setLicenseNumber((String) map.get("cardNumber"));
+            //todo 是否自动生成免税附表
+            complexIncome.setIsAutoGenerateExempt("是");
+            //当期收入额*
+            complexIncome.setIncome((BigDecimal) map.get("t39"));
+            //免税收入
+            complexIncome.setExemptIncome((BigDecimal) map.get("t2"));
+            //其他
+            //complexIncome.setOther(BigDecimal.ZERO);
+            //减免税额      无
+            complexIncome.setTaxDeduction((BigDecimal) map.get("t17"));
+            //备注
+            //complexIncome.setRemark("");
+            //所得项目名称*
+            complexIncome.setIncomeItemName("解除劳动合同一次性补偿金");
+            //准予扣除的捐赠额      无
+            complexIncome.setDeductibleDonation((BigDecimal) map.get("t16"));
+            compensateIncome.add(complexIncome);
+        }
+        return compensateIncome;
+    }
+
+    /**
+     * 一般劳务报酬所得列表
+     *
+     * @param caluDataMap
+     * @return
+     */
+    private List<ComplexIncome> getLaborRemunerationIncome(Map<String, List<Map<String, Object>>> caluDataMap) {
+        List<ComplexIncome> laborRemunerationIncome = new ArrayList<>();
+        List<Map<String, Object>> list = caluDataMap.get("lwbclb");
+        for (int i = 0; list != null && i < list.size(); i++) {
+            Map<String, Object> map = list.get(i);
+            ComplexIncome complexIncome = new ComplexIncome();
+            //姓名*
+            complexIncome.setName((String) map.get("personName"));
+            //证件类型名称*
+            complexIncome.setLicenseType((String) map.get("cardType"));
+            //证件号码*
+            complexIncome.setLicenseNumber((String) map.get("cardNumber"));
+            //是否明细申报
+            //complexIncome.setIsDetailedDeclaration("");
+            //当期收入额*
+            complexIncome.setIncome((BigDecimal) map.get("t1"));
+            //免税收入
+            complexIncome.setExemptIncome((BigDecimal) map.get("t2"));
+            //商业健康保险
+            complexIncome.setCommercialHealthInsurance((BigDecimal) map.get("t13"));
+            //税延养老保险
+            complexIncome.setExtensionEndowmentInsurance((BigDecimal) map.get("t14"));
+            //其他
+            //complexIncome.setOther(BigDecimal.ZERO);
+            //减免税额
+            complexIncome.setTaxDeduction((BigDecimal) map.get("t17"));
+            //备注
+            //complexIncome.setRemark("");
+            //减除费用
+            // complexIncome.setDeductionAmount(BigDecimal.ZERO);
+            //应纳税额
+            //complexIncome.setPayableAmount(BigDecimal.ZERO);
+            //税率
+            //complexIncome.setTaxRate(BigDecimal.ZERO);
+            //所得项目名称*
+            complexIncome.setIncomeItemName("一般劳务报酬所得");
+            //允许扣除的税费
+            complexIncome.setTaxDeductible((BigDecimal) map.get("t18"));
+            laborRemunerationIncome.add(complexIncome);
+        }
+        return laborRemunerationIncome;
+    }
+
+    /**
+     * 获取全年一次性奖金
+     * taxItemPlanName  个税项目名称
+     * cmpschemeid 计算规则ID
+     *
+     * @return
+     */
+    public ComplexIncome getAnnualOneTimeBonusIncome() throws SQLException, BOSException {
+        ComplexIncome complexIncome = new ComplexIncome();
+        //姓名
+        complexIncome.setName(personName);
+        //证照类型
+        complexIncome.setLicenseType(cardType);
+        complexIncome.setLicenseNumber(cardNumber);
+        //税后收入额
+        complexIncome.setAbroadIncome(new BigDecimal("123123"));
+        //收入额
+        complexIncome.setIncome(new BigDecimal("10000"));
+        return complexIncome;
+    }
+
+    /**
+     * 全年一次性奖金收入列表
+     *
+     * @return
+     */
+    private List<ComplexIncome> getAnnualOneTimeBonusIncomeList(
+            Map<String, List<Map<String, Object>>> caluDataMap) {
+        List<ComplexIncome> annualOneTimeBonusIncome = new ArrayList<>();
+        List<Map<String, Object>> list = caluDataMap.get("qnycxjjsslb");
+        for (int i = 0; list != null && i < list.size(); i++) {
+            Map<String, Object> map = list.get(i);
+            ComplexIncome complexIncome = new ComplexIncome();
+            //姓名*
+            complexIncome.setName((String) map.get("personName"));
+            //证件类型名称*
+            complexIncome.setLicenseType((String) map.get("cardType"));
+            //证件号码*
+            complexIncome.setLicenseNumber((String) map.get("cardNumber"));
+            //当期收入额*
+            complexIncome.setIncome((BigDecimal) map.get("t1"));
+            //免税收入
+            complexIncome.setExemptIncome((BigDecimal) map.get("t2"));
+            //其他
+            //complexIncome.setOther(BigDecimal.ZERO);
+            //减免税额
+            complexIncome.setTaxDeduction((BigDecimal) map.get("t17"));
+            //备注
+            //complexIncome.setRemark("");
+            //所得项目名称*
+            complexIncome.setIncomeItemName("全年一次性奖金收入");
+            //准予扣除的捐赠额
+            complexIncome.setDeductibleDonation((BigDecimal) map.get("t16"));
+            annualOneTimeBonusIncome.add(complexIncome);
+        }
+        return annualOneTimeBonusIncome;
+    }
+
+    /**
+     * 获取正常工资薪金对象
+     *
+     * @return
+     */
+    public NormalSalarySpecIncome getNormalSalarySpecIncomes() throws BOSException, EASBizException {
+        //正常工资薪金对象
+        NormalSalarySpecIncome normalSalarySpecIncome = new NormalSalarySpecIncome();
+        //正常工资薪金列表
+        List<ComplexIncome> normalSalarySpec = new ArrayList();
+        ComplexIncome complexIncome = new ComplexIncome();
+        //姓名
+        complexIncome.setName(personName);
+        //证照类型
+        complexIncome.setLicenseType(cardType);
+        complexIncome.setLicenseNumber(cardNumber);
+        //税后收入额
+        complexIncome.setAbroadIncome(new BigDecimal("10000"));
+        //收入额
+        complexIncome.setIncome(new BigDecimal("10000"));
+        //所得项目名称
+        complexIncome.setIncomeItemName("正常工资薪金");
+        normalSalarySpecIncome.setNormalSalarySpec(normalSalarySpec);
+        return normalSalarySpecIncome;
+    }
+
+    /**
+     * 人员
+     *
+     * @return
+     */
+    public DetailCompanyEmployee getDetailCompanyEmployee() {
+
+        //人员对象
+        DetailCompanyEmployee detailCompanyEmployee = new DetailCompanyEmployee();
+        //姓名
+        detailCompanyEmployee.setName(personName);
+        //证照类型
+        detailCompanyEmployee.setLicenseType(cardType);
+        //证照号码
+        detailCompanyEmployee.setLicenseNumber(cardNumber);
+        //人员状态
+        //detailCompanyEmployee.setState(personInfo.getEmployeeType().getName());
+        ////人员报税信息->任职受雇从业信息
+        //ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
+        //TaxPersonRecordEntryCollection taxPersonRecordEntryCollection = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("where person.id = '" + personInfo.getId() + "'");
+        //TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxPersonRecordEntryCollection.get(0);
+        //任职受雇类型  可选择雇员、保险营销员、证券经纪人、其他、实习学生(全日制学历教育)
+        detailCompanyEmployee.setIsEmployee("雇员");
+        //手机号
+        detailCompanyEmployee.setPhone("13333282630");
+        //detailCompanyEmployee.setIsEmployee(taxPersonRecordEntryInfo.getEmployedType().getAlias());
+        //受雇日期  YYYY-MM-DD,不能大于当前时间,任职受雇类型选择雇员、保险营销员、证券经纪人时必录
+        SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
+        detailCompanyEmployee.setEmployedDate("2022-10-02");
+        ////性别
+        detailCompanyEmployee.setGender("女");
+        ////出生日期
+        detailCompanyEmployee.setBirthday("2001-01-01");
+        //国籍 nationality
+        //NationalityInfo nationality = personInfo.getNationality();
+        detailCompanyEmployee.setNationality("中国");
+        return detailCompanyEmployee;
+    }
+
+    /**
+     * 获取正常工资薪金参数
+     *
+     * @return
+     */
+    private NormalSalarySpecIncome getNormalSalarySpecIncome
+    (Map<String, List<Map<String, Object>>> caluDataMap) {
+        //正常工资薪金对象
+        NormalSalarySpecIncome normalSalarySpecIncome = new NormalSalarySpecIncome();
+        //正常工资薪金是否需要专项*
+        //normalSalarySpecIncome.setZcgzxjsfxyzx("");
+        //正常工资薪金是否传入累计(申报/单月计算时使用)
+        //normalSalarySpecIncome.setZcgzxjsfcrlj("");
+        //年金算税上限选项
+        normalSalarySpecIncome.setAnnuityAndHouseProvidentFundOption("");
+        //个人养老金策略
+        normalSalarySpecIncome.setPersonalPensionOption("");
+        //上月个人养老金策略
+        normalSalarySpecIncome.setLastMonthPersonalPensionOption("");
+        List<ComplexIncome> normalSalarySpec = new ArrayList<>();
+        //正常工资薪金(带专项)列表*
+        normalSalarySpecIncome.setNormalSalarySpec(normalSalarySpec);
+        List<Map<String, Object>> list = caluDataMap.get("zcgzxjlb");
+        for (int i = 0; list != null && i < list.size(); i++) {
+            Map<String, Object> map = list.get(i);
+            ComplexIncome complexIncome = new ComplexIncome();
+            //姓名*
+            complexIncome.setName((String) map.get("personName"));
+            //证件类型名称*
+            complexIncome.setLicenseType((String) map.get("cardType"));
+            //证件号码*
+            complexIncome.setLicenseNumber((String) map.get("cardNumber"));
+            //是否明细申报
+            //complexIncome.setIsDetailedDeclaration("");
+            //当期收入额*
+            complexIncome.setIncome((BigDecimal) map.get("t1"));
+            //免税收入
+            complexIncome.setExemptIncome((BigDecimal) map.get("t2"));
+            //基本养老保险
+            complexIncome.setEndowmentInsurance((BigDecimal) map.get("t3"));
+            //基本医疗保险
+            complexIncome.setMedicalInsurance((BigDecimal) map.get("t4"));
+            //失业保险
+            complexIncome.setUnemploymentInsurance((BigDecimal) map.get("t5"));
+            //住房公积金
+            complexIncome.setHouseProvidentFund((BigDecimal) map.get("t6"));
+            //子女教育支出
+            complexIncome.setChildEducationExpenditure((BigDecimal) map.get("t64"));
+            //赡养老人支出
+            complexIncome.setSupportElderExpenditure((BigDecimal) map.get("t65"));
+            //住房租金支出
+            complexIncome.setHouseRentExpenditure((BigDecimal) map.get("t67"));
+            //房屋贷款支出
+            complexIncome.setHouseLoanExpenditure((BigDecimal) map.get("t66"));
+            //继续教育支出
+            complexIncome.setContinueEducationExpenditure((BigDecimal) map.get("t68"));
+            //婴幼儿照护支出
+            complexIncome.setBabyCareExpenditure((BigDecimal) map.get("t70"));
+            //todo 企业年金/职业年金
+            complexIncome.setAnnuity(BigDecimal.ZERO);
+            //商业健康保险
+            complexIncome.setCommercialHealthInsurance((BigDecimal) map.get("t13"));
+            //税延养老保险
+            complexIncome.setExtensionEndowmentInsurance((BigDecimal) map.get("t14"));
+            //其他
+            complexIncome.setOther(BigDecimal.ZERO);
+            //减免税额
+            complexIncome.setTaxDeduction(BigDecimal.ZERO);
+            //备注 根据政策要求,填写【其他】项,一定在备注中写明具体扣除项目名称
+            complexIncome.setRemark("");
+            //应纳税额
+            complexIncome.setPayableAmount(BigDecimal.ZERO);
+            //已缴税额
+            complexIncome.setPaidAmount(BigDecimal.ZERO);
+            //税率
+            complexIncome.setTaxRate(BigDecimal.ZERO);
+            //所得项目名称
+            complexIncome.setIncomeItemName("正常工资薪金");
+            //累计收入额 本年累计收入=本期所有的工资薪金所得收入之和+往期工资薪金所得收入之和(见税款计算)
+            complexIncome.setAccumulatedIncome(BigDecimal.ZERO);
+            //累计专项扣除额
+            complexIncome.setAccumulatedSpecDeduction(BigDecimal.ZERO);
+            //累计其他扣除额
+            complexIncome.setAccumulatedOtherDeduction(BigDecimal.ZERO);
+            //累计减除费用额
+            complexIncome.setAccumulatedDeductionAmount(BigDecimal.ZERO);
+            //累计子女教育支出
+            complexIncome.setAccumulatedChildEducation(BigDecimal.ZERO);
+            //累计继续教育支出
+            complexIncome.setAccumulatedContinueEducation(BigDecimal.ZERO);
+            //累计住房租金支出
+            complexIncome.setAccumulatedHouseRent(BigDecimal.ZERO);
+            //累计房屋贷款支出
+            complexIncome.setAccumulatedHouseLoan(BigDecimal.ZERO);
+            //累计赡养老人支出
+            complexIncome.setAccumulatedSupportElder(BigDecimal.ZERO);
+            //累计3岁以下婴幼儿照护支出
+            complexIncome.setAccumulatedBabyCare(BigDecimal.ZERO);
+            //累计准予扣除的捐赠额
+            complexIncome.setAccumulatedDeductibleDonation(BigDecimal.ZERO);
+            //累计个人养老金
+            complexIncome.setAccumulatedPersonalPension(BigDecimal.ZERO);
+            //累计个人养老金校验码
+            complexIncome.setAccumulatedPersonalPensionCheckCode("");
+            //准予扣除的捐赠额
+            complexIncome.setDeductibleDonation(BigDecimal.ZERO);
+            //试用公式
+            complexIncome.setFormula("");
+            //境内工作天数
+            complexIncome.setDomesticWorkingDays(BigDecimal.ZERO);
+            //境外工作天数
+            complexIncome.setAbroadWorkingDays(BigDecimal.ZERO);
+            //境外支付
+            complexIncome.setAbroadIncome(BigDecimal.ZERO);
+            //境内支付
+            complexIncome.setDomesticIncome(BigDecimal.ZERO);
+            normalSalarySpec.add(complexIncome);
+        }
+        return normalSalarySpecIncome;
+    }
+
+    /**
+     * 获取企业人员列表
+     */
+    private List<DetailCompanyEmployee> getCompanyEmployeeList(Map<String, List<Map<String, Object>>> caluDataMap) {
+        List<DetailCompanyEmployee> companyEmployeeList = new ArrayList<>();
+        List<Map<String, Object>> list = caluDataMap.get("zcgzxjlb");
+        for (int i = 0; list != null && i < list.size(); i++) {
+            Map<String, Object> map = list.get(i);
+            DetailCompanyEmployee employee = new DetailCompanyEmployee();
+            //姓名*
+            employee.setName((String) map.get("personName"));
+            //证件类型名称*
+            employee.setLicenseType((String) map.get("cardType"));
+            //证件号码*
+            employee.setLicenseNumber((String) map.get("cardNumber"));
+            //部门编号
+            //employee.setDeptNo("");
+            //工号
+            employee.setEmployeeNumber((String) map.get("personNumber"));
+            //所属期
+            //employee.setPeriod("");
+            //手机号码  中国籍必填;非中国籍首次入境时间超过一个月必填;
+            employee.setPhone((String) map.get("phoneNumber"));
+            //人员状态* 默认为正常,可选择正常/非正常
+            employee.setState((String) map.get("personstatusName"));
+            //是否雇员* 可选择雇员、保险营销员、证券经纪人、其他、实习学生(全日制学历教育)
+            employee.setIsEmployee((String) map.get("employedtypeName"));
+            //入职年度就业情况  当雇员保险营销员、证券经纪人时可选择:当年首次入职学生、当年首次入职其他人员。其他情况下填写默认为空
+            employee.setFirstEmploymentSituation((String) map.get("situationName"));
+            //受雇日期
+            employee.setEmployedDate((String) map.get("employeddate"));
+            //性别*   男/女
+            employee.setGender((String) map.get("gender"));
+            //出生日期* YYYY-MM-DD 需要和身份证上保持一致
+            employee.setBirthday((String) map.get("birthday"));
+            //国籍*
+            employee.setNationality((String) map.get("nationalityName"));
+            //人员地区* 境内/境外
+            employee.setArea((String) map.get("isoversea"));
+            //离职日期
+            employee.setResignDate((String) map.get("departuredate"));
+            //个人投资总额
+            employee.setPersonInvestment((BigDecimal) map.get("investmenttotal"));
+            //个人投资比例
+            employee.setPersonInvestmentRatio((BigDecimal) map.get("investmentrate"));
+            //是否残疾
+            String isdisability = (String) map.get("isdisability");
+            employee.setIsDisabled(isdisability);
+            if ("是".equals(isdisability)) {
+                //todo 残疾证件类型
+                employee.setDisableCardTypeName("残疾证");
+            }
+            //是否烈属
+            employee.setIsMartyr((String) map.get("ishero"));
+            //是否孤老
+            employee.setIsBereavedGaffer((String) map.get("isold"));
+            //残疾证号
+            employee.setDisableCardNumber((String) map.get("discardnumber"));
+            //烈属证号
+            employee.setMartyrCardNumber((String) map.get("herocardnumber"));
+            //电子邮箱
+            employee.setEmail((String) map.get("email"));
+            //学历
+            employee.setEducation((String) map.get("diploma"));
+            //职务
+            employee.setPosition((String) map.get("positionName"));
+            //开户银行省份(名字)
+            employee.setDepositBankProvinceName((String) map.get("bankcardprovince"));
+            //开户银行
+            employee.setDepositBank((String) map.get("bankcardprovince"));
+            //银行账号
+            employee.setBankAccount((String) map.get("account"));
+            //居住省份
+            employee.setResidentProvince((String) map.get("address"));
+            //居住城市
+            employee.setResidentCity((String) map.get("addresscity"));
+            //居住区县
+            employee.setResidentDistrict((String) map.get("addresscounty"));
+            //居住街道
+            employee.setResidentStreet((String) map.get("addressstreet"));
+            //户籍省份
+            employee.setCensusProvince((String) map.get("hometown"));
+            //户籍城市
+            employee.setCensusCity((String) map.get("hometowncity"));
+            //户籍区县
+            employee.setCensusDistrict((String) map.get("hometowncountry"));
+            //户籍街道
+            employee.setCensusStreet((String) map.get("hometownstreet"));
+            //户籍详细地址
+            employee.setCensusAddress((String) map.get("hometowndetailed"));
+            //备注
+            employee.setEmpRemark((String) map.get("desc"));
+            //出生地
+            employee.setBirthplace((String) map.get("birthplaceName"));
+            //首次入境时间
+            employee.setFirstEntryDate((String) map.get("entrydate"));
+            //预计离境时间
+            employee.setEstimatedDepartureDate((String) map.get("leavedate"));
+            //联系地省份
+            employee.setContactProvince((String) map.get("contactaddress"));
+            //联系地城市
+            employee.setContactCity((String) map.get("contactcity"));
+            //联系地区县
+            employee.setContactDistrict((String) map.get("contactcountry"));
+            //联系地街道
+            employee.setContactStreet((String) map.get("contactstreet"));
+            //联系地详细地址
+            employee.setContactStreet((String) map.get("contactdetailed"));
+            //中文名
+            employee.setChineseName((String) map.get("chinesename"));
+            //涉税事项
+            employee.setTaxRelatedReason((String) map.get("taxreason"));
+            //其他证件号码
+            employee.setOtherLicenseNumber((String) map.get("othercardnumber"));
+            //其他证件类型    其他证件类型为:外国人永久居留身份证(外国人永久居留证),外国护照,中华人民共和国外国人工作许可证(A类),中华人民共和国外国人工作许可证(B类),中华人民共和国外国人工作许可证(C类),中华人民共和国港澳居民居住证,中华人民共和国台湾居民居住证,中国护照,港澳居民来往内地通行证,台湾居民来往大陆通行证,其他证件号码必填
+            employee.setOtherLicenseType((String) map.get("othercardtype"));
+            //是否扣除减除费用(原是否主单位)
+            employee.setIsMainUnits((String) map.get("deductfees"));
+            companyEmployeeList.add(employee);
+        }
+        return companyEmployeeList;
+    }
+}

+ 81 - 0
websrc/com/kingdee/eas/custom/compensation/service/SynIncomeTaxDeclareService.java

@@ -0,0 +1,81 @@
+package com.kingdee.eas.custom.compensation.service;
+
+import cn.com.servyou.dto.ApiResponse;
+import cn.com.servyou.dto.declare.Feedback;
+import cn.com.servyou.rmi.client.ClientProxyFactory;
+import cn.com.servyou.service.DeclarationRequest;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.bsf.service.app.IHRMsfService;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoFactory;
+import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoInfo;
+import com.kingdee.eas.custom.shuiyou.task.MessageResult;
+import com.kingdee.eas.custom.shuiyou.utils.ClientProxyFactoryUtils;
+import org.apache.log4j.Logger;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author qingwu
+ * @date 2024/9/19
+ * @apiNote
+ */
+public class SynIncomeTaxDeclareService implements IHRMsfService {
+    Logger logger = Logger.getLogger("com.kingdee.eas.custom.compensation.service.SynIncomeTaxDeclareService");
+
+    public Object process(Context context, Map map) throws EASBizException, BOSException {
+        //接口日志实体
+        LogInfoInfo logInfo = new LogInfoInfo();
+        //入口
+        logInfo.setEntrance(this.getClass().getName());
+        logInfo.setBizDate(new Date());
+        Map resMap = new HashMap();
+        logger.error("SynIncomeTaxDeclareService----------OSF----Start");
+        JSONObject paramData = JSONObject.parseObject((String) map.get("paramData"));
+        logger.error("paramData--------" + paramData);
+        String requestId = paramData.getString("requestId");
+        //JSONObject param = paramData.getJSONObject("param");
+        logger.error("requestId--------" + requestId);
+        //logger.error("param--------" + param);
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            //客户端代理工厂
+            ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
+            //算税请求接口
+            DeclarationRequest declarationRequest = clientProxyFactory.getDeclarationRequest();
+            //申报数据反馈  requestId:请求Id   reportType:申报所得类型[1:综合所得;2:分类所得;3:非居民所得;4:限售股所得]
+            ApiResponse<Feedback> feedback = declarationRequest.getFeedback(requestId, "1");
+            logInfo.setInterfaceAddress("/gateway/iit/report/getFeedback");//接口地址
+            logInfo.setInterfaceName("getFeedback");//接口名
+            logger.error("feedback--------" + mapper.writeValueAsString(feedback));
+            String status = feedback.getHead().getStatus();
+            Feedback body = null;
+            if ("N".equals(status)) {
+                //请求失败响应
+                String msg = feedback.getHead().getMsg();
+                //throw new BOSException(msg);
+                return MessageResult.FAILED(msg);
+            } else {
+                //调用成功
+                //请求id
+                body = feedback.getBody();
+                logInfo.setOutParameter(mapper.writeValueAsString(body));//回参
+                LogInfoFactory.getLocalInstance(context).addnew(logInfo);
+            }
+            return MessageResult.SUCCESS(mapper.writeValueAsString(body));
+        } catch (IOException e) {
+            e.printStackTrace();
+            logInfo.setErrorInfo(e.getMessage());//错误信息
+            LogInfoFactory.getLocalInstance(context).save(logInfo);
+            //throw new BOSException(e);
+            return MessageResult.ERROR(e.getMessage());
+        }
+    }
+
+}

+ 210 - 0
websrc/com/kingdee/eas/custom/compensation/service/SynIndividualIncomeTaxService.java

@@ -0,0 +1,210 @@
+package com.kingdee.eas.custom.compensation.service;
+
+import cn.com.servyou.dto.ApiResponse;
+import cn.com.servyou.dto.tax.CalculateTaxResultRequest;
+import cn.com.servyou.dto.tax.ComplexIncome;
+import cn.com.servyou.dto.tax.ComplexIncomeResultRequest;
+import cn.com.servyou.dto.tax.ComplexTaxCalculateResult;
+import cn.com.servyou.rmi.client.ClientProxyFactory;
+import cn.com.servyou.service.TaxRequest;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.bsf.service.app.IHRMsfService;
+import com.kingdee.bos.dao.IObjectPK;
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.metadata.entity.EntityViewInfo;
+import com.kingdee.bos.metadata.entity.FilterInfo;
+import com.kingdee.bos.metadata.entity.FilterItemInfo;
+import com.kingdee.bos.metadata.query.util.CompareType;
+import com.kingdee.eas.basedata.person.IPerson;
+import com.kingdee.eas.basedata.person.PersonCollection;
+import com.kingdee.eas.basedata.person.PersonFactory;
+import com.kingdee.eas.basedata.person.PersonInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.individualback.*;
+import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoFactory;
+import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoInfo;
+import com.kingdee.eas.custom.shuiyou.task.MessageResult;
+import com.kingdee.eas.custom.shuiyou.utils.ClientProxyFactoryUtils;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.compensation.CalSchemeFactory;
+import com.kingdee.util.StringUtils;
+import org.apache.log4j.Logger;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author qingwu
+ * @date 2024/9/9
+ * @apiNote
+ */
+public class SynIndividualIncomeTaxService implements IHRMsfService {
+    Logger logger = Logger.getLogger("com.kingdee.eas.custom.compensation.service.SynIndividualIncomeTaxService");
+
+    @Override
+    public Object process(Context context, Map map) throws EASBizException, BOSException {
+        //接口日志实体
+        LogInfoInfo logInfo = new LogInfoInfo();
+        //入口
+        logInfo.setEntrance(this.getClass().getName());
+        logInfo.setBizDate(new Date());
+        Map resMap = new HashMap();
+        logger.error("SynIndividualIncomeTaxService----------OSF----Start");
+        JSONObject paramData = JSONObject.parseObject((String) map.get("paramData"));
+        logger.error("paramData--------" + paramData);
+        String requestId = paramData.getString("requestId");
+        JSONObject param = paramData.getJSONObject("param");
+        logger.error("requestId--------" + requestId);
+        logger.error("param--------" + param);
+        try {
+            //客户端代理工厂
+            ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
+            //算税请求接口
+            TaxRequest taxRequest = clientProxyFactory.getTaxRequest();
+            ApiResponse<CalculateTaxResultRequest> aSynIndividualIncomeTaxFeedback = taxRequest.getReverseASynIndividualIncomeTaxFeedback(requestId);
+            String status = aSynIndividualIncomeTaxFeedback.getHead().getStatus();
+            logInfo.setInterfaceAddress("/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback");//接口地址
+            logInfo.setInterfaceName("getASynIndividualIncomeTaxFeedback");//接口名
+            ObjectMapper mapper = new ObjectMapper();
+            logInfo.setInParameter(mapper.writeValueAsString(aSynIndividualIncomeTaxFeedback));//入参
+            CalculateTaxResultRequest body = null;
+            if ("N".equals(status)) {
+                //请求失败响应
+                String msg = aSynIndividualIncomeTaxFeedback.getHead().getMsg();
+                //throw new BOSException(msg);
+                return MessageResult.FAILED(msg);
+            } else {
+                //调用成功
+                //请求id
+                body = aSynIndividualIncomeTaxFeedback.getBody();
+                logInfo.setOutParameter(mapper.writeValueAsString(body));//回参
+                LogInfoFactory.getLocalInstance(context).addnew(logInfo);
+                disposeTaxPaymentBackCalculate(context, body, param);
+            }
+            logger.error("SynIndividualIncomeTaxService----------OSF----end");
+            return MessageResult.SUCCESS(mapper.writeValueAsString(body));
+        } catch (IOException e) {
+            e.printStackTrace();
+            logInfo.setErrorInfo(e.getMessage());//错误信息
+            LogInfoFactory.getLocalInstance(context).save(logInfo);
+            //throw new BOSException(e);
+            return MessageResult.ERROR(e.getMessage());
+        }
+    }
+
+    /**
+     * 处理个税反算数据
+     *
+     * @param resBody 查询反算反馈结果接口返回结果
+     * @param param   员工ID
+     * @return
+     */
+    public void disposeTaxPaymentBackCalculate(Context ctx, CalculateTaxResultRequest resBody, com.alibaba.fastjson.JSONObject param) throws BOSException, EASBizException {
+        logger.error("addTaxPaymentBackCalculate============Start===============");
+        ITaxPaymentBackCalculate iTaxPaymentBackCalculate = TaxPaymentBackCalculateFactory.getLocalInstance(ctx);
+
+        String taxItemPlanNumber = param.getString("taxItemPlanNumber");//个税项目方案
+
+        ComplexTaxCalculateResult complexTaxCalculateResult = null;
+        //zhsd   综合所得
+        ComplexIncomeResultRequest complexIncomeResultRequest = resBody.getComplexIncomeResultRequest();
+        //全年一次性奖金
+        if ("2024083001".equals(taxItemPlanNumber)) {
+            //qnycxjjsslb  全年一次性奖金
+            complexTaxCalculateResult = complexIncomeResultRequest.getAnnualOneTimeBonusIncome();
+        }
+        //一般劳务报酬所得列表
+        if ("2024083003".equals(taxItemPlanNumber)) {
+            //lwbclb  一般劳务报酬所得列表
+            complexTaxCalculateResult = complexIncomeResultRequest.getLaborRemunerationIncome();
+        }
+        //正常工资薪金对象
+        if ("2024083004".equals(taxItemPlanNumber)) {
+            //zcgzxj  正常工资薪金对象
+            complexTaxCalculateResult = complexIncomeResultRequest.getNormalSalarySpecIncome();
+        }
+        IPerson iPerson = PersonFactory.getLocalInstance(ctx);
+        List<ComplexIncome> successComplexIncomes = complexTaxCalculateResult.getSuccessComplexIncomes();
+        for (ComplexIncome complexIncome : successComplexIncomes) {
+            //证件类型
+            String licenseType = complexIncome.getLicenseType();
+            PersonInfo personInfo = null;
+            if ("居民身份证".equals(licenseType)) {
+                //证件号码
+                String licenseNumber = complexIncome.getLicenseNumber();
+                PersonCollection personCollection = iPerson.getPersonCollection("where idCardNO = '" + licenseNumber + "'");
+                if (personCollection.size() > 0) {
+                    personInfo = personCollection.get(0);
+
+                }
+            }
+            if ("中国护照".equals(licenseType)) {
+                //证件号码
+                String licenseNumber = complexIncome.getLicenseNumber();
+                PersonCollection personCollection = iPerson.getPersonCollection("where passportNO = '" + licenseNumber + "'");
+                if (personCollection.size() > 0) {
+                    personInfo = personCollection.get(0);
+                }
+            }
+            param.put("personId", personInfo.getId());
+            saveTaxPaymentBackCalculateCollection(ctx, param, complexIncome);
+        }
+        logger.error("addTaxPaymentBackCalculate============end===============");
+    }
+
+    public String getParamContent(String requestId) {
+        return "select CFParamContent as paramContent  from CT_TK_TaskRequestParam where CFTaskID in (select FID from CT_TK_Task where CFRequestId = '" + requestId + "')";
+    }
+
+    public TaxPaymentBackCalculateCollection saveTaxPaymentBackCalculateCollection(Context ctx, JSONObject param, ComplexIncome complexIncome) throws BOSException, EASBizException {
+        TaxPaymentBackCalculateInfo taxPaymentBackCalculateInfo = new TaxPaymentBackCalculateInfo();
+        String personId = param.getString("personId");//员工ID
+        String periodYear = param.getString("periodYear");//统计年
+        String periodMonth = param.getString("periodMonth");//统计月
+        String cmpschemeid = param.getString("cmpschemeid");//计算规则ID
+        String taxItemPlanName = param.getString("taxItemPlanName");//个税项目方案
+        String taxItemPlanNumber = param.getString("taxItemPlanNumber");//个税项目方案
+
+        FilterInfo filterInfo = new FilterInfo();
+        filterInfo.getFilterItems().add(new FilterItemInfo("person", personId, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("periodMonth", periodMonth, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("periodYear", periodYear, CompareType.EQUALS));
+        filterInfo.getFilterItems().add(new FilterItemInfo("cmpscheme", cmpschemeid, CompareType.EQUALS));
+        EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
+        ////查询税款反算表是否存在该数据
+        ITaxPaymentBackCalculate iTaxPaymentBackCalculate = TaxPaymentBackCalculateFactory.getLocalInstance(ctx);
+        TaxPaymentBackCalculateCollection taxPaymentBackCalculateCollection = iTaxPaymentBackCalculate.getTaxPaymentBackCalculateCollection(entityViewInfo);
+        if (taxPaymentBackCalculateCollection.size() > 0) {
+            taxPaymentBackCalculateInfo = taxPaymentBackCalculateCollection.get(0);
+            taxPaymentBackCalculateInfo.setId(taxPaymentBackCalculateCollection.get(0).getId());
+        }
+        //员工
+        taxPaymentBackCalculateInfo.setPerson(PersonFactory.getLocalInstance(ctx).getPersonInfo(new ObjectUuidPK(personId)));
+        //统计年
+        taxPaymentBackCalculateInfo.setPeriodYear(periodYear);
+        //统计月
+        taxPaymentBackCalculateInfo.setPeriodMonth(periodMonth);
+        //计算规则
+        taxPaymentBackCalculateInfo.setCmpscheme(CalSchemeFactory.getLocalInstance(ctx).getCalSchemeInfo(new ObjectUuidPK(cmpschemeid)));
+        //个税项目方案
+        taxPaymentBackCalculateInfo.setTaxItemPlan(taxItemPlanName);
+        //sre  收入额
+        BigDecimal income = complexIncome.getIncome();
+        taxPaymentBackCalculateInfo.setSalarySum(income);
+        //ybtse refundTax  应补退税额
+        BigDecimal refundTax = complexIncome.getRefundTax();
+        taxPaymentBackCalculateInfo.setIndividual(refundTax);
+        IObjectPK save = iTaxPaymentBackCalculate.save(taxPaymentBackCalculateInfo);
+        return taxPaymentBackCalculateCollection;
+    }
+}

+ 32 - 0
websrc/com/kingdee/eas/custom/compensation/vo/TaxUnitAndPerson.java

@@ -0,0 +1,32 @@
+package com.kingdee.eas.custom.compensation.vo;
+
+/**
+ * @author qingwu
+ * @date 2024/9/13
+ * @apiNote
+ */
+public class TaxUnitAndPerson {
+    private  String taxunitId;
+    private  String personId;
+
+    public TaxUnitAndPerson(String taxunitId, String personId) {
+        this.taxunitId = taxunitId;
+        this.personId = personId;
+    }
+
+    public String getTaxunitId() {
+        return taxunitId;
+    }
+
+    public String getPersonId() {
+        return personId;
+    }
+
+    public void setTaxunitId(String taxunitId) {
+        this.taxunitId = taxunitId;
+    }
+
+    public void setPersonId(String personId) {
+        this.personId = personId;
+    }
+}

+ 315 - 0
websrc/com/kingdee/eas/custom/individualback/TaxPersonRecordListHandlerExEx.java

@@ -0,0 +1,315 @@
+package com.kingdee.eas.custom.individualback;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.ctrl.swing.StringUtils;
+import com.kingdee.bos.dao.IObjectPK;
+import com.kingdee.bos.metadata.entity.EntityViewInfo;
+import com.kingdee.bos.metadata.entity.FilterInfo;
+import com.kingdee.bos.metadata.entity.FilterItemInfo;
+import com.kingdee.bos.metadata.entity.SelectorItemCollection;
+import com.kingdee.bos.metadata.query.util.CompareType;
+import com.kingdee.eas.basedata.person.IPerson;
+import com.kingdee.eas.basedata.person.PersonCollection;
+import com.kingdee.eas.basedata.person.PersonFactory;
+import com.kingdee.eas.basedata.person.PersonInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.shuiyou.six.handler.TaxPersonRecordListHandlerEx;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
+import com.kingdee.shr.compensation.*;
+import com.kingdee.shr.compensation.app.incomeTax.*;
+import com.kingdee.shr.compensation.app.tax.ITaxUnit;
+import com.kingdee.shr.compensation.app.tax.TaxUnitFactory;
+import com.kingdee.shr.compensation.app.tax.TaxUnitInfo;
+import com.kingdee.shr.compensation.web.handler.incometax.TaxPersonRecordListHandler;
+import org.apache.log4j.Logger;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.SQLException;
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
+/**
+ * @author qingwu
+ * @date 2024/9/4
+ * @apiNote
+ */
+public class TaxPersonRecordListHandlerExEx extends TaxPersonRecordListHandler {
+    private Context ctx = SHRContext.getInstance().getContext();
+    Logger logger = Logger.getLogger("com.kingdee.eas.custom.individualback.TaxPersonRecordListHandlerExEx");
+
+    /**
+     * 同步人员纳税信息
+     *
+     * @param request
+     * @param response
+     * @param modelMap
+     * @throws ShrWebBizException
+     * @throws BOSException
+     */
+    public void synTaxPersonRecordAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws ShrWebBizException, BOSException {
+        String taxUnitIds = (String) request.getParameter("taxUnitIds");
+        String yearMonth = (String) request.getParameter("yearMonth");
+        if (StringUtils.isEmpty(taxUnitIds)) {
+            throw new ShrWebBizException("纳税单位不可为空!!");
+        }
+        if (StringUtils.isEmpty(yearMonth)) {
+            throw new ShrWebBizException("所属年月不可为空!!");
+        }
+        try {
+            //截取日期年月
+            String[] parts = yearMonth.split("-");
+            int year = Integer.parseInt(parts[0]);
+            int month = Integer.parseInt(parts[1]);
+            String[] taxUnitIdArray = taxUnitIds.split(",");
+            for (int i = 0; i < taxUnitIdArray.length; i++) {
+                String taxUnitId = taxUnitIdArray[i];
+                //getSCmpCalTablePersonsSql 获取薪酬核算人员sqlhjkl;
+                String sCmpCalTablePersonsSql = getSCmpCalTablePersonsSql(year, month, taxUnitId);
+                logger.error("sCmpCalTablePersonsSql--" + sCmpCalTablePersonsSql);
+                IRowSet iRowSet = DbUtil.executeQuery(ctx, sCmpCalTablePersonsSql);
+                //存储员工ID
+                List personIds = new ArrayList();
+                while (iRowSet.next()) {
+                    personIds.add(iRowSet.getString("personId"));
+                }
+                logger.error("personIds--" + personIds);
+                //
+                ////获取年月第一天
+                //LocalDate currentDate = LocalDate.of(year, month, 1);
+                //Date oneDay = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+                //
+                ////获取yearMonth年月的最后一天
+                //YearMonth yearAndMonth = YearMonth.parse(yearMonth);
+                //LocalDate lastDayOfMonth = yearAndMonth.atEndOfMonth();
+                //
+                //Date date = Date.from(lastDayOfMonth.withDayOfMonth(lastDayOfMonth.lengthOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
+                //////保存人员纳税信息
+                ////addTaxPersonRecord(personIds, oneDay, taxUnitIds, yearMonth);
+                //获取数据进行对比
+                comparison(personIds, taxUnitId, year, month, yearMonth);
+            }
+
+        } catch (SQLException | EASBizException e) {
+            e.printStackTrace();
+            throw new ShrWebBizException(e);
+        }
+
+    }
+
+    /**
+     * 对比数据 修改任职受雇从业信息
+     *
+     * @param personIdSet 薪酬核算人员
+     * @param taxUnitId   纳税单位
+     * @param periodYear  年
+     * @param periodMonth 月
+     * @param yearMonth   年月
+     */
+    public void comparison(List personIdSet, String taxUnitId, int periodYear, int periodMonth, String yearMonth) throws BOSException, EASBizException, SQLException {
+        ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
+        ITaxPersonRecord iTaxPersonRecord = TaxPersonRecordFactory.getLocalInstance(ctx);
+        //获取上一个月的计算规则  统计年:periodYear   统计月:periodMonth
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
+        LocalDate date = LocalDate.of(periodYear, periodMonth, 1);
+        LocalDate previousMonthDate = date.minusMonths(1);
+        String previousMonth = previousMonthDate.format(formatter);
+        //上个月数据
+        //TaxPersonRecordEntryCollection taxPersonRecordEntryCollUp = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.* where  taxUnit = '" + taxUnitId + "' and lastReportMonth = '" + previousMonth + "' ");
+        //人员报税信息数据
+        TaxPersonRecordEntryCollection taxPersonRecordEntryCollDn = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("select * ,person.*  where  taxUnit = '" + taxUnitId + "' ");
+        //保存上个月的核算人员
+        //List<String> listUp = new ArrayList<>();
+        //for (int i = 0; i < personIds.size(); i++) {
+        //    listUp.add(personIds.get(i));
+        //}
+        //保存当前月的核算人员
+        List<String> list = new ArrayList<>();
+        for (int i = 0; i < taxPersonRecordEntryCollDn.size(); i++) {
+            String personId = taxPersonRecordEntryCollDn.get(i).getPerson().getId().toString();
+            TaxPersonRecordCollection taxPersonRecordCollection = iTaxPersonRecord.getTaxPersonRecordCollection("where person = '" + personId + "'");
+            if (taxPersonRecordCollection.size() > 0) {
+                logger.error("comparison--personId--------------" + personId);
+                list.add(personId);
+            }
+        }
+        //人员报税
+        Set<String> setUp = new HashSet<>(list);
+        logger.error("comparison--setUp--------------" + setUp);
+
+        //薪酬核算
+        Set<String> set = new HashSet<>(personIdSet);
+        logger.error("comparison--set--------------" + set);
+
+
+        // 找出 上个月核算人员 中比 当前月核算人员 多的数据 为离职人员 修改人员纳税信息的 人员状态为非正常  离职日期为当前月最后一天
+        Set<String> pseronIdsUp = new HashSet<>(setUp);
+        pseronIdsUp.removeAll(set);
+        logger.error("comparison--pseronIdsUp--------------" + pseronIdsUp);
+
+        // 找出 当前月核算人员 中比 上个月核算人员 多的数据 为新增人员 创建人员纳税信息和任职受雇从业信息 人员状态为正常 任职受雇从业日期为当前月1号
+        Set<String> pseronIds = new HashSet<>(set);
+        pseronIds.removeAll(setUp);
+        logger.error("comparison--pseronIds--------------" + pseronIds);
+
+        SelectorItemCollection updateSic = new SelectorItemCollection();
+        updateSic.add("personStatus");
+        updateSic.add("departureDate");
+
+        if (pseronIdsUp.size() > 0) {
+            //获取任职受雇从业信息   修改人员纳税信息的 人员状态为非正常  离职日期为当前月最后一天
+            TaxPersonRecordEntryCollection taxPersonRecordEntryCollUp2 = getTaxPersonRecordEntryColl(pseronIdsUp, iTaxPersonRecordEntry);
+            if (taxPersonRecordEntryCollUp2.size() > 0) {
+                for (int i = 0; i < taxPersonRecordEntryCollUp2.size(); i++) {
+                    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);
+                }
+            }
+        }
+        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);
+        }
+    }
+
+    /**
+     * 获取任职受雇从业信息
+     *
+     * @param pseronIds 员工ID集合
+     * @return
+     * @throws BOSException
+     */
+    public TaxPersonRecordEntryCollection getTaxPersonRecordEntryColl(Set<String> pseronIds, ITaxPersonRecordEntry iTaxPersonRecordEntry) throws BOSException {
+        //获取当前月的薪酬计算
+        FilterInfo filterInfo = new FilterInfo();
+        filterInfo.getFilterItems().add(new FilterItemInfo("bill.person", pseronIds, CompareType.INCLUDE));
+        EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
+        return iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection(entityViewInfo);
+    }
+
+    /**
+     * 新增人员纳税信息
+     *
+     * @param pseronIds 人员
+     * @param oneDay    年月最后一天日期
+     * @param taxUnitId 纳税单位ID
+     * @throws BOSException
+     * @throws EASBizException
+     * @throws SQLException
+     */
+    public void addTaxPersonRecord(Set<String> pseronIds, Date oneDay, String taxUnitId, String yearMonth) throws BOSException, EASBizException, SQLException {
+        logger.error("addTaxPersonRecord--------新增开始");
+        //pseronIds.forEach(id -> {});
+        ITaxPersonRecord iTaxPersonRecord = TaxPersonRecordFactory.getLocalInstance(ctx);
+        IPerson iPerson = PersonFactory.getLocalInstance(ctx);
+        ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
+
+        SelectorItemCollection sic = new SelectorItemCollection();
+        sic.add("*");
+        FilterInfo filterInfo = new FilterInfo();
+        filterInfo.getFilterItems().add(new FilterItemInfo("id", pseronIds, CompareType.INCLUDE));
+        EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
+        PersonCollection personCollection = iPerson.getPersonCollection(entityViewInfo);
+        if (personCollection.size() > 0) {
+            for (int i = 0; i < personCollection.size(); i++) {
+                PersonInfo personInfo = personCollection.get(i);
+                boolean exists = iTaxPersonRecordEntry.exists("where person = '" + personInfo.getId().toString() + "' and taxUnit = '" + taxUnitId + "' and lastReportMonth = '" + yearMonth + "' ");
+                if (!exists) {
+                    TaxPersonRecordInfo taxPersonRecordInfo = new TaxPersonRecordInfo();
+                    //人员纳税分录对象
+                    TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = new TaxPersonRecordEntryInfo();
+                    //人员
+                    taxPersonRecordInfo.setPerson(personInfo);
+                    //证件类型
+                    if (personInfo.getIdCardNO() != null || personInfo.getPassportNO() != null) {
+                        if (null == personInfo.getIdCardNO()) {
+                            //护照
+                            taxPersonRecordInfo.setCardType(CardTypeEnum.Passport);
+                            taxPersonRecordInfo.setCardNumber(personInfo.getPassportNO());
+                            //纳税人类型
+                            taxPersonRecordEntryInfo.setPayerType(PayerTypeEnum.NotResident);
+                        }
+                        if (null == personInfo.getPassportNO()) {
+                            //证件号
+                            taxPersonRecordInfo.setCardType(CardTypeEnum.IdCard);
+                            taxPersonRecordInfo.setCardNumber(personInfo.getIdCardNO());
+                            //纳税人类型
+                            taxPersonRecordEntryInfo.setPayerType(PayerTypeEnum.Resident);
+
+                        }
+                    } else {
+                        logger.error(personInfo.getName() + "护照和身份证为空,证件类型保存失败!");
+                    }
+                    //性别
+                    taxPersonRecordInfo.setGender(personInfo.getGender());
+                    //出生日期
+                    taxPersonRecordInfo.setBirthday(personInfo.getBirthday());
+                    //国籍
+                    taxPersonRecordInfo.setNationality(personInfo.getNationality());
+                    //是否境外人员
+                    taxPersonRecordInfo.setIsOversea(IsOverseaEnum.NotOversea);
+                    //手机号码
+                    taxPersonRecordInfo.setPhoneNumber(personInfo.getCell());
+                    IObjectPK save = iTaxPersonRecord.save(taxPersonRecordInfo);
+                    if (save != null) {
+                        //保存分录数据
+                        taxPersonRecordEntryInfo.setPerson(personInfo);
+                        taxPersonRecordEntryInfo.setBill(taxPersonRecordInfo);
+                        //获取纳税单位
+                        ITaxUnit iTaxUnit = TaxUnitFactory.getLocalInstance(ctx);
+                        TaxUnitInfo taxUnitInfo = iTaxUnit.getTaxUnitInfo("where id = '" + taxUnitId + "'");
+                        taxPersonRecordEntryInfo.setTaxUnit(taxUnitInfo);
+                        //人员状态
+                        taxPersonRecordEntryInfo.setPersonStatus(PersonStatusEnum.Normal);
+                        //获取当前月的最后一天转成Date类型 //任职受雇从业日期为当前月第一天
+                        taxPersonRecordEntryInfo.setEmployedDate(oneDay);
+                        //报送状态
+                        taxPersonRecordEntryInfo.setSubmitStatus(SubmitStatusEnum.NotSubmit);
+                        taxPersonRecordEntryInfo.setLastReportMonth(yearMonth);
+                        IObjectPK saveEntry = iTaxPersonRecordEntry.save(taxPersonRecordEntryInfo);
+                        logger.error("saveEntry--------分录新增返回ID" + saveEntry);
+                    }
+                }
+            }
+        }
+        logger.error("addTaxPersonRecord--------新增结束");
+    }
+
+    /**
+     * 获取薪酬核算人员
+     *
+     * @param year      统计年
+     * @param month     统计月
+     * @param taxUnitId 纳税单位
+     */
+    public String getSCmpCalTablePersonsSql(Integer year, Integer month, String taxUnitId) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("SELECT").append("\n");
+        sb.append("FPersonID as personId").append("\n");
+        sb.append("FROM T_HR_SCmpCalTable").append("\n");
+        sb.append("WHERE").append("\n");
+        sb.append("FPeriodYear = '").append(year).append("'").append("\n");
+        sb.append(" and ").append("\n");
+        sb.append("FPeriodMonth = '").append(month).append("'").append("\n");
+        sb.append(" and ").append("\n");
+        sb.append("FTaxUnitID = '").append(taxUnitId).append("'").append("\n");
+        return sb.toString();
+    }
+}