数智代码备份
This commit is contained in:
parent
d1d878e549
commit
9206d2f6d9
|
|
@ -0,0 +1,6 @@
|
|||
#edc_uf_table160±íÄ£¿éid
|
||||
edc_formmodeid=52
|
||||
#uf_drztzbd±íÄ£¿éid
|
||||
uf_formmodeid=55
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
## 得力云的key
|
||||
key=79e26d45aec2d152dba78419db2e622f
|
||||
|
||||
## 得力云的secret
|
||||
secret=hpgmkq03yzlujquiiovt2n63hqnb20d8
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#员工关系更新提醒流程id
|
||||
workflowid=143
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<%@ page import="okhttp3.OkHttpClient" %>
|
||||
<%@ page import="okhttp3.Request" %>
|
||||
<%@ page import="okhttp3.Response" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.workflow.biz.NewRequestBiz" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowVersion" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="com.engine.workflow.entity.newRequest.WfType" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page import="com.engine.workflow.entity.newRequest.WfBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
BaseBean bb = new BaseBean();
|
||||
String pubkey = bb.getPropValue("CHATGPT","pubkey");
|
||||
RecordSet rs = new RecordSet();
|
||||
String userinfo = request.getParameter("userinfo") ;
|
||||
String query = request.getParameter("query");
|
||||
|
||||
out.print("userinfo:"+userinfo+"</br>");
|
||||
out.print("query:"+query+"</br>");
|
||||
|
||||
String host = bb.getPropValue("CHATGPT","host");
|
||||
String appid = bb.getPropValue("CHATGPT","appid");
|
||||
out.print("pubkey:"+pubkey+"</br>");
|
||||
out.print("host:"+host+"</br>");
|
||||
out.print("appid:"+appid+"</br>");
|
||||
String loginid = "" ;
|
||||
String userid = "";
|
||||
if(StringUtils.isNotBlank(userinfo)){
|
||||
String userSql = " select id,loginid from hrmresource where upper(md5(concat(loginid,'"+pubkey+"')))='"+userinfo.toUpperCase()+"'";
|
||||
out.print("userSql:"+userSql+"</br>");
|
||||
rs.executeQuery(userSql);
|
||||
if(rs.next()){
|
||||
loginid = Util.null2String(rs.getString("loginid"));
|
||||
userid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
}
|
||||
out.print("loginid:"+loginid+"</br>");
|
||||
if(StringUtils.isNotBlank(loginid) && StringUtils.isNotBlank(appid)){
|
||||
String token = getToken(host,appid,loginid);
|
||||
out.print("token:"+token+"</br>");
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
String[] workflowArray = query.split("\\$");
|
||||
|
||||
out.print("userid:"+userid+"</br>");
|
||||
User user = new User(Util.getIntValue(userid));
|
||||
out.print("user:"+user.getLastname()+"</br>");
|
||||
String inornot = "in";
|
||||
NewRequestBiz wfBiz = new NewRequestBiz(user);
|
||||
wfBiz.setNewRequestRange(WorkflowVersion.getAllVersionStringByWFIDs(""));
|
||||
wfBiz.setInornot(inornot);
|
||||
wfBiz.setIsmobile(false);
|
||||
wfBiz.setCustomSqlWhere("");//新建流程扩展条件
|
||||
List<WfType> wftypes = wfBiz.getWfInfo("");
|
||||
// out.print("wftypes:"+ JSON.toJSON(wftypes));
|
||||
for(WfType wfType : wftypes){
|
||||
List<WfBean> wfBeanList = wfType.getWfbeans();
|
||||
for(WfBean wfBean : wfBeanList){
|
||||
int count = 0;
|
||||
String wf_name = wfBean.getName();
|
||||
String workflowid = wfBean.getId();
|
||||
for(int i=0;i<workflowArray.length;i++) {
|
||||
String workflowname = workflowArray[i];
|
||||
if(!wf_name.contains(workflowname)){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
out.print("wf_name:"+ wf_name+"</br>");
|
||||
out.print("workflowid:"+ workflowid+"</br>");
|
||||
out.print("count:"+ count+"</br>");
|
||||
|
||||
if(count == 0){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("requestname",wf_name);
|
||||
jsonObject.put("pc_url","/workflow/request/CreateRequestForward.jsp?workflowid="+workflowid+"&ssoToken="+token);
|
||||
jsonObject.put("h5_url","/spa/workflow/static4mobileform/index.html#/req?iscreate=1&workflowid="+workflowid+"&ssoToken="+token);
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
out.print("jsonArray:"+ jsonArray.size()+"</br>");
|
||||
// String[] workflowArray = query.split("\\$");
|
||||
// for(int i=0;i<workflowArray.length;i++){
|
||||
// String workflowname = workflowArray[i];
|
||||
// out.print("workflowname:"+workflowname+"</br>");
|
||||
//// if(StringUtils.isNotBlank(workflowname)){
|
||||
//// String sql = " select id,workflowname from workflow_base where workflowname like '%"+workflowname+"%'" ;
|
||||
//// out.print("sql:"+sql+"</br>");
|
||||
//// rs.executeQuery(sql);
|
||||
//// while (rs.next()){
|
||||
//// String name = Util.null2String(rs.getString("workflowname"));
|
||||
//// String workflowid = Util.null2String(rs.getString("id"));
|
||||
////
|
||||
//// JSONObject jsonObject = new JSONObject();
|
||||
//// jsonObject.put("requestname",name);
|
||||
//// jsonObject.put("pc_url","/workflow/request/CreateRequestForward.jsp?workflowid="+workflowid+"&ssoToken="+token);
|
||||
//// jsonObject.put("h5_url","/spa/workflow/static4mobileform/index.html#/req?iscreate=1&workflowid="+workflowid+"&ssoToken="+token);
|
||||
//// jsonArray.add(jsonObject);
|
||||
//// }
|
||||
//// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
||||
<%=jsonArray.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getToken(String host,String appid,String loginid){
|
||||
String token = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
.url(host+"/ssologin/getToken?appid="+appid+"&loginid="+loginid)
|
||||
.method("GET", null)
|
||||
.build();
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
if(code == 200){
|
||||
token = response.body().string();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
|
||||
|
||||
<%--
|
||||
User: wangj
|
||||
Design Ideas:
|
||||
数智-数据中心--通过手机号获取简历信息(姓名,性别,年龄,身份证号,民族,应聘企业,意向岗位)
|
||||
表名:edc_uf_table160
|
||||
需要:通过手机号获取简历信息(姓名,性别,年龄,身份证号,民族,应聘企业,意向岗位)
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject res = new JSONObject();
|
||||
RecordSet rs = new RecordSet();
|
||||
String mobile = Util.null2String(request.getParameter("mobile"));
|
||||
boolean flag = false;
|
||||
String xm = "";
|
||||
String xb = "";
|
||||
String age = "";
|
||||
String cardno = "";
|
||||
String mz = "";
|
||||
String ypqy = "";
|
||||
String gw = "";
|
||||
|
||||
String sql = "select field001 as xm,field002 as xb,field008 as age,field004 as cardno,field013 as mz,field011 as ypqy,field007 as gw " +
|
||||
" from edc_uf_table160 where field005 = '"+mobile+"'";
|
||||
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
flag = true;
|
||||
xm = Util.null2String(rs.getString("xm"));
|
||||
xb = getFildName("edc_uf_table160","field002",Util.null2String(rs.getString("xb")));
|
||||
age = Util.null2String(rs.getString("age"));
|
||||
cardno = Util.null2String(rs.getString("cardno"));
|
||||
mz = getFildName("edc_uf_table160","field013",Util.null2String(rs.getString("mz")));
|
||||
ypqy = getFildName("edc_uf_table160","field011",Util.null2String(rs.getString("ypqy")));
|
||||
gw = Util.null2String(rs.getString("gw"));
|
||||
|
||||
res.put("xm",xm);
|
||||
res.put("xb",xb);
|
||||
res.put("age",age);
|
||||
res.put("cardno",cardno);
|
||||
res.put("mz",mz);
|
||||
res.put("ypqy",ypqy);
|
||||
res.put("gw",gw);
|
||||
}
|
||||
|
||||
|
||||
data.put("flag",flag);
|
||||
data.put("data",res);
|
||||
out.print(data.toJSONString());
|
||||
%>
|
||||
|
||||
<%!
|
||||
private String getFildName(String tablename,String fieldname,String value){
|
||||
String selectname = "";
|
||||
if("".equals(value)){
|
||||
return selectname;
|
||||
}
|
||||
String sql = " select c.selectname from workflow_billfield a, workflow_bill b,workflow_selectitem c where a.billid=b.id and c.fieldid=a.id and b.tablename='"+tablename+"' and a.fieldname='"+fieldname+"' and c.selectvalue='" + value + "'";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
selectname = Util.null2String(rs.getString("selectname"));
|
||||
}
|
||||
return selectname;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,266 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.MD5" %>
|
||||
<%@ page import="java.util.Scanner" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpRequestBase" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="org.apache.commons.collections.MapUtils" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.Consts" %>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.StatusLine" %>
|
||||
<%@ page import="javax.net.ssl.SSLContext" %>
|
||||
<%@ page import="org.apache.http.conn.socket.ConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.config.Registry" %>
|
||||
<%@ page import="org.apache.http.config.RegistryBuilder" %>
|
||||
<%@ page import="org.apache.http.conn.socket.PlainConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.SSLConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.NoopHostnameVerifier" %>
|
||||
<%@ page import="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||||
<%@ page import="java.security.KeyManagementException" %>
|
||||
<%@ page import="javax.net.ssl.X509TrustManager" %>
|
||||
<%@ page import="java.security.cert.CertificateException" %>
|
||||
<%@ page import="javax.net.ssl.TrustManager" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="java.util.Calendar" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String path = "/v2.0/employee/delete";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
String userid = request.getParameter("userid");
|
||||
try {
|
||||
String workcode = "";
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String sql = " select workcode from hrmresource where id = ? and status=5 ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql,new Object[]{userid});
|
||||
if(rs.next()){
|
||||
workcode = Util.null2String(rs.getString("workcode"));
|
||||
}
|
||||
}
|
||||
out.print("workcode:"+workcode+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(workcode)){
|
||||
// String key = "";
|
||||
// String sercet = "";
|
||||
// String sqlOr = "select dlkey,dlsercet from uf_dlkqdj where bs = 'DlKqGetDayNew'";
|
||||
// out.print("sqlOr:"+sqlOr+"</br>");
|
||||
// rs.executeQuery(sqlOr);
|
||||
// if (rs.next()) {
|
||||
// key = Util.null2String(rs.getString("dlkey"));
|
||||
// sercet = Util.null2String(rs.getString("dlsercet"));
|
||||
// }
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
|
||||
out.print("key:"+key+"</br>");
|
||||
out.print("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
out.print("sjc:"+sjc+"</br>");
|
||||
out.print("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("employee_ext_id", workcode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
// bb.writeLog("headers:" + JSONObject.toJSONString(heads));
|
||||
// bb.writeLog("body:" + JSONObject.toJSONString(dataMap));
|
||||
|
||||
// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
// bb.writeLog("response:" + back);
|
||||
// out.print("response:"+back+"</br>");
|
||||
// JSONObject backObj = JSONObject.parseObject(back);
|
||||
// String code = backObj.getString("code");
|
||||
// String data = backObj.getString("data");
|
||||
// out.print("code:"+code+"</br>");
|
||||
// if ("0".equals(code)) {
|
||||
// bb.writeLog("新接口调用成功");
|
||||
// JSONObject dataObj = JSONObject.parseObject(data);
|
||||
// out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
// } else {
|
||||
// bb.writeLog("接口调用失败");
|
||||
// out.print("接口调用失败");
|
||||
// }
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,290 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.MD5" %>
|
||||
<%@ page import="java.util.Scanner" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpRequestBase" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="org.apache.commons.collections.MapUtils" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.Consts" %>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.StatusLine" %>
|
||||
<%@ page import="javax.net.ssl.SSLContext" %>
|
||||
<%@ page import="org.apache.http.conn.socket.ConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.config.Registry" %>
|
||||
<%@ page import="org.apache.http.config.RegistryBuilder" %>
|
||||
<%@ page import="org.apache.http.conn.socket.PlainConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.SSLConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.NoopHostnameVerifier" %>
|
||||
<%@ page import="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||||
<%@ page import="java.security.KeyManagementException" %>
|
||||
<%@ page import="javax.net.ssl.X509TrustManager" %>
|
||||
<%@ page import="java.security.cert.CertificateException" %>
|
||||
<%@ page import="javax.net.ssl.TrustManager" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="java.util.Calendar" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String path = "/v2.0/employee/delete";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
String userid = request.getParameter("userid");
|
||||
try {
|
||||
String workcode = "";
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String sql = " select workcode from hrmresource where id = ? and status = 5 ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql,new Object[]{userid});
|
||||
if(rs.next()){
|
||||
workcode = Util.null2String(rs.getString("workcode"));
|
||||
}
|
||||
}
|
||||
out.print("workcode:"+workcode+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(workcode)){
|
||||
// String key = "";
|
||||
// String sercet = "";
|
||||
// String sqlOr = "select dlkey,dlsercet from uf_dlkqdj where bs = 'DlKqGetDayNew'";
|
||||
// out.print("sqlOr:"+sqlOr+"</br>");
|
||||
// rs.executeQuery(sqlOr);
|
||||
// if (rs.next()) {
|
||||
// key = Util.null2String(rs.getString("dlkey"));
|
||||
// sercet = Util.null2String(rs.getString("dlsercet"));
|
||||
// }
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
|
||||
out.print("key:"+key+"</br>");
|
||||
out.print("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String all = path + sjc + key + secret;
|
||||
out.print("all:" + all+"</br>");
|
||||
out.print("sjc:" + sjc+"</br>");
|
||||
MD5 md5 = new MD5();
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
out.print("sig22:" + sig+"</br>");
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
String newStr = "";
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
newStr = newStr + c2;
|
||||
} else {
|
||||
newStr = newStr + c1;
|
||||
}
|
||||
}
|
||||
out.print("sigNew:" + newStr+"</br>");
|
||||
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
out.print("sjc:"+sjc+"</br>");
|
||||
out.print("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", newStr);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("employee_ext_id", workcode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
// bb.writeLog("headers:" + JSONObject.toJSONString(heads));
|
||||
// bb.writeLog("body:" + JSONObject.toJSONString(dataMap));
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,478 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.MD5" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpRequestBase" %>
|
||||
<%@ page import="org.apache.commons.collections.MapUtils" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.Consts" %>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.StatusLine" %>
|
||||
<%@ page import="javax.net.ssl.SSLContext" %>
|
||||
<%@ page import="org.apache.http.conn.socket.ConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.config.Registry" %>
|
||||
<%@ page import="org.apache.http.config.RegistryBuilder" %>
|
||||
<%@ page import="org.apache.http.conn.socket.PlainConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.SSLConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.NoopHostnameVerifier" %>
|
||||
<%@ page import="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||||
<%@ page import="java.security.KeyManagementException" %>
|
||||
<%@ page import="javax.net.ssl.X509TrustManager" %>
|
||||
<%@ page import="java.security.cert.CertificateException" %>
|
||||
<%@ page import="javax.net.ssl.TrustManager" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
BaseBean bb = new BaseBean();
|
||||
String id = request.getParameter("id");
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
try {
|
||||
String where = "";
|
||||
if(StringUtils.isNotBlank(id)){
|
||||
where = " and id in("+id+")" ;
|
||||
}
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
out.print("key:"+key+"</br>");
|
||||
out.print("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
out.print("sjc:"+sjc+"</br>");
|
||||
out.print("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
List<Map<String,String>> topSubcompanyList = getTopSubcompanyList(where);
|
||||
for(int i=0;i<topSubcompanyList.size();i++){
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompanycode = topSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = topSubcompanyMap.get("subcompanyname");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", "");
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<topSubcompanyList.size();i++) {
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompanyid = topSubcompanyMap.get("subcompanyid");
|
||||
|
||||
List<Map<String,String>> childSubcompanyList = getSubcompanyListByParentid(subcompanyid);
|
||||
|
||||
for(int k=0;k<childSubcompanyList.size();k++){
|
||||
Map<String,String> childSubcompanyMap = childSubcompanyList.get(k);
|
||||
String subcompanycode = childSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = childSubcompanyMap.get("subcompanyname");
|
||||
String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", supsubcompanycode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> topDepartmentList = getTopDeptList();
|
||||
for(int i=0;i<topDepartmentList.size();i++){
|
||||
Map<String,String> topDepartmentMap = topDepartmentList.get(i);
|
||||
String departmentcode = topDepartmentMap.get("departmentcode");
|
||||
String departmentname = topDepartmentMap.get("departmentname");
|
||||
String subcompanycode = topDepartmentMap.get("subcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", subcompanycode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("top-dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<topDepartmentList.size();i++) {
|
||||
Map<String,String> topDeptMap = topDepartmentList.get(i);
|
||||
String deptid = topDeptMap.get("deptid");
|
||||
|
||||
List<Map<String,String>> childDepartmentList = getDeptListByParentid(deptid);
|
||||
for(int k=0;k<childDepartmentList.size();k++){
|
||||
Map<String,String> childDepartmentMap = childDepartmentList.get(k);
|
||||
String departmentcode = childDepartmentMap.get("departmentcode");
|
||||
String departmentname = childDepartmentMap.get("departmentname");
|
||||
String supdeptcode = childDepartmentMap.get("supdeptcode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", supdeptcode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> getTopSubcompanyList(String where){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select id,subcompanycode,subcompanyname,subcompanydesc \n" +
|
||||
" from HrmSubCompany where supsubcomid = 0 \n" + where +
|
||||
" and (canceled is null or canceled = 0)" ;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String subcompanyid = rs.getString("id");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanyid",subcompanyid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getSubcompanyListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,subcompanyname,supsubcomid,subcompanycode,curlevel) as (\n" +
|
||||
" select id,subcompanyname,supsubcomid,subcompanycode,1 as level \n" +
|
||||
" from HrmSubCompany where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.subcompanyname,a.supsubcomid,a.subcompanycode,b.curlevel+1\n" +
|
||||
" from HrmSubCompany a \n" +
|
||||
" inner join tem_table b on (a.supsubcomid = b.id)\n" +
|
||||
" )\n" +
|
||||
" select l.*,k.subcompanycode as supsubcompanycode from tem_table l " +
|
||||
" left join HrmSubCompany k on l.supsubcomid = k.id where l.id <> "+supsubcomid ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String sup_subcomid = rs.getString("supsubcomid");
|
||||
String supsubcompanycode = rs.getString("supsubcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
map.put("supsubcomid",sup_subcomid);
|
||||
map.put("supsubcompanycode",supsubcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String,String>> getTopDeptList(){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select t.id,t.departmentcode,t.departmentname,t.subcompanyid1,h.subcompanycode\n" +
|
||||
" from HrmDepartment t\n" +
|
||||
" left join HrmSubCompany h on h.id = t.subcompanyid1\n" +
|
||||
" where t.supdepid = 0" ;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String deptid = rs.getString("id");
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("deptid",deptid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getDeptListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,departmentname,supdepid,departmentcode,curlevel) as(\n" +
|
||||
" select id,departmentname,supdepid,departmentcode,1 as level \n" +
|
||||
" from HrmDepartment where id =" + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.departmentname,a.supdepid,a.departmentcode,b.curlevel+1 \n" +
|
||||
" from HrmDepartment a \n" +
|
||||
" inner join tem_table b on (a.supdepid = b.id) \n" +
|
||||
" )\n" +
|
||||
" select p.*,k.departmentcode as supdeptcode from tem_table p\n" +
|
||||
" left join HrmDepartment k on p.supdepid = k.id where id <> "+supsubcomid ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String sup_depid = rs.getString("supdepid");
|
||||
String supdeptcode = rs.getString("supdeptcode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("supdepid",sup_depid);
|
||||
map.put("supdeptcode",supdeptcode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,274 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.MD5" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpRequestBase" %>
|
||||
<%@ page import="org.apache.commons.collections.MapUtils" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.Consts" %>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.StatusLine" %>
|
||||
<%@ page import="javax.net.ssl.SSLContext" %>
|
||||
<%@ page import="org.apache.http.conn.socket.ConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.config.Registry" %>
|
||||
<%@ page import="org.apache.http.config.RegistryBuilder" %>
|
||||
<%@ page import="org.apache.http.conn.socket.PlainConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.SSLConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.NoopHostnameVerifier" %>
|
||||
<%@ page import="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||||
<%@ page import="java.security.KeyManagementException" %>
|
||||
<%@ page import="javax.net.ssl.X509TrustManager" %>
|
||||
<%@ page import="java.security.cert.CertificateException" %>
|
||||
<%@ page import="javax.net.ssl.TrustManager" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
try {
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
out.print("key:"+key+"</br>");
|
||||
out.print("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
out.print("sjc:"+sjc+"</br>");
|
||||
out.print("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
List<Map<String,String>> list = getTopSubcompanyList();
|
||||
for(int i=0;i<list.size();i++){
|
||||
Map<String,String> map = list.get(i);
|
||||
String subcompanyid = map.get("subcompanyid");
|
||||
String subcompanyname = map.get("subcompanyname");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanyid);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", "");
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
bb.writeLog("headers:" + JSONObject.toJSONString(heads));
|
||||
bb.writeLog("body:" + JSONObject.toJSONString(dataMap));
|
||||
|
||||
// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
// bb.writeLog("response:" + back);
|
||||
// out.print("response:"+back+"</br>");
|
||||
// JSONObject backObj = JSONObject.parseObject(back);
|
||||
// String code = backObj.getString("code");
|
||||
// String data = backObj.getString("data");
|
||||
// out.print("code:"+code+"</br>");
|
||||
// if ("0".equals(code)) {
|
||||
// bb.writeLog("新接口调用成功");
|
||||
// JSONObject dataObj = JSONObject.parseObject(data);
|
||||
// out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
// } else {
|
||||
// bb.writeLog("接口调用失败");
|
||||
// out.print("接口调用失败");
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> getTopSubcompanyList(){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select id,subcompanyname,subcompanydesc \n" +
|
||||
" from HrmSubCompany where supsubcomid = 0 \n" +
|
||||
" and (canceled is null or canceled = 0)" ;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = rs.getString("id");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanyid",id);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,478 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.MD5" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpRequestBase" %>
|
||||
<%@ page import="org.apache.commons.collections.MapUtils" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.Consts" %>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.StatusLine" %>
|
||||
<%@ page import="javax.net.ssl.SSLContext" %>
|
||||
<%@ page import="org.apache.http.conn.socket.ConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.config.Registry" %>
|
||||
<%@ page import="org.apache.http.config.RegistryBuilder" %>
|
||||
<%@ page import="org.apache.http.conn.socket.PlainConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.SSLConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.NoopHostnameVerifier" %>
|
||||
<%@ page import="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||||
<%@ page import="java.security.KeyManagementException" %>
|
||||
<%@ page import="javax.net.ssl.X509TrustManager" %>
|
||||
<%@ page import="java.security.cert.CertificateException" %>
|
||||
<%@ page import="javax.net.ssl.TrustManager" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
BaseBean bb = new BaseBean();
|
||||
String id = request.getParameter("id");
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
try {
|
||||
String where = "";
|
||||
if(StringUtils.isNotBlank(id)){
|
||||
where = " and id in("+id+")" ;
|
||||
}
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
out.print("key:"+key+"</br>");
|
||||
out.print("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
out.print("sjc:"+sjc+"</br>");
|
||||
out.print("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
List<Map<String,String>> topSubcompanyList = getTopSubcompanyList(where);
|
||||
for(int i=0;i<topSubcompanyList.size();i++){
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompanycode = topSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = topSubcompanyMap.get("subcompanyname");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", "");
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<topSubcompanyList.size();i++) {
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompanyid = topSubcompanyMap.get("subcompanyid");
|
||||
|
||||
List<Map<String,String>> childSubcompanyList = getSubcompanyListByParentid(subcompanyid);
|
||||
|
||||
for(int k=0;k<childSubcompanyList.size();k++){
|
||||
Map<String,String> childSubcompanyMap = childSubcompanyList.get(k);
|
||||
String subcompanycode = childSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = childSubcompanyMap.get("subcompanyname");
|
||||
String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", supsubcompanycode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// List<Map<String,String>> topDepartmentList = getTopDeptList();
|
||||
// for(int i=0;i<topDepartmentList.size();i++){
|
||||
// Map<String,String> topDepartmentMap = topDepartmentList.get(i);
|
||||
// String departmentcode = topDepartmentMap.get("departmentcode");
|
||||
// String departmentname = topDepartmentMap.get("departmentname");
|
||||
// String subcompanycode = topDepartmentMap.get("subcompanycode");
|
||||
//
|
||||
// Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
// dataMap.put("department_ext_id", departmentcode);
|
||||
// dataMap.put("name", departmentname);
|
||||
// dataMap.put("p_ext_id", subcompanycode);
|
||||
//
|
||||
// out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
// out.print("top-dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
//
|
||||
// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
// bb.writeLog("response:" + back);
|
||||
// out.print("response:"+back+"</br>");
|
||||
// JSONObject backObj = JSONObject.parseObject(back);
|
||||
// String code = backObj.getString("code");
|
||||
// String data = backObj.getString("data");
|
||||
// out.print("code:"+code+"</br>");
|
||||
// if ("0".equals(code)) {
|
||||
// bb.writeLog("新接口调用成功");
|
||||
// JSONObject dataObj = JSONObject.parseObject(data);
|
||||
// out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
// } else {
|
||||
// bb.writeLog("接口调用失败");
|
||||
// out.print("接口调用失败");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for(int i=0;i<topDepartmentList.size();i++) {
|
||||
// Map<String,String> topDeptMap = topDepartmentList.get(i);
|
||||
// String deptid = topDeptMap.get("deptid");
|
||||
//
|
||||
// List<Map<String,String>> childDepartmentList = getDeptListByParentid(deptid);
|
||||
// for(int k=0;k<childDepartmentList.size();i++){
|
||||
// Map<String,String> childDepartmentMap = childDepartmentList.get(i);
|
||||
// String departmentcode = childDepartmentMap.get("departmentcode");
|
||||
// String departmentname = childDepartmentMap.get("departmentname");
|
||||
// String supdeptcode = childDepartmentMap.get("supdeptcode");
|
||||
//
|
||||
// Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
// dataMap.put("department_ext_id", departmentcode);
|
||||
// dataMap.put("name", departmentname);
|
||||
// dataMap.put("p_ext_id", supdeptcode);
|
||||
//
|
||||
// out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
// out.print("dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
//
|
||||
// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
// bb.writeLog("response:" + back);
|
||||
// out.print("response:"+back+"</br>");
|
||||
// JSONObject backObj = JSONObject.parseObject(back);
|
||||
// String code = backObj.getString("code");
|
||||
// String data = backObj.getString("data");
|
||||
// out.print("code:"+code+"</br>");
|
||||
// if ("0".equals(code)) {
|
||||
// bb.writeLog("新接口调用成功");
|
||||
// JSONObject dataObj = JSONObject.parseObject(data);
|
||||
// out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
// } else {
|
||||
// bb.writeLog("接口调用失败");
|
||||
// out.print("接口调用失败");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> getTopSubcompanyList(String where){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select id,subcompanycode,subcompanyname,subcompanydesc \n" +
|
||||
" from HrmSubCompany where supsubcomid = 0 \n" + where +
|
||||
" and (canceled is null or canceled = 0)" ;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String subcompanyid = rs.getString("id");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanyid",subcompanyid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getSubcompanyListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,subcompanyname,supsubcomid,subcompanycode,curlevel) as (\n" +
|
||||
" select id,subcompanyname,supsubcomid,1 as level \n" +
|
||||
" from HrmSubCompany where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.subcompanyname,a.supsubcomid,subcompanycode,b.curlevel+1\n" +
|
||||
" from HrmSubCompany a \n" +
|
||||
" inner join tem_table b on (a.supsubcomid = b.id)\n" +
|
||||
" )\n" +
|
||||
" select l.*,k.subcompanycode as supsubcompanycode from tem_table l " +
|
||||
" left join HrmSubCompany k on l.supsubcomid = k.id where id <> "+supsubcomid ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String sup_subcomid = rs.getString("supsubcomid");
|
||||
String supsubcompanycode = rs.getString("supsubcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
map.put("supsubcomid",sup_subcomid);
|
||||
map.put("supsubcompanycode",supsubcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String,String>> getTopDeptList(){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select t.id,t.departmentcode,t.departmentname,t.subcompanyid1,h.subcompanycode\n" +
|
||||
" from HrmDepartment t\n" +
|
||||
" left join HrmSubCompany h on h.id = t.subcompanyid1\n" +
|
||||
" where t.supdepid = 0" ;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String deptid = rs.getString("id");
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("deptid",deptid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getDeptListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,departmentname,supdepid,departmentcode,curlevel) as(\n" +
|
||||
" select id,departmentname,supdepid,departmentcode,1 as level \n" +
|
||||
" from HrmDepartment where id =" + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.departmentname,a.supdepid,a.departmentcode,b.curlevel+1 \n" +
|
||||
" from HrmDepartment a \n" +
|
||||
" inner join tem_table b on (a.supdepid = b.id) \n" +
|
||||
" )\n" +
|
||||
" select p.*,k.departmentcode as supdeptcode from tem_table p\n" +
|
||||
" left join HrmDepartment k on p.supdepid = k.id where id <> "+supsubcomid ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String sup_depid = rs.getString("supdepid");
|
||||
String supdeptcode = rs.getString("supdeptcode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("supdepid",sup_depid);
|
||||
map.put("supdeptcode",supdeptcode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,478 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.MD5" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpRequestBase" %>
|
||||
<%@ page import="org.apache.commons.collections.MapUtils" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.Consts" %>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.StatusLine" %>
|
||||
<%@ page import="javax.net.ssl.SSLContext" %>
|
||||
<%@ page import="org.apache.http.conn.socket.ConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.config.Registry" %>
|
||||
<%@ page import="org.apache.http.config.RegistryBuilder" %>
|
||||
<%@ page import="org.apache.http.conn.socket.PlainConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.SSLConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.NoopHostnameVerifier" %>
|
||||
<%@ page import="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||||
<%@ page import="java.security.KeyManagementException" %>
|
||||
<%@ page import="javax.net.ssl.X509TrustManager" %>
|
||||
<%@ page import="java.security.cert.CertificateException" %>
|
||||
<%@ page import="javax.net.ssl.TrustManager" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
BaseBean bb = new BaseBean();
|
||||
String id = request.getParameter("id");
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
try {
|
||||
String where = "";
|
||||
if(StringUtils.isNotBlank(id)){
|
||||
where = " and id in("+id+")" ;
|
||||
}
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
out.print("key:"+key+"</br>");
|
||||
out.print("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
out.print("sjc:"+sjc+"</br>");
|
||||
out.print("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
// List<Map<String,String>> topSubcompanyList = getTopSubcompanyList(where);
|
||||
// for(int i=0;i<topSubcompanyList.size();i++){
|
||||
// Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
// String subcompanycode = topSubcompanyMap.get("subcompanycode");
|
||||
// String subcompanyname = topSubcompanyMap.get("subcompanyname");
|
||||
//
|
||||
// Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
// dataMap.put("department_ext_id", subcompanycode);
|
||||
// dataMap.put("name", subcompanyname);
|
||||
// dataMap.put("p_ext_id", "");
|
||||
//
|
||||
// out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
// out.print("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
//
|
||||
// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
// bb.writeLog("response:" + back);
|
||||
// out.print("response:"+back+"</br>");
|
||||
// JSONObject backObj = JSONObject.parseObject(back);
|
||||
// String code = backObj.getString("code");
|
||||
// String data = backObj.getString("data");
|
||||
// out.print("code:"+code+"</br>");
|
||||
// if ("0".equals(code)) {
|
||||
// bb.writeLog("新接口调用成功");
|
||||
// JSONObject dataObj = JSONObject.parseObject(data);
|
||||
// out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
// } else {
|
||||
// bb.writeLog("接口调用失败");
|
||||
// out.print("接口调用失败");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for(int i=0;i<topSubcompanyList.size();i++) {
|
||||
// Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
// String subcompanyid = topSubcompanyMap.get("subcompanyid");
|
||||
//
|
||||
// List<Map<String,String>> childSubcompanyList = getSubcompanyListByParentid(subcompanyid);
|
||||
//
|
||||
// for(int k=0;k<childSubcompanyList.size();i++){
|
||||
// Map<String,String> childSubcompanyMap = childSubcompanyList.get(i);
|
||||
// String subcompanycode = childSubcompanyMap.get("subcompanycode");
|
||||
// String subcompanyname = childSubcompanyMap.get("subcompanyname");
|
||||
// String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode");
|
||||
//
|
||||
// Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
// dataMap.put("department_ext_id", subcompanycode);
|
||||
// dataMap.put("name", subcompanyname);
|
||||
// dataMap.put("p_ext_id", supsubcompanycode);
|
||||
//
|
||||
// out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
// out.print("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
//
|
||||
// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
// bb.writeLog("response:" + back);
|
||||
// out.print("response:"+back+"</br>");
|
||||
// JSONObject backObj = JSONObject.parseObject(back);
|
||||
// String code = backObj.getString("code");
|
||||
// String data = backObj.getString("data");
|
||||
// out.print("code:"+code+"</br>");
|
||||
// if ("0".equals(code)) {
|
||||
// bb.writeLog("新接口调用成功");
|
||||
// JSONObject dataObj = JSONObject.parseObject(data);
|
||||
// out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
// } else {
|
||||
// bb.writeLog("接口调用失败");
|
||||
// out.print("接口调用失败");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
List<Map<String,String>> topDepartmentList = getTopDeptList();
|
||||
for(int i=0;i<topDepartmentList.size();i++){
|
||||
Map<String,String> topDepartmentMap = topDepartmentList.get(i);
|
||||
String departmentcode = topDepartmentMap.get("departmentcode");
|
||||
String departmentname = topDepartmentMap.get("departmentname");
|
||||
String subcompanycode = topDepartmentMap.get("subcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", subcompanycode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("top-dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<topDepartmentList.size();i++) {
|
||||
Map<String,String> topDeptMap = topDepartmentList.get(i);
|
||||
String deptid = topDeptMap.get("deptid");
|
||||
|
||||
List<Map<String,String>> childDepartmentList = getDeptListByParentid(deptid);
|
||||
for(int k=0;k<childDepartmentList.size();k++){
|
||||
Map<String,String> childDepartmentMap = childDepartmentList.get(k);
|
||||
String departmentcode = childDepartmentMap.get("departmentcode");
|
||||
String departmentname = childDepartmentMap.get("departmentname");
|
||||
String supdeptcode = childDepartmentMap.get("supdeptcode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", supdeptcode);
|
||||
|
||||
out.print("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
out.print("dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
out.print("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
out.print("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> getTopSubcompanyList(String where){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select id,subcompanycode,subcompanyname,subcompanydesc \n" +
|
||||
" from HrmSubCompany where supsubcomid = 0 \n" + where +
|
||||
" and (canceled is null or canceled = 0)" ;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String subcompanyid = rs.getString("id");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanyid",subcompanyid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getSubcompanyListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,subcompanyname,supsubcomid,subcompanycode,curlevel) as (\n" +
|
||||
" select id,subcompanyname,supsubcomid,1 as level \n" +
|
||||
" from HrmSubCompany where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.subcompanyname,a.supsubcomid,subcompanycode,b.curlevel+1\n" +
|
||||
" from HrmSubCompany a \n" +
|
||||
" inner join tem_table b on (a.supsubcomid = b.id)\n" +
|
||||
" )\n" +
|
||||
" select l.*,k.subcompanycode as supsubcompanycode from tem_table l " +
|
||||
" left join HrmSubCompany k on l.supsubcomid = k.id where id <> "+supsubcomid ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String sup_subcomid = rs.getString("supsubcomid");
|
||||
String supsubcompanycode = rs.getString("supsubcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
map.put("supsubcomid",sup_subcomid);
|
||||
map.put("supsubcompanycode",supsubcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String,String>> getTopDeptList(){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select t.id,t.departmentcode,t.departmentname,t.subcompanyid1,h.subcompanycode\n" +
|
||||
" from HrmDepartment t\n" +
|
||||
" left join HrmSubCompany h on h.id = t.subcompanyid1\n" +
|
||||
" where t.supdepid = 0" ;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String deptid = rs.getString("id");
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("deptid",deptid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getDeptListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,departmentname,supdepid,departmentcode,curlevel) as(\n" +
|
||||
" select id,departmentname,supdepid,departmentcode,1 as level \n" +
|
||||
" from HrmDepartment where id =" + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.departmentname,a.supdepid,a.departmentcode,b.curlevel+1 \n" +
|
||||
" from HrmDepartment a \n" +
|
||||
" inner join tem_table b on (a.supdepid = b.id) \n" +
|
||||
" )\n" +
|
||||
" select p.*,k.departmentcode as supdeptcode from tem_table p\n" +
|
||||
" left join HrmDepartment k on p.supdepid = k.id where id <> "+supsubcomid ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String sup_depid = rs.getString("supdepid");
|
||||
String supdeptcode = rs.getString("supdeptcode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("supdepid",sup_depid);
|
||||
map.put("supdeptcode",supdeptcode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,495 @@
|
|||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.MD5" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpRequestBase" %>
|
||||
<%@ page import="org.apache.commons.collections.MapUtils" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.Consts" %>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.StatusLine" %>
|
||||
<%@ page import="javax.net.ssl.SSLContext" %>
|
||||
<%@ page import="org.apache.http.conn.socket.ConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.config.Registry" %>
|
||||
<%@ page import="org.apache.http.config.RegistryBuilder" %>
|
||||
<%@ page import="org.apache.http.conn.socket.PlainConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.SSLConnectionSocketFactory" %>
|
||||
<%@ page import="org.apache.http.conn.ssl.NoopHostnameVerifier" %>
|
||||
<%@ page import="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||||
<%@ page import="java.security.KeyManagementException" %>
|
||||
<%@ page import="javax.net.ssl.X509TrustManager" %>
|
||||
<%@ page import="java.security.cert.CertificateException" %>
|
||||
<%@ page import="javax.net.ssl.TrustManager" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%
|
||||
BaseBean bb = new BaseBean();
|
||||
String path = "/v2.0/employee";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
String userid = request.getParameter("userid");
|
||||
try {
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
out.print("key:"+key+"</br>");
|
||||
out.print("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
out.print("sjc:"+sjc+"</br>");
|
||||
out.print("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
Map<String,String> userMap = getUserData(userid);
|
||||
String workcode = Util.null2String(userMap.get("workcode"));
|
||||
String lastname = Util.null2String(userMap.get("lastname"));
|
||||
String mobile = Util.null2String(userMap.get("mobile"));
|
||||
String deptcode = Util.null2String(userMap.get("departmentcode"));
|
||||
String deptname = Util.null2String(userMap.get("departmentname"));
|
||||
String deptid = Util.null2String(userMap.get("departmentid"));
|
||||
String subcompanyid1 = Util.null2String(userMap.get("subcompanyid1"));
|
||||
|
||||
out.print("workcode:"+workcode+ "</br>");
|
||||
out.print("lastname:"+lastname+ "</br>");
|
||||
out.print("mobile:"+mobile+ "</br>");
|
||||
|
||||
out.print("deptcode:"+deptcode+ "</br>");
|
||||
out.print("deptname:"+deptname+ "</br>");
|
||||
out.print("deptid:"+deptid+ "</br>");
|
||||
out.print("subcompanyid1:"+subcompanyid1+ "</br>");
|
||||
|
||||
int errorcount = 0;
|
||||
int errorcount1 = updateSubcompanyData(subcompanyid1,key,secret);
|
||||
errorcount = errorcount + errorcount1 ;
|
||||
out.print("errorcount1:"+errorcount1+"</br>");
|
||||
|
||||
int errorcount2 = updateDeptData(deptid,key,secret);
|
||||
errorcount = errorcount + errorcount2 ;
|
||||
out.print("errorcount2:"+errorcount2+"</br>");
|
||||
|
||||
if(errorcount == 0){
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("employee_ext_id", workcode);
|
||||
dataMap.put("name", lastname);
|
||||
dataMap.put("mobile", mobile);
|
||||
dataMap.put("employee_num", workcode);
|
||||
|
||||
List<Map<String, Object>> department_infolist = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> department_infos = new HashMap<String, Object>();
|
||||
department_infos.put("ext_id",deptcode);
|
||||
department_infos.put("title",deptname);
|
||||
department_infolist.add(department_infos);
|
||||
dataMap.put("department_infos", department_infolist);
|
||||
|
||||
out.print("employee-headers:" + JSONObject.toJSONString(heads) + "</br>");
|
||||
out.print("employee-body:" + JSONObject.toJSONString(dataMap) + "</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
out.print("employee-response:" + back + "</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
out.print("employee-code:" + code + "</br>");
|
||||
if (!"0".equals(code)) {
|
||||
errorcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,String>> getSubcompanyListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,subcompanyname,supsubcomid,subcompanycode,curlevel) as (\n" +
|
||||
" select id,subcompanyname,supsubcomid,1 as level \n" +
|
||||
" from HrmSubCompany where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.subcompanyname,a.supsubcomid,subcompanycode,b.curlevel+1\n" +
|
||||
" from HrmSubCompany a \n" +
|
||||
" inner join tem_table b on (a.id = b.supsubcomid)\n" +
|
||||
" )\n" +
|
||||
" select l.*,k.subcompanycode as supsubcompanycode from tem_table l " +
|
||||
" left join HrmSubCompany k on l.supsubcomid = k.id " ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String sup_subcomid = rs.getString("supsubcomid");
|
||||
String supsubcompanycode = rs.getString("supsubcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
map.put("supsubcomid",sup_subcomid);
|
||||
map.put("supsubcompanycode",supsubcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
if(list !=null && list.size() > 0){
|
||||
Collections.reverse(list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getDeptListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,departmentname,supdepid,departmentcode,subcompanyid1,curlevel) as(\n" +
|
||||
" select id,departmentname,supdepid,departmentcode,subcompanyid1,1 as level \n" +
|
||||
" from HrmDepartment where id =" + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.departmentname,a.supdepid,a.departmentcode,a.subcompanyid1,b.curlevel+1 \n" +
|
||||
" from HrmDepartment a \n" +
|
||||
" inner join tem_table b on (a.id = b.supdepid) \n" +
|
||||
" )\n" +
|
||||
" select p.*,k.departmentcode as supdeptcode,h.subcompanycode from tem_table p\n" +
|
||||
" left join HrmDepartment k on p.supdepid = k.id " +
|
||||
" left join hrmsubcompany h on h.id = p.subcompanyid1 " ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String sup_depid = rs.getString("supdepid");
|
||||
String supdeptcode = rs.getString("supdeptcode");
|
||||
if(StringUtils.isBlank(supdeptcode)){
|
||||
supdeptcode = subcompanycode;
|
||||
}
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("supdepid",sup_depid);
|
||||
map.put("supdeptcode",supdeptcode);
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
if(list !=null && list.size() > 0){
|
||||
Collections.reverse(list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getUserData(String userid){
|
||||
|
||||
Map<String,String> userMap = new HashMap<String,String>();
|
||||
String workcode = "";
|
||||
String departmentid = "";
|
||||
String subcompanyid1 = "";
|
||||
String departmentcode = "";
|
||||
String lastname = "";
|
||||
String mobile = "";
|
||||
String departmentname = "";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
|
||||
try{
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String sql =" select t.workcode,t.departmentid,t.subcompanyid1,t.lastname,t.mobile,k.departmentcode,k.departmentname " +
|
||||
" from hrmresource t inner join hrmdepartment k on k.id = t.departmentid" +
|
||||
" where t.id = ? and t.status in (0,1,2,3) ";
|
||||
|
||||
rs.executeQuery(sql,new Object[]{userid});
|
||||
if(rs.next()){
|
||||
workcode = Util.null2String(rs.getString("workcode"));
|
||||
departmentid = Util.null2String(rs.getString("departmentid"));
|
||||
subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
||||
departmentcode = Util.null2String(rs.getString("departmentcode"));
|
||||
lastname = Util.null2String(rs.getString("lastname"));
|
||||
mobile = Util.null2String(rs.getString("mobile"));
|
||||
|
||||
departmentname = Util.null2String(rs.getString("departmentname"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
userMap.put("workcode",workcode);
|
||||
userMap.put("lastname",lastname);
|
||||
userMap.put("mobile",mobile);
|
||||
userMap.put("departmentcode",departmentcode);
|
||||
userMap.put("departmentname",departmentname);
|
||||
userMap.put("departmentid",departmentid);
|
||||
userMap.put("subcompanyid1",subcompanyid1);
|
||||
|
||||
return userMap;
|
||||
}
|
||||
|
||||
|
||||
public int updateSubcompanyData(String subcompanyid1,String key,String secret){
|
||||
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
int errorcount = 0;
|
||||
List<Map<String,String>> childSubcompanyList = getSubcompanyListByParentid(subcompanyid1);
|
||||
for(int k=0;k<childSubcompanyList.size();k++) {
|
||||
Map<String, String> childSubcompanyMap = childSubcompanyList.get(k);
|
||||
String subcompanycode = childSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = childSubcompanyMap.get("subcompanyname");
|
||||
String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", supsubcompanycode);
|
||||
|
||||
String back = null;
|
||||
try {
|
||||
back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
if (!"0".equals(code)) {
|
||||
errorcount++;
|
||||
}
|
||||
}
|
||||
return errorcount;
|
||||
}
|
||||
|
||||
|
||||
public int updateDeptData(String deptid,String key,String secret){
|
||||
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
int errorcount = 0;
|
||||
List<Map<String,String>> childDepartmentList = getDeptListByParentid(deptid);
|
||||
for(int k=0;k<childDepartmentList.size();k++){
|
||||
Map<String,String> childDepartmentMap = childDepartmentList.get(k);
|
||||
String departmentcode = childDepartmentMap.get("departmentcode");
|
||||
String departmentname = childDepartmentMap.get("departmentname");
|
||||
String supdeptcode = childDepartmentMap.get("supdeptcode");
|
||||
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", supdeptcode);
|
||||
|
||||
|
||||
String back = null;
|
||||
try {
|
||||
back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
if (!"0".equals(code)) {
|
||||
errorcount++;
|
||||
}
|
||||
}
|
||||
return errorcount;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.api.browser.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import weaver.general.Util;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import com.api.browser.bean.SplitTableBean;
|
||||
import com.api.browser.bean.SplitTableColBean;
|
||||
import com.api.browser.service.BrowserService;
|
||||
import com.api.browser.util.BoolAttr;
|
||||
import com.api.browser.util.BrowserConstant;
|
||||
import com.api.browser.util.ConditionFactory;
|
||||
import com.api.browser.util.SplitTableUtil;
|
||||
import com.api.browser.bean.SearchConditionItem;
|
||||
import com.api.browser.util.ConditionType;
|
||||
|
||||
/**
|
||||
* 职务类别
|
||||
*
|
||||
* @author lvyi
|
||||
*
|
||||
*/
|
||||
public class JobActivitiesBrowserService extends BrowserService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
String jobactivitymark = Util.null2String(params.get("jobactivitymark"));
|
||||
String jobactivityname = Util.null2String(params.get("jobactivityname"));
|
||||
String sqlwhere = "where 1 = 1 and a.jobgroupid = b.id ";
|
||||
String backfields = "";
|
||||
String fromSql = "";
|
||||
String orderby = "";
|
||||
if(!jobactivitymark.equals("")){
|
||||
sqlwhere += " and a.Jobactivitymark like '%";
|
||||
sqlwhere += Util.fromScreen2(jobactivitymark,user.getLanguage());
|
||||
sqlwhere += "%'";
|
||||
}
|
||||
if(!jobactivityname.equals("")){
|
||||
sqlwhere += " and a.jobactivityname like '%";
|
||||
sqlwhere += Util.fromScreen2(jobactivityname,user.getLanguage());
|
||||
sqlwhere += "%'";
|
||||
}
|
||||
|
||||
List<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
|
||||
backfields = " a.id,a.jobactivitymark,a.jobactivityname,b.jobgroupname ";
|
||||
fromSql = " HrmJobActivities a , HrmJobGroups b ";
|
||||
orderby = " a.id ";
|
||||
|
||||
cols.add(new SplitTableColBean("true", "id"));
|
||||
cols.add(new SplitTableColBean("25%", "子序列简称", "jobactivitymark", "jobactivitymark").setIsInputCol(BoolAttr.TRUE));
|
||||
cols.add(new SplitTableColBean("25%", "子序列全称", "jobactivityname", "jobactivityname"));
|
||||
cols.add(new SplitTableColBean("25%", "序列", "jobgroupname", "jobgroupname"));
|
||||
|
||||
|
||||
SplitTableBean tableBean = new SplitTableBean(backfields, fromSql, sqlwhere, orderby, "a.id", cols);
|
||||
|
||||
tableBean.setSqlsortway("ASC");
|
||||
tableBean.setSqlisdistinct("true");
|
||||
apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean));
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getBrowserConditionInfo(Map<String, Object> params) throws Exception {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
List<SearchConditionItem> conditions = new ArrayList<SearchConditionItem>();
|
||||
apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions);
|
||||
ConditionFactory conditionFactory = new ConditionFactory(user);
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 399, "jobactivitymark", true));
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 15767, "jobactivityname"));
|
||||
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
package com.api.browser.service.impl;
|
||||
|
||||
import com.api.browser.bean.ListHeadBean;
|
||||
import com.api.browser.bean.SearchConditionItem;
|
||||
import com.api.browser.bean.SplitTableBean;
|
||||
import com.api.browser.bean.SplitTableColBean;
|
||||
import com.api.browser.service.BrowserService;
|
||||
import com.api.browser.util.*;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数智岗位浏览按钮二开
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/05/04
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class JobTitlesBrowserService extends BrowserService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
|
||||
Map<String, Object> apidatas = new HashMap<>(16);
|
||||
String jobtitlemark = Util.null2String(params.get("jobtitlemark"));
|
||||
String jobtitlename = Util.null2String(params.get("jobtitlename"));
|
||||
String jobtitlecode = Util.null2String(params.get("jobtitlecode"));
|
||||
String jobactivityname = Util.null2String(params.get("jobactivityname"));
|
||||
String sqlwhere = "where 1 = 1 ";
|
||||
String backfields;
|
||||
String fromSql;
|
||||
String orderby;
|
||||
List<SplitTableColBean> cols = new ArrayList<>();
|
||||
SplitTableBean tableBean;
|
||||
if ("278".equals(browserType)) {
|
||||
backfields = "c.id,c.jobtitlemark,c.jobtitlename,a.jobgroupname,a.jobgroupremark,b.jobactivitymark";
|
||||
fromSql = "from HrmJobTitles c left join HrmJobActivities b on b.id = c.jobactivityid left join HrmJobGroups a on a.id = b.jobgroupid";
|
||||
orderby = "c.id";
|
||||
sqlwhere = " where (c.canceled is null or c.canceled <> 1)";
|
||||
String jobgroupid = Util.null2String(params.get("jobgroupid"));
|
||||
String jobactivitieid = Util.null2String(params.get("jobactivitieid"));
|
||||
if (!"".equals(jobgroupid)) {
|
||||
sqlwhere += " and a.id =" + jobgroupid;
|
||||
}
|
||||
if (!"".equals(jobactivitieid)) {
|
||||
sqlwhere += " and b.id= " + jobactivitieid;
|
||||
}
|
||||
if (!"".equals(jobtitlemark)) {
|
||||
sqlwhere += " and c.jobtitlemark like '%" + Util.fromScreen2(jobtitlemark, user.getLanguage()) + "%' ";
|
||||
}
|
||||
if (!"".equals(jobtitlename)) {
|
||||
sqlwhere += " and c.jobtitlename like '%" + Util.fromScreen2(jobtitlename, user.getLanguage()) + "%' ";
|
||||
}
|
||||
if (!"".equals(jobtitlecode)) {
|
||||
sqlwhere += " and c.jobtitlecode like '%" + Util.fromScreen2(jobtitlecode, user.getLanguage()) + "%' ";
|
||||
}
|
||||
|
||||
cols.add(new SplitTableColBean("true", "id"));
|
||||
cols.add(new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(6086, user.getLanguage()), "jobtitlemark", "jobtitlemark", 1).setIsInputCol(BoolAttr.TRUE));
|
||||
cols.add(new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(1915, user.getLanguage()), "jobactivitymark", "jobactivitymark"));
|
||||
cols.add(new SplitTableColBean("30%", SystemEnv.getHtmlLabelName(805, user.getLanguage()), "jobgroupremark", "jobgroupremark"));
|
||||
tableBean = new SplitTableBean(backfields, fromSql, sqlwhere, orderby, "c.id", cols);
|
||||
} else {
|
||||
backfields = " a.id as id,a.jobtitlemark as jobtitlemark,a.jobtitlename as jobtitlename, b.jobactivityname as jobactivityname, b.jobactivitymark as jobactivitymark , a.jobtitlecode as jobtitlecode, c.jobgroupremark as jobgroupremark";
|
||||
fromSql = " from HrmJobTitles a left join HrmJobActivities b on a.jobactivityid=b.id left join hrmjobgroups c on b.jobgroupid =c.id";
|
||||
orderby = " a.id ";
|
||||
sqlwhere += " and (a.canceled is null or a.canceled <> 1)";
|
||||
if (!"".equals(jobtitlemark)) {
|
||||
sqlwhere += " and a.jobtitlemark like '%" + jobtitlemark + "%'";
|
||||
}
|
||||
|
||||
if (!"".equals(jobtitlename)) {
|
||||
sqlwhere += " and a.jobtitlename like '%" + jobtitlename + "%'";
|
||||
}
|
||||
|
||||
if (!"".equals(jobtitlecode)) {
|
||||
sqlwhere += " and a.jobtitlecode like '%" + jobtitlecode + "%'";
|
||||
}
|
||||
|
||||
if (!"".equals(jobactivityname)) {
|
||||
sqlwhere += " and jobactivityname like '%" + jobactivityname + "%'";
|
||||
}
|
||||
cols.add(new SplitTableColBean("true", "id"));
|
||||
cols.add(new SplitTableColBean("20%", "岗位简称", "jobtitlename", "jobtitlename"));
|
||||
cols.add(new SplitTableColBean("20%", "岗位全称", "jobtitlemark", "jobtitlemark").setIsInputCol(BoolAttr.TRUE));
|
||||
cols.add(new SplitTableColBean("20%", "岗位编号", "jobtitlecode", "jobtitlecode"));
|
||||
cols.add(new SplitTableColBean("20%", "子序列", "jobactivitymark", "jobactivitymark"));
|
||||
cols.add(new SplitTableColBean("20%", "序列", "jobgroupremark", "jobgroupremark"));
|
||||
tableBean = new SplitTableBean(backfields, fromSql, sqlwhere, orderby, "a.id", cols);
|
||||
}
|
||||
|
||||
tableBean.setSqlsortway("ASC");
|
||||
tableBean.setSqlisdistinct("true");
|
||||
apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean));
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getBrowserConditionInfo(Map<String, Object> params) throws Exception {
|
||||
Map<String, Object> apidatas = new HashMap<>(16);
|
||||
List<SearchConditionItem> conditions = new ArrayList<>();
|
||||
apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions);
|
||||
ConditionFactory conditionFactory = new ConditionFactory(user);
|
||||
if ("278".equals(browserType)) {
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.BROWSER, 805, "jobgroupid", "281"));
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.BROWSER, 15855, "jobactivitieid", "282"));
|
||||
}
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 15767, "jobtitlename"));
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 399, "jobtitlemark", true));
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 524944, "jobtitlecode"));
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMultBrowserDestData(Map<String, Object> params) throws Exception {
|
||||
Map<String, Object> apidatas = new HashMap<>(16);
|
||||
List<Map<String, Object>> datas = new ArrayList<>();
|
||||
String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS));
|
||||
if (user == null || "".equals(selectids)) {
|
||||
return apidatas;
|
||||
}
|
||||
RecordSet rs = new RecordSet();
|
||||
String tempSql = " select c.id,c.jobtitlemark,c.jobtitlename,a.jobgroupname,a.jobgroupremark,b.jobactivitymark " +
|
||||
" from HrmJobTitles c left join HrmJobActivities b on b.id = c.jobactivityid left join HrmJobGroups a on a.id = b.jobgroupid " +
|
||||
" where c.id in (" + selectids + ")" +
|
||||
" order by c.jobtitlemark ";
|
||||
rs.execute(tempSql);
|
||||
while (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>(16);
|
||||
item.put("id", rs.getString("id"));
|
||||
item.put("jobtitlemark", Util.null2String(rs.getString("jobtitlemark")));
|
||||
item.put("jobactivitymark", Util.null2String(rs.getString("jobactivitymark")));
|
||||
item.put("jobgroupremark", Util.null2String(rs.getString("jobgroupremark")));
|
||||
datas.add(item);
|
||||
}
|
||||
|
||||
List<ListHeadBean> tableHeadColumns = new ArrayList<>();
|
||||
tableHeadColumns.add(new ListHeadBean("id", BoolAttr.TRUE));
|
||||
tableHeadColumns.add(new ListHeadBean("jobtitlemark", "", 1, BoolAttr.TRUE));
|
||||
tableHeadColumns.add(new ListHeadBean("jobactivitymark", ""));
|
||||
tableHeadColumns.add(new ListHeadBean("jobgroupremark", ""));
|
||||
|
||||
apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns);
|
||||
apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas);
|
||||
apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid());
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
Map<String, Object> apidatas = new HashMap<>(16);
|
||||
String q = Util.null2String(request.getParameter("q"));
|
||||
List<String> sqlParams = new ArrayList<>();
|
||||
String keyword = "";
|
||||
if (q.length() > 0) {
|
||||
keyword = "%" + q + "%";
|
||||
}
|
||||
RecordSet rs = new RecordSet();
|
||||
String sqlwhere = "where 1 = 1 ";
|
||||
String backfields = " a.id as id,a.jobtitlemark as jobtitlemark,a.jobtitlename as jobtitlename,a.jobtitlecode as jobtitlecode,b.jobactivityname as jobactivityname, b.jobactivitymark as jobactivitymark ";
|
||||
String fromSql = " from HrmJobTitles a left join HrmJobActivities b on a.jobactivityid=b.id ";
|
||||
String orderby = " order by a.id ";
|
||||
sqlwhere += " and (a.canceled is null or a.canceled <> 1)";
|
||||
if (!"".equals(keyword)) {
|
||||
sqlwhere += " and (a.jobtitlemark like ? or a.jobtitlename like ? or a.ecology_pinyin_search like ? )";
|
||||
sqlParams.add(keyword);
|
||||
sqlParams.add(keyword);
|
||||
sqlParams.add(keyword);
|
||||
}
|
||||
String sql = "select " + backfields + fromSql + sqlwhere + orderby;
|
||||
rs.executeQuery(sql, sqlParams);
|
||||
List<Map<String, String>> datas = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
Map<String, String> item = new HashMap<>();
|
||||
item.put("id", Util.null2String(rs.getString("id")));
|
||||
String name = Util.null2String(rs.getString("jobtitlemark"));
|
||||
String jobtitlecode = Util.null2String(rs.getString("jobtitlecode"));
|
||||
String title = name + "|" + jobtitlecode + "|" + Util.null2String(rs.getString("jobactivitymark"));
|
||||
item.put("name", name);
|
||||
item.put("title", title);
|
||||
datas.add(item);
|
||||
}
|
||||
apidatas.put("datas", datas);
|
||||
return apidatas;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.api.shuzhi.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Path("/shuzhi/mode")
|
||||
public class SzBatchExportController extends com.engine.shuzhi.web.SzBatchExportController{
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.api.shuzhi.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
@Path("/shuzhi/datacenter")
|
||||
public class SzDataCenterController extends com.engine.shuzhi.web.SzDataCenterController {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.api.shuzhi.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
@Path("/shuzhi/resume")
|
||||
public class SzResumeController extends com.engine.shuzhi.web.SzResumeController {
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.customization.shuzhi;
|
||||
|
||||
import com.cloudstore.dev.api.util.Util_TableMap;
|
||||
import com.engine.core.cfg.annotation.CommandDynamicProxy;
|
||||
import com.engine.core.interceptor.AbstractCommandProxy;
|
||||
import com.engine.core.interceptor.Command;
|
||||
import com.engine.hrm.cmd.jobset.GetJobTitleListCmd;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 岗位列表表头信息调整
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/04/26
|
||||
* @version: 1.0
|
||||
*/
|
||||
@CommandDynamicProxy(target = GetJobTitleListCmd.class, desc = "调整表头信息")
|
||||
public class SzGetJobTitleListCmd extends AbstractCommandProxy<Map<String, Object>> {
|
||||
@Override
|
||||
public Map<String, Object> execute(Command<Map<String, Object>> targetCommand) {
|
||||
Map<String, Object> result = (Map)this.nextExecute(targetCommand);
|
||||
String sessionKey = Util.null2String(result.get("sessionkey"));
|
||||
String tableString = Util_TableMap.getVal(sessionKey);
|
||||
tableString = tableString.replace("岗位简称", "岗位名称").replace("岗位全称", "职级名称").replace("所属职务", "职级代码").replace("职务类别", "序列");
|
||||
|
||||
try {
|
||||
Document document = DocumentHelper.parseText(tableString);
|
||||
Element rootElement = document.getRootElement();
|
||||
Element head = rootElement.element("head");
|
||||
List colList = head.elements();
|
||||
Element col = DocumentHelper.createElement("col");
|
||||
col.addAttribute("width", "20%");
|
||||
col.addAttribute("text", "标识");
|
||||
col.addAttribute("column", "id");
|
||||
col.addAttribute("orderkey", "id");
|
||||
colList.add(0, col);
|
||||
tableString = document.asXML();
|
||||
} catch (Exception var10) {
|
||||
var10.getMessage();
|
||||
}
|
||||
|
||||
Util_TableMap.setVal(sessionKey, tableString);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,80 @@
|
|||
package com.engine.shuzhi.entity.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ModeStaffPO {
|
||||
/**
|
||||
* 在岗人数
|
||||
*/
|
||||
private String num;
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private String departmentid;
|
||||
/**
|
||||
* 岗位ID
|
||||
*/
|
||||
private String jobtitle;
|
||||
|
||||
|
||||
///**
|
||||
// * 编制台账ID
|
||||
// */
|
||||
//private String staffId;
|
||||
/**
|
||||
* 编制人数
|
||||
*/
|
||||
private String staffNum;
|
||||
/**
|
||||
* 空编人数
|
||||
*/
|
||||
private Integer lackNum;
|
||||
|
||||
|
||||
/**
|
||||
* 获取空编人数
|
||||
*
|
||||
* @return 空编人数
|
||||
*/
|
||||
public Integer getLackNum() {
|
||||
return parseInt(staffNum) - parseInt(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在岗人数
|
||||
*
|
||||
* @return 在岗人数
|
||||
*/
|
||||
public Integer getNum() {
|
||||
return parseInt(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* String 转 Integer
|
||||
*
|
||||
* @param str String
|
||||
* @return Integer
|
||||
*/
|
||||
private Integer parseInt(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(str);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.engine.shuzhi.exception;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2023/2/21
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class CustomizeRunTimeException extends RuntimeException{
|
||||
|
||||
public CustomizeRunTimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CustomizeRunTimeException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CustomizeRunTimeException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.engine.shuzhi.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface SzBatchExportService {
|
||||
|
||||
/**
|
||||
* 下载人员附件
|
||||
*
|
||||
* @param idList 所选人员ID
|
||||
* @return 文件名称、文件路径
|
||||
*/
|
||||
Map<String, Object> downloadResourceFile(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 下载合同附件
|
||||
*
|
||||
* @param idList 所选记录ID
|
||||
* @return 文件名称、文件路径
|
||||
*/
|
||||
Map<String, Object> downloadContractFile(List<Long> idList);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.engine.shuzhi.service;
|
||||
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
public interface SzDataCenterService {
|
||||
Map<String, Object> updateResume(Map<String, Object> params, User user);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.engine.shuzhi.service;
|
||||
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
public interface SzResumeCenterService {
|
||||
Map<String, Object> updateResume(Map<String, Object> params);
|
||||
Map<String, Object> getResumeInfo(Map<String, Object> params);
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
package com.engine.shuzhi.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.shuzhi.exception.CustomizeRunTimeException;
|
||||
import com.engine.shuzhi.service.SzBatchExportService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class SzBatchExportServiceImpl extends Service implements SzBatchExportService {
|
||||
@Override
|
||||
public Map<String, Object> downloadResourceFile(List<Long> idList) {
|
||||
Map<String, Object> returnMap = new HashMap<>(2);
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
throw new CustomizeRunTimeException("未选择需要下载的人员信息");
|
||||
}
|
||||
// 身份证复印件+日期
|
||||
String zipFilename = "身份证复印件" + LocalDate.now() + ".zip";
|
||||
|
||||
String outPutPath = GCONST.getRootPath() + "filesystem" + File.separator + "downloadBatchTemp";
|
||||
File outPut = new File(outPutPath);
|
||||
if (!outPut.exists() && !outPut.isDirectory()) {
|
||||
outPut.mkdir();
|
||||
}
|
||||
outPutPath += File.separator + zipFilename;
|
||||
|
||||
|
||||
try {
|
||||
RecordSet rs = new RecordSet();
|
||||
// TODO 调整附件字段
|
||||
String sql = "select a.lastname ,a.workcode ,b.field13 as fileId from HrmResource a inner join cus_fielddata b on a.id =b.id and b.scopeid =1 and a.id = ? ";
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(Paths.get(outPutPath)));
|
||||
byte[] buffer = new byte[1024];
|
||||
for (Long userId : idList) {
|
||||
String fileId = "";
|
||||
String lastname = "";
|
||||
String workcode = "";
|
||||
rs.executeQuery(sql, userId);
|
||||
if (rs.next()) {
|
||||
fileId = rs.getString("fileId");
|
||||
lastname = rs.getString("lastname");
|
||||
workcode = rs.getString("workcode");
|
||||
}
|
||||
if (StringUtils.isNotBlank(fileId)) {
|
||||
for (String file : fileId.split(",")) {
|
||||
ImageFileManager manager = new ImageFileManager();
|
||||
manager.getImageFileInfoById(Util.getIntValue(file));
|
||||
manager.getImageFileType();
|
||||
InputStream inputStream = manager.getInputStream();
|
||||
// 姓名+工号(身份证)
|
||||
zipOutputStream.putNextEntry(new ZipEntry(lastname + workcode + getFileSuffix(manager.getImageFileName())));
|
||||
int length;
|
||||
while ((length = inputStream.read(buffer)) > 0) {
|
||||
zipOutputStream.write(buffer, 0, length);
|
||||
}
|
||||
inputStream.close();
|
||||
zipOutputStream.closeEntry();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
zipOutputStream.close();
|
||||
returnMap.put("zipFilename", zipFilename);
|
||||
returnMap.put("outPutPath", outPutPath);
|
||||
} catch (IOException e) {
|
||||
new BaseBean().writeLog(e);
|
||||
throw new CustomizeRunTimeException(e);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> downloadContractFile(List<Long> idList) {
|
||||
Map<String, Object> returnMap = new HashMap<>(2);
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
throw new CustomizeRunTimeException("未选择需要下载的人员信息");
|
||||
}
|
||||
|
||||
// 合同附件+日期
|
||||
String zipFilename = "合同附件" + LocalDate.now() + ".zip";
|
||||
|
||||
String outPutPath = GCONST.getRootPath() + "filesystem" + File.separator + "downloadBatchTemp";
|
||||
File outPut = new File(outPutPath);
|
||||
if (!outPut.exists() && !outPut.isDirectory()) {
|
||||
outPut.mkdir();
|
||||
}
|
||||
outPutPath += File.separator + zipFilename;
|
||||
|
||||
try {
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "select a.lastname ,a.workcode ,b.fj as fileId,b.htksrq from HrmResource a inner join uf_ygqdhtbd b on a.id =b.xm where b.id = ?";
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(Paths.get(outPutPath)));
|
||||
byte[] buffer = new byte[1024];
|
||||
for (Long id : idList) {
|
||||
String docId = "";
|
||||
String lastname = "";
|
||||
String workcode = "";
|
||||
String htksrq = "";
|
||||
rs.executeQuery(sql, id);
|
||||
if (rs.next()) {
|
||||
docId = rs.getString("fileId");
|
||||
lastname = rs.getString("lastname");
|
||||
workcode = rs.getString("workcode");
|
||||
htksrq = rs.getString("htksrq");
|
||||
}
|
||||
if (StringUtils.isNotBlank(docId)) {
|
||||
for (String doc : docId.split(",")) {
|
||||
rs.executeQuery("select imagefileid from DocImageFile where docid = ?", doc);
|
||||
String file = "";
|
||||
if (rs.next()) {
|
||||
file = rs.getString("imagefileid");
|
||||
}
|
||||
if (StringUtils.isBlank(file)) {
|
||||
continue;
|
||||
}
|
||||
ImageFileManager manager = new ImageFileManager();
|
||||
manager.getImageFileInfoById(Util.getIntValue(file));
|
||||
manager.getImageFileType();
|
||||
InputStream inputStream = manager.getInputStream();
|
||||
// 姓名+工号+开始日期(合同)
|
||||
zipOutputStream.putNextEntry(new ZipEntry(lastname + workcode + htksrq + getFileSuffix(manager.getImageFileName())));
|
||||
int length;
|
||||
while ((length = inputStream.read(buffer)) > 0) {
|
||||
zipOutputStream.write(buffer, 0, length);
|
||||
}
|
||||
inputStream.close();
|
||||
zipOutputStream.closeEntry();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
zipOutputStream.close();
|
||||
returnMap.put("zipFilename", zipFilename);
|
||||
returnMap.put("outPutPath", outPutPath);
|
||||
} catch (IOException e) {
|
||||
new BaseBean().writeLog(e);
|
||||
throw new CustomizeRunTimeException(e);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件名后缀
|
||||
*
|
||||
* @param sourceName
|
||||
* @return
|
||||
*/
|
||||
private String getFileSuffix(String sourceName) {
|
||||
if (StringUtils.isBlank(sourceName) || !sourceName.contains(".")) {
|
||||
return "";
|
||||
}
|
||||
return sourceName.substring(sourceName.lastIndexOf('.'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,636 @@
|
|||
package com.engine.shuzhi.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.shuzhi.service.SzDataCenterService;
|
||||
import com.ibm.db2.jcc.am.sg;
|
||||
import com.time.util.DateUtil;
|
||||
import weaver.conn.BatchRecordSet;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 类的详细说明
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
|
||||
public class SzDataCenterServiceImpl extends Service implements SzDataCenterService {
|
||||
@Override
|
||||
public Map<String, Object> updateResume(Map<String, Object> params, User user) {
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
String id = Util.null2String(params.get("id"));
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
//###################起始数据#######################
|
||||
|
||||
//候选人姓名
|
||||
String field001 = "";
|
||||
//性别
|
||||
String field002 = "";
|
||||
//年龄
|
||||
String field008 = "";
|
||||
//身份证号
|
||||
String field004 = "";
|
||||
//手机号码
|
||||
String field005 = "";
|
||||
//民族
|
||||
String field051 = "";
|
||||
//应聘企业
|
||||
String field037 = "";
|
||||
//最高学历
|
||||
String field052 = "";
|
||||
//专业
|
||||
String field053 = "";
|
||||
//毕业院校
|
||||
String field054 = "";
|
||||
//意向岗位
|
||||
String field007 = "";
|
||||
//简历状态
|
||||
String field010 = "";
|
||||
|
||||
//######################基础数据#########################
|
||||
//曾用名
|
||||
String field015 = "";
|
||||
//英文名
|
||||
String field016 = "";
|
||||
//国家地区
|
||||
String field017 = "";
|
||||
//所属国籍
|
||||
String field018 = "";
|
||||
//其他证件类型
|
||||
String field019 = "";
|
||||
//其他证件号码
|
||||
String field020 = "";
|
||||
//政治面貌
|
||||
String field038 = "";
|
||||
//籍贯(省份+市/县名)
|
||||
String field021 = "";
|
||||
//户籍城市(省份+市/县名)
|
||||
String field022 = "";
|
||||
//户籍地址(具体到门牌号)
|
||||
String field023 = "";
|
||||
//户口性质
|
||||
String field024 = "";
|
||||
//现居住地(具体到门牌号)
|
||||
String field025 = "";
|
||||
//首次参加工作日期
|
||||
String field026 = "";
|
||||
//个人邮箱
|
||||
String field027 = "";
|
||||
//婚姻状况
|
||||
String field029 = "";
|
||||
//生育状况
|
||||
String field030 = "";
|
||||
//血型
|
||||
String field028 = "";
|
||||
//健康状况
|
||||
String field039 = "";
|
||||
//出生日期
|
||||
String csrq = "";
|
||||
//属相
|
||||
String field062 = "";
|
||||
//身高
|
||||
String field063 = "";
|
||||
//体重
|
||||
String field064 = "";
|
||||
//是否为内部推荐
|
||||
String field067 = "";
|
||||
//推荐人
|
||||
String field066 = "";
|
||||
//工资卡卡号
|
||||
String field031 = "";
|
||||
//工资卡开户支行
|
||||
String field040 = "";
|
||||
|
||||
//###############亲属信息 edc_uf_table185_dt1##################
|
||||
//亲属姓名
|
||||
String field001dt1 = "";
|
||||
//亲属关系
|
||||
String field006dt1 = "";
|
||||
//联系方式
|
||||
String field003dt1 = "";
|
||||
//联系人地址
|
||||
String field004dt1 = "";
|
||||
//是否紧急联系人
|
||||
String field005dt1 = "";
|
||||
|
||||
//###############教育经历 edc_uf_table185_dt3##################
|
||||
//毕业院校
|
||||
String field001dt3 = "";
|
||||
//毕业专业
|
||||
String field002dt3 = "";
|
||||
//开始日期
|
||||
String field003dt3 = "";
|
||||
//结束日期
|
||||
String field004dt3 = "";
|
||||
//学历
|
||||
String field008dt3 = "";
|
||||
//学习形式
|
||||
String field006dt3 = "";
|
||||
//学位类型
|
||||
String field007dt3 = "";
|
||||
|
||||
//###############工作经历 edc_uf_table185_dt2##################
|
||||
//起止日期(x年x月-x年x月)
|
||||
String field001dt2 = "";
|
||||
//上家工作单位名称
|
||||
String field002dt2 = "";
|
||||
//上家工作单位职务
|
||||
String field003dt2 = "";
|
||||
//工作地点
|
||||
String field004dt2 = "";
|
||||
//证明人及联系方式
|
||||
String field005dt2 = "";
|
||||
|
||||
//###############证书列表 edc_uf_table185_dt4##################
|
||||
//证书名称
|
||||
String field001dt4 = "";
|
||||
//发证机关
|
||||
String field003dt4 = "";
|
||||
//发证日期
|
||||
String field004dt4 = "";
|
||||
//证书有效期
|
||||
String field005dt4 = "";
|
||||
|
||||
|
||||
String sql = "select field001,field002,field008,field004,field005,field051,field037,field052,field053,field054,field007,field010," +
|
||||
"field015,field016,field017,field018,field019,field020,field038,field021,field022,field023,field024,field025,field026," +
|
||||
"field027,field029,field030,field028,field039,csrq,field062,field063,field064,field067,field066,field031,field040 from edc_uf_table185 where id = '" + id + "'";
|
||||
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001 = rs.getString("field001");
|
||||
field002 = rs.getString("field002");
|
||||
field008 = rs.getString("field008");
|
||||
field004 = rs.getString("field004");
|
||||
field005 = rs.getString("field005");
|
||||
field051 = rs.getString("field051");
|
||||
field037 = rs.getString("field037");
|
||||
field052 = rs.getString("field052");
|
||||
field053 = rs.getString("field053");
|
||||
field054 = rs.getString("field054");
|
||||
field007 = rs.getString("field007");
|
||||
field010 = rs.getString("field010");
|
||||
field015 = rs.getString("field015");
|
||||
field016 = rs.getString("field016");
|
||||
field017 = rs.getString("field017");
|
||||
field018 = rs.getString("field018");
|
||||
field019 = rs.getString("field019");
|
||||
field020 = rs.getString("field020");
|
||||
field038 = rs.getString("field038");
|
||||
field021 = rs.getString("field021");
|
||||
field022 = rs.getString("field022");
|
||||
field023 = rs.getString("field023");
|
||||
field024 = rs.getString("field024");
|
||||
field025 = rs.getString("field025");
|
||||
field026 = rs.getString("field026");
|
||||
field027 = rs.getString("field027");
|
||||
field029 = rs.getString("field029");
|
||||
field030 = rs.getString("field030");
|
||||
field028 = rs.getString("field028");
|
||||
field039 = rs.getString("field039");
|
||||
csrq = rs.getString("csrq");
|
||||
|
||||
//属相
|
||||
field062 = rs.getString("field062");
|
||||
//身高
|
||||
field063 = rs.getString("field063");
|
||||
//体重
|
||||
field064 = rs.getString("field064");
|
||||
//是否为内部推荐
|
||||
field067 = rs.getString("field067");
|
||||
//推荐人
|
||||
field066 = rs.getString("field066");
|
||||
field031 = rs.getString("field031");
|
||||
field040 = rs.getString("field040");
|
||||
}
|
||||
|
||||
//亲属信息
|
||||
List<Map<String, Object>> qsxx = new ArrayList<>();
|
||||
//教育经历
|
||||
List<Map<String, Object>> jyjl = new ArrayList<>();
|
||||
//工作经历
|
||||
List<Map<String, Object>> gzjl = new ArrayList<>();
|
||||
//证书列表
|
||||
List<Map<String, Object>> zslb = new ArrayList<>();
|
||||
|
||||
|
||||
sql = "select field001,field006,field003,field004,field005 from edc_uf_table185_dt1 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt1 = rs.getString("field001");
|
||||
field006dt1 = rs.getString("field006");
|
||||
field003dt1 = rs.getString("field003");
|
||||
field004dt1 = rs.getString("field004");
|
||||
field005dt1 = rs.getString("field005");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt1);
|
||||
map.put("field006", field006dt1);
|
||||
map.put("field003", field003dt1);
|
||||
map.put("field004", field004dt1);
|
||||
map.put("field005", field005dt1);
|
||||
qsxx.add(map);
|
||||
}
|
||||
|
||||
|
||||
sql = "select field001,field002,field003,field004,field008,field006,field007 from edc_uf_table185_dt3 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt3 = rs.getString("field001");
|
||||
field002dt3 = rs.getString("field002");
|
||||
field003dt3 = rs.getString("field003");
|
||||
field004dt3 = rs.getString("field004");
|
||||
field008dt3 = rs.getString("field008");
|
||||
field006dt3 = rs.getString("field006");
|
||||
field007dt3 = rs.getString("field007");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt3);
|
||||
map.put("field002", field002dt3);
|
||||
map.put("field003", field003dt3);
|
||||
map.put("field004", field004dt3);
|
||||
map.put("field008", field008dt3);
|
||||
map.put("field006", field006dt3);
|
||||
map.put("field007", field007dt3);
|
||||
jyjl.add(map);
|
||||
}
|
||||
|
||||
|
||||
sql = "select field001,field002,field003,field004,field005 from edc_uf_table185_dt2 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt2 = rs.getString("field001");
|
||||
field002dt2 = rs.getString("field002");
|
||||
field003dt2 = rs.getString("field003");
|
||||
field004dt2 = rs.getString("field004");
|
||||
field005dt2 = rs.getString("field005");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt2);
|
||||
map.put("field002", field002dt2);
|
||||
map.put("field003", field003dt2);
|
||||
map.put("field004", field004dt2);
|
||||
map.put("field005", field005dt2);
|
||||
gzjl.add(map);
|
||||
}
|
||||
|
||||
sql = "select field001,field003,field004,field005 from edc_uf_table185_dt4 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt4 = rs.getString("field001");
|
||||
field003dt4 = rs.getString("field003");
|
||||
field004dt4 = rs.getString("field004");
|
||||
field005dt4 = rs.getString("field005");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt4);
|
||||
map.put("field003", field003dt4);
|
||||
map.put("field004", field004dt4);
|
||||
map.put("field005", field005dt4);
|
||||
zslb.add(map);
|
||||
}
|
||||
|
||||
|
||||
//更新简历中心(edc_uf_table160) 基础数据 //更具手机号
|
||||
String edcid = "";
|
||||
sql = "select id from edc_uf_table160 where field005 = '" + field005 + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
edcid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
boolean jlflag = updateEdcInfo(field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field010, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, csrq, field062, field063, field064, field067, field066, field031, field040, edcid, qsxx, jyjl, gzjl, zslb);
|
||||
|
||||
|
||||
//更新待入职模板(uf_drztzbd) 基础数据 明细数据
|
||||
boolean rzflag = false;
|
||||
|
||||
String ufid = "";
|
||||
sql = "select id from uf_drztzbd where sjhm = '" + field005 + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
ufid = rs.getString("id");
|
||||
}
|
||||
|
||||
rzflag = updateUfInfo(field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, csrq, field062, field063, field064, field067, field066, field031, field040, ufid, qsxx, jyjl, gzjl, zslb);
|
||||
|
||||
|
||||
res.put("jlflag", jlflag);
|
||||
res.put("rzflag", rzflag);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean updateEdcInfo(String field001, String field002, String field008, String field004, String field005, String field051, String field037, String field052, String field053, String field054, String field007, String field010, String field015, String field016, String field017, String field018, String field019, String field020, String field038, String field021, String field022, String field023, String field024, String field025, String field026, String field027, String field029, String field030, String field028, String field039, String csrq, String field062, String field063, String field064, String field067, String field066, String field031, String field040, String edcid, List<Map<String, Object>> qsxx, List<Map<String, Object>> jyjl, List<Map<String, Object>> gzjl, List<Map<String, Object>> zslb) {
|
||||
boolean flag = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String formmodeid = bb.getPropValue("dataCenter_config", "edc_formmodeid");
|
||||
|
||||
if ("".equals(edcid)) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
int modedatacreater = 1;
|
||||
int modedatacreatertype = 0;
|
||||
String modedatacreatedate = DateUtil.getCurrentTime("yyyy-MM-dd");
|
||||
String modedatacreatetime = DateUtil.getCurrentTime("HH:mm:ss");
|
||||
|
||||
|
||||
sql = "insert into edc_uf_table160 (field001,field002,field008,field004,field005,field013,field011,xl,zy,byyx,field007,field010,zym, ywm, gjdq, szgj, qtzjlx, qtzjhm, zzmm, jgsfsxm, hjcshjcssfsxm, hjdzjtdmph, hkxz, xjzd, sccjgzrq, gryx, hyzk, syzk, xx, jkzk, csrq, zx, sg, tz, sfwnbrytj, tjr, gzkkh, gzkkhzx,modeuuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field010, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, csrq, field062, field063, field064, field067, field066, field031, field040, uuid, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime);
|
||||
|
||||
|
||||
if (flag) {
|
||||
sql = "select id from edc_uf_table160 where modeuuid = '" + uuid + "'";
|
||||
rs.execute(sql);
|
||||
rs.next();
|
||||
String billid = rs.getString("id");
|
||||
edcid = billid;
|
||||
ModeRightInfo modeRightInfo = new ModeRightInfo();
|
||||
modeRightInfo.editModeDataShare(modedatacreater, Integer.parseInt(formmodeid), Integer.parseInt(billid));
|
||||
}
|
||||
|
||||
} else {
|
||||
sql = "update edc_uf_table160 set field001 = ?,field002 = ?,field008 = ?,field004 = ?,field005 = ?,field013 = ?,field011 = ?,xl = ?,zy = ?,byyx = ?,field007 = ?,field010 = ?,zym = ?, ywm = ?, gjdq = ?, szgj = ?, qtzjlx = ?, qtzjhm = ?, zzmm = ?, jgsfsxm = ?, hjcshjcssfsxm = ?, hjdzjtdmph = ?, hkxz = ?, xjzd = ?, sccjgzrq = ?, gryx = ?, hyzk = ?, syzk = ?, xx = ?, jkzk = ?, csrq = ?, zx = ?, sg = ?, tz = ?, sfwnbrytj = ?, tjr = ?, gzkkh = ?, gzkkhzx = ? where id = ?";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field010, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, csrq, field062, field063, field064, field067, field066, field031, field040, edcid);
|
||||
}
|
||||
|
||||
if (!"".equals(edcid)) {
|
||||
|
||||
sql = "delete from edc_uf_table160_dt1 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from edc_uf_table160_dt2 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from edc_uf_table160_dt3 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from edc_uf_table160_dt4 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
BatchRecordSet batchRecordSet = new BatchRecordSet();
|
||||
|
||||
//亲属信息
|
||||
List<List<Object>> qsxxlist = new ArrayList<>();
|
||||
for (int i = 0; i < qsxx.size(); i++) {
|
||||
Map<String, Object> map = qsxx.get(i);
|
||||
String field001dt1 = (String) map.get("field001");
|
||||
String field006dt1 = (String) map.get("field006");
|
||||
String field003dt1 = (String) map.get("field003");
|
||||
String field004dt1 = (String) map.get("field004");
|
||||
String field005dt1 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt1);
|
||||
list.add(field006dt1);
|
||||
list.add(field003dt1);
|
||||
list.add(field004dt1);
|
||||
list.add(field005dt1);
|
||||
qsxxlist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt1 (mainid,qzxm,qzgx,lxfs,lxrgzdw,sfjjlxr) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, qsxxlist);
|
||||
|
||||
//教育经历
|
||||
List<List<Object>> jyjllist = new ArrayList<>();
|
||||
for (int i = 0; i < jyjl.size(); i++) {
|
||||
Map<String, Object> map = jyjl.get(i);
|
||||
|
||||
String field001dt3 = (String) map.get("field001");
|
||||
String field002dt3 = (String) map.get("field002");
|
||||
String field003dt3 = (String) map.get("field003");
|
||||
String field004dt3 = (String) map.get("field004");
|
||||
String field008dt3 = (String) map.get("field008");
|
||||
String field006dt3 = (String) map.get("field006");
|
||||
String field007dt3 = (String) map.get("field007");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt3);
|
||||
list.add(field002dt3);
|
||||
list.add(field003dt3);
|
||||
list.add(field004dt3);
|
||||
list.add(field008dt3);
|
||||
list.add(field006dt3);
|
||||
list.add(field007dt3);
|
||||
jyjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt2 (mainid,byyx,byzy,ksrq,jsrq,xl,xxxs,xwlx) values (?,?,?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, jyjllist);
|
||||
|
||||
//工作经历
|
||||
List<List<Object>> gzjllist = new ArrayList<>();
|
||||
for (int i = 0; i < gzjl.size(); i++) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String field001dt2 = (String) map.get("field001");
|
||||
String field002dt2 = (String) map.get("field002");
|
||||
String field003dt2 = (String) map.get("field003");
|
||||
String field004dt2 = (String) map.get("field004");
|
||||
String field005dt2 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt2);
|
||||
list.add(field002dt2);
|
||||
list.add(field003dt2);
|
||||
list.add(field004dt2);
|
||||
list.add(field005dt2);
|
||||
gzjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt3 (mainid,qzrqxnxyxnxy,sjgzdwmc,sjgzdwzw,gzdd,zmrjlxfs) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, gzjllist);
|
||||
|
||||
//证书列表
|
||||
List<List<Object>> zslblist = new ArrayList<>();
|
||||
for (int i = 0; i < zslb.size(); i++) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String field001dt4 = (String) map.get("field001");
|
||||
String field003dt4 = (String) map.get("field003");
|
||||
String field004dt4 = (String) map.get("field004");
|
||||
String field005dt4 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt4);
|
||||
list.add(field003dt4);
|
||||
list.add(field004dt4);
|
||||
list.add(field005dt4);
|
||||
zslblist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt4 (mainid,zsmc,fzjg,fzrq,zsyxq) values (?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, zslblist);
|
||||
}
|
||||
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
private boolean updateUfInfo(String field001, String field002, String field008, String field004, String field005, String field051, String field037, String field052, String field053, String field054, String field007, String field015, String field016, String field017, String field018, String field019, String field020, String field038, String field021, String field022, String field023, String field024, String field025, String field026, String field027, String field029, String field030, String field028, String field039, String csrq, String field062, String field063, String field064, String field067, String field066, String field031, String field040, String ufid, List<Map<String, Object>> qsxx, List<Map<String, Object>> jyjl, List<Map<String, Object>> gzjl, List<Map<String, Object>> zslb) {
|
||||
|
||||
boolean flag = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String formmodeid = bb.getPropValue("dataCenter_config", "uf_formmodeid");
|
||||
|
||||
if ("".equals(ufid)) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
int modedatacreater = 1;
|
||||
int modedatacreatertype = 0;
|
||||
String modedatacreatedate = DateUtil.getCurrentTime("yyyy-MM-dd");
|
||||
String modedatacreatetime = DateUtil.getCurrentTime("HH:mm:ss");
|
||||
|
||||
sql = "insert into uf_drztzbd (xm,xb,nl,sfzh,sjhm,mz,szqy,dyxl,zy,byyx,yxgw,zym,ywm,gjdq,szgj,zjlx,zjhm,zzmm,jgxxsxxs,hjcs,hjdz,hkxz,xjdz,cjgzsj,gryx,sfyh,sfyy,xx,jkzk,csrq,zx,sg,tz,sfwnbtj,tjr,gzkkh,gzkkhx,modeuuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, csrq, field062, field063, field064, field067, field066, field031, field040, uuid, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime);
|
||||
|
||||
if (flag) {
|
||||
sql = "select id from uf_drztzbd where modeuuid = '" + uuid + "'";
|
||||
rs.execute(sql);
|
||||
rs.next();
|
||||
String billid = rs.getString("id");
|
||||
ufid = billid;
|
||||
ModeRightInfo modeRightInfo = new ModeRightInfo();
|
||||
modeRightInfo.editModeDataShare(modedatacreater, Integer.parseInt(formmodeid), Integer.parseInt(billid));
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
sql = "update uf_drztzbd set xm = ?,xb = ?,nl = ?,sfzh = ?,sjhm = ?,mz = ?,szqy = ?,dyxl = ?,zy = ?,byyx = ?,yxgw = ?,zym = ?,ywm = ?,gjdq = ?,szgj = ?,zjlx = ?,zjhm = ?,zzmm = ?,jgxxsxxs = ?,hjcs = ?,hjdz = ?,hkxz = ?,xjdz = ?,cjgzsj = ?,gryx = ?,sfyh = ?,sfyy = ?,xx = ?,jkzk = ?,csrq = ?,zx = ?,sg = ?,tz = ?,sfwnbtj = ?,tjr = ?,gzkkh = ?,gzkkhx = ? where id = ?";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, csrq, field062, field063, field064, field067, field066, field031, field040, ufid);
|
||||
}
|
||||
|
||||
|
||||
//操作明细表数据
|
||||
if (!"".equals(ufid)) {
|
||||
sql = "delete from uf_drztzbd_dt1 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from uf_drztzbd_dt4 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from uf_drztzbd_dt3 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from uf_drztzbd_dt5 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
BatchRecordSet batchRecordSet = new BatchRecordSet();
|
||||
|
||||
//亲属信息
|
||||
List<List<Object>> qsxxlist = new ArrayList<>();
|
||||
for (int i = 0; i < qsxx.size(); i++) {
|
||||
Map<String, Object> map = qsxx.get(i);
|
||||
String field001dt1 = (String) map.get("field001");
|
||||
String field006dt1 = (String) map.get("field006");
|
||||
String field003dt1 = (String) map.get("field003");
|
||||
String field004dt1 = (String) map.get("field004");
|
||||
String field005dt1 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt1);
|
||||
list.add(field006dt1);
|
||||
list.add(field003dt1);
|
||||
list.add(field004dt1);
|
||||
list.add(field005dt1);
|
||||
qsxxlist.add(list);
|
||||
}
|
||||
sql = "insert into uf_drztzbd_dt1 (mainid,xm,qzgx,nl,lxfs,sfjjlxr) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, qsxxlist);
|
||||
|
||||
//教育经历
|
||||
List<List<Object>> jyjllist = new ArrayList<>();
|
||||
for (int i = 0; i < jyjl.size(); i++) {
|
||||
Map<String, Object> map = jyjl.get(i);
|
||||
|
||||
String field001dt3 = (String) map.get("field001");
|
||||
String field002dt3 = (String) map.get("field002");
|
||||
String field003dt3 = (String) map.get("field003");
|
||||
String field004dt3 = (String) map.get("field004");
|
||||
String field008dt3 = (String) map.get("field008");
|
||||
String field006dt3 = (String) map.get("field006");
|
||||
String field007dt3 = (String) map.get("field007");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt3);
|
||||
list.add(field002dt3);
|
||||
list.add(field003dt3);
|
||||
list.add(field004dt3);
|
||||
list.add(field008dt3);
|
||||
list.add(field006dt3);
|
||||
list.add(field007dt3);
|
||||
jyjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into uf_drztzbd_dt4 (mainid,qzsj,zgxlbyzy,zgxljykssj,zgxljyjssj,xl,xxxs,xwlx) values (?,?,?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, jyjllist);
|
||||
|
||||
//工作经历 uf_drztzbd_dt3
|
||||
List<List<Object>> gzjllist = new ArrayList<>();
|
||||
for (int i = 0; i < gzjl.size(); i++) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String field001dt2 = (String) map.get("field001");
|
||||
String field002dt2 = (String) map.get("field002");
|
||||
String field003dt2 = (String) map.get("field003");
|
||||
String field004dt2 = (String) map.get("field004");
|
||||
String field005dt2 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt2);
|
||||
list.add(field002dt2);
|
||||
list.add(field003dt2);
|
||||
list.add(field004dt2);
|
||||
list.add(field005dt2);
|
||||
gzjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into uf_drztzbd_dt3 (mainid,qzrq,jzdw,gw,gzdd,zmrjlxfs) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, gzjllist);
|
||||
|
||||
//证书列表
|
||||
List<List<Object>> zslblist = new ArrayList<>();
|
||||
for (int i = 0; i < zslb.size(); i++) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String field001dt4 = (String) map.get("field001");
|
||||
String field003dt4 = (String) map.get("field003");
|
||||
String field004dt4 = (String) map.get("field004");
|
||||
String field005dt4 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt4);
|
||||
list.add(field003dt4);
|
||||
list.add(field004dt4);
|
||||
list.add(field005dt4);
|
||||
zslblist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into uf_drztzbd_dt5 (mainid,zsmc,fzjg,fzsj,zsyxq) values (?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, zslblist);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,696 @@
|
|||
package com.engine.shuzhi.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.shuzhi.service.SzResumeCenterService;
|
||||
import com.time.util.DateUtil;
|
||||
import weaver.conn.BatchRecordSet;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 类的详细说明
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
|
||||
public class SzResumeCenterServiceImpl extends Service implements SzResumeCenterService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getResumeInfo(Map<String, Object> params) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
JSONObject res = new JSONObject();
|
||||
RecordSet rs = new RecordSet();
|
||||
String mobile = Util.null2String(params.get("mobile"));
|
||||
boolean flag = false;
|
||||
String xm = "";
|
||||
String xb = "";
|
||||
String age = "";
|
||||
String cardno = "";
|
||||
String mz = "";
|
||||
String ypqy = "";
|
||||
String gw = "";
|
||||
|
||||
String sql = "select field001 as xm,field002 as xb,field008 as age,field004 as cardno,field013 as mz,field011 as ypqy,field007 as gw " +
|
||||
" from edc_uf_table160 where field005 = '"+mobile+"'";
|
||||
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
flag = true;
|
||||
xm = Util.null2String(rs.getString("xm"));
|
||||
xb = getFildName("edc_uf_table160","field002",Util.null2String(rs.getString("xb")));
|
||||
age = Util.null2String(rs.getString("age"));
|
||||
cardno = Util.null2String(rs.getString("cardno"));
|
||||
mz = getFildName("edc_uf_table160","field013",Util.null2String(rs.getString("mz")));
|
||||
ypqy = getFildName("edc_uf_table160","field011",Util.null2String(rs.getString("ypqy")));
|
||||
gw = Util.null2String(rs.getString("gw"));
|
||||
|
||||
res.put("xm",xm);
|
||||
res.put("xb",xb);
|
||||
res.put("age",age);
|
||||
res.put("cardno",cardno);
|
||||
res.put("mz",mz);
|
||||
res.put("ypqy",ypqy);
|
||||
res.put("gw",gw);
|
||||
}
|
||||
|
||||
|
||||
result.put("flag",flag);
|
||||
result.put("data",res);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private String getFildName(String tablename,String fieldname,String value){
|
||||
String selectname = "";
|
||||
if("".equals(value)){
|
||||
return selectname;
|
||||
}
|
||||
String sql = " select c.selectname from workflow_billfield a, workflow_bill b,workflow_selectitem c where a.billid=b.id and c.fieldid=a.id and b.tablename='"+tablename+"' and a.fieldname='"+fieldname+"' and c.selectvalue='" + value + "'";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
selectname = Util.null2String(rs.getString("selectname"));
|
||||
}
|
||||
return selectname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateResume(Map<String, Object> params) {
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
String id = Util.null2String(params.get("id"));
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
//###################起始数据#######################
|
||||
|
||||
//候选人姓名
|
||||
String field001 = "";
|
||||
//性别
|
||||
String field002 = "";
|
||||
//年龄
|
||||
String field008 = "";
|
||||
//身份证号
|
||||
String field004 = "";
|
||||
//手机号码
|
||||
String field005 = "";
|
||||
//民族
|
||||
String field051 = "";
|
||||
//应聘企业
|
||||
String field037 = "";
|
||||
//最高学历
|
||||
String field052 = "";
|
||||
//专业
|
||||
String field053 = "";
|
||||
//毕业院校
|
||||
String field054 = "";
|
||||
//意向岗位
|
||||
String field007 = "";
|
||||
//简历状态
|
||||
String field010 = "";
|
||||
|
||||
//######################基础数据#########################
|
||||
//曾用名
|
||||
String field015 = "";
|
||||
//英文名
|
||||
String field016 = "";
|
||||
//国家地区
|
||||
String field017 = "";
|
||||
//所属国籍
|
||||
String field018 = "";
|
||||
//其他证件类型
|
||||
String field019 = "";
|
||||
//其他证件号码
|
||||
String field020 = "";
|
||||
//政治面貌
|
||||
String field038 = "";
|
||||
//籍贯(省份+市/县名)
|
||||
String field021 = "";
|
||||
//户籍城市(省份+市/县名)
|
||||
String field022 = "";
|
||||
//户籍地址(具体到门牌号)
|
||||
String field023 = "";
|
||||
//户口性质
|
||||
String field024 = "";
|
||||
//现居住地(具体到门牌号)
|
||||
String field025 = "";
|
||||
//首次参加工作日期
|
||||
String field026 = "";
|
||||
//个人邮箱
|
||||
String field027 = "";
|
||||
//婚姻状况
|
||||
String field029 = "";
|
||||
//生育状况
|
||||
String field030 = "";
|
||||
//血型
|
||||
String field028 = "";
|
||||
//健康状况
|
||||
String field039 = "";
|
||||
//出生日期
|
||||
String field061 = "";
|
||||
//属相
|
||||
String field062 = "";
|
||||
//身高
|
||||
String field063 = "";
|
||||
//体重
|
||||
String field064 = "";
|
||||
//是否为内部推荐
|
||||
String field067 = "";
|
||||
//推荐人
|
||||
String field066 = "";
|
||||
//工资卡卡号
|
||||
String field031 = "";
|
||||
//工资卡开户支行
|
||||
String field040 = "";
|
||||
|
||||
//###############亲属信息 edc_uf_table185_dt1##################
|
||||
//亲属姓名
|
||||
String field001dt1 = "";
|
||||
//亲属关系
|
||||
String field006dt1 = "";
|
||||
//联系方式
|
||||
String field003dt1 = "";
|
||||
//联系人地址
|
||||
String field004dt1 = "";
|
||||
//是否紧急联系人
|
||||
String field005dt1 = "";
|
||||
|
||||
//###############教育经历 edc_uf_table185_dt3##################
|
||||
//毕业院校
|
||||
String field001dt3 = "";
|
||||
//毕业专业
|
||||
String field002dt3 = "";
|
||||
//开始日期
|
||||
String field003dt3 = "";
|
||||
//结束日期
|
||||
String field004dt3 = "";
|
||||
//学历
|
||||
String field008dt3 = "";
|
||||
//学习形式
|
||||
String field006dt3 = "";
|
||||
//学位类型
|
||||
String field007dt3 = "";
|
||||
|
||||
//###############工作经历 edc_uf_table185_dt2##################
|
||||
//起止日期(x年x月-x年x月)
|
||||
String field001dt2 = "";
|
||||
//上家工作单位名称
|
||||
String field002dt2 = "";
|
||||
//上家工作单位职务
|
||||
String field003dt2 = "";
|
||||
//工作地点
|
||||
String field004dt2 = "";
|
||||
//证明人及联系方式
|
||||
String field005dt2 = "";
|
||||
|
||||
//###############证书列表 edc_uf_table185_dt4##################
|
||||
//证书名称
|
||||
String field001dt4 = "";
|
||||
//发证机关
|
||||
String field003dt4 = "";
|
||||
//发证日期
|
||||
String field004dt4 = "";
|
||||
//证书有效期
|
||||
String field005dt4 = "";
|
||||
|
||||
|
||||
String sql = "select field001,field002,field008,field004,field005,field051,field037,field052,field053,field054,field007,field010," +
|
||||
"field015,field016,field017,field018,field019,field020,field038,field021,field022,field023,field024,field025,field026," +
|
||||
"field027,field029,field030,field028,field039,field061,field062,field063,field064,field067,field066,field031,field040 from edc_uf_table185 where id = '" + id + "'";
|
||||
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001 = rs.getString("field001");
|
||||
field002 = rs.getString("field002");
|
||||
field008 = rs.getString("field008");
|
||||
field004 = rs.getString("field004");
|
||||
field005 = rs.getString("field005");
|
||||
field051 = rs.getString("field051");
|
||||
field037 = rs.getString("field037");
|
||||
field052 = rs.getString("field052");
|
||||
field053 = rs.getString("field053");
|
||||
field054 = rs.getString("field054");
|
||||
field007 = rs.getString("field007");
|
||||
field010 = rs.getString("field010");
|
||||
field015 = rs.getString("field015");
|
||||
field016 = rs.getString("field016");
|
||||
field017 = rs.getString("field017");
|
||||
field018 = rs.getString("field018");
|
||||
field019 = rs.getString("field019");
|
||||
field020 = rs.getString("field020");
|
||||
field038 = rs.getString("field038");
|
||||
field021 = rs.getString("field021");
|
||||
field022 = rs.getString("field022");
|
||||
field023 = rs.getString("field023");
|
||||
field024 = rs.getString("field024");
|
||||
field025 = rs.getString("field025");
|
||||
field026 = rs.getString("field026");
|
||||
field027 = rs.getString("field027");
|
||||
field029 = rs.getString("field029");
|
||||
field030 = rs.getString("field030");
|
||||
field028 = rs.getString("field028");
|
||||
field039 = rs.getString("field039");
|
||||
field061 = rs.getString("field061");
|
||||
|
||||
//属相
|
||||
field062 = rs.getString("field062");
|
||||
//身高
|
||||
field063 = rs.getString("field063");
|
||||
//体重
|
||||
field064 = rs.getString("field064");
|
||||
//是否为内部推荐
|
||||
field067 = rs.getString("field067");
|
||||
//推荐人
|
||||
field066 = rs.getString("field066");
|
||||
field031 = rs.getString("field031");
|
||||
field040 = rs.getString("field040");
|
||||
}
|
||||
|
||||
//亲属信息
|
||||
List<Map<String, Object>> qsxx = new ArrayList<>();
|
||||
//教育经历
|
||||
List<Map<String, Object>> jyjl = new ArrayList<>();
|
||||
//工作经历
|
||||
List<Map<String, Object>> gzjl = new ArrayList<>();
|
||||
//证书列表
|
||||
List<Map<String, Object>> zslb = new ArrayList<>();
|
||||
|
||||
|
||||
sql = "select field001,field006,field003,field004,field005 from edc_uf_table185_dt1 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt1 = rs.getString("field001");
|
||||
field006dt1 = rs.getString("field006");
|
||||
field003dt1 = rs.getString("field003");
|
||||
field004dt1 = rs.getString("field004");
|
||||
field005dt1 = rs.getString("field005");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt1);
|
||||
map.put("field006", field006dt1);
|
||||
map.put("field003", field003dt1);
|
||||
map.put("field004", field004dt1);
|
||||
map.put("field005", field005dt1);
|
||||
qsxx.add(map);
|
||||
}
|
||||
|
||||
|
||||
sql = "select field001,field002,field003,field004,field008,field006,field007 from edc_uf_table185_dt3 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt3 = rs.getString("field001");
|
||||
field002dt3 = rs.getString("field002");
|
||||
field003dt3 = rs.getString("field003");
|
||||
field004dt3 = rs.getString("field004");
|
||||
field008dt3 = rs.getString("field008");
|
||||
field006dt3 = rs.getString("field006");
|
||||
field007dt3 = rs.getString("field007");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt3);
|
||||
map.put("field002", field002dt3);
|
||||
map.put("field003", field003dt3);
|
||||
map.put("field004", field004dt3);
|
||||
map.put("field008", field008dt3);
|
||||
map.put("field006", field006dt3);
|
||||
map.put("field007", field007dt3);
|
||||
jyjl.add(map);
|
||||
}
|
||||
|
||||
|
||||
sql = "select field001,field002,field003,field004,field005 from edc_uf_table185_dt2 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt2 = rs.getString("field001");
|
||||
field002dt2 = rs.getString("field002");
|
||||
field003dt2 = rs.getString("field003");
|
||||
field004dt2 = rs.getString("field004");
|
||||
field005dt2 = rs.getString("field005");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt2);
|
||||
map.put("field002", field002dt2);
|
||||
map.put("field003", field003dt2);
|
||||
map.put("field004", field004dt2);
|
||||
map.put("field005", field005dt2);
|
||||
gzjl.add(map);
|
||||
}
|
||||
|
||||
sql = "select field001,field003,field004,field005 from edc_uf_table185_dt4 where mainid = '" + id + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
field001dt4 = rs.getString("field001");
|
||||
field003dt4 = rs.getString("field003");
|
||||
field004dt4 = rs.getString("field004");
|
||||
field005dt4 = rs.getString("field005");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("field001", field001dt4);
|
||||
map.put("field003", field003dt4);
|
||||
map.put("field004", field004dt4);
|
||||
map.put("field005", field005dt4);
|
||||
zslb.add(map);
|
||||
}
|
||||
|
||||
|
||||
//更新简历中心(edc_uf_table160) 基础数据 //更具手机号
|
||||
String edcid = "";
|
||||
sql = "select id from edc_uf_table160 where field005 = '" + field005 + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
edcid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
boolean jlflag = updateEdcInfo(field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field010, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, field061, field062, field063, field064, field067, field066, field031, field040, edcid, qsxx, jyjl, gzjl, zslb);
|
||||
|
||||
|
||||
//更新待入职模板(uf_drztzbd) 基础数据 明细数据
|
||||
|
||||
|
||||
String ufid = "";
|
||||
sql = "select id from uf_drztzbd where sjhm = '" + field005 + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
ufid = rs.getString("id");
|
||||
}
|
||||
|
||||
boolean rzflag = updateUfInfo(field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, field061, field062, field063, field064, field067, field066, field031, field040, ufid, qsxx, jyjl, gzjl, zslb);
|
||||
|
||||
|
||||
res.put("jlflag", jlflag);
|
||||
res.put("rzflag", rzflag);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean updateEdcInfo(String field001, String field002, String field008, String field004, String field005, String field051, String field037, String field052, String field053, String field054, String field007, String field010, String field015, String field016, String field017, String field018, String field019, String field020, String field038, String field021, String field022, String field023, String field024, String field025, String field026, String field027, String field029, String field030, String field028, String field039, String field061, String field062, String field063, String field064, String field067, String field066, String field031, String field040, String edcid, List<Map<String, Object>> qsxx, List<Map<String, Object>> jyjl, List<Map<String, Object>> gzjl, List<Map<String, Object>> zslb) {
|
||||
boolean flag = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String formmodeid = bb.getPropValue("dataCenter_config", "edc_formmodeid");
|
||||
|
||||
if ("".equals(edcid)) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
int modedatacreater = 1;
|
||||
int modedatacreatertype = 0;
|
||||
String modedatacreatedate = DateUtil.getCurrentTime("yyyy-MM-dd");
|
||||
String modedatacreatetime = DateUtil.getCurrentTime("HH:mm:ss");
|
||||
|
||||
|
||||
sql = "insert into edc_uf_table160 (field001,field002,field008,field004,field005,field013,field011,xl,zy,byyx,field007,field010,zym, ywm, gjdq, szgj, qtzjlx, qtzjhm, zzmm, jgsfsxm, hjcshjcssfsxm, hjdzjtdmph, hkxz, xjzd, sccjgzrq, gryx, hyzk, syzk, xx, jkzk, csrq, zx, sg, tz, sfwnbrytj, tjr, gzkkh, gzkkhzx,modeuuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field010, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, field061, field062, field063, field064, field067, field066, field031, field040, uuid, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime);
|
||||
|
||||
|
||||
if (flag) {
|
||||
sql = "select id from edc_uf_table160 where modeuuid = '" + uuid + "'";
|
||||
rs.execute(sql);
|
||||
rs.next();
|
||||
String billid = rs.getString("id");
|
||||
edcid = billid;
|
||||
ModeRightInfo modeRightInfo = new ModeRightInfo();
|
||||
modeRightInfo.editModeDataShare(modedatacreater, Integer.parseInt(formmodeid), Integer.parseInt(billid));
|
||||
}
|
||||
|
||||
} else {
|
||||
sql = "update edc_uf_table160 set field001 = ?,field002 = ?,field008 = ?,field004 = ?,field005 = ?,field013 = ?,field011 = ?,xl = ?,zy = ?,byyx = ?,field007 = ?,field010 = ?,zym = ?, ywm = ?, gjdq = ?, szgj = ?, qtzjlx = ?, qtzjhm = ?, zzmm = ?, jgsfsxm = ?, hjcshjcssfsxm = ?, hjdzjtdmph = ?, hkxz = ?, xjzd = ?, sccjgzrq = ?, gryx = ?, hyzk = ?, syzk = ?, xx = ?, jkzk = ?, csrq = ?, zx = ?, sg = ?, tz = ?, sfwnbrytj = ?, tjr = ?, gzkkh = ?, gzkkhzx = ? where id = ?";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field010, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, field061, field062, field063, field064, field067, field066, field031, field040, edcid);
|
||||
}
|
||||
|
||||
if (!"".equals(edcid)) {
|
||||
|
||||
sql = "delete from edc_uf_table160_dt1 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from edc_uf_table160_dt2 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from edc_uf_table160_dt3 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from edc_uf_table160_dt4 where mainid = '" + edcid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
BatchRecordSet batchRecordSet = new BatchRecordSet();
|
||||
|
||||
//亲属信息
|
||||
List<List<Object>> qsxxlist = new ArrayList<>();
|
||||
for (int i = 0; i < qsxx.size(); i++) {
|
||||
Map<String, Object> map = qsxx.get(i);
|
||||
String field001dt1 = (String) map.get("field001");
|
||||
String field006dt1 = (String) map.get("field006");
|
||||
String field003dt1 = (String) map.get("field003");
|
||||
String field004dt1 = (String) map.get("field004");
|
||||
String field005dt1 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt1);
|
||||
list.add(field006dt1);
|
||||
list.add(field003dt1);
|
||||
list.add(field004dt1);
|
||||
list.add(field005dt1);
|
||||
qsxxlist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt1 (mainid,qzxm,qzgx,lxfs,lxrgzdw,sfjjlxr) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, qsxxlist);
|
||||
|
||||
//教育经历
|
||||
List<List<Object>> jyjllist = new ArrayList<>();
|
||||
for (int i = 0; i < jyjl.size(); i++) {
|
||||
Map<String, Object> map = jyjl.get(i);
|
||||
|
||||
String field001dt3 = (String) map.get("field001");
|
||||
String field002dt3 = (String) map.get("field002");
|
||||
String field003dt3 = (String) map.get("field003");
|
||||
String field004dt3 = (String) map.get("field004");
|
||||
String field008dt3 = (String) map.get("field008");
|
||||
String field006dt3 = (String) map.get("field006");
|
||||
String field007dt3 = (String) map.get("field007");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt3);
|
||||
list.add(field002dt3);
|
||||
list.add(field003dt3);
|
||||
list.add(field004dt3);
|
||||
list.add(field008dt3);
|
||||
list.add(field006dt3);
|
||||
list.add(field007dt3);
|
||||
jyjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt2 (mainid,byyx,byzy,ksrq,jsrq,xl,xxxs,xwlx) values (?,?,?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, jyjllist);
|
||||
|
||||
//工作经历
|
||||
List<List<Object>> gzjllist = new ArrayList<>();
|
||||
for (int i = 0; i < gzjl.size(); i++) {
|
||||
Map<String, Object> map = gzjl.get(i);
|
||||
String field001dt2 = (String) map.get("field001");
|
||||
String field002dt2 = (String) map.get("field002");
|
||||
String field003dt2 = (String) map.get("field003");
|
||||
String field004dt2 = (String) map.get("field004");
|
||||
String field005dt2 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt2);
|
||||
list.add(field002dt2);
|
||||
list.add(field003dt2);
|
||||
list.add(field004dt2);
|
||||
list.add(field005dt2);
|
||||
gzjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt3 (mainid,qzrqxnxyxnxy,sjgzdwmc,sjgzdwzw,gzdd,zmrjlxfs) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, gzjllist);
|
||||
|
||||
//证书列表
|
||||
List<List<Object>> zslblist = new ArrayList<>();
|
||||
for (int i = 0; i < zslb.size(); i++) {
|
||||
Map<String, Object> map = zslb.get(i);
|
||||
String field001dt4 = (String) map.get("field001");
|
||||
String field003dt4 = (String) map.get("field003");
|
||||
String field004dt4 = (String) map.get("field004");
|
||||
String field005dt4 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(edcid);
|
||||
list.add(field001dt4);
|
||||
list.add(field003dt4);
|
||||
list.add(field004dt4);
|
||||
list.add(field005dt4);
|
||||
zslblist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into edc_uf_table160_dt4 (mainid,zsmc,fzjg,fzrq,zsyxq) values (?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, zslblist);
|
||||
}
|
||||
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
private boolean updateUfInfo(String field001, String field002, String field008, String field004, String field005, String field051, String field037, String field052, String field053, String field054, String field007, String field015, String field016, String field017, String field018, String field019, String field020, String field038, String field021, String field022, String field023, String field024, String field025, String field026, String field027, String field029, String field030, String field028, String field039, String field061, String field062, String field063, String field064, String field067, String field066, String field031, String field040, String ufid, List<Map<String, Object>> qsxx, List<Map<String, Object>> jyjl, List<Map<String, Object>> gzjl, List<Map<String, Object>> zslb) {
|
||||
|
||||
boolean flag = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String formmodeid = bb.getPropValue("dataCenter_config", "uf_formmodeid");
|
||||
|
||||
if ("".equals(ufid)) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
int modedatacreater = 1;
|
||||
int modedatacreatertype = 0;
|
||||
String modedatacreatedate = DateUtil.getCurrentTime("yyyy-MM-dd");
|
||||
String modedatacreatetime = DateUtil.getCurrentTime("HH:mm:ss");
|
||||
|
||||
sql = "insert into uf_drztzbd (xm,xb,nl,sfzh,sjhm,mz,szqy,dyxl,zy,byyx,yxgw,zym,ywm,gjdq,szgj,zjlx,zjhm,zzmm,jgxxsxxs,hjcs,hjdz,hkxz,xjdz,cjgzsj,gryx,sfyh,sfyy,xx,jkzk,csrq,zx,sg,tz,sfwnbtj,tjr,gzkkh,gzkkhx,modeuuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, field061, field062, field063, field064, field067, field066, field031, field040, uuid, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime);
|
||||
|
||||
if (flag) {
|
||||
sql = "select id from uf_drztzbd where modeuuid = '" + uuid + "'";
|
||||
rs.execute(sql);
|
||||
rs.next();
|
||||
String billid = rs.getString("id");
|
||||
ufid = billid;
|
||||
ModeRightInfo modeRightInfo = new ModeRightInfo();
|
||||
modeRightInfo.editModeDataShare(modedatacreater, Integer.parseInt(formmodeid), Integer.parseInt(billid));
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
sql = "update uf_drztzbd set xm = ?,xb = ?,nl = ?,sfzh = ?,sjhm = ?,mz = ?,szqy = ?,dyxl = ?,zy = ?,byyx = ?,yxgw = ?,zym = ?,ywm = ?,gjdq = ?,szgj = ?,zjlx = ?,zjhm = ?,zzmm = ?,jgxxsxxs = ?,hjcs = ?,hjdz = ?,hkxz = ?,xjdz = ?,cjgzsj = ?,gryx = ?,sfyh = ?,sfyy = ?,xx = ?,jkzk = ?,csrq = ?,zx = ?,sg = ?,tz = ?,sfwnbtj = ?,tjr = ?,gzkkh = ?,gzkkhx = ? where id = ?";
|
||||
flag = rs.executeUpdate(sql, field001, field002, field008, field004, field005, field051, field037, field052, field053, field054, field007, field015, field016, field017, field018, field019, field020, field038, field021, field022, field023, field024, field025, field026, field027, field029, field030, field028, field039, field061, field062, field063, field064, field067, field066, field031, field040, ufid);
|
||||
}
|
||||
|
||||
|
||||
//操作明细表数据
|
||||
if (!"".equals(ufid)) {
|
||||
sql = "delete from uf_drztzbd_dt1 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from uf_drztzbd_dt4 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from uf_drztzbd_dt3 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "delete from uf_drztzbd_dt5 where mainid = '" + ufid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
BatchRecordSet batchRecordSet = new BatchRecordSet();
|
||||
|
||||
//亲属信息
|
||||
List<List<Object>> qsxxlist = new ArrayList<>();
|
||||
for (int i = 0; i < qsxx.size(); i++) {
|
||||
Map<String, Object> map = qsxx.get(i);
|
||||
String field001dt1 = (String) map.get("field001");
|
||||
String field006dt1 = (String) map.get("field006");
|
||||
String field003dt1 = (String) map.get("field003");
|
||||
String field004dt1 = (String) map.get("field004");
|
||||
String field005dt1 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt1);
|
||||
list.add(field006dt1);
|
||||
list.add(field003dt1);
|
||||
list.add(field004dt1);
|
||||
list.add(field005dt1);
|
||||
qsxxlist.add(list);
|
||||
}
|
||||
sql = "insert into uf_drztzbd_dt1 (mainid,xm,qzgx,nl,lxfs,sfjjlxr) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, qsxxlist);
|
||||
|
||||
//教育经历
|
||||
List<List<Object>> jyjllist = new ArrayList<>();
|
||||
for (int i = 0; i < jyjl.size(); i++) {
|
||||
Map<String, Object> map = jyjl.get(i);
|
||||
|
||||
String field001dt3 = (String) map.get("field001");
|
||||
String field002dt3 = (String) map.get("field002");
|
||||
String field003dt3 = (String) map.get("field003");
|
||||
String field004dt3 = (String) map.get("field004");
|
||||
String field008dt3 = (String) map.get("field008");
|
||||
String field006dt3 = (String) map.get("field006");
|
||||
String field007dt3 = (String) map.get("field007");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt3);
|
||||
list.add(field002dt3);
|
||||
list.add(field003dt3);
|
||||
list.add(field004dt3);
|
||||
list.add(field008dt3);
|
||||
list.add(field006dt3);
|
||||
list.add(field007dt3);
|
||||
jyjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into uf_drztzbd_dt4 (mainid,qzsj,zgxlbyzy,jykssj,jyjssj,xl,xxxs,xwlx) values (?,?,?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, jyjllist);
|
||||
|
||||
//工作经历 uf_drztzbd_dt3
|
||||
List<List<Object>> gzjllist = new ArrayList<>();
|
||||
for (int i = 0; i < gzjl.size(); i++) {
|
||||
Map<String, Object> map = gzjl.get(i);
|
||||
String field001dt2 = (String) map.get("field001");
|
||||
String field002dt2 = (String) map.get("field002");
|
||||
String field003dt2 = (String) map.get("field003");
|
||||
String field004dt2 = (String) map.get("field004");
|
||||
String field005dt2 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt2);
|
||||
list.add(field002dt2);
|
||||
list.add(field003dt2);
|
||||
list.add(field004dt2);
|
||||
list.add(field005dt2);
|
||||
gzjllist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into uf_drztzbd_dt3 (mainid,qzrq,jzdw,gw,gzdd,zmrjlxfs) values (?,?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, gzjllist);
|
||||
|
||||
//证书列表
|
||||
List<List<Object>> zslblist = new ArrayList<>();
|
||||
for (int i = 0; i < zslb.size(); i++) {
|
||||
Map<String, Object> map = zslb.get(i);
|
||||
String field001dt4 = (String) map.get("field001");
|
||||
String field003dt4 = (String) map.get("field003");
|
||||
String field004dt4 = (String) map.get("field004");
|
||||
String field005dt4 = (String) map.get("field005");
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(ufid);
|
||||
list.add(field001dt4);
|
||||
list.add(field003dt4);
|
||||
list.add(field004dt4);
|
||||
list.add(field005dt4);
|
||||
zslblist.add(list);
|
||||
}
|
||||
|
||||
sql = "insert into uf_drztzbd_dt5 (mainid,zsmc,fzjg,fzsj,zsyxq) values (?,?,?,?,?)";
|
||||
batchRecordSet.executeBatchSql(sql, zslblist);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.engine.shuzhi.util;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2023/2/21
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class ExceptionUtil {
|
||||
public static String getRealMessage(Throwable e) {
|
||||
while (e != null) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause == null) {
|
||||
return e.getMessage();
|
||||
}
|
||||
e = cause;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
package com.engine.shuzhi.util;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.engine.core.exception.ECException;
|
||||
import com.engine.shuzhi.exception.CustomizeRunTimeException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 请求执行器
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Slf4j
|
||||
public class ResponseResult<T, R> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final User user;
|
||||
|
||||
private final BaseBean baseBean = new BaseBean();
|
||||
|
||||
private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log"));
|
||||
|
||||
public ResponseResult(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统一返回方法
|
||||
*/
|
||||
public String run(Function<T, R> f, T t) {
|
||||
try {
|
||||
if (isLog) {
|
||||
log.info("run api , param {}", t);
|
||||
}
|
||||
return Ok(f.apply(t));
|
||||
} catch (CustomizeRunTimeException e) {
|
||||
log.error("api run fail", e);
|
||||
return Error(e.getMessage());
|
||||
} catch (ECException e) {
|
||||
log.error("api run fail", e);
|
||||
Throwable cause = e.getCause();
|
||||
return Error(cause.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("api run fail", e);
|
||||
return Error("系统异常!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一返回方法(有参无返回)
|
||||
*/
|
||||
public String run(Consumer<T> f, T t) {
|
||||
try {
|
||||
if (isLog) {
|
||||
log.info("run api , param {}", t);
|
||||
}
|
||||
f.accept(t);
|
||||
return Ok();
|
||||
} catch (CustomizeRunTimeException e) {
|
||||
log.error("api run fail", e);
|
||||
return Error(e.getMessage());
|
||||
} catch (ECException e) {
|
||||
log.error("api run fail", e);
|
||||
return Error(ExceptionUtil.getRealMessage(e));
|
||||
} catch (Exception e) {
|
||||
log.error("api run fail", e);
|
||||
return Error("系统异常!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统一返回方法(无参有返回)
|
||||
*/
|
||||
public String run(Supplier<R> f) {
|
||||
try {
|
||||
if (isLog) {
|
||||
log.info("run api");
|
||||
}
|
||||
return Ok(f.get());
|
||||
} catch (CustomizeRunTimeException e) {
|
||||
log.error("api run fail", e);
|
||||
return Error(e.getMessage());
|
||||
} catch (ECException e) {
|
||||
log.error("api run fail", e);
|
||||
Throwable cause = e.getCause();
|
||||
return Error(cause.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("api run fail", e);
|
||||
return Error("系统异常!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String getJsonString(Object apidatas) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
return mapper.writeValueAsString(apidatas);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 成功返回
|
||||
*/
|
||||
private String Ok() {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
apidatas.put("status", true);
|
||||
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 成功返回
|
||||
*/
|
||||
private String Ok(R r) {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
apidatas.put("status", true);
|
||||
apidatas.put("data", r);
|
||||
String success = getJsonString(apidatas);
|
||||
if (isLog) {
|
||||
log.info("run salary api success return {}", success);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 失败返回
|
||||
*/
|
||||
private static String Error(String message) {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
apidatas.put("status", false);
|
||||
apidatas.put("errormsg", message);
|
||||
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系统异常失败返回
|
||||
*/
|
||||
private static String Error(String message, Exception e) {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
apidatas.put("status", false);
|
||||
apidatas.put("errormsg", message);
|
||||
apidatas.put("error", e.getMessage());
|
||||
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package com.engine.shuzhi.web;
|
||||
|
||||
import com.alipay.oceanbase.jdbc.StringUtils;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.shuzhi.service.SzBatchExportService;
|
||||
import com.engine.shuzhi.service.impl.SzBatchExportServiceImpl;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class SzBatchExportController {
|
||||
|
||||
public SzBatchExportService getService(User user) {
|
||||
return ServiceUtil.getService(SzBatchExportServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/resource/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response resourceExport(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("ids") String ids) {
|
||||
List<Long> idList = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(ids)) {
|
||||
idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
||||
Map<String, Object> map = getService(user).downloadResourceFile(idList);
|
||||
String zipFilename = Util.null2String(map.get("zipFilename"));
|
||||
String outPutPath = Util.null2String(map.get("outPutPath"));
|
||||
try {
|
||||
zipFilename = URLEncoder.encode(zipFilename, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
java.nio.file.Path path = Paths.get(outPutPath);
|
||||
StreamingOutput output = outputStream -> {
|
||||
byte[] data = Files.readAllBytes(path);
|
||||
outputStream.write(data);
|
||||
outputStream.flush();
|
||||
};
|
||||
response.setContentType("application/octet-stream");
|
||||
return Response.ok(output).header("Content-disposition", "attachment;filename=" + zipFilename).header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/contract/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response contractExport(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("ids") String ids) {
|
||||
List<Long> idList = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(ids)) {
|
||||
idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
||||
Map<String, Object> map = getService(user).downloadContractFile(idList);
|
||||
String zipFilename = Util.null2String(map.get("zipFilename"));
|
||||
String outPutPath = Util.null2String(map.get("outPutPath"));
|
||||
try {
|
||||
zipFilename = URLEncoder.encode(zipFilename, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
java.nio.file.Path path = Paths.get(outPutPath);
|
||||
StreamingOutput output = outputStream -> {
|
||||
byte[] data = Files.readAllBytes(path);
|
||||
outputStream.write(data);
|
||||
outputStream.flush();
|
||||
};
|
||||
response.setContentType("application/octet-stream");
|
||||
return Response.ok(output).header("Content-disposition", "attachment;filename=" + zipFilename).header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.engine.shuzhi.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.shuzhi.service.SzDataCenterService;
|
||||
import com.engine.shuzhi.service.impl.SzDataCenterServiceImpl;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
|
||||
public class SzDataCenterController {
|
||||
public SzDataCenterService getService(User user) {
|
||||
return ServiceUtil.getService(SzDataCenterServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/updateResume")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String updateResume(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
response.setContentType("application/x-www-form-urlencoded; charset=utf-8");
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> paramMap = ParamUtil.request2Map(request);
|
||||
apidatas = this.getService(user).updateResume(paramMap, user);
|
||||
apidatas.put("status", "1");
|
||||
} catch (Exception e) {
|
||||
apidatas.put("status", "-1");
|
||||
apidatas.put("error", e.getMessage());
|
||||
new BaseBean().writeLog("updateResume: ", e);
|
||||
}
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.engine.shuzhi.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.shuzhi.service.SzResumeCenterService;
|
||||
import com.engine.shuzhi.service.impl.SzResumeCenterServiceImpl;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/6/26
|
||||
*/
|
||||
|
||||
public class SzResumeController {
|
||||
public SzResumeCenterService getService() {
|
||||
return ServiceUtil.getService(SzResumeCenterServiceImpl.class);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getResumeInfo")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String getResumeInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
response.setContentType("application/x-www-form-urlencoded; charset=utf-8");
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
try {
|
||||
Map<String, Object> paramMap = ParamUtil.request2Map(request);
|
||||
|
||||
apidatas = this.getService().getResumeInfo(paramMap);
|
||||
apidatas.put("status", "1");
|
||||
} catch (Exception e) {
|
||||
apidatas.put("status", "-1");
|
||||
apidatas.put("error", e.getMessage());
|
||||
new BaseBean().writeLog("getResumeInfo: ", e);
|
||||
}
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/updateResume")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String updateResume(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
response.setContentType("application/x-www-form-urlencoded; charset=utf-8");
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
try {
|
||||
Map<String, Object> paramMap = ParamUtil.request2Map(request);
|
||||
apidatas = this.getService().updateResume(paramMap);
|
||||
apidatas.put("status", "1");
|
||||
} catch (Exception e) {
|
||||
apidatas.put("status", "-1");
|
||||
apidatas.put("error", e.getMessage());
|
||||
new BaseBean().writeLog("updateResume: ", e);
|
||||
}
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,557 @@
|
|||
package weaver.hrm.pm.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject ;
|
||||
import weaver.conn.RecordSet ;
|
||||
import weaver.general.Util ;
|
||||
import weaver.general.BaseBean ;
|
||||
import weaver.general.MD5 ;
|
||||
import org.apache.http.client.methods.HttpRequestBase ;
|
||||
import org.apache.commons.collections.MapUtils ;
|
||||
import java.io.IOException ;
|
||||
import org.apache.http.client.methods.HttpPost ;
|
||||
import org.apache.http.entity.StringEntity ;
|
||||
import org.apache.http.Consts ;
|
||||
import org.apache.http.impl.client.CloseableHttpClient ;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse ;
|
||||
import org.apache.http.HttpEntity ;
|
||||
import org.apache.http.util.EntityUtils ;
|
||||
import org.apache.http.StatusLine ;
|
||||
import javax.net.ssl.SSLContext ;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory ;
|
||||
import org.apache.http.config.Registry ;
|
||||
import org.apache.http.config.RegistryBuilder ;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory ;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory ;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier ;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager ;
|
||||
import org.apache.http.impl.client.HttpClients ;
|
||||
import java.security.NoSuchAlgorithmException ;
|
||||
import java.security.KeyManagementException ;
|
||||
import javax.net.ssl.X509TrustManager ;
|
||||
import java.security.cert.CertificateException ;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import javax.net.ssl.TrustManager ;
|
||||
import org.apache.commons.lang3.StringUtils ;
|
||||
import java.util.* ;
|
||||
import com.alibaba.fastjson.JSON ;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @description:人员入职
|
||||
* @author:xuxy
|
||||
* @createTime: 2024/10/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class SyndeliUserRzAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
BaseBean log = new BaseBean();
|
||||
String path = "/v2.0/employee";
|
||||
String url = "http://v2-api.delicloud.com" + path;
|
||||
//获取主表数据
|
||||
Map mainInfo = getMainInfo(requestInfo);
|
||||
log.writeLog("入职流程主表信息:mainInfo:{}",mainInfo);
|
||||
//此处获取主表字段信息
|
||||
String sfzh = Util.null2String(mainInfo.get("sfzh"));//id
|
||||
log.writeLog("-UpdateHrmOrgInfo-主表数据是:" + sfzh);
|
||||
try {
|
||||
|
||||
String key = bb.getPropValue("deliCloud", "key");
|
||||
String secret = bb.getPropValue("deliCloud", "secret");
|
||||
log.writeLog("key:" + key + "</br>");
|
||||
log.writeLog("secret:" + secret + "</br>");
|
||||
|
||||
if (StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)) {
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path, key, secret, sjc);
|
||||
|
||||
log.writeLog("sjc:" + sjc + "</br>");
|
||||
log.writeLog("appSig:" + appSig + "</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
Map<String, String> userMap = getUserData(sfzh);
|
||||
String workcode = Util.null2String(userMap.get("workcode"));
|
||||
String lastname = Util.null2String(userMap.get("lastname"));
|
||||
String mobile = Util.null2String(userMap.get("mobile"));
|
||||
String deptcode = Util.null2String(userMap.get("departmentcode"));
|
||||
String deptname = Util.null2String(userMap.get("departmentname"));
|
||||
String deptid = Util.null2String(userMap.get("departmentid"));
|
||||
String subcompanyid1 = Util.null2String(userMap.get("subcompanyid1"));
|
||||
|
||||
log.writeLog("workcode:" + workcode + "</br>");
|
||||
log.writeLog("lastname:" + lastname + "</br>");
|
||||
log.writeLog("mobile:" + mobile + "</br>");
|
||||
|
||||
log.writeLog("deptcode:" + deptcode + "</br>");
|
||||
log.writeLog("deptname:" + deptname + "</br>");
|
||||
log.writeLog("deptid:" + deptid + "</br>");
|
||||
log.writeLog("subcompanyid1:" + subcompanyid1 + "</br>");
|
||||
|
||||
int errorcount = 0;
|
||||
log.writeLog("key:" + key + "</br>");
|
||||
log.writeLog("secret:" + secret + "</br>");
|
||||
int errorcount1 = updateSubcompanyData2(subcompanyid1, key, secret);
|
||||
errorcount = errorcount + errorcount1;
|
||||
log.writeLog("errorcount1:" + errorcount1 + "</br>");
|
||||
|
||||
int errorcount2 = updateDeptData(deptid, key, secret);
|
||||
errorcount = errorcount + errorcount2;
|
||||
log.writeLog("errorcount2:" + errorcount2 + "</br>");
|
||||
|
||||
if (errorcount == 0) {
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("employee_ext_id", workcode);
|
||||
dataMap.put("name", lastname);
|
||||
dataMap.put("mobile", mobile);
|
||||
dataMap.put("employee_num", workcode);
|
||||
|
||||
List<Map<String, Object>> department_infolist = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> department_infos = new HashMap<String, Object>();
|
||||
department_infos.put("ext_id", deptcode);
|
||||
department_infos.put("title", deptname);
|
||||
department_infolist.add(department_infos);
|
||||
dataMap.put("department_infos", department_infolist);
|
||||
|
||||
log.writeLog("employee-headers:" + JSONObject.toJSONString(heads) + "</br>");
|
||||
log.writeLog("employee-body:" + JSONObject.toJSONString(dataMap) + "</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
log.writeLog("employee-response:" + back + "</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
log.writeLog("employee-code:" + code + "</br>");
|
||||
if (!"0".equals(code)) {
|
||||
errorcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getSubcompanyListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,subcompanyname,supsubcomid,subcompanycode,curlevel) as (\n" +
|
||||
" select id,subcompanyname,supsubcomid,subcompanycode,1 as level \n" +
|
||||
" from HrmSubCompany where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.subcompanyname,a.supsubcomid,a.subcompanycode,b.curlevel+1\n" +
|
||||
" from HrmSubCompany a \n" +
|
||||
//" inner join tem_table b on (a.id = b.supsubcomid)\n" +
|
||||
" inner join tem_table b on (a.supsubcomid = b.id)\n" +
|
||||
" )\n" +
|
||||
" select l.*,k.subcompanycode as supsubcompanycode from tem_table l " +
|
||||
" left join HrmSubCompany k on l.supsubcomid = k.id " ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String sup_subcomid = rs.getString("supsubcomid");
|
||||
String supsubcompanycode = rs.getString("supsubcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
map.put("supsubcomid",sup_subcomid);
|
||||
map.put("supsubcompanycode",supsubcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
if(list !=null && list.size() > 0){
|
||||
Collections.reverse(list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getDeptListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql =" with tem_table(id,departmentname,supdepid,departmentcode,subcompanyid1,curlevel) as(\n" +
|
||||
" select id,departmentname,supdepid,departmentcode,subcompanyid1,1 as level \n" +
|
||||
" from HrmDepartment where id =" + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.departmentname,a.supdepid,a.departmentcode,a.subcompanyid1,b.curlevel+1 \n" +
|
||||
" from HrmDepartment a \n" +
|
||||
" inner join tem_table b on (a.id = b.supdepid) \n" +
|
||||
" )\n" +
|
||||
" select p.*,k.departmentcode as supdeptcode,h.subcompanycode from tem_table p\n" +
|
||||
" left join HrmDepartment k on p.supdepid = k.id " +
|
||||
" left join hrmsubcompany h on h.id = p.subcompanyid1 " ;
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String sup_depid = rs.getString("supdepid");
|
||||
String supdeptcode = rs.getString("supdeptcode");
|
||||
if(StringUtils.isBlank(supdeptcode)){
|
||||
supdeptcode = subcompanycode;
|
||||
}
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("supdepid",sup_depid);
|
||||
map.put("supdeptcode",supdeptcode);
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
if(list !=null && list.size() > 0){
|
||||
Collections.reverse(list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("doPostJsonRequest:"+url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
bb.writeLog("doPostJsonRequest:"+jsonStr);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("sendRequest3333");
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
bb.writeLog("sendRequest44444");
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
bb.writeLog("sendRequest-response:" + resp + "</br>");
|
||||
HttpEntity entity = resp.getEntity();
|
||||
bb.writeLog("sendRequest-entity:" + entity + "</br>");
|
||||
result = (entity == null ? null : EntityUtils.toString((HttpEntity) entity, Consts.UTF_8));
|
||||
bb.writeLog("sendRequest-result:" + result + "</br>");
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume((HttpEntity) entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("CloseableHttpClient:"+e);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getUserData(String sfzh){
|
||||
|
||||
Map<String,String> userMap = new HashMap<String,String>();
|
||||
String workcode = "";
|
||||
String departmentid = "";
|
||||
String subcompanyid1 = "";
|
||||
String departmentcode = "";
|
||||
String lastname = "";
|
||||
String mobile = "";
|
||||
String departmentname = "";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sfzh)){
|
||||
String sql = "select t.workcode,t.departmentid,t.subcompanyid1,t.lastname,t.mobile,k.departmentcode,k.departmentname " +
|
||||
" from hrmresource t inner join hrmdepartment k on k.id = t.departmentid" +
|
||||
" where t.certificatenum = ? and t.status in (0,1,2,3) ";
|
||||
|
||||
rs.executeQuery(sql,new Object[]{sfzh});
|
||||
if(rs.next()){
|
||||
workcode = Util.null2String(rs.getString("workcode"));
|
||||
departmentid = Util.null2String(rs.getString("departmentid"));
|
||||
subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
||||
departmentcode = Util.null2String(rs.getString("departmentcode"));
|
||||
lastname = Util.null2String(rs.getString("lastname"));
|
||||
mobile = Util.null2String(rs.getString("mobile"));
|
||||
|
||||
departmentname = Util.null2String(rs.getString("departmentname"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
userMap.put("workcode",workcode);
|
||||
userMap.put("lastname",lastname);
|
||||
userMap.put("mobile",mobile);
|
||||
userMap.put("departmentcode",departmentcode);
|
||||
userMap.put("departmentname",departmentname);
|
||||
userMap.put("departmentid",departmentid);
|
||||
userMap.put("subcompanyid1",subcompanyid1);
|
||||
|
||||
return userMap;
|
||||
}
|
||||
|
||||
|
||||
public int updateSubcompanyData2(String subcompanyid1,String key,String secret){
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("updateSubcompanyData2:start" +"</br>");
|
||||
bb.writeLog("updateSubcompanyData2:subcompanyid1" +subcompanyid1+"</br>");
|
||||
bb.writeLog("updateSubcompanyData2:key" +key+"</br>");
|
||||
bb.writeLog("updateSubcompanyData2:secret" +secret+"</br>");
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
int errorcount = 0;
|
||||
List<Map<String,String>> childSubcompanyList = getSubcompanyListByParentid(subcompanyid1);
|
||||
bb.writeLog("updateSubcompanyData2:childSubcompanyList" +childSubcompanyList+"</br>");
|
||||
for(int k=0;k<childSubcompanyList.size();k++) {
|
||||
Map<String, String> childSubcompanyMap = childSubcompanyList.get(k);
|
||||
String subcompanycode = childSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = childSubcompanyMap.get("subcompanyname");
|
||||
String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode");
|
||||
bb.writeLog("updateSubcompanyData2:supsubcompanycode" +supsubcompanycode+"</br>");
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", supsubcompanycode);
|
||||
bb.writeLog("updateSubcompanyData2:dataMap" +dataMap+"</br>");
|
||||
String back = null;
|
||||
try {
|
||||
String jsonString = JSON.toJSONString(dataMap);
|
||||
bb.writeLog("updateSubcompanyData:jsonString" + jsonString + "</br>");
|
||||
back = doPostJsonRequest(url, heads, jsonString);
|
||||
bb.writeLog("updateSubcompanyData:back" + back + "</br>");
|
||||
} catch (IOException e) {
|
||||
bb.writeLog("updateSubcompanyData2:IOException" +e.getMessage()+"</br>");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
bb.writeLog("updateSubcompanyData:backObj" + backObj + "</br>");
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
if (!"0".equals(code)) {
|
||||
errorcount++;
|
||||
}
|
||||
}
|
||||
bb.writeLog("updateSubcompanyData:" + errorcount + "</br>");
|
||||
bb.writeLog("updateSubcompanyData2:end" +"</br>");
|
||||
return errorcount;
|
||||
}
|
||||
|
||||
|
||||
public int updateDeptData(String deptid,String key,String secret){
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("updateDeptData:start" +"</br>");
|
||||
bb.writeLog("updateDeptData:deptid" +deptid+"</br>");
|
||||
bb.writeLog("updateDeptData:key" +key+"</br>");
|
||||
bb.writeLog("updateDeptData:secret" +secret+"</br>");
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
int errorcount = 0;
|
||||
List<Map<String,String>> childDepartmentList = getDeptListByParentid(deptid);
|
||||
for(int k=0;k<childDepartmentList.size();k++){
|
||||
Map<String,String> childDepartmentMap = childDepartmentList.get(k);
|
||||
String departmentcode = childDepartmentMap.get("departmentcode");
|
||||
String departmentname = childDepartmentMap.get("departmentname");
|
||||
String supdeptcode = childDepartmentMap.get("supdeptcode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", supdeptcode);
|
||||
|
||||
String back = null;
|
||||
try {
|
||||
back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
} catch (IOException e) {
|
||||
bb.writeLog("updateDeptData:IOException" +e.getMessage()+"</br>");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
if (!"0".equals(code)) {
|
||||
errorcount++;
|
||||
}
|
||||
}
|
||||
bb.writeLog("updateDeptData:" + errorcount + "</br>");
|
||||
bb.writeLog("updateDeptData:end" +"</br>");
|
||||
return errorcount;
|
||||
}
|
||||
/**
|
||||
* 根据requestInfo获取主表数据
|
||||
* */
|
||||
public static Map getMainInfo(RequestInfo requestInfo){
|
||||
Map map = new HashMap();
|
||||
Property[] property = requestInfo.getMainTableInfo().getProperty();
|
||||
for (int i = 0; i < property.length; i++) {
|
||||
map.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package weaver.interfaces.shuzhi.action;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* 更新待入职生成流程的员工gh
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/7/4
|
||||
*/
|
||||
|
||||
public class PendingEmploymentModeAction implements Action {
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String tableName = requestInfo.getRequestManager().getBillTableName();
|
||||
String lcid = requestInfo.getRequestid();
|
||||
String gzdw = "";
|
||||
String sfzh = "";
|
||||
String sql = "select gzdw,sfzh from " + tableName + " where requestid = '" + lcid + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
gzdw = Util.null2String(rs.getString("gzdw"));
|
||||
sfzh = Util.null2String(rs.getString("sfzh"));
|
||||
}
|
||||
bb.writeLog("PendingEmploymentModeAction--------lcid-:" + lcid);
|
||||
bb.writeLog("PendingEmploymentModeAction--------gzdw-:" + gzdw);
|
||||
bb.writeLog("PendingEmploymentModeAction--------sfzh-:" + sfzh);
|
||||
|
||||
|
||||
if (!"".equals(lcid) && !"".equals(gzdw) && !"".equals(sfzh)) {
|
||||
|
||||
String workcode = "";
|
||||
sql = "SELECT " +
|
||||
"CASE " +
|
||||
" WHEN " +
|
||||
" MAX( workcode ) IS NULL THEN " +
|
||||
" ( " +
|
||||
" ( select subcompanycode from HrmSubCompany where id = '" + gzdw + "' ) + RIGHT ( DATEPART ( yy, GETDATE ( ) ), 2 ) + '0001' " +
|
||||
" ) ELSE cast( MAX( workcode ) AS INT ) + 1 " +
|
||||
" END AS 'workcode' " +
|
||||
" FROM " +
|
||||
" HrmResource " +
|
||||
"WHERE " +
|
||||
" workcode LIKE ( select subcompanycode from HrmSubCompany where id = '" + gzdw + "' ) + RIGHT ( DATEPART ( yy, GETDATE ( ) ), 2 ) + '%'";
|
||||
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
workcode = Util.null2String(rs.getString("workcode"));
|
||||
}
|
||||
|
||||
if (!"".equals(workcode)) {
|
||||
updateWfdata(lcid, workcode, sfzh, tableName);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateWfdata(String lcid, String workcode, String sfzh, String tableName) {
|
||||
String sql = "update " + tableName + " set gh = '" + workcode + "' where requestid = '" + lcid + "'";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "update hrmresource set workcode = '" + workcode + "' where certificatenum= '" + sfzh + "' and status != '5'";
|
||||
rs.execute(sql);
|
||||
new BaseBean().writeLog("PendingEmploymentModeAction--updateWfdata sql:" + sql);
|
||||
|
||||
// //入职确认 sfzh
|
||||
// sql = "update uf_rzgljmb set gh = '" + workcode + "' where sfzh = '" + sfzh + "'";
|
||||
// rs.execute(sql);
|
||||
//
|
||||
// ////入职确认 uf_syqglbd
|
||||
// sql = "update uf_syqglbd set gh = '" + workcode + "' where sjid = '" + lcid + "'";
|
||||
// rs.execute(sql);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
package weaver.interfaces.shuzhi.cronjob;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.Consts;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.MD5;
|
||||
import weaver.general.Util;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.IOException;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class EcologyToDelicloudUtil {
|
||||
|
||||
public void updateEmployeeResign(String userid){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String path = "/v2.0/employee/delete";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
try {
|
||||
String workcode = "";
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String sql = " select workcode from hrmresource where id = "+userid+" and status=5 ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
workcode = Util.null2String(rs.getString("workcode"));
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(workcode)){
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
|
||||
bb.writeLog("key:"+key+"</br>");
|
||||
bb.writeLog("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("employee_ext_id", workcode);
|
||||
|
||||
bb.writeLog("headers:" + JSONObject.toJSONString(heads));
|
||||
bb.writeLog("body:" + JSONObject.toJSONString(dataMap));
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String msg = backObj.getString("msg");
|
||||
bb.writeLog("code:" + code);
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog(userid+"调用delicloud接口成功");
|
||||
} else {
|
||||
bb.writeLog(userid+"调用delicloud接口失败:"+msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,275 @@
|
|||
package weaver.interfaces.shuzhi.cronjob;
|
||||
|
||||
import com.time.util.DateUtil;
|
||||
import tebie.applib.api.S;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.shuzhi.util.WorkflowUtil;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 员工关系提醒流程-计划任务
|
||||
* <p>
|
||||
* 从转正记录(uf_zzjl)、员工调动记录(uf_ddjl)、离职办理查询表单(uf_lzblcxbd),
|
||||
*
|
||||
* <p>
|
||||
* uf_zzjl:生效日期=zzrq(转正日期)、归档日期=gdrq(归档日期)
|
||||
1、生效日期小于等于归档日期,当前日期=归档日期+1天,更新人力资源表单(hrmresource)、入职管理建模表(uf_rzgljmb)
|
||||
2、生效日期大于归档日期,当前日期=生效日期,更新人力资源表单(hrmresource)、入职管理建模表(uf_rzgljmb)
|
||||
|
||||
*
|
||||
* hrmresource表:根据人员id更新status='1'
|
||||
* uf_rzgljmb表:(员工状态:ygzt,转正日期:zzrq,员工(人力资源):ygrlzy)
|
||||
* update uf_rzgljmb set ygzt = '1' , zzrq = '" + date + "' where ygrlzy = '" + userid + "'
|
||||
*
|
||||
* <p>
|
||||
* uf_ddjl:生效日期=ddrq(调动日期)、归档日期=gdrq(归档日期)
|
||||
* 1、生效日期大于归档日期,当前日期=生效日期,根据记录数据更新数据
|
||||
* 2、生效日期小于等于归档日期,当前日期=归档日期+1天,根据记录数据更新数据
|
||||
*
|
||||
* hrmresource表:根据人员id更新jobtitle(岗位)、departmentid(部门)、subcompanyid1(分部)
|
||||
* uf_rzgljmb表:(岗位名称:gwmc,职级:xl,部门:bm,公司分部:gsfb,员工(人力资源):ygrlzy)
|
||||
* update uf_rzgljmb set gwmc = '"+xgw+"' , xl = '" + zj + "' ,bm = '"+xbm+"' ,gsfb = '"+xfb+"' where ygrlzy = '" + userid + "'
|
||||
*
|
||||
* <p>
|
||||
* uf_lzblcxbd:生效日期=jhlzrq(uf_lzblcxbd_dt1 计划离职日期)、归档日期=gdrq(归档日期)
|
||||
* 1、生效日期大于归档日期,当前日期=生效日期,根据记录数据更新数据
|
||||
* 2、生效日期小于等于归档日期,当前日期=归档日期+1天,根据记录数据更新数据
|
||||
*
|
||||
* hrmresource表:根据人员id更新status='5'
|
||||
* uf_rzgljmb表:(员工状态:ygzt,离职日期:lzrq,员工(人力资源):ygrlzy)
|
||||
* update uf_rzgljmb set ygzt = '3' , lzrq = '" + date + "' where ygrlzy = '" + userid + "'
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/7/3
|
||||
*/
|
||||
|
||||
public class RelationshipReminderJob extends BaseCronJob {
|
||||
@Override
|
||||
public void execute() {
|
||||
BaseBean bb = new BaseBean();
|
||||
String workflowid = bb.getPropValue("relationship", "workflowid");
|
||||
String id = "";
|
||||
String lastname = "";
|
||||
String userid = "";
|
||||
String sxrq = "";
|
||||
String gdrq = "";
|
||||
String date = DateUtil.getCurrentTime("yyyy-MM-dd");
|
||||
|
||||
String datebefore = DateUtil.formatDate(DateUtil.getDateAfterDays(new Date(),-1),"yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
//转正记录(uf_zzjl) uf_zzjl:生效日期=zzrq(转正日期)、归档日期=gdrq(归档日期)
|
||||
String sql = "select a.id,b.lastname,a.zzry,a.zzrq,a.gdrq from uf_zzjl a left join hrmresource b on a.zzry = b.id where a.txlcid is null";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
String zt = "";
|
||||
id = Util.null2String(rs.getString("id"));
|
||||
lastname = Util.null2String(rs.getString("lastname"));
|
||||
sxrq = Util.null2String(rs.getString("zzrq"));
|
||||
gdrq = Util.null2String(rs.getString("gdrq"));
|
||||
userid = Util.null2String(rs.getString("zzry"));
|
||||
|
||||
if ("".equals(id) || "".equals(sxrq) || "".equals(userid)|| "".equals(gdrq)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (compareDateLessEquation(sxrq,gdrq) && compareDateEquation(datebefore,gdrq)) {
|
||||
//1、生效日期小于等于当前日期,当前日期 - 1 = 归档日期,更新人力资源表单(hrmresource)、入职管理建模表(uf_rzgljmb)
|
||||
zt = updateZZHrmStatus(userid, "1", sxrq);
|
||||
}
|
||||
|
||||
if(!compareDateLessEquation(sxrq,gdrq) && compareDateEquation(date,sxrq)){
|
||||
//2、生效日期大于当前日期,当前日期=生效日期,更新人力资源表单(hrmresource)、入职管理建模表(uf_rzgljmb)
|
||||
zt = updateZZHrmStatus(userid, "1", date);
|
||||
}
|
||||
|
||||
if(!"".equals(zt)){
|
||||
updateRecordData( id, zt,"uf_zzjl");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String xbm = "";
|
||||
String xgw = "";
|
||||
String zj = "";
|
||||
String xfb = "";
|
||||
//员工调动记录(uf_ddjl) uf_ddjl:生效日期=ddrq(调动日期)、归档日期=gdrq(归档日期)
|
||||
sql = " select b.id,b.nzzry,b.xbm,d.subcompanyid1,b.xgw,c.lastname,b.zj,a.ddrq,a.gdrq from uf_ddjl a left join uf_ddjl_dt1 b on a.id = b.mainid left join hrmresource c on c.id = b.nzzry left join hrmdepartment d on d.id = b.xbm where b.txlcid is null";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
String zt = "";
|
||||
id = Util.null2String(rs.getString("id"));
|
||||
lastname = Util.null2String(rs.getString("lastname"));
|
||||
sxrq = Util.null2String(rs.getString("ddrq"));
|
||||
gdrq = Util.null2String(rs.getString("gdrq"));
|
||||
userid = Util.null2String(rs.getString("nzzry"));
|
||||
xbm = Util.null2String(rs.getString("xbm"));
|
||||
xgw = Util.null2String(rs.getString("xgw"));
|
||||
zj = Util.null2String(rs.getString("zj"));
|
||||
xfb = Util.null2String(rs.getString("subcompanyid1"));
|
||||
|
||||
|
||||
if ("".equals(id) || "".equals(sxrq) || "".equals(userid)|| "".equals(gdrq)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (compareDateLessEquation(sxrq,gdrq)&&compareDateEquation(datebefore,gdrq)) {
|
||||
//2、生效日期小于等于当前日期,当前日期-1 =归档日期,根据记录数据更新数据
|
||||
//更新hrmresource表(岗位、部门)、入职管理建模表uf_rzgljmb(岗位、职级名称、部门、公司名称-分部)
|
||||
zt = updateDDHrmStatus(userid, sxrq, xgw, xbm, xfb, zj);
|
||||
}
|
||||
|
||||
if(!compareDateLessEquation(sxrq,gdrq)&&compareDateEquation(date,sxrq)){
|
||||
//1、生效日期大于当前日期,当前日期=生效日期,根据记录数据更新数据
|
||||
zt = updateDDHrmStatus(userid, date, xgw, xbm, xfb, zj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!"".equals(zt)){
|
||||
updateRecordData( id, zt,"uf_ddjl_dt1");
|
||||
}
|
||||
}
|
||||
|
||||
//uf_lzblcxbd:生效日期=jhlzrq(uf_lzblcxbd_dt1 计划离职日期)、归档日期=gdrq(归档日期)
|
||||
|
||||
sql = "select b.id,b.lzry,c.lastname,b.jhlzrq,a.gdrq from uf_lzblcxbd a left join uf_lzblcxbd_dt1 b on a.id = b.mainid left join hrmresource c on c.id = b.lzry where b.txlcid is null";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
String zt = "";
|
||||
id = Util.null2String(rs.getString("id"));
|
||||
lastname = Util.null2String(rs.getString("lastname"));
|
||||
sxrq = Util.null2String(rs.getString("jhlzrq"));
|
||||
gdrq = Util.null2String(rs.getString("gdrq"));
|
||||
userid = Util.null2String(rs.getString("lzry"));
|
||||
|
||||
if ("".equals(id) || "".equals(sxrq) || "".equals(userid)|| "".equals(gdrq)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (compareDateLessEquation(sxrq,gdrq)&&compareDateEquation(datebefore,gdrq)) {
|
||||
//2、生效日期小于等于当前日期,当前日期=归档日期+1天,根据记录数据更新数据
|
||||
zt = updateLZHrmStatus(userid, "5", sxrq);
|
||||
}
|
||||
|
||||
if(!compareDateLessEquation(sxrq,gdrq)&&compareDateEquation(date,sxrq)){
|
||||
//1、生效日期大于当前日期,当前日期=生效日期,根据记录数据更新数据
|
||||
zt = updateLZHrmStatus(userid, "5", date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!"".equals(zt)){
|
||||
updateRecordData( id, zt,"uf_lzblcxbd_dt1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//转正
|
||||
private String updateZZHrmStatus(String userid, String status, String date) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "update hrmresource set status = '" + status + "' where id = '" + userid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
sql = "update uf_rzgljmb set ygzt = '1' , zzrq = '" + date + "' where ygrlzy = '" + userid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
return "update";
|
||||
}
|
||||
|
||||
|
||||
//离职
|
||||
private String updateLZHrmStatus(String userid, String status, String date) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "update hrmresource set status = '" + status + "' where id = '" + userid + "'";
|
||||
boolean isTrue = rs.executeUpdate(sql);
|
||||
|
||||
sql = "update uf_rzgljmb set ygzt = '3' , lzrq = '" + date + "' where ygrlzy = '" + userid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
if(isTrue){
|
||||
EcologyToDelicloudUtil EcologyToDelicloudUtil = new EcologyToDelicloudUtil();
|
||||
EcologyToDelicloudUtil.updateEmployeeResign(userid);
|
||||
}
|
||||
return "update";
|
||||
}
|
||||
|
||||
//调动
|
||||
private String updateDDHrmStatus(String userid, String date, String xgw, String xbm, String xfb, String zj) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "update hrmresource set jobtitle = '" + xgw + "' ,departmentid = '"+xbm+"' ,subcompanyid1 = '"+xfb+"' where id = '" + userid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
//岗位、职级名称、部门、公司名称-分部
|
||||
sql = "update uf_rzgljmb set gwmc = '"+xgw+"' , xl = '" + zj + "' ,bm = '"+xbm+"' ,gzdw = '"+xfb+"' where ygrlzy = '" + userid + "'";
|
||||
rs.execute(sql);
|
||||
|
||||
return "update";
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 比较日期相等
|
||||
* @Param:
|
||||
* @return:
|
||||
* @Author: wangj
|
||||
*/
|
||||
private boolean compareDateEquation(String start, String end) {
|
||||
boolean flag = false;
|
||||
Date sdate = DateUtil.parseDate(start, "yyyy-MM-dd");
|
||||
Date edate = DateUtil.parseDate(end, "yyyy-MM-dd");
|
||||
if (sdate.getTime() == edate.getTime()) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 比较日期小于等于
|
||||
* @Param:
|
||||
* @return:
|
||||
* @Author: wangj
|
||||
*/
|
||||
private boolean compareDateLessEquation(String start, String end) {
|
||||
boolean flag = false;
|
||||
Date sdate = DateUtil.parseDate(start, "yyyy-MM-dd");
|
||||
Date edate = DateUtil.parseDate(end, "yyyy-MM-dd");
|
||||
if (sdate.getTime() <= edate.getTime()) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @Description: 比较日期加一天相等
|
||||
// * @Param:
|
||||
// * @return:
|
||||
// * @Author: wangj
|
||||
// */
|
||||
// private boolean compareDateOneDayEquation(String start, String end) {
|
||||
// boolean flag = false;
|
||||
// Date sdate = DateUtil.parseDate(start, "yyyy-MM-dd");
|
||||
// Date edate = DateUtil.parseDate(end, "yyyy-MM-dd");
|
||||
// if (sdate.getTime() < edate.getTime()) {
|
||||
// flag = true;
|
||||
// }
|
||||
// return flag;
|
||||
// }
|
||||
|
||||
private void updateRecordData(String id,String zt,String tablename){
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute("update "+tablename+" set txlcid = '"+zt+"' where id = '"+id+"'");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package weaver.interfaces.shuzhi.cronjob;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
* 定时更新人员简历黑名单状态
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/06/05
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class SyncBlackListJob extends BaseCronJob {
|
||||
// TODO 正式、测试表名切换
|
||||
private static final String TABLE_NAME = "edc_uf_table160";
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
new BaseBean().writeLog("######定时更新人员简历黑名单状态,任务开始######");
|
||||
RecordSet rs = new RecordSet();
|
||||
// 通过身份证号更新候选人信息台账
|
||||
String sql = "update " + TABLE_NAME + " set sfhmd = 0 where field004 in(select sfzh from uf_hmdk)";
|
||||
rs.executeUpdate(sql);
|
||||
// 通过手机号码更新候选人信息台账
|
||||
sql = "update " + TABLE_NAME + " set sfhmd = 0 where field005 in(select sjhm from uf_hmdk)";
|
||||
rs.executeUpdate(sql);
|
||||
new BaseBean().writeLog("######定时更新人员简历黑名单状态,任务结束######");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package weaver.interfaces.shuzhi.cronjob;
|
||||
|
||||
import com.engine.shuzhi.entity.po.ModeStaffPO;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 编制数据同步服务
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/06/01
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class SyncModeStaffJob extends BaseCronJob {
|
||||
private static String SPECIAL_JOB_NAME = "培训生";
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
new BaseBean().writeLog("######编制数据同步服务,任务开始######");
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql;
|
||||
// 查询培训生的岗位ID
|
||||
sql = "select id from hrmjobtitles where jobtitlename = ? ";
|
||||
Set<String> specialJobIds = new HashSet<>();
|
||||
rs.executeQuery(sql, SPECIAL_JOB_NAME);
|
||||
while (rs.next()) {
|
||||
specialJobIds.add(rs.getString("id"));
|
||||
}
|
||||
// 查询各个岗位下对应的人员
|
||||
sql = "select count(id) as num, departmentid, jobtitle from hrmresource where status < 4 group by departmentid, jobtitle";
|
||||
rs.executeQuery(sql);
|
||||
List<ModeStaffPO> modeStaffList = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
modeStaffList.add(ModeStaffPO.builder().num(rs.getString("num")).departmentid(rs.getString("departmentid")).jobtitle(rs.getString("jobtitle")).build());
|
||||
}
|
||||
|
||||
// 根据部门+岗位查询最新一个月的记录
|
||||
if ("sqlserver".equals(rs.getDBType())) {
|
||||
sql = "select top 1 id, bzrs from uf_bzxxbd where bm = ? and gw = ? order by yf desc";
|
||||
} else if ("oracle".equals(rs.getDBType())) {
|
||||
sql = "select id, bzrs from uf_bzxxbd where bm = ? and gw = ? and rownum = 1 order by yf desc";
|
||||
} else {
|
||||
sql = "select id, bzrs from uf_bzxxbd where bm = ? and gw = ? order by yf desc limit 1";
|
||||
}
|
||||
for (ModeStaffPO modeStaff : modeStaffList) {
|
||||
rs.executeQuery(sql, modeStaff.getDepartmentid(), modeStaff.getJobtitle());
|
||||
if (rs.next()) {
|
||||
String staffId = rs.getString("id");
|
||||
String staffNum = rs.getString("bzrs");
|
||||
// 岗位为培训生编制人数等于在岗人数
|
||||
modeStaff.setStaffNum(specialJobIds.contains(modeStaff.getJobtitle()) ? modeStaff.getNum().toString() : staffNum);
|
||||
rs.executeUpdate("update uf_bzxxbd set zgrs = ? ,bzrs = ? ,kbrs = ? where id = ?", modeStaff.getNum(), modeStaff.getStaffNum(), modeStaff.getLackNum(), staffId);
|
||||
}
|
||||
}
|
||||
|
||||
sql = "update uf_bzxxbd set zgrs = 0, kbrs = bzrs where zgrs is null or zgrs = 0";
|
||||
rs.execute(sql);
|
||||
new BaseBean().writeLog("######编制数据同步服务,任务结束######");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,502 @@
|
|||
package weaver.interfaces.shuzhi.cronjob;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject ;
|
||||
import weaver.conn.RecordSet ;
|
||||
import weaver.general.BaseBean ;
|
||||
import weaver.general.MD5 ;
|
||||
import org.apache.http.client.methods.HttpRequestBase ;
|
||||
import org.apache.commons.collections.MapUtils ;
|
||||
import java.io.IOException ;
|
||||
import org.apache.http.client.methods.HttpPost ;
|
||||
import org.apache.http.entity.StringEntity ;
|
||||
import org.apache.http.Consts ;
|
||||
import org.apache.http.impl.client.CloseableHttpClient ;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse ;
|
||||
import org.apache.http.HttpEntity ;
|
||||
import org.apache.http.util.EntityUtils ;
|
||||
import org.apache.http.StatusLine ;
|
||||
import javax.net.ssl.SSLContext ;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory ;
|
||||
import org.apache.http.config.Registry ;
|
||||
import org.apache.http.config.RegistryBuilder ;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory ;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory ;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier ;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager ;
|
||||
import org.apache.http.impl.client.HttpClients ;
|
||||
import java.security.NoSuchAlgorithmException ;
|
||||
import java.security.KeyManagementException ;
|
||||
import javax.net.ssl.X509TrustManager ;
|
||||
import java.security.cert.CertificateException ;
|
||||
import javax.net.ssl.TrustManager ;
|
||||
import org.apache.commons.lang3.StringUtils ;
|
||||
import java.util.* ;
|
||||
import com.alibaba.fastjson.JSON ;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author:xuxy
|
||||
* @createTime: 2023/10/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class SyndeliOrgJob extends BaseCronJob {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
BaseBean bb = new BaseBean();
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
try {
|
||||
|
||||
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
bb.writeLog("key:"+key+"</br>");
|
||||
bb.writeLog("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
bb.writeLog("sjc:"+sjc+"</br>");
|
||||
bb.writeLog("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
List<Map<String,String>> topSubcompanyList = getTopSubcompanyList();
|
||||
for(int i=0;i<topSubcompanyList.size();i++){
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompanycode = topSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = topSubcompanyMap.get("subcompanyname");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", "");
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
bb.writeLog("response:"+back+"</br>");
|
||||
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
bb.writeLog("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
bb.writeLog("kao----------------------:"+"</br>");
|
||||
for(int i=0;i<topSubcompanyList.size();i++) {
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompany_id = topSubcompanyMap.get("subcompanyid");
|
||||
bb.writeLog("subcompany_id:"+subcompany_id+"</br>");
|
||||
List<Map<String,String>> childSubcompanyList = getSubcompanyListByParentid(subcompany_id);
|
||||
bb.writeLog("分部组织长度:"+childSubcompanyList.size()+"</br>");
|
||||
for(int k=0;k<childSubcompanyList.size();k++){
|
||||
Map<String,String> childSubcompanyMap = childSubcompanyList.get(k);
|
||||
String subcompanycode = childSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = childSubcompanyMap.get("subcompanyname");
|
||||
String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", supsubcompanycode);
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> topDepartmentList = getTopDeptList();
|
||||
for(int i=0;i<topDepartmentList.size();i++){
|
||||
Map<String,String> topDepartmentMap = topDepartmentList.get(i);
|
||||
String departmentcode = topDepartmentMap.get("departmentcode");
|
||||
String departmentname = topDepartmentMap.get("departmentname");
|
||||
String subcompanycode = topDepartmentMap.get("subcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", subcompanycode);
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("top-dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
bb.writeLog("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
bb.writeLog("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<topDepartmentList.size();i++) {
|
||||
Map<String,String> topDeptMap = topDepartmentList.get(i);
|
||||
String deptid = topDeptMap.get("deptid");
|
||||
|
||||
List<Map<String,String>> childDepartmentList = getDeptListByParentid(deptid);
|
||||
for(int k=0;k<childDepartmentList.size();k++){
|
||||
Map<String,String> childDepartmentMap = childDepartmentList.get(k);
|
||||
String departmentcode = childDepartmentMap.get("departmentcode");
|
||||
String departmentname = childDepartmentMap.get("departmentname");
|
||||
String supdeptcode = childDepartmentMap.get("supdeptcode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", supdeptcode);
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
bb.writeLog("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
bb.writeLog("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> getTopSubcompanyList(){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select id,subcompanycode,subcompanyname,subcompanydesc \n" +
|
||||
" from HrmSubCompany where supsubcomid = 0 and (canceled is null or canceled = 0) " ;
|
||||
bb.writeLog("getSubcompanyListByParentid-sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String subcompany_id = rs.getString("id");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanyid",subcompany_id);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getSubcompanyListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql = " with tem_table(id,subcompanyname,supsubcomid,subcompanycode,curlevel,canceled) as (\n" +
|
||||
" select id,subcompanyname,supsubcomid,subcompanycode,1 as level,canceled \n" +
|
||||
" from HrmSubCompany where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.subcompanyname,a.supsubcomid,a.subcompanycode,b.curlevel+1,a.canceled\n" +
|
||||
" from HrmSubCompany a \n" +
|
||||
" inner join tem_table b on (a.supsubcomid = b.id)\n" +
|
||||
" )\n" +
|
||||
" select l.*,k.subcompanycode as supsubcompanycode from tem_table l " +
|
||||
" left join HrmSubCompany k on l.supsubcomid = k.id " +
|
||||
" where l.id <> "+supsubcomid +
|
||||
" and (l.canceled is null or l.canceled = 0)";
|
||||
|
||||
bb.writeLog("getSubcompanyListByParentid-sql:"+sql);
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String sup_subcomid = rs.getString("supsubcomid");
|
||||
String supsubcompanycode = rs.getString("supsubcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
map.put("supsubcomid",sup_subcomid);
|
||||
map.put("supsubcompanycode",supsubcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String,String>> getTopDeptList(){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select t.id,t.departmentcode,t.departmentname,t.subcompanyid1,h.subcompanycode\n" +
|
||||
" from HrmDepartment t\n" +
|
||||
" left join HrmSubCompany h on h.id = t.subcompanyid1\n" +
|
||||
" where t.supdepid = 0 and (t.canceled is null or t.canceled = 0) ";
|
||||
|
||||
bb.writeLog("getTopDeptList-sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String deptid = rs.getString("id");
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("deptid",deptid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getDeptListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String sql =" with tem_table(id,departmentname,supdepid,departmentcode,curlevel,canceled) as(\n" +
|
||||
" select id,departmentname,supdepid,departmentcode,1 as level,canceled \n" +
|
||||
" from HrmDepartment where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.departmentname,a.supdepid,a.departmentcode,b.curlevel+1,a.canceled \n" +
|
||||
" from HrmDepartment a \n" +
|
||||
" inner join tem_table b on (a.supdepid = b.id) \n" +
|
||||
" )\n" +
|
||||
" select p.*,k.departmentcode as supdeptcode from tem_table p\n" +
|
||||
" left join HrmDepartment k on p.supdepid = k.id " +
|
||||
" where p.id <> "+supsubcomid +"" +
|
||||
" and (p.canceled is null or p.canceled = 0)";
|
||||
|
||||
bb.writeLog("getDeptListByParentid-sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String sup_depid = rs.getString("supdepid");
|
||||
String supdeptcode = rs.getString("supdeptcode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("supdepid",sup_depid);
|
||||
map.put("supdeptcode",supdeptcode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("doPostJsonRequest-url:"+url);
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
bb.writeLog("doPostJsonRequest2");
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("sendRequest");
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("CloseableHttpClient");
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,526 @@
|
|||
package weaver.interfaces.shuzhi.cronjob;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.Consts;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.MD5;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.IOException;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author:xuxy
|
||||
* @createTime: 2023/10/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class SyndeliOrgJob4Subcompany extends BaseCronJob {
|
||||
|
||||
private String subcompanyid ;
|
||||
|
||||
public String getSubcompanyid() {
|
||||
return subcompanyid;
|
||||
}
|
||||
|
||||
public void setSubcompanyid(String subcompanyid) {
|
||||
this.subcompanyid = subcompanyid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
BaseBean bb = new BaseBean();
|
||||
String path = "/v2.0/department";
|
||||
String url = "http://v2-api.delicloud.com"+path;
|
||||
|
||||
try {
|
||||
String key = bb.getPropValue("deliCloud","key");
|
||||
String secret = bb.getPropValue("deliCloud","secret");
|
||||
bb.writeLog("key:"+key+"</br>");
|
||||
bb.writeLog("secret:"+secret+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){
|
||||
String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis());
|
||||
String appSig = getAppSigData(path,key,secret,sjc);
|
||||
|
||||
bb.writeLog("sjc:"+sjc+"</br>");
|
||||
bb.writeLog("appSig:"+appSig+"</br>");
|
||||
|
||||
Map<String, String> heads = new HashMap<String, String>();
|
||||
heads.put("App-Key", key);
|
||||
heads.put("App-Timestamp", sjc);
|
||||
heads.put("App-Sig", appSig);
|
||||
heads.put("Api-Module", "CHECKIN");
|
||||
heads.put("Api-Cmd", "checkin_query");
|
||||
|
||||
String allSubcompanyid = subcompanyid;
|
||||
List<Map<String,String>> topSubcompanyList = getTopSubcompanyList();
|
||||
bb.writeLog("topSubcompanyList:"+topSubcompanyList.size());
|
||||
for(int i=0;i<topSubcompanyList.size();i++){
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompanycode = topSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = topSubcompanyMap.get("subcompanyname");
|
||||
bb.writeLog("subcompanyname:"+subcompanyname);
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", "");
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
bb.writeLog("response:"+back+"</br>");
|
||||
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
bb.writeLog("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
bb.writeLog("kao----------------------:"+"</br>");
|
||||
for(int i=0;i<topSubcompanyList.size();i++) {
|
||||
Map<String,String> topSubcompanyMap = topSubcompanyList.get(i);
|
||||
String subcompany_id = topSubcompanyMap.get("subcompanyid");
|
||||
bb.writeLog("subcompany_id:"+subcompany_id+"</br>");
|
||||
allSubcompanyid += StringUtils.isBlank(allSubcompanyid) ? subcompany_id : ","+subcompany_id ;
|
||||
List<Map<String,String>> childSubcompanyList = getSubcompanyListByParentid(subcompany_id);
|
||||
bb.writeLog("childSubcompanyList:"+childSubcompanyList.size()+"");
|
||||
for(int k=0;k<childSubcompanyList.size();k++){
|
||||
Map<String,String> childSubcompanyMap = childSubcompanyList.get(k);
|
||||
String subcompanycode = childSubcompanyMap.get("subcompanycode");
|
||||
String subcompanyname = childSubcompanyMap.get("subcompanyname");
|
||||
String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode");
|
||||
bb.writeLog("subcompanycode:"+subcompanycode+"");
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", subcompanycode);
|
||||
dataMap.put("name", subcompanyname);
|
||||
dataMap.put("p_ext_id", supsubcompanycode);
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> topDepartmentList = getTopDeptList(allSubcompanyid);
|
||||
bb.writeLog("topDepartmentList:"+topDepartmentList.size()+"");
|
||||
for(int i=0;i<topDepartmentList.size();i++){
|
||||
Map<String,String> topDepartmentMap = topDepartmentList.get(i);
|
||||
String departmentcode = topDepartmentMap.get("departmentcode");
|
||||
String departmentname = topDepartmentMap.get("departmentname");
|
||||
String subcompanycode = topDepartmentMap.get("subcompanycode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", subcompanycode);
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("top-dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
bb.writeLog("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
bb.writeLog("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<topDepartmentList.size();i++) {
|
||||
Map<String,String> topDeptMap = topDepartmentList.get(i);
|
||||
String deptid = topDeptMap.get("deptid");
|
||||
bb.writeLog("deptid:"+deptid+"");
|
||||
List<Map<String,String>> childDepartmentList = getDeptListByParentid(deptid);
|
||||
bb.writeLog("childDepartmentList:"+childDepartmentList.size()+"");
|
||||
for(int k=0;k<childDepartmentList.size();k++){
|
||||
Map<String,String> childDepartmentMap = childDepartmentList.get(k);
|
||||
String departmentcode = childDepartmentMap.get("departmentcode");
|
||||
String departmentname = childDepartmentMap.get("departmentname");
|
||||
String supdeptcode = childDepartmentMap.get("supdeptcode");
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("department_ext_id", departmentcode);
|
||||
dataMap.put("name", departmentname);
|
||||
dataMap.put("p_ext_id", supdeptcode);
|
||||
|
||||
bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"</br>");
|
||||
bb.writeLog("dept-body:"+JSONObject.toJSONString(dataMap)+"</br>");
|
||||
|
||||
String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap));
|
||||
bb.writeLog("response:" + back);
|
||||
bb.writeLog("response:"+back+"</br>");
|
||||
JSONObject backObj = JSONObject.parseObject(back);
|
||||
String code = backObj.getString("code");
|
||||
String data = backObj.getString("data");
|
||||
bb.writeLog("code:"+code+"</br>");
|
||||
if ("0".equals(code)) {
|
||||
bb.writeLog("新接口调用成功");
|
||||
JSONObject dataObj = JSONObject.parseObject(data);
|
||||
bb.writeLog("dataObj:"+dataObj.toJSONString()+"</br>");
|
||||
} else {
|
||||
bb.writeLog("接口调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("数据异常!");
|
||||
bb.writeLog(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> getTopSubcompanyList(){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
|
||||
String where = "";
|
||||
if(StringUtils.isNotBlank(subcompanyid)){
|
||||
where = " and id in("+subcompanyid+")" ;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select id,subcompanycode,subcompanyname,subcompanydesc \n" +
|
||||
" from HrmSubCompany where supsubcomid = 0 and (canceled is null or canceled = 0) "+where ;
|
||||
bb.writeLog("getTopSubcompanyList-sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String subcompany_id = rs.getString("id");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanyid",subcompany_id);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getSubcompanyListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql = " with tem_table(id,subcompanyname,supsubcomid,subcompanycode,curlevel,canceled) as (\n" +
|
||||
" select id,subcompanyname,supsubcomid,subcompanycode,1 as level,canceled \n" +
|
||||
" from HrmSubCompany where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.subcompanyname,a.supsubcomid,a.subcompanycode,b.curlevel+1,a.canceled\n" +
|
||||
" from HrmSubCompany a \n" +
|
||||
" inner join tem_table b on (a.supsubcomid = b.id)\n" +
|
||||
" )\n" +
|
||||
" select l.*,k.subcompanycode as supsubcompanycode from tem_table l " +
|
||||
" left join HrmSubCompany k on l.supsubcomid = k.id " +
|
||||
" where l.id <> "+supsubcomid +
|
||||
" and (l.canceled is null or l.canceled = 0)";
|
||||
|
||||
bb.writeLog("getSubcompanyListByParentid-sql:"+sql);
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
String subcompanyname = rs.getString("subcompanyname");
|
||||
String sup_subcomid = rs.getString("supsubcomid");
|
||||
String supsubcompanycode = rs.getString("supsubcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
map.put("subcompanyname",subcompanyname);
|
||||
map.put("supsubcomid",sup_subcomid);
|
||||
map.put("supsubcompanycode",supsubcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String,String>> getTopDeptList(String allSubcompanyid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
|
||||
String where = "";
|
||||
if(StringUtils.isNotBlank(allSubcompanyid)){
|
||||
where = " and h.id in("+allSubcompanyid+")" ;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select t.id,t.departmentcode,t.departmentname,t.subcompanyid1,h.subcompanycode\n" +
|
||||
" from HrmDepartment t\n" +
|
||||
" left join HrmSubCompany h on h.id = t.subcompanyid1\n" +
|
||||
" where t.supdepid = 0 and (t.canceled is null or t.canceled = 0) "+ where;
|
||||
|
||||
bb.writeLog("getTopDeptList-sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String deptid = rs.getString("id");
|
||||
String subcompanycode = rs.getString("subcompanycode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("deptid",deptid);
|
||||
map.put("subcompanycode",subcompanycode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getDeptListByParentid(String supsubcomid){
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> map = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String sql =" with tem_table(id,departmentname,supdepid,departmentcode,curlevel,canceled) as(\n" +
|
||||
" select id,departmentname,supdepid,departmentcode,1 as level,canceled \n" +
|
||||
" from HrmDepartment where id = " + supsubcomid +
|
||||
" union all\n" +
|
||||
" select a.id,a.departmentname,a.supdepid,a.departmentcode,b.curlevel+1,a.canceled \n" +
|
||||
" from HrmDepartment a \n" +
|
||||
" inner join tem_table b on (a.supdepid = b.id) \n" +
|
||||
" )\n" +
|
||||
" select p.*,k.departmentcode as supdeptcode from tem_table p\n" +
|
||||
" left join HrmDepartment k on p.supdepid = k.id " +
|
||||
" where p.id <> "+supsubcomid +"" +
|
||||
" and (p.canceled is null or p.canceled = 0)";
|
||||
|
||||
bb.writeLog("getDeptListByParentid-sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String departmentcode = rs.getString("departmentcode");
|
||||
String departmentname = rs.getString("departmentname");
|
||||
String sup_depid = rs.getString("supdepid");
|
||||
String supdeptcode = rs.getString("supdeptcode");
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("departmentcode",departmentcode);
|
||||
map.put("departmentname",departmentname);
|
||||
map.put("supdepid",sup_depid);
|
||||
map.put("supdeptcode",supdeptcode);
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param path
|
||||
* @param key
|
||||
* @param sercet
|
||||
* @param sjc
|
||||
* @return
|
||||
*/
|
||||
public String getAppSigData(String path,String key,String sercet,String sjc){
|
||||
|
||||
String appSig = "";
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
MD5 md5 = new MD5();
|
||||
String all = path + sjc + key + sercet;
|
||||
String sig = md5.getMD5ofStr(all);
|
||||
bb.writeLog("sig:" + sig);
|
||||
Scanner sc = new Scanner(md5.getMD5ofStr(all));
|
||||
String str = sc.next();
|
||||
char[] arrays = str.toCharArray();
|
||||
|
||||
for (int i = 0; i < arrays.length; i++) {
|
||||
char c1 = arrays[i];
|
||||
if (c1 >= 65 && c1 <= 90) {
|
||||
char c2 = toLowerCase(c1);//如果输入是大写 ,则调用toLowerCase方法
|
||||
appSig = appSig + c2;
|
||||
} else {
|
||||
appSig = appSig + c1;
|
||||
}
|
||||
}
|
||||
bb.writeLog("appSig:" + appSig);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return appSig;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param c1
|
||||
* @return
|
||||
*/
|
||||
public static char toLowerCase(char c1){
|
||||
int a = (int) c1;//将接收到的小写字符c1转换成int类型的数据给a
|
||||
int b =a+32; //a+32得出大写写对应小写的ascll数值
|
||||
char bb = (char)b;//最后将b转换成char类型字符给bb
|
||||
return bb; //返回bb;就是返回字母小写的字符
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void prepareHeaders(HttpRequestBase httpRequest, Map<String, String> headers) {
|
||||
if (!MapUtils.isEmpty(headers)) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpRequest.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String doPostJsonRequest(String url, Map<String, String> headers, String jsonStr) throws IOException {
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("doPostJsonRequest-url:"+url);
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
prepareHeaders(httpost, headers);
|
||||
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
|
||||
entity.setContentEncoding("UTF-8");
|
||||
entity.setContentType("application/json");
|
||||
httpost.setEntity(entity);
|
||||
bb.writeLog("doPostJsonRequest2");
|
||||
return sendRequest(httpost);
|
||||
}
|
||||
|
||||
|
||||
private static String sendRequest(HttpRequestBase httpRequest) throws IOException {
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("sendRequest");
|
||||
String result = null;
|
||||
CloseableHttpClient httpclient = creteClient();
|
||||
try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) {
|
||||
HttpEntity entity = resp.getEntity();
|
||||
result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8));
|
||||
StatusLine statusLine = resp.getStatusLine();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
EntityUtils.consume(entity);
|
||||
// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static CloseableHttpClient creteClient() {
|
||||
//采用绕过验证的方式处理https请求
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("CloseableHttpClient");
|
||||
try {
|
||||
SSLContext sslcontext = createIgnoreVerifySSL();
|
||||
// 设置协议http和https对应的处理socket链接工厂的对象
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE)
|
||||
.register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE))
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
HttpClients.custom().setConnectionManager(connManager);
|
||||
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build();
|
||||
return client;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绕过验证
|
||||
*
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSLv3");
|
||||
|
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
|
||||
String paramString) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
sc.init(null, new TrustManager[]{trustManager}, null);
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package weaver.interfaces.shuzhi.util;
|
||||
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.soa.workflow.request.MainTableInfo;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
import weaver.workflow.request.RequestComInfo;
|
||||
import weaver.workflow.workflow.WorkflowComInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类的详细说明
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2023/7/3
|
||||
*/
|
||||
|
||||
public class WorkflowUtil extends BaseBean {
|
||||
/**
|
||||
* @param @param creatorId 创建⼈Id
|
||||
* @param @param workflowId 流程Id
|
||||
* @param @param requestName 请求标题
|
||||
* @param @param IsNextFlow 是否提交到下⼀节点
|
||||
* @param @param requestMap Map格式的主表数据<fieldname,fieldvalue>=<字段名称,字段值>
|
||||
* @param @return 设定⽂件
|
||||
* @return String 返回类型
|
||||
* @throws
|
||||
* @Title: WorkflowCreateByMainTableMap
|
||||
*/
|
||||
public String WorkflowCreateByMainTableMap(String creatorId, String workflowId, String requestName, String IsNextFlow, Map<String, String> requestMainMap) {
|
||||
writeLog("-----创建流程传递的参数个数--------");
|
||||
writeLog("creatorId:" + creatorId);
|
||||
writeLog("workflowId:" + workflowId);
|
||||
writeLog("requestName:" + requestName);
|
||||
writeLog("IsNextFlow:" + IsNextFlow);
|
||||
String requestid = "";
|
||||
RequestInfo requestInfo = new RequestInfo();
|
||||
requestInfo.setCreatorid(creatorId);//创建⼈Id
|
||||
requestInfo.setWorkflowid(workflowId);//⼯作流Id
|
||||
requestInfo.setDescription(requestName);//请求标题
|
||||
if (!"".equals(IsNextFlow)) {
|
||||
requestInfo.setIsNextFlow(IsNextFlow);
|
||||
}
|
||||
//主表字段
|
||||
MainTableInfo mainTableInfo = new MainTableInfo();
|
||||
Property[] propertyArray = new Property[requestMainMap.size()];
|
||||
int p = 0;
|
||||
for (Map.Entry<String, String> entry : requestMainMap.entrySet()) {
|
||||
propertyArray[p] = new Property();
|
||||
propertyArray[p].setName(Util.null2String(entry.getKey()));
|
||||
//2、其他接⼝
|
||||
propertyArray[p].setValue(Util.null2String(entry.getValue()));
|
||||
writeLog("\r\n---p=" + p + "---Key=" + entry.getKey() + "---Value = " + entry.getValue());
|
||||
p++;
|
||||
}
|
||||
writeLog("-----创建流程传递的参数个数p=" + p);
|
||||
mainTableInfo.setProperty(propertyArray);
|
||||
requestInfo.setMainTableInfo(mainTableInfo);
|
||||
RequestService service = new RequestService();
|
||||
try {
|
||||
//流程
|
||||
try {
|
||||
requestid = service.createRequest(requestInfo);//创建请求id
|
||||
} catch (Exception e) {
|
||||
writeLog("=======" + e.getMessage());
|
||||
}
|
||||
//String userId = requestInfo.getLastoperator();//请求最后的操作者
|
||||
//记录⽇志
|
||||
StringBuffer sbf = new StringBuffer("\r\n-----xwd创建⼯作流记录⽇志开始");
|
||||
WorkflowComInfo wfcif = new WorkflowComInfo();
|
||||
RequestComInfo rcif = new RequestComInfo();
|
||||
ResourceComInfo rscif = new ResourceComInfo();
|
||||
sbf.append("\r\n-----姓名:" + rscif.getLastname(rcif.getRequestCreater(requestid)));
|
||||
sbf.append("\r\n-----时间:" + rcif.getRequestCreateTime(requestid));
|
||||
sbf.append("\r\n-----创建流程:" + wfcif.getWorkflowname(workflowId));
|
||||
sbf.append("\r\n-----请求:" + rcif.getRequestname(requestid));
|
||||
sbf.append("\r\n-----请求:" + requestid);
|
||||
sbf.append("\r\n-----创建⼯作流记录⽇志结束");
|
||||
writeLog(sbf.toString());
|
||||
System.out.println("" + sbf.toString());
|
||||
} catch (Exception e) {
|
||||
writeLog("错误:" + e);
|
||||
System.out.println("错误:" + e);
|
||||
}
|
||||
return requestid;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue