Browse Source

个税申报 个税反算 个税信息同步

“luojun” 8 months ago
parent
commit
63ca29dd63

+ 25 - 16
websrc/com/kingdee/eas/custom/compensation/handler/CmpCalDynamicListHandlerExExEx.java

@@ -121,15 +121,15 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
                     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);
+                    if (!StringUtils.isEmpty(taxUnitId)) {
+                        //throw new ShrWebBizException("员工ID:" + personId + "未获取到纳税单位!!");
+                        TaxUnitAndPerson taxUnitAndPerson = new TaxUnitAndPerson(taxUnitId, personId);
+                        taxUnitAndPeople.add(taxUnitAndPerson);
+                    }
                 }
             }
             logger.error("taxUnitAndPeople-----------" + taxUnitAndPeople);
@@ -214,13 +214,15 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
                     //resList.add(saveId);
                 }
             }
+            rseMap.put("msg", "已增加至后台事务中执行!");
         } catch (Exception e) {
             e.printStackTrace();
             logInfo.setErrorInfo(e.getMessage());//错误信息
             LogInfoFactory.getLocalInstance(ctx).save(logInfo);
+            rseMap.put("msg", e.getMessage());
             throw new SHRWebException(e);
         }
-        JSONUtils.writeJson(response, "已增加至后台事务中执行!");
+        JSONUtils.SUCCESS(rseMap);
     }
 
     /**
@@ -247,6 +249,8 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
         calculateIndividualIncomeTaxRequest.setName(taxUnitInfo.getName());
         //calculateIndividualIncomeTaxRequest.setName("荆州九州通医药有限公司00");
         //申报密码
+        logger.error("taxUnitInfo----" + taxUnitInfo);
+        logger.error("declPassword----" + taxUnitInfo.getDeclPassword());
         String sbmm = new String(Base64.getDecoder().decode(taxUnitInfo.getDeclPassword()));
         //String sbmm = new String(Base64.getDecoder().decode("QWExMjM0NTY="));
         logger.error("sbmm----" + sbmm);
@@ -570,7 +574,6 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
         //nonResidentsIncome.setLicenseNumber("429004198601085125");
         //nonResidentsIncome.setAbroadIncome(new BigDecimal("8000"));
         //nonResidentsIncome.setIncomeItemName("无住所个人正常工资薪金");
-
         //姓名
         nonResidentsIncome.setName(personInfo.getName());
         //complexIncome.setName("何云");
@@ -591,7 +594,7 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
         Integer abroadIncome = getAbroadIncome(personInfo.getId().toString(), cmpschemeid);
         //complexIncome.setLicenseNumber("429004198601085125");
         //税后收入额
-        nonResidentsIncome.setAbroadIncome(new BigDecimal(abroadIncome));
+        //nonResidentsIncome.setAbroadIncome(new BigDecimal(abroadIncome));
         nonResidentsIncome.setIncomeItemName(taxItemPlanName);
         return nonResidentsIncome;
     }
@@ -614,9 +617,12 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
             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);
+                logger.error("getAbroadIncome-----" + personInfo.getName() + "-----------" + getAbroadIncome(personInfo.getId().toString(), cmpschemeid));
+                if (getAbroadIncome(personInfo.getId().toString(), cmpschemeid) != null || getAbroadIncome(personInfo.getId().toString(), cmpschemeid) != 0) {
+                    ComplexIncome annualOneTimeBonusIncome = getAnnualOneTimeBonusIncome(personInfo, taxItemPlanName, cmpschemeid);
+                    aOneBonusIncomeList.add(annualOneTimeBonusIncome);
+                    complexIncomeRequest.setAnnualOneTimeBonusIncome(aOneBonusIncomeList);
+                }
             }
         }
         //一般劳务报酬所得列表
@@ -625,9 +631,12 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
             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);
+                logger.error("getAbroadIncome-----" + personInfo.getName() + "-----------" + +getAbroadIncome(personInfo.getId().toString(), cmpschemeid));
+                if (getAbroadIncome(personInfo.getId().toString(), cmpschemeid) != null || getAbroadIncome(personInfo.getId().toString(), cmpschemeid) != 0) {
+                    ComplexIncome laborRemunerationIncome = getLaborRemunerationIncome(personInfo, taxItemPlanName, cmpschemeid);
+                    complexIncomeList.add(laborRemunerationIncome);
+                    complexIncomeRequest.setLaborRemunerationIncome(complexIncomeList);
+                }
             }
         }
         //正常工资薪金对象
@@ -668,7 +677,7 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
         Integer abroadIncome = getAbroadIncome(personInfo.getId().toString(), cmpschemeid);
         //complexIncome.setLicenseNumber("429004198601085125");
         //税后收入额
-        complexIncome.setAbroadIncome(new BigDecimal(abroadIncome));
+        complexIncome.setAfterTaxIncome(new BigDecimal(abroadIncome));
         complexIncome.setIncomeItemName(taxItemPlanName);
         return complexIncome;
     }
@@ -702,7 +711,7 @@ public class CmpCalDynamicListHandlerExExEx extends CmpCalDynamicListHandlerExEx
         Integer abroadIncome = getAbroadIncome(personInfo.getId().toString(), cmpschemeid);
         //complexIncome.setLicenseNumber("429004198601085125");
         //税后收入额
-        complexIncome.setAbroadIncome(new BigDecimal(abroadIncome));
+        complexIncome.setAfterTaxIncome(new BigDecimal(abroadIncome));
         complexIncome.setIncomeItemName(taxItemPlanName);
         return complexIncome;
     }

+ 774 - 662
websrc/com/kingdee/eas/custom/compensation/handler/IncomeTaxDeclareListHandlerEx.java

@@ -7,29 +7,53 @@ 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.core.JsonProcessingException;
 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.bos.metadata.entity.*;
+import com.kingdee.bos.metadata.query.util.CompareType;
+import com.kingdee.bos.util.EASResource;
 import com.kingdee.eas.basedata.hraux.NationalityInfo;
+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.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.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.dynamic.util.DynamicUtil;
+import com.kingdee.shr.base.syssetting.web.dynamic.util.MD5;
 import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
+import com.kingdee.shr.base.syssetting.web.util.UserUtil;
+import com.kingdee.shr.compensation.TbTypeEnum;
+import com.kingdee.shr.compensation.app.incomeTax.ITaxPersonRecordEntry;
+import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordEntryCollection;
+import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordEntryFactory;
+import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordEntryInfo;
 import com.kingdee.shr.compensation.app.tax.*;
-import com.kingdee.shr.compensation.util.Base64Utils;
+import com.kingdee.shr.compensation.app.tax.base.TaxIncomeItemInfo;
+import com.kingdee.shr.compensation.app.taxCal.*;
+import com.kingdee.shr.compensation.util.*;
 import com.kingdee.shr.compensation.web.handler.tax.IncomeTaxDeclareListHandler;
+import com.kingdee.shr.compensation.web.handler.tax.dto.TaxDeclarExcelRowDTO;
+import com.kingdee.shr.compensation.web.handler.tax.dto.TaxDeclareDTO;
 import com.kingdee.util.StringUtils;
 import org.apache.log4j.Logger;
+import org.apache.poi.hssf.usermodel.*;
 import org.springframework.ui.ModelMap;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.sql.SQLException;
@@ -42,10 +66,12 @@ import java.util.*;
  * @apiNote 个税申报扩展
  */
 public class IncomeTaxDeclareListHandlerEx extends IncomeTaxDeclareListHandler {
-    Logger logger = Logger.getLogger("com.kingdee.eas.custom.compensation.handler.IncomeTaxDeclareListHandlerEx");
-    String personName = "测试姜凌";
-    String cardType = "居民身份证";
-    String cardNumber = "828888201005039412";
+    private static final Logger LOG = Logger.getLogger(IncomeTaxDeclareListHandlerEx.class);
+
+    private Context ctx = SHRContext.getInstance().getContext();
+
+    private ObjectMapper mapper = new ObjectMapper();
+
     /**
      * 个税申报
      *
@@ -53,142 +79,165 @@ public class IncomeTaxDeclareListHandlerEx extends IncomeTaxDeclareListHandler {
      * @param response
      * @param modelMap
      */
-    public void taxDeclaresAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SHRWebException {
-        logger.error("taxDeclareAction-----start-------");
-
+    @Override
+    public void taxDeclareAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SHRWebException {
+        LOG.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, "");
+            boolean isHaveTaxService = CmpTaxUtil.isHaveTaxService(ctx);
+            if (!isHaveTaxService) {
+                throw new ShrWebBizException(EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label136", ctx.getLocale()));
+            } else {
+                String selectedId = request.getParameter("selectedId");
+                Map<String, Object> resultMap = new HashMap();
+                Map<String, Object> declareData = this.getDeclareData(ctx, selectedId);
+                Map<String, Object> paramMap = new HashMap();
+                paramMap.put("declaData", declareData.get("WATI_TO_DECLARE"));
+                LOG.error("paramMap-----------" + paramMap);
+                try {
+                    //纳税单位
+                    List<String> advanceDeclareInfo = (List) declareData.get("advanceDeclareInfo");
+                    LOG.error("advanceDeclareInfo------------" + advanceDeclareInfo);
+                    if (!advanceDeclareInfo.isEmpty()) {
+                        throw new ShrWebBizException(this.combineError(advanceDeclareInfo));
+                    }
+                    //个税审批 审批状态=审批通过的数据
+                    List<IncomeTaxDeclarInfo> waitToDeclareList = (List) paramMap.get("declaData");
+                    if (waitToDeclareList.size() <= 0) {
+                        resultMap.put("success", false);
+                        resultMap.put("excel", "");
+                        resultMap.put("hasErrData", true);
+                        resultMap.put("hasCheckDataErr", true);
+                        resultMap.put("info", "不可重复声申报!!");
+                        JSONUtils.SUCCESS(resultMap);
+                        return;
+                    }
+                    //检查纳税申报数据
+                    Map<String, Object> checkResultMap = this.checkTaxDeclareData(ctx, request, waitToDeclareList);
+                    Boolean hasErr = (Boolean) checkResultMap.get("hasErrData");
+                    if (hasErr != null && hasErr) {
+                        resultMap.put("success", false);
+                        resultMap.put("excel", checkResultMap.get("excel"));
+                        resultMap.put("hasErrData", true);
+                        resultMap.put("hasCheckDataErr", true);
+                        resultMap.put("info", "");
+                        JSONUtils.SUCCESS(resultMap);
+                        return;
+                    }
+                    String errMsg = this.checkTaxCalStatus(ctx, waitToDeclareList);
+                    if (null != errMsg) {
+                        resultMap.put("success", false);
+                        resultMap.put("dataError", true);
+                        resultMap.put("errMsg", errMsg);
+                        JSONUtils.SUCCESS(resultMap);
+                        return;
+                    }
+
+                    checkResultMap = this.checkIncomeTaxIssue(ctx, waitToDeclareList);
+                    if (checkResultMap != null) {
+                        checkResultMap.put("success", false);
+                        JSONUtils.SUCCESS(checkResultMap);
+                        return;
+                    }
+
+                    //errMsg = this.checkReductionItems(ctx, waitToDeclareList);
+                    //if (null != errMsg) {
+                    //    resultMap.put("success", false);
+                    //    resultMap.put("reductionError", true);
+                    //    resultMap.put("errMsg", errMsg);
+                    //    JSONUtils.SUCCESS(resultMap);
+                    //    return;
+                    //}
+
+                    //Map<String, Object> taxDeclareResult = IncomeTaxDeclareFacadeFactory.getLocalInstance(ctx).taxDeclare(paramMap);
+                    //调佣税友纳税申报
+                    Map<String, Object> taxDeclareResult = callShuiYouTaxDeclare(paramMap);
+                    Boolean isSuccess = (Boolean) taxDeclareResult.get("success");
+                    resultMap.put("success", isSuccess);
+                    resultMap.put("excel", "");
+                    resultMap.put("hasErrData", !isSuccess);
+                    resultMap.put("hasCheckDataErr", false);
+                    resultMap.put("info", declareData.get("info"));
+                } catch (Exception var17) {
+                    var17.printStackTrace();
+                    LOG.error(var17.getMessage(), var17);
+                    resultMap.put("success", false);
+                    resultMap.put("excel", "");
+                    resultMap.put("hasErrData", true);
+                    resultMap.put("hasCheckDataErr", false);
+                    resultMap.put("info", declareData.get("info"));
+                    resultMap.put("errorMsg", var17.getMessage());
                 }
+                LOG.error("taxDeclareAction-----------end-----------");
+                JSONUtils.SUCCESS(resultMap);
             }
-            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) {
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
             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);
-    //    }
-    //}
+
+
+    /**
+     * 调佣税友纳税申报
+     *
+     * @param paramMap
+     * @return
+     */
+    public Map<String, Object> callShuiYouTaxDeclare(Map paramMap) {
+        LOG.error("callShuiYouTaxDeclare--------------------paramMap" + paramMap);
+        Map<String, Object> resultMap = new HashMap();
+        resultMap.put("success", true);
+        resultMap.put("msg", "");
+        List<IncomeTaxDeclarInfo> waitToDeclareList = (List) paramMap.get("declaData");
+        Map<String, Object> requestParamMap = new HashMap();
+        List<Object[]> paramList = new ArrayList();
+        try {
+            if (waitToDeclareList != null && waitToDeclareList.size() > 0) {
+
+                for (int i = 0; i < waitToDeclareList.size(); i++) {
+                    IncomeTaxDeclarInfo taxDeclarInfo = waitToDeclareList.get(i);
+                    JSONObject param = new JSONObject();
+                    param.put("taxDeclarId", taxDeclarInfo.getId());
+                    param.put("taxDeclarBatchNo", taxDeclarInfo.getBatchNo());
+                    //纳税单位
+                    TaxUnitInfo taxUnitInfo = taxDeclarInfo.getTaxUnit();
+                    //客户端代理工厂
+                    ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
+                    //算税请求接口
+                    DeclarationRequest declarationRequest = clientProxyFactory.getDeclarationRequest();
+                    //获取请求参数
+                    CompanyDeclareRequest declareRequestParameter = getDeclareRequestParameter(taxUnitInfo, taxDeclarInfo);
+                    LOG.error("declareRequestParameter-----------------" + mapper.writeValueAsString(declareRequestParameter));
+                    ApiResponse<AsyncResult> apiResponse = declarationRequest.send(declareRequestParameter);
+                    LOG.error("asyncResultApiResponse-----getCode-------" + apiResponse.getHead().getCode());
+                    LOG.error("asyncResultApiResponse-----getMsg--------" + apiResponse.getHead().getMsg());
+                    resultMap.put("msg", mapper.writeValueAsString(declareRequestParameter));
+                    if (apiResponse.getHead().getCode().equals("00000000")) {
+                        AsyncResult body = apiResponse.getBody();
+                        String requestId = body.getRequestId();
+                        LOG.error("requestId-----" + requestId);
+                        LOG.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", param.toString());
+                        isyUtilsFacade.addTask("synIncomeTaxDeclareService", json.toJSONString(), TaskCatalogEnum.UN_CAL_GET, "");
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            resultMap.put("success", false);
+            resultMap.put("msg", e.getMessage());
+            return resultMap;
+        }
+        return resultMap;
+
+    }
 
     /**
      * 获取请求参数
@@ -197,17 +246,18 @@ public class IncomeTaxDeclareListHandlerEx extends IncomeTaxDeclareListHandler {
      * 2.解除劳动合同一次性补偿金、稿酬所得,由于税务规则需要,解除劳动合同一次性补偿金、稿酬所得必须填写免税附表。
      *
      * @param taxUnitInfo
-     * @param declareDataMap
-     * @param yearMonth
+     * @param taxDeclarInfo
      * @return
      */
     private CompanyDeclareRequest getDeclareRequestParameter(TaxUnitInfo taxUnitInfo,
-                                                             Map<String, List<Map<String, Object>>> declareDataMap,
-                                                             String yearMonth) throws BOSException, SQLException, EASBizException {
+                                                             IncomeTaxDeclarInfo taxDeclarInfo
+    ) throws BOSException, JsonProcessingException, EASBizException, SQLException {
+        LOG.error("getDeclareRequestParameter-----------taxDeclarInfo-----" + taxDeclarInfo);
         CompanyDeclareRequest declareRequestPara = new CompanyDeclareRequest();
+        Map<String, Object> requestParamMap = new HashMap();
         //随机id
         String bizNo = UUID.randomUUID().toString();
-        logger.error("bizNo:" + bizNo);
+        LOG.error("bizNo:" + bizNo);
         //外部业务订单号*
         declareRequestPara.setBizNo(bizNo);
         //企业名称*
@@ -218,124 +268,157 @@ public class IncomeTaxDeclareListHandlerEx extends IncomeTaxDeclareListHandler {
         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();
+        //所得月份
+        String yearMonth = taxDeclarInfo.getYearMonth();
+        String replaceYearMonth = yearMonth.replace("-", "");
+        LOG.error("replaceYearMonth----------------" + replaceYearMonth);
+        //税款所属期YYYYMM*
+        declareRequestPara.setMonth(replaceYearMonth);
+        //总金额
+        //BigDecimal totalMoney = taxDeclarInfo.getTotalMoney();
+        //应退税额
+        //BigDecimal taxRebate = taxDeclarInfo.getTaxRebate();
+        //总人数
+        //long totalPerson = taxDeclarInfo.getTotalPerson();
+        //申报表分类 1=预扣预缴申报表  2=分类所得申报表   3=非居民所得申报表
+        //String tbTble = taxDeclarInfo.getTbType().getValue();
+        //纳税单位ID
+        //String taxUnitId = taxUnitInfo.getId().toString();
+        //Map<String, Object> tbTypeMap = new HashMap();
+        //if (totalMoney.compareTo(BigDecimal.ZERO) == 0) {
+        //    tbTypeMap.put("zje", 0.0);
+        //} else {
+        //    tbTypeMap.put("zje", totalMoney);
+        //}
+        //
+        //if (taxRebate.compareTo(BigDecimal.ZERO) == 0) {
+        //    tbTypeMap.put("ynse", 0.0);
+        //} else {
+        //    tbTypeMap.put("ynse", taxRebate);
+        //}
+        //tbTypeMap.put("zrs", totalPerson);
+        //Map<String, Object> dataMap = new HashMap();
+        //if ("1".equals(tbTble)) {
+        //    dataMap.put("ykyj", tbTypeMap);
+        //} else if ("2".equals(tbTble)) {
+        //    dataMap.put("flsd", tbTypeMap);
+        //} else if ("3".equals(tbTble)) {
+        //    dataMap.put("fjm", tbTypeMap);
+        //}
         //密码类型*
         declareRequestPara.setPasswordType("0");
         //离职日期处理策略 1、不传或传1,代表离职日期自动清空,即人员状态由“非正常”变更为“正常”时,离职日期字段自动清空,默认逻辑。
         //2、传2离职日期不自动清空,即人员状态由“非正常”变更为“正常”时,离职日期不自动清空,客户如需清空需对离职日期字段传入空字符串。
         //declareRequestPara.setResignDateStrategy();
-        //企业员工列表
-        List<DetailCompanyEmployee> companyEmployeeList = getCompanyEmployeeList();
-        declareRequestPara.setCompanyEmployeeList(companyEmployeeList);
-        //综合所得
+        //批次号
+        String batchNo = taxDeclarInfo.getBatchNo();
+        LOG.error("taxCalConfigDetailCollection--------taxDeclarInfo---------" + taxDeclarInfo);
+        //个税应用+税款计算最终拆分明细表
+        ITaxCalConfigDetail taxCalConfigDetail = TaxCalConfigDetailFactory.getLocalInstance(ctx);
+        TaxCalConfigDetailCollection taxCalConfigDetailCollection = taxCalConfigDetail.getTaxCalConfigDetailCollection("select *,incomeItem.*, person.* where batchNo = '" + batchNo + "' and state = '20'");
+        LOG.error("taxCalConfigDetailCollection-----------------" + taxCalConfigDetailCollection.size());
+        //员工信息ID
+        Set personIds = new HashSet();
         //综合所得对象
         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);
+        //正常工资薪金对象
+        NormalSalarySpecIncome normalSalarySpecIncome = new NormalSalarySpecIncome();
+        //正常工资薪金列表
+        List<ComplexIncome> normalSalarySpec = new ArrayList();
+        //全年一次性奖金收入
+        List<ComplexIncome> annualOneTimeBonusIncome = new ArrayList();
+        //全年一次性奖金收入
+        List<ComplexIncome> laborRemunerationIncome = new ArrayList();
+        if (taxCalConfigDetailCollection.size() > 0) {
+            for (int i = 0; i < taxCalConfigDetailCollection.size(); i++) {
+                TaxCalConfigDetailInfo taxCalConfigDetailInfo = taxCalConfigDetailCollection.get(i);
+                //员工信息
+                PersonInfo personInfo = taxCalConfigDetailInfo.getPerson();
+                personIds.add(personInfo.getId().toString());
+                //所得项目
+                TaxIncomeItemInfo incomeItem = taxCalConfigDetailInfo.getIncomeItem();
+                //本期收入
+                Integer sre = null;
+                String getSreSql = "select t1 from T_HR_STaxCalConfigDetail where fid ='" + taxCalConfigDetailInfo.getId().toString() + "'";
+                IRowSet iRowSet = DbUtil.executeQuery(ctx, getSreSql);
+                while (iRowSet.next()) {
+                    sre = iRowSet.getInt("t1");
+                }
+                LOG.error("incomeItem-----------------" + incomeItem);
+                //所属项目名称
+                String incomeItemName = incomeItem.getName();
+                //所属项目编码
+                String incomeItemNumber = incomeItem.getNumber();
 
+                //正常工资薪金
+                if ("zcgzxjlb".equals(incomeItemNumber)) {
+                    //getComplexIncome(员工信息对象 ,所属项目,本期收入)
+                    normalSalarySpec.add(getComplexIncome(personInfo, incomeItemName, sre));
+                    //正常工资薪金列表 保存数据
+                    normalSalarySpecIncome.setNormalSalarySpec(normalSalarySpec);
+                    LOG.error("normalSalarySpecIncome-----------------" + mapper.writeValueAsString(normalSalarySpecIncome));
+                    complexIncomeRequest.setNormalSalarySpecIncome(normalSalarySpecIncome);
+                }
+                //全年一次性奖金收入
+                if ("qnycxjjlb".equals(incomeItemNumber)) {
+                    annualOneTimeBonusIncome.add(getComplexIncome(personInfo, incomeItemName, sre));
+                    LOG.error("annualOneTimeBonusIncome-----------------" + mapper.writeValueAsString(annualOneTimeBonusIncome));
+                    LOG.error("annualOneTimeBonusIncome-----------------" + annualOneTimeBonusIncome);
+                    LOG.error("annualOneTimeBonusIncome.size()-----------------" + annualOneTimeBonusIncome.size());
+                    //全年一次性奖金收入 保存数据
+                    complexIncomeRequest.setAnnualOneTimeBonusIncome(annualOneTimeBonusIncome);
+                }
+                //一般劳务报酬所得
+                if ("lwbclb".equals(incomeItemNumber)) {
+                    laborRemunerationIncome.add(getComplexIncome(personInfo, incomeItemName, sre));
+                    LOG.error("laborRemunerationIncome-----------------" + mapper.writeValueAsString(laborRemunerationIncome));
+                    //一般劳务报酬所得 保存数据
+                    complexIncomeRequest.setLaborRemunerationIncome(laborRemunerationIncome);
+                }
+            }
+        }
+        //综合所得
         declareRequestPara.setComplexIncomeRequest(complexIncomeRequest);
+        //企业员工列表
+        List<DetailCompanyEmployee> companyEmployeeList = getCompanyEmployeeList(personIds);
+        declareRequestPara.setCompanyEmployeeList(companyEmployeeList);
+        LOG.error("companyEmployeeList-----------------" + mapper.writeValueAsString(companyEmployeeList));
+
         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();
+    private ComplexIncome getComplexIncome(PersonInfo personInfo, String incomeItemName, Integer sre) {
         ComplexIncome complexIncome = new ComplexIncome();
         //姓名
-        complexIncome.setName(personName);
-        //证照类型
-        complexIncome.setLicenseType(cardType);
-        complexIncome.setLicenseNumber(cardNumber);
-        //税后收入额
-        complexIncome.setAbroadIncome(new BigDecimal("123123"));
+        complexIncome.setName(personInfo.getName());
+        //居民身份证
+        if (personInfo.getIdCardNO() != null) {
+            //证照号码
+            complexIncome.setLicenseNumber(personInfo.getIdCardNO());
+            //证照类型
+            complexIncome.setLicenseType("居民身份证");
+        }
+        //中国护照不
+        if (personInfo.getPassportNO() != null) {
+            //证照类型
+            complexIncome.setLicenseType("中国护照");
+            //证照号码
+            complexIncome.setLicenseNumber(personInfo.getPassportNO());
+        }
         //收入额
-        complexIncome.setIncome(new BigDecimal("10000"));
-        //所得项目名称
-        complexIncome.setIncomeItemName("全年一次性奖金收入");
-        complexIncomeList.add(complexIncome);
-        return complexIncomeList;
+        complexIncome.setIncome(new BigDecimal(sre));
+        complexIncome.setIncomeItemName(incomeItemName);
+        return complexIncome;
     }
 
     /**
@@ -343,468 +426,497 @@ public class IncomeTaxDeclareListHandlerEx extends IncomeTaxDeclareListHandler {
      *
      * @return
      */
-    private List<DetailCompanyEmployee> getCompanyEmployeeList() {
+    private List<DetailCompanyEmployee> getCompanyEmployeeList(Set personIds) throws BOSException, EASBizException {
         List<DetailCompanyEmployee> companyEmployeeList = new ArrayList<DetailCompanyEmployee>();
-        //获取人员数据
-        DetailCompanyEmployee detailCompanyEmployee = getDetailCompanyEmployee();
-        companyEmployeeList.add(detailCompanyEmployee);
+        SelectorItemCollection sic = new SelectorItemCollection();
+        sic.add("*");
+        FilterInfo filterInfo = new FilterInfo();
+        filterInfo.getFilterItems().add(new FilterItemInfo("id", personIds, CompareType.INCLUDE));
+        EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);        //获取人员数据
+        PersonCollection personCollection = PersonFactory.getLocalInstance(ctx).getPersonCollection(entityViewInfo);
+        if (personCollection.size() > 0) {
+            for (int i = 0; i < personCollection.size(); i++) {
+                PersonInfo personInfo = personCollection.get(i);
+                companyEmployeeList.add(getDetailCompanyEmployee(personInfo));
+            }
+        }
+
         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);
+    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("境内");
         }
-        return compensateIncome;
+        //中国护照
+        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 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);
+
+    private String getCheckSqlByType(Map<String, Object> incomeIdMap, String taxUnitId, String yearMonth, TbTypeEnum typeEnum) {
+        StringBuilder sqlBuf = new StringBuilder();
+        sqlBuf.append(" SELECT distinct tx.FTAXUNITID,t1.Fname_l2 as TAXNAME,p1.FNUMBER,p1.Fname_l2 as PERSONNAME, ti.fIncomeCode ");
+        sqlBuf.append(" FROM T_HR_STaxCalConfigDetail tx  ");
+        sqlBuf.append(" left join T_HR_TAXUNIT as t1 on t1.fid = tx.FTaxUnitID  ");
+        sqlBuf.append(" left join T_BD_PERSON as p1 on p1.fid = tx.FPersonId  ");
+        sqlBuf.append(" left join t_hr_sTaxIncomeItem as ti on tx.fIncomeItemId = ti.fid ");
+        String dateFilter = CmpSQLUtil.generateSqlDateFilter("tx.FPeriodBegin", "tx.FPeriodEnd", yearMonth);
+        sqlBuf.append(" where ").append(dateFilter);
+        sqlBuf.append(" and tx.FTAXUNITID='").append(taxUnitId).append("'");
+        sqlBuf.append(" and tx.FSTATE=10");
+        sqlBuf.append(" and tx.FIsLast=1");
+        sqlBuf.append(" and tx.FIncomeItemId in ").append(incomeIdMap.get(typeEnum.getValue()));
+        return sqlBuf.toString();
+    }
+
+    //private Map<String, Object> checkTaxDeclareData(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException {
+    //    Map<String, Object> checkDataResultMap = new HashMap();
+    //    return null;
+    //}
+    private Map<String, Object> checkTaxDeclareData(Context ctx, HttpServletRequest request, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException, SQLException, ShrWebBizException {
+        Map<String, Object> checkDataResultMap = new HashMap();
+        boolean hasErrData = false;
+        if (waitToDeclareList != null && waitToDeclareList.size() > 0) {
+            List<String> preCheckSql = new ArrayList();
+            List<String> specCheckForPre = new ArrayList();
+            List<String> notPersonCheckSql = new ArrayList();
+            List<String> classifyCheckSql = new ArrayList();
+            Map<String, Object> incomeIdMap = new HashMap();
+            incomeIdMap.put("1", CmpTaxUtil.genIncomeItemId(ctx, "1"));
+            incomeIdMap.put("2", CmpTaxUtil.genIncomeItemId(ctx, "2"));
+            incomeIdMap.put("3", CmpTaxUtil.genIncomeItemId(ctx, "3"));
+            Iterator i$ = waitToDeclareList.iterator();
+
+            String yearMonth;
+            while (i$.hasNext()) {
+                IncomeTaxDeclarInfo declareInfo = (IncomeTaxDeclarInfo) i$.next();
+                TbTypeEnum tbType = declareInfo.getTbType();
+                String taxUnitId = declareInfo.getTaxUnit().getId().toString();
+                yearMonth = declareInfo.getYearMonth();
+                if (tbType != null) {
+                    if ("1".equals(tbType.getValue())) {
+                        preCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0701));
+                        specCheckForPre.add(this.getPreCheckSql(declareInfo));
+                    } else if ("3".equals(tbType.getValue())) {
+                        notPersonCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0703));
+                    } else {
+                        classifyCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0702));
+                    }
+                }
+            }
+
+            Map<String, String> reasonOperaMap = new HashMap();
+            reasonOperaMap.put("noCalDataReson", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label140", ctx.getLocale()));
+            reasonOperaMap.put("noCalDataOper", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label141", ctx.getLocale()));
+            reasonOperaMap.put("preDataReason", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label142", ctx.getLocale()));
+            reasonOperaMap.put("preDataOpera", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label143", ctx.getLocale()));
+            List<TaxDeclarExcelRowDTO> taxDeclareExcelRowDTOS = new ArrayList();
+            taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, preCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0701));
+            taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, classifyCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0702));
+            taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, notPersonCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0703));
+            String filePath = "";
+            if (taxDeclareExcelRowDTOS.size() > 0) {
+                hasErrData = true;
+                HSSFWorkbook workbook = new HSSFWorkbook();
+                yearMonth = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label144", ctx.getLocale());
+                this.fillTitle(ctx, workbook, yearMonth.split(","));
+                this.fillWorkdBookData(workbook, taxDeclareExcelRowDTOS);
+                SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+                File dir = new File(UserUtil.getUserTempDirAbsolutePath(request.getSession()));
+                if (!dir.exists()) {
+                    dir.mkdirs();
+                }
+
+                String fileName = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label145", ctx.getLocale()) + "_" + format.format(new Date()) + ".xls";
+                String realFileName = MD5.md5Hash(fileName);
+                File file = new File(dir, realFileName);
+                FileOutputStream out = null;
+
+                try {
+                    out = new FileOutputStream(file);
+                    workbook.write(out);
+                    out.flush();
+                } catch (FileNotFoundException var33) {
+                    LOG.error(var33.getMessage(), var33);
+                } catch (IOException var34) {
+                    LOG.error(var34.getMessage(), var34);
+                } finally {
+                    if (out != null) {
+                        try {
+                            out.close();
+                        } catch (IOException var32) {
+                            LOG.error(var32.getMessage(), var32);
+                        }
+                    }
+
+                }
+
+                Map<String, String> params = new HashMap();
+                params.put("method", "tmp");
+                params.put("file", realFileName);
+                params.put("filename", fileName);
+                filePath = DynamicUtil.assembleUrl("/downloadfile.do", params);
+            }
+
+            checkDataResultMap.put("excel", filePath);
         }
-        return laborRemunerationIncome;
+
+        checkDataResultMap.put("hasErrData", hasErrData);
+        return checkDataResultMap;
     }
 
-    /**
-     * 获取全年一次性奖金
-     * 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;
+    private void fillTitle(Context ctx, HSSFWorkbook workbook, String[] titleArr) {
+        HSSFSheet sheet = workbook.createSheet();
+        HSSFRow createRow = sheet.createRow(0);
+        HSSFCell infoCell = createRow.createCell(0);
+        infoCell.setCellValue(EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label146", ctx.getLocale()));
+        sheet.setColumnWidth(0, 12800);
+        createRow = sheet.createRow(1);
+        HSSFFont font = workbook.createFont();
+        font.setColor((short) 8);
+        font.setFontHeightInPoints((short) 12);
+        font.setBoldweight((short) 700);
+        HSSFCellStyle style = workbook.createCellStyle();
+        style.setFont(font);
+        style.setAlignment((short) 2);
+        style.setVerticalAlignment((short) 1);
+        if (titleArr != null && titleArr.length > 0) {
+            for (int i = 0; i < titleArr.length; ++i) {
+                HSSFCell cell = createRow.createCell(i);
+                cell.setCellStyle(style);
+                cell.setCellValue(titleArr[i]);
+                if (i > 3) {
+                    sheet.setColumnWidth(i, 15360);
+                } else {
+                    sheet.setColumnWidth(i, 7680);
+                }
+            }
+        }
+
     }
 
-    /**
-     * 全年一次性奖金收入列表
-     *
-     * @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);
+    private void fillWorkdBookData(HSSFWorkbook workbook, List<TaxDeclarExcelRowDTO> dataList) {
+        HSSFSheet sheet = workbook.getSheetAt(0);
+        if (dataList != null && dataList.size() > 0) {
+            for (int i = 0; i < dataList.size(); ++i) {
+                HSSFRow row = sheet.createRow(i + 2);
+                TaxDeclarExcelRowDTO excelRowDTO = (TaxDeclarExcelRowDTO) dataList.get(i);
+                HSSFCell cell = row.createCell(0);
+                cell.setCellValue(excelRowDTO.getPersonNum());
+                cell = row.createCell(1);
+                cell.setCellValue(excelRowDTO.getPersonName());
+                cell = row.createCell(2);
+                cell.setCellValue(excelRowDTO.getTaxName());
+                cell = row.createCell(3);
+                cell.setCellValue(excelRowDTO.getDeclarType());
+                cell = row.createCell(4);
+                cell.setCellValue(excelRowDTO.getReason());
+                cell = row.createCell(5);
+                cell.setCellValue(excelRowDTO.getOperation());
+            }
         }
-        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;
+    private String getSqlDateFilterLqDate(String dateStr) {
+        String[] beginDateArr = dateStr.split("-");
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Integer.parseInt(beginDateArr[0]), Integer.parseInt(beginDateArr[1]) - 1, 1, 0, 0, 0);
+        Date beginDate = calendar.getTime();
+        return CmpDateUtil.toKSqlDate(beginDate);
+    }
+
+    private List<TaxDeclarExcelRowDTO> getExceptData(Context ctx, List<String> preCheckSql, List<String> specCheckForPre, Map<String, String> noCalDataOper, TbTypeEnum typeEnum) throws BOSException, SQLException, ShrWebBizException {
+        List<TaxDeclarExcelRowDTO> taxDeclarExcelRowDTOS = new ArrayList();
+        Iterator i$;
+        String s;
+        IRowSet rowSet;
+        TaxDeclarExcelRowDTO taxDeclareExcelRow;
+        if (preCheckSql != null && preCheckSql.size() > 0) {
+            i$ = preCheckSql.iterator();
+
+            while (i$.hasNext()) {
+                s = (String) i$.next();
+                rowSet = DbUtil.executeQuery(ctx, s);
+
+                while (rowSet.next()) {
+                    taxDeclareExcelRow = new TaxDeclarExcelRowDTO();
+                    taxDeclareExcelRow.setPersonNum(rowSet.getString("FNUMBER"));
+                    taxDeclareExcelRow.setPersonName(rowSet.getString("PERSONNAME"));
+                    String taxUnitName = rowSet.getString("TAXNAME");
+                    taxDeclareExcelRow.setTaxName(taxUnitName);
+                    taxDeclareExcelRow.setDeclarType(typeEnum.getAlias());
+                    taxDeclareExcelRow.setReason((String) noCalDataOper.get("noCalDataReson"));
+                    taxDeclareExcelRow.setOperation((String) noCalDataOper.get("noCalDataOper"));
+                    String incomeCode = (String) noCalDataOper.get("fIncomeCode");
+                    taxDeclarExcelRowDTOS.add(taxDeclareExcelRow);
+                }
+            }
+        }
+
+        if ("1".equals(typeEnum.getValue()) && specCheckForPre != null && specCheckForPre.size() > 0) {
+            i$ = specCheckForPre.iterator();
+
+            while (i$.hasNext()) {
+                s = (String) i$.next();
+                rowSet = DbUtil.executeQuery(ctx, s);
+
+                while (rowSet.next()) {
+                    taxDeclareExcelRow = new TaxDeclarExcelRowDTO();
+                    taxDeclareExcelRow.setPersonNum(rowSet.getString("FNUMBER"));
+                    taxDeclareExcelRow.setPersonName(rowSet.getString("PERSONNAME"));
+                    taxDeclareExcelRow.setTaxName(rowSet.getString("TAXNAME"));
+                    taxDeclareExcelRow.setDeclarType(typeEnum.getAlias());
+                    taxDeclareExcelRow.setReason((String) noCalDataOper.get("preDataReason"));
+                    taxDeclareExcelRow.setOperation((String) noCalDataOper.get("preDataOpera"));
+                    taxDeclarExcelRowDTOS.add(taxDeclareExcelRow);
+                }
+            }
+        }
+
+        return taxDeclarExcelRowDTOS;
+    }
+
+    private String getPreCheckSql(IncomeTaxDeclarInfo incomeTaxDeclarInfo) {
+        StringBuilder sqlBuf = new StringBuilder();
+        String yearMonth = incomeTaxDeclarInfo.getYearMonth();
+        String taxUnitId = incomeTaxDeclarInfo.getTaxUnit().getId().toString();
+        String sql = "select FPersonID from T_HR_STaxCalConfigDetail where FTaxUnitId='" + taxUnitId + "' and FPeriodBegin = " + CmpDateUtil.toKSqlDate(incomeTaxDeclarInfo.getYearMonthDate());
+        sqlBuf.append(" SELECT distinct ent.FTAXUNITID, t.Fname_l2 as TAXNAME, p.FNUMBER, p.Fname_l2 as PERSONNAME ");
+        sqlBuf.append(" FROM T_HR_STaxPersonRecordEntry ent ");
+        sqlBuf.append(" left join T_HR_TAXUNIT as t on t.fid = ent.FTaxUnitID ");
+        sqlBuf.append(" left join T_BD_PERSON as p on p.fid = ent.FPersonId ");
+        sqlBuf.append(" where ent.FSubmitStatus='2' and ent.FPersonStatus='1' ");
+        sqlBuf.append(" and ent.FTaxUnitID='").append(taxUnitId).append("'");
+        sqlBuf.append(" and ent.FENDDATE <=").append(this.getSqlDateFilterLqDate(yearMonth));
+        sqlBuf.append(" and ent.FPersonID not in ( ").append(sql).append(" )");
+        return sqlBuf.toString();
+    }
+
+    private Map<String, Object> checkIncomeTaxIssue(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException {
+        StringBuilder taxUnitIds = new StringBuilder();
+
+        IncomeTaxDeclarInfo declareInfo;
+        for (Iterator i$ = waitToDeclareList.iterator(); i$.hasNext(); taxUnitIds.append(declareInfo.getTaxUnit().getId().toString())) {
+            declareInfo = (IncomeTaxDeclarInfo) i$.next();
+            if (taxUnitIds.length() > 0) {
+                taxUnitIds.append(",");
+            }
+        }
+
+        String oql = "select person.person.name where taxUnit.id in " + CmpStrUtil.buildInSql(taxUnitIds.toString()) + " and result = " + 1 + " and status = " + 2 + " and inviteStatus = " + 0;
+        IncomeTaxIssueCollection collection = IncomeTaxIssueFactory.getLocalInstance(ctx).getIncomeTaxIssueCollection(oql);
+        if (collection != null && !collection.isEmpty()) {
+            StringBuilder errMsg = new StringBuilder();
+
+            for (int i = 0; i < collection.size() && i != 5; ++i) {
+                if (errMsg.length() > 0) {
+                    errMsg.append(",");
+                }
+
+                errMsg.append("[").append(collection.get(i).getPerson().getPerson().getName()).append("]");
+            }
+
+            Map<String, Object> map = new HashMap();
+            map.put("errMsg", "以下员工存在申诉属实争议,且未进行邀请确认,需要进行发送邀请确认后才可进行个税申报或者进行非正常人员报送(更新人员报税信息中的人员状态为非正常,并进行人员报送成功),员工姓名:" + errMsg.toString() + ",选择[是]则跳转到[申诉争议-申诉属实人员]列表,选择[否]则跳转到[人员报税信息]列表。");
+            map.put("issueError", true);
+            return map;
+        } else {
+            return null;
+        }
+    }
+
+    private String checkTaxCalStatus(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws SHRWebException {
+        String sql = "select t.fState, u.fName_l2 taxUnitName, d.fIncomeItemId  from t_hr_sTaxCalConfigDetail d left join t_hr_sTaxCalInitDetail t  on d.fCmpCalTableId = t.fCmpCalTableId and d.fIncomeItemId = t.fIncomeItemId  left join t_hr_taxUnit u on d.fTaxUnitId = u.fid  where d.fTaxUnitId = ? and d.fPeriodBegin = ?";
+
+        try {
+            Iterator i$ = waitToDeclareList.iterator();
+
+            boolean isTaxCalFinished;
+            String taxUnitName;
+            do {
+                if (!i$.hasNext()) {
+                    return null;
+                }
+
+                IncomeTaxDeclarInfo declareInfo = (IncomeTaxDeclarInfo) i$.next();
+                String taxUnitId = declareInfo.getTaxUnit().getId().toString();
+                Date periodDate = declareInfo.getYearMonthDate();
+                Object[] param = new Object[]{taxUnitId, CmpDateUtil.toSqlDate(periodDate)};
+                IRowSet rs = DbUtil.executeQuery(ctx, sql, param);
+                boolean havingSalaryIncome = false;
+                isTaxCalFinished = true;
+                taxUnitName = "";
+
+                while (rs.next()) {
+                    int state = rs.getInt("fState");
+                    taxUnitName = rs.getString("taxUnitName");
+                    String incomeItemId = rs.getString("fIncomeItemId");
+                    if (state != 40) {
+                        isTaxCalFinished = false;
+                    }
+
+                    if ("8r0AAABCg2PDiOoP".equals(incomeItemId)) {
+                        havingSalaryIncome = true;
+                    }
+                }
+
+                TbTypeEnum typeEnum = declareInfo.getTbType();
+                if (!havingSalaryIncome && typeEnum == TbTypeEnum.SB0701) {
+                    return "纳税单位[" + taxUnitName + "]当期预扣预缴申报表未包含所得项目为正常工资薪金所得的员工,不允许申报,请确认";
+                }
+            } while (isTaxCalFinished);
+
+            return "纳税单位【" + taxUnitName + "】存在接口算税未完成的数据,请确认";
+        } catch (Exception var15) {
+            LOG.error("checkTaxCalStatus error: ", var15);
+            throw new SHRWebException(var15.getMessage());
+        }
     }
 
     /**
-     * 人员
+     * 异常提醒
      *
+     * @param advanceDeclareInfo
      * @return
      */
