123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- package com.kingdee.eas.custom.shuiyou.six.osf;
- import cn.hutool.core.util.StrUtil;
- import cn.hutool.json.JSONArray;
- import cn.hutool.json.JSONObject;
- import cn.hutool.json.JSONUtil;
- import com.kingdee.bos.BOSException;
- import com.kingdee.bos.Context;
- import com.kingdee.bos.bsf.service.app.IHRMsfService;
- import com.kingdee.bos.metadata.entity.*;
- import com.kingdee.bos.metadata.query.util.CompareType;
- import com.kingdee.eas.basedata.person.*;
- import com.kingdee.eas.common.EASBizException;
- import com.kingdee.eas.custom.shuiyou.task.MessageResult;
- import com.kingdee.eas.custom.shuiyou.uitls.ISYUtilsFacade;
- import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacadeFactory;
- import com.kingdee.eas.custom.shuiyou.uitls.URLConfigEnum;
- import com.kingdee.eas.framework.CoreBaseCollection;
- import com.kingdee.shr.compensation.app.tax.*;
- import com.kingdee.shr.dydeploy.web.executeSql.ExceptionUtils;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Map;
- /**
- * description: GetCompanyIncomes <br>
- * date: 2024/9/13 19:02 <br>
- * author: lhbj <br>
- * version: 1.0 <br>
- */
- public class GetCompanyIncomesService implements IHRMsfService {
- @Override
- public Object process(Context context, Map map) throws EASBizException, BOSException {
- String this_taskid = (String) map.get("this_taskId");
- String param = (String) map.get("paramData");
- ISYUtilsFacade facade = SYUtilsFacadeFactory.getLocalInstance(context);
- Map<String, String> config = facade.getConfig();
- ITaxUnit taxUnit = TaxUnitFactory.getLocalInstance(context);
- String skssq = (String) map.get("skssq");
- MessageResult messageResult = null;
- try {
- JSONObject parJSONMap = null;
- if (StrUtil.isNotBlank(param)) {
- parJSONMap = JSONUtil.parseObj(param);
- if (StrUtil.isBlank(skssq)) {
- skssq = (String) parJSONMap.getStr("skssq");
- }
- }
- BigDecimal ZERO = BigDecimal.ZERO;
- EntityViewInfo viewInfo = new EntityViewInfo();
- SelectorItemCollection sc = new SelectorItemCollection();
- sc.add(new SelectorItemInfo("id"));
- sc.add(new SelectorItemInfo("number"));
- sc.add(new SelectorItemInfo("name"));
- sc.add(new SelectorItemInfo("realPassword"));//实名密码
- sc.add(new SelectorItemInfo("declPassword"));//申报密码
- sc.add(new SelectorItemInfo("areaCode"));//行政区划代码
- sc.add(new SelectorItemInfo("regNumber"));//登记号
- sc.add(new SelectorItemInfo("taxNumber"));//扣缴单位纳税人识别号
- sc.add(new SelectorItemInfo("state"));
- viewInfo.setSelector(sc);
- FilterInfo filterInfo = new FilterInfo();
- filterInfo.getFilterItems().add(new FilterItemInfo("state", "1", CompareType.EQUALS));
- viewInfo.setFilter(filterInfo);
- TaxUnitCollection taxUnitCollection = taxUnit.getTaxUnitCollection(viewInfo);
- ITaxDeclaration taxDeclaration = TaxDeclarationFactory.getLocalInstance(context);
- IPerson iPerson = PersonFactory.getLocalInstance(context);
- EntityViewInfo personViewInfo = new EntityViewInfo();
- SelectorItemCollection personSc = new SelectorItemCollection();
- personSc.add(new SelectorItemInfo("id"));
- personViewInfo.setSelector(personSc);
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
- System.out.println("GetCompanyIncomesService:"+taxUnitCollection.toString());
- for (int i = 0; i < taxUnitCollection.size(); i++) {
- TaxUnitInfo taxUnitInfo = taxUnitCollection.get(i);
- String declPassword = taxUnitInfo.getDeclPassword();
- String areaid = taxUnitInfo.getAreaCode();
- String name = taxUnitInfo.getName();
- String djxhid = taxUnitInfo.getRegNumber();
- String nsrsbh = taxUnitInfo.getTaxNumber();
- if (StrUtil.isNotBlank(nsrsbh) && StrUtil.isNotBlank(djxhid) &&
- StrUtil.isNotBlank(name) && StrUtil.isNotBlank(areaid) &&
- StrUtil.isNotBlank(declPassword)) {
- int pageNo = 1;
- int pageSize = 4999;
- boolean next =false;
- do {
- next =false;
- String result = facade.post(config.get("ip") + URLConfigEnum.GETCOMPANYINCOMES_VALUE, param);
- System.out.println("GetCompanyIncomesService:result:"+result.toString());
- TaxDeclarationInfo info = new TaxDeclarationInfo();
- JSONObject resultMap = JSONUtil.parseObj(result);
- JSONObject head = resultMap.getJSONObject("head");
- JSONObject body = resultMap.getJSONObject("body");
- String code = head.getStr("code");
- if ("00000000".equals(code)) {
- String total = body.getStr("total");
- Integer totalInt = Integer.valueOf(total);
- if (totalInt.compareTo(0) > 0) {
- if(totalInt.compareTo(pageSize+pageNo) > 0){
- pageNo=pageNo+1;
- next =true;
- }
- JSONArray sfmx = body.getJSONArray("sfmx");
- CoreBaseCollection collection = new CoreBaseCollection();
- for (int j = 0; j < sfmx.size(); j++) {
- TaxDeclarationInfo declaration = new TaxDeclarationInfo();
- JSONObject sfm = sfmx.getJSONObject(j);
- String zjhm = sfm.getStr("zjhm");
- FilterInfo personfilterInfo = new FilterInfo();
- personfilterInfo.getFilterItems().add(new FilterItemInfo("idCardNO", zjhm, CompareType.EQUALS));
- FilterInfo personfilterInfo2 = new FilterInfo();
- personfilterInfo2.getFilterItems().add(new FilterItemInfo("passportNO", zjhm, CompareType.EQUALS));
- personfilterInfo.mergeFilter(personfilterInfo2, "or");
- personViewInfo.setFilter(personfilterInfo);
- PersonCollection perc = iPerson.getPersonCollection(personViewInfo);
- PersonInfo personInfo = null;
- if (null != perc) {
- personInfo = perc.get(0);
- }
- if (null == personInfo) {
- continue;
- }
- declaration.setPerson(personInfo);
- Integer year = Integer.valueOf(skssq.substring(0, 4));
- Integer month = Integer.valueOf(skssq.substring(4, 6));
- declaration.setPeriodYear(year);
- declaration.setPeriodMonth(month);
- Calendar begin = Calendar.getInstance();
- begin.set(year, month, 1);
- declaration.setTaxPeriodBegin(begin.getTime());
- begin.add(Calendar.MONTH, 1);
- begin.add(Calendar.DAY_OF_MONTH, -1);
- declaration.setTaxPeriodEnd(begin.getTime());
- declaration.setTaxUnit(taxUnitInfo);
- declaration.setIdType(sfm.getStr("zjlx"));//证件类型
- declaration.setIdNO(zjhm);
- declaration.setTaxPayerNum(sfm.getStr(nsrsbh));
- declaration.setIsPersonal(("1".equals(sfm.getStr("sffjm"))) ? false : true);//非居民个人;1:否 2:是
- declaration.setProceedItem(sfm.getStr("sdxmmc"));//所得项目名称
- String income = sfm.getStr("sre");
- declaration.setIncome(StrUtil.isNotBlank(income) ? new BigDecimal(income) : ZERO);
- String cost = sfm.getStr("fy");
- declaration.setIncome(StrUtil.isNotBlank(cost) ? new BigDecimal(cost) : ZERO);
- String exemptIncome = sfm.getStr("mssr");
- declaration.setExemptIncome(StrUtil.isNotBlank(exemptIncome) ? new BigDecimal(exemptIncome) : ZERO);
- String deductions = sfm.getStr("jcfy");
- declaration.setDeductions(StrUtil.isNotBlank(deductions) ? new BigDecimal(deductions) : ZERO);
- String basicPension = sfm.getStr("jbylaobxf");
- declaration.setBasicPension(StrUtil.isNotBlank(basicPension) ? new BigDecimal(basicPension) : ZERO);
- String basicMedical = sfm.getStr("jbylbxf");
- declaration.setBasicMedical(StrUtil.isNotBlank(basicMedical) ? new BigDecimal(basicMedical) : ZERO);
- String unemployment = sfm.getStr("sybxf");
- declaration.setUnemployment(StrUtil.isNotBlank(unemployment) ? new BigDecimal(unemployment) : ZERO);
- String housingFund = sfm.getStr("zfgjj");
- declaration.setHousingFund(StrUtil.isNotBlank(housingFund) ? new BigDecimal(housingFund) : ZERO);
- String annuity = sfm.getStr("nj");
- declaration.setAnnuity(StrUtil.isNotBlank(annuity) ? new BigDecimal(annuity) : ZERO);
- String comHelath = sfm.getStr("syjkbx");
- declaration.setComHelath(StrUtil.isNotBlank(comHelath) ? new BigDecimal(comHelath) : ZERO);
- String taxDeferred = sfm.getStr("syylbx");
- declaration.setTaxDeferred(StrUtil.isNotBlank(taxDeferred) ? new BigDecimal(taxDeferred) : ZERO);
- String originalValue = sfm.getStr("ccyz");
- declaration.setOriginalValue(StrUtil.isNotBlank(originalValue) ? new BigDecimal(originalValue) : ZERO);
- String taxAllowReduct = sfm.getStr("yxkcsf");
- declaration.setTaxAllowReduct(StrUtil.isNotBlank(taxAllowReduct) ? new BigDecimal(taxAllowReduct) : ZERO);
- String otherDeductions = sfm.getStr("qt");
- declaration.setOtherDeductions(StrUtil.isNotBlank(otherDeductions) ? new BigDecimal(otherDeductions) : ZERO);
- String incomeSum = sfm.getStr("ljsre");
- declaration.setIncomeSum(StrUtil.isNotBlank(incomeSum) ? new BigDecimal(incomeSum) : ZERO);
- String deductionSum = sfm.getStr("ljjcfy");
- declaration.setDeductionSum(StrUtil.isNotBlank(deductionSum) ? new BigDecimal(deductionSum) : ZERO);
- String specialDeductSum = sfm.getStr("ljzxkc");
- declaration.setSpecialDeductSum(StrUtil.isNotBlank(specialDeductSum) ? new BigDecimal(specialDeductSum) : ZERO);
- String ChildEducateSum = sfm.getStr("ljznjy");
- declaration.setChildEducateSum(StrUtil.isNotBlank(ChildEducateSum) ?
- new BigDecimal(ChildEducateSum) : ZERO);
- String OldSupportSum = sfm.getStr("ljsylr");
- declaration.setOldSupportSum(StrUtil.isNotBlank(OldSupportSum) ?
- new BigDecimal(OldSupportSum) : ZERO);
- String LoanInterestSum = sfm.getStr("ljzfdklx");
- declaration.setLoanInterestSum(StrUtil.isNotBlank(LoanInterestSum) ?
- new BigDecimal(LoanInterestSum) : ZERO);
- String HousingRentSum = sfm.getStr("ljzfzj");
- declaration.setHousingRentSum(StrUtil.isNotBlank(HousingRentSum) ?
- new BigDecimal(HousingRentSum) : ZERO);
- String ContinueEducateSum = sfm.getStr("ljjxjy");
- declaration.setContinueEducateSum(StrUtil.isNotBlank(ContinueEducateSum) ?
- new BigDecimal(ContinueEducateSum) : ZERO);
- String OtherDeductionSum = sfm.getStr("ljqtkc");
- declaration.setOtherDeductionSum(StrUtil.isNotBlank(OtherDeductionSum) ?
- new BigDecimal(OtherDeductionSum) : ZERO);
- String TaxableRatio = sfm.getStr("jjbl");
- declaration.setTaxableRatio(StrUtil.isNotBlank(TaxableRatio) ?
- new BigDecimal(TaxableRatio) : ZERO);
- String AllowDonationSum = sfm.getStr("zykcjze");
- declaration.setAllowDonationSum(StrUtil.isNotBlank(AllowDonationSum) ?
- new BigDecimal(AllowDonationSum) : ZERO);
- String TaxableIncomeSum = sfm.getStr("ynssde");
- declaration.setTaxableIncomeSum(StrUtil.isNotBlank(TaxableIncomeSum) ?
- new BigDecimal(TaxableIncomeSum) : ZERO);
- String TaxRatio = sfm.getStr("sl");
- declaration.setTaxRatio(StrUtil.isNotBlank(TaxRatio) ?
- new BigDecimal(TaxRatio) : ZERO);
- String QuickDeduct = sfm.getStr("sskcs");
- declaration.setQuickDeduct(StrUtil.isNotBlank(QuickDeduct) ?
- new BigDecimal(QuickDeduct) : ZERO);
- String TaxPayableSum = sfm.getStr("ynse");
- declaration.setTaxPayableSum(StrUtil.isNotBlank(TaxPayableSum) ?
- new BigDecimal(TaxPayableSum) : ZERO);
- String TaxCreditSum = sfm.getStr("jmse");
- declaration.setTaxCreditSum(StrUtil.isNotBlank(TaxCreditSum) ?
- new BigDecimal(TaxCreditSum) : ZERO);
- String TaxPaidSum = sfm.getStr("ykjse");
- declaration.setTaxPaidSum(StrUtil.isNotBlank(TaxPaidSum) ?
- new BigDecimal(TaxPaidSum) : ZERO);
- String TaxSupOrRefund = sfm.getStr("ybtse");
- declaration.setTaxSupOrRefund(StrUtil.isNotBlank(TaxSupOrRefund) ?
- new BigDecimal(TaxSupOrRefund) : ZERO);
- declaration.setSourceType(SourceType.outer);
- declaration.setItemDefine(ItemDefine.NormalSalary);
- declaration.setReportName(sfm.getStr("xm"));
- String InFantSum = sfm.getStr("ljyyezhzc");
- declaration.setInFantSum(StrUtil.isNotBlank(InFantSum) ?
- new BigDecimal(InFantSum) : ZERO);
- String PersonalPension = sfm.getStr("ljgrylj");
- declaration.setPersonalPension(StrUtil.isNotBlank(PersonalPension) ?
- new BigDecimal(PersonalPension) : ZERO);
- collection.add(declaration);
- }
- taxDeclaration.addnewBatchData(collection);
- }
- }
- }while (next);
- }
- }
- messageResult = MessageResult.SUCCESS();
- } catch (Exception e) {
- e.printStackTrace();
- messageResult = MessageResult.ERROR(ExceptionUtils.getStackTrace(e));
- }
- return messageResult;
- }
- }
|