diff --git a/ecology-weaver.iml b/ecology-weaver.iml index 66ad733..672f9b7 100644 --- a/ecology-weaver.iml +++ b/ecology-weaver.iml @@ -31,6 +31,18 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/html/aiyh_pcn/copyMultipeFile/index.js b/html/aiyh_pcn/copyMultipeFile/index.js index 31cb8c4..9ae8acb 100644 --- a/html/aiyh_pcn/copyMultipeFile/index.js +++ b/html/aiyh_pcn/copyMultipeFile/index.js @@ -7,7 +7,7 @@ class Utils { data, isAsync = true, success = () => { }, error = (err) => { - console.log(err) + console.log(err) }, complete = () => { }, contentType = 'application/json', @@ -74,73 +74,93 @@ class CopyMultipleFile { * @param listenerField 浏览框字段 */ bindBrowseBoxChangeEvent() { - WfForm.bindFieldChangeEvent(this.convertField2Id(this.configuration.browseBox), async (elem, id, value) => { - //为空,清除其他模板字段数据,TODO 删除文件 - if ((value ?? '') === '') { - let deleteArr = [] - this.configuration.detailList.forEach(item => { - let fieldId = this.convertField2Id(item.workflowFile) - deleteArr = [...wfform.getFieldValue(fieldId).split(","), ...deleteArr] - WfForm.changeFieldValue(fieldId, { - value: '', + WfForm.bindFieldChangeEvent(this.convertField2Id(this.configuration.browseBox),async (elem, id, value) => { + await this.copyFile(value) + }) + } + + /** + * 复制文件逻辑 + * @param value 浏览框的值 + * @returns {Promise} + */ + async copyFile(value){ + //为空,清除其他模板字段数据,TODO 删除文件 + if ((value ?? '') === '') { + let deleteArr = [] + this.configuration.detailList.forEach(item => { + let fieldId = this.convertField2Id(item.workflowFile) + deleteArr = [...wfform.getFieldValue(fieldId).split(","), ...deleteArr] + WfForm.changeFieldValue(fieldId, { + value: '', + specialobj: { + filedatas: [] + } + }) + }) + Utils.request(`/api/browseBox/copyMultipleFile/delete/${deleteArr.join(",")}`).then((res) => { + // console.log(res) + }) + return + } + //判断是否和原来的数据不同,不同则进行文件复制带出 + if (value !== this.oldBrowseBoxValue) { + let copyFileParam = { + workflowType: this.baseInfo.workflowid, + requestId: this.baseInfo.requestid, + browseValue: value, + modeTable: this.configuration.modeTable, + fileMapperList: this.configuration.detailList, + queryFileInfoMap: { + listType: "list", + requestid: this.baseInfo.requestid, + desrequestid: -1, + isprint: 0, + f_weaver_belongto_userid: this.baseInfo.f_weaver_belongto_userid, + f_weaver_belongto_usertype: this.baseInfo.f_weaver_belongto_usertype, + authStr: '', + authSignatureStr: '' + }, + } + ecCom.WeaLoadingGlobal.start({ + tip: "文件模板复制中" + }) + let result = await Utils.request("/api/browseBox/copyMultipleFile/copy", "POST", copyFileParam) + ecCom.WeaLoadingGlobal.destroy() + // console.log(result) + if (result && result.code == 200) { + let copyResult = result.data + copyResult.forEach(item => { + // 设置模板字段值 + WfForm.changeFieldValue(this.convertField2Id(item.workflowFile), { + value: item.fileId, specialobj: { - filedatas: [] + filedatas: item.fileInfo ? item.fileInfo.filedatas : [] } }) }) - Utils.request(`/api/browseBox/multipleCopy/delete/${deleteArr.join(",")}`).then((res)=>{ - // console.log(res) - }) - return + } else { + antd.message.error("复制模板文件失败!") } - //判断是否和原来的数据不同,不同则进行文件复制带出 - if (value !== this.oldBrowseBoxValue) { - let copyFileParam = { - workflowType: this.baseInfo.workflowid, - requestId: this.baseInfo.requestid, - browseValue: value, - modeTable: this.configuration.modeTable, - fileMapperList: this.configuration.detailList, - queryFileInfoMap: { - listType: "list", - requestid: this.baseInfo.requestid, - desrequestid: -1, - isprint: 0, - f_weaver_belongto_userid: this.baseInfo.f_weaver_belongto_userid, - f_weaver_belongto_usertype: this.baseInfo.f_weaver_belongto_usertype, - authStr: '', - authSignatureStr: '' - }, - } - ecCom.WeaLoadingGlobal.start({ - tip:"文件模板复制中" - }) - let result = await Utils.request("/api/browseBox/multipleCopy/copy", "POST", copyFileParam) - ecCom.WeaLoadingGlobal.destroy() - // console.log(result) - if (result && result.code == 200) { - let copyResult = result.data - copyResult.forEach(item => { - // 设置模板字段值 - WfForm.changeFieldValue(this.convertField2Id(item.workflowFile), { - value: item.fileId, - specialobj: { - filedatas: item.fileInfo ? item.fileInfo.filedatas : [] - } - }) - }) - } else { - antd.message.error("复制模板文件失败!") - } - } - }) + } } + + /** + * 强制触发一次复制 + */ + mandatoryCopy() { + let browseBoxValue = WfForm.getFieldValue(this.convertField2Id(this.configuration.browseBox)) + this.copyFile(browseBoxValue) + } + } class CopyMultipleFileBuilder { configuration = [] + copyMultipleFileArr = [] + constructor() { this.workflowId = WfForm.getBaseInfo().workflowid @@ -149,12 +169,13 @@ class CopyMultipleFileBuilder { async init() { // 获取配置信息 - let result = await Utils.request(`/api/browseBox/multipleCopy/getConfig/${this.workflowId}`, "GET"); + let result = await Utils.request(`/api/browseBox/copyMultipleFile/getConfig/${this.workflowId}`, "GET"); if (result && result.code == 200) { this.configuration = result.data this.configuration.forEach(item => { let copyMultipleFile = new CopyMultipleFile(item); copyMultipleFile.bindBrowseBoxChangeEvent() + this.copyMultipleFileArr.push(copyMultipleFile) }) } else { antd.message.error("请求模板复制信息失败!") @@ -164,5 +185,11 @@ class CopyMultipleFileBuilder { } $(() => { - new CopyMultipleFileBuilder() + let copyMultipleFileBuilder = new CopyMultipleFileBuilder() + //绑定强制触发 + window.mandatoryCopy = function () { + copyMultipleFileBuilder.copyMultipleFileArr.forEach(item => { + item.mandatoryCopy() + }) + } }) \ No newline at end of file diff --git a/html/aiyh_pcn/流程代码块/index.js b/html/aiyh_pcn/流程代码块/index.js index 2066a8c..4eca779 100644 --- a/html/aiyh_pcn/流程代码块/index.js +++ b/html/aiyh_pcn/流程代码块/index.js @@ -30,15 +30,19 @@ function statisticalDetailTableData() { let groupFieldId = groupFieldMark + "_" + rowIndex // 获取值 let groupFieldValue = WfForm.getFieldValue(groupFieldId) + let groupFieldValueObj = WfForm.getFieldValueObj(groupFieldId) let sumFieldMark = convertField2Id(config.sumField, config.detailTableSimple) let sumFieldId = sumFieldMark + "_" + rowIndex // 获取值 - let sumFieldValue = parseInt(WfForm.getFieldValue(sumFieldId)) + let sumFieldValue = parseInt(WfForm.getFieldValue(sumFieldId) === "" ? 0 : WfForm.getFieldValue(sumFieldId)) if (sumMap.has(groupFieldValue)) { - let sumValue = sumMap.get(groupFieldValue) + sumFieldValue - sumMap.set(groupFieldValue, sumValue) + sumMap.get(groupFieldValue).sum += sumFieldValue } else { - sumMap.set(groupFieldValue, sumFieldValue) + let obj = { + value: groupFieldValueObj, + sum: sumFieldValue + } + sumMap.set(groupFieldValue, obj) } } return sumMap @@ -64,17 +68,20 @@ function assignmentDetailTable2(sumMap) { // 赋值 sumMap.forEach((value, key) => { let valueObj = { - [convertField2Id(config.groupField, config.detailTableSimple)]: { - value: key - }, + [convertField2Id(config.groupField, config.detailTableSimple)]: value.value, [convertField2Id(config.sumField, config.detailTableSimple)]: { - value: value + value: value.sum }, } WfForm.addDetailRow(config.detailTableSimple, valueObj); }) } +$(() => { + //页面加载时执行一次 + let sumMap = statisticalDetailTableData() + assignmentDetailTable2(sumMap) +}) /** * 注册监听提交和保存事件 */ @@ -85,18 +92,115 @@ WfForm.registerCheckEvent(WfForm.OPER_SAVE + "," + WfForm.OPER_SUBMIT, function }); +//#endregion +// (╰_╯)#(╰_╯)# + +// ================================================================================ + +// +//#region + +/** + * 转换字段名为字段id + * @param fieldName 字段名 + * @param detail 表 + * @returns {*} 字段id + */ +function convertField2Id(fieldName, detail = "main") { + return WfForm.convertFieldNameToId(fieldName, detail) +} + +/** + * 绑定明细表发生变化时触发并执行计算逻辑 + */ +function bindDetailFieldChange() { + let config = { + changeField: 'fyygrmb', + detailTable: 'formtable_main_173_dt1', + detailTableSimple: 'detail_1' + } + WfForm.bindDetailFieldChangeEvent(convertField2Id(config.changeField, config.detailTableSimple), () => { + let sumMap = statisticalDetailTableData() + assignmentDetailTable2(sumMap) + }) +} + +/** + * 统计第一个明细表数据 + * @returns {Map} 整理后的明细数据 + */ +function statisticalDetailTableData() { + let config = { + groupField: "sqrbm", + sumField: 'fyygrmb', + detailTable: 'formtable_main_173_dt1', + detailTableSimple: 'detail_1' + } + let sumMap = new Map() + let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(","); + for (let i = 0; i < rowArr.length; i++) { + let rowIndex = rowArr[i]; + let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple) + let groupFieldId = groupFieldMark + "_" + rowIndex + // 获取值 + let groupFieldValue = WfForm.getFieldValue(groupFieldId) + let sumFieldMark = convertField2Id(config.sumField, config.detailTableSimple) + let sumFieldId = sumFieldMark + "_" + rowIndex + // 获取值 + let sumFieldValue = parseInt(WfForm.getFieldValue(sumFieldId) === "" ? 0 : WfForm.getFieldValue(sumFieldId)) + if (sumMap.has(groupFieldValue)) { + let sumValue = sumMap.get(groupFieldValue) + sumFieldValue + sumMap.set(groupFieldValue, sumValue) + } else { + sumMap.set(groupFieldValue, sumFieldValue) + } + } + return sumMap +} + +/** + * 第二个明细表赋值 + * @param sumMap 整理后的明细数据 + */ +function assignmentDetailTable2(sumMap) { + let config = { + groupField: "sqrbm", + sumField: 'fyygrmbxj', + detailTable: 'formtable_main_173_dt2', + detailTableSimple: 'detail_2' + } + + // 赋值 + let valueObj = {} + let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(","); + for (let i = 0; i < rowArr.length; i++) { + let rowIndex = rowArr[i]; + let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple) + let groupFieldId = groupFieldMark + "_" + rowIndex + // 获取值 + let groupFieldValue = WfForm.getFieldValue(groupFieldId) + sumMap.forEach((value, key) => { + if (groupFieldValue == key) { + valueObj[convertField2Id(config.sumField, config.detailTableSimple) + "_" + rowIndex] = {value: value} + } + }) + } + WfForm.changeMoreField(valueObj); +} + +$(() => { + //页面加载时执行一次 + bindDetailFieldChange() +}) + //#endregion // (╰_╯)#(╰_╯)# - // ================================================================================ - // -// - /** * 转换字段名为字段id * @param fieldName 字段名 @@ -129,7 +233,7 @@ function calculateDiscountDetail1(discountMap) { let discountFieldId = discountFieldMark + "_" + rowArr[i] let costCountFieldId = costCountFieldMark + "_" + rowArr[i] let groupFieldValue = WfForm.getFieldValue(groupFieldId) - let costCountFieldValue = parseInt(WfForm.getFieldValue(costCountFieldId)) + let costCountFieldValue = parseInt(WfForm.getFieldValue(costCountFieldId) === "" ? 0 : WfForm.getFieldValue(costCountFieldId)) // console.log(discountMap.get(groupFieldValue) * costCountFieldValue) //修改值 WfForm.changeFieldValue(discountFieldId, { @@ -158,7 +262,7 @@ function getDiscountByDetail2() { let groupFieldId = groupFieldMark + "_" + rowArr[i] let discountFieldId = discountFieldMark + "_" + rowArr[i] let groupFieldValue = WfForm.getFieldValue(groupFieldId) - discountMap[groupFieldValue] = parseFloat(WfForm.getFieldValue(discountFieldId)) / 100 + discountMap[groupFieldValue] = parseFloat(WfForm.getFieldValue(discountFieldId) === "" ? 0 : WfForm.getFieldValue(discountFieldId)) / 100 } return discountMap } @@ -178,7 +282,7 @@ function bindEvent() { }) } -$(()=>{ +$(() => { //页面加载时执行一次 let discountMap = getDiscountByDetail2(); calculateDiscountDetail1(discountMap) @@ -186,4 +290,173 @@ $(()=>{ }) // +// ================================================================================ + +// +//#region 捐赠/赞助合作伙伴合规评估 红绿灯变颜色 + + +/** + * 转换字段名为字段id + * @param fieldName 字段名 + * @param detail 表 + * @returns {*} 字段id + */ +function convertField2Id(fieldName, detail = "main", showPrefix = true) { + return WfForm.convertFieldNameToId(fieldName, detail, showPrefix) +} + +/** + * 改变颜色逻辑处理 + * @param colorMapper 颜色和值的映射关系 + * @returns {(function(*=, *=): void)|*} 值改变回调函数 + */ +function changeColor(colorMapper) { + return (info, compFn) => { + let value = info.fieldValue + if (value === "") { + return compFn() + } + let options = {style: {}} + colorMapper.forEach(item => { + if (item.value == value) { + options.style.background = item.color + } + }) + return React.createElement("div", options, [compFn()]); + } +} + + +/** + * 绑定自定义渲染事件 + * @param configObj 配置对象 + */ +function bindEvent(configObj) { + configObj.forEach(item => { + let colorMapper = item.colorMapper + for (let v in colorMapper) { + WfForm.proxyFieldContentComp(convertField2Id(v, item.simpleTableName, false), changeColor(colorMapper[v])); + WfForm.forceRenderField(convertField2Id(v, item.simpleTableName)); + } + }) +} + +$(() => { + let configObj = [{ + tableName: "formtable_main_106_dt1", + simpleTableName: "detail_1", + colorMapper: { + jg: [{ + value: 0, + color: 'rgb(213,0,28)' + }, { + value: 1, + color: 'rgb(255,255,0)' + }, { + value: 2, + color: 'rgb(146,208,80)' + }] + } + }, { + tableName: "formtable_main_106_dt2", + simpleTableName: "detail_2", + colorMapper: { + zzjg2: [{ + value: 0, + color: 'rgb(213,0,28)' + }, { + value: 1, + color: 'rgb(255,255,0)' + }, { + value: 2, + color: 'rgb(146,208,80)' + }] + } + }] + bindEvent(configObj) +}) + + +//#endregion +// + +// ================================================================================ + +// +//#region 发达大合同用印计算 + +/** + * 转换字段名为字段id + * @param fieldName 字段名 + * @param detail 表 + * @returns {*} 字段id + */ +function convertField2Id(fieldName, detail = "main") { + return WfForm.convertFieldNameToId(fieldName, detail) +} + +/** + * 修改用印类型的值 + * @param config 配置信息 + * @param value 需要修改的值 + */ +function changeContractSelectBox(config, value) { + WfForm.changeFieldValue(convertField2Id(config.changeField), {value: value}); +} + +/** + * 检查是否存在法大大认证编号 + * @param config 配置信息 + * @returns {boolean} 是否存在 + */ +function checkContractFadadaechapter(config) { + let rowArr = (WfForm.getDetailAllRowIndexStr(config.simpleTableName) ?? '').split(","); + for (let i = 0; i < rowArr.length; i++) { + let rowIndex = rowArr[i] + let fieldValue = WfForm.getFieldValue(convertField2Id(config.changeField,config.simpleTableName) + "_" + rowIndex); + if((fieldValue ?? "" ) === ""){ + return false + } + } + return true +} + +/** + * 绑定提交和保存事件拦截,触发修改电子用印字段 + * @param config + */ +function bindSubmitEvent(config){ + WfForm.registerCheckEvent(WfForm.OPER_SAVE+","+WfForm.OPER_SUBMIT, function(callback){ + let electronicSeals = checkContractFadadaechapter(config.detailConfig) + if(electronicSeals){ + // 电子用印 + changeContractSelectBox(config.mainConfig,0) + }else{ + // 物理用印 + changeContractSelectBox(config.mainConfig,1) + } + callback(); + }); +} + +$(() => { + let config = { + mainConfig: { + tableName: "formtable_main_56", + changeField: "yylx", + simpleTableName: "main" + }, + detailConfig: { + tableName: "formtable_main_56_dt1", + changeField: "fadadaechapter", + simpleTableName: "detail_1" + } + } + bindSubmitEvent(config) +}) + +//#endregion +// + diff --git a/java.io.tempdir/.ehcache-diskstore.lock b/java.io.tempdir/.ehcache-diskstore.lock new file mode 100644 index 0000000..e69de29 diff --git a/java.io.tempdir/workflowcache.data b/java.io.tempdir/workflowcache.data new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml index a52f01b..f60cb12 100644 --- a/pom.xml +++ b/pom.xml @@ -36,31 +36,53 @@ - + org.projectlombok lombok ${lombok.version} provided - + cn.hutool hutool-all ${hutool.version} - + com.drewnoakes metadata-extractor ${metadata-extractor.version} - + junit junit 4.12 + + + org.apache.poi + poi-excelant + 3.12 + + + org.apache.poi + poi-scratchpad + 3.12 + + + org.apache.poi + poi-ooxml + 3.8 + + + org.apache.poi + poi-ooxml-schemas + 3.8 + + @@ -73,13 +95,27 @@ 8 8 - - - - - - - + + + org.projectors + lombok + ${lombok.version} + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + + junit + junit + 4.12 + + @@ -106,4 +142,4 @@ - + diff --git a/sql/index.sql b/sql/index.sql new file mode 100644 index 0000000..0490d8f --- /dev/null +++ b/sql/index.sql @@ -0,0 +1,11 @@ +select kqdt.signindate,kqdt.signoutdate,kqdt.signintime ,kqdt.signouttime, + FLOOR( + datediff(minute,signindate + ' ' + signintime,signoutdate + ' ' + signouttime)/60.0 - 8.0 + ) overtime, + kqdt.changeType +from kq_format_detail kqdt +join kq_holidayset kqst on kqdt.signindate = kqst.holidayDate +where signindate is not null +and signoutdate is not null +and signindate <> '' and signoutdate <> '' +and FLOOR(datediff(minute,signindate + ' ' + signintime,signoutdate + ' ' + signouttime)/60.0 - 8.0) > 0 \ No newline at end of file diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 82c9213..297f5d7 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -3,6 +3,7 @@ package aiyh.utils; import aiyh.utils.annotation.DateFormatAn; import aiyh.utils.entity.*; import aiyh.utils.fileUtil.ProperUtil; +import aiyh.utils.logger.LoggerUtil; import aiyh.utils.mapUtil.UtilHashMap; import aiyh.utils.mapUtil.UtilLinkedHashMap; import aiyh.utils.recordset.RecordsetUtil; @@ -15,6 +16,7 @@ import aiyh.utils.zwl.common.ToolUtil; import cn.hutool.core.util.ObjectUtil; import com.ibm.icu.text.SimpleDateFormat; import org.apache.dubbo.common.utils.CollectionUtils; +import org.apache.log4j.Logger; import org.h2.util.StringUtils; import weaver.common.util.string.StringUtil; import weaver.conn.RecordSet; @@ -27,10 +29,12 @@ import weaver.workflow.workflow.WorkflowVersion; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.beans.BeanInfo; +import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.*; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.math.BigDecimal; @@ -38,6 +42,7 @@ import java.net.URLDecoder; import java.text.ParseException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.regex.Matcher; @@ -54,10 +59,13 @@ import java.util.zip.ZipEntry; public class Util extends weaver.general.Util { - static ToolUtil toolUtil = new ToolUtil(); private static final UtilService utilService = new UtilService(); private static final RecordSet rs = new RecordSet(); - private static RecordsetUtil recordsetUtil = new RecordsetUtil();; + private static final String LOGGER_NAME = "cusAYH"; + static ToolUtil toolUtil = new ToolUtil(); + private static RecordsetUtil recordsetUtil = new RecordsetUtil(); + private static LoggerUtil loggerUtil = new LoggerUtil(); + private static volatile Logger log = null; /** @@ -149,7 +157,8 @@ public class Util extends weaver.general.Util { /** * 移除前后的指定字符 - * @param sqlBuilder 需要移除的字符串的StringBuilder 对象 + * + * @param sqlBuilder 需要移除的字符串的StringBuilder 对象 * @param removeSeparator 移除的字符串 * @return 移除前后指定字符后的字符串 */ @@ -167,7 +176,8 @@ public class Util extends weaver.general.Util { /** * 移除前后的指定字符 - * @param string 需要移除的字符串的 + * + * @param string 需要移除的字符串的 * @param removeSeparator 移除的字符串 * @return 移除前后指定字符后的字符串 */ @@ -642,7 +652,7 @@ public class Util extends weaver.general.Util { //处理字符串 for (int i = 0, l = charArray.length; i < l; i++) { if (charArray[i] >= 65 && charArray[i] <= 90) { - if(i==0){ + if (i == 0) { buffer.append(charArray[i] += 32); continue; } @@ -1620,7 +1630,7 @@ public class Util extends weaver.general.Util { } public static String getDocCategorys(int workflowId, String docField) { - return getDocCategorys(String.valueOf(workflowId),docField); + return getDocCategorys(String.valueOf(workflowId), docField); } /** @@ -1788,18 +1798,19 @@ public class Util extends weaver.general.Util { /** * 获取完整的错误信息 + * * @param throwable 异常 * @return 完整堆栈信息 */ - public static String getErrString(Throwable throwable){ - StringWriter stringWriter = new StringWriter(); - throwable.printStackTrace(new PrintWriter(stringWriter,true)); + public static String getErrString(Throwable throwable) { + StringWriter stringWriter = new StringWriter(); + throwable.printStackTrace(new PrintWriter(stringWriter, true)); new Thread(() -> { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); - }finally { + } finally { try { stringWriter.close(); } catch (IOException e) { @@ -1812,6 +1823,7 @@ public class Util extends weaver.general.Util { /** * 获取RecordSetUtil的SQL代理类对象 + * * @param t * @param * @return @@ -1823,6 +1835,7 @@ public class Util extends weaver.general.Util { /** * join方法 + * * @param coll * @param split * @return @@ -1835,8 +1848,8 @@ public class Util extends weaver.general.Util { boolean isFirst = true; String s; - for(Iterator item = coll.iterator(); item.hasNext(); sb.append(s)) { - s = (String)item.next(); + for (Iterator item = coll.iterator(); item.hasNext(); sb.append(s)) { + s = (String) item.next(); if (isFirst) { isFirst = false; } else { @@ -1857,7 +1870,7 @@ public class Util extends weaver.general.Util { boolean isFirst = true; String s; - for(Iterator item = coll.iterator(); item.hasNext(); sb.append(s)) { + for (Iterator item = coll.iterator(); item.hasNext(); sb.append(s)) { Object next = item.next(); s = next == null ? "" : String.valueOf(next); if (isFirst) { @@ -1870,4 +1883,250 @@ public class Util extends weaver.general.Util { return sb.toString(); } } + + public static void errorException(Object message, Throwable exception) { + loggerUtil.error(message, exception); + } + + public static Logger getLogger() { + if (log == null) { + synchronized (Util.class) { + if (log == null) { + log = org.apache.log4j.Logger.getLogger(LOGGER_NAME); + } + } + } + return log; + } + + + /** + * 将list转化为树形list + * + * @param dataList 元数据 + * @param getIdFn 获取元数据的id + * @param getParentId 获取父类id的方法 + * @param setChildFn 设置子结点方法 + * @param predicate 判断是否属于根结点的方法 + * @param list的泛型 + * @param 元数据id的泛型 + * @return 树形的list + */ + public static List listToTree(List dataList, Function getIdFn, + Function getParentId, BiConsumer setChildFn, Predicate predicate) { + if (dataList == null || dataList.isEmpty() || dataList.size() == 1) { + return dataList; + } + return buildTree(dataList, new HashMap<>(dataList.size()), new HashMap<>(dataList.size()), 0, + getIdFn, getParentId, setChildFn, predicate); + } + /** + * 将list转化为树形list + * + * @param dataList 元数据 + * @param getIdFn 获取元数据的id + * @param getParentId 获取父类id的方法 + * @param setChildFn 设置子结点方法 + * @param getChildFn 获取子结点方法 + * @param predicate 判断是否属于根结点的方法 + * @param list的泛型 + * @param 元数据id的泛型 + * @return 树形的list + */ + public static List listToTree(List dataList, Function getIdFn, + Function getParentId, Function> getChildFn, + BiConsumer> setChildFn, Predicate predicate){ + if (dataList == null || dataList.isEmpty() || dataList.size() == 1) { + return dataList; + } + return buildTree(dataList,new HashMap<>(dataList.size()),new HashMap<>(dataList.size()), + 0,getIdFn,getParentId,getChildFn,setChildFn,predicate); + } + + /** + * 将list转为树形list + * + * @param dataList 元数据list + * @param dataMap 数据map + * @param childMap 已添加过的子元素 + * @param index 从第几个开始格式化 + * @param getIdFn 获取id的方法 + * @param getParentId 获取父类id的方法 + * @param setChildFn 设置孩子节点的方法 + * @param predicate 判断是否属于根节点的方法 + * @param list的泛型 + * @param 泛型的id的类型 + * @return 树形结构 + */ + private static List buildTree(List dataList, Map dataMap, Map childMap, int index, Function getIdFn, + Function getParentId, BiConsumer setChildFn, + Predicate predicate) { + List treeList = new ArrayList<>(dataList.size()); + while (index < dataList.size()) { + T item = dataList.get(index); + index++; + K id = getIdFn.apply(item); + K parentId = getParentId.apply(item); + dataMap.put(id, item); +// 判断是否属于根节点,如果是根节点,则将数据添加到树中 + if (predicate.test(parentId)) { + if (childMap.containsKey(id)) { + continue; + } + treeList.add(item); + childMap.put(id, item); + } else { +// 如果不是根节点,则通过id查找到父级 + T parent = dataMap.get(parentId); + if (Objects.isNull(parent)) { +// 如果父级为空,则说明他的父级还没有遍历到,需要从之后的数据进行遍历,直到找到父级为止 + List list = buildTree(dataList, dataMap, childMap, index, getIdFn, getParentId, setChildFn, predicate); + parent = dataMap.get(parentId); + if (Objects.isNull(parent)) { +// 如果还是没有查询到父节点,则表明是顶层节点,将他添加到顶层节点中 + treeList.add(item); + } else { +// 如果找到了父节点,则将自己挂到父节点上 + if (childMap.containsKey(id)) { + continue; + } + setChildFn.accept(parent, item); + childMap.put(id, item); + } +// 如果查找的list不为空并且有值,那就说明属于根节点 + if (list != null && list.size() > 0) { + treeList.addAll(list); + } + } else { +// 如果找到了父节点,则将自己挂到父节点上 + if (childMap.containsKey(id)) { + continue; + } + setChildFn.accept(parent, item); + childMap.put(id, item); + } + } + } + return treeList; + } + + + /** + * 将list转为树形list + * + * @param dataList 元数据list + * @param dataMap 数据map + * @param childMap 已添加过的子元素 + * @param index 从第几个开始格式化 + * @param getIdFn 获取id的方法 + * @param getParentId 获取父类id的方法 + * @param getChildFn 获取子结点方法 + * @param setChildFn 设置孩子节点的方法 + * @param predicate 判断是否属于根节点的方法 + * @param list的泛型 + * @param 泛型的id的类型 + * @return 树形结构 + */ + private static List buildTree(List dataList, Map dataMap, Map childMap, int index, Function getIdFn, + Function getParentId, Function> getChildFn, + BiConsumer> setChildFn, Predicate predicate) { + List treeList = new ArrayList<>(dataList.size()); + while (index < dataList.size()) { + T item = dataList.get(index); + index++; + K id = getIdFn.apply(item); + K parentId = getParentId.apply(item); + dataMap.put(id, item); +// 判断是否属于根节点,如果是根节点,则将数据添加到树中 + if (predicate.test(parentId)) { + if (childMap.containsKey(id)) { + continue; + } + treeList.add(item); + childMap.put(id, item); + } else { +// 如果不是根节点,则通过id查找到父级 + T parent = dataMap.get(parentId); + if (Objects.isNull(parent)) { +// 如果父级为空,则说明他的父级还没有遍历到,需要从之后的数据进行遍历,直到找到父级为止 + List list = buildTree(dataList, dataMap, childMap, index, getIdFn, getParentId, getChildFn, setChildFn, predicate); + parent = dataMap.get(parentId); + if (Objects.isNull(parent)) { +// 如果还是没有查询到父节点,则表明是顶层节点,将他添加到顶层节点中 + treeList.add(item); + } else { +// 如果找到了父节点,则将自己挂到父节点上 + if (childMap.containsKey(id)) { + continue; + } + List childList = Optional.ofNullable(getChildFn.apply(parent)).orElse(new ArrayList<>()); + childList.add(item); + setChildFn.accept(parent, childList); + childMap.put(id, item); + } +// 如果查找的list不为空并且有值,那就说明属于根节点 + if (list != null && list.size() > 0) { + treeList.addAll(list); + } + } else { +// 如果找到了父节点,则将自己挂到父节点上 + if (childMap.containsKey(id)) { + continue; + } + List childList = Optional.ofNullable(getChildFn.apply(parent)).orElse(new ArrayList<>()); + childList.add(item); + setChildFn.accept(parent, childList); + childMap.put(id, item); + } + } + } + return treeList; + } + + /** + * 复制java bean中的基本属性,引用类型除外 + * @param source 原对象 + * @param target 目标对象 + * @param 原对象泛型 + * @param 目标对象泛型 + * @return 复制后的目标对象 + */ + public static K copyBeanBaseField(T source, K target){ + if(Objects.isNull(source)){ + return target; + } + if(Objects.isNull(target)){ + throw new RuntimeException("target is null, You cannot pass a null bean"); + } + BeanInfo beanInfo = null; + try { + beanInfo = Introspector.getBeanInfo(target.getClass()); + } catch (IntrospectionException e) { + e.printStackTrace(); + } + if(Objects.isNull(beanInfo)){ + throw new RuntimeException("无法获取对象信息!can not get bean info"); + } + Class sourceClass = source.getClass(); + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { + Method writeMethod = propertyDescriptor.getWriteMethod(); + String name = propertyDescriptor.getName(); + try { + Field sourceClassField = sourceClass.getDeclaredField(name); + Class propertyType = propertyDescriptor.getPropertyType(); + Class classFieldType = sourceClassField.getType(); + if(propertyType.equals(classFieldType)){ + Method getMethod = sourceClass.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1)); + Object invoke = getMethod.invoke(source); + writeMethod.invoke(target,invoke); + } + } catch (NoSuchFieldException | IllegalAccessException | InvocationTargetException ignored) { + } catch (NoSuchMethodException e) { + throw new RuntimeException("invoke method err, cant not invoke method set" + name.substring(0,1).toUpperCase() + name.substring(1)); + } + } +// TODO 复制bean + return target; + } } diff --git a/src/main/java/aiyh/utils/annotation/recordset/CaseConversion.java b/src/main/java/aiyh/utils/annotation/recordset/CaseConversion.java index d10900a..6d0094b 100644 --- a/src/main/java/aiyh/utils/annotation/recordset/CaseConversion.java +++ b/src/main/java/aiyh/utils/annotation/recordset/CaseConversion.java @@ -5,6 +5,7 @@ import java.lang.annotation.*; /** * @author @author EBU7-dev1-ay * create 2021/12/21 0021 15:25 + * 是否开启大小写转换默认开启 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) diff --git a/src/main/java/aiyh/utils/apirequest/ApiRequestUtil.java b/src/main/java/aiyh/utils/apirequest/ApiRequestUtil.java new file mode 100644 index 0000000..d5aa93d --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/ApiRequestUtil.java @@ -0,0 +1,12 @@ +package aiyh.utils.apirequest; + +/** + *

第三方请求工具类

+ *

create 2022/1/22 0022 20:15

+ * + * @author EBU7-dev1-ayh + */ + + +public class ApiRequestUtil { +} diff --git a/src/main/java/aiyh/utils/apirequest/core/factory/AbstractFactory.java b/src/main/java/aiyh/utils/apirequest/core/factory/AbstractFactory.java new file mode 100644 index 0000000..72ea680 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/factory/AbstractFactory.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.factory; + +/** + *

抽象工厂

+ *

create 2022/1/26 0026 12:03

+ * + * @author EBU7-dev1-ayh + */ + + +public interface AbstractFactory { + /** + * 创建参数处理工厂 + * @param type 工厂类型 + * @return 参数处理工厂 + */ + T createParamHandlerFactory(Class type); +} diff --git a/src/main/java/aiyh/utils/apirequest/core/factory/AbstractFactoryImpl.java b/src/main/java/aiyh/utils/apirequest/core/factory/AbstractFactoryImpl.java new file mode 100644 index 0000000..77a1a86 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/factory/AbstractFactoryImpl.java @@ -0,0 +1,26 @@ +package aiyh.utils.apirequest.core.factory; + +/** + *

+ *

create 2022/1/26 0026 12:55

+ * + * @author EBU7-dev1-ayh + */ + + +public class AbstractFactoryImpl implements AbstractFactory { + + @Override + public T createParamHandlerFactory(Class type) { + if (ParamTypeHandlerFactory.class.equals(type)) { + return (T) new ParamTypeHandlerFactory(); + } + if (ParamValueRuleHandlerFactory.class.equals(type)) { + return (T) new ParamValueRuleHandlerFactory(); + } + if (DataSourceHandlerFactory.class.equals(type)) { + return (T) new DataSourceHandlerFactory(); + } + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/factory/DataSourceHandlerFactory.java b/src/main/java/aiyh/utils/apirequest/core/factory/DataSourceHandlerFactory.java new file mode 100644 index 0000000..3b6f6b3 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/factory/DataSourceHandlerFactory.java @@ -0,0 +1,31 @@ +package aiyh.utils.apirequest.core.factory; + +import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler; +import aiyh.utils.apirequest.core.typehandler.datasource.ModelDataHandler; +import aiyh.utils.apirequest.core.typehandler.datasource.WorkflowDataHandler; +import aiyh.utils.apirequest.enumtype.DataSourceRuleEnum; +import aiyh.utils.apirequest.enumtype.ParamValueRuleEnum; + +/** + *

解析参数处理器工厂

+ *

create 2022/1/25 0025 13:52

+ * + * @author EBU7-dev1-ayh + */ + + +public class DataSourceHandlerFactory implements ParamHandlerFactory { + + @Override + public IDataSourceHandler createParamHandler(DataSourceRuleEnum factoryEnum) { + switch (factoryEnum){ + case WORKFLOW_DATA: + return new WorkflowDataHandler(); + case MODEL_DATA: + return new ModelDataHandler(); + default: + break; + } + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/factory/ParamHandlerFactory.java b/src/main/java/aiyh/utils/apirequest/core/factory/ParamHandlerFactory.java new file mode 100644 index 0000000..104834c --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/factory/ParamHandlerFactory.java @@ -0,0 +1,19 @@ +package aiyh.utils.apirequest.core.factory; + +/** + *

参数处理工厂接口

+ *

create 2022/1/24 0024 10:59

+ * + * @author EBU7-dev1-ayh + */ + + +public interface ParamHandlerFactory { + /** + * 创建参数处理对象工厂方法 + * @param factoryEnum 工厂类型枚举 + * @return 产生的对象 + */ + + public R createParamHandler(V factoryEnum); +} diff --git a/src/main/java/aiyh/utils/apirequest/core/factory/ParamTypeHandlerFactory.java b/src/main/java/aiyh/utils/apirequest/core/factory/ParamTypeHandlerFactory.java new file mode 100644 index 0000000..bb7e730 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/factory/ParamTypeHandlerFactory.java @@ -0,0 +1,21 @@ +package aiyh.utils.apirequest.core.factory; + +import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler; +import aiyh.utils.apirequest.enumtype.ParamTypeEnum; + +/** + *

参数类型处理器工厂

+ *

create 2022/1/23 0023 21:24

+ * + * @author EBU7-dev1-ayh + */ + + +public class ParamTypeHandlerFactory implements ParamHandlerFactory { + + + @Override + public IParamTypeHandler createParamHandler(ParamTypeEnum factoryEnum) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/factory/ParamValueRuleHandlerFactory.java b/src/main/java/aiyh/utils/apirequest/core/factory/ParamValueRuleHandlerFactory.java new file mode 100644 index 0000000..c0941e9 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/factory/ParamValueRuleHandlerFactory.java @@ -0,0 +1,21 @@ +package aiyh.utils.apirequest.core.factory; + +import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler; +import aiyh.utils.apirequest.enumtype.ParamValueRuleEnum; + +/** + *

请求参数值处理器工厂

+ *

create 2022/1/23 0023 21:25

+ * + * @author EBU7-dev1-ayh + */ + + +public class ParamValueRuleHandlerFactory implements ParamHandlerFactory { + + + @Override + public IParamValueRuleHandler createParamHandler(ParamValueRuleEnum factoryEnum) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/IDataSourceHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/IDataSourceHandler.java new file mode 100644 index 0000000..c3d66d9 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/IDataSourceHandler.java @@ -0,0 +1,22 @@ +package aiyh.utils.apirequest.core.typehandler; + +import aiyh.utils.apirequest.entity.ParamConfigInfo; +import aiyh.utils.apirequest.pojo.ApiRequestMain; + +/** + *

解析参数统一接口

+ *

create 2022/1/26 0026 10:39

+ * + * @author EBU7-dev1-ayh + */ + + +public interface IDataSourceHandler { + + /** + * 数据来源处理方法 + * @param apiRequestMain 请求配置信息 + * @return 解析后 + */ + public ParamConfigInfo parseDataSource(ApiRequestMain apiRequestMain); +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/IParamTypeHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/IParamTypeHandler.java new file mode 100644 index 0000000..ae3c593 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/IParamTypeHandler.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.typehandler; + +/** + *

请求参数类型处理器接口

+ *

create 2022/1/22 0022 20:21

+ * + * @author EBU7-dev1-ayh + */ + + +public interface IParamTypeHandler { + /** + * 参数值类型的转换 + * @param value 为转换前参数值 + * @return 转换后的参数 + */ + public Object getValue(Object value); +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/IParamValueRuleHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/IParamValueRuleHandler.java new file mode 100644 index 0000000..8e9b5ff --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/IParamValueRuleHandler.java @@ -0,0 +1,23 @@ +package aiyh.utils.apirequest.core.typehandler; + +import aiyh.utils.apirequest.pojo.ApiRequestParamDetail; + +import java.util.Map; + +/** + *

参数取值方式处理器

+ *

create 2022/1/22 0022 20:22

+ * + * @author EBU7-dev1-ayh + */ + + +public interface IParamValueRuleHandler { + /** + * 获取参数配置对应的值 + * @param paramInfo 参数信息 + * @param dataMap 流程数据或建模表数据 + * @return 参数对应 的值 + */ + public Object getValue(ApiRequestParamDetail paramInfo, Map dataMap); +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/datasource/ModelDataHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/datasource/ModelDataHandler.java new file mode 100644 index 0000000..89d2c6f --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/datasource/ModelDataHandler.java @@ -0,0 +1,20 @@ +package aiyh.utils.apirequest.core.typehandler.datasource; + +import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler; +import aiyh.utils.apirequest.entity.ParamConfigInfo; +import aiyh.utils.apirequest.pojo.ApiRequestMain; + +/** + *

数据来源为流程的处理方法实现

+ *

create 2022/1/26 0026 11:00

+ * + * @author EBU7-dev1-ayh + */ + + +public class ModelDataHandler implements IDataSourceHandler { + @Override + public ParamConfigInfo parseDataSource(ApiRequestMain apiRequestMain) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/datasource/WorkflowDataHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/datasource/WorkflowDataHandler.java new file mode 100644 index 0000000..ff1e539 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/datasource/WorkflowDataHandler.java @@ -0,0 +1,75 @@ +package aiyh.utils.apirequest.core.typehandler.datasource; + +import aiyh.utils.Util; +import aiyh.utils.apirequest.core.factory.AbstractFactory; +import aiyh.utils.apirequest.core.factory.AbstractFactoryImpl; +import aiyh.utils.apirequest.core.factory.ParamValueRuleHandlerFactory; +import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler; +import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler; +import aiyh.utils.apirequest.entity.ParamConfigInfo; +import aiyh.utils.apirequest.entity.ParamInfo; +import aiyh.utils.apirequest.enumtype.ParamValueRuleEnum; +import aiyh.utils.apirequest.mapper.DataSourceMapper; +import aiyh.utils.apirequest.pojo.ApiRequestMain; +import aiyh.utils.apirequest.pojo.ApiRequestParamDetail; +import weaver.workflow.workflow.WorkflowVersion; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

数据来源为流程的处理方法实现

+ *

create 2022/1/26 0026 11:00

+ * + * @author EBU7-dev1-ayh + */ + + +public class WorkflowDataHandler implements IDataSourceHandler { + + private final DataSourceMapper mapper = Util.getMapper(DataSourceMapper.class); + private final AbstractFactory factory = new AbstractFactoryImpl(); + + @Override + public ParamConfigInfo parseDataSource(ApiRequestMain apiRequestMain) { + String workflowId = apiRequestMain.getWorkflowType(); + String workflowVersionIds = WorkflowVersion.getVersionStringByWfid(workflowId); + String workflowTable = mapper.selectWorkflowTableById(workflowVersionIds.split(",")); + Map mainData = mapper.selectMainData(workflowTable, apiRequestMain.getRequestId()); + ParamConfigInfo paramConfigInfo = Util.copyBeanBaseField(apiRequestMain, new ParamConfigInfo()); + List paramDetailList = apiRequestMain.getParamDetailList(); + // 明细请求模式,单挑明细 当做请求参数进行一次请求 + if (apiRequestMain.getParamRequestType() == 1) { + + } else { +// 默认模式 + + } + return paramConfigInfo; + } + + + public List> parseValueForDetail(ApiRequestMain apiRequestMain, Map mainData) { + String requestDetailTableName = apiRequestMain.getRequestDetailTableName(); + List> detailList = mapper.selectDetailData(requestDetailTableName, String.valueOf(mainData.get("id"))); + List paramDetailList = apiRequestMain.getParamDetailList(); + ParamValueRuleHandlerFactory paramHandlerFactory = factory.createParamHandlerFactory(ParamValueRuleHandlerFactory.class); + for (Map detail : detailList) { + Map dataMap = new HashMap<>(8); + dataMap.put("main", mainData); + dataMap.put("detail", detail); + for (ApiRequestParamDetail paramDetail : paramDetailList) { + ParamValueRuleEnum paramValueRuleEnum = ParamValueRuleEnum.get(paramDetail.getValueRule()); + IParamValueRuleHandler paramHandler = paramHandlerFactory.createParamHandler(paramValueRuleEnum); + Object value = paramHandler.getValue(paramDetail, dataMap); + } + } + return null; + } + + public List parseValueForDefault() { + return null; + } + +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/BooleanTypeHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/BooleanTypeHandler.java new file mode 100644 index 0000000..9a6a03a --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/BooleanTypeHandler.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.typehandler.paramtype; + +import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler; + +/** + *

boolean参数类型处理器

+ *

create 2022/1/24 0024 11:35

+ * + * @author EBU7-dev1-ayh + */ + + +public class BooleanTypeHandler implements IParamTypeHandler { + @Override + public Boolean getValue(Object value) { + return Boolean.valueOf(String.valueOf(value)); + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/DoubleTypeHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/DoubleTypeHandler.java new file mode 100644 index 0000000..2cb8b8b --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/DoubleTypeHandler.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.typehandler.paramtype; + +import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler; + +/** + *

浮点数类型处理器

+ *

create 2022/1/24 0024 11:35

+ * + * @author EBU7-dev1-ayh + */ + + +public class DoubleTypeHandler implements IParamTypeHandler { + @Override + public Double getValue(Object value) { + return Double.valueOf(String.valueOf(value)); + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/ListTypeHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/ListTypeHandler.java new file mode 100644 index 0000000..64d7ddb --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/ListTypeHandler.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.typehandler.paramtype; + +import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler; + +/** + *

数组参数类型处理器

+ *

create 2022/1/24 0024 11:36

+ * + * @author EBU7-dev1-ayh + */ + + +public class ListTypeHandler implements IParamTypeHandler { + @Override + public Object getValue(Object value) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/LongTypeHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/LongTypeHandler.java new file mode 100644 index 0000000..6ad58eb --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/LongTypeHandler.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.typehandler.paramtype; + +import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler; + +/** + *

长整型数据类型处理器

+ *

create 2022/1/24 0024 11:34

+ * + * @author EBU7-dev1-ayh + */ + + +public class LongTypeHandler implements IParamTypeHandler { + @Override + public Long getValue(Object value) { + return Long.valueOf(String.valueOf(value)); + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/ObjectTypeHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/ObjectTypeHandler.java new file mode 100644 index 0000000..4a50981 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/ObjectTypeHandler.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.typehandler.paramtype; + +import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler; + +/** + *

Object参数类型处理器

+ *

create 2022/1/24 0024 11:34

+ * + * @author EBU7-dev1-ayh + */ + + +public class ObjectTypeHandler implements IParamTypeHandler { + @Override + public Object getValue(Object value) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/StringTypeHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/StringTypeHandler.java new file mode 100644 index 0000000..12c8f36 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramtype/StringTypeHandler.java @@ -0,0 +1,18 @@ +package aiyh.utils.apirequest.core.typehandler.paramtype; + +import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler; + +/** + *

字符串类型处理器

+ *

create 2022/1/24 0024 11:09

+ * + * @author EBU7-dev1-ayh + */ + + +public class StringTypeHandler implements IParamTypeHandler { + @Override + public String getValue(Object value) { + return String.valueOf(value); + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramvalue/FixedValueRuleHandle.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramvalue/FixedValueRuleHandle.java new file mode 100644 index 0000000..d19df23 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramvalue/FixedValueRuleHandle.java @@ -0,0 +1,22 @@ +package aiyh.utils.apirequest.core.typehandler.paramvalue; + +import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler; +import aiyh.utils.apirequest.pojo.ApiRequestParamDetail; + +import java.util.Map; + +/** + *

固定值处理器

+ *

create 2022/1/23 0023 19:51

+ * + * @author EBU7-dev1-ayh + */ + + +public class FixedValueRuleHandle implements IParamValueRuleHandler { + + @Override + public Object getValue(ApiRequestParamDetail paramInfo, Map dataMap) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/core/typehandler/paramvalue/NullValueRuleHandler.java b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramvalue/NullValueRuleHandler.java new file mode 100644 index 0000000..d4ef605 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/core/typehandler/paramvalue/NullValueRuleHandler.java @@ -0,0 +1,22 @@ +package aiyh.utils.apirequest.core.typehandler.paramvalue; + +import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler; +import aiyh.utils.apirequest.pojo.ApiRequestParamDetail; + +import java.util.Map; + +/** + *

空值处理器

+ *

create 2022/1/23 0023 19:52

+ * + * @author EBU7-dev1-ayh + */ + + +public class NullValueRuleHandler implements IParamValueRuleHandler { + + @Override + public Object getValue(ApiRequestParamDetail paramInfo, Map dataMap) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/entity/HeardInfo.java b/src/main/java/aiyh/utils/apirequest/entity/HeardInfo.java new file mode 100644 index 0000000..9e2c4d9 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/entity/HeardInfo.java @@ -0,0 +1,24 @@ +package aiyh.utils.apirequest.entity; + +import lombok.Data; + +import java.util.List; + +/** + *

请求头信息

+ *

create 2022/1/23 0023 21:09

+ * + * @author EBU7-dev1-ayh + */ + +@Data +public class HeardInfo { + /** + * 参数名称 + */ + private String heardName; + /** + * 参数值 + */ + private String heardValue; +} diff --git a/src/main/java/aiyh/utils/apirequest/entity/ParamConfigInfo.java b/src/main/java/aiyh/utils/apirequest/entity/ParamConfigInfo.java new file mode 100644 index 0000000..1fcfb86 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/entity/ParamConfigInfo.java @@ -0,0 +1,72 @@ +package aiyh.utils.apirequest.entity; + +import lombok.Data; + +import java.util.List; + +/** + *

配置信息

+ *

create 2022/1/23 0023 21:08

+ * + * @author EBU7-dev1-ayh + */ + +@Data +public class ParamConfigInfo { + private String requestId; + + private Integer id; + /** + * api地址 + */ + private String apiUrl; + /** + * 测试环境api地址 + */ + private String testApiUrl; + /** + * 请求方式 + */ + private Integer requestType; + /** + * api启用类型 + */ + private Integer apiType; + /** + * 数据来源 + */ + private Integer dataSource; + /** + * api接口描述 + */ + private String apiDesc; + /** + * 流程类型 + */ + private String workflowType; + /** + * 建模表表名 + */ + private String modelTableName; + /** + * 参数请求方式 + */ + private Integer paramRequestType; + /** + * 请求参数的数据来源,适用于参数请求方式为明细表模式 + */ + private String requestDetailTableName; + + /** + * 唯一标识 + */ + private String onlyMark; + /** + * 参数信息 + */ + private List paramInfoList; + /** + * 请求头信息 + */ + private List heardInfoList; +} diff --git a/src/main/java/aiyh/utils/apirequest/entity/ParamInfo.java b/src/main/java/aiyh/utils/apirequest/entity/ParamInfo.java new file mode 100644 index 0000000..1efa372 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/entity/ParamInfo.java @@ -0,0 +1,37 @@ +package aiyh.utils.apirequest.entity; + +import aiyh.utils.apirequest.pojo.ApiRequestParamDetail; +import lombok.Data; + +import java.util.List; + +/** + *

参数信息

+ *

create 2022/1/23 0023 21:04

+ * + * @author EBU7-dev1-ayh + */ + +@Data +public class ParamInfo { + /** + * 行号 + */ + private Integer lineNum; + /** + * 参数名称 + */ + private String paramName; + /** + * 参数值 + */ + private Object paramValue; + /** + * 所属 父级参数名 + */ + private Integer parentLine; + /** + * 子节点 + */ + private List childList; +} diff --git a/src/main/java/aiyh/utils/apirequest/entity/ParseAfterData.java b/src/main/java/aiyh/utils/apirequest/entity/ParseAfterData.java new file mode 100644 index 0000000..e5d3bda --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/entity/ParseAfterData.java @@ -0,0 +1,26 @@ +package aiyh.utils.apirequest.entity; + +import java.util.Map; + +/** + *

解析后的参数

+ *

create 2022/1/23 0023 20:33

+ * + * @author EBU7-dev1-ayh + */ + + +public class ParseAfterData { + /** + * 是否自动发送请求 + */ + private boolean autoRequest; + /** + * 请求参数 + */ + private Map requestData; + /** + * 请求头信息 + */ + private Map requestHeard; +} diff --git a/src/main/java/aiyh/utils/apirequest/enumtype/DataSourceRuleEnum.java b/src/main/java/aiyh/utils/apirequest/enumtype/DataSourceRuleEnum.java new file mode 100644 index 0000000..55d0360 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/enumtype/DataSourceRuleEnum.java @@ -0,0 +1,48 @@ +package aiyh.utils.apirequest.enumtype; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +/** + *

参数处理类型枚举

+ *

create 2022/1/26 0026 10:43

+ * + * @author EBU7-dev1-ayh + */ + + +public enum DataSourceRuleEnum { + + /** + * 流程 + */ + WORKFLOW_DATA(0), + /** + * 建模表 + */ + MODEL_DATA(1); + + private static final Map LOOKUP; + + static { + LOOKUP = new HashMap<>(); + for (DataSourceRuleEnum enumType : EnumSet.allOf(DataSourceRuleEnum.class)) { + LOOKUP.put(enumType.getValue(), enumType); + } + } + + private final int value; + + DataSourceRuleEnum(int value) { + this.value = value; + } + + public static DataSourceRuleEnum get(int value) { + return LOOKUP.get(value); + } + + public int getValue() { + return this.value; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/enumtype/ParamTypeEnum.java b/src/main/java/aiyh/utils/apirequest/enumtype/ParamTypeEnum.java new file mode 100644 index 0000000..afb684a --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/enumtype/ParamTypeEnum.java @@ -0,0 +1,12 @@ +package aiyh.utils.apirequest.enumtype; + +/** + *

参数类型枚举

+ *

create 2022/1/25 0025 10:36

+ * + * @author EBU7-dev1-ayh + */ + + +public enum ParamTypeEnum { +} diff --git a/src/main/java/aiyh/utils/apirequest/enumtype/ParamValueRuleEnum.java b/src/main/java/aiyh/utils/apirequest/enumtype/ParamValueRuleEnum.java new file mode 100644 index 0000000..e63833e --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/enumtype/ParamValueRuleEnum.java @@ -0,0 +1,83 @@ +package aiyh.utils.apirequest.enumtype; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +/** + *

取值方式枚举

+ *

create 2022/1/25 0025 10:16

+ * + * @author EBU7-dev1-ayh + */ + + +public enum ParamValueRuleEnum { + /** + * 空值 + */ + NULL_VALUE(0), + /** + * 固定值 + */ + FIXED_VALUE(1), + /** + * 系统字段 + */ + SYSTEM_FIELD(2), + /** + * 自定义SQL + */ + CUSTOMER_SQL(3), + /** + * 当前时间 + */ + CURRENT_TIME(4), + /** + * 流程请求id + */ + REQUEST_ID(5), + /** + * 流程id + */ + WORKFLOW_ID(6), + /** + * 随机值 + */ + RANDOM_VALUE(7), + /** + * 附件 + */ + ATTACHMENT_FILE(8), + /** + * 时间戳 + */ + TIME_STAMP(9), + /** + * SQL字段 + */ + SQL_FIELD(10); + + private static final Map LOOKUP; + + static { + LOOKUP = new HashMap<>(); + for (ParamValueRuleEnum enumType : EnumSet.allOf(ParamValueRuleEnum.class)) { + LOOKUP.put(enumType.getValue(), enumType); + } + } + + private final int value; + + ParamValueRuleEnum(int value) { + this.value = value; + } + + public static ParamValueRuleEnum get(int value) { + return LOOKUP.get(value); + } + + public int getValue() { + return this.value; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/interceptor/ApiRequestInterceptor.java b/src/main/java/aiyh/utils/apirequest/interceptor/ApiRequestInterceptor.java new file mode 100644 index 0000000..353eb12 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/interceptor/ApiRequestInterceptor.java @@ -0,0 +1,51 @@ +package aiyh.utils.apirequest.interceptor; + +import aiyh.utils.apirequest.entity.ParamConfigInfo; +import aiyh.utils.apirequest.entity.ParseAfterData; +import aiyh.utils.apirequest.pojo.ApiRequestMain; +import aiyh.utils.httpUtil.ResponeVo; + +/** + *

api 请求工具类拦截器

+ *

create 2022/1/22 0022 20:19

+ * + * @author EBU7-dev1-ayh + */ + + +public interface ApiRequestInterceptor { + /** + * 值解析前;拦截器' + * @param apiRequestMain 数据库配置数据信息 + * @return 数据库配置数据 + */ + public ApiRequestMain parseBefore(ApiRequestMain apiRequestMain); + + /** + * 解析值之后拦截器 + * @param paramConfigInfo 解析后的值 + * @return 值解析后的数据 + */ + public ParamConfigInfo parseAfter(ParamConfigInfo paramConfigInfo); + + /** + * 解析成树形结构之后拦截器 + * @param paramConfigTreeInfo 树形结构的请求参数配置信息 + * @return 树形结构的请求参数配置信息 + */ + public ParamConfigInfo parseTreeAfter(ParamConfigInfo paramConfigTreeInfo); + /** + * 请求前拦截器 + * @param parseAfterData 参数树形解析后参数 + * @return 最终请求参数 + */ + public ParseAfterData requestBefore(ParseAfterData parseAfterData); + + /** + * 请求完成后回调 + * @param isSuccess 是否请求成功 + * @param responeVo 响应结果信息 + */ + public void requestAfter(ResponeVo responeVo,boolean isSuccess); + +} diff --git a/src/main/java/aiyh/utils/apirequest/mapper/ApiRequestMapper.java b/src/main/java/aiyh/utils/apirequest/mapper/ApiRequestMapper.java new file mode 100644 index 0000000..0d44d47 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/mapper/ApiRequestMapper.java @@ -0,0 +1,53 @@ +package aiyh.utils.apirequest.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.apirequest.pojo.ApiRequestHeardDetail; +import aiyh.utils.apirequest.pojo.ApiRequestMain; +import aiyh.utils.apirequest.pojo.ApiRequestParamDetail; + +import java.util.List; + +/** + *

查询数据库数据接口

+ *

create 2022/1/23 0023 17:52

+ * + * @author EBU7-dev1-ayh + */ + +@SqlMapper +public interface ApiRequestMapper { + + /** + * 查询请求参数主表配置信息 + * @param onlyMark 唯一标识 + * @return 主表配置信息 + */ + @Select("") + public ApiRequestMain selectApiConfigByOnlyMark(@ParamMapper("onlyMark") String onlyMark); + + /** + * 查询请求参数主表配置信息 + * @param id id + * @return 主表配置信息 + */ + @Select("") + public ApiRequestMain selectApiConfigById(@ParamMapper("id") int id); + + /** + * 根据主表id查询请求参数配置信息 + * @param mainId 主表id + * @return 请求参数配置信息 + */ + @Select("") + public List selectApiParamListByMainId(@ParamMapper("mainId") int mainId); + + /** + * 个女警主表id查询请求头配置信息 + * @param mainId 主表id + * @return 请求头配置信息 + */ + @Select("") + public List selectApiHeardListByMainId(@ParamMapper("mainId") int mainId); +} diff --git a/src/main/java/aiyh/utils/apirequest/mapper/DataSourceMapper.java b/src/main/java/aiyh/utils/apirequest/mapper/DataSourceMapper.java new file mode 100644 index 0000000..4b3ad8f --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/mapper/DataSourceMapper.java @@ -0,0 +1,40 @@ +package aiyh.utils.apirequest.mapper; + +import aiyh.utils.annotation.recordset.CaseConversion; +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; +import java.util.Map; + +/** + *

数据来源逻辑处理查询数据库

+ *

create 2022/1/26 0026 14:10

+ * + * @author EBU7-dev1-ayh + */ + +@SqlMapper +public interface DataSourceMapper { + + /** + * 根据流程id查询流程表 + * @param versionIds 流程所有版本的id + * @return 流程对应的表名 + */ + @Select("select distinct tablename from workflow_base wb " + + "left join workflow_bill wbi on wbi.id = wb.formid " + + "where wb.id in (${versionIds})") + public String selectWorkflowTableById(@ParamMapper("versionIds") String[] versionIds); + + @Select("select * from $t{workflowTable} where requestid = #{requestid}") + @CaseConversion(false) + Map selectMainData(@ParamMapper("workflowTable") String workflowTable, + @ParamMapper("requestId") String requestId); + + @Select("select * from $t{detailTable} where mainid = #{mainId}") + @CaseConversion(false) + List> selectDetailData(@ParamMapper("detailTable") String requestDetailTableName, + @ParamMapper("mainId") String mainId); +} diff --git a/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestHeardDetail.java b/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestHeardDetail.java new file mode 100644 index 0000000..f271028 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestHeardDetail.java @@ -0,0 +1,31 @@ +package aiyh.utils.apirequest.pojo; + +import lombok.Data; + +/** + *

api请求头信息

+ *

create 2022/1/23 0023 18:10

+ * + * @author EBU7-dev1-ayh + */ + +@Data +public class ApiRequestHeardDetail { + private Integer mainId; + /** + * 请求头参数名称 + */ + private String heardName; + /** + * 取值规则 + */ + private Integer valueRule; + /** + * 自定义值 + */ + private String customerValue; + /** + * 是否启用参数 + */ + private Integer enableParam; +} diff --git a/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestMain.java b/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestMain.java new file mode 100644 index 0000000..91b3796 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestMain.java @@ -0,0 +1,78 @@ +package aiyh.utils.apirequest.pojo; + +import lombok.Data; + +import java.util.List; + +/** + *

主表

+ *

create 2022/1/23 0023 17:55

+ * + * @author EBU7-dev1-ayh + */ + + +@Data +public class ApiRequestMain { + /** + * 流程请求id + */ + private String requestId; + /** + * 主表id + */ + private Integer id; + /** + * api地址 + */ + private String apiUrl; + /** + * 测试环境api地址 + */ + private String testApiUrl; + /** + * 请求方式 + */ + private Integer requestType; + /** + * api启用类型 + */ + private Integer apiType; + /** + * 数据来源 + */ + private Integer dataSource; + /** + * api接口描述 + */ + private String apiDesc; + /** + * 流程类型 + */ + private String workflowType; + /** + * 建模表表名 + */ + private String modelTableName; + /** + * 参数请求方式 + */ + private Integer paramRequestType; + /** + * 请求参数的数据来源,适用于参数请求方式为明细表模式 + */ + private String requestDetailTableName; + + /** + * 唯一标识 + */ + private String onlyMark; + /** + * 请求参数信息 + */ + private List paramDetailList; + /** + * 请求头信息 + */ + private List heardDetailList; +} diff --git a/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestParamDetail.java b/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestParamDetail.java new file mode 100644 index 0000000..1f51cda --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/pojo/ApiRequestParamDetail.java @@ -0,0 +1,62 @@ +package aiyh.utils.apirequest.pojo; + +import lombok.Data; + +import java.util.List; + +/** + *

+ *

create 2022/1/23 0023 18:04

+ * + * @author EBU7-dev1-ayh + */ + +@Data +public class ApiRequestParamDetail { + /** + * 主表id + */ + private Integer mainId; + /** + * 行号 + */ + private Integer lineNum; + /** + * 参数名称 + */ + private String paramName; + /** + * 参数类型 + */ + private Integer paramType; + /** + * 数据来源 + */ + private Integer dataSource; + /** + * 明细表表名 + */ + private String detailTableName; + /** + * 所属 父级行号 + */ + private Integer parentLine; + /** + * 取值方式 + */ + private Integer valueRule; + /** + * 系统字段 + */ + private String systemFieldName; + /** + * 自定义值文本 + */ + private String customerValue; + /** + * 是否启用参数 + */ + private Integer enableParam; + + +} diff --git a/src/main/java/aiyh/utils/apirequest/service/ApiRequestService.java b/src/main/java/aiyh/utils/apirequest/service/ApiRequestService.java new file mode 100644 index 0000000..0288f86 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/service/ApiRequestService.java @@ -0,0 +1,137 @@ +package aiyh.utils.apirequest.service; + +import aiyh.utils.Util; +import aiyh.utils.apirequest.core.factory.AbstractFactory; +import aiyh.utils.apirequest.core.factory.AbstractFactoryImpl; +import aiyh.utils.apirequest.core.factory.DataSourceHandlerFactory; +import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler; +import aiyh.utils.apirequest.entity.ParamConfigInfo; +import aiyh.utils.apirequest.entity.ParamInfo; +import aiyh.utils.apirequest.entity.ParseAfterData; +import aiyh.utils.apirequest.enumtype.DataSourceRuleEnum; +import aiyh.utils.apirequest.interceptor.ApiRequestInterceptor; +import aiyh.utils.apirequest.mapper.ApiRequestMapper; +import aiyh.utils.apirequest.pojo.ApiRequestHeardDetail; +import aiyh.utils.apirequest.pojo.ApiRequestMain; +import aiyh.utils.apirequest.pojo.ApiRequestParamDetail; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicReference; + +/** + *

api 请求工具具体处理 逻辑

+ *

create 2022/1/22 0022 20:26

+ * + * @author EBU7-dev1-ayh + */ + + +public class ApiRequestService { + + /** + * 请求拦截器 + */ + private final ApiRequestInterceptor interceptor; + private final AbstractFactory abstractFactory = new AbstractFactoryImpl(); + /** + * 查询数据库数据 + */ + private final ApiRequestMapper mapper; + + private String requestId; + + /** + * @param interceptor 拦截器 + */ + public ApiRequestService(ApiRequestInterceptor interceptor) { + this.mapper = Util.getMapper(ApiRequestMapper.class); + this.interceptor = interceptor; + } + + /** + * 获取数据库配置信息 + * + * @param id 配置id + * @return + */ + public ApiRequestMain getApiRequestMain(int id) { + AtomicReference apiRequestMain = new AtomicReference<>(mapper.selectApiConfigById(id)); + if (Objects.isNull(apiRequestMain.get())) { + return null; + } + List paramDetailList = mapper.selectApiParamListByMainId(apiRequestMain.get().getId()); + + apiRequestMain.get().setParamDetailList(paramDetailList); + List heardDetailList = mapper.selectApiHeardListByMainId(apiRequestMain.get().getId()); + apiRequestMain.get().setHeardDetailList(heardDetailList); + Optional.ofNullable(interceptor).map(interceptor -> { + Optional.ofNullable(interceptor.parseBefore(apiRequestMain.get())).map(v -> { + apiRequestMain.set(v); + return v; + }); + return interceptor; + }); + return apiRequestMain.get(); + } + + /** + * 解析参数值 + * + * @param apiRequestMain 主表配置信息 + * @return 解析后的参数值 + */ + public ParamConfigInfo parseParam(ApiRequestMain apiRequestMain) { + DataSourceHandlerFactory dataSourceHandlerFactory = abstractFactory.createParamHandlerFactory(DataSourceHandlerFactory.class); + DataSourceRuleEnum dataSourceRuleEnum = DataSourceRuleEnum.get(apiRequestMain.getDataSource()); + IDataSourceHandler paramHandler = dataSourceHandlerFactory.createParamHandler(dataSourceRuleEnum); + apiRequestMain.setRequestId(this.requestId); + AtomicReference paramConfigInfo = new AtomicReference<>(paramHandler.parseDataSource(apiRequestMain)); +// TODO 解析配置表中的参数 + Optional.ofNullable(interceptor).map(interceptor -> { + Optional.ofNullable(interceptor.parseAfter(paramConfigInfo.get())).map(v -> { + paramConfigInfo.set(v); + return v; + }); + return interceptor; + }); + return paramConfigInfo.get(); + } + + + /** + * 解析树形参数并解析最终请求参数 + * + * @param paramConfigInfo 解析后的请求参数值 + * @return + */ + public ParseAfterData parseTree(ParamConfigInfo paramConfigInfo) { + AtomicReference parseParamConfig = new AtomicReference<>(new ParamConfigInfo()); + Util.copyBeanBaseField(paramConfigInfo, parseParamConfig.get()); + List paramInfoList = paramConfigInfo.getParamInfoList(); + List treeParamList = Util.listToTree(paramInfoList, + ParamInfo::getLineNum, ParamInfo::getParentLine, + ParamInfo::getChildList, ParamInfo::setChildList, + parentId -> Objects.isNull(parentId) || parentId == -1 || parentId == 0); + parseParamConfig.get().setParamInfoList(treeParamList); +// TODO 将树形结构组合为最终的请求参数结构 + Optional.ofNullable(interceptor).map(interceptor->{ + Optional.ofNullable(interceptor.parseTreeAfter(parseParamConfig.get())).map(v->{ + parseParamConfig.set(v); + return v; + }); + return interceptor; + }); + return null; + } + + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } +} diff --git a/src/main/java/aiyh/utils/apirequest/service/ParseParamValue.java b/src/main/java/aiyh/utils/apirequest/service/ParseParamValue.java new file mode 100644 index 0000000..5a01154 --- /dev/null +++ b/src/main/java/aiyh/utils/apirequest/service/ParseParamValue.java @@ -0,0 +1,29 @@ +package aiyh.utils.apirequest.service; + +import aiyh.utils.apirequest.core.factory.AbstractFactory; +import aiyh.utils.apirequest.core.factory.AbstractFactoryImpl; +import aiyh.utils.apirequest.core.factory.DataSourceHandlerFactory; +import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler; +import aiyh.utils.apirequest.entity.ParamConfigInfo; +import aiyh.utils.apirequest.enumtype.DataSourceRuleEnum; +import aiyh.utils.apirequest.pojo.ApiRequestMain; + +/** + *

解析参数值

+ *

create 2022/1/25 0025 10:02

+ * + * @author EBU7-dev1-ayh + */ + + +public class ParseParamValue { + + private final AbstractFactory abstractFactory = new AbstractFactoryImpl(); + + public ParamConfigInfo parseValue(ApiRequestMain apiRequestMain) { + DataSourceHandlerFactory dataSourceHandlerFactory = abstractFactory.createParamHandlerFactory(DataSourceHandlerFactory.class); + DataSourceRuleEnum dataSourceRuleEnum = DataSourceRuleEnum.get(apiRequestMain.getDataSource()); + IDataSourceHandler paramHandler = dataSourceHandlerFactory.createParamHandler(dataSourceRuleEnum); + return paramHandler.parseDataSource(apiRequestMain); + } +} diff --git a/src/main/java/aiyh/utils/function/ListToTreeSetChildFunction.java b/src/main/java/aiyh/utils/function/ListToTreeSetChildFunction.java new file mode 100644 index 0000000..5813f15 --- /dev/null +++ b/src/main/java/aiyh/utils/function/ListToTreeSetChildFunction.java @@ -0,0 +1,18 @@ +package aiyh.utils.function; + +/** + *

设置孩子节点function

+ *

create 2022/1/22 0022 18:26

+ * + * @author EBU7-dev1-ayh + */ + +@FunctionalInterface +public interface ListToTreeSetChildFunction { + /** + * 设置树形结构中的孩子节点 + * @param parent 父节点 + * @param child 孩子节点 + */ + void setChildItem(T parent, T child); +} diff --git a/src/main/java/aiyh/utils/logger/Logger.java b/src/main/java/aiyh/utils/logger/Logger.java new file mode 100644 index 0000000..b8418a5 --- /dev/null +++ b/src/main/java/aiyh/utils/logger/Logger.java @@ -0,0 +1,64 @@ +package aiyh.utils.logger; + +/** + * create 2022/1/17 0017 9:58 + * 日志接口 + * + * @author EBU7-dev1-ayh + */ + +public interface Logger { + + /** + * 打印debug日志 + * @param message 消息 + */ + public void debug(Object message); + + /** + * 打印debug日志 + * @param message 消息 + * @param exception 异常 + */ + public void debug(Object message, Throwable exception); + + /** + * 打印info日志 + * @param message 消息 + */ + public void info(Object message); + + + /** + * 打印info日志 + * @param message 消息 + * @param exception 异常 + */ + public void info(Object message, Throwable exception); + + /** + * 打印warn日志 + * @param message 消息 + */ + public void warn(Object message); + + /** + * 打印warn日志 + * @param message 消息 + * @param exception 异常 + */ + public void warn(Object message, Throwable exception); + + /** + * 打印error日志 + * @param message 错误消息 + */ + public void error(Object message); + + /** + * 打印error日志 + * @param message 消息 + * @param exception 异常 + */ + public void error(Object message, Throwable exception); +} diff --git a/src/main/java/aiyh/utils/logger/LoggerUtil.java b/src/main/java/aiyh/utils/logger/LoggerUtil.java new file mode 100644 index 0000000..9a88121 --- /dev/null +++ b/src/main/java/aiyh/utils/logger/LoggerUtil.java @@ -0,0 +1,69 @@ +package aiyh.utils.logger; + +import aiyh.utils.Util; + +/** + * create 2022/1/17 0017 9:57 + * 日志工具 + * + * @author EBU7-dev1-ayh + */ + + +public class LoggerUtil implements Logger{ + private final String LOGGER_NAME = "cusAYH"; + private final org.apache.log4j.Logger log; + + public LoggerUtil() { + log = org.apache.log4j.Logger.getLogger(LOGGER_NAME); + } + + public LoggerUtil(String loggerName) { + this.log = org.apache.log4j.Logger.getLogger(loggerName); + } + + @Override + public void debug(Object message) { + this.log.debug(message); + } + + @Override + public void debug(Object message, Throwable exception) { + this.log.debug(message,exception); + } + + @Override + public void info(Object message) { + this.log.info(message); + } + + @Override + public void info(Object message, Throwable exception) { + this.log.info(message,exception); + } + + @Override + public void warn(Object message) { + this.log.warn(message); + } + + @Override + public void warn(Object message, Throwable exception) { + this.log.warn(message,exception); + } + + @Override + public void error(Object message) { + this.log.error(message); + } + + @Override + public void error(Object message, Throwable exception) { + this.log.error(message,exception); + } + + + public void errorException(Object message, Throwable exception) { + this.log.error(message + " ==> :\n " + Util.getErrString(exception)); + } +} diff --git a/src/main/java/com/api/aiyh_guijiu/service/WorkflowQueueService.java b/src/main/java/com/api/aiyh_guijiu/service/WorkflowQueueService.java index d66a6fc..6fec1b8 100644 --- a/src/main/java/com/api/aiyh_guijiu/service/WorkflowQueueService.java +++ b/src/main/java/com/api/aiyh_guijiu/service/WorkflowQueueService.java @@ -22,6 +22,7 @@ import com.drew.metadata.Tag; import com.engine.workflow.biz.requestForm.FileBiz; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.log4j.Logger; import org.h2.util.StringUtils; import weaver.conn.RecordSet; import weaver.docs.docs.DocManager; @@ -47,7 +48,7 @@ public class WorkflowQueueService { ToolUtil toolUtil = new ToolUtil(); ObjectMapper mapper = new ObjectMapper(); ConflictWorkflowDao conflictWorkflowDao = new ConflictWorkflowDao(); - + private Logger log = Util.getLogger(); /** * 查询ps配置参数 @@ -105,7 +106,7 @@ public class WorkflowQueueService { // 遍历Directory对象,每个对象里面包含标签 for (Directory directory : metadata.getDirectories()) { String directoryName = directory.getName(); - System.out.println(directory); + log.info(directory); if ("Photoshop".equalsIgnoreCase(directoryName) || "Adobe JPEG".equalsIgnoreCase(directoryName) || directoryName.contains("Adobe")) { if (picPsVO.getScore() > 90) { @@ -116,7 +117,7 @@ public class WorkflowQueueService { } String model = ""; for (Tag tag : directory.getTags()) { - System.out.println(tag); + log.info(tag); if (tag.getDescription() != null && tag.getDescription().toLowerCase().contains("Adobe".toLowerCase())) { picPsVO.setDescribe("图片经过Adobe Photoshop软件,注意审核!"); picPsVO.setScore(70); @@ -170,10 +171,14 @@ public class WorkflowQueueService { } } catch (ImageProcessingException | IOException e) { e.printStackTrace(); + toolUtil.writeErrorLog("图片识别异常!"); } - list.add(picPsVO); + if (picPsVO.getScore() > 0){ + list.add(picPsVO); + } } List collect = list.stream().filter(item -> item.getScore() > 0).collect(Collectors.toList()); +// log.info("最终识别后的数组:" + collect); return ApiResult.success(collect); } diff --git a/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java b/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java index f388e48..851eeee 100644 --- a/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java +++ b/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java @@ -954,15 +954,11 @@ public class FaDDContractService { } public void pushAPush(String requestId) { - toolUtil.writeDebuggerLog("进入催一催方法==================="); UfContractInfoDTO ufContractInfoDTO = faDDContractMapping.queryContractInfoByRequestId(requestId); - toolUtil.writeDebuggerLog("获取到合同数据:" + JSON.toJSONString(ufContractInfoDTO)); String signedUrls = Util.null2String(ufContractInfoDTO.getContractSignedUrl()); PushAPushEmailEntity pushAPushEmailEntity = queryEmailInfo(ufContractInfoDTO.getWorkflowType(), ufContractInfoDTO.getWorkflowRequestId()); - toolUtil.writeDebuggerLog("获取到邮件信息数据:" + JSON.toJSONString(pushAPushEmailEntity)); String content = pushAPushEmailEntity.getEmailContent().replaceAll("#\\{info.signedUrls}", signedUrls); - toolUtil.writeDebuggerLog("contnet:" + content); try { EmailWorkRunnable.threadModeReminder(pushAPushEmailEntity.getEmailAddress(), "", "", pushAPushEmailEntity.getEmailTitle(), @@ -970,7 +966,6 @@ public class FaDDContractService { } catch (Exception e) { toolUtil.writeDebuggerLog(e.toString()); } - toolUtil.writeDebuggerLog("结束催一催方法==================="); } private PushAPushEmailEntity queryEmailInfo(int workflowType, String requestId) { diff --git a/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java b/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java index 4f56cca..84021eb 100644 --- a/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java +++ b/src/main/java/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java @@ -34,7 +34,7 @@ import weaver.workflow.workflow.WorkflowVersion; /** * @author EBU7-dev1-ayh - * @create 2021/9/30 0030 11:12 service + * @create 2021/9/30 0030 11:12 core */ public class FaDDServiceImpl implements IFaDDService { private final FaDDServiceMapping faDDServiceMapping = new FaDDServiceMapping(); diff --git a/src/main/java/weaver/aiyh_pcn/async_organization/util/SyncOrganizationUtils.java b/src/main/java/weaver/aiyh_pcn/async_organization/util/SyncOrganizationUtils.java index ffe387f..a9ba967 100644 --- a/src/main/java/weaver/aiyh_pcn/async_organization/util/SyncOrganizationUtils.java +++ b/src/main/java/weaver/aiyh_pcn/async_organization/util/SyncOrganizationUtils.java @@ -293,7 +293,7 @@ public class SyncOrganizationUtils extends ToolUtil { String today = TimeUtil.getCurrentDateString(); // 根据outkey,询是否存在该人员 String query = "select id from hrmresource where outkey = ?"; - try { + try { rs.executeQuery(query, Util.null2String(String.valueOf(employee.getUserID()))); } catch (Exception e) { writeErrorLog("select hrmresource error: " + query + Util.null2String(String.valueOf(employee.getUserID()))); diff --git a/src/main/resources/WEB-INF/config/ehcache.xml b/src/main/resources/WEB-INF/config/ehcache.xml new file mode 100644 index 0000000..dc6629b --- /dev/null +++ b/src/main/resources/WEB-INF/config/ehcache.xml @@ -0,0 +1,39 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/WEB-INF/log4j.xml b/src/main/resources/WEB-INF/log4j.xml index 8f2459b..1f26a27 100644 --- a/src/main/resources/WEB-INF/log4j.xml +++ b/src/main/resources/WEB-INF/log4j.xml @@ -3,7 +3,7 @@ - + diff --git a/src/main/resources/WEB-INF/log4jinit.properties b/src/main/resources/WEB-INF/log4jinit.properties index e653c74..6172096 100644 --- a/src/main/resources/WEB-INF/log4jinit.properties +++ b/src/main/resources/WEB-INF/log4jinit.properties @@ -172,3 +172,16 @@ log4j.appender.cus.layout=org.apache.log4j.PatternLayout log4j.appender.cus.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %m%n #log4j.appender.cuslog.Threshold = INFO log4j.additivity.cus=false + + +#cusAYH log \u81EA\u5B9A\u4E49\u65E5\u5FD7\u6587\u4EF6\u914D\u7F6EINFO,ERROR,WARN,DEBUG,cusAYH +log4j.logger.cusAYH=INFO,ERROR,WARN,DEBUG,cusAYH +log4j.additivity.cusAYH=false +log4j.appender.cusAYH=org.apache.log4j.DailyRollingFileAppender +log4j.appender.cusAYH.Encoding=UTF-8 +log4j.appender.cusAYH.DatePattern='_'yyyyMMdd'.log' +log4j.appender.cusAYH.File=@ayh/ayh_cus.log +log4j.appender.cusAYH.Threshold=DEBUG +log4j.appender.cusAYH.layout=org.apache.log4j.PatternLayout +log4j.appender.cusAYH.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [Thread:%t][%F.%M:%L] ==> : %m %x %n + diff --git a/src/main/resources/WEB-INF/sqllog/ecologysql b/src/main/resources/WEB-INF/sqllog/ecologysql new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/WEB-INF/web.xml b/src/main/resources/WEB-INF/web.xml new file mode 100644 index 0000000..79d66d2 --- /dev/null +++ b/src/main/resources/WEB-INF/web.xml @@ -0,0 +1,767 @@ + + + + + + + + + + + + WSessionClusterFilter + weaver.session.WSessionClusterFilter + + + WSessionClusterFilter + /* + + + + EncodingFilterWeaver + weaver.security.filter.EncodingFilter + + + EncodingFilterWeaver + /* + + + SecurityTransFilter + weaver.security.encryptedtrans.SecurityTransFilter + + + SecurityTransFilter + /* + + + CheckSensitiveFilter + com.engine.sensitive.biz.CheckSensitiveFilter + + + CheckSensitiveFilter + /* + + + WeaSsoIocComponentFilter + com.weaverboot.frame.ioc.filter.WeaSsoIocComponentFilter + + + WeaSsoIocComponentFilter + /api/* + + + WeaSsoIocComponentFilter + *.jsp + + + WeaSsoIocComponentFilter + *.html + + + EMFilter + com.cloudstore.dev.api.service.EMFilter + + + EMFilter + /* + + + SessionCloudFilter + com.cloudstore.dev.api.service.SessionFilter + + checkurl + /api/hrm/emmanager; + + + uncheckurl + /api/ec/dev/app/getCheckSystemInfo;/api/ec/dev/app/emjoin; + + + unchecksessionurl + + + + + SessionCloudFilter + /api/* + + + SessionCloudFilter + /page/interfaces/*.jsp + + + SessionCloudFilter + /workflow/core/ControlServlet.jsp + + + SecurityFilter + weaver.filter.SecurityFilter + + + SecurityFilter + /* + + + Compress + weaver.filter.WGzipFilter + + exclude + /wui/theme/ecology8/page/login.jsp;/login/login.jsp;/keygenerator/KeyGenerator.jsp;/keygenerator/getNoCheckFiles.jsp;/keygenerator/packNoCheckFiles.jsp;/workflow/request/WorkflowPDFStream.jsp;/keygenerator/packKeyCompareFiles.jsp;/mobile/plugin/Download.jsp + + + + Compress + *.js + + + Compress + *.css + + + Compress + /api/* + + + Compress + *.jsp + + + Compress + /weaver/weaver.common.util.taglib.SplitPageXmlServlet + + + Compress + /weaver/weaver.common.util.taglib.SplitPageXmlServletNew + + + Compress + /Messager/MessagerServlet + + + encodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + + + + + /browserTag + /WEB-INF/tld/browser.tld + + + /browser + /WEB-INF/tld/browser.tld + + + + IECompatibleFilter + weaver.filter.IECompatibleFilter + + + IECompatibleFilter + *.jsp + + + IECompatibleFilter + *.js + + + IECompatibleFilter + *.htm + + + IECompatibleFilter + *.html + + + ConnFastFilter + weaver.filter.ConnFastFilter + + + ConnFastFilter + *.jsp + + + ConnFastFilter + /weaver/weaver.common.util.taglib.SplitPageXmlServlet + + + ConnFastFilter + /weaver/weaver.common.util.taglib.SplitPageXmlServletNew + + + ConnFastFilter + /api/* + + + MultiLangFilter + weaver.filter.MultiLangFilter + + + MultiLangFilter + *.jsp + + + MultiLangFilter + /weaver/* + + + MultiLangFilter + /api/* + + + MultiLangFilter + /ReportServer + + + DialogHandleFilter + weaver.filter.DialogHandleFilter + + + DialogHandleFilter + *.jsp + + + WStatic + weaver.filter.WStaticFilter + + max-age + 86400000 + + + + WStatic + *.gif + + + WStatic + *.jpg + + + WStatic + *.png + + + WStatic + *.css + + + WStatic + *.js + + + WStatic + *.htm + + + WStatic + *.html + + + resin-ln + ln.LNFilter + + + resin-ln + *.* + + + InitServer + weaver.general.InitServer + + serverName + ecology + + 1 + + + dwr-invoker + uk.ltd.getahead.dwr.DWRServlet + + crossDomainSessionSecurity + false + + + allowScriptTagRemoting + true + + 1 + + + XFireServlet + XFire Servlet + org.codehaus.xfire.transport.http.XFireConfigurableServlet + + + XFireServlet + /services/* + + + CreateQRCodeServlet + weaver.workflow.exceldesign.CreateQRCodeServlet + + + CreateQRCodeServlet + /workflow/createQRCode + + + CreateQRCodeServlet + /createQRCode + + + ReplyFileDownload + weaver.docs.docs.reply.FileDownload + + + ReplyFileDownload + /weaver/weaver.docs.docs.reply.FileDownload + + + CreateWfBarCodeServlet + weaver.workflow.exceldesign.CreateBarCodeServlet + + + CreateWfBarCodeServlet + /workflow/createWfBarCode + + + CreateWfBarCodeServlet + /createWfBarCode + + + SplitPageXmlServlet + weaver.common.util.taglib.SplitPageXmlServlet + + + SplitPageXmlServletNew + weaver.common.util.taglib.SplitPageXmlServletNew + + + FileDownload + weaver.file.FileDownload + + + DownloadDeptLayoutServlet + weaver.org.layout.DownloadDeptLayoutServlet + + + DownloadWFLayoutServlet + weaver.workflow.layout.DownloadWFLayoutServlet + + + ShowDepLayoutToPicServlet + weaver.org.layout.ShowDepLayoutToPicServlet + + + ShowDocsImageServlet + weaver.docs.docs.ShowDocsImageServlet + + + ShowImgServlet + weaver.album.ShowImgServlet + + + HomePageServlet + weaver.homepage.HomepageCreateImage + + + Admin + org.logicalcobwebs.proxool.admin.servlet.AdminServlet + + + Admin + /admin + + + dwr-invoker + /dwr/* + + + SplitPageXmlServlet + /weaver/weaver.common.util.taglib.SplitPageXmlServlet + + + SplitPageXmlServletNew + /weaver/weaver.common.util.taglib.SplitPageXmlServletNew + + + FileDownload + /weaver/weaver.file.FileDownload + + + DownloadDeptLayoutServlet + /weaver/weaver.org.layout.DownloadDeptLayoutServlet + + + DownloadWFLayoutServlet + /weaver/weaver.workflow.layout.DownloadWFLayoutServlet + + + ShowDepLayoutToPicServlet + /weaver/weaver.org.layout.ShowDepLayoutToPicServlet + + + ShowDocsImageServlet + /weaver/weaver.docs.docs.ShowDocsImageServlet + + + ShowImgServlet + /weaver/weaver.album.ShowImgServlet + + + HomePageServlet + /weaver/weaver.homepage.HomepageCreateImage + + + WorkflowXmlParser + weaver.workflow.layout.WorkflowXmlParser + + + WorkflowXmlParser + /weaver/weaver.workflow.layout.WorkflowXmlParser + + + WorkflowDesignOperatoinServlet + weaver.workflow.layout.WorkflowDesignOperatoinServlet + + + WorkflowDesignOperatoinServlet + /weaver/weaver.workflow.layout.WorkflowDesignOperatoinServlet + + + ShowWorkFlow + weaver.workflow.workflow.ShowWorkFlow + + + ShowWorkFlow + /weaver/weaver.workflow.workflow.ShowWorkFlow + + + ExcelOut + weaver.file.ExcelOut + + + ExcelOut + /weaver/weaver.file.ExcelOut + + + MakeValidateCode + weaver.file.MakeValidateCode + + + MakeValidateCode + /weaver/weaver.file.MakeValidateCode + + + CreateExcelServer + weaver.common.util.taglib.CreateExcelServer + + + CreateExcelServer + /weaver/weaver.common.util.taglib.CreateExcelServer + + + SignatureDownLoad + weaver.file.SignatureDownLoad + + + SignatureDownLoad + /weaver/weaver.file.SignatureDownLoad + + + ImgFileDownload + weaver.file.ImgFileDownload + + + ImgFileDownload + /weaver/weaver.file.ImgFileDownload + + + xsd + text/xml + + + CloudStoreInit + com.cloudstore.api.util.Util_InitSys + 3 + + + restservlet + com.sun.jersey.spi.container.servlet.ServletContainer + + com.sun.jersey.config.property.packages + com.cloudstore;com.api + + + + restservlet + /api/* + + + InitFilter + weaver.filter.InitFilter + + + InitFilter + /wui/index.html + + + RsaInfo + weaver.rsa.GetRsaInfo + + + RsaInfo + /rsa/weaver.rsa.GetRsaInfo + + + FileNamingCheckFilter + weaver.file.FileNamingCheckFilter + + + FileNamingCheckFilter + *.jsp + + + FileNamingCheckFilter + /weaver/* + + + FileNamingCheckFilter + /api/* + + + AddressAccessFilter + com.engine.edc.web.AddressAccessFilter + + + AddressAccessFilter + /* + + + DateFormatFilter + weaver.dateformat.DateFormatFilter + + + DateFormatFilter + *.jsp + + + DateFormatFilter + /weaver/* + + + DateFormatFilter + /api/* + + + WeaComponentFilter + com.weaverboot.frame.ioc.filter.WeaComponentFilter + + + WeaComponentFilter + /api/* + + + WeaIocInitServlet + com.weaverboot.frame.ioc.prop.init.WeaIocInitServlet + 1 + + + WeaIocInitServlet + /weaIoc/init + + + EcodeInit + com.cloudstore.api.util.Util_InitEcode + 1 + + + HeartBeat + weaver.ofs.heartbeat.HeartBeat + + + HeartBeat + /HeartBeat + + + RestDispatcherServlet + weaver.rest.servlet.RestDispatcherServlet + + + RestDispatcherServlet + /rest/* + + + FileDownloadForNews + weaver.file.FileDownloadForNews + + + FileDownloadForNews + /weaver/weaver.file.FileDownloadForNews + + + QYSPrivateCallbackServlet + QYSPrivateCallbackServlet + weaver.workflow.qiyuesuo.servlet.QYSPrivateCallbackServlet + + + QYSPrivateCallbackServlet + /QYSPrivateCallbackServlet + + + QYSDownloadFileServlet + QYSDownloadFileServlet + weaver.workflow.qiyuesuo.servlet.QYSDownloadFileServlet + + + QYSDownloadFileServlet + /weaver/weaver.workflow.qiyuesuo.servlet.QYSDownloadFileServlet + + + QYSInitializeServlet + QYSInitializeServlet + weaver.workflow.qiyuesuo.servlet.QYSInitializeServlet + + + QYSInitializeServlet + /QYSInitializeServlet + + + VerifyLoginServlet + weaver.login.VerifyLoginServlet + + + VerifyLoginServlet + /weaver/weaver.login.VerifyLoginServlet + + + ShowColServlet + weaver.common.util.taglib.ShowColServlet + + + ShowColServlet + /weaver/weaver.common.util.taglib.ShowColServlet + + + InterfaceServlet + weaver.admincenter.servlet.InterfaceServlet + + + InterfaceServlet + /weaver/weaver.admincenter.servlet.InterfaceServlet + + + CreateBarCodeServlet + weaver.workflow.exceldesign.CreateBarCodeServlet + + + CreateBarCodeServlet + /createBarCode + + + CreateCptBarCode + weaver.cpt.barcode.BarCodeServlet + + + CreateCptBarCode + /CreateCptBarCode + + + MobilemodeApiServlet + com.weaver.formmodel.gateway.servlet.MobilemodeApiServlet + + apiBasicPath + /mobilemode/api + + + + MobilemodeApiServlet + /mobilemode/api/* + + + FileDownloadForEM + weaver.file.FileDownloadForEM + + + FileDownloadForEM + /weaver/weaver.file.FileDownloadForEM + + + 404 + /errorpage/404.htm + + + 500 + /errorpage/500.htm + + + 403 + /errorpage/403.htm + + + 503 + /errorpage/503.htm + + + 502 + /errorpage/502.htm + + + FileDownloadForWps + weaver.file.other.DownloadForTokenServlet + + + FileDownloadForWps + /weaver/weaver.file.FileDownloadForWps + + + ExpCardServer + weaver.formmode.expcard.servlet.ExpCardServer + + + ExpCardServer + /weaver/weaver.formmode.expcard.servlet.ExpCardServer + + + xls + application/octet-stream + + + xlsx + application/octet-stream + + + EdcFormViewServlet + com.engine.edc.web.EdcFormViewServlet + + + EdcFormViewServlet + /edc/formview/* + + + OfficeServer + DBstep.OfficeServer + + + OfficeServer + /OfficeServer + + + FileDownloadForOutDoc + weaver.file.FileDownloadForOutDoc + + + FileDownloadForOutDoc + /weaver/weaver.file.FileDownloadForOutDoc + + + FileDownloadLocation + weaver.email.FileDownloadLocation + + + FileDownloadLocation + /weaver/weaver.email.FileDownloadLocation + + diff --git a/src/main/resources/application.xml b/src/main/resources/application.xml new file mode 100644 index 0000000..a822a2b --- /dev/null +++ b/src/main/resources/application.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/pcn/copy/TestCopy.java b/src/test/java/pcn/copy/TestCopy.java index 5bb4540..5593ec7 100644 --- a/src/test/java/pcn/copy/TestCopy.java +++ b/src/test/java/pcn/copy/TestCopy.java @@ -2,14 +2,16 @@ package pcn.copy; import aiyh.utils.Util; import com.alibaba.fastjson.JSON; -import com.api.aiyh_pcn.multipleCopy.mapper.MultipleCopyMapper; -import com.api.aiyh_pcn.multipleCopy.pojo.CopyMultipleMain; -import com.api.aiyh_pcn.multipleCopy.services.MultipleCopyService; -import com.api.aiyh_pcn.multipleCopy.vo.MultipleCopyConfigVO; +import com.api.aiyh_logincheck.service.DynamicCodeService; +import com.api.aiyh_pcn.copy_multiple_file.mapper.MultipleCopyMapper; +import com.api.aiyh_pcn.copy_multiple_file.services.MultipleCopyService; +import com.api.aiyh_pcn.copy_multiple_file.vo.MultipleCopyConfigVO; +import com.cloudstore.dev.api.util.Util_DataCache; import org.apache.commons.lang.StringUtils; import org.junit.Before; import org.junit.Test; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -51,5 +53,36 @@ public class TestCopy { System.out.println(join); } + @Test + public void testLog() throws InterruptedException, IOException { + System.out.println(Util_DataCache.getObjValWithRedis("name")); + Util_DataCache.setObjValWithRedis("loginId","aiyh",2); + Object loginId = Util_DataCache.getObjValWithRedis("loginId"); + System.out.println(loginId); + + Util_DataCache.setObjVal("name","zhangshan",2); + Object name = Util_DataCache.getObjVal("name"); + System.out.println(name); + Thread.sleep(1000*5); + name = Util_DataCache.getObjVal("aiyh"); + System.out.println("获取名字" + name); + } + + @Test + public void test2(){ + String code = "aldfiu${code}".replaceAll("\\$\\{\\s*code\\s*}", "code"); + System.out.println(code); + } + + + @Test + public void test3(){ + DynamicCodeService dynamicCodeService = new DynamicCodeService(); + boolean aiyh = dynamicCodeService.getCode("aiyh"); + System.out.println(aiyh); + } + + + } diff --git a/src/test/java/unknow/CalculateOvertimeTest.java b/src/test/java/unknow/CalculateOvertimeTest.java new file mode 100644 index 0000000..dd33716 --- /dev/null +++ b/src/test/java/unknow/CalculateOvertimeTest.java @@ -0,0 +1,39 @@ +package unknow; + +import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; +import org.junit.Before; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import weaver.schedule.aiyh_calculate_overtime.entity.WorkdayInfo; +import weaver.schedule.aiyh_calculate_overtime.service.CalculateOvertimeService; + +/** + * create 2022/1/18 0018 23:59 + * + * @author EBU7-dev1-ayh + */ + + +public class CalculateOvertimeTest { + @Before + public void before() { + weaver.general.GCONST.setServerName("ecology"); + weaver.general.GCONST.setRootPath("H:\\ecology-9-dev\\src\\main\\resources\\"); + } + + + @Test + public void test(){ + CalculateOvertimeService calculateOvertimeService = new CalculateOvertimeService(); + WorkdayInfo workdayInfo = calculateOvertimeService.checkWorkday(); + System.out.println(workdayInfo); + } + + + @Test + public void test1(){ + ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml"); + WorkdayInfo workdayInfo = (WorkdayInfo) applicationContext.getBean("workdayInfo"); + System.out.println(workdayInfo); + } +} diff --git a/src/test/java/utilTest/UtilTest.java b/src/test/java/utilTest/UtilTest.java index cf1720b..4e06fdb 100644 --- a/src/test/java/utilTest/UtilTest.java +++ b/src/test/java/utilTest/UtilTest.java @@ -1,20 +1,32 @@ package utilTest; import aiyh.utils.Util; +import aiyh.utils.apirequest.entity.ParamConfigInfo; +import aiyh.utils.apirequest.pojo.ApiRequestMain; import aiyh.utils.entity.ApiConfigMainDTO; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl; import com.alibaba.fastjson.JSON; +import com.api.aiyh_guijiu.vo.PicPsVO; import com.api.aiyh_pcn.fadada.service.impl.FaDDContractService; +import com.drew.imaging.ImageMetadataReader; +import com.drew.imaging.ImageProcessingException; +import com.drew.metadata.Directory; +import com.drew.metadata.Metadata; +import com.drew.metadata.Tag; +import com.engine.doc.cmd.secCategoryList.DocSecCategoryAddCmd; import entity.ImageInfo; import mybatisTest.mapper.IMapperTest; import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; +import utilTest.entity.TestTreeEntity; import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; -import java.io.IOException; +import java.io.*; import java.lang.reflect.*; import java.util.*; import java.util.regex.Matcher; @@ -48,6 +60,31 @@ public class UtilTest { } } + // @Test + public static void main(String[] args) { + final int[] n = {5}; + Object o = new Object(); + Thread thread = new Thread(() -> { + System.out.println("啊法法大大方"); + synchronized (o) { + while (n[0] >= 0) { + System.out.println("妈的"); + n[0]--; + try { + o.wait(1000*2); + System.out.println("测试!"); +// Thread.sleep(1000 * 2); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }); + thread.start(); + System.out.println("main线程结束"); + + } + @Before public void before() { weaver.general.GCONST.setServerName("ecology"); @@ -177,7 +214,6 @@ public class UtilTest { } } - @Test public void builderSelect() { // 将以下数据插入到数据库中,比如 inset into name ,email values('update_name','update_email') @@ -216,7 +252,6 @@ public class UtilTest { System.out.println(imageInfos); } - @Test public void testSqlUtil() { // 获取代理对象 @@ -226,7 +261,6 @@ public class UtilTest { System.out.println(result); } - @Test public void testRequest() { // 构建工具实体 @@ -258,7 +292,6 @@ public class UtilTest { } - @Test public void testTerr() { FaDDContractService faDDContractService = new FaDDContractService(); @@ -272,12 +305,196 @@ public class UtilTest { System.out.println(JSON.toJSONString(maps)); } - @Test - public void te(){ + public void te() { String test = ",7629,7632,"; System.out.println(test.contains(",7632,")); } + @Test + public void testPs() throws FileNotFoundException { + PicPsVO picPsVO = PicPsVO.PicPsVOBuilder.aPicPsVO() + .docId(1) + .fileId(1) + .fileName("name") + .build(); +// 通过物理文件的id进行获取对应的输入流信息。 +// ImageFileManager imageFileManager = new ImageFileManager(); + // 通过文件id获取输入流 + InputStream inputStreamById = new FileInputStream("C:\\Users\\77449\\Desktop\\test.jpg"); + try { +// 获取媒体数据 + Metadata metadata = ImageMetadataReader.readMetadata(inputStreamById); +// 遍历Directory对象,每个对象里面包含标签 + for (Directory directory : metadata.getDirectories()) { + String directoryName = directory.getName(); + System.out.println(directory); + if ("Photoshop".equalsIgnoreCase(directoryName) || "Adobe JPEG".equalsIgnoreCase(directoryName) + || directoryName.contains("Adobe")) { + if (picPsVO.getScore() > 90) { + continue; + } + picPsVO.setDescribe("图片经过Adobe Photoshop软件,注意审核!"); + picPsVO.setScore(90); + } + String model = ""; + for (Tag tag : directory.getTags()) { + System.out.println(tag); + if (tag.getDescription() != null && tag.getDescription().toLowerCase().contains("Adobe".toLowerCase())) { + picPsVO.setDescribe("图片经过Adobe Photoshop软件,注意审核!"); + picPsVO.setScore(70); + if (picPsVO.getScore() > 70) { + continue; + } + } + if ("Software".equalsIgnoreCase(tag.getTagName())) { + if (tag.getDescription().toLowerCase().contains("Adobe".toLowerCase()) + || tag.getDescription().toLowerCase().contains("Photoshop".toLowerCase())) { + picPsVO.setDescribe("图片经过Adobe Photoshop软件,注意审核!"); + picPsVO.setScore(100); + } else { + if (picPsVO.getScore() > 70) { + continue; + } + picPsVO.setDescribe("图片经过" + tag.getDescription() + "软件,注意审核!"); + picPsVO.setScore(70); + } + if (!org.h2.util.StringUtils.isNullOrEmpty(model) && picPsVO.getDescribe().contains(model)) { + picPsVO.setDescribe(""); + picPsVO.setScore(-1); + } + } + if ("Model".equalsIgnoreCase(tag.getTagName())) { + model = tag.getDescription(); + if (!org.h2.util.StringUtils.isNullOrEmpty(picPsVO.getDescribe())) { + if (picPsVO.getDescribe().contains(tag.getDescription())) { + picPsVO.setDescribe(""); + picPsVO.setScore(-1); + } + } + } + if ("User Comment".equalsIgnoreCase(tag.getTagName())) { + try { + if (picPsVO.getScore() > 80) { + continue; + } + com.alibaba.fastjson.JSONObject.parseObject(tag.getDescription()); + picPsVO.setDescribe("图片经过手机端图片处理软件,软件未知!请注意审核!"); + picPsVO.setScore(80); + } catch (Exception e) { + if (picPsVO.getScore() > 40) { + continue; + } + picPsVO.setDescribe("图片可能经过未知软件!请注意审核!"); + picPsVO.setScore(40); + } + } + } + } + } catch (ImageProcessingException | IOException e) { + e.printStackTrace(); + } + System.out.println(picPsVO); + } + + @Test + public void testList2Tree() { + List list = new ArrayList<>(); + list.add(new TestTreeEntity("0", "根节点1", null)); + list.add(new TestTreeEntity("1", "根节点2", null)); + list.add(new TestTreeEntity("2", "根节点3", null)); + list.add(new TestTreeEntity("3", "子结点1.1", "0")); + list.add(new TestTreeEntity("4", "子结点5.1", "9")); + list.add(new TestTreeEntity("5", "子结点1.3", "0")); + list.add(new TestTreeEntity("6", "子结点1.2", "0")); + list.add(new TestTreeEntity("7", "子结点1.2.1", "6")); + list.add(new TestTreeEntity("8", "子结点2.1", "1")); + list.add(new TestTreeEntity("9", "根节点5", null)); + list.add(new TestTreeEntity("10", "子结点3.1", "2")); +// List treeList = Util.listToTree(list, TestTreeEntity::getParamName, TestTreeEntity::getParentName, (parent, child) -> { +// Optional.ofNullable(parent.getChildList()).map(v -> { +// v.add(child); +// return list; +// }).orElseGet(()->{ +// List childList = new ArrayList<>(); +// childList.add(child); +// parent.setChildList(childList); +// return null; +// }); +// }, parentName -> parentName == null || "".equals(parentName)); +// System.out.println(JSON.toJSONString(treeList)); + System.out.println("==================================="); + List list1 = Util.listToTree(list, TestTreeEntity::getParamName, + TestTreeEntity::getParentName, + TestTreeEntity::getChildList, TestTreeEntity::setChildList, + parentName -> parentName == null || "".equals(parentName)); + System.out.println(JSON.toJSONString(list1)); + } + + @Test + public void test3() { + User user = new User(1); + System.out.println(user.getUserSubCompany1()); + System.out.println(user.getUsername()); + Map createMap = new HashMap<>(4); + createMap.put("parentid", "89"); + createMap.put("categoryname", "使用代码测试创建测试缓存123"); + createMap.put("subcompanyid", String.valueOf(user.getUserSubCompany1())); + createMap.put("extendParentAttr", "1"); + DocSecCategoryAddCmd docSecCategoryAddcCmd = new DocSecCategoryAddCmd(createMap, user); + Map execute = docSecCategoryAddcCmd.execute(null); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + manageDetachComInfo.removeManageDetachCache(); + System.out.println(execute); + } + + @Test + public void scanFiles() { + ArrayList objects = scanFilesWithRecursion("F:\\fanwei"); + System.out.println(JSON.toJSONString(objects)); + } + + public ArrayList scanFilesWithRecursion(String folderPath) { + ArrayList scanFiles = new ArrayList<>(); + File directory = new File(folderPath); + if (!directory.isDirectory()) { + throw new RuntimeException("输入的路径不是一个文件夹! input path is not a folder!"); + } + if (directory.isDirectory()) { + File[] filelist = directory.listFiles(); + Optional.ofNullable(filelist).map(v -> { + for (File file : filelist) { + /*如果当前是文件夹,进入递归扫描文件夹*/ + if (file.isDirectory()) { + continue; + } + /*非文件夹*/ + else { + System.out.println(file.getName()); + scanFiles.add(file.getAbsolutePath()); + } + } + return v; + }); + + } + return scanFiles; + } + + @Test + public void testCopy(){ + ApiRequestMain apiRequestMain = new ApiRequestMain(); + apiRequestMain.setApiDesc("api描述"); + apiRequestMain.setApiType(2); + apiRequestMain.setApiUrl("http://www.baidu.com"); + apiRequestMain.setDataSource(2); + apiRequestMain.setModelTableName("modelTable"); + apiRequestMain.setId(20); + apiRequestMain.setParamRequestType(2); + apiRequestMain.setOnlyMark("onlyMark"); + ParamConfigInfo paramConfigInfo = new ParamConfigInfo(); + paramConfigInfo = Util.copyBeanBaseField(apiRequestMain, paramConfigInfo); + System.out.println(paramConfigInfo); + } } diff --git a/src/test/java/utilTest/entity/TestTreeEntity.java b/src/test/java/utilTest/entity/TestTreeEntity.java new file mode 100644 index 0000000..837274a --- /dev/null +++ b/src/test/java/utilTest/entity/TestTreeEntity.java @@ -0,0 +1,30 @@ +package utilTest.entity; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + *

+ *

create 2022/1/22 0022 18:49

+ * + * @author EBU7-dev1-ayh + */ + + +@Data +public class TestTreeEntity { + private String paramName; + private String desc; + + private String parentName; + + private List childList; + + public TestTreeEntity(String paramName, String desc, String parentName) { + this.paramName = paramName; + this.desc = desc; + this.parentName = parentName; + } +}