IncomeTaxDeclareListHandlerEx.java 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. package com.kingdee.eas.custom.compensation.handler;
  2. import cn.com.servyou.dto.ApiResponse;
  3. import cn.com.servyou.dto.AsyncResult;
  4. import cn.com.servyou.dto.declare.CompanyDeclareRequest;
  5. import cn.com.servyou.dto.declare.DeclareCancelRequest;
  6. import cn.com.servyou.dto.declare.DeclareCorrectRequest;
  7. import cn.com.servyou.dto.tax.*;
  8. import cn.com.servyou.rmi.client.ClientProxyFactory;
  9. import cn.com.servyou.service.DeclarationRequest;
  10. import com.alibaba.fastjson.JSONObject;
  11. import com.fasterxml.jackson.core.JsonProcessingException;
  12. import com.fasterxml.jackson.databind.ObjectMapper;
  13. import com.google.gson.Gson;
  14. import com.google.gson.reflect.TypeToken;
  15. import com.kingdee.bos.BOSException;
  16. import com.kingdee.bos.Context;
  17. import com.kingdee.bos.dao.ormapping.impl.ImplUtils;
  18. import com.kingdee.bos.metadata.entity.*;
  19. import com.kingdee.bos.metadata.query.util.CompareType;
  20. import com.kingdee.bos.util.EASResource;
  21. import com.kingdee.eas.basedata.hraux.NationalityInfo;
  22. import com.kingdee.eas.basedata.person.PersonCollection;
  23. import com.kingdee.eas.basedata.person.PersonFactory;
  24. import com.kingdee.eas.basedata.person.PersonInfo;
  25. import com.kingdee.eas.common.EASBizException;
  26. import com.kingdee.eas.custom.shuiyou.task.TaskCatalogEnum;
  27. import com.kingdee.eas.custom.shuiyou.uitls.ISYUtilsFacade;
  28. import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacadeFactory;
  29. import com.kingdee.eas.custom.shuiyou.utils.ClientProxyFactoryUtils;
  30. import com.kingdee.eas.util.app.DbUtil;
  31. import com.kingdee.jdbc.rowset.IRowSet;
  32. import com.kingdee.jdbc.rowset.IRowSetMetaData;
  33. import com.kingdee.shr.base.syssetting.context.SHRContext;
  34. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  35. import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
  36. import com.kingdee.shr.base.syssetting.web.dynamic.util.DynamicUtil;
  37. import com.kingdee.shr.base.syssetting.web.dynamic.util.MD5;
  38. import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
  39. import com.kingdee.shr.base.syssetting.web.util.UserUtil;
  40. import com.kingdee.shr.compensation.TaxDeclareStatusEnum;
  41. import com.kingdee.shr.compensation.TbTypeEnum;
  42. import com.kingdee.shr.compensation.app.incomeTax.ITaxPersonRecordEntry;
  43. import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordEntryCollection;
  44. import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordEntryFactory;
  45. import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordEntryInfo;
  46. import com.kingdee.shr.compensation.app.tax.*;
  47. import com.kingdee.shr.compensation.app.tax.base.TaxIncomeItemInfo;
  48. import com.kingdee.shr.compensation.app.taxCal.*;
  49. import com.kingdee.shr.compensation.helper.CmpConstants;
  50. import com.kingdee.shr.compensation.taxCal.util.TaxCalcFileUtils;
  51. import com.kingdee.shr.compensation.util.*;
  52. import com.kingdee.shr.compensation.web.handler.tax.IncomeTaxDeclareListHandler;
  53. import com.kingdee.shr.compensation.web.handler.tax.dto.TaxDeclarExcelRowDTO;
  54. import com.kingdee.shr.compensation.web.handler.tax.dto.TaxDeclareDTO;
  55. import com.kingdee.util.StringUtils;
  56. import org.apache.log4j.Logger;
  57. import org.apache.poi.hssf.usermodel.*;
  58. import org.springframework.ui.ModelMap;
  59. import javax.servlet.http.HttpServletRequest;
  60. import javax.servlet.http.HttpServletResponse;
  61. import java.io.File;
  62. import java.io.FileNotFoundException;
  63. import java.io.FileOutputStream;
  64. import java.io.IOException;
  65. import java.lang.reflect.Type;
  66. import java.math.BigDecimal;
  67. import java.net.URLEncoder;
  68. import java.sql.SQLException;
  69. import java.text.SimpleDateFormat;
  70. import java.util.*;
  71. /**
  72. * @author qingwu
  73. * @date 2024/9/18
  74. * @apiNote 个税申报扩展
  75. */
  76. public class IncomeTaxDeclareListHandlerEx extends IncomeTaxDeclareListHandler {
  77. private static final Logger LOG = Logger.getLogger(IncomeTaxDeclareListHandlerEx.class);
  78. private Context ctx = SHRContext.getInstance().getContext();
  79. private ObjectMapper mapper = new ObjectMapper();
  80. /**
  81. * 个税申报
  82. *
  83. * @param request
  84. * @param response
  85. * @param modelMap
  86. */
  87. @Override
  88. public void taxDeclareAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SHRWebException {
  89. LOG.error("taxDeclareAction-----------start-----------");
  90. Context ctx = SHRContext.getInstance().getContext();
  91. try {
  92. boolean isHaveTaxService = CmpTaxUtil.isHaveTaxService(ctx);
  93. //if (!isHaveTaxService) {
  94. // throw new ShrWebBizException(EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label136", ctx.getLocale()));
  95. //} else {
  96. String selectedId = request.getParameter("selectedId");
  97. Map<String, Object> resultMap = new HashMap();
  98. Map<String, Object> declareData = this.getDeclareData(ctx, selectedId);
  99. Map<String, Object> paramMap = new HashMap();
  100. paramMap.put("declaData", declareData.get("WATI_TO_DECLARE"));
  101. LOG.error("paramMap-----------" + paramMap);
  102. try {
  103. //纳税单位
  104. List<String> advanceDeclareInfo = (List) declareData.get("advanceDeclareInfo");
  105. LOG.error("advanceDeclareInfo------------" + advanceDeclareInfo);
  106. if (!advanceDeclareInfo.isEmpty()) {
  107. throw new ShrWebBizException(this.combineError(advanceDeclareInfo));
  108. }
  109. //个税审批 审批状态=审批通过的数据
  110. List<IncomeTaxDeclarInfo> waitToDeclareList = (List) paramMap.get("declaData");
  111. if (waitToDeclareList.size() <= 0) {
  112. resultMap.put("success", false);
  113. resultMap.put("excel", "");
  114. resultMap.put("hasErrData", true);
  115. resultMap.put("hasCheckDataErr", true);
  116. resultMap.put("info", "不可重复声申报!!");
  117. JSONUtils.SUCCESS(resultMap);
  118. return;
  119. }
  120. //检查纳税申报数据
  121. Map<String, Object> checkResultMap = this.checkTaxDeclareData(ctx, request, waitToDeclareList);
  122. Boolean hasErr = (Boolean) checkResultMap.get("hasErrData");
  123. if (hasErr != null && hasErr) {
  124. resultMap.put("success", false);
  125. resultMap.put("excel", checkResultMap.get("excel"));
  126. resultMap.put("hasErrData", true);
  127. resultMap.put("hasCheckDataErr", true);
  128. resultMap.put("info", "");
  129. JSONUtils.SUCCESS(resultMap);
  130. return;
  131. }
  132. String errMsg = this.checkTaxCalStatus(ctx, waitToDeclareList);
  133. if (null != errMsg) {
  134. resultMap.put("success", false);
  135. resultMap.put("dataError", true);
  136. resultMap.put("errMsg", errMsg);
  137. JSONUtils.SUCCESS(resultMap);
  138. return;
  139. }
  140. checkResultMap = this.checkIncomeTaxIssue(ctx, waitToDeclareList);
  141. if (checkResultMap != null) {
  142. checkResultMap.put("success", false);
  143. JSONUtils.SUCCESS(checkResultMap);
  144. return;
  145. }
  146. //errMsg = this.checkReductionItems(ctx, waitToDeclareList);
  147. //if (null != errMsg) {
  148. // resultMap.put("success", false);
  149. // resultMap.put("reductionError", true);
  150. // resultMap.put("errMsg", errMsg);
  151. // JSONUtils.SUCCESS(resultMap);
  152. // return;
  153. //}
  154. //Map<String, Object> taxDeclareResult = IncomeTaxDeclareFacadeFactory.getLocalInstance(ctx).taxDeclare(paramMap);
  155. //调佣税友纳税申报
  156. Map<String, Object> taxDeclareResult = callShuiYouTaxDeclare(paramMap);
  157. Boolean isSuccess = (Boolean) taxDeclareResult.get("success");
  158. resultMap.put("success", isSuccess);
  159. resultMap.put("excel", "");
  160. resultMap.put("hasErrData", !isSuccess);
  161. resultMap.put("hasCheckDataErr", false);
  162. resultMap.put("info", declareData.get("info"));
  163. } catch (Exception var17) {
  164. var17.printStackTrace();
  165. LOG.error(var17.getMessage(), var17);
  166. resultMap.put("success", false);
  167. resultMap.put("excel", "");
  168. resultMap.put("hasErrData", true);
  169. resultMap.put("hasCheckDataErr", false);
  170. resultMap.put("info", declareData.get("info"));
  171. resultMap.put("errorMsg", var17.getMessage());
  172. }
  173. LOG.error("taxDeclareAction-----------end-----------");
  174. JSONUtils.SUCCESS(resultMap);
  175. //}
  176. } catch (JsonProcessingException e) {
  177. e.printStackTrace();
  178. throw new RuntimeException(e);
  179. }
  180. }
  181. /**
  182. * 调佣税友纳税申报
  183. *
  184. * @param paramMap
  185. * @return
  186. */
  187. public Map<String, Object> callShuiYouTaxDeclare(Map paramMap) {
  188. LOG.error("callShuiYouTaxDeclare--------------------paramMap" + paramMap);
  189. Map<String, Object> resultMap = new HashMap();
  190. resultMap.put("success", true);
  191. resultMap.put("msg", "");
  192. List<IncomeTaxDeclarInfo> waitToDeclareList = (List) paramMap.get("declaData");
  193. Map<String, Object> requestParamMap = new HashMap();
  194. List<Object[]> paramList = new ArrayList();
  195. try {
  196. if (waitToDeclareList != null && waitToDeclareList.size() > 0) {
  197. for (int i = 0; i < waitToDeclareList.size(); i++) {
  198. IncomeTaxDeclarInfo taxDeclarInfo = waitToDeclareList.get(i);
  199. JSONObject param = new JSONObject();
  200. param.put("taxDeclarId", taxDeclarInfo.getId());
  201. param.put("taxDeclarBatchNo", taxDeclarInfo.getBatchNo());
  202. //纳税单位
  203. TaxUnitInfo taxUnitInfo = taxDeclarInfo.getTaxUnit();
  204. //客户端代理工厂
  205. ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
  206. //算税请求接口
  207. DeclarationRequest declarationRequest = clientProxyFactory.getDeclarationRequest();
  208. //获取请求参数
  209. CompanyDeclareRequest declareRequestParameter = getDeclareRequestParameter(taxUnitInfo, taxDeclarInfo);
  210. LOG.error("declareRequestParameter-----------------" + mapper.writeValueAsString(declareRequestParameter));
  211. ApiResponse<AsyncResult> apiResponse = declarationRequest.send(declareRequestParameter);
  212. LOG.error("asyncResultApiResponse-----getCode-------" + apiResponse.getHead().getCode());
  213. LOG.error("asyncResultApiResponse-----getMsg--------" + apiResponse.getHead().getMsg());
  214. resultMap.put("msg", mapper.writeValueAsString(declareRequestParameter));
  215. if (apiResponse.getHead().getCode().equals("00000000")) {
  216. AsyncResult body = apiResponse.getBody();
  217. String requestId = body.getRequestId();
  218. LOG.error("requestId-----" + requestId);
  219. LOG.error("apiResponse-----" + mapper.writeValueAsString(apiResponse));
  220. //查询反算反馈结果
  221. ISYUtilsFacade isyUtilsFacade = SYUtilsFacadeFactory.getLocalInstance(ctx);
  222. //backTask(url,requestId,回调osf服务,自定义参数,任务类型)
  223. //isyUtilsFacade.backTask(isyUtilsFacade.getConfig().get("ip") + "/gateway/iit/reverseCalculateTax/getASynIndividualIncomeTaxFeedback", requestId, "synIndividualIncomeTaxService", jsonObject.toString(), TaskCatalogEnum.CAL_GET);
  224. JSONObject json = new JSONObject();
  225. json.put("requestId", requestId);
  226. json.put("param", param.toString());
  227. isyUtilsFacade.addTask("synIncomeTaxDeclareService", json.toJSONString(), TaskCatalogEnum.TAX, "");
  228. }
  229. }
  230. }
  231. } catch (Exception e) {
  232. e.printStackTrace();
  233. resultMap.put("success", false);
  234. resultMap.put("msg", e.getMessage());
  235. return resultMap;
  236. }
  237. return resultMap;
  238. }
  239. /**
  240. * 获取请求参数
  241. * 注意:
  242. * 1.解除劳动合同一次性补偿金、全年一次性奖金所得,不能单独申报,需要同正常工资薪金一起申报。
  243. * 2.解除劳动合同一次性补偿金、稿酬所得,由于税务规则需要,解除劳动合同一次性补偿金、稿酬所得必须填写免税附表。
  244. *
  245. * @param taxUnitInfo
  246. * @param taxDeclarInfo
  247. * @return
  248. */
  249. private CompanyDeclareRequest getDeclareRequestParameter(TaxUnitInfo taxUnitInfo,
  250. IncomeTaxDeclarInfo taxDeclarInfo
  251. ) throws BOSException, JsonProcessingException, EASBizException, SQLException {
  252. LOG.error("getDeclareRequestParameter-----------taxDeclarInfo-----" + taxDeclarInfo);
  253. CompanyDeclareRequest declareRequestPara = new CompanyDeclareRequest();
  254. Map<String, Object> requestParamMap = new HashMap();
  255. //随机id
  256. String bizNo = UUID.randomUUID().toString();
  257. LOG.error("bizNo:" + bizNo);
  258. //外部业务订单号*
  259. declareRequestPara.setBizNo(bizNo);
  260. //企业名称*
  261. declareRequestPara.setName(taxUnitInfo.getName());
  262. //税号*
  263. declareRequestPara.setTaxNo(taxUnitInfo.getTaxNumber());
  264. //行政区划代码*
  265. declareRequestPara.setArea(taxUnitInfo.getAreaCode());
  266. //登记序号
  267. declareRequestPara.setRegistrationNumber(taxUnitInfo.getRegNumber());
  268. String declPassword = taxUnitInfo.getDeclPassword();
  269. //申报密码
  270. if (StringUtils.isEmpty(declPassword)) {
  271. //实名账号
  272. declareRequestPara.setRealNameAccount(taxUnitInfo.getString("realAccount"));
  273. //实名密码
  274. declareRequestPara.setRealNamePassword(Base64Utils.decode(taxUnitInfo.getRealPassword()));
  275. //密码类型
  276. declareRequestPara.setPasswordType("2");
  277. }else {
  278. String sbmm = new String(Base64Utils.decode(declPassword));
  279. declareRequestPara.setDeclarePassword(sbmm);
  280. //密码类型
  281. declareRequestPara.setPasswordType("0");
  282. }
  283. //所得月份
  284. String yearMonth = taxDeclarInfo.getYearMonth();
  285. String replaceYearMonth = yearMonth.replace("-", "");
  286. LOG.error("replaceYearMonth----------------" + replaceYearMonth);
  287. //税款所属期YYYYMM*
  288. declareRequestPara.setMonth(replaceYearMonth);
  289. //总金额
  290. //BigDecimal totalMoney = taxDeclarInfo.getTotalMoney();
  291. //应退税额
  292. //BigDecimal taxRebate = taxDeclarInfo.getTaxRebate();
  293. //总人数
  294. //long totalPerson = taxDeclarInfo.getTotalPerson();
  295. //申报表分类 1=预扣预缴申报表 2=分类所得申报表 3=非居民所得申报表
  296. //String tbTble = taxDeclarInfo.getTbType().getValue();
  297. //纳税单位ID
  298. //String taxUnitId = taxUnitInfo.getId().toString();
  299. //Map<String, Object> tbTypeMap = new HashMap();
  300. //if (totalMoney.compareTo(BigDecimal.ZERO) == 0) {
  301. // tbTypeMap.put("zje", 0.0);
  302. //} else {
  303. // tbTypeMap.put("zje", totalMoney);
  304. //}
  305. //
  306. //if (taxRebate.compareTo(BigDecimal.ZERO) == 0) {
  307. // tbTypeMap.put("ynse", 0.0);
  308. //} else {
  309. // tbTypeMap.put("ynse", taxRebate);
  310. //}
  311. //tbTypeMap.put("zrs", totalPerson);
  312. //Map<String, Object> dataMap = new HashMap();
  313. //if ("1".equals(tbTble)) {
  314. // dataMap.put("ykyj", tbTypeMap);
  315. //} else if ("2".equals(tbTble)) {
  316. // dataMap.put("flsd", tbTypeMap);
  317. //} else if ("3".equals(tbTble)) {
  318. // dataMap.put("fjm", tbTypeMap);
  319. //}
  320. //密码类型*
  321. declareRequestPara.setPasswordType("0");
  322. //离职日期处理策略 1、不传或传1,代表离职日期自动清空,即人员状态由“非正常”变更为“正常”时,离职日期字段自动清空,默认逻辑。
  323. //2、传2离职日期不自动清空,即人员状态由“非正常”变更为“正常”时,离职日期不自动清空,客户如需清空需对离职日期字段传入空字符串。
  324. //declareRequestPara.setResignDateStrategy();
  325. //批次号
  326. String batchNo = taxDeclarInfo.getBatchNo();
  327. LOG.error("taxCalConfigDetailCollection--------taxDeclarInfo---------" + taxDeclarInfo);
  328. //个税应用+税款计算最终拆分明细表
  329. ITaxCalConfigDetail taxCalConfigDetail = TaxCalConfigDetailFactory.getLocalInstance(ctx);
  330. TaxCalConfigDetailCollection taxCalConfigDetailCollection = taxCalConfigDetail.getTaxCalConfigDetailCollection("select *,incomeItem.*, person.* where batchNo = '" + batchNo + "' and state = '20'");
  331. LOG.error("taxCalConfigDetailCollection-----------------" + taxCalConfigDetailCollection.size());
  332. //员工信息ID
  333. Set personIds = new HashSet();
  334. //综合所得对象
  335. ComplexIncomeRequest complexIncomeRequest = new ComplexIncomeRequest();
  336. //正常工资薪金对象
  337. NormalSalarySpecIncome normalSalarySpecIncome = new NormalSalarySpecIncome();
  338. //正常工资薪金列表
  339. List<ComplexIncome> normalSalarySpec = new ArrayList();
  340. //全年一次性奖金收入
  341. List<ComplexIncome> annualOneTimeBonusIncome = new ArrayList();
  342. //全年一次性奖金收入
  343. List<ComplexIncome> laborRemunerationIncome = new ArrayList();
  344. if (taxCalConfigDetailCollection.size() > 0) {
  345. for (int i = 0; i < taxCalConfigDetailCollection.size(); i++) {
  346. TaxCalConfigDetailInfo taxCalConfigDetailInfo = taxCalConfigDetailCollection.get(i);
  347. //员工信息
  348. PersonInfo personInfo = taxCalConfigDetailInfo.getPerson();
  349. personIds.add(personInfo.getId().toString());
  350. //所得项目
  351. TaxIncomeItemInfo incomeItem = taxCalConfigDetailInfo.getIncomeItem();
  352. //本期收入
  353. Integer sre = null;
  354. String getSreSql = "select t1 from T_HR_STaxCalConfigDetail where fid ='" + taxCalConfigDetailInfo.getId().toString() + "'";
  355. IRowSet iRowSet = DbUtil.executeQuery(ctx, getSreSql);
  356. while (iRowSet.next()) {
  357. sre = iRowSet.getInt("t1");
  358. }
  359. LOG.error("incomeItem-----------------" + incomeItem);
  360. //所属项目名称
  361. String incomeItemName = incomeItem.getName();
  362. //所属项目编码
  363. String incomeItemNumber = incomeItem.getNumber();
  364. //正常工资薪金
  365. if ("zcgzxjlb".equals(incomeItemNumber)) {
  366. //getComplexIncome(员工信息对象 ,所属项目,本期收入)
  367. normalSalarySpec.add(getComplexIncome(personInfo, incomeItemName, sre));
  368. //正常工资薪金列表 保存数据
  369. normalSalarySpecIncome.setNormalSalarySpec(normalSalarySpec);
  370. LOG.error("normalSalarySpecIncome-----------------" + mapper.writeValueAsString(normalSalarySpecIncome));
  371. complexIncomeRequest.setNormalSalarySpecIncome(normalSalarySpecIncome);
  372. }
  373. //全年一次性奖金收入
  374. if ("qnycxjjlb".equals(incomeItemNumber)) {
  375. annualOneTimeBonusIncome.add(getComplexIncome(personInfo, incomeItemName, sre));
  376. LOG.error("annualOneTimeBonusIncome-----------------" + mapper.writeValueAsString(annualOneTimeBonusIncome));
  377. LOG.error("annualOneTimeBonusIncome-----------------" + annualOneTimeBonusIncome);
  378. LOG.error("annualOneTimeBonusIncome.size()-----------------" + annualOneTimeBonusIncome.size());
  379. //全年一次性奖金收入 保存数据
  380. complexIncomeRequest.setAnnualOneTimeBonusIncome(annualOneTimeBonusIncome);
  381. }
  382. //一般劳务报酬所得
  383. if ("lwbclb".equals(incomeItemNumber)) {
  384. laborRemunerationIncome.add(getComplexIncome(personInfo, incomeItemName, sre));
  385. LOG.error("laborRemunerationIncome-----------------" + mapper.writeValueAsString(laborRemunerationIncome));
  386. //一般劳务报酬所得 保存数据
  387. complexIncomeRequest.setLaborRemunerationIncome(laborRemunerationIncome);
  388. }
  389. }
  390. }
  391. //综合所得
  392. declareRequestPara.setComplexIncomeRequest(complexIncomeRequest);
  393. //企业员工列表
  394. List<DetailCompanyEmployee> companyEmployeeList = getCompanyEmployeeList(personIds);
  395. declareRequestPara.setCompanyEmployeeList(companyEmployeeList);
  396. LOG.error("companyEmployeeList-----------------" + mapper.writeValueAsString(companyEmployeeList));
  397. return declareRequestPara;
  398. }
  399. /***
  400. * 员工
  401. * @return
  402. */
  403. private ComplexIncome getComplexIncome(PersonInfo personInfo, String incomeItemName, Integer sre) {
  404. ComplexIncome complexIncome = new ComplexIncome();
  405. //姓名
  406. complexIncome.setName(personInfo.getName());
  407. //居民身份证
  408. if (personInfo.getIdCardNO() != null) {
  409. //证照号码
  410. complexIncome.setLicenseNumber(personInfo.getIdCardNO());
  411. //证照类型
  412. complexIncome.setLicenseType("居民身份证");
  413. }
  414. //中国护照不
  415. if (personInfo.getPassportNO() != null) {
  416. //证照类型
  417. complexIncome.setLicenseType("中国护照");
  418. //证照号码
  419. complexIncome.setLicenseNumber(personInfo.getPassportNO());
  420. }
  421. //收入额
  422. complexIncome.setIncome(new BigDecimal(sre));
  423. complexIncome.setIncomeItemName(incomeItemName);
  424. return complexIncome;
  425. }
  426. /**
  427. * 企业员工列表*
  428. *
  429. * @return
  430. */
  431. private List<DetailCompanyEmployee> getCompanyEmployeeList(Set personIds) throws BOSException, EASBizException {
  432. List<DetailCompanyEmployee> companyEmployeeList = new ArrayList<DetailCompanyEmployee>();
  433. SelectorItemCollection sic = new SelectorItemCollection();
  434. sic.add("*");
  435. FilterInfo filterInfo = new FilterInfo();
  436. filterInfo.getFilterItems().add(new FilterItemInfo("id", personIds, CompareType.INCLUDE));
  437. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null); //获取人员数据
  438. PersonCollection personCollection = PersonFactory.getLocalInstance(ctx).getPersonCollection(entityViewInfo);
  439. if (personCollection.size() > 0) {
  440. for (int i = 0; i < personCollection.size(); i++) {
  441. PersonInfo personInfo = personCollection.get(i);
  442. companyEmployeeList.add(getDetailCompanyEmployee(personInfo));
  443. }
  444. }
  445. return companyEmployeeList;
  446. }
  447. /**
  448. * 人员
  449. *
  450. * @return
  451. */
  452. public DetailCompanyEmployee getDetailCompanyEmployee(PersonInfo personInfo) throws BOSException, EASBizException {
  453. //人员对象
  454. DetailCompanyEmployee detailCompanyEmployee = new DetailCompanyEmployee();
  455. ////姓名
  456. //detailCompanyEmployee.setName("何云");
  457. ////证件类型
  458. //detailCompanyEmployee.setLicenseType("居民身份证");
  459. ////证照号码
  460. //detailCompanyEmployee.setLicenseNumber("429004198601085125");
  461. //姓名
  462. detailCompanyEmployee.setName(personInfo.getName());
  463. //complexIncome.setName("何云");
  464. //居民身份证
  465. if (personInfo.getIdCardNO() != null) {
  466. //证照号码
  467. detailCompanyEmployee.setLicenseNumber(personInfo.getIdCardNO());
  468. //证照类型
  469. detailCompanyEmployee.setLicenseType("居民身份证");
  470. //人员地区
  471. detailCompanyEmployee.setArea("境内");
  472. }
  473. //中国护照
  474. if (personInfo.getPassportNO() != null) {
  475. //证照类型
  476. detailCompanyEmployee.setLicenseType("中国护照");
  477. //证照号码
  478. detailCompanyEmployee.setLicenseNumber(personInfo.getPassportNO());
  479. //人员地区
  480. detailCompanyEmployee.setArea("境外");
  481. }
  482. //电话号码
  483. detailCompanyEmployee.setPhone(personInfo.getCell());
  484. //人员状态
  485. detailCompanyEmployee.setState(personInfo.getEmployeeType().getName());
  486. //人员报税信息->任职受雇从业信息
  487. ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
  488. TaxPersonRecordEntryCollection taxPersonRecordEntryCollection = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("where person.id = '" + personInfo.getId() + "'");
  489. TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxPersonRecordEntryCollection.get(0);
  490. //任职受雇类型 可选择雇员、保险营销员、证券经纪人、其他、实习学生(全日制学历教育)
  491. //detailCompanyEmployee.setIsEmployee("其他");
  492. detailCompanyEmployee.setIsEmployee(taxPersonRecordEntryInfo.getEmployedType().getAlias());
  493. //受雇日期 YYYY-MM-DD,不能大于当前时间,任职受雇类型选择雇员、保险营销员、证券经纪人时必录
  494. SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
  495. detailCompanyEmployee.setEmployedDate(inputFormat.format(taxPersonRecordEntryInfo.getEmployedDate()));
  496. //性别
  497. detailCompanyEmployee.setGender(personInfo.getGender().getAlias());
  498. //出生日期
  499. detailCompanyEmployee.setBirthday(inputFormat.format(personInfo.getBirthday()));
  500. //国籍 nationality
  501. NationalityInfo nationality = personInfo.getNationality();
  502. detailCompanyEmployee.setNationality(nationality.getName());
  503. return detailCompanyEmployee;
  504. }
  505. private String getCheckSqlByType(Map<String, Object> incomeIdMap, String taxUnitId, String yearMonth, TbTypeEnum typeEnum) {
  506. StringBuilder sqlBuf = new StringBuilder();
  507. sqlBuf.append(" SELECT distinct tx.FTAXUNITID,t1.Fname_l2 as TAXNAME,p1.FNUMBER,p1.Fname_l2 as PERSONNAME, ti.fIncomeCode ");
  508. sqlBuf.append(" FROM T_HR_STaxCalConfigDetail tx ");
  509. sqlBuf.append(" left join T_HR_TAXUNIT as t1 on t1.fid = tx.FTaxUnitID ");
  510. sqlBuf.append(" left join T_BD_PERSON as p1 on p1.fid = tx.FPersonId ");
  511. sqlBuf.append(" left join t_hr_sTaxIncomeItem as ti on tx.fIncomeItemId = ti.fid ");
  512. String dateFilter = CmpSQLUtil.generateSqlDateFilter("tx.FPeriodBegin", "tx.FPeriodEnd", yearMonth);
  513. sqlBuf.append(" where ").append(dateFilter);
  514. sqlBuf.append(" and tx.FTAXUNITID='").append(taxUnitId).append("'");
  515. sqlBuf.append(" and tx.FSTATE=10");
  516. sqlBuf.append(" and tx.FIsLast=1");
  517. sqlBuf.append(" and tx.FIncomeItemId in ").append(incomeIdMap.get(typeEnum.getValue()));
  518. return sqlBuf.toString();
  519. }
  520. //private Map<String, Object> checkTaxDeclareData(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException {
  521. // Map<String, Object> checkDataResultMap = new HashMap();
  522. // return null;
  523. //}
  524. private Map<String, Object> checkTaxDeclareData(Context ctx, HttpServletRequest request, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException, SQLException, ShrWebBizException {
  525. Map<String, Object> checkDataResultMap = new HashMap();
  526. boolean hasErrData = false;
  527. if (waitToDeclareList != null && waitToDeclareList.size() > 0) {
  528. List<String> preCheckSql = new ArrayList();
  529. List<String> specCheckForPre = new ArrayList();
  530. List<String> notPersonCheckSql = new ArrayList();
  531. List<String> classifyCheckSql = new ArrayList();
  532. Map<String, Object> incomeIdMap = new HashMap();
  533. incomeIdMap.put("1", CmpTaxUtil.genIncomeItemId(ctx, "1"));
  534. incomeIdMap.put("2", CmpTaxUtil.genIncomeItemId(ctx, "2"));
  535. incomeIdMap.put("3", CmpTaxUtil.genIncomeItemId(ctx, "3"));
  536. Iterator i$ = waitToDeclareList.iterator();
  537. String yearMonth;
  538. while (i$.hasNext()) {
  539. IncomeTaxDeclarInfo declareInfo = (IncomeTaxDeclarInfo) i$.next();
  540. TbTypeEnum tbType = declareInfo.getTbType();
  541. String taxUnitId = declareInfo.getTaxUnit().getId().toString();
  542. yearMonth = declareInfo.getYearMonth();
  543. if (tbType != null) {
  544. if ("1".equals(tbType.getValue())) {
  545. preCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0701));
  546. specCheckForPre.add(this.getPreCheckSql(declareInfo));
  547. } else if ("3".equals(tbType.getValue())) {
  548. notPersonCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0703));
  549. } else {
  550. classifyCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0702));
  551. }
  552. }
  553. }
  554. Map<String, String> reasonOperaMap = new HashMap();
  555. reasonOperaMap.put("noCalDataReson", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label140", ctx.getLocale()));
  556. reasonOperaMap.put("noCalDataOper", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label141", ctx.getLocale()));
  557. reasonOperaMap.put("preDataReason", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label142", ctx.getLocale()));
  558. reasonOperaMap.put("preDataOpera", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label143", ctx.getLocale()));
  559. List<TaxDeclarExcelRowDTO> taxDeclareExcelRowDTOS = new ArrayList();
  560. taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, preCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0701));
  561. taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, classifyCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0702));
  562. taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, notPersonCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0703));
  563. String filePath = "";
  564. if (taxDeclareExcelRowDTOS.size() > 0) {
  565. hasErrData = true;
  566. HSSFWorkbook workbook = new HSSFWorkbook();
  567. yearMonth = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label144", ctx.getLocale());
  568. this.fillTitle(ctx, workbook, yearMonth.split(","));
  569. this.fillWorkdBookData(workbook, taxDeclareExcelRowDTOS);
  570. SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
  571. File dir = new File(UserUtil.getUserTempDirAbsolutePath(request.getSession()));
  572. if (!dir.exists()) {
  573. dir.mkdirs();
  574. }
  575. String fileName = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label145", ctx.getLocale()) + "_" + format.format(new Date()) + ".xls";
  576. String realFileName = MD5.md5Hash(fileName);
  577. File file = new File(dir, realFileName);
  578. FileOutputStream out = null;
  579. try {
  580. out = new FileOutputStream(file);
  581. workbook.write(out);
  582. out.flush();
  583. } catch (FileNotFoundException var33) {
  584. LOG.error(var33.getMessage(), var33);
  585. } catch (IOException var34) {
  586. LOG.error(var34.getMessage(), var34);
  587. } finally {
  588. if (out != null) {
  589. try {
  590. out.close();
  591. } catch (IOException var32) {
  592. LOG.error(var32.getMessage(), var32);
  593. }
  594. }
  595. }
  596. Map<String, String> params = new HashMap();
  597. params.put("method", "tmp");
  598. params.put("file", realFileName);
  599. params.put("filename", fileName);
  600. filePath = DynamicUtil.assembleUrl("/downloadfile.do", params);
  601. }
  602. checkDataResultMap.put("excel", filePath);
  603. }
  604. checkDataResultMap.put("hasErrData", hasErrData);
  605. return checkDataResultMap;
  606. }
  607. private void fillTitle(Context ctx, HSSFWorkbook workbook, String[] titleArr) {
  608. HSSFSheet sheet = workbook.createSheet();
  609. HSSFRow createRow = sheet.createRow(0);
  610. HSSFCell infoCell = createRow.createCell(0);
  611. infoCell.setCellValue(EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label146", ctx.getLocale()));
  612. sheet.setColumnWidth(0, 12800);
  613. createRow = sheet.createRow(1);
  614. HSSFFont font = workbook.createFont();
  615. font.setColor((short) 8);
  616. font.setFontHeightInPoints((short) 12);
  617. font.setBoldweight((short) 700);
  618. HSSFCellStyle style = workbook.createCellStyle();
  619. style.setFont(font);
  620. style.setAlignment((short) 2);
  621. style.setVerticalAlignment((short) 1);
  622. if (titleArr != null && titleArr.length > 0) {
  623. for (int i = 0; i < titleArr.length; ++i) {
  624. HSSFCell cell = createRow.createCell(i);
  625. cell.setCellStyle(style);
  626. cell.setCellValue(titleArr[i]);
  627. if (i > 3) {
  628. sheet.setColumnWidth(i, 15360);
  629. } else {
  630. sheet.setColumnWidth(i, 7680);
  631. }
  632. }
  633. }
  634. }
  635. private void fillWorkdBookData(HSSFWorkbook workbook, List<TaxDeclarExcelRowDTO> dataList) {
  636. HSSFSheet sheet = workbook.getSheetAt(0);
  637. if (dataList != null && dataList.size() > 0) {
  638. for (int i = 0; i < dataList.size(); ++i) {
  639. HSSFRow row = sheet.createRow(i + 2);
  640. TaxDeclarExcelRowDTO excelRowDTO = (TaxDeclarExcelRowDTO) dataList.get(i);
  641. HSSFCell cell = row.createCell(0);
  642. cell.setCellValue(excelRowDTO.getPersonNum());
  643. cell = row.createCell(1);
  644. cell.setCellValue(excelRowDTO.getPersonName());
  645. cell = row.createCell(2);
  646. cell.setCellValue(excelRowDTO.getTaxName());
  647. cell = row.createCell(3);
  648. cell.setCellValue(excelRowDTO.getDeclarType());
  649. cell = row.createCell(4);
  650. cell.setCellValue(excelRowDTO.getReason());
  651. cell = row.createCell(5);
  652. cell.setCellValue(excelRowDTO.getOperation());
  653. }
  654. }
  655. }
  656. private String getSqlDateFilterLqDate(String dateStr) {
  657. String[] beginDateArr = dateStr.split("-");
  658. Calendar calendar = Calendar.getInstance();
  659. calendar.set(Integer.parseInt(beginDateArr[0]), Integer.parseInt(beginDateArr[1]) - 1, 1, 0, 0, 0);
  660. Date beginDate = calendar.getTime();
  661. return CmpDateUtil.toKSqlDate(beginDate);
  662. }
  663. private List<TaxDeclarExcelRowDTO> getExceptData(Context ctx, List<String> preCheckSql, List<String> specCheckForPre, Map<String, String> noCalDataOper, TbTypeEnum typeEnum) throws BOSException, SQLException, ShrWebBizException {
  664. List<TaxDeclarExcelRowDTO> taxDeclarExcelRowDTOS = new ArrayList();
  665. Iterator i$;
  666. String s;
  667. IRowSet rowSet;
  668. TaxDeclarExcelRowDTO taxDeclareExcelRow;
  669. if (preCheckSql != null && preCheckSql.size() > 0) {
  670. i$ = preCheckSql.iterator();
  671. while (i$.hasNext()) {
  672. s = (String) i$.next();
  673. rowSet = DbUtil.executeQuery(ctx, s);
  674. while (rowSet.next()) {
  675. taxDeclareExcelRow = new TaxDeclarExcelRowDTO();
  676. taxDeclareExcelRow.setPersonNum(rowSet.getString("FNUMBER"));
  677. taxDeclareExcelRow.setPersonName(rowSet.getString("PERSONNAME"));
  678. String taxUnitName = rowSet.getString("TAXNAME");
  679. taxDeclareExcelRow.setTaxName(taxUnitName);
  680. taxDeclareExcelRow.setDeclarType(typeEnum.getAlias());
  681. taxDeclareExcelRow.setReason((String) noCalDataOper.get("noCalDataReson"));
  682. taxDeclareExcelRow.setOperation((String) noCalDataOper.get("noCalDataOper"));
  683. String incomeCode = (String) noCalDataOper.get("fIncomeCode");
  684. taxDeclarExcelRowDTOS.add(taxDeclareExcelRow);
  685. }
  686. }
  687. }
  688. if ("1".equals(typeEnum.getValue()) && specCheckForPre != null && specCheckForPre.size() > 0) {
  689. i$ = specCheckForPre.iterator();
  690. while (i$.hasNext()) {
  691. s = (String) i$.next();
  692. rowSet = DbUtil.executeQuery(ctx, s);
  693. while (rowSet.next()) {
  694. taxDeclareExcelRow = new TaxDeclarExcelRowDTO();
  695. taxDeclareExcelRow.setPersonNum(rowSet.getString("FNUMBER"));
  696. taxDeclareExcelRow.setPersonName(rowSet.getString("PERSONNAME"));
  697. taxDeclareExcelRow.setTaxName(rowSet.getString("TAXNAME"));
  698. taxDeclareExcelRow.setDeclarType(typeEnum.getAlias());
  699. taxDeclareExcelRow.setReason((String) noCalDataOper.get("preDataReason"));
  700. taxDeclareExcelRow.setOperation((String) noCalDataOper.get("preDataOpera"));
  701. taxDeclarExcelRowDTOS.add(taxDeclareExcelRow);
  702. }
  703. }
  704. }
  705. return taxDeclarExcelRowDTOS;
  706. }
  707. private String getPreCheckSql(IncomeTaxDeclarInfo incomeTaxDeclarInfo) {
  708. StringBuilder sqlBuf = new StringBuilder();
  709. String yearMonth = incomeTaxDeclarInfo.getYearMonth();
  710. String taxUnitId = incomeTaxDeclarInfo.getTaxUnit().getId().toString();
  711. String sql = "select FPersonID from T_HR_STaxCalConfigDetail where FTaxUnitId='" + taxUnitId + "' and FPeriodBegin = " + CmpDateUtil.toKSqlDate(incomeTaxDeclarInfo.getYearMonthDate());
  712. sqlBuf.append(" SELECT distinct ent.FTAXUNITID, t.Fname_l2 as TAXNAME, p.FNUMBER, p.Fname_l2 as PERSONNAME ");
  713. sqlBuf.append(" FROM T_HR_STaxPersonRecordEntry ent ");
  714. sqlBuf.append(" left join T_HR_TAXUNIT as t on t.fid = ent.FTaxUnitID ");
  715. sqlBuf.append(" left join T_BD_PERSON as p on p.fid = ent.FPersonId ");
  716. sqlBuf.append(" where ent.FSubmitStatus='2' and ent.FPersonStatus='1' ");
  717. sqlBuf.append(" and ent.FTaxUnitID='").append(taxUnitId).append("'");
  718. sqlBuf.append(" and ent.FENDDATE <=").append(this.getSqlDateFilterLqDate(yearMonth));
  719. sqlBuf.append(" and ent.FPersonID not in ( ").append(sql).append(" )");
  720. return sqlBuf.toString();
  721. }
  722. private Map<String, Object> checkIncomeTaxIssue(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException {
  723. StringBuilder taxUnitIds = new StringBuilder();
  724. IncomeTaxDeclarInfo declareInfo;
  725. for (Iterator i$ = waitToDeclareList.iterator(); i$.hasNext(); taxUnitIds.append(declareInfo.getTaxUnit().getId().toString())) {
  726. declareInfo = (IncomeTaxDeclarInfo) i$.next();
  727. if (taxUnitIds.length() > 0) {
  728. taxUnitIds.append(",");
  729. }
  730. }
  731. String oql = "select person.person.name where taxUnit.id in " + CmpStrUtil.buildInSql(taxUnitIds.toString()) + " and result = " + 1 + " and status = " + 2 + " and inviteStatus = " + 0;
  732. IncomeTaxIssueCollection collection = IncomeTaxIssueFactory.getLocalInstance(ctx).getIncomeTaxIssueCollection(oql);
  733. if (collection != null && !collection.isEmpty()) {
  734. StringBuilder errMsg = new StringBuilder();
  735. for (int i = 0; i < collection.size() && i != 5; ++i) {
  736. if (errMsg.length() > 0) {
  737. errMsg.append(",");
  738. }
  739. errMsg.append("[").append(collection.get(i).getPerson().getPerson().getName()).append("]");
  740. }
  741. Map<String, Object> map = new HashMap();
  742. map.put("errMsg", "以下员工存在申诉属实争议,且未进行邀请确认,需要进行发送邀请确认后才可进行个税申报或者进行非正常人员报送(更新人员报税信息中的人员状态为非正常,并进行人员报送成功),员工姓名:" + errMsg.toString() + ",选择[是]则跳转到[申诉争议-申诉属实人员]列表,选择[否]则跳转到[人员报税信息]列表。");
  743. map.put("issueError", true);
  744. return map;
  745. } else {
  746. return null;
  747. }
  748. }
  749. private String checkTaxCalStatus(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws SHRWebException {
  750. 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 = ?";
  751. try {
  752. Iterator i$ = waitToDeclareList.iterator();
  753. boolean isTaxCalFinished;
  754. String taxUnitName;
  755. do {
  756. if (!i$.hasNext()) {
  757. return null;
  758. }
  759. IncomeTaxDeclarInfo declareInfo = (IncomeTaxDeclarInfo) i$.next();
  760. String taxUnitId = declareInfo.getTaxUnit().getId().toString();
  761. Date periodDate = declareInfo.getYearMonthDate();
  762. Object[] param = new Object[]{taxUnitId, CmpDateUtil.toSqlDate(periodDate)};
  763. IRowSet rs = DbUtil.executeQuery(ctx, sql, param);
  764. boolean havingSalaryIncome = false;
  765. isTaxCalFinished = true;
  766. taxUnitName = "";
  767. while (rs.next()) {
  768. int state = rs.getInt("fState");
  769. taxUnitName = rs.getString("taxUnitName");
  770. String incomeItemId = rs.getString("fIncomeItemId");
  771. if (state != 40) {
  772. isTaxCalFinished = false;
  773. }
  774. if ("8r0AAABCg2PDiOoP".equals(incomeItemId)) {
  775. havingSalaryIncome = true;
  776. }
  777. }
  778. TbTypeEnum typeEnum = declareInfo.getTbType();
  779. if (!havingSalaryIncome && typeEnum == TbTypeEnum.SB0701) {
  780. return "纳税单位[" + taxUnitName + "]当期预扣预缴申报表未包含所得项目为正常工资薪金所得的员工,不允许申报,请确认";
  781. }
  782. } while (isTaxCalFinished);
  783. return "纳税单位【" + taxUnitName + "】存在接口算税未完成的数据,请确认";
  784. } catch (Exception var15) {
  785. LOG.error("checkTaxCalStatus error: ", var15);
  786. throw new SHRWebException(var15.getMessage());
  787. }
  788. }
  789. /**
  790. * 异常提醒
  791. *
  792. * @param advanceDeclareInfo
  793. * @return
  794. */
  795. private String combineError(List<String> advanceDeclareInfo) {
  796. StringBuilder error = new StringBuilder();
  797. error.append("以下纳税单位尚未到申报时间,请不要提前申报:");
  798. Iterator i$ = advanceDeclareInfo.iterator();
  799. while (i$.hasNext()) {
  800. String taxUnitInfo = (String) i$.next();
  801. if (advanceDeclareInfo.indexOf(taxUnitInfo) == 5) {
  802. error.append("...");
  803. break;
  804. }
  805. if (advanceDeclareInfo.indexOf(taxUnitInfo) > 0) {
  806. error.append(",");
  807. }
  808. String[] arr = taxUnitInfo.split("_");
  809. error.append(arr[0]).append("【").append(arr[1]).append("】");
  810. }
  811. return error.toString();
  812. }
  813. /**
  814. * 获取个税申报审批通过数据
  815. *
  816. * @param ctx
  817. * @param selectedId
  818. * @return
  819. * @throws BOSException
  820. */
  821. private Map<String, Object> getDeclareData(Context ctx, String selectedId) throws BOSException, JsonProcessingException {
  822. Map<String, Object> resultMap = new HashMap();
  823. List<TaxDeclareDTO> declaredList = new ArrayList();
  824. List<IncomeTaxDeclarInfo> waitToDeclareList = new ArrayList();
  825. String sqlInString = CmpUtils.spiltToSqlString(selectedId);
  826. if (StringUtils.isEmpty(sqlInString)) {
  827. sqlInString = "''";
  828. }
  829. String currentYearMonth = CmpDateUtil.getDateStr(new Date(), "yyyy-MM");
  830. 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 + " )";
  831. LOG.error("getDeclareData----------oqlBuffer------" + oqlBuffer);
  832. IncomeTaxDeclarCollection declareCollection = IncomeTaxDeclarFactory.getLocalInstance(ctx).getIncomeTaxDeclarCollection(oqlBuffer);
  833. LOG.error("getDeclareData----------declareCollection------" + declareCollection.size());
  834. String ms1 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label137", ctx.getLocale());
  835. String ms2 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label138", ctx.getLocale());
  836. String ms3 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label139", ctx.getLocale());
  837. List<String> taxUnitInfo = new ArrayList();
  838. if (declareCollection != null && declareCollection.size() > 0) {
  839. for (int i = 0; i < declareCollection.size(); ++i) {
  840. IncomeTaxDeclarInfo declareInfo = declareCollection.get(i);
  841. String declareStatus = declareInfo.getDeclareStatus().getValue();
  842. LOG.error("getDeclareData----------declareStatus------" + declareStatus);
  843. String taxUnitName = declareInfo.getTaxUnit().getName();
  844. String tbTypeAlia = declareInfo.getTbType().getAlias();
  845. if (currentYearMonth.compareTo(declareInfo.getYearMonth()) <= 0) {
  846. taxUnitInfo.add(declareInfo.getTaxUnit().getName() + "_" + declareInfo.getYearMonth());
  847. }
  848. if (!"1".equals(declareStatus) && !"2".equals(declareStatus)) {
  849. waitToDeclareList.add(declareInfo);
  850. LOG.error("getDeclareData----------waitToDeclareList------" + waitToDeclareList);
  851. } else {
  852. TaxDeclareDTO dto = new TaxDeclareDTO(taxUnitName, tbTypeAlia);
  853. declaredList.add(dto);
  854. }
  855. }
  856. if (declaredList.size() == declareCollection.size()) {
  857. resultMap.put("info", ms1);
  858. } else if (declaredList.size() == 0) {
  859. resultMap.put("info", ms2);
  860. } else {
  861. resultMap.put("info", ms3);
  862. }
  863. }
  864. LOG.error("getDeclareData----------resultMap------" + resultMap);
  865. resultMap.put("DECLARED", declaredList);
  866. resultMap.put("advanceDeclareInfo", taxUnitInfo);
  867. resultMap.put("WATI_TO_DECLARE", waitToDeclareList);
  868. return resultMap;
  869. }
  870. }