-    public DetailCompanyEmployee getDetailCompanyEmployee() {
+    private String combineError(List<String> advanceDeclareInfo) {
+        StringBuilder error = new StringBuilder();
+        error.append("以下纳税单位尚未到申报时间,请不要提前申报:");
+        Iterator i$ = advanceDeclareInfo.iterator();
 
-        //人员对象
-        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;
+        while (i$.hasNext()) {
+            String taxUnitInfo = (String) i$.next();
+            if (advanceDeclareInfo.indexOf(taxUnitInfo) == 5) {
+                error.append("...");
+                break;
+            }
+
+            if (advanceDeclareInfo.indexOf(taxUnitInfo) > 0) {
+                error.append(",");
+            }
+
+            String[] arr = taxUnitInfo.split("_");
+            error.append(arr[0]).append("【").append(arr[1]).append("】");
+        }
+
+        return error.toString();
     }
 
+
     /**
-     * 获取正常工资薪金参数
+     * 获取个税申报审批通过数据
      *
+     * @param ctx
+     * @param selectedId
      * @return
+     * @throws BOSException
      */
-    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);
+    private Map<String, Object> getDeclareData(Context ctx, String selectedId) throws BOSException, JsonProcessingException {
+        Map<String, Object> resultMap = new HashMap();
+        List<TaxDeclareDTO> declaredList = new ArrayList();
+        List<IncomeTaxDeclarInfo> waitToDeclareList = new ArrayList();
+        String sqlInString = CmpUtils.spiltToSqlString(selectedId);
+        if (StringUtils.isEmpty(sqlInString)) {
+            sqlInString = "''";
         }
-        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("残疾证");
+        String currentYearMonth = CmpDateUtil.getDateStr(new Date(), "yyyy-MM");
+        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 + " )";
+        LOG.error("getDeclareData----------oqlBuffer------" + oqlBuffer);
+        IncomeTaxDeclarCollection declareCollection = IncomeTaxDeclarFactory.getLocalInstance(ctx).getIncomeTaxDeclarCollection(oqlBuffer);
+        LOG.error("getDeclareData----------declareCollection------" + declareCollection.size());
+        String ms1 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label137", ctx.getLocale());
+        String ms2 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label138", ctx.getLocale());
+        String ms3 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label139", ctx.getLocale());
+        List<String> taxUnitInfo = new ArrayList();
+        if (declareCollection != null && declareCollection.size() > 0) {
+            for (int i = 0; i < declareCollection.size(); ++i) {
+                IncomeTaxDeclarInfo declareInfo = declareCollection.get(i);
+                String declareStatus = declareInfo.getDeclareStatus().getValue();
+                LOG.error("getDeclareData----------declareStatus------" + declareStatus);
+                String taxUnitName = declareInfo.getTaxUnit().getName();
+                String tbTypeAlia = declareInfo.getTbType().getAlias();
+                if (currentYearMonth.compareTo(declareInfo.getYearMonth()) <= 0) {
+                    taxUnitInfo.add(declareInfo.getTaxUnit().getName() + "_" + declareInfo.getYearMonth());
+                }
+                if (!"1".equals(declareStatus) && !"2".equals(declareStatus)) {
+                    waitToDeclareList.add(declareInfo);
+                    LOG.error("getDeclareData----------waitToDeclareList------" + waitToDeclareList);
+                } else {
+                    TaxDeclareDTO dto = new TaxDeclareDTO(taxUnitName, tbTypeAlia);
+                    declaredList.add(dto);
+                }
+            }
+
+            if (declaredList.size() == declareCollection.size()) {
+                resultMap.put("info", ms1);
+            } else if (declaredList.size() == 0) {
+                resultMap.put("info", ms2);
+            } else {
+                resultMap.put("info", ms3);
             }
-            //是否烈属
-            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;
+        LOG.error("getDeclareData----------resultMap------" + resultMap);
+
+        resultMap.put("DECLARED", declaredList);
+        resultMap.put("advanceDeclareInfo", taxUnitInfo);
+        resultMap.put("WATI_TO_DECLARE", waitToDeclareList);
+        return resultMap;
     }
+
 }

+ 185 - 5
websrc/com/kingdee/eas/custom/compensation/service/SynIncomeTaxDeclareService.java

@@ -9,17 +9,34 @@ 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.ctrl.swing.StringUtils;
+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.bos.util.BOSUuid;
+import com.kingdee.eas.basedata.person.PersonInfo;
 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 com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.compensation.app.tax.*;
+import com.kingdee.shr.compensation.app.tax.base.ITaxIncomeItem;
+import com.kingdee.shr.compensation.app.tax.base.TaxIncomeItemFactory;
+import com.kingdee.shr.compensation.app.tax.base.TaxIncomeItemInfo;
+import com.kingdee.shr.compensation.app.taxCal.ITaxCalConfigDetail;
+import com.kingdee.shr.compensation.app.taxCal.TaxCalConfigDetailCollection;
+import com.kingdee.shr.compensation.app.taxCal.TaxCalConfigDetailFactory;
+import com.kingdee.shr.compensation.app.taxCal.TaxCalConfigDetailInfo;
 import org.apache.log4j.Logger;
 
 import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.util.*;
 
 /**
  * @author qingwu
@@ -40,9 +57,9 @@ public class SynIncomeTaxDeclareService implements IHRMsfService {
         JSONObject paramData = JSONObject.parseObject((String) map.get("paramData"));
         logger.error("paramData--------" + paramData);
         String requestId = paramData.getString("requestId");
-        //JSONObject param = paramData.getJSONObject("param");
+        JSONObject param = paramData.getJSONObject("param");
         logger.error("requestId--------" + requestId);
-        //logger.error("param--------" + param);
+        logger.error("param--------" + param);
         ObjectMapper mapper = new ObjectMapper();
         try {
             //客户端代理工厂
@@ -67,7 +84,9 @@ public class SynIncomeTaxDeclareService implements IHRMsfService {
                 body = feedback.getBody();
                 logInfo.setOutParameter(mapper.writeValueAsString(body));//回参
                 LogInfoFactory.getLocalInstance(context).addnew(logInfo);
+
             }
+
             return MessageResult.SUCCESS(mapper.writeValueAsString(body));
         } catch (IOException e) {
             e.printStackTrace();
@@ -78,4 +97,165 @@ public class SynIncomeTaxDeclareService implements IHRMsfService {
         }
     }
 
+    /**
+     * 保存个税申报结果
+     *
+     * @param param
+     */
+    public void saveTaxDeclaration(Context ctx, JSONObject param) throws BOSException {
+        //个税申报ID
+        String taxDeclarId = param.getString("taxDeclarId");
+        //个税申报批次号
+        String taxDeclarBatchNo = param.getString("taxDeclarBatchNo");
+        ////个税应用+税款计算最终拆分明细表
+        //ITaxCalConfigDetail taxCalConfigDetail = TaxCalConfigDetailFactory.getLocalInstance(ctx);
+        //TaxCalConfigDetailCollection taxCalConfigDetailCollection = taxCalConfigDetail.getTaxCalConfigDetailCollection("select *,incomeItem.*, person.* where batchNo = '" + taxDeclarBatchNo + "' and state = '20'");
+        //for (int i = 0; i < taxCalConfigDetailCollection.size(); i++) {
+        //    TaxCalConfigDetailInfo taxCalConfigDetailInfo = taxCalConfigDetailCollection.get(i);
+        //    //员工信息
+        //    PersonInfo person = taxCalConfigDetailInfo.getPerson();
+        //}
+        try {
+            //个税申报表
+            ITaxDeclaration iTaxDeclaration = TaxDeclarationFactory.getLocalInstance(ctx);
+            //个税项目
+            ITaxIncomeItem iTaxIncomeItem = TaxIncomeItemFactory.getLocalInstance(ctx);
+            List<Map<String, Object>> taxDeclarationDate = getTaxDeclarationDate(ctx, taxDeclarBatchNo);
+            for (int i = 0; i < taxDeclarationDate.size(); i++) {
+                Map<String, Object> map = taxDeclarationDate.get(i);
+                TaxIncomeItemInfo taxIncomeItemInfo = iTaxIncomeItem.getTaxIncomeItemCollection("where id = '" + map.get("incomeitmemId") + "'").get(0);
+
+                FilterInfo filterInfo = new FilterInfo();
+                filterInfo.getFilterItems().add(new FilterItemInfo("person", map.get("personId"), CompareType.EQUALS));
+                filterInfo.getFilterItems().add(new FilterItemInfo("taxUnit", map.get("taxunitId"), CompareType.EQUALS));
+                filterInfo.getFilterItems().add(new FilterItemInfo("taxPeriodBegin", map.get("periodbegin"), CompareType.EQUALS));
+                filterInfo.getFilterItems().add(new FilterItemInfo("taxPeriodEnd", map.get("periodend"), CompareType.EQUALS));
+                filterInfo.getFilterItems().add(new FilterItemInfo("proceedItem", taxIncomeItemInfo.getName(), CompareType.EQUALS));
+                EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
+                TaxDeclarationCollection taxDeclarationCollection = iTaxDeclaration.getTaxDeclarationCollection(entityViewInfo);
+                if (taxDeclarationCollection.size() <= 0) {
+                    TaxDeclarationInfo taxDeclarationInfo = new TaxDeclarationInfo();
+                    //员工
+                    PersonInfo personInfo = new PersonInfo();
+                    personInfo.setId(BOSUuid.read((String) map.get("personId")));
+                    taxDeclarationInfo.setPerson(personInfo);
+                    //纳税单位
+                    TaxUnitInfo taxUnitInfo = new TaxUnitInfo();
+                    taxUnitInfo.setId(BOSUuid.read((String) map.get("taxunitId")));
+                    taxDeclarationInfo.setTaxUnit(taxUnitInfo);
+                    //税款所属期间起始时间
+                    taxDeclarationInfo.setTaxPeriodBegin((Date) map.get("periodbegin"));
+                    //税款所属期间截止时间
+                    taxDeclarationInfo.setTaxPeriodEnd((Date) map.get("periodend"));
+                    //个税项目
+                    taxDeclarationInfo.setProceedItem(taxIncomeItemInfo.getName());
+                    taxDeclarationInfo.setCost((BigDecimal) map.get("t25"));//费用
+                    taxDeclarationInfo.setIncome((BigDecimal) map.get(" t1"));//收入
+                    taxDeclarationInfo.setExemptIncome((BigDecimal) map.get("t2"));//免税收入
+                    taxDeclarationInfo.setBasicPension((BigDecimal) map.get("t3"));//基本养老保险费
+                    taxDeclarationInfo.setBasicMedical((BigDecimal) map.get("t4"));//基本医疗保险费
+                    taxDeclarationInfo.setUnemployment((BigDecimal) map.get("t5"));//失业保险费
+                    taxDeclarationInfo.setHousingFund((BigDecimal) map.get("t6"));//住房公积金
+                    taxDeclarationInfo.setChildEducateSum((BigDecimal) map.get("t7"));//累计子女教育
+                    taxDeclarationInfo.setContinueEducateSum((BigDecimal) map.get("t8"));//累计继续教育
+                    taxDeclarationInfo.setLoanInterestSum((BigDecimal) map.get("t9"));//累计住房贷款利息
+                    taxDeclarationInfo.setHousingRentSum((BigDecimal) map.get("t10"));//累计住房租金
+                    taxDeclarationInfo.setOldSupportSum((BigDecimal) map.get("t11"));//累计赡养老人
+                    taxDeclarationInfo.setIncomeSum((BigDecimal) map.get("t20"));//累计收入额
+                    taxDeclarationInfo.setDeductionSum((BigDecimal) map.get("t24"));//累计减除费用
+                    taxDeclarationInfo.setSpecialDeductSum((BigDecimal) map.get("t26"));//累计专项扣除
+                    taxDeclarationInfo.setOtherDeductionSum((BigDecimal) map.get("t28"));//累计其他扣除
+                    taxDeclarationInfo.setAllowDonationSum((BigDecimal) map.get("t29"));//累计准予扣除的捐赠
+                    taxDeclarationInfo.setTaxableIncomeSum((BigDecimal) map.get("t30"));//累计应纳税所得额
+                    taxDeclarationInfo.setTaxRatio((BigDecimal) map.get("t31"));//税率
+                    taxDeclarationInfo.setQuickDeduct((BigDecimal) map.get("t32"));//速算扣除数
+                    taxDeclarationInfo.setTaxPayableSum((BigDecimal) map.get("t33"));//累计应纳税额
+                    taxDeclarationInfo.setTaxCreditSum((BigDecimal) map.get("t34"));//累计减免税额
+                    taxDeclarationInfo.setTaxSupOrRefund((BigDecimal) map.get("t38"));//应补/退税额
+                    taxDeclarationInfo.setInFantSum((BigDecimal) map.get("t45"));//累计婴幼儿照护费用
+                    taxDeclarationInfo.setPersonalPension((BigDecimal) map.get("t46"));//累计个人养老金
+                    iTaxDeclaration.save(taxDeclarationInfo);
+                }
+            }
+        } catch (SQLException e) {
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        } catch (EASBizException e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+
+    /***
+     * 封装个税申报数据
+     * @param batchNo
+     * @return
+     */
+    public List<Map<String, Object>> getTaxDeclarationDate(Context ctx, String batchNo) throws BOSException, SQLException {
+        List list = new ArrayList();
+        String sql = getSql(batchNo);
+        IRowSet iRowSet = DbUtil.executeQuery(ctx, sql);
+        while (iRowSet.next()) {
+            Map map = new HashMap();
+            map.put("personId", iRowSet.getString("personId"));//员工Id
+            map.put("taxunitId", iRowSet.getString("taxunitId"));//纳税单位Id
+            map.put("periodbegin", iRowSet.getDate("periodbegin"));//税款所属期间起始时间
+            map.put("periodend", iRowSet.getDate("periodend"));//税款所属期间截止时间
+            map.put("incomeitmemId", iRowSet.getString("incomeitmemId"));//个税项目Id
+            map.put("t25", iRowSet.getBigDecimal("t25"));//本期收入
+            map.put("t1", iRowSet.getBigDecimal(" t1"));//本期免税收入
+            map.put("t2", iRowSet.getBigDecimal("t2"));//基本养老保险费
+            map.put("t3", iRowSet.getBigDecimal("t3"));//基本医疗保险费
+            map.put("t4", iRowSet.getBigDecimal("t4"));//失业保险费
+            map.put("t5", iRowSet.getBigDecimal("t5"));//住房公积金
+            map.put("t6", iRowSet.getBigDecimal("t6"));//累计子女教育
+            map.put("t7", iRowSet.getBigDecimal("t7"));//累计继续教育
+            map.put("t8", iRowSet.getBigDecimal("t8"));//累计住房贷款利息
+            map.put("t9", iRowSet.getBigDecimal("t9"));//累计住房租金
+            map.put("t10", iRowSet.getBigDecimal("t10"));//累计赡养老人
+            map.put("t11", iRowSet.getBigDecimal("t11"));//其他
+            map.put("t15", iRowSet.getBigDecimal("t15"));//本期累计收入
+            map.put("t20", iRowSet.getBigDecimal("t20"));//本期累计免税收入
+            map.put("t22", iRowSet.getBigDecimal("t22"));//累计减除费用
+            map.put("t24", iRowSet.getBigDecimal("t24"));//累计专项扣除
+            map.put("t26", iRowSet.getBigDecimal("t26"));//累计其他扣除
+            map.put("t28", iRowSet.getBigDecimal("t28"));//累计准予扣除的捐赠
+            map.put("t29", iRowSet.getBigDecimal("t29"));//累计应纳税所得额
+            map.put("t30", iRowSet.getBigDecimal("t30"));//税率
+            map.put("t31", iRowSet.getBigDecimal("t31"));//速算扣除数
+            map.put("t32", iRowSet.getBigDecimal("t32"));//累计应纳税额
+            map.put("t33", iRowSet.getBigDecimal("t33"));//累计减免税额
+            map.put("t34", iRowSet.getBigDecimal("t34"));//累计应扣缴税额
+            map.put("t35", iRowSet.getBigDecimal("t35"));//累计已预缴税额
+            map.put("t36", iRowSet.getBigDecimal("t36"));//本期应补(退)税额
+            map.put("t38", iRowSet.getBigDecimal("t38"));//备注
+            map.put("t41", iRowSet.getBigDecimal("t41"));//累计婴幼儿照护费用
+            map.put("t45", iRowSet.getBigDecimal("t45"));//累计个人养老金
+            list.add(map);
+        }
+        return list;
+    }
+
+    /**
+     * 查询个税申报人员数据
+     *
+     * @param batchNo
+     * @return
+     */
+    public String getSql(String batchNo) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("select").append("\n");
+        sb.append(" taxCalConfigDetail.FPERSONID as personId,").append("\n");
+        sb.append(" taxCalConfigDetail.FTAXUNITID as taxunitId,").append("\n");
+        sb.append("taxCalConfigDetail.FPERIODBEGIN as periodbegin,\n").append("\n");
+        sb.append("taxCalConfigDetail.FPERIODEND as periodend,\n").append("\n");
+        sb.append("taxCalConfigDetail.FINCOMEITEMID as incomeitmemId,\n").append("\n");
+        sb.append(" t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t15,t20,t22,t24,t25,t26,t28,t29,t30,t31,t32,t33,t34,t35,t36,t38,t41,t45,t46\n").append("\n");
+        sb.append(" from T_HR_STaxCalConfigDetail taxCalConfigDetail\n").append("\n");
+        sb.append("where").append("\n");
+        sb.append("FBATCHNO = '").append(batchNo).append("'").append("\n");
+        return sb.toString();
+    }
+
+
 }

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

@@ -87,9 +87,11 @@ public class SynIndividualIncomeTaxService implements IHRMsfService {
                 //µ÷Óóɹ¦
                 //ÇëÇóid
                 body = aSynIndividualIncomeTaxFeedback.getBody();
+                logger.error("SynIndividualIncomeTaxService----------body---" + mapper.writeValueAsString(body));
                 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));
@@ -205,6 +207,7 @@ public class SynIndividualIncomeTaxService implements IHRMsfService {
         BigDecimal refundTax = complexIncome.getRefundTax();
         taxPaymentBackCalculateInfo.setIndividual(refundTax);
         IObjectPK save = iTaxPaymentBackCalculate.save(taxPaymentBackCalculateInfo);
+        logger.error("saveTaxPaymentBackCalculateCollection----------save---" + save);
         return taxPaymentBackCalculateCollection;
     }
 }