修改流程保存触发流程转数据接口,修改分布式锁,添加建模targetSetting按钮置灰
parent
24a1db60ac
commit
d59ed4f677
|
@ -135,7 +135,15 @@ window.Utils = {
|
|||
*/
|
||||
getFiledValueByName: function (fieldName, rowIndex) {
|
||||
return WfForm.getFieldValue(Utils.convertNameObjToId(fieldName) + rowIndex ? '_' + rowIndex : '')
|
||||
},
|
||||
|
||||
/**
|
||||
* 通过字段名称修改字段值
|
||||
* @param fieldName 字段名称
|
||||
* @param value 值
|
||||
*/
|
||||
changeFieldValueByName: function (fieldName, value) {
|
||||
WfForm.changeFieldValue(Utils.convertNameObjToId(fieldName), {value})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -134,5 +134,20 @@ WfForm.changeFieldValue = function (fieldMark, valueInfo) {
|
|||
}
|
||||
|
||||
|
||||
/* ******************* 建模表开发依赖 ******************* */
|
||||
|
||||
const ModeList = {}
|
||||
ModeList.dataLoadAfter = function (data) {
|
||||
// 描述:在列表数据加载完,对列表的数据进行二次加工,并渲染。 dataLoadAfter传入dataHandle方法,用来接收并处理数据,dataHandle有两个参数。
|
||||
// var dataHandle = function(datas,displayType){
|
||||
// //Changes to 'datas' do not directly modify the real database data, but modify the data received at the front end.
|
||||
// var newDatas = datas;
|
||||
// if(displayType == 'normal'){
|
||||
// console.log(newDatas);
|
||||
// }
|
||||
// return newDatas;
|
||||
// }
|
||||
// ModeList.dataLoadAfter(dataHandle);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ class ConfigWorkflowTitle {
|
|||
|
||||
constructor(config) {
|
||||
this.config = config
|
||||
console.log(config)
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,17 +11,14 @@ class ConfigWorkflowTitle {
|
|||
* 初始化参数
|
||||
*/
|
||||
init = () => {
|
||||
console.log("init")
|
||||
let baseInfo = WfForm.getBaseInfo();
|
||||
if (baseInfo.workflowid != this.config.workflowId) {
|
||||
return
|
||||
}
|
||||
let filedArr = []
|
||||
console.log("jahh")
|
||||
this.config.rules.filter(item => item.type === RulesType.FIELD_VALUE
|
||||
|| item.type === RulesType.SELECT_VALUE
|
||||
|| item.type === RulesType.RADIO_VALUE).forEach(item => filedArr.push(item.fieldName))
|
||||
console.log("bind", filedArr)
|
||||
this.addListenerEvent(filedArr)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,133 +1,232 @@
|
|||
/* ******************* 保时捷target setting流程提交控制 start ******************* */
|
||||
/**
|
||||
* @author youhong.ai
|
||||
* @desc 禁止点击提交按钮
|
||||
*/
|
||||
function doNotClickSubmit() {
|
||||
let submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="Submit "]')
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="提交"]')
|
||||
}
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $("#weareqtop_9v5e5i_1670481049632 div.ant-row.wea-new-top-req div.ant-col-xs-18.ant-col-sm-18.ant-col-md-16.ant-col-lg-14 button[title='提交'],[title='Submit '],[title='Submit']")
|
||||
}
|
||||
if (submitButton.length !== 0) {
|
||||
let buttonReact = window.Utils.findReact(submitButton[0])
|
||||
let rightBtn = Utils.findReact($(".ant-menu-item.text-elli[ecid='_Route@vmt0lk_Comp@upn4fo_WeaRightMenu@1ok9r0_Item@eu37n0_li@zyccqn']")[0])
|
||||
setTimeout(() => {
|
||||
buttonReact.props.disabled = true
|
||||
window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, {
|
||||
/**
|
||||
* @author youhong.ai
|
||||
* @desc 禁止点击提交按钮
|
||||
*/
|
||||
doNotClickSubmit: function () {
|
||||
let submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="Submit "]')
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="提交"]')
|
||||
}
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $("#weareqtop_9v5e5i_1670481049632 div.ant-row.wea-new-top-req div.ant-col-xs-18.ant-col-sm-18.ant-col-md-16.ant-col-lg-14 button[title='提交'],[title='Submit '],[title='Submit']")
|
||||
}
|
||||
if (submitButton.length !== 0) {
|
||||
let buttonReact = window.Utils.findReact(submitButton[0])
|
||||
let rightBtn = Utils.findReact($(".ant-menu-item.text-elli[ecid='_Route@vmt0lk_Comp@upn4fo_WeaRightMenu@1ok9r0_Item@eu37n0_li@zyccqn']")[0])
|
||||
setTimeout(() => {
|
||||
buttonReact.props.disabled = true
|
||||
buttonReact.setState({})
|
||||
rightBtn.props.disabled = true
|
||||
rightBtn.setState({})
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @author youhong.ai
|
||||
* @desc 允许点击按钮
|
||||
*/
|
||||
allowClickSubmit: function () {
|
||||
let submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="Submit "]')
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="提交"]')
|
||||
}
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $("#weareqtop_9v5e5i_1670481049632 div.ant-row.wea-new-top-req div.ant-col-xs-18.ant-col-sm-18.ant-col-md-16.ant-col-lg-14 button[title='提交'],[title='Submit '],[title='Submit']")
|
||||
}
|
||||
if (submitButton.length !== 0) {
|
||||
WfForm.controlBtnDisabled(false)
|
||||
let buttonReact = window.Utils.findReact(submitButton[0])
|
||||
buttonReact.props.disabled = false
|
||||
buttonReact.setState({})
|
||||
rightBtn.props.disabled = true
|
||||
rightBtn.setState({})
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @author youhong.ai
|
||||
* @desc 允许点击按钮
|
||||
*/
|
||||
function allowClickSubmit() {
|
||||
let submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="Submit "]')
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $('.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="提交"]')
|
||||
}
|
||||
if (submitButton.length === 0) {
|
||||
submitButton = $("#weareqtop_9v5e5i_1670481049632 div.ant-row.wea-new-top-req div.ant-col-xs-18.ant-col-sm-18.ant-col-md-16.ant-col-lg-14 button[title='提交'],[title='Submit '],[title='Submit']")
|
||||
}
|
||||
if (submitButton.length !== 0) {
|
||||
WfForm.controlBtnDisabled(false)
|
||||
let buttonReact = window.Utils.findReact(submitButton[0])
|
||||
buttonReact.props.disabled = false
|
||||
buttonReact.setState({})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听qzhj字段值改变
|
||||
* @author youhong.ai
|
||||
* @param id 字段id
|
||||
* @param value 字段值
|
||||
* @param obj 字段值对象
|
||||
*/
|
||||
function onQzhjFieldChangeValue(obj, id, value) {
|
||||
if (value != '100') {
|
||||
doNotClickSubmit()
|
||||
} else {
|
||||
allowClickSubmit()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查qzhj字段值
|
||||
* @author youhong.ai
|
||||
* @param fieldId qzhj字段id
|
||||
*/
|
||||
function checkOnQzhJfiedlChangeValue(fieldId) {
|
||||
let value = WfForm.getFieldValue(fieldId);
|
||||
onQzhjFieldChangeValue(null, null, value)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查提交按钮是否符合条件
|
||||
* @author youhong.ai
|
||||
* @param fieldId 字段id
|
||||
* @returns {(function(function()=): void)|*}
|
||||
*/
|
||||
function checkClickSubmit(fieldId) {
|
||||
return (callback = () => {
|
||||
}) => {
|
||||
let value = WfForm.getFieldValue(fieldId);
|
||||
if (value != 100) {
|
||||
WfForm.showMessage("~`~`7 目标设定的总值必须是100%,请检查并修改后提交。 " + "`~`8 The total value of target setting must be 100%,please check to submit after modification! " + "`~`9 目标设定的总值必须是100%,请检查并修改后提交。`~`~", 2, 5);
|
||||
/**
|
||||
* 监听qzhj字段值改变
|
||||
* @author youhong.ai
|
||||
* @param id 字段id
|
||||
* @param value 字段值
|
||||
* @param obj 字段值对象
|
||||
*/
|
||||
onQzhjFieldChangeValue: function (obj, id, value) {
|
||||
if (value != '100') {
|
||||
window.workflowCus.doNotClickSubmit()
|
||||
} else {
|
||||
callback()
|
||||
window.workflowCus.allowClickSubmit()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存按钮触发流程转数据
|
||||
* @author youhong.ai
|
||||
* @param callback 保存后页面跳转前回调
|
||||
*/
|
||||
async function saveTriggerWorkflowToModel() {
|
||||
let baseInfo = WfForm.getBaseInfo()
|
||||
if (baseInfo && baseInfo.requestid != '-1') {
|
||||
let result = await Utils.api({
|
||||
url: "/api/aiyh/workflow/target-setting/save-trigger",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({requestId: baseInfo.requestid})
|
||||
})
|
||||
if (result && result.code === 200) {
|
||||
localStorage.setItem("saveTriggerWorkflowToModel", "false")
|
||||
/**
|
||||
* 检查qzhj字段值
|
||||
* @author youhong.ai
|
||||
* @param fieldId qzhj字段id
|
||||
*/
|
||||
checkOnQzhJfiedlChangeValue: function (fieldId) {
|
||||
let value = WfForm.getFieldValue(fieldId);
|
||||
window.workflowCus.onQzhjFieldChangeValue(null, null, value)
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 检查提交按钮是否符合条件
|
||||
* @author youhong.ai
|
||||
* @param fieldId 字段id
|
||||
* @returns {(function(function()=): void)|*}
|
||||
*/
|
||||
checkClickSubmit: function (fieldId) {
|
||||
return (callback = () => {
|
||||
}) => {
|
||||
let value = WfForm.getFieldValue(fieldId);
|
||||
if (value != 100) {
|
||||
WfForm.showMessage("~`~`7 目标设定的总值必须是100%,请检查并修改后提交。 " + "`~`8 The total value of target setting must be 100%,please check to submit after modification! " + "`~`9 目标设定的总值必须是100%,请检查并修改后提交。`~`~", 2, 5);
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存按钮触发流程转数据
|
||||
* @author youhong.ai
|
||||
*/
|
||||
saveTriggerWorkflowToModel: async function () {
|
||||
let baseInfo = WfForm.getBaseInfo()
|
||||
if (baseInfo && baseInfo.requestid != '-1') {
|
||||
let result = await Utils.api({
|
||||
url: "/api/aiyh/workflow/target-setting/save-trigger",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
requestId: baseInfo.requestid,
|
||||
nodeId: baseInfo.nodeid,
|
||||
isBill: baseInfo.isbill,
|
||||
formId: baseInfo.formid,
|
||||
workflowId: baseInfo.workflowid
|
||||
})
|
||||
})
|
||||
if (result && result.code === 200) {
|
||||
localStorage.setItem("saveTriggerWorkflowToModel", "false")
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
saveAfterCallback: function (callback) {
|
||||
localStorage.setItem("saveTriggerWorkflowToModel", "true")
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
function saveAfterCallback(callback) {
|
||||
localStorage.setItem("saveTriggerWorkflowToModel", "true")
|
||||
callback()
|
||||
}
|
||||
|
||||
/* ******************* 保时捷target setting流程提交控制 end ******************* */
|
||||
|
||||
/* ******************* 保时捷target setting流程提交控制 start ******************* */
|
||||
$(() => {
|
||||
let qzhjFieldId = WfForm.convertFieldNameToId("qzhj")
|
||||
checkOnQzhJfiedlChangeValue(qzhjFieldId)
|
||||
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, checkClickSubmit(qzhjFieldId))
|
||||
WfForm.registerCheckEvent(WfForm.OPER_SAVECOMPLETE, saveAfterCallback)
|
||||
WfForm.bindFieldChangeEvent(qzhjFieldId, onQzhjFieldChangeValue)
|
||||
window.workflowCus.checkOnQzhJfiedlChangeValue(qzhjFieldId)
|
||||
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, window.workflowCus.checkClickSubmit(qzhjFieldId))
|
||||
WfForm.registerCheckEvent(WfForm.OPER_SAVECOMPLETE, window.workflowCus.saveAfterCallback)
|
||||
WfForm.bindFieldChangeEvent(qzhjFieldId, window.workflowCus.onQzhjFieldChangeValue)
|
||||
let flag = localStorage.getItem("saveTriggerWorkflowToModel")
|
||||
if (flag === "true") {
|
||||
saveTriggerWorkflowToModel()
|
||||
window.workflowCus.saveTriggerWorkflowToModel()
|
||||
}
|
||||
})
|
||||
|
||||
/* ******************* 保时捷target setting流程提交控制 end ******************* */
|
||||
|
||||
|
||||
/* ******************* 保时捷个人目标台账查询target setting按钮默认置灰色 ******************* */
|
||||
window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, {
|
||||
|
||||
notAllowedTargetSetting: function () {
|
||||
window.workflowCus.changeBtnDisabledValue(true)
|
||||
},
|
||||
|
||||
changeBtnDisabledValue: function (disable) {
|
||||
if ($(".ant-btn.ant-btn-primary[ecid='_Route@9uoqid_Com@knmejd_ButtonNew@813let@0_Button@tegwjx_button@xq1ea3']").length === 0) {
|
||||
return
|
||||
}
|
||||
let button = Utils.findReact($(".ant-btn.ant-btn-primary[ecid='_Route@9uoqid_Com@knmejd_ButtonNew@813let@0_Button@tegwjx_button@xq1ea3']")[0])
|
||||
if (button) {
|
||||
button.props.disabled = disable
|
||||
button.setState({})
|
||||
}
|
||||
},
|
||||
|
||||
allowedTargetSettingBtnClick: function () {
|
||||
window.workflowCus.changeBtnDisabledValue(false)
|
||||
},
|
||||
|
||||
queryTotalWeight: function () {
|
||||
Utils.api({
|
||||
url: "/api/ayh/target-setting/btn/can-allowed"
|
||||
}).then(res => {
|
||||
if (res && res.code === 200) {
|
||||
if (res.data) {
|
||||
window.workflowCus.allowedTargetSettingBtnClick()
|
||||
} else {
|
||||
window.workflowCus.notAllowedTargetSetting()
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
|
||||
reRender: function () {
|
||||
const dataHandle = function (datas, displayType) {
|
||||
window.workflowCus.notAllowedTargetSetting()
|
||||
//Changes to 'datas' do not directly modify the real database data, but modify the data received at the front end.
|
||||
$(() => {
|
||||
window.workflowCus.queryTotalWeight()
|
||||
})
|
||||
return datas
|
||||
|
||||
}
|
||||
ModeList.dataLoadAfter(dataHandle)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$(() => {
|
||||
window.workflowCus.notAllowedTargetSetting()
|
||||
setTimeout(() => {
|
||||
window.workflowCus.notAllowedTargetSetting()
|
||||
}, 10)
|
||||
window.workflowCus.reRender()
|
||||
})
|
||||
/* ******************* 保时捷个人目标台账查询target setting按钮默认置灰色 END ******************* */
|
||||
|
||||
|
||||
/* ******************* apa流程通过apa分数字段带出level字段 ******************* */
|
||||
|
||||
window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, {
|
||||
getLevelByScore: async function (config) {
|
||||
let scoreFiled = config.scoreFiled
|
||||
let score = Utils.getFiledValueByName(scoreFiled);
|
||||
let result = await Utils.api({
|
||||
url: "/api/ayh/workflow/apa/level",
|
||||
data: {
|
||||
score
|
||||
}
|
||||
})
|
||||
if (result && result.code === 200) {
|
||||
Utils.changeFieldValueByName(config.levelField, result.data)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$(() => {
|
||||
let config = {
|
||||
scoreFiled: "",
|
||||
levelField: ""
|
||||
}
|
||||
window.workflowCus.getLevelByScore(config)
|
||||
})
|
||||
|
||||
|
||||
/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */
|
||||
|
|
|
@ -10,9 +10,9 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author EBU7-dev1-ayh
|
||||
* create 2021/12/13 0013 10:29
|
||||
* 多语言工具类
|
||||
* <h1>多语言工具类</h1>
|
||||
*
|
||||
* @author EBU7-dev1-ayh create 2021/12/13 0013 10:29
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -7,24 +7,26 @@ import java.io.File;
|
|||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* @author EBU7-dev1-ayh
|
||||
* create 2021/12/14 0014 15:57
|
||||
* <h1>mybatis集成工具</h1>
|
||||
*
|
||||
* @author EBU7-dev1-ayh create 2021/12/14 0014 15:57
|
||||
*/
|
||||
|
||||
|
||||
public class MybatisUtil {
|
||||
private static SqlSessionManager sqlSessionManager = null;
|
||||
|
||||
private synchronized static void init(String config){
|
||||
private synchronized static void init(String config) {
|
||||
try {
|
||||
Reader resourceAsReader = Resources.getResourceAsReader("WEB-INF" + File.separator +config);
|
||||
Reader resourceAsReader = Resources.getResourceAsReader("WEB-INF" + File.separator + config);
|
||||
sqlSessionManager = SqlSessionManager.newInstance(resourceAsReader);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static SqlSessionManager getSessionManager(String config){
|
||||
if(sqlSessionManager == null){
|
||||
|
||||
public static SqlSessionManager getSessionManager(String config) {
|
||||
if (sqlSessionManager == null) {
|
||||
synchronized (MybatisUtil.class) {
|
||||
if (sqlSessionManager == null) {
|
||||
init(config);
|
||||
|
@ -34,7 +36,7 @@ public class MybatisUtil {
|
|||
return sqlSessionManager;
|
||||
}
|
||||
|
||||
public static <T> T getMapper(Class<T> tClass){
|
||||
public static <T> T getMapper(Class<T> tClass) {
|
||||
return sqlSessionManager.getMapper(tClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ public class LockUtils {
|
|||
/**
|
||||
* <h2>重试锁</h2>
|
||||
* <i>2022/12/11 01:39</i>
|
||||
* ******************************************
|
||||
* ************************************************************
|
||||
*
|
||||
* @param dataId 数据id
|
||||
* @param lockName 锁名称
|
||||
|
@ -286,6 +286,38 @@ public class LockUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>释放锁</h2>
|
||||
* <i>2022/12/11 15:56</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @param lockName 锁名称
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
public static void unLock(String lockName) {
|
||||
if (LOCK_MAP.containsKey(lockName)) {
|
||||
// 存在本地锁
|
||||
LockEntity lockEntity = LOCK_MAP.get(lockName);
|
||||
if (!lockEntity.getLockMark().equals(Thread.currentThread())) {
|
||||
// 并非当前上锁的线程在释放锁
|
||||
return;
|
||||
}
|
||||
Integer times = lockEntity.getTimes();
|
||||
if (times - 1 == 0) {
|
||||
boolean unlock = mapper.unLock(lockName);
|
||||
if (!unlock) {
|
||||
int n = 0;
|
||||
do {
|
||||
if (n++ > 5) {
|
||||
throw new CustomerException("can not unLock!Failed to release the lock after five attempts!");
|
||||
}
|
||||
} while (!mapper.unLock(lockName)); // 释放锁失败
|
||||
}
|
||||
return;
|
||||
}
|
||||
lockEntity.setTimes(lockEntity.getTimes() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>锁续期</h2>
|
||||
|
@ -314,39 +346,5 @@ public class LockUtils {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>释放锁</h2>
|
||||
* <i>2022/12/11 15:56</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @param lockName 锁名称
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
public void unLock(String lockName) {
|
||||
if (LOCK_MAP.containsKey(lockName)) {
|
||||
// 存在本地锁
|
||||
LockEntity lockEntity = LOCK_MAP.get(lockName);
|
||||
if (!lockEntity.getLockMark().equals(Thread.currentThread())) {
|
||||
// 并非当前上锁的线程在释放锁
|
||||
return;
|
||||
}
|
||||
Integer times = lockEntity.getTimes();
|
||||
if (times - 1 == 0) {
|
||||
boolean unlock = mapper.unLock(lockName);
|
||||
if (!unlock) {
|
||||
int n = 0;
|
||||
do {
|
||||
if (n++ > 5) {
|
||||
throw new CustomerException("can not unLock!Failed to release the lock after five attempts!");
|
||||
}
|
||||
} while (!mapper.unLock(lockName)); // 释放锁失败
|
||||
}
|
||||
return;
|
||||
}
|
||||
lockEntity.setTimes(lockEntity.getTimes() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.service.NotAllowedClickTGSService;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.Consumes;
|
||||
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>是否允许当前用户点击targetSetting按钮</h1>
|
||||
*
|
||||
* <p>create: 2022-12-12 15:36</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Path("/ayh/target-setting/btn")
|
||||
public class NotAllowedClickTGSController {
|
||||
|
||||
private final NotAllowedClickTGSService service = new NotAllowedClickTGSService();
|
||||
|
||||
@Path("/can-allowed")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String canAllowedClickTGSBtn(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
try {
|
||||
return ApiResult.success(service.canAllowedClickTGSBtn(user));
|
||||
} catch (Exception e) {
|
||||
Util.getLogger().error("get can allowed click target setting button error!\n" + Util.getErrString(e));
|
||||
return ApiResult.error("system error!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2022-12-12 15:56</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@SqlMapper
|
||||
public interface NotAllowedClickTGSMapper {
|
||||
|
||||
/**
|
||||
* <h2>根据用户id和当前年份查询个人目标台账主表id</h2>
|
||||
* <i>2022/12/12 17:27</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param currentYear 当前年年份
|
||||
* @return List<Integer> 主表id数组
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
@Select("select id from uf_targetsettingdat where sqr = #{userId} and nf = #{currentYear}")
|
||||
List<Integer> selectMainIdsByUserIdAndYear(@ParamMapper("userId") Integer userId,
|
||||
@ParamMapper("currentYear") String currentYear);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>根据主表id查询明细数据</h2>
|
||||
* <i>2022/12/12 17:28</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param list 主表id数组
|
||||
* @return List<String> 明细权重
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
@Select("select qz from uf_targetsettingdat_dt1 where mainid in (${list})")
|
||||
List<String> selectWeightByMainIds(List<Integer> list);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper.NotAllowedClickTGSMapper;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2022-12-12 15:38</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class NotAllowedClickTGSService {
|
||||
|
||||
|
||||
private final NotAllowedClickTGSMapper mapper = Util.getMapper(NotAllowedClickTGSMapper.class);
|
||||
|
||||
/**
|
||||
* <h2>查询是否可以点击创建targetSetting流程</h2>
|
||||
* <i>2022/12/12 17:29</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param user 当前登陆用户
|
||||
* @return boolean 是否可以点击创建按钮
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
public boolean canAllowedClickTGSBtn(User user) {
|
||||
List<Integer> mainIdList = mapper.selectMainIdsByUserIdAndYear(user.getUID(), Util.getTime("yyyy"));
|
||||
if (Objects.isNull(mainIdList) || mainIdList.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
List<String> qzList = mapper.selectWeightByMainIds(mainIdList);
|
||||
if (Objects.isNull(qzList) || qzList.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
Integer sum = qzList.stream()
|
||||
.filter(item -> !Util.isNullOrEmpty(item))
|
||||
.map(Integer::parseInt)
|
||||
.reduce(0, Integer::sum);
|
||||
return sum < 100;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper.TriggerWorkflowToModelMapper;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.formmode.interfaces.action.WorkflowToMode;
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
@ -26,33 +28,57 @@ public class TriggerWorkflowToModelService {
|
|||
private final RequestService service = new RequestService();
|
||||
|
||||
private final TriggerWorkflowToModelMapper mapper = Util.getMapper(TriggerWorkflowToModelMapper.class);
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
public String saveTriggerWorkflowToModel(Map<String, Object> params, HttpServletRequest request, User user) {
|
||||
log.info("request param:" + JSON.toJSONString(params));
|
||||
String requestId = String.valueOf(params.get("requestId"));
|
||||
String nodeId = String.valueOf(params.get("nodeId"));
|
||||
String isBill = String.valueOf(params.get("isBill"));
|
||||
String formId = String.valueOf(params.get("formId"));
|
||||
String workflowId = String.valueOf(params.get("workflowId"));
|
||||
RequestInfo requestInfo = service.getRequest(Integer.parseInt(requestId));
|
||||
requestInfo.setIspreadd("1");
|
||||
requestInfo.setWorkflowid(workflowId);
|
||||
RequestManager requestManager = requestInfo.getRequestManager();
|
||||
requestManager.setRequest(request);
|
||||
requestManager.setUser(user);
|
||||
requestManager.setNodeid(Integer.parseInt(nodeId));
|
||||
requestManager.setIsbill(Integer.parseInt(isBill));
|
||||
requestManager.setFormid(Integer.parseInt(formId));
|
||||
requestManager.setWorkflowid(Integer.parseInt(workflowId));
|
||||
WorkflowToMode workflowToMode = new WorkflowToMode();
|
||||
workflowToMode.setNodeid(Integer.parseInt(nodeId));
|
||||
workflowToMode.setIp(getRemoteHost(request));
|
||||
List<Integer> actionIds = mapper.selectActionId(nodeId, workflowId);
|
||||
if (Objects.isNull(actionIds) || actionIds.isEmpty()) {
|
||||
return "can not query actionIds;";
|
||||
}
|
||||
List<Integer> failAction = new ArrayList<>();
|
||||
List<String> failAction = new ArrayList<>();
|
||||
for (Integer actionId : actionIds) {
|
||||
workflowToMode.setActionid(actionId);
|
||||
if ("0".equals(workflowToMode.execute(requestInfo))) {
|
||||
failAction.add(actionId);
|
||||
failAction.add("[" + actionId + "]: " + requestManager.getMessagecontent() + "\t" + requestManager.getMessage());
|
||||
}
|
||||
}
|
||||
return "action execute finish! " + Util.intJoin(failAction, ",") + "execute fail!";
|
||||
if (failAction.isEmpty()) {
|
||||
return "success";
|
||||
}
|
||||
log.error(Util.join(failAction, "\n"));
|
||||
return "action execute finish! execute fail!";
|
||||
}
|
||||
|
||||
private String getRemoteHost(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return ip.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ip;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package youhong.ai.pcn;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import basetest.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>流程相关测试</h1>
|
||||
*
|
||||
* <p>create: 2022-12-12 16:13</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class WorkflowTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
List<String> qzList = new ArrayList<>();
|
||||
Collections.addAll(qzList, null, "", "1", "2", "3", "4");
|
||||
Integer sum = qzList.stream()
|
||||
.filter(item -> !Util.isNullOrEmpty(item))
|
||||
.map(Integer::parseInt)
|
||||
.reduce(0, Integer::sum);
|
||||
System.out.println(sum);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue