保时捷关键字定位aciton,流程参数检查
parent
3f96ed75bc
commit
da145d2d32
|
@ -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 {
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package aiyh.utils.function;
|
||||
|
||||
/**
|
||||
* <h1>三个参数的function</h1>
|
||||
* <h1>四个参数的function</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 21:30</p>
|
||||
*
|
||||
|
|
|
@ -1066,21 +1066,38 @@ public class HttpUtils {
|
|||
List<NameValuePair> nvps = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
|
||||
// 修复请求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.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
||||
List<NameValuePair> nvps = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
|
||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||
/* ******************* 修改参数转换为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 {
|
||||
StringEntity stringEntity;
|
||||
|
@ -1095,6 +1112,22 @@ public class HttpUtils {
|
|||
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 {
|
||||
return handleHttpPostObject(url, headerMap, paramsMap);
|
||||
}
|
||||
|
@ -1261,8 +1294,18 @@ public class HttpUtils {
|
|||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
// 修复请求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())));
|
||||
}
|
||||
}
|
||||
httpPut.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
||||
|
@ -1270,8 +1313,18 @@ public class HttpUtils {
|
|||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
// 修复请求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())));
|
||||
}
|
||||
}
|
||||
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
||||
StringEntity stringEntity = new StringEntity(JSON.toJSONString(paramsMap), DEFAULT_ENCODING);
|
||||
|
|
|
@ -312,9 +312,14 @@ public class ResultMapper {
|
|||
|
||||
try {
|
||||
if (o instanceof Map) {
|
||||
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
|
||||
for (int i = 0; i < columnName.length; 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 (Objects.nonNull(toLowerCase)) {
|
||||
((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;
|
||||
|
@ -325,9 +330,14 @@ public class ResultMapper {
|
|||
((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;
|
||||
}
|
||||
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;
|
||||
|
@ -338,8 +348,13 @@ public class ResultMapper {
|
|||
((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) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
||||
continue;
|
||||
|
@ -350,6 +365,7 @@ public class ResultMapper {
|
|||
((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;
|
||||
}
|
||||
return o;
|
||||
|
@ -451,6 +467,7 @@ public class ResultMapper {
|
|||
|
||||
try {
|
||||
if (o instanceof Map) {
|
||||
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
|
||||
for (int i = 0; i < columnName.length; i++) {
|
||||
String columnType = "";
|
||||
if (i >= columnTypeName.length) {
|
||||
|
@ -459,6 +476,10 @@ public class ResultMapper {
|
|||
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 (Objects.nonNull(toLowerCase)) {
|
||||
((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;
|
||||
|
@ -469,9 +490,14 @@ public class ResultMapper {
|
|||
((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;
|
||||
}
|
||||
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.getString(i + 1));
|
||||
} else {
|
||||
if (enable) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
||||
continue;
|
||||
|
@ -482,6 +508,7 @@ public class ResultMapper {
|
|||
((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;
|
||||
}
|
||||
if (method.isAnnotationPresent(Associations.class)) {
|
||||
|
@ -506,6 +533,10 @@ public class ResultMapper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Objects.nonNull(toLowerCase)) {
|
||||
((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;
|
||||
|
@ -516,6 +547,9 @@ public class ResultMapper {
|
|||
((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;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,10 @@ public class OrgChartService {
|
|||
/* ******************* 次账号处理逻辑 ******************* */
|
||||
String accountType = logInUser.getAccount_type();
|
||||
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);
|
||||
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Map;
|
|||
public interface CheckWorkflowRequestParamsMapper {
|
||||
|
||||
|
||||
@Select("select * from table where workflow_type = #{workflowId}")
|
||||
@Select("select * from uf_check_request_create where workflow_type = #{workflowId}")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(
|
||||
property = "detailList",
|
||||
|
@ -36,7 +36,7 @@ public interface CheckWorkflowRequestParamsMapper {
|
|||
CheckCreateConfig selectCheckConfig(int workflowId);
|
||||
|
||||
|
||||
@Select("select * from table_dt1 where mainid = #{mainId}")
|
||||
@Select("select * from uf_check_request_create_dt1 where mainid = #{mainId}")
|
||||
@Associations({
|
||||
@Association(
|
||||
property = "workflowField",
|
||||
|
@ -49,12 +49,13 @@ public interface CheckWorkflowRequestParamsMapper {
|
|||
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,条件配置参数")
|
||||
List<CheckConditionItem> selectConditionDetail(String mainId);
|
||||
|
||||
|
||||
@Select(custom = true)
|
||||
@ToLowerCase
|
||||
Map<String, Object> selectCustomerSql(@SqlString String sql,
|
||||
@ParamMapper("value") String value,
|
||||
@ParamMapper("user") User user);
|
||||
|
|
|
@ -18,10 +18,10 @@ import java.util.List;
|
|||
@ToString
|
||||
public class CheckCreateConfig {
|
||||
/** 流程id */
|
||||
private Integer workflowId;
|
||||
private Integer workflowType;
|
||||
|
||||
/** 描述 */
|
||||
private String desc;
|
||||
private String description;
|
||||
|
||||
/** 检查配置明细 */
|
||||
private List<CheckCreateConfigDetail> detailList;
|
||||
|
|
|
@ -23,11 +23,11 @@ public class CheckCreateConfigDetail {
|
|||
/** 流程字段 */
|
||||
private FieldViewInfo workflowField;
|
||||
|
||||
/** 是否允许为null */
|
||||
private String allowNull;
|
||||
/** 错误提示消息 */
|
||||
private String errorMsg;
|
||||
|
||||
/** 校验规则 */
|
||||
private String checkRule;
|
||||
private Integer checkRule;
|
||||
|
||||
/** 自定义值 */
|
||||
private String customerValue;
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -3,7 +3,6 @@ package com.customization.youhong.pcn.createrworkflow.util;
|
|||
import aiyh.utils.ScriptUtil;
|
||||
import aiyh.utils.Util;
|
||||
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.util.StrUtil;
|
||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||
|
@ -13,11 +12,9 @@ import org.apache.log4j.Logger;
|
|||
import weaver.hrm.User;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* <h1>检查方法校验工具</h1>
|
||||
|
@ -28,17 +25,11 @@ import java.util.Map;
|
|||
*/
|
||||
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);
|
||||
public static final Map<Integer,
|
||||
Bi4Function<
|
||||
WorkflowRequestTableField,
|
||||
CheckCreateConfigDetail,
|
||||
CheckConditionItem,
|
||||
User,
|
||||
Boolean
|
||||
>
|
||||
Function<CheckFunctionParam, Boolean>
|
||||
> CHECK_RULE_MAP = new HashMap<>(8);
|
||||
|
||||
static {
|
||||
|
@ -46,14 +37,14 @@ public class CheckRuleMethodUtil {
|
|||
Class<CheckRuleMethodUtil> checkRuleMethodUtilClass = CheckRuleMethodUtil.class;
|
||||
Method[] methods = checkRuleMethodUtilClass.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
|
||||
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
||||
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
||||
int value = annotation.value();
|
||||
CHECK_RULE_MAP.put(value, (workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user) -> {
|
||||
CHECK_RULE_MAP.put(value, (checkFunctionParam) -> {
|
||||
try {
|
||||
return (Boolean) method.invoke(null, workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
return (Boolean) method.invoke(null, checkFunctionParam);
|
||||
} catch (Exception e) {
|
||||
log.error("调用CheckRuleMethodUtil类中注解方法失败!" + Util.getErrString(e));
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
@ -62,21 +53,18 @@ public class CheckRuleMethodUtil {
|
|||
} catch (Exception e) {
|
||||
log.error("初始化CheckRuleMethodUtil失败!" + Util.getErrString(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 0, desc = "不为null")
|
||||
public static boolean noNull(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
private static boolean noNull(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
return StrUtil.isNotBlank(workflowRequestTableField.getFieldValue());
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 1, desc = "整数类型")
|
||||
public static boolean isNumber(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
private static boolean isNumber(CheckFunctionParam checkFunctionParam) {
|
||||
try {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
Integer.parseInt(workflowRequestTableField.getFieldValue());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
@ -85,9 +73,8 @@ public class CheckRuleMethodUtil {
|
|||
}
|
||||
|
||||
@MethodRuleNo(value = 2, desc = "小数类型")
|
||||
public static boolean isDouble(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
private static boolean isDouble(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
try {
|
||||
Double.parseDouble(workflowRequestTableField.getFieldValue());
|
||||
return true;
|
||||
|
@ -97,11 +84,15 @@ public class CheckRuleMethodUtil {
|
|||
}
|
||||
|
||||
@MethodRuleNo(value = 3, desc = "枚举值")
|
||||
public static boolean isEnumerate(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
private static boolean isEnumerate(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||
if (Objects.nonNull(checkConditionItem)) {
|
||||
customerValue = checkConditionItem.getCustomerValue();
|
||||
}
|
||||
if (StrUtil.isNotBlank(customerValue)) {
|
||||
String[] split = customerValue.split(",");
|
||||
return Arrays.asList(split).contains(fieldValue);
|
||||
|
@ -110,21 +101,36 @@ public class CheckRuleMethodUtil {
|
|||
}
|
||||
|
||||
@MethodRuleNo(value = 4, desc = "自定义sql存在值")
|
||||
public static boolean customerSqlHasValue(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
private static boolean customerSqlHasValue(CheckFunctionParam checkFunctionParam) {
|
||||
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
User user = checkFunctionParam.getUser();
|
||||
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);
|
||||
return CollectionUtil.isNotEmpty(map);
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 5, desc = "自定义sql校验表达式")
|
||||
public static boolean customerSqlCheck(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
private static boolean customerSqlCheck(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
User user = checkFunctionParam.getUser();
|
||||
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);
|
||||
if (CollectionUtil.isNotEmpty(map)) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.CheckCreateConfigDetail;
|
||||
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.workflow.webservices.WorkflowRequestTableField;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableRecord;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -28,6 +29,7 @@ public class CheckWorkflowRequestParamsUtil {
|
|||
|
||||
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||
|
||||
private final Logger log = Util.getLogger("workflow");
|
||||
|
||||
/**
|
||||
* ************************************************************
|
||||
|
@ -70,15 +72,80 @@ public class CheckWorkflowRequestParamsUtil {
|
|||
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,
|
||||
Map<String, CheckConditionItem> checkConditionItemMap,
|
||||
ReqOperateRequestEntity requestParam) {
|
||||
ReqOperateRequestEntity requestParam, User user) {
|
||||
List<WorkflowRequestTableField> mainData = requestParam.getMainData();
|
||||
for (WorkflowRequestTableField mainDatum : mainData) {
|
||||
String fieldName = mainDatum.getFieldName();
|
||||
checkData(checkDetailMap, checkConditionItemMap, mainData, user, "主表");
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
}
|
|
@ -13,6 +13,9 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.junit.Test;
|
||||
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.ParameterizedType;
|
||||
|
|
|
@ -9,9 +9,9 @@ import cn.hutool.crypto.asymmetric.KeyType;
|
|||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -32,7 +32,8 @@ public class TestApi extends BaseTest {
|
|||
|
||||
@Test
|
||||
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 spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
// 封装请求头参数
|
||||
|
@ -44,13 +45,43 @@ public class TestApi extends BaseTest {
|
|||
head.put("token", token);
|
||||
head.put("userid", encryptUserid);
|
||||
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;
|
||||
head.put("Content-Type", MediaType.APPLICATION_FORM_URLENCODED + ";charset=utf-8");
|
||||
try {
|
||||
responeVo = httpUtils.apiGet(api, head);
|
||||
responeVo = httpUtils.apiPost(api, body, head);
|
||||
} catch (IOException 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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -14,5 +14,5 @@ import lombok.ToString;
|
|||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ExcelBody extends ExcelCell{
|
||||
public class ExcelBody extends ExcelCell {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.xssf.streaming.SXSSFCell;
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue