保时捷提供文件下载接口,修改请求工具方法public

dev
youhong.ai 2023-06-29 14:57:22 +08:00
parent 2c3fcb7ac4
commit 47c31b05b5
20 changed files with 835 additions and 198 deletions

View File

@ -107,3 +107,121 @@ $(() => {
})
/* ******************* 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 ******************* */

View File

@ -244,7 +244,7 @@ public class Util extends weaver.general.Util {
str = str.substring(0, str.length() - 1);
}
if (str.trim().startsWith(removeSeparator)) {
str = str.substring(1);
str = str.substring(removeSeparator.length());
}
return str;
}

View File

@ -121,7 +121,7 @@ public class HttpUtils {
return getUrl;
}
private static String serializeParams(Map<String, Object> params) {
public static String serializeParams(Map<String, Object> params) {
if (params != null && params.size() > 0) {
StringBuilder builder = new StringBuilder();
for (Map.Entry<String, Object> entry : params.entrySet()) {
@ -1113,6 +1113,9 @@ public class HttpUtils {
}
private boolean isBean(Object o) {
if (Objects.isNull(o)) {
return false;
}
if (o instanceof Number) {
return false;
}
@ -1122,9 +1125,6 @@ public class HttpUtils {
if (o instanceof Boolean) {
return false;
}
if (Objects.isNull(o)) {
return false;
}
return !o.getClass().isPrimitive();
}

View File

@ -336,18 +336,18 @@ public class ResultMapper {
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
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 {
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;
}
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].toUpperCase(), rs.getFloat(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], 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.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
}
continue;
}
@ -475,39 +475,58 @@ public class ResultMapper {
} else {
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 (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 {
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;
}
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;
}
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
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 {
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;
}
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].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], 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(), value);
((Map<? super Object, ? super Object>) o).put(columnName[i], value);
}
continue;
}
@ -535,18 +554,18 @@ public class ResultMapper {
}
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 {
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;
}
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].toUpperCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i], 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(), value);
((Map<? super Object, ? super Object>) o).put(columnName[i], value);
}

View File

@ -17,8 +17,13 @@ import weaver.hrm.User;
import weaver.workflow.webservices.WorkflowRequestTableField;
import weaver.xuanran.wang.common.util.CommonUtil;
import java.util.*;
import java.util.concurrent.*;
import java.util.ArrayList;
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;
@ -39,11 +44,13 @@ public class BatchCreateWorkflowService {
private static final String CUSTOM_ID = "customId";
// private final MeetingMapper meetingTransMapper = Util.getTransMapper(MeetingMapper.class);
private final MeetingService meetingService = new MeetingService();
/**
* <h1> </h1>
*
* @param ids id
* @author xuanran.wang
* @dateTime 2023/2/24 10:21
* @param ids id
**/
public void cancelMeeting(String ids) {
meetingService.cancelMeeting(ids);
@ -51,10 +58,11 @@ public class BatchCreateWorkflowService {
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/2/22 17:10
*
* @param array
* @return
* @author xuanran.wang
* @dateTime 2023/2/22 17:10
**/
public List<CreateWfVO> batchCreateWorkflow(User user, JSONArray array) {
List<Future<CusCreateWfInfo>> list = new ArrayList<>();
@ -121,12 +129,13 @@ public class BatchCreateWorkflowService {
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/2/24 14:33
*
* @param user
* @param requestEntity
* @param index
* @return
* @author xuanran.wang
* @dateTime 2023/2/24 14:33
**/
public CusCreateWfInfo createWorkflow(User user,
ReqOperateRequestEntity requestEntity,
@ -155,10 +164,11 @@ public class BatchCreateWorkflowService {
/**
* <h1>jsonReqOperateRequestEntity</h1>
* @author xuanran.wang
* @dateTime 2023/2/24 13:36
*
* @param array json
* @return
* @author xuanran.wang
* @dateTime 2023/2/24 13:36
**/
public List<ReqOperateRequestEntity> checkParams(JSONArray array) {
ArrayList<ReqOperateRequestEntity> res = new ArrayList<>();

View File

@ -143,4 +143,5 @@ public class TaskElementController {
return ApiResult.error("system error!");
}
}
}

View File

@ -168,4 +168,22 @@ public interface TaskElementMapper {
*/
@Update("update uf_rwtzeq_dt1 set zjwczt = 0 where zjr = #{userId} and mainid = #{mainId}")
boolean updateTaskHandoverStatus(@ParamMapper("userId") String userId, @ParamMapper("mainId") String mainId);
/**
* <h2></h2>
*
* @param nameLike like
* @return likeid
*/
@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);
}

View File

@ -106,7 +106,10 @@ public class TaskElementService {
for (Map<String, Object> item : authorityList) {
if ("0".equals(dataSource)) {
// 自定义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);
if (CollectionUtil.isNotEmpty(list)) {
result.addAll(list);
@ -179,8 +182,10 @@ public class TaskElementService {
Map<String, Object> map = new HashMap<>(8);
map.put("currentDate", Util.getTime("yyyy-MM-dd"));
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();
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();
String key = Util.null2String(valueMap.get("key"));
String value = Util.null2String(valueMap.get("value"));
@ -196,6 +201,49 @@ public class TaskElementService {
}
}
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();
List<Map<String, Object>> authorityList = mapper.selectAuthority(viewAuthoritySql, user, map);

View File

@ -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();
}
}
}

View File

@ -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();
}
}

View File

@ -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>使AESBase64</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>使AESBase64</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);
}
}

View File

@ -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!");
}
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -2,7 +2,6 @@ package com.customization.youhong.pcn.createrworkflow.impl;
import aiyh.utils.Util;
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.engine.core.cfg.annotation.ServiceDynamicProxy;
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 CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();

View File

@ -2,6 +2,7 @@ package com.customization.youhong.pcn.createrworkflow.util;
import aiyh.utils.Util;
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.mapper.CheckWorkflowRequestParamsMapper;
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
@ -51,6 +52,8 @@ public class CheckWorkflowRequestParamsUtil {
if (CollectionUtil.isEmpty(detailList)) {
return;
}
log.info("checkCreateConfig: " + JSON.toJSONString(checkCreateConfig));
log.info("detailList " + JSON.toJSONString(detailList));
Map<String, CheckConditionItem> checkConditionItemMap;
List<CheckConditionItem> conditionGroupItems = checkCreateConfig.getConditionGroupItems();
if (CollectionUtil.isNotEmpty(conditionGroupItems)) {

View File

@ -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;
}
}

View File

@ -1,10 +1,14 @@
package youhong.ai.pcn;
import basetest.BaseTest;
import com.api.youhong.ai.pcn.download.service.EncryptionFileIdUtil;
import com.api.youhong.ai.pcn.ssoyunzhao.service.SsoYunZhaoService;
import org.junit.Test;
import weaver.hrm.User;
import java.net.URLDecoder;
import java.net.URLEncoder;
/**
* <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=="));
}
@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));
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}