diff --git a/数智制造/WEB-INF/prop/dataCenter_config.properties b/数智制造/WEB-INF/prop/dataCenter_config.properties new file mode 100644 index 0000000..9f28ea0 --- /dev/null +++ b/数智制造/WEB-INF/prop/dataCenter_config.properties @@ -0,0 +1,6 @@ +#edc_uf_table160ģid +edc_formmodeid=52 +#uf_drztzbdģid +uf_formmodeid=55 + + diff --git a/数智制造/WEB-INF/prop/deliCloud.properties b/数智制造/WEB-INF/prop/deliCloud.properties new file mode 100644 index 0000000..af0f73e --- /dev/null +++ b/数智制造/WEB-INF/prop/deliCloud.properties @@ -0,0 +1,8 @@ + +## 得力云的key +key=79e26d45aec2d152dba78419db2e622f + +## 得力云的secret +secret=hpgmkq03yzlujquiiovt2n63hqnb20d8 + + diff --git a/数智制造/WEB-INF/prop/relationship.properties b/数智制造/WEB-INF/prop/relationship.properties new file mode 100644 index 0000000..36002da --- /dev/null +++ b/数智制造/WEB-INF/prop/relationship.properties @@ -0,0 +1,4 @@ +#Աϵid +workflowid=143 + + diff --git a/数智制造/interface.suzhi/chatgptsearch_test.jsp b/数智制造/interface.suzhi/chatgptsearch_test.jsp new file mode 100644 index 0000000..28c8b31 --- /dev/null +++ b/数智制造/interface.suzhi/chatgptsearch_test.jsp @@ -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+"
"); + out.print("query:"+query+"
"); + + String host = bb.getPropValue("CHATGPT","host"); + String appid = bb.getPropValue("CHATGPT","appid"); + out.print("pubkey:"+pubkey+"
"); + out.print("host:"+host+"
"); + out.print("appid:"+appid+"
"); + 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+"
"); + rs.executeQuery(userSql); + if(rs.next()){ + loginid = Util.null2String(rs.getString("loginid")); + userid = Util.null2String(rs.getString("id")); + } + } + out.print("loginid:"+loginid+"
"); + if(StringUtils.isNotBlank(loginid) && StringUtils.isNotBlank(appid)){ + String token = getToken(host,appid,loginid); + out.print("token:"+token+"
"); + if(StringUtils.isNotBlank(token)){ + + String[] workflowArray = query.split("\\$"); + + out.print("userid:"+userid+"
"); + User user = new User(Util.getIntValue(userid)); + out.print("user:"+user.getLastname()+"
"); + String inornot = "in"; + NewRequestBiz wfBiz = new NewRequestBiz(user); + wfBiz.setNewRequestRange(WorkflowVersion.getAllVersionStringByWFIDs("")); + wfBiz.setInornot(inornot); + wfBiz.setIsmobile(false); + wfBiz.setCustomSqlWhere("");//新建流程扩展条件 + List wftypes = wfBiz.getWfInfo(""); +// out.print("wftypes:"+ JSON.toJSON(wftypes)); + for(WfType wfType : wftypes){ + List wfBeanList = wfType.getWfbeans(); + for(WfBean wfBean : wfBeanList){ + int count = 0; + String wf_name = wfBean.getName(); + String workflowid = wfBean.getId(); + for(int i=0;i"); + out.print("workflowid:"+ workflowid+"
"); + out.print("count:"+ count+"
"); + + 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()+"
"); +// String[] workflowArray = query.split("\\$"); +// for(int i=0;i"); +//// if(StringUtils.isNotBlank(workflowname)){ +//// String sql = " select id,workflowname from workflow_base where workflowname like '%"+workflowname+"%'" ; +//// out.print("sql:"+sql+"
"); +//// 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; + } +%> + diff --git a/数智制造/interface.suzhi/getResumeInfo.jsp b/数智制造/interface.suzhi/getResumeInfo.jsp new file mode 100644 index 0000000..f3f22d7 --- /dev/null +++ b/数智制造/interface.suzhi/getResumeInfo.jsp @@ -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; + } +%> + diff --git a/数智制造/interface.suzhi/getdelicloud.jsp b/数智制造/interface.suzhi/getdelicloud.jsp new file mode 100644 index 0000000..3b224b0 --- /dev/null +++ b/数智制造/interface.suzhi/getdelicloud.jsp @@ -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+"
"); + rs.executeQuery(sql,new Object[]{userid}); + if(rs.next()){ + workcode = Util.null2String(rs.getString("workcode")); + } + } + out.print("workcode:"+workcode+"
"); + + if(StringUtils.isNotBlank(workcode)){ +// String key = ""; +// String sercet = ""; +// String sqlOr = "select dlkey,dlsercet from uf_dlkqdj where bs = 'DlKqGetDayNew'"; +// out.print("sqlOr:"+sqlOr+"
"); +// 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+"
"); + out.print("secret:"+secret+"
"); + + 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+"
"); + out.print("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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 dataMap = new HashMap(); + dataMap.put("employee_ext_id", workcode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("body:"+JSONObject.toJSONString(dataMap)+"
"); + +// 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+"
"); +// JSONObject backObj = JSONObject.parseObject(back); +// String code = backObj.getString("code"); +// String data = backObj.getString("data"); +// out.print("code:"+code+"
"); +// if ("0".equals(code)) { +// bb.writeLog("新接口调用成功"); +// JSONObject dataObj = JSONObject.parseObject(data); +// out.print("dataObj:"+dataObj.toJSONString()+"
"); +// } 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +%> + diff --git a/数智制造/interface.suzhi/getdelicloud3.jsp b/数智制造/interface.suzhi/getdelicloud3.jsp new file mode 100644 index 0000000..775bd29 --- /dev/null +++ b/数智制造/interface.suzhi/getdelicloud3.jsp @@ -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+"
"); + rs.executeQuery(sql,new Object[]{userid}); + if(rs.next()){ + workcode = Util.null2String(rs.getString("workcode")); + } + } + out.print("workcode:"+workcode+"
"); + + if(StringUtils.isNotBlank(workcode)){ +// String key = ""; +// String sercet = ""; +// String sqlOr = "select dlkey,dlsercet from uf_dlkqdj where bs = 'DlKqGetDayNew'"; +// out.print("sqlOr:"+sqlOr+"
"); +// 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+"
"); + out.print("secret:"+secret+"
"); + + if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){ + + String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis()); + String all = path + sjc + key + secret; + out.print("all:" + all+"
"); + out.print("sjc:" + sjc+"
"); + MD5 md5 = new MD5(); + String sig = md5.getMD5ofStr(all); + bb.writeLog("sig:" + sig); + out.print("sig22:" + sig+"
"); + 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+"
"); + + String appSig = getAppSigData(path,key,secret,sjc); + + out.print("sjc:"+sjc+"
"); + out.print("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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 dataMap = new HashMap(); + dataMap.put("employee_ext_id", workcode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("body:"+JSONObject.toJSONString(dataMap)+"
"); + +// 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+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +%> + diff --git a/数智制造/interface.suzhi/syndeliorg.jsp b/数智制造/interface.suzhi/syndeliorg.jsp new file mode 100644 index 0000000..e3cf455 --- /dev/null +++ b/数智制造/interface.suzhi/syndeliorg.jsp @@ -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+"
"); + out.print("secret:"+secret+"
"); + + 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+"
"); + out.print("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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> topSubcompanyList = getTopSubcompanyList(where); + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompanycode = topSubcompanyMap.get("subcompanycode"); + String subcompanyname = topSubcompanyMap.get("subcompanyname"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", ""); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompanyid = topSubcompanyMap.get("subcompanyid"); + + List> childSubcompanyList = getSubcompanyListByParentid(subcompanyid); + + for(int k=0;k childSubcompanyMap = childSubcompanyList.get(k); + String subcompanycode = childSubcompanyMap.get("subcompanycode"); + String subcompanyname = childSubcompanyMap.get("subcompanyname"); + String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", supsubcompanycode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + } + + List> topDepartmentList = getTopDeptList(); + for(int i=0;i topDepartmentMap = topDepartmentList.get(i); + String departmentcode = topDepartmentMap.get("departmentcode"); + String departmentname = topDepartmentMap.get("departmentname"); + String subcompanycode = topDepartmentMap.get("subcompanycode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", subcompanycode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("top-dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + + for(int i=0;i topDeptMap = topDepartmentList.get(i); + String deptid = topDeptMap.get("deptid"); + + List> childDepartmentList = getDeptListByParentid(deptid); + for(int k=0;k childDepartmentMap = childDepartmentList.get(k); + String departmentcode = childDepartmentMap.get("departmentcode"); + String departmentname = childDepartmentMap.get("departmentname"); + String supdeptcode = childDepartmentMap.get("supdeptcode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", supdeptcode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + } + } + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + +%> + +<%! + + /*** + * + * @return + */ + public List> getTopSubcompanyList(String where){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanyid",subcompanyid); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + list.add(map); + } + return list; + } + + + public List> getSubcompanyListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + map.put("supsubcomid",sup_subcomid); + map.put("supsubcompanycode",supsubcompanycode); + list.add(map); + } + return list; + } + + + + public List> getTopDeptList(){ + List> list = new ArrayList>(); + Map 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(); + map.put("departmentcode",departmentcode); + map.put("departmentname",departmentname); + map.put("deptid",deptid); + map.put("subcompanycode",subcompanycode); + list.add(map); + } + return list; + } + + + public List> getDeptListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +%> + diff --git a/数智制造/interface.suzhi/syndeliorg2.jsp b/数智制造/interface.suzhi/syndeliorg2.jsp new file mode 100644 index 0000000..0a3d588 --- /dev/null +++ b/数智制造/interface.suzhi/syndeliorg2.jsp @@ -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+"
"); + out.print("secret:"+secret+"
"); + + 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+"
"); + out.print("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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> list = getTopSubcompanyList(); + for(int i=0;i map = list.get(i); + String subcompanyid = map.get("subcompanyid"); + String subcompanyname = map.get("subcompanyname"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanyid); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", ""); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("body:"+JSONObject.toJSONString(dataMap)+"
"); + + 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+"
"); +// JSONObject backObj = JSONObject.parseObject(back); +// String code = backObj.getString("code"); +// String data = backObj.getString("data"); +// out.print("code:"+code+"
"); +// if ("0".equals(code)) { +// bb.writeLog("新接口调用成功"); +// JSONObject dataObj = JSONObject.parseObject(data); +// out.print("dataObj:"+dataObj.toJSONString()+"
"); +// } else { +// bb.writeLog("接口调用失败"); +// out.print("接口调用失败"); +// } + } + + } + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + +%> + +<%! + + /*** + * + * @return + */ + public List> getTopSubcompanyList(){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +%> + diff --git a/数智制造/interface.suzhi/syndeliorg3.jsp b/数智制造/interface.suzhi/syndeliorg3.jsp new file mode 100644 index 0000000..6e0f5ca --- /dev/null +++ b/数智制造/interface.suzhi/syndeliorg3.jsp @@ -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+"
"); + out.print("secret:"+secret+"
"); + + 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+"
"); + out.print("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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> topSubcompanyList = getTopSubcompanyList(where); + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompanycode = topSubcompanyMap.get("subcompanycode"); + String subcompanyname = topSubcompanyMap.get("subcompanyname"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", ""); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompanyid = topSubcompanyMap.get("subcompanyid"); + + List> childSubcompanyList = getSubcompanyListByParentid(subcompanyid); + + for(int k=0;k childSubcompanyMap = childSubcompanyList.get(k); + String subcompanycode = childSubcompanyMap.get("subcompanycode"); + String subcompanyname = childSubcompanyMap.get("subcompanyname"); + String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", supsubcompanycode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + } + +// List> topDepartmentList = getTopDeptList(); +// for(int i=0;i topDepartmentMap = topDepartmentList.get(i); +// String departmentcode = topDepartmentMap.get("departmentcode"); +// String departmentname = topDepartmentMap.get("departmentname"); +// String subcompanycode = topDepartmentMap.get("subcompanycode"); +// +// Map dataMap = new HashMap(); +// dataMap.put("department_ext_id", departmentcode); +// dataMap.put("name", departmentname); +// dataMap.put("p_ext_id", subcompanycode); +// +// out.print("headers:"+JSONObject.toJSONString(heads)+"
"); +// out.print("top-dept-body:"+JSONObject.toJSONString(dataMap)+"
"); +// +// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); +// bb.writeLog("response:" + back); +// out.print("response:"+back+"
"); +// JSONObject backObj = JSONObject.parseObject(back); +// String code = backObj.getString("code"); +// String data = backObj.getString("data"); +// out.print("code:"+code+"
"); +// if ("0".equals(code)) { +// bb.writeLog("新接口调用成功"); +// JSONObject dataObj = JSONObject.parseObject(data); +// out.print("dataObj:"+dataObj.toJSONString()+"
"); +// } else { +// bb.writeLog("接口调用失败"); +// out.print("接口调用失败"); +// } +// } +// +// for(int i=0;i topDeptMap = topDepartmentList.get(i); +// String deptid = topDeptMap.get("deptid"); +// +// List> childDepartmentList = getDeptListByParentid(deptid); +// for(int k=0;k childDepartmentMap = childDepartmentList.get(i); +// String departmentcode = childDepartmentMap.get("departmentcode"); +// String departmentname = childDepartmentMap.get("departmentname"); +// String supdeptcode = childDepartmentMap.get("supdeptcode"); +// +// Map dataMap = new HashMap(); +// dataMap.put("department_ext_id", departmentcode); +// dataMap.put("name", departmentname); +// dataMap.put("p_ext_id", supdeptcode); +// +// out.print("headers:"+JSONObject.toJSONString(heads)+"
"); +// out.print("dept-body:"+JSONObject.toJSONString(dataMap)+"
"); +// +// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); +// bb.writeLog("response:" + back); +// out.print("response:"+back+"
"); +// JSONObject backObj = JSONObject.parseObject(back); +// String code = backObj.getString("code"); +// String data = backObj.getString("data"); +// out.print("code:"+code+"
"); +// if ("0".equals(code)) { +// bb.writeLog("新接口调用成功"); +// JSONObject dataObj = JSONObject.parseObject(data); +// out.print("dataObj:"+dataObj.toJSONString()+"
"); +// } else { +// bb.writeLog("接口调用失败"); +// out.print("接口调用失败"); +// } +// } +// } + } + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + +%> + +<%! + + /*** + * + * @return + */ + public List> getTopSubcompanyList(String where){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanyid",subcompanyid); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + list.add(map); + } + return list; + } + + + public List> getSubcompanyListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + map.put("supsubcomid",sup_subcomid); + map.put("supsubcompanycode",supsubcompanycode); + list.add(map); + } + return list; + } + + + + public List> getTopDeptList(){ + List> list = new ArrayList>(); + Map 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(); + map.put("departmentcode",departmentcode); + map.put("departmentname",departmentname); + map.put("deptid",deptid); + map.put("subcompanycode",subcompanycode); + list.add(map); + } + return list; + } + + + public List> getDeptListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +%> + diff --git a/数智制造/interface.suzhi/syndeliorg4.jsp b/数智制造/interface.suzhi/syndeliorg4.jsp new file mode 100644 index 0000000..ef2b186 --- /dev/null +++ b/数智制造/interface.suzhi/syndeliorg4.jsp @@ -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+"
"); + out.print("secret:"+secret+"
"); + + 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+"
"); + out.print("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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> topSubcompanyList = getTopSubcompanyList(where); +// for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); +// String subcompanycode = topSubcompanyMap.get("subcompanycode"); +// String subcompanyname = topSubcompanyMap.get("subcompanyname"); +// +// Map dataMap = new HashMap(); +// dataMap.put("department_ext_id", subcompanycode); +// dataMap.put("name", subcompanyname); +// dataMap.put("p_ext_id", ""); +// +// out.print("headers:"+JSONObject.toJSONString(heads)+"
"); +// out.print("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); +// +// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); +// bb.writeLog("response:" + back); +// out.print("response:"+back+"
"); +// JSONObject backObj = JSONObject.parseObject(back); +// String code = backObj.getString("code"); +// String data = backObj.getString("data"); +// out.print("code:"+code+"
"); +// if ("0".equals(code)) { +// bb.writeLog("新接口调用成功"); +// JSONObject dataObj = JSONObject.parseObject(data); +// out.print("dataObj:"+dataObj.toJSONString()+"
"); +// } else { +// bb.writeLog("接口调用失败"); +// out.print("接口调用失败"); +// } +// } +// +// for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); +// String subcompanyid = topSubcompanyMap.get("subcompanyid"); +// +// List> childSubcompanyList = getSubcompanyListByParentid(subcompanyid); +// +// for(int k=0;k childSubcompanyMap = childSubcompanyList.get(i); +// String subcompanycode = childSubcompanyMap.get("subcompanycode"); +// String subcompanyname = childSubcompanyMap.get("subcompanyname"); +// String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode"); +// +// Map dataMap = new HashMap(); +// dataMap.put("department_ext_id", subcompanycode); +// dataMap.put("name", subcompanyname); +// dataMap.put("p_ext_id", supsubcompanycode); +// +// out.print("headers:"+JSONObject.toJSONString(heads)+"
"); +// out.print("Subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); +// +// String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); +// bb.writeLog("response:" + back); +// out.print("response:"+back+"
"); +// JSONObject backObj = JSONObject.parseObject(back); +// String code = backObj.getString("code"); +// String data = backObj.getString("data"); +// out.print("code:"+code+"
"); +// if ("0".equals(code)) { +// bb.writeLog("新接口调用成功"); +// JSONObject dataObj = JSONObject.parseObject(data); +// out.print("dataObj:"+dataObj.toJSONString()+"
"); +// } else { +// bb.writeLog("接口调用失败"); +// out.print("接口调用失败"); +// } +// } +// } + + List> topDepartmentList = getTopDeptList(); + for(int i=0;i topDepartmentMap = topDepartmentList.get(i); + String departmentcode = topDepartmentMap.get("departmentcode"); + String departmentname = topDepartmentMap.get("departmentname"); + String subcompanycode = topDepartmentMap.get("subcompanycode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", subcompanycode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("top-dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + + for(int i=0;i topDeptMap = topDepartmentList.get(i); + String deptid = topDeptMap.get("deptid"); + + List> childDepartmentList = getDeptListByParentid(deptid); + for(int k=0;k childDepartmentMap = childDepartmentList.get(k); + String departmentcode = childDepartmentMap.get("departmentcode"); + String departmentname = childDepartmentMap.get("departmentname"); + String supdeptcode = childDepartmentMap.get("supdeptcode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", supdeptcode); + + out.print("headers:"+JSONObject.toJSONString(heads)+"
"); + out.print("dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + out.print("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + out.print("接口调用失败"); + } + } + } + } + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + +%> + +<%! + + /*** + * + * @return + */ + public List> getTopSubcompanyList(String where){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanyid",subcompanyid); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + list.add(map); + } + return list; + } + + + public List> getSubcompanyListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + map.put("supsubcomid",sup_subcomid); + map.put("supsubcompanycode",supsubcompanycode); + list.add(map); + } + return list; + } + + + + public List> getTopDeptList(){ + List> list = new ArrayList>(); + Map 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(); + map.put("departmentcode",departmentcode); + map.put("departmentname",departmentname); + map.put("deptid",deptid); + map.put("subcompanycode",subcompanycode); + list.add(map); + } + return list; + } + + + public List> getDeptListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +%> + diff --git a/数智制造/interface.suzhi/syndeliuser.jsp b/数智制造/interface.suzhi/syndeliuser.jsp new file mode 100644 index 0000000..08acf83 --- /dev/null +++ b/数智制造/interface.suzhi/syndeliuser.jsp @@ -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+"
"); + out.print("secret:"+secret+"
"); + + 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+"
"); + out.print("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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 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+ "
"); + out.print("lastname:"+lastname+ "
"); + out.print("mobile:"+mobile+ "
"); + + out.print("deptcode:"+deptcode+ "
"); + out.print("deptname:"+deptname+ "
"); + out.print("deptid:"+deptid+ "
"); + out.print("subcompanyid1:"+subcompanyid1+ "
"); + + int errorcount = 0; + int errorcount1 = updateSubcompanyData(subcompanyid1,key,secret); + errorcount = errorcount + errorcount1 ; + out.print("errorcount1:"+errorcount1+"
"); + + int errorcount2 = updateDeptData(deptid,key,secret); + errorcount = errorcount + errorcount2 ; + out.print("errorcount2:"+errorcount2+"
"); + + if(errorcount == 0){ + + Map dataMap = new HashMap(); + dataMap.put("employee_ext_id", workcode); + dataMap.put("name", lastname); + dataMap.put("mobile", mobile); + dataMap.put("employee_num", workcode); + + List> department_infolist = new ArrayList>(); + Map department_infos = new HashMap(); + 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) + "
"); + out.print("employee-body:" + JSONObject.toJSONString(dataMap) + "
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + out.print("employee-response:" + back + "
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + out.print("employee-code:" + code + "
"); + if (!"0".equals(code)) { + errorcount++; + } + } + } + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + +%> + +<%! + + public List> getSubcompanyListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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> getDeptListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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 getUserData(String userid){ + + Map userMap = new HashMap(); + 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 heads = new HashMap(); + 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> childSubcompanyList = getSubcompanyListByParentid(subcompanyid1); + for(int k=0;k childSubcompanyMap = childSubcompanyList.get(k); + String subcompanycode = childSubcompanyMap.get("subcompanycode"); + String subcompanyname = childSubcompanyMap.get("subcompanyname"); + String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode"); + + Map dataMap = new HashMap(); + 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 heads = new HashMap(); + 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> childDepartmentList = getDeptListByParentid(deptid); + for(int k=0;k childDepartmentMap = childDepartmentList.get(k); + String departmentcode = childDepartmentMap.get("departmentcode"); + String departmentname = childDepartmentMap.get("departmentname"); + String supdeptcode = childDepartmentMap.get("supdeptcode"); + + + Map dataMap = new HashMap(); + 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; + } + +%> + diff --git a/数智制造/src/com/api/browser/service/impl/JobActivitiesBrowserService.java b/数智制造/src/com/api/browser/service/impl/JobActivitiesBrowserService.java new file mode 100644 index 0000000..67d7a9f --- /dev/null +++ b/数智制造/src/com/api/browser/service/impl/JobActivitiesBrowserService.java @@ -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 getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + 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 cols = new ArrayList(); + 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 getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + 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; + } + +} diff --git a/数智制造/src/com/api/browser/service/impl/JobTitlesBrowserService.java b/数智制造/src/com/api/browser/service/impl/JobTitlesBrowserService.java new file mode 100644 index 0000000..171be87 --- /dev/null +++ b/数智制造/src/com/api/browser/service/impl/JobTitlesBrowserService.java @@ -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 getBrowserData(Map params) throws Exception { + Map 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 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 getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap<>(16); + List 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 getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap<>(16); + List> 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 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 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 browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception { + Map apidatas = new HashMap<>(16); + String q = Util.null2String(request.getParameter("q")); + List 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> datas = new ArrayList<>(); + while (rs.next()) { + Map 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; + } +} diff --git a/数智制造/src/com/api/shuzhi/web/SzBatchExportController.java b/数智制造/src/com/api/shuzhi/web/SzBatchExportController.java new file mode 100644 index 0000000..0f78823 --- /dev/null +++ b/数智制造/src/com/api/shuzhi/web/SzBatchExportController.java @@ -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{ +} diff --git a/数智制造/src/com/api/shuzhi/web/SzDataCenterController.java b/数智制造/src/com/api/shuzhi/web/SzDataCenterController.java new file mode 100644 index 0000000..10724e9 --- /dev/null +++ b/数智制造/src/com/api/shuzhi/web/SzDataCenterController.java @@ -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 { +} diff --git a/数智制造/src/com/api/shuzhi/web/SzResumeController.java b/数智制造/src/com/api/shuzhi/web/SzResumeController.java new file mode 100644 index 0000000..4e1806d --- /dev/null +++ b/数智制造/src/com/api/shuzhi/web/SzResumeController.java @@ -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 { +} diff --git a/数智制造/src/com/customization/shuzhi/SzGetJobTitleListCmd.java b/数智制造/src/com/customization/shuzhi/SzGetJobTitleListCmd.java new file mode 100644 index 0000000..807557c --- /dev/null +++ b/数智制造/src/com/customization/shuzhi/SzGetJobTitleListCmd.java @@ -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> { + @Override + public Map execute(Command> targetCommand) { + Map 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; + } +} diff --git a/数智制造/src/com/engine/kq/biz/KQReportBiz.java b/数智制造/src/com/engine/kq/biz/KQReportBiz.java new file mode 100644 index 0000000..edb7a76 --- /dev/null +++ b/数智制造/src/com/engine/kq/biz/KQReportBiz.java @@ -0,0 +1,3684 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; + +import java.text.DecimalFormatSymbols; +import java.util.Map.Entry; + +import com.engine.kq.util.KQTransMethod; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.text.DecimalFormat; +import java.util.*; + +public class KQReportBiz extends BaseBean { + + private static DecimalFormat df = new DecimalFormat("0.00"); + + private DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + + + public String format(double value) { +// DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + df.setMaximumFractionDigits(5); + df.setDecimalFormatSymbols(symbols); + return df.format(value); + } + + + private KQLog kqLog = new KQLog(); + /** + * 初始化当天考勤数据 + */ + public void initKQReportData(){ + String date = DateUtil.getCurrentDate(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + boolean hasInit = false; + sql = "select 1 from kq_report_check where check_date = ? "; + rs.executeQuery(sql,date); + if(rs.next()) { + hasInit = true; + } + + String beforeyesterday = DateUtil.addDate(date,-2); + String yesterday = DateUtil.addDate(date,-1); + if(!hasInit){ + //这里做过功能是每天都刷下考勤缓存 因为这个缓存也是异步的,一点都不稳定 + kqLog.info("begin do KQOneStopUp refreshCominfo invoke ..."); + new KQOneStopUp().refreshCominfo(); + kqLog.info("end do KQOneStopUp refreshCominfo invoke ..."); + + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.clearFormatPool(); + //格式化上上天数据 + kqFormatBiz.formatDateByKQDate(beforeyesterday); + //格式化上一天数据 + kqFormatBiz.formatDateByKQDate(yesterday); + //初始化今天数据 + kqFormatBiz.formatDateByKQDate(date); + + sql = " insert into kq_report_check(check_date) values (?)"; + rs.executeUpdate(sql,date); + + writeLog(date+"执行考勤报表数据格式化成功!"); + } + }catch (Exception e){ + writeLog(e); + } + } + + public Map getModel_ShiftRule(String i,String serialId) { + RecordSet rs = new RecordSet(); + HashMap sectionMap = new HashMap<>(); + String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where SERIALID=? and record=? "; + rs.executeQuery(getStartWorkSections,serialId,i); + while (rs.next()) { + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + String clockinnot = Util.null2s(Util.null2String(rs.getString("clockinnot")), "0"); + sectionMap.put(onoffworktype, clockinnot); + } + return sectionMap; + } + + /*** + * 获取考勤状态 + * @param resourceId + * @param fromdate + * @param todate + * @param isAll + * @return + */ + public List getKqDateInfo(String resourceId, String fromdate, String todate, boolean isAll) { + List kqdates = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + Map kqdate = null; + List datas = null; + Map data = null; + sql = " select kqdate,serialid, workbegindate, workbegintime,workenddate, workendtime," + + " signintime,signouttime,beLateMins,graveBeLateMins,leaveEarlyMins,graveLeaveEarlyMins," + + " absenteeismMins, forgotCheckMins,forgotBeginWorkCheckMins,otherinfo,serialnumber "+ + " from kq_format_detail " + + " where resourceid=? and kqdate>=? and kqdate<=? "; + if(!isAll){ + if(rs.getDBType().equalsIgnoreCase("oracle") || Util.null2String(rs.getOrgindbtype()).equals("dm") || Util.null2String(rs.getOrgindbtype()).equals("st")) { + sql += " and nvl(beLateMins,0)+nvl(graveBeLateMins,0)+nvl(leaveEarlyMins,0)+nvl(graveLeaveEarlyMins,0)+nvl(absenteeismMins,0)+nvl(forgotCheckMins,0)+nvl(forgotBeginWorkCheckMins,0)>0 "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + sql += " and ifnull(beLateMins,0)+ifnull(graveBeLateMins,0)+ifnull(leaveEarlyMins,0)+ifnull(graveLeaveEarlyMins,0)+ifnull(absenteeismMins,0)+ifnull(forgotCheckMins,0)+ifnull(forgotBeginWorkCheckMins,0)>0 "; + }else { + sql += " and isnull(beLateMins,0)+isnull(graveBeLateMins,0)+isnull(leaveEarlyMins,0)+isnull(graveLeaveEarlyMins,0)+isnull(absenteeismMins,0)+isnull(forgotCheckMins,0)+isnull(forgotBeginWorkCheckMins,0)>0 "; + } + } + sql += " order by kqdate,serialnumber "; + + rs.executeQuery(sql,resourceId,fromdate, todate); + while(rs.next()){ + String serialnumber = Util.null2String(rs.getString("serialnumber")); + String serialid = Util.null2String(rs.getString("serialid")); + String workbegindate = Util.null2String(rs.getString("workbegindate")); + String workbegintime = Util.null2String(rs.getString("workbegintime")); + String workenddate = Util.null2String(rs.getString("workenddate")); + String workendtime = Util.null2String(rs.getString("workendtime")); + String signintime = Util.null2String(rs.getString("signintime")); + String signouttime = Util.null2String(rs.getString("signouttime")); + int beLateMins = rs.getInt("beLateMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + String otherinfo = Util.null2String(rs.getString("otherinfo")); + + String shift_begindate = ""; + String shift_beginworktime = ""; + String shift_enddate = ""; + String shift_endworktime = ""; + if(otherinfo.length() > 0){ + JSONObject otherinfo_object = JSONObject.parseObject(otherinfo); + if(otherinfo_object != null && !otherinfo_object.isEmpty()){ + JSONObject shiftRule = (JSONObject) otherinfo_object.get("shiftRule"); + if(shiftRule != null && !shiftRule.isEmpty()){ + shift_begindate = Util.null2String(shiftRule.get("shift_begindate")); + shift_beginworktime = Util.null2String(shiftRule.get("shift_beginworktime")); + shift_enddate = Util.null2String(shiftRule.get("shift_enddate")); + shift_endworktime = Util.null2String(shiftRule.get("shift_endworktime")); + if(shift_begindate.length() > 0){ + workbegindate = shift_begindate; + } + if(shift_beginworktime.length() > 0){ + workbegintime = shift_beginworktime; + } + if(shift_enddate.length() > 0){ + workenddate = shift_enddate; + } + if(shift_endworktime.length() > 0){ + workendtime = shift_endworktime; + } + } + } + } + + kqdate = new HashMap<>(); + datas = new ArrayList<>(); + kqdate.put("kqdate",Util.null2String(rs.getString("kqdate"))); + if(workbegindate.length()>0){ + data = new HashMap<>(); + data.put("workbegindate",workbegindate); + data.put("workbegintime",workbegintime); + data.put("signintime",signintime); + + data.put("workenddate",workenddate); + data.put("workendtime",workendtime); + data.put("signouttime",signouttime); + String status = ""; + if(beLateMins>0||graveBeLateMins>0){ + status = ButtonStatusEnum.BELATE.getStatusCode(); + } + if(forgotBeginWorkCheckMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.NOSIGN_ON.getStatusCode(); + } + if(leaveEarlyMins>0||graveLeaveEarlyMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.LEAVEERALY.getStatusCode(); + } + if(absenteeismMins>0){ + int isondutyfreecheck =0; + int isoffdutyfreecheck =0; + Map model_ShiftRule = getModel_ShiftRule(serialnumber, serialid); + Iterator iter = model_ShiftRule.entrySet().iterator(); + while (iter.hasNext()) { + Entry entry = (Entry) iter.next(); + String key = Util.null2String(entry.getKey()); + String value = Util.null2String(entry.getValue()); + if(key.equals("start")&&value.equals("1")){ + isondutyfreecheck = 1; + } + if(key.equals("end")&&value.equals("1")){ + isoffdutyfreecheck = 1; + } + } + data.put("start",isondutyfreecheck); + data.put("end",isoffdutyfreecheck); + if(status.length()>0)status+=","; + status += ButtonStatusEnum.ABSENT.getStatusCode(); + } + if(forgotCheckMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.NOSIGN.getStatusCode(); + } + data.put("status",status); + datas.add(data); + } + + kqdate.put("checkInfo",datas); + kqdates.add(kqdate); + } + } catch (Exception e) { + writeLog(e); + } + return kqdates; + } + + /** + * 获取真实的开始日期和结束日期,没有权限的人最大只能查询本季 + * @param fromDate + * @param toDate + * @param user + * @return + */ + public Map realDate(String fromDate, String toDate, User user, String reportType) { + Map dateMap = new HashMap<>(); + dateMap.put("fromDate", fromDate); + dateMap.put("toDate", toDate); + boolean hasRight = false; + if("-100".equals(reportType)) { + RecordSet rs = new RecordSet(); + String departmentId = ""; + rs.executeQuery("select subcompanyid1, departmentId from hrmresource where id = ?", user.getUID()); + if (rs.next()) { + departmentId = StringUtil.vString(rs.getString("departmentId")); + } + hasRight = HrmUserVarify.checkUserRight("MobileSignInfo:Manage", user, departmentId); + } else { + hasRight = new KQReportBiz().hasReportRight(reportType,""+user.getUID()); + } + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + if(!hasRight && kq_personal_reportsearch) { // 开启开关,且没有权限的账号,最大查询只支持到本季 + String seasonFromDate = TimeUtil.getDateByOption("4","0"); + String seasonToDate = TimeUtil.getDateByOption("4","1"); + if(toDate.compareTo(seasonFromDate) < 0 || fromDate.compareTo(seasonToDate) > 0) { + dateMap.put("fromDate", "-1"); + dateMap.put("toDate", "-1"); + return dateMap; + } else if(fromDate.compareTo(seasonFromDate) < 0) { + fromDate = seasonFromDate; + if(toDate.compareTo(seasonToDate) > 0) { + toDate = seasonToDate; + } + } else if(fromDate.compareTo(seasonFromDate) >= 0) { + if(toDate.compareTo(seasonToDate) > 0) { + toDate = seasonToDate; + } + } + } + dateMap.put("fromDate", fromDate); + dateMap.put("toDate", toDate); + return dateMap; + } + + /** + * 是否有考勤报表相关权限 + * @param reportType 1:考勤汇总报表; 2:每日统计报表; 3:原始打卡记录; 4:员工假期余额 + * @param userId + * @return + */ + public boolean hasReportRight(String reportType, String userId){ + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " select sharelevel,subcomid, deptid,userid,jobtitleid,foralluser from kq_reportshare where resourceid=? "; + if(reportType.length()>0 ){ + sql += " and (reportname =0 or reportname =" + reportType+")"; + } + rs.executeQuery(sql,userId); + if(rs.next()) { + return true; + } + return false; + } + + /** + * 将操作导出四大考勤报表的日志记录到数据库中,谁操作的导出,什么时间操作的导出,导出的条件都存储下来 + * @param params + * @param user + */ + public void insertKqReportExportLog(Map params, User user) { + RecordSet rs = new RecordSet(); + String exportParams = JSON.toJSONString(params); + String sql = "insert into kq_exportreport_log(operatorid,exportparams) values(?,?)"; + rs.executeUpdate(sql, user.getUID(), exportParams); + } + + /** + * 获取报表权限 + * @param reportType 报表类型 + * @param userId 用户id + * @param tableExt 别名 + * @return + */ + public String getReportRight(String reportType, String userId, String tableExt){ + String rightSql = ""; + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + List userAllUserIds = new ArrayList<>(); + List userAllDeptIds = new ArrayList<>(); + List userAllSubCompanyIds = new ArrayList<>(); + List userAllJobtitleIds = new ArrayList<>(); + boolean forAllUser = false; + sql = " select sharelevel,subcomid, deptid,userid,jobtitleid,foralluser from kq_reportshare where resourceid=? "; + if(reportType.length()>0 ){ + sql += " and (reportname =0 or reportname =" + reportType+")"; + } + rs.executeQuery(sql,userId); + while(rs.next()){ + int sharelevel = rs.getInt("sharelevel"); + if(sharelevel==0){//分部 + if(Util.null2String(rs.getString("subcomid")).length()>0){ + userAllSubCompanyIds.add(rs.getString("subcomid")); + } + }else if(sharelevel==1){//部门 + if(Util.null2String(rs.getString("deptid")).length()>0) { + userAllDeptIds.add(rs.getString("deptid")); + } + }else if(sharelevel==2){//人员 + if(Util.null2String(rs.getString("userid")).length()>0) { + userAllUserIds.add(rs.getString("userid")); + } + }else if(sharelevel==3){//岗位 + if(Util.null2String(rs.getString("jobtitleid")).length()>0) { + userAllJobtitleIds.add(rs.getString("jobtitleid")); + } + }else if(sharelevel==4){//所有人 + forAllUser = true; + userAllUserIds.clear(); + userAllDeptIds.clear(); + userAllSubCompanyIds.clear(); + userAllJobtitleIds.clear(); + break; + } + } + + if(!forAllUser) { + for (int sharelevel = 0; sharelevel < 4; sharelevel++) { + if (sharelevel == 0) {//分部 + if (userAllSubCompanyIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".subcompanyid1 in(" + String.join(",", userAllSubCompanyIds) + ")"; + } + } else if (sharelevel == 1) {//部门 + if (userAllDeptIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".departmentid in(" + String.join(",", userAllDeptIds) + ")"; + } + } else if (sharelevel == 2) {//人员 + if (userAllUserIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".id in(" + String.join(",", userAllUserIds) + ")"; + } + } else if (sharelevel == 3) {//岗位 + if (userAllJobtitleIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".jobtitle in(" + String.join(",", userAllJobtitleIds) + ")"; + } + } + } + + //可以看自己和下属的考勤 + String selfSql = " ("+tableExt+".id = "+userId+" or "+tableExt+".managerstr like '%,"+userId+",%')"; + if(rightSql.length()>0){ + rightSql = " and ((" +rightSql+") or "+selfSql+" ) "; + }else{ + rightSql = " and "+selfSql; + } + + } + }catch (Exception e){ + writeLog(e); + } + return rightSql; + } + + public static String getUnitType(KQReportFieldComInfo kqReportFieldComInfo, User user){ + String unitTypeName = ""; + String unitType = Util.null2String(kqReportFieldComInfo.getUnittype()); + String parentid = Util.null2String( kqReportFieldComInfo.getParentid()); + String fieldName = Util.null2String(kqReportFieldComInfo.getFieldname()); + if(kqReportFieldComInfo.getIsLeaveType().equals("1")){ + if(fieldName.equals("businessLeave")){ + unitType = KQTravelRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型 + }else if(fieldName.equals("officialBusiness")){ + unitType = KQExitRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型 + }else if(parentid.equals("overtime") || parentid.equals("overtime_nonleave") || parentid.equals("overtime_4leave")){ + unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";//单位类型 + } + } + if(Util.null2String(unitType).length()>0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + return unitTypeName; + } + + /** + * 为每日统计报表做流程数据查询 + * @param params + * @param user + * @return + */ + public Map getDailyFlowData(Map params, User user){ + Map datas = new HashMap<>();; + try{ + datas.putAll(getDailyFlowLeaveData(params,user)); + datas.putAll(getDailyFlowEvectionOutData(params,user)); + datas.putAll(getDailyFlowOverTimeData(params,user)); + datas.putAll(getDailyFlowLeaveBackData(params,user)); + + datas.putAll(getSignDetailInfoData(params,user)); + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + public Map getFlowData(Map params, User user){ + Map datas = new HashMap<>();; + try{ + datas.putAll(getFlowLeaveData(params,user)); + datas.putAll(getFlowEvectionOutData(params,user)); + datas.putAll(getFlowOverTimeDataNew(params,user)); + datas.putAll(getFlowOtherData(params,user)); + datas.putAll(getFlowLeaveBackData(params,user)); + datas.putAll(getFlowProcessChangeData(params,user)); + + datas.putAll(getCardMap(params,user)); + datas.putAll(getOverTime(params,user)); + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取出差和公出数据 + * @param params + * @param user + * @return + */ + public Map getFlowEvectionOutData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差 + KqSplitFlowTypeEnum.OUT.getTablename()};//公出 + + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + for(String table : tables){ + sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+table+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + double value = rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ + flowType = "businessLeave"; + minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + + }else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){ + flowType = "officialBusiness"; + minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日的出差和公出数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowEvectionOutData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差 + KqSplitFlowTypeEnum.OUT.getTablename()};//公出 + + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + for(String table : tables){ + sql = " select resourceid, durationrule, sum(duration) as val,belongdate from hrmresource a, "+table+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + double value = rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ + flowType = "businessLeave"; + minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + }else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){ + flowType = "officialBusiness"; + minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取请假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLeaveData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status != 1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype, kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leaveType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + //获取打卡数据用于判断外勤,补卡等信息=============================== + public Map getCardMap(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + //rs.writeLog("getCardMap="+ JSONObject.toJSONString(params)); + try{ + String show_card_source = Util.null2String(params.get("show_card_source")); + if(!"1".equals(show_card_source)){//下面的日历都是实时拼接,这里还是控制下数据库的交互次数,虽然用起来没啥用-.- + return datas; + } + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTransMethod kqTransMethod = new KQTransMethod(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + rs.writeLog("jsonObj="+ jsonObj.toJSONString()); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + //em7外勤、云桥外勤数据同步、钉钉外勤打卡、微信外勤转考勤(补卡先留一个口子,以防客户要) +// sqlWhere += " and (signfrom like 'card%' or signfrom='e9_mobile_out' or signfrom='EMSyn_out' or signfrom='DingTalk_out' or signfrom='Wechat_out') "; + + sql = " select a.id,b.signdate,b.id as signid,b.signfrom from hrmresource a, hrmschedulesign b "+ + " where a.id = b.userid and b.signdate >='"+fromDate+"' and b.signdate <='"+toDate+"' " +sqlWhere + + " order by a.id,b.signdate "; + rs.execute(sql); +// kqLog.info("card.sql="+sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signid = Util.null2String(rs.getString("signid")); + String signfrom = Util.null2String(rs.getString("signfrom")); + String signFromShow = kqTransMethod.getSignFromShow(signfrom, ""+user.getLanguage()); + String key = resourceid+"|"+signdate; + + datas.put(signid,signFromShow); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + +//获取打卡数据用于判断外勤,补卡等信息=============================== + + /** + * 获取销假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取考勤变更流程数据 + * @param params + * @param user + * @return + */ + public Map getFlowProcessChangeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, durationrule, changetype,sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.PROCESSCHANGE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule,changetype "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + int changetype = Util.getIntValue(rs.getString("changetype")); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == changetype){ + flowType = "businessLeave_back"; + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + minimumUnit = KQTravelRulesBiz.getMinimumUnit(); + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == changetype){ + flowType = "officialBusiness_back"; + minimumUnit = KQExitRulesBiz.getMinimumUnit(); + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日请假数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowLeaveData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|leaveType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + public Map getSignDetailInfoData(Map params, User user){ + Map data = new HashMap<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String isneedcal = Util.null2String(params.get("isneedcal")); + if("".equals(isneedcal)){ + isneedcal = KQSettingsBiz.getKqformatAccurate()?"1":"0"; + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + //================================= +// Map data = new HashMap<>(); + Map signStatusInfo = null; + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + sql = " select kqdate,resourceid,day_type,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid,flowinfo,on_absenteeismmins,off_absenteeismmins \n" + + " from hrmresource a,kq_format_detail b \n" + + " where a.id = b.resourceid " +sqlWhere+ + " and b.kqdate >='" + fromDate + "' and b.kqdate<='"+toDate+"' \n" + + " order by b.serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + String day_type = Util.null2s(rs.getString("day_type"),""); + int workMins = rs.getInt("workMins"); + boolean isNonWork = false; + if(day_type.length() > 0){ + if("holiday".equals(day_type) || "playday".equals(day_type)){ + isNonWork = true; + } + if(serialid.length() == 0){ + //弹性班制,会存在dayType是work但是没有班次的情况 + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialid.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + int serialnumber = rs.getInt("serialnumber")+1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + int attendanceMins = rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + String flowinfo = Util.null2String(rs.getString("flowinfo")); + String on_absenteeismmins = Util.null2String(rs.getString("on_absenteeismmins")); + String off_absenteeismmins = Util.null2String(rs.getString("off_absenteeismmins")); + + String tmpkey = resourceid+"|"+kqdate+"|"; + + + if(!isNonWork){ + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate",workbegindate); + signStatusInfo.put("worktime",workbegintime); + signStatusInfo.put("beLateMins",beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins",graveBeLateMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data.put(tmpkey+"signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate",workenddate); + signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins",leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins",forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + if(workMins>0){ + //弹性工时打卡时间取自签到签退数据 + } + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + if(signinid.length() > 0){ + data.put(tmpkey+"signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + if(signoutid.length() > 0){ + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else if(signoutid.length() > 0){ + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + }else{ + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + } + } + }catch (Exception e){ + writeLog(e); + } + return data; + } + + /** + * 获取每日销假数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取实际加班数据,包括流程,打卡生成的 + * @return + */ + public Map getFlowOverTimeDataNew(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + + sql = " select resourceid,changeType, sum(cast(duration_min as decimal(18,4))) as val,paidLeaveEnable "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable "; + rs.execute(sql); + kqLog.info("getFlowOverTimeDataNew:sql:"+sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + if("1".equalsIgnoreCase(paidLeaveEnable)){ + //1表示关联调休 + flowType += "_4leave"; + }else{ + //0表示不关联调休 + flowType += "_nonleave"; + } + String key = resourceid+"|"+flowType; + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + /** + * 获取加班数据 + * @return + */ + public Map getFlowOverTimeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and b.subcompanyid in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and b.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val"; + }else{//按天计算 + valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val"; + } + + sql = " select resourceid,changeType, " +valueField+ + " from hrmresource a, "+KqSplitFlowTypeEnum.OVERTIME.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + String key = resourceid+"|"+flowType; + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日加班数据 + * @return + */ + public Map getDailyFlowOverTimeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val"; + }else{//按天计算 + valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val"; + } + + sql = " select resourceid,changeType,belongdate,paidLeaveEnable, sum(cast(duration_min as decimal(18,4))) as val "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + if("1".equalsIgnoreCase(paidLeaveEnable)){ + //1表示关联调休 + flowType += "_4leave"; + }else{ + //0表示不关联调休 + flowType += "_nonleave"; + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(resourceid+"|"+belongdate+"|"+flowType,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 异常冲抵 + * @return + */ + public Map getFlowOtherData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.OTHER.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leaveDeduction"; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + *日报表数据 + * @param resourceId + * @param fromDate + * @param toDate + * @return + */ + public Map getDetialDatas(String resourceId,String fromDate, String toDate, User user){ + return getDetialDatas(resourceId,fromDate,toDate,user,new HashMap(),false,0,"0"); + } + + /** + * 考勤汇总报表上下午显示开关不开启 + * @param resourceId + * @param fromDate + * @param toDate + * @param user + * @param flowData + * @param isWrap + * @param uintType + * @param show_card_source + * @return + */ + public Map getDetialDatasHalfNotOpen(String resourceId,String fromDate, String toDate, User user, + Map flowData,boolean isWrap,int uintType,String show_card_source){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + Map datas = new HashMap<>(); + Map data = null; + Map tmpdatas = new HashMap<>(); + Map tmpdatass = new HashMap<>(); + Map tmpdata = null; + Map tmpmap = null; + + Map tmpstatusdata = new HashMap<>(); + Map tmpstatus = null; + RecordSet rs = new RecordSet(); + String sql = ""; + + BaseBean bb = new BaseBean(); + //add + String unit = "小时"; + if(uintType==1 || uintType== 2 || uintType== 4){//按天计算 + unit = "天"; + } + //kqLog.info("detail.flowdata="+JSONObject.toJSONString(flowData)); + + try { + sql = " select resourceid,day_type,serialid, kqdate, workMins,attendanceMins,signindate,signintime,signoutdate,signouttime,signinid,signoutid, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ + " leaveMins,leaveInfo,evectionMins,outMins " + + " from kq_format_detail " + + " where resourceid = ? and kqdate>=? and kqdate<=? "+ + " order by resourceid, kqdate, serialnumber "; + rs.executeQuery(sql,resourceId, fromDate,toDate); + while (rs.next()) { + String key = rs.getString("resourceid") + "|" + rs.getString("kqdate"); + int workMins = rs.getInt("workMins"); + + boolean isNonWork = false; + String serialid = Util.null2s(rs.getString("serialid"),""); + String dayType = Util.null2s(rs.getString("day_type"),""); + if(dayType.length() > 0){ + if("holiday".equals(dayType) || "playday".equals(dayType)){ + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialid.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + String attendanceMins = rs.getString("attendanceMins"); +// String chuqin = "出勤:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(attendanceMins) / 60.0)))+"小时"; + String overtimekey = key+"|overtime"; + String overtime = Util.null2String(flowData.get(overtimekey)); + boolean hasovertime = Util.getDoubleValue(overtime)>0; + overtime = hasovertime?(SystemEnv.getHtmlLabelName(6151, user.getLanguage())+":"+overtime+unit):"";//显示加班 + + String signinid = ""; + String signoutid = ""; + String signintime = ""; + String signouttime = ""; + if("1".equals(show_card_source)){ + String nosign = SystemEnv.getHtmlLabelName(25994, user.getLanguage());//未打卡 + signinid = Util.null2String(rs.getString("signinid")).trim(); + signintime = Util.null2String(rs.getString("signintime")).trim(); + String tmpin = SystemEnv.getHtmlLabelName(21974, user.getLanguage())+":"; + if(signinid.length()>0){ + String signinfrom = Util.null2String(flowData.get(signinid)); + signintime = tmpin+signintime+" "+signinfrom; + }else{ + signintime = tmpin+nosign; + } +// signintime = isWrap?"\r\n"+signintime:"
"+signintime; + + signoutid = Util.null2String(rs.getString("signoutid")).trim(); + signouttime = Util.null2String(rs.getString("signouttime")).trim(); + String tmpout = SystemEnv.getHtmlLabelName(21975, user.getLanguage())+":"; + if(signoutid.length()>0){ + String signoutfrom = Util.null2String(flowData.get(signoutid)); + signouttime = tmpout+signouttime+" "+signoutfrom; + }else{ + signouttime = tmpout+nosign; + } + signouttime = isWrap?"\r\n"+signouttime:"
"+signouttime; + } + + int beLateMins = rs.getInt("beLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = rs.getString("leaveInfo"); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + String text = ""; + String tmptext =""; + String flag ="true"; + if(datas.get(key)==null){ + data = new HashMap<>(); + }else{ + data = (Map)datas.get(key); + tmptext = Util.null2String(data.get("text")); + } + tmpdata = new HashMap<>(); + if(tmpdatas.get(key)!=null){ + tmpmap = (Map)tmpdatas.get(key); + flag = Util.null2String(tmpmap.get("text")); + } + + String yichang =""; + if(tmpstatusdata.get(key)!=null){ + yichang = Util.null2String(tmpstatusdata.get(key)); + } + String sign =""; + String signkey = key+"|text"; + if(tmpstatusdata.get(signkey)!=null){ + sign = Util.null2String(tmpstatusdata.get(signkey)); + } + + if (isNonWork) { + if(text.length()>0) text +=" "; + if(sign.indexOf(SystemEnv.getHtmlLabelName(26593, user.getLanguage()))==-1){ + if(text.length()>0) { + text+= isWrap?"\r\n":"
"; + } + text += SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } + //休息日处理 + if(signinid.length()>0){ + text += (isWrap?"\r\n":"
")+signintime; + } + if(signoutid.length()>0){ + text += signouttime; + } + sign += text; + } else { + //处理打卡数据================== + if(text.length()>0) text+= isWrap?"\r\n":"
"; + text += signintime; + text += signouttime; + if(sign.length()>0) sign+= isWrap?"\r\n":"
"; + sign += text; + //处理打卡数据================== + + if (absenteeismMins > 0) {//旷工 + if(text.length()>0) text+=" "; + text += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+absenteeismMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20085, user.getLanguage()))==-1){ + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + }else { + if (beLateMins > 0) {//迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+beLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20081, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveBeLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500546, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20082, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveLeaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500547, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + } + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + bb.writeLog("resourceId:"+resourceId+" leaveMins:"+leaveMins+" leaveInfo:"+leaveInfo+" text:"+text +" yichang:"+yichang); + + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + bb.writeLog("newLeaveType:"+newLeaveType); + bb.writeLog("tmpLeaveMins:"+tmpLeaveMins); + + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); + try{ + bb.writeLog("resourceId:"+resourceId+ " leaveMins2:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+tmpLeaveMins) / 60.0)))); + yichang += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+tmpLeaveMins) / 60.0)))+"小时"; + }catch (Exception e){ + bb.writeLog("e:"+e); + } + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + + bb.writeLog("resourceId:"+resourceId+" evectionMins:"+evectionMins); + + + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + try{ + bb.writeLog("resourceId:"+resourceId+" evectionMins2:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))); + yichang += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))+"小时"; + }catch (Exception e){ + bb.writeLog("e:"+e); + } + } + } + if (outMins > 0) {//公出 + + bb.writeLog("resourceId:"+resourceId+" outMins:"+outMins); + + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + try{ + bb.writeLog("resourceId:"+resourceId+" outMins2:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))); + yichang += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))+"小时"; + }catch (Exception e){ + bb.writeLog("e:"+e); + } + } + } + + if(text.length()==0) { + text = "√"; + }else{ + flag = "false";//有其他的异常状态,则表示为false,不需要处理直接全部显示即可 + } + text += overtime; + + + //需要处理下打卡时间和异常状态显示的顺序--start + tmpstatusdata.put(key, yichang); + tmpstatusdata.put(signkey, sign); + boolean hasyichang = tmpstatusdata.get(key).length()>0; + if(tmptext.length()>0){ +// text = tmpstatusdata.get(signkey)+(isWrap?"\r\n":"
")+tmpstatusdata.get(key)+(isWrap?"\r\n":"
"+overtime); + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + }else{ + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + } + //需要处理下打卡时间和异常状态显示的顺序--end + tmpdatass.put(key, (isWrap?"\r\n":"
")+overtime); +// text = tmptext.length()>0?tmptext+" "+text:text;//显示所有的状态 + data.put("text", text); + datas.put(key, data); + + //add + tmpdata.put("text", flag); + tmpdatas.put(key, tmpdata); + //end + } + //全部搞一遍 + if(tmpdatas != null){ +// writeLog(n+">>>tmpdatas="+JSONObject.toJSONString(tmpdatas)); + Map data1 = null; + for(Entry entry : tmpdatas.entrySet()){ + String mapKey = Util.null2String(entry.getKey()); + Map mapValue = (Map)entry.getValue(); + String flag = Util.null2String(mapValue.get("text")); + if("true".equals(flag)){//需要加工的数据 + String overtime = String.valueOf(tmpdatass.get(mapKey)); + data1 = new HashMap<>(); + data1.put("text", "√"+overtime); + datas.put(mapKey, data1); + } + } +// writeLog("datas="+JSONObject.toJSONString(datas)); + } + }catch (Exception e){ + writeLog(e); + } + // 最后针对数据再处理一遍,不然出现2023-01-02: "休息" 形式的错误,导致页面记载报错,应该是2023-01-01: {text: "休息"}格式 + boolean isEnd = false; + for(String currentDate = fromDate; !isEnd;) { + if (currentDate.equals(toDate)) isEnd = true; + String dailyValue = Util.null2String(datas.get(currentDate)); + if(!"".equals(dailyValue) && !dailyValue.contains("text")) { + Map innerMap2 = new HashMap<>(); + innerMap2.put("text", dailyValue); + datas.put(currentDate, innerMap2); + } + currentDate = DateUtil.addDate(currentDate, 1); + } + return datas; + } + + /** + * 考勤汇总报表上下午显示开关开启 + * @param resourceId + * @param fromDate + * @param toDate + * @param user + * @param flowData + * @param isWrap + * @param uintType + * @param show_card_source + * @return + */ + public Map getDetialDatasHalfOpen(String resourceId,String fromDate, String toDate, User user, + Map flowData,boolean isWrap,int uintType,String show_card_source){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + int split_time_index = kqTimesArrayComInfo.getArrayindexByTimes("13:00"); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + Map datas = new HashMap<>(); + Map data = null; + Map tmpdatas = new HashMap<>(); + Map tmpdatass = new HashMap<>(); + Map tmpdata = null; + Map tmpmap = null; + + Map tmpstatusdata = new HashMap<>(); + Map tmpstatus = null; + RecordSet rs = new RecordSet(); + String sql = ""; + + //add + String unit = "小时"; + if(uintType==1 || uintType== 2 || uintType== 4){//按天计算 + unit = "天"; + } + //kqLog.info("detail.flowdata="+JSONObject.toJSONString(flowData)); + + try { + sql = " select resourceid,day_type,serialid, kqdate, workMins, workbegintime, workendtime,attendanceMins,signindate,signintime,signoutdate,signouttime,signinid,signoutid, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ + " leaveMins,leaveInfo,evectionMins,outMins,flowinfo,on_absenteeismmins,off_absenteeismmins " + + " from kq_format_detail " + + " where resourceid = ? and kqdate>=? and kqdate<=? "+ + " order by resourceid, kqdate, serialnumber "; + rs.executeQuery(sql,resourceId, fromDate,toDate); + while (rs.next()) { + String kqDate = rs.getString("kqdate"); + String key = rs.getString("resourceid") + "|" + kqDate; + int workMins = rs.getInt("workMins"); + + String signinid = ""; + String signoutid = ""; + String signintime = ""; + String signouttime = ""; + if("1".equals(show_card_source)){ + String nosign = SystemEnv.getHtmlLabelName(25994, user.getLanguage());//未打卡 + signinid = Util.null2String(rs.getString("signinid")).trim(); + signintime = Util.null2String(rs.getString("signintime")).trim(); + String tmpin = SystemEnv.getHtmlLabelName(21974, user.getLanguage())+":"; + if(signinid.length()>0){ + String signinfrom = Util.null2String(flowData.get(signinid)); + signintime = tmpin+signintime+" "+signinfrom; + }else{ + signintime = tmpin+nosign; + } + signintime = isWrap?"\r\n"+signintime:"
"+signintime; +// signintime = isWrap?"\r\n"+signintime:"
"+signintime; + + signoutid = Util.null2String(rs.getString("signoutid")).trim(); + signouttime = Util.null2String(rs.getString("signouttime")).trim(); + String tmpout = SystemEnv.getHtmlLabelName(21975, user.getLanguage())+":"; + if(signoutid.length()>0){ + String signoutfrom = Util.null2String(flowData.get(signoutid)); + signouttime = tmpout+signouttime+" "+signoutfrom; + }else{ + signouttime = tmpout+nosign; + } + signouttime = isWrap?"\r\n"+signouttime:"
"+signouttime; + } + + String overtimekey = key+"|overtime"; + String overtime = Util.null2String(flowData.get(overtimekey)); + boolean hasovertime = Util.getDoubleValue(overtime)>0; + overtime = hasovertime? ((isWrap?"\r\n":"
")+(SystemEnv.getHtmlLabelName(6151, user.getLanguage())+":"+overtime+unit)):"";//显示加班 + + + String flowinfo = Util.null2String(rs.getString("flowinfo")); + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceId, kqDate, false); + boolean isNonWork = false; + String serialid = Util.null2s(rs.getString("serialid"),""); + String dayType = Util.null2s(rs.getString("day_type"),""); + if(dayType.length() > 0){ + if("holiday".equals(dayType) || "playday".equals(dayType)){ + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialid.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + if(shiftInfoBean == null || isNonWork) { + String textAM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + String textPM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + if(datas.get(key)==null){ + data = new HashMap<>(); + }else{ + data = (Map)datas.get(key); + } + if(shiftInfoBean != null) { + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if (halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } + } + if(flowinfo.length() > 0) { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + textAM = jsonValue; + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + textPM = jsonValue; + } else { + //全天 + textAM = jsonValue; + textPM = jsonValue; + } + } + } + } + } + } + if(!"".equals(signintime)) { + textAM+=signintime; + } + if(!"".equals(signouttime)) { + textPM+=signouttime; + } + if(!"".equals(overtime)) { + textPM+=overtime; + } + data.put("text", textAM+""+textPM); + data.put("textAM", textAM); + data.put("textPM", textPM); + datas.put(key, data); + continue; + } + String attendanceMins = rs.getString("attendanceMins"); +// String chuqin = "出勤:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(attendanceMins) / 60.0)))+"小时"; + + + int beLateMins = rs.getInt("beLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = rs.getString("leaveInfo"); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + String workbeigintime = rs.getString("workbegintime"); + String workendtime = rs.getString("workendtime"); + + String halfPoint = shiftInfoBean.getHalfcalpoint(); //1440 + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if (halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } +// int halfPointIndex = split_time_index; //kqTimesArrayComInfo.getArrayindexByTimes(halfPoint); + + int on_absenteeismmins = Util.getIntValue(Util.null2String(rs.getString("on_absenteeismmins"))); + int off_absenteeismmins = Util.getIntValue(Util.null2String(rs.getString("off_absenteeismmins"))); + + String textAM = ""; + String textPM = ""; + if (workMins<=0) { + if("".equals(flowinfo)) { + textAM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + textPM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } else { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + textAM = jsonValue; + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + textPM = jsonValue; + } else { + //全天 + textAM = jsonValue; + textPM = jsonValue; + } + } + } + } + } + } + }else{ + textAM = "√"; + textPM = "√"; + if(on_absenteeismmins > 0) { + textAM = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if(beLateMins > 0) { + //迟到 + textAM = SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + if(graveBeLateMins > 0) { + //严重迟到 + textAM = SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + if(forgotBeginWorkCheckMins > 0) { + // 漏签 + textAM = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if(off_absenteeismmins > 0) { + // 下午旷工 + textPM = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if (leaveEarlyMins > 0) { + // 早退 + textPM = SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) { + // 严重早退 + textPM = SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + if(forgotCheckMins > 0) { + // 下午漏签 + textPM = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + + if(workMins > 0 && flowinfo.length() > 0){ + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + + String jsonKey = entry.getKey(); + String jsonValue = ""; + if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if(jsonArray != null && !jsonArray.isEmpty()){ + //客户不存在多个重复流程的情况,只是显示第一个就行 + for(int i = 0 ; i < jsonArray.size() ; i++){ + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if(jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (begintime.equals(workbeigintime) && endIdx == split_time_index) { + textAM = jsonValue; + } else if (begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + textAM = jsonValue; + textPM = jsonValue; + } else if (endIdx == split_time_index && endtime.equals(workendtime)) { + textPM = jsonValue; + } else { + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + textAM = jsonValue + (("".equals(textAM) || "√".equals(textAM)) ? "" : ", " + textAM); + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + textPM = jsonValue + (("".equals(textPM) || "√".equals(textPM)) ? "" : ", " + textPM); + } else { + //全天 + textAM = jsonValue + (("".equals(textAM) || "√".equals(textAM)) ? "" : ", " + textAM); + textPM = jsonValue + (("".equals(textPM) || "√".equals(textPM)) ? "" : ", " + textPM); + } + } + } + } + } + } + } + String text = ""; + String tmptext =""; + String flag ="true"; + if(datas.get(key)==null){ + data = new HashMap<>(); + }else{ + data = (Map)datas.get(key); + tmptext = Util.null2String(data.get("text")); + } + tmpdata = new HashMap<>(); + if(tmpdatas.get(key)!=null){ + tmpmap = (Map)tmpdatas.get(key); + flag = Util.null2String(tmpmap.get("text")); + } + + String yichang =""; + if(tmpstatusdata.get(key)!=null){ + yichang = Util.null2String(tmpstatusdata.get(key)); + } + String sign =""; + String signkey = key+"|text"; + if(tmpstatusdata.get(signkey)!=null){ + sign = Util.null2String(tmpstatusdata.get(signkey)); + } + + if (isNonWork) { + if(text.length()>0) text +=" "; + if(sign.indexOf(SystemEnv.getHtmlLabelName(26593, user.getLanguage()))==-1){ + if(text.length()>0) { + text+= isWrap?"\r\n":"
"; + } + text += SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } + //休息日处理 + if(signinid.length()>0){ + text += (isWrap?"\r\n":"
")+signintime; + } + if(signoutid.length()>0){ + text += signouttime; + } + sign += text; + } else { + //处理打卡数据================== + if(text.length()>0) text+= isWrap?"\r\n":"
"; + text += signintime; + text += signouttime; + if(sign.length()>0) sign+= isWrap?"\r\n":"
"; + sign += text; + //处理打卡数据================== + + if (absenteeismMins > 0) {//旷工 + if(text.length()>0) text+=" "; + text += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+absenteeismMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20085, user.getLanguage()))==-1){ + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + }else { + if (beLateMins > 0) {//迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+beLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20081, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveBeLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500546, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20082, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveLeaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500547, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + } +// if (leaveMins > 0) {//请假 +// Map jsonObject = null; +// if(leaveInfo.length()>0){ +// jsonObject = JSON.parseObject(leaveInfo); +// for (Entry entry : jsonObject.entrySet()) { +// String newLeaveType = entry.getKey(); +// String tmpLeaveMins = Util.null2String(entry.getValue()); +// if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ +// if (text.length() > 0) text += " "; +// //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// text += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +//// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveMins) / 60.0)))+"小时"; +// if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; +// yichang += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +// } +// } +// }else{ +// if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { +// if (text.length() > 0) text += " "; +// text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); +// } +// } +// } +// if (evectionMins > 0) {//出差 +// if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { +// if (text.length() > 0) text += " "; +// text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); +//// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))+"小时"; +// if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; +// yichang += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); +// } +// } +// if (outMins > 0) {//公出 +// if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { +// if (text.length() > 0) text += " "; +// text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); +//// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))+"小时"; +// if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; +// yichang += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); +// } +// } + + if(text.length()==0) { + text = "√"; + }else{ + flag = "false";//有其他的异常状态,则表示为false,不需要处理直接全部显示即可 + } + text += overtime; + + + //需要处理下打卡时间和异常状态显示的顺序--start + tmpstatusdata.put(key, yichang); + tmpstatusdata.put(signkey, sign); + boolean hasyichang = tmpstatusdata.get(key).length()>0; + if(tmptext.length()>0){ +// text = tmpstatusdata.get(signkey)+(isWrap?"\r\n":"
")+tmpstatusdata.get(key)+(isWrap?"\r\n":"
"+overtime); + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + }else{ + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + } + //需要处理下打卡时间和异常状态显示的顺序--end + tmpdatass.put(key, (isWrap?"\r\n":"
")+overtime); + if(!"".equals(signintime)) { + textAM+=signintime; + } + if(!"".equals(signouttime)) { + textPM+=signouttime; + } + if(!"".equals(overtime)) { + textPM+=overtime; + } + data.put("text", textAM+""+textPM); + data.put("textAM", textAM); + data.put("textPM", textPM); +// text = tmptext.length()>0?tmptext+" "+text:text;//显示所有的状态 +// data.put("text", text); + datas.put(key, data); + + //add + tmpdata.put("text", flag); + tmpdatas.put(key, tmpdata); + //end + } + //全部搞一遍 +// if(tmpdatas != null){ +//// writeLog(n+">>>tmpdatas="+JSONObject.toJSONString(tmpdatas)); +// Map data1 = null; +// for(Entry entry : tmpdatas.entrySet()){ +// String mapKey = Util.null2String(entry.getKey()); +// Map mapValue = (Map)entry.getValue(); +// String flag = Util.null2String(mapValue.get("text")); +// if("true".equals(flag)){//需要加工的数据 +// String overtime = String.valueOf(tmpdatass.get(mapKey)); +// data1 = new HashMap<>(); +// data1.put("text", "√"+overtime); +// datas.put(mapKey, data1); +// } +// } +//// writeLog("datas="+JSONObject.toJSONString(datas)); +// } + }catch (Exception e){ + writeLog(e); + } + // 最后针对数据再处理一遍,不然出现2023-01-02: "休息" 形式的错误,导致页面记载报错,应该是2023-01-01: {text: "休息"}格式 +// boolean isEnd = false; +// for(String currentDate = fromDate; !isEnd;) { +// if (currentDate.equals(toDate)) isEnd = true; +// String dailyValue = Util.null2String(datas.get(currentDate)); +// if(!"".equals(dailyValue) && !dailyValue.contains("text")) { +// Map innerMap2 = new HashMap<>(); +// innerMap2.put("text", dailyValue); +// datas.put(currentDate, innerMap2); +// } +// currentDate = DateUtil.addDate(currentDate, 1); +// } + return datas; + } + + public Map getDetialDatas(String resourceId,String fromDate, String toDate, User user, + Map flowData,boolean isWrap,int uintType,String show_card_source){ + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + if(isKqReportHalfOpen) { + return getDetialDatasHalfOpen(resourceId, fromDate, toDate, user, flowData, isWrap, uintType, show_card_source); + } + return getDetialDatasHalfNotOpen(resourceId, fromDate, toDate, user, flowData, isWrap, uintType, show_card_source); + } + +// public String getSignStatus(Map data, User user){ +// String result = ""; +// String signtype = Util.null2String(data.get("signtype"));//上班 下班 +// String worktime = Util.null2String(data.get("worktime"));//工作时间 +// String signtime = Util.null2String(data.get("signtime"));//签到时间 +// String abnormalMins = Util.null2String(data.get("abnormalMins"));//异常分钟数 +// String forgotCheck = Util.null2String(data.get("forgotCheck"));//漏签 +// if(worktime.length()>0){ +// if(signtime.length()>0){ +// if(Util.getDoubleValue(abnormalMins)>0){ +// result =SystemEnv.getHtmlLabelName(signtype.equals("1")?20081:20082, user.getLanguage())+abnormalMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());//迟到 早退 +// }else{ +// result =SystemEnv.getHtmlLabelName(225, user.getLanguage());//正常 +// } +// }else if(forgotCheck.equals("1")){ +// result =SystemEnv.getHtmlLabelName(20086, user.getLanguage());//漏签 +// } +// }else{ +// result = ""; +// } +// +// return result; +// } + + public int getSerialCount(String resourceId, String fromDate, String toDate, String serialId){ + RecordSet rs = new RecordSet(); + String sql = ""; + int serialCount = 0; + try{ + sql = "select count(1) from hrmresource a, kq_format_total b where a.id= b.resourceid and b.resourceid = ? and b.kqdate >=? and b.kqdate <=? and b.serialId = ? "; + rs.executeQuery(sql,resourceId,fromDate,toDate, serialId); + if(rs.next()){ + serialCount = rs.getInt(1); + } + }catch (Exception e){ + writeLog(e); + } + return serialCount; + } + + public static String getSignStatus(Map signInfo, User user){ + return getSignStatus(signInfo,user,""); + } + + public static String getSignStatusHalfNotOpen(Map signInfo, User user,String onOrOff){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String text = ""; + String isneedcal = Util.null2String(signInfo.get("isneedcal")); + String workdate = Util.null2String(signInfo.get("workdate")); + String worktime = Util.null2String(signInfo.get("worktime")); + if(!new KQFormatBiz().needCal(workdate,worktime,isneedcal)) {//还未到时间无需计算 + return text; + } + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + + if(worktime.length()>0){ + if (absenteeismMins > 0) {//旷工 + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage())+absenteeismMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + }else { + if (beLateMins > 0) {//迟到 + text = SystemEnv.getHtmlLabelName(20081, user.getLanguage())+beLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + text = SystemEnv.getHtmlLabelName( 500546, user.getLanguage())+graveBeLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + text = SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + text = SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if(onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)){ + if (forgotBeginWorkCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + if(text.equals("")){ + boolean needCal = new KQFormatBiz().needCal(workdate,worktime,isneedcal); + text = needCal?SystemEnv.getHtmlLabelName(225, user.getLanguage()):""; + } + }else{ + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType)); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + } + return text; + } + + /** + * 应用设置开启了考勤汇总报表半天开关方法 + * @param signInfo + * @param user + * @param onOrOff + * @return + */ + public static String getSignStatusHalfOpen(Map signInfo, User user,String onOrOff){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + String split_time = Util.null2s(kqTimesArrayComInfo.getPropValue("qc1054152","split_time"),"13:00"); + int split_time_index = kqTimesArrayComInfo.getArrayindexByTimes(split_time); + String text = ""; + String isneedcal = Util.null2String(signInfo.get("isneedcal")); + String workdate = Util.null2String(signInfo.get("workdate")); + String worktime = Util.null2String(signInfo.get("worktime")); + String flowinfo = Util.null2String(signInfo.get("flowinfo")); + boolean isNonWork = Util.str2bool(Util.null2String(signInfo.get("isNonWork"))); + if(!new KQFormatBiz().needCal(workdate,worktime,isneedcal)) {//还未到时间无需计算 + return text; + } + String resourceId = Util.null2String(signInfo.get("resourceId")); + String kqDate = Util.null2String(signInfo.get("kqdate")); + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceId, kqDate, false); + if(shiftInfoBean == null || isNonWork) { + text = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + if(shiftInfoBean != null) { + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if (halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } + } + if(flowinfo.length() > 0) { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonObject.containsKey(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + if (jsonKey.length() > 0) { + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + if ("on".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + if ("off".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else { + //全天 + text = jsonValue; + } + } + } + } + } + } + } + return text; + } + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if(halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + + int on_absenteeismmins = Util.getIntValue(Util.null2String(signInfo.get("on_absenteeismmins"))); + int off_absenteeismmins = Util.getIntValue(Util.null2String(signInfo.get("off_absenteeismmins"))); + + String workbeigintime = Util.null2String(signInfo.get("workbegintime")); + String workendtime = Util.null2String(signInfo.get("workendtime")); + String halfPoint = shiftInfoBean.getHalfcalpoint(); + int halfPointIndex = kqTimesArrayComInfo.getArrayindexByTimes(halfPoint); + + if(worktime.length()>0){ +// if (on_absenteeismmins > 0) {//上午旷工 +// text = SystemEnv.getHtmlLabelName(20085, user.getLanguage())+absenteeismMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// }else { +// if (beLateMins > 0) {//迟到 +// text = SystemEnv.getHtmlLabelName(20081, user.getLanguage())+beLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (graveBeLateMins > 0) {//严重迟到 +// text = SystemEnv.getHtmlLabelName( 500546, user.getLanguage())+graveBeLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (leaveEarlyMins > 0) {//早退 +// text = SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (graveLeaveEarlyMins > 0) {//严重早退 +// text = SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (forgotCheckMins > 0) {//漏签 +// text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); +// } +// if(onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)){ +// if (forgotBeginWorkCheckMins > 0) {//漏签 +// text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); +// } +// } +// } + + if("on".equalsIgnoreCase(onOrOff)) { + if (on_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if (beLateMins > 0) {//迟到 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()) + beLateMins + SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()) + graveBeLateMins + SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + if("off".equalsIgnoreCase(onOrOff)){ + if(off_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + + if(flowinfo.length() > 0){ + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + if(jsonKey.length() > 0){ + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if(jsonArray != null && !jsonArray.isEmpty()){ + //客户不存在多个重复流程的情况,只是显示第一个就行 + for(int i = 0 ; i < jsonArray.size() ; i++){ + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if(jsonObject1 != null && !jsonObject1.isEmpty()){ + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")),""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")),""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")),""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + + if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + if(newLeaveType.length() > 0){ + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if(beginIdx <= split_time_index && endIdx <= split_time_index){ + //上午 + if("on".equalsIgnoreCase(onOrOff)){ + if(begintime.equals(workbeigintime) && endIdx == halfPointIndex) { + text = ""; + } else if(begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + text = ""; + } + text = jsonValue+("".equals(text) ? "":", "+text); + } + }else if(beginIdx >= split_time_index && endIdx >= split_time_index){ + //下午 + if("off".equalsIgnoreCase(onOrOff)){ + if(endIdx == halfPointIndex && endtime.equals(workendtime)) { + text = ""; + } else if(begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + text = ""; + } + text = jsonValue+("".equals(text) ? "":", "+text); + } + }else { + //全天 + if(begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + text = ""; + } + text = jsonValue+("".equals(text) ? "":", "+text); + } + } + if(text.length() > 0){ + break; + } + } + } + } + } + } + + if(text.equals("")){ + boolean needCal = new KQFormatBiz().needCal(workdate,worktime); + text = needCal? SystemEnv.getHtmlLabelName(225, user.getLanguage()):""; + } + }else{ + text = SystemEnv.getHtmlLabelName(225, user.getLanguage()); + if("on".equalsIgnoreCase(onOrOff)){ + if(on_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + } + if("off".equalsIgnoreCase(onOrOff)){ + if(off_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + } + if(flowinfo.length() > 0) { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonObject.containsKey(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + if (jsonKey.length() > 0) { + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + if ("on".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + if ("off".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else { + //全天 + text = jsonValue; + } + } + } + } + } + } + } + if(text.length() == 0){ + text = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } + } + return text; + } + + public static String getSignStatus(Map signInfo, User user,String onOrOff){ + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + if(isKqReportHalfOpen) { + return getSignStatusHalfOpen(signInfo, user, onOrOff); + } + return getSignStatusHalfNotOpen(signInfo, user, onOrOff); + } + + /** + * 获取打卡状态(不包含具体分钟数) + * @param signInfo + * @param user + * @param onOrOff + * @return + */ + public static String getSignStatus2(Map signInfo, User user, String onOrOff) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String text = ""; + String worktime = Util.null2String(signInfo.get("worktime")); + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + Boolean isNonWork = (Boolean) signInfo.get("isNonWork"); + + if (!isNonWork) { + if (absenteeismMins > 0) {//旷工 + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } else { + if (beLateMins > 0) {//迟到 + text = SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + text = SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + text = SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + text = SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if (onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)) { + if (forgotBeginWorkCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + if (text.equals("") && leaveMins <= 0 && evectionMins <= 0 && outMins <= 0) { + text = SystemEnv.getHtmlLabelName(225, user.getLanguage()); + } + } + return text; + } + + public static boolean getShowFlowText(String leaveInfo,String onOrOff){ + Map jsonObject = null; + jsonObject = JSON.parseObject(leaveInfo); + String flow_signtype = ""; + for (Entry entry : jsonObject.entrySet()) { + String tmpSignType = Util.null2String(entry.getValue()); + flow_signtype += ","+tmpSignType; + } + if(flow_signtype.length() == 0){ + return true; + } + return isShowFlowText(flow_signtype,onOrOff); + } + + public static boolean isShowFlowText(String flow_signtype,String onOrOff){ + boolean showFlowText = true; + + if(flow_signtype.length() > 0){ + flow_signtype = flow_signtype.substring(1); + if("on".equalsIgnoreCase(onOrOff)){ + if((","+flow_signtype+",").indexOf(",1,") > -1){ + //抵扣了上班卡 + }else{ + //上班状态,但是没有上班抵扣流程 + showFlowText = false; + } + } + if("off".equalsIgnoreCase(onOrOff)){ + if((","+flow_signtype+",").indexOf(",2,") > -1){ + //抵扣了下班卡 + }else{ + //下班状态,但是没有下班抵扣流程 + showFlowText = false; + } + } + } + return showFlowText; + } + + public static int getPageSize(String pageSize, String pageUid, int userid){ + String sql = ""; + RecordSet rs = new RecordSet(); + int iPageSize= Util.getIntValue(pageSize,10); + if(iPageSize<10)iPageSize=10; + try{ + if(pageSize.length()>0){ + boolean flag = false; + sql = "select count(1) from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + flag = true; + } + } + if(flag){ + sql = "update ecology_pagesize set pagesize ="+pageSize+" where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeUpdate(sql); + }else{ + sql = "insert into ecology_pagesize (pageid,pagesize,userid) values ('"+pageUid+"',"+pageSize+","+userid+")"; + rs.executeUpdate(sql); + } + }else{ + sql = "select pageSize from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeQuery(sql); + if(rs.next()){ + iPageSize = rs.getInt("pageSize"); + } + } + }catch (Exception e){ + new BaseBean().writeLog("KQReportBiz.getPageSize"+e); + } + + return iPageSize; + } + + //经常遇到申请变更流程或销假流程提示未归档,不胜其烦,所以搞一下 + public void reflow(String requestid){ + try { + requestid = Util.null2String(requestid); + String workflowid = ""; + String currentnodetype = ""; + if(requestid.length() == 0){ + return; + } + RecordSet rs2 = new RecordSet(); + String sql = "select requestid,workflowid,currentnodetype from workflow_requestbase where requestid = '"+requestid+"'"; + rs2.executeQuery(sql); + if(rs2.next()){ + workflowid = Util.null2String(rs2.getString("workflowid")); + currentnodetype = Util.null2String(rs2.getString("currentnodetype")); + } + + boolean isForce1 = false; + boolean isUpgrade1 = false; + if(requestid.length() == 0){ + return ; + } + if(workflowid.length() == 0){ + return ; + } + if(!"3".equals(currentnodetype)){ + return ; + } + long start = System.currentTimeMillis(); + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? "; + rs.executeQuery(proc_set_sql, workflowid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + + Map map = new HashMap(); + if(Util.getIntValue(requestid) > 0){ + map.put("requestId", "and t.requestId = " + requestid); + } + String tablename = ""; + if(kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVE.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.EVECTION.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OUT.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OVERTIME.getTablename(); + return; + }else if(kqtype == KqSplitFlowTypeEnum.SHIFT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.SHIFT.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.OTHER.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OTHER.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.CARD.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.CARD.getTablename();; + return; + }else if(kqtype == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVEBACK.getTablename();; + }else{ + return; + } + if(null != tablename && tablename.length() > 0){ + String tmpsql = "select * from "+tablename+" where requestId="+requestid; + rs1.executeQuery(tmpsql); + if(rs1.next()){ + return;//表示已经产生了拆分数据 + } + } + + //先根据requestid删除中间表里的数据,再做啥插入操作 + if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()) { + return;//加班就不搞了,有遇到用户销假选择错误流程,选择了加班流程导致这里reflow一次,多余生成了调休 + }else{ + String delSql = "delete from "+tablename+" where requestid = "+requestid; + rs1.executeUpdate(delSql); + Map result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, Util.getIntValue(requestid), kqtype, Util.getIntValue(workflowid), isForce1,isUpgrade1,map); + } + + } + long end = System.currentTimeMillis(); + }catch (Exception e){ + e.printStackTrace();; + } + } + + + //add + public Map getOverTime(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = Util.getIntValue(Util.null2String(params.get("uintType")));//当前加班单位 + double hoursToDay = Util.getDoubleValue(Util.null2String(params.get("hoursToDay")));//当前天跟小时计算关系 + + String valueField = ""; + + sql = " select resourceid,belongdate,paidLeaveEnable,duration_min "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " order by resourceid,belongdate "; + rs.execute(sql); +// kqLog.info("getOverTime:sql:"+sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); +// int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("duration_min")<0?0:rs.getDouble("duration_min"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String key = resourceid+"|"+belongdate+"|overtime"; + if(value>0){ + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + +// if(datas.containsKey(key)){ +// datas.put(key,"加班"); +//// datas.put(key,SystemEnv.getHtmlLabelName(6151, user.getLanguage())); +// }else{ +// datas.put(key,"加班"); +// } + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } +} diff --git a/数智制造/src/com/engine/shuzhi/entity/po/ModeStaffPO.java b/数智制造/src/com/engine/shuzhi/entity/po/ModeStaffPO.java new file mode 100644 index 0000000..c1e9156 --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/entity/po/ModeStaffPO.java @@ -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); + } + + +} diff --git a/数智制造/src/com/engine/shuzhi/exception/CustomizeRunTimeException.java b/数智制造/src/com/engine/shuzhi/exception/CustomizeRunTimeException.java new file mode 100644 index 0000000..0449f2b --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/exception/CustomizeRunTimeException.java @@ -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); + } +} diff --git a/数智制造/src/com/engine/shuzhi/service/SzBatchExportService.java b/数智制造/src/com/engine/shuzhi/service/SzBatchExportService.java new file mode 100644 index 0000000..0290feb --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/service/SzBatchExportService.java @@ -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 downloadResourceFile(List idList); + + /** + * 下载合同附件 + * + * @param idList 所选记录ID + * @return 文件名称、文件路径 + */ + Map downloadContractFile(List idList); + +} diff --git a/数智制造/src/com/engine/shuzhi/service/SzDataCenterService.java b/数智制造/src/com/engine/shuzhi/service/SzDataCenterService.java new file mode 100644 index 0000000..bdc5349 --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/service/SzDataCenterService.java @@ -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 updateResume(Map params, User user); + +} diff --git a/数智制造/src/com/engine/shuzhi/service/SzResumeCenterService.java b/数智制造/src/com/engine/shuzhi/service/SzResumeCenterService.java new file mode 100644 index 0000000..59da956 --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/service/SzResumeCenterService.java @@ -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 updateResume(Map params); + Map getResumeInfo(Map params); +} diff --git a/数智制造/src/com/engine/shuzhi/service/impl/SzBatchExportServiceImpl.java b/数智制造/src/com/engine/shuzhi/service/impl/SzBatchExportServiceImpl.java new file mode 100644 index 0000000..eb02466 --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/service/impl/SzBatchExportServiceImpl.java @@ -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 downloadResourceFile(List idList) { + Map 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 downloadContractFile(List idList) { + Map 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('.')); + } +} diff --git a/数智制造/src/com/engine/shuzhi/service/impl/SzDataCenterServiceImpl.java b/数智制造/src/com/engine/shuzhi/service/impl/SzDataCenterServiceImpl.java new file mode 100644 index 0000000..8e7177a --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/service/impl/SzDataCenterServiceImpl.java @@ -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 updateResume(Map params, User user) { + Map 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> qsxx = new ArrayList<>(); + //教育经历 + List> jyjl = new ArrayList<>(); + //工作经历 + List> gzjl = new ArrayList<>(); + //证书列表 + List> 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 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 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 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 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> qsxx, List> jyjl, List> gzjl, List> 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> qsxxlist = new ArrayList<>(); + for (int i = 0; i < qsxx.size(); i++) { + Map 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 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> jyjllist = new ArrayList<>(); + for (int i = 0; i < jyjl.size(); i++) { + Map 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 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> gzjllist = new ArrayList<>(); + for (int i = 0; i < gzjl.size(); i++) { + Map 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 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> zslblist = new ArrayList<>(); + for (int i = 0; i < zslb.size(); i++) { + Map 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 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> qsxx, List> jyjl, List> gzjl, List> 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> qsxxlist = new ArrayList<>(); + for (int i = 0; i < qsxx.size(); i++) { + Map 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 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> jyjllist = new ArrayList<>(); + for (int i = 0; i < jyjl.size(); i++) { + Map 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 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> gzjllist = new ArrayList<>(); + for (int i = 0; i < gzjl.size(); i++) { + Map 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 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> zslblist = new ArrayList<>(); + for (int i = 0; i < zslb.size(); i++) { + Map 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 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; + } + +} diff --git a/数智制造/src/com/engine/shuzhi/service/impl/SzResumeCenterServiceImpl.java b/数智制造/src/com/engine/shuzhi/service/impl/SzResumeCenterServiceImpl.java new file mode 100644 index 0000000..648fd8a --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/service/impl/SzResumeCenterServiceImpl.java @@ -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 getResumeInfo(Map params) { + Map 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 updateResume(Map params) { + Map 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> qsxx = new ArrayList<>(); + //教育经历 + List> jyjl = new ArrayList<>(); + //工作经历 + List> gzjl = new ArrayList<>(); + //证书列表 + List> 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 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 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 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 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> qsxx, List> jyjl, List> gzjl, List> 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> qsxxlist = new ArrayList<>(); + for (int i = 0; i < qsxx.size(); i++) { + Map 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 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> jyjllist = new ArrayList<>(); + for (int i = 0; i < jyjl.size(); i++) { + Map 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 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> gzjllist = new ArrayList<>(); + for (int i = 0; i < gzjl.size(); i++) { + Map 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 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> zslblist = new ArrayList<>(); + for (int i = 0; i < zslb.size(); i++) { + Map 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 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> qsxx, List> jyjl, List> gzjl, List> 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> qsxxlist = new ArrayList<>(); + for (int i = 0; i < qsxx.size(); i++) { + Map 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 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> jyjllist = new ArrayList<>(); + for (int i = 0; i < jyjl.size(); i++) { + Map 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 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> gzjllist = new ArrayList<>(); + for (int i = 0; i < gzjl.size(); i++) { + Map 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 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> zslblist = new ArrayList<>(); + for (int i = 0; i < zslb.size(); i++) { + Map 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 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; + } + + +} diff --git a/数智制造/src/com/engine/shuzhi/util/ExceptionUtil.java b/数智制造/src/com/engine/shuzhi/util/ExceptionUtil.java new file mode 100644 index 0000000..7b898e6 --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/util/ExceptionUtil.java @@ -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 ""; + } +} diff --git a/数智制造/src/com/engine/shuzhi/util/ResponseResult.java b/数智制造/src/com/engine/shuzhi/util/ResponseResult.java new file mode 100644 index 0000000..de19a74 --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/util/ResponseResult.java @@ -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; + +/** + * 请求执行器 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class ResponseResult { + + 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 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 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 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 apidatas = new HashMap<>(); + apidatas.put("status", true); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + * 成功返回 + */ + private String Ok(R r) { + Map 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 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 apidatas = new HashMap<>(); + apidatas.put("status", false); + apidatas.put("errormsg", message); + apidatas.put("error", e.getMessage()); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + +} diff --git a/数智制造/src/com/engine/shuzhi/web/SzBatchExportController.java b/数智制造/src/com/engine/shuzhi/web/SzBatchExportController.java new file mode 100644 index 0000000..1d72364 --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/web/SzBatchExportController.java @@ -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 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 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 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 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(); + } + + +} diff --git a/数智制造/src/com/engine/shuzhi/web/SzDataCenterController.java b/数智制造/src/com/engine/shuzhi/web/SzDataCenterController.java new file mode 100644 index 0000000..cc3784a --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/web/SzDataCenterController.java @@ -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 apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map 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); + } + + + + +} diff --git a/数智制造/src/com/engine/shuzhi/web/SzResumeController.java b/数智制造/src/com/engine/shuzhi/web/SzResumeController.java new file mode 100644 index 0000000..e2ce9cb --- /dev/null +++ b/数智制造/src/com/engine/shuzhi/web/SzResumeController.java @@ -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 apidatas = new HashMap(); + try { + Map 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 apidatas = new HashMap(); + try { + Map 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); + } + +} diff --git a/数智制造/src/weaver/hrm/pm/action/SyndeliUserRzAction.java b/数智制造/src/weaver/hrm/pm/action/SyndeliUserRzAction.java new file mode 100644 index 0000000..a9dd132 --- /dev/null +++ b/数智制造/src/weaver/hrm/pm/action/SyndeliUserRzAction.java @@ -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 + "
"); + log.writeLog("secret:" + secret + "
"); + + 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 + "
"); + log.writeLog("appSig:" + appSig + "
"); + + Map heads = new HashMap(); + 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 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 + "
"); + log.writeLog("lastname:" + lastname + "
"); + log.writeLog("mobile:" + mobile + "
"); + + log.writeLog("deptcode:" + deptcode + "
"); + log.writeLog("deptname:" + deptname + "
"); + log.writeLog("deptid:" + deptid + "
"); + log.writeLog("subcompanyid1:" + subcompanyid1 + "
"); + + int errorcount = 0; + log.writeLog("key:" + key + "
"); + log.writeLog("secret:" + secret + "
"); + int errorcount1 = updateSubcompanyData2(subcompanyid1, key, secret); + errorcount = errorcount + errorcount1; + log.writeLog("errorcount1:" + errorcount1 + "
"); + + int errorcount2 = updateDeptData(deptid, key, secret); + errorcount = errorcount + errorcount2; + log.writeLog("errorcount2:" + errorcount2 + "
"); + + if (errorcount == 0) { + + Map dataMap = new HashMap(); + dataMap.put("employee_ext_id", workcode); + dataMap.put("name", lastname); + dataMap.put("mobile", mobile); + dataMap.put("employee_num", workcode); + + List> department_infolist = new ArrayList>(); + Map department_infos = new HashMap(); + 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) + "
"); + log.writeLog("employee-body:" + JSONObject.toJSONString(dataMap) + "
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + log.writeLog("employee-response:" + back + "
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + log.writeLog("employee-code:" + code + "
"); + if (!"0".equals(code)) { + errorcount++; + } + } + } + return SUCCESS; + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + return FAILURE_AND_CONTINUE; + } + + + public List> getSubcompanyListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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> getDeptListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 + "
"); + HttpEntity entity = resp.getEntity(); + bb.writeLog("sendRequest-entity:" + entity + "
"); + result = (entity == null ? null : EntityUtils.toString((HttpEntity) entity, Consts.UTF_8)); + bb.writeLog("sendRequest-result:" + result + "
"); + 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 socketFactoryRegistry = RegistryBuilder.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 getUserData(String sfzh){ + + Map userMap = new HashMap(); + 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" +"
"); + bb.writeLog("updateSubcompanyData2:subcompanyid1" +subcompanyid1+"
"); + bb.writeLog("updateSubcompanyData2:key" +key+"
"); + bb.writeLog("updateSubcompanyData2:secret" +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 heads = new HashMap(); + 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> childSubcompanyList = getSubcompanyListByParentid(subcompanyid1); + bb.writeLog("updateSubcompanyData2:childSubcompanyList" +childSubcompanyList+"
"); + for(int k=0;k childSubcompanyMap = childSubcompanyList.get(k); + String subcompanycode = childSubcompanyMap.get("subcompanycode"); + String subcompanyname = childSubcompanyMap.get("subcompanyname"); + String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode"); + bb.writeLog("updateSubcompanyData2:supsubcompanycode" +supsubcompanycode+"
"); + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", supsubcompanycode); + bb.writeLog("updateSubcompanyData2:dataMap" +dataMap+"
"); + String back = null; + try { + String jsonString = JSON.toJSONString(dataMap); + bb.writeLog("updateSubcompanyData:jsonString" + jsonString + "
"); + back = doPostJsonRequest(url, heads, jsonString); + bb.writeLog("updateSubcompanyData:back" + back + "
"); + } catch (IOException e) { + bb.writeLog("updateSubcompanyData2:IOException" +e.getMessage()+"
"); + throw new RuntimeException(e); + } + JSONObject backObj = JSONObject.parseObject(back); + bb.writeLog("updateSubcompanyData:backObj" + backObj + "
"); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + if (!"0".equals(code)) { + errorcount++; + } + } + bb.writeLog("updateSubcompanyData:" + errorcount + "
"); + bb.writeLog("updateSubcompanyData2:end" +"
"); + return errorcount; + } + + + public int updateDeptData(String deptid,String key,String secret){ + BaseBean bb = new BaseBean(); + bb.writeLog("updateDeptData:start" +"
"); + bb.writeLog("updateDeptData:deptid" +deptid+"
"); + bb.writeLog("updateDeptData:key" +key+"
"); + bb.writeLog("updateDeptData:secret" +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 heads = new HashMap(); + 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> childDepartmentList = getDeptListByParentid(deptid); + for(int k=0;k childDepartmentMap = childDepartmentList.get(k); + String departmentcode = childDepartmentMap.get("departmentcode"); + String departmentname = childDepartmentMap.get("departmentname"); + String supdeptcode = childDepartmentMap.get("supdeptcode"); + + Map dataMap = new HashMap(); + 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()+"
"); + 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 + "
"); + bb.writeLog("updateDeptData:end" +"
"); + 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; + } + + +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/action/PendingEmploymentModeAction.java b/数智制造/src/weaver/interfaces/shuzhi/action/PendingEmploymentModeAction.java new file mode 100644 index 0000000..8875807 --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/action/PendingEmploymentModeAction.java @@ -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); + } +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/cronjob/EcologyToDelicloudUtil.java b/数智制造/src/weaver/interfaces/shuzhi/cronjob/EcologyToDelicloudUtil.java new file mode 100644 index 0000000..4ff66ab --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/cronjob/EcologyToDelicloudUtil.java @@ -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+"
"); + bb.writeLog("secret:"+secret+"
"); + + if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(secret)){ + + String sjc = String.valueOf(Calendar.getInstance().getTimeInMillis()); + String appSig = getAppSigData(path,key,secret,sjc); + + Map heads = new HashMap(); + 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 dataMap = new HashMap(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } + + + +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/cronjob/RelationshipReminderJob.java b/数智制造/src/weaver/interfaces/shuzhi/cronjob/RelationshipReminderJob.java new file mode 100644 index 0000000..59219bc --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/cronjob/RelationshipReminderJob.java @@ -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; + +/** + * 员工关系提醒流程-计划任务 + *

+ * 从转正记录(uf_zzjl)、员工调动记录(uf_ddjl)、离职办理查询表单(uf_lzblcxbd), + * + *

+ * 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 + "' + * + *

+ * 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 + "' + * + *

+ * 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+"'"); + } + + +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyncBlackListJob.java b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyncBlackListJob.java new file mode 100644 index 0000000..cd97d4c --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyncBlackListJob.java @@ -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("######定时更新人员简历黑名单状态,任务结束######"); + } +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyncModeStaffJob.java b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyncModeStaffJob.java new file mode 100644 index 0000000..ba19e3c --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyncModeStaffJob.java @@ -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 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 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("######编制数据同步服务,任务结束######"); + } +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyndeliOrgJob.java b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyndeliOrgJob.java new file mode 100644 index 0000000..50d9a8a --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyndeliOrgJob.java @@ -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+"
"); + bb.writeLog("secret:"+secret+"
"); + + 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+"
"); + bb.writeLog("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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> topSubcompanyList = getTopSubcompanyList(); + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompanycode = topSubcompanyMap.get("subcompanycode"); + String subcompanyname = topSubcompanyMap.get("subcompanyname"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", ""); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + bb.writeLog("response:"+back+"
"); + + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + bb.writeLog("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + bb.writeLog("接口调用失败"); + } + } + + bb.writeLog("kao----------------------:"+"
"); + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompany_id = topSubcompanyMap.get("subcompanyid"); + bb.writeLog("subcompany_id:"+subcompany_id+"
"); + List> childSubcompanyList = getSubcompanyListByParentid(subcompany_id); + bb.writeLog("分部组织长度:"+childSubcompanyList.size()+"
"); + for(int k=0;k childSubcompanyMap = childSubcompanyList.get(k); + String subcompanycode = childSubcompanyMap.get("subcompanycode"); + String subcompanyname = childSubcompanyMap.get("subcompanyname"); + String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", supsubcompanycode); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("Subcompany-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 data = backObj.getString("data"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + } + } + } + + List> topDepartmentList = getTopDeptList(); + for(int i=0;i topDepartmentMap = topDepartmentList.get(i); + String departmentcode = topDepartmentMap.get("departmentcode"); + String departmentname = topDepartmentMap.get("departmentname"); + String subcompanycode = topDepartmentMap.get("subcompanycode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", subcompanycode); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("top-dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + bb.writeLog("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + bb.writeLog("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + } + } + + for(int i=0;i topDeptMap = topDepartmentList.get(i); + String deptid = topDeptMap.get("deptid"); + + List> childDepartmentList = getDeptListByParentid(deptid); + for(int k=0;k childDepartmentMap = childDepartmentList.get(k); + String departmentcode = childDepartmentMap.get("departmentcode"); + String departmentname = childDepartmentMap.get("departmentname"); + String supdeptcode = childDepartmentMap.get("supdeptcode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", supdeptcode); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + bb.writeLog("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + bb.writeLog("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + } + } + } + } + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + } + + + /*** + * + * @return + */ + public List> getTopSubcompanyList(){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanyid",subcompany_id); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + list.add(map); + } + return list; + } + + + public List> getSubcompanyListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + BaseBean bb = new BaseBean(); + Map 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(); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + map.put("supsubcomid",sup_subcomid); + map.put("supsubcompanycode",supsubcompanycode); + list.add(map); + } + return list; + } + + + + public List> getTopDeptList(){ + List> list = new ArrayList>(); + Map 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(); + map.put("departmentcode",departmentcode); + map.put("departmentname",departmentname); + map.put("deptid",deptid); + map.put("subcompanycode",subcompanycode); + list.add(map); + } + return list; + } + + + public List> getDeptListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyndeliOrgJob4Subcompany.java b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyndeliOrgJob4Subcompany.java new file mode 100644 index 0000000..a040c8f --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/cronjob/SyndeliOrgJob4Subcompany.java @@ -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+"
"); + bb.writeLog("secret:"+secret+"
"); + + 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+"
"); + bb.writeLog("appSig:"+appSig+"
"); + + Map heads = new HashMap(); + 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> topSubcompanyList = getTopSubcompanyList(); + bb.writeLog("topSubcompanyList:"+topSubcompanyList.size()); + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompanycode = topSubcompanyMap.get("subcompanycode"); + String subcompanyname = topSubcompanyMap.get("subcompanyname"); + bb.writeLog("subcompanyname:"+subcompanyname); + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", ""); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("top-subcompany-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + bb.writeLog("response:"+back+"
"); + + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + bb.writeLog("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + bb.writeLog("接口调用失败"); + } + } + + bb.writeLog("kao----------------------:"+"
"); + for(int i=0;i topSubcompanyMap = topSubcompanyList.get(i); + String subcompany_id = topSubcompanyMap.get("subcompanyid"); + bb.writeLog("subcompany_id:"+subcompany_id+"
"); + allSubcompanyid += StringUtils.isBlank(allSubcompanyid) ? subcompany_id : ","+subcompany_id ; + List> childSubcompanyList = getSubcompanyListByParentid(subcompany_id); + bb.writeLog("childSubcompanyList:"+childSubcompanyList.size()+""); + for(int k=0;k childSubcompanyMap = childSubcompanyList.get(k); + String subcompanycode = childSubcompanyMap.get("subcompanycode"); + String subcompanyname = childSubcompanyMap.get("subcompanyname"); + String supsubcompanycode = childSubcompanyMap.get("supsubcompanycode"); + bb.writeLog("subcompanycode:"+subcompanycode+""); + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", subcompanycode); + dataMap.put("name", subcompanyname); + dataMap.put("p_ext_id", supsubcompanycode); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("Subcompany-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 data = backObj.getString("data"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + } + } + } + + List> topDepartmentList = getTopDeptList(allSubcompanyid); + bb.writeLog("topDepartmentList:"+topDepartmentList.size()+""); + for(int i=0;i topDepartmentMap = topDepartmentList.get(i); + String departmentcode = topDepartmentMap.get("departmentcode"); + String departmentname = topDepartmentMap.get("departmentname"); + String subcompanycode = topDepartmentMap.get("subcompanycode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", subcompanycode); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("top-dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + bb.writeLog("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + bb.writeLog("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + } + } + + for(int i=0;i topDeptMap = topDepartmentList.get(i); + String deptid = topDeptMap.get("deptid"); + bb.writeLog("deptid:"+deptid+""); + List> childDepartmentList = getDeptListByParentid(deptid); + bb.writeLog("childDepartmentList:"+childDepartmentList.size()+""); + for(int k=0;k childDepartmentMap = childDepartmentList.get(k); + String departmentcode = childDepartmentMap.get("departmentcode"); + String departmentname = childDepartmentMap.get("departmentname"); + String supdeptcode = childDepartmentMap.get("supdeptcode"); + + Map dataMap = new HashMap(); + dataMap.put("department_ext_id", departmentcode); + dataMap.put("name", departmentname); + dataMap.put("p_ext_id", supdeptcode); + + bb.writeLog("headers:"+JSONObject.toJSONString(heads)+"
"); + bb.writeLog("dept-body:"+JSONObject.toJSONString(dataMap)+"
"); + + String back = doPostJsonRequest(url, heads, JSON.toJSONString(dataMap)); + bb.writeLog("response:" + back); + bb.writeLog("response:"+back+"
"); + JSONObject backObj = JSONObject.parseObject(back); + String code = backObj.getString("code"); + String data = backObj.getString("data"); + bb.writeLog("code:"+code+"
"); + if ("0".equals(code)) { + bb.writeLog("新接口调用成功"); + JSONObject dataObj = JSONObject.parseObject(data); + bb.writeLog("dataObj:"+dataObj.toJSONString()+"
"); + } else { + bb.writeLog("接口调用失败"); + } + } + } + } + } catch (Exception e) { + bb.writeLog("数据异常!"); + bb.writeLog(e.getMessage()); + } + } + + + /*** + * + * @return + */ + public List> getTopSubcompanyList(){ + List> list = new ArrayList>(); + Map 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(); + map.put("subcompanyid",subcompany_id); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + list.add(map); + } + return list; + } + + + public List> getSubcompanyListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + BaseBean bb = new BaseBean(); + Map 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(); + map.put("subcompanycode",subcompanycode); + map.put("subcompanyname",subcompanyname); + map.put("supsubcomid",sup_subcomid); + map.put("supsubcompanycode",supsubcompanycode); + list.add(map); + } + return list; + } + + + + public List> getTopDeptList(String allSubcompanyid){ + List> list = new ArrayList>(); + Map 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(); + map.put("departmentcode",departmentcode); + map.put("departmentname",departmentname); + map.put("deptid",deptid); + map.put("subcompanycode",subcompanycode); + list.add(map); + } + return list; + } + + + public List> getDeptListByParentid(String supsubcomid){ + List> list = new ArrayList>(); + Map 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(); + 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 headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + + public static String doPostJsonRequest(String url, Map 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 socketFactoryRegistry = RegistryBuilder.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; + } +} diff --git a/数智制造/src/weaver/interfaces/shuzhi/util/WorkflowUtil.java b/数智制造/src/weaver/interfaces/shuzhi/util/WorkflowUtil.java new file mode 100644 index 0000000..a1c4d24 --- /dev/null +++ b/数智制造/src/weaver/interfaces/shuzhi/util/WorkflowUtil.java @@ -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格式的主表数据=<字段名称,字段值> + * @param @return 设定⽂件 + * @return String 返回类型 + * @throws + * @Title: WorkflowCreateByMainTableMap + */ + public String WorkflowCreateByMainTableMap(String creatorId, String workflowId, String requestName, String IsNextFlow, Map 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 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; + } +}