IncomeTaxDeclareListHandlerEx.java 46 KB

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