修改打包工具跟路径配置必须配置

dev
youhong.ai 2023-07-07 16:28:43 +08:00
parent 96c6e7f727
commit 9e9ed8f094
10 changed files with 440 additions and 25 deletions

View File

@ -1,3 +1,6 @@
<script src="/cloudstore/release/caa2c848ca50448b882137cb82ffb9a5/index.js"></script>
const ecodeSDK = {} const ecodeSDK = {}
ecodeSDK.setCom = (id, name, Com) => { ecodeSDK.setCom = (id, name, Com) => {
} }
@ -44,6 +47,32 @@ const WfForm = {
*/ */
forceRenderField(field) { 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,删除部分行”123”
delDetailRow(tableName, all) {
WfForm.delDetailRow("detail_1", "all"); //删除明细1所有行
WfForm.delDetailRow("detail_1", "3,6"); //删除明细1行标为3,6的行
} }
} }
WfForm.OPER_SAVE = '保存' WfForm.OPER_SAVE = '保存'

View File

@ -23,7 +23,7 @@
wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); wf.changeFieldValue("100003720000000611", {value: "外出技术支持"});
wf.changeFieldValue("100003720000008715", {value: '2'}); wf.changeFieldValue("100003720000008715", {value: '2'});
wf.changeFieldValue("877132351682273302", {value: '1'}); 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; let workflowTitle = workflowTitleObj.value;
workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay;
const container = document.getElementById("widget_100003720000000664"); const container = document.getElementById("widget_100003720000000664");
@ -62,7 +62,9 @@
wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); wf.changeFieldValue("100003720000000611", {value: "外出技术支持"});
wf.changeFieldValue("100003720000008715", {value: '4'}); wf.changeFieldValue("100003720000008715", {value: '4'});
wf.changeFieldValue("877132351682273302", {value: '1'}); 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; let workflowTitle = workflowTitleObj.value;
workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; 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();
})() })()

View File

@ -1,4 +1,7 @@
/* ******************* 保时捷target setting流程提交控制 start ******************* */ /* ******************* 保时捷target setting流程提交控制 start ******************* */
import React from "react";
import ReactDOM from "react-dom"
window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, { window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, {
/** /**
* @author youhong.ai * @author youhong.ai
@ -999,3 +1002,159 @@ $(() => {
}) })
/* ******************* youhong.ai 限制考试按钮点击 end ******************* */ /* ******************* 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 ******************* */

View File

@ -10,10 +10,7 @@ import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes; import javax.ws.rs.*;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Map; import java.util.Map;
@ -32,6 +29,14 @@ public class ExamBtnControlController {
private final ExamBtnControlService service = new ExamBtnControlService(); private final ExamBtnControlService service = new ExamBtnControlService();
/**
* <h2></h2>
*
* @param request
* @param response
* @param params
* @return
*/
@Path("/is-read") @Path("/is-read")
@POST @POST
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -46,4 +51,49 @@ public class ExamBtnControlController {
return ApiResult.error("system error!"); return ApiResult.error("system error!");
} }
} }
/**
* <h2>使</h2>
*
* @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!");
}
}
/**
* <h2></h2>
*
* @param params
* @return
*/
@Path("/random-test-questions")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String randomTestQuestions(@RequestBody Map<String, Object> 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!");
}
}
} }

View File

@ -42,4 +42,26 @@ public interface ExamBtnControlMapper {
@Select("select id from docreadtag where userid = #{userId} and docid in ($t{docIds})") @Select("select id from docreadtag where userid = #{userId} and docid in ($t{docIds})")
List<Integer> selectReadTag(@ParamMapper("userId") int userId, List<Integer> selectReadTag(@ParamMapper("userId") int userId,
@ParamMapper("docIds") String docIds); @ParamMapper("docIds") String docIds);
/**
* <h2></h2>
*
* @param roleId id
* @return
*/
@Select("select resourceid from hrmrolemembers where roleid = #{roleId}")
List<String> selectRoleMembers(String roleId);
/**
* <h2>使</h2>
*
* @param scopeOfUse 使
* @param scopeOfUseField 使
* @param table
* @return 使
*/
@Select("select * from $t{table} where $t{scopeOfUseField} = #{scopeOfUse}")
List<Map<String, Object>> selectTestQuestions(@ParamMapper("scopeOfUse") String scopeOfUse,
@ParamMapper("scopeOfUseField") String scopeOfUseField,
@ParamMapper("table") String table);
} }

View File

@ -7,13 +7,14 @@ import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import com.api.youhong.ai.pcn.examcontrol.mapper.ExamBtnControlMapper; import com.api.youhong.ai.pcn.examcontrol.mapper.ExamBtnControlMapper;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import weaver.hrm.User; import weaver.hrm.User;
import java.util.List; import java.util.*;
import java.util.Map; import java.util.stream.Collectors;
/** /**
* <h1></h1> * <h1>service</h1>
* *
* <p>create: 2023/7/5 16:39</p> * <p>create: 2023/7/5 16:39</p>
* *
@ -26,6 +27,13 @@ public class ExamBtnControlService {
private final ExamBtnControlMapper mapper = Util.getMapper(ExamBtnControlMapper.class); private final ExamBtnControlMapper mapper = Util.getMapper(ExamBtnControlMapper.class);
/**
* <h2></h2>
*
* @param user
* @param params
* @return
*/
public boolean isReadDoc(User user, Map<String, Object> params) { public boolean isReadDoc(User user, Map<String, Object> params) {
// 系统管理员可以直接考试 // 系统管理员可以直接考试
@ -36,26 +44,151 @@ public class ExamBtnControlService {
if (CollectionUtil.isEmpty(params)) { if (CollectionUtil.isEmpty(params)) {
return false; return false;
} }
// 获取角色id当前角色所对应的所有人员不需要判断是否已读文档
String roleId = Util.null2String(params.get("roleId"));
if (StrUtil.isNotBlank(roleId)) {
List<String> roleMembers = mapper.selectRoleMembers(roleId);
if (CollectionUtil.isNotEmpty(roleMembers) && roleMembers.contains(user.getUID() + "")) {
return true;
}
}
// 获取表名称 // 获取表名称
String tableName = Util.null2String(params.get("tableName")); String tableName = Util.null2String(params.get("tableName"));
String docIdField = Util.null2String(params.get("docIdField")); String docIdField = Util.null2String(params.get("docIdField"));
// 获取条件
Map<String, Object> conditions = (Map<String, Object>) params.get("conditions"); Map<String, Object> conditions = (Map<String, Object>) params.get("conditions");
if (CollectionUtil.isEmpty(conditions)) { if (CollectionUtil.isEmpty(conditions)) {
return false; return false;
} }
// 构建sql where条件
String where = MapperBuilderSql.builderWhereAnd(conditions, "where", true); String where = MapperBuilderSql.builderWhereAnd(conditions, "where", true);
if (StrUtil.isBlank(where)) { if (StrUtil.isBlank(where)) {
log.error("没有生成where条件"); log.error("没有生成where条件");
return false; return false;
} }
// 查询满足条件的所有文档的docId
List<String> docIdList = mapper.selectDocIds(tableName, docIdField, where, conditions); List<String> docIdList = mapper.selectDocIds(tableName, docIdField, where, conditions);
if (CollectionUtil.isEmpty(docIdList)) { if (CollectionUtil.isEmpty(docIdList)) {
throw new CustomerException("没有查询到对应的文件ID信息请检查sql"); throw new CustomerException("没有查询到对应的文件ID信息请检查sql");
} }
// 查询这些文档中哪些是当前用户已读的文档
List<Integer> readIdList = mapper.selectReadTag(user.getUID(), Util.join(docIdList, ",")); List<Integer> readIdList = mapper.selectReadTag(user.getUID(), Util.join(docIdList, ","));
if (CollectionUtil.isEmpty(readIdList)) { if (CollectionUtil.isEmpty(readIdList)) {
return false; return false;
} }
// 如果已读文档长度等于待查验文档id的长度则表示全部已读
return readIdList.size() == docIdList.size(); return readIdList.size() == docIdList.size();
} }
/**
* <h2></h2>
*
* @param scopeOfUse 使
* @param groupField
* @param scopeOfUseField 使
* @param table
* @return
*/
public Map<String, Integer> getTestQuestionCount(String scopeOfUse, String groupField,
String scopeOfUseField, String table) {
// 查询考题
Map<String, List<Map<String, Object>>> collect = getTestQuestions(scopeOfUse, groupField, scopeOfUseField, table);
Map<String, Integer> result = new HashMap<>(8);
// 考题分组统计数量
for (Map.Entry<String, List<Map<String, Object>>> entry : collect.entrySet()) {
String key = entry.getKey();
result.put(Util.null2String(key), entry.getValue().size());
}
return result;
}
/**
* <h2>使</h2>
*
* @param scopeOfUse 使
* @param groupField
* @param scopeOfUseField 使
* @param table
* @return
*/
@NotNull
private Map<String, List<Map<String, Object>>> getTestQuestions(String scopeOfUse, String groupField, String scopeOfUseField, String table) {
List<Map<String, Object>> 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))));
}
/**
* <h2></h2>
*
* @param params
* @return
*/
public List<Map<String, Object>> randomTestQuestions(Map<String, Object> 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<String, Object> questNumberMap = (Map<String, Object>) params.get("questNumberMap");
// 查询所有考题分组后信息
Map<String, List<Map<String, Object>>> testQuestionList = getTestQuestions(scopeOfUse, groupField, scopeOfUseField, table);
List<Map<String, Object>> result = new ArrayList<>();
// 循环考题对应数量获取随机考题
for (Map.Entry<String, Object> entry : questNumberMap.entrySet()) {
String key = entry.getKey();
List<Map<String, Object>> maps = testQuestionList.get(key);
// 随机获取其中的n道题
int n = Integer.parseInt(Util.null2String(questNumberMap.get(key)));
List<Map<String, Object>> randomElements = pickRandomElements(maps, n);
result.addAll(randomElements);
}
return result;
}
/**
* <h2></h2>
*
* @param list
* @param n
* @return
*/
public List<Map<String, Object>> pickRandomElements(List<Map<String, Object>> list, int n) {
// 创建一个新的列表用于存储选定的元素
List<Map<String, Object>> 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<String, Object> selectedElement = list.get(randomIndex);
// 将选定的元素添加到结果列表中
selectedElements.add(selectedElement);
// 从原始列表中移除已选定的元素,避免重复选择
list.remove(randomIndex);
}
// 返回选定的元素列表
return selectedElements;
}
} }

View File

@ -4,6 +4,7 @@ import aiyh.utils.Util;
import aiyh.utils.entity.DocImageInfo; import aiyh.utils.entity.DocImageInfo;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.api.doc.detail.util.DocDownloadCheckUtil; import com.api.doc.detail.util.DocDownloadCheckUtil;
import com.customization.youhong.taibao.compresspicture.mapper.CompressDocPictureMapper; import com.customization.youhong.taibao.compresspicture.mapper.CompressDocPictureMapper;
import com.customization.youhong.taibao.compresspicture.util.CompressPictureUtil; import com.customization.youhong.taibao.compresspicture.util.CompressPictureUtil;
@ -42,41 +43,55 @@ public class CompressDocPictureImpl {
*/ */
@WeaReplaceAfter(value = "/api/doc/save/save", order = 1) @WeaReplaceAfter(value = "/api/doc/save/save", order = 1)
public String after(WeaAfterReplaceParam weaAfterReplaceParam) { public String after(WeaAfterReplaceParam weaAfterReplaceParam) {
String data = weaAfterReplaceParam.getData();
try {
// 初始化全局参数
if (Objects.isNull(mapper)) { if (Objects.isNull(mapper)) {
mapper = Util.getMapper(CompressDocPictureMapper.class); mapper = Util.getMapper(CompressDocPictureMapper.class);
} }
if (Objects.isNull(log)) { if (Objects.isNull(log)) {
log = Util.getLogger(); log = Util.getLogger();
} }
String data = weaAfterReplaceParam.getData(); // 获取请求参数
try {
Map<String, Object> paramMap = weaAfterReplaceParam.getParamMap(); Map<String, Object> paramMap = weaAfterReplaceParam.getParamMap();
String doccontent = Util.null2String(paramMap.get("doccontent")); String docContent = Util.null2String(paramMap.get("doccontent"));
if (StrUtil.isBlank(doccontent)) { if (StrUtil.isBlank(docContent)) {
return data; return data;
} }
List<String> imgSrcList = CompressPictureUtil.parseImageSrc(doccontent); // 获取其中的图片链接
List<String> imgSrcList = CompressPictureUtil.parseImageSrc(docContent);
if (CollectionUtil.isEmpty(imgSrcList)) { if (CollectionUtil.isEmpty(imgSrcList)) {
return data; return data;
} }
log.info("获取到的图片数据列表:" + JSON.toJSONString(imgSrcList));
// 循环处理
for (String imgSrc : imgSrcList) { for (String imgSrc : imgSrcList) {
// 获取加密的imgId
String imageFileIdEncrypt = CompressPictureUtil.extractFileId(imgSrc); String imageFileIdEncrypt = CompressPictureUtil.extractFileId(imgSrc);
String imageFileId = DocDownloadCheckUtil.DncodeFileid(imageFileIdEncrypt); String imageFileId = DocDownloadCheckUtil.DncodeFileid(imageFileIdEncrypt);
// 查询附件信息
DocImageInfo docImageInfo = Util.selectImageInfoByImageId(imageFileId); DocImageInfo docImageInfo = Util.selectImageInfoByImageId(imageFileId);
if (StrUtil.isNotBlank(docImageInfo.getMiniImgPath())) { if (StrUtil.isNotBlank(docImageInfo.getMiniImgPath())) {
continue; continue;
} }
// 获取文件流
InputStream inputStreamById = ImageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); InputStream inputStreamById = ImageFileManager.getInputStreamById(Integer.parseInt(imageFileId));
// 压缩文件
InputStream quality = CompressPictureUtil.compressImage(inputStreamById, docImageInfo.getImageFileName(), InputStream quality = CompressPictureUtil.compressImage(inputStreamById, docImageInfo.getImageFileName(),
Float.parseFloat(Util.getCusConfigValueNullOrEmpty("quality", "0.5"))); Float.parseFloat(Util.getCusConfigValueNullOrEmpty("quality", "0.5")));
if (Objects.isNull(quality)) { if (Objects.isNull(quality)) {
log.info("压缩文件失败!压缩文件名称: " + docImageInfo.getImageFileName());
log.info("压缩文件信息:" + JSON.toJSONString(docImageInfo));
continue; continue;
} }
// 生成压缩后的文件信息
int newImageFileId = Util.createFileByInputSteam(quality, docImageInfo.getImageFileName()); int newImageFileId = Util.createFileByInputSteam(quality, docImageInfo.getImageFileName());
if (newImageFileId <= 0) { if (newImageFileId <= 0) {
continue; continue;
} }
DocImageInfo newDocImageInfo = Util.selectImageInfoByImageId(Util.null2String(newImageFileId)); DocImageInfo newDocImageInfo = Util.selectImageInfoByImageId(Util.null2String(newImageFileId));
log.info("压缩后文件信息:" + JSON.toJSONString(docImageInfo));
boolean flag = mapper.updateImageInfo(docImageInfo, newDocImageInfo); boolean flag = mapper.updateImageInfo(docImageInfo, newDocImageInfo);
if (flag) { if (flag) {
mapper.updateImageInfo(docImageInfo, newDocImageInfo); mapper.updateImageInfo(docImageInfo, newDocImageInfo);

View File

@ -55,7 +55,7 @@ public class BuilderPackageEcology extends Application {
try { try {
FileCompressor.compressFiles(filePaths, outputFile.getAbsolutePath(), path -> { FileCompressor.compressFiles(filePaths, outputFile.getAbsolutePath(), path -> {
String rootPath = Util.class.getResource("/").getPath(); 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/"); String replace = "/ecology/" + (isEcology ? "WEB-INF/classes/" : "classbean/");
if (path.endsWith(".jar")) { if (path.endsWith(".jar")) {
replace = "/ecology/WEB-INF/lib/"; replace = "/ecology/WEB-INF/lib/";

View File

@ -25,7 +25,7 @@ public class AutoPackageJar {
public static void createJar(String targetPath) { public static void createJar(String targetPath) {
String path = AutoPackageJar.class.getResource("").getPath(); 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 + "aiyh", finalPath + "aiyh_utils.jar");
createJar(finalPath + "ebu7common", finalPath + "ebu7common.jar"); createJar(finalPath + "ebu7common", finalPath + "ebu7common.jar");
} }

View File

@ -14,8 +14,11 @@ public class FileTreeBuilder {
public static String targetPath; public static String targetPath;
public static String classPath;
public static FileInfo buildFileTree() { public static FileInfo buildFileTree() {
String directoryPath = "target"; String directoryPath = "target";
String classRootPath = "";
List<String> blackList = new ArrayList<>(); List<String> blackList = new ArrayList<>();
Properties properties = new Properties(); Properties properties = new Properties();
@ -35,16 +38,18 @@ public class FileTreeBuilder {
} }
targetPath = directoryPath; targetPath = directoryPath;
} }
classRootPath = properties.getProperty("classRootPath");
classPath = classRootPath;
List<String> blacklistPrefixes = Arrays.asList( List<String> blacklistPrefixes = Arrays.asList(
directoryPath + "generated-sources", directoryPath + "generated-sources",
directoryPath + "generated-test-sources", directoryPath + "generated-test-sources",
directoryPath + "test-classes", directoryPath + "test-classes",
directoryPath + "classes" + File.separator + "aiyh", directoryPath + classRootPath + "aiyh",
directoryPath + "classes" + File.separator + "ebu7common", directoryPath + classRootPath + "ebu7common",
directoryPath + "classes" + File.separator + "ln", directoryPath + classRootPath + "ln",
directoryPath + "classes" + File.separator + "cus_getlog" directoryPath + classRootPath + "cus_getlog"
); );
AutoPackageJar.createJar(directoryPath); AutoPackageJar.createJar(directoryPath, classRootPath);
blackList.addAll(blacklistPrefixes); blackList.addAll(blacklistPrefixes);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();