上汽出行以及施罗德代码测试完成

main
wangxuanran 2022-12-23 16:07:57 +08:00
parent f2b3189e4f
commit 50789e184b
32 changed files with 1918 additions and 197 deletions

View File

@ -0,0 +1,54 @@
/**
* 柏美 施工合同申请js
* 明细表自动添加5行 不允许增删 并校验付款比例是否等于100% 自动计算付款日期
* @author xuanran.wang
*/
// 明细表
const detailTable = "detail_2";
// 主表合同签订日期
const contractSignDateId = WfForm.convertFieldNameToId("htqdrq");
// 明细2付款比例字段
const detail2PayProportionId = WfForm.convertFieldNameToId("fkbl",detailTable);
// 明细2款项类型
const detail2PaymentTypeId = WfForm.convertFieldNameToId("kxlx",detailTable);
// 明细2前后字段
const detail2AroundId = WfForm.convertFieldNameToId("qh",detailTable);
// 明细2天数字段
const detail2DayId = WfForm.convertFieldNameToId("ts",detailTable);
// 明细2预计付款日期
const detail2ComPayDateId = WfForm.convertFieldNameToId("yjfkrq",detailTable);
// 对应日期
const detail2TempDateField = WfForm.convertFieldNameToId("dyrq", detailTable);
// 需要计算的款项类型集合
const computeDatePayType = ['0'];
// 款项类型预计对应日期取值
const paymentTypeGetValue = {
0: (index)=>{
WfForm.changeFieldValue(`${detail2TempDateField}_${index}`,{value : WfForm.getFieldValue(contractSignDateId)});
}
}
jQuery().ready(function(){
let configObj = {
'detailPaymentTypeId':detail2PaymentTypeId,
'detailTempDateId': detail2TempDateField,
'around': detail2AroundId,
'detailComPayDateId': detail2ComPayDateId,
'dayId': detail2DayId,
'computeDatePayType': computeDatePayType,
'paymentTypeGetValue': paymentTypeGetValue
}
// 默认增加5条
for (let i = 0; i < 5; i++) {
WfForm.addDetailRow(detailTable,{ [detail2PaymentTypeId]: {value: i}});
}
// 主表字段发生变化
mainFieldChangeDetailCom(contractSignDateId, detailTable, configObj);
// 明细的款项类型字段变化绑定
detailFieldChangeDetailCom(`${detail2AroundId},${detail2DayId}`, configObj);
submitCallback(detailTable, detail2PayProportionId);
});

View File

@ -0,0 +1,154 @@
const ADD = '1';
const DEL = '0';
const READ_ONLY = '1';
const EDIT = '2';
/**
* 计算日期
* @param date 计算日期
* @param around / 前是0 后是1
* @param day
*/
function computeDate(date, around, day){
let dateTime = new Date(date).getTime();
let mill = 0;
switch (around){
case ADD:{
mill = day * 1;
console.log('add :', mill);
break;
}
case DEL:{
mill = day * -1;
console.log('del :', mill);
break;
}
}
// 转成毫秒数
mill *= (24 * 60 * 60 * 1000);
dateTime += mill;
return getDate(dateTime);
}
/**
* 时间戳转 yyyy-MM-dd
* @param time
* @returns {string}
*/
function getDate(time) {
let date = new Date(time);
y = date.getFullYear();
m = date.getMonth() + 1;
d = date.getDate();
return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
}
/**
* 校验比例是否等于100
* @param detailTable 明细表
* @param detail2PayProportionId 比例字段
*/
function submitCallback(detailTable, detail2PayProportionId){
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT,function(callback){
let rowArr = WfForm.getDetailAllRowIndexStr(detailTable).split(",");
let sum = 0;
for(let i=0; i < rowArr.length; i++){
let rowIndex = rowArr[i];
if(rowIndex !== ""){
let field = `${detail2PayProportionId}_${rowIndex}`;
sum += parseFloat(WfForm.getFieldValue(field));//遍历明细行字段
}
}
sum === 100.00 ? callback() : WfForm.showMessage("明细付款比例总和不等于100,请修改后提交!");
});
}
/**
* 明细表字段发生变化进行日期计算
* @param bindField
* @param configObj
*/
function detailFieldChangeDetailCom(bindField, configObj){
WfForm.bindDetailFieldChangeEvent(bindField,function(id,index,value){
configObj.index = index;
changeDetailPayDate(configObj);
});
}
/**
* 主表字段发生变化进行日期计算
* @param mainField
* @param detailTable
* @param configObj
*/
function mainFieldChangeDetailCom(mainField, detailTable, configObj){
// 主表项目字段变化绑定
WfForm.bindFieldChangeEvent(mainField, function(obj,id,value){
let rowArr = WfForm.getDetailAllRowIndexStr(detailTable).split(",");
for(let i=0; i < rowArr.length; i++){
let index = rowArr[i];
if(index !== ""){
configObj.index = index;
changeDetailPayDate(configObj);
}
}
});
}
/**
* 先进行主表的dml查询日期字段赋值到明细 然后在计算日期
* @param obj 配置对象
*/
function changeDetailPayDate(obj){
console.log('---- changeDetailPayDate obj ----', obj);
// 明细表的款项类型
let detailPaymentTypeId = obj['detailPaymentTypeId'];
// 明细下标
let index = obj['index'];
// 明细表的对应日期
let detailTempDateId = obj['detailTempDateId'];
// 明细表的前/后
let aroundId = obj['around'];
// 明细表的预计付款日期
let detailComPayDateId = obj['detailComPayDateId'];
// 明细表的天数
let dayId = obj['dayId'];
// 需要计算的款项数组
let computeDatePayType = obj['computeDatePayType'];
// 获取主表的字符值转换函数
let paymentTypeGetValue = obj['paymentTypeGetValue'];
// 款项类型
let paymentType = WfForm.getFieldValue(`${detailPaymentTypeId}_${index}`);
// 先进行赋值
if(computeDatePayType.includes(paymentType)){
WfForm.changeFieldAttr(`${detailComPayDateId}_${index}`, READ_ONLY);
// 存在字段联动延时处理
setTimeout(()=>{
if(paymentTypeGetValue){
paymentTypeGetValue[paymentType](index);
}
// 获取对应日期
let tempDate = WfForm.getFieldValue(`${detailTempDateId}_${index}`);
if(tempDate){
// 前/后
let around = WfForm.getFieldValue(`${aroundId}_${index}`);
// 天数
let day = WfForm.getFieldValue(`${dayId}_${index}`);
// 如果明细表三个字段的值都不为空 那么就去计算日期
if(tempDate && around && day){
let comDate = computeDate(tempDate, around, day);
WfForm.changeFieldValue(`${detailComPayDateId}_${index}`,{
value: comDate
});
}
}else {
// 如果对应日期为空就给预计付款赋空值
WfForm.changeFieldValue(`${detailComPayDateId}_${index}`,{
value: ''
});
}
},100);
}else{
// 如果款项类型不需要计算就把预计付款日期属性改成可编辑
WfForm.changeFieldAttr(`${detailComPayDateId}_${index}`, EDIT);
}
}

View File

@ -0,0 +1,58 @@
/**
* 柏美 采购合同申请js
* @author xuanran.wang
*/
// 明细表
const detailTable = "detail_3";
// 主表项目字段
const mainProjectId = WfForm.convertFieldNameToId("xmmc");
// 主表合同签订日期
const contractSignDateId = WfForm.convertFieldNameToId("htqdrq");
// 明细2付款比例字段
const detailPayProportionId = WfForm.convertFieldNameToId("fkbl",detailTable);
// 明细2款项类型
const detailPaymentTypeId = WfForm.convertFieldNameToId("kxlx",detailTable);
// 明细2前后字段
const detailAroundId = WfForm.convertFieldNameToId("qh",detailTable);
// 明细2天数字段
const detailDayId = WfForm.convertFieldNameToId("ts",detailTable);
// 明细2预计付款日期
const detailComPayDateId = WfForm.convertFieldNameToId("yjfkrq",detailTable);
// 对应日期
const detailTempDateField = WfForm.convertFieldNameToId("dyrq", detailTable);
// 需要计算的款项类型集合
const computeDatePayType = ['0','2','4'];
// 款项类型预计对应日期取值
const paymentTypeGetValue = {
0: (index)=>{
WfForm.changeFieldValue(`${detailTempDateField}_${index}`,{value : WfForm.getFieldValue(contractSignDateId)});
},
2: (index)=>{
WfForm.changeFieldValue(`${detailTempDateField}_${index}`,{value : WfForm.getFieldValue(mainActualCheckId)});
},
4: (index)=>{
WfForm.changeFieldValue(`${detailTempDateField}_${index}`,{value : WfForm.getFieldValue(mainActualCheckId)});
}
}
$(()=>{
init();
});
function init(){
let obj = {
'detailPaymentTypeId':detailPaymentTypeId,
'detailTempDateId': detailTempDateField,
'around': detailAroundId,
'detailComPayDateId': detailComPayDateId,
'dayId': detailDayId,
'computeDatePayType': computeDatePayType,
'paymentTypeGetValue': paymentTypeGetValue
}
// 主表字段发生变化
mainFieldChangeDetailCom(`${mainProjectId},${contractSignDateId}`, detailTable, obj);
// 明细的款项类型字段变化绑定
detailFieldChangeDetailCom(`${detailPaymentTypeId},${detailAroundId},${detailDayId}`, obj);
submitCallback(detailTable, detailPayProportionId);
}

View File

@ -0,0 +1,61 @@
/**
* 柏美 销售合同申请js
* @author xuanran.wang
*/
// 明细表
const detailTable = "detail_2";
// 主表项目字段
const mainProjectId = WfForm.convertFieldNameToId("xmmc");
// 主表流程归档日期
const mainWorkFlowEndId = WfForm.convertFieldNameToId("fhdgdrq");
// 主表实际验收
const mainActualCheckId = WfForm.convertFieldNameToId("sjysrq");
// 明细2付款比例字段
const detail2PayProportionId = WfForm.convertFieldNameToId("fkbl",detailTable);
// 明细2款项类型
const detail2PaymentTypeId = WfForm.convertFieldNameToId("kxlx",detailTable);
// 明细2前后字段
const detail2AroundId = WfForm.convertFieldNameToId("qh",detailTable);
// 明细2天数字段
const detail2DayId = WfForm.convertFieldNameToId("ts",detailTable);
// 明细2预计付款日期
const detail2ComPayDateId = WfForm.convertFieldNameToId("yjfkrq",detailTable);
// 对应日期
const detail2TempDateField = WfForm.convertFieldNameToId("dyrq", detailTable);
// 需要计算的款项类型集合
const computeDatePayType = ['2', '4', '5'];
// 款项类型预计对应日期取值
const paymentTypeGetValue = {
2: (index)=>{
console.log('将主表的 mainWorkFlowEndId : ' + mainWorkFlowEndId + ' val : ' + WfForm.getFieldValue(mainWorkFlowEndId) + ' 赋值给明细 ' + `${detail2TempDateField}_${index}`);
WfForm.changeFieldValue(`${detail2TempDateField}_${index}`,{value : WfForm.getFieldValue(mainWorkFlowEndId)});
},
4: (index)=>{
WfForm.changeFieldValue(`${detail2TempDateField}_${index}`,{value : WfForm.getFieldValue(mainActualCheckId)});
},
5: (index)=>{
WfForm.changeFieldValue(`${detail2TempDateField}_${index}`,{value : WfForm.getFieldValue(mainActualCheckId)});
}
}
$(()=>{
init();
});
function init(){
let obj = {
'detailPaymentTypeId':detail2PaymentTypeId,
'detailTempDateId': detail2TempDateField,
'around': detail2AroundId,
'detailComPayDateId': detail2ComPayDateId,
'dayId': detail2DayId,
'computeDatePayType': computeDatePayType,
'paymentTypeGetValue': paymentTypeGetValue
}
// 主表字段发生变化
mainFieldChangeDetailCom(mainProjectId, detailTable, obj);
// 明细的款项类型字段变化绑定
detailFieldChangeDetailCom(`${detail2PaymentTypeId},${detail2AroundId},${detail2DayId}`, obj);
submitCallback(detailTable, detail2PayProportionId);
}

View File

@ -0,0 +1,151 @@
// 打印盖章
const pritGz = 1;
// 鉴伪盖章
const jwGz = 3;
// 开门盖章
const kmGz = 4;
// 用印方式字段名
const sealTypeId = WfForm.convertFieldNameToId("yyfs");
// 用印方式字段名明细
const detailSealTypeId = WfForm.convertFieldNameToId("yylx","detail_1");
// 是否需要加骑缝章
const detailQfzField = WfForm.convertFieldNameToId("sfjgqfz","detail_1");
// 否
const no = 1;
// 是
const yes = 0;// 组合用印
const zh = 6;
// 取章用印
const qzyy = 7;
// 是否归档
const lastField = WfForm.convertFieldNameToId("sfgd");
// 来源
const source = WfForm.convertFieldNameToId("htspcfyy");
//属于合同
const isht = WfForm.convertFieldNameToId("zyht");
//完成法神
const islaw = WfForm.convertFieldNameToId("wcfs");
// 用印文件字段
const detailFileTypeId = WfForm.convertFieldNameToId("yywj","detail_1");
// 主表
const mainsealtype = WfForm.convertFieldNameToId("yzzl");
// 主表合同专用章次数
const mainht = WfForm.convertFieldNameToId("htzyzcshj");
// 主表公章次数
const maingz = WfForm.convertFieldNameToId("gzcshj");
// 主表法人章次数
const mainfr = WfForm.convertFieldNameToId("frzcshj");
// 必填
const required = 3;
// 只读
const readOnly = 1;
// 可编辑
const edit = 2;
// 默认文件docid
const defaultfile = 85;
// 明细1用印文件
jQuery(document).ready(()=>{
let sourceVal = WfForm.getFieldValue(source);
console.log('sourceVal ', sourceVal)
if(sourceVal == 0){
WfForm.changeSingleField(isht,{value:yes}, {viewAttr:readOnly});
WfForm.changeSingleField(islaw,{value:yes}, {viewAttr:readOnly});
// 明细表用印文件字段做只读
var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
for(var i=0; i<rowArr.length; i++){
var rowIndex = rowArr[i];
if(rowIndex !== ""){
WfForm.changeFieldAttr(`${detailFileTypeId}_${rowIndex}`, readOnly);
}
}
// 明细行上+-按钮清除
$('#detail1Btn').empty();
}
WfForm.bindFieldChangeEvent(sealTypeId, function(obj,id,val){ //变更用印方式触发
changeDetailFieldVal();
if(val == qzyy || val == kmGz){
WfForm.delDetailRow("detail_1", "all");
}
if(pritGz == val || jwGz == val || zh == val){
WfForm.changeSingleField(lastField,{value:1}, {viewAttr:readOnly});
} else if (kmGz == val){
WfForm.changeSingleField(lastField,{value:2}, {viewAttr:readOnly});
} else{
WfForm.changeSingleField(lastField,{value:''}, {viewAttr:required});
}
addRow();
});
WfForm.bindFieldChangeEvent(`${mainsealtype}, ${mainfr}, ${maingz}, ${mainht}`, function(obj,id,val){
WfForm.delDetailRow("detail_1", "all");
addRow();
})
WfForm.registerCheckEvent(WfForm.OPER_ADDROW+ "1", function(callback){
callback(); //允许继续添加行调用callback不调用代表阻断添加
let val = WfForm.getFieldValue(sealTypeId);
if(val == zh){
return;
}
changeDetailFieldVal();
});
})
function addRow(){
let val = WfForm.getFieldValue(sealTypeId);
if(val == kmGz || val == qzyy){
// 明细1印章种类
let detail1SealType = WfForm.convertFieldNameToId("yzzl","detail_1");
// 明细1合同专用章次数
let detail1ht = WfForm.convertFieldNameToId("htzyzcs","detail_1");
// 明细1公章次数
let detail1gz = WfForm.convertFieldNameToId("gzcs","detail_1");
// 明细1法人章次数
let detail1fr = WfForm.convertFieldNameToId("frzcs","detail_1");
console.log('detail1SealType ', detail1SealType);
console.log('detail1ht ', detail1SealType);
console.log('detail1SealType ', detail1SealType);
console.log('detail1SealType ', detail1SealType);
let obj = {
detailFileTypeId: {value:defaultfile},
detail1SealType: {value:WfForm.getFieldValue(mainsealtype)},
detail1gz: {value:WfForm.getFieldValue(maingz)},
detail1fr: {value:WfForm.getFieldValue(mainfr)},
detail1ht: {value:WfForm.getFieldValue(mainht)}
};
console.log('obj ', obj)
WfForm.addDetailRow("detail_1",obj);
}
}
function changeDetailFieldVal(){
let val = WfForm.getFieldValue(sealTypeId);
// 必填
let attr = required;
let syqf = '';
if(val == pritGz || val == jwGz){
attr = readOnly;
syqf = no;
}else{
val = '';
}
var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
for(var i=0; i<rowArr.length; i++){
var rowIndex = rowArr[i];
if(rowIndex !== ""){
WfForm.changeSingleField(`${detailSealTypeId}_${rowIndex}`,{value:val}, {viewAttr:attr});
WfForm.changeSingleField(`${detailQfzField}_${rowIndex}`,{value:syqf}, {viewAttr:attr});
}
}
}

View File

@ -56,7 +56,7 @@ public class CheckUserService {
String searchBase = Util.null2String(ADConfig.get("searchBase"));
// LDAP搜索过滤器类 cn=*name*模糊查询 cn=name 精确查询 String searchFilter = "(objectClass="+type+")";
//查询域帐号
String searchFilter = Util.null2String(ADConfig.get("queryField")) + "=" + checkInfo;
String searchFilter = "(" + Util.null2String(ADConfig.get("queryField")) + "=" + checkInfo + ")";
log.info("searchFilter : " + searchFilter);
// 创建搜索控制器
SearchControls searchControl = new SearchControls();
@ -64,8 +64,14 @@ public class CheckUserService {
searchControl.setSearchScope(SearchControls.SUBTREE_SCOPE);
// 根据设置的域节点、过滤器类和搜索控制器搜索LDAP得到结果
NamingEnumeration answer = ldapContext.search(searchBase, searchFilter, searchControl);
boolean has = answer.hasMoreElements();
while (answer.hasMoreElements()) {
SearchResult sr = (SearchResult) answer.next();
String dn = sr.getName();
log.info("dn " + dn);
}
// 初始化搜索结果数为0
return answer.hasMoreElements();
return has;
} catch (NamingException e) {
throw new CustomerException(Util.logStr("从AD搜索用户异常:[{}]",e.getMessage()));
} finally {

View File

@ -2,10 +2,20 @@ package com.api.xuanran.wang.saic_travel.model_create_workflow.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.saic_travel.model_create_workflow.service.CreateWorkFlowService;
import com.icbc.api.internal.apache.http.E;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.formmode.data.ModeDataApproval;
import weaver.general.TimeUtil;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.xuanran.wang.common.mapper.CommonMapper;
import weaver.xuanran.wang.common.util.CommonUtil; // 工具类
import javax.servlet.http.HttpServletRequest;
@ -13,9 +23,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -28,26 +36,75 @@ public class CusCreateWorkFlowController {
private final Logger logger = Util.getLogger(); // 获取日志对象
private final CreateWorkFlowService createWorkFlowService = new CreateWorkFlowService();
@Path("cusCreateWorkFlow")
@POST
@Produces(MediaType.TEXT_PLAIN)
public String createWorkFlow(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User logInUser = HrmUserVarify.getUser(request, response);
if(logInUser == null){
return ApiResult.error(403,"请先登录!");
}
String choiceData = request.getParameter("choiceData");
int modelId = Util.getIntValue(request.getParameter("modelId"), -1);
List<String> dataList = Arrays.stream(choiceData.split(",")).collect(Collectors.toList());
List<String> requestIds = CommonUtil.doCreateWorkFlow(modelId, dataList); // 通过数据审批生成流程
List<String> errorData = new ArrayList<>();
for (int i = 0; i < requestIds.size(); i++) {
if (Util.getIntValue(requestIds.get(i), -1) < 0) {
errorData.add(dataList.get(i));
try {
User logInUser = HrmUserVarify.getUser(request, response);
if(logInUser == null){
return ApiResult.error(403,"请先登录!");
}
String choiceData = request.getParameter("choiceData");
if(StringUtils.isBlank(choiceData)){
return ApiResult.error(403,"请勾选数据!");
}
int modelId = Util.getIntValue(request.getParameter("modelId"), -1);
String triggerWorkflowSetId = Util.null2DefaultStr(request.getParameter("triggerWorkflowSetId"), "");
String createDateField = Util.null2DefaultStr(request.getParameter("createDateField"), "");
if(modelId < 0 || StringUtils.isBlank(triggerWorkflowSetId) || StringUtils.isBlank(createDateField)){
logger.info(Util.logStr("modelId : {}, triggerWorkflowSetId : {}, createDateField : {}", modelId, triggerWorkflowSetId, createDateField));
return ApiResult.error(403,"api必要参数未配置!");
}
return ApiResult.success(JSONObject.toJSONString( createWorkFlowService.hrmCusCreateWorkFlow(choiceData, createDateField, triggerWorkflowSetId, modelId)));
}catch (Exception e){
logger.error(Util.logStr(e.getMessage()));
logger.error(Util.getErrString(e));
return ApiResult.error("接口发生异常!");
}
logger.error(Util.logStr("执行创建流程失败集合: {}",JSONObject.toJSONString(errorData))); // 构建日志字符串
return ApiResult.success(errorData);
}
@Path("gysCusCreateWorkFlow")
@POST
@Produces(MediaType.TEXT_PLAIN)
public String gysCusCreateWorkFlow(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User logInUser = HrmUserVarify.getUser(request, response);
if(logInUser == null){
return ApiResult.error(403,"请先登录!");
}
String choiceData = request.getParameter("choiceData");
if(StringUtils.isBlank(choiceData)){
return ApiResult.error(403,"请勾选数据!");
}
// 执行创建流程数据审批的模块id
int dataApprovalModelId = Util.getIntValue(request.getParameter("dataApprovalModelId"), -1);
// 待合并数据审批id
int createTriggerId = Util.getIntValue(request.getParameter("createTriggerId"), -1);
// 数据同步配置参数
String asyncCode = Util.null2DefaultStr(request.getParameter("asyncCode"), "");
// 带合并模块id
String dataModelId = Util.null2DefaultStr(request.getParameter("dataModelId"), "");
if(createTriggerId < 0 || StringUtils.isBlank(asyncCode) || dataApprovalModelId < 0 || StringUtils.isBlank(dataModelId)){
logger.info(Util.logStr("createTriggerId : {}, asyncCode : {}, dataApprovalModelId : {}", createTriggerId, asyncCode, dataApprovalModelId));
return ApiResult.error(403,"api必要参数未配置!");
}
return ApiResult.success(createWorkFlowService.supplierCusCreateWorkFlow(String.valueOf(createTriggerId), dataModelId, asyncCode, choiceData, dataApprovalModelId));
}catch (Exception e){
logger.error(Util.logStr(e.getMessage()));
logger.error(Util.getErrString(e));
return ApiResult.error("接口发生异常!");
}
}
}

View File

@ -0,0 +1,233 @@
package com.api.xuanran.wang.saic_travel.model_create_workflow.service;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject;
import com.icbc.api.internal.apache.http.impl.cookie.S;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.xuanran.wang.common.mapper.CommonMapper;
import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.saic_travel.model_data_async.config.eneity.DataAsyncDetail;
import weaver.xuanran.wang.saic_travel.model_data_async.config.eneity.DataAsyncMain;
import weaver.xuanran.wang.saic_travel.model_data_async.constant.DataAsyncConstant;
import weaver.xuanran.wang.saic_travel.model_data_async.service.DataAsyncConfigService;
import java.util.*;
import java.util.stream.Collectors;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/15 14:33
*/
public class CreateWorkFlowService {
private final DataAsyncConfigService dataAsyncConfigService = new DataAsyncConfigService();
private final CommonMapper commonMapper = Util.getMapper(CommonMapper.class);
private final Logger logger = Util.getLogger();
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/15 17:07
* @param choiceData
* @param createDateField
* @param triggerWorkflowSetId id
* @param modelId id
* @return id
**/
public List<String> hrmCusCreateWorkFlow(String choiceData, String createDateField, String triggerWorkflowSetId, int modelId){
String name = commonMapper.getModelNameByModelId(String.valueOf(modelId));
List<String> dataList = Arrays.stream(choiceData.split(",")).collect(Collectors.toList());
RecordSet rs = new RecordSet();
List<List<String>> splitList = CommonUtil.splitList(dataList);
for (List<String> list : splitList) {
List<Integer> ids = list.stream().map(item -> Util.getIntValue(item, -1)).collect(Collectors.toList());
if(CollectionUtils.isEmpty(ids)){
continue;
}
String updateCreatDateSql = "update " + name + " set " + createDateField + " = '"+ TimeUtil.getCurrentDateString() +"' where id in ( " + StringUtils.join(ids,",") + " )";
if(!rs.executeUpdate(updateCreatDateSql)){
throw new CustomerException(Util.logStr("更新建模表数据失败!, 当前sql : {} ", updateCreatDateSql));
}
}
// 数据审批配置Id
String[] triggerIds = triggerWorkflowSetId.split(",");
logger.info("triggerIds : " + JSONObject.toJSONString(triggerIds));
List<String> errorData = new ArrayList<>();
for (String id : triggerIds) {
String sql = "select id from " + name;
String condition = commonMapper.getConditionByTriggerId(id);
if(StringUtils.isNotBlank(condition)){
sql += " where " + condition;
}
logger.info(Util.logStr("人员创建流程查询数据sql : {}", sql));
List<String> filterIds = filterIds(sql);
List<String> dataIds = dataList.stream().filter(filterIds::contains).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(dataIds)){
List<String> requestIds = CommonUtil.doCreateWorkFlow(modelId, dataIds, Util.getIntValue(id, -1)); // 通过数据审批生成流程
for (int i = 0; i < requestIds.size(); i++) {
if (Util.getIntValue(requestIds.get(i), -1) < 0) {
errorData.add(dataList.get(i));
}
}
}else {
logger.info("当前数据都不满足触发条件!");
}
logger.error(Util.logStr("人员创建流程执行创建流程失败集合: {}",JSONObject.toJSONString(errorData))); // 构建日志字符串
}
return errorData;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/15 17:11
* @param createTriggerId id
* @param dataModelId id
* @param asyncCode
* @param choiceData
* @param dataApprovalModelId id
* @return requestId
**/
public String supplierCusCreateWorkFlow(String createTriggerId, String dataModelId, String asyncCode, String choiceData, int dataApprovalModelId){
// 查询来源数据待合并 数据审批配置
Map<String, String> configByTriggerId = commonMapper.getConfigByTriggerId(String.valueOf(createTriggerId));
if(MapUtils.isEmpty(configByTriggerId)){
return ApiResult.error(403,"请给模块id = [ "+createTriggerId + " ] 配置数据审批!");
}
// 待合并的表名
String dataTable = commonMapper.getModelNameByModelId(dataModelId);
String sql = "select id from " + dataTable;
// 触发条件
String condition = Util.null2DefaultStr(configByTriggerId.get("showcondition"), "");
String successWriteBack = Util.null2DefaultStr(configByTriggerId.get("successwriteback"), "");
if(StringUtils.isNotBlank(condition)){
sql += " where " + condition;
}
List<String> dataList = Arrays.stream(choiceData.split(",")).collect(Collectors.toList());
logger.info(Util.logStr("查询数据sql : {}", sql));
List<String> filterIds = filterIds(sql);
// 过滤之后的数据id
List<String> dataIds = dataList.stream().filter(filterIds::contains).collect(Collectors.toList());
List<String> requestIds = new ArrayList<>();
if(!CollectionUtils.isEmpty(dataIds)){
String dataId = asyncModelData(asyncCode, dataIds, dataApprovalModelId);
requestIds = CommonUtil.doCreateWorkFlow(dataApprovalModelId, Collections.singletonList(dataId));
if(CollectionUtils.isEmpty(requestIds)){
throw new CustomerException("流程创建失败!");
}
if(CollectionUtils.isNotEmpty(requestIds) && !(Util.getIntValue(requestIds.get(0),-1) < 0 && StringUtils.isNotBlank(successWriteBack))){
RecordSet rs = new RecordSet();
sql = "update " + dataTable + " set " + successWriteBack + " where " + Util.getSubINClause(StringUtils.join(dataIds, ","),"id"," in ");
if (!rs.executeUpdate(sql)) {
logger.error(Util.logStr("回写sql : {}", sql));
throw new CustomerException("流程创建成功, 但回写失败!");
}
}
return requestIds.get(0);
}else {
logger.info("当前数据都不满足触发条件!");
}
return "";
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/2 13:28
* @param configCode
* @param modelId id
**/
public String asyncModelData(String configCode, List<String> dataIds, int modelId) {
DataAsyncMain asyncConfig = dataAsyncConfigService.getDataAsyncConfigByUniqueCode(configCode);
String dataSource = asyncConfig.getDataSource();
String selectSql = dataAsyncConfigService.getSelectSql(asyncConfig);
List<DataAsyncDetail> asyncDetailList = asyncConfig.getDataAsyncDetailList();
selectSql += " where " + Util.getSubINClause(StringUtils.join(dataIds, ","),"id"," in ");
RecordSet rs = new RecordSet();
if (!rs.executeQuery(selectSql)) {
throw new CustomerException(Util.logStr("执行查询数据源sql失败! 当前sql:{}", selectSql));
}
// 主表同步配置条件
List<DataAsyncDetail> mainConfigList = asyncDetailList.stream().filter(item -> !DataAsyncConstant.DETAIL_TABLE.equals(item.getMainOrDetail())).collect(Collectors.toList());
List<DataAsyncDetail> detailConfigList = asyncDetailList.stream().filter(item -> DataAsyncConstant.DETAIL_TABLE.equals(item.getMainOrDetail())).collect(Collectors.toList());
String mainId = "";
if (rs.next()){
// 先把数据同步到主表
LinkedHashMap<String, Object> params = getValue(mainConfigList, rs, dataSource);
mainId = CusInfoToOAUtil.getDataId(modelId, params);
logger.info("生成建模mainId : " + mainId);
}
rs.executeQuery(selectSql);
ArrayList<LinkedHashMap<String, Object>> detailParams = new ArrayList<>();
while (rs.next()){
LinkedHashMap<String, Object> value = getValue(detailConfigList, rs, dataSource);
value.put("mainid", mainId);
detailParams.add(value);
}
CusInfoToOAUtil.executeDetailBatch(asyncConfig.getAsyncTargetModelTableName()+ "_dt" + asyncConfig.getDetailIndex(),detailParams);
return mainId;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/15 16:29
* @param asyncDetailList
* @param rs
* @param dataSource
* @return
**/
public LinkedHashMap<String, Object> getValue(List<DataAsyncDetail> asyncDetailList, RecordSet rs, String dataSource){
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
for (DataAsyncDetail dataAsyncDetail : asyncDetailList) {
String field = "";
switch (dataSource){
case DataAsyncConstant.DATA_SOURCE_MODEL:{
field = dataAsyncDetail.getDataSourceModelFiledName();
}break;
case DataAsyncConstant.DATA_SOURCE_CUS_TABLE:{
field = dataAsyncDetail.getCusTableField();
}break;
default:throw new CustomerException("暂不支持的数据来源");
}
// 同步建模字段
String asyncModelTableField = dataAsyncDetail.getAsyncModelTableField();
Object value = dataAsyncConfigService.getFieldValue(rs, field, dataAsyncDetail, 0);
map.put(asyncModelTableField, value);
}
if(MapUtils.isEmpty(map)){
throw new CustomerException("转换配置生成参数map为空!");
}
return map;
}
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2022/12/15 13:22
* @param sql sql
* @return id
**/
public List<String> filterIds(String sql){
RecordSet rs = new RecordSet();
ArrayList<String> res = new ArrayList<>();
if (rs.executeQuery(sql)) {
while (rs.next()){
res.add(Util.null2DefaultStr(rs.getString(1),""));
}
}
return res;
}
}

View File

@ -0,0 +1,91 @@
package weaver.xuanran.wang.bme.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSetTrans;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Map;
/**
* <h1>action</h1>
*
* @Author xuanran.wang
* @Date 2022/12/20 11:33
*/
public class ContractApplyComDateAction extends SafeCusBaseAction {
/**
* <h2></h2>
**/
@RequiredMark
private String buildContractProjectField;
/**
* <h2></h2>
**/
@RequiredMark
private String buildContractTable;
/**
* <h2></h2>
**/
@RequiredMark
private String detailContractTable;
/**
* <h2></h2>
**/
@RequiredMark
private String detailContractDateFiled;
/**
* <h2></h2>
**/
@RequiredMark
private String projectField;
/**
* <h2></h2>
**/
@RequiredMark
private String checkDateField;
/**
* <h2></h2>
**/
private String updateWhere;
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
RecordSetTrans rs = requestInfo.getRsTrans();
rs.setAutoCommit(false);
try {
Map<String, String> mainTableValue = getMainTableValue(requestInfo);
// 验收流程的实际验收日期
String checkDate = mainTableValue.get(checkDateField);
String project = mainTableValue.get(projectField);
if(StringUtils.isBlank(checkDate) || StringUtils.isBlank(project)){
log.error(Util.logStr("checkDate:{}, project:{}", checkDate, project));
throw new CustomerException("实际验收日期或项目字段字段为空!");
}
String selectSql = "select id from " + buildContractTable + " where " + buildContractProjectField + " = ?";
if(rs.executeQuery(selectSql, project) && rs.next()){
String mainId = rs.getString("id");
String updateSql = "update " + detailContractTable + " set " + detailContractDateFiled + " = ? where mainid = ?";
if(StringUtils.isNotBlank(updateWhere)){
updateSql += " and " + updateWhere;
}
if(!rs.executeUpdate(updateSql, checkDate, mainId)){
log.error(Util.logStr("更新合同明细表sql:{}, 参数:{}", updateSql, new String[]{checkDate, mainId}));
throw new CustomerException("更新合同sql错误!");
}
rs.commit();
}else{
log.error(Util.logStr("查询施工合同关联项目sql : {}", selectSql));
}
}catch (Exception e){
rs.rollback();
throw new CustomerException(Util.logStr("更新施工合同实际验收日期发生异常: {} ", e.getMessage()));
}
}
}

View File

@ -0,0 +1,111 @@
package weaver.xuanran.wang.bme.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* <h1></h1>
* <p>
* + 4 DUJE0101 DUJE0199 => DUJE0201
* </p>
*
* @Author xuanran.wang
* @Date 2022/12/22 13:18
*/
public class CusCreateWaterNoAction extends SafeCusBaseAction {
/**
* <h2></h2>
**/
@RequiredMark
private String invClassificationCode;
/**
* <h2> </h2>
**/
@RequiredMark
private String inventoryCode;
/**
* <h2>id</h2>
**/
private String serialNumberModelId;
private static final String START_NO = "0101";
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info("----------- CusCreateWaterNoAction Begin " + requestId + "-----------");
RecordSetTrans rsts = new RecordSetTrans();
rsts.setAutoCommit(false);
try {
Map<String, String> mainTableValue = getMainTableValue(requestInfo);
String invClassificationCodeVal = mainTableValue.get(invClassificationCode);
String nextInventoryCode = getNextInventoryCode(invClassificationCodeVal);
String updateSql = "update " + billTable + " set " + inventoryCode + " = ? where requestid = ?";
if(!rsts.executeUpdate(updateSql, nextInventoryCode, requestId)){
log.error(Util.logStr("sql :{}, nextInventoryCode : {}, requestId: {}", updateSql, nextInventoryCode, requestId));
throw new CustomerException("更新表单存货编码字段失败!");
}
}catch (Exception e){
throw new CustomerException(Util.logStr("生成存货编码Action异常: [{}]",e.getMessage()));
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/22 14:08
* @param inventoryCode
* @return +
**/
private synchronized String getNextInventoryCode(String inventoryCode){
RecordSet rs = new RecordSet();
String modelTableName = CommonUtil.getModelTableNameById(Util.getIntValue(serialNumberModelId, -1));
String sql = "select max(serialNumber) serialNumber from " + modelTableName + " where invClassificationCode = ? order by createDateTime";
String res = "";
if(rs.executeQuery(sql, inventoryCode)){
if (!rs.next()) {
res = inventoryCode + START_NO;
}else {
String serialNumber = rs.getString(1);
String front = serialNumber.substring(0,2);
String end = serialNumber.substring(3);
int frontInt = Util.getIntValue(front);
int endInt = Util.getIntValue(end);
String endStr = "";
String frontStr = "";
if(++endInt >= 100){
frontInt += 1;
endInt = 1;
}
if(endInt < 10){
endStr = "0" + endInt;
}
if(frontInt < 10){
frontStr = "0" + frontInt;
}
res = frontStr + endStr;
}
}
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
map.put("invClassificationCode", inventoryCode);
map.put("serialNumber", res);
map.put("serialCode", inventoryCode + res);
CusInfoToOAUtil.getDataId(Util.getIntValue(serialNumberModelId, -1), map);
return res;
}
}

View File

@ -50,4 +50,11 @@ public interface CommonMapper {
"ON mp.id = mpd.mainId " +
"WHERE mp.modeid = #{modelId} AND mp.isSystem = 1 AND mp.iSSystemFlag = 1")
Map<String, Integer> getExpendConfigByModeId(@ParamMapper("modelId") int modelId);
@Select("select * from mode_triggerworkflowset where id = #{triggerId}")
Map<String, String> getConfigByTriggerId(@ParamMapper("triggerId") String triggerId);
@Select("select showcondition from mode_triggerworkflowset where id = #{triggerId}")
String getConditionByTriggerId(@ParamMapper("triggerId") String triggerId);
}

View File

@ -232,6 +232,16 @@ public class CommonUtil {
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/11/25 16:01
* @param list
* @return
**/
public static <T> List<List<T>> splitList(List<T> list) {
return splitList(list, SQL_IN_PAGE_SIZE);
}
/**
* <h1></h1>
* @author xuanran.wang
@ -337,6 +347,9 @@ public class CommonUtil {
* @return true/false
**/
public static boolean deleteDataByIds(List<String> ids, String tableName,int pageSize) {
if(CollectionUtils.isEmpty(ids)){
return true;
}
List<List<String>> lists = CommonUtil.splitList(ids, pageSize);
for (List<String> list : lists) {
boolean success = commonMapper.deleteModelDataByIds(tableName, list);
@ -526,4 +539,61 @@ public class CommonUtil {
return requestIds;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/1 21:14
* @param modeId id
* @param dataIds id
* @param triggerWorkflowSetId id
**/
public static List<String> doCreateWorkFlow(int modeId, List<String> dataIds, int triggerWorkflowSetId){
if(modeId < 0){
throw new CustomerException("模块id不能小于0!");
}
if(triggerWorkflowSetId < 0){
throw new CustomerException("自定义数据审批id不能小于0!");
}
if(org.springframework.util.CollectionUtils.isEmpty(dataIds)){
logger.info("暂无数据要生成流程!");
return Collections.emptyList();
}
Map<String, Integer> expendConfig = commonMapper.getExpendConfigByModeId(modeId);
logger.info(Util.logStr("expendConfig {}", JSONObject.toJSONString(expendConfig)));
int expendId = expendConfig.get("id");
int formId = expendConfig.get("formId");
ArrayList<String> requestIds = new ArrayList<>();
if(expendId > 0 && triggerWorkflowSetId > 0){
for (String daId : dataIds) {
ModeDataApproval modeDataApproval = new ModeDataApproval();
modeDataApproval.setUser(new User(1));
modeDataApproval.setBillid(Util.getIntValue(daId));
modeDataApproval.setFormid(formId);
modeDataApproval.setModeid(modeId);
modeDataApproval.setTriggerWorkflowSetId(triggerWorkflowSetId);
modeDataApproval.setPageexpandid(expendId);
Map<String, String> resMap = modeDataApproval.approvalDataResult();
logger.info(Util.logStr("模块数据id : {}, 创建流程结果 : {}", daId, JSONObject.toJSONString(resMap)));
requestIds.add(Util.null2String(resMap.get("requestid")));
}
}
return requestIds;
}
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2022/12/22 14:18
* @param modelId id
* @return
**/
public static String getModelTableNameById(int modelId){
if(modelId < 0){
throw new CustomerException("模块id不能小于0!");
}
return commonMapper.getModelNameByModelId(String.valueOf(modelId));
}
}

View File

@ -16,6 +16,7 @@ import weaver.general.TimeUtil;
import weaver.xuanran.wang.common.mapper.CommonMapper;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author xuanran.wang
@ -26,7 +27,7 @@ public class CusInfoToOAUtil {
private static final ModeDataIdUpdate modeDataIdUpdate = ModeDataIdUpdate.getInstance();
private static final ModeRightInfo moderightinfo = new ModeRightInfo();
private static final Logger log = Util.getLogger();
public static final String TABLE_NAME_PLACEHOLDER = "#\\{tableName}";
private static final String TABLE_NAME_PLACEHOLDER = "#\\{tableName}";
/**
* <h1></h1>
@ -74,7 +75,7 @@ public class CusInfoToOAUtil {
String whereSql,
List<String> whereParams,
boolean needDel) {
return executeBatch(modelId, Collections.singletonList(new LinkedHashMap<>(params)), whereSql, whereParams, needDel).get(0);
return executeBatch(modelId, Collections.singletonList(new LinkedHashMap<>(params)), whereSql,Collections.singletonList(whereParams), needDel, Collections.emptyList()).get(0);
}
/**
@ -87,7 +88,7 @@ public class CusInfoToOAUtil {
**/
public static List<String> executeBatch( int modelId,
List<LinkedHashMap<String, Object>> params) {
return executeBatch(modelId, params, "", Collections.emptyList(), true);
return executeBatch(modelId, params, "", Collections.emptyList());
}
/**
@ -111,8 +112,13 @@ public class CusInfoToOAUtil {
if(StringUtils.isBlank(tableName)){
throw new CustomerException("模块id为 " + modelId + ", 在系统中暂没查询到对应表单!");
}
return executeBatch(modelId, tableName, params, whereSql, whereParams, true);
ArrayList<List<String>> lists = new ArrayList<>();
for (String param : whereParams) {
lists.add(new ArrayList<>(Collections.singleton(param)));
}
return executeBatch(modelId, tableName, params, whereSql, lists, true, Collections.emptyList());
}
/**
* <h1></h1>
* @author xuanran.wang
@ -124,11 +130,12 @@ public class CusInfoToOAUtil {
* @param needDel
* @return id
**/
public static List<String> executeBatch( int modelId,
List<LinkedHashMap<String, Object>> params,
String whereSql,
List<String> whereParams,
boolean needDel) {
public static List<String> executeBatch( int modelId,
List<LinkedHashMap<String, Object>> params,
String whereSql,
List<List<String>> whereParams,
boolean needDel,
List<LinkedHashMap<String, Object>> updateParams) {
if(modelId < 0){
throw new RuntimeException("建模模块id不能小于0!");
}
@ -136,7 +143,7 @@ public class CusInfoToOAUtil {
if(StringUtils.isBlank(tableName)){
throw new CustomerException("模块id为 " + modelId + ", 在系统中暂没查询到对应表单!");
}
return executeBatch(modelId, tableName, params, whereSql, whereParams, needDel);
return executeBatch(modelId, tableName, params, whereSql, whereParams, needDel, updateParams);
}
/**
@ -149,57 +156,75 @@ public class CusInfoToOAUtil {
* @param whereSql sql
* @param whereParams
* @param needDel
* @param updateParams
* @return id
**/
public static List<String> executeBatch( int modelId,
String tableName,
List<LinkedHashMap<String, Object>> params,
String whereSql,
List<String> whereParams,
boolean needDel) {
List<List<String>> whereParams,
boolean needDel,
List<LinkedHashMap<String, Object>> updateParams) {
// 如果要对模块数据中重复的进行更新则判断待插入的集合大小和判断重复的集合大小参数长度是否一致
if(StringUtils.isNotBlank(whereSql)){
if(CollectionUtils.isEmpty(whereParams) || CollectionUtils.isEmpty(params) || whereParams.size() != params.size()){
log.error(Util.logStr("params : {}", JSONObject.toJSONString(params)));
log.error(Util.logStr("whereSql : {}", whereSql));
log.error(Util.logStr("whereParams : {} ", JSONObject.toJSONString(whereParams)));
log.error(Util.logStr("updateParams : {} ", updateParams));
throw new CustomerException("使用批量更新时如果需要对重复数据进行更新,参数集合和判断重复参数集合大小必须相等!");
}
}
RecordSet rs = new RecordSet();
List<String> dataIds = new ArrayList<>();
List<Where> wheres = new ArrayList<>();
List<Where> paramsWheres = new ArrayList<>();
List<Where> updateWheres = new ArrayList<>();
whereSql = Util.sbc2dbcCase(whereSql);
whereSql = whereSql.replaceAll(TABLE_NAME_PLACEHOLDER, tableName);
// 需要插入的建模参数
List<LinkedHashMap<String, Object>> tempParams = new ArrayList<>();
// 如果建模中已经存在只想更新部分字段参数
List<LinkedHashMap<String, Object>> tempUpdateParams = new ArrayList<>();
for (int i = 0; i < params.size(); i++) {
int mainId = -1;
if(StringUtils.isNotBlank(whereSql)){
whereSql = Util.sbc2dbcCase(whereSql);
whereSql = whereSql.replaceAll(TABLE_NAME_PLACEHOLDER, tableName);
if (rs.executeQuery(whereSql, whereParams) && rs.next()) {
// 如果匹配到数据
if (rs.executeQuery(whereSql, whereParams.get(i)) && rs.next()) {
mainId = Util.getIntValue(rs.getString(1),-1);
updateWheres.add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(mainId));
dataIds.add(String.valueOf(mainId));
if(!CollectionUtils.isEmpty(updateParams)){
tempUpdateParams.add(updateParams.get(i));
}else {
tempUpdateParams.add(params.get(i));
}
}else {
log.info("whereSql : " + whereSql);
log.info("参数 : " + whereParams);
log.info(Util.logStr("==== 未匹配到数据 ==== whereSql : {}, 参数 : {}", whereSql, JSONObject.toJSONString(whereParams.get(i))));
}
}
if(mainId < 0){
mainId = getNewIdByModelInfo(tableName, modelId);
paramsWheres.add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(mainId));
dataIds.add(String.valueOf(mainId));
tempParams.add(params.get(i));
}
dataIds.add(String.valueOf(mainId));
wheres.add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(mainId));
}
BatchSqlResultImpl batchSql = Util.createSqlBuilder().updateBatchSql(tableName, params, wheres);
String sqlStr = batchSql.getSqlStr();
List<List> batchList = batchSql.getBatchList();
if(!rs.executeBatchSql(sqlStr, batchList)){
log.error(Util.logStr("batchSql:{}", sqlStr));
log.error(Util.logStr("batchList:{}", JSONObject.toJSONString(batchList)));
log.error(Util.logStr("whereList:{}", JSONObject.toJSONString(wheres)));
try {
if(CollectionUtils.isNotEmpty(tempParams) && CollectionUtils.isNotEmpty(paramsWheres)){
execute(tableName, tempParams, paramsWheres);
}
if(CollectionUtils.isNotEmpty(tempUpdateParams) && CollectionUtils.isNotEmpty(updateWheres)){
execute(tableName, tempUpdateParams, updateWheres);
}
}catch (Exception e){
if(needDel){
if (!deleteModelDataByIds(String.valueOf(modelId), dataIds)) {
log.error(Util.logStr("删除数据失败!未删除数据集合:{}", JSONObject.toJSONString(dataIds)));
}
}
throw new CustomerException("执行批量更新sql失败!");
}
if(CollectionUtils.isEmpty(dataIds)){
throw new CustomerException("建模数据生成失败!");
throw new CustomerException(e.getMessage());
}
for (String dataId : dataIds) {
moderightinfo.rebuildModeDataShareByEdit(1, modelId, Integer.parseInt(dataId));
@ -207,6 +232,49 @@ public class CusInfoToOAUtil {
return dataIds;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/11/23 17:00
* @param tableName
* @param params map
* @return id
**/
public static boolean executeDetailBatch(String tableName, List<LinkedHashMap<String, Object>> params){
RecordSet rs = new RecordSet();
BatchSqlResultImpl batchSql = Util.createSqlBuilder().insertBatchSql(tableName, params);
String sqlStr = batchSql.getSqlStr();
List<List> list = batchSql.getBatchList();
if (!rs.executeBatchSql(sqlStr, list)) {
throw new CustomerException(Util.logStr("明细数据插入失败! sql : {}, params : {}", sqlStr, JSONObject.toJSONString(list)));
}
return true;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/15 10:53
* @param tableName
* @param params
* @param wheres where
**/
public static void execute(String tableName, List<LinkedHashMap<String, Object>> params, List<Where> wheres){
// log.info(Util.logStr("params : [{}],size : [{}]", JSONObject.toJSONString(params), params.size()));
// log.info(Util.logStr("wheres : [{}],size : [{}]", JSONObject.toJSONString(wheres), wheres.size()));
BatchSqlResultImpl batchSql = Util.createSqlBuilder().updateBatchSql(tableName, params, wheres);
String sqlStr = batchSql.getSqlStr();
List<List> batchList = batchSql.getBatchList();
RecordSet rs = new RecordSet();
if(!rs.executeBatchSql(sqlStr, batchList)){
log.error(Util.logStr("batchSql:{}", sqlStr));
log.error(Util.logStr("batchList:{}", JSONObject.toJSONString(batchList)));
log.error(Util.logStr("whereList:{}", JSONObject.toJSONString(wheres)));
throw new CustomerException("执行批量更新sql失败!请查看后台cus日志!");
}
}
/**
* <h1></h1>
* @author xuanran.wang
@ -219,6 +287,14 @@ public class CusInfoToOAUtil {
String tableName = commonMapper.getModelNameByModelId(modelId);
return commonMapper.deleteModelDataByIds(tableName, ids);
}
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2022/12/15 10:56
* @param modelTableName
* @param modelId id
* @return id
**/
private static Integer getNewIdByModelInfo(String modelTableName, int modelId){
String currentDateTime = TimeUtil.getCurrentTimeString();
//日期

View File

@ -0,0 +1,21 @@
package weaver.xuanran.wang.epdi.datapush.eneity;
import lombok.Data;
/**
* @Author xuanran.wang
* @Date 2022/6/18 16:47
*/
@Data
public class DetailRequestConfig {
private String paramName;
private String paramType;
private String getValueType;
private String valueContext;
private String tableName;
private String workFlowField;
private String fieldName;
private String detailId;
private String parentName;
}

View File

@ -0,0 +1,25 @@
package weaver.xuanran.wang.epdi.datapush.eneity;
import lombok.Data;
import java.util.List;
/**
* @Author xuanran.wang
* @Date 2022/6/18 15:43
*/
@Data
public class MainRequestConfig {
private String id;
private String uniqueCode;
private String workflow;
private String requestUrl;
private String dataSource;
private String detailIndex;
private String cusSql;
private String configFilePath;
private String enable;
private String methodParameterClassName;
private List<DetailRequestConfig> detailRequestConfigList;
}

View File

@ -5,7 +5,7 @@ import lombok.*;
import java.sql.Timestamp;
/**
* <h1></h1>
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/1 14:01
@ -48,4 +48,16 @@ public class DataAsyncDetail {
* <h2></h2>
**/
private String dataSourceModelFiledName;
/**
* <h2></h2>
**/
private String updateCriteria;
/**
* <h2></h2>
**/
private String updateField;
/**
* <h2></h2>
**/
private String mainOrDetail;
}

View File

@ -22,5 +22,6 @@ public class DataAsyncMain {
private String cusWhere;
private String modelTypeTableName;
private String asyncTargetModelTableName;
private String detailIndex;
private List<DataAsyncDetail> dataAsyncDetailList;
}

View File

@ -76,4 +76,12 @@ public class DataAsyncConstant {
* <h2>-</h2>
**/
public static final String CONVERT_RULES_SPLIT_COPY = "5";
/**
* <h2></h2>
**/
public static final String MAIN_TABLE = "0";
/**
* <h2></h2>
**/
public static final String DETAIL_TABLE = "1";
}

View File

@ -30,9 +30,11 @@ public class CusDataToModelAsync extends BaseCronJob {
@Override
public void execute() {
try {
logger.info("------------ CusDataToModelAsync Begin ------------");
CommonUtil.checkParamNotNull(this);
DataAsyncMain dataAsyncConfigByUniqueCode = asyncConfigService.getDataAsyncConfigByUniqueCode(uniqueCode);
asyncConfigService.asyncModelData(dataAsyncConfigByUniqueCode, Util.getIntValue(modelId, -1));
logger.info("------------ CusDataToModelAsync End ------------");
}catch (Exception e){
logger.error(Util.logStr("执行数据同步计划任务失败!异常信息 : {}", e.getMessage()));
}

View File

@ -18,6 +18,4 @@ public interface DataAsyncMapper {
@CaseConversion(false)
RecordSet getRecordSetByCusSql(@SqlString String sql);
}

View File

@ -2,8 +2,12 @@ package weaver.xuanran.wang.saic_travel.model_data_async.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.zwl.common.ToolUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import weaver.conn.RecordSet;
@ -62,17 +66,51 @@ public class DataAsyncConfigService {
}
logger.info("selectSql : " + selectSql);
List<LinkedHashMap<String, Object>> linkedHashMapList = new ArrayList<>();
StringBuilder updateWhereSql = new StringBuilder();
// 需要更新时候的参数集合
List<LinkedHashMap<String, Object>> updateLinkedList = new ArrayList<>();
// 判断是否更新sql的参数
List<List<String>> updateWhereParam = new ArrayList<>();
int splitCopy = -1;
String splitCopyFiledName = "";
// 复制个数
List<DataAsyncDetail> splitCopyList = asyncDetailList.stream().filter(item -> DataAsyncConstant.CONVERT_RULES_SPLIT_COPY.equals(item.getConvertRules())).collect(Collectors.toList());
DataAsyncDetail copyAsyncDetail = null;
if(!CollectionUtils.isEmpty(splitCopyList)){
DataAsyncDetail detail = splitCopyList.get(0);
copyAsyncDetail = detail;
splitCopy = Util.getIntValue(detail.getCusText(),-1);
splitCopyFiledName = Util.null2DefaultStr(detail.getAsyncModelTableField(),"");
}
// 更新数据条件
List<String> updateCriteriaList = asyncDetailList.stream()
.filter(item -> DataAsyncConstant.CONFIG_ENABLE.equals(item.getUpdateCriteria()))
.map(DataAsyncDetail::getAsyncModelTableField)
.collect(Collectors.toList());
// 更新字段
List<String> updateFieldList = asyncDetailList.stream()
.filter(item -> DataAsyncConstant.CONFIG_ENABLE.equals(item.getUpdateField()))
.map(DataAsyncDetail::getAsyncModelTableField)
.collect(Collectors.toList());
// 如果更新条件不为空那么就拼接更新sql
if(!CollectionUtils.isEmpty(updateCriteriaList)){
StringBuilder sqlSb = new StringBuilder();
for (int i = 0; i < updateCriteriaList.size(); i++) {
if(i != updateCriteriaList.size() -1 ){
sqlSb.append(updateCriteriaList.get(i)).append(" = ? and ");
}else {
sqlSb.append(updateCriteriaList.get(i)).append(" = ? ");
}
}
updateWhereSql.append("select id from #{tableName} where ").append(sqlSb);
}
while (rs.next()){
// 建模表插入参数
LinkedHashMap<String, Object> linkedHashMap = new LinkedHashMap<>();
// 如果数据存在更新参数集合
LinkedHashMap<String, Object> updateLinkedMap = new LinkedHashMap<>();
// 更新条件参数
LinkedHashMap<String, String> updateParam = new LinkedHashMap<>();
int tempCount = 0;
for (DataAsyncDetail dataAsyncDetail : asyncDetailList) {
String field = "";
@ -85,19 +123,49 @@ public class DataAsyncConfigService {
}break;
default:throw new CustomerException("暂不支持的数据来源");
}
// 同步建模字段
String asyncModelTableField = dataAsyncDetail.getAsyncModelTableField();
Object value = getFieldValue(rs, field, dataAsyncDetail, tempCount);
linkedHashMap.put(dataAsyncDetail.getAsyncModelTableField(), value);
// 把当前字段和值放到更新条件参数集合中
if(!CollectionUtils.isEmpty(updateCriteriaList) && updateCriteriaList.contains(asyncModelTableField)){
updateParam.put(asyncModelTableField, Util.null2DefaultStr(value,""));
}
// 需要更新时更新字段参数集合
if(!CollectionUtils.isEmpty(updateCriteriaList) && updateFieldList.contains(asyncModelTableField)){
updateLinkedMap.put(asyncModelTableField, value);
}
linkedHashMap.put(asyncModelTableField, value);
}
updateWhereParam.add(new ArrayList<>(updateParam.values()));
linkedHashMapList.add(linkedHashMap);
if(MapUtils.isNotEmpty(updateLinkedMap)){
updateLinkedList.add(updateLinkedMap);
}
// 记录复制
while (++tempCount < splitCopy) {
LinkedHashMap<String, Object> copyMap = new LinkedHashMap<>(linkedHashMap);
// 如果更新条件参数map不为空
if(MapUtils.isNotEmpty(updateLinkedMap)){
// 需要更新的参数map集合
LinkedHashMap<String, Object> copyUpdateLinkedMap = new LinkedHashMap<>(updateLinkedMap);
// 如果更新条件中包含拆分复制条件的
if(copyAsyncDetail != null && updateCriteriaList.contains(copyAsyncDetail.getAsyncModelTableField())){
updateParam.put(copyAsyncDetail.getAsyncModelTableField(), String.valueOf(tempCount));
}
// 将拆分复制的值加进去
if(copyAsyncDetail != null && updateFieldList.contains(copyAsyncDetail.getAsyncModelTableField())){
copyUpdateLinkedMap.put(splitCopyFiledName, tempCount);
}
updateLinkedList.add(copyUpdateLinkedMap);
updateWhereParam.add(new ArrayList<>(updateParam.values()));
}
copyMap.put(splitCopyFiledName, tempCount);
linkedHashMapList.add(copyMap);
}
}
return CusInfoToOAUtil.executeBatch(modelId, linkedHashMapList);
return CusInfoToOAUtil.executeBatch(modelId, linkedHashMapList, updateWhereSql.toString(), updateWhereParam, true, updateLinkedList);
}
/**
* <h1></h1>
* @author xuanran.wang
@ -108,7 +176,7 @@ public class DataAsyncConfigService {
* @param count
* @return
**/
public Object getFieldValue(RecordSet recordSet, String field, DataAsyncDetail dataAsyncDetail, int count){
public Object getFieldValue(RecordSet recordSet, String field, @NotNull DataAsyncDetail dataAsyncDetail, int count){
String convertRules = dataAsyncDetail.getConvertRules();
String dataType = dataAsyncDetail.getDataType();
String cusText = dataAsyncDetail.getCusText();
@ -131,12 +199,14 @@ public class DataAsyncConfigService {
// 自定义sql查询
case DataAsyncConstant.CONVERT_RULES_CUS_SQL: {
if(!StringUtils.isBlank(cusText)){
String cusSql = Util.sbc2dbcCase(cusText);
String where = "";
if(StringUtils.isNotBlank(field)){
where = Util.null2DefaultStr(recordSet.getString(field),"");
}
tempRs.executeQuery(cusSql, where);
String cusSql = Util.sbc2dbcCase(cusText)
.replace("?",where)
.replace("{main.id}", recordSet.getString("id"));
tempRs.executeQuery(cusSql);
if (!tempRs.next()) {
logger.error(Util.logStr("执行自定义sql失败!当前sql:{}, 当前参数:{}", cusSql, where));
break;
@ -146,6 +216,7 @@ public class DataAsyncConfigService {
}break;
case DataAsyncConstant.CONVERT_RULES_DATA_ID: {
value = recordSet.getString("id");
logger.info(Util.logStr("主数据Id : {}", value));
}break;
case DataAsyncConstant.CONVERT_RULES_SPLIT_COPY: {
value = count;
@ -232,30 +303,33 @@ public class DataAsyncConfigService {
* @return sql
**/
public String getSelectSql(DataAsyncMain asyncConfig){
String dataSource = asyncConfig.getDataSource();
String cusWhere = Util.null2DefaultStr(asyncConfig.getCusWhere(), "");
String dataSourceTableName = "";
List<DataAsyncDetail> asyncDetailList = asyncConfig.getDataAsyncDetailList();
String selectSql = "select ";
List<String> modelFieldList = new ArrayList<>();
// 判断数据来源拼接查询sql
switch (dataSource) {
case DataAsyncConstant.DATA_SOURCE_MODEL:{
modelFieldList = asyncDetailList.stream().map(DataAsyncDetail::getDataSourceModelFiledName).filter(StringUtils::isNotBlank).collect(Collectors.toList());
dataSourceTableName = asyncConfig.getModelTypeTableName();
}break;
case DataAsyncConstant.DATA_SOURCE_CUS_TABLE:{
modelFieldList = asyncDetailList.stream().map(DataAsyncDetail::getCusTableField).filter(StringUtils::isNotBlank).collect(Collectors.toList());
dataSourceTableName = asyncConfig.getCusTable();
}break;
default:throw new CustomerException("暂不支持的数据来源!");
}
// 拼接数据源查询sql
selectSql += StringUtils.join(modelFieldList, ",") + " from " + dataSourceTableName;
String selectSql = "select * from " + getTableName(asyncConfig);
if(StringUtils.isNotBlank(cusWhere)){
selectSql += " where " + cusWhere;
}
return selectSql;
}
/**
* <h1>sql</h1>
* @author xuanran.wang
* @dateTime 2022/12/2 12:56
* @param asyncConfig
* @return sql
**/
public String getTableName(DataAsyncMain asyncConfig){
// 判断数据来源拼接查询sql
switch (asyncConfig.getDataSource()) {
case DataAsyncConstant.DATA_SOURCE_MODEL:{
return asyncConfig.getModelTypeTableName();
}
case DataAsyncConstant.DATA_SOURCE_CUS_TABLE:{
return asyncConfig.getCusTable();
}
default:throw new CustomerException("暂不支持的数据来源!");
}
}
}

View File

@ -1,19 +1,23 @@
package weaver.xuanran.wang.schroeder.action;
import aiyh.utils.Util;
import aiyh.utils.action.CusBaseAction; // 基础的action实现一些基础的参数
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException; // 自定义异常类 create 2022/3/9 2:20 PM
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.schroeder.before.interfaces.CusActionBeforeProcessor;
import weaver.xuanran.wang.schroeder.service.SchroederQRCodeService;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -23,7 +27,7 @@ import java.util.stream.Collectors;
* @Author xuanran.wang
* @Date 2022/11/30 16:08
*/
public class PushSealTaskAction extends CusBaseAction { // 基础的action实现一些基础的参数
public class PushSealTaskAction extends SafeCusBaseAction { // 基础的action实现一些基础的参数
/**
* <h2></h2>
@ -47,43 +51,162 @@ public class PushSealTaskAction extends CusBaseAction { // 基础的action
* <h2>id</h2>
**/
@RequiredMark
private String modelId;
private String docLogModelId;
/**
* <h2>requestIdid</h2>
**/
@RequiredMark
private String requestIdLogModelId;
/**
* <h2></h2>
**/
@RequiredMark
private String filePeopleType;
/**
* <h2></h2>
**/
@RequiredMark
private String detailNo;
/**
* <h2></h2>
**/
@RequiredMark
private String successCode;
/**
* <h2></h2>
**/
@RequiredMark
private String backField;
/**
* <h2></h2>
**/
private String cusBeforeProcessor;
/**
* <h2></h2>
**/
private String type;
private final SchroederQRCodeService schroederQRCodeService = new SchroederQRCodeService(); // 施罗德业务方法 施罗德业务方法
@Override // action 提交流程业务处理方法 具体业务逻辑实现
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestManager requestManager) {
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info("---------- PushSealTaskSealValue Begin " + requestId + "----------");
RequestInfo requestInfo = requestInfoThreadLocal.get();
String scanNum = schroederQRCodeService.pushSealTask(onlyMark, billTable, requestId); // 推送数据创建任务 建模配置唯一标识
RecordSetTrans trans = requestManager.getRsTrans();
String delSql = "";
String mainId = "";
RecordSetTrans trans = new RecordSetTrans();
trans.setAutoCommit(false);
String updateSql = "update " + billTable + " set " + QRCodeField + " = ? where requestid = ?"; // 二维码来源字段
// 插入模块的参数集合
List<String> requestIdLogModelIdList = new ArrayList<>();
List<String> docLogModelIdList = new ArrayList<>();
// 前置接口做了添加明细表的操作 最后是否需要删除添加的明细
boolean del = false;
// 执行前置处理 默认添加一行明细
if(StringUtils.isNotBlank(cusBeforeProcessor)){
Map<String, String> pathParam = Util.parseCusInterfacePathParam(cusBeforeProcessor);
String classPath = pathParam.remove("_ClassPath");
del = executeBeforeProcessor(classPath, requestInfo, null, pathParam);
}
RecordSet mainRs = new RecordSet();
mainRs.executeQuery("select * from " + billTable + " where requestid = ?", requestId);
mainRs.next();
try{
mainId = mainRs.getString("id");
String detailTable = billTable + "_dt" + detailNo;
if(StringUtils.isNotBlank(mainId)){
delSql = "delete from " + detailTable + " where mainid = ? ";
}
try{
// 获取明细表数据
List<Map<String, String>> detailList = schroederQRCodeService.getDetailList(detailTable, mainId);
List<String> docIds = detailList.stream()
.map(item -> Util.null2DefaultStr(item.get(fileField), ""))
.filter(StringUtils::isNotBlank).collect(Collectors.toList());
List<LinkedHashMap<String, Object>> docLogParamList = new ArrayList<>();
for (String docId : docIds) {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
map.put("docId", docId);
map.put("enable", 0);
docLogParamList.add(map);
}
// 将docLog数据写入建模
docLogModelIdList = CusInfoToOAUtil.executeBatch(Util.getIntValue(docLogModelId, -1), docLogParamList, "select id from #{tableName} where docId = ?", docIds);
// requestLog写入建模
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
int count = schroederQRCodeService.getTaskIdByRequestId(requestId);
if(Util.getIntValue(String.valueOf(count),-1) < 0){
count = 1;
}else {
count += 1;
}
map.put("count", count);
map.put("cusRequestId", requestId);
requestIdLogModelIdList = CusInfoToOAUtil.executeBatch(Util.getIntValue(requestIdLogModelId, -1), Collections.singletonList(map));
}catch (Exception e){
throw new CustomerException(Util.logStr("数据写入建模异常!:{}", e.getMessage()));
}
String scanNum = schroederQRCodeService.pushSealTask(onlyMark, billTable, requestId, type, successCode, backField, filePeopleType); // 推送数据创建任务 建模配置唯一标识
String updateSql = "update " + billTable + " set " + QRCodeField + " = ? where requestid = ?"; // 二维码来源字段
if(!trans.executeUpdate(updateSql, scanNum, requestId)){
throw new CustomerException(Util.logStr("更新表单sql执行失败!sql : {}, 参数 scanNum : {}, requestId : {}", scanNum, requestId)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
// 获取明细表数据
List<Map<String, String>> detailList = getDetailTableValueByDetailNo(1, requestInfo);
List<String> docIds = detailList.stream()
.map(item -> Util.null2DefaultStr(item.get(fileField), ""))
.filter(StringUtils::isNotBlank).collect(Collectors.toList());
ArrayList<LinkedHashMap<String, Object>> list = new ArrayList<>();
for (String docId : docIds) {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
map.put("docId", docId);
map.put("enable", 0);
list.add(map);
}
// 将数据写入建模
CusInfoToOAUtil.executeBatch(Util.getIntValue(modelId, -1), list, "select 1 from #{tableName} where docId = ?", docIds);
}catch (Exception e){
CommonUtil.deleteDataByIds(requestIdLogModelIdList, Util.getIntValue(requestIdLogModelId,-1));
CommonUtil.deleteDataByIds(docLogModelIdList, Util.getIntValue(docLogModelId,-1));
trans.rollback();
throw new CustomerException(Util.logStr("执行提交方法异常:{}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}finally {
log.info(Util.logStr("del: {}, sql: {}, mainId: {}", del, delSql, mainId));
if(del && StringUtils.isNotBlank(delSql)){
RecordSet rs = new RecordSet();
if(!rs.executeUpdate(delSql, mainId)){
log.error(Util.logStr("删除明细表失败! sql: {}, mainId: {}", delSql, mainId));
}
}
}
trans.commit();
}
/**
* <h2></h2>
*
* @param className
* @return
*/
private boolean executeBeforeProcessor(String className, RequestInfo requestInfo,
RequestMappingConfig requestMappingConfig,
Map<String, String> pathParam) {
Class<?> aClass;
try {
aClass = Class.forName(className);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("未能找到自定义action前置置处理方法理接口" + className);
}
Constructor<?> constructor;
try {
constructor = aClass.getConstructor();
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(className + "没有空参构造方法,无法获取构造方法对象!");
}
if (!CusActionBeforeProcessor.class.isAssignableFrom(aClass)) {
throw new IllegalArgumentException("自定义前置置处理接口:" + className + " 不是"
+ CusActionBeforeProcessor.class.getName() + "的子类或实现类!");
}
CusActionBeforeProcessor o;
try {
o = (CusActionBeforeProcessor) constructor.newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalArgumentException("无法构造" + className + "对象!");
}
return o.beforeProcessor(requestInfo, requestMappingConfig, pathParam);
}
}

View File

@ -0,0 +1,45 @@
package weaver.xuanran.wang.schroeder.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xuanran.wang.schroeder.service.SchroederQRCodeService;
/**
* <h1>action</h1>
*
* @Author xuanran.wang
* @Date 2022/12/23 10:49
*/
public class SalesforceEndpointAction extends SafeCusBaseAction {
/**
* <h2></h2>
**/
@RequiredMark
private String onlyMark;
/**
* <h2></h2>
**/
@RequiredMark
private String successCode;
/**
* <h2></h2>
**/
@RequiredMark
private String type;
private final SchroederQRCodeService schroederQRCodeService = new SchroederQRCodeService();
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
try {
schroederQRCodeService.pushSealTask(onlyMark, billTable, requestId,type, successCode,"","");
}catch (Exception e){
throw new CustomerException(Util.logStr("执行提交方法异常:{}", e.getMessage())); //
}
}
}

View File

@ -0,0 +1,62 @@
package weaver.xuanran.wang.schroeder.before;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import com.alibaba.fastjson.JSONObject;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xuanran.wang.schroeder.before.interfaces.CusActionBeforeProcessor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/21 16:44
*/
public class PushSealTaskBeforeProcessor implements CusActionBeforeProcessor {
private final Logger logger = Util.getLogger();
/**
* weaver.xuanran.wang.schroeder.before.PushSealTaskBeforeProcessor?whereSql=`yyfs in (4,7)`&mapping=`yzzl:yzzl,htzyzcshj:htzyzcs,gzcshj:gzcs,frzcshj:frzcs`&detailNo=1
*/
@Override
public boolean beforeProcessor(RequestInfo requestInfo, RequestMappingConfig requestMappingConfig, Map<String, String> pathParam) {
String whereSql = pathParam.get("whereSql");
String tableName = requestInfo.getRequestManager().getBillTableName();
String sql = "select * from " + tableName + " where requestid = ? and " + whereSql;
RecordSet rs = new RecordSet();
// 如果主表数据符合插入条件
// mapping=sas:dashdjas,dhjsadh:dfhjs
logger.info(Util.logStr("前置接口 : sql : {}, 路径参数: {}", sql, JSONObject.toJSONString(pathParam)));
if(rs.executeQuery(sql, requestInfo.getRequestid()) && rs.next()){
HashMap<String, Object> detailMap = new HashMap<>();
String mapping = pathParam.get("mapping");
String detailNo = pathParam.get("detailNo");
String[] split = mapping.split(",");
for (String str : split) {
String[] map = str.split(":");
detailMap.put(map[1], Util.null2DefaultStr(rs.getString(map[0]),""));
}
detailMap.put("mainid", rs.getString("id"));
// 用印文件docId
detailMap.put(pathParam.get("fileField"),pathParam.get("fileFieldValue"));
PrepSqlResultImpl sqlResult = Util.createSqlBuilder().insertSql(tableName + "_dt" + detailNo, detailMap);
String sqlStr = sqlResult.getSqlStr();
List<Object> args = sqlResult.getArgs();
if (!rs.executeUpdate(sqlStr, args)) {
throw new CustomerException(Util.logStr("明细数据插入失败! sql : {}, params : {}", sqlStr, JSONObject.toJSONString(args)));
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,23 @@
package weaver.xuanran.wang.schroeder.before.interfaces;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import java.util.Map;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/21 16:40
*/
public interface CusActionBeforeProcessor {
/**
*
* @param requestInfo
* @param requestMappingConfig onlyMark
* @param pathParam
* @return
*/
boolean beforeProcessor(RequestInfo requestInfo, RequestMappingConfig requestMappingConfig, Map<String, String> pathParam);
}

View File

@ -27,7 +27,6 @@ public class PushSealTaskSealValue implements CusInterfaceGetValue { // 自定
@Override // 获取参数值
public Object execute(Map<String, Object> mainMap, Map<String, Object> detailMap, String currentValue, Map<String, String> pathParam) {
logger.info(Util.logStr("路径参数:[{}]", JSONObject.toJSONString(pathParam)));
logger.info("路径参数(字符串拼接) : " + JSONObject.toJSONString(pathParam));// 构建日志字符串
// 接口字段
String sealSnField = pathParam.get("sealSnField");
String sealNumField = pathParam.get("sealNumField");
@ -39,7 +38,6 @@ public class PushSealTaskSealValue implements CusInterfaceGetValue { // 自定
if(checkBlank(sealSnField, sealNumField, sealSnCusSql, sealNumCusSql)){
throw new CustomerException(Util.logStr("自定义类路径中必要参数为空,请检查!当前pathParam : {}", JSONObject.toJSONString(pathParam))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
logger.info(Util.logStr("当前值 : {}", currentValue)); // 构建日志字符串
// 如果为空返回空集合
if(StringUtils.isBlank(currentValue)){
return Collections.emptyList();

View File

@ -3,6 +3,7 @@ package weaver.xuanran.wang.schroeder.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import com.icbc.api.internal.apache.http.impl.cookie.S;
import java.util.List;
import java.util.Map;
@ -41,5 +42,20 @@ public interface SchroederMapper {
List<Map<String, Object>> selectSealFileList(@ParamMapper("fileField") String fileField,
@ParamMapper("tableName") String tableName,
@ParamMapper("mainId") String mainId);
/**
* <h1>Id</h1>
* @author xuanran.wang
* @dateTime 2022/12/21 9:39
* @param cusRequestId id
* @return taskId
**/
@Select("select max(count) count " +
"from uf_request_task_log " +
"where cusRequestId = #{cusRequestId} " +
"group by cusRequestId")
Integer selectTaskId(@ParamMapper("cusRequestId") String cusRequestId);
@Select("select * from $t{tableName} where mainid = #{mainId}")
List<Map<String, String>> detailList(@ParamMapper("tableName") String tableName,
@ParamMapper("mainId") String mainId);
}

View File

@ -5,29 +5,21 @@ import aiyh.utils.excention.CustomerException; // 自定义异常类 create 20
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.zxing.qrcode.encoder.QRCode;
import com.icbc.api.internal.apache.http.M;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import weaver.conn.RecordSet;
import weaver.mobile.plugin.ecology.QRCodeComInfo;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping;
import weaver.xuanran.wang.schroeder.mapper.SchroederMapper;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@ -38,10 +30,6 @@ import java.util.stream.Collectors;
*/
public class SchroederQRCodeService {
private static final int SUCCESS_CODE = 200;
/**
* <h2></h2>
**/
private static final int SUCCESS_STATUS= 0;
/**
* <h2></h2>
**/
@ -54,91 +42,154 @@ public class SchroederQRCodeService {
* <h2></h2>
**/
private static final String STATUS_FIELD = "status";
/**
* <h2>get</h2>
**/
public static final String GET = "GET";
/**
* <h2>post</h2>
**/
public static final String POST = "POST";
/**
* <h2>requestId</h2>
**/
private final DealWithMapping dealWithMapping = new DealWithMapping();
private final Logger log = Util.getLogger(); // 获取日志对象
private final HttpUtils httpUtils = new HttpUtils();
{
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
}
private final SchroederMapper schroederMapper = Util.getMapper(SchroederMapper.class);
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/5 17:05
* @param onlyMark
* <h1></h1>
*
* @param onlyMark
* @param billTable
* @param requestId id
* @param type
* @param successCode
* @param backField
* @param filePeopleType filePeopleType
* @return
* @author xuanran.wang
* @dateTime 2022/12/5 17:05
**/
public String pushSealTask(String onlyMark, String billTable, String requestId){
String res = "";
public String pushSealTask(String onlyMark, String billTable,
String requestId, String type,
String successCode, String backField,String filePeopleType) {
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构
String cusWhere = Util.null2DefaultStr(requestMappingConfig.getCusWhereSql(),"");
if(StringUtils.isNotBlank(cusWhere)){
cusWhere = DealWithMapping.sbc2dbcCase(cusWhere); // 全角转半角
Map<String, Object> requestParam = getParamsMap(requestMappingConfig, billTable, requestId, filePeopleType);
String url = requestMappingConfig.getRequestUrl();
ResponeVo responeVo = null;
try {
switch (type){
case GET: {
responeVo = httpUtils.apiGet(url, requestParam, new HashMap<>());
}break;
case POST: {
responeVo = httpUtils.apiPost(url, requestParam);
}break;
default:throw new CustomerException("暂不支持的请求方式!");
}
} catch (IOException e) {
throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
String selectMainSql = "select * from " + billTable + " where requestid = ? " + cusWhere;
log.info("查询主表数据sql { " + selectMainSql + " }, requestId { " + requestId + " }");
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(selectMainSql, requestId);
if (recordSet.next()) {
dealWithMapping.setMainTable(billTable);
Map<String, Object> requestParam = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
// 如果明细数据存在骑缝章时候增加一行数据进去
changeRequestMap(requestParam, billTable + "_dt1", recordSet.getString("id"));
// 解析请求参数配置树,转换成请求参数
log.info(Util.logStr("请求json : {}", JSONObject.toJSONString(requestParam))); // 构建日志字符串
String url = requestMappingConfig.getRequestUrl();
ResponeVo responeVo = null;
try {
responeVo = httpUtils.apiPost(url, requestParam);
} catch (IOException e) {
throw new CustomerException(Util.logStr("发送印章请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
Map<String, String> headers = httpUtils.getGlobalCache().header; // 全局请求头
if (responeVo.getCode() != SUCCESS_CODE) { // 相应状态码
log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串
"this request heard is [{}]but response status code is [{}]" +
"this response is [{}]", url, JSON.toJSON(requestParam), JSON.toJSONString(headers), responeVo.getCode(), // 相应状态码
responeVo.getEntityString())); // 相应内容
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
Map<String, Object> response;
log.info(Util.logStr("this response is [{}]", responeVo.getEntityString())); // 构建日志字符串 相应内容
try {
response = responeVo.getEntityMap(); // 根据相应结果转化为map集合
log.info(Util.logStr("接口响应:{}", JSONObject.toJSONString(response))); // 构建日志字符串
} catch (JsonProcessingException e) {
log.error(Util.logStr("push data error, can not parse response to map" + // 构建日志字符串
"this response is [{}], url is [{}]request params is [{}] request heard is [{}];",
responeVo.getEntityString(), url, JSON.toJSONString(requestParam), JSON.toJSONString(headers))); // 相应内容
throw new CustomerException(Util.logStr("push data error, can not parse response to map")); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
int status = (int) response.get(STATUS_FIELD);
if(SUCCESS_STATUS != status){
throw new CustomerException(Util.logStr("接口响应码不为0,接口响应信息:{}", Util.null2DefaultStr(response.get(MESSAGE_FIELD),""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
res = Util.null2DefaultStr(response.get(SCAN_NUM_FIELD),"");
return parseResponseVo(responeVo, url, requestParam, successCode, backField);
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/23 11:25
* @param responseVo
* @param url
* @param requestParam
* @param successCode
* @param backField
* @return
**/
private String parseResponseVo(ResponeVo responseVo, String url,
Map<String, Object> requestParam,
String successCode, String backField){
String res = "";
Map<String, String> headers = httpUtils.getGlobalCache().header;// 全局请求头
if (responseVo.getCode() != SUCCESS_CODE) { // 相应状态码
log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串
"this request heard is [{}]but response status code is [{}]" +
"this response is [{}]", url, JSON.toJSON(requestParam), JSON.toJSONString(headers), responseVo.getCode(), // 相应状态码
responseVo.getEntityString())); // 相应内容
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
if(StringUtils.isBlank(res)){
throw new CustomerException("获取接口中响应任务字段为空, 请检查!"); // 自定义异常类 create 2022/3/9 2:20 PM
Map<String, Object> response;
log.info(Util.logStr("this response is [{}]", responseVo.getEntityString())); // 构建日志字符串 相应内容
try {
response = responseVo.getEntityMap(); // 根据相应结果转化为map集合
} catch (JsonProcessingException e) {
log.error(Util.logStr("push data error, can not parse response to map" + // 构建日志字符串
"this response is [{}], url is [{}]request params is [{}] request heard is [{}];",
responseVo.getEntityString(), url, JSON.toJSONString(requestParam), JSON.toJSONString(headers))); // 相应内容
throw new CustomerException(Util.logStr("push data error, can not parse response to map")); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
String status = Util.null2DefaultStr(response.get(STATUS_FIELD), "");
if (!successCode.equals(status)) {
throw new CustomerException(Util.logStr("接口响应码不为 : [{}],接口响应信息: {}", successCode, Util.null2DefaultStr(response.get(MESSAGE_FIELD), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
if(StringUtils.isNotBlank(backField)){
res = Util.null2DefaultStr(response.get(backField), "");
if (StringUtils.isBlank(res)) {
throw new CustomerException("获取接口中响应任务字段为空, 请检查!"); // 自定义异常类 create 2022/3/9 2:20 PM
}
}
return res;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/12/23 11:02
* @param requestMappingConfig
* @param billTable
* @param requestId id
* @param filePeopleType filePeopleType
* @return map
**/
public Map<String, Object> getParamsMap(RequestMappingConfig requestMappingConfig, String billTable, String requestId, String filePeopleType) {
String cusWhere = Util.null2DefaultStr(requestMappingConfig.getCusWhereSql(), "");
if (StringUtils.isNotBlank(cusWhere)) {
cusWhere = DealWithMapping.sbc2dbcCase(cusWhere); // 全角转半角
}
String selectMainSql = "select * from " + billTable + " where requestid = ? " + cusWhere;
log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId));
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(selectMainSql, requestId);
Map<String, Object> requestParam = new HashMap<>();
if (recordSet.next()) {
dealWithMapping.setMainTable(billTable);
requestParam = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
// 如果明细数据存在骑缝章时候增加一行数据进去
if (StringUtils.isNotBlank(filePeopleType)) {
changeRequestMap(requestParam, billTable + "_dt1", recordSet.getString("id"), filePeopleType);
}
}
return requestParam;
}
/**
* <h1></h1>
*
* @param requestParam
* @param billTable
* @param mainId id
* @author xuanran.wang
* @dateTime 2022/12/13 14:15
* @param requestParam
* @param billTable
* @param mainId id
**/
public void changeRequestMap(Map<String, Object> requestParam, String billTable, String mainId){
public void changeRequestMap(Map<String, Object> requestParam, String billTable, String mainId, String filePeopleType) {
List<Map<String, Object>> files = (List<Map<String, Object>>) requestParam.get("file");
List<Map<String, Object>> detail1List = schroederMapper.selectSealTaskInfoList(billTable, mainId);
if(CollectionUtils.isEmpty(detail1List) || CollectionUtils.isEmpty(files)){
if (CollectionUtils.isEmpty(detail1List) || CollectionUtils.isEmpty(files)) {
return;
}
// 遍历明细数据
@ -148,25 +199,53 @@ public class SchroederQRCodeService {
// 从生成的请求参数map中开始匹配
List<Map<String, Object>> filterFiles = files.stream()
.filter(item -> {
String filePath = Util.null2DefaultStr(item.get("filePath"), "");
String docId = Util.null2DefaultStr(filePath.substring(filePath.lastIndexOf("=") + 1),"");
String filePath = Util.null2DefaultStr(item.get("fileUrlPath"), "");
String docId = Util.null2DefaultStr(filePath.substring(filePath.lastIndexOf("=") + 1), "");
return sealFile.equals(docId);
})
.collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(filterFiles)){
if (CollectionUtils.isNotEmpty(filterFiles)) {
// 只有一个能匹配
Map<String, Object> o = filterFiles.get(0);
HashMap<String, Object> tempMap = o.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a, HashMap::new));
// 印章集合
List<HashMap<String, Object>> sealList = new ArrayList<>();
HashMap<String, Object> seal = new HashMap<>();
seal.put("sealSn",Util.null2DefaultStr(detailItem.get("qfzzl"),""));
seal.put("sealNum",Util.null2DefaultStr(detailItem.get("qfzcs"),"0"));
tempMap.put("seal", seal);
seal.put("sealSn", Util.null2DefaultStr(detailItem.get("qfzzl"), ""));
seal.put("sealNum", Util.null2DefaultStr(detailItem.get("qfzcs"), "0"));
sealList.add(seal);
tempMap.put("seal", sealList);
tempMap.put("filePeopleType", filePeopleType);
files.add(tempMap);
}
}
}
/**
* <h1>taskId</h1>
*
* @return id
* @author xuanran.wang
* @dateTime 2022/12/21 9:42
**/
public Integer getTaskIdByRequestId(String requestId) {
return schroederMapper.selectTaskId(requestId);
}
/**
* <h1></h1>
*
* @param tableName
* @param mainId id
* @return
* @author xuanran.wang
* @dateTime 2022/12/21 18:03
**/
public List<Map<String, String>> getDetailList(String tableName, String mainId) {
return schroederMapper.detailList(tableName, mainId);
}
}

View File

@ -2,6 +2,7 @@ package weaver.xuanran.wang.traffic_bank.waco_first.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.ChannelSftp;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -103,9 +104,11 @@ public class WacoDataPushOAService {
for (Info info : infos) {
List<String> docDetailParam = new ArrayList<>();
Map<String, Object> param = getParamsMapByInfo(secCategory, info, docDetailParam);
logger.info("param : " + JSONObject.toJSONString(param));
String dataId = CusInfoToOAUtil.getDataId(modelId, param,
whereSql,
Collections.singletonList(info.getInfoId()));
logger.info("dataId : " + JSONObject.toJSONString(dataId));
ids.add(dataId);
docDetailContentParams.add(docDetailParam);
}

View File

@ -1,17 +1,25 @@
package xuanran.wang.saic_travel.model_data_async;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.saic_travel.model_create_workflow.service.CreateWorkFlowService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import weaver.conn.RecordSet;
import weaver.formmode.data.ModeDataApproval;
import weaver.general.Util;
import weaver.general.TimeUtil;
import weaver.hrm.User;
import weaver.xuanran.wang.common.mapper.CommonMapper;
import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.saic_travel.model_data_async.config.eneity.DataAsyncMain;
import weaver.xuanran.wang.saic_travel.model_data_async.service.DataAsyncConfigService;
import java.util.*;
import java.util.stream.Collectors;
/**
* <h1></h1>
@ -21,7 +29,8 @@ import java.util.*;
*/
public class AsyncTest extends BaseTest {
private DataAsyncConfigService dataAsyncConfigService = new DataAsyncConfigService();
private final CommonMapper commonMapper = Util.getMapper(CommonMapper.class);
private final CreateWorkFlowService createWorkFlowService = new CreateWorkFlowService();
@Test
public void testGetConfig(){
// DataAsyncMain hrmAsyncTest = dataAsyncConfigService.getDataAsyncConfigByUniqueCode("hrmAsyncTest");
@ -45,24 +54,71 @@ public class AsyncTest extends BaseTest {
@Test
public void testAsync(){
// try {
// DataAsyncMain config = dataAsyncConfigService.getDataAsyncConfigByUniqueCode("wacoTest");
// List<String> data = dataAsyncConfigService.asyncModelData(config, 109);
// log.info("生成的数据id : " + JSONObject.toJSONString(data));
// }catch (Exception e){
// log.error("生成建模数据异常 : " + e.getMessage());
try {
DataAsyncMain config = dataAsyncConfigService.getDataAsyncConfigByUniqueCode("hrmAsyncTest");
List<String> data = dataAsyncConfigService.asyncModelData(config, 109);
log.info("生成的数据id : " + JSONObject.toJSONString(data));
}catch (Exception e){
log.error("生成建模数据异常 : " + e.getMessage());
}
// String choiceData = "2357,2358,2274,2275";
// String triggerWorkflowSetId = "4";
// // 勾选的数据集合
// List<String> dataList = Arrays.stream(choiceData.split(",")).collect(Collectors.toList());
// RecordSet rs = new RecordSet();
// List<List<String>> splitList = CommonUtil.splitList(dataList);
// String name = commonMapper.getModelNameByModelId(String.valueOf(109));
// for (List<String> list : splitList) {
// List<Integer> ids = list.stream().map(item -> aiyh.utils.Util.getIntValue(item, -1)).collect(Collectors.toList());
// if(CollectionUtils.isEmpty(ids)){
// continue;
// }
// }
// String sql = "select id from " + name;
// for (String id : triggerWorkflowSetId.split(",")) {
// String condition = commonMapper.getConditionByTriggerId(id);
// if(StringUtils.isNotBlank(condition)){
// sql += " where " + condition;
// }
// log.info(aiyh.utils.Util.logStr("查询数据sql : {}", sql));
// List<String> filterIds = filterIds(sql);
// List<String> dataIds = dataList.stream().filter(filterIds::contains).collect(Collectors.toList());
// List<String> requestIds = CommonUtil.doCreateWorkFlow(109, dataIds, aiyh.utils.Util.getIntValue(id, -1)); // 通过数据审批生成流程
// List<String> errorData = new ArrayList<>();
// for (int i = 0; i < requestIds.size(); i++) {
// if (aiyh.utils.Util.getIntValue(requestIds.get(i), -1) < 0) {
// errorData.add(dataList.get(i));
// }
// }
// log.error(Util.logStr("执行创建流程失败集合: {}",JSONObject.toJSONString(errorData))); // 构建日志字符串
// }
// List<String> list = CommonUtil.doCreateWorkFlow(109, data);
// log.info("触发成功 : " + JSONObject.toJSONString(list));
log.info("select hr.email from HrmResource hr where status in (0,1,2,3) AND "+ Util.getSubINClause("1,3,323,124,544","id","in") + " and " + Util.getSubINClause("1","id","not in"));
log.info(Util.getSubINClause("1,3,323,124,544","id","in",2));
// log.info("select hr.email from HrmResource hr where status in (0,1,2,3) AND "+ Util.getSubINClause("1,3,323,124,544","id","in") + " and " + Util.getSubINClause("1","id","not in"));
// log.info(Util.getSubINClause("1,3,323,124,544","id","in",2));
}
public List<String> filterIds(String sql){
RecordSet rs = new RecordSet();
ArrayList<String> res = new ArrayList<>();
if (rs.executeQuery(sql)) {
while (rs.next()){
res.add(Util.null2DefaultStr(rs.getString(1),""));
}
}
return res;
}
@Test
public void testNotNull(){
String str = "jssjhgdkjs?docId={?}&{$requestid}";
System.out.println(str.replace("{?}", "123")
.replace("{$requestid}", "12194283"));
public void testNotNull() {
try {
String datas = "2600,2601,2602,2603,2599,2598";
String gys = createWorkFlowService.supplierCusCreateWorkFlow("6", "109", "gys", datas, 110);
log.info(" gys : " + gys);
}catch (Exception e){
log.error("e => " + e.getMessage());
}
}
public boolean checkNull(String ... args){

View File

@ -1,6 +1,7 @@
package xuanran.wang.schroeder.download_file;
import aiyh.utils.Util;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.schroeder.download_file.mapper.DownLoadFileMapper;
@ -154,4 +155,49 @@ public class DownLoadFileTest extends BaseTest {
String resultString = text.replaceAll("2", replacement);
log.info("resultString " + resultString);
}
@Test
public void testBefore(){
Map<String, String> pathParam = Util.parseCusInterfacePathParam("weaver.xuanran.wang.schroeder.before.PushSealTaskBeforeProcessor?whereSql=`yyfs in (4,7)`&mapping=`yzzl:yzzl,htzyzcshj:htzyzcs,gzcshj:gzcs,frzcshj:frzcs`&detailNo=1");
HashMap<String, Object> detailMap = new HashMap<>();
String mapping = pathParam.get("mapping");
String detailNo = pathParam.get("detailNo");
String[] split = mapping.split(",");
for (String str : split) {
String[] map = str.split(":");
detailMap.put(map[1], map[0]);
}
detailMap.put("mainid", "1");
PrepSqlResultImpl sqlResult = Util.createSqlBuilder().insertSql("121212" + "_dt" + detailNo, detailMap);
String sqlStr = sqlResult.getSqlStr();
List<Object> args = sqlResult.getArgs();
log.info("sqlStr : " + sqlStr);
log.info("args : " + args);
}
@Test
public void testUrl(){
String serialNumber = "0199";
String front = serialNumber.substring(0,2);
String end = serialNumber.substring(2);
log.info("front " + front);
log.info("end " + end);
int frontInt = Util.getIntValue(front);
int endInt = Util.getIntValue(end);
log.info("frontInt " + frontInt);
log.info("endInt " + endInt);
String endStr = "";
String frontStr = "";
if(++endInt >= 100){
frontInt += 1;
endInt = 1;
}
if(endInt < 10){
endStr = "0" + endInt;
}
if(frontInt < 10){
frontStr = "0" + frontInt;
}
log.info(frontStr + endStr);
}
}

View File

@ -72,7 +72,7 @@ public class WacoFirstTest extends BaseTest {
public void testFinally() throws IOException {
String currentDate = TimeUtil.getCurrentDateString();
String WACO_TEMP_PATH = "WACO" + File.separator + "temp" + File.separator;
String fileName = currentDate.replaceAll("-","") + ".zip";
String fileName = "20221208.zip";
String zipOATempPath = GCONST.getSysFilePath() + WACO_TEMP_PATH + fileName;
try {
String tempFolder = GCONST.getSysFilePath() + WACO_TEMP_PATH;