From bd56639b06737d407264600141e49e7c40174b7b Mon Sep 17 00:00:00 2001 From: IT-xiaoXiong <774495953@qq.com> Date: Wed, 12 Jan 2022 11:22:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=8D=E5=88=B6=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/aiyh_pcn/copyMultipeFile/index.js | 168 ++++++++++++++++ html/aiyh_pcn/流程代码块/index.js | 189 ++++++++++++++++++ src/test/java/utilTest/UtilsTest.java | 98 +++++++++ src/test/java/utilTest/entity/TestEntity.java | 20 ++ 4 files changed, 475 insertions(+) create mode 100644 html/aiyh_pcn/copyMultipeFile/index.js create mode 100644 html/aiyh_pcn/流程代码块/index.js create mode 100644 src/test/java/utilTest/UtilsTest.java create mode 100644 src/test/java/utilTest/entity/TestEntity.java diff --git a/html/aiyh_pcn/copyMultipeFile/index.js b/html/aiyh_pcn/copyMultipeFile/index.js new file mode 100644 index 0000000..31cb8c4 --- /dev/null +++ b/html/aiyh_pcn/copyMultipeFile/index.js @@ -0,0 +1,168 @@ +; + +// #region + +class Utils { + static request = (url, type = "GET", + data, isAsync = true, + success = () => { + }, error = (err) => { + console.log(err) + }, complete = () => { + }, + contentType = 'application/json', + beforeSend = () => { + }) => { + let options = { + url, + type, + dataType: "json", + contentType, + async: isAsync, + data, + beforeSend, + success, + error, + complete, + } + if (contentType === 'application/json') { + options.data = JSON.stringify(data) + } + return $.ajax(options) + } +} + +class CopyMultipleFile { + + configuration = { + browseBox: "", + detailList: [{ + modeFile: "", + workflowFile: "" + }], + modeTable: "", + workflowType: "" + } + oldBrowseBoxValue = null + baseInfo = { + f_weaver_belongto_userid: "1", + f_weaver_belongto_usertype: "0", + formid: 0, + isbill: "1", + languageid: 7, + nodeid: 0, + requestid: "-1", + workflowid: 0, + } + + constructor(_configuration) { + this.configuration = _configuration + this.baseInfo = WfForm.getBaseInfo() + } + + /** + * 转换字段名为字段id + * @param fieldName 字段名 + * @returns {*} 字段id + */ + convertField2Id(fieldName) { + return WfForm.convertFieldNameToId(fieldName) + } + + /** + * 绑定浏览框改变触发事件 + * @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: '', + specialobj: { + filedatas: [] + } + }) + }) + Utils.request(`/api/browseBox/multipleCopy/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/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("复制模板文件失败!") + } + } + }) + } +} + + +class CopyMultipleFileBuilder { + + configuration = [] + + constructor() { + this.workflowId = WfForm.getBaseInfo().workflowid + this.init() + } + + async init() { + // 获取配置信息 + let result = await Utils.request(`/api/browseBox/multipleCopy/getConfig/${this.workflowId}`, "GET"); + if (result && result.code == 200) { + this.configuration = result.data + this.configuration.forEach(item => { + let copyMultipleFile = new CopyMultipleFile(item); + copyMultipleFile.bindBrowseBoxChangeEvent() + }) + } else { + antd.message.error("请求模板复制信息失败!") + console.log(result) + } + } +} + +$(() => { + new CopyMultipleFileBuilder() +}) \ No newline at end of file diff --git a/html/aiyh_pcn/流程代码块/index.js b/html/aiyh_pcn/流程代码块/index.js new file mode 100644 index 0000000..2066a8c --- /dev/null +++ b/html/aiyh_pcn/流程代码块/index.js @@ -0,0 +1,189 @@ +// +//#region 法务预算审核流程 明细表数据计算 + +/** + * 转换字段名为字段id + * @param fieldName 字段名 + * @param detail 表 + * @returns {*} 字段id + */ +function convertField2Id(fieldName, detail = "main") { + return WfForm.convertFieldNameToId(fieldName, detail) +} + +/** + * 统计第一个明细表数据 + * @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)) + 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' + } +// 删除所有信息 + + if ((WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? "") !== "") { + return + // WfForm.delDetailRow(config.detailTableSimple, "all"); + } + // 赋值 + sumMap.forEach((value, key) => { + let valueObj = { + [convertField2Id(config.groupField, config.detailTableSimple)]: { + value: key + }, + [convertField2Id(config.sumField, config.detailTableSimple)]: { + value: value + }, + } + WfForm.addDetailRow(config.detailTableSimple, valueObj); + }) +} + +/** + * 注册监听提交和保存事件 + */ +WfForm.registerCheckEvent(WfForm.OPER_SAVE + "," + WfForm.OPER_SUBMIT, function (callback) { + let sumMap = statisticalDetailTableData() + assignmentDetailTable2(sumMap) + callback(); +}); + + + +//#endregion +// (╰_╯)#(╰_╯)# + + +// ================================================================================ + + +// + +// + +/** + * 转换字段名为字段id + * @param fieldName 字段名 + * @param detail 表 + * @returns {*} 字段id + */ +function convertField2Id(fieldName, detail = "main") { + return WfForm.convertFieldNameToId(fieldName, detail) +} + + +/** + * 根据明细2中的折扣还是啥,不清楚,计算明细1中的实际钱? + * @param discountMap + */ +function calculateDiscountDetail1(discountMap) { + let config = { + groupField: "sqrbm", + discountField: 'spys', + costCountField: 'fyygrmb', + detailTable: 'formtable_main_173_dt1', + detailTableSimple: 'detail_1' + } + let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(","); + let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple) + let discountFieldMark = convertField2Id(config.discountField, config.detailTableSimple) + let costCountFieldMark = convertField2Id(config.costCountField, config.detailTableSimple) + for (let i = 0; i < rowArr.length; i++) { + let groupFieldId = groupFieldMark + "_" + rowArr[i] + let discountFieldId = discountFieldMark + "_" + rowArr[i] + let costCountFieldId = costCountFieldMark + "_" + rowArr[i] + let groupFieldValue = WfForm.getFieldValue(groupFieldId) + let costCountFieldValue = parseInt(WfForm.getFieldValue(costCountFieldId)) + // console.log(discountMap.get(groupFieldValue) * costCountFieldValue) + //修改值 + WfForm.changeFieldValue(discountFieldId, { + value: discountMap[groupFieldValue] * costCountFieldValue + }); + } +} + + +/** + * 获取明细表2的折扣啥的不知道,反正就是这几个字段 + * @returns {{}} + */ +function getDiscountByDetail2() { + let config = { + groupField: "sqrbm", + discountField: 'spys', + detailTable: 'formtable_main_173_dt2', + detailTableSimple: 'detail_2' + } + let discountMap = {} + let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(","); + let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple) + let discountFieldMark = convertField2Id(config.discountField, config.detailTableSimple) + for (let i = 0; i < rowArr.length; i++) { + let groupFieldId = groupFieldMark + "_" + rowArr[i] + let discountFieldId = discountFieldMark + "_" + rowArr[i] + let groupFieldValue = WfForm.getFieldValue(groupFieldId) + discountMap[groupFieldValue] = parseFloat(WfForm.getFieldValue(discountFieldId)) / 100 + } + return discountMap +} + +/** + * 绑定明细表事件,监听字段改变时触发计算 + */ +function bindEvent() { + let config = { + changeField: 'spys', + detailTable: 'formtable_main_173_dt2', + detailTableSimple: 'detail_2' + } + WfForm.bindDetailFieldChangeEvent(convertField2Id(config.changeField, config.detailTableSimple), () => { + let discountMap = getDiscountByDetail2(); + calculateDiscountDetail1(discountMap) + }) +} + +$(()=>{ + //页面加载时执行一次 + let discountMap = getDiscountByDetail2(); + calculateDiscountDetail1(discountMap) + bindEvent() +}) +// + + diff --git a/src/test/java/utilTest/UtilsTest.java b/src/test/java/utilTest/UtilsTest.java new file mode 100644 index 0000000..b07f677 --- /dev/null +++ b/src/test/java/utilTest/UtilsTest.java @@ -0,0 +1,98 @@ +package utilTest; + +import aiyh.utils.Util; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.staticUtil.HttpStaticUtils; +import aiyh.utils.httpUtil.util.HttpUtils; +import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl; +import aiyh.utils.sqlUtil.whereUtil.Where; +import aiyh.utils.zwl.common.ToolUtil; +import org.junit.Before; +import org.junit.Test; +import utilTest.entity.TestEntity; +import weaver.conn.RecordSet; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * create 2022/1/10 0010 19:47 + * 工具测试 + * + * @author EBU7-dev1-ayh + */ + + +public class UtilsTest { + @Before + public void before() { + weaver.general.GCONST.setServerName("ecology"); + weaver.general.GCONST.setRootPath("H:\\ecology-9-dev\\src\\main\\resources\\"); + } + + + @Test + public void test(){ + Map map = new HashMap<>(); + map.put("name","test"); + map.put("age",10); + map.put("sex","nan"); + PrepSqlResultImpl sqlResult = Util.createSqlBuilder().insertSql("tatble1", map); + System.out.println(sqlResult.getSqlStr()); + System.out.println(sqlResult.getArgs()); + + Where where = Util.createPrepWhereImpl().whereAnd("id") + .whereEqual(10).whereAnd("name").whereNotEqual("zhangsan"); + PrepSqlResultImpl sqlResult1 = Util.createSqlBuilder().updateSql("table1", map, where); + System.out.println(sqlResult1.getSqlStr()); + System.out.println(sqlResult1.getArgs()); +// RecordSet rs = new RecordSet(); +// rs.executeBatchSql(sqlResult.getSqlStr(),sqlResult.getArgs()); + } + + @Test + public void test1(){ + UtilsTestMapper mapper = Util.getMapper(UtilsTestMapper.class); + List> maps = mapper.selectAll(); + System.out.println(maps); + + TestEntity stringObjectMap = mapper.selectOne("select * from uf_copy_multiple where id = #{id}",2); + System.out.println(stringObjectMap); + Map map = new HashMap<>(); + map.put("name","test"); + map.put("age",10); + map.put("sex","nan"); + mapper.selectOneByMap(map); +// Map stringObjectMap1 = Util.recordSet2Map(rs,false); +// Util.recordSet2MapList(rs,false); +// TestEntity testEntity = Util.recordeSet2Entity(rs, TestEntity.class); +// List testEntities = Util.recordeSet2Array(rs, TestEntity.class); +// List strings = Util.recordeSet2Array(rs, String.class); +// List integers = Util.recordeSet2Array(rs, Integer.class); + } + + + @Test + public void test2() throws IOException { + ToolUtil toolUtil = new ToolUtil(); + toolUtil.writeDebuggerLog("日志信息"); +// String dev_param = toolUtil.getSystemParamValue("dev_param"); +// System.out.println(dev_param); +// Util.readProperties2Map() + +// HttpUtils httpUtils = new HttpUtils(); +//// httpUtils.getGlobalCache().header.put("appkey","aklsdddfuieaklu"); +//// httpUtils.getGlobalCache().paramMap.put("appkey","aklsdddfuieaklu"); +// Map map = new HashMap<>(); +// map.put("city","%E4%B8%8A%E6%B5%B7"); +// map.put("key","6d29ea420d50dc38b85bd07b893982f3"); +// httpUtils.apiGet("http://apis.juhe.cn/simpleWeather/query", map,null, response->{ +// }); +// +//// TestEntity entity = responeVo.getEntity(TestEntity.class); + +// HttpStaticUtils.api + } +} diff --git a/src/test/java/utilTest/entity/TestEntity.java b/src/test/java/utilTest/entity/TestEntity.java new file mode 100644 index 0000000..5c8435b --- /dev/null +++ b/src/test/java/utilTest/entity/TestEntity.java @@ -0,0 +1,20 @@ +package utilTest.entity; + +import aiyh.utils.annotation.DateFormatAn; +import lombok.Data; + +import java.util.Date; + +/** + * create 2022/1/10 0010 20:11 + * + * @author EBU7-dev1-ayh + */ + +@Data +public class TestEntity { + String browseBox; + Integer workflowType; + @DateFormatAn("yyyy-MM-dd") + Date modedatacreatedate; +}