Compare commits

...

2 Commits

Author SHA1 Message Date
youhong.ai e2e0ae2c0b 合并 2023-06-16 18:13:01 +08:00
youhong.ai da145d2d32 保时捷关键字定位aciton,流程参数检查 2023-06-16 18:09:12 +08:00
27 changed files with 849 additions and 190 deletions

View File

@ -0,0 +1,16 @@
package aiyh.utils.annotation.recordset;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* <p>create: 2023/6/16 13:02</p>
*
* @author youHong.ai
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface ToLowerCase {
}

View File

@ -1,4 +1,4 @@
package aiyh.utils.ecologyutil.rightutil; package aiyh.utils.ecologyutil.timeutil;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.httpUtil.cushttpclasses.CusHttpServletRequest; import aiyh.utils.httpUtil.cushttpclasses.CusHttpServletRequest;
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd; import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import weaver.hrm.User; import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.util.HashMap; import java.util.HashMap;
@ -15,54 +16,55 @@ import java.util.Map;
/** /**
* ecology * ecology
*
*/ */
public class RightMoveUtil { public class TimeUtil {
private static Logger logger = Util.getLogger(); private static final Logger logger = Util.getLogger();
/** /**
* *
* @param param *
* fromid * @param param
* toid * fromid
* T133All * toid
* T133AllNum * T133All
* @return * T133AllNum
*/ * @return
public static JSONObject moveRight(JSONObject param){ */
JSONObject result = new JSONObject(); public static JSONObject moveRight(JSONObject param) {
try{ JSONObject result = new JSONObject();
logger.info("RightMoveUtil moveRight begin;param:" + param.toJSONString()); try {
Map<String, Object> params = new HashMap<>(); logger.info("RightMoveUtil moveRight begin;param:" + param.toJSONString());
for(Object key : param.keySet()){ Map<String, Object> params = new HashMap<>();
params.put(key.toString(),param.get(key)); for (Object key : param.keySet()) {
} params.put(key.toString(), param.get(key));
HttpServletRequest request = new CusHttpServletRequest(){ }
@Override HttpServletRequest request = new CusHttpServletRequest() {
public String getParameter(String s) { @Override
return param.getString(s); public String getParameter(String s) {
} return param.getString(s);
@Override }
public HttpSession getSession(boolean b) {
HttpSession session = new CusHttpSession(){ @Override
@Override public HttpSession getSession(boolean b) {
public Object getAttribute(String s) { HttpSession session = new CusHttpSession() {
return new User(1); @Override
} public Object getAttribute(String s) {
}; return new User(1);
return session; }
} };
}; return session;
ProcessDataCmd cmd = new ProcessDataCmd(params,request,new User(1)); }
Map<String, Object> execute = cmd.execute(null); };
result = new JSONObject(execute); ProcessDataCmd cmd = new ProcessDataCmd(params, request, new User(1));
logger.info("RightMoveUtil moveRight end;result:" + execute.toString()); Map<String, Object> execute = cmd.execute(null);
return result; result = new JSONObject(execute);
}catch (Throwable e){ logger.info("RightMoveUtil moveRight end;result:" + execute);
logger.error("RightMoveUtil moveRight error;message:" + e.getMessage()); return result;
return result; } catch (Throwable e) {
} logger.error("RightMoveUtil moveRight error;message:" + e.getMessage());
} return result;
}
}
} }

View File

@ -0,0 +1,86 @@
package aiyh.utils.fileUtil;
import aiyh.utils.excention.CustomerException;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* <h1>word</h1>
*
* @author ebu7-dev1 youhong.ai
*/
public class WordKeywordFinder {
/**
* <h2></h2>
*
* @param inputStream
* @param keyword
* @param fileName
* @return
* @throws IOException io
*/
public static List<KeywordLocation> findKeywords(InputStream inputStream, String keyword, String fileName) {
try {
List<KeywordLocation> keywordLocations = new ArrayList<>();
if (fileName.endsWith(".docx")) {
XWPFDocument docx = new XWPFDocument(inputStream);
XWPFWordExtractor extractor = new XWPFWordExtractor(docx);
String text = extractor.getText();
String[] paragraphs = text.split("\n");
for (int i = 0; i < paragraphs.length; i++) {
String paragraph = paragraphs[i];
if (paragraph.contains(keyword)) {
keywordLocations.add(new KeywordLocation(keyword, i + 1));
}
}
extractor.close();
docx.close();
} else if (fileName.endsWith(".doc")) {
HWPFDocument doc = new HWPFDocument(inputStream);
WordExtractor extractor = new WordExtractor(doc);
String text = extractor.getText();
String[] paragraphs = text.split("\n");
for (int i = 0; i < paragraphs.length; i++) {
String paragraph = paragraphs[i];
if (paragraph.contains(keyword)) {
keywordLocations.add(new KeywordLocation(keyword, i + 1));
}
}
extractor.close();
doc.close();
} else {
throw new IllegalArgumentException("Unsupported file format: " + fileName);
}
return keywordLocations;
} catch (Exception e) {
throw new CustomerException(e);
}
}
public static class KeywordLocation {
private final String keyword;
private final int paragraphNumber;
public KeywordLocation(String keyword, int paragraphNumber) {
this.keyword = keyword;
this.paragraphNumber = paragraphNumber;
}
public String getKeyword() {
return keyword;
}
public int getParagraphNumber() {
return paragraphNumber;
}
}
}

View File

@ -1,7 +1,7 @@
package aiyh.utils.function; package aiyh.utils.function;
/** /**
* <h1>function</h1> * <h1>function</h1>
* *
* <p>create: 2023/6/14 21:30</p> * <p>create: 2023/6/14 21:30</p>
* *

View File

@ -84,7 +84,7 @@ public class HttpUtils {
} }
public HttpUtils() { public HttpUtils() {
} }
public void setCredentialsProvider(CredentialsProvider credentialsProvider) { public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
@ -215,7 +215,7 @@ public class HttpUtils {
httpUtilParamInfo.setParams(params); httpUtilParamInfo.setParams(params);
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
return baseRequest(httpConnection, httpGet); return baseRequest(httpConnection, httpGet);
} }
@ -244,7 +244,7 @@ public class HttpUtils {
httpUtilParamInfo.setUrl(getUrl.trim()); httpUtilParamInfo.setUrl(getUrl.trim());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
return baseRequest(httpConnection, httpDelete); return baseRequest(httpConnection, httpDelete);
} }
@ -274,7 +274,7 @@ public class HttpUtils {
httpUtilParamInfo.setUrl(getUrl.trim()); httpUtilParamInfo.setUrl(getUrl.trim());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
return baseRequest(httpConnection, httpGet); return baseRequest(httpConnection, httpGet);
} }
@ -296,7 +296,7 @@ public class HttpUtils {
httpUtilParamInfo.setUrl(getUrl.trim()); httpUtilParamInfo.setUrl(getUrl.trim());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
return baseRequest(httpConnection, httpDelete); return baseRequest(httpConnection, httpDelete);
} }
@ -318,7 +318,7 @@ public class HttpUtils {
httpUtilParamInfo.setUrl(getUrl.trim()); httpUtilParamInfo.setUrl(getUrl.trim());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
return baseRequest(httpConnection, httpGet); return baseRequest(httpConnection, httpGet);
} }
@ -350,7 +350,7 @@ public class HttpUtils {
httpUtilParamInfo.setUrl(getUrl.trim()); httpUtilParamInfo.setUrl(getUrl.trim());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
return baseRequest(httpConnection, httpDelete); return baseRequest(httpConnection, httpDelete);
} }
@ -381,7 +381,7 @@ public class HttpUtils {
httpUtilParamInfo.setUrl(getUrl.trim()); httpUtilParamInfo.setUrl(getUrl.trim());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
callBackRequest(httpConnection, httpGet, consumer); callBackRequest(httpConnection, httpGet, consumer);
} }
@ -412,7 +412,7 @@ public class HttpUtils {
httpUtilParamInfo.setUrl(getUrl.trim()); httpUtilParamInfo.setUrl(getUrl.trim());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
callBackRequest(httpConnection, httpDelete, consumer); callBackRequest(httpConnection, httpDelete, consumer);
} }
@ -708,7 +708,7 @@ public class HttpUtils {
SerializerFeature.PrettyFormat, SerializerFeature.PrettyFormat,
SerializerFeature.WriteDateUseDateFormat))); SerializerFeature.WriteDateUseDateFormat)));
} catch (Exception ignore) { } catch (Exception ignore) {
} }
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove(); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove();
ExtendedIOUtils.closeQuietly(httpClient); ExtendedIOUtils.closeQuietly(httpClient);
@ -755,7 +755,7 @@ public class HttpUtils {
SerializerFeature.PrettyFormat, SerializerFeature.PrettyFormat,
SerializerFeature.WriteDateUseDateFormat))); SerializerFeature.WriteDateUseDateFormat)));
} catch (Exception ignore) { } catch (Exception ignore) {
} }
ExtendedIOUtils.closeQuietly(httpClient); ExtendedIOUtils.closeQuietly(httpClient);
ExtendedIOUtils.closeQuietly(response); ExtendedIOUtils.closeQuietly(response);
@ -793,7 +793,7 @@ public class HttpUtils {
SerializerFeature.PrettyFormat, SerializerFeature.PrettyFormat,
SerializerFeature.WriteDateUseDateFormat))); SerializerFeature.WriteDateUseDateFormat)));
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} catch (Exception e) { } catch (Exception e) {
log.error(" http调用失败:" + Util.getErrString(e)); log.error(" http调用失败:" + Util.getErrString(e));
@ -805,7 +805,7 @@ public class HttpUtils {
SerializerFeature.PrettyFormat, SerializerFeature.PrettyFormat,
SerializerFeature.WriteDateUseDateFormat))); SerializerFeature.WriteDateUseDateFormat)));
} catch (Exception ignore) { } catch (Exception ignore) {
} }
throw e; throw e;
} finally { } finally {
@ -1066,9 +1066,18 @@ public class HttpUtils {
List<NameValuePair> nvps = new ArrayList<>(); List<NameValuePair> nvps = new ArrayList<>();
for (Map.Entry<String, Object> entry : params.entrySet()) { for (Map.Entry<String, Object> entry : params.entrySet()) {
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue()))); // nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
// 修复请求form表单提交时参数值被双引号括了起来 // 修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue()))); // nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
/* ******************* 修改参数转换为string的逻辑如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
if (entry.getValue() instanceof Map) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (entry.getValue() instanceof Collection) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (isBean(entry.getValue())) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else {
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
} }
httpPost.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE); httpPost.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
httpPost.setEntity(new UrlEncodedFormEntity(nvps)); httpPost.setEntity(new UrlEncodedFormEntity(nvps));
@ -1076,11 +1085,19 @@ public class HttpUtils {
List<NameValuePair> nvps = new ArrayList<>(); List<NameValuePair> nvps = new ArrayList<>();
for (Map.Entry<String, Object> entry : params.entrySet()) { for (Map.Entry<String, Object> entry : params.entrySet()) {
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue()))); // nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
// 修复请求form表单提交时参数值被双引号括了起来 // 修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue()))); /* ******************* 修改参数转换为string的逻辑如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
if (entry.getValue() instanceof Map) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (entry.getValue() instanceof Collection) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (isBean(entry.getValue())) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else {
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
} }
httpPost.setEntity(new UrlEncodedFormEntity(nvps)); httpPost.setEntity(new UrlEncodedFormEntity(nvps, DEFAULT_ENCODING));
// } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) { // } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
} else { } else {
StringEntity stringEntity; StringEntity stringEntity;
@ -1095,6 +1112,22 @@ public class HttpUtils {
return httpPost; return httpPost;
} }
private boolean isBean(Object o) {
if (o instanceof Number) {
return false;
}
if (o instanceof String) {
return false;
}
if (o instanceof Boolean) {
return false;
}
if (Objects.isNull(o)) {
return false;
}
return !o.getClass().isPrimitive();
}
private HttpPost handleHttpPost(String url, Map<String, String> headerMap, Map<String, Object> paramsMap) throws UnsupportedEncodingException { private HttpPost handleHttpPost(String url, Map<String, String> headerMap, Map<String, Object> paramsMap) throws UnsupportedEncodingException {
return handleHttpPostObject(url, headerMap, paramsMap); return handleHttpPostObject(url, headerMap, paramsMap);
} }
@ -1261,7 +1294,17 @@ public class HttpUtils {
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) { for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue()))); // nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
// 修复请求form表单提交时参数值被双引号括了起来 // 修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue()))); // nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
/* ******************* 修改参数转换为string的逻辑如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
if (entry.getValue() instanceof Map) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (entry.getValue() instanceof Collection) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (isBean(entry.getValue())) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else {
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
} }
httpPut.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE); httpPut.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
httpPut.setEntity(new UrlEncodedFormEntity(nvps)); httpPut.setEntity(new UrlEncodedFormEntity(nvps));
@ -1270,7 +1313,17 @@ public class HttpUtils {
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) { for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue()))); // nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
// 修复请求form表单提交时参数值被双引号括了起来 // 修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue()))); // nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
/* ******************* 修改参数转换为string的逻辑如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
if (entry.getValue() instanceof Map) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (entry.getValue() instanceof Collection) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else if (isBean(entry.getValue())) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
} else {
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
} }
httpPut.setEntity(new UrlEncodedFormEntity(nvps)); httpPut.setEntity(new UrlEncodedFormEntity(nvps));
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) { } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {

View File

@ -312,44 +312,60 @@ public class ResultMapper {
try { try {
if (o instanceof Map) { if (o instanceof Map) {
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
for (int i = 0; i < columnName.length; i++) { for (int i = 0; i < columnName.length; i++) {
String columnType = columnTypeName[i]; String columnType = columnTypeName[i];
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) { if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); if (Objects.nonNull(toLowerCase)) {
continue; ((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
} else {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getInt(i + 1));
} }
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getInt(i + 1));
continue; continue;
} }
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) { if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
if (Objects.nonNull(toLowerCase)) {
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1));
} else {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getFloat(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getFloat(i + 1));
}
continue;
}
if (Objects.nonNull(toLowerCase)) {
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
} else {
if (enable) { if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); ((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
continue; continue;
} }
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); ((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
} }
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1)); ((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getFloat(i + 1)); ((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getFloat(i + 1)); ((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
continue;
} }
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
continue; continue;
} }
return o; return o;
@ -451,6 +467,7 @@ public class ResultMapper {
try { try {
if (o instanceof Map) { if (o instanceof Map) {
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
for (int i = 0; i < columnName.length; i++) { for (int i = 0; i < columnName.length; i++) {
String columnType = ""; String columnType = "";
if (i >= columnTypeName.length) { if (i >= columnTypeName.length) {
@ -459,29 +476,39 @@ public class ResultMapper {
columnType = columnTypeName[i]; columnType = columnTypeName[i];
} }
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) { if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i])); if (Objects.nonNull(toLowerCase)) {
continue; ((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
} else {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getInt(i + 1));
} }
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getInt(i + 1));
continue; continue;
} }
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) { if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); if (Objects.nonNull(toLowerCase)) {
continue; ((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
} else {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
} }
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
continue; continue;
} }
if (method.isAnnotationPresent(Associations.class)) { if (method.isAnnotationPresent(Associations.class)) {
@ -506,16 +533,23 @@ public class ResultMapper {
} }
} }
} }
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); if (Objects.nonNull(toLowerCase)) {
continue; ((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
} else {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
} }
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
} }
return o; return o;
} }

View File

@ -50,7 +50,10 @@ public class OrgChartService {
/* ******************* 次账号处理逻辑 ******************* */ /* ******************* 次账号处理逻辑 ******************* */
String accountType = logInUser.getAccount_type(); String accountType = logInUser.getAccount_type();
if ("1".equals(accountType)) { if ("1".equals(accountType)) {
return secondaryAccountTree(hrmResourceDtoList); // 对当前账号过滤当前分部信息
List<HrmResourceDto> collect = hrmResourceDtoList.stream().filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId())
.collect(Collectors.toList());
return secondaryAccountTree(collect);
} }
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser); filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */ /* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */

View File

@ -20,7 +20,7 @@ import java.util.Map;
public interface CheckWorkflowRequestParamsMapper { public interface CheckWorkflowRequestParamsMapper {
@Select("select * from table where workflow_type = #{workflowId}") @Select("select * from uf_check_request_create where workflow_type = #{workflowId}")
@CollectionMappings({ @CollectionMappings({
@CollectionMapping( @CollectionMapping(
property = "detailList", property = "detailList",
@ -36,7 +36,7 @@ public interface CheckWorkflowRequestParamsMapper {
CheckCreateConfig selectCheckConfig(int workflowId); CheckCreateConfig selectCheckConfig(int workflowId);
@Select("select * from table_dt1 where mainid = #{mainId}") @Select("select * from uf_check_request_create_dt1 where mainid = #{mainId}")
@Associations({ @Associations({
@Association( @Association(
property = "workflowField", property = "workflowField",
@ -49,12 +49,13 @@ public interface CheckWorkflowRequestParamsMapper {
List<CheckCreateConfigDetail> selectCheckDetail(String mainId); List<CheckCreateConfigDetail> selectCheckDetail(String mainId);
@Select("select * from table_dt2 where mainid = #{mainId}") @Select("select * from uf_check_request_create_dt2 where mainid = #{mainId}")
@CollectionMethod(value = 2, desc = "查询明细表2条件配置参数") @CollectionMethod(value = 2, desc = "查询明细表2条件配置参数")
List<CheckConditionItem> selectConditionDetail(String mainId); List<CheckConditionItem> selectConditionDetail(String mainId);
@Select(custom = true) @Select(custom = true)
@ToLowerCase
Map<String, Object> selectCustomerSql(@SqlString String sql, Map<String, Object> selectCustomerSql(@SqlString String sql,
@ParamMapper("value") String value, @ParamMapper("value") String value,
@ParamMapper("user") User user); @ParamMapper("user") User user);

View File

@ -18,10 +18,10 @@ import java.util.List;
@ToString @ToString
public class CheckCreateConfig { public class CheckCreateConfig {
/** 流程id */ /** 流程id */
private Integer workflowId; private Integer workflowType;
/** 描述 */ /** 描述 */
private String desc; private String description;
/** 检查配置明细 */ /** 检查配置明细 */
private List<CheckCreateConfigDetail> detailList; private List<CheckCreateConfigDetail> detailList;

View File

@ -23,11 +23,11 @@ public class CheckCreateConfigDetail {
/** 流程字段 */ /** 流程字段 */
private FieldViewInfo workflowField; private FieldViewInfo workflowField;
/** 是否允许为null */ /** 错误提示消息 */
private String allowNull; private String errorMsg;
/** 校验规则 */ /** 校验规则 */
private String checkRule; private Integer checkRule;
/** 自定义值 */ /** 自定义值 */
private String customerValue; private String customerValue;

View File

@ -0,0 +1,22 @@
package com.customization.youhong.pcn.createrworkflow.util;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023/6/15 19:59</p>
*
* @author youHong.ai
*/
public interface CheckCreateRequestCustomerInterface {
/**
* <h2></h2>
*
* @param checkFunctionParam
* @param pathParam
* @return
*/
boolean check(CheckFunctionParam checkFunctionParam, Map<String, String> pathParam);
}

View File

@ -0,0 +1,29 @@
package com.customization.youhong.pcn.createrworkflow.util;
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import weaver.hrm.User;
import weaver.workflow.webservices.WorkflowRequestTableField;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023/6/15 15:24</p>
*
* @author youHong.ai
*/
@Getter
@Setter
@ToString
public class CheckFunctionParam {
private WorkflowRequestTableField workflowRequestTableField;
private CheckCreateConfigDetail checkCreateConfigDetail;
private Map<String, CheckConditionItem> checkConditionMap;
private User user;
private CheckConditionItem checkConditionItem;
}

View File

@ -3,7 +3,6 @@ package com.customization.youhong.pcn.createrworkflow.util;
import aiyh.utils.ScriptUtil; import aiyh.utils.ScriptUtil;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo; import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.function.Bi4Function;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper; import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
@ -13,11 +12,9 @@ import org.apache.log4j.Logger;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.workflow.webservices.WorkflowRequestTableField; import weaver.workflow.webservices.WorkflowRequestTableField;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays; import java.util.*;
import java.util.HashMap; import java.util.function.Function;
import java.util.Map;
/** /**
* <h1></h1> * <h1></h1>
@ -28,17 +25,11 @@ import java.util.Map;
*/ */
public class CheckRuleMethodUtil { public class CheckRuleMethodUtil {
private static final Logger log = Util.getLogger(); private static final Logger log = Util.getLogger("workflow");
private static final CheckWorkflowRequestParamsMapper MAPPER = Util.getMapper(CheckWorkflowRequestParamsMapper.class); private static final CheckWorkflowRequestParamsMapper MAPPER = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
public static final Map<Integer, public static final Map<Integer,
Bi4Function< Function<CheckFunctionParam, Boolean>
WorkflowRequestTableField,
CheckCreateConfigDetail,
CheckConditionItem,
User,
Boolean
>
> CHECK_RULE_MAP = new HashMap<>(8); > CHECK_RULE_MAP = new HashMap<>(8);
static { static {
@ -46,14 +37,14 @@ public class CheckRuleMethodUtil {
Class<CheckRuleMethodUtil> checkRuleMethodUtilClass = CheckRuleMethodUtil.class; Class<CheckRuleMethodUtil> checkRuleMethodUtilClass = CheckRuleMethodUtil.class;
Method[] methods = checkRuleMethodUtilClass.getDeclaredMethods(); Method[] methods = checkRuleMethodUtilClass.getDeclaredMethods();
for (Method method : methods) { for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) { if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value(); int value = annotation.value();
CHECK_RULE_MAP.put(value, (workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user) -> { CHECK_RULE_MAP.put(value, (checkFunctionParam) -> {
try { try {
return (Boolean) method.invoke(null, workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user); return (Boolean) method.invoke(null, checkFunctionParam);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (Exception e) {
log.error("调用CheckRuleMethodUtil类中注解方法失败" + Util.getErrString(e));
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}); });
@ -62,21 +53,18 @@ public class CheckRuleMethodUtil {
} catch (Exception e) { } catch (Exception e) {
log.error("初始化CheckRuleMethodUtil失败" + Util.getErrString(e)); log.error("初始化CheckRuleMethodUtil失败" + Util.getErrString(e));
} }
} }
@MethodRuleNo(value = 0, desc = "不为null") @MethodRuleNo(value = 0, desc = "不为null")
public static boolean noNull(WorkflowRequestTableField workflowRequestTableField, private static boolean noNull(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail, WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
CheckConditionItem checkConditionItem, User user) {
return StrUtil.isNotBlank(workflowRequestTableField.getFieldValue()); return StrUtil.isNotBlank(workflowRequestTableField.getFieldValue());
} }
@MethodRuleNo(value = 1, desc = "整数类型") @MethodRuleNo(value = 1, desc = "整数类型")
public static boolean isNumber(WorkflowRequestTableField workflowRequestTableField, private static boolean isNumber(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail,
CheckConditionItem checkConditionItem, User user) {
try { try {
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
Integer.parseInt(workflowRequestTableField.getFieldValue()); Integer.parseInt(workflowRequestTableField.getFieldValue());
return true; return true;
} catch (Exception e) { } catch (Exception e) {
@ -85,9 +73,8 @@ public class CheckRuleMethodUtil {
} }
@MethodRuleNo(value = 2, desc = "小数类型") @MethodRuleNo(value = 2, desc = "小数类型")
public static boolean isDouble(WorkflowRequestTableField workflowRequestTableField, private static boolean isDouble(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail, WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
CheckConditionItem checkConditionItem, User user) {
try { try {
Double.parseDouble(workflowRequestTableField.getFieldValue()); Double.parseDouble(workflowRequestTableField.getFieldValue());
return true; return true;
@ -97,11 +84,15 @@ public class CheckRuleMethodUtil {
} }
@MethodRuleNo(value = 3, desc = "枚举值") @MethodRuleNo(value = 3, desc = "枚举值")
public static boolean isEnumerate(WorkflowRequestTableField workflowRequestTableField, private static boolean isEnumerate(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail, WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
CheckConditionItem checkConditionItem, User user) { CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
String fieldValue = workflowRequestTableField.getFieldValue(); String fieldValue = workflowRequestTableField.getFieldValue();
String customerValue = checkCreateConfigDetail.getCustomerValue(); String customerValue = checkCreateConfigDetail.getCustomerValue();
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
if (Objects.nonNull(checkConditionItem)) {
customerValue = checkConditionItem.getCustomerValue();
}
if (StrUtil.isNotBlank(customerValue)) { if (StrUtil.isNotBlank(customerValue)) {
String[] split = customerValue.split(","); String[] split = customerValue.split(",");
return Arrays.asList(split).contains(fieldValue); return Arrays.asList(split).contains(fieldValue);
@ -110,21 +101,36 @@ public class CheckRuleMethodUtil {
} }
@MethodRuleNo(value = 4, desc = "自定义sql存在值") @MethodRuleNo(value = 4, desc = "自定义sql存在值")
public static boolean customerSqlHasValue(WorkflowRequestTableField workflowRequestTableField, private static boolean customerSqlHasValue(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail, CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
CheckConditionItem checkConditionItem, User user) { WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
User user = checkFunctionParam.getUser();
String fieldValue = workflowRequestTableField.getFieldValue(); String fieldValue = workflowRequestTableField.getFieldValue();
String customerValue = checkCreateConfigDetail.getCustomerValue(); String customerValue;
if (Objects.nonNull(checkConditionItem)) {
// 条件组调用方法
customerValue = checkConditionItem.getCustomerValue();
} else {
customerValue = checkCreateConfigDetail.getCustomerValue();
}
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user); Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
return CollectionUtil.isNotEmpty(map); return CollectionUtil.isNotEmpty(map);
} }
@MethodRuleNo(value = 5, desc = "自定义sql校验表达式") @MethodRuleNo(value = 5, desc = "自定义sql校验表达式")
public static boolean customerSqlCheck(WorkflowRequestTableField workflowRequestTableField, private static boolean customerSqlCheck(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail, WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
CheckConditionItem checkConditionItem, User user) { CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
User user = checkFunctionParam.getUser();
String fieldValue = workflowRequestTableField.getFieldValue(); String fieldValue = workflowRequestTableField.getFieldValue();
String customerValue = checkCreateConfigDetail.getCustomerValue(); CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
String customerValue;
if (Objects.nonNull(checkConditionItem)) {
customerValue = checkConditionItem.getCustomerValue();
} else {
customerValue = checkCreateConfigDetail.getCustomerValue();
}
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user); Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
if (CollectionUtil.isNotEmpty(map)) { if (CollectionUtil.isNotEmpty(map)) {
String checkExpression = checkCreateConfigDetail.getCheckExpression(); String checkExpression = checkCreateConfigDetail.getCheckExpression();
@ -136,4 +142,78 @@ public class CheckRuleMethodUtil {
} }
@MethodRuleNo(value = 6, desc = "自定义表达式")
private static boolean checkCustomerExpression(CheckFunctionParam checkFunctionParam) {
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
String fieldValue = workflowRequestTableField.getFieldValue();
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
String checkExpression;
if (Objects.nonNull(checkConditionItem)) {
checkExpression = checkConditionItem.getCustomerValue();
} else {
checkExpression = checkCreateConfigDetail.getCheckExpression();
}
Map<String, Object> map = new HashMap<>(8);
map.put("value", fieldValue);
if (StrUtil.isNotBlank(checkExpression)) {
return (Boolean) ScriptUtil.invokeScript(checkExpression, map);
} else {
return false;
}
}
@MethodRuleNo(value = 7, desc = "自定义条件组")
private static boolean checkCustomerConditionGroup(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
Map<String, CheckConditionItem> checkConditionMap = checkFunctionParam.getCheckConditionMap();
String customerValue = checkCreateConfigDetail.getCheckExpression();
String replace = customerValue.replace("(", " ")
.replace(")", " ");
String[] groups = replace.split(" ");
List<String> groupList = new ArrayList<>();
for (String group : groups) {
if (StrUtil.isBlank(group) || "and".equalsIgnoreCase(group) || "or".equalsIgnoreCase(group)) {
continue;
}
if ("||".equalsIgnoreCase(group) || "&&".equalsIgnoreCase(group)) {
continue;
}
groupList.add(group);
}
if (CollectionUtil.isEmpty(groupList)) {
return false;
}
Map<String, Object> conditionMap = new HashMap<>(8);
for (String groupName : groupList) {
CheckConditionItem checkConditionItem = checkConditionMap.get(groupName);
checkFunctionParam.setCheckConditionItem(checkConditionItem);
Function<CheckFunctionParam, Boolean> checkFunctionParamBooleanFunction = CHECK_RULE_MAP.get(checkConditionItem.getConditionRule());
if (Objects.nonNull(checkFunctionParamBooleanFunction)) {
Boolean check = checkFunctionParamBooleanFunction.apply(checkFunctionParam);
conditionMap.put(groupName, check);
}
}
String checkExpression = checkCreateConfigDetail.getCheckExpression();
if (StrUtil.isNotBlank(checkExpression)) {
return (Boolean) ScriptUtil.invokeScript(checkExpression, conditionMap);
}
return false;
}
@MethodRuleNo(value = 8, desc = "自定义校验")
private static boolean checkCustomerInterface(CheckFunctionParam checkFunctionParam) {
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
String customerValue = checkCreateConfigDetail.getCustomerValue();
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
if (Objects.nonNull(checkConditionItem)) {
customerValue = checkConditionItem.getCustomerValue();
}
Map<String, String> map = Util.parseCusInterfacePathParam(customerValue);
String classPath = map.remove("_ClassPath");
CheckCreateRequestCustomerInterface instance = Util.getClassInstance(classPath, CheckCreateRequestCustomerInterface.class);
return instance.check(checkFunctionParam, map);
}
} }

View File

@ -8,13 +8,14 @@ import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig; import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig;
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail; import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity; import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
import com.engine.workflow.entity.publicApi.WorkflowDetailTableInfoEntity;
import org.apache.log4j.Logger;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.workflow.webservices.WorkflowRequestTableField; import weaver.workflow.webservices.WorkflowRequestTableField;
import weaver.workflow.webservices.WorkflowRequestTableRecord;
import java.util.HashMap; import java.util.*;
import java.util.List; import java.util.function.Function;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -28,6 +29,7 @@ public class CheckWorkflowRequestParamsUtil {
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class); private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
private final Logger log = Util.getLogger("workflow");
/** /**
* ************************************************************ * ************************************************************
@ -70,15 +72,80 @@ public class CheckWorkflowRequestParamsUtil {
value -> value value -> value
) )
); );
checkMainData(checkDetailMap, checkConditionItemMap, requestParam); // 校验主表数据
checkMainData(checkDetailMap, checkConditionItemMap, requestParam, user);
// 校验明细表参数
checkDetailData(checkDetailMap, checkConditionItemMap, requestParam, user);
if (CollectionUtil.isNotEmpty(checkDetailMap)) {
List<String> required = new ArrayList<>();
for (Map.Entry<String, CheckCreateConfigDetail> entry : checkDetailMap.entrySet()) {
required.add(entry.getKey());
}
throw new CreateRequestException(Util.logStr("必填参数校验未通过,[{}]字段必填!", Util.join(required, ",")));
}
} }
/**
* <h2></h2>
*
* @param checkDetailMap map
* @param checkConditionItemMap map
* @param requestParam
* @param user
*/
private void checkMainData(Map<String, CheckCreateConfigDetail> checkDetailMap, private void checkMainData(Map<String, CheckCreateConfigDetail> checkDetailMap,
Map<String, CheckConditionItem> checkConditionItemMap, Map<String, CheckConditionItem> checkConditionItemMap,
ReqOperateRequestEntity requestParam) { ReqOperateRequestEntity requestParam, User user) {
List<WorkflowRequestTableField> mainData = requestParam.getMainData(); List<WorkflowRequestTableField> mainData = requestParam.getMainData();
for (WorkflowRequestTableField mainDatum : mainData) { checkData(checkDetailMap, checkConditionItemMap, mainData, user, "主表");
String fieldName = mainDatum.getFieldName(); }
private void checkDetailData(Map<String, CheckCreateConfigDetail> checkDetailMap,
Map<String, CheckConditionItem> checkConditionItemMap,
ReqOperateRequestEntity requestParam, User user) {
List<WorkflowDetailTableInfoEntity> detailData = requestParam.getDetailData();
if (CollectionUtil.isEmpty(detailData)) {
return;
}
for (WorkflowDetailTableInfoEntity detailDatum : detailData) {
WorkflowRequestTableRecord[] workflowRequestTableRecords = detailDatum.getWorkflowRequestTableRecords();
if (Objects.isNull(workflowRequestTableRecords)) {
continue;
}
for (WorkflowRequestTableRecord workflowRequestTableRecord : workflowRequestTableRecords) {
WorkflowRequestTableField[] workflowRequestTableFields = workflowRequestTableRecord.getWorkflowRequestTableFields();
if (Objects.isNull(workflowRequestTableFields)) {
continue;
}
List<WorkflowRequestTableField> dataList
= Arrays.asList(workflowRequestTableFields);
checkData(checkDetailMap, checkConditionItemMap, dataList, user, detailDatum.getTableDBName());
}
}
}
private void checkData(Map<String, CheckCreateConfigDetail> checkDetailMap,
Map<String, CheckConditionItem> checkConditionItemMap,
List<WorkflowRequestTableField> dataList, User user, String tableDesc) {
for (WorkflowRequestTableField dataItem : dataList) {
String fieldName = dataItem.getFieldName();
CheckCreateConfigDetail checkCreateConfigDetail = checkDetailMap.get(fieldName);
if (Objects.isNull(checkCreateConfigDetail)) {
continue;
}
checkDetailMap.remove(fieldName);
CheckFunctionParam checkFunctionParam = new CheckFunctionParam();
checkFunctionParam.setCheckCreateConfigDetail(checkCreateConfigDetail);
checkFunctionParam.setCheckConditionMap(checkConditionItemMap);
checkFunctionParam.setUser(user);
checkFunctionParam.setWorkflowRequestTableField(dataItem);
Integer checkRule = checkCreateConfigDetail.getCheckRule();
Function<CheckFunctionParam, Boolean> function = CheckRuleMethodUtil.CHECK_RULE_MAP.get(checkRule);
Boolean apply = function.apply(checkFunctionParam);
if (!apply) {
throw new CreateRequestException(Util.logStr("[{}] 表数据校验未通过,字段[{}],错误信息[{}]",
tableDesc, fieldName, checkCreateConfigDetail.getErrorMsg()));
}
} }
} }
} }

View File

@ -0,0 +1,119 @@
package weaver.youhong.ai.pcn.actioin.locationkeyword;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDefaultTestValue;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.entity.DocImageInfo;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.fileUtil.WordKeywordFinder;
import aiyh.utils.fileUtil.pdf.PdfPointItem;
import aiyh.utils.fileUtil.pdf.PdfUtil;
import aiyh.utils.mapper.UtilMapper;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import lombok.Setter;
import weaver.file.ImageFileManager;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023/6/16 16:38</p>
*
* @author youHong.ai
*/
@Setter
@ActionDesc(author = "youhong.ai", value = "word文件和pdf文件关键字识别是否存在关键字")
public class LocationKeywordAction extends SafeCusBaseAction {
@RequiredMark(desc = "关键字,多个关键字之间使用;分割")
@ActionDefaultTestValue("盖章关键字;日期关键字")
private String keywords;
@RequiredMark(desc = "附件字段字段名")
@ActionDefaultTestValue("fj")
private String docField;
@ActionOptionalParam(value = "false", desc = "报错是否自动退回")
@ActionDefaultTestValue("false")
private String isBack = "false";
private final UtilMapper mapper = Util.getMapper(UtilMapper.class);
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
Map<String, String> mainData = getMainTableValue(requestInfo);
String docIds = mainData.get(docField);
if (StrUtil.isBlank(docIds)) {
return;
}
List<DocImageInfo> docImageInfos = mapper.selectDocImageInfos(docIds);
if (CollectionUtil.isEmpty(docImageInfos)) {
log.error("未查询到物理文件信息!=>" + docIds);
Util.actionFailException(requestInfo.getRequestManager(), "系统异常,请联系管理员");
}
String[] keywordArr = keywords.split(";");
Map<String, Boolean> keyMap = new HashMap<>(8);
for (DocImageInfo docImageInfo : docImageInfos) {
Map<String, Boolean> keyword = findKeyWord(docImageInfo, keywordArr);
for (Map.Entry<String, Boolean> entry : keyword.entrySet()) {
if (keyMap.containsKey(entry.getKey())) {
Boolean isKeyword = keyMap.get(entry.getKey());
if (!isKeyword) {
keyMap.put(entry.getKey(), entry.getValue());
}
} else {
keyMap.put(entry.getKey(), entry.getValue());
}
}
}
if (!Boolean.parseBoolean(isBack)) {
return;
}
for (Map.Entry<String, Boolean> entry : keyMap.entrySet()) {
if (!entry.getValue()) {
throw new CustomerException(Util.logStr("关键字[{}]定位异常!文件中不存在关键字!", entry.getKey()));
}
}
}
private Map<String, Boolean> findKeyWord(DocImageInfo docImageInfo, String[] keywordArr) {
String imageFileName = docImageInfo.getImageFileName();
Integer imageFileId = docImageInfo.getImageFileId();
Map<String, Boolean> result = new HashMap<>(8);
InputStream inputStream = ImageFileManager.getInputStreamById(imageFileId);
if (imageFileName.endsWith(".pdf")) {
for (String keyword : keywordArr) {
List<PdfPointItem> keywordPoints = PdfUtil.findKeywordPoints(inputStream, keyword);
if (CollectionUtil.isEmpty(keywordPoints)) {
result.put(keyword, false);
} else {
result.put(keyword, true);
}
}
} else if (imageFileName.endsWith(".doc") || imageFileName.endsWith(".docx")) {
for (String keyword : keywordArr) {
List<WordKeywordFinder.KeywordLocation> keywordPoints = WordKeywordFinder.findKeywords(inputStream, keyword, imageFileName);
if (CollectionUtil.isEmpty(keywordPoints)) {
result.put(keyword, false);
} else {
result.put(keyword, true);
}
}
}
return result;
}
}

View File

@ -0,0 +1,14 @@
package weaver.youhong.ai.pcn.actioin.locationkeyword.mapper;
import aiyh.utils.annotation.recordset.SqlMapper;
/**
* <h1></h1>
*
* <p>create: 2023/6/16 16:56</p>
*
* @author youHong.ai
*/
@SqlMapper
public interface LocationKeywordMapper {
}

View File

@ -13,6 +13,9 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.junit.Test; import org.junit.Test;
import weaver.youhong.ai.pcn.actioin.doctoavatar.DocToAvatarAction; import weaver.youhong.ai.pcn.actioin.doctoavatar.DocToAvatarAction;
import youhong.ai.utiltest.excel.ExcelCell;
import youhong.ai.utiltest.excel.ExcelPort;
import youhong.ai.utiltest.excel.ExcelRow;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;

View File

@ -9,9 +9,9 @@ import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA; import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import org.junit.Test; import org.junit.Test;
import javax.ws.rs.core.MediaType;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -32,7 +32,8 @@ public class TestApi extends BaseTest {
@Test @Test
public void testApi() { public void testApi() {
String api = "https://ecology.yeyaguitu.cn/api/aiyh/test/req-msg/test/cus-api"; // String api = "https://ecology.yeyaguitu.cn/api/aiyh/test/req-msg/test/cus-api";
String api = "https://ecology.yeyaguitu.cn/api/workflow/paService/doCreateRequest";
String token = (String) testGetoken("https://ecology.yeyaguitu.cn").get("token"); String token = (String) testGetoken("https://ecology.yeyaguitu.cn").get("token");
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY"); String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
// 封装请求头参数 // 封装请求头参数
@ -44,13 +45,43 @@ public class TestApi extends BaseTest {
head.put("token", token); head.put("token", token);
head.put("userid", encryptUserid); head.put("userid", encryptUserid);
HttpUtils httpUtils = new HttpUtils(); HttpUtils httpUtils = new HttpUtils();
Map<String, Object> body = new HashMap<>();
body.put("mainData", "[{\n" +
"\t\"fieldName\":\"cs1\",\n" +
"\t\"fieldValue\":\"api测试1\"\n" +
"},{\n" +
"\t\"fieldName\":\"cs2\",\n" +
"\t\"fieldValue\":\"api测试2\"\n" +
"},{\n" +
"\t\"fieldName\":\"cs3\",\n" +
"\t\"fieldValue\":\"api测试3\"\n" +
"},{\n" +
"\t\"fieldName\":\"sjid\",\n" +
"\t\"fieldValue\":\"8\"\n" +
"},{\n" +
"\t\"fieldName\":\"bmllan\",\n" +
"\t\"fieldValue\":\"5\"\n" +
"},{\n" +
"\t\"fieldName\":\"mc\",\n" +
"\t\"fieldValue\":\"不1道\"\n" +
"}]");
body.put("requestName", "api流程测试调用接口校验参数");
body.put("workflowId", "44");
ResponeVo responeVo = null; ResponeVo responeVo = null;
head.put("Content-Type", MediaType.APPLICATION_FORM_URLENCODED + ";charset=utf-8");
try { try {
responeVo = httpUtils.apiGet(api, head); responeVo = httpUtils.apiPost(api, body, head);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
System.out.println(JSON.toJSONString(responeVo)); System.out.println(responeVo);
// ResponeVo responeVo = null;
// try {
// responeVo = httpUtils.apiGet(api, head);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// System.out.println(JSON.toJSONString(responeVo));
} }
/** /**

View File

@ -1,4 +1,4 @@
package youhong.ai.utiltest; package youhong.ai.utiltest.excel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -14,5 +14,5 @@ import lombok.ToString;
@Getter @Getter
@Setter @Setter
@ToString @ToString
public class ExcelBody extends ExcelCell{ public class ExcelBody extends ExcelCell {
} }

View File

@ -1,4 +1,4 @@
package youhong.ai.utiltest; package youhong.ai.utiltest.excel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,4 +1,4 @@
package youhong.ai.utiltest; package youhong.ai.utiltest.excel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,4 +1,4 @@
package youhong.ai.utiltest; package youhong.ai.utiltest.excel;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;

View File

@ -1,4 +1,4 @@
package youhong.ai.utiltest; package youhong.ai.utiltest.excel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,4 +1,4 @@
package youhong.ai.utiltest; package youhong.ai.utiltest.excel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,4 +1,4 @@
package youhong.ai.utiltest; package youhong.ai.utiltest.excel;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.streaming.SXSSFCell; import org.apache.poi.xssf.streaming.SXSSFCell;

View File

@ -0,0 +1,32 @@
package youhong.ai.utiltest.wordread;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
public class Main {
public static void main(String[] args) {
try {
String fileName = "/Users/aoey.oct.22/Downloads/offer 发放测试 0522 RC (1).docx";
String keyword = "Human Resource";
InputStream inputStream = Files.newInputStream(Paths.get(fileName));
List<WordKeywordFinder.KeywordLocation> keywordLocations = WordKeywordFinder.findKeywords(inputStream, keyword, fileName);
if (keywordLocations.isEmpty()) {
System.out.println("未找到关键字:" + keyword);
} else {
for (WordKeywordFinder.KeywordLocation location : keywordLocations) {
System.out.println("关键字:" + location.getKeyword());
System.out.println("段落编号:" + location.getParagraphNumber());
System.out.println("-----------------------");
}
}
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,67 @@
package youhong.ai.utiltest.wordread;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class WordKeywordFinder {
public static List<KeywordLocation> findKeywords(InputStream inputStream, String keyword, String fileName) throws IOException {
List<KeywordLocation> keywordLocations = new ArrayList<>();
if (fileName.endsWith(".docx")) {
XWPFDocument docx = new XWPFDocument(inputStream);
XWPFWordExtractor extractor = new XWPFWordExtractor(docx);
String text = extractor.getText();
String[] paragraphs = text.split("\n");
for (int i = 0; i < paragraphs.length; i++) {
String paragraph = paragraphs[i];
if (paragraph.contains(keyword)) {
keywordLocations.add(new KeywordLocation(keyword, i + 1));
}
}
extractor.close();
docx.close();
} else if (fileName.endsWith(".doc")) {
HWPFDocument doc = new HWPFDocument(inputStream);
WordExtractor extractor = new WordExtractor(doc);
String text = extractor.getText();
String[] paragraphs = text.split("\n");
for (int i = 0; i < paragraphs.length; i++) {
String paragraph = paragraphs[i];
if (paragraph.contains(keyword)) {
keywordLocations.add(new KeywordLocation(keyword, i + 1));
}
}
extractor.close();
doc.close();
} else {
throw new IllegalArgumentException("Unsupported file format: " + fileName);
}
return keywordLocations;
}
public static class KeywordLocation {
private final String keyword;
private final int paragraphNumber;
public KeywordLocation(String keyword, int paragraphNumber) {
this.keyword = keyword;
this.paragraphNumber = paragraphNumber;
}
public String getKeyword() {
return keyword;
}
public int getParagraphNumber() {
return paragraphNumber;
}
}
}