From da145d2d3203cd4680e4a2a7d82ec9ce39215945 Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Fri, 16 Jun 2023 18:09:12 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=9D=E6=97=B6=E6=8D=B7=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E5=AD=97=E5=AE=9A=E4=BD=8Daciton=EF=BC=8C=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=8F=82=E6=95=B0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../annotation/recordset/ToLowerCase.java | 16 ++ .../utils/fileUtil/WordKeywordFinder.java | 86 ++++++++++ .../java/aiyh/utils/function/Bi4Function.java | 2 +- .../aiyh/utils/httpUtil/util/HttpUtils.java | 93 ++++++++--- .../aiyh/utils/recordset/ResultMapper.java | 138 ++++++++++------ .../orgchart/service/OrgChartService.java | 5 +- .../CheckWorkflowRequestParamsMapper.java | 7 +- .../pojo/CheckCreateConfig.java | 4 +- .../pojo/CheckCreateConfigDetail.java | 6 +- .../CheckCreateRequestCustomerInterface.java | 22 +++ .../util/CheckFunctionParam.java | 29 ++++ .../util/CheckRuleMethodUtil.java | 156 +++++++++++++----- .../util/CheckWorkflowRequestParamsUtil.java | 83 +++++++++- .../LocationKeywordAction.java | 119 +++++++++++++ .../mapper/LocationKeywordMapper.java | 14 ++ .../java/youhong/ai/utiltest/GenericTest.java | 3 + .../java/youhong/ai/utiltest/TestApi.java | 39 ++++- .../ai/utiltest/{ => excel}/ExcelBody.java | 4 +- .../ai/utiltest/{ => excel}/ExcelCell.java | 2 +- .../ai/utiltest/{ => excel}/ExcelHead.java | 2 +- .../ai/utiltest/{ => excel}/ExcelPort.java | 2 +- .../ai/utiltest/{ => excel}/ExcelRow.java | 2 +- .../ai/utiltest/{ => excel}/ExcelSheet.java | 2 +- .../{ => excel}/IExcelCellStyleCreator.java | 2 +- .../youhong/ai/utiltest/wordread/Main.java | 32 ++++ .../utiltest/wordread/WordKeywordFinder.java | 67 ++++++++ 26 files changed, 797 insertions(+), 140 deletions(-) create mode 100644 src/main/java/aiyh/utils/annotation/recordset/ToLowerCase.java create mode 100644 src/main/java/aiyh/utils/fileUtil/WordKeywordFinder.java create mode 100644 src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckCreateRequestCustomerInterface.java create mode 100644 src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckFunctionParam.java create mode 100644 src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/LocationKeywordAction.java create mode 100644 src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/mapper/LocationKeywordMapper.java rename src/test/java/youhong/ai/utiltest/{ => excel}/ExcelBody.java (70%) rename src/test/java/youhong/ai/utiltest/{ => excel}/ExcelCell.java (90%) rename src/test/java/youhong/ai/utiltest/{ => excel}/ExcelHead.java (87%) rename src/test/java/youhong/ai/utiltest/{ => excel}/ExcelPort.java (98%) rename src/test/java/youhong/ai/utiltest/{ => excel}/ExcelRow.java (89%) rename src/test/java/youhong/ai/utiltest/{ => excel}/ExcelSheet.java (89%) rename src/test/java/youhong/ai/utiltest/{ => excel}/IExcelCellStyleCreator.java (94%) create mode 100644 src/test/java/youhong/ai/utiltest/wordread/Main.java create mode 100644 src/test/java/youhong/ai/utiltest/wordread/WordKeywordFinder.java diff --git a/src/main/java/aiyh/utils/annotation/recordset/ToLowerCase.java b/src/main/java/aiyh/utils/annotation/recordset/ToLowerCase.java new file mode 100644 index 0000000..bc7406a --- /dev/null +++ b/src/main/java/aiyh/utils/annotation/recordset/ToLowerCase.java @@ -0,0 +1,16 @@ +package aiyh.utils.annotation.recordset; + +import java.lang.annotation.*; + +/** + *

小写键

+ * + *

create: 2023/6/16 13:02

+ * + * @author youHong.ai + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +@Documented +public @interface ToLowerCase { +} diff --git a/src/main/java/aiyh/utils/fileUtil/WordKeywordFinder.java b/src/main/java/aiyh/utils/fileUtil/WordKeywordFinder.java new file mode 100644 index 0000000..50f5ba8 --- /dev/null +++ b/src/main/java/aiyh/utils/fileUtil/WordKeywordFinder.java @@ -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; + +/** + *

word关键字查找

+ * + * @author ebu7-dev1 youhong.ai + */ +public class WordKeywordFinder { + + /** + *

查找关键字

+ * + * @param inputStream 文件流 + * @param keyword 关键字 + * @param fileName 文件名称 + * @return 关键字信息 + * @throws IOException io异常 + */ + public static List findKeywords(InputStream inputStream, String keyword, String fileName) { + try { + List 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; + } + } +} diff --git a/src/main/java/aiyh/utils/function/Bi4Function.java b/src/main/java/aiyh/utils/function/Bi4Function.java index efd9a3c..7a19c8c 100644 --- a/src/main/java/aiyh/utils/function/Bi4Function.java +++ b/src/main/java/aiyh/utils/function/Bi4Function.java @@ -1,7 +1,7 @@ package aiyh.utils.function; /** - *

三个参数的function

+ *

四个参数的function

* *

create: 2023/6/14 21:30

* diff --git a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java index bc39ea2..77ea7c8 100644 --- a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java +++ b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java @@ -84,7 +84,7 @@ public class HttpUtils { } public HttpUtils() { - + } public void setCredentialsProvider(CredentialsProvider credentialsProvider) { @@ -215,7 +215,7 @@ public class HttpUtils { httpUtilParamInfo.setParams(params); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } return baseRequest(httpConnection, httpGet); } @@ -244,7 +244,7 @@ public class HttpUtils { httpUtilParamInfo.setUrl(getUrl.trim()); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } return baseRequest(httpConnection, httpDelete); } @@ -274,7 +274,7 @@ public class HttpUtils { httpUtilParamInfo.setUrl(getUrl.trim()); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } return baseRequest(httpConnection, httpGet); } @@ -296,7 +296,7 @@ public class HttpUtils { httpUtilParamInfo.setUrl(getUrl.trim()); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } return baseRequest(httpConnection, httpDelete); } @@ -318,7 +318,7 @@ public class HttpUtils { httpUtilParamInfo.setUrl(getUrl.trim()); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } return baseRequest(httpConnection, httpGet); } @@ -350,7 +350,7 @@ public class HttpUtils { httpUtilParamInfo.setUrl(getUrl.trim()); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } return baseRequest(httpConnection, httpDelete); } @@ -381,7 +381,7 @@ public class HttpUtils { httpUtilParamInfo.setUrl(getUrl.trim()); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } callBackRequest(httpConnection, httpGet, consumer); } @@ -412,7 +412,7 @@ public class HttpUtils { httpUtilParamInfo.setUrl(getUrl.trim()); HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.set(httpUtilParamInfo); } catch (Exception ignore) { - + } callBackRequest(httpConnection, httpDelete, consumer); } @@ -708,7 +708,7 @@ public class HttpUtils { SerializerFeature.PrettyFormat, SerializerFeature.WriteDateUseDateFormat))); } catch (Exception ignore) { - + } HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove(); ExtendedIOUtils.closeQuietly(httpClient); @@ -755,7 +755,7 @@ public class HttpUtils { SerializerFeature.PrettyFormat, SerializerFeature.WriteDateUseDateFormat))); } catch (Exception ignore) { - + } ExtendedIOUtils.closeQuietly(httpClient); ExtendedIOUtils.closeQuietly(response); @@ -793,7 +793,7 @@ public class HttpUtils { SerializerFeature.PrettyFormat, SerializerFeature.WriteDateUseDateFormat))); } catch (Exception ignore) { - + } } catch (Exception e) { log.error(" http调用失败:" + Util.getErrString(e)); @@ -805,7 +805,7 @@ public class HttpUtils { SerializerFeature.PrettyFormat, SerializerFeature.WriteDateUseDateFormat))); } catch (Exception ignore) { - + } throw e; } finally { @@ -1066,9 +1066,18 @@ public class HttpUtils { List nvps = new ArrayList<>(); for (Map.Entry entry : params.entrySet()) { // nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue()))); - // 修复请求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.setEntity(new UrlEncodedFormEntity(nvps)); @@ -1076,11 +1085,19 @@ public class HttpUtils { List nvps = new ArrayList<>(); for (Map.Entry 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.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 headerMap, Map paramsMap) throws UnsupportedEncodingException { return handleHttpPostObject(url, headerMap, paramsMap); } @@ -1261,7 +1294,17 @@ public class HttpUtils { for (Map.Entry entry : paramsMap.entrySet()) { // nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue()))); // 修复请求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.setEntity(new UrlEncodedFormEntity(nvps)); @@ -1270,7 +1313,17 @@ public class HttpUtils { for (Map.Entry entry : paramsMap.entrySet()) { // nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue()))); // 修复请求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)); } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) { diff --git a/src/main/java/aiyh/utils/recordset/ResultMapper.java b/src/main/java/aiyh/utils/recordset/ResultMapper.java index c25e24e..c5305cf 100644 --- a/src/main/java/aiyh/utils/recordset/ResultMapper.java +++ b/src/main/java/aiyh/utils/recordset/ResultMapper.java @@ -312,44 +312,60 @@ 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 (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); - continue; + + if (Objects.nonNull(toLowerCase)) { + ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); + } else { + if (enable) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); + continue; + } + if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); + } + ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); + ((Map) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1)); + ((Map) o).put(columnName[i], rs.getInt(i + 1)); } - if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); - } - ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1)); - ((Map) o).put(columnName[i], rs.getInt(i + 1)); continue; } if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) { + + if (Objects.nonNull(toLowerCase)) { + ((Map) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1)); + } else { + if (enable) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); + continue; + } + if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); + } + ((Map) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1)); + ((Map) o).put(columnName[i].toUpperCase(), rs.getFloat(i + 1)); + ((Map) o).put(columnName[i], rs.getFloat(i + 1)); + } + continue; + } + + if (Objects.nonNull(toLowerCase)) { + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + } else { if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); continue; } if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); } - ((Map) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getFloat(i + 1)); - ((Map) o).put(columnName[i], rs.getFloat(i + 1)); - continue; + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i], rs.getString(i + 1)); } - if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); - continue; - } - if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); - } - ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); - ((Map) 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,29 +476,39 @@ 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 (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i])); - continue; + + if (Objects.nonNull(toLowerCase)) { + ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); + } else { + if (enable) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i])); + continue; + } + if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); + } + ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); + ((Map) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1)); + ((Map) o).put(columnName[i], rs.getInt(i + 1)); } - if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); - } - ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1)); - ((Map) o).put(columnName[i], rs.getInt(i + 1)); continue; } if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) { - if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); - continue; + + if (Objects.nonNull(toLowerCase)) { + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + } else { + if (enable) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); + continue; + } + if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); + } + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i], rs.getString(i + 1)); } - if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); - } - ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i], rs.getString(i + 1)); continue; } if (method.isAnnotationPresent(Associations.class)) { @@ -506,16 +533,23 @@ public class ResultMapper { } } } - if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); - continue; + + if (Objects.nonNull(toLowerCase)) { + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + } else { + if (enable) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); + continue; + } + if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); + } + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i], rs.getString(i + 1)); + } - if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); - } - ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i], rs.getString(i + 1)); + } return o; } diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java index b4606e3..6f5519e 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java @@ -50,7 +50,10 @@ public class OrgChartService { /* ******************* 次账号处理逻辑 ******************* */ String accountType = logInUser.getAccount_type(); if ("1".equals(accountType)) { - return secondaryAccountTree(hrmResourceDtoList); + // 对当前账号过滤当前分部信息 + List collect = hrmResourceDtoList.stream().filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId()) + .collect(Collectors.toList()); + return secondaryAccountTree(collect); } filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser); /* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */ diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/mapper/CheckWorkflowRequestParamsMapper.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/mapper/CheckWorkflowRequestParamsMapper.java index f13c335..effce62 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/mapper/CheckWorkflowRequestParamsMapper.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/mapper/CheckWorkflowRequestParamsMapper.java @@ -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 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 selectConditionDetail(String mainId); @Select(custom = true) + @ToLowerCase Map selectCustomerSql(@SqlString String sql, @ParamMapper("value") String value, @ParamMapper("user") User user); diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfig.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfig.java index 2763cc5..a4e6b5e 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfig.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfig.java @@ -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 detailList; diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfigDetail.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfigDetail.java index 01f38a7..e6e39ae 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfigDetail.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/pojo/CheckCreateConfigDetail.java @@ -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; diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckCreateRequestCustomerInterface.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckCreateRequestCustomerInterface.java new file mode 100644 index 0000000..d8ef36f --- /dev/null +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckCreateRequestCustomerInterface.java @@ -0,0 +1,22 @@ +package com.customization.youhong.pcn.createrworkflow.util; + +import java.util.Map; + +/** + *

自定义校验接口

+ * + *

create: 2023/6/15 19:59

+ * + * @author youHong.ai + */ +public interface CheckCreateRequestCustomerInterface { + + /** + *

自定义检查方法接口

+ * + * @param checkFunctionParam 检查方法参数 + * @param pathParam 路径参数 + * @return 是否符合条件 + */ + boolean check(CheckFunctionParam checkFunctionParam, Map pathParam); +} diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckFunctionParam.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckFunctionParam.java new file mode 100644 index 0000000..e17ffcf --- /dev/null +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckFunctionParam.java @@ -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; + +/** + *

检查方法参数实体

+ * + *

create: 2023/6/15 15:24

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class CheckFunctionParam { + private WorkflowRequestTableField workflowRequestTableField; + private CheckCreateConfigDetail checkCreateConfigDetail; + private Map checkConditionMap; + private User user; + private CheckConditionItem checkConditionItem; +} diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckRuleMethodUtil.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckRuleMethodUtil.java index dc65634..8c83117 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckRuleMethodUtil.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckRuleMethodUtil.java @@ -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; /** *

检查方法校验工具

@@ -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 + Function > CHECK_RULE_MAP = new HashMap<>(8); static { @@ -46,14 +37,14 @@ public class CheckRuleMethodUtil { Class 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 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 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 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 checkConditionMap = checkFunctionParam.getCheckConditionMap(); + String customerValue = checkCreateConfigDetail.getCheckExpression(); + String replace = customerValue.replace("(", " ") + .replace(")", " "); + String[] groups = replace.split(" "); + List 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 conditionMap = new HashMap<>(8); + for (String groupName : groupList) { + CheckConditionItem checkConditionItem = checkConditionMap.get(groupName); + checkFunctionParam.setCheckConditionItem(checkConditionItem); + Function 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 map = Util.parseCusInterfacePathParam(customerValue); + String classPath = map.remove("_ClassPath"); + CheckCreateRequestCustomerInterface instance = Util.getClassInstance(classPath, CheckCreateRequestCustomerInterface.class); + return instance.check(checkFunctionParam, map); + } + } diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java index e4eeca4..8165b72 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java @@ -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 required = new ArrayList<>(); + for (Map.Entry entry : checkDetailMap.entrySet()) { + required.add(entry.getKey()); + } + throw new CreateRequestException(Util.logStr("必填参数校验未通过,[{}]字段必填!", Util.join(required, ","))); + } } + /** + *

校验主表数据

+ * + * @param checkDetailMap 校验规则map + * @param checkConditionItemMap 校验自定义条件组map + * @param requestParam 流程参数 + * @param user 用户 + */ private void checkMainData(Map checkDetailMap, Map checkConditionItemMap, - ReqOperateRequestEntity requestParam) { + ReqOperateRequestEntity requestParam, User user) { List mainData = requestParam.getMainData(); - for (WorkflowRequestTableField mainDatum : mainData) { - String fieldName = mainDatum.getFieldName(); + checkData(checkDetailMap, checkConditionItemMap, mainData, user, "主表"); + } + + private void checkDetailData(Map checkDetailMap, + Map checkConditionItemMap, + ReqOperateRequestEntity requestParam, User user) { + List 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 dataList + = Arrays.asList(workflowRequestTableFields); + checkData(checkDetailMap, checkConditionItemMap, dataList, user, detailDatum.getTableDBName()); + } + } + } + + private void checkData(Map checkDetailMap, + Map checkConditionItemMap, + List 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 function = CheckRuleMethodUtil.CHECK_RULE_MAP.get(checkRule); + Boolean apply = function.apply(checkFunctionParam); + if (!apply) { + throw new CreateRequestException(Util.logStr("[{}] 表数据校验未通过,字段[{}],错误信息[{}]", + tableDesc, fieldName, checkCreateConfigDetail.getErrorMsg())); + } } } } diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/LocationKeywordAction.java b/src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/LocationKeywordAction.java new file mode 100644 index 0000000..ad57fcf --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/LocationKeywordAction.java @@ -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; + +/** + *

定位查找关键字

+ * + *

create: 2023/6/16 16:38

+ * + * @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 mainData = getMainTableValue(requestInfo); + String docIds = mainData.get(docField); + if (StrUtil.isBlank(docIds)) { + return; + } + List docImageInfos = mapper.selectDocImageInfos(docIds); + if (CollectionUtil.isEmpty(docImageInfos)) { + log.error("未查询到物理文件信息!=>" + docIds); + Util.actionFailException(requestInfo.getRequestManager(), "系统异常,请联系管理员"); + } + String[] keywordArr = keywords.split(";"); + Map keyMap = new HashMap<>(8); + for (DocImageInfo docImageInfo : docImageInfos) { + Map keyword = findKeyWord(docImageInfo, keywordArr); + for (Map.Entry 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 entry : keyMap.entrySet()) { + if (!entry.getValue()) { + throw new CustomerException(Util.logStr("关键字[{}]定位异常!文件中不存在关键字!", entry.getKey())); + } + } + } + + + private Map findKeyWord(DocImageInfo docImageInfo, String[] keywordArr) { + String imageFileName = docImageInfo.getImageFileName(); + Integer imageFileId = docImageInfo.getImageFileId(); + Map result = new HashMap<>(8); + InputStream inputStream = ImageFileManager.getInputStreamById(imageFileId); + if (imageFileName.endsWith(".pdf")) { + for (String keyword : keywordArr) { + List 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 keywordPoints = WordKeywordFinder.findKeywords(inputStream, keyword, imageFileName); + if (CollectionUtil.isEmpty(keywordPoints)) { + result.put(keyword, false); + } else { + result.put(keyword, true); + } + } + } + return result; + } +} diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/mapper/LocationKeywordMapper.java b/src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/mapper/LocationKeywordMapper.java new file mode 100644 index 0000000..934ce61 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/locationkeyword/mapper/LocationKeywordMapper.java @@ -0,0 +1,14 @@ +package weaver.youhong.ai.pcn.actioin.locationkeyword.mapper; + +import aiyh.utils.annotation.recordset.SqlMapper; + +/** + *

+ * + *

create: 2023/6/16 16:56

+ * + * @author youHong.ai + */ +@SqlMapper +public interface LocationKeywordMapper { +} diff --git a/src/test/java/youhong/ai/utiltest/GenericTest.java b/src/test/java/youhong/ai/utiltest/GenericTest.java index b0c0be6..b567c20 100644 --- a/src/test/java/youhong/ai/utiltest/GenericTest.java +++ b/src/test/java/youhong/ai/utiltest/GenericTest.java @@ -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; diff --git a/src/test/java/youhong/ai/utiltest/TestApi.java b/src/test/java/youhong/ai/utiltest/TestApi.java index fb9d2ef..8c33456 100644 --- a/src/test/java/youhong/ai/utiltest/TestApi.java +++ b/src/test/java/youhong/ai/utiltest/TestApi.java @@ -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 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)); } /** diff --git a/src/test/java/youhong/ai/utiltest/ExcelBody.java b/src/test/java/youhong/ai/utiltest/excel/ExcelBody.java similarity index 70% rename from src/test/java/youhong/ai/utiltest/ExcelBody.java rename to src/test/java/youhong/ai/utiltest/excel/ExcelBody.java index e143903..cea4c27 100644 --- a/src/test/java/youhong/ai/utiltest/ExcelBody.java +++ b/src/test/java/youhong/ai/utiltest/excel/ExcelBody.java @@ -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 { } diff --git a/src/test/java/youhong/ai/utiltest/ExcelCell.java b/src/test/java/youhong/ai/utiltest/excel/ExcelCell.java similarity index 90% rename from src/test/java/youhong/ai/utiltest/ExcelCell.java rename to src/test/java/youhong/ai/utiltest/excel/ExcelCell.java index 8f38d69..083a975 100644 --- a/src/test/java/youhong/ai/utiltest/ExcelCell.java +++ b/src/test/java/youhong/ai/utiltest/excel/ExcelCell.java @@ -1,4 +1,4 @@ -package youhong.ai.utiltest; +package youhong.ai.utiltest.excel; import lombok.Getter; import lombok.Setter; diff --git a/src/test/java/youhong/ai/utiltest/ExcelHead.java b/src/test/java/youhong/ai/utiltest/excel/ExcelHead.java similarity index 87% rename from src/test/java/youhong/ai/utiltest/ExcelHead.java rename to src/test/java/youhong/ai/utiltest/excel/ExcelHead.java index 6ede4bf..a7a9b9b 100644 --- a/src/test/java/youhong/ai/utiltest/ExcelHead.java +++ b/src/test/java/youhong/ai/utiltest/excel/ExcelHead.java @@ -1,4 +1,4 @@ -package youhong.ai.utiltest; +package youhong.ai.utiltest.excel; import lombok.Getter; import lombok.Setter; diff --git a/src/test/java/youhong/ai/utiltest/ExcelPort.java b/src/test/java/youhong/ai/utiltest/excel/ExcelPort.java similarity index 98% rename from src/test/java/youhong/ai/utiltest/ExcelPort.java rename to src/test/java/youhong/ai/utiltest/excel/ExcelPort.java index 73f7db6..7a285af 100644 --- a/src/test/java/youhong/ai/utiltest/ExcelPort.java +++ b/src/test/java/youhong/ai/utiltest/excel/ExcelPort.java @@ -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; diff --git a/src/test/java/youhong/ai/utiltest/ExcelRow.java b/src/test/java/youhong/ai/utiltest/excel/ExcelRow.java similarity index 89% rename from src/test/java/youhong/ai/utiltest/ExcelRow.java rename to src/test/java/youhong/ai/utiltest/excel/ExcelRow.java index 5b538f9..d83748d 100644 --- a/src/test/java/youhong/ai/utiltest/ExcelRow.java +++ b/src/test/java/youhong/ai/utiltest/excel/ExcelRow.java @@ -1,4 +1,4 @@ -package youhong.ai.utiltest; +package youhong.ai.utiltest.excel; import lombok.Getter; import lombok.Setter; diff --git a/src/test/java/youhong/ai/utiltest/ExcelSheet.java b/src/test/java/youhong/ai/utiltest/excel/ExcelSheet.java similarity index 89% rename from src/test/java/youhong/ai/utiltest/ExcelSheet.java rename to src/test/java/youhong/ai/utiltest/excel/ExcelSheet.java index da992d6..63804c3 100644 --- a/src/test/java/youhong/ai/utiltest/ExcelSheet.java +++ b/src/test/java/youhong/ai/utiltest/excel/ExcelSheet.java @@ -1,4 +1,4 @@ -package youhong.ai.utiltest; +package youhong.ai.utiltest.excel; import lombok.Getter; import lombok.Setter; diff --git a/src/test/java/youhong/ai/utiltest/IExcelCellStyleCreator.java b/src/test/java/youhong/ai/utiltest/excel/IExcelCellStyleCreator.java similarity index 94% rename from src/test/java/youhong/ai/utiltest/IExcelCellStyleCreator.java rename to src/test/java/youhong/ai/utiltest/excel/IExcelCellStyleCreator.java index e5d581f..932a83c 100644 --- a/src/test/java/youhong/ai/utiltest/IExcelCellStyleCreator.java +++ b/src/test/java/youhong/ai/utiltest/excel/IExcelCellStyleCreator.java @@ -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; diff --git a/src/test/java/youhong/ai/utiltest/wordread/Main.java b/src/test/java/youhong/ai/utiltest/wordread/Main.java new file mode 100644 index 0000000..59c3f91 --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/wordread/Main.java @@ -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 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(); + } + } +} diff --git a/src/test/java/youhong/ai/utiltest/wordread/WordKeywordFinder.java b/src/test/java/youhong/ai/utiltest/wordread/WordKeywordFinder.java new file mode 100644 index 0000000..f88651d --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/wordread/WordKeywordFinder.java @@ -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 findKeywords(InputStream inputStream, String keyword, String fileName) throws IOException { + List 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; + } + } +} From e4787fc0c6319089b9c8958554fec3f788416b6b Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Fri, 16 Jun 2023 18:12:23 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8A=A8=E6=80=81=E7=94=9F=E6=88=90class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 + .../controller/VerifyController.java | 73 ++++++++++ .../cus_login/mapper/DzInvoiceMapper.java | 60 ++++++++ .../cus_login/service/VerifyCodeService.java | 54 ++++++++ .../xiao/zhenn/controller/BankController.java | 33 ++++- .../xiao/zhenn/service/BankService.java | 28 +++- .../xiao/zhenn/util/GenerateClassUtil.java | 129 ++++++++++++++++++ .../zenner/job/SyncAccountTradeInfoJob.java | 34 ++++- src/test/java/bokang/xiao/NormalTest.java | 111 ++++++++++++++- web/WEB-INF/web.xml | 6 + 10 files changed, 526 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/api/bokang/xiao/cus_login/controller/VerifyController.java create mode 100644 src/main/java/com/api/bokang/xiao/cus_login/mapper/DzInvoiceMapper.java create mode 100644 src/main/java/com/api/bokang/xiao/cus_login/service/VerifyCodeService.java create mode 100644 src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java create mode 100644 web/WEB-INF/web.xml diff --git a/pom.xml b/pom.xml index 7267c9b..ead8c4a 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,12 @@ + + org.javassist + javassist + 3.27.0-GA + + org.mapstruct diff --git a/src/main/java/com/api/bokang/xiao/cus_login/controller/VerifyController.java b/src/main/java/com/api/bokang/xiao/cus_login/controller/VerifyController.java new file mode 100644 index 0000000..b49ab7d --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/cus_login/controller/VerifyController.java @@ -0,0 +1,73 @@ +package com.api.bokang.xiao.cus_login.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.cus_login.service.VerifyCodeService; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @ClassName InvoiceSelectController + * @Author 肖博亢 + * @Date 2023/2/2 16:21 + * @Description

发票勾选,查询

+ **/ + +@Path("/xbk/cusLogin") +public class VerifyController { + + private final Logger log = Util.getLogger(); + + private final VerifyCodeService verifyCodeService = new VerifyCodeService(); + + /** + *

获取验证码

+ * @param request 请求体 + * @param response 响应体 + * @param param 请求参数 + * @return 请求结果 + */ + @Path("/getCode") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String getCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("into getCode success params ==> "+param); + String verifyCode = verifyCodeService.getVerifyCode(param); + return ApiResult.success(verifyCode); + }catch (Exception e){ + log.error("getCode error ==> \n"+Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } + + /** + *

检查验证码

+ * @param request 请求体 + * @param response 响应体 + * @param param 请求参数 + * @return 请求结果 + */ + @Path("/checkCode") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String checkCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("into checkCode success params ==> "+param); + return ApiResult.success(verifyCodeService.checkVerifyCode(param)); + }catch (Exception e){ + log.error("checkCode error ==> \n"+Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } + +} diff --git a/src/main/java/com/api/bokang/xiao/cus_login/mapper/DzInvoiceMapper.java b/src/main/java/com/api/bokang/xiao/cus_login/mapper/DzInvoiceMapper.java new file mode 100644 index 0000000..6bc4258 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/cus_login/mapper/DzInvoiceMapper.java @@ -0,0 +1,60 @@ +package com.api.bokang.xiao.cus_login.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.Update; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName DzInvoiceMapper + * @Author 肖博亢 + * @Date 2023/2/2 17:03 + * @Description

发票信息查询

+ **/ + +@SqlMapper +public interface DzInvoiceMapper { + + /** + *

通过id查询发票信息

+ * @param ids 发票id字符串 + * @return 发票信息集合 + */ + @Select("select * from APInvoice where id in ($t{ids})") + List> queryInvoiceList(@ParamMapper("ids") String ids); + + /** + *

更新发票勾选状态

+ * @param checkStatus 勾选状态值 + * @param fieldId 字段名 + * @param fieldValue 字段值 + * @return 操作结果 + */ + @Update("update fnaInvoiceLedger set check_status = #{checkStatus} where $t{fieldId} = #{fieldValue}") + boolean updateInvoiceCheckStatus(@ParamMapper("checkStatus") int checkStatus, + @ParamMapper("fieldId") String fieldId, + @ParamMapper("fieldValue") Object fieldValue); + + /** + *

更新发票勾选状态

+ * @param checkStatus 勾选状态值 + * @param fieldId 字段名 + * @param fieldValue 字段值 + * @return 操作结果 + */ + @Update("update fnaInvoiceLedger set check_status = #{checkStatus} where $t{fieldId} in ($t{fieldValue})") + boolean batchUpdateInvoiceCheckStatus(@ParamMapper("checkStatus") int checkStatus, + @ParamMapper("fieldId") String fieldId, + @ParamMapper("fieldValue") String fieldValue); + + /** + *

查询已经勾选过的发票信息

+ * @return 发票信息集合 + */ + @Select("select * from fnaInvoiceLedger where (check_status = 2 or check_status = 3) and hxjksflr = 'Y'") + List> queryOnChooseInvoices(); + +} diff --git a/src/main/java/com/api/bokang/xiao/cus_login/service/VerifyCodeService.java b/src/main/java/com/api/bokang/xiao/cus_login/service/VerifyCodeService.java new file mode 100644 index 0000000..f5ff5fa --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/cus_login/service/VerifyCodeService.java @@ -0,0 +1,54 @@ +package com.api.bokang.xiao.cus_login.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.cloudstore.dev.api.util.Util_DataCache; +import org.apache.log4j.Logger; + +import java.util.Map; + +/** + * @ClassName VerifyCodeService + * @Author 肖博亢 + * @Date 2023/6/14 14:49 + * @Description

+ **/ +public class VerifyCodeService { + + private final HttpUtils httpUtils = new HttpUtils(); + + private final Logger log = Util.getLogger(); + + /** + * 发送验证码 + * @param param 参数信息 + * @return 发送结果 + */ + public String getVerifyCode(Map param){ + String loginUser = Util.null2String(param.get("loginUser")); + //todo 发送请求获取验证码 + //将验证码加入缓存中 + Util_DataCache.setObjVal(loginUser,"9088",60); + return ""; + } + + /** + * 验证验证码 + * @param param 参数信息 + * @return 验证结果 + */ + public boolean checkVerifyCode(Map param){ + String loginUser = Util.null2String(param.get("loginUser")); + String verifyCode = Util.null2String(param.get("verifyCode")); + String tempVerifyCode = Util.null2String(Util_DataCache.getObjVal(loginUser)); + if("".equals(tempVerifyCode)){ + throw new CustomerException("验证码已过期!请重新获取验证码"); + } + if(verifyCode.equals(tempVerifyCode)){ + Util_DataCache.clearVal(loginUser); + return true; + } + throw new CustomerException("验证码不正确!请重新输入"); + } +} diff --git a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java index 142abea..cbc3692 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java @@ -12,11 +12,14 @@ import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URLEncoder; import java.util.List; import java.util.Map; @@ -77,4 +80,28 @@ public class BankController { } } + @POST + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportExcel(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) throws IOException { + try { + log.info("====== into exportExcel success ======="); + log.info("param:"+param); + String dialogTitle = Util.null2String(param.get("dialogTitle")); + String fileName = dialogTitle + Util.getTime("yyyy-MM-dd") + ".xlsx"; + StreamingOutput streamingOutput = outputStream -> { + bankService.export(outputStream,param); + }; + log.info("fileName==>"+fileName); + String encodedFileName = URLEncoder.encode(fileName, "UTF-8"); + return Response.ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM) + // 指定编码方式为 UTF-8 + .header("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName) + .build(); + }catch (Exception e){ + log.error("exportExcel error ==> "+Util.getErrString(e)); + return Response.ok(ApiResult.error("导出文件失败!"), MediaType.APPLICATION_JSON).build(); + } + } + } diff --git a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java index 4af3a11..e29fce9 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java @@ -1,13 +1,19 @@ package com.api.bokang.xiao.zhenn.service; import aiyh.utils.Util; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.fastjson.JSON; import com.api.bokang.xiao.zhenn.mapper.BankMapper; +import com.api.bokang.xiao.zhenn.util.GenerateClassUtil; import org.apache.log4j.Logger; import weaver.bokang.xiao.common.CommonUtil; import weaver.bokang.xiao.common.mapper.WorkflowMapper; import weaver.hrm.User; +import java.io.File; +import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -107,8 +113,8 @@ public class BankService { bankBaseInfo.put("bankAccount",bankAccount); //求总和 Map amountMap = new HashMap<>(); - double bankDayAmount = this.queryBankDayAmount(param); - double bankStatementBalance = this.queryBankStatementBalance(param); + double bankDayAmount = this.queryBankStatementBalance(param);//sap余额信息 + double bankStatementBalance = this.queryBankDayAmount(param);//银行余额信息 double bankInDifference = bankInTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum(); double oaInDifference = 0; double bankOutDifference = bankOutTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum(); @@ -165,4 +171,22 @@ public class BankService { return bankMapper.queryBankStatementBalance(param); } + /** + * 导出Excel处理方法 + * @param outputStream 请求输出流 + * @param param 参数信息 + */ + public void export(OutputStream outputStream, Map param) { + log.info("导出Excel export"); + List> columns = (List>) param.get("columns"); + List> dataSource = (List>) param.get("dataSource"); + String className = Util.null2String(param.get("type")); + Map classMessage = new HashMap<>(); + classMessage.put("columns",columns); + classMessage.put("className",className); + Class aClass = GenerateClassUtil.generateClassByMap(classMessage); + List objects = GenerateClassUtil.covertClassList(dataSource, aClass); + log.info("excel List ==>"+objects.size()); + EasyExcel.write(outputStream, aClass).sheet("Sheet1").doWrite(objects); + } } diff --git a/src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java b/src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java new file mode 100644 index 0000000..6fc9271 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java @@ -0,0 +1,129 @@ +package com.api.bokang.xiao.zhenn.util; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.excel.annotation.ExcelProperty; +import javassist.*; +import javassist.bytecode.AnnotationsAttribute; +import javassist.bytecode.ConstPool; +import javassist.bytecode.annotation.Annotation; +import javassist.bytecode.annotation.ArrayMemberValue; +import javassist.bytecode.annotation.MemberValue; +import javassist.bytecode.annotation.StringMemberValue; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @ClassName GenerateClassUtil + * @Author 肖博亢 + * @Date 2023/6/16 11:04 + * @Description

+ **/ +public class GenerateClassUtil { + + private static final Logger log = Util.getLogger(); + + private static final Map> CLASS_MAP = new HashMap<>(); + + /** + * 利用javassist动态生成class + * @param classMessage 类基础信息 + * @return Class + */ + public static Class generateClassByMap(Map classMessage){ + String className = Util.null2String(classMessage.get("className")); + //className = className+System.currentTimeMillis(); + List> columns = (List>) classMessage.get("columns"); + if(StringUtils.isBlank(className)){ + throw new CustomerException("GenerateClass Exception 类名不能为空!!!"); + } + if(Objects.isNull(columns) || columns.isEmpty()){ + throw new CustomerException("GenerateClass Exception 列信息不能为空!!!"); + } + try { + Class cacheClass = CLASS_MAP.get(className); + if(Objects.nonNull(cacheClass)){ + return cacheClass; + } + // 创建 ClassPool 对象 + ClassPool pool = ClassPool.getDefault(); + CtClass cc = null; + //从缓存中获取类 + try { + cc = pool.getCtClass(className); + if(Objects.isNull(cc)) { + // 创建一个新的类 + cc = pool.makeClass(className); + } + return cc.toClass(); + }catch (NotFoundException e){ + // 创建一个新的类 + cc = pool.makeClass(className); + } + + for (Map column : columns) { + String title = column.get("title"); + String dataIndex = column.get("dataIndex"); + CtField field = new CtField(ClassPool.getDefault().get(String.class.getName()), dataIndex, cc); + field.setModifiers(Modifier.PRIVATE); + cc.addField(field); + cc.addMethod(CtNewMethod.setter("set" + dataIndex.substring(0, 1).toUpperCase() + dataIndex.substring(1), field)); + cc.addMethod(CtNewMethod.getter("get" + dataIndex.substring(0, 1).toUpperCase() + dataIndex.substring(1), field)); + field.getFieldInfo().addAttribute(new AnnotationsAttribute(field.getFieldInfo().getConstPool(), AnnotationsAttribute.visibleTag)); + // 添加 ExcelProperty 注解 + ConstPool cp = cc.getClassFile().getConstPool(); + AnnotationsAttribute annotationsAttribute = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag); + Annotation annotation = new Annotation(ExcelProperty.class.getName(), cp); + //annotation.addMemberValue("value", new StringMemberValue(Arrays.toString(new String[] {title}), cp)); + StringMemberValue stringMemberValue = new StringMemberValue(title, cp); + MemberValue[] memberValues = new MemberValue[]{stringMemberValue}; + ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cp); + arrayMemberValue.setValue(memberValues); + annotation.addMemberValue("value", arrayMemberValue); + annotationsAttribute.addAnnotation(annotation); + field.getFieldInfo().addAttribute(annotationsAttribute); + } + Class aClass = cc.toClass(); + CLASS_MAP.put(className,aClass); + return aClass; + }catch (Exception e){ + log.error("GenerateClass error!"+Util.getErrString(e)); + throw new CustomerException("GenerateClass error "+e.getMessage()); + } + } + + /** + * 将Map转为实体类 + * @param dataSource map集合 + * @param clazz 实体类类信息 + * @return 转换后List + */ + public static List covertClassList(List> dataSource,Class clazz){ + if(Objects.isNull(dataSource) || dataSource.isEmpty()){ + return new ArrayList<>(); + } + return dataSource.stream().map(item ->{ + try { + Object data = clazz.newInstance(); + Field[] declaredFields = clazz.getDeclaredFields(); + for (Field declaredField : declaredFields) { + declaredField.setAccessible(true); + String name = declaredField.getName(); + String fieldVal = Util.null2String(item.get(name)); + declaredField.set(data,fieldVal); + } + return data; + } catch (Exception e) { + log.error("covertClass error "+Util.getErrString(e)); + throw new CustomerException("covertClass error 反射异常"+e.getMessage()); + } + }).collect(Collectors.toList()); + } + + +} diff --git a/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java index 01f4496..1a72ca3 100644 --- a/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java +++ b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java @@ -31,8 +31,30 @@ public class SyncAccountTradeInfoJob extends BaseCronJob { private String interfaceName; + /** 同步开始日期 */ + private String fromDate; + + /** 同步结束日期 */ + private String toDate; + private final static String JobName = " SyncAccountTradeInfoJob "; + public String getFromDate() { + return fromDate; + } + + public void setFromDate(String fromDate) { + this.fromDate = fromDate; + } + + public String getToDate() { + return toDate; + } + + public void setToDate(String toDate) { + this.toDate = toDate; + } + public String getInterfaceName() { return interfaceName; } @@ -48,6 +70,7 @@ public class SyncAccountTradeInfoJob extends BaseCronJob { ZennerApiService zennerApiService = new ZennerApiService(); try { logger.writeLog("-----" + JobName + " getInterfaceName------" + getInterfaceName()); + logger.writeLog(String.format("params --- fromDate:%s toDate:%s",fromDate,toDate)); //银行 String bankApiUrl = zennerApiService.getSystemConfigValue("BANK_API_URL"); @@ -103,8 +126,10 @@ public class SyncAccountTradeInfoJob extends BaseCronJob { //xmlParams.put("from", "20220919"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, -1); - xmlParams.put("from", ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit)); - xmlParams.put("to", ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit)); + String from = !"".equals(Util.null2String(this.fromDate)) ? this.fromDate : ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit); + String to = !"".equals(Util.null2String(this.toDate)) ? this.toDate : ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit); + xmlParams.put("from", from); + xmlParams.put("to", to); xmlParams.put("amountFrom", "1"); xmlParams.put("amountTo", "100000"); xmlParams.put("begnum", start + ""); @@ -312,6 +337,11 @@ public class SyncAccountTradeInfoJob extends BaseCronJob { tradeInfo.setDirection(l4Element.getStringValue()); } } + if ("insid".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setInsid(l4Element.getStringValue()); + } + } } tradeInfoList.add(tradeInfo); diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 86ca4e0..e1a85c0 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -11,14 +11,24 @@ import bokang.xiao.entity.TeacherEntity; import bokang.xiao.util.XmlParser; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; -import com.alibaba.fastjson.JSON; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.annotation.ExcelProperty; + import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; import com.api.bokang.xiao.wx_report.mapper.ReportMapper; import com.api.bokang.xiao.wx_report.service.ReportService; import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl; +import com.api.bokang.xiao.zhenn.service.BankService; import com.api.bokang.xiao.zscq.service.ReserveService; import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl; +import javassist.*; +import javassist.bytecode.AnnotationsAttribute; +import javassist.bytecode.ConstPool; +import javassist.bytecode.annotation.Annotation; +import javassist.bytecode.annotation.ArrayMemberValue; +import javassist.bytecode.annotation.MemberValue; +import javassist.bytecode.annotation.StringMemberValue; import org.apache.log4j.Logger; import org.apache.poi.ss.usermodel.Workbook; import org.junit.Test; @@ -51,7 +61,9 @@ import weaver.xiao.commons.utils.DocImageFileUtil; import java.io.*; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; import java.sql.*; import java.text.SimpleDateFormat; import java.util.*; @@ -72,6 +84,103 @@ public class NormalTest extends BaseTest { //GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class); } + @Test + public void testReport1() throws FileNotFoundException { + BankService bankService = new BankService(); + Map param = new HashMap<>(); + List> dataSource = new ArrayList<>(); + Map data = new HashMap<>(); + data.put("requestId",123445); + data.put("outAmount",2444); + data.put("inCompany","公司"); + data.put("outDate","2023-06-16"); + dataSource.add(data); + param.put("columns",getColumn()); + param.put("dataSource",dataSource); + param.put("type","oaOut"); + bankService.export(new FileOutputStream("/Users/ic_excellent/Downloads/test.xlsx"),param); + bankService.export(new FileOutputStream("/Users/ic_excellent/Downloads/test1.xlsx"),param); + } + + @Test + public void testGen() throws CannotCompileException, NotFoundException, InstantiationException, IllegalAccessException, IOException { + // 创建 ClassPool 对象 + ClassPool pool = ClassPool.getDefault(); + + // 创建一个新的类 + CtClass cc = pool.makeClass("Person"); + + List> columns = getColumn(); + for (Map column : columns) { + String title = column.get("title"); + String dataIndex = column.get("dataIndex"); + CtField field = new CtField(ClassPool.getDefault().get(String.class.getName()), dataIndex, cc); + field.setModifiers(Modifier.PRIVATE); + cc.addField(field); + cc.addMethod(CtNewMethod.setter("set" + dataIndex.substring(0, 1).toUpperCase() + dataIndex.substring(1), field)); + cc.addMethod(CtNewMethod.getter("get" + dataIndex.substring(0, 1).toUpperCase() + dataIndex.substring(1), field)); + field.getFieldInfo().addAttribute(new AnnotationsAttribute(field.getFieldInfo().getConstPool(), AnnotationsAttribute.visibleTag)); + // 添加 ExcelProperty 注解 + ConstPool cp = cc.getClassFile().getConstPool(); + AnnotationsAttribute annotationsAttribute = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag); + Annotation annotation = new Annotation(ExcelProperty.class.getName(), cp); + //annotation.addMemberValue("value", new StringMemberValue(Arrays.toString(new String[] {title}), cp)); + StringMemberValue stringMemberValue = new StringMemberValue(title, cp); + MemberValue[] memberValues = new MemberValue[]{stringMemberValue}; + ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cp); + arrayMemberValue.setValue(memberValues); + annotation.addMemberValue("value", arrayMemberValue); + annotationsAttribute.addAnnotation(annotation); + field.getFieldInfo().addAttribute(annotationsAttribute); + } + + Class aClass = cc.toClass(); + + List dataList = new ArrayList<>(); + // 构造实体类 + Object data = aClass.newInstance(); + Field[] declaredFields = aClass.getDeclaredFields(); + for (Field declaredField : declaredFields) { + declaredField.setAccessible(true); + declaredField.set(data,"test"); + } + dataList.add(data); +// cc.writeFile(); + EasyExcel.write(new File("/Users/ic_excellent/Downloads/test.xlsx"), aClass).sheet("Sheet1").doWrite(dataList); + + } + + public List> getColumn() { + List> list = new ArrayList<>(); + Map map = new HashMap<>(); + + map = new HashMap<>(); + map.put("title", "OA流程号"); + map.put("dataIndex", "requestId"); + map.put("key", "requestId"); + list.add(map); + + map = new HashMap<>(); + map.put("title", "收款金额"); + map.put("dataIndex", "outAmount"); + map.put("key", "inAmount"); + list.add(map); + + map = new HashMap<>(); + map.put("title", "付款单位"); + map.put("dataIndex", "inCompany"); + map.put("key", "outCompany"); + list.add(map); + + map = new HashMap<>(); + map.put("title", "收款日期"); + map.put("dataIndex", "outDate"); + map.put("key", "inDate"); + list.add(map); + + return list; + } + @Test public void testChain(){ GenerateReportSchedule generateReportSchedule = new GenerateReportSchedule(); diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml new file mode 100644 index 0000000..d80081d --- /dev/null +++ b/web/WEB-INF/web.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file From 3333e103f432e6ec740edbabcc4fbccd7c6c048b Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Tue, 20 Jun 2023 23:47:33 +0800 Subject: [PATCH 3/5] =?UTF-8?q?vms=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xuanran.wang/longgong/NewProductTest.js | 7 +- .../wang/immc/cusfieldvalue/CusListValue.java | 20 +-- .../service/WorkFlowToVmsAndMQService.java | 114 +++++++++--------- .../common/util/SendTodoTaskUtil.java | 27 +++-- .../sh_bigdata/common/util/ShBigDataUtil.java | 2 + .../prop/prop2map/ShBigdataConf.properties | 5 +- src/test/java/xuanran/wang/NormalTest.java | 3 +- 7 files changed, 98 insertions(+), 80 deletions(-) diff --git a/javascript/xuanran.wang/longgong/NewProductTest.js b/javascript/xuanran.wang/longgong/NewProductTest.js index fe457d8..9e7768e 100644 --- a/javascript/xuanran.wang/longgong/NewProductTest.js +++ b/javascript/xuanran.wang/longgong/NewProductTest.js @@ -59,7 +59,7 @@ function initTimeoutDate(){ console.log('计算下次超时日期 ', computeTimeoutDate); var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField)); var detail2LineNum = WfForm.getDetailRowCount("detail_2"); - setTimeout(()=>{ + setTimeout(function (){ WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate}); // 判断流程提交走向 console.log('主表跟踪触发行数 : ', trackingLine) @@ -101,7 +101,10 @@ function getCurrentDate() { function parseDate(date) { var currentYear = date.getFullYear(); - var currentMonth = date.getMonth() + 1; // getMonth()返回0~11,需要加1 + var currentMonth = date.getMonth() + 1;// getMonth()返回0~11,需要加1 + if(currentMonth < 10){ + currentMonth = '0' + currentMonth; + } var currentDay = date.getDate(); return currentYear + '-' + currentMonth + '-' + currentDay; } diff --git a/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java b/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java index 4694a75..8079d3e 100644 --- a/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java +++ b/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java @@ -32,19 +32,20 @@ public class CusListValue implements CusInterfaceGetValue { // 如果fileName不为空则对集合中每个map添加"fileName":value value则是附件字段名称 String fileName = Util.null2DefaultStr(pathParam.get("fileName"), ""); if(StringUtils.isNotBlank(cusSql)){ + cusSql = cusSql.replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),"")); if (StringUtils.isNotBlank(attachmentField)) { - for (String item : attachmentField.split(",")) { + String[] fields = attachmentField.split(","); + for (String item : fields) { String filedValue = Util.null2DefaultStr(mainMap.get(item),""); - if(StringUtils.isNotBlank(Util.null2DefaultStr(mainMap.get(filedValue),""))){ - cusSql = cusSql - .replace("{?docIds}", "( " + filedValue + " )") - .replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),"")); - List> attachmentInfo = mapper.getAttachmentInfo(cusSql); + String fileSql = cusSql; + if(StringUtils.isNotBlank(filedValue)){ + fileSql = fileSql.replace("{?docIds}", "( " + filedValue + " )"); + List> attachmentInfo = mapper.getAttachmentInfo(fileSql); if(CollectionUtils.isEmpty(attachmentInfo)){ continue; } // 往map中put附件字段名 - if(StringUtils.isBlank(fileName)){ + if(StringUtils.isNotBlank(fileName)){ attachmentInfo.forEach(file ->{ file.put(fileName, item); }); @@ -52,6 +53,11 @@ public class CusListValue implements CusInterfaceGetValue { list.addAll(attachmentInfo); } } + }else { + List> attachmentInfo = mapper.getAttachmentInfo(cusSql); + if(CollectionUtils.isNotEmpty(attachmentInfo)){ + list.addAll(attachmentInfo); + } } } return list; diff --git a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java index efcbf85..6de58fa 100644 --- a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java +++ b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java @@ -42,7 +42,6 @@ public class WorkFlowToVmsAndMQService { // 表单字段 private static final String VMS_SUCCESS = "vms_success"; private static final String SUCCESS = "0"; - { httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头 } @@ -51,11 +50,11 @@ public class WorkFlowToVmsAndMQService { /** *

推送数据

* - * @param onlyMark 唯一编码 - * @param billTable 表名 - * @param requestId 请求id + * @param onlyMark 唯一编码 + * @param billTable 表名 + * @param requestId 请求id * @param vmsResponseVoField vms成功标识 - * @param config kafka配置文件名称 + * @param config kafka配置文件名称 * @author xuanran.wang * @dateTime 2022/12/5 17:05 **/ @@ -69,9 +68,9 @@ public class WorkFlowToVmsAndMQService { String url = requestMappingConfig.getRequestUrl(); dealWithMapping.setMainTable(billTable); Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); - String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS), ""); - String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS), ""); - if (!SUCCESS.equals(vmsSuccess)) { + String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS),""); + String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS),""); + if(!SUCCESS.equals(vmsSuccess)){ ResponeVo responeVo; try { responeVo = httpUtils.apiPost(url, param); @@ -81,7 +80,7 @@ public class WorkFlowToVmsAndMQService { parseResponseVo(responeVo, url, param, vmsResponseVoField); updateWorkFlow(VMS_SUCCESS, billTable, requestId); } - if (!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)) { + if(!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)){ sendToMQ(config, param); updateWorkFlow(MQ_SUCCESS, billTable, requestId); } @@ -89,14 +88,13 @@ public class WorkFlowToVmsAndMQService { /** *

解析响应对象

- * - * @param responseVo 响应对象 - * @param url 地址 - * @param requestParam 请求 * @author xuanran.wang * @dateTime 2022/12/23 11:25 + * @param responseVo 响应对象 + * @param url 地址 + * @param requestParam 请求 **/ - private void parseResponseVo(ResponeVo responseVo, String url, Map requestParam, VmsResponseVoField vmsResponseVoField) { + private void parseResponseVo(ResponeVo responseVo, String url, Map requestParam, VmsResponseVoField vmsResponseVoField){ if (responseVo.getCode() != SUCCESS_CODE) { // 相应状态码 log.error(Util.logStr("can not fetch [{}],this request params is [{}]," + // 构建日志字符串 "this request heard is [{}],but response status code is [{}]," + @@ -114,65 +112,63 @@ public class WorkFlowToVmsAndMQService { /** *

将流程信息发送到kafka

- * - * @param kafkaConfig kafka配置文件名称 - * @param message 消息对象 * @author xuanran.wang * @dateTime 2023/3/30 14:56 + * @param kafkaConfig kafka配置文件名称 + * @param message 消息对象 **/ - public void sendToMQ(String kafkaConfig, Map message) { + public void sendToMQ(String kafkaConfig, Map message){ KafkaProducer producer = null; InputStream inputStream = null; - try { - String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties"; - File configFile = new File(path); - if (!configFile.exists()) { - throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties"); - } - Properties prop = new Properties(); - inputStream = new BufferedInputStream(Files.newInputStream(configFile.toPath())); - prop.load(inputStream); - log.info("prop => " + JSONObject.toJSONString(prop)); - log.info("msg => " + JSONObject.toJSONString(message)); - String topic = Util.null2DefaultStr(prop.getProperty("topic"), ""); - if (StringUtils.isBlank(topic)) { - throw new CustomerException("kafka properties topic can not null!"); - } - producer = new KafkaProducer<>(prop); - // 发送消息到指定主题 - ProducerRecord record = new ProducerRecord<>(topic, JSONObject.toJSONString(message)); - producer.send(record).get(); - } catch (Exception e) { - log.error(Util.getErrString(e)); - throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage())); - } finally { - // 关闭Kafka生产者实例 - if (producer != null) { - producer.close(); - } - if (inputStream != null) { - try { - inputStream.close(); - } catch (Exception e) { - log.error("inputStream close error! " + e.getMessage()); - } - } - } + try { + String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties"; + File configFile = new File(path); + if(!configFile.exists()){ + throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties"); + } + Properties prop = new Properties(); + inputStream= new BufferedInputStream(Files.newInputStream(configFile.toPath())); + prop.load(inputStream); + log.info("prop => " + JSONObject.toJSONString(prop)); + log.info("msg => " + JSONObject.toJSONString(message)); + String topic = Util.null2DefaultStr(prop.getProperty("topic"),""); + if(StringUtils.isBlank(topic)){ + throw new CustomerException("kafka properties topic can not null!"); + } + producer = new KafkaProducer<>(prop); + // 发送消息到指定主题 + ProducerRecord record = new ProducerRecord<>(topic, JSONObject.toJSONString(message)); + producer.send(record).get(); + }catch (Exception e){ + log.error(Util.getErrString(e)); + throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage())); + }finally { + // 关闭Kafka生产者实例 + if(producer != null){ + producer.close(); + } + if(inputStream != null){ + try { + inputStream.close(); + }catch (Exception e){ + log.error("inputStream close error! " + e.getMessage()); + } + } + } } /** *

更新流程sql

- * - * @param field 主表字段 - * @param tableName 表名 - * @param requestId 请求id * @author xuanran.wang * @dateTime 2023/3/30 19:18 + * @param field 主表字段 + * @param tableName 表名 + * @param requestId 请求id **/ - public void updateWorkFlow(String field, String tableName, String requestId) { + public void updateWorkFlow(String field, String tableName, String requestId){ String updateSQL = "update " + tableName + " set " + field + " = " + SUCCESS + " where requestid = ?"; RecordSet recordSet = new RecordSet(); - if (!recordSet.executeUpdate(updateSQL, requestId)) { + if(!recordSet.executeUpdate(updateSQL, requestId)){ log.error(Util.logStr("update field error! sql: {}, requestId: {}", updateSQL, requestId)); throw new CustomerException("更新表单字段失败!"); } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java index 4a9e12d..b6c8e8c 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java @@ -80,15 +80,16 @@ public class SendTodoTaskUtil { } todoTask.setPcAgentId(pcAgentId); String todoSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoSSOCallBackUrl"); - StringBuilder sb = new StringBuilder(todoSSOCallBackUrl); - sb.append("?user=") - .append(userId) - .append("&requestId=") - .append(requestId); -// todoTask.setLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskPcUrl"), oaAddress) + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestId); -// todoTask.setMobileLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskMobileUrl"), oaAddress) + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestId); - todoTask.setLinkUrl(sb.toString()); - todoTask.setMobileLinkUrl(sb.append("&mobile=1").toString()); + String todoPcSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoPcSSOCallBackUrl"); + if(StringUtils.isBlank(todoPcSSOCallBackUrl)){ + todoPcSSOCallBackUrl = todoSSOCallBackUrl; + } + // 移动端链接 + StringBuilder mobileUrl = new StringBuilder(todoSSOCallBackUrl); + // pc端链接 + StringBuilder pcUrl = new StringBuilder(todoPcSSOCallBackUrl); + todoTask.setLinkUrl(appendParam(pcUrl, userId, requestId).toString()); + todoTask.setMobileLinkUrl(appendParam(mobileUrl, userId, requestId).append("&mobile=1").toString()); todoTask.setSender(getConvertHrm(0, obj, String.valueOf(obj.getCreator().getUID()))); todoTask.setReceiver(getConvertHrm(1, obj, String.valueOf(userId))); res.add(todoTask); @@ -96,6 +97,14 @@ public class SendTodoTaskUtil { return res; } + public static StringBuilder appendParam(StringBuilder sb, int userId, int requestId){ + sb.append("?user=") + .append(userId) + .append("&requestId=") + .append(requestId); + return sb; + } + /** *

将oa任务对象转换成三方系统任务对象

* @author xuanran.wang diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java index 022066b..88d217c 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java @@ -38,6 +38,8 @@ public class ShBigDataUtil { WHILTE_LIST.add("ssoInterfaceCompareField"); WHILTE_LIST.add("ssoOaCompareField"); WHILTE_LIST.add("pcAgentId"); + // pc回调地址 + WHILTE_LIST.add("todoPcSSOCallBackUrl"); } /** diff --git a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties index 5c93ffa..7c96873 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties @@ -26,9 +26,10 @@ taskPcUrl=http://127.0.0.1/spa/workflow/static4form/index.html?#/main/workflow/r taskMobileUrl=http://127.0.0.1/spa/workflow/static4mobileform/index.html?#/req?requestid={requestId} # oa token缓存对象提前过期时间 expiryBeforeTime=5 -# 统一待办单点接口地址 +# 统一待办单点移动端接口地址 todoSSOCallBackUrl=http://127.0.0.1/api/wxr/sh_big_data/sso/login/dhajhdsajdhsajdaskdlakdl - +# 统一待办单点pc接口地址 +todoPcSSOCallBackUrl=http://127.0.0.1/api/wxr/sh_big_data/sso/login/dhajhdsajdhsajdaskdlakdl # ================ 组织架构同步新增 ================ # 分部最大的层级 maxLevel=3 diff --git a/src/test/java/xuanran/wang/NormalTest.java b/src/test/java/xuanran/wang/NormalTest.java index 0fc4fb5..17b6aac 100644 --- a/src/test/java/xuanran/wang/NormalTest.java +++ b/src/test/java/xuanran/wang/NormalTest.java @@ -4,6 +4,7 @@ import aiyh.utils.GenerateFileUtil; import basetest.BaseTest; import org.junit.Test; import weaver.xuanran.wang.eighty_five_degreec.sap.action.WorkflowToSap; +import weaver.xuanran.wang.immc.WorkFlowToVmsAndMQ; /** *

@@ -16,6 +17,6 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - GenerateFileUtil.createActionDocument(WorkflowToSap.class); + GenerateFileUtil.createActionDocument(WorkFlowToVmsAndMQ.class); } } From 0540f6b72e44cf10b8e055041eef1f577e1da5b6 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Mon, 26 Jun 2023 10:18:01 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E6=96=87=E4=B9=B1?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/Util.java | 11 ++- .../controller/ApiImmcWorkFlowToKafka.java | 49 ++++++++++ .../wang/immc/dto/ImmcWorkFlowToKafkaDto.java | 24 +++++ .../xuanran/wang/immc/WorkFlowToVmsAndMQ.java | 6 +- .../wang/immc/entity/CusRequestParam.java | 26 +++++ .../service/WorkFlowToVmsAndMQService.java | 98 +++++++++++++++---- .../common/util/SendTodoTaskUtil.java | 40 +++++++- .../sh_bigdata/common/util/ShBigDataUtil.java | 6 +- .../task_async/entity/CusTodoLeaderTask.java | 17 ++++ .../service/impl/SendTodoTaskServiceImpl.java | 6 +- .../prop/prop2map/ShBigdataConf.properties | 9 ++ .../xuanran/wang/big_data/BigDataTest.java | 44 +++++++++ 12 files changed, 311 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java create mode 100644 src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java create mode 100644 src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 99763b9..72856e1 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -1210,9 +1210,15 @@ public class Util extends weaver.general.Util { Properties prop = new Properties(); Map map = new HashMap<>(); InputStream inputStream = null; + InputStreamReader reader = null; try { inputStream = new BufferedInputStream(new FileInputStream(path)); - prop.load(inputStream); + /** + *

解决配置文件中 值包含中文乱码问题

+ *

xuanran.wang 2023-06-26 10:16

+ **/ + reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + prop.load(reader); Enumeration enumeration = prop.propertyNames(); while (enumeration.hasMoreElements()) { String key = String.valueOf(enumeration.nextElement()); @@ -1222,6 +1228,9 @@ public class Util extends weaver.general.Util { throw new RuntimeException("找不到文件:" + path); } finally { try { + if (reader != null) { + reader.close(); + } if (inputStream != null) { inputStream.close(); } diff --git a/src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java b/src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java new file mode 100644 index 0000000..eaffbf8 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java @@ -0,0 +1,49 @@ +package com.api.xuanran.wang.immc.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.immc.dto.ImmcWorkFlowToKafkaDto; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.xuanran.wang.immc.service.WorkFlowToVmsAndMQService; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + *

智己流程操作下发kafka

+ * + * @author xuanran.wang + * @date 2023/6/21 15:40 + */ +@Path("/wxr/immc/workflow/kafka") +public class ApiImmcWorkFlowToKafka { + + private final Logger log = Util.getLogger(); + + private final WorkFlowToVmsAndMQService service = new WorkFlowToVmsAndMQService(); + + @Path("/del") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String delWorkFlowToKafka(@Context HttpServletRequest request, + @Context HttpServletResponse response, + @RequestBody ImmcWorkFlowToKafkaDto config){ + try { + log.info("删除流程下发kafka配置对象 : " + JSONObject.toJSONString(config)); +// ImmcWorkFlowToKafkaDto dto = JSONObject.parseObject(JSONObject.toJSONString(config), ImmcWorkFlowToKafkaDto.class); + service.workFlowToKafkaByDto(config); + return ApiResult.successNoData(); + }catch (Exception e){ + log.error("删除流程下发kafka执行失败 : [ " + e.getMessage() + " ]"); + log.error(Util.getErrString(e)); + return ApiResult.error("下发kafka失败! " + e.getMessage()); + } + } +} diff --git a/src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java b/src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java new file mode 100644 index 0000000..2d06016 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java @@ -0,0 +1,24 @@ +package com.api.xuanran.wang.immc.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *

vo 智己流程下发kafka

+ * + * @author xuanran.wang + * @date 2023/6/21 16:08 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ImmcWorkFlowToKafkaDto { + private String onlyMark; + private Integer billTable; + private String config; + private Integer requestId; + private String skip; +} diff --git a/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java b/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java index 0246fb8..0c6ec5d 100644 --- a/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java +++ b/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java @@ -49,6 +49,10 @@ public class WorkFlowToVmsAndMQ extends SafeCusBaseAction { @PrintParamMark @ActionOptionalParam(value = "message", desc = "报错返回信息字段") private String msg; + @PrintParamMark + @ActionOptionalParam(value = "0", desc = "发送mq跳过校验") + private String mqSkip; + @Override public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { @@ -59,6 +63,6 @@ public class WorkFlowToVmsAndMQ extends SafeCusBaseAction { .successVal(Util.null2DefaultStr(successVal, "200")) .message(Util.null2DefaultStr(msg, "message")) .build(); - workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig); + workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig, mqSkip); } } diff --git a/src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java b/src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java new file mode 100644 index 0000000..c427a0e --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java @@ -0,0 +1,26 @@ +package weaver.xuanran.wang.immc.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import weaver.conn.RecordSet; + +import java.util.Map; + +/** + *

请求url, 请求参数

+ * + * @author xuanran.wang + * @date 2023/6/21 15:50 + */ +@Setter +@Builder +@AllArgsConstructor +@Getter +public class CusRequestParam { + private String url; + private RecordSet rs; + private Map param; + private String requestId; +} diff --git a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java index 6de58fa..766bb82 100644 --- a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java +++ b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java @@ -6,24 +6,25 @@ import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import org.apache.commons.collections.MapUtils; +import com.api.xuanran.wang.immc.dto.ImmcWorkFlowToKafkaDto; import org.apache.commons.lang3.StringUtils; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; -import org.apache.kafka.clients.producer.RecordMetadata; import org.apache.log4j.Logger; import weaver.conn.RecordSet; import weaver.general.GCONST; import weaver.xiao.commons.config.entity.RequestMappingConfig; import weaver.xiao.commons.config.service.DealWithMapping; import weaver.xuanran.wang.common.util.CommonUtil; +import weaver.xuanran.wang.immc.entity.CusRequestParam; import weaver.xuanran.wang.immc.entity.VmsResponseVoField; import javax.ws.rs.core.MediaType; import java.io.*; +import java.lang.reflect.Field; import java.nio.file.Files; -import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Properties; /** @@ -42,10 +43,24 @@ public class WorkFlowToVmsAndMQService { // 表单字段 private static final String VMS_SUCCESS = "vms_success"; private static final String SUCCESS = "0"; + + private static final String SKIP = "1"; + { httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头 } + /** + *

将流程数据下发到kafka中

+ * @author xuanran.wang + * @dateTime 2023/6/21 16:14 + * @param dto 接口封装对象 + **/ + public void workFlowToKafkaByDto(ImmcWorkFlowToKafkaDto dto){ + this.checkDtoFieldValueNotNull(dto); + this.workFlowToVmsAndMQ(dto.getOnlyMark(), "formtable_main_" + Math.abs(dto.getBillTable()), + String.valueOf(dto.getRequestId()), null, dto.getConfig(), dto.getSkip()); + } /** *

推送数据

@@ -58,19 +73,19 @@ public class WorkFlowToVmsAndMQService { * @author xuanran.wang * @dateTime 2022/12/5 17:05 **/ - public void workFlowToVmsAndMQ(String onlyMark, String billTable, String requestId, VmsResponseVoField vmsResponseVoField, String config) { - RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 - String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable); - log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId)); - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery(selectMainSql, requestId); - recordSet.next(); - String url = requestMappingConfig.getRequestUrl(); - dealWithMapping.setMainTable(billTable); - Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); - String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS),""); - String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS),""); - if(!SUCCESS.equals(vmsSuccess)){ + public void workFlowToVmsAndMQ(String onlyMark, String billTable, + String requestId, VmsResponseVoField vmsResponseVoField, + String config, String skip) { + CusRequestParam requestParam = getRequestParam(onlyMark, billTable, requestId); + if(Objects.isNull(requestParam)){ + return; + } + RecordSet rs = requestParam.getRs(); + Map param = requestParam.getParam(); + String url = requestParam.getUrl(); + String vmsSuccess = Util.null2DefaultStr(rs.getString(VMS_SUCCESS),""); + String mqSuccess = Util.null2DefaultStr(rs.getString(MQ_SUCCESS),""); + if(!SUCCESS.equals(vmsSuccess) && !Objects.isNull(vmsResponseVoField)){ ResponeVo responeVo; try { responeVo = httpUtils.apiPost(url, param); @@ -80,12 +95,61 @@ public class WorkFlowToVmsAndMQService { parseResponseVo(responeVo, url, param, vmsResponseVoField); updateWorkFlow(VMS_SUCCESS, billTable, requestId); } - if(!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)){ + if((!SUCCESS.equals(mqSuccess) || SKIP.equals(skip)) && StringUtils.isNotBlank(config)){ sendToMQ(config, param); updateWorkFlow(MQ_SUCCESS, billTable, requestId); } } + /** + *

校验对象中字段值是否为空

+ * @author xuanran.wang + * @dateTime 2023/6/21 16:17 + * @param object 对象 + **/ + public void checkDtoFieldValueNotNull(Object object){ + try { + Field[] fields = object.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + Object o = field.get(object); + if(Objects.isNull(o)){ + throw new CustomerException("该对象中 " + field.getName() + " 字段值为空!"); + } + } + }catch (Exception e) { + throw new CustomerException("校验对象失败 : [ " + e.getMessage() + " ]", e); + } + } + + /** + *

对发送对数据参数进行封装

+ * @author xuanran.wang + * @dateTime 2023/6/21 15:56 + * @param onlyMark 建模配置唯一标识 + * @param billTable 流程表名 + * @param requestId 请求id + * @return 封装的数据 + **/ + public CusRequestParam getRequestParam(String onlyMark, String billTable, String requestId){ + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 + if(Objects.isNull(requestMappingConfig)){ + throw new CustomerException("唯一标识为 : " + onlyMark + " ,在参数配置表中没有找到对应的配置!"); + } + String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable); +// log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId)); + RecordSet recordSet = new RecordSet(); + if (recordSet.executeQuery(selectMainSql, requestId) && recordSet.next()) { + String url = requestMappingConfig.getRequestUrl(); + dealWithMapping.setMainTable(billTable); + Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); + return CusRequestParam.builder().url(url).rs(recordSet).requestId(requestId).param(param).build(); + }else { + log.error("该流程暂未查到数据! requestId : " + requestId); + return null; + } + } + /** *

解析响应对象

* @author xuanran.wang diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java index b6c8e8c..87e1262 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java @@ -3,13 +3,16 @@ package weaver.xuanran.wang.sh_bigdata.common.util; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; +import com.icbc.api.internal.apache.http.impl.cookie.S; import lombok.Data; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import org.springframework.beans.BeanUtils; import weaver.workflow.request.todo.RequestStatusObj; import weaver.xuanran.wang.common.mapper.CommonMapper; import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusDoneTask; +import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoLeaderTask; import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask; import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper; @@ -63,8 +66,8 @@ public class SendTodoTaskUtil { * @param objs 任务对象 * @return 三方系统任务接收对象 **/ - public List getTodoTaskInfo(List objs){ - ArrayList res = new ArrayList<>(); + public List getTodoTaskInfo(List objs){ + ArrayList res = new ArrayList<>(); for (RequestStatusObj obj : objs) { String taskId = getTaskId(0, obj); CusTodoTask todoTask = new CusTodoTask(); @@ -92,11 +95,44 @@ public class SendTodoTaskUtil { todoTask.setMobileLinkUrl(appendParam(mobileUrl, userId, requestId).append("&mobile=1").toString()); todoTask.setSender(getConvertHrm(0, obj, String.valueOf(obj.getCreator().getUID()))); todoTask.setReceiver(getConvertHrm(1, obj, String.valueOf(userId))); + // 是否领导待办逻辑处理 + int nodeId = obj.getNodeid(); + String nodeNme = obj.getNodename(); + if(strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeId"), String.valueOf(nodeId)) + || strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeName"), nodeNme)){ + CusTodoLeaderTask leaderTask = new CusTodoLeaderTask(); + // 进行数据拷贝 + BeanUtils.copyProperties(todoTask, leaderTask); + leaderTask.setLeader(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderValue"),"1")); + res.add(leaderTask); + continue; + } res.add(todoTask); } return res; } + /** + *

判断字符串中是否含有指定字符

+ * @author xuanran.wang + * @dateTime 2023/6/25 13:24 + * @param str 字符串 + * @param key 标识 + * @return true/false + **/ + public static boolean strContainsKey(String str, String key){ + return StringUtils.isNotBlank(str) && Arrays.asList(str.split(",")).contains(key); + } + + /** + *

参数拼接

+ * @author xuanran.wang + * @dateTime 2023/6/25 13:22 + * @param sb stringBuilder + * @param userId 用户id + * @param requestId 请求id + * @return 进行字符串拼接 + **/ public static StringBuilder appendParam(StringBuilder sb, int userId, int requestId){ sb.append("?user=") .append(userId) diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java index 88d217c..cc506fc 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java @@ -20,7 +20,7 @@ import java.util.stream.Collectors; public class ShBigDataUtil { private static final String CONFIG_NAME = "ShBigdataConf"; - + // 白名单 private static final List WHILTE_LIST = new ArrayList<>(); static { @@ -40,6 +40,10 @@ public class ShBigDataUtil { WHILTE_LIST.add("pcAgentId"); // pc回调地址 WHILTE_LIST.add("todoPcSSOCallBackUrl"); + // 统一待办推送领导节点id + WHILTE_LIST.add("taskAsyncLeaderNodeId"); + // 统一待办推送领导节点名称 + WHILTE_LIST.add("taskAsyncLeaderNodeName"); } /** diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java new file mode 100644 index 0000000..bb2c8db --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java @@ -0,0 +1,17 @@ +package weaver.xuanran.wang.sh_bigdata.task_async.entity; + +import lombok.*; + +/** + *

领导待办计划任务

+ * + * @author xuanran.wang + * @date 2023/6/25 10:50 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CusTodoLeaderTask extends CusTodoTask{ + private String leader; +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java index 0fc232c..9727bb5 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java @@ -61,7 +61,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { .dataKey("") .build(); - List taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList); + List taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList); log.info("---------------- todoTaskInfo ---------------- \n" + JSONObject.toJSONString(taskInfo)); Map response = null; int success = 0; @@ -74,8 +74,8 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { success = 1; } ArrayList details = new ArrayList<>(); - for (CusTodoTask cusTodoTask : taskInfo) { - + for (Object obj : taskInfo) { + CusTodoTask cusTodoTask = (CusTodoTask) obj; CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail(); detail.setTaskNum(cusTodoTask.getTaskNum()); detail.setRequestUrl(addTodoTaskUrl); diff --git a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties index 7c96873..127bf0b 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties @@ -59,3 +59,12 @@ ssoOaCompareField= # sso校验时 接口取值字段 ssoInterfaceCompareField= + +# =============== 统一待办推送 =============== +# 统一待办推送领导节点id +taskAsyncLeaderNodeId=1,2 +# 统一待办推送领导节点名称 +taskAsyncLeaderNodeName=节点名1,21212 +# leader字段默认值 +taskAsyncLeaderValue=1 + diff --git a/src/test/java/xuanran/wang/big_data/BigDataTest.java b/src/test/java/xuanran/wang/big_data/BigDataTest.java index f828e71..e164414 100644 --- a/src/test/java/xuanran/wang/big_data/BigDataTest.java +++ b/src/test/java/xuanran/wang/big_data/BigDataTest.java @@ -12,8 +12,11 @@ import org.apache.commons.lang3.StringUtils; import org.junit.Test; import weaver.email.EmailWorkRunnable; import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.workflow.request.todo.RequestStatusObj; import weaver.xuanran.wang.common.util.CusInfoToOAUtil; import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; +import weaver.xuanran.wang.sh_bigdata.common.util.SendTodoTaskUtil; import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; @@ -22,6 +25,7 @@ import weaver.xuanran.wang.sh_bigdata.org_hrm_async.mapper.OrgHrmAsyncMapper; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncApiService; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncApiServiceImpl; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncServiceImpl; +import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask; import java.io.IOException; import java.util.*; @@ -396,4 +400,44 @@ public class BigDataTest extends BaseTest { int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey); log.info("id => " + id); } + + @Test + public void testH(){ + SendTodoTaskUtil taskUtil = new SendTodoTaskUtil(); + List requestStatusObjs = new ArrayList<>(); + RequestStatusObj obj = new RequestStatusObj(); + obj.setNodeid(121212); + obj.setRequestid(1234455); + obj.setUser(new User(1)); + obj.setNodename("节点名1"); + obj.setCreator(new User(1)); + requestStatusObjs.add(obj); + + RequestStatusObj obj2 = new RequestStatusObj(); + obj2.setNodeid(121); + obj2.setRequestid(232432143); + obj2.setUser(new User(1)); + obj2.setNodename("test2"); + obj2.setCreator(new User(1)); + requestStatusObjs.add(obj2); + + List todoTaskInfo = taskUtil.getTodoTaskInfo(requestStatusObjs); + System.out.println("todoTaskInfo : " + JSONObject.toJSONString(todoTaskInfo)); + for (Object todo : todoTaskInfo) { + CusTodoTask cusTodoTask = (CusTodoTask) todo; + System.out.println("cusTodoTask : " + JSONObject.toJSONString(cusTodoTask)); + } + } + @Test + public void testI(){ + String value = ""; + String valueContext = "123"; + Map mainMap = new HashMap<>(); + mainMap.put("requestid","123456"); + String workFlowVal = ""; + value = weaver.general.Util.null2String(valueContext) + .replace("{?requestid}", String.valueOf(mainMap.get("requestid"))) + .replace("{?}", workFlowVal); + System.out.println(value); + } } From 4c2dbb9efd2d994e36f44353910a179683b01b0c Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Mon, 26 Jun 2023 10:26:39 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=9D=E6=97=B6=E6=8D=B7=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C=EF=BC=8Cihg?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E5=85=83=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/common/dev.js | 36 +++++ .../youhong.ai/pcn/workflow_code_block.js | 124 +++++++++++++++++- .../java/aiyh/utils/GenerateFileUtil.java | 8 +- src/main/java/aiyh/utils/ScriptUtil.java | 4 +- .../userinfoel/mapper/UserInfoMapper.java | 14 +- .../userinfoel/service/UserInfoService.java | 29 +++- .../impl/CheckWorkflowRequestParamsImpl.java | 2 +- .../util/CheckWorkflowRequestParamsUtil.java | 1 + .../GenerateLoginIdAction.java | 3 - .../PushWorkflowDataToDWFAction.java | 81 ++++++++++++ .../mapper/DynamicCodeMapper.java | 7 +- .../service/DynamicCodeService.java | 25 +++- .../java/youhong/ai/utiltest/GenericTest.java | 4 +- .../java/youhong/ai/utiltest/TestApi.java | 2 +- 14 files changed, 311 insertions(+), 29 deletions(-) create mode 100644 src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java diff --git a/javascript/common/dev.js b/javascript/common/dev.js index 67a3756..666912e 100644 --- a/javascript/common/dev.js +++ b/javascript/common/dev.js @@ -9,6 +9,42 @@ const WfForm = { isMobile: () => { // true表示是eMobile、微信、钉钉等移动终端,false代表PC端 }, + /** + * 4.6 函数式自定义渲染表单字段 + * 最低版本要求:KB900190701 + * + * 以函数返回值方式自定义渲染表单字段,支持全部的字段类型,可实现基于原组件追加/复写/重新布局等等 + * + * 建议结合ecode工具,放到模块加载前调用,使用JSX,可实现与表单字段渲染有关的二次开发 + * + * 此接口的优先级高于4.4、4.5,即使用此接口代理的字段,如再使用4.4、4.5会直接无效 + * + * proxyFieldContentComp: function(fieldid,fn) + * @param convertFieldNameToId + * @param customerRender + */ + proxyFieldContentComp(convertFieldNameToId, customerRender = (info, compFn) => { + // console.log("字段id:",info.fieldid); + // console.log("明细行号:",info.rowIndex); + // console.log("字段只读必填属性:",info.viewAttr); + // console.log("字段值:",info.fieldValue); + // //返回自定义渲染的组件 + // return React.createElement("div", {}, ["想怎么玩就怎么玩"]); + // //返回原组件 + // return compFn(); + // //返回基于原组件的复写组件 + // return React.createElement("div", {}, ["前置组件",compFn(),"后置组件"]); + } + ) { + }, + /** + * //如果此接口调用在代码块、custompage等(非模块加载前调用),需强制渲染字段一次 + * WfForm.forceRenderField("field111"); + * @param field + */ + forceRenderField(field) { + + } } WfForm.OPER_SAVE = '保存' WfForm.OPER_SUBMIT = '提交/批准/提交需反馈/不需反馈等' diff --git a/javascript/youhong.ai/pcn/workflow_code_block.js b/javascript/youhong.ai/pcn/workflow_code_block.js index 5dca6db..feae264 100644 --- a/javascript/youhong.ai/pcn/workflow_code_block.js +++ b/javascript/youhong.ai/pcn/workflow_code_block.js @@ -787,4 +787,126 @@ $(() => { } } }) -/* ******************* 年假计算 end ******************* */ \ No newline at end of file +/* ******************* 年假计算 end ******************* */ + + +/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 start ******************* */ +$(() => { + const config = { + // 明细表 + detail: 'detail_3', + // 明细字段 + detailField: 'jbxxnr', + // 主表字段 + mainField: 'jbxxnr' + } + + function runJs() { + let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail); + let rowIndexArr = rowIndexStr.split(","); + let value = "" + rowIndexArr.forEach(item => { + let fieldId = WfForm.convertFieldNameToId(config.detailField, config.detail) + "_" + item + let fieldValue = WfForm.getFieldValue(fieldId); + value += (+item + 1) + "、" + fieldValue + "\n"; + }) + WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.mainField), {value}) + } + + WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => { + runJs() + callback() + }) + +}) +/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 end ******************* */ + + +/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 start ******************* */ +$(() => { + const config = { + // 明细表 + detail: 'detail_1', + // 映射关系 + mapping: [{ + // 明细表字段 + detailField: 'jbsj', + // 主表字段 + mainField: 'zzjsrq', + }, { + // 明细表字段 + detailField: 'jbtd', + // 主表字段 + mainField: 'jbqd', + }], + dateSort: 'jbsj' + } + + + function runJs() { + let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail); + let rowIndexArray = rowIndexStr.split(","); + const detailData = [] + rowIndexArray.forEach(item => { + let obj = {} + config.mapping.forEach(mapping => { + obj[mapping.detailField] = WfForm.getFieldValue(WfForm.convertFieldNameToId(mapping.detailField, config.detail) + "_" + item) + }) + detailData.push(obj) + }) + console.log(detailData) + let minDateObj = filterByMinDate(detailData, config.dateSort); + console.log(minDateObj) + config.mapping.forEach(item => { + WfForm.changeFieldValue(WfForm.convertFieldNameToId(item.mainField), { + value: minDateObj[item.detailField] + }) + }) + } + + function filterByMinDate(arr, key) { + return arr.reduce((min, obj) => { + if (!min || new Date(obj[key]) <= new Date(min[key])) { + return obj; + } + return min; + }, null); + } + + WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => { + runJs() + callback() + }) +}) +/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 end ******************* */ + +/* ******************* youhong.ai 主表选择框自定义渲染为进度条 start ******************* */ +$(() => { + const field = 'jz' + const config = { + '-1': 0, + '0': 20, + '1': 40, + '2': 60, + '3': 80, + '4': 100, + } + + function customerRender(info, compFn) { + let fieldValue = info.fieldValue; + if (!fieldValue) { + fieldValue = '-1' + } + let {WeaProgress} = ecCom + return React.createElement(WeaProgress, { + strokeColor: '#6c8dc1', + percent: config[fieldValue] + }) + } + + WfForm.proxyFieldContentComp(WfForm.convertFieldNameToId(field).replace("field", ""), customerRender) + setTimeout(() => { + WfForm.forceRenderField(WfForm.convertFieldNameToId(field)); + }, 500) +}) +/* ******************* youhong.ai 主表选择框自定义渲染为进度条 end ******************* */ diff --git a/src/main/java/aiyh/utils/GenerateFileUtil.java b/src/main/java/aiyh/utils/GenerateFileUtil.java index 7b8631b..e443f6e 100644 --- a/src/main/java/aiyh/utils/GenerateFileUtil.java +++ b/src/main/java/aiyh/utils/GenerateFileUtil.java @@ -85,10 +85,11 @@ public class GenerateFileUtil { if (hasRequired) { // 必填参数 RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class); - String fieldDesc = requiredMark.value(); - Map param = new HashMap<>(); + String fieldDesc = requiredMark.desc(); + Map param = new HashMap<>(8); param.put("name", name); param.put("desc", fieldDesc); + param.put("example", requiredMark.value()); param.put("isRequired", "是"); boolean hasDefaultTestValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class); if (hasDefaultTestValue) { @@ -105,9 +106,10 @@ public class GenerateFileUtil { ActionOptionalParam actionOptionalParam = declaredField.getAnnotation(ActionOptionalParam.class); String fieldDesc = actionOptionalParam.desc(); String defaultValue = actionOptionalParam.value(); - Map param = new HashMap<>(); + Map param = new HashMap<>(8); param.put("name", name); param.put("desc", fieldDesc); + param.put("example", defaultValue); param.put("isRequired", "否"); param.put("defaultValue", defaultValue); paramList.add(param); diff --git a/src/main/java/aiyh/utils/ScriptUtil.java b/src/main/java/aiyh/utils/ScriptUtil.java index 7f6cbd1..6c53d1d 100644 --- a/src/main/java/aiyh/utils/ScriptUtil.java +++ b/src/main/java/aiyh/utils/ScriptUtil.java @@ -12,14 +12,14 @@ import java.util.Map; * @author youHong.ai */ public class ScriptUtil { - private static final JexlEngine jexl = new JexlBuilder().create(); + private static final JexlEngine JEXL = new JexlBuilder().create(); public static Object invokeScript(String script, Map params) { JexlContext jc = new MapContext(); for (Map.Entry entry : params.entrySet()) { jc.set(entry.getKey(), entry.getValue()); } - JexlExpression expression = jexl.createExpression(script); + JexlExpression expression = JEXL.createExpression(script); return expression.evaluate(jc); } } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java index 6767fc8..f149ea3 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java @@ -44,7 +44,7 @@ public interface UserInfoMapper { "or concat(',',fbleader,',') like concat(',',#{uID},',')\n" + "or concat(',',hrleader,',') like concat(',',#{uID},',')\n" + "or concat(',',generalmanager,',') like concat(',', #{uID},',')")*/ - @Select("select count(id) from uf_hotelinfo where\n" + + @Select("select * from uf_hotelinfo where\n" + "concat(',',olt,',') like concat(',',#{userId},',')\n" + "or concat(',',vpo,',') like concat(',',#{userId},',')\n" + "or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" + @@ -61,7 +61,7 @@ public interface UserInfoMapper { "or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" + "or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" + "or concat(',',headofengineering,',') like concat(',',#{userId},',')") - Integer selectIsHotel(int uid); + List> selectIsHotel(int uid); /** *

查询酒店信息

@@ -85,12 +85,11 @@ public interface UserInfoMapper { /** *

查询角色信息

* - * @param uid 当前人员 - * @param hotelIndex 酒店编码 + * @param uid 当前人员 * @return 角色信息 */ @Select("select * from uf_hotelinfo where\n" + - "(concat(',',olt,',') like concat(',',#{userId},',')\n" + + "concat(',',olt,',') like concat(',',#{userId},',')\n" + "or concat(',',vpo,',') like concat(',',#{userId},',')\n" + "or concat(',',subregionadmin,',') like concat(',',#{userId},',')\n" + "or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" + @@ -112,9 +111,8 @@ public interface UserInfoMapper { "or concat(',',revenueleader,',') like concat(',',#{userId},',')\n" + "or concat(',',financeleader,',') like concat(',',#{userId},',')\n" + "or concat(',',fbleader,',') like concat(',',#{userId},',')\n" + - "or concat(',',hrleader,',') like concat(',',#{userId},',')) " + - "and holidex = #{hotelIndex}") - List> selectRoles(@ParamMapper("userId") int uid, @ParamMapper("hotelIndex") String hotelIndex); + "or concat(',',hrleader,',') like concat(',',#{userId},',')") + List> selectRoles(@ParamMapper("userId") int uid); /** *

查询部门信息

diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java index 6f360fd..2aa4961 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java @@ -43,7 +43,6 @@ public class UserInfoService { userInfoVo.setTaskAcceptance(true); } } - // 查询用户信息 Map userInfo = this.mapper.selectHrmInfo(user.getUID()); if (CollectionUtil.isNotEmpty(userInfo)) { @@ -70,8 +69,32 @@ public class UserInfoService { // 支持中心,显示部门信息 userInfoVo.setDepartmentInfo(department); } + List> hotelList = mapper.selectRoles(user.getUID()); // 如果存在酒店信息 - if (StrUtil.isNotBlank(hotelIndex)) { + Set roleNames = new HashSet<>(); + if (CollectionUtil.isNotEmpty(hotelList)) { + for (Map hotel : hotelList) { + // 循环酒店角色名称 + for (Map.Entry entry : ROLES_MAP.entrySet()) { + String key = entry.getKey(); + if (!hotel.containsKey(key)) { + continue; + } + String value = Util.null2String(hotel.get(key)); + // 如果在酒店名称中找到对应的人,则为角色名 + if (StrUtil.isBlank(value)) { + continue; + } + String[] split = value.split(","); + List strings = Arrays.asList(split); + if (strings.contains(Util.null2String(user.getUID()))) { + roleNames.add(entry.getValue()); + } + } + } + } + userInfoVo.setRoleNames(roleNames); + /*if (StrUtil.isNotBlank(hotelIndex)) { List> hotelRoles = this.mapper.selectRoles(user.getUID(), hotelIndex); if (CollectionUtil.isEmpty(hotelRoles)) { return userInfoVo; @@ -98,7 +121,7 @@ public class UserInfoService { } } userInfoVo.setRoleNames(roleNames); - } + }*/ } return userInfoVo; } diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java index d1012aa..6e8f413 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java @@ -36,7 +36,7 @@ public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy impleme private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil(); @Override - @ServiceMethodDynamicProxy(desc = "子流程触发时,做流程转数据") + @ServiceMethodDynamicProxy(desc = "流程创建校验流程参数") public PAResponseEntity doCreateRequest(User user, ReqOperateRequestEntity requestParam) { try { try { diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java index 8165b72..a710693 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java @@ -133,6 +133,7 @@ public class CheckWorkflowRequestParamsUtil { if (Objects.isNull(checkCreateConfigDetail)) { continue; } + // TODO 主表明细表字段一致可能出现问题 checkDetailMap.remove(fieldName); CheckFunctionParam checkFunctionParam = new CheckFunctionParam(); checkFunctionParam.setCheckCreateConfigDetail(checkCreateConfigDetail); diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java b/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java index 8a0b35f..53f5298 100644 --- a/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java @@ -58,9 +58,6 @@ public class GenerateLoginIdAction extends SafeCusBaseAction { Map mainTableValue = super.getMainTableValue(requestInfo); String subCompanyName = mainTableValue.get(subCompanyTextField); String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName); - // Map lastLoginIdInfo = mapper.selectLastLoginId(subCompanyName, subCompanyId, subCompanyName + "%"); - // String loginIdNo = lastLoginIdInfo.get("loginIdNo"); - // String loginId = prefixFill(loginIdNo, subCompanyName); List loginIdList = mapper.selectLoginIdList(subCompanyId); String loginId = subCompanyName + formatList(loginIdList, Integer.parseInt(numberFillQuantity)); if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) { diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java b/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java new file mode 100644 index 0000000..af4845f --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java @@ -0,0 +1,81 @@ +package weaver.youhong.ai.pcn.actioin.todwfworkflow; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import lombok.Getter; +import lombok.Setter; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; + +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.util.Map; + +/** + *

推送流程数据到dwf

+ * + *

create: 2023/6/25 21:56

+ * + * @author youHong.ai + */ +@Setter +@Getter +@ActionDesc(author = "youhong.ai", value = "推送流程数据到dwf") +public class PushWorkflowDataToDWFAction extends SafeCusBaseAction { + + @RequiredMark(desc = "请求参数配置表的唯一标识") + private String onlyMark; + + + @ActionOptionalParam(desc = "流程失败是否退回", value = "true") + private String isBlack = "true"; + + + @ActionOptionalParam(desc = "成功标识", value = "200") + private String successCode = "200"; + + + private final HttpUtils httpUtils = new HttpUtils(); + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + + { + httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); + } + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + dealWithMapping.setMainTable(billTable); + try { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); + String requestUrl = requestMappingConfig.getRequestUrl(); + Map objMainTableValue = getObjMainTableValue(requestInfo); + Map requestParam = dealWithMapping.getRequestParam(objMainTableValue, requestMappingConfig); + ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam); + if (responeVo.getCode() != 200) { + log.error(Util.logStr("接口请求出错:[]", responeVo.getEntityString())); + } + Map responseMap = responeVo.getResponseMap(); + String code = Util.null2String(responseMap.get("code")); + if (!successCode.equals(code)) { + black(requestInfo, Util.null2String(responseMap.get("msg"))); + } + } catch (IOException e) { + black(requestInfo, "system error!"); + } + } + + private void black(RequestInfo requestInfo, String msg) { + if (Boolean.parseBoolean(isBlack)) { + Util.actionFailException(requestInfo.getRequestManager(), msg); + } + } +} diff --git a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java index e4291f8..5f8716e 100644 --- a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java +++ b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java @@ -4,6 +4,8 @@ import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; +import java.util.Map; + /** * create 2022/1/17 0017 16:57 * @@ -14,7 +16,7 @@ import aiyh.utils.annotation.recordset.SqlMapper; public interface DynamicCodeMapper { @Select("select email from hrmresource where loginid = #{loginId}") - public String selectEmail(@ParamMapper("loginId") String loginId); + String selectEmail(@ParamMapper("loginId") String loginId); /** *

查询用户

@@ -26,4 +28,7 @@ public interface DynamicCodeMapper { @Select("select id from hrmresource where loginid = #{loginId} and password = #{password}") Integer selectUser(@ParamMapper("loginId") String user, @ParamMapper("password") String mdPassword); + + @Select("select id,lastname,loginid,isadaccount from hrmresource where loginid = #{loginId}") + Map selectUserInfo(@ParamMapper("loginId") String user); } diff --git a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java index 9058784..293ea99 100644 --- a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java +++ b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java @@ -2,6 +2,7 @@ package com.api.aiyh_logincheck.service; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import aiyh.utils.zwl.common.ToolUtil; import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson.JSON; @@ -15,6 +16,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import weaver.email.EmailWorkRunnable; import weaver.general.BaseBean; +import weaver.ldap.LdapUtil; import weaver.sm.SM4Utils; import javax.servlet.ServletContext; @@ -122,10 +124,25 @@ public class DynamicCodeService { password = sm4.decrypt(password, key); } } - String mdPassword = EncryptHelper.encodeMd5(password).toUpperCase(); - Integer userId = dynamicCodeMapper.selectUser(user, mdPassword); - if (Objects.isNull(userId) || userId < 0) { - throw new CustomerException("账号或密码错误!", 403); + // 校验AD登录 + Map userInfoMap = dynamicCodeMapper.selectUserInfo(user); + if (CollectionUtil.isNotEmpty(userInfoMap) && "1".equals(Util.null2String(userInfoMap.get("isadaccount")))) { + LdapUtil util = LdapUtil.getInstance(); + String authenticResult = util.authenticuser(user); + if (authenticResult == null || "uac".equals(authenticResult)) { + throw new CustomerException("AD账号不存在或被禁用!", 403); + } + boolean flag; + flag = util.authentic(user, password); + if (!flag) { + throw new CustomerException("账号或密码错误!", 403); + } + } else { + String mdPassword = EncryptHelper.encodeMd5(password).toUpperCase(); + Integer userId = dynamicCodeMapper.selectUser(user, mdPassword); + if (Objects.isNull(userId) || userId < 0) { + throw new CustomerException("账号或密码错误!", 403); + } } String uncheckList = toolUtil.getSystemParamValue("uncheckList"); String isEnable = toolUtil.getSystemParamValue("enableDynamicCode"); diff --git a/src/test/java/youhong/ai/utiltest/GenericTest.java b/src/test/java/youhong/ai/utiltest/GenericTest.java index b567c20..285f650 100644 --- a/src/test/java/youhong/ai/utiltest/GenericTest.java +++ b/src/test/java/youhong/ai/utiltest/GenericTest.java @@ -12,7 +12,7 @@ import org.apache.poi.xssf.streaming.SXSSFRow; 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 weaver.youhong.ai.pcn.actioin.todwfworkflow.PushWorkflowDataToDWFAction; import youhong.ai.utiltest.excel.ExcelCell; import youhong.ai.utiltest.excel.ExcelPort; import youhong.ai.utiltest.excel.ExcelRow; @@ -98,7 +98,7 @@ public class GenericTest extends BaseTest { @Test public void testGre() { - GenerateFileUtil.createActionDocument(DocToAvatarAction.class); + GenerateFileUtil.createActionDocument(PushWorkflowDataToDWFAction.class); } diff --git a/src/test/java/youhong/ai/utiltest/TestApi.java b/src/test/java/youhong/ai/utiltest/TestApi.java index 8c33456..5781bcc 100644 --- a/src/test/java/youhong/ai/utiltest/TestApi.java +++ b/src/test/java/youhong/ai/utiltest/TestApi.java @@ -63,7 +63,7 @@ public class TestApi extends BaseTest { "\t\"fieldValue\":\"5\"\n" + "},{\n" + "\t\"fieldName\":\"mc\",\n" + - "\t\"fieldValue\":\"不1道\"\n" + + "\t\"fieldValue\":\"不道\"\n" + "}]"); body.put("requestName", "api流程测试调用接口校验参数"); body.put("workflowId", "44");