|
@@ -0,0 +1,259 @@
|
|
|
+package com.kingdee.eas.custom.shuiyou.six.handler;
|
|
|
+
|
|
|
+import cn.hutool.json.JSONConfig;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.kingdee.bos.BOSException;
|
|
|
+import com.kingdee.bos.Context;
|
|
|
+import com.kingdee.bos.dao.IObjectPK;
|
|
|
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
|
|
|
+import com.kingdee.bos.metadata.entity.EntityViewInfo;
|
|
|
+import com.kingdee.bos.rabbitmq.guava.Lists;
|
|
|
+import com.kingdee.bos.sql.ParserException;
|
|
|
+import com.kingdee.bos.util.BOSUuid;
|
|
|
+import com.kingdee.eas.custom.shuiyou.six.osf.vo.SixTConfirmInfo;
|
|
|
+import com.kingdee.eas.custom.shuiyou.six.osf.vo.SixTPersonInfo;
|
|
|
+import com.kingdee.eas.custom.shuiyou.task.TaskCatalogEnum;
|
|
|
+import com.kingdee.eas.custom.shuiyou.uitls.ISYUtilsFacade;
|
|
|
+import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacade;
|
|
|
+import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacadeFactory;
|
|
|
+import com.kingdee.eas.custom.shuiyou.uitls.URLConfigEnum;
|
|
|
+import com.kingdee.eas.util.app.DbUtil;
|
|
|
+import com.kingdee.jdbc.rowset.IRowSet;
|
|
|
+import com.kingdee.shr.base.syssetting.context.SHRContext;
|
|
|
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
|
|
|
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
|
|
|
+import com.kingdee.shr.compensation.app.tax.TaxUnitInfo;
|
|
|
+import com.kingdee.shr.compensation.app.taxCal.*;
|
|
|
+import com.kingdee.shr.compensation.util.Base64Utils;
|
|
|
+import com.kingdee.shr.compensation.util.CmpDateUtil;
|
|
|
+import com.kingdee.shr.compensation.util.CmpStrUtil;
|
|
|
+import com.kingdee.shr.compensation.web.handler.tax.TaxDirectDeductionListHandler;
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
+import org.apache.log4j.Logger;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 不满6万确认名单
|
|
|
+ * description: TaxDirectDeductionListHandlerEx <br>
|
|
|
+ * date: 2024/8/28 14:42 <br>
|
|
|
+ * author: lhbj <br>
|
|
|
+ * version: 1.0 <br>
|
|
|
+ */
|
|
|
+public class TaxDirectDeductionListHandlerEx extends TaxDirectDeductionListHandler {
|
|
|
+ private static final Logger LOG = Logger.getLogger(TaxDirectDeductionListHandler.class);
|
|
|
+ /**
|
|
|
+ * 确认人员名单
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param modelMap
|
|
|
+ * @throws SHRWebException
|
|
|
+ */
|
|
|
+ public void personCollectConfirmAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ String selectedData = request.getParameter("selectedData");
|
|
|
+ ArrayList ids = new ArrayList();
|
|
|
+
|
|
|
+ try {
|
|
|
+ String oql;
|
|
|
+ if (StringUtils.isEmpty(selectedData)) {
|
|
|
+ super.prepareQueryList(request, response, modelMap);
|
|
|
+ EntityViewInfo defaultEntityViewInfo = (EntityViewInfo)modelMap.get("DataGridEntityView");
|
|
|
+ oql = "select id, sate where " + defaultEntityViewInfo.getFilter().toSql();
|
|
|
+ } else {
|
|
|
+ oql = "select id, sate where id in " + CmpStrUtil.buildInSql(selectedData);
|
|
|
+ }
|
|
|
+ StringBuilder msg = this.checkBeforeConfirm(ctx, ids, oql);
|
|
|
+ if(msg.length()>0) {
|
|
|
+ throw new BOSException(msg.toString());
|
|
|
+ }else {
|
|
|
+ int lastYear = CmpDateUtil.getYear(new Date());
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+ map.put("ids", ids);
|
|
|
+ map.put("period", lastYear + "-01");
|
|
|
+ this._confirm(ctx, map);
|
|
|
+ }
|
|
|
+ } catch (Exception var10) {
|
|
|
+ var10.printStackTrace();
|
|
|
+ LOG.error("TaxDirectDeduction confirm failed, caused by: ", var10);
|
|
|
+ throw new ShrWebBizException(var10.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验选中行是否已经确认
|
|
|
+ * @param ctx
|
|
|
+ * @param ids
|
|
|
+ * @param oql
|
|
|
+ * @return
|
|
|
+ * @throws BOSException
|
|
|
+ */
|
|
|
+ protected StringBuilder checkBeforeConfirm(Context ctx, List<String> ids, String oql) throws BOSException {
|
|
|
+ StringBuilder msg = new StringBuilder();
|
|
|
+ TaxDirectDeductionCollection collection = TaxDirectDeductionFactory.getLocalInstance(ctx).getTaxDirectDeductionCollection(oql);
|
|
|
+ if (collection != null && !collection.isEmpty()) {
|
|
|
+ for(int i = 0; i < collection.size(); ++i) {
|
|
|
+ TaxDirectDeductionInfo info = collection.get(i);
|
|
|
+ if (info.getSate() == TaxDeductionStateEnum.CONFIRMING || info.getSate() == TaxDeductionStateEnum.CONFIRMED) {
|
|
|
+ msg.append("请不要对【已确认】或【确认中】的人员再次发起确认。");
|
|
|
+ }
|
|
|
+
|
|
|
+ ids.add(info.getId().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ msg.append("当前所选择数据无可确认人员,请先调用接口[获取人员名单]成功后再进行确认");
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ protected List _confirm(Context ctx, Map paramMap) throws BOSException, ParserException {
|
|
|
+ List<String> ids = (List)paramMap.get("ids");
|
|
|
+ String oql = "select id, taxUnitDeduction.id, taxUnitDeduction.taxUnit.taxNumber,taxUnitDeduction.taxUnit.name, taxUnitDeduction.taxUnit.id, " +
|
|
|
+ "taxUnitDeduction.taxUnit.areaCode, taxUnitDeduction.taxUnit.regNumber,taxUnitDeduction.year, taxUnitDeduction.taxUnit.declPassword, " +
|
|
|
+ "taxUnitDeduction.taxUnit.realPassword, taxUnitDeduction.taxUnit.isAutoDeduct, isDecdut, " +
|
|
|
+ "taxPersonRecordEntry.bill.cardType, taxPersonRecordEntry.bill.cardNumber," +
|
|
|
+ "taxPersonRecordEntry.bill.reportName,taxPersonRecordEntry.bill.nationality.name where id in " + CmpStrUtil.concatList(ids);
|
|
|
+
|
|
|
+ TaxDirectDeductionCollection collection = TaxDirectDeductionFactory.getLocalInstance(ctx).getTaxDirectDeductionCollection(oql);
|
|
|
+ LOG.error(collection.toString());
|
|
|
+ if (null != collection && collection.size() != 0) {
|
|
|
+ List<IObjectPK> arrayList = new ArrayList();
|
|
|
+ Map<String, List<TaxDirectDeductionInfo>> groups = this.groupByTaxUnit(collection);
|
|
|
+ Map<String, String> acceptIdMap = this.getAcceptIdMap(ctx, groups);
|
|
|
+ List<Object[]> params = new ArrayList();
|
|
|
+ Iterator i$groups = groups.entrySet().iterator();
|
|
|
+
|
|
|
+ while(i$groups.hasNext()) {
|
|
|
+ Map.Entry<String, List<TaxDirectDeductionInfo>> entry = (Map.Entry)i$groups.next();
|
|
|
+ TaxDirectDeductionInfo deductionInfo = ((TaxDirectDeductionInfo)((List)entry.getValue()).get(0));
|
|
|
+ TaxUnitDeductionInfo taxUnitDeductionInfo = deductionInfo.getTaxUnitDeduction();
|
|
|
+ TaxUnitInfo taxUnitInfo = taxUnitDeductionInfo.getTaxUnit();
|
|
|
+ StringBuilder confirmIds = new StringBuilder();
|
|
|
+ SixTConfirmInfo sixTConfirmInfo = new SixTConfirmInfo();
|
|
|
+ sixTConfirmInfo.setBizNo(deductionInfo.getId().toString());
|
|
|
+ sixTConfirmInfo.setQymc(taxUnitInfo.getName());
|
|
|
+ sixTConfirmInfo.setMmlx(null);
|
|
|
+ sixTConfirmInfo.setSmzh(null);
|
|
|
+ sixTConfirmInfo.setSmmm(null);
|
|
|
+ sixTConfirmInfo.setJmsmmm(null);
|
|
|
+ sixTConfirmInfo.setDjxhid(taxUnitInfo.getRegNumber());
|
|
|
+ sixTConfirmInfo.setNsrsbh(taxUnitInfo.getTaxNumber());
|
|
|
+ sixTConfirmInfo.setAreaid(taxUnitInfo.getAreaCode());
|
|
|
+ sixTConfirmInfo.setBmbh(null);
|
|
|
+ sixTConfirmInfo.setBmmc(null);
|
|
|
+ sixTConfirmInfo.setSbmm(Base64Utils.decode(taxUnitInfo.getDeclPassword()));
|
|
|
+ sixTConfirmInfo.setJmsbmm(null);
|
|
|
+ sixTConfirmInfo.setSkssnd(String.valueOf(taxUnitDeductionInfo.getYear()));
|
|
|
+ sixTConfirmInfo.setAcceptId(acceptIdMap.get(taxUnitDeductionInfo.getId().toString()));
|
|
|
+ sixTConfirmInfo.setTAXUNITID(taxUnitInfo.getId().toString());
|
|
|
+ int lastYear = CmpDateUtil.getYear(new Date());
|
|
|
+ String period = lastYear + "01";
|
|
|
+ sixTConfirmInfo.setSdyf(period);
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+
|
|
|
+ List<SixTPersonInfo> kczglb = Lists.newArrayList();
|
|
|
+ sixTConfirmInfo.setKczglb(kczglb);
|
|
|
+
|
|
|
+ TaxDirectDeductionInfo taxDirectDeductionInfo;
|
|
|
+ for(Iterator i$ = ((List)entry.getValue()).iterator(); i$.hasNext(); confirmIds.append(taxDirectDeductionInfo.getId().toString())) {
|
|
|
+ taxDirectDeductionInfo = (TaxDirectDeductionInfo)i$.next();
|
|
|
+ SixTPersonInfo sixTPersonInfo = new SixTPersonInfo();
|
|
|
+ kczglb.add(sixTPersonInfo);
|
|
|
+ sixTPersonInfo.setXm(taxDirectDeductionInfo.getTaxPersonRecordEntry().getBill().getReportName());
|
|
|
+ sixTPersonInfo.setZzlx(taxDirectDeductionInfo.getTaxPersonRecordEntry().getBill().getCardType().getAlias());
|
|
|
+ sixTPersonInfo.setZzhm(taxDirectDeductionInfo.getTaxPersonRecordEntry().getBill().getCardNumber());
|
|
|
+ sixTPersonInfo.setGj(taxDirectDeductionInfo.getTaxPersonRecordEntry().getBill().getNationality().getName());
|
|
|
+ sixTPersonInfo.setKcbs( taxDirectDeductionInfo.isIsDecdut() ? "是" : "否");
|
|
|
+ Object[] param = new Object[2];
|
|
|
+ param[0] = 40;
|
|
|
+ param[1] = taxDirectDeductionInfo.getId().toString();
|
|
|
+ params.add(param);
|
|
|
+ if (confirmIds.length() > 0) {
|
|
|
+ confirmIds.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("ids", confirmIds.toString());
|
|
|
+ map.put("qrgjrylb", kczglb);
|
|
|
+
|
|
|
+ ISYUtilsFacade facade = SYUtilsFacadeFactory.getLocalInstance(ctx);
|
|
|
+ Map<String,String> config =facade.getConfig();
|
|
|
+ JSONConfig jc = JSONConfig.create();
|
|
|
+ jc.setIgnoreNullValue(true);
|
|
|
+ String sixTConfirmJSON =JSONUtil.toJsonStr(sixTConfirmInfo,jc);
|
|
|
+ LOG.error(sixTConfirmJSON);
|
|
|
+ String result = SYUtilsFacadeFactory.getLocalInstance(ctx).post(config.get("ip")+URLConfigEnum.CONFIRMPREDEDUCT_VALUE, sixTConfirmJSON);
|
|
|
+ LOG.error(result);
|
|
|
+
|
|
|
+ if(null!=result) {
|
|
|
+ JSONObject object = JSONUtil.parseObj(result);
|
|
|
+ JSONObject head = object.getJSONObject("head");
|
|
|
+ if("00000000".equals(head.getStr("code"))) {
|
|
|
+ JSONObject body = object.getJSONObject("body");
|
|
|
+ String taskId = facade.backTask(config.get("ip")+URLConfigEnum.GETPREDEDUCTCONFIRMFEEDBACK_VALUE, body.getStr("requestId"),"getPreDeductConfirmFeedBack",result, TaskCatalogEnum.COLLECTION_CONFIRM);
|
|
|
+ //sixTConfirmInfo添加任务
|
|
|
+ //IObjectPK pk = TaxServiceTaskFacadeFactory.getLocalInstance(ctx).addTask(TaxCalTaskCatalogEnum.COLLECTION_CONFIRM, map);
|
|
|
+ String updateSQL = "update T_HR_STaxDirectDeduction set FSate = ?,FTASKID='"+taskId+"' where fid = ?";
|
|
|
+ DbUtil.executeBatch(ctx, updateSQL, params);
|
|
|
+
|
|
|
+ arrayList.add(new ObjectUuidPK(taskId));
|
|
|
+ }else{
|
|
|
+ throw new BOSException(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return arrayList;
|
|
|
+ } else {
|
|
|
+ throw new BOSException("6万直接扣除人员确认,未获取到对应的人员数据,请联系管理员检查数据是否被删除");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取纳税单位归集年记录表
|
|
|
+ * @param collection
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ protected Map<String, List<TaxDirectDeductionInfo>> groupByTaxUnit(TaxDirectDeductionCollection collection) {
|
|
|
+ Map<String, List<TaxDirectDeductionInfo>> map = new HashMap();
|
|
|
+
|
|
|
+ for(int i = 0; i < collection.size(); ++i) {
|
|
|
+ TaxDirectDeductionInfo info = collection.get(i);
|
|
|
+ String taxUnitDeductionId = info.getTaxUnitDeduction().getId().toString();
|
|
|
+ List<TaxDirectDeductionInfo> list = (List)map.get(taxUnitDeductionId);
|
|
|
+ if (null == list) {
|
|
|
+ list = new ArrayList();
|
|
|
+ }
|
|
|
+
|
|
|
+ ((List)list).add(info);
|
|
|
+ map.put(taxUnitDeductionId, list);
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ protected Map<String, String> getAcceptIdMap(Context ctx, Map<String, List<TaxDirectDeductionInfo>> groups) throws BOSException {
|
|
|
+ try {
|
|
|
+ String sql = "select t3.fAccept_id acceptId, t1.fid fid from t_hr_sTaxUnitDeduction t1, T_HR_STaskIncomeTaxRelation t2, t_hr_sTaxCalTask t3 where t1.fid = t2.fBizId and t2.fTaskId = t3.fid and t1.fid in (" + CmpStrUtil.convertSetToSqlString(groups.keySet()) + ")";
|
|
|
+ Map<String, String> acceptIdMap = new HashMap();
|
|
|
+ IRowSet rs = DbUtil.executeQuery(ctx, sql);
|
|
|
+
|
|
|
+ while(rs.next()) {
|
|
|
+ String key = rs.getString("fid");
|
|
|
+ String acceptId = rs.getString("acceptId");
|
|
|
+ acceptIdMap.put(key, acceptId);
|
|
|
+ }
|
|
|
+
|
|
|
+ return acceptIdMap;
|
|
|
+ } catch (Exception var8) {
|
|
|
+ LOG.error("getAcceptIdMap error: ", var8);
|
|
|
+ throw new BOSException(var8.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|