Bladeren bron

企业注册,人员推送,专项附加功能修改

9060 8 maanden geleden
bovenliggende
commit
eaaebc2b3b

+ 197 - 179
websrc/com/kingdee/eas/custom/shuiyou/inter/handler/TaxUnitListHandlerEx.java

@@ -1,15 +1,21 @@
 package com.kingdee.eas.custom.shuiyou.inter.handler;
 
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
 import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.metadata.entity.SelectorItemCollection;
+import com.kingdee.bos.metadata.entity.SelectorItemInfo;
 import com.kingdee.bos.util.BOSUuid;
 import com.kingdee.eas.basedata.hraux.BirthplaceFactory;
 import com.kingdee.eas.basedata.hraux.NationalityFactory;
 import com.kingdee.eas.basedata.person.PersonFactory;
 import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.shuiyou.registration.IRegistrationInfo;
 import com.kingdee.eas.custom.shuiyou.registration.RegistrationInfoCollection;
 import com.kingdee.eas.custom.shuiyou.registration.RegistrationInfoFactory;
 import com.kingdee.eas.custom.shuiyou.registration.RegistrationInfoInfo;
@@ -20,12 +26,14 @@ import com.kingdee.shr.base.syssetting.context.SHRContext;
 import com.kingdee.shr.base.syssetting.exception.SHRWebException;
 import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
 import com.kingdee.shr.compensation.app.incomeTax.*;
+import com.kingdee.shr.compensation.app.tax.ITaxUnit;
 import com.kingdee.shr.compensation.app.tax.TaxUnitCollection;
 import com.kingdee.shr.compensation.app.tax.TaxUnitFactory;
 import com.kingdee.shr.compensation.app.tax.TaxUnitInfo;
 import com.kingdee.shr.compensation.util.Base64Utils;
 import com.kingdee.shr.compensation.web.handler.tax.taxUnit.TaxUnitListHandler;
 import okhttp3.*;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.springframework.ui.ModelMap;
 
@@ -39,7 +47,7 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 public class TaxUnitListHandlerEx extends TaxUnitListHandler {
-    private Properties propt = new Properties();
+
     private static Logger logger = Logger.getLogger("com.kingdee.eas.custom.shuiyou.TaxUnitListHandlerEx");
 
     /**
@@ -54,187 +62,207 @@ public class TaxUnitListHandlerEx extends TaxUnitListHandler {
         String entrance = "com.kingdee.eas.custom.jiuzhoutong.shuiyou.TaxUnitListHandlerEx.businessAegistrationAction";
         Map<String, Object> returnMap = new HashMap<String, Object>();
         logger.error("=========进入:" + entrance + "==========");
-        String id = request.getParameter("id");
+        String ids = request.getParameter("id");
         Context context = SHRContext.getInstance().getContext();
-        Map<String, String> commonParameter = null;
+
         String postBody = "";
         String post = "";
+        List<Map<String,Object>> unList = Lists.newArrayList();
         try {
+            ISYUtilsFacade utilsFacade = SYUtilsFacadeFactory.getLocalInstance(context);
+            Map propt=utilsFacade.getConfig();
             logger.error("=====获取基本信息=====");
-            this.propt.load(new FileInputStream(System.getProperty("EAS_HOME") + "/server/properties/sy/syConfig.properties"));
-            logger.error("=======获取报税企业信息=====");
-            TaxUnitInfo taxUnitInfo = TaxUnitFactory.getLocalInstance(context).getTaxUnitInfo(new ObjectUuidPK(id));
-            String name = taxUnitInfo.getName();//企业名称
-            String taxNumber = taxUnitInfo.getTaxNumber();//税号
-            String areaCode = taxUnitInfo.getAreaCode();//行政区代码
-            logger.error("企业名称:" + name);
-            logger.error("税号:" + taxNumber);
-            logger.error("行政区代码:" + areaCode);
-            logger.error("==========================");
-
-
-            logger.error("==========发送请求 post================");
-            OkHttpClient client = new OkHttpClient();
-            String ip = propt.getProperty("ip");
-            String url = ip + "/gateway/iit/declare/getCompanyRegisterInfo";
-            logger.error("地址:" + url);
-            postBody = "{\"qymc\":\"" + name + "\",\"nsrsbh\":\"" + taxNumber + "\",\"areaid\":\"" + areaCode + "\"}";
-            logger.error("参数:" + postBody);
-            logger.error("公共参数:" + JSONObject.toJSONString(commonParameter));
-
-            post = SYUtilsFacadeFactory.getLocalInstance(context).post(url, postBody);
-            //gateway/iit/declare/getCompanyRegisterInfo
-//            RequestBody body = RequestBody.create(MediaType.parse("application/json"), postBody);
-//            Request sYRequest = new Request.Builder()
-//                    .url(url)
-//                    .post(body).headers(Headers.of(commonParameter))
-//                    .build();
-//            sYResponse = client.newCall(sYRequest).execute();
-
-            logger.error("返回参数:" + post);
-            //返回值需要改 不是JSONArray 类型 需要更具 正常返回值来判断
-            //JSONArray jsonArray = JSONArray.parseArray(post);
-            JSONObject returnDate = JSONObject.parseObject(post);
-            JSONObject head = returnDate.getJSONObject("head");
-            String description = head.getString("description");
-            RegistrationInfoInfo registrationInfo;
-            if (!"成功".equals(description)) {
-                returnMap.put("code", 500);
-                returnMap.put("error", "接口调用失败,请看日志");
-                JSONUtils.SUCCESS(returnMap);
-                return;
-            }
-
-            JSONArray body = returnDate.getJSONArray("body");
-//            if (body.size() > 0) {
-//                logger.error("写入数据:"+body.toJSONString());
-//                logger.error("删除原有的数据以便以写入行的数据");
-//                String sql = "delete from CT_REG_RegistrationInfo";
-//                DBUtil.execute(context, sql);
-//            }
-            logger.error("写入数据:");
-            for (int i = 0; i < body.size(); i++) {
-                JSONObject jsonObject = body.getJSONObject(i);
-                String djxhid = jsonObject.getString("djxhid");//	登记序号
-                RegistrationInfoCollection registrationInfoCollection = RegistrationInfoFactory.getLocalInstance(context).getRegistrationInfoCollection("where djxhid = '" + djxhid + "'");
-                if (registrationInfoCollection.size() == 0) {
-                    registrationInfo = new RegistrationInfoInfo();
-                } else {
-                    registrationInfo = registrationInfoCollection.get(0);
-                }
-
-                registrationInfo.setDjxhid(djxhid);
-                String qymc = jsonObject.getString("qymc");//	企业名称
-
-                registrationInfo.setQymc(qymc);
-                String frxm = jsonObject.getString("frxm");//	法人姓名
-                registrationInfo.setFrxm(frxm);
-
-                String lxdh = jsonObject.getString("lxdh");//	联系电话
-                registrationInfo.setLxdh(lxdh);
-
-                String scjydz = jsonObject.getString("scjydz");//	生产经营地址
-                registrationInfo.setScjydz(scjydz);
-
-                String hymc = jsonObject.getString("hymc");//	行业名称
-                registrationInfo.setHymc(hymc);
-
-                String zgswjgmc = jsonObject.getString("zgswjgmc");//	主管税务机关名称
-                registrationInfo.setZgswjgmc(zgswjgmc);
-
-                String zgswjg = jsonObject.getString("zgswjg");//	主管税务机关代码
-                registrationInfo.setZgswjg(zgswjg);
-
-                String zgswjgskdm = jsonObject.getString("zgswjgskdm");//	主管税务分局所科代码
-                registrationInfo.setZgswjgskdm(zgswjgskdm);
-
-                String zgswjgskmc = jsonObject.getString("zgswjgskmc");//	主管税务分局所科名称
-                registrationInfo.setZgswjgskmc(zgswjgskmc);
-
-                String fbmba = jsonObject.getString("fbmba");//	是否分部门备案
-                registrationInfo.setFbmba(fbmba);
-
-                String smzh = jsonObject.getString("smzh");//	实名账号
-                registrationInfo.setSmzh(smzh);
-
-                String shxydm = jsonObject.getString("shxydm");//	社会信用代码
-                registrationInfo.setShxydm(shxydm);
-
-                String nsrsbm = jsonObject.getString("nsrsbm");//	纳税人识别码
-                registrationInfo.setNsrsbm(nsrsbm);
-
-                String yzbm = jsonObject.getString("yzbm");//	邮政编码
-                registrationInfo.setYzbm(yzbm);
-
-                String cwxm = jsonObject.getString("cwxm");//	财务负责人
-                registrationInfo.setCwxm(cwxm);
-
-                String hydm = jsonObject.getString("hydm");//	行业代码
-                registrationInfo.setHydm(hydm);
-
-                String jjlxdm = jsonObject.getString("jjlxdm");//	经济类型名称代码
-                registrationInfo.setJjlxdm(jjlxdm);
-
-                String jjlxmc = jsonObject.getString("jjlxmc");//	经济类型名称
-                registrationInfo.setJjlxmc(jjlxmc);
-
-                String ssglydm = jsonObject.getString("ssglydm");//	税收管理员代码
-                registrationInfo.setSsglydm(ssglydm);
-
-                String bsrxm = jsonObject.getString("bsrxm");//	报税人姓名
-                registrationInfo.setBsrxm(bsrxm);
-
-                String jdxzdm = jsonObject.getString("jdxzdm");//	街道乡镇代码
-                registrationInfo.setJdxzdm(jdxzdm);
-
-                String kjywrdm = jsonObject.getString("kjywrdm");//	扣缴义务人代码
-                registrationInfo.setKjywrdm(kjywrdm);
-
-                String djrq = jsonObject.getString("djrq");//	登记日期
-                registrationInfo.setDjrq(djrq);
-
-                String swjgdm = jsonObject.getString("swjgdm");//	税务机关代码
-                registrationInfo.setSwjgdm(swjgdm);
-
-                String swjgmc = jsonObject.getString("swjgmc");//	税务机关名称
-                registrationInfo.setSwjgmc(swjgmc);
-
-                String sfscjyqy = jsonObject.getString("sfscjyqy");//	是否是生产经营企业
-                registrationInfo.setSfscjyqy(sfscjyqy);
+            IRegistrationInfo ir = RegistrationInfoFactory.getLocalInstance(context);
+            ITaxUnitRegisterDetail itr = TaxUnitRegisterDetailFactory.getLocalInstance(context);
+            if(StringUtils.isNotBlank(ids)) {
+                String[] idsArr = ids.split(",");
+                for (String id : idsArr) {
+                    logger.error("=======获取报税企业信息=====");
+                    ITaxUnit taxUnit = TaxUnitFactory.getLocalInstance(context);
+                    TaxUnitInfo taxUnitInfo = taxUnit.getTaxUnitInfo(new ObjectUuidPK(id));
+                    String name = taxUnitInfo.getName();//企业名称
+                    String taxNumber = taxUnitInfo.getTaxNumber();//税号
+                    String areaCode = taxUnitInfo.getAreaCode();//行政区代码
+                    String regNumber = taxUnitInfo.getRegNumber();//登记序列号
+                    logger.error("企业名称:" + name);
+                    logger.error("税号:" + taxNumber);
+                    logger.error("行政区代码:" + areaCode);
+                    logger.error("==========================");
+                    logger.error("==========发送请求 post================");
+                    String ip = (String) propt.get("ip");
+                    String url = ip + "/gateway/iit/declare/getCompanyRegisterInfo";
+                    logger.error("地址:" + url);
+                    Map<String, Object> param = Maps.newHashMap();
+                    param.put("qymc", name);
+                    param.put("nsrsbh", taxNumber);
+                    param.put("areaid", areaCode);
+                    param.put("djxhid", regNumber);
+                    postBody = JSONUtil.toJsonStr(param);
+                    logger.error("参数:" + postBody);
+                    post = SYUtilsFacadeFactory.getLocalInstance(context).post(url, postBody);
+                    logger.error("返回参数:" + post);
+                    JSONObject returnDate = JSONObject.parseObject(post);
+                    JSONObject head = returnDate.getJSONObject("head");
+                    String code = head.getString("code");
+                    RegistrationInfoInfo registrationInfo;
+                    TaxUnitRegisterDetailInfo  registrationInfo_old;
+                    if (!"00000000".equals(code)) {
+                        Map<String,Object> errMap = Maps.newHashMap();
+                        errMap.put("msg",name+",注册失败!");
+                        errMap.put("result",post);
+                        unList.add(errMap);
+                        continue;
+                    }
+                    JSONArray body = returnDate.getJSONArray("body");
+                    logger.error("写入数据:");
 
-                String nsrztdm = jsonObject.getString("nsrztdm");//	纳税人状态代码
-                registrationInfo.setNsrztdm(nsrztdm);
+                    for (int i = 0; i < body.size(); i++) {
+                        JSONObject jsonObject = body.getJSONObject(i);
+                        String djxhid = jsonObject.getString("djxhid");//	登记序号
+                        String nsrsbm = jsonObject.getString("nsrsbm");//	纳税人识别码
 
-                String nsrztmc = jsonObject.getString("nsrztmc");//	纳税人状态名称
-                registrationInfo.setNsrztmc(nsrztmc);
-                if (registrationInfoCollection.size() == 0) {
-                    RegistrationInfoFactory.getLocalInstance(context).save(registrationInfo);
-                } else {
-                    RegistrationInfoFactory.getLocalInstance(context).update(new ObjectUuidPK(registrationInfo.getId()), registrationInfo);
+                        RegistrationInfoCollection registrationInfoCollection = ir.getRegistrationInfoCollection("where djxhid = '" + djxhid + "'");
+                        TaxUnitRegisterDetailCollection registrationInfo_oldCollection = itr.getTaxUnitRegisterDetailCollection("where registerNo = '" + djxhid + "'");
+                        if (registrationInfoCollection.size() <= 0) {
+                            registrationInfo = new RegistrationInfoInfo();
+                        } else {
+                            registrationInfo = registrationInfoCollection.get(0);
+                        }
+                        if (registrationInfo_oldCollection.size() <= 0) {
+                            registrationInfo_old = new TaxUnitRegisterDetailInfo();
+                        } else {
+                            registrationInfo_old = registrationInfo_oldCollection.get(0);
+                        }
+                        registrationInfo_old.setTaxUnit(taxUnitInfo);
+                        registrationInfo_old.setRegisterDate(new Date());
+                        registrationInfo_old.setRegisterNo(djxhid);
+                        registrationInfo_old.setTaxNumber(nsrsbm);
+                        registrationInfo.setDjxhid(djxhid);
+                        registrationInfo_old.setNumber(nsrsbm);
+                        String qymc = jsonObject.getString("qymc");//	企业名称
+                        registrationInfo_old.setRegisterName(qymc);
+                        registrationInfo_old.setName(qymc);
+                        registrationInfo.setQymc(qymc);
+                        String frxm = jsonObject.getString("frxm");//	法人姓名
+                        registrationInfo.setFrxm(frxm);
+
+                        String lxdh = jsonObject.getString("lxdh");//	联系电话
+                        registrationInfo_old.setTelephone(lxdh);
+                        registrationInfo.setLxdh(lxdh);
+
+                        String scjydz = jsonObject.getString("scjydz");//	生产经营地址
+                        registrationInfo.setScjydz(scjydz);
+
+                        String hymc = jsonObject.getString("hymc");//	行业名称
+                        registrationInfo.setHymc(hymc);
+
+                        String zgswjgmc = jsonObject.getString("zgswjgmc");//	主管税务机关名称
+                        registrationInfo_old.setTaxAuthName(zgswjgmc);
+                        registrationInfo.setZgswjgmc(zgswjgmc);
+
+                        String zgswjg = jsonObject.getString("zgswjg");//	主管税务机关代码
+                        registrationInfo.setZgswjg(zgswjg);
+
+                        String zgswjgskdm = jsonObject.getString("zgswjgskdm");//	主管税务分局所科代码
+                        registrationInfo.setZgswjgskdm(zgswjgskdm);
+
+                        String zgswjgskmc = jsonObject.getString("zgswjgskmc");//	主管税务分局所科名称
+                        registrationInfo.setZgswjgskmc(zgswjgskmc);
+
+                        String fbmba = jsonObject.getString("fbmba");//	是否分部门备案
+                        registrationInfo.setFbmba(fbmba);
+
+                        String smzh = jsonObject.getString("smzh");//	实名账号
+                        registrationInfo.setSmzh(smzh);
+
+                        String shxydm = jsonObject.getString("shxydm");//	社会信用代码
+                        registrationInfo.setShxydm(shxydm);
+
+
+                        registrationInfo.setNsrsbm(nsrsbm);
+
+                        String yzbm = jsonObject.getString("yzbm");//	邮政编码
+                        registrationInfo.setYzbm(yzbm);
+
+                        String cwxm = jsonObject.getString("cwxm");//	财务负责人
+                        registrationInfo.setCwxm(cwxm);
+
+                        String hydm = jsonObject.getString("hydm");//	行业代码
+                        registrationInfo.setHydm(hydm);
+
+                        String jjlxdm = jsonObject.getString("jjlxdm");//	经济类型名称代码
+                        registrationInfo.setJjlxdm(jjlxdm);
+
+                        String jjlxmc = jsonObject.getString("jjlxmc");//	经济类型名称
+                        registrationInfo.setJjlxmc(jjlxmc);
+
+                        String ssglydm = jsonObject.getString("ssglydm");//	税收管理员代码
+                        registrationInfo.setSsglydm(ssglydm);
+
+                        String bsrxm = jsonObject.getString("bsrxm");//	报税人姓名
+                        registrationInfo.setBsrxm(bsrxm);
+
+                        String jdxzdm = jsonObject.getString("jdxzdm");//	街道乡镇代码
+                        registrationInfo.setJdxzdm(jdxzdm);
+
+                        String kjywrdm = jsonObject.getString("kjywrdm");//	扣缴义务人代码
+                        registrationInfo.setKjywrdm(kjywrdm);
+
+                        String djrq = jsonObject.getString("djrq");//	登记日期
+                        registrationInfo.setDjrq(djrq);
+
+                        String swjgdm = jsonObject.getString("swjgdm");//	税务机关代码
+                        registrationInfo.setSwjgdm(swjgdm);
+
+                        String swjgmc = jsonObject.getString("swjgmc");//	税务机关名称
+                        registrationInfo.setSwjgmc(swjgmc);
+
+                        String sfscjyqy = jsonObject.getString("sfscjyqy");//	是否是生产经营企业
+                        registrationInfo.setSfscjyqy(sfscjyqy);
+
+                        String nsrztdm = jsonObject.getString("nsrztdm");//	纳税人状态代码
+                        registrationInfo.setNsrztdm(nsrztdm);
+
+                        String nsrztmc = jsonObject.getString("nsrztmc");//	纳税人状态名称
+                        registrationInfo.setNsrztmc(nsrztmc);
+                        if (registrationInfoCollection.size() == 0) {
+                            ir.addnew(registrationInfo);
+                        } else {
+                            ir.save(registrationInfo);
+                        }
+                        if (registrationInfo_oldCollection.size() == 0) {
+                            itr.addnew(registrationInfo_old);
+                        } else {
+                            itr.save(registrationInfo_old);
+                        }
+                        if (taxNumber.equals(nsrsbm)) {
+                            taxUnitInfo.setRegNumber(djxhid);
+                            taxUnitInfo.put("registration",registrationInfo);
+                            taxUnitInfo.setTaxRegisterInfo(registrationInfo_old);
+                            taxUnit.save(taxUnitInfo);
+                        }
+                    }
                 }
             }
             logger.error("记录成功接口日志");
             returnMap.put("code", 200);
-            returnMap.put("error", "");
+            returnMap.put("unList", unList);
             returnMap.put("info", "注册成功");
+            JSONUtils.SUCCESS(returnMap);
         } catch (BOSException e) {
+            e.printStackTrace();
             logger.error("记录BOSException报错接口日志");
             returnMap.put("code", 500);
-            returnMap.put("error", e);
+            returnMap.put("error", e.getMessage());
+            JSONUtils.ERROR(e.getMessage(),e);
         } catch (EASBizException e) {
+            e.printStackTrace();
             logger.error("记录 EASBizException 报错接口日志");
             returnMap.put("code", 500);
-            returnMap.put("error", e);
-        } catch (FileNotFoundException e) {
-            logger.error("记录 FileNotFoundException 报错接口日志");
-            returnMap.put("code", 500);
-            returnMap.put("error", e);
-        } catch (IOException e) {
-            logger.error("记录 IOException 报错接口日志");
-            returnMap.put("code", 500);
-            returnMap.put("error", e);
+            returnMap.put("error", e.getMessage());
+            JSONUtils.ERROR(e.getMessage(),e);
         }
-        JSONUtils.SUCCESS(returnMap);
+
         logger.error("======================退出==================================");
     }
 
@@ -257,7 +285,8 @@ public class TaxUnitListHandlerEx extends TaxUnitListHandler {
             taxPeriodDate=taxPeriodFormat.format(new Date());
         }
         try {
-            this.propt.load(new FileInputStream(System.getProperty("EAS_HOME") + "/server/properties/sy/syConfig.properties"));
+             ISYUtilsFacade utilsFacade = SYUtilsFacadeFactory.getLocalInstance(context);
+            Map propt=utilsFacade.getConfig();
             TaxUnitCollection taxUnitCollection = TaxUnitFactory.getLocalInstance(context).getTaxUnitCollection();
             for (int i = 0; i < taxUnitCollection.size(); i++) {
                 TaxUnitInfo taxUnitInfo = taxUnitCollection.get(i);
@@ -478,7 +507,7 @@ public class TaxUnitListHandlerEx extends TaxUnitListHandler {
 
                 }
                 postBody.put("rylb", rylb);
-                String ip = propt.getProperty("ip");
+                String ip = (String) propt.get("ip");
                 String url = ip + "/gateway/iit/declare/declareEmployeeInfo";
                 logger.error("===请求参数=="+postBody+"========");
                 ISYUtilsFacade localInstance = SYUtilsFacadeFactory.getLocalInstance(context);
@@ -507,12 +536,6 @@ public class TaxUnitListHandlerEx extends TaxUnitListHandler {
         } catch (BOSException e) {
             JSONUtils.ERROR("BOSException",e);
             throw new RuntimeException(e);
-        } catch (FileNotFoundException e) {
-            JSONUtils.ERROR("FileNotFoundException",e);
-            throw new RuntimeException(e);
-        } catch (IOException e) {
-            JSONUtils.ERROR("IOException",e);
-            throw new RuntimeException(e);
         } catch (EASBizException e) {
             JSONUtils.ERROR("EASBizException",e);
             throw new RuntimeException(e);
@@ -535,7 +558,8 @@ public class TaxUnitListHandlerEx extends TaxUnitListHandler {
         Calendar cal = Calendar.getInstance();
         String skssq = skssqFormat.format(cal.getTime());
         try {
-            this.propt.load(new FileInputStream(System.getProperty("EAS_HOME") + "/server/properties/sy/syConfig.properties"));
+             ISYUtilsFacade utilsFacade = SYUtilsFacadeFactory.getLocalInstance(context);
+            Map propt=utilsFacade.getConfig();
             TaxUnitCollection taxUnitCollection = TaxUnitFactory.getLocalInstance(context).getTaxUnitCollection();
             for (int i = 0; i < taxUnitCollection.size(); i++) {
                 TaxUnitInfo taxUnitInfo = taxUnitCollection.get(i);
@@ -599,7 +623,7 @@ public class TaxUnitListHandlerEx extends TaxUnitListHandler {
                     rylb.add(personInfo);
                 }
                 postBody.put("rylb", rylb);
-                String ip = propt.getProperty("ip");
+                String ip = (String) propt.get("ip");
                 String url = ip + "/gateway/iit/personalPension/download";
                 logger.error("===请求参数=="+postBody+"========");
                 ISYUtilsFacade localInstance = SYUtilsFacadeFactory.getLocalInstance(context);
@@ -626,12 +650,6 @@ public class TaxUnitListHandlerEx extends TaxUnitListHandler {
         } catch (BOSException e) {
             JSONUtils.ERROR("BOSException",e);
             throw new RuntimeException(e);
-        } catch (FileNotFoundException e) {
-            JSONUtils.ERROR("FileNotFoundException",e);
-            throw new RuntimeException(e);
-        } catch (IOException e) {
-            JSONUtils.ERROR("IOException",e);
-            throw new RuntimeException(e);
         } catch (EASBizException e) {
             JSONUtils.ERROR("EASBizException",e);
             throw new RuntimeException(e);

+ 8 - 5
websrc/com/kingdee/eas/custom/shuiyou/six/handler/CmpTaxDeclarationListHandlerEx.java

@@ -1,11 +1,13 @@
 package com.kingdee.eas.custom.shuiyou.six.handler;
 
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
 import com.google.common.collect.Maps;
 import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
 import com.kingdee.eas.common.EASBizException;
-import com.kingdee.shr.base.syssetting.MSFServiceFacadeFactory;
+import com.kingdee.eas.custom.shuiyou.task.TaskCatalogEnum;
+import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacadeFactory;
 import com.kingdee.shr.base.syssetting.context.SHRContext;
 import com.kingdee.shr.base.syssetting.exception.SHRWebException;
 import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
@@ -29,15 +31,16 @@ public class CmpTaxDeclarationListHandlerEx extends CmpTaxDeclarationListHandler
 
     public String getCompanyIncomesAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException, BOSException, EASBizException {
         Context ctx = SHRContext.getInstance().getContext();
-        String skssq = request.getParameter("skssq");
+        String skssq = request.getParameter("taxPeriodDate");
         if(StrUtil.isBlank(skssq)){
             new ShrWebBizException("ÖÜÆÚΪ¿Õ,Çë´«Èë");
         }
         Map<String,String> param = Maps.newHashMap();
+        skssq=skssq.replace("-","");
         param.put("skssq",skssq);
-        Object obj = MSFServiceFacadeFactory.getLocalInstance(ctx).processService("getCompanyIncomesService", param);
-
-        JSONUtils.SUCCESS(obj);
+        String id = SYUtilsFacadeFactory.getLocalInstance(ctx).addTask("getCompanyIncomesService", JSONUtil.toJsonStr(param), TaskCatalogEnum.TAXSUMDATADOWNLOAD_GET,"");
+        //Object obj = MSFServiceFacadeFactory.getLocalInstance(ctx).processService("getCompanyIncomesService", param);
+        JSONUtils.SUCCESS(id);
         return null;
     }
 

+ 274 - 35
websrc/com/kingdee/eas/custom/shuiyou/six/handler/TaxDirectDeductionListHandlerEx.java

@@ -2,20 +2,27 @@ package com.kingdee.eas.custom.shuiyou.six.handler;
 
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.google.common.collect.Maps;
 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.metadata.entity.FilterInfo;
-import com.kingdee.bos.sql.ParserException;
+
+import com.kingdee.bos.rabbitmq.guava.Lists;
 import com.kingdee.bos.util.BOSUuid;
+import com.kingdee.eas.basedata.person.PersonFactory;
 import com.kingdee.eas.common.EASBizException;
 import com.kingdee.eas.custom.shuiyou.incomeTax.TaxDirectDeductionExFacadeFactory;
 
+import com.kingdee.eas.custom.shuiyou.incomeTax.TaxPersonReportExFacadeFactory;
+import com.kingdee.eas.custom.shuiyou.task.TaskCatalogEnum;
 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.custom.shuiyou.vo.SixTConfirmInfo;
+import com.kingdee.eas.framework.CoreBaseCollection;
 import com.kingdee.eas.util.app.DbUtil;
 import com.kingdee.jdbc.rowset.IRowSet;
 import com.kingdee.shr.base.syssetting.app.filter.HRFilterUtils;
@@ -23,6 +30,13 @@ 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.base.syssetting.web.json.JSONUtils;
+import com.kingdee.shr.compensation.BankCardStatusEnum;
+import com.kingdee.shr.compensation.IdentityStatusEnume;
+import com.kingdee.shr.compensation.SubmitStatusEnum;
+import com.kingdee.shr.compensation.app.entity.TaxPersonEntity;
+import com.kingdee.shr.compensation.app.entity.Triple;
+import com.kingdee.shr.compensation.app.incomeTax.*;
 import com.kingdee.shr.compensation.app.tax.TaxUnitCollection;
 import com.kingdee.shr.compensation.app.tax.TaxUnitFactory;
 import com.kingdee.shr.compensation.app.tax.TaxUnitInfo;
@@ -33,6 +47,7 @@ import com.kingdee.shr.compensation.util.CmpDateUtil;
 import com.kingdee.shr.compensation.util.CmpStrUtil;
 
 import com.kingdee.shr.compensation.util.TaxReportUtil;
+
 import com.kingdee.shr.compensation.util.filter.CmpTaxUnitPermFilter;
 import com.kingdee.shr.compensation.util.lock.CmpDistributedLockUtils;
 import com.kingdee.shr.compensation.web.handler.tax.TaxDirectDeductionListHandler;
@@ -43,6 +58,7 @@ import org.springframework.ui.ModelMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -55,39 +71,259 @@ import java.util.*;
 public class TaxDirectDeductionListHandlerEx extends TaxDirectDeductionListHandler {
     private static final Logger LOG = Logger.getLogger(TaxDirectDeductionListHandler.class);
 
-    protected FilterInfo getDefaultFilter(HttpServletRequest request, HttpServletResponse response) throws SHRWebException {
-        FilterInfo customFilter = null;
-//        Context ctx = SHRContext.getInstance().getContext();
-//        String sql = CmpTaxUnitPermFilter.getCurPersonPermTaxUnitSql(ctx);
-//        String inRange = "''";
-//        if (!"".equals(sql)) {
-//            inRange = sql;
-//        }
-//
-//        String oql = "taxPersonRecordEntry.taxUnit.id in (" + inRange + ")";
-//        if (customFilter == null) {
-//            //int lastYear = CmpDateUtil.getYear(new Date()) - 1;
-//           // oql = oql + " and taxUnitDeduction.year = " + lastYear;
-//
-//            try {
-//                customFilter = new FilterInfo(oql);
-//            } catch (ParserException var12) {
-//                LOG.error(var12.getMessage(), var12);
-//            }
-//        } else {
-//            try {
-//                FilterInfo inRangeFilterInfo = new FilterInfo(oql);
-//                customFilter.mergeFilter(inRangeFilterInfo, "AND");
-//            } catch (BOSException var10) {
-//                LOG.error(var10.getMessage(), var10);
-//            } catch (ParserException var11) {
-//                LOG.error(var11.getMessage(), var11);
-//            }
-//        }
-
-        return customFilter;
+    /**
+     * 获取人员名单
+     * @param request
+     * @param response
+     * @param modelMap
+     * @throws SHRWebException
+     */
+    public void taxPersonReportAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        Context ctx = SHRContext.getInstance().getContext();
+        String ids = request.getParameter("taxUnitIds");
+        String period = request.getParameter("period");
+        int thisYear = CmpDateUtil.getYear(new Date());
+        Map<String, Object> map = new HashMap();
+        map.put("taxUnitIds", ids);
+        String taxPeriodDate = "";
+        if(!StringUtils.isEmpty(period)&&period.indexOf("-")>=0){
+            String[] periods=period.split("-");
+            taxPeriodDate=periods[0]+"-01";
+            map.put("period", taxPeriodDate);
+        } else {
+            taxPeriodDate=(thisYear-1) + "-01";
+            map.put("period", taxPeriodDate);
+        }
+        try {
+            List list = this._pensionReport(ctx,taxPeriodDate,CmpStrUtil.buildInSql(ids),null);
+            JSONUtils.SUCCESS(list);
+        } catch (BOSException var9) {
+            LOG.error("staffCollection failed, caused by: ", var9);
+            throw new ShrWebBizException(var9.getMessage());
+        }
+    }
+    /**
+     * 养老金下载
+     */
+
+    protected List _pensionReport(Context ctx, String taxPeriodDate, String ids, String filter) throws BOSException {
+
+        //String curPersonPermTaxUnitSql = CmpTaxUnitPermFilter.getCurPersonPermTaxUnitSql(ctx);
+        String oql = "select *,bill.*,bill.person.*,bill.nationality.*,bill.position.*,bill.birthPlace.*,bill.eduLevel.*,bill.bank.name,bill.hrBank.name,taxUnit.id,taxUnit.areacode,taxUnit.name,taxUnit.taxNumber,taxUnit.areaCode,taxUnit.regNumber,taxUnit.declPassword,taxUnit.realPassword where (submitStatus=0 or submitStatus=3) ";
+        //logger.error("------------>>>>_pensionReport:" + oql);
+        if (!StringUtils.isEmpty(ids)) {
+           // oql = oql + " and taxUnit.id in (" + curPersonPermTaxUnitSql + ")";
+            oql = oql + " and taxUnit.id in (" + ids + ")";
+        } else {
+            if (StringUtils.isEmpty(filter)) {
+                return null;
+            }
+
+            oql = oql + " and " + filter;
+        }
+        List<String> resultList= Lists.newArrayList();
+        try {
+            LOG.error("------------>>>>_pensionReport:" + oql);
+            ITaxPersonRecordEntry iTaxPersonRecordEntry = TaxPersonRecordEntryFactory.getLocalInstance(ctx);
+            TaxPersonRecordEntryCollection taxRecordEntryCollection = iTaxPersonRecordEntry.getTaxPersonRecordEntryCollection(oql);
+            if (taxRecordEntryCollection.size() == 0) {
+                return null;
+            } else {
+                Map<TaxUnitInfo, Triple<List<TaxPersonEntity>, CoreBaseCollection, CoreBaseCollection>> tripleMap = this.getTripleMap(taxRecordEntryCollection, taxPeriodDate);
+
+                LOG.error("------------>>>>_pensionReport:" + tripleMap);
+                ISYUtilsFacade localInstance = SYUtilsFacadeFactory.getLocalInstance(ctx);
+                Map<String, Object> propt = localInstance.getConfig();
+                Iterator i$ = tripleMap.entrySet().iterator();
+                while (i$.hasNext()) {
+                    Map.Entry<TaxUnitInfo, Triple<List<TaxPersonEntity>, CoreBaseCollection, CoreBaseCollection>> entry = (Map.Entry) i$.next();
+                    TaxUnitInfo taxUnitInfo = entry.getKey();
+                    Triple<List<TaxPersonEntity>, CoreBaseCollection, CoreBaseCollection> value = (Triple) entry.getValue();
+                    List<TaxPersonEntity> taxPersonEntitys = (List) value.getFirst();
+                    CoreBaseCollection entryBaseCollection = (CoreBaseCollection) value.getSecond();
+                    CoreBaseCollection billBaseCollection = (CoreBaseCollection) value.getThree();
+                    String bizNo = UUID.randomUUID().toString().replace("-", "");
+                    String qymc = taxUnitInfo.getName();//企业名称
+                    String mmlx = "0";//密码类型 0表示申报密码;2表示实名账号实名密码
+                    String smzh = "";//实名账号
+                    String smmm = "";//实名密码
+                    String jmsmmm = "";//加密实名密码
+                    byte[] decode = Base64.getDecoder().decode(taxUnitInfo.getDeclPassword());
+                    String sbmm = new String(decode);//;//申报密码
+                    String jmsbmm = "";//申报密码加密
+                    String djxhid = taxUnitInfo.getRegNumber();//登记序号
+                    String nsrsbh = taxUnitInfo.getTaxNumber();//税号
+                    String areaid = taxUnitInfo.getAreaCode();//地区编码
+                    String bmbh = "";//部门编号
+                    String bmmc = "";//部门编码
+
+                    String skssq = TaxReportUtil.getCurrentYearMonth(taxPeriodDate);
+                    String year = skssq.substring(0,4);
+                    String lzrqcl = "";
+                    Map<String,Object> postBody = Maps.newHashMap();
+                    postBody.put("bizNo", bizNo);
+                    postBody.put("qymc", qymc);
+                    postBody.put("mmlx", mmlx);
+                    postBody.put("smzh", smzh);
+                    postBody.put("smmm", smmm);
+                    postBody.put("jmsmmm", jmsmmm);
+                    postBody.put("sbmm", sbmm);
+                    postBody.put("jmsbmm", jmsbmm);
+                    postBody.put("djxhid", djxhid);
+                    postBody.put("nsrsbh", nsrsbh);
+                    postBody.put("areaid", areaid);
+                    postBody.put("bmbh", bmbh);
+                    postBody.put("bmmc", bmmc);
+                    postBody.put("year", year);
+                    postBody.put("skssq", skssq);
+                    postBody.put("lzrqcl", lzrqcl);
+                    BOSUuid id = taxUnitInfo.getId();
+                    //STaxPersonRecordEntry
+                    TaxPersonRecordEntryCollection taxPersonRecordEntrys =
+                            TaxPersonRecordEntryFactory.getLocalInstance(ctx).
+                                    getTaxPersonRecordEntryCollection("select * , bill.* where taxUnit = '" + id.toString() + "'");
+                    JSONArray rylb = new JSONArray();
+                    com.alibaba.fastjson.JSONObject personInfo = null;
+                    int size = taxPersonRecordEntrys.size();
+                    if (size == 0) {
+                        break;
+                    }
+                    for (int j = 0; j < size; j++) {
+                        personInfo = new com.alibaba.fastjson.JSONObject();
+                        TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxPersonRecordEntrys.get(j);
+                        TaxPersonRecordInfo bill = taxPersonRecordEntryInfo.getBill();
+                        String xm = PersonFactory.getLocalInstance(ctx).getPersonInfo(new ObjectUuidPK(bill.getPerson().getId())).getName();//姓名
+                        String zzlx = bill.getCardType().getAlias();//证件类型
+                        String zzhm = bill.getCardNumber();//证件号码
+                        String s = cardTypeReflection(zzlx);//证件类型
+                        personInfo.put("xm", xm);
+                        personInfo.put("zzlx", s);
+                        personInfo.put("zzhm", zzhm);
+                        rylb.add(personInfo);
+                    }
+                    postBody.put("rylb", rylb);
+                    String ip = (String) propt.get("ip");
+                    String url = ip + "/gateway/iit/personalPension/download";
+
+                    String taskId = localInstance.addTask("getPensionDownloadService",JSONUtil.toJsonStr(postBody), TaskCatalogEnum.PERSONAL_PENSION,null);
+                    resultList.add(taskId);
+                }
+            }
+        } catch (BOSException e) {
+          e.printStackTrace();
+            throw new RuntimeException(e);
+        } catch (EASBizException e) {
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        }
+        return resultList;
     }
+    protected Map<TaxUnitInfo, List<TaxPersonRecordEntryInfo>> getEntryMap(TaxPersonRecordEntryCollection taxRecordEntryCollection) {
+        Map<TaxUnitInfo, List<TaxPersonRecordEntryInfo>> entryMap = new HashMap();
+        Map<String, List<TaxPersonRecordEntryInfo>> stringEntryMap = new HashMap();
+        Map<String, TaxUnitInfo> taxUnitMap = new HashMap();
+
+        for (int i = 0; i < taxRecordEntryCollection.size(); ++i) {
+            TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = taxRecordEntryCollection.get(i);
+            TaxUnitInfo taxUnit = taxPersonRecordEntryInfo.getTaxUnit();
+            if (!taxUnitMap.containsKey(taxUnit.getId().toString())) {
+                taxUnitMap.put(taxUnit.getId().toString(), taxUnit);
+            }
+
+            if (stringEntryMap.containsKey(taxUnit.getId().toString())) {
+                List<TaxPersonRecordEntryInfo> taxPersonRecordEntryInfos = (List) stringEntryMap.get(taxUnit.getId().toString());
+                taxPersonRecordEntryInfos.add(taxPersonRecordEntryInfo);
+            } else {
+                List<TaxPersonRecordEntryInfo> taxPersonRecordEntryInfos = new ArrayList();
+                taxPersonRecordEntryInfos.add(taxPersonRecordEntryInfo);
+                stringEntryMap.put(taxUnit.getId().toString(), taxPersonRecordEntryInfos);
+            }
+        }
 
+        Iterator i$ = stringEntryMap.entrySet().iterator();
+
+        while (i$.hasNext()) {
+            Map.Entry<String, List<TaxPersonRecordEntryInfo>> entry = (Map.Entry) i$.next();
+            entryMap.put(taxUnitMap.get(entry.getKey()), entry.getValue());
+        }
+
+        return entryMap;
+    }
+    public String cardTypeReflection(String cardTypeName) {
+        switch (cardTypeName) {
+            case "居民身份证":
+                return "居民身份证";
+            case "中国护照":
+                return "中国护照";
+            case "港澳居民来往内地通行证":
+                return "港澳居民来往内地通行证";
+            case "中华人民共和国港澳居民居住证":
+                return "港澳居民来往内地通行证";
+            case "台湾居民来往大陆通行证":
+                return "台湾居民来往大陆通行证";
+            case "中华人民共和国台湾居民居住证":
+                return "台湾居民居住证";
+            case "外国护照":
+                return "外国护照";
+            case "外国人永久居留身份证":
+                return "外国人永久居留身份证";
+            case "中华人民共和国外国人工作许可证(A类)":
+                return "外国人工作许可证(A类)";
+            case "中华人民共和国外国人工作许可证(B类)":
+                return "外国人工作许可证(B类)";
+            case "中华人民共和国外国人工作许可证(C类)":
+                return "外国人工作许可证(C类)";
+        }
+        return "";
+    }
+    protected Map<TaxUnitInfo, Triple<List<TaxPersonEntity>, CoreBaseCollection, CoreBaseCollection>> getTripleMap(TaxPersonRecordEntryCollection taxRecordEntryCollection, String taxPeriodDate) {
+        Map<TaxUnitInfo, Triple<List<TaxPersonEntity>, CoreBaseCollection, CoreBaseCollection>> tripleMap = new HashMap();
+        Map<TaxUnitInfo, List<TaxPersonRecordEntryInfo>> entryMap = this.getEntryMap(taxRecordEntryCollection);
+        Set<String> billIdSet = new HashSet();
+        Iterator i$ = entryMap.entrySet().iterator();
+
+        while (i$.hasNext()) {
+            Map.Entry<TaxUnitInfo, List<TaxPersonRecordEntryInfo>> entry = (Map.Entry) i$.next();
+            Triple<List<TaxPersonEntity>, CoreBaseCollection, CoreBaseCollection> triple = new Triple();
+            TaxUnitInfo key = (TaxUnitInfo) entry.getKey();
+            List<TaxPersonRecordEntryInfo> value = (List) entry.getValue();
+            List<TaxPersonEntity> taxPersonEntitys = new ArrayList();
+            CoreBaseCollection entryBaseCollection = new CoreBaseCollection();
+            CoreBaseCollection billBaseCollection = new CoreBaseCollection();
+            Iterator i$value = value.iterator();
+
+            while (i$value.hasNext()) {
+                TaxPersonRecordEntryInfo taxPersonRecordEntryInfo = (TaxPersonRecordEntryInfo) i$value.next();
+                TaxPersonEntity taxPersonEntity = TaxReportUtil.taxPersonRecordEntryInfo2TaxPersonEntity(taxPersonRecordEntryInfo);
+                taxPersonEntitys.add(taxPersonEntity);
+                taxPersonRecordEntryInfo.setSubmitStatus(SubmitStatusEnum.Submiting);
+                taxPersonRecordEntryInfo.setIdentityStatus(IdentityStatusEnume.VerifyING);
+                taxPersonRecordEntryInfo.setLastReportMonth(taxPeriodDate);
+                entryBaseCollection.add(taxPersonRecordEntryInfo);
+                TaxPersonRecordInfo bill = taxPersonRecordEntryInfo.getBill();
+                if (!billIdSet.contains(bill.getId().toString())) {
+                    bill.setBankCardStatus(BankCardStatusEnum.VerifyING);
+                    billBaseCollection.add(bill);
+                    billIdSet.add(bill.getId().toString());
+                }
+            }
+
+            triple.setFirst(taxPersonEntitys);
+            triple.setSecond(entryBaseCollection);
+            triple.setThree(billBaseCollection);
+            tripleMap.put(key, triple);
+        }
+
+        return tripleMap;
+    }
+    public Boolean isCardType(String cardType) {
+        String cardTypes = "港澳居民居住证,台湾居民居住证,外国人永久居留身份证,外国人工作许可证(A类),外国人工作许可证(B类),外国人工作许可证(C类)";
+        if (cardTypes.indexOf(cardType) >= 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 
     /**
      * 获取人员名单
@@ -174,10 +410,13 @@ public class TaxDirectDeductionListHandlerEx extends TaxDirectDeductionListHandl
         IObjectPK pk;
         try {
             String taxUnitId = taxUnit.getId().toString();
-            String deleteSQL = "delete from T_HR_STaxUnitDeduction where fTaxUnitId = '" + taxUnitId + "' and fYear = " + year;
+            String deleteSQL = "delete from t_hr_sTaxDirectDeduction where fTaxUnitDeductionId in (select fid from T_HR_STaxUnitDeduction where fTaxUnitId = '" + taxUnitId + "' and fYear = " + year + ")";
+            System.out.println(deleteSQL);
             DbUtil.execute(ctx, deleteSQL);
-            deleteSQL = "delete from t_hr_sTaxDirectDeduction where fTaxUnitDeductionId in (select fid from T_HR_STaxUnitDeduction where fTaxUnitId = '" + taxUnitId + "' and fYear = " + year + ")";
+            deleteSQL = "delete from T_HR_STaxUnitDeduction where fTaxUnitId = '" + taxUnitId + "' and fYear = " + year;
+            System.out.println(deleteSQL);
             DbUtil.execute(ctx, deleteSQL);
+
             TaxUnitDeductionInfo info = new TaxUnitDeductionInfo();
             info.setTaxUnit(taxUnit);
             info.setYear(year);

+ 7 - 1
websrc/com/kingdee/eas/custom/shuiyou/six/handler/TaxPersonRecordListHandlerEx.java

@@ -111,7 +111,13 @@ public class TaxPersonRecordListHandlerEx extends TaxPersonRecordListHandler {
 
             logger.error("------------>>>>reportAction£ºtaxPeriodDate" + taxPeriodDate);
             ITaxPersonReportExFacade iTaxPersonReportFacade = TaxPersonReportExFacadeFactory.getLocalInstance(ctx);
-            iTaxPersonReportFacade.report(selectedIds, taxPeriodDate, filter);
+            Map<String,Object> paramMap = Maps.newHashMap();
+
+            paramMap.put("filter",filter);
+            paramMap.put("entryIDs",selectedIds);
+            paramMap.put("taxPeriodDate",taxPeriodDate);
+
+            iTaxPersonReportFacade.report(paramMap);
             //this._report(ctx,selectedIds, taxPeriodDate, filter);
             JSONUtils.SUCCESS(map);
             return null;

+ 49 - 11
websrc/com/kingdee/eas/custom/shuiyou/six/osf/GetCompanyIncomesService.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.google.common.collect.Maps;
 import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
 import com.kingdee.bos.bsf.service.app.IHRMsfService;
@@ -18,6 +19,7 @@ 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.compensation.util.Base64Utils;
 import com.kingdee.shr.dydeploy.web.executeSql.ExceptionUtils;
 
 
@@ -77,7 +79,7 @@ public class GetCompanyIncomesService implements IHRMsfService {
             personSc.add(new SelectorItemInfo("id"));
             personViewInfo.setSelector(personSc);
             SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
-            System.out.println("GetCompanyIncomesService:"+taxUnitCollection.toString());
+            System.out.println("GetCompanyIncomesService:" + taxUnitCollection.toString());
             for (int i = 0; i < taxUnitCollection.size(); i++) {
                 TaxUnitInfo taxUnitInfo = taxUnitCollection.get(i);
                 String declPassword = taxUnitInfo.getDeclPassword();
@@ -88,14 +90,32 @@ public class GetCompanyIncomesService implements IHRMsfService {
                 if (StrUtil.isNotBlank(nsrsbh) && StrUtil.isNotBlank(djxhid) &&
                         StrUtil.isNotBlank(name) && StrUtil.isNotBlank(areaid) &&
                         StrUtil.isNotBlank(declPassword)) {
+                    Map<String, Object> paramMap = Maps.newHashMap();
+                    paramMap.put("bizNo", facade.getBizNo());
+                    paramMap.put("qymc", name);
+                    paramMap.put("nsrsbh", nsrsbh);
+                    paramMap.put("areaid", areaid);
+                    paramMap.put("skssq", skssq);
+                    paramMap.put("sbmm", Base64Utils.decode(declPassword));
+                    paramMap.put("reportType", "1");
                     int pageNo = 1;
                     int pageSize = 4999;
-                    boolean next =false;
-                    do {
-                        next =false;
+                    paramMap.put("pageSize", pageSize);
+                    if (StrUtil.isNotBlank(param)) {
+                        JSONObject jsonObject = JSONUtil.parseObj(param);
+                        for (Map.Entry entry : jsonObject.entrySet()) {
+                            paramMap.put((String) entry.getKey(), entry.getValue());
+                        }
+                    }
 
+                    boolean next = false;
+                    do {
+                        paramMap.put("pageNo", pageNo);
+                        next = false;
+                        param = JSONUtil.toJsonStr(paramMap);
+                        System.out.println("GetCompanyIncomesService:result:" + param.toString());
                         String result = facade.post(config.get("ip") + URLConfigEnum.GETCOMPANYINCOMES_VALUE, param);
-                        System.out.println("GetCompanyIncomesService:result:"+result.toString());
+                        System.out.println("GetCompanyIncomesService:result:" + result.toString());
                         TaxDeclarationInfo info = new TaxDeclarationInfo();
                         JSONObject resultMap = JSONUtil.parseObj(result);
                         JSONObject head = resultMap.getJSONObject("head");
@@ -105,12 +125,13 @@ public class GetCompanyIncomesService implements IHRMsfService {
                             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;
+                                if (totalInt.compareTo(pageSize + pageNo) > 0) {
+                                    pageNo = pageNo + 1;
+                                    next = true;
                                 }
                                 JSONArray sfmx = body.getJSONArray("sfmx");
                                 CoreBaseCollection collection = new CoreBaseCollection();
+                                CoreBaseCollection upCollection = new CoreBaseCollection();
                                 for (int j = 0; j < sfmx.size(); j++) {
                                     TaxDeclarationInfo declaration = new TaxDeclarationInfo();
                                     JSONObject sfm = sfmx.getJSONObject(j);
@@ -132,8 +153,15 @@ public class GetCompanyIncomesService implements IHRMsfService {
                                     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);
+                                    FilterInfo filterInfo1 = new FilterInfo();
+                                    filterInfo1.getFilterItems().add(new FilterItemInfo("person.id", personInfo.getId().toString(), CompareType.EQUALS));
+                                    filterInfo1.getFilterItems().add(new FilterItemInfo("periodYear", year, CompareType.EQUALS));
+                                    filterInfo1.getFilterItems().add(new FilterItemInfo("periodMonth", month, CompareType.EQUALS));
+
+
                                     Calendar begin = Calendar.getInstance();
                                     begin.set(year, month, 1);
                                     declaration.setTaxPeriodBegin(begin.getTime());
@@ -235,12 +263,22 @@ public class GetCompanyIncomesService implements IHRMsfService {
                                     String PersonalPension = sfm.getStr("ljgrylj");
                                     declaration.setPersonalPension(StrUtil.isNotBlank(PersonalPension) ?
                                             new BigDecimal(PersonalPension) : ZERO);
-                                    collection.add(declaration);
+
+                                    if (taxDeclaration.exists(filterInfo1)) {
+                                        collection.add(declaration);
+                                    } else {
+                                        upCollection.add(declaration);
+                                    }
+                                }
+                                if(collection.size()>0){
+                                    taxDeclaration.addnewBatchData(collection);
+                                }
+                                if(upCollection.size()>0) {
+                                    //taxDeclaration.updateBatchData(upCollection);
                                 }
-                                taxDeclaration.addnewBatchData(collection);
                             }
                         }
-                    }while (next);
+                    } while (next);
                 }
             }
             messageResult = MessageResult.SUCCESS();

+ 5 - 0
websrc/com/kingdee/eas/custom/shuiyou/six/osf/GetPensionDownloadFeedback.java

@@ -34,6 +34,9 @@ import java.util.Map;
 public class GetPensionDownloadFeedback implements IHRMsfService {
     @Override
     public Object process(Context context, Map map) throws EASBizException, BOSException {
+        SelectorItemCollection scs = new SelectorItemCollection();
+        scs.add(new SelectorItemInfo("state"));
+
         ITask iTask = TaskFactory.getLocalInstance(context);
         ISYUtilsFacade facade = SYUtilsFacadeFactory.getLocalInstance(context);
         //»ñÈ¡ÇëÇó½á¹û
@@ -122,6 +125,8 @@ public class GetPensionDownloadFeedback implements IHRMsfService {
         } catch (Exception e) {
             e.printStackTrace();
             messageResult = MessageResult.ERROR(ExceptionUtils.getStackTrace(e));
+        }finally {
+            iTask.updatePartial(taskInfo, scs);
         }
         return messageResult;
     }

+ 2 - 2
websrc/com/kingdee/eas/custom/shuiyou/six/osf/GetPensionDownloadService.java

@@ -36,8 +36,8 @@ public class GetPensionDownloadService implements IHRMsfService {
             if("00000000".equals(head.getStr("code"))) {
                 JSONObject body = object.getJSONObject("body");
                 body.set("parent_taskid",this_taskid);
-                String taskId = facade.addTask("getPensionDownloadFeedback",JSONUtil.toJsonStr(body), TaskCatalogEnum.PERSON_GET,null);
-                msgr = MessageResult.SUCCESS(taskId);
+                String taskId = facade.addTask("getPensionDownloadFeedback",JSONUtil.toJsonStr(body), TaskCatalogEnum.PERSONAL_PENSION_GET,null);
+                msgr = MessageResult.AWAIT_W();
             }else if("00000004".equals(head.getStr("code")))  {
                 msgr = MessageResult.AGAIN();
             }else {