Compare commits
2 Commits
a9835d1cdf
...
d5d32720b9
Author | SHA1 | Date |
---|---|---|
youhong.ai | d5d32720b9 | |
youhong.ai | 47c31b05b5 |
|
@ -106,4 +106,122 @@ $(() => {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/* ******************* youhong.ai 流程部分 end ******************* */
|
/* ******************* youhong.ai 流程部分 end ******************* */
|
||||||
|
|
||||||
|
|
||||||
|
/* ******************* youhong.ai 编号验证是否存在 start ******************* */
|
||||||
|
$(() => {
|
||||||
|
const config = {
|
||||||
|
ecId: '',
|
||||||
|
tableName: '',
|
||||||
|
field: 'fwbh',
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author youhong.ai
|
||||||
|
* @desc 发起请求
|
||||||
|
*/
|
||||||
|
function api(requestOptions = {
|
||||||
|
url: "",
|
||||||
|
type: "GET",
|
||||||
|
data: "",
|
||||||
|
isAsync: true,
|
||||||
|
success: () => {
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
},
|
||||||
|
contentType: 'application/json',
|
||||||
|
beforeSend: () => {
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
let options = Object.assign({
|
||||||
|
url: "",
|
||||||
|
type: "GET",
|
||||||
|
data: "",
|
||||||
|
isAsync: true,
|
||||||
|
success: () => {
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
},
|
||||||
|
contentType: 'application/json',
|
||||||
|
beforeSend: () => {
|
||||||
|
}
|
||||||
|
}, requestOptions)
|
||||||
|
return $.ajax(options)
|
||||||
|
}
|
||||||
|
|
||||||
|
function findReact(dom, traverseUp = 0) {
|
||||||
|
const key = Object.keys(dom).find(key => {
|
||||||
|
return key.startsWith("__reactFiber$") // react 17+
|
||||||
|
|| key.startsWith("__reactInternalInstance$")
|
||||||
|
|| key.startsWith("__reactEventHandlers$"); // react <17
|
||||||
|
});
|
||||||
|
const domFiber = dom[key];
|
||||||
|
if (domFiber == null) return null;
|
||||||
|
// react <16
|
||||||
|
if (domFiber._currentElement) {
|
||||||
|
let compFiber = domFiber._currentElement._owner;
|
||||||
|
for (let i = 0; i < traverseUp; i++) {
|
||||||
|
compFiber = compFiber._currentElement._owner;
|
||||||
|
}
|
||||||
|
return compFiber._instance;
|
||||||
|
}
|
||||||
|
// react 16+
|
||||||
|
const GetCompFiber = fiber => {
|
||||||
|
let parentFiber = fiber.return;
|
||||||
|
while (typeof parentFiber.type == "string") {
|
||||||
|
parentFiber = parentFiber.return;
|
||||||
|
}
|
||||||
|
return parentFiber;
|
||||||
|
};
|
||||||
|
let compFiber = GetCompFiber(domFiber);
|
||||||
|
for (let i = 0; i < traverseUp; i++) {
|
||||||
|
compFiber = GetCompFiber(compFiber);
|
||||||
|
}
|
||||||
|
return compFiber.stateNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
function runJs() {
|
||||||
|
let node = findReact($(`button[ecid='${config.ecId}']`)[0])
|
||||||
|
let baseInfo = WfForm.getBaseInfo();
|
||||||
|
baseInfo.workflowid
|
||||||
|
if (baseInfo.requestid == -1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (node) {
|
||||||
|
let click = node.props.onClick;
|
||||||
|
node.props.onClick = (e) => {
|
||||||
|
api({
|
||||||
|
url: `/api/aiyh/taibao/bh/check-number?tableName=${config.tableName}&field=${config.field}&requestId=${baseInfo.requestid}`,
|
||||||
|
success(res) {
|
||||||
|
if (res && res.code == 200) {
|
||||||
|
if (res.data) {
|
||||||
|
// 存在编号,提示是否需要编号
|
||||||
|
WfForm.showConfirm("编号一存在,是否重新编号?", function () {
|
||||||
|
click(e)
|
||||||
|
}, function () {
|
||||||
|
// 不重新编号,刷新
|
||||||
|
window.location.reload()
|
||||||
|
}, {
|
||||||
|
title: "编号确认", //弹确认框的title,仅PC端有效
|
||||||
|
okText: "确认", //自定义确认按钮名称
|
||||||
|
cancelText: "取消" //自定义取消按钮名称
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
click(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
runJs()
|
||||||
|
})
|
||||||
|
/* ******************* youhong.ai 编号验证是否存在 end ******************* */
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class Util extends weaver.general.Util {
|
||||||
str = str.substring(0, str.length() - 1);
|
str = str.substring(0, str.length() - 1);
|
||||||
}
|
}
|
||||||
if (str.trim().startsWith(removeSeparator)) {
|
if (str.trim().startsWith(removeSeparator)) {
|
||||||
str = str.substring(1);
|
str = str.substring(removeSeparator.length());
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class HttpUtils {
|
||||||
return getUrl;
|
return getUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String serializeParams(Map<String, Object> params) {
|
public static String serializeParams(Map<String, Object> params) {
|
||||||
if (params != null && params.size() > 0) {
|
if (params != null && params.size() > 0) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||||
|
@ -1113,6 +1113,9 @@ public class HttpUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBean(Object o) {
|
private boolean isBean(Object o) {
|
||||||
|
if (Objects.isNull(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (o instanceof Number) {
|
if (o instanceof Number) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1122,9 +1125,6 @@ public class HttpUtils {
|
||||||
if (o instanceof Boolean) {
|
if (o instanceof Boolean) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Objects.isNull(o)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !o.getClass().isPrimitive();
|
return !o.getClass().isPrimitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,18 +336,18 @@ public class ResultMapper {
|
||||||
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
||||||
|
|
||||||
if (Objects.nonNull(toLowerCase)) {
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||||
} else {
|
} else {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
||||||
}
|
}
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -475,39 +475,58 @@ public class ResultMapper {
|
||||||
} else {
|
} else {
|
||||||
columnType = columnTypeName[i];
|
columnType = columnTypeName[i];
|
||||||
}
|
}
|
||||||
|
String value = rs.getString(i + 1);
|
||||||
|
String valueCloumn = rs.getString(columnName[i]);
|
||||||
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
|
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
|
||||||
|
|
||||||
if (Objects.nonNull(toLowerCase)) {
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
|
try {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), Integer.parseInt(value));
|
||||||
|
} catch (Exception e) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i]));
|
try {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), Integer.parseInt(valueCloumn));
|
||||||
|
} catch (Exception e) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), valueCloumn);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
try {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), Integer.parseInt(value));
|
||||||
|
} catch (Exception e) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), Integer.parseInt(value));
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), Integer.parseInt(value));
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i], Integer.parseInt(value));
|
||||||
|
} catch (Exception e) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), value);
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), value);
|
||||||
|
((Map<? super Object, ? super Object>) o).put(columnName[i], value);
|
||||||
}
|
}
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
|
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1));
|
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getInt(i + 1));
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
||||||
|
|
||||||
if (Objects.nonNull(toLowerCase)) {
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), value);
|
||||||
} else {
|
} else {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), valueCloumn);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), valueCloumn);
|
||||||
}
|
}
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), value);
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), value);
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i], value);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -535,18 +554,18 @@ public class ResultMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Objects.nonNull(toLowerCase)) {
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), value);
|
||||||
} else {
|
} else {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), valueCloumn);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), value);
|
||||||
}
|
}
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), value);
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), value);
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i], value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,13 @@ import weaver.hrm.User;
|
||||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||||
import weaver.xuanran.wang.common.util.CommonUtil;
|
import weaver.xuanran.wang.common.util.CommonUtil;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,165 +34,170 @@ import java.util.stream.Collectors;
|
||||||
* @date 2023/2/22 13:58
|
* @date 2023/2/22 13:58
|
||||||
*/
|
*/
|
||||||
public class BatchCreateWorkflowService {
|
public class BatchCreateWorkflowService {
|
||||||
|
|
||||||
// 表名 : requestId 本次需要删除的数据
|
// 表名 : requestId 本次需要删除的数据
|
||||||
private final ConcurrentHashMap<String, List<String>> delWorkflowTableRequestId = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, List<String>> delWorkflowTableRequestId = new ConcurrentHashMap<>();
|
||||||
// workflowId : tableName
|
// workflowId : tableName
|
||||||
private static final HashMap<Integer, String> workflowTable = new HashMap<>();
|
private static final HashMap<Integer, String> workflowTable = new HashMap<>();
|
||||||
private final Logger log = Util.getLogger();
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
private static final String CUSTOM_ID = "customId";
|
private static final String CUSTOM_ID = "customId";
|
||||||
// private final MeetingMapper meetingTransMapper = Util.getTransMapper(MeetingMapper.class);
|
// private final MeetingMapper meetingTransMapper = Util.getTransMapper(MeetingMapper.class);
|
||||||
private final MeetingService meetingService = new MeetingService();
|
private final MeetingService meetingService = new MeetingService();
|
||||||
/**
|
|
||||||
* <h1>取消会议 支持多个</h1>
|
/**
|
||||||
* @author xuanran.wang
|
* <h1>取消会议 支持多个</h1>
|
||||||
* @dateTime 2023/2/24 10:21
|
*
|
||||||
* @param ids 会议id
|
* @param ids 会议id
|
||||||
**/
|
* @author xuanran.wang
|
||||||
public void cancelMeeting(String ids){
|
* @dateTime 2023/2/24 10:21
|
||||||
meetingService.cancelMeeting(ids);
|
**/
|
||||||
}
|
public void cancelMeeting(String ids) {
|
||||||
|
meetingService.cancelMeeting(ids);
|
||||||
/**
|
}
|
||||||
* <h1>批量创建流程</h1>
|
|
||||||
* @author xuanran.wang
|
/**
|
||||||
* @dateTime 2023/2/22 17:10
|
* <h1>批量创建流程</h1>
|
||||||
* @param array 流程数据数组
|
*
|
||||||
* @return 创建流程结果
|
* @param array 流程数据数组
|
||||||
**/
|
* @return 创建流程结果
|
||||||
public List<CreateWfVO> batchCreateWorkflow(User user, JSONArray array) {
|
* @author xuanran.wang
|
||||||
List<Future<CusCreateWfInfo>> list = new ArrayList<>();
|
* @dateTime 2023/2/22 17:10
|
||||||
List<CusCreateWfInfo> errors = new ArrayList<>();
|
**/
|
||||||
ArrayList<CreateWfVO> res = new ArrayList<>();
|
public List<CreateWfVO> batchCreateWorkflow(User user, JSONArray array) {
|
||||||
try {
|
List<Future<CusCreateWfInfo>> list = new ArrayList<>();
|
||||||
List<ReqOperateRequestEntity> reqOperateRequestEntities = checkParams(array);
|
List<CusCreateWfInfo> errors = new ArrayList<>();
|
||||||
// 结果集
|
ArrayList<CreateWfVO> res = new ArrayList<>();
|
||||||
for (int i = 0; i < reqOperateRequestEntities.size(); i++) {
|
try {
|
||||||
int temp = i;
|
List<ReqOperateRequestEntity> reqOperateRequestEntities = checkParams(array);
|
||||||
// 创建流程
|
// 结果集
|
||||||
Callable<CusCreateWfInfo> callable = () -> this.createWorkflow(user,reqOperateRequestEntities.get(temp), temp);
|
for (int i = 0; i < reqOperateRequestEntities.size(); i++) {
|
||||||
list.add(Util.threadPool.submit(callable));
|
int temp = i;
|
||||||
}
|
// 创建流程
|
||||||
for (Future<CusCreateWfInfo> future : list) {
|
Callable<CusCreateWfInfo> callable = () -> this.createWorkflow(user, reqOperateRequestEntities.get(temp), temp);
|
||||||
CusCreateWfInfo cusCreateWfInfo = future.get();
|
list.add(Util.threadPool.submit(callable));
|
||||||
PAResponseEntity entity = cusCreateWfInfo.getPaResponseEntity();
|
}
|
||||||
String tableName = workflowTable.get(cusCreateWfInfo.getWorkflowId());
|
for (Future<CusCreateWfInfo> future : list) {
|
||||||
if(PAResponseCode.SUCCESS != entity.getCode()){
|
CusCreateWfInfo cusCreateWfInfo = future.get();
|
||||||
errors.add(cusCreateWfInfo);
|
PAResponseEntity entity = cusCreateWfInfo.getPaResponseEntity();
|
||||||
continue;
|
String tableName = workflowTable.get(cusCreateWfInfo.getWorkflowId());
|
||||||
}
|
if (PAResponseCode.SUCCESS != entity.getCode()) {
|
||||||
// 将生成的requestId存到vo中返回
|
errors.add(cusCreateWfInfo);
|
||||||
Map<String, Object> data = (Map<String, Object>) entity.getData();
|
continue;
|
||||||
String requestId = Util.null2DefaultStr(data.get("requestid"),"");
|
}
|
||||||
CreateWfVO vo = new CreateWfVO();
|
// 将生成的requestId存到vo中返回
|
||||||
vo.setRequestId(requestId);
|
Map<String, Object> data = (Map<String, Object>) entity.getData();
|
||||||
vo.setCustomId(cusCreateWfInfo.getCustomId());
|
String requestId = Util.null2DefaultStr(data.get("requestid"), "");
|
||||||
res.add(vo);
|
CreateWfVO vo = new CreateWfVO();
|
||||||
|
vo.setRequestId(requestId);
|
||||||
// 将表名 requestId 存到成员变量中
|
vo.setCustomId(cusCreateWfInfo.getCustomId());
|
||||||
if (!delWorkflowTableRequestId.containsKey(tableName)) {
|
res.add(vo);
|
||||||
ArrayList<String> requestIds = new ArrayList<>();
|
|
||||||
requestIds.add(requestId);
|
// 将表名 requestId 存到成员变量中
|
||||||
delWorkflowTableRequestId.put(tableName, requestIds);
|
if (!delWorkflowTableRequestId.containsKey(tableName)) {
|
||||||
}else {
|
ArrayList<String> requestIds = new ArrayList<>();
|
||||||
delWorkflowTableRequestId.get(tableName).add(requestId);
|
requestIds.add(requestId);
|
||||||
}
|
delWorkflowTableRequestId.put(tableName, requestIds);
|
||||||
}
|
} else {
|
||||||
if(errors.size() > 0){
|
delWorkflowTableRequestId.get(tableName).add(requestId);
|
||||||
throw new CustomerException(JSONObject.toJSONString(errors));
|
}
|
||||||
}
|
}
|
||||||
return res;
|
if (errors.size() > 0) {
|
||||||
}catch (Exception e){
|
throw new CustomerException(JSONObject.toJSONString(errors));
|
||||||
if(MapUtils.isNotEmpty(delWorkflowTableRequestId)){
|
}
|
||||||
log.info("删除流程数据map : " + JSONObject.toJSONString(delWorkflowTableRequestId));
|
return res;
|
||||||
for (Map.Entry<String, List<String>> entry : delWorkflowTableRequestId.entrySet()) {
|
} catch (Exception e) {
|
||||||
String tableName = entry.getKey();
|
if (MapUtils.isNotEmpty(delWorkflowTableRequestId)) {
|
||||||
List<String> requestIds = entry.getValue();
|
log.info("删除流程数据map : " + JSONObject.toJSONString(delWorkflowTableRequestId));
|
||||||
if (!CommonUtil.deleteWorkflowDataByRequestIds(tableName, requestIds)) {
|
for (Map.Entry<String, List<String>> entry : delWorkflowTableRequestId.entrySet()) {
|
||||||
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", tableName,JSONObject.toJSONString(requestIds)));
|
String tableName = entry.getKey();
|
||||||
}
|
List<String> requestIds = entry.getValue();
|
||||||
if (!CommonUtil.deleteWorkflowDataByRequestIds("workflow_requestbase", requestIds)) {
|
if (!CommonUtil.deleteWorkflowDataByRequestIds(tableName, requestIds)) {
|
||||||
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "workflow_requestbase", JSONObject.toJSONString(requestIds)));
|
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", tableName, JSONObject.toJSONString(requestIds)));
|
||||||
}
|
}
|
||||||
if (!CommonUtil.deleteWorkflowDataByRequestIds("Bill_Meeting", requestIds)) {
|
if (!CommonUtil.deleteWorkflowDataByRequestIds("workflow_requestbase", requestIds)) {
|
||||||
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "Bill_Meeting", JSONObject.toJSONString(requestIds)));
|
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "workflow_requestbase", JSONObject.toJSONString(requestIds)));
|
||||||
}
|
}
|
||||||
}
|
if (!CommonUtil.deleteWorkflowDataByRequestIds("Bill_Meeting", requestIds)) {
|
||||||
}
|
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "Bill_Meeting", JSONObject.toJSONString(requestIds)));
|
||||||
throw new CustomerException(e.getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new CustomerException(e.getMessage());
|
||||||
/**
|
}
|
||||||
* <h1>创建流程</h1>
|
}
|
||||||
* @author xuanran.wang
|
|
||||||
* @dateTime 2023/2/24 14:33
|
/**
|
||||||
* @param user 用户
|
* <h1>创建流程</h1>
|
||||||
* @param requestEntity 流程请求体
|
*
|
||||||
* @param index 流程集合下标
|
* @param user 用户
|
||||||
* @return 流程创建成功相关数据
|
* @param requestEntity 流程请求体
|
||||||
**/
|
* @param index 流程集合下标
|
||||||
public CusCreateWfInfo createWorkflow(User user,
|
* @return 流程创建成功相关数据
|
||||||
ReqOperateRequestEntity requestEntity,
|
* @author xuanran.wang
|
||||||
int index){
|
* @dateTime 2023/2/24 14:33
|
||||||
// 创建流程
|
**/
|
||||||
PAResponseEntity responseEntity = BatchCreateWorkFlowController.WRO.doCreateRequest(user, requestEntity);
|
public CusCreateWfInfo createWorkflow(User user,
|
||||||
CusCreateWfInfo cusCreateWfInfo = new CusCreateWfInfo();
|
ReqOperateRequestEntity requestEntity,
|
||||||
cusCreateWfInfo.setIndex(index);
|
int index) {
|
||||||
cusCreateWfInfo.setPaResponseEntity(responseEntity);
|
// 创建流程
|
||||||
int workflowId = requestEntity.getWorkflowId();
|
PAResponseEntity responseEntity = BatchCreateWorkFlowController.WRO.doCreateRequest(user, requestEntity);
|
||||||
String tableName = workflowTable.get(workflowId);
|
CusCreateWfInfo cusCreateWfInfo = new CusCreateWfInfo();
|
||||||
if(StringUtils.isBlank(tableName)){
|
cusCreateWfInfo.setIndex(index);
|
||||||
tableName = CommonUtil.getTableNameByWorkflowId(workflowId);
|
cusCreateWfInfo.setPaResponseEntity(responseEntity);
|
||||||
workflowTable.put(workflowId, tableName);
|
int workflowId = requestEntity.getWorkflowId();
|
||||||
}
|
String tableName = workflowTable.get(workflowId);
|
||||||
// 获取主表的customId
|
if (StringUtils.isBlank(tableName)) {
|
||||||
List<WorkflowRequestTableField> collect = requestEntity.getMainData()
|
tableName = CommonUtil.getTableNameByWorkflowId(workflowId);
|
||||||
.stream()
|
workflowTable.put(workflowId, tableName);
|
||||||
.filter(item -> CUSTOM_ID.equals(item.getFieldName()))
|
}
|
||||||
.collect(Collectors.toList());
|
// 获取主表的customId
|
||||||
String customIdVal = collect.get(0).getFieldValue();
|
List<WorkflowRequestTableField> collect = requestEntity.getMainData()
|
||||||
cusCreateWfInfo.setCustomId(customIdVal);
|
.stream()
|
||||||
cusCreateWfInfo.setWorkflowId(workflowId);
|
.filter(item -> CUSTOM_ID.equals(item.getFieldName()))
|
||||||
return cusCreateWfInfo;
|
.collect(Collectors.toList());
|
||||||
}
|
String customIdVal = collect.get(0).getFieldValue();
|
||||||
|
cusCreateWfInfo.setCustomId(customIdVal);
|
||||||
/**
|
cusCreateWfInfo.setWorkflowId(workflowId);
|
||||||
* <h1>参数校验并将json转成ReqOperateRequestEntity</h1>
|
return cusCreateWfInfo;
|
||||||
* @author xuanran.wang
|
}
|
||||||
* @dateTime 2023/2/24 13:36
|
|
||||||
* @param array json数组
|
/**
|
||||||
* @return 解析后的集合
|
* <h1>参数校验并将json转成ReqOperateRequestEntity</h1>
|
||||||
**/
|
*
|
||||||
public List<ReqOperateRequestEntity> checkParams(JSONArray array){
|
* @param array json数组
|
||||||
ArrayList<ReqOperateRequestEntity> res = new ArrayList<>();
|
* @return 解析后的集合
|
||||||
try {
|
* @author xuanran.wang
|
||||||
for (Object obj : array) {
|
* @dateTime 2023/2/24 13:36
|
||||||
ReqOperateRequestEntity entity;
|
**/
|
||||||
JSONObject jsonObject;
|
public List<ReqOperateRequestEntity> checkParams(JSONArray array) {
|
||||||
// 将json转成内部流程对象
|
ArrayList<ReqOperateRequestEntity> res = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
jsonObject = JSONObject.parseObject(obj.toString());
|
for (Object obj : array) {
|
||||||
entity = JSONObject.parseObject(jsonObject.toString(), ReqOperateRequestEntity.class);
|
ReqOperateRequestEntity entity;
|
||||||
}catch (Exception e){
|
JSONObject jsonObject;
|
||||||
throw new CustomerException(Util.logStr("json反序列化失败!当前对象:{}, 错误信息: {}" ,obj,e.getMessage()));
|
// 将json转成内部流程对象
|
||||||
}
|
try {
|
||||||
if(Util.getIntValue(String.valueOf(entity.getWorkflowId()),-1) < 0){
|
jsonObject = JSONObject.parseObject(obj.toString());
|
||||||
throw new CustomerException(Util.logStr("该对象workflowId为空!", obj));
|
entity = JSONObject.parseObject(jsonObject.toString(), ReqOperateRequestEntity.class);
|
||||||
}
|
} catch (Exception e) {
|
||||||
List<WorkflowRequestTableField> collect = entity.getMainData()
|
throw new CustomerException(Util.logStr("json反序列化失败!当前对象:{}, 错误信息: {}", obj, e.getMessage()));
|
||||||
.stream()
|
}
|
||||||
.filter(item -> CUSTOM_ID.equals(item.getFieldName()))
|
if (Util.getIntValue(String.valueOf(entity.getWorkflowId()), -1) < 0) {
|
||||||
.collect(Collectors.toList());
|
throw new CustomerException(Util.logStr("该对象workflowId为空!", obj));
|
||||||
if(collect.size() == 0){
|
}
|
||||||
throw new CustomerException(Util.logStr("该对象mainData中未找到customId!:{}", obj));
|
List<WorkflowRequestTableField> collect = entity.getMainData()
|
||||||
}
|
.stream()
|
||||||
res.add(entity);
|
.filter(item -> CUSTOM_ID.equals(item.getFieldName()))
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
}catch (Exception e){
|
if (collect.size() == 0) {
|
||||||
throw new CustomerException(Util.logStr("JSON参数校验失败!请检查json是否正确!错误信息: {}",e.getMessage()));
|
throw new CustomerException(Util.logStr("该对象mainData中未找到customId!:{}", obj));
|
||||||
}
|
}
|
||||||
return res;
|
res.add(entity);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomerException(Util.logStr("JSON参数校验失败!请检查json是否正确!错误信息: {}", e.getMessage()));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,4 +143,5 @@ public class TaskElementController {
|
||||||
return ApiResult.error("system error!");
|
return ApiResult.error("system error!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,4 +168,22 @@ public interface TaskElementMapper {
|
||||||
*/
|
*/
|
||||||
@Update("update uf_rwtzeq_dt1 set zjwczt = 0 where zjr = #{userId} and mainid = #{mainId}")
|
@Update("update uf_rwtzeq_dt1 set zjwczt = 0 where zjr = #{userId} and mainid = #{mainId}")
|
||||||
boolean updateTaskHandoverStatus(@ParamMapper("userId") String userId, @ParamMapper("mainId") String mainId);
|
boolean updateTaskHandoverStatus(@ParamMapper("userId") String userId, @ParamMapper("mainId") String mainId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询相似名称的人员信息</h2>
|
||||||
|
*
|
||||||
|
* @param nameLike 姓名like
|
||||||
|
* @return 姓名like的id
|
||||||
|
*/
|
||||||
|
@Select("select id from hrmresource where lastname like #{nameLike}")
|
||||||
|
List<Integer> selectUserNameLike(String nameLike);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询相似名称的人员信息</h2>
|
||||||
|
*
|
||||||
|
* @param value 姓名
|
||||||
|
* @return 姓名的id
|
||||||
|
*/
|
||||||
|
@Select("select id from hrmresource where lastname = #{nameLike}")
|
||||||
|
Integer selectUserName(String value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,10 @@ public class TaskElementService {
|
||||||
for (Map<String, Object> item : authorityList) {
|
for (Map<String, Object> item : authorityList) {
|
||||||
if ("0".equals(dataSource)) {
|
if ("0".equals(dataSource)) {
|
||||||
// 自定义sql
|
// 自定义sql
|
||||||
customerValue += " " + whereStr;
|
// customerValue += " " + whereStr;
|
||||||
|
if (StrUtil.isNotBlank(whereStr)) {
|
||||||
|
customerValue = "select * from (" + customerValue + ") temp where " + whereStr;
|
||||||
|
}
|
||||||
List<Map<String, Object>> list = mapper.selectWorkList(customerValue, item, user, whereMap, currentMap);
|
List<Map<String, Object>> list = mapper.selectWorkList(customerValue, item, user, whereMap, currentMap);
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
result.addAll(list);
|
result.addAll(list);
|
||||||
|
@ -179,8 +182,10 @@ public class TaskElementService {
|
||||||
Map<String, Object> map = new HashMap<>(8);
|
Map<String, Object> map = new HashMap<>(8);
|
||||||
map.put("currentDate", Util.getTime("yyyy-MM-dd"));
|
map.put("currentDate", Util.getTime("yyyy-MM-dd"));
|
||||||
map.put("currentTime", Util.getTime("HH:mm:ss"));
|
map.put("currentTime", Util.getTime("HH:mm:ss"));
|
||||||
|
Map<String, Object> searchParam = (Map<String, Object>) params.get("searchParam");
|
||||||
|
Map<String, Object> allSearch = (Map<String, Object>) params.get("allSearch");
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
for (Map.Entry<String, Object> entry : searchParam.entrySet()) {
|
||||||
Map<String, Object> valueMap = (Map<String, Object>) entry.getValue();
|
Map<String, Object> valueMap = (Map<String, Object>) entry.getValue();
|
||||||
String key = Util.null2String(valueMap.get("key"));
|
String key = Util.null2String(valueMap.get("key"));
|
||||||
String value = Util.null2String(valueMap.get("value"));
|
String value = Util.null2String(valueMap.get("value"));
|
||||||
|
@ -196,6 +201,49 @@ public class TaskElementService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String whereStr = builder.toString();
|
String whereStr = builder.toString();
|
||||||
|
if (StrUtil.isNotBlank(whereStr)) {
|
||||||
|
String trim = whereStr.trim();
|
||||||
|
if (trim.startsWith("and")) {
|
||||||
|
whereStr = trim.substring(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(allSearch)) {
|
||||||
|
StringBuilder orWhere = new StringBuilder();
|
||||||
|
String value = Util.null2String(allSearch.get("value"));
|
||||||
|
if (StrUtil.isNotBlank(value)) {
|
||||||
|
List<Map<String, Object>> fields = (List<Map<String, Object>>) allSearch.get("fields");
|
||||||
|
for (Map<String, Object> field : fields) {
|
||||||
|
String key = Util.null2String(field.get("key"));
|
||||||
|
String type = Util.null2String(field.get("type"));
|
||||||
|
if ("like".equalsIgnoreCase(type)) {
|
||||||
|
orWhere.append(" or ").append(key).append(" like ").append("concat('%',#{where._allValue},'%')");
|
||||||
|
} else if ("hrm like".equalsIgnoreCase(type)) {
|
||||||
|
List<Integer> hrmList = mapper.selectUserNameLike("%" + value + "%");
|
||||||
|
orWhere.append(" or ").append(key).append(" in ( ").append(Util.intJoin(hrmList, ",")).append(") ");
|
||||||
|
} else if ("hrm".equalsIgnoreCase(type)) {
|
||||||
|
Integer hrmId = mapper.selectUserName(value);
|
||||||
|
orWhere.append(" or ").append(key).append(" = ").append(hrmId);
|
||||||
|
} else {
|
||||||
|
orWhere.append(" or ").append(key).append(" = ").append("#{where._allValue}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("_allValue", value);
|
||||||
|
String orWhereStr = orWhere.toString();
|
||||||
|
if (StrUtil.isNotBlank(orWhereStr)) {
|
||||||
|
String trim = orWhereStr.trim();
|
||||||
|
if (trim.startsWith("or")) {
|
||||||
|
orWhereStr = trim.substring(2);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(whereStr)) {
|
||||||
|
whereStr = whereStr + " or ( " + orWhereStr + " )";
|
||||||
|
} else {
|
||||||
|
whereStr = orWhereStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 查询可查看权限并进行过滤
|
// 查询可查看权限并进行过滤
|
||||||
String viewAuthoritySql = ihgTaskElementConfItem.getViewAuthority();
|
String viewAuthoritySql = ihgTaskElementConfItem.getViewAuthority();
|
||||||
List<Map<String, Object>> authorityList = mapper.selectAuthority(viewAuthoritySql, user, map);
|
List<Map<String, Object>> authorityList = mapper.selectAuthority(viewAuthoritySql, user, map);
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.api.youhong.ai.pcn.download.controller;
|
||||||
|
|
||||||
|
import aiyh.utils.ApiResult;
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import com.api.youhong.ai.pcn.download.service.DownloadFileService;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>下载文件</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/26 23:30</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Path("aiyh/download-file")
|
||||||
|
public class DownloadFileController {
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
private final DownloadFileService service = new DownloadFileService();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("download")
|
||||||
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
public Response downloadFile(@QueryParam("fieldId") String fieldId) {
|
||||||
|
try {
|
||||||
|
return service.downloadFile(fieldId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("下载文件出错:" + Util.getErrString(e));
|
||||||
|
return Response.ok(ApiResult.error("system error!"), MediaType.APPLICATION_JSON).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.api.youhong.ai.pcn.download.service;
|
||||||
|
|
||||||
|
import aiyh.utils.ApiResult;
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.entity.DocImageInfo;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
|
import weaver.file.ImageFileManager;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.StreamingOutput;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/26 23:33</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DownloadFileService {
|
||||||
|
|
||||||
|
|
||||||
|
public static final String SUFFIX = "==";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>下载文件</h2>
|
||||||
|
*
|
||||||
|
* @param encryptionFileId 加密后的文件id docid
|
||||||
|
* @return 文件流
|
||||||
|
*/
|
||||||
|
public Response downloadFile(String encryptionFileId) {
|
||||||
|
if (StrUtil.isBlank(encryptionFileId)) {
|
||||||
|
return Response.ok(ApiResult.error("fileId is blank!"), MediaType.APPLICATION_JSON).build();
|
||||||
|
}
|
||||||
|
String fieldId = null;
|
||||||
|
try {
|
||||||
|
String decode = URLDecoder.decode(encryptionFileId, "UTF-8");
|
||||||
|
if (encryptionFileId.endsWith(SUFFIX)) {
|
||||||
|
decode = encryptionFileId;
|
||||||
|
}
|
||||||
|
fieldId = EncryptionFileIdUtil.decrypt(decode);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomerException("解密附件id失败!", e);
|
||||||
|
}
|
||||||
|
DocImageInfo docImageInfo = Util.selectImageInfoByDocId(fieldId);
|
||||||
|
StreamingOutput stream = outputStream -> {
|
||||||
|
Integer imageFileId = docImageInfo.getImageFileId();
|
||||||
|
InputStream inputStreamById = ImageFileManager.getInputStreamById(imageFileId);
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = inputStreamById.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
String imageFileName = docImageInfo.getImageFileName();
|
||||||
|
return Response
|
||||||
|
.ok(stream)
|
||||||
|
.header("Content-Disposition", "attachment; filename=\"" + imageFileName + "\"")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.api.youhong.ai.pcn.download.service;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>加密工具</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/26 23:43</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class EncryptionFileIdUtil {
|
||||||
|
private static final String PASSWORD = "H6f9T4x2jL8E3K7Y";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将密码补齐到合法长度
|
||||||
|
*
|
||||||
|
* @param password 密码
|
||||||
|
* @return 合法长度的密码
|
||||||
|
*/
|
||||||
|
public static String padPassword(String password) {
|
||||||
|
byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8);
|
||||||
|
// AES-128
|
||||||
|
int validKeyLength = 16;
|
||||||
|
if (passwordBytes.length < validKeyLength) {
|
||||||
|
byte[] paddedBytes = Arrays.copyOf(passwordBytes, validKeyLength);
|
||||||
|
return new String(paddedBytes, StandardCharsets.UTF_8);
|
||||||
|
} else if (passwordBytes.length > validKeyLength) {
|
||||||
|
return new String(Arrays.copyOf(passwordBytes, validKeyLength), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>使用AES对称加密算法和Base64编码进行加密</h2>
|
||||||
|
*
|
||||||
|
* @param plaintext 待加密字符串
|
||||||
|
* @return 加密后的字符串
|
||||||
|
* @throws Exception 产生的异常信息
|
||||||
|
*/
|
||||||
|
public static String encrypt(String plaintext) throws Exception {
|
||||||
|
String password = padPassword(PASSWORD);
|
||||||
|
SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES");
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||||
|
byte[] encryptedData = cipher.doFinal(plaintext.getBytes(StandardCharsets.UTF_8));
|
||||||
|
return Base64.getEncoder().encodeToString(encryptedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>使用AES对称加密算法和Base64编码进行解密</h2>
|
||||||
|
*
|
||||||
|
* @param encryptedText 加密后的字符串
|
||||||
|
* @return 解密后的字符串
|
||||||
|
* @throws Exception 异常信息
|
||||||
|
*/
|
||||||
|
public static String decrypt(String encryptedText) throws Exception {
|
||||||
|
String password = padPassword(PASSWORD);
|
||||||
|
SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES");
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||||
|
byte[] decryptedData = cipher.doFinal(Base64.getDecoder().decode(encryptedText));
|
||||||
|
return new String(decryptedData, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.api.youhong.ai.taibao.checknumber.controller;
|
||||||
|
|
||||||
|
import aiyh.utils.ApiResult;
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import com.api.youhong.ai.taibao.checknumber.service.CheckNumberService;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>检查是否存在编号</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/26 11:03</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Path("/aiyh/taibao/bh")
|
||||||
|
public class CheckNumberController {
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
private final CheckNumberService service = new CheckNumberService();
|
||||||
|
|
||||||
|
@Path("check-number")
|
||||||
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String checkNumber(@QueryParam("tableName") String tableName,
|
||||||
|
@QueryParam("field") String field,
|
||||||
|
@QueryParam("requestId") String requestId) {
|
||||||
|
try {
|
||||||
|
return ApiResult.success(service.checkNumber(tableName, field, requestId));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("检查是否存在编号出错:" + Util.getErrString(e));
|
||||||
|
return ApiResult.error("system error!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.api.youhong.ai.taibao.checknumber.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Select;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/26 11:08</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@SqlMapper
|
||||||
|
public interface CheckNumberMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h3>查询编号是否存在</h3>
|
||||||
|
*
|
||||||
|
* @param field 编号字段
|
||||||
|
* @param tableName 表名称
|
||||||
|
* @param requestId 流程id
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
@Select("select $t{field} from $t{tableName} where requestid = #{requestId}")
|
||||||
|
String selectNumber(@ParamMapper("field") String field,
|
||||||
|
@ParamMapper("tableName") String tableName,
|
||||||
|
@ParamMapper("requestId") String requestId);
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.api.youhong.ai.taibao.checknumber.service;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
|
import com.api.youhong.ai.taibao.checknumber.mapper.CheckNumberMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/26 11:06</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class CheckNumberService {
|
||||||
|
|
||||||
|
private final CheckNumberMapper mapper = Util.getMapper(CheckNumberMapper.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>检查是否存在编号</h2>
|
||||||
|
*
|
||||||
|
* @param tableName 表名称
|
||||||
|
* @param field 字段
|
||||||
|
* @param requestId 流程id
|
||||||
|
* @return 是否存在编号
|
||||||
|
*/
|
||||||
|
public boolean checkNumber(String tableName, String field, String requestId) {
|
||||||
|
String number = mapper.selectNumber(field, tableName, requestId);
|
||||||
|
return StrUtil.isNotBlank(number);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,6 @@ package com.customization.youhong.pcn.createrworkflow.impl;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import com.customization.youhong.pcn.createrworkflow.CreateRequestException;
|
import com.customization.youhong.pcn.createrworkflow.CreateRequestException;
|
||||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
|
||||||
import com.customization.youhong.pcn.createrworkflow.util.CheckWorkflowRequestParamsUtil;
|
import com.customization.youhong.pcn.createrworkflow.util.CheckWorkflowRequestParamsUtil;
|
||||||
import com.engine.core.cfg.annotation.ServiceDynamicProxy;
|
import com.engine.core.cfg.annotation.ServiceDynamicProxy;
|
||||||
import com.engine.core.cfg.annotation.ServiceMethodDynamicProxy;
|
import com.engine.core.cfg.annotation.ServiceMethodDynamicProxy;
|
||||||
|
@ -31,7 +30,6 @@ public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy impleme
|
||||||
|
|
||||||
private final Logger log = Util.getLogger("workflow");
|
private final Logger log = Util.getLogger("workflow");
|
||||||
|
|
||||||
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
|
||||||
|
|
||||||
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();
|
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.customization.youhong.pcn.createrworkflow.util;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.customization.youhong.pcn.createrworkflow.CreateRequestException;
|
import com.customization.youhong.pcn.createrworkflow.CreateRequestException;
|
||||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||||
|
@ -51,6 +52,8 @@ public class CheckWorkflowRequestParamsUtil {
|
||||||
if (CollectionUtil.isEmpty(detailList)) {
|
if (CollectionUtil.isEmpty(detailList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
log.info("checkCreateConfig: " + JSON.toJSONString(checkCreateConfig));
|
||||||
|
log.info("detailList: " + JSON.toJSONString(detailList));
|
||||||
Map<String, CheckConditionItem> checkConditionItemMap;
|
Map<String, CheckConditionItem> checkConditionItemMap;
|
||||||
List<CheckConditionItem> conditionGroupItems = checkCreateConfig.getConditionGroupItems();
|
List<CheckConditionItem> conditionGroupItems = checkCreateConfig.getConditionGroupItems();
|
||||||
if (CollectionUtil.isNotEmpty(conditionGroupItems)) {
|
if (CollectionUtil.isNotEmpty(conditionGroupItems)) {
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.todwfworkflow.cusgetdata;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.entity.DocImageInfo;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
|
import com.api.youhong.ai.pcn.download.service.EncryptionFileIdUtil;
|
||||||
|
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>自定义附件数组获取值</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/26 23:57</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class FileLinkListGetImpl implements CusInterfaceGetValue {
|
||||||
|
@Override
|
||||||
|
public Object execute(Map<String, Object> mainMap, Map<String, Object> detailMap, String currentValue, Map<String, String> pathParam) {
|
||||||
|
if (StrUtil.isBlank(currentValue)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
String downloadFileHost = Util.getCusConfigValue("downloadFileHost");
|
||||||
|
List<DocImageInfo> docImageInfos = Util.selectImageInfoByDocIds(currentValue);
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
for (DocImageInfo docImageInfo : docImageInfos) {
|
||||||
|
String encode = null;
|
||||||
|
try {
|
||||||
|
String encrypt = EncryptionFileIdUtil.encrypt(docImageInfo.getDocId() + "");
|
||||||
|
encode = URLEncoder.encode(encrypt, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomerException("加密附件id出错!", e);
|
||||||
|
}
|
||||||
|
String url = downloadFileHost + "/api/aiyh/download-file/download?fieldId=" + encode;
|
||||||
|
Map<String, Object> map = new HashMap<>(8);
|
||||||
|
map.put("fileName", docImageInfo.getImageFileName());
|
||||||
|
map.put("fileId", docImageInfo.getImageFileId());
|
||||||
|
map.put("fileUrl", url);
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,14 @@
|
||||||
package youhong.ai.pcn;
|
package youhong.ai.pcn;
|
||||||
|
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
|
import com.api.youhong.ai.pcn.download.service.EncryptionFileIdUtil;
|
||||||
import com.api.youhong.ai.pcn.ssoyunzhao.service.SsoYunZhaoService;
|
import com.api.youhong.ai.pcn.ssoyunzhao.service.SsoYunZhaoService;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>test</h1>
|
* <h1>test</h1>
|
||||||
*
|
*
|
||||||
|
@ -23,4 +27,13 @@ public class Test01 extends BaseTest {
|
||||||
System.out.println(service.rsaDecryptUserInfo("EpPlcAYvNOFfJWHBuvLkWzkTOoEk3NoO95FoRlEJTGlblyBEYV0CQWnCDd4yXDCgcR1yhaig/5NrIZ5dGTTgwZ6f0fOfVDdnFPr5/GUUzxxsW8qpdHLIswFT1O4E57ny1Df6uxPaE5Hqp3QHvGkfUo4ak2mI0D11V7XzxGmVsSqoofdrCVXJIRrTkUHJ3OSxtQtkuxHcc0ivSAtJkWtdgnxRbmCvMMuPKELAq/cxqPfRSAf/sL/SI374DqlYnZDn/BCVA9Ab9TC/9g08QHSlGP+XV/CySecV5Z8bILCTV8bzcgMUznQSTuyIastzMHWLtcJ2zr4gE8jR393vRtAI9A=="));
|
System.out.println(service.rsaDecryptUserInfo("EpPlcAYvNOFfJWHBuvLkWzkTOoEk3NoO95FoRlEJTGlblyBEYV0CQWnCDd4yXDCgcR1yhaig/5NrIZ5dGTTgwZ6f0fOfVDdnFPr5/GUUzxxsW8qpdHLIswFT1O4E57ny1Df6uxPaE5Hqp3QHvGkfUo4ak2mI0D11V7XzxGmVsSqoofdrCVXJIRrTkUHJ3OSxtQtkuxHcc0ivSAtJkWtdgnxRbmCvMMuPKELAq/cxqPfRSAf/sL/SI374DqlYnZDn/BCVA9Ab9TC/9g08QHSlGP+XV/CySecV5Z8bILCTV8bzcgMUznQSTuyIastzMHWLtcJ2zr4gE8jR393vRtAI9A=="));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnDocid() throws Exception {
|
||||||
|
String encrypt = EncryptionFileIdUtil.encrypt("76");
|
||||||
|
String encode = URLEncoder.encode(encrypt, "UTF-8");
|
||||||
|
System.out.println(encode);
|
||||||
|
String decode = URLDecoder.decode(encode, "UTF-8");
|
||||||
|
System.out.println(EncryptionFileIdUtil.decrypt(decode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package youhong.ai.utiltest;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>其他测试</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/28 10:59</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class OtherTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
String str = "and alsdjf jsi3jtj";
|
||||||
|
System.out.println(str.substring(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package youhong.ai.utiltest;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
public class ShortEncryptionExample {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
String plaintext = "9384819";
|
||||||
|
String password = "SecretPassword";
|
||||||
|
|
||||||
|
// 补齐密码到合法长度
|
||||||
|
password = padPassword(password);
|
||||||
|
|
||||||
|
// 加密
|
||||||
|
String encryptedText = encrypt(plaintext, password);
|
||||||
|
|
||||||
|
// 解密
|
||||||
|
String decryptedText = decrypt(encryptedText, password);
|
||||||
|
|
||||||
|
System.out.println("原文: " + plaintext);
|
||||||
|
System.out.println("加密后: " + encryptedText);
|
||||||
|
System.out.println("解密后: " + decryptedText);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将密码补齐到合法长度
|
||||||
|
public static String padPassword(String password) {
|
||||||
|
byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8);
|
||||||
|
int validKeyLength = 16; // AES-128
|
||||||
|
if (passwordBytes.length < validKeyLength) {
|
||||||
|
byte[] paddedBytes = Arrays.copyOf(passwordBytes, validKeyLength);
|
||||||
|
return new String(paddedBytes, StandardCharsets.UTF_8);
|
||||||
|
} else if (passwordBytes.length > validKeyLength) {
|
||||||
|
return new String(Arrays.copyOf(passwordBytes, validKeyLength), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用AES对称加密算法和Base64编码进行加密
|
||||||
|
public static String encrypt(String plaintext, String password) throws Exception {
|
||||||
|
SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES");
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||||
|
byte[] encryptedData = cipher.doFinal(plaintext.getBytes(StandardCharsets.UTF_8));
|
||||||
|
return Base64.getEncoder().encodeToString(encryptedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用AES对称加密算法和Base64编码进行解密
|
||||||
|
public static String decrypt(String encryptedText, String password) throws Exception {
|
||||||
|
SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES");
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||||
|
byte[] decryptedData = cipher.doFinal(Base64.getDecoder().decode(encryptedText));
|
||||||
|
return new String(decryptedData, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue