From e91825226a13c9e785dbbdd9791ed563d7da4d65 Mon Sep 17 00:00:00 2001 From: howec <> Date: Tue, 30 Jan 2024 16:43:02 +0800 Subject: [PATCH] =?UTF-8?q?2024-1-30=E9=99=95=E5=BB=BA=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/weaver/seconddev/sxjg/esb/ApplyPositionToNccQt.java | 5 + .../com/weaver/seconddev/sxjg/esb/ErrorfjResendToNcc.java | 2 +- .../com/weaver/seconddev/sxjg/esb/ErrorfjResendToNccQt.java | 2 +- .../com/weaver/seconddev/sxjg/esb/FrCompanyApplyToNcc.java | 14 +- .../java/com/weaver/seconddev/sxjg/esb/PersonDdToNcc.java | 22 +- .../java/com/weaver/seconddev/sxjg/esb/PersonJxToNcc.java | 10 +- .../com/weaver/seconddev/sxjg/esb/SunCompanyDpToNcc.java | 10 +- .../src/main/java/com/weaver/seconddev/sxjg/esb/TestDd.java | 16 + .../java/com/weaver/seconddev/sxjg/esb/ZhiGongBdToNcc.java | 10 +- .../com/weaver/seconddev/sxjg/esb/ZhiGongnbdpToNcc.java | 10 +- .../java/com/weaver/seconddev/sxjg/util/NccApiUtil.java | 2 +- .../java/com/weaver/seconddev/sxjg/util/NccApiUtil2.java | 339 ++++++++++++++++++ .../src/main/resources/config/nccconfig.properties | 2 +- .../java/com/weaver/sxjg/esb/EsbRpcPositionZhilian.java | 6 +- .../java/com/weaver/sxjg/esb/EsbRpcPositionZhilianSz.java | 5 +- .../main/java/com/weaver/sxjg/esb/EsbRpcRemoteSendDx.java | 5 +- .../com/weaver/sxjg/assess/esb/SendAssessNotice.java | 4 - .../main/java/com/weaver/sxjg/assess/util/SxjgUtil.java | 5 + 18 files changed, 414 insertions(+), 55 deletions(-) create mode 100644 陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/TestDd.java create mode 100644 陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil2.java diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ApplyPositionToNccQt.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ApplyPositionToNccQt.java index f72e40d..53815a9 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ApplyPositionToNccQt.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ApplyPositionToNccQt.java @@ -229,6 +229,11 @@ public class ApplyPositionToNccQt implements EsbServerlessRpcRemoteInterface { jsonObject2.put("id",id); jsonObject2.put("idtype",idtypePk); JSONArray r11 = getFjByCollectId(collectid); + if(r11.size() == 0) { + sql = "update uf_rcrt_entry_manage_qtry set entry_status = '1' where id = "+rzid; + jdbcTemplate.execute(sql); + return WeaResult.success(finresult); + } jsonObject2.put("data",r11); nccApiUtil = new NccApiUtil(); nccApiUtil.init(); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNcc.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNcc.java index 1f727df..500f5f3 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNcc.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNcc.java @@ -70,7 +70,7 @@ public class ErrorfjResendToNcc implements EsbServerlessRpcRemoteInterface { String rs11 = nccApiUtil.doJsonPost(url,token,jsonObject2.toJSONString()); NccResultUtil rs = new NccResultUtil(rs11); if(rs.getResult()){ - sql = "update uf_rcrt_entry_manage set fjtbsfyc = '0' where id = "+rzid; + sql = "update uf_rcrt_entry_manage set fjtbsfyc = '0', entry_status = '1' where id = "+rzid; jdbcTemplate.execute(sql); return WeaResult.success(finresult); }else { diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNccQt.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNccQt.java index ee4e1f4..4ebb87a 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNccQt.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ErrorfjResendToNccQt.java @@ -70,7 +70,7 @@ public class ErrorfjResendToNccQt implements EsbServerlessRpcRemoteInterface { String rs11 = nccApiUtil.doJsonPost(url,token,jsonObject2.toJSONString()); NccResultUtil rs = new NccResultUtil(rs11); if(rs.getResult()){ - sql = "update uf_rcrt_entry_manage_qtry set fjtbsfyc = '0' where id = "+rzid; + sql = "update uf_rcrt_entry_manage_qtry set fjtbsfyc = '0',entry_status = '1' where id = "+rzid; jdbcTemplate.execute(sql); return WeaResult.success(finresult); }else { diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/FrCompanyApplyToNcc.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/FrCompanyApplyToNcc.java index c780e09..9187c05 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/FrCompanyApplyToNcc.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/FrCompanyApplyToNcc.java @@ -101,22 +101,22 @@ public class FrCompanyApplyToNcc implements EsbServerlessRpcRemoteInterface { long negotiation = (long)r.get("negotiation");//谈判工资 String xbdb = ""; if(r.get("wa_seclv")!=null) { - long id1 = (long)r.get("wa_seclv"); - if(id1 != 0l) { + String id1 = (String)r.get("wa_seclv"); + if(id1.length()>0) { sql = "select levelname from uf_wa_prmlv where id = "+id1; Map rso= jdbcTemplate.queryForMap(sql); xbdb = (String)rso.get("levelname"); } } - String nmoney = ""; - if(r.get("waitem")!=null) { - nmoney = (String)r.get("waitem");//金额 + String money = ""; + if(r.get("money")!=null) { + money = String.valueOf(r.get("money"));//金额 } String memo=(String)r.get("memo");//备注 //通过薪资标准表id获取薪资标准名称 String pk_wa_crt_name = ""; if(r.get("pk_wa_crt") != null) { - long pk_wa_crt = (long)r.get("pk_wa_crt");//薪资标准表 + String pk_wa_crt = String.valueOf(r.get("pk_wa_crt"));//薪资标准表 sql = "select name from uf_wa_grade where id = "+pk_wa_crt; Map rso= jdbcTemplate.queryForMap(sql); pk_wa_crt_name = (String)rso.get("name"); @@ -127,7 +127,7 @@ public class FrCompanyApplyToNcc implements EsbServerlessRpcRemoteInterface { dataobj.put("begindate",usedate); dataobj.put("wa_prmlv",xbdb);//薪资级别 // dataobj.put("wa_seclv","");//薪档级别 - dataobj.put("nmoney",nmoney); + dataobj.put("nmoney",money); dataobj.put("waflag","Y"); dataobj.put("pk_wa_item_showname",xzxmmc); dataobj.put("pk_wa_grd_showname",pk_wa_crt_name); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonDdToNcc.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonDdToNcc.java index da64b71..ea9bf22 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonDdToNcc.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonDdToNcc.java @@ -8,7 +8,9 @@ import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface; import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfig; import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfigResp; import com.weaver.seconddev.sxjg.util.NccApiUtil; +import com.weaver.seconddev.sxjg.util.NccApiUtil2; import com.weaver.seconddev.sxjg.util.NccResultUtil; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.jdbc.core.JdbcTemplate; @@ -91,11 +93,11 @@ public class PersonDdToNcc implements EsbServerlessRpcRemoteInterface { return WeaResult.success(finresult); } r1.put("data",array); - nccApiUtil = new NccApiUtil(); - nccApiUtil.init(); - token = nccApiUtil.getToken(); - url = nccApiUtil.getBaseUrl()+"nccloud/api/hrwa/customermanage/adjust/import"; - rs11 = nccApiUtil.doJsonPost(url,token,r1.toJSONString()); + NccApiUtil2 nccApiUtil2 = new NccApiUtil2(); + nccApiUtil2.init(); + token = nccApiUtil2.getToken(); + url = nccApiUtil2.getBaseUrl()+"nccloud/api/hrwa/customermanage/adjust/import"; + rs11 = nccApiUtil2.doJsonPost(url,token,r1.toJSONString()); rs = new NccResultUtil(rs11); if(rs.getResult()) { return WeaResult.success(finresult); @@ -133,22 +135,22 @@ public class PersonDdToNcc implements EsbServerlessRpcRemoteInterface { long negotiation = (long)r.get("negotiation");//谈判工资 String xbdb = ""; if(r.get("wa_seclv")!=null) { - long id1 = (long)r.get("wa_seclv"); - if(id1 != 0l) { + String id1 = (String)r.get("wa_seclv"); + if(id1.length()>0) { sql = "select levelname from uf_wa_prmlv where id = "+id1; Map rso= jdbcTemplate.queryForMap(sql); xbdb = (String)rso.get("levelname"); } } String nmoney = ""; - if(r.get("waitem")!=null) { - nmoney = (String)r.get("waitem");//金额 + if(r.get("money")!=null) { + nmoney = String.valueOf(r.get("money"));//金额 } String memo=(String)r.get("memo");//备注 //通过薪资标准表id获取薪资标准名称 String pk_wa_crt_name = ""; if(r.get("pk_wa_crt") != null) { - long pk_wa_crt = (long)r.get("pk_wa_crt");//薪资标准表 + String pk_wa_crt = String.valueOf(r.get("pk_wa_crt"));//薪资标准表 sql = "select name from uf_wa_grade where id = "+pk_wa_crt; Map rso= jdbcTemplate.queryForMap(sql); pk_wa_crt_name = (String)rso.get("name"); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonJxToNcc.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonJxToNcc.java index 9ff57fa..cc590f8 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonJxToNcc.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/PersonJxToNcc.java @@ -108,22 +108,22 @@ public class PersonJxToNcc implements EsbServerlessRpcRemoteInterface { long negotiation = (long)r.get("negotiation");//谈判工资 String xbdb = ""; if(r.get("wa_seclv")!=null) { - long id1 = (long)r.get("wa_seclv"); - if(id1 != 0l) { + String id1 = (String)r.get("wa_seclv"); + if(id1.length()>0) { sql = "select levelname from uf_wa_prmlv where id = "+id1; Map rso= jdbcTemplate.queryForMap(sql); xbdb = (String)rso.get("levelname"); } } String nmoney = ""; - if(r.get("waitem")!=null) { - nmoney = (String)r.get("waitem");//金额 + if(r.get("money")!=null) { + nmoney = String.valueOf(r.get("money"));//金额 } String memo=(String)r.get("memo");//备注 //通过薪资标准表id获取薪资标准名称 String pk_wa_crt_name = ""; if(r.get("pk_wa_crt") != null) { - long pk_wa_crt = (long)r.get("pk_wa_crt");//薪资标准表 + String pk_wa_crt = String.valueOf(r.get("pk_wa_crt"));//薪资标准表 sql = "select name from uf_wa_grade where id = "+pk_wa_crt; Map rso= jdbcTemplate.queryForMap(sql); pk_wa_crt_name = (String)rso.get("name"); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/SunCompanyDpToNcc.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/SunCompanyDpToNcc.java index f05d61c..7348ffb 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/SunCompanyDpToNcc.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/SunCompanyDpToNcc.java @@ -119,22 +119,22 @@ public class SunCompanyDpToNcc implements EsbServerlessRpcRemoteInterface { long negotiation = (long)r.get("negotiation");//谈判工资 String xbdb = ""; if(r.get("wa_seclv")!=null) { - long id1 = (long)r.get("wa_seclv"); - if(id1 != 0l) { + String id1 = (String)r.get("wa_seclv"); + if(id1.length()>0) { sql = "select levelname from uf_wa_prmlv where id = "+id1; Map rso= jdbcTemplate.queryForMap(sql); xbdb = (String)rso.get("levelname"); } } String nmoney = ""; - if(r.get("waitem")!=null) { - nmoney = (String)r.get("waitem");//金额 + if(r.get("money")!=null) { + nmoney = String.valueOf(r.get("money"));//金额 } String memo=(String)r.get("memo");//备注 //通过薪资标准表id获取薪资标准名称 String pk_wa_crt_name = ""; if(r.get("pk_wa_crt") != null) { - long pk_wa_crt = (long)r.get("pk_wa_crt");//薪资标准表 + String pk_wa_crt = String.valueOf(r.get("pk_wa_crt"));//薪资标准表 sql = "select name from uf_wa_grade where id = "+pk_wa_crt; Map rso= jdbcTemplate.queryForMap(sql); pk_wa_crt_name = (String)rso.get("name"); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/TestDd.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/TestDd.java new file mode 100644 index 0000000..40f4966 --- /dev/null +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/TestDd.java @@ -0,0 +1,16 @@ +package com.weaver.seconddev.sxjg.esb; + +import com.weaver.seconddev.sxjg.util.NccApiUtil; +import org.junit.Test; + +public class TestDd { + @Test + public void test() throws Exception { + String str = "{\"data\":[{\"waflag\":\"Y\",\"begindate\":\"2024-01-25\",\"wa_prmlv\":\"01&服务类\",\"pk_wa_item_showname\":\"基本工资标准\",\"pk_wa_grd_showname\":\"陕建集团总部技能操作通道基本薪资规则\",\"negotiation_wage\":\"N\",\"nmoney\":\"8000.00\",\"psnName\":\"孟立超1\",\"psnCode\":\"00105895\"},{\"waflag\":\"Y\",\"begindate\":\"2024-01-25\",\"wa_prmlv\":\"\",\"pk_wa_item_showname\":\"绩效工资标准\",\"pk_wa_grd_showname\":\"\",\"negotiation_wage\":\"Y\",\"nmoney\":\"9000.00\",\"psnName\":\"孟立超1\",\"psnCode\":\"00105895\"}],\"state\":\"2\",\"pk_org\":\"0001A21000000000IR6D\"}"; + NccApiUtil nccApiUtil = new NccApiUtil(); + nccApiUtil.init(); + String token = nccApiUtil.getToken(); + String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrwa/customermanage/adjust/import"; + String rs11 = nccApiUtil.doJsonPost(url,token,str); + } +} diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongBdToNcc.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongBdToNcc.java index 80321f6..3c45e3c 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongBdToNcc.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongBdToNcc.java @@ -118,22 +118,22 @@ public class ZhiGongBdToNcc implements EsbServerlessRpcRemoteInterface { long negotiation = (long)r.get("negotiation");//谈判工资 String xbdb = ""; if(r.get("wa_seclv")!=null) { - long id1 = (long)r.get("wa_seclv"); - if(id1 != 0l) { + String id1 = (String)r.get("wa_seclv"); + if(id1.length()>0) { sql = "select levelname from uf_wa_prmlv where id = "+id1; Map rso= jdbcTemplate.queryForMap(sql); xbdb = (String)rso.get("levelname"); } } String nmoney = ""; - if(r.get("waitem")!=null) { - nmoney = (String)r.get("waitem");//金额 + if(r.get("money")!=null) { + nmoney = String.valueOf(r.get("money"));//金额 } String memo=(String)r.get("memo");//备注 //通过薪资标准表id获取薪资标准名称 String pk_wa_crt_name = ""; if(r.get("pk_wa_crt") != null) { - long pk_wa_crt = (long)r.get("pk_wa_crt");//薪资标准表 + String pk_wa_crt = String.valueOf(r.get("pk_wa_crt"));//薪资标准表 sql = "select name from uf_wa_grade where id = "+pk_wa_crt; Map rso= jdbcTemplate.queryForMap(sql); pk_wa_crt_name = (String)rso.get("name"); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongnbdpToNcc.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongnbdpToNcc.java index 25bed31..4c4152a 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongnbdpToNcc.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/esb/ZhiGongnbdpToNcc.java @@ -118,22 +118,22 @@ public class ZhiGongnbdpToNcc implements EsbServerlessRpcRemoteInterface { long negotiation = (long)r.get("negotiation");//谈判工资 String xbdb = ""; if(r.get("wa_seclv")!=null) { - long id1 = (long)r.get("wa_seclv"); - if(id1 != 0l) { + String id1 = (String)r.get("wa_seclv"); + if(id1.length()>0) { sql = "select levelname from uf_wa_prmlv where id = "+id1; Map rso= jdbcTemplate.queryForMap(sql); xbdb = (String)rso.get("levelname"); } } String nmoney = ""; - if(r.get("waitem")!=null) { - nmoney = (String)r.get("waitem");//金额 + if(r.get("money")!=null) { + nmoney = String.valueOf(r.get("money"));//金额 } String memo=(String)r.get("memo");//备注 //通过薪资标准表id获取薪资标准名称 String pk_wa_crt_name = ""; if(r.get("pk_wa_crt") != null) { - long pk_wa_crt = (long)r.get("pk_wa_crt");//薪资标准表 + String pk_wa_crt = String.valueOf(r.get("pk_wa_crt"));//薪资标准表 sql = "select name from uf_wa_grade where id = "+pk_wa_crt; Map rso= jdbcTemplate.queryForMap(sql); pk_wa_crt_name = (String)rso.get("name"); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil.java index 3065efd..6f9305a 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil.java +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil.java @@ -141,8 +141,8 @@ public class NccApiUtil { String line; while ((line = reader.readLine()) != null) strber.append(line + "\n"); - inStream.close(); result = strber.toString(); + inStream.close(); log.error("NCC接口"+url+",返回值:>>>>>>>>>>>>>>>>>>>>>>"+result); } catch (Exception e) { log.error("NCC接口"+url+",返回值:>>>>>>>>>>>>>>>>>>>>>>"+e.getMessage()); diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil2.java b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil2.java new file mode 100644 index 0000000..784144e --- /dev/null +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/java/com/weaver/seconddev/sxjg/util/NccApiUtil2.java @@ -0,0 +1,339 @@ +package com.weaver.seconddev.sxjg.util; + +import com.alibaba.fastjson.JSONObject; +import com.weaver.ebuilder.common.exception.BusinessException; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.OAEPParameterSpec; +import javax.crypto.spec.PSource; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.security.*; +import java.security.spec.MGF1ParameterSpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.HashMap; +import java.util.Map; + +public class NccApiUtil2 { + + private static final Logger log = LoggerFactory.getLogger(NccApiUtil2.class); + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + private String baseUrl; + // 访问的nccloud系统的账套编码,开发环境使用develop,生产环境需要使用用root账号登录,在“系统管理”节点查看账套编码(由陕西建工HR系统提供) + private String biz_center; + + public String getClient_id() { + return client_id; + } + + public void setClient_id(String client_id) { + this.client_id = client_id; + } + + //陕煤HR系统在陕西建工HR系统中应用注册当中的app_id + private String client_id; + //陕煤HR系统在陕西建工HR系统中应用注册当中的app_secret(由陕西建工HR系统提供) + private String client_secret; + //陕西建工HR系统中应用注册当中的(公钥)pubKey(由陕西建工HR系统提供) + private String pubKey; + + private String signature; + public void init() { + PropertiesConfiguration p = null; + try { + p = new PropertiesConfiguration(); + p.setEncoding("utf-8"); + p.setFileName("config/nccconfig.properties"); + p.load(); + this.baseUrl = p.getString("sxjgncc.url"); + this.biz_center = p.getString("sxjgncc.biz_center"); + this.client_id = p.getString("sxjgncc.client_id"); + this.client_secret = p.getString("sxjgncc.client_secret"); + this.pubKey = p.getString("sxjgncc.public_key"); + }catch (ConfigurationException e) { + throw new BusinessException("获取sxjg.properties配置文件失败,", e); + } + } + + /** + * 获取设置的ncc用户token + * @return@ + * @throws Exception + */ + public String getToken() throws Exception { + Map paramMap = new HashMap(); + //获取token方式(固定为client_credentials) + paramMap.put("grant_type", "client_credentials"); + //陕煤HR系统在陕西建工HR系统中应用注册当中的app_id(由陕西建工HR系统提供) + paramMap.put("client_id", this.client_id); + //加密陕煤HR系统在陕西建工HR系统中应用注册当中的(公钥)pubKey和app_secret(由陕西建工HR系统提供) + String encode = URLEncoder.encode(pubEncrypt(this.pubKey, this.client_secret), "UTF-8");//需要写入报文头中 + paramMap.put("client_secret", encode); + // 账套编码,开发环境使用develop,生产环境需要使用用root账号登录,在“系统管理”节点查看账套编码(由陕西建工HR系统提供) + paramMap.put("biz_center", this.biz_center); + //请求加签,其算法getSHA256(client_id + client_secret + pubKey) + String sign = getSHA256(this.client_id + this.client_secret + this.pubKey, this.pubKey); + paramMap.put("signature", sign);//需要写入报文头中 + this.setSignature(sign); + //查询token的url + String url = this.baseUrl + "nccloud/opm/accesstoken"; + String mediaType = "application/x-www-form-urlencoded"; + String token = this.doPost(url, paramMap, mediaType, (Map)null, ""); + JSONObject rs = JSONObject.parseObject(token); + if(rs.getBoolean("success")) { + JSONObject jsonObject = rs.getJSONObject("data"); + String token1 = jsonObject.getString("access_token"); + return token1; + }else { + log.error("howec::::::::::::111:"+token); + throw new Exception("获取toaken失败!"); + } + } + + public String doJsonPost(String url, String accessToken, String json) { + log.error("NCC接口"+url+",推送报文:>>>>>>>>>>>>>>>>>>>>>>"+json); + CloseableHttpClient client = HttpClients.createDefault(); + HttpPost post = new HttpPost(url); + post.setHeader("Content-Type", "application/json;charset=utf-8"); + post.setHeader("access_token", accessToken); + post.setHeader("repeat_check","Y"); + post.setHeader("ucg_flag","Y"); + post.setHeader("signature",this.getSignature()); + post.setHeader("client_id",this.getClient_id()); + + String result=""; + try { + StringEntity s = new StringEntity(json,"UTF-8"); + s.setContentEncoding("utf-8"); + s.setContentType("application/json"); + post.setEntity(s); + // 发送请求 + HttpResponse httpResponse = client.execute(post); + // 获取响应输入流 + InputStream inStream = httpResponse.getEntity().getContent(); + BufferedReader reader = new BufferedReader(new InputStreamReader( + inStream,"utf-8")); + StringBuilder strber = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) + strber.append(line + "\n"); + inStream.close(); + result = strber.toString(); + log.error("NCC接口"+url+",返回值:>>>>>>>>>>>>>>>>>>>>>>"+result); + } catch (Exception e) { + e.printStackTrace(); + log.error("NCC接口"+url+",返回值:>>>>>>>>>>>1>>>>>>>>>>>"+e.getMessage()); + } + return result; + } + + public static String pubEncrypt(String pubKey, String src) throws Exception { + String target = null; + ByteArrayOutputStream out = null; + + try { + Key key = getPublicKey(pubKey); + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); + cipher.init(1, key, new OAEPParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), PSource.PSpecified.DEFAULT)); + byte[] data = src.getBytes(); + int inputLen = data.length; + out = new ByteArrayOutputStream(); + int offSet = 0; + + for(int i = 0; inputLen - offSet > 0; offSet = i * 117) { + byte[] cache; + if (inputLen - offSet > 117) { + cache = cipher.doFinal(data, offSet, 117); + } else { + cache = cipher.doFinal(data, offSet, inputLen - offSet); + } + + out.write(cache, 0, cache.length); + ++i; + } + + target = (new Base64()).encodeToString(out.toByteArray()); + } catch (NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException | NoSuchAlgorithmException var14) { + throw new Exception("加密失败", var14); + } finally { + if (out != null) { + out.close(); + } + + } + return target; + } + public static Key getPublicKey(String pubKey) throws Exception { + PublicKey key = null; + + try { + byte[] keyBytes = (new Base64()).decode(pubKey);; + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes); + key = keyFactory.generatePublic(x509KeySpec); + return key; + } catch (Exception var5) { + throw new Exception("无效的密钥 ", var5); + } + } + + public static String getSHA256(String str, String key) throws Exception { + byte[] salt = new byte[16]; + SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); + random.setSeed(key.getBytes()); + random.nextBytes(salt); + String salt_value = (new Base64()).encodeToString(salt); + return getSHA256(str + salt_value.replaceAll("\r|\n", "")); + } + private static String getSHA256(String str) throws Exception { + String encodestr = ""; + MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); + messageDigest.update(str.getBytes("UTF-8")); + encodestr = byte2Hex(messageDigest.digest()); + return encodestr; + } + private static String byte2Hex(byte[] bytes) { + StringBuffer stringBuffer = new StringBuffer(); + String temp = null; + + for(int i = 0; i < bytes.length; ++i) { + temp = Integer.toHexString(bytes[i] & 255); + if (temp.length() == 1) { + stringBuffer.append("0"); + } + + stringBuffer.append(temp); + } + + return stringBuffer.toString(); + } + + + + + /** + * 发送post请求 + * + * @param baseUrl + * @param paramMap + * @param mediaType + * @param headers + * @param json + * @return + */ + private static String doPost(String baseUrl, Map paramMap, String mediaType, Map headers, String json) { + + HttpURLConnection urlConnection = null; + InputStream in = null; + OutputStream out = null; + BufferedReader bufferedReader = null; + String result = null; + try { + StringBuffer sb = new StringBuffer(); + sb.append(baseUrl); + if (paramMap != null) { + sb.append("?"); + for (Map.Entry entry : paramMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + sb.append(key + "=" + value).append("&"); + } + baseUrl = sb.toString().substring(0, sb.toString().length() - 1); + } + + URL urlObj = new URL(baseUrl); + urlConnection = (HttpURLConnection) urlObj.openConnection(); + urlConnection.setConnectTimeout(50000); + urlConnection.setRequestMethod("POST"); + urlConnection.setDoOutput(true); + urlConnection.setDoInput(true); + urlConnection.setUseCaches(false); + urlConnection.addRequestProperty("content-type", mediaType); + if (headers != null) { + for (String key : headers.keySet()) { + urlConnection.addRequestProperty(key, headers.get(key)); + } + } + out = urlConnection.getOutputStream(); + out.write(json.getBytes("utf-8")); + out.flush(); + int resCode = urlConnection.getResponseCode(); + if (resCode == HttpURLConnection.HTTP_OK || resCode == HttpURLConnection.HTTP_CREATED || resCode == HttpURLConnection.HTTP_ACCEPTED) { + in = urlConnection.getInputStream(); + } else { + in = urlConnection.getErrorStream(); + } + bufferedReader = new BufferedReader(new InputStreamReader(in, "utf-8")); + StringBuffer temp = new StringBuffer(); + String line = bufferedReader.readLine(); + while (line != null) { + temp.append(line).append("\r\n"); + line = bufferedReader.readLine(); + } + String ecod = urlConnection.getContentEncoding(); + if (ecod == null) { + ecod = Charset.forName("utf-8").name(); + } + result = new String(temp.toString().getBytes("utf-8"), ecod); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (null != bufferedReader) { + try { + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != out) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != in) { + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + urlConnection.disconnect(); + } + return result; + } + + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } +} diff --git a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/resources/config/nccconfig.properties b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/resources/config/nccconfig.properties index 9d39e25..40b5104 100644 --- a/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/resources/config/nccconfig.properties +++ b/陕建岗位申请规则校验(ecode服务)checkPositionNew/src/main/resources/config/nccconfig.properties @@ -43,4 +43,4 @@ sxjgncc.b14=ft_staff_nbbdlxd_t1 ##职工报到联系单-总部定薪表 #sxjgncc.b13=ft_staff_bdlxd_t1 ##职工内部调配联系单-总部定薪表 -#sxjgncc.b14=ft_staff_nbbdlxd_t1 +#sxjgncc.b14=ft_staff_nbbdlxd_t1 \ No newline at end of file diff --git a/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilian.java b/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilian.java index 5b4947f..61f817a 100644 --- a/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilian.java +++ b/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilian.java @@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; import com.weaver.common.base.entity.result.WeaResult; -import com.weaver.ebuilder.common.exception.BusinessException; import com.weaver.esb.api.rpc.EsbRpcRemoteInterface; import com.weaver.eteams.file.client.file.FileObj; import com.weaver.eteams.file.client.param.RemoteUploadParam; @@ -26,7 +25,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.io.File; @@ -71,7 +69,7 @@ public class EsbRpcPositionZhilian implements EsbRpcRemoteInterface { @Autowired FileUploadService fileUploadService; - public EsbRpcPositionZhilian() { + public EsbRpcPositionZhilian() throws Exception { PropertiesConfiguration p = null; try { p = new PropertiesConfiguration(); @@ -93,7 +91,7 @@ public class EsbRpcPositionZhilian implements EsbRpcRemoteInterface { this.setManagerId(p.getString("managerid")); this.setAnnex(p.getString("sxjg.annexurl")); }catch (ConfigurationException e) { - throw new BusinessException("获取sxjg.properties配置文件失败,", e); + throw new Exception("获取sxjg.properties配置文件失败"); } } diff --git a/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilianSz.java b/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilianSz.java index f0cee37..95f5ccc 100644 --- a/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilianSz.java +++ b/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcPositionZhilianSz.java @@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; import com.weaver.common.base.entity.result.WeaResult; -import com.weaver.ebuilder.common.exception.BusinessException; import com.weaver.esb.api.rpc.EsbRpcRemoteInterface; import com.weaver.eteams.file.client.file.FileObj; import com.weaver.eteams.file.client.param.RemoteUploadParam; @@ -57,7 +56,7 @@ public class EsbRpcPositionZhilianSz implements EsbRpcRemoteInterface { RecruitCandidateRemoteService recruitCandidateRemoteService; @Autowired FileUploadService fileUploadService; - public EsbRpcPositionZhilianSz() { + public EsbRpcPositionZhilianSz() throws Exception { PropertiesConfiguration p = null; try { p = new PropertiesConfiguration(); @@ -74,7 +73,7 @@ public class EsbRpcPositionZhilianSz implements EsbRpcRemoteInterface { this.setTenantKey(p.getString("tenantKey")); this.setManagerId(p.getString("managerid")); } catch (ConfigurationException e) { - throw new BusinessException("获取sxjg.properties配置文件失败,", e); + throw new Exception("获取sxjg.properties配置文件失败,"); } } diff --git a/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcRemoteSendDx.java b/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcRemoteSendDx.java index 8b9294c..9a5eeff 100644 --- a/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcRemoteSendDx.java +++ b/陕建智联对接和短信对接源码e1001/src/main/java/com/weaver/sxjg/esb/EsbRpcRemoteSendDx.java @@ -1,6 +1,5 @@ package com.weaver.sxjg.esb; -import com.weaver.ebuilder.common.exception.BusinessException; import com.weaver.esb.api.rpc.EsbRpcRemoteInterface; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; @@ -21,7 +20,7 @@ import java.util.Map; */ @Service("esbRpcRemoteSendDx_sj") public class EsbRpcRemoteSendDx implements EsbRpcRemoteInterface { - public EsbRpcRemoteSendDx() { + public EsbRpcRemoteSendDx() throws Exception { PropertiesConfiguration p = null; try { p = new PropertiesConfiguration(); @@ -33,7 +32,7 @@ public class EsbRpcRemoteSendDx implements EsbRpcRemoteInterface { this.setCorpID(p.getString("message.CorpID")); this.setQm(p.getString("message.qm")); }catch (ConfigurationException e) { - throw new BusinessException("获取sxjg.properties配置文件失败,", e); + throw new Exception("获取sxjg.properties配置文件失败,", e); } } private static final Logger log = LoggerFactory.getLogger(EsbRpcRemoteSendDx.class); diff --git a/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/esb/SendAssessNotice.java b/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/esb/SendAssessNotice.java index 4f37f14..dc8be4a 100644 --- a/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/esb/SendAssessNotice.java +++ b/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/esb/SendAssessNotice.java @@ -4,15 +4,12 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.weaver.common.base.entity.result.WeaResult; import com.weaver.ebuilder.common.exception.BusinessException; -import com.weaver.ebuilder.form.client.entity.obj.Obj; -import com.weaver.ebuilder.form.client.utils.UserUtils; import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface; import com.weaver.eteams.file.client.file.FileObj; import com.weaver.eteams.file.client.param.RemoteUploadParam; import com.weaver.file.ud.api.FileUploadService; import com.weaver.sxjg.assess.config.EbDbDataSourceConfig; import com.weaver.sxjg.assess.util.SxjgUtil; -import com.weaver.teams.security.UserAgentUtils; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.slf4j.Logger; @@ -22,7 +19,6 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import java.io.InputStream; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.Date; diff --git a/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/util/SxjgUtil.java b/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/util/SxjgUtil.java index cab2e47..670ae27 100644 --- a/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/util/SxjgUtil.java +++ b/陕建测评管理对接源码assessManagesj/src/main/java/com/weaver/sxjg/assess/util/SxjgUtil.java @@ -98,6 +98,11 @@ public class SxjgUtil{ } } + public static void main(String[] args) { + String r =getApiResult(null,"950211276134719488","876950","950206388353032192","https://eas.zhaopin.com/Assessment/api/OpenApiResult.ashx","f65a0fc0c3cf0c1ff60343d8f771cc98"); + System.out.println(r); + } + public static String getApiResult(JdbcTemplate jdbcTemplate, String personIds, String CompanyId, String jobid,String url1,String secret) { String url = url1+"?CompanyId="+CompanyId+"&PersonIds="+personIds+"&JobId="+jobid+"&Signature="; String r2 = CompanyId+jobid+personIds+secret;