Compare commits

...

2 Commits

Author SHA1 Message Date
youhong.ai 2c3fcb7ac4 Merge branch 'dev' of https://gitea.yeyaguitu.cn/ecology/ebu_ecology_dev1 into dev
合并远程分支,保时捷流程数据推送,api创建流程,ihg用户信息元素后段
2023-06-26 10:26:46 +08:00
youhong.ai 4c2dbb9efd 保时捷流程参数校验,ihg用户信息元素 2023-06-26 10:26:39 +08:00
14 changed files with 311 additions and 29 deletions

View File

@ -9,6 +9,42 @@ const WfForm = {
isMobile: () => {
// true表示是eMobile、微信、钉钉等移动终端false代表PC端
},
/**
* 4.6 函数式自定义渲染表单字段
* 最低版本要求KB900190701
*
* 以函数返回值方式自定义渲染表单字段支持全部的字段类型可实现基于原组件追加/复写/重新布局等等
*
* 建议结合ecode工具放到模块加载前调用使用JSX可实现与表单字段渲染有关的二次开发
*
* 此接口的优先级高于4.44.5即使用此接口代理的字段如再使用4.44.5会直接无效
*
* proxyFieldContentComp: function(fieldid,fn)
* @param convertFieldNameToId
* @param customerRender
*/
proxyFieldContentComp(convertFieldNameToId, customerRender = (info, compFn) => {
// console.log("字段id",info.fieldid);
// console.log("明细行号:",info.rowIndex);
// console.log("字段只读必填属性:",info.viewAttr);
// console.log("字段值:",info.fieldValue);
// //返回自定义渲染的组件
// return React.createElement("div", {}, ["想怎么玩就怎么玩"]);
// //返回原组件
// return compFn();
// //返回基于原组件的复写组件
// return React.createElement("div", {}, ["前置组件",compFn(),"后置组件"]);
}
) {
},
/**
* //如果此接口调用在代码块、custompage等(非模块加载前调用),需强制渲染字段一次
* WfForm.forceRenderField("field111");
* @param field
*/
forceRenderField(field) {
}
}
WfForm.OPER_SAVE = '保存'
WfForm.OPER_SUBMIT = '提交/批准/提交需反馈/不需反馈等'

View File

@ -788,3 +788,125 @@ $(() => {
}
})
/* ******************* 年假计算 end ******************* */
/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 start ******************* */
$(() => {
const config = {
// 明细表
detail: 'detail_3',
// 明细字段
detailField: 'jbxxnr',
// 主表字段
mainField: 'jbxxnr'
}
function runJs() {
let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail);
let rowIndexArr = rowIndexStr.split(",");
let value = ""
rowIndexArr.forEach(item => {
let fieldId = WfForm.convertFieldNameToId(config.detailField, config.detail) + "_" + item
let fieldValue = WfForm.getFieldValue(fieldId);
value += (+item + 1) + "、" + fieldValue + "\n";
})
WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.mainField), {value})
}
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => {
runJs()
callback()
})
})
/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 end ******************* */
/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 start ******************* */
$(() => {
const config = {
// 明细表
detail: 'detail_1',
// 映射关系
mapping: [{
// 明细表字段
detailField: 'jbsj',
// 主表字段
mainField: 'zzjsrq',
}, {
// 明细表字段
detailField: 'jbtd',
// 主表字段
mainField: 'jbqd',
}],
dateSort: 'jbsj'
}
function runJs() {
let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail);
let rowIndexArray = rowIndexStr.split(",");
const detailData = []
rowIndexArray.forEach(item => {
let obj = {}
config.mapping.forEach(mapping => {
obj[mapping.detailField] = WfForm.getFieldValue(WfForm.convertFieldNameToId(mapping.detailField, config.detail) + "_" + item)
})
detailData.push(obj)
})
console.log(detailData)
let minDateObj = filterByMinDate(detailData, config.dateSort);
console.log(minDateObj)
config.mapping.forEach(item => {
WfForm.changeFieldValue(WfForm.convertFieldNameToId(item.mainField), {
value: minDateObj[item.detailField]
})
})
}
function filterByMinDate(arr, key) {
return arr.reduce((min, obj) => {
if (!min || new Date(obj[key]) <= new Date(min[key])) {
return obj;
}
return min;
}, null);
}
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => {
runJs()
callback()
})
})
/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 end ******************* */
/* ******************* youhong.ai 主表选择框自定义渲染为进度条 start ******************* */
$(() => {
const field = 'jz'
const config = {
'-1': 0,
'0': 20,
'1': 40,
'2': 60,
'3': 80,
'4': 100,
}
function customerRender(info, compFn) {
let fieldValue = info.fieldValue;
if (!fieldValue) {
fieldValue = '-1'
}
let {WeaProgress} = ecCom
return React.createElement(WeaProgress, {
strokeColor: '#6c8dc1',
percent: config[fieldValue]
})
}
WfForm.proxyFieldContentComp(WfForm.convertFieldNameToId(field).replace("field", ""), customerRender)
setTimeout(() => {
WfForm.forceRenderField(WfForm.convertFieldNameToId(field));
}, 500)
})
/* ******************* youhong.ai 主表选择框自定义渲染为进度条 end ******************* */

View File

@ -85,10 +85,11 @@ public class GenerateFileUtil {
if (hasRequired) {
// 必填参数
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
String fieldDesc = requiredMark.value();
Map<String, String> param = new HashMap<>();
String fieldDesc = requiredMark.desc();
Map<String, String> param = new HashMap<>(8);
param.put("name", name);
param.put("desc", fieldDesc);
param.put("example", requiredMark.value());
param.put("isRequired", "是");
boolean hasDefaultTestValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
if (hasDefaultTestValue) {
@ -105,9 +106,10 @@ public class GenerateFileUtil {
ActionOptionalParam actionOptionalParam = declaredField.getAnnotation(ActionOptionalParam.class);
String fieldDesc = actionOptionalParam.desc();
String defaultValue = actionOptionalParam.value();
Map<String, String> param = new HashMap<>();
Map<String, String> param = new HashMap<>(8);
param.put("name", name);
param.put("desc", fieldDesc);
param.put("example", defaultValue);
param.put("isRequired", "否");
param.put("defaultValue", defaultValue);
paramList.add(param);

View File

@ -12,14 +12,14 @@ import java.util.Map;
* @author youHong.ai
*/
public class ScriptUtil {
private static final JexlEngine jexl = new JexlBuilder().create();
private static final JexlEngine JEXL = new JexlBuilder().create();
public static Object invokeScript(String script, Map<String, Object> params) {
JexlContext jc = new MapContext();
for (Map.Entry<String, Object> entry : params.entrySet()) {
jc.set(entry.getKey(), entry.getValue());
}
JexlExpression expression = jexl.createExpression(script);
JexlExpression expression = JEXL.createExpression(script);
return expression.evaluate(jc);
}
}

View File

@ -44,7 +44,7 @@ public interface UserInfoMapper {
"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" +
@Select("select * 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" +
@ -61,7 +61,7 @@ public interface UserInfoMapper {
"or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" +
"or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" +
"or concat(',',headofengineering,',') like concat(',',#{userId},',')")
Integer selectIsHotel(int uid);
List<Map<String, Object>> selectIsHotel(int uid);
/**
* <h2></h2>
@ -86,11 +86,10 @@ public interface UserInfoMapper {
* <h2></h2>
*
* @param uid
* @param hotelIndex
* @return
*/
@Select("select * from uf_hotelinfo where\n" +
"(concat(',',olt,',') like concat(',',#{userId},',')\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" +
@ -112,9 +111,8 @@ public interface UserInfoMapper {
"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);
"or concat(',',hrleader,',') like concat(',',#{userId},',')")
List<Map<String, Object>> selectRoles(@ParamMapper("userId") int uid);
/**
* <h2></h2>

View File

@ -43,7 +43,6 @@ public class UserInfoService {
userInfoVo.setTaskAcceptance(true);
}
}
// 查询用户信息
Map<String, Object> userInfo = this.mapper.selectHrmInfo(user.getUID());
if (CollectionUtil.isNotEmpty(userInfo)) {
@ -70,8 +69,32 @@ public class UserInfoService {
// 支持中心,显示部门信息
userInfoVo.setDepartmentInfo(department);
}
List<Map<String, Object>> hotelList = mapper.selectRoles(user.getUID());
// 如果存在酒店信息
if (StrUtil.isNotBlank(hotelIndex)) {
Set<String> roleNames = new HashSet<>();
if (CollectionUtil.isNotEmpty(hotelList)) {
for (Map<String, Object> hotel : hotelList) {
// 循环酒店角色名称
for (Map.Entry<String, String> entry : ROLES_MAP.entrySet()) {
String key = entry.getKey();
if (!hotel.containsKey(key)) {
continue;
}
String value = Util.null2String(hotel.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);
/*if (StrUtil.isNotBlank(hotelIndex)) {
List<Map<String, Object>> hotelRoles = this.mapper.selectRoles(user.getUID(), hotelIndex);
if (CollectionUtil.isEmpty(hotelRoles)) {
return userInfoVo;
@ -98,7 +121,7 @@ public class UserInfoService {
}
}
userInfoVo.setRoleNames(roleNames);
}
}*/
}
return userInfoVo;
}

View File

@ -36,7 +36,7 @@ public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy impleme
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();
@Override
@ServiceMethodDynamicProxy(desc = "子流程触发时,做流程转数据")
@ServiceMethodDynamicProxy(desc = "流程创建校验流程参数")
public PAResponseEntity doCreateRequest(User user, ReqOperateRequestEntity requestParam) {
try {
try {

View File

@ -133,6 +133,7 @@ public class CheckWorkflowRequestParamsUtil {
if (Objects.isNull(checkCreateConfigDetail)) {
continue;
}
// TODO 主表明细表字段一致可能出现问题
checkDetailMap.remove(fieldName);
CheckFunctionParam checkFunctionParam = new CheckFunctionParam();
checkFunctionParam.setCheckCreateConfigDetail(checkCreateConfigDetail);

View File

@ -58,9 +58,6 @@ public class GenerateLoginIdAction extends SafeCusBaseAction {
Map<String, String> mainTableValue = super.getMainTableValue(requestInfo);
String subCompanyName = mainTableValue.get(subCompanyTextField);
String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName);
// Map<String, String> lastLoginIdInfo = mapper.selectLastLoginId(subCompanyName, subCompanyId, subCompanyName + "%");
// String loginIdNo = lastLoginIdInfo.get("loginIdNo");
// String loginId = prefixFill(loginIdNo, subCompanyName);
List<String> loginIdList = mapper.selectLoginIdList(subCompanyId);
String loginId = subCompanyName + formatList(loginIdList, Integer.parseInt(numberFillQuantity));
if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) {

View File

@ -0,0 +1,81 @@
package weaver.youhong.ai.pcn.actioin.todwfworkflow;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import lombok.Getter;
import lombok.Setter;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.util.Map;
/**
* <h1>dwf</h1>
*
* <p>create: 2023/6/25 21:56</p>
*
* @author youHong.ai
*/
@Setter
@Getter
@ActionDesc(author = "youhong.ai", value = "推送流程数据到dwf")
public class PushWorkflowDataToDWFAction extends SafeCusBaseAction {
@RequiredMark(desc = "请求参数配置表的唯一标识")
private String onlyMark;
@ActionOptionalParam(desc = "流程失败是否退回", value = "true")
private String isBlack = "true";
@ActionOptionalParam(desc = "成功标识", value = "200")
private String successCode = "200";
private final HttpUtils httpUtils = new HttpUtils();
private final DealWithMapping dealWithMapping = new DealWithMapping();
{
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON);
}
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
dealWithMapping.setMainTable(billTable);
try {
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
String requestUrl = requestMappingConfig.getRequestUrl();
Map<String, Object> objMainTableValue = getObjMainTableValue(requestInfo);
Map<String, Object> requestParam = dealWithMapping.getRequestParam(objMainTableValue, requestMappingConfig);
ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam);
if (responeVo.getCode() != 200) {
log.error(Util.logStr("接口请求出错:[]", responeVo.getEntityString()));
}
Map<String, Object> responseMap = responeVo.getResponseMap();
String code = Util.null2String(responseMap.get("code"));
if (!successCode.equals(code)) {
black(requestInfo, Util.null2String(responseMap.get("msg")));
}
} catch (IOException e) {
black(requestInfo, "system error!");
}
}
private void black(RequestInfo requestInfo, String msg) {
if (Boolean.parseBoolean(isBlack)) {
Util.actionFailException(requestInfo.getRequestManager(), msg);
}
}
}

View File

@ -4,6 +4,8 @@ import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.Map;
/**
* create 2022/1/17 0017 16:57
*
@ -14,7 +16,7 @@ import aiyh.utils.annotation.recordset.SqlMapper;
public interface DynamicCodeMapper {
@Select("select email from hrmresource where loginid = #{loginId}")
public String selectEmail(@ParamMapper("loginId") String loginId);
String selectEmail(@ParamMapper("loginId") String loginId);
/**
* <h2></h2>
@ -26,4 +28,7 @@ public interface DynamicCodeMapper {
@Select("select id from hrmresource where loginid = #{loginId} and password = #{password}")
Integer selectUser(@ParamMapper("loginId") String user,
@ParamMapper("password") String mdPassword);
@Select("select id,lastname,loginid,isadaccount from hrmresource where loginid = #{loginId}")
Map<String, Object> selectUserInfo(@ParamMapper("loginId") String user);
}

View File

@ -2,6 +2,7 @@ package com.api.aiyh_logincheck.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import aiyh.utils.zwl.common.ToolUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
@ -15,6 +16,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import weaver.email.EmailWorkRunnable;
import weaver.general.BaseBean;
import weaver.ldap.LdapUtil;
import weaver.sm.SM4Utils;
import javax.servlet.ServletContext;
@ -122,11 +124,26 @@ public class DynamicCodeService {
password = sm4.decrypt(password, key);
}
}
// 校验AD登录
Map<String, Object> userInfoMap = dynamicCodeMapper.selectUserInfo(user);
if (CollectionUtil.isNotEmpty(userInfoMap) && "1".equals(Util.null2String(userInfoMap.get("isadaccount")))) {
LdapUtil util = LdapUtil.getInstance();
String authenticResult = util.authenticuser(user);
if (authenticResult == null || "uac".equals(authenticResult)) {
throw new CustomerException("AD账号不存在或被禁用", 403);
}
boolean flag;
flag = util.authentic(user, password);
if (!flag) {
throw new CustomerException("账号或密码错误!", 403);
}
} else {
String mdPassword = EncryptHelper.encodeMd5(password).toUpperCase();
Integer userId = dynamicCodeMapper.selectUser(user, mdPassword);
if (Objects.isNull(userId) || userId < 0) {
throw new CustomerException("账号或密码错误!", 403);
}
}
String uncheckList = toolUtil.getSystemParamValue("uncheckList");
String isEnable = toolUtil.getSystemParamValue("enableDynamicCode");
Map<String, Object> map = new HashMap<>(4);

View File

@ -12,7 +12,7 @@ import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.junit.Test;
import weaver.youhong.ai.pcn.actioin.doctoavatar.DocToAvatarAction;
import weaver.youhong.ai.pcn.actioin.todwfworkflow.PushWorkflowDataToDWFAction;
import youhong.ai.utiltest.excel.ExcelCell;
import youhong.ai.utiltest.excel.ExcelPort;
import youhong.ai.utiltest.excel.ExcelRow;
@ -98,7 +98,7 @@ public class GenericTest extends BaseTest {
@Test
public void testGre() {
GenerateFileUtil.createActionDocument(DocToAvatarAction.class);
GenerateFileUtil.createActionDocument(PushWorkflowDataToDWFAction.class);
}

View File

@ -63,7 +63,7 @@ public class TestApi extends BaseTest {
"\t\"fieldValue\":\"5\"\n" +
"},{\n" +
"\t\"fieldName\":\"mc\",\n" +
"\t\"fieldValue\":\"不1道\"\n" +
"\t\"fieldValue\":\"不道\"\n" +
"}]");
body.put("requestName", "api流程测试调用接口校验参数");
body.put("workflowId", "44");