From 9e9ed8f0948cb870c6044a3b1dba7276de0e965f Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Fri, 7 Jul 2023 16:28:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8C=85=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=B7=9F=E8=B7=AF=E5=BE=84=E9=85=8D=E7=BD=AE=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/common/dev.js | 29 ++++ javascript/common/脚本.js | 6 +- .../youhong.ai/pcn/workflow_code_block.js | 159 ++++++++++++++++++ .../controller/ExamBtnControlController.java | 58 ++++++- .../mapper/ExamBtnControlMapper.java | 22 +++ .../service/ExamBtnControlService.java | 139 ++++++++++++++- .../impl/CompressDocPictureImpl.java | 33 +++- src/test/java/BuilderPackageEcology.java | 2 +- .../java/builderpackage/AutoPackageJar.java | 2 +- .../java/builderpackage/FileTreeBuilder.java | 15 +- 10 files changed, 440 insertions(+), 25 deletions(-) diff --git a/javascript/common/dev.js b/javascript/common/dev.js index 666912e..173e0ad 100644 --- a/javascript/common/dev.js +++ b/javascript/common/dev.js @@ -1,3 +1,6 @@ + + + const ecodeSDK = {} ecodeSDK.setCom = (id, name, Com) => { } @@ -44,6 +47,32 @@ const WfForm = { */ forceRenderField(field) { + }, + // 说明:手动触发一次字段涉及的所有联动,包括字段联动、SQL联动、日期时间计算、字段赋值、公式、行列规则、显示属性联动、选择框联动、bindPropertyChange事件绑定等 + // + // 场景:触发出的子流程打开默认不执行字段联动、归档节点查看表单不执行联动,可通过此接口实现 + // + // triggerFieldAllLinkage:function(fieldMark) + triggerFieldAllLinkage(s) { +//表单打开强制执行某字段的联动 +// jQuery(document).ready(function(){ +// WfForm.triggerFieldAllLinkage("field110"); //执行字段涉及的所有联动 +// }); + }, + // 5.2 删除明细表指定行/全部行 + // delDetailRow: function(detailMark, rowIndexMark) + // + // 说明:此方法会清空明细已选情况,删除时没有提示”是否删除”的确认框 + // + // 参数说明 + // + // 参数 参数类型 必须 说明 + // detailMark String 是 明细表标示,明细1就是detail_1,以此递增类推 + // rowIndexMark String 是 需要删除的行标示,删除全部行:all,删除部分行:”1,2,3” + delDetailRow(tableName, all) { + WfForm.delDetailRow("detail_1", "all"); //删除明细1所有行 + WfForm.delDetailRow("detail_1", "3,6"); //删除明细1行标为3,6的行 + } } WfForm.OPER_SAVE = '保存' diff --git a/javascript/common/脚本.js b/javascript/common/脚本.js index dffd9ee..435b629 100644 --- a/javascript/common/脚本.js +++ b/javascript/common/脚本.js @@ -23,7 +23,7 @@ wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); wf.changeFieldValue("100003720000008715", {value: '2'}); wf.changeFieldValue("877132351682273302", {value: '1'}); - let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"'); + let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"]'); let workflowTitle = workflowTitleObj.value; workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; const container = document.getElementById("widget_100003720000000664"); @@ -62,7 +62,9 @@ wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); wf.changeFieldValue("100003720000008715", {value: '4'}); wf.changeFieldValue("877132351682273302", {value: '1'}); - let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"'); + let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"]'); let workflowTitle = workflowTitleObj.value; workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; + window.open("/sp/workflow/flowpage/fullCreate/100003460000000746?workflowId=100003460000000746&isCreate=1", "_blank"); + document.querySelector("button[weid='3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_t03ihg@0_xomsa1@0']").click(); })() \ No newline at end of file diff --git a/javascript/youhong.ai/pcn/workflow_code_block.js b/javascript/youhong.ai/pcn/workflow_code_block.js index 114d081..8d9c82c 100644 --- a/javascript/youhong.ai/pcn/workflow_code_block.js +++ b/javascript/youhong.ai/pcn/workflow_code_block.js @@ -1,4 +1,7 @@ /* ******************* 保时捷target setting流程提交控制 start ******************* */ +import React from "react"; +import ReactDOM from "react-dom" + window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, { /** * @author youhong.ai @@ -999,3 +1002,159 @@ $(() => { }) /* ******************* youhong.ai 限制考试按钮点击 end ******************* */ + + +/* ******************* youhong.ai 随机抽取题库考题 start ******************* */ + +$(() => { + const config = { + table: '', + // 使用范围字段 + scopeOfUse: '', + // 类型明细表 + typeDetail: { + // 明细表名 + tableName: "", + // 类型字段 + typeField: '', + // 类型数量 + typeNumber: '', + // 类型数量字段 + typeTotalNumber: '' + }, + targetDetail: { + tableName: '', + testQuestionField: '' + } + } + + + /** + * 获取考题分类总数 + * @param scopeOfUse 大分类:管理员 与 普通员工 + */ + function getTestPaperTypeNumber(scopeOfUse) { + Utils.api({ + url: `/api/aiyh/exam-btn/control/count?scopeOfUse=${scopeOfUse}&groupField=${config.typeDetail.typeField}&scopeOfUseField=${config.scopeOfUse}&table=${config.table}` + }).then(res => { + if (res && res.code === 200) { + let typeNumber = res.data + // 监听类型变化 + WfForm.bindDetailFieldChangeEvent(WfForm.convertFieldNameToId(config.typeDetail.typeField, + config.typeDetail.tableName), (id, rowIndex, value) => { + let totalNumber = typeNumber[value] + // 更新总数字段 + WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.typeDetail.typeTotalNumber, + config.typeDetail.tableName) + "_" + rowIndex, { + value: totalNumber + }) + }) + } + }) + } + + /** + * 获取试题类型和数量 + * @param scopeOfUse 使用范围 + */ + function getTestPaper(scopeOfUse) { + getTestPaperTypeNumber(scopeOfUse) + } + + /** + * 生成随机试题 + */ + function extractTestQuestions() { + let detailAllRowIndexStr = WfForm.getDetailAllRowIndexStr(config.typeDetail.tableName); + let rowArr = detailAllRowIndexStr.split(","); + let typeNumberObj = {} + rowArr.forEach(item => { + let type = WfForm.getFieldValue(WfForm.convertFieldNameToId(config.typeDetail.typeField, config.typeDetail.tableName) + "_" + item); + let number = WfForm.getFieldValue(WfForm.convertFieldNameToId(config.typeDetail.typeNumber, config.typeDetail.tableName) + "_" + item); + if (number <= 0) { + return + } + typeNumberObj[type] = number + }) + let params = { + scopeOfUse: WfForm.getFieldValue(config.scopeOfUse), + groupField: config.typeDetail.typeField, + scopeOfUseField: config.scopeOfUse, + table: config.table, + questNumberMap: typeNumberObj + } + console.log('请求参数', params) + Utils.api({ + url: "/api/aiyh/exam-btn/control/random-test-questions", + data: JSON.stringify(params), + }).then(res => { + if (res && res.code == 200) { + let testQuestions = res.data + let n = 0; + WfForm.delDetailRow(config.targetDetail.tableName, "all"); + testQuestions.forEach(item => { + let fieldMark = WfForm.convertFieldNameToId(config.targetDetail.testQuestionField, config.targetDetail.tableName) + WfForm.addDetailRow(config.targetDetail.tableName, { + [fieldMark]: { + value: item.id, + specialobj: [{ + id: item.id, + name: item.name + }] + } + }) + WfForm.triggerFieldAllLinkage(fieldMark + "_" + n++) + }) + } + }) + } + + + function runJs() { + // 监听分类数量发生变化 + WfForm.bindFieldChangeEvent(WfForm.convertFieldNameToId(config.typeDetail.typeNumber, config.typeDetail.tableName), + (id, rowIndex, value) => { + if (value == '') { + return + } + let total = WfForm.getFieldValue(WfForm.convertFieldNameToId(config.typeDetail.typeTotalNumber, config.typeDetail.tableName) + "_" + rowIndex); + if (value > total) { + WfForm.showConfirm("抽题数不能大于总题数!", function () { + WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.typeDetail.typeNumber, config.typeDetail.tableName) + "_" + rowIndex, { + value: "" + }) + }); + } + }) + // 监听主表使用范围 + WfForm.bindFieldChangeEvent(WfForm.convertFieldNameToId(config.scopeOfUse), (obj, id, value) => { + if (value == '') { + return + } + getTestPaper(value) + }) + // 渲染生成抽取试题按钮 + const generateBtnNode = document.querySelector("#cus_generate_test_questions>span") + const {Button} = antd + ReactDOM.render(React.createElement(Button, { + type: "primary", + children: "抽取试题", + onClick: () => { + extractTestQuestions() + } + }), generateBtnNode) + $("#cus_generate_test_questions button").css({ + margin: "3px auto" + }) + $("#cus_generate_test_questions span").css("color", "#FFF") + } + + + runJs() +}) + + +/* ******************* youhong.ai 随机抽取题库考题 end ******************* */ + + + diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java index d13221f..ac45180 100644 --- a/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java @@ -10,10 +10,7 @@ import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import java.util.Map; @@ -32,6 +29,14 @@ public class ExamBtnControlController { private final ExamBtnControlService service = new ExamBtnControlService(); + /** + *

判断文档是否已读

+ * + * @param request 请求体 + * @param response 响应体 + * @param params 请求参数 + * @return 是否已读 + */ @Path("/is-read") @POST @Produces(MediaType.APPLICATION_JSON) @@ -46,4 +51,49 @@ public class ExamBtnControlController { return ApiResult.error("system error!"); } } + + + /** + *

获取对应使用范围的考题的考题类型对应的总考题数

+ * + * @param scopeOfUse 使用范围 + * @param groupField 分组字段 + * @param scopeOfUseField 使用范围字段 + * @param table 表 + * @return 考题数量 + */ + @Path("/count") + @GET + @Produces(MediaType.APPLICATION_JSON) + public String getTestQuestionCount(@QueryParam("scopeOfUse") String scopeOfUse, + @QueryParam("groupField") String groupField, + @QueryParam("scopeOfUseField") String scopeOfUseField, + @QueryParam("table") String table) { + try { + return ApiResult.success(service.getTestQuestionCount(scopeOfUse, groupField, scopeOfUseField, table)); + } catch (Exception e) { + log.error("is read doc error!\n" + Util.getErrString(e)); + return ApiResult.error("system error!"); + } + } + + /** + *

获取随机数量的考题

+ * + * @param params 请求参数 + * @return 随机考题合集 + */ + + @Path("/random-test-questions") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String randomTestQuestions(@RequestBody Map params) { + try { + return ApiResult.success(service.randomTestQuestions(params)); + } catch (Exception e) { + log.error("is read doc error!\n" + Util.getErrString(e)); + return ApiResult.error("system error!"); + } + } } diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java index 5911dd7..21f62f2 100644 --- a/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java @@ -42,4 +42,26 @@ public interface ExamBtnControlMapper { @Select("select id from docreadtag where userid = #{userId} and docid in ($t{docIds})") List selectReadTag(@ParamMapper("userId") int userId, @ParamMapper("docIds") String docIds); + + /** + *

查询角色成员信息

+ * + * @param roleId 角色id + * @return 角色成员 + */ + @Select("select resourceid from hrmrolemembers where roleid = #{roleId}") + List selectRoleMembers(String roleId); + + /** + *

查询对应使用范围的考题信息

+ * + * @param scopeOfUse 使用范围 + * @param scopeOfUseField 使用范围字段 + * @param table 表 + * @return 对应的使用范围的考题集合 + */ + @Select("select * from $t{table} where $t{scopeOfUseField} = #{scopeOfUse}") + List> selectTestQuestions(@ParamMapper("scopeOfUse") String scopeOfUse, + @ParamMapper("scopeOfUseField") String scopeOfUseField, + @ParamMapper("table") String table); } diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java index 96e2bea..7ebff6f 100644 --- a/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java @@ -7,13 +7,14 @@ import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import com.api.youhong.ai.pcn.examcontrol.mapper.ExamBtnControlMapper; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import weaver.hrm.User; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** - *

+ *

考题培训相关的service

* *

create: 2023/7/5 16:39

* @@ -26,6 +27,13 @@ public class ExamBtnControlService { private final ExamBtnControlMapper mapper = Util.getMapper(ExamBtnControlMapper.class); + /** + *

是否已读文档

+ * + * @param user 当前用户 + * @param params 请求参数 + * @return 是否已读 + */ public boolean isReadDoc(User user, Map params) { // 系统管理员可以直接考试 @@ -36,26 +44,151 @@ public class ExamBtnControlService { if (CollectionUtil.isEmpty(params)) { return false; } + // 获取角色id,当前角色所对应的所有人员不需要判断是否已读文档 + String roleId = Util.null2String(params.get("roleId")); + if (StrUtil.isNotBlank(roleId)) { + List roleMembers = mapper.selectRoleMembers(roleId); + if (CollectionUtil.isNotEmpty(roleMembers) && roleMembers.contains(user.getUID() + "")) { + return true; + } + } // 获取表名称 String tableName = Util.null2String(params.get("tableName")); String docIdField = Util.null2String(params.get("docIdField")); + // 获取条件 Map conditions = (Map) params.get("conditions"); if (CollectionUtil.isEmpty(conditions)) { return false; } + // 构建sql where条件 String where = MapperBuilderSql.builderWhereAnd(conditions, "where", true); if (StrUtil.isBlank(where)) { log.error("没有生成where条件!"); return false; } + // 查询满足条件的所有文档的docId List docIdList = mapper.selectDocIds(tableName, docIdField, where, conditions); if (CollectionUtil.isEmpty(docIdList)) { throw new CustomerException("没有查询到对应的文件ID信息,请检查sql!"); } + // 查询这些文档中哪些是当前用户已读的文档 List readIdList = mapper.selectReadTag(user.getUID(), Util.join(docIdList, ",")); if (CollectionUtil.isEmpty(readIdList)) { return false; } + // 如果已读文档长度等于待查验文档id的长度则表示全部已读 return readIdList.size() == docIdList.size(); } + + /** + *

获取考题数量

+ * + * @param scopeOfUse 考题使用范围 + * @param groupField 考题分组字段 + * @param scopeOfUseField 考试使用范围字段 + * @param table 表名称 + * @return 考题分组对应的数量 + */ + public Map getTestQuestionCount(String scopeOfUse, String groupField, + String scopeOfUseField, String table) { + // 查询考题 + Map>> collect = getTestQuestions(scopeOfUse, groupField, scopeOfUseField, table); + Map result = new HashMap<>(8); + // 考题分组统计数量 + for (Map.Entry>> entry : collect.entrySet()) { + String key = entry.getKey(); + result.put(Util.null2String(key), entry.getValue().size()); + } + return result; + } + + /** + *

获取使用范围内的所有考题信息

+ * + * @param scopeOfUse 使用范围 + * @param groupField 分组字段 + * @param scopeOfUseField 考题使用范围字段 + * @param table 表名称 + * @return 返回考题分组后信息 + */ + @NotNull + private Map>> getTestQuestions(String scopeOfUse, String groupField, String scopeOfUseField, String table) { + List> testQuestionList = mapper.selectTestQuestions(scopeOfUse, scopeOfUseField, table); + if (CollectionUtil.isEmpty(testQuestionList)) { + throw new CustomerException("没有查询到对应的题库试题"); + } + // 对考题进行分组 + return testQuestionList.stream() + .collect(Collectors.groupingBy(value -> Util.null2String(value.get(groupField)))); + } + + + /** + *

随机抽取题库试题

+ * + * @param params 请求参数 + * @return 随机试题 + */ + + public List> randomTestQuestions(Map params) { + // 获取请求参数 + String scopeOfUse = Util.null2String(params.get("scopeOfUse")); + String groupField = Util.null2String(params.get("groupField")); + String scopeOfUseField = Util.null2String(params.get("scopeOfUseField")); + String table = Util.null2String(params.get("table")); + // 获取每个分组对应的题目数量对应关系 + Map questNumberMap = (Map) params.get("questNumberMap"); + // 查询所有考题分组后信息 + Map>> testQuestionList = getTestQuestions(scopeOfUse, groupField, scopeOfUseField, table); + List> result = new ArrayList<>(); + // 循环考题对应数量获取随机考题 + for (Map.Entry entry : questNumberMap.entrySet()) { + String key = entry.getKey(); + List> maps = testQuestionList.get(key); + // 随机获取其中的n道题 + int n = Integer.parseInt(Util.null2String(questNumberMap.get(key))); + List> randomElements = pickRandomElements(maps, n); + result.addAll(randomElements); + } + return result; + } + + /** + *

随机在数组中抽取指定数量的元素

+ * + * @param list 源数组 + * @param n 指定数量 + * @return 随机元素 + */ + public List> pickRandomElements(List> list, int n) { + // 创建一个新的列表用于存储选定的元素 + List> selectedElements = new ArrayList<>(); + + // 创建一个随机数生成器 + Random random = new Random(); + + // 检查传入的列表是否为空或元素数量小于 n + if (list == null || list.isEmpty() || n <= 0 || n > list.size()) { + // 返回空列表,表示无法选择任何元素 + return selectedElements; + } + + // 从原始列表中随机选择 n 个元素 + for (int i = 0; i < n; i++) { + // 生成一个随机索引 + int randomIndex = random.nextInt(list.size()); + + // 根据随机索引获取对应的元素 + Map selectedElement = list.get(randomIndex); + + // 将选定的元素添加到结果列表中 + selectedElements.add(selectedElement); + + // 从原始列表中移除已选定的元素,避免重复选择 + list.remove(randomIndex); + } + + // 返回选定的元素列表 + return selectedElements; + } } diff --git a/src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java b/src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java index bfe25dd..60895f9 100644 --- a/src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java +++ b/src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java @@ -4,6 +4,7 @@ import aiyh.utils.Util; import aiyh.utils.entity.DocImageInfo; import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.api.doc.detail.util.DocDownloadCheckUtil; import com.customization.youhong.taibao.compresspicture.mapper.CompressDocPictureMapper; import com.customization.youhong.taibao.compresspicture.util.CompressPictureUtil; @@ -42,41 +43,55 @@ public class CompressDocPictureImpl { */ @WeaReplaceAfter(value = "/api/doc/save/save", order = 1) public String after(WeaAfterReplaceParam weaAfterReplaceParam) { - if (Objects.isNull(mapper)) { - mapper = Util.getMapper(CompressDocPictureMapper.class); - } - if (Objects.isNull(log)) { - log = Util.getLogger(); - } + String data = weaAfterReplaceParam.getData(); try { + // 初始化全局参数 + if (Objects.isNull(mapper)) { + mapper = Util.getMapper(CompressDocPictureMapper.class); + } + if (Objects.isNull(log)) { + log = Util.getLogger(); + } + // 获取请求参数 Map paramMap = weaAfterReplaceParam.getParamMap(); - String doccontent = Util.null2String(paramMap.get("doccontent")); - if (StrUtil.isBlank(doccontent)) { + String docContent = Util.null2String(paramMap.get("doccontent")); + if (StrUtil.isBlank(docContent)) { return data; } - List imgSrcList = CompressPictureUtil.parseImageSrc(doccontent); + // 获取其中的图片链接 + List imgSrcList = CompressPictureUtil.parseImageSrc(docContent); if (CollectionUtil.isEmpty(imgSrcList)) { return data; } + log.info("获取到的图片数据列表:" + JSON.toJSONString(imgSrcList)); + // 循环处理 for (String imgSrc : imgSrcList) { + // 获取加密的imgId String imageFileIdEncrypt = CompressPictureUtil.extractFileId(imgSrc); String imageFileId = DocDownloadCheckUtil.DncodeFileid(imageFileIdEncrypt); + // 查询附件信息 DocImageInfo docImageInfo = Util.selectImageInfoByImageId(imageFileId); if (StrUtil.isNotBlank(docImageInfo.getMiniImgPath())) { continue; } + // 获取文件流 InputStream inputStreamById = ImageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + // 压缩文件 InputStream quality = CompressPictureUtil.compressImage(inputStreamById, docImageInfo.getImageFileName(), Float.parseFloat(Util.getCusConfigValueNullOrEmpty("quality", "0.5"))); if (Objects.isNull(quality)) { + log.info("压缩文件失败!压缩文件名称: " + docImageInfo.getImageFileName()); + log.info("压缩文件信息:" + JSON.toJSONString(docImageInfo)); continue; } + // 生成压缩后的文件信息 int newImageFileId = Util.createFileByInputSteam(quality, docImageInfo.getImageFileName()); if (newImageFileId <= 0) { continue; } DocImageInfo newDocImageInfo = Util.selectImageInfoByImageId(Util.null2String(newImageFileId)); + log.info("压缩后文件信息:" + JSON.toJSONString(docImageInfo)); boolean flag = mapper.updateImageInfo(docImageInfo, newDocImageInfo); if (flag) { mapper.updateImageInfo(docImageInfo, newDocImageInfo); diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index e0f4b9c..82102f1 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -55,7 +55,7 @@ public class BuilderPackageEcology extends Application { try { FileCompressor.compressFiles(filePaths, outputFile.getAbsolutePath(), path -> { String rootPath = Util.class.getResource("/").getPath(); - rootPath = rootPath.split(File.separator + FileTreeBuilder.targetPath)[0] + File.separator + FileTreeBuilder.targetPath + "classes" + File.separator; + rootPath = rootPath.split(File.separator + FileTreeBuilder.targetPath)[0] + File.separator + FileTreeBuilder.targetPath + FileTreeBuilder.classPath; String replace = "/ecology/" + (isEcology ? "WEB-INF/classes/" : "classbean/"); if (path.endsWith(".jar")) { replace = "/ecology/WEB-INF/lib/"; diff --git a/src/test/java/builderpackage/AutoPackageJar.java b/src/test/java/builderpackage/AutoPackageJar.java index 4897ef2..be6d848 100644 --- a/src/test/java/builderpackage/AutoPackageJar.java +++ b/src/test/java/builderpackage/AutoPackageJar.java @@ -25,7 +25,7 @@ public class AutoPackageJar { public static void createJar(String targetPath) { String path = AutoPackageJar.class.getResource("").getPath(); - String finalPath = path.split(File.separator + targetPath)[0] + File.separator + targetPath + File.separator + "classes" + File.separator; + String finalPath = path.split(File.separator + targetPath)[0] + File.separator + targetPath + File.separator + FileTreeBuilder.classPath; createJar(finalPath + "aiyh", finalPath + "aiyh_utils.jar"); createJar(finalPath + "ebu7common", finalPath + "ebu7common.jar"); } diff --git a/src/test/java/builderpackage/FileTreeBuilder.java b/src/test/java/builderpackage/FileTreeBuilder.java index ee9dd68..6e5ad30 100644 --- a/src/test/java/builderpackage/FileTreeBuilder.java +++ b/src/test/java/builderpackage/FileTreeBuilder.java @@ -14,8 +14,11 @@ public class FileTreeBuilder { public static String targetPath; + public static String classPath; + public static FileInfo buildFileTree() { String directoryPath = "target"; + String classRootPath = ""; List blackList = new ArrayList<>(); Properties properties = new Properties(); @@ -35,16 +38,18 @@ public class FileTreeBuilder { } targetPath = directoryPath; } + classRootPath = properties.getProperty("classRootPath"); + classPath = classRootPath; List blacklistPrefixes = Arrays.asList( directoryPath + "generated-sources", directoryPath + "generated-test-sources", directoryPath + "test-classes", - directoryPath + "classes" + File.separator + "aiyh", - directoryPath + "classes" + File.separator + "ebu7common", - directoryPath + "classes" + File.separator + "ln", - directoryPath + "classes" + File.separator + "cus_getlog" + directoryPath + classRootPath + "aiyh", + directoryPath + classRootPath + "ebu7common", + directoryPath + classRootPath + "ln", + directoryPath + classRootPath + "cus_getlog" ); - AutoPackageJar.createJar(directoryPath); + AutoPackageJar.createJar(directoryPath, classRootPath); blackList.addAll(blacklistPrefixes); } catch (IOException e) { e.printStackTrace();