Compare commits
2 Commits
b49b18e9d2
...
3f96ed75bc
Author | SHA1 | Date |
---|---|---|
youhong.ai | 3f96ed75bc | |
youhong.ai | 78bcb2ef1a |
|
@ -161,3 +161,51 @@ class CusUtils {
|
|||
}
|
||||
|
||||
window.Utils = new CusUtils()
|
||||
|
||||
|
||||
const getLeble = function (lable, defaultStr) {
|
||||
if (!langue[lable + '']) {
|
||||
return defaultStr;
|
||||
}
|
||||
let lableMap = langue[lable + '']
|
||||
const userInfo = JSON.parse(localStorage.getItem("theme-account"))
|
||||
if (!lableMap[userInfo.userLanguage + '']) {
|
||||
return defaultStr
|
||||
}
|
||||
return lableMap[userInfo.userLanguage + '']
|
||||
}
|
||||
|
||||
|
||||
class LanguageUtil {
|
||||
|
||||
static language = {
|
||||
'1': {
|
||||
'8': '英文',
|
||||
'7': '中文',
|
||||
'15': '日语'
|
||||
}
|
||||
}
|
||||
|
||||
static getLabel(label, defaultStr) {
|
||||
if (!LanguageUtil.language[label + '']) {
|
||||
return defaultStr;
|
||||
}
|
||||
let languageMap = LanguageUtil.language[label + '']
|
||||
let userInfo = JSON.parse(localStorage.getItem("theme-account"))
|
||||
if (!userInfo) {
|
||||
userInfo = {
|
||||
userLanguage: '7'
|
||||
}
|
||||
}
|
||||
|
||||
if (!languageMap[userInfo.userLanguage + '']) {
|
||||
return defaultStr
|
||||
}
|
||||
return languageMap[userInfo.userLanguage + '']
|
||||
}
|
||||
}
|
||||
|
||||
// export default CusUtils
|
||||
ecodeSDK.exp(LanguageUtil)
|
||||
window.LanguageUtil = LanguageUtil
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/* ******************* youhong.ai 转交任务提交状态修改 start ******************* */
|
||||
|
||||
$(() => {
|
||||
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)
|
||||
}
|
||||
|
||||
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, callback => {
|
||||
let obj = {}
|
||||
obj.actionId = WfForm.getFieldValue(WfForm.convertFieldNameToId('actionid'))
|
||||
obj.userId = WfForm.getFieldValue(WfForm.convertFieldNameToId('zjr', 'detail_1') + "_0")
|
||||
api({
|
||||
url: "/api/aiyh/ihg/task/submit-task",
|
||||
type: "POST",
|
||||
data: JSON.stringify(obj),
|
||||
isAsync: false,
|
||||
success(res) {
|
||||
if (res && res.code === 200) {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
complete() {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
/* ******************* youhong.ai 转交任务提交状态修改 end ******************* */
|
|
@ -751,13 +751,12 @@ $(() => {
|
|||
$(() => {
|
||||
let config = {
|
||||
// 基础年假
|
||||
base: 21,
|
||||
base: 20,
|
||||
// 入职日期
|
||||
dateField: 'jrbsjjtsj',
|
||||
// 年假
|
||||
targetField: 'nj'
|
||||
}
|
||||
|
||||
runJs()
|
||||
|
||||
function runJs() {
|
||||
|
@ -769,20 +768,22 @@ $(() => {
|
|||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.targetField), {value: njValue})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function calculateBonus(startDate, endDate, config) {
|
||||
const diffInMs = endDate.getTime() - startDate.getTime();
|
||||
const diffInYears = diffInMs / (1000 * 60 * 60 * 24 * 365);
|
||||
|
||||
if (diffInYears < 3) {
|
||||
return 0;
|
||||
} else if (diffInYears >= 3 && diffInYears < 6) {
|
||||
return config.base;
|
||||
} else if (diffInYears >= 3 && diffInYears < 6) {
|
||||
return config.base + 1;
|
||||
} else {
|
||||
const extraYears = Math.floor((diffInYears - 3) / 3);
|
||||
return config.base + extraYears * 2;
|
||||
let resultDay = config.base + extraYears * 2
|
||||
if (resultDay >= 25) {
|
||||
return 25;
|
||||
}
|
||||
return resultDay;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -77,7 +77,6 @@ import java.util.function.Predicate;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
* @author EBU7-dev1-ayh
|
||||
|
@ -1599,126 +1598,6 @@ public class Util extends weaver.general.Util {
|
|||
return getUtilService().getApiConfigMainTree(id);
|
||||
}
|
||||
|
||||
public static <T> AZipOutputStream createZip(List<T> inputList) throws IOException {
|
||||
return createZip(inputList, File.separator);
|
||||
}
|
||||
|
||||
private static <T> AZipOutputStream createZip(List<T> inputList, String base) throws IOException {
|
||||
FileOutputStream fileOutputStream = null;
|
||||
|
||||
try {
|
||||
File file = new File(AZipOutputStream.filePath);
|
||||
if (!file.exists()) {
|
||||
// 先得到文件的上级目录,并创建上级目录,在创建文件
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
// 创建文件
|
||||
file.createNewFile();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (fileOutputStream == null) {
|
||||
return null;
|
||||
}
|
||||
AZipOutputStream zipOut = new AZipOutputStream(fileOutputStream);
|
||||
int catchLen = 10 * 1024;
|
||||
for (int i = 0; i < inputList.size(); i++) {
|
||||
T item = inputList.get(i);
|
||||
if (item instanceof InputStream) {
|
||||
// 属于单级文件,直接压缩并返回
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(base + i));
|
||||
} catch (IOException e) {
|
||||
throw new IOException(e.toString());
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = ((InputStream) item).read(buffer)) != -1) {
|
||||
zipOut.write(buffer, 0, len);
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
if (item instanceof AInputStream) {
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(((AInputStream) item).getFileName()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = ((AInputStream) item).getInputStream().read(buffer)) != -1) {
|
||||
try {
|
||||
zipOut.write(buffer, 0, len);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
if (item instanceof ListZipEntity) {
|
||||
ListZipEntity listZipEntity = (ListZipEntity) item;
|
||||
if (listZipEntity.isDirectory()) {
|
||||
// 表示属于文件夹,循环添加处理文件夹
|
||||
handlerDirectory(listZipEntity.getFileList(), zipOut, base + listZipEntity.getDirectory() + File.separator);
|
||||
} else {
|
||||
List<AInputStream> aInputStreams = listZipEntity.getaInputStreamList();
|
||||
for (AInputStream aInputStream : aInputStreams) {
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(aInputStream.getFileName()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = (aInputStream.getInputStream()).read(buffer)) != -1) {
|
||||
try {
|
||||
zipOut.write(buffer, 0, len);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return zipOut;
|
||||
}
|
||||
|
||||
private static void handlerDirectory(List<ListZipEntity> fileList, AZipOutputStream zipOut, String base) throws IOException {
|
||||
int catchLen = 10 * 1024;
|
||||
for (ListZipEntity listZipEntity : fileList) {
|
||||
if (listZipEntity.isDirectory()) {
|
||||
// 如果是文件夹
|
||||
handlerDirectory(listZipEntity.getFileList(), zipOut, base + listZipEntity.getDirectory() + File.separator);
|
||||
} else {
|
||||
List<AInputStream> aInputStreams = listZipEntity.getaInputStreamList();
|
||||
for (AInputStream aInputStream : aInputStreams) {
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(aInputStream.getFileName()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = (aInputStream.getInputStream()).read(buffer)) != -1) {
|
||||
try {
|
||||
zipOut.write(buffer, 0, len);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> queryLanguage(int groupId, int languageId) {
|
||||
return getUtilService().queryLanguage(groupId, languageId);
|
||||
}
|
||||
|
@ -2266,7 +2145,6 @@ public class Util extends weaver.general.Util {
|
|||
if (otherLog.containsKey(name)) {
|
||||
return otherLog.get(name);
|
||||
}
|
||||
if (!otherLog.containsKey(name)) {
|
||||
synchronized (Util.otherLog) {
|
||||
if (otherLog.containsKey(name)) {
|
||||
return otherLog.get(name);
|
||||
|
@ -2330,8 +2208,6 @@ public class Util extends weaver.general.Util {
|
|||
return cusLog;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自定义配置参数值
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
package aiyh.utils.entity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import weaver.file.FileUpload;
|
||||
import weaver.system.SystemComInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author EBU7-dev1-ayh
|
||||
* @create 2021/10/25 0025 17:38
|
||||
* zipoutputstaream
|
||||
*/
|
||||
|
||||
|
||||
public class AZipOutputStream extends ZipOutputStream {
|
||||
|
||||
private ZipOutputStream zipOutputStream;
|
||||
public static String filePath;
|
||||
private OutputStream out;
|
||||
static {
|
||||
filePath = FileUpload.getCreateDir(new SystemComInfo().getFilesystem()) + "tempfile" + File.separator;
|
||||
filePath += "zip" + File.separator + System.currentTimeMillis() + UUID.randomUUID() + ".zip";
|
||||
}
|
||||
|
||||
public AZipOutputStream(@NotNull OutputStream out) {
|
||||
super(out);
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
public AZipOutputStream(@NotNull OutputStream out, @NotNull Charset charset) {
|
||||
super(out, charset);
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
Files.deleteIfExists(Paths.get(AZipOutputStream.filePath));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
out.flush();
|
||||
super.flush();
|
||||
super.close();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
public ZipOutputStream getZipOutputStream() {
|
||||
return zipOutputStream;
|
||||
}
|
||||
|
||||
public void setZipOutputStream(ZipOutputStream zipOutputStream) {
|
||||
this.zipOutputStream = zipOutputStream;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package aiyh.utils.function;
|
||||
|
||||
/**
|
||||
* <h1>三个参数的function</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 21:30</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Bi3Function<A, B, C, R> {
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param a the first function argument
|
||||
* @param b the second function argument
|
||||
* @param c the second function argument
|
||||
* @return the function result
|
||||
*/
|
||||
R apply(A a, B b, C c);
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package aiyh.utils.function;
|
||||
|
||||
/**
|
||||
* <h1>三个参数的function</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 21:30</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Bi4Function<A, B, C, D, R> {
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param a the first function argument
|
||||
* @param b the second function argument
|
||||
* @param c the second function argument
|
||||
* @param d the second function argument
|
||||
* @return the function result
|
||||
*/
|
||||
R apply(A a, B b, C c, D d);
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.api.test.aiyh.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import weaver.workflow.msg.MsgPushUtil;
|
||||
import weaver.workflow.msg.entity.MsgEntity;
|
||||
|
@ -11,7 +12,9 @@ import javax.ws.rs.GET;
|
|||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>ceshi </h1>
|
||||
|
@ -36,4 +39,15 @@ public class RequestMsgNotifiyController {
|
|||
new MsgPushUtil().pushMsg(operateMsg);
|
||||
return "";
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/test/cus-api")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String testCusApiJiaoYan() {
|
||||
Map<String, Object> result = new HashMap<>(8);
|
||||
result.put("key", "asldfjalksd");
|
||||
result.put("name", "test");
|
||||
return ApiResult.success(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,14 @@ public class TaskElementController {
|
|||
|
||||
private final TaskElementService service = new TaskElementService();
|
||||
|
||||
/**
|
||||
* <h2>查询任务列表</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @param itemGroup 分组值
|
||||
* @return 任务列表
|
||||
*/
|
||||
@Path("/list-get")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -43,6 +51,15 @@ public class TaskElementController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>搜索任务信息</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @param params 请求参数
|
||||
* @param configId 配置id
|
||||
* @return 任务信息列表
|
||||
*/
|
||||
@Path("/search-list")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -61,6 +78,13 @@ public class TaskElementController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询按钮权限</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @return 按钮权限信息
|
||||
*/
|
||||
@Path("/get-btn")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -77,6 +101,11 @@ public class TaskElementController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>清除配置信息</h2>
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Path("/clear-config")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -89,4 +118,29 @@ public class TaskElementController {
|
|||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>提交转发任务修改状态</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @param params 请求参数
|
||||
* @return 更新状态
|
||||
*/
|
||||
@Path("/submit-task")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String submitTask(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response,
|
||||
@RequestBody Map<String, Object> params) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ApiResult.success(service.submitTask(user, params));
|
||||
} catch (Exception e) {
|
||||
log.error("提交转交任务状态写入失败!" + Util.getErrString(e));
|
||||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,4 +150,22 @@ public interface TaskElementMapper {
|
|||
String selectConvert(@SqlString String sql, @ParamMapper("value") String o);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询主表ID</h2>
|
||||
*
|
||||
* @param actionId actionId
|
||||
* @return 主表id
|
||||
*/
|
||||
@Select("select id from uf_rwtzeq where touchpointbh = #{actionId}")
|
||||
String selectTaskMainId(String actionId);
|
||||
|
||||
/**
|
||||
* <h2>更新被转交任务状态</h2>
|
||||
*
|
||||
* @param userId 当前用户
|
||||
* @param mainId 主表ID
|
||||
* @return 更新状态
|
||||
*/
|
||||
@Update("update uf_rwtzeq_dt1 set zjwczt = 0 where zjr = #{userId} and mainid = #{mainId}")
|
||||
boolean updateTaskHandoverStatus(@ParamMapper("userId") String userId, @ParamMapper("mainId") String mainId);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import aiyh.utils.excention.CustomerException;
|
|||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.lang.Assert;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.youhong.ai.ihgzhouji.taskele.entity.IhgTaskElementConfigItem;
|
||||
import com.api.youhong.ai.ihgzhouji.taskele.mapper.TaskElementMapper;
|
||||
import com.api.youhong.ai.ihgzhouji.taskele.mapstruct.TaskElementMapstruct;
|
||||
|
@ -243,4 +244,29 @@ public class TaskElementService {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>提交转交任务修改转交任务状态</h2>
|
||||
*
|
||||
* @param user 当前登录用户
|
||||
* @param params 请求参数
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
public Object submitTask(User user, Map<String, Object> params) {
|
||||
String actionId = Util.null2String(params.get("actionId"));
|
||||
String userId = Util.null2String(params.get("userId"));
|
||||
if (!userId.equals(Util.null2String(user.getUID()))) {
|
||||
throw new CustomerException("被转交人和当前登录人不一致!");
|
||||
}
|
||||
String mainId = mapper.selectTaskMainId(actionId);
|
||||
if (StrUtil.isBlank(mainId)) {
|
||||
throw new CustomerException("无法查询到对应的任务信息!");
|
||||
}
|
||||
// 更新被转交人转交任务状态
|
||||
boolean flag = mapper.updateTaskHandoverStatus(userId, mainId);
|
||||
if (!flag) {
|
||||
log.error("更新被转交任务状态失败!当前用户信息以及请求参数:" + JSON.toJSONString(params));
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.youhong.ai.ihgzhouji.userinfoel.service.UserInfoService;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* <h1>获取用户信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/11 22:11</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Path("/aiyh/user-info")
|
||||
public class UserInfoController {
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
private final UserInfoService service = new UserInfoService();
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/get")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getUserInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ApiResult.success(service.getUserInfo(user));
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户信息失败!" + Util.getErrString(e));
|
||||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
import aiyh.utils.annotation.recordset.SqlString;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/6/11 22:25</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface UserInfoMapper {
|
||||
|
||||
/**
|
||||
* <h2>查询按钮权限</h2>
|
||||
*
|
||||
* @param sql 按钮权限sql
|
||||
* @param user 当前用户
|
||||
* @return 查询到的数据
|
||||
*/
|
||||
@Select(custom = true)
|
||||
Map<String, Object> selectAuthoritySql(@SqlString String sql, User user);
|
||||
|
||||
/**
|
||||
* <h2>查询是否是酒店人员</h2>
|
||||
*
|
||||
* @param uid 当前人员
|
||||
* @return 酒店数量
|
||||
*/
|
||||
/*@Select("select count(id)\n" +
|
||||
"from uf_hotelinfo\n" +
|
||||
"where\n" +
|
||||
" concat(',',salesmarketingleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',revenueleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',financeleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',fbleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',hrleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',generalmanager,',') like concat(',', #{uID},',')")*/
|
||||
@Select("select count(id) from uf_hotelinfo where\n" +
|
||||
"concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',humanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',commercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',revenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',financebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',rbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',engineering,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofopsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofhumanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofcommercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrevenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofengineering,',') like concat(',',#{userId},',')")
|
||||
Integer selectIsHotel(int uid);
|
||||
|
||||
/**
|
||||
* <h2>查询酒店信息</h2>
|
||||
*
|
||||
* @param hotelIndex 酒店编码
|
||||
* @return 酒店信息
|
||||
*/
|
||||
@Select("select * from v_commercial \n" +
|
||||
" where holidex = #{hotelIndex}")
|
||||
Map<String, Object> selectHotelInfo(String hotelIndex);
|
||||
|
||||
/**
|
||||
* <h2>查询人员信息</h2>
|
||||
*
|
||||
* @param uid 当前人员
|
||||
* @return 人员信息
|
||||
*/
|
||||
@Select("select id,lastname,messagerurl,departmentid from hrmresource where id = #{userId}")
|
||||
Map<String, Object> selectHrmInfo(int uid);
|
||||
|
||||
/**
|
||||
* <h2>查询角色信息</h2>
|
||||
*
|
||||
* @param uid 当前人员
|
||||
* @param hotelIndex 酒店编码
|
||||
* @return 角色信息
|
||||
*/
|
||||
@Select("select * from uf_hotelinfo where\n" +
|
||||
"(concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',subregionadmin,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',humanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',commercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',revenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',financebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',rbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',engineering,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofopsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofhumanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofcommercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrevenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofengineering,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',generalmanager,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',salesmarketingleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',revenueleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',financeleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',fbleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',hrleader,',') like concat(',',#{userId},',')) " +
|
||||
"and holidex = #{hotelIndex}")
|
||||
List<Map<String, Object>> selectRoles(@ParamMapper("userId") int uid, @ParamMapper("hotelIndex") String hotelIndex);
|
||||
|
||||
/**
|
||||
* <h2>查询部门信息</h2>
|
||||
*
|
||||
* @param departmentId 部门id
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Select("select id,departmentname,departmentcode,departmentmark from hrmdepartment where id = #{departmentId}")
|
||||
Map<String, Object> selectDepartmentInfo(String departmentId);
|
||||
|
||||
/**
|
||||
* <h2>查询所有下级部门信息</h2>
|
||||
*
|
||||
* @param gCSupportCenterId 支持中心部门
|
||||
* @return 所有部门信息
|
||||
*/
|
||||
@Select("select *\n" +
|
||||
"from (\n" +
|
||||
"WITH RECURSIVE subdepts AS (\n" +
|
||||
"SELECT id, DEPARTMENTNAME, SUPDEPID\n" +
|
||||
"FROM HrmDepartment\n" +
|
||||
"WHERE id = #{gCSupportCenterId}\n" +
|
||||
"UNION ALL\n" +
|
||||
"SELECT\n" +
|
||||
" d.id, \n" +
|
||||
" d.DEPARTMENTNAME,\n" +
|
||||
" d.SUPDEPID\n" +
|
||||
"FROM HrmDepartment d\n" +
|
||||
"JOIN subdepts sd ON d.SUPDEPID = sd.id)\n" +
|
||||
" SELECT *\n" +
|
||||
" FROM subdepts) temp;")
|
||||
List<Map<String, Object>> selectGCSupportCenterDep(String gCSupportCenterId);
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.api.youhong.ai.ihgzhouji.userinfoel.mapper.UserInfoMapper;
|
||||
import com.api.youhong.ai.ihgzhouji.userinfoel.vo.UserInfoVo;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author youhong.ai
|
||||
*/
|
||||
public class UserInfoService {
|
||||
private final UserInfoMapper mapper = Util.getMapper(UserInfoMapper.class);
|
||||
private final static Map<String, String> ROLES_MAP = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* <h2>获取用户信息</h2>
|
||||
*
|
||||
* @param user 当前登录用户
|
||||
* @return 用户信息
|
||||
*/
|
||||
public UserInfoVo getUserInfo(User user) {
|
||||
UserInfoVo userInfoVo = new UserInfoVo();
|
||||
String taskDispatchAuthority = Util.getCusConfigValue("TaskDispatchAuthority");
|
||||
String taskAcceptanceAuthority = Util.getCusConfigValue("TaskAcceptanceAuthority");
|
||||
String gCSupportCenterId = Util.getCusConfigValue("GCSupportCenterId");
|
||||
// 查询任务下发
|
||||
if (StrUtil.isNotBlank(taskDispatchAuthority)) {
|
||||
Map<String, Object> map = this.mapper.selectAuthoritySql(taskDispatchAuthority, user);
|
||||
if (CollectionUtil.isNotEmpty(map)) {
|
||||
userInfoVo.setTaskDispatch(true);
|
||||
}
|
||||
}
|
||||
// 查询任务清单
|
||||
if (StrUtil.isNotBlank(taskAcceptanceAuthority)) {
|
||||
Map<String, Object> map = this.mapper.selectAuthoritySql(taskAcceptanceAuthority, user);
|
||||
if (CollectionUtil.isNotEmpty(map)) {
|
||||
userInfoVo.setTaskAcceptance(true);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询用户信息
|
||||
Map<String, Object> userInfo = this.mapper.selectHrmInfo(user.getUID());
|
||||
if (CollectionUtil.isNotEmpty(userInfo)) {
|
||||
userInfoVo.setUserInfo(userInfo);
|
||||
// 查询支持中心所有部门
|
||||
List<Map<String, Object>> depList = mapper.selectGCSupportCenterDep(gCSupportCenterId);
|
||||
Map<String, Object> department = findMapById(depList, user.getUserDepartment());
|
||||
String hotelIndex = null;
|
||||
if (CollectionUtil.isEmpty(department)) {
|
||||
// 不属于支持中心人,查询对应酒店信息
|
||||
String lastname = Util.null2String(userInfo.get("lastname"));
|
||||
if (StrUtil.isBlank(lastname)) {
|
||||
throw new CustomerException("获取酒店人员信息失败!未查询到人员姓名");
|
||||
}
|
||||
|
||||
String[] split = lastname.split("-");
|
||||
if (split.length <= 1) {
|
||||
throw new CustomerException("获取酒店人员信息失败!lastName中不存在酒店代码");
|
||||
}
|
||||
hotelIndex = split[split.length - 1];
|
||||
Map<String, Object> hotelInfo = this.mapper.selectHotelInfo(hotelIndex);
|
||||
userInfoVo.setHotelInfo(hotelInfo);
|
||||
} else {
|
||||
// 支持中心,显示部门信息
|
||||
userInfoVo.setDepartmentInfo(department);
|
||||
}
|
||||
// 如果存在酒店信息
|
||||
if (StrUtil.isNotBlank(hotelIndex)) {
|
||||
List<Map<String, Object>> hotelRoles = this.mapper.selectRoles(user.getUID(), hotelIndex);
|
||||
if (CollectionUtil.isEmpty(hotelRoles)) {
|
||||
return userInfoVo;
|
||||
}
|
||||
Set<String> roleNames = new HashSet<>();
|
||||
// 循环酒店角色信息
|
||||
for (Map<String, Object> hotelRole : hotelRoles) {
|
||||
// 循环酒店角色名称
|
||||
for (Map.Entry<String, String> entry : ROLES_MAP.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (!hotelRole.containsKey(key)) {
|
||||
continue;
|
||||
}
|
||||
String value = Util.null2String(hotelRole.get(key));
|
||||
// 如果在酒店名称中找到对应的人,则为角色名
|
||||
if (StrUtil.isBlank(value)) {
|
||||
continue;
|
||||
}
|
||||
String[] split = value.split(",");
|
||||
List<String> strings = Arrays.asList(split);
|
||||
if (strings.contains(Util.null2String(user.getUID()))) {
|
||||
roleNames.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
userInfoVo.setRoleNames(roleNames);
|
||||
}
|
||||
}
|
||||
return userInfoVo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查找对应的部门</h2>
|
||||
*
|
||||
* @param dataList 部门列表
|
||||
* @param id 部门id
|
||||
* @return 部门信息
|
||||
*/
|
||||
public static Map<String, Object> findMapById(List<Map<String, Object>> dataList, int id) {
|
||||
for (Map<String, Object> map : dataList) {
|
||||
if (map.containsKey("id") && Integer.parseInt(Util.null2String(map.get("id"))) == id) {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* <h2>获取酒店角色信息</h2>
|
||||
*
|
||||
* @return 酒店角色信息
|
||||
*/
|
||||
static {
|
||||
ROLES_MAP.put("olt", "OLT");
|
||||
ROLES_MAP.put("vpo", "VPO");
|
||||
ROLES_MAP.put("subregionadmin", "Sub Region Admin");
|
||||
ROLES_MAP.put("opsconsultant", "Ops Consultant");
|
||||
ROLES_MAP.put("humanresources", "Human Resources");
|
||||
ROLES_MAP.put("commercialperformance", "Commercial Performance");
|
||||
ROLES_MAP.put("revenuemanagement", "Revenue Management");
|
||||
ROLES_MAP.put("financebusinesssupport", "Finance & Business Support");
|
||||
ROLES_MAP.put("rbeoperations", "RB&E Operations");
|
||||
ROLES_MAP.put("engineering", "Engineering");
|
||||
ROLES_MAP.put("headofopsconsultant", "Head of Ops Consultant");
|
||||
ROLES_MAP.put("headofhumanresources", "Head of Human Resources");
|
||||
ROLES_MAP.put("headofcommercialperformance", "Head of Commercial Performance");
|
||||
ROLES_MAP.put("headofrevenuemanagement", "Head of Revenue Management");
|
||||
ROLES_MAP.put("headoffinancebusinesssupport", "Head of Finance & Business Support");
|
||||
ROLES_MAP.put("headofrbeoperations", "Head of RB&E Operations");
|
||||
ROLES_MAP.put("headofengineering", "Head of Engineering");
|
||||
ROLES_MAP.put("generalmanager", "General Manager");
|
||||
ROLES_MAP.put("salesmarketingleader", "Sales & Marketing leader");
|
||||
ROLES_MAP.put("revenueleader", "Revenue Leader");
|
||||
ROLES_MAP.put("financeleader", "Finance Leader");
|
||||
ROLES_MAP.put("fbleader", "F&B Leader");
|
||||
ROLES_MAP.put("hrleader", "HR Leader");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <h1>用户信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/11 22:16</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class UserInfoVo {
|
||||
|
||||
/** 任务下发权限 */
|
||||
private boolean taskDispatch;
|
||||
|
||||
/** 任务接收权限 */
|
||||
private boolean taskAcceptance;
|
||||
|
||||
/** 酒店信息 */
|
||||
Map<String, Object> hotelInfo;
|
||||
|
||||
/** 用户信息 */
|
||||
Map<String, Object> userInfo;
|
||||
|
||||
/** 角色 */
|
||||
Set<String> roleNames;
|
||||
|
||||
/** 部门信息 */
|
||||
Map<String, Object> departmentInfo;
|
||||
|
||||
}
|
|
@ -42,15 +42,15 @@ public interface OrgChartMapper {
|
|||
" job.JOBTITLENAME job_title_name, " +
|
||||
" uftb.$t{parentField} type_of_employment " +
|
||||
"from hrmresource hrm " +
|
||||
" left join hrmjobtitles job on hrm.JOBTITLE = job.id " +
|
||||
" left join cus_fielddata cus on cus.ID = hrm.ID " +
|
||||
" inner join hrmjobtitles job on hrm.JOBTITLE = job.id " +
|
||||
" inner join cus_fielddata cus on cus.ID = hrm.ID " +
|
||||
" and cus.SCOPE = 'HrmCustomFieldByInfoType' " +
|
||||
" and cus.SCOPEID = 1 " +
|
||||
" left join cus_fielddata cus1 on cus1.id = hrm.id" +
|
||||
" inner join cus_fielddata cus1 on cus1.id = hrm.id" +
|
||||
" and cus1.scope = 'HrmCustomFieldByInfoType' " +
|
||||
" and cus1.scopeid = -1" +
|
||||
" left join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
||||
" left join $t{typeOfEmploymentTable} uftb on uftb.$t{typeOfEmploymentIdField} = cus1.$t{typeOfEmploymentFiled} " +
|
||||
" inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
||||
" inner join $t{typeOfEmploymentTable} uftb on uftb.$t{typeOfEmploymentIdField} = cus1.$t{typeOfEmploymentFiled} " +
|
||||
"where hrm.status in (0, 1)")
|
||||
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
|
||||
@ParamMapper("lastNameEnField") String lastNameEnField,
|
||||
|
|
|
@ -47,6 +47,11 @@ public class OrgChartService {
|
|||
if (userId == 1) {
|
||||
return systemAdminTree(hrmResourceDtoList);
|
||||
}
|
||||
/* ******************* 次账号处理逻辑 ******************* */
|
||||
String accountType = logInUser.getAccount_type();
|
||||
if ("1".equals(accountType)) {
|
||||
return secondaryAccountTree(hrmResourceDtoList);
|
||||
}
|
||||
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
||||
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
||||
ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId);
|
||||
|
@ -111,6 +116,7 @@ public class OrgChartService {
|
|||
if (userId == 1) {
|
||||
return systemAdminTree(hrmResourceDtoList);
|
||||
}
|
||||
|
||||
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
||||
List<OrgChartNodeVo> orgChartNodeVoList = null;
|
||||
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||
|
@ -145,6 +151,8 @@ public class OrgChartService {
|
|||
* @param logInUser 当前登陆用户
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
|
||||
|
||||
private void filterCurrentSubCom(List<HrmResourceDto> hrmResourceDtoList,
|
||||
AtomicReference<HrmResourceDto> currentUser,
|
||||
User logInUser) {
|
||||
|
@ -192,7 +200,7 @@ public class OrgChartService {
|
|||
.with(OrgChartNodeVo::setCurrent, true)
|
||||
.endSet())
|
||||
.collect(Collectors.toList());
|
||||
return Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
||||
List<OrgChartNodeVo> orgChartNodeVoList = Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
||||
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
|
||||
parentId -> parentId == null || parentId <= 0)
|
||||
.stream().peek(item -> Builder.startSet(item)
|
||||
|
@ -201,6 +209,40 @@ public class OrgChartService {
|
|||
.endSet())
|
||||
.peek(item -> recursionChildrenNums(item, 0))
|
||||
.collect(Collectors.toList());
|
||||
sortByNameFirstLetter(orgChartNodeVoList);
|
||||
return orgChartNodeVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>次账号返回数据数据</h2>
|
||||
* <i>2023/06/13 17:15</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param hrmResourceDtoList 人力资源dtolist
|
||||
* @return List<OrgChartNodeVo> 树型list
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private List<OrgChartNodeVo> secondaryAccountTree(List<HrmResourceDto> hrmResourceDtoList) {
|
||||
List<OrgChartNodeVo> collect = hrmResourceDtoList.stream()
|
||||
.map(struct::hrmResourceDtoToVo)
|
||||
.peek(item -> Builder.startSet(item)
|
||||
.with(OrgChartNodeVo::setShow, 1)
|
||||
.with(OrgChartNodeVo::setShowBrother, 1)
|
||||
.with(OrgChartNodeVo::setShowChildren, 1)
|
||||
.with(OrgChartNodeVo::setCurrent, true)
|
||||
.endSet())
|
||||
.collect(Collectors.toList());
|
||||
List<OrgChartNodeVo> orgChartNodeVoList = Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
||||
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
|
||||
parentId -> parentId == null || parentId <= 0)
|
||||
.stream().peek(item -> Builder.startSet(item)
|
||||
.with(OrgChartNodeVo::setIsRoot, true)
|
||||
.with(OrgChartNodeVo::setCurrent, true)
|
||||
.endSet())
|
||||
.peek(item -> recursionChildrenNums(item, 0))
|
||||
.collect(Collectors.toList());
|
||||
sortByNameFirstLetter(orgChartNodeVoList);
|
||||
return orgChartNodeVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package com.customization.youhong.pcn.createrworkflow;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.engine.workflow.constant.PAResponseCode;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <h1>创建流程参数校验异常信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 15:22</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class CreateRequestException extends RuntimeException {
|
||||
private final Logger logger = Util.getLogger();
|
||||
private final String msg;
|
||||
private Throwable throwable;
|
||||
private Integer code = -1;
|
||||
|
||||
private PAResponseCode responseCode;
|
||||
|
||||
public CreateRequestException(Throwable throwable) {
|
||||
super(throwable);
|
||||
this.msg = throwable.getMessage();
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
|
||||
public CreateRequestException(String msg, PAResponseCode responseCode) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, String... obj) {
|
||||
super(Util.logStr(msg, obj));
|
||||
this.msg = Util.logStr(msg, obj);
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, Integer code) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, Integer code, Throwable throwable) {
|
||||
super(msg, throwable);
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, Throwable throwable) {
|
||||
super(msg, throwable);
|
||||
this.msg = msg;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public PAResponseCode getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.msg;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
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;
|
||||
import com.engine.core.impl.aop.AbstractServiceProxy;
|
||||
import com.engine.workflow.constant.PAResponseCode;
|
||||
import com.engine.workflow.entity.publicApi.PAResponseEntity;
|
||||
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
|
||||
import com.engine.workflow.publicApi.WorkflowRequestOperatePA;
|
||||
import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>检查流程创建流程参数</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 14:14</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@ServiceDynamicProxy(target = WorkflowRequestOperatePAImpl.class, desc = "公共接口创建流程对流程参数校验")
|
||||
public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy implements WorkflowRequestOperatePA {
|
||||
|
||||
private final Logger log = Util.getLogger("workflow");
|
||||
|
||||
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||
|
||||
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();
|
||||
|
||||
@Override
|
||||
@ServiceMethodDynamicProxy(desc = "子流程触发时,做流程转数据")
|
||||
public PAResponseEntity doCreateRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
try {
|
||||
try {
|
||||
checkUtil.checkRequestParam(user, requestParam);
|
||||
return (PAResponseEntity) executeMethod(user, requestParam);
|
||||
} catch (CreateRequestException e) {
|
||||
PAResponseEntity paResponseEntity = new PAResponseEntity();
|
||||
paResponseEntity.setCode(e.getResponseCode());
|
||||
Map<String, Object> errorMsg = new HashMap<>(8);
|
||||
errorMsg.put("msg", e.getMsg());
|
||||
paResponseEntity.setErrMsg(errorMsg);
|
||||
return paResponseEntity;
|
||||
} catch (Exception e) {
|
||||
log.error("自定义流程创建校验请求参数出错:" + Util.getErrString(e));
|
||||
PAResponseEntity paResponseEntity = new PAResponseEntity();
|
||||
paResponseEntity.setCode(PAResponseCode.SYSTEM_INNER_ERROR);
|
||||
Map<String, Object> errorMsg = new HashMap<>(8);
|
||||
errorMsg.put("msg", "system error!");
|
||||
paResponseEntity.setErrMsg(errorMsg);
|
||||
return paResponseEntity;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("自定义流程创建校验请求参数出错:" + Util.getErrString(e));
|
||||
return (PAResponseEntity) executeMethod(user, requestParam);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity withdrawRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity submitRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity forwardRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity rejectRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity doForceDrawBack(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity doForceOver(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity deleteRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity saveRequestLog(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity doIntervenor(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity getNodeOperator(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity getNodeMenu(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity getCanRejectNodes(User user, ReqOperateRequestEntity request2Entity) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>mapper</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 14:20</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface CheckWorkflowRequestParamsMapper {
|
||||
|
||||
|
||||
@Select("select * from table where workflow_type = #{workflowId}")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(
|
||||
property = "detailList",
|
||||
column = "id",
|
||||
id = @Id(value = String.class, methodId = 1)
|
||||
),
|
||||
@CollectionMapping(
|
||||
property = "conditionGroupItems",
|
||||
column = "id",
|
||||
id = @Id(value = String.class, methodId = 2)
|
||||
),
|
||||
})
|
||||
CheckCreateConfig selectCheckConfig(int workflowId);
|
||||
|
||||
|
||||
@Select("select * from table_dt1 where mainid = #{mainId}")
|
||||
@Associations({
|
||||
@Association(
|
||||
property = "workflowField",
|
||||
column = "workflow_field",
|
||||
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||
id = @Id(Integer.class)
|
||||
)
|
||||
})
|
||||
@CollectionMethod(value = 1, desc = "查询明细表1,参数校验配置")
|
||||
List<CheckCreateConfigDetail> selectCheckDetail(String mainId);
|
||||
|
||||
|
||||
@Select("select * from table_dt2 where mainid = #{mainId}")
|
||||
@CollectionMethod(value = 2, desc = "查询明细表2,条件配置参数")
|
||||
List<CheckConditionItem> selectConditionDetail(String mainId);
|
||||
|
||||
|
||||
@Select(custom = true)
|
||||
Map<String, Object> selectCustomerSql(@SqlString String sql,
|
||||
@ParamMapper("value") String value,
|
||||
@ParamMapper("user") User user);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 17:52</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CheckConditionItem {
|
||||
|
||||
/** id */
|
||||
private Integer id;
|
||||
|
||||
/** 条件名称 */
|
||||
private String conditionName;
|
||||
|
||||
/** 条件规则 */
|
||||
private Integer conditionRule;
|
||||
|
||||
/** 条件自定义 */
|
||||
private String customerValue;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>检查流程请求参数校验配置信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 17:21</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CheckCreateConfig {
|
||||
/** 流程id */
|
||||
private Integer workflowId;
|
||||
|
||||
/** 描述 */
|
||||
private String desc;
|
||||
|
||||
/** 检查配置明细 */
|
||||
private List<CheckCreateConfigDetail> detailList;
|
||||
|
||||
/** 条件分组配置 */
|
||||
private List<CheckConditionItem> conditionGroupItems;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.pojo;
|
||||
|
||||
import aiyh.utils.entity.FieldViewInfo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 17:24</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CheckCreateConfigDetail {
|
||||
|
||||
/** id */
|
||||
private Integer id;
|
||||
|
||||
/** 流程字段 */
|
||||
private FieldViewInfo workflowField;
|
||||
|
||||
/** 是否允许为null */
|
||||
private String allowNull;
|
||||
|
||||
/** 校验规则 */
|
||||
private String checkRule;
|
||||
|
||||
/** 自定义值 */
|
||||
private String customerValue;
|
||||
|
||||
/** 校验表达式 */
|
||||
private String checkExpression;
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.util;
|
||||
|
||||
import aiyh.utils.ScriptUtil;
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.annotation.MethodRuleNo;
|
||||
import aiyh.utils.function.Bi4Function;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>检查方法校验工具</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 18:30</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class CheckRuleMethodUtil {
|
||||
|
||||
private static final Logger log = Util.getLogger();
|
||||
|
||||
private static final CheckWorkflowRequestParamsMapper MAPPER = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||
public static final Map<Integer,
|
||||
Bi4Function<
|
||||
WorkflowRequestTableField,
|
||||
CheckCreateConfigDetail,
|
||||
CheckConditionItem,
|
||||
User,
|
||||
Boolean
|
||||
>
|
||||
> CHECK_RULE_MAP = new HashMap<>(8);
|
||||
|
||||
static {
|
||||
try {
|
||||
Class<CheckRuleMethodUtil> checkRuleMethodUtilClass = CheckRuleMethodUtil.class;
|
||||
Method[] methods = checkRuleMethodUtilClass.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
|
||||
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
||||
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
||||
int value = annotation.value();
|
||||
CHECK_RULE_MAP.put(value, (workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user) -> {
|
||||
try {
|
||||
return (Boolean) method.invoke(null, workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("初始化CheckRuleMethodUtil失败!" + Util.getErrString(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 0, desc = "不为null")
|
||||
public static boolean noNull(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
return StrUtil.isNotBlank(workflowRequestTableField.getFieldValue());
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 1, desc = "整数类型")
|
||||
public static boolean isNumber(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
try {
|
||||
Integer.parseInt(workflowRequestTableField.getFieldValue());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 2, desc = "小数类型")
|
||||
public static boolean isDouble(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
try {
|
||||
Double.parseDouble(workflowRequestTableField.getFieldValue());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 3, desc = "枚举值")
|
||||
public static boolean isEnumerate(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
if (StrUtil.isNotBlank(customerValue)) {
|
||||
String[] split = customerValue.split(",");
|
||||
return Arrays.asList(split).contains(fieldValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 4, desc = "自定义sql存在值")
|
||||
public static boolean customerSqlHasValue(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
|
||||
return CollectionUtil.isNotEmpty(map);
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 5, desc = "自定义sql校验表达式")
|
||||
public static boolean customerSqlCheck(WorkflowRequestTableField workflowRequestTableField,
|
||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
||||
CheckConditionItem checkConditionItem, User user) {
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
|
||||
if (CollectionUtil.isNotEmpty(map)) {
|
||||
String checkExpression = checkCreateConfigDetail.getCheckExpression();
|
||||
if (StrUtil.isNotBlank(checkExpression)) {
|
||||
return (Boolean) ScriptUtil.invokeScript(checkExpression, map);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.util;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import com.customization.youhong.pcn.createrworkflow.CreateRequestException;
|
||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
|
||||
import weaver.hrm.User;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <h1>工具</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 14:20</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class CheckWorkflowRequestParamsUtil {
|
||||
|
||||
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||
|
||||
|
||||
/**
|
||||
* ************************************************************
|
||||
* <h2>checkRequestParam 自定义参数校验</h2>
|
||||
* <i>2023/6/14 15:31</i>
|
||||
*
|
||||
* @param user: 当前用户
|
||||
* @param requestParam: 请求参数
|
||||
* @author youHong.ai
|
||||
* ************************************************************
|
||||
*/
|
||||
public void checkRequestParam(User user, ReqOperateRequestEntity requestParam) throws CreateRequestException {
|
||||
int workflowId = requestParam.getWorkflowId();
|
||||
CheckCreateConfig checkCreateConfig = mapper.selectCheckConfig(workflowId);
|
||||
if (Objects.isNull(checkCreateConfig)) {
|
||||
return;
|
||||
}
|
||||
List<CheckCreateConfigDetail> detailList = checkCreateConfig.getDetailList();
|
||||
if (CollectionUtil.isEmpty(detailList)) {
|
||||
return;
|
||||
}
|
||||
Map<String, CheckConditionItem> checkConditionItemMap;
|
||||
List<CheckConditionItem> conditionGroupItems = checkCreateConfig.getConditionGroupItems();
|
||||
if (CollectionUtil.isNotEmpty(conditionGroupItems)) {
|
||||
checkConditionItemMap =
|
||||
conditionGroupItems.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
CheckConditionItem::getConditionName,
|
||||
value -> value
|
||||
));
|
||||
} else {
|
||||
checkConditionItemMap = new HashMap<>(8);
|
||||
}
|
||||
Map<String, CheckCreateConfigDetail> checkDetailMap =
|
||||
detailList.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
item -> item.getWorkflowField().getFieldName(),
|
||||
value -> value
|
||||
)
|
||||
);
|
||||
checkMainData(checkDetailMap, checkConditionItemMap, requestParam);
|
||||
}
|
||||
|
||||
private void checkMainData(Map<String, CheckCreateConfigDetail> checkDetailMap,
|
||||
Map<String, CheckConditionItem> checkConditionItemMap,
|
||||
ReqOperateRequestEntity requestParam) {
|
||||
List<WorkflowRequestTableField> mainData = requestParam.getMainData();
|
||||
for (WorkflowRequestTableField mainDatum : mainData) {
|
||||
String fieldName = mainDatum.getFieldName();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import aiyh.utils.Util;
|
|||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.api.doc.detail.util.DocDownloadCheckUtil;
|
||||
import com.api.youhong.ai.taibao.fcuntionlist.service.FunctionListService;
|
||||
import com.api.youhong.ai.taibao.qikan.service.PeriodicalService;
|
||||
import com.cloudstore.dev.api.util.Util_DataCache;
|
||||
|
@ -193,4 +194,10 @@ public class TestTaiBao extends BaseTest {
|
|||
System.out.println(JSON.toJSONString(subRequestEntities));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testjlsdfj() {
|
||||
System.out.println(DocDownloadCheckUtil.DncodeFileid("a1c0c56773deeff8d8f7f235f3eb3db0d2b34cbedb9ff32262414a3c6c4b9a393fc01656cc42ddaf07cd9319d68901a734f710fbddd167603"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
package youhong.ai.utiltest;
|
||||
|
||||
import aiyh.utils.httpUtil.ResponeVo;
|
||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||
import basetest.BaseTest;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <h1>测试调用api</h1>
|
||||
*
|
||||
* <p>create: 2023/6/13 20:04</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class TestApi extends BaseTest {
|
||||
|
||||
Map<String, String> SYSTEM_CACHE = new HashMap<>();
|
||||
|
||||
String APPID = "c6d2b3f5-5c1c-4b90-bad7-4a9b3b2c4bca";
|
||||
|
||||
@Test
|
||||
public void testApi() {
|
||||
String api = "https://ecology.yeyaguitu.cn/api/aiyh/test/req-msg/test/cus-api";
|
||||
String token = (String) testGetoken("https://ecology.yeyaguitu.cn").get("token");
|
||||
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
// 封装请求头参数
|
||||
RSA rsa = new RSA(null, spk);
|
||||
// 对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64("1", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
Map<String, String> head = new HashMap<>();
|
||||
head.put("appid", APPID);
|
||||
head.put("token", token);
|
||||
head.put("userid", encryptUserid);
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
ResponeVo responeVo = null;
|
||||
try {
|
||||
responeVo = httpUtils.apiGet(api, head);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
System.out.println(JSON.toJSONString(responeVo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一步:
|
||||
* <p>
|
||||
* 调用ecology注册接口,根据appid进行注册,将返回服务端公钥和Secret信息
|
||||
*/
|
||||
public Map<String, Object> testRegist(String address) {
|
||||
// 获取当前系统RSA加密的公钥
|
||||
RSA rsa = new RSA();
|
||||
String publicKey = rsa.getPublicKeyBase64();
|
||||
String privateKey = rsa.getPrivateKeyBase64();
|
||||
// 客户端RSA私钥
|
||||
SYSTEM_CACHE.put("LOCAL_PRIVATE_KEY", privateKey);
|
||||
// 客户端RSA公钥
|
||||
SYSTEM_CACHE.put("LOCAL_PUBLIC_KEY", publicKey);
|
||||
// 调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address + "/api/ec/dev/auth/regist")
|
||||
.header("appid", APPID)
|
||||
.header("cpk", publicKey)
|
||||
.timeout(2000)
|
||||
.execute().body();
|
||||
// 打印ECOLOGY响应信息
|
||||
System.out.println("testRegist():" + data);
|
||||
Map<String, Object> datas = JSONUtil.parseObj(data);
|
||||
// ECOLOGY返回的系统公钥
|
||||
SYSTEM_CACHE.put("SERVER_PUBLIC_KEY", StrUtil.nullToEmpty((String) datas.get("spk")));
|
||||
// ECOLOGY返回的系统密钥
|
||||
SYSTEM_CACHE.put("SERVER_SECRET", StrUtil.nullToEmpty((String) datas.get("secrit")));
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第二步:
|
||||
* <p>
|
||||
* 通过第一步中注册系统返回信息进行获取token信息
|
||||
*/
|
||||
public Map<String, Object> testGetoken(String address) {
|
||||
// 从系统缓存或者数据库中获取ECOLOGY系统公钥和Secret信息
|
||||
String secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
||||
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
// 如果为空,说明还未进行注册,调用注册接口进行注册认证与数据更新
|
||||
if (Objects.isNull(secret) || Objects.isNull(spk)) {
|
||||
testRegist(address);
|
||||
// 重新获取最新ECOLOGY系统公钥和Secret信息
|
||||
secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
||||
spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
}
|
||||
// 公钥加密,所以RSA对象私钥为null
|
||||
RSA rsa = new RSA(null, spk);
|
||||
// 对秘钥进行加密传输,防止篡改数据
|
||||
String encryptSecret = rsa.encryptBase64(secret, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
// 调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address + "/api/ec/dev/auth/applytoken")
|
||||
.header("appid", APPID)
|
||||
.header("secret", encryptSecret)
|
||||
.header("time", "3600")
|
||||
.execute().body();
|
||||
System.out.println("testGetoken():" + data);
|
||||
Map<String, Object> datas = JSONUtil.parseObj(data);
|
||||
// ECOLOGY返回的token
|
||||
// TODO 为Token缓存设置过期时间
|
||||
SYSTEM_CACHE.put("SERVER_TOKEN", StrUtil.nullToEmpty((String) datas.get("token")));
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三步:
|
||||
* <p>
|
||||
* 调用ecology系统的rest接口,请求头部带上token和用户标识认证信息
|
||||
*
|
||||
* @param address ecology系统地址
|
||||
* @param api rest api 接口地址(该测试代码仅支持GET请求)
|
||||
* @param jsonParams 请求参数json串
|
||||
* <p>
|
||||
* 注意:ECOLOGY系统所有POST接口调用请求头请设置 "Content-Type","application/x-www-form-urlencoded; charset=utf-8"
|
||||
*/
|
||||
public String testRestful(String address, String api, String jsonParams) {
|
||||
// ECOLOGY返回的token
|
||||
String token = SYSTEM_CACHE.get("SERVER_TOKEN");
|
||||
if (StrUtil.isEmpty(token)) {
|
||||
token = (String) testGetoken(address).get("token");
|
||||
}
|
||||
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
// 封装请求头参数
|
||||
RSA rsa = new RSA(null, spk);
|
||||
// 对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64("1", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
// 调用ECOLOGY系统接口,注意此处的disableCookie,可翻阅hutool的文档查看
|
||||
String data = HttpRequest
|
||||
.get(address + api)
|
||||
.header("appid", APPID)
|
||||
.header("token", token)
|
||||
.header("userid", encryptUserid)
|
||||
.body(jsonParams)
|
||||
.execute().body();
|
||||
System.out.println("testRestful():" + data);
|
||||
return data;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue