IncomeTaxDeclareListHandlerEx.java 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  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. if (StringUtils.isEmpty(declPassword)) {
  270. throw new BOSException("申报密码不能为空!");
  271. }
  272. declareRequestPara.setDeclarePassword(Base64Utils.decode(declPassword));
  273. //所得月份
  274. String yearMonth = taxDeclarInfo.getYearMonth();
  275. String replaceYearMonth = yearMonth.replace("-", "");
  276. LOG.error("replaceYearMonth----------------" + replaceYearMonth);
  277. //税款所属期YYYYMM*
  278. declareRequestPara.setMonth(replaceYearMonth);
  279. //总金额
  280. //BigDecimal totalMoney = taxDeclarInfo.getTotalMoney();
  281. //应退税额
  282. //BigDecimal taxRebate = taxDeclarInfo.getTaxRebate();
  283. //总人数
  284. //long totalPerson = taxDeclarInfo.getTotalPerson();
  285. //申报表分类 1=预扣预缴申报表 2=分类所得申报表 3=非居民所得申报表
  286. //String tbTble = taxDeclarInfo.getTbType().getValue();
  287. //纳税单位ID
  288. //String taxUnitId = taxUnitInfo.getId().toString();
  289. //Map<String, Object> tbTypeMap = new HashMap();
  290. //if (totalMoney.compareTo(BigDecimal.ZERO) == 0) {
  291. // tbTypeMap.put("zje", 0.0);
  292. //} else {
  293. // tbTypeMap.put("zje", totalMoney);
  294. //}
  295. //
  296. //if (taxRebate.compareTo(BigDecimal.ZERO) == 0) {
  297. // tbTypeMap.put("ynse", 0.0);
  298. //} else {
  299. // tbTypeMap.put("ynse", taxRebate);
  300. //}
  301. //tbTypeMap.put("zrs", totalPerson);
  302. //Map<String, Object> dataMap = new HashMap();
  303. //if ("1".equals(tbTble)) {
  304. // dataMap.put("ykyj", tbTypeMap);
  305. //} else if ("2".equals(tbTble)) {
  306. // dataMap.put("flsd", tbTypeMap);
  307. //} else if ("3".equals(tbTble)) {
  308. // dataMap.put("fjm", tbTypeMap);
  309. //}
  310. //密码类型*
  311. declareRequestPara.setPasswordType("0");
  312. //离职日期处理策略 1、不传或传1,代表离职日期自动清空,即人员状态由“非正常”变更为“正常”时,离职日期字段自动清空,默认逻辑。
  313. //2、传2离职日期不自动清空,即人员状态由“非正常”变更为“正常”时,离职日期不自动清空,客户如需清空需对离职日期字段传入空字符串。
  314. //declareRequestPara.setResignDateStrategy();
  315. //批次号
  316. String batchNo = taxDeclarInfo.getBatchNo();
  317. LOG.error("taxCalConfigDetailCollection--------taxDeclarInfo---------" + taxDeclarInfo);
  318. //个税应用+税款计算最终拆分明细表
  319. ITaxCalConfigDetail taxCalConfigDetail = TaxCalConfigDetailFactory.getLocalInstance(ctx);
  320. TaxCalConfigDetailCollection taxCalConfigDetailCollection = taxCalConfigDetail.getTaxCalConfigDetailCollection("select *,incomeItem.*, person.* where batchNo = '" + batchNo + "' and state = '20'");
  321. LOG.error("taxCalConfigDetailCollection-----------------" + taxCalConfigDetailCollection.size());
  322. //员工信息ID
  323. Set personIds = new HashSet();
  324. //综合所得对象
  325. ComplexIncomeRequest complexIncomeRequest = new ComplexIncomeRequest();
  326. //正常工资薪金对象
  327. NormalSalarySpecIncome normalSalarySpecIncome = new NormalSalarySpecIncome();
  328. //正常工资薪金列表
  329. List<ComplexIncome> normalSalarySpec = new ArrayList();
  330. //全年一次性奖金收入
  331. List<ComplexIncome> annualOneTimeBonusIncome = new ArrayList();
  332. //全年一次性奖金收入
  333. List<ComplexIncome> laborRemunerationIncome = new ArrayList();
  334. if (taxCalConfigDetailCollection.size() > 0) {
  335. for (int i = 0; i < taxCalConfigDetailCollection.size(); i++) {
  336. TaxCalConfigDetailInfo taxCalConfigDetailInfo = taxCalConfigDetailCollection.get(i);
  337. //员工信息
  338. PersonInfo personInfo = taxCalConfigDetailInfo.getPerson();
  339. personIds.add(personInfo.getId().toString());
  340. //所得项目
  341. TaxIncomeItemInfo incomeItem = taxCalConfigDetailInfo.getIncomeItem();
  342. //本期收入
  343. Integer sre = null;
  344. String getSreSql = "select t1 from T_HR_STaxCalConfigDetail where fid ='" + taxCalConfigDetailInfo.getId().toString() + "'";
  345. IRowSet iRowSet = DbUtil.executeQuery(ctx, getSreSql);
  346. while (iRowSet.next()) {
  347. sre = iRowSet.getInt("t1");
  348. }
  349. LOG.error("incomeItem-----------------" + incomeItem);
  350. //所属项目名称
  351. String incomeItemName = incomeItem.getName();
  352. //所属项目编码
  353. String incomeItemNumber = incomeItem.getNumber();
  354. //正常工资薪金
  355. if ("zcgzxjlb".equals(incomeItemNumber)) {
  356. //getComplexIncome(员工信息对象 ,所属项目,本期收入)
  357. normalSalarySpec.add(getComplexIncome(personInfo, incomeItemName, sre));
  358. //正常工资薪金列表 保存数据
  359. normalSalarySpecIncome.setNormalSalarySpec(normalSalarySpec);
  360. LOG.error("normalSalarySpecIncome-----------------" + mapper.writeValueAsString(normalSalarySpecIncome));
  361. complexIncomeRequest.setNormalSalarySpecIncome(normalSalarySpecIncome);
  362. }
  363. //全年一次性奖金收入
  364. if ("qnycxjjlb".equals(incomeItemNumber)) {
  365. annualOneTimeBonusIncome.add(getComplexIncome(personInfo, incomeItemName, sre));
  366. LOG.error("annualOneTimeBonusIncome-----------------" + mapper.writeValueAsString(annualOneTimeBonusIncome));
  367. LOG.error("annualOneTimeBonusIncome-----------------" + annualOneTimeBonusIncome);
  368. LOG.error("annualOneTimeBonusIncome.size()-----------------" + annualOneTimeBonusIncome.size());
  369. //全年一次性奖金收入 保存数据
  370. complexIncomeRequest.setAnnualOneTimeBonusIncome(annualOneTimeBonusIncome);
  371. }
  372. //一般劳务报酬所得
  373. if ("lwbclb".equals(incomeItemNumber)) {
  374. laborRemunerationIncome.add(getComplexIncome(personInfo, incomeItemName, sre));
  375. LOG.error("laborRemunerationIncome-----------------" + mapper.writeValueAsString(laborRemunerationIncome));
  376. //一般劳务报酬所得 保存数据
  377. complexIncomeRequest.setLaborRemunerationIncome(laborRemunerationIncome);
  378. }
  379. }
  380. }
  381. //综合所得
  382. declareRequestPara.setComplexIncomeRequest(complexIncomeRequest);
  383. //企业员工列表
  384. List<DetailCompanyEmployee> companyEmployeeList = getCompanyEmployeeList(personIds);
  385. declareRequestPara.setCompanyEmployeeList(companyEmployeeList);
  386. LOG.error("companyEmployeeList-----------------" + mapper.writeValueAsString(companyEmployeeList));
  387. return declareRequestPara;
  388. }
  389. /***
  390. * 员工
  391. * @return
  392. */
  393. private ComplexIncome getComplexIncome(PersonInfo personInfo, String incomeItemName, Integer sre) {
  394. ComplexIncome complexIncome = new ComplexIncome();
  395. //姓名
  396. complexIncome.setName(personInfo.getName());
  397. //居民身份证
  398. if (personInfo.getIdCardNO() != null) {
  399. //证照号码
  400. complexIncome.setLicenseNumber(personInfo.getIdCardNO());
  401. //证照类型
  402. complexIncome.setLicenseType("居民身份证");
  403. }
  404. //中国护照不
  405. if (personInfo.getPassportNO() != null) {
  406. //证照类型
  407. complexIncome.setLicenseType("中国护照");
  408. //证照号码
  409. complexIncome.setLicenseNumber(personInfo.getPassportNO());
  410. }
  411. //收入额
  412. complexIncome.setIncome(new BigDecimal(sre));
  413. complexIncome.setIncomeItemName(incomeItemName);
  414. return complexIncome;
  415. }
  416. /**
  417. * 企业员工列表*
  418. *
  419. * @return
  420. */
  421. private List<DetailCompanyEmployee> getCompanyEmployeeList(Set personIds) throws BOSException, EASBizException {
  422. List<DetailCompanyEmployee> companyEmployeeList = new ArrayList<DetailCompanyEmployee>();
  423. SelectorItemCollection sic = new SelectorItemCollection();
  424. sic.add("*");
  425. FilterInfo filterInfo = new FilterInfo();
  426. filterInfo.getFilterItems().add(new FilterItemInfo("id", personIds, CompareType.INCLUDE));
  427. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null); //获取人员数据
  428. PersonCollection personCollection = PersonFactory.getLocalInstance(ctx).getPersonCollection(entityViewInfo);
  429. if (personCollection.size() > 0) {
  430. for (int i = 0; i < personCollection.size(); i++) {
  431. PersonInfo personInfo = personCollection.get(i);
  432. companyEmployeeList.add(getDetailCompanyEmployee(personInfo));
  433. }
  434. }
  435. return companyEmployeeList;
  436. }
  437. /**
  438. * 人员
  439. *
  440. * @return
  441. */
  442. public DetailCompanyEmployee getDetailCompanyEmployee(PersonInfo personInfo) throws BOSException, EASBizException {
  443. //人员对象
  444. DetailCompanyEmployee detailCompanyEmployee = new DetailCompanyEmployee();
  445. ////姓名
  446. //detailCompanyEmployee.setName("何云");
  447. ////证件类型
  448. //detailCompanyEmployee.setLicenseType("居民身份证");
  449. ////证照号码
  450. //detailCompanyEmployee.setLicenseNumber("429004198601085125");
  451. //姓名
  452. detailCompanyEmployee.setName(personInfo.getName());
  453. //complexIncome.setName("何云");
  454. //居民身份证
  455. if (personInfo.getIdCardNO() != null) {
  456. //证照号码
  457. detailCompanyEmployee.setLicenseNumber(personInfo.getIdCardNO());
  458. //证照类型
  459. detailCompanyEmployee.setLicenseType("居民身份证");
  460. //人员地区
  461. detailCompanyEmployee.setArea("境内");
  462. }
  463. //中国护照
  464. if (personInfo.getPassportNO() != null) {
  465. //证照类型
  466. detailCompanyEmployee.setLicenseType("中国护照");
  467. //证照号码
  468. detailCompanyEmployee.setLicenseNumber(personInfo.getPassportNO());
  469. //人员地区
  470. detailCompanyEmployee.setArea("境外");
  471. }
  472. //电话号码
  473. detailCompanyEmployee.setPhone(personInfo.getCell());
  474. //人员状态
  475. detailCompanyEmployee.setState(personInfo.getEmployeeType().getName());
  476. //人员报税信息->任职受雇从业信息
  477. ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
  478. TaxPersonRecordEntryCollection taxPersonRecordEntryCollection = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection("where person.id = '" + personInfo.getId() + "'");
  479. TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxPersonRecordEntryCollection.get(0);
  480. //任职受雇类型 可选择雇员、保险营销员、证券经纪人、其他、实习学生(全日制学历教育)
  481. //detailCompanyEmployee.setIsEmployee("其他");
  482. detailCompanyEmployee.setIsEmployee(taxPersonRecordEntryInfo.getEmployedType().getAlias());
  483. //受雇日期 YYYY-MM-DD,不能大于当前时间,任职受雇类型选择雇员、保险营销员、证券经纪人时必录
  484. SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
  485. detailCompanyEmployee.setEmployedDate(inputFormat.format(taxPersonRecordEntryInfo.getEmployedDate()));
  486. //性别
  487. detailCompanyEmployee.setGender(personInfo.getGender().getAlias());
  488. //出生日期
  489. detailCompanyEmployee.setBirthday(inputFormat.format(personInfo.getBirthday()));
  490. //国籍 nationality
  491. NationalityInfo nationality = personInfo.getNationality();
  492. detailCompanyEmployee.setNationality(nationality.getName());
  493. return detailCompanyEmployee;
  494. }
  495. private String getCheckSqlByType(Map<String, Object> incomeIdMap, String taxUnitId, String yearMonth, TbTypeEnum typeEnum) {
  496. StringBuilder sqlBuf = new StringBuilder();
  497. sqlBuf.append(" SELECT distinct tx.FTAXUNITID,t1.Fname_l2 as TAXNAME,p1.FNUMBER,p1.Fname_l2 as PERSONNAME, ti.fIncomeCode ");
  498. sqlBuf.append(" FROM T_HR_STaxCalConfigDetail tx ");
  499. sqlBuf.append(" left join T_HR_TAXUNIT as t1 on t1.fid = tx.FTaxUnitID ");
  500. sqlBuf.append(" left join T_BD_PERSON as p1 on p1.fid = tx.FPersonId ");
  501. sqlBuf.append(" left join t_hr_sTaxIncomeItem as ti on tx.fIncomeItemId = ti.fid ");
  502. String dateFilter = CmpSQLUtil.generateSqlDateFilter("tx.FPeriodBegin", "tx.FPeriodEnd", yearMonth);
  503. sqlBuf.append(" where ").append(dateFilter);
  504. sqlBuf.append(" and tx.FTAXUNITID='").append(taxUnitId).append("'");
  505. sqlBuf.append(" and tx.FSTATE=10");
  506. sqlBuf.append(" and tx.FIsLast=1");
  507. sqlBuf.append(" and tx.FIncomeItemId in ").append(incomeIdMap.get(typeEnum.getValue()));
  508. return sqlBuf.toString();
  509. }
  510. //private Map<String, Object> checkTaxDeclareData(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException {
  511. // Map<String, Object> checkDataResultMap = new HashMap();
  512. // return null;
  513. //}
  514. private Map<String, Object> checkTaxDeclareData(Context ctx, HttpServletRequest request, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException, SQLException, ShrWebBizException {
  515. Map<String, Object> checkDataResultMap = new HashMap();
  516. boolean hasErrData = false;
  517. if (waitToDeclareList != null && waitToDeclareList.size() > 0) {
  518. List<String> preCheckSql = new ArrayList();
  519. List<String> specCheckForPre = new ArrayList();
  520. List<String> notPersonCheckSql = new ArrayList();
  521. List<String> classifyCheckSql = new ArrayList();
  522. Map<String, Object> incomeIdMap = new HashMap();
  523. incomeIdMap.put("1", CmpTaxUtil.genIncomeItemId(ctx, "1"));
  524. incomeIdMap.put("2", CmpTaxUtil.genIncomeItemId(ctx, "2"));
  525. incomeIdMap.put("3", CmpTaxUtil.genIncomeItemId(ctx, "3"));
  526. Iterator i$ = waitToDeclareList.iterator();
  527. String yearMonth;
  528. while (i$.hasNext()) {
  529. IncomeTaxDeclarInfo declareInfo = (IncomeTaxDeclarInfo) i$.next();
  530. TbTypeEnum tbType = declareInfo.getTbType();
  531. String taxUnitId = declareInfo.getTaxUnit().getId().toString();
  532. yearMonth = declareInfo.getYearMonth();
  533. if (tbType != null) {
  534. if ("1".equals(tbType.getValue())) {
  535. preCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0701));
  536. specCheckForPre.add(this.getPreCheckSql(declareInfo));
  537. } else if ("3".equals(tbType.getValue())) {
  538. notPersonCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0703));
  539. } else {
  540. classifyCheckSql.add(this.getCheckSqlByType(incomeIdMap, taxUnitId, yearMonth, TbTypeEnum.SB0702));
  541. }
  542. }
  543. }
  544. Map<String, String> reasonOperaMap = new HashMap();
  545. reasonOperaMap.put("noCalDataReson", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label140", ctx.getLocale()));
  546. reasonOperaMap.put("noCalDataOper", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label141", ctx.getLocale()));
  547. reasonOperaMap.put("preDataReason", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label142", ctx.getLocale()));
  548. reasonOperaMap.put("preDataOpera", EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label143", ctx.getLocale()));
  549. List<TaxDeclarExcelRowDTO> taxDeclareExcelRowDTOS = new ArrayList();
  550. taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, preCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0701));
  551. taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, classifyCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0702));
  552. taxDeclareExcelRowDTOS.addAll(this.getExceptData(ctx, notPersonCheckSql, specCheckForPre, reasonOperaMap, TbTypeEnum.SB0703));
  553. String filePath = "";
  554. if (taxDeclareExcelRowDTOS.size() > 0) {
  555. hasErrData = true;
  556. HSSFWorkbook workbook = new HSSFWorkbook();
  557. yearMonth = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label144", ctx.getLocale());
  558. this.fillTitle(ctx, workbook, yearMonth.split(","));
  559. this.fillWorkdBookData(workbook, taxDeclareExcelRowDTOS);
  560. SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
  561. File dir = new File(UserUtil.getUserTempDirAbsolutePath(request.getSession()));
  562. if (!dir.exists()) {
  563. dir.mkdirs();
  564. }
  565. String fileName = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label145", ctx.getLocale()) + "_" + format.format(new Date()) + ".xls";
  566. String realFileName = MD5.md5Hash(fileName);
  567. File file = new File(dir, realFileName);
  568. FileOutputStream out = null;
  569. try {
  570. out = new FileOutputStream(file);
  571. workbook.write(out);
  572. out.flush();
  573. } catch (FileNotFoundException var33) {
  574. LOG.error(var33.getMessage(), var33);
  575. } catch (IOException var34) {
  576. LOG.error(var34.getMessage(), var34);
  577. } finally {
  578. if (out != null) {
  579. try {
  580. out.close();
  581. } catch (IOException var32) {
  582. LOG.error(var32.getMessage(), var32);
  583. }
  584. }
  585. }
  586. Map<String, String> params = new HashMap();
  587. params.put("method", "tmp");
  588. params.put("file", realFileName);
  589. params.put("filename", fileName);
  590. filePath = DynamicUtil.assembleUrl("/downloadfile.do", params);
  591. }
  592. checkDataResultMap.put("excel", filePath);
  593. }
  594. checkDataResultMap.put("hasErrData", hasErrData);
  595. return checkDataResultMap;
  596. }
  597. private void fillTitle(Context ctx, HSSFWorkbook workbook, String[] titleArr) {
  598. HSSFSheet sheet = workbook.createSheet();
  599. HSSFRow createRow = sheet.createRow(0);
  600. HSSFCell infoCell = createRow.createCell(0);
  601. infoCell.setCellValue(EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label146", ctx.getLocale()));
  602. sheet.setColumnWidth(0, 12800);
  603. createRow = sheet.createRow(1);
  604. HSSFFont font = workbook.createFont();
  605. font.setColor((short) 8);
  606. font.setFontHeightInPoints((short) 12);
  607. font.setBoldweight((short) 700);
  608. HSSFCellStyle style = workbook.createCellStyle();
  609. style.setFont(font);
  610. style.setAlignment((short) 2);
  611. style.setVerticalAlignment((short) 1);
  612. if (titleArr != null && titleArr.length > 0) {
  613. for (int i = 0; i < titleArr.length; ++i) {
  614. HSSFCell cell = createRow.createCell(i);
  615. cell.setCellStyle(style);
  616. cell.setCellValue(titleArr[i]);
  617. if (i > 3) {
  618. sheet.setColumnWidth(i, 15360);
  619. } else {
  620. sheet.setColumnWidth(i, 7680);
  621. }
  622. }
  623. }
  624. }
  625. private void fillWorkdBookData(HSSFWorkbook workbook, List<TaxDeclarExcelRowDTO> dataList) {
  626. HSSFSheet sheet = workbook.getSheetAt(0);
  627. if (dataList != null && dataList.size() > 0) {
  628. for (int i = 0; i < dataList.size(); ++i) {
  629. HSSFRow row = sheet.createRow(i + 2);
  630. TaxDeclarExcelRowDTO excelRowDTO = (TaxDeclarExcelRowDTO) dataList.get(i);
  631. HSSFCell cell = row.createCell(0);
  632. cell.setCellValue(excelRowDTO.getPersonNum());
  633. cell = row.createCell(1);
  634. cell.setCellValue(excelRowDTO.getPersonName());
  635. cell = row.createCell(2);
  636. cell.setCellValue(excelRowDTO.getTaxName());
  637. cell = row.createCell(3);
  638. cell.setCellValue(excelRowDTO.getDeclarType());
  639. cell = row.createCell(4);
  640. cell.setCellValue(excelRowDTO.getReason());
  641. cell = row.createCell(5);
  642. cell.setCellValue(excelRowDTO.getOperation());
  643. }
  644. }
  645. }
  646. private String getSqlDateFilterLqDate(String dateStr) {
  647. String[] beginDateArr = dateStr.split("-");
  648. Calendar calendar = Calendar.getInstance();
  649. calendar.set(Integer.parseInt(beginDateArr[0]), Integer.parseInt(beginDateArr[1]) - 1, 1, 0, 0, 0);
  650. Date beginDate = calendar.getTime();
  651. return CmpDateUtil.toKSqlDate(beginDate);
  652. }
  653. private List<TaxDeclarExcelRowDTO> getExceptData(Context ctx, List<String> preCheckSql, List<String> specCheckForPre, Map<String, String> noCalDataOper, TbTypeEnum typeEnum) throws BOSException, SQLException, ShrWebBizException {
  654. List<TaxDeclarExcelRowDTO> taxDeclarExcelRowDTOS = new ArrayList();
  655. Iterator i$;
  656. String s;
  657. IRowSet rowSet;
  658. TaxDeclarExcelRowDTO taxDeclareExcelRow;
  659. if (preCheckSql != null && preCheckSql.size() > 0) {
  660. i$ = preCheckSql.iterator();
  661. while (i$.hasNext()) {
  662. s = (String) i$.next();
  663. rowSet = DbUtil.executeQuery(ctx, s);
  664. while (rowSet.next()) {
  665. taxDeclareExcelRow = new TaxDeclarExcelRowDTO();
  666. taxDeclareExcelRow.setPersonNum(rowSet.getString("FNUMBER"));
  667. taxDeclareExcelRow.setPersonName(rowSet.getString("PERSONNAME"));
  668. String taxUnitName = rowSet.getString("TAXNAME");
  669. taxDeclareExcelRow.setTaxName(taxUnitName);
  670. taxDeclareExcelRow.setDeclarType(typeEnum.getAlias());
  671. taxDeclareExcelRow.setReason((String) noCalDataOper.get("noCalDataReson"));
  672. taxDeclareExcelRow.setOperation((String) noCalDataOper.get("noCalDataOper"));
  673. String incomeCode = (String) noCalDataOper.get("fIncomeCode");
  674. taxDeclarExcelRowDTOS.add(taxDeclareExcelRow);
  675. }
  676. }
  677. }
  678. if ("1".equals(typeEnum.getValue()) && specCheckForPre != null && specCheckForPre.size() > 0) {
  679. i$ = specCheckForPre.iterator();
  680. while (i$.hasNext()) {
  681. s = (String) i$.next();
  682. rowSet = DbUtil.executeQuery(ctx, s);
  683. while (rowSet.next()) {
  684. taxDeclareExcelRow = new TaxDeclarExcelRowDTO();
  685. taxDeclareExcelRow.setPersonNum(rowSet.getString("FNUMBER"));
  686. taxDeclareExcelRow.setPersonName(rowSet.getString("PERSONNAME"));
  687. taxDeclareExcelRow.setTaxName(rowSet.getString("TAXNAME"));
  688. taxDeclareExcelRow.setDeclarType(typeEnum.getAlias());
  689. taxDeclareExcelRow.setReason((String) noCalDataOper.get("preDataReason"));
  690. taxDeclareExcelRow.setOperation((String) noCalDataOper.get("preDataOpera"));
  691. taxDeclarExcelRowDTOS.add(taxDeclareExcelRow);
  692. }
  693. }
  694. }
  695. return taxDeclarExcelRowDTOS;
  696. }
  697. private String getPreCheckSql(IncomeTaxDeclarInfo incomeTaxDeclarInfo) {
  698. StringBuilder sqlBuf = new StringBuilder();
  699. String yearMonth = incomeTaxDeclarInfo.getYearMonth();
  700. String taxUnitId = incomeTaxDeclarInfo.getTaxUnit().getId().toString();
  701. String sql = "select FPersonID from T_HR_STaxCalConfigDetail where FTaxUnitId='" + taxUnitId + "' and FPeriodBegin = " + CmpDateUtil.toKSqlDate(incomeTaxDeclarInfo.getYearMonthDate());
  702. sqlBuf.append(" SELECT distinct ent.FTAXUNITID, t.Fname_l2 as TAXNAME, p.FNUMBER, p.Fname_l2 as PERSONNAME ");
  703. sqlBuf.append(" FROM T_HR_STaxPersonRecordEntry ent ");
  704. sqlBuf.append(" left join T_HR_TAXUNIT as t on t.fid = ent.FTaxUnitID ");
  705. sqlBuf.append(" left join T_BD_PERSON as p on p.fid = ent.FPersonId ");
  706. sqlBuf.append(" where ent.FSubmitStatus='2' and ent.FPersonStatus='1' ");
  707. sqlBuf.append(" and ent.FTaxUnitID='").append(taxUnitId).append("'");
  708. sqlBuf.append(" and ent.FENDDATE <=").append(this.getSqlDateFilterLqDate(yearMonth));
  709. sqlBuf.append(" and ent.FPersonID not in ( ").append(sql).append(" )");
  710. return sqlBuf.toString();
  711. }
  712. private Map<String, Object> checkIncomeTaxIssue(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws BOSException {
  713. StringBuilder taxUnitIds = new StringBuilder();
  714. IncomeTaxDeclarInfo declareInfo;
  715. for (Iterator i$ = waitToDeclareList.iterator(); i$.hasNext(); taxUnitIds.append(declareInfo.getTaxUnit().getId().toString())) {
  716. declareInfo = (IncomeTaxDeclarInfo) i$.next();
  717. if (taxUnitIds.length() > 0) {
  718. taxUnitIds.append(",");
  719. }
  720. }
  721. String oql = "select person.person.name where taxUnit.id in " + CmpStrUtil.buildInSql(taxUnitIds.toString()) + " and result = " + 1 + " and status = " + 2 + " and inviteStatus = " + 0;
  722. IncomeTaxIssueCollection collection = IncomeTaxIssueFactory.getLocalInstance(ctx).getIncomeTaxIssueCollection(oql);
  723. if (collection != null && !collection.isEmpty()) {
  724. StringBuilder errMsg = new StringBuilder();
  725. for (int i = 0; i < collection.size() && i != 5; ++i) {
  726. if (errMsg.length() > 0) {
  727. errMsg.append(",");
  728. }
  729. errMsg.append("[").append(collection.get(i).getPerson().getPerson().getName()).append("]");
  730. }
  731. Map<String, Object> map = new HashMap();
  732. map.put("errMsg", "以下员工存在申诉属实争议,且未进行邀请确认,需要进行发送邀请确认后才可进行个税申报或者进行非正常人员报送(更新人员报税信息中的人员状态为非正常,并进行人员报送成功),员工姓名:" + errMsg.toString() + ",选择[是]则跳转到[申诉争议-申诉属实人员]列表,选择[否]则跳转到[人员报税信息]列表。");
  733. map.put("issueError", true);
  734. return map;
  735. } else {
  736. return null;
  737. }
  738. }
  739. private String checkTaxCalStatus(Context ctx, List<IncomeTaxDeclarInfo> waitToDeclareList) throws SHRWebException {
  740. 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 = ?";
  741. try {
  742. Iterator i$ = waitToDeclareList.iterator();
  743. boolean isTaxCalFinished;
  744. String taxUnitName;
  745. do {
  746. if (!i$.hasNext()) {
  747. return null;
  748. }
  749. IncomeTaxDeclarInfo declareInfo = (IncomeTaxDeclarInfo) i$.next();
  750. String taxUnitId = declareInfo.getTaxUnit().getId().toString();
  751. Date periodDate = declareInfo.getYearMonthDate();
  752. Object[] param = new Object[]{taxUnitId, CmpDateUtil.toSqlDate(periodDate)};
  753. IRowSet rs = DbUtil.executeQuery(ctx, sql, param);
  754. boolean havingSalaryIncome = false;
  755. isTaxCalFinished = true;
  756. taxUnitName = "";
  757. while (rs.next()) {
  758. int state = rs.getInt("fState");
  759. taxUnitName = rs.getString("taxUnitName");
  760. String incomeItemId = rs.getString("fIncomeItemId");
  761. if (state != 40) {
  762. isTaxCalFinished = false;
  763. }
  764. if ("8r0AAABCg2PDiOoP".equals(incomeItemId)) {
  765. havingSalaryIncome = true;
  766. }
  767. }
  768. TbTypeEnum typeEnum = declareInfo.getTbType();
  769. if (!havingSalaryIncome && typeEnum == TbTypeEnum.SB0701) {
  770. return "纳税单位[" + taxUnitName + "]当期预扣预缴申报表未包含所得项目为正常工资薪金所得的员工,不允许申报,请确认";
  771. }
  772. } while (isTaxCalFinished);
  773. return "纳税单位【" + taxUnitName + "】存在接口算税未完成的数据,请确认";
  774. } catch (Exception var15) {
  775. LOG.error("checkTaxCalStatus error: ", var15);
  776. throw new SHRWebException(var15.getMessage());
  777. }
  778. }
  779. /**
  780. * 异常提醒
  781. *
  782. * @param advanceDeclareInfo
  783. * @return
  784. */
  785. private String combineError(List<String> advanceDeclareInfo) {
  786. StringBuilder error = new StringBuilder();
  787. error.append("以下纳税单位尚未到申报时间,请不要提前申报:");
  788. Iterator i$ = advanceDeclareInfo.iterator();
  789. while (i$.hasNext()) {
  790. String taxUnitInfo = (String) i$.next();
  791. if (advanceDeclareInfo.indexOf(taxUnitInfo) == 5) {
  792. error.append("...");
  793. break;
  794. }
  795. if (advanceDeclareInfo.indexOf(taxUnitInfo) > 0) {
  796. error.append(",");
  797. }
  798. String[] arr = taxUnitInfo.split("_");
  799. error.append(arr[0]).append("【").append(arr[1]).append("】");
  800. }
  801. return error.toString();
  802. }
  803. /**
  804. * 获取个税申报审批通过数据
  805. *
  806. * @param ctx
  807. * @param selectedId
  808. * @return
  809. * @throws BOSException
  810. */
  811. private Map<String, Object> getDeclareData(Context ctx, String selectedId) throws BOSException, JsonProcessingException {
  812. Map<String, Object> resultMap = new HashMap();
  813. List<TaxDeclareDTO> declaredList = new ArrayList();
  814. List<IncomeTaxDeclarInfo> waitToDeclareList = new ArrayList();
  815. String sqlInString = CmpUtils.spiltToSqlString(selectedId);
  816. if (StringUtils.isEmpty(sqlInString)) {
  817. sqlInString = "''";
  818. }
  819. String currentYearMonth = CmpDateUtil.getDateStr(new Date(), "yyyy-MM");
  820. 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 + " )";
  821. LOG.error("getDeclareData----------oqlBuffer------" + oqlBuffer);
  822. IncomeTaxDeclarCollection declareCollection = IncomeTaxDeclarFactory.getLocalInstance(ctx).getIncomeTaxDeclarCollection(oqlBuffer);
  823. LOG.error("getDeclareData----------declareCollection------" + declareCollection.size());
  824. String ms1 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label137", ctx.getLocale());
  825. String ms2 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label138", ctx.getLocale());
  826. String ms3 = EASResource.getString("com.kingdee.shr.compensation.resource.CommonResource", "label139", ctx.getLocale());
  827. List<String> taxUnitInfo = new ArrayList();
  828. if (declareCollection != null && declareCollection.size() > 0) {
  829. for (int i = 0; i < declareCollection.size(); ++i) {
  830. IncomeTaxDeclarInfo declareInfo = declareCollection.get(i);
  831. String declareStatus = declareInfo.getDeclareStatus().getValue();
  832. LOG.error("getDeclareData----------declareStatus------" + declareStatus);
  833. String taxUnitName = declareInfo.getTaxUnit().getName();
  834. String tbTypeAlia = declareInfo.getTbType().getAlias();
  835. if (currentYearMonth.compareTo(declareInfo.getYearMonth()) <= 0) {
  836. taxUnitInfo.add(declareInfo.getTaxUnit().getName() + "_" + declareInfo.getYearMonth());
  837. }
  838. if (!"1".equals(declareStatus) && !"2".equals(declareStatus)) {
  839. waitToDeclareList.add(declareInfo);
  840. LOG.error("getDeclareData----------waitToDeclareList------" + waitToDeclareList);
  841. } else {
  842. TaxDeclareDTO dto = new TaxDeclareDTO(taxUnitName, tbTypeAlia);
  843. declaredList.add(dto);
  844. }
  845. }
  846. if (declaredList.size() == declareCollection.size()) {
  847. resultMap.put("info", ms1);
  848. } else if (declaredList.size() == 0) {
  849. resultMap.put("info", ms2);
  850. } else {
  851. resultMap.put("info", ms3);
  852. }
  853. }
  854. LOG.error("getDeclareData----------resultMap------" + resultMap);
  855. resultMap.put("DECLARED", declaredList);
  856. resultMap.put("advanceDeclareInfo", taxUnitInfo);
  857. resultMap.put("WATI_TO_DECLARE", waitToDeclareList);
  858. return resultMap;
  859. }
  860. }