commit
40b268455b
|
@ -48,6 +48,7 @@ src/test/resources/font
|
|||
src/main/resources/WEB-INF/vm/outFile
|
||||
target/
|
||||
*.back
|
||||
!/src/main/youhong_ai_jitu_src/selfdev/util/log
|
||||
# 老项目代码
|
||||
#/lib/jitulib/
|
||||
#/lib/classbean
|
||||
|
|
|
@ -161,3 +161,51 @@ class CusUtils {
|
|||
}
|
||||
|
||||
window.Utils = new CusUtils()
|
||||
|
||||
|
||||
const getLeble = function (lable, defaultStr) {
|
||||
if (!langue[lable + '']) {
|
||||
return defaultStr;
|
||||
}
|
||||
let lableMap = langue[lable + '']
|
||||
const userInfo = JSON.parse(localStorage.getItem("theme-account"))
|
||||
if (!lableMap[userInfo.userLanguage + '']) {
|
||||
return defaultStr
|
||||
}
|
||||
return lableMap[userInfo.userLanguage + '']
|
||||
}
|
||||
|
||||
|
||||
class LanguageUtil {
|
||||
|
||||
static language = {
|
||||
'1': {
|
||||
'8': '英文',
|
||||
'7': '中文',
|
||||
'15': '日语'
|
||||
}
|
||||
}
|
||||
|
||||
static getLabel(label, defaultStr) {
|
||||
if (!LanguageUtil.language[label + '']) {
|
||||
return defaultStr;
|
||||
}
|
||||
let languageMap = LanguageUtil.language[label + '']
|
||||
let userInfo = JSON.parse(localStorage.getItem("theme-account"))
|
||||
if (!userInfo) {
|
||||
userInfo = {
|
||||
userLanguage: '7'
|
||||
}
|
||||
}
|
||||
|
||||
if (!languageMap[userInfo.userLanguage + '']) {
|
||||
return defaultStr
|
||||
}
|
||||
return languageMap[userInfo.userLanguage + '']
|
||||
}
|
||||
}
|
||||
|
||||
// export default CusUtils
|
||||
ecodeSDK.exp(LanguageUtil)
|
||||
window.LanguageUtil = LanguageUtil
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ function submitCallback(detailTable, detail2PayProportionId){
|
|||
let rowIndex = rowArr[i];
|
||||
if(rowIndex !== ""){
|
||||
let field = `${detail2PayProportionId}_${rowIndex}`;
|
||||
sum += parseFloat(WfForm.getFieldValue(field));//遍历明细行字段
|
||||
sum = addFloat(sum, parseFloat(WfForm.getFieldValue(field)));//遍历明细行字段
|
||||
}
|
||||
}
|
||||
console.log('sum => ', sum)
|
||||
|
@ -65,6 +65,11 @@ function submitCallback(detailTable, detail2PayProportionId){
|
|||
});
|
||||
}
|
||||
|
||||
function addFloat(a, b) {
|
||||
let precision = Math.pow(10, 10); // 设置精度,根据需要调整
|
||||
return (Math.round(a * precision) + Math.round(b * precision)) / precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* 明细表字段发生变化进行日期计算
|
||||
* @param bindField
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
// 首台销售日期
|
||||
const firstSaleDateField = WfForm.convertFieldNameToId("stxsrq");
|
||||
var firstSaleDateField = WfForm.convertFieldNameToId("stxsrq");
|
||||
// 跟踪时间
|
||||
const trackTimeField = WfForm.convertFieldNameToId("gzsj");
|
||||
var trackTimeField = WfForm.convertFieldNameToId("gzsj");
|
||||
// 跟踪时间为三个月以内
|
||||
const threeMonthIndex = 1;
|
||||
var threeMonthIndex = 1;
|
||||
// 是否提交等待节点
|
||||
const submitWaitNode = WfForm.convertFieldNameToId("sftjddjd");
|
||||
var submitWaitNode = WfForm.convertFieldNameToId("sftjddjd");
|
||||
// 下次超时提醒日期
|
||||
const timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq");
|
||||
var timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq");
|
||||
// 跟踪天数 <= 1 ? 15 : 30;
|
||||
const trackingDaysField = WfForm.convertFieldNameToId("gzts")
|
||||
var trackingDaysField = WfForm.convertFieldNameToId("gzts")
|
||||
// 跟踪触发行数
|
||||
const trackingLineField = WfForm.convertFieldNameToId("gzcfxs");
|
||||
$(() => {
|
||||
let detail2LineNum = WfForm.getDetailRowCount("detail_2");
|
||||
var trackingLineField = WfForm.convertFieldNameToId("gzcfxs");
|
||||
jQuery(document).ready(function (){
|
||||
var detail2LineNum = WfForm.getDetailRowCount("detail_2");
|
||||
// let firstTrack = Boolean(true);
|
||||
// if (new Date(firstSaleDate) < new Date(currentDate) && dayDiff > 0) {
|
||||
// firstTrack = false;
|
||||
// }
|
||||
// console.log('firstTrack ', firstTrack)
|
||||
// 到达节点次数
|
||||
const nodeNum = getNodeNum();
|
||||
let trackingLine = parseInt(WfForm.getFieldValue(trackingLineField));
|
||||
var nodeNum = getNodeNum();
|
||||
var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField));
|
||||
// 如果不是则自动添加一行明细让他自己填写
|
||||
if (detail2LineNum < trackingLine && detail2LineNum < nodeNum) {
|
||||
console.log('添加一行明细!');
|
||||
|
@ -33,32 +33,32 @@ $(() => {
|
|||
return;
|
||||
}
|
||||
initTimeoutDate();
|
||||
WfForm.bindFieldChangeEvent(`${firstSaleDateField},${trackTimeField}`,()=>{
|
||||
WfForm.bindFieldChangeEvent(firstSaleDateField + "," + trackTimeField,function (){
|
||||
initTimeoutDate();
|
||||
});
|
||||
});
|
||||
|
||||
function getNodeNum(){
|
||||
let firstSaleDate = WfForm.getFieldValue(firstSaleDateField);
|
||||
var firstSaleDate = WfForm.getFieldValue(firstSaleDateField);
|
||||
console.log('首台销售日期 ', firstSaleDate);
|
||||
let currentDate = getCurrentDate();
|
||||
let dayDiff = getDaysDiff(firstSaleDate, currentDate);
|
||||
var currentDate = getCurrentDate();
|
||||
var dayDiff = getDaysDiff(firstSaleDate, currentDate);
|
||||
console.log('当前天数与首台销售日期相差天数 : ', dayDiff)
|
||||
let trackingDays = WfForm.getFieldValue(trackingDaysField);
|
||||
var trackingDays = WfForm.getFieldValue(trackingDaysField);
|
||||
return Math.floor(dayDiff / trackingDays) + 1;
|
||||
}
|
||||
|
||||
function initTimeoutDate(){
|
||||
console.log('==== initTimeoutDate begin ====')
|
||||
let firstSaleDate = WfForm.getFieldValue(firstSaleDateField);
|
||||
const nodeNum = getNodeNum();
|
||||
var firstSaleDate = WfForm.getFieldValue(firstSaleDateField);
|
||||
var nodeNum = getNodeNum();
|
||||
console.log('到达节点次数 ', nodeNum);
|
||||
let trackingDays = WfForm.getFieldValue(trackingDaysField);
|
||||
var trackingDays = WfForm.getFieldValue(trackingDaysField);
|
||||
console.log('跟踪天数 ', trackingDays);
|
||||
let computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays);
|
||||
var computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays);
|
||||
console.log('计算下次超时日期 ', computeTimeoutDate);
|
||||
let trackingLine = parseInt(WfForm.getFieldValue(trackingLineField));
|
||||
let detail2LineNum = WfForm.getDetailRowCount("detail_2");
|
||||
var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField));
|
||||
var detail2LineNum = WfForm.getDetailRowCount("detail_2");
|
||||
setTimeout(()=>{
|
||||
WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate});
|
||||
// 判断流程提交走向
|
||||
|
@ -72,7 +72,7 @@ function initTimeoutDate(){
|
|||
if (detail2LineNum < trackingLine) {
|
||||
WfForm.showMessage('请填写明细表信息!');
|
||||
detail2LineNum = WfForm.getDetailRowCount("detail_2");
|
||||
for (let i = 0; i < trackingLine - parseInt(detail2LineNum); i++) {
|
||||
for (var i = 0; i < trackingLine - parseInt(detail2LineNum); i++) {
|
||||
WfForm.addDetailRow("detail_2", {});
|
||||
}
|
||||
return;
|
||||
|
@ -89,8 +89,8 @@ function initTimeoutDate(){
|
|||
function getDaysDiff(date1, date2) {
|
||||
date1 = new Date(date1);
|
||||
date2 = new Date(date2);
|
||||
const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数
|
||||
const timeDiff = Math.abs(date1.getTime() - date2.getTime()); // 两个日期对象的毫秒数差值
|
||||
var oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数
|
||||
var timeDiff = Math.abs(date1.getTime() - date2.getTime()); // 两个日期对象的毫秒数差值
|
||||
// 将毫秒数差值转换为天数差值并四舍五入
|
||||
return Math.round(timeDiff / oneDay);
|
||||
}
|
||||
|
@ -100,14 +100,14 @@ function getCurrentDate() {
|
|||
}
|
||||
|
||||
function parseDate(date) {
|
||||
const currentYear = date.getFullYear();
|
||||
const currentMonth = date.getMonth() + 1; // getMonth()返回0~11,需要加1
|
||||
const currentDay = date.getDate();
|
||||
var currentYear = date.getFullYear();
|
||||
var currentMonth = date.getMonth() + 1; // getMonth()返回0~11,需要加1
|
||||
var currentDay = date.getDate();
|
||||
return currentYear + '-' + currentMonth + '-' + currentDay;
|
||||
}
|
||||
|
||||
function addDays(date, days) {
|
||||
const newDate = new Date(date);
|
||||
var newDate = new Date(date);
|
||||
newDate.setDate(newDate.getDate() + days);
|
||||
console.log('newDate ', newDate)
|
||||
return parseDate(newDate);
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/* ******************* youhong.ai 转交任务提交状态修改 start ******************* */
|
||||
|
||||
$(() => {
|
||||
function api(requestOptions = {
|
||||
url: "",
|
||||
type: "GET",
|
||||
data: "",
|
||||
isAsync: true,
|
||||
success: () => {
|
||||
},
|
||||
error: () => {
|
||||
},
|
||||
complete: () => {
|
||||
},
|
||||
contentType: 'application/json',
|
||||
beforeSend: () => {
|
||||
}
|
||||
}) {
|
||||
let options = Object.assign({
|
||||
url: "",
|
||||
type: "GET",
|
||||
data: "",
|
||||
isAsync: true,
|
||||
success: () => {
|
||||
},
|
||||
error: () => {
|
||||
},
|
||||
complete: () => {
|
||||
},
|
||||
contentType: 'application/json',
|
||||
beforeSend: () => {
|
||||
}
|
||||
}, requestOptions)
|
||||
return $.ajax(options)
|
||||
}
|
||||
|
||||
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, callback => {
|
||||
let obj = {}
|
||||
obj.actionId = WfForm.getFieldValue(WfForm.convertFieldNameToId('actionid'))
|
||||
obj.userId = WfForm.getFieldValue(WfForm.convertFieldNameToId('zjr', 'detail_1') + "_0")
|
||||
api({
|
||||
url: "/api/aiyh/ihg/task/submit-task",
|
||||
type: "POST",
|
||||
data: JSON.stringify(obj),
|
||||
isAsync: false,
|
||||
success(res) {
|
||||
if (res && res.code === 200) {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
complete() {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
/* ******************* youhong.ai 转交任务提交状态修改 end ******************* */
|
|
@ -751,13 +751,12 @@ $(() => {
|
|||
$(() => {
|
||||
let config = {
|
||||
// 基础年假
|
||||
base: 21,
|
||||
base: 20,
|
||||
// 入职日期
|
||||
dateField: 'jrbsjjtsj',
|
||||
// 年假
|
||||
targetField: 'nj'
|
||||
}
|
||||
|
||||
runJs()
|
||||
|
||||
function runJs() {
|
||||
|
@ -769,20 +768,22 @@ $(() => {
|
|||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.targetField), {value: njValue})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function calculateBonus(startDate, endDate, config) {
|
||||
const diffInMs = endDate.getTime() - startDate.getTime();
|
||||
const diffInYears = diffInMs / (1000 * 60 * 60 * 24 * 365);
|
||||
|
||||
if (diffInYears < 3) {
|
||||
return 0;
|
||||
} else if (diffInYears >= 3 && diffInYears < 6) {
|
||||
return config.base;
|
||||
} else if (diffInYears >= 3 && diffInYears < 6) {
|
||||
return config.base + 1;
|
||||
} else {
|
||||
const extraYears = Math.floor((diffInYears - 3) / 3);
|
||||
return config.base + extraYears * 2;
|
||||
let resultDay = config.base + extraYears * 2
|
||||
if (resultDay >= 25) {
|
||||
return 25;
|
||||
}
|
||||
return resultDay;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -77,7 +77,6 @@ import java.util.function.Predicate;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
* @author EBU7-dev1-ayh
|
||||
|
@ -1599,126 +1598,6 @@ public class Util extends weaver.general.Util {
|
|||
return getUtilService().getApiConfigMainTree(id);
|
||||
}
|
||||
|
||||
public static <T> AZipOutputStream createZip(List<T> inputList) throws IOException {
|
||||
return createZip(inputList, File.separator);
|
||||
}
|
||||
|
||||
private static <T> AZipOutputStream createZip(List<T> inputList, String base) throws IOException {
|
||||
FileOutputStream fileOutputStream = null;
|
||||
|
||||
try {
|
||||
File file = new File(AZipOutputStream.filePath);
|
||||
if (!file.exists()) {
|
||||
// 先得到文件的上级目录,并创建上级目录,在创建文件
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
// 创建文件
|
||||
file.createNewFile();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (fileOutputStream == null) {
|
||||
return null;
|
||||
}
|
||||
AZipOutputStream zipOut = new AZipOutputStream(fileOutputStream);
|
||||
int catchLen = 10 * 1024;
|
||||
for (int i = 0; i < inputList.size(); i++) {
|
||||
T item = inputList.get(i);
|
||||
if (item instanceof InputStream) {
|
||||
// 属于单级文件,直接压缩并返回
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(base + i));
|
||||
} catch (IOException e) {
|
||||
throw new IOException(e.toString());
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = ((InputStream) item).read(buffer)) != -1) {
|
||||
zipOut.write(buffer, 0, len);
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
if (item instanceof AInputStream) {
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(((AInputStream) item).getFileName()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = ((AInputStream) item).getInputStream().read(buffer)) != -1) {
|
||||
try {
|
||||
zipOut.write(buffer, 0, len);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
if (item instanceof ListZipEntity) {
|
||||
ListZipEntity listZipEntity = (ListZipEntity) item;
|
||||
if (listZipEntity.isDirectory()) {
|
||||
// 表示属于文件夹,循环添加处理文件夹
|
||||
handlerDirectory(listZipEntity.getFileList(), zipOut, base + listZipEntity.getDirectory() + File.separator);
|
||||
} else {
|
||||
List<AInputStream> aInputStreams = listZipEntity.getaInputStreamList();
|
||||
for (AInputStream aInputStream : aInputStreams) {
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(aInputStream.getFileName()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = (aInputStream.getInputStream()).read(buffer)) != -1) {
|
||||
try {
|
||||
zipOut.write(buffer, 0, len);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return zipOut;
|
||||
}
|
||||
|
||||
private static void handlerDirectory(List<ListZipEntity> fileList, AZipOutputStream zipOut, String base) throws IOException {
|
||||
int catchLen = 10 * 1024;
|
||||
for (ListZipEntity listZipEntity : fileList) {
|
||||
if (listZipEntity.isDirectory()) {
|
||||
// 如果是文件夹
|
||||
handlerDirectory(listZipEntity.getFileList(), zipOut, base + listZipEntity.getDirectory() + File.separator);
|
||||
} else {
|
||||
List<AInputStream> aInputStreams = listZipEntity.getaInputStreamList();
|
||||
for (AInputStream aInputStream : aInputStreams) {
|
||||
try {
|
||||
zipOut.putNextEntry(new ZipEntry(aInputStream.getFileName()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] buffer = new byte[catchLen];
|
||||
int len = 0;
|
||||
while ((len = (aInputStream.getInputStream()).read(buffer)) != -1) {
|
||||
try {
|
||||
zipOut.write(buffer, 0, len);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> queryLanguage(int groupId, int languageId) {
|
||||
return getUtilService().queryLanguage(groupId, languageId);
|
||||
}
|
||||
|
@ -2266,7 +2145,6 @@ public class Util extends weaver.general.Util {
|
|||
if (otherLog.containsKey(name)) {
|
||||
return otherLog.get(name);
|
||||
}
|
||||
if (!otherLog.containsKey(name)) {
|
||||
synchronized (Util.otherLog) {
|
||||
if (otherLog.containsKey(name)) {
|
||||
return otherLog.get(name);
|
||||
|
@ -2330,8 +2208,6 @@ public class Util extends weaver.general.Util {
|
|||
return cusLog;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自定义配置参数值
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package aiyh.utils.annotation.recordset;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <h1>小写键</h1>
|
||||
*
|
||||
* <p>create: 2023/6/16 13:02</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Documented
|
||||
public @interface ToLowerCase {
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package aiyh.utils.ecologyutil.modelutil;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.httpUtil.cushttpclasses.CusHttpSession;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.cube.service.ModeAppService;
|
||||
import com.engine.cube.service.impl.ModeAppServiceImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 建模相关工具方法
|
||||
*/
|
||||
public class CusModelUtil {
|
||||
|
||||
private static Logger logger = Util.getLogger();
|
||||
public static ModeAppService modeAppService = ServiceUtil.getService(ModeAppServiceImpl.class, new User(1));
|
||||
|
||||
/**
|
||||
* 建模数据全部权限重构
|
||||
* @param modeId
|
||||
*/
|
||||
public static void rebuildRight(String modeId) {
|
||||
try{
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("rebulidFlag", "1");
|
||||
param.put("righttype", "1");
|
||||
param.put("modeid", modeId);
|
||||
param.put("rebulidFlag", "1");
|
||||
param.put("showProgress", "0");
|
||||
param.put("operation", "resetAllRight");
|
||||
param.put("session", new CusHttpSession());
|
||||
Map<String, Object> stringObjectMap = modeAppService.saveModeRightList(param, new User(1));
|
||||
logger.info("CusModelUtil.rebuildRight end;result:"+new JSONObject(stringObjectMap).toJSONString() + ";param:" + modeId);
|
||||
}catch(Throwable e){
|
||||
logger.error("CusModelUtil.rebuildRight error;message:" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package aiyh.utils.ecologyutil.rightutil;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.httpUtil.cushttpclasses.CusHttpServletRequest;
|
||||
import aiyh.utils.httpUtil.cushttpclasses.CusHttpSession;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* ecology权限相关方法
|
||||
*
|
||||
*/
|
||||
public class RightMoveUtil {
|
||||
|
||||
private static Logger logger = Util.getLogger();
|
||||
|
||||
/**
|
||||
* 触发标准权限转移 转移待办已办等信息
|
||||
* @param param 入参按需填写如下等参数
|
||||
* fromid
|
||||
* toid
|
||||
* T133All
|
||||
* T133AllNum
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject moveRight(JSONObject param){
|
||||
JSONObject result = new JSONObject();
|
||||
try{
|
||||
logger.info("RightMoveUtil moveRight begin;param:" + param.toJSONString());
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
for(Object key : param.keySet()){
|
||||
params.put(key.toString(),param.get(key));
|
||||
}
|
||||
HttpServletRequest request = new CusHttpServletRequest(){
|
||||
@Override
|
||||
public String getParameter(String s) {
|
||||
return param.getString(s);
|
||||
}
|
||||
@Override
|
||||
public HttpSession getSession(boolean b) {
|
||||
HttpSession session = new CusHttpSession(){
|
||||
@Override
|
||||
public Object getAttribute(String s) {
|
||||
return new User(1);
|
||||
}
|
||||
};
|
||||
return session;
|
||||
}
|
||||
};
|
||||
ProcessDataCmd cmd = new ProcessDataCmd(params,request,new User(1));
|
||||
Map<String, Object> execute = cmd.execute(null);
|
||||
result = new JSONObject(execute);
|
||||
logger.info("RightMoveUtil moveRight end;result:" + execute.toString());
|
||||
return result;
|
||||
}catch (Throwable e){
|
||||
logger.error("RightMoveUtil moveRight error;message:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package aiyh.utils.ecologyutil.timeutil;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.httpUtil.cushttpclasses.CusHttpServletRequest;
|
||||
import aiyh.utils.httpUtil.cushttpclasses.CusHttpSession;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* ecology权限相关方法
|
||||
*/
|
||||
public class TimeUtil {
|
||||
|
||||
private static final Logger logger = Util.getLogger();
|
||||
|
||||
/**
|
||||
* 触发标准权限转移 转移待办已办等信息
|
||||
*
|
||||
* @param param 入参按需填写如下等参数
|
||||
* fromid
|
||||
* toid
|
||||
* T133All
|
||||
* T133AllNum
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject moveRight(JSONObject param) {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
logger.info("RightMoveUtil moveRight begin;param:" + param.toJSONString());
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
for (Object key : param.keySet()) {
|
||||
params.put(key.toString(), param.get(key));
|
||||
}
|
||||
HttpServletRequest request = new CusHttpServletRequest() {
|
||||
@Override
|
||||
public String getParameter(String s) {
|
||||
return param.getString(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession(boolean b) {
|
||||
HttpSession session = new CusHttpSession() {
|
||||
@Override
|
||||
public Object getAttribute(String s) {
|
||||
return new User(1);
|
||||
}
|
||||
};
|
||||
return session;
|
||||
}
|
||||
};
|
||||
ProcessDataCmd cmd = new ProcessDataCmd(params, request, new User(1));
|
||||
Map<String, Object> execute = cmd.execute(null);
|
||||
result = new JSONObject(execute);
|
||||
logger.info("RightMoveUtil moveRight end;result:" + execute);
|
||||
return result;
|
||||
} catch (Throwable e) {
|
||||
logger.error("RightMoveUtil moveRight error;message:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package aiyh.utils.entity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import weaver.file.FileUpload;
|
||||
import weaver.system.SystemComInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author EBU7-dev1-ayh
|
||||
* @create 2021/10/25 0025 17:38
|
||||
* zipoutputstaream
|
||||
*/
|
||||
|
||||
|
||||
public class AZipOutputStream extends ZipOutputStream {
|
||||
|
||||
private ZipOutputStream zipOutputStream;
|
||||
public static String filePath;
|
||||
private OutputStream out;
|
||||
static {
|
||||
filePath = FileUpload.getCreateDir(new SystemComInfo().getFilesystem()) + "tempfile" + File.separator;
|
||||
filePath += "zip" + File.separator + System.currentTimeMillis() + UUID.randomUUID() + ".zip";
|
||||
}
|
||||
|
||||
public AZipOutputStream(@NotNull OutputStream out) {
|
||||
super(out);
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
public AZipOutputStream(@NotNull OutputStream out, @NotNull Charset charset) {
|
||||
super(out, charset);
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
Files.deleteIfExists(Paths.get(AZipOutputStream.filePath));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
out.flush();
|
||||
super.flush();
|
||||
super.close();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
public ZipOutputStream getZipOutputStream() {
|
||||
return zipOutputStream;
|
||||
}
|
||||
|
||||
public void setZipOutputStream(ZipOutputStream zipOutputStream) {
|
||||
this.zipOutputStream = zipOutputStream;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package aiyh.utils.fileUtil;
|
||||
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import org.apache.poi.hwpf.HWPFDocument;
|
||||
import org.apache.poi.hwpf.extractor.WordExtractor;
|
||||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>word关键字查找</h1>
|
||||
*
|
||||
* @author ebu7-dev1 youhong.ai
|
||||
*/
|
||||
public class WordKeywordFinder {
|
||||
|
||||
/**
|
||||
* <h2>查找关键字</h2>
|
||||
*
|
||||
* @param inputStream 文件流
|
||||
* @param keyword 关键字
|
||||
* @param fileName 文件名称
|
||||
* @return 关键字信息
|
||||
* @throws IOException io异常
|
||||
*/
|
||||
public static List<KeywordLocation> findKeywords(InputStream inputStream, String keyword, String fileName) {
|
||||
try {
|
||||
List<KeywordLocation> keywordLocations = new ArrayList<>();
|
||||
if (fileName.endsWith(".docx")) {
|
||||
XWPFDocument docx = new XWPFDocument(inputStream);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(docx);
|
||||
String text = extractor.getText();
|
||||
String[] paragraphs = text.split("\n");
|
||||
for (int i = 0; i < paragraphs.length; i++) {
|
||||
String paragraph = paragraphs[i];
|
||||
if (paragraph.contains(keyword)) {
|
||||
keywordLocations.add(new KeywordLocation(keyword, i + 1));
|
||||
}
|
||||
}
|
||||
extractor.close();
|
||||
docx.close();
|
||||
} else if (fileName.endsWith(".doc")) {
|
||||
HWPFDocument doc = new HWPFDocument(inputStream);
|
||||
WordExtractor extractor = new WordExtractor(doc);
|
||||
String text = extractor.getText();
|
||||
String[] paragraphs = text.split("\n");
|
||||
for (int i = 0; i < paragraphs.length; i++) {
|
||||
String paragraph = paragraphs[i];
|
||||
if (paragraph.contains(keyword)) {
|
||||
keywordLocations.add(new KeywordLocation(keyword, i + 1));
|
||||
}
|
||||
}
|
||||
extractor.close();
|
||||
doc.close();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported file format: " + fileName);
|
||||
}
|
||||
|
||||
return keywordLocations;
|
||||
} catch (Exception e) {
|
||||
throw new CustomerException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeywordLocation {
|
||||
private final String keyword;
|
||||
private final int paragraphNumber;
|
||||
|
||||
public KeywordLocation(String keyword, int paragraphNumber) {
|
||||
this.keyword = keyword;
|
||||
this.paragraphNumber = paragraphNumber;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public int getParagraphNumber() {
|
||||
return paragraphNumber;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package aiyh.utils.function;
|
||||
|
||||
/**
|
||||
* <h1>三个参数的function</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 21:30</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Bi3Function<A, B, C, R> {
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param a the first function argument
|
||||
* @param b the second function argument
|
||||
* @param c the second function argument
|
||||
* @return the function result
|
||||
*/
|
||||
R apply(A a, B b, C c);
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package aiyh.utils.function;
|
||||
|
||||
/**
|
||||
* <h1>四个参数的function</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 21:30</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Bi4Function<A, B, C, D, R> {
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param a the first function argument
|
||||
* @param b the second function argument
|
||||
* @param c the second function argument
|
||||
* @param d the second function argument
|
||||
* @return the function result
|
||||
*/
|
||||
R apply(A a, B b, C c, D d);
|
||||
|
||||
}
|
|
@ -0,0 +1,274 @@
|
|||
package aiyh.utils.httpUtil.cushttpclasses;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.Principal;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class CusHttpServletRequest implements HttpServletRequest {
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestURI() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuffer getRequestURL() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContextPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathTranslated() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getHeaders(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getHeaderNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntHeader(String s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDateHeader(String s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cookie[] getCookies() {
|
||||
return new Cookie[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession(boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestedSessionId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdValid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromCookie() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromURL() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteUser() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromUrl() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteAddr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterEncoding(String s) throws UnsupportedEncodingException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String s) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getParameterNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getParameterMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws IOException, IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentLength() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getLocales() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getAttributeNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestDispatcher getRequestDispatcher(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
public String getRealPath(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package aiyh.utils.httpUtil.cushttpclasses;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionContext;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class CusHttpSession implements HttpSession {
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastAccessedTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxInactiveInterval(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInactiveInterval() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
public HttpSessionContext getSessionContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
public Object getValue(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
public String[] getValueNames() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @param o
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
public void putValue(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
public void removeValue(String s) {
|
||||
|
||||
}
|
||||
}
|
|
@ -323,6 +323,16 @@ public class HttpUtils {
|
|||
return baseRequest(httpConnection, httpGet);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>删除方法调用</h2>
|
||||
*
|
||||
* @param url 地址
|
||||
* @param params 参数
|
||||
* @param headers 请求头
|
||||
* @return 请求结果
|
||||
* @throws IOException 异常
|
||||
*/
|
||||
|
||||
public ResponeVo apiDelete(String url, Map<String, Object> params, Map<String, String> headers) throws IOException {
|
||||
Map<String, Object> paramsMap = paramsHandle(params);
|
||||
String getUrl = urlHandle(url, paramsMap);
|
||||
|
@ -1056,21 +1066,38 @@ public class HttpUtils {
|
|||
List<NameValuePair> nvps = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
|
||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
||||
/* ******************* 修改参数转换为string的逻辑,如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
|
||||
if (entry.getValue() instanceof Map) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (entry.getValue() instanceof Collection) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (isBean(entry.getValue())) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
||||
}
|
||||
}
|
||||
httpPost.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
||||
List<NameValuePair> nvps = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
|
||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||
/* ******************* 修改参数转换为string的逻辑,如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
|
||||
if (entry.getValue() instanceof Map) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (entry.getValue() instanceof Collection) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (isBean(entry.getValue())) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
||||
}
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
}
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps, DEFAULT_ENCODING));
|
||||
// } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
||||
} else {
|
||||
StringEntity stringEntity;
|
||||
|
@ -1085,6 +1112,22 @@ public class HttpUtils {
|
|||
return httpPost;
|
||||
}
|
||||
|
||||
private boolean isBean(Object o) {
|
||||
if (o instanceof Number) {
|
||||
return false;
|
||||
}
|
||||
if (o instanceof String) {
|
||||
return false;
|
||||
}
|
||||
if (o instanceof Boolean) {
|
||||
return false;
|
||||
}
|
||||
if (Objects.isNull(o)) {
|
||||
return false;
|
||||
}
|
||||
return !o.getClass().isPrimitive();
|
||||
}
|
||||
|
||||
private HttpPost handleHttpPost(String url, Map<String, String> headerMap, Map<String, Object> paramsMap) throws UnsupportedEncodingException {
|
||||
return handleHttpPostObject(url, headerMap, paramsMap);
|
||||
}
|
||||
|
@ -1251,8 +1294,18 @@ public class HttpUtils {
|
|||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
||||
/* ******************* 修改参数转换为string的逻辑,如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
|
||||
if (entry.getValue() instanceof Map) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (entry.getValue() instanceof Collection) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (isBean(entry.getValue())) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
||||
}
|
||||
}
|
||||
httpPut.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
||||
|
@ -1260,8 +1313,18 @@ public class HttpUtils {
|
|||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||
// nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
||||
/* ******************* 修改参数转换为string的逻辑,如果是对象则进行json序列化 youhong.ai 20230616 ******************* */
|
||||
if (entry.getValue() instanceof Map) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (entry.getValue() instanceof Collection) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else if (isBean(entry.getValue())) {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||
} else {
|
||||
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
||||
}
|
||||
}
|
||||
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
||||
StringEntity stringEntity = new StringEntity(JSON.toJSONString(paramsMap), DEFAULT_ENCODING);
|
||||
|
|
|
@ -312,9 +312,14 @@ public class ResultMapper {
|
|||
|
||||
try {
|
||||
if (o instanceof Map) {
|
||||
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
|
||||
for (int i = 0; i < columnName.length; i++) {
|
||||
String columnType = columnTypeName[i];
|
||||
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
|
||||
|
||||
if (Objects.nonNull(toLowerCase)) {
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
|
||||
} else {
|
||||
if (enable) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
||||
continue;
|
||||
|
@ -325,9 +330,14 @@ public class ResultMapper {
|
|||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getInt(i + 1));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
||||
|
||||
if (Objects.nonNull(toLowerCase)) {
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1));
|
||||
} else {
|
||||
if (enable) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
|
||||
continue;
|
||||
|
@ -338,8 +348,13 @@ public class ResultMapper {
|
|||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getFloat(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getFloat(i + 1));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Objects.nonNull(toLowerCase)) {
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||
} else {
|
||||
if (enable) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
||||
continue;
|
||||
|
@ -350,6 +365,7 @@ public class ResultMapper {
|
|||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return o;
|
||||
|
@ -451,6 +467,7 @@ public class ResultMapper {
|
|||
|
||||
try {
|
||||
if (o instanceof Map) {
|
||||
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
|
||||
for (int i = 0; i < columnName.length; i++) {
|
||||
String columnType = "";
|
||||
if (i >= columnTypeName.length) {
|
||||
|
@ -459,6 +476,10 @@ public class ResultMapper {
|
|||
columnType = columnTypeName[i];
|
||||
}
|
||||
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
|
||||
|
||||
if (Objects.nonNull(toLowerCase)) {
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
|
||||
} else {
|
||||
if (enable) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i]));
|
||||
continue;
|
||||
|
@ -469,9 +490,14 @@ public class ResultMapper {
|
|||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getInt(i + 1));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
||||
|
||||
if (Objects.nonNull(toLowerCase)) {
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||
} else {
|
||||
if (enable) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
||||
continue;
|
||||
|
@ -482,6 +508,7 @@ public class ResultMapper {
|
|||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (method.isAnnotationPresent(Associations.class)) {
|
||||
|
@ -506,6 +533,10 @@ public class ResultMapper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Objects.nonNull(toLowerCase)) {
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||
} else {
|
||||
if (enable) {
|
||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
||||
continue;
|
||||
|
@ -516,6 +547,9 @@ public class ResultMapper {
|
|||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
|
||||
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.controller;
|
||||
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.entity.ContractParametersEntity;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.service.PublishInformationService;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.service.impl.PublishInformationServiceImpl;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Map;
|
||||
//合同系统接收单位或部门编码,根据编码整理所有下级单位及部门的合同台账详细信息,并将数据返回给调用方。
|
||||
@Path("/pubish")
|
||||
public class PublishInformationAction {
|
||||
|
||||
//日志处理
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
//service主要的业务逻辑
|
||||
private final PublishInformationService publishInformationService = new PublishInformationServiceImpl();
|
||||
|
||||
@Path("/information/action")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
||||
//单位编码
|
||||
String divisionCode = request.getParameter("divisionCode");
|
||||
//部门编码
|
||||
String deptCode = request.getParameter("deptCode");
|
||||
ContractParametersEntity contractParametersEntity = publishInformationService.getResponseJson(divisionCode,deptCode);
|
||||
if (contractParametersEntity!=null){
|
||||
return ApiResult.success(contractParametersEntity,200,"查询成功,结果如下");
|
||||
}
|
||||
return ApiResult.error(404,"参数为空,请重新选择单位编码和部门编码");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
/**
|
||||
* <h1>合同系统响应返回参数实体类</h1>
|
||||
* @Author 何朝阳
|
||||
* @Date 2023/4/21 17:59
|
||||
*/
|
||||
@Data
|
||||
public class ContractParametersEntity {
|
||||
//合同编码
|
||||
private String contractno;
|
||||
//合同名称
|
||||
private String contractname;
|
||||
//合同密级
|
||||
private String contractsecret;
|
||||
//合同类别
|
||||
private String contracttype;
|
||||
//合同审批流程
|
||||
private String contractworkflow;
|
||||
//合同性质
|
||||
private String contractproperties;
|
||||
//对应型号
|
||||
private String correspond;
|
||||
//甲方
|
||||
private String partya;
|
||||
//甲方单位属性
|
||||
private String partyaprop;
|
||||
//乙方
|
||||
private String partyb;
|
||||
//项目名称
|
||||
private String entryname;
|
||||
//订单编号
|
||||
private String orderno;
|
||||
//合同总金额
|
||||
private String totalamount;
|
||||
//价款类型
|
||||
private String pricetype;
|
||||
//已收/付金额
|
||||
private String receivedamount;
|
||||
//已开/收票金额
|
||||
private String issuedamount;
|
||||
//剩余未收/付金额
|
||||
private String remainingamount;
|
||||
//币种
|
||||
private String currency;
|
||||
//合同状态
|
||||
private String contractstatus;
|
||||
//收付款进度
|
||||
private String collectionprogress;
|
||||
//收付款方式
|
||||
private String paymentmethod;
|
||||
//签约日期
|
||||
private String signingdate;
|
||||
//签约地
|
||||
private String signingplace;
|
||||
//是否需要飞行试验
|
||||
private String flighttest;
|
||||
//二级单位名称
|
||||
private String secondaryunit;
|
||||
//承办单位名称
|
||||
private String organizername;
|
||||
//承办部门
|
||||
private String undertakedepart;
|
||||
//承办人
|
||||
private String undertakeperson;
|
||||
//签订人
|
||||
private String signedby;
|
||||
//合同用印文件
|
||||
private String contractfile;
|
||||
//其他合同附件
|
||||
private String otherattachments;
|
||||
|
||||
// getter and setter methods
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.entity.ContractParametersEntity;
|
||||
|
||||
@SqlMapper
|
||||
public interface PublishInformationMapper {
|
||||
|
||||
/**
|
||||
* <h2>这里可以根据单位编码和部门编码查询uf_xyz表中的合同信息,并将结果存储到 ContractParametersEntity对象中</h2>
|
||||
* @param divisionCode 单位编码
|
||||
* @param deptCode 部门编码
|
||||
* @return ContractParametersEntity 处理DB查询返回参数的实体类
|
||||
* @author hcy
|
||||
* @Date 2023/4/23 9:47
|
||||
*/
|
||||
@Select("select * from uf_xyz where division = #{divisionCode} and deptment =#{deptCode}")
|
||||
ContractParametersEntity getDeptList(String divisionCode, String deptCode);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.service;
|
||||
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.entity.ContractParametersEntity;
|
||||
|
||||
public interface PublishInformationService {
|
||||
ContractParametersEntity getResponseJson(String divisionCode, String deptCode);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.service.impl;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.entity.ContractParametersEntity;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.mapper.PublishInformationMapper;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.accesscontractsystem.service.PublishInformationService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
public class PublishInformationServiceImpl implements PublishInformationService {
|
||||
|
||||
//日志
|
||||
private final Logger logger = Util.getLogger();
|
||||
//处理业务的sql
|
||||
private final PublishInformationMapper publishInformationMapper = Util.getMapper(PublishInformationMapper.class);
|
||||
|
||||
|
||||
@Override
|
||||
public ContractParametersEntity getResponseJson(String divisionCode, String deptCode) {
|
||||
|
||||
if (!"".equals(divisionCode)&& !"".equals(deptCode)){
|
||||
ContractParametersEntity dataDb = publishInformationMapper.getDeptList(divisionCode,deptCode);
|
||||
if (dataDb == null){
|
||||
return dataDb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.service.SendContractInfoService;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.service.impl.SendContractInfoServiceImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>GM集团下级单位合同台账信息上报接口</h1>
|
||||
* @author hcy
|
||||
* @date 2023/5/8 13:36
|
||||
*/
|
||||
@Path("/send")
|
||||
public class SendContractInfoController {
|
||||
|
||||
|
||||
/**
|
||||
* 日志处理
|
||||
*/
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
/**
|
||||
* 接口主要业务处理,service层
|
||||
*/
|
||||
private final SendContractInfoService sendContractInfoService = new SendContractInfoServiceImpl();
|
||||
|
||||
@POST
|
||||
@Path("/Contract/Info")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String sendContractInfo(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
String zbzt = request.getParameter("zbzt");
|
||||
List<Map<String,Object>> contractInfo = sendContractInfoService.sendContractData(zbzt);
|
||||
if (contractInfo.size() == 0){
|
||||
return ApiResult.error("接口数据为空,请检查台账数据是否为空");
|
||||
}
|
||||
return ApiResult.success(contractInfo,200,"成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SqlMapper
|
||||
public interface SendContractInfoMapper {
|
||||
|
||||
@Select("select * from uf_httztb where wybs = #{uniqueIdentification} ")
|
||||
List<Map<String, Object>> selectConfigData(@ParamMapper("uniqueIdentification") String uniqueIdentification);
|
||||
|
||||
|
||||
@Select("select * from uf_httztb_dt1 where mainid = #{mainid}")
|
||||
List<Map<String, Object>> getConfigDetal1Information(@ParamMapper("mainid")String mainid);
|
||||
|
||||
@Select("select * from uf_httztb_dt2 where mainid = #{mainid}")
|
||||
List<Map<String, Object>> getConfigDetal2Information(@ParamMapper("mainid")String mainid);
|
||||
|
||||
@Select("select $t{selectKeys} from $t{tableName}")
|
||||
List<Map<String, Object>> selectAllDBData(@ParamMapper("selectKeys") String selectKeys,
|
||||
@ParamMapper("tableName") String tableName);
|
||||
|
||||
@Select("select $t{selectKeys} from $t{tableName} where LEFT(modedatacreatedate,10) = LEFT(#{yesterday},10) or LEFT(modedatamodifydatetime,10) = LEFT(#{yesterday},10)")
|
||||
List<Map<String, Object>> selectYesterdayDBData(@ParamMapper("selectKeys")String selectKeys,
|
||||
@ParamMapper("tableName")String tableName,
|
||||
@ParamMapper("yesterday")String yesterday);
|
||||
|
||||
@Select("select $t{selectDatailTableKeys} from $t{s} where mainid = #{mainid}")
|
||||
List<Map<String, Object>> selectAllDetailDBData(@ParamMapper("selectDatailTableKeys") String selectDatailTableKeys,
|
||||
@ParamMapper("s")String s,
|
||||
@ParamMapper("mainid")String mainid);
|
||||
|
||||
@Select("select imagefileid from DocImageFile where docid = #{lcqzyj} order by versionId")
|
||||
String getImageFileId(@ParamMapper("lcqzyj") String lcqzyj);
|
||||
|
||||
@Select("select imagefilename from DocImageFile where docid = #{lcqzyj} order by versionId desc")
|
||||
String getImagefilename(@ParamMapper("lcqzyj") String lcqzyj);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SendContractInfoService {
|
||||
List<Map<String, Object>> sendContractData(String zbzt);
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
package com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.service.impl;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.mapper.SendContractInfoMapper;
|
||||
import com.api.chaoyang.he.hcy_hangtiankeji.gmlowgroupsenddata.service.SendContractInfoService;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.weaver.formmodel.util.DateHelper;
|
||||
import org.apache.log4j.Logger;
|
||||
import sun.misc.BASE64Decoder;
|
||||
import weaver.file.ImageFileManager;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
public class SendContractInfoServiceImpl implements SendContractInfoService {
|
||||
|
||||
/**
|
||||
* 日志处理
|
||||
*/
|
||||
private final Logger logger = Util.getLogger();
|
||||
/**
|
||||
* deal sql
|
||||
*/
|
||||
private final SendContractInfoMapper sendContractInfoMapper = Util.getMapper(SendContractInfoMapper.class);
|
||||
|
||||
/**
|
||||
* 查询国密下级单位台账中数据并返回
|
||||
* @return 返回台账数据集合
|
||||
* @param zbzt 同步状态:0 全量同步 1 增量同步
|
||||
*/
|
||||
public List<Map<String, Object>> sendContractData(String zbzt) {
|
||||
//获取配置表主表数据
|
||||
List<Map<String,Object>> configMainTableData = sendContractInfoMapper.selectConfigData("fw002");
|
||||
if (configMainTableData.size()==0)return configMainTableData;
|
||||
String mainid = Util.null2String(configMainTableData.get(0).get("id"));
|
||||
//配置表明细表1数据:
|
||||
List<Map<String,Object>> configDetal1TableData = sendContractInfoMapper.getConfigDetal1Information(mainid);
|
||||
logger.info("配置表明细表数据---configDetal1TableData---"+configDetal1TableData);
|
||||
//明细表2数据
|
||||
List<Map<String,Object>> configDetal2TableData = sendContractInfoMapper.getConfigDetal2Information(mainid);
|
||||
|
||||
List<Map<String,Object>> configDetal2TableNewData = new ArrayList<>();//处理完大小写问题后
|
||||
filterUppercaseField(configDetal2TableData,configDetal2TableNewData);
|
||||
logger.info("配置表明细表数据---configDetal2TableNewData---"+configDetal2TableNewData);
|
||||
|
||||
|
||||
if (configDetal1TableData.size()==0) return configDetal1TableData;
|
||||
String tableName = Util.null2String(configDetal1TableData.get(0).get("ejdwtzb"));//二级单位台账表数据库名称
|
||||
String bz = Util.null2String(configDetal1TableData.get(0).get("bz")); //备注
|
||||
logger.info("二级单位台账表数据库名称===="+tableName+" 二级单位台账表数名称==="+bz);
|
||||
|
||||
if (configDetal2TableNewData.size()==0)return configDetal1TableData;
|
||||
List<String> mainTableKeys = new ArrayList<>();//用于insert和update的key
|
||||
List<String> detailTableKeys = new ArrayList<>();//用于insert和update的key
|
||||
|
||||
for (Map<String, Object> configdetal2 : configDetal2TableNewData) {
|
||||
String sfzb = Util.null2String(configdetal2.get("sfzb"));//是否主表
|
||||
if ("0".equals(sfzb)){
|
||||
mainTableKeys.add(Util.null2String(configdetal2.get("tbzd")));//添加主表key
|
||||
}else {
|
||||
detailTableKeys.add(Util.null2String(configdetal2.get("tbzd")));//添加明细表key
|
||||
}
|
||||
}
|
||||
mainTableKeys.add("id");//拼接id
|
||||
String selectMainTableKeys = Joiner.on(",").join((Iterable<?>) mainTableKeys);//拼接主表的查询条件
|
||||
String selectDatailTableKeys = Joiner.on(",").join((Iterable<?>) detailTableKeys);//拼接明细表的查询条件
|
||||
|
||||
|
||||
List<Map<String, Object>> returnDataList = new ArrayList<>();//返回一个空数组
|
||||
logger.info("selectMainTableKeys:"+selectMainTableKeys+"------selectDatailTableKeys:"+selectDatailTableKeys );
|
||||
if ("0".equals(zbzt)) {//全量数据
|
||||
List<Map<String, Object>> allDBData = sendContractInfoMapper.selectAllDBData(selectMainTableKeys, tableName);
|
||||
logger.info("-------allDBData------"+allDBData);
|
||||
List<Map<String,Object>> filterUppercaseNewAllDBData = new ArrayList<>();
|
||||
filterUppercaseField(allDBData,filterUppercaseNewAllDBData);
|
||||
for (Map<String, Object> allDBDatum : filterUppercaseNewAllDBData) {
|
||||
String ejdw_mainid = Util.null2String(allDBDatum.get("id"));
|
||||
List<Map<String, Object>> detalData = sendContractInfoMapper.selectAllDetailDBData(selectDatailTableKeys, tableName + "_dt1", ejdw_mainid);//查询到主表对应的明细表数据
|
||||
logger.info("------detalData------"+detalData);
|
||||
List<Map<String, Object>> filterUppercaseFieldDetailData = new ArrayList<>();
|
||||
filterUppercaseField(detalData,filterUppercaseFieldDetailData);//处理掉大写字母的问题
|
||||
logger.info("------filterUppercaseFieldDetailData------"+filterUppercaseFieldDetailData);
|
||||
allDBDatum.put("detailData", filterUppercaseFieldDetailData);//向主表数据中放入明细表数据
|
||||
}
|
||||
logger.info("-------filterUppercaseNewAllDBData------"+filterUppercaseNewAllDBData);
|
||||
List<Map<String,Object>> newAllDBData = this.dealwithSpecialFields(filterUppercaseNewAllDBData);
|
||||
logger.info("-------newAllDBData------"+newAllDBData);
|
||||
return newAllDBData;
|
||||
}else if ("1".equals(zbzt)) {//增量数据
|
||||
List<Map<String, Object>> yesterDayDBData = sendContractInfoMapper.selectYesterdayDBData(selectMainTableKeys, tableName, DateHelper.getYesterday());
|
||||
logger.info("-------yesterDayDBData------"+yesterDayDBData);
|
||||
List<Map<String,Object>> filterUppercasenewYesterDayDBData = new ArrayList<>();
|
||||
filterUppercaseField(yesterDayDBData,filterUppercasenewYesterDayDBData);
|
||||
for (Map<String, Object> yesterDayDBDatum : filterUppercasenewYesterDayDBData) {
|
||||
String id = Util.null2String(yesterDayDBDatum.get("id"));
|
||||
List<Map<String, Object>> detalData = sendContractInfoMapper.selectAllDetailDBData(selectDatailTableKeys, tableName + "_dt1", id);//查询到主表对应的明细表数据
|
||||
logger.info("-------detalData------"+detalData);
|
||||
List<Map<String, Object>> filterUppercaseFieldDetailData = new ArrayList<>();
|
||||
filterUppercaseField(detalData,filterUppercaseFieldDetailData);//处理掉大写字母的问题
|
||||
logger.info("-------filterUppercaseFieldDetailData------"+filterUppercaseFieldDetailData);
|
||||
yesterDayDBDatum.put("detailData", filterUppercaseFieldDetailData);//向主表数据中放入明细表数据
|
||||
}
|
||||
logger.info("-------filterUppercasenewYesterDayDBData------"+filterUppercasenewYesterDayDBData);
|
||||
List<Map<String, Object>> newYesterDayDBData = this.dealwithSpecialFields(filterUppercasenewYesterDayDBData);
|
||||
logger.info("-------newYesterDayDBData------"+newYesterDayDBData);
|
||||
return newYesterDayDBData;
|
||||
}
|
||||
return returnDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤大写字段问题
|
||||
* @param oldListMap 旧的字段
|
||||
* @param newListMap 处理完的字段
|
||||
*/
|
||||
public void filterUppercaseField(List<Map<String,Object>> oldListMap,List<Map<String,Object>> newListMap){
|
||||
for (Map<String, Object> configDetal2TableDatum : oldListMap) {
|
||||
Map<String, Object> newData = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : configDetal2TableDatum.entrySet()) {
|
||||
String key = entry.getKey().toLowerCase();
|
||||
Object value = entry.getValue();
|
||||
newData.put(key, value);
|
||||
}
|
||||
// 创建新数据集合
|
||||
newListMap.add(newData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理双方用印文件、其它合同附件、流程签字意见三个字段
|
||||
* @param allDBData 处理之前的数据
|
||||
* @return 处理完逻辑之后的数据
|
||||
*/
|
||||
private List<Map<String, Object>> dealwithSpecialFields(List<Map<String, Object>> allDBData) {
|
||||
for (Map<String, Object> allDBDatum : allDBData) {
|
||||
String htyywj = Util.null2String(allDBDatum.get("htyywj"));//双方用印文件
|
||||
String qthtfj = Util.null2String(allDBDatum.get("qthtfj"));//其它合同附件
|
||||
String lcqzyj = Util.null2String(allDBDatum.get("lcqzyj"));//流程签字意见:需要流程存为文档
|
||||
String ip = Util.getCusConfigValue("setIp_htkj");//获取配置表中自定义参数,用来配置ip地址、
|
||||
if (!"".equals(htyywj)){
|
||||
String newIp = ip + htyywj;
|
||||
allDBDatum.put("htyywj",newIp);//链接地址:ip://xxx--docid
|
||||
}
|
||||
if (!"".equals(qthtfj)){
|
||||
String newIp = ip +qthtfj;
|
||||
allDBDatum.put("qthtfj",newIp);//链接地址:ip:xxx--docid
|
||||
}
|
||||
if (!"".equals(lcqzyj) && !"-1".equals(lcqzyj)){
|
||||
//根据docid获取文件名称
|
||||
String imagefilename = sendContractInfoMapper.getImagefilename(lcqzyj);
|
||||
if (!"".equals(imagefilename)) {
|
||||
allDBDatum.put("imagefilename",imagefilename);
|
||||
}else{
|
||||
allDBDatum.put("imagefilename", UUID.randomUUID()+".pdf");
|
||||
}
|
||||
int imagefileid = Util.getIntValue(sendContractInfoMapper.getImageFileId(lcqzyj));//根据docid,查询到imageFileid
|
||||
InputStream inputStream = ImageFileManager.getInputStreamById(imagefileid);//根据imagefileid查询到文件流
|
||||
if (inputStream!=null){
|
||||
try {
|
||||
allDBDatum.put("lcqzyj",Util.null2String(inputStream2Base64(inputStream)));//将处理好的文件消息重新放入字段中
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("流转换异常===="+e);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
allDBDatum.put("lcqzyj", "");
|
||||
}
|
||||
}
|
||||
return allDBData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将inputstream转为Base64
|
||||
* @param is 字节流
|
||||
* @return String 加密后的字符串
|
||||
*/
|
||||
private static String inputStream2Base64(InputStream is) throws Exception {
|
||||
byte[] data = null;
|
||||
try {
|
||||
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
|
||||
byte[] buff = new byte[1024];
|
||||
int rc = 0;
|
||||
while ((rc = is.read(buff, 0, 100)) > 0) {
|
||||
swapStream.write(buff, 0, rc);
|
||||
}
|
||||
data = swapStream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
throw new Exception("输入流关闭异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
return Base64.getEncoder().encodeToString(data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* base64转inputStream
|
||||
* @param base64string 包含输入流的字符串
|
||||
* @return inputStream
|
||||
*/
|
||||
private static InputStream base2InputStream(String base64string) {
|
||||
ByteArrayInputStream stream = null;
|
||||
try {
|
||||
BASE64Decoder decoder = new BASE64Decoder();
|
||||
byte[] bytes1 = decoder.decodeBuffer(base64string);
|
||||
stream = new ByteArrayInputStream(bytes1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.api.test.aiyh.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import weaver.workflow.msg.MsgPushUtil;
|
||||
import weaver.workflow.msg.entity.MsgEntity;
|
||||
|
@ -11,7 +12,9 @@ import javax.ws.rs.GET;
|
|||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>ceshi </h1>
|
||||
|
@ -36,4 +39,15 @@ public class RequestMsgNotifiyController {
|
|||
new MsgPushUtil().pushMsg(operateMsg);
|
||||
return "";
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/test/cus-api")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String testCusApiJiaoYan() {
|
||||
Map<String, Object> result = new HashMap<>(8);
|
||||
result.put("key", "asldfjalksd");
|
||||
result.put("name", "test");
|
||||
return ApiResult.success(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
package com.api.xuanran.wang.eny.export_excel.controller;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.api.xuanran.wang.eny.export_excel.entity.CusExportExcelConfigMain;
|
||||
import com.api.xuanran.wang.eny.export_excel.service.ExportExcelServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.general.TimeUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
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;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <h1>安永 建模自定义导出excel</h1>
|
||||
|
@ -19,14 +28,42 @@ import java.nio.charset.StandardCharsets;
|
|||
@Path("/wxr/eny/excel")
|
||||
public class ExportExcelController {
|
||||
|
||||
@POST
|
||||
private final ExportExcelServiceImpl exportExcelService = new ExportExcelServiceImpl();
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
@GET
|
||||
@Path("/cus_port")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportExcel(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response){
|
||||
String onlyMark = request.getParameter("onlyMark");
|
||||
String dataId = request.getParameter("dataId");
|
||||
if(StringUtils.isBlank(onlyMark) || StringUtils.isBlank(dataId)){
|
||||
logger.error("配置唯一标识或dataId为空!");
|
||||
return null;
|
||||
// return Response.ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM).type("application/zip")
|
||||
// .header("Content-Disposition", "attachment;filename=" +
|
||||
// new String(packageName.toString().getBytes("GBK"), StandardCharsets.ISO_8859_1) + ".zip").build();
|
||||
}
|
||||
CusExportExcelConfigMain config = exportExcelService.getConfig(onlyMark);
|
||||
if(Objects.isNull(config)){
|
||||
logger.error("该唯一标识在配置表中没有找到配置数据!");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String suffix = config.getTemplate_path().substring(config.getTemplate_path().lastIndexOf("."));
|
||||
StreamingOutput os = exportExcelService.exportExcel(config, dataId, suffix);
|
||||
// String mimeType = ".xls".equals(suffix) ? "application/vnd.ms-excel":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
String fileName = request.getParameter("fileName");
|
||||
if(StringUtils.isBlank(fileName)){
|
||||
fileName = TimeUtil.getCurrentDateString() + config.getFile_name();
|
||||
}
|
||||
fileName += suffix;
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
logger.info("文件名称 : " + fileName);
|
||||
return Response.ok(os, MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header("Content-Disposition", "attachment; filename*=UTF-8''" + fileName).build();
|
||||
}catch (Exception e){
|
||||
logger.error("生成excel文件异常 : ");
|
||||
logger.error(Util.getErrString(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@ import lombok.Data;
|
|||
public class CusExportExcelConfigDetail {
|
||||
private String excel_row;
|
||||
private String model_field;
|
||||
private String get_value_type;
|
||||
private int get_value_type;
|
||||
private String value_context;
|
||||
}
|
||||
|
|
|
@ -15,5 +15,6 @@ public class CusExportExcelConfigMain {
|
|||
private String model_table;
|
||||
private String template_path;
|
||||
private String file_name;
|
||||
private String table_name;
|
||||
private List<CusExportExcelConfigDetail> configDetailList;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.api.xuanran.wang.eny.export_excel.mapper;
|
|||
import aiyh.utils.annotation.recordset.*;
|
||||
import com.api.xuanran.wang.eny.export_excel.entity.CusExportExcelConfigDetail;
|
||||
import com.api.xuanran.wang.eny.export_excel.entity.CusExportExcelConfigMain;
|
||||
import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigDetail;
|
||||
import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigMain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -17,13 +15,17 @@ import java.util.Map;
|
|||
*/
|
||||
@SqlMapper
|
||||
public interface ExportExcelMapper {
|
||||
@Select("select * from uf_mod_export_excel where model_table = #{modelTable}")
|
||||
@Select("SELECT a.*,b.tablename as table_name " +
|
||||
"FROM uf_mod_export_excel a " +
|
||||
"left join workflow_mode_table_view b " +
|
||||
"on a.model_table = b.id " +
|
||||
"where only_mark = #{onlyMark}")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(property = "configDetailList",
|
||||
column = "id",
|
||||
id = @Id(value = Integer.class, methodId = 1))
|
||||
})
|
||||
CusExportExcelConfigMain selectConfigByModelId(@ParamMapper("modelTable") int modelTable);
|
||||
CusExportExcelConfigMain selectConfigByOnlyMark(@ParamMapper("onlyMark") String onlyMark);
|
||||
|
||||
/**
|
||||
* <h1>查询配置表明细表信息</h1>
|
||||
|
@ -39,6 +41,9 @@ public interface ExportExcelMapper {
|
|||
@CollectionMethod(1)
|
||||
List<CusExportExcelConfigDetail> selectConfigDetail(@ParamMapper("mainId") int mainId);
|
||||
|
||||
@Select(custom = true)
|
||||
Map<String, Object> selectCustomerSqlMap(@SqlString String sql, Map<String, Object> map);
|
||||
|
||||
@Select(custom = true)
|
||||
String selectCustomerSql(@SqlString String sql, Map<String, Object> map);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,27 @@
|
|||
package com.api.xuanran.wang.eny.export_excel.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.api.xuanran.wang.eny.export_excel.entity.CusExportExcelConfigDetail;
|
||||
import com.api.xuanran.wang.eny.export_excel.entity.CusExportExcelConfigMain;
|
||||
import com.api.xuanran.wang.eny.export_excel.mapper.ExportExcelMapper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.general.GCONST;
|
||||
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.*;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <h1>自定义导出excel</h1>
|
||||
|
@ -12,16 +31,143 @@ import com.api.xuanran.wang.eny.export_excel.mapper.ExportExcelMapper;
|
|||
*/
|
||||
public class ExportExcelServiceImpl {
|
||||
private final ExportExcelMapper exportExcelMapper = Util.getMapper(ExportExcelMapper.class);
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
/**
|
||||
* <h1>根据模块id查询配置</h1>
|
||||
*
|
||||
* @param onlyMark 唯一标识
|
||||
* @return 配置对象
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/7 11:28
|
||||
* @param modelId 模块id
|
||||
* @return 配置对象
|
||||
**/
|
||||
public CusExportExcelConfigMain getConfig(int modelId){
|
||||
return exportExcelMapper.selectConfigByModelId(modelId);
|
||||
public CusExportExcelConfigMain getConfig(String onlyMark) {
|
||||
return exportExcelMapper.selectConfigByOnlyMark(onlyMark);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>导出excel</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/7 16:26
|
||||
* @param config 配置对象
|
||||
* @param dataId 数据ID
|
||||
* @param suffix 文件后缀
|
||||
* @return 输出流
|
||||
**/
|
||||
public StreamingOutput exportExcel(CusExportExcelConfigMain config,
|
||||
String dataId,
|
||||
String suffix) throws IOException {
|
||||
return outputStream -> {
|
||||
String filePath = config.getTemplate_path();
|
||||
filePath = parseConfigPath(filePath);
|
||||
if(!new File(filePath).exists()){
|
||||
throw new IOException("在服务器中未找到模版文件!");
|
||||
}
|
||||
String sql = "select * from " + config.getTable_name() + " where id in ( " + dataId + " )";
|
||||
Map<String, Object> map = exportExcelMapper.selectCustomerSqlMap(sql, new HashMap<>());
|
||||
if(MapUtils.isEmpty(map)){
|
||||
throw new CustomerException("模块数据查询为空!");
|
||||
}
|
||||
List<CusExportExcelConfigDetail> configDetailList = config.getConfigDetailList();
|
||||
List<String> specialRow = new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(configDetailList)){
|
||||
specialRow = configDetailList.stream().map(CusExportExcelConfigDetail::getExcel_row).collect(Collectors.toList());
|
||||
}
|
||||
FileInputStream fis = new FileInputStream(filePath);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
Workbook workbook;
|
||||
if (".xls".equals(suffix)) {
|
||||
workbook = new HSSFWorkbook(fis);
|
||||
}else {
|
||||
workbook = new XSSFWorkbook(fis);
|
||||
}
|
||||
try {
|
||||
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
||||
for (Row row : sheet) {
|
||||
for (Cell cell : row) {
|
||||
String cellValue = cell.getStringCellValue();
|
||||
String replacedValue = replacePlaceholder(cellValue, map, specialRow, config);
|
||||
cell.setCellValue(replacedValue);
|
||||
}
|
||||
}
|
||||
workbook.write(bos);
|
||||
bos.writeTo(outputStream);
|
||||
outputStream.flush();
|
||||
}catch (Exception e){
|
||||
throw new CustomerException("replacePlaceholder error ", e);
|
||||
}finally {
|
||||
try {
|
||||
outputStream.close();
|
||||
bos.close();
|
||||
workbook.close();
|
||||
fis.close();
|
||||
}catch (Exception e){
|
||||
log.error("关流异常 : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>将excel模版中的参数进行替换</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/7 14:32
|
||||
* @param cellValue 单元格数据
|
||||
* @param modelMap 建模数据集合
|
||||
* @param specialRow 明细1配置的数据
|
||||
* @param config 配置对象
|
||||
* @return 替换后的值
|
||||
**/
|
||||
public String replacePlaceholder(String cellValue, Map<String, Object> modelMap, List<String> specialRow, CusExportExcelConfigMain config){
|
||||
Pattern pattern = Pattern.compile("\\{(.*?)}"); // 匹配以{}包裹的内容
|
||||
Matcher matcher = pattern.matcher(cellValue);
|
||||
StringBuffer replacedValue = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String placeholder = matcher.group(1); // 获取{}中的内容
|
||||
Object replacement = Util.null2DefaultStr(modelMap.get(placeholder),"");
|
||||
// sql特殊处理
|
||||
if(CollectionUtils.isNotEmpty(specialRow) && specialRow.contains(placeholder)){
|
||||
List<CusExportExcelConfigDetail> collect = config.getConfigDetailList().stream().filter(item -> item.getExcel_row().equals(placeholder)).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(collect)){
|
||||
CusExportExcelConfigDetail configDetail = collect.get(0);
|
||||
if(configDetail.getGet_value_type() == 2){
|
||||
String cusSql = configDetail.getValue_context();
|
||||
cusSql = Util.sbc2dbcCase(cusSql);
|
||||
replacement = exportExcelMapper.selectCustomerSql(cusSql, modelMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 根据需要进行替换的逻辑
|
||||
matcher.appendReplacement(replacedValue, replacement.toString());
|
||||
}
|
||||
matcher.appendTail(replacedValue);
|
||||
return replacedValue.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>解析请求xls模板位置</h1>
|
||||
* @param configFilePath 模板文件路径
|
||||
* @return 解析后的文件路径
|
||||
*/
|
||||
public String parseConfigPath(String configFilePath){
|
||||
StringBuilder filePath = new StringBuilder(GCONST.getSysFilePath());
|
||||
int beginIndex = configFilePath.indexOf(".");
|
||||
int endIndex = configFilePath.lastIndexOf(".");
|
||||
if(beginIndex == endIndex){
|
||||
filePath.append(configFilePath);
|
||||
}else {
|
||||
String[] pathArr = configFilePath.split("\\.");
|
||||
for (int i = 0; i < pathArr.length - 2; i++) {
|
||||
if(i != 0){
|
||||
filePath.append(File.separator);
|
||||
}
|
||||
filePath.append(pathArr[i]);
|
||||
}
|
||||
filePath.append(File.separator)
|
||||
.append(pathArr[pathArr.length - 2])
|
||||
.append(".")
|
||||
.append(pathArr[pathArr.length - 1]);
|
||||
}
|
||||
return filePath.toString();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService {
|
|||
String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}";
|
||||
int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey);
|
||||
if(id < 0){
|
||||
throw new CustomerException(Util.logStr("code : {} not found in OA!", id));
|
||||
throw new CustomerException(Util.logStr("code : {} not found in OA!", oaOutKey));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,14 @@ public class TaskElementController {
|
|||
|
||||
private final TaskElementService service = new TaskElementService();
|
||||
|
||||
/**
|
||||
* <h2>查询任务列表</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @param itemGroup 分组值
|
||||
* @return 任务列表
|
||||
*/
|
||||
@Path("/list-get")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -36,13 +44,22 @@ public class TaskElementController {
|
|||
@QueryParam("itemGroup") String itemGroup) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
try {
|
||||
return ApiResult.success(service.getList(user,itemGroup));
|
||||
return ApiResult.success(service.getList(user, itemGroup));
|
||||
} catch (Exception e) {
|
||||
log.error("get task list error!\n" + Util.getErrString(e));
|
||||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>搜索任务信息</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @param params 请求参数
|
||||
* @param configId 配置id
|
||||
* @return 任务信息列表
|
||||
*/
|
||||
@Path("/search-list")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -61,6 +78,13 @@ public class TaskElementController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询按钮权限</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @return 按钮权限信息
|
||||
*/
|
||||
@Path("/get-btn")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -77,6 +101,11 @@ public class TaskElementController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>清除配置信息</h2>
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Path("/clear-config")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -89,4 +118,29 @@ public class TaskElementController {
|
|||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>提交转发任务修改状态</h2>
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @param params 请求参数
|
||||
* @return 更新状态
|
||||
*/
|
||||
@Path("/submit-task")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String submitTask(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response,
|
||||
@RequestBody Map<String, Object> params) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ApiResult.success(service.submitTask(user, params));
|
||||
} catch (Exception e) {
|
||||
log.error("提交转交任务状态写入失败!" + Util.getErrString(e));
|
||||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,4 +150,22 @@ public interface TaskElementMapper {
|
|||
String selectConvert(@SqlString String sql, @ParamMapper("value") String o);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询主表ID</h2>
|
||||
*
|
||||
* @param actionId actionId
|
||||
* @return 主表id
|
||||
*/
|
||||
@Select("select id from uf_rwtzeq where touchpointbh = #{actionId}")
|
||||
String selectTaskMainId(String actionId);
|
||||
|
||||
/**
|
||||
* <h2>更新被转交任务状态</h2>
|
||||
*
|
||||
* @param userId 当前用户
|
||||
* @param mainId 主表ID
|
||||
* @return 更新状态
|
||||
*/
|
||||
@Update("update uf_rwtzeq_dt1 set zjwczt = 0 where zjr = #{userId} and mainid = #{mainId}")
|
||||
boolean updateTaskHandoverStatus(@ParamMapper("userId") String userId, @ParamMapper("mainId") String mainId);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import aiyh.utils.excention.CustomerException;
|
|||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.lang.Assert;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.youhong.ai.ihgzhouji.taskele.entity.IhgTaskElementConfigItem;
|
||||
import com.api.youhong.ai.ihgzhouji.taskele.mapper.TaskElementMapper;
|
||||
import com.api.youhong.ai.ihgzhouji.taskele.mapstruct.TaskElementMapstruct;
|
||||
|
@ -48,11 +49,11 @@ public class TaskElementService {
|
|||
return config;
|
||||
}
|
||||
|
||||
public List<IhgTaskElementVo> getList(User user,String itemGroup) {
|
||||
public List<IhgTaskElementVo> getList(User user, String itemGroup) {
|
||||
List<IhgTaskElementConfigItem> ihgTaskElementConfItemList = null;
|
||||
if (StrUtil.isBlank(itemGroup)) {
|
||||
ihgTaskElementConfItemList = mapper.selectConfig();
|
||||
}else {
|
||||
} else {
|
||||
ihgTaskElementConfItemList = mapper.selectConfigByGroup(itemGroup);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(ihgTaskElementConfItemList)) {
|
||||
|
@ -243,4 +244,29 @@ public class TaskElementService {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>提交转交任务修改转交任务状态</h2>
|
||||
*
|
||||
* @param user 当前登录用户
|
||||
* @param params 请求参数
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
public Object submitTask(User user, Map<String, Object> params) {
|
||||
String actionId = Util.null2String(params.get("actionId"));
|
||||
String userId = Util.null2String(params.get("userId"));
|
||||
if (!userId.equals(Util.null2String(user.getUID()))) {
|
||||
throw new CustomerException("被转交人和当前登录人不一致!");
|
||||
}
|
||||
String mainId = mapper.selectTaskMainId(actionId);
|
||||
if (StrUtil.isBlank(mainId)) {
|
||||
throw new CustomerException("无法查询到对应的任务信息!");
|
||||
}
|
||||
// 更新被转交人转交任务状态
|
||||
boolean flag = mapper.updateTaskHandoverStatus(userId, mainId);
|
||||
if (!flag) {
|
||||
log.error("更新被转交任务状态失败!当前用户信息以及请求参数:" + JSON.toJSONString(params));
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.youhong.ai.ihgzhouji.userinfoel.service.UserInfoService;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* <h1>获取用户信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/11 22:11</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Path("/aiyh/user-info")
|
||||
public class UserInfoController {
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
private final UserInfoService service = new UserInfoService();
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/get")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getUserInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ApiResult.success(service.getUserInfo(user));
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户信息失败!" + Util.getErrString(e));
|
||||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
import aiyh.utils.annotation.recordset.SqlString;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/6/11 22:25</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface UserInfoMapper {
|
||||
|
||||
/**
|
||||
* <h2>查询按钮权限</h2>
|
||||
*
|
||||
* @param sql 按钮权限sql
|
||||
* @param user 当前用户
|
||||
* @return 查询到的数据
|
||||
*/
|
||||
@Select(custom = true)
|
||||
Map<String, Object> selectAuthoritySql(@SqlString String sql, User user);
|
||||
|
||||
/**
|
||||
* <h2>查询是否是酒店人员</h2>
|
||||
*
|
||||
* @param uid 当前人员
|
||||
* @return 酒店数量
|
||||
*/
|
||||
/*@Select("select count(id)\n" +
|
||||
"from uf_hotelinfo\n" +
|
||||
"where\n" +
|
||||
" concat(',',salesmarketingleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',revenueleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',financeleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',fbleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',hrleader,',') like concat(',',#{uID},',')\n" +
|
||||
"or concat(',',generalmanager,',') like concat(',', #{uID},',')")*/
|
||||
@Select("select count(id) from uf_hotelinfo where\n" +
|
||||
"concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',humanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',commercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',revenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',financebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',rbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',engineering,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofopsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofhumanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofcommercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrevenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofengineering,',') like concat(',',#{userId},',')")
|
||||
Integer selectIsHotel(int uid);
|
||||
|
||||
/**
|
||||
* <h2>查询酒店信息</h2>
|
||||
*
|
||||
* @param hotelIndex 酒店编码
|
||||
* @return 酒店信息
|
||||
*/
|
||||
@Select("select * from v_commercial \n" +
|
||||
" where holidex = #{hotelIndex}")
|
||||
Map<String, Object> selectHotelInfo(String hotelIndex);
|
||||
|
||||
/**
|
||||
* <h2>查询人员信息</h2>
|
||||
*
|
||||
* @param uid 当前人员
|
||||
* @return 人员信息
|
||||
*/
|
||||
@Select("select id,lastname,messagerurl,departmentid from hrmresource where id = #{userId}")
|
||||
Map<String, Object> selectHrmInfo(int uid);
|
||||
|
||||
/**
|
||||
* <h2>查询角色信息</h2>
|
||||
*
|
||||
* @param uid 当前人员
|
||||
* @param hotelIndex 酒店编码
|
||||
* @return 角色信息
|
||||
*/
|
||||
@Select("select * from uf_hotelinfo where\n" +
|
||||
"(concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',subregionadmin,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',humanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',commercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',revenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',financebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',rbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',engineering,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofopsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofhumanresources,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofcommercialperformance,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrevenuemanagement,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',headofengineering,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',generalmanager,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',salesmarketingleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',revenueleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',financeleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',fbleader,',') like concat(',',#{userId},',')\n" +
|
||||
"or concat(',',hrleader,',') like concat(',',#{userId},',')) " +
|
||||
"and holidex = #{hotelIndex}")
|
||||
List<Map<String, Object>> selectRoles(@ParamMapper("userId") int uid, @ParamMapper("hotelIndex") String hotelIndex);
|
||||
|
||||
/**
|
||||
* <h2>查询部门信息</h2>
|
||||
*
|
||||
* @param departmentId 部门id
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Select("select id,departmentname,departmentcode,departmentmark from hrmdepartment where id = #{departmentId}")
|
||||
Map<String, Object> selectDepartmentInfo(String departmentId);
|
||||
|
||||
/**
|
||||
* <h2>查询所有下级部门信息</h2>
|
||||
*
|
||||
* @param gCSupportCenterId 支持中心部门
|
||||
* @return 所有部门信息
|
||||
*/
|
||||
@Select("select *\n" +
|
||||
"from (\n" +
|
||||
"WITH RECURSIVE subdepts AS (\n" +
|
||||
"SELECT id, DEPARTMENTNAME, SUPDEPID\n" +
|
||||
"FROM HrmDepartment\n" +
|
||||
"WHERE id = #{gCSupportCenterId}\n" +
|
||||
"UNION ALL\n" +
|
||||
"SELECT\n" +
|
||||
" d.id, \n" +
|
||||
" d.DEPARTMENTNAME,\n" +
|
||||
" d.SUPDEPID\n" +
|
||||
"FROM HrmDepartment d\n" +
|
||||
"JOIN subdepts sd ON d.SUPDEPID = sd.id)\n" +
|
||||
" SELECT *\n" +
|
||||
" FROM subdepts) temp;")
|
||||
List<Map<String, Object>> selectGCSupportCenterDep(String gCSupportCenterId);
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.api.youhong.ai.ihgzhouji.userinfoel.mapper.UserInfoMapper;
|
||||
import com.api.youhong.ai.ihgzhouji.userinfoel.vo.UserInfoVo;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author youhong.ai
|
||||
*/
|
||||
public class UserInfoService {
|
||||
private final UserInfoMapper mapper = Util.getMapper(UserInfoMapper.class);
|
||||
private final static Map<String, String> ROLES_MAP = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* <h2>获取用户信息</h2>
|
||||
*
|
||||
* @param user 当前登录用户
|
||||
* @return 用户信息
|
||||
*/
|
||||
public UserInfoVo getUserInfo(User user) {
|
||||
UserInfoVo userInfoVo = new UserInfoVo();
|
||||
String taskDispatchAuthority = Util.getCusConfigValue("TaskDispatchAuthority");
|
||||
String taskAcceptanceAuthority = Util.getCusConfigValue("TaskAcceptanceAuthority");
|
||||
String gCSupportCenterId = Util.getCusConfigValue("GCSupportCenterId");
|
||||
// 查询任务下发
|
||||
if (StrUtil.isNotBlank(taskDispatchAuthority)) {
|
||||
Map<String, Object> map = this.mapper.selectAuthoritySql(taskDispatchAuthority, user);
|
||||
if (CollectionUtil.isNotEmpty(map)) {
|
||||
userInfoVo.setTaskDispatch(true);
|
||||
}
|
||||
}
|
||||
// 查询任务清单
|
||||
if (StrUtil.isNotBlank(taskAcceptanceAuthority)) {
|
||||
Map<String, Object> map = this.mapper.selectAuthoritySql(taskAcceptanceAuthority, user);
|
||||
if (CollectionUtil.isNotEmpty(map)) {
|
||||
userInfoVo.setTaskAcceptance(true);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询用户信息
|
||||
Map<String, Object> userInfo = this.mapper.selectHrmInfo(user.getUID());
|
||||
if (CollectionUtil.isNotEmpty(userInfo)) {
|
||||
userInfoVo.setUserInfo(userInfo);
|
||||
// 查询支持中心所有部门
|
||||
List<Map<String, Object>> depList = mapper.selectGCSupportCenterDep(gCSupportCenterId);
|
||||
Map<String, Object> department = findMapById(depList, user.getUserDepartment());
|
||||
String hotelIndex = null;
|
||||
if (CollectionUtil.isEmpty(department)) {
|
||||
// 不属于支持中心人,查询对应酒店信息
|
||||
String lastname = Util.null2String(userInfo.get("lastname"));
|
||||
if (StrUtil.isBlank(lastname)) {
|
||||
throw new CustomerException("获取酒店人员信息失败!未查询到人员姓名");
|
||||
}
|
||||
|
||||
String[] split = lastname.split("-");
|
||||
if (split.length <= 1) {
|
||||
throw new CustomerException("获取酒店人员信息失败!lastName中不存在酒店代码");
|
||||
}
|
||||
hotelIndex = split[split.length - 1];
|
||||
Map<String, Object> hotelInfo = this.mapper.selectHotelInfo(hotelIndex);
|
||||
userInfoVo.setHotelInfo(hotelInfo);
|
||||
} else {
|
||||
// 支持中心,显示部门信息
|
||||
userInfoVo.setDepartmentInfo(department);
|
||||
}
|
||||
// 如果存在酒店信息
|
||||
if (StrUtil.isNotBlank(hotelIndex)) {
|
||||
List<Map<String, Object>> hotelRoles = this.mapper.selectRoles(user.getUID(), hotelIndex);
|
||||
if (CollectionUtil.isEmpty(hotelRoles)) {
|
||||
return userInfoVo;
|
||||
}
|
||||
Set<String> roleNames = new HashSet<>();
|
||||
// 循环酒店角色信息
|
||||
for (Map<String, Object> hotelRole : hotelRoles) {
|
||||
// 循环酒店角色名称
|
||||
for (Map.Entry<String, String> entry : ROLES_MAP.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (!hotelRole.containsKey(key)) {
|
||||
continue;
|
||||
}
|
||||
String value = Util.null2String(hotelRole.get(key));
|
||||
// 如果在酒店名称中找到对应的人,则为角色名
|
||||
if (StrUtil.isBlank(value)) {
|
||||
continue;
|
||||
}
|
||||
String[] split = value.split(",");
|
||||
List<String> strings = Arrays.asList(split);
|
||||
if (strings.contains(Util.null2String(user.getUID()))) {
|
||||
roleNames.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
userInfoVo.setRoleNames(roleNames);
|
||||
}
|
||||
}
|
||||
return userInfoVo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查找对应的部门</h2>
|
||||
*
|
||||
* @param dataList 部门列表
|
||||
* @param id 部门id
|
||||
* @return 部门信息
|
||||
*/
|
||||
public static Map<String, Object> findMapById(List<Map<String, Object>> dataList, int id) {
|
||||
for (Map<String, Object> map : dataList) {
|
||||
if (map.containsKey("id") && Integer.parseInt(Util.null2String(map.get("id"))) == id) {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* <h2>获取酒店角色信息</h2>
|
||||
*
|
||||
* @return 酒店角色信息
|
||||
*/
|
||||
static {
|
||||
ROLES_MAP.put("olt", "OLT");
|
||||
ROLES_MAP.put("vpo", "VPO");
|
||||
ROLES_MAP.put("subregionadmin", "Sub Region Admin");
|
||||
ROLES_MAP.put("opsconsultant", "Ops Consultant");
|
||||
ROLES_MAP.put("humanresources", "Human Resources");
|
||||
ROLES_MAP.put("commercialperformance", "Commercial Performance");
|
||||
ROLES_MAP.put("revenuemanagement", "Revenue Management");
|
||||
ROLES_MAP.put("financebusinesssupport", "Finance & Business Support");
|
||||
ROLES_MAP.put("rbeoperations", "RB&E Operations");
|
||||
ROLES_MAP.put("engineering", "Engineering");
|
||||
ROLES_MAP.put("headofopsconsultant", "Head of Ops Consultant");
|
||||
ROLES_MAP.put("headofhumanresources", "Head of Human Resources");
|
||||
ROLES_MAP.put("headofcommercialperformance", "Head of Commercial Performance");
|
||||
ROLES_MAP.put("headofrevenuemanagement", "Head of Revenue Management");
|
||||
ROLES_MAP.put("headoffinancebusinesssupport", "Head of Finance & Business Support");
|
||||
ROLES_MAP.put("headofrbeoperations", "Head of RB&E Operations");
|
||||
ROLES_MAP.put("headofengineering", "Head of Engineering");
|
||||
ROLES_MAP.put("generalmanager", "General Manager");
|
||||
ROLES_MAP.put("salesmarketingleader", "Sales & Marketing leader");
|
||||
ROLES_MAP.put("revenueleader", "Revenue Leader");
|
||||
ROLES_MAP.put("financeleader", "Finance Leader");
|
||||
ROLES_MAP.put("fbleader", "F&B Leader");
|
||||
ROLES_MAP.put("hrleader", "HR Leader");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.api.youhong.ai.ihgzhouji.userinfoel.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <h1>用户信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/11 22:16</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class UserInfoVo {
|
||||
|
||||
/** 任务下发权限 */
|
||||
private boolean taskDispatch;
|
||||
|
||||
/** 任务接收权限 */
|
||||
private boolean taskAcceptance;
|
||||
|
||||
/** 酒店信息 */
|
||||
Map<String, Object> hotelInfo;
|
||||
|
||||
/** 用户信息 */
|
||||
Map<String, Object> userInfo;
|
||||
|
||||
/** 角色 */
|
||||
Set<String> roleNames;
|
||||
|
||||
/** 部门信息 */
|
||||
Map<String, Object> departmentInfo;
|
||||
|
||||
}
|
|
@ -42,15 +42,15 @@ public interface OrgChartMapper {
|
|||
" job.JOBTITLENAME job_title_name, " +
|
||||
" uftb.$t{parentField} type_of_employment " +
|
||||
"from hrmresource hrm " +
|
||||
" left join hrmjobtitles job on hrm.JOBTITLE = job.id " +
|
||||
" left join cus_fielddata cus on cus.ID = hrm.ID " +
|
||||
" inner join hrmjobtitles job on hrm.JOBTITLE = job.id " +
|
||||
" inner join cus_fielddata cus on cus.ID = hrm.ID " +
|
||||
" and cus.SCOPE = 'HrmCustomFieldByInfoType' " +
|
||||
" and cus.SCOPEID = 1 " +
|
||||
" left join cus_fielddata cus1 on cus1.id = hrm.id" +
|
||||
" inner join cus_fielddata cus1 on cus1.id = hrm.id" +
|
||||
" and cus1.scope = 'HrmCustomFieldByInfoType' " +
|
||||
" and cus1.scopeid = -1" +
|
||||
" left join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
||||
" left join $t{typeOfEmploymentTable} uftb on uftb.$t{typeOfEmploymentIdField} = cus1.$t{typeOfEmploymentFiled} " +
|
||||
" inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
||||
" inner join $t{typeOfEmploymentTable} uftb on uftb.$t{typeOfEmploymentIdField} = cus1.$t{typeOfEmploymentFiled} " +
|
||||
"where hrm.status in (0, 1)")
|
||||
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
|
||||
@ParamMapper("lastNameEnField") String lastNameEnField,
|
||||
|
|
|
@ -47,6 +47,14 @@ public class OrgChartService {
|
|||
if (userId == 1) {
|
||||
return systemAdminTree(hrmResourceDtoList);
|
||||
}
|
||||
/* ******************* 次账号处理逻辑 ******************* */
|
||||
String accountType = logInUser.getAccount_type();
|
||||
if ("1".equals(accountType)) {
|
||||
// 对当前账号过滤当前分部信息
|
||||
List<HrmResourceDto> collect = hrmResourceDtoList.stream().filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId())
|
||||
.collect(Collectors.toList());
|
||||
return secondaryAccountTree(collect);
|
||||
}
|
||||
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
||||
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
||||
ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId);
|
||||
|
@ -111,6 +119,7 @@ public class OrgChartService {
|
|||
if (userId == 1) {
|
||||
return systemAdminTree(hrmResourceDtoList);
|
||||
}
|
||||
|
||||
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
||||
List<OrgChartNodeVo> orgChartNodeVoList = null;
|
||||
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||
|
@ -145,6 +154,8 @@ public class OrgChartService {
|
|||
* @param logInUser 当前登陆用户
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
|
||||
|
||||
private void filterCurrentSubCom(List<HrmResourceDto> hrmResourceDtoList,
|
||||
AtomicReference<HrmResourceDto> currentUser,
|
||||
User logInUser) {
|
||||
|
@ -192,7 +203,7 @@ public class OrgChartService {
|
|||
.with(OrgChartNodeVo::setCurrent, true)
|
||||
.endSet())
|
||||
.collect(Collectors.toList());
|
||||
return Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
||||
List<OrgChartNodeVo> orgChartNodeVoList = Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
||||
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
|
||||
parentId -> parentId == null || parentId <= 0)
|
||||
.stream().peek(item -> Builder.startSet(item)
|
||||
|
@ -201,6 +212,40 @@ public class OrgChartService {
|
|||
.endSet())
|
||||
.peek(item -> recursionChildrenNums(item, 0))
|
||||
.collect(Collectors.toList());
|
||||
sortByNameFirstLetter(orgChartNodeVoList);
|
||||
return orgChartNodeVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>次账号返回数据数据</h2>
|
||||
* <i>2023/06/13 17:15</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param hrmResourceDtoList 人力资源dtolist
|
||||
* @return List<OrgChartNodeVo> 树型list
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private List<OrgChartNodeVo> secondaryAccountTree(List<HrmResourceDto> hrmResourceDtoList) {
|
||||
List<OrgChartNodeVo> collect = hrmResourceDtoList.stream()
|
||||
.map(struct::hrmResourceDtoToVo)
|
||||
.peek(item -> Builder.startSet(item)
|
||||
.with(OrgChartNodeVo::setShow, 1)
|
||||
.with(OrgChartNodeVo::setShowBrother, 1)
|
||||
.with(OrgChartNodeVo::setShowChildren, 1)
|
||||
.with(OrgChartNodeVo::setCurrent, true)
|
||||
.endSet())
|
||||
.collect(Collectors.toList());
|
||||
List<OrgChartNodeVo> orgChartNodeVoList = Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
||||
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
|
||||
parentId -> parentId == null || parentId <= 0)
|
||||
.stream().peek(item -> Builder.startSet(item)
|
||||
.with(OrgChartNodeVo::setIsRoot, true)
|
||||
.with(OrgChartNodeVo::setCurrent, true)
|
||||
.endSet())
|
||||
.peek(item -> recursionChildrenNums(item, 0))
|
||||
.collect(Collectors.toList());
|
||||
sortByNameFirstLetter(orgChartNodeVoList);
|
||||
return orgChartNodeVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package com.customization.youhong.pcn.createrworkflow;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.engine.workflow.constant.PAResponseCode;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <h1>创建流程参数校验异常信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 15:22</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class CreateRequestException extends RuntimeException {
|
||||
private final Logger logger = Util.getLogger();
|
||||
private final String msg;
|
||||
private Throwable throwable;
|
||||
private Integer code = -1;
|
||||
|
||||
private PAResponseCode responseCode;
|
||||
|
||||
public CreateRequestException(Throwable throwable) {
|
||||
super(throwable);
|
||||
this.msg = throwable.getMessage();
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
|
||||
public CreateRequestException(String msg, PAResponseCode responseCode) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, String... obj) {
|
||||
super(Util.logStr(msg, obj));
|
||||
this.msg = Util.logStr(msg, obj);
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, Integer code) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, Integer code, Throwable throwable) {
|
||||
super(msg, throwable);
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public CreateRequestException(String msg, Throwable throwable) {
|
||||
super(msg, throwable);
|
||||
this.msg = msg;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public PAResponseCode getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.msg;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.impl;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.customization.youhong.pcn.createrworkflow.CreateRequestException;
|
||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||
import com.customization.youhong.pcn.createrworkflow.util.CheckWorkflowRequestParamsUtil;
|
||||
import com.engine.core.cfg.annotation.ServiceDynamicProxy;
|
||||
import com.engine.core.cfg.annotation.ServiceMethodDynamicProxy;
|
||||
import com.engine.core.impl.aop.AbstractServiceProxy;
|
||||
import com.engine.workflow.constant.PAResponseCode;
|
||||
import com.engine.workflow.entity.publicApi.PAResponseEntity;
|
||||
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
|
||||
import com.engine.workflow.publicApi.WorkflowRequestOperatePA;
|
||||
import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>检查流程创建流程参数</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 14:14</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@ServiceDynamicProxy(target = WorkflowRequestOperatePAImpl.class, desc = "公共接口创建流程对流程参数校验")
|
||||
public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy implements WorkflowRequestOperatePA {
|
||||
|
||||
private final Logger log = Util.getLogger("workflow");
|
||||
|
||||
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||
|
||||
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();
|
||||
|
||||
@Override
|
||||
@ServiceMethodDynamicProxy(desc = "子流程触发时,做流程转数据")
|
||||
public PAResponseEntity doCreateRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
try {
|
||||
try {
|
||||
checkUtil.checkRequestParam(user, requestParam);
|
||||
return (PAResponseEntity) executeMethod(user, requestParam);
|
||||
} catch (CreateRequestException e) {
|
||||
PAResponseEntity paResponseEntity = new PAResponseEntity();
|
||||
paResponseEntity.setCode(e.getResponseCode());
|
||||
Map<String, Object> errorMsg = new HashMap<>(8);
|
||||
errorMsg.put("msg", e.getMsg());
|
||||
paResponseEntity.setErrMsg(errorMsg);
|
||||
return paResponseEntity;
|
||||
} catch (Exception e) {
|
||||
log.error("自定义流程创建校验请求参数出错:" + Util.getErrString(e));
|
||||
PAResponseEntity paResponseEntity = new PAResponseEntity();
|
||||
paResponseEntity.setCode(PAResponseCode.SYSTEM_INNER_ERROR);
|
||||
Map<String, Object> errorMsg = new HashMap<>(8);
|
||||
errorMsg.put("msg", "system error!");
|
||||
paResponseEntity.setErrMsg(errorMsg);
|
||||
return paResponseEntity;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("自定义流程创建校验请求参数出错:" + Util.getErrString(e));
|
||||
return (PAResponseEntity) executeMethod(user, requestParam);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity withdrawRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity submitRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity forwardRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity rejectRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity doForceDrawBack(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity doForceOver(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity deleteRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity saveRequestLog(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity doIntervenor(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity getNodeOperator(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity getNodeMenu(User user, ReqOperateRequestEntity requestParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PAResponseEntity getCanRejectNodes(User user, ReqOperateRequestEntity request2Entity) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>mapper</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 14:20</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface CheckWorkflowRequestParamsMapper {
|
||||
|
||||
|
||||
@Select("select * from uf_check_request_create where workflow_type = #{workflowId}")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(
|
||||
property = "detailList",
|
||||
column = "id",
|
||||
id = @Id(value = String.class, methodId = 1)
|
||||
),
|
||||
@CollectionMapping(
|
||||
property = "conditionGroupItems",
|
||||
column = "id",
|
||||
id = @Id(value = String.class, methodId = 2)
|
||||
),
|
||||
})
|
||||
CheckCreateConfig selectCheckConfig(int workflowId);
|
||||
|
||||
|
||||
@Select("select * from uf_check_request_create_dt1 where mainid = #{mainId}")
|
||||
@Associations({
|
||||
@Association(
|
||||
property = "workflowField",
|
||||
column = "workflow_field",
|
||||
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||
id = @Id(Integer.class)
|
||||
)
|
||||
})
|
||||
@CollectionMethod(value = 1, desc = "查询明细表1,参数校验配置")
|
||||
List<CheckCreateConfigDetail> selectCheckDetail(String mainId);
|
||||
|
||||
|
||||
@Select("select * from uf_check_request_create_dt2 where mainid = #{mainId}")
|
||||
@CollectionMethod(value = 2, desc = "查询明细表2,条件配置参数")
|
||||
List<CheckConditionItem> selectConditionDetail(String mainId);
|
||||
|
||||
|
||||
@Select(custom = true)
|
||||
@ToLowerCase
|
||||
Map<String, Object> selectCustomerSql(@SqlString String sql,
|
||||
@ParamMapper("value") String value,
|
||||
@ParamMapper("user") User user);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 17:52</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CheckConditionItem {
|
||||
|
||||
/** id */
|
||||
private Integer id;
|
||||
|
||||
/** 条件名称 */
|
||||
private String conditionName;
|
||||
|
||||
/** 条件规则 */
|
||||
private Integer conditionRule;
|
||||
|
||||
/** 条件自定义 */
|
||||
private String customerValue;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>检查流程请求参数校验配置信息</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 17:21</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CheckCreateConfig {
|
||||
/** 流程id */
|
||||
private Integer workflowType;
|
||||
|
||||
/** 描述 */
|
||||
private String description;
|
||||
|
||||
/** 检查配置明细 */
|
||||
private List<CheckCreateConfigDetail> detailList;
|
||||
|
||||
/** 条件分组配置 */
|
||||
private List<CheckConditionItem> conditionGroupItems;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.pojo;
|
||||
|
||||
import aiyh.utils.entity.FieldViewInfo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 17:24</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CheckCreateConfigDetail {
|
||||
|
||||
/** id */
|
||||
private Integer id;
|
||||
|
||||
/** 流程字段 */
|
||||
private FieldViewInfo workflowField;
|
||||
|
||||
/** 错误提示消息 */
|
||||
private String errorMsg;
|
||||
|
||||
/** 校验规则 */
|
||||
private Integer checkRule;
|
||||
|
||||
/** 自定义值 */
|
||||
private String customerValue;
|
||||
|
||||
/** 校验表达式 */
|
||||
private String checkExpression;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.util;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>自定义校验接口</h1>
|
||||
*
|
||||
* <p>create: 2023/6/15 19:59</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public interface CheckCreateRequestCustomerInterface {
|
||||
|
||||
/**
|
||||
* <h2>自定义检查方法接口</h2>
|
||||
*
|
||||
* @param checkFunctionParam 检查方法参数
|
||||
* @param pathParam 路径参数
|
||||
* @return 是否符合条件
|
||||
*/
|
||||
boolean check(CheckFunctionParam checkFunctionParam, Map<String, String> pathParam);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.util;
|
||||
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import weaver.hrm.User;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>检查方法参数实体</h1>
|
||||
*
|
||||
* <p>create: 2023/6/15 15:24</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CheckFunctionParam {
|
||||
private WorkflowRequestTableField workflowRequestTableField;
|
||||
private CheckCreateConfigDetail checkCreateConfigDetail;
|
||||
private Map<String, CheckConditionItem> checkConditionMap;
|
||||
private User user;
|
||||
private CheckConditionItem checkConditionItem;
|
||||
}
|
|
@ -0,0 +1,219 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.util;
|
||||
|
||||
import aiyh.utils.ScriptUtil;
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.annotation.MethodRuleNo;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* <h1>检查方法校验工具</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 18:30</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class CheckRuleMethodUtil {
|
||||
|
||||
private static final Logger log = Util.getLogger("workflow");
|
||||
|
||||
private static final CheckWorkflowRequestParamsMapper MAPPER = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||
public static final Map<Integer,
|
||||
Function<CheckFunctionParam, Boolean>
|
||||
> CHECK_RULE_MAP = new HashMap<>(8);
|
||||
|
||||
static {
|
||||
try {
|
||||
Class<CheckRuleMethodUtil> checkRuleMethodUtilClass = CheckRuleMethodUtil.class;
|
||||
Method[] methods = checkRuleMethodUtilClass.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
||||
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
||||
int value = annotation.value();
|
||||
CHECK_RULE_MAP.put(value, (checkFunctionParam) -> {
|
||||
try {
|
||||
return (Boolean) method.invoke(null, checkFunctionParam);
|
||||
} catch (Exception e) {
|
||||
log.error("调用CheckRuleMethodUtil类中注解方法失败!" + Util.getErrString(e));
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("初始化CheckRuleMethodUtil失败!" + Util.getErrString(e));
|
||||
}
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 0, desc = "不为null")
|
||||
private static boolean noNull(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
return StrUtil.isNotBlank(workflowRequestTableField.getFieldValue());
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 1, desc = "整数类型")
|
||||
private static boolean isNumber(CheckFunctionParam checkFunctionParam) {
|
||||
try {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
Integer.parseInt(workflowRequestTableField.getFieldValue());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 2, desc = "小数类型")
|
||||
private static boolean isDouble(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
try {
|
||||
Double.parseDouble(workflowRequestTableField.getFieldValue());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 3, desc = "枚举值")
|
||||
private static boolean isEnumerate(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||
if (Objects.nonNull(checkConditionItem)) {
|
||||
customerValue = checkConditionItem.getCustomerValue();
|
||||
}
|
||||
if (StrUtil.isNotBlank(customerValue)) {
|
||||
String[] split = customerValue.split(",");
|
||||
return Arrays.asList(split).contains(fieldValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 4, desc = "自定义sql存在值")
|
||||
private static boolean customerSqlHasValue(CheckFunctionParam checkFunctionParam) {
|
||||
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
User user = checkFunctionParam.getUser();
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
String customerValue;
|
||||
if (Objects.nonNull(checkConditionItem)) {
|
||||
// 条件组调用方法
|
||||
customerValue = checkConditionItem.getCustomerValue();
|
||||
} else {
|
||||
customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
}
|
||||
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
|
||||
return CollectionUtil.isNotEmpty(map);
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 5, desc = "自定义sql校验表达式")
|
||||
private static boolean customerSqlCheck(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
User user = checkFunctionParam.getUser();
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||
String customerValue;
|
||||
if (Objects.nonNull(checkConditionItem)) {
|
||||
customerValue = checkConditionItem.getCustomerValue();
|
||||
} else {
|
||||
customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
}
|
||||
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
|
||||
if (CollectionUtil.isNotEmpty(map)) {
|
||||
String checkExpression = checkCreateConfigDetail.getCheckExpression();
|
||||
if (StrUtil.isNotBlank(checkExpression)) {
|
||||
return (Boolean) ScriptUtil.invokeScript(checkExpression, map);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@MethodRuleNo(value = 6, desc = "自定义表达式")
|
||||
private static boolean checkCustomerExpression(CheckFunctionParam checkFunctionParam) {
|
||||
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||
String checkExpression;
|
||||
if (Objects.nonNull(checkConditionItem)) {
|
||||
checkExpression = checkConditionItem.getCustomerValue();
|
||||
} else {
|
||||
checkExpression = checkCreateConfigDetail.getCheckExpression();
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>(8);
|
||||
map.put("value", fieldValue);
|
||||
if (StrUtil.isNotBlank(checkExpression)) {
|
||||
return (Boolean) ScriptUtil.invokeScript(checkExpression, map);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 7, desc = "自定义条件组")
|
||||
private static boolean checkCustomerConditionGroup(CheckFunctionParam checkFunctionParam) {
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
Map<String, CheckConditionItem> checkConditionMap = checkFunctionParam.getCheckConditionMap();
|
||||
String customerValue = checkCreateConfigDetail.getCheckExpression();
|
||||
String replace = customerValue.replace("(", " ")
|
||||
.replace(")", " ");
|
||||
String[] groups = replace.split(" ");
|
||||
List<String> groupList = new ArrayList<>();
|
||||
for (String group : groups) {
|
||||
if (StrUtil.isBlank(group) || "and".equalsIgnoreCase(group) || "or".equalsIgnoreCase(group)) {
|
||||
continue;
|
||||
}
|
||||
if ("||".equalsIgnoreCase(group) || "&&".equalsIgnoreCase(group)) {
|
||||
continue;
|
||||
}
|
||||
groupList.add(group);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(groupList)) {
|
||||
return false;
|
||||
}
|
||||
Map<String, Object> conditionMap = new HashMap<>(8);
|
||||
for (String groupName : groupList) {
|
||||
CheckConditionItem checkConditionItem = checkConditionMap.get(groupName);
|
||||
checkFunctionParam.setCheckConditionItem(checkConditionItem);
|
||||
Function<CheckFunctionParam, Boolean> checkFunctionParamBooleanFunction = CHECK_RULE_MAP.get(checkConditionItem.getConditionRule());
|
||||
if (Objects.nonNull(checkFunctionParamBooleanFunction)) {
|
||||
Boolean check = checkFunctionParamBooleanFunction.apply(checkFunctionParam);
|
||||
conditionMap.put(groupName, check);
|
||||
}
|
||||
}
|
||||
String checkExpression = checkCreateConfigDetail.getCheckExpression();
|
||||
if (StrUtil.isNotBlank(checkExpression)) {
|
||||
return (Boolean) ScriptUtil.invokeScript(checkExpression, conditionMap);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@MethodRuleNo(value = 8, desc = "自定义校验")
|
||||
private static boolean checkCustomerInterface(CheckFunctionParam checkFunctionParam) {
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||
if (Objects.nonNull(checkConditionItem)) {
|
||||
customerValue = checkConditionItem.getCustomerValue();
|
||||
}
|
||||
Map<String, String> map = Util.parseCusInterfacePathParam(customerValue);
|
||||
String classPath = map.remove("_ClassPath");
|
||||
CheckCreateRequestCustomerInterface instance = Util.getClassInstance(classPath, CheckCreateRequestCustomerInterface.class);
|
||||
return instance.check(checkFunctionParam, map);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package com.customization.youhong.pcn.createrworkflow.util;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import com.customization.youhong.pcn.createrworkflow.CreateRequestException;
|
||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig;
|
||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
|
||||
import com.engine.workflow.entity.publicApi.WorkflowDetailTableInfoEntity;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.User;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableRecord;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <h1>工具</h1>
|
||||
*
|
||||
* <p>create: 2023/6/14 14:20</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class CheckWorkflowRequestParamsUtil {
|
||||
|
||||
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||
|
||||
private final Logger log = Util.getLogger("workflow");
|
||||
|
||||
/**
|
||||
* ************************************************************
|
||||
* <h2>checkRequestParam 自定义参数校验</h2>
|
||||
* <i>2023/6/14 15:31</i>
|
||||
*
|
||||
* @param user: 当前用户
|
||||
* @param requestParam: 请求参数
|
||||
* @author youHong.ai
|
||||
* ************************************************************
|
||||
*/
|
||||
public void checkRequestParam(User user, ReqOperateRequestEntity requestParam) throws CreateRequestException {
|
||||
int workflowId = requestParam.getWorkflowId();
|
||||
CheckCreateConfig checkCreateConfig = mapper.selectCheckConfig(workflowId);
|
||||
if (Objects.isNull(checkCreateConfig)) {
|
||||
return;
|
||||
}
|
||||
List<CheckCreateConfigDetail> detailList = checkCreateConfig.getDetailList();
|
||||
if (CollectionUtil.isEmpty(detailList)) {
|
||||
return;
|
||||
}
|
||||
Map<String, CheckConditionItem> checkConditionItemMap;
|
||||
List<CheckConditionItem> conditionGroupItems = checkCreateConfig.getConditionGroupItems();
|
||||
if (CollectionUtil.isNotEmpty(conditionGroupItems)) {
|
||||
checkConditionItemMap =
|
||||
conditionGroupItems.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
CheckConditionItem::getConditionName,
|
||||
value -> value
|
||||
));
|
||||
} else {
|
||||
checkConditionItemMap = new HashMap<>(8);
|
||||
}
|
||||
Map<String, CheckCreateConfigDetail> checkDetailMap =
|
||||
detailList.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
item -> item.getWorkflowField().getFieldName(),
|
||||
value -> value
|
||||
)
|
||||
);
|
||||
// 校验主表数据
|
||||
checkMainData(checkDetailMap, checkConditionItemMap, requestParam, user);
|
||||
// 校验明细表参数
|
||||
checkDetailData(checkDetailMap, checkConditionItemMap, requestParam, user);
|
||||
if (CollectionUtil.isNotEmpty(checkDetailMap)) {
|
||||
List<String> required = new ArrayList<>();
|
||||
for (Map.Entry<String, CheckCreateConfigDetail> entry : checkDetailMap.entrySet()) {
|
||||
required.add(entry.getKey());
|
||||
}
|
||||
throw new CreateRequestException(Util.logStr("必填参数校验未通过,[{}]字段必填!", Util.join(required, ",")));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>校验主表数据</h2>
|
||||
*
|
||||
* @param checkDetailMap 校验规则map
|
||||
* @param checkConditionItemMap 校验自定义条件组map
|
||||
* @param requestParam 流程参数
|
||||
* @param user 用户
|
||||
*/
|
||||
private void checkMainData(Map<String, CheckCreateConfigDetail> checkDetailMap,
|
||||
Map<String, CheckConditionItem> checkConditionItemMap,
|
||||
ReqOperateRequestEntity requestParam, User user) {
|
||||
List<WorkflowRequestTableField> mainData = requestParam.getMainData();
|
||||
checkData(checkDetailMap, checkConditionItemMap, mainData, user, "主表");
|
||||
}
|
||||
|
||||
private void checkDetailData(Map<String, CheckCreateConfigDetail> checkDetailMap,
|
||||
Map<String, CheckConditionItem> checkConditionItemMap,
|
||||
ReqOperateRequestEntity requestParam, User user) {
|
||||
List<WorkflowDetailTableInfoEntity> detailData = requestParam.getDetailData();
|
||||
if (CollectionUtil.isEmpty(detailData)) {
|
||||
return;
|
||||
}
|
||||
for (WorkflowDetailTableInfoEntity detailDatum : detailData) {
|
||||
WorkflowRequestTableRecord[] workflowRequestTableRecords = detailDatum.getWorkflowRequestTableRecords();
|
||||
if (Objects.isNull(workflowRequestTableRecords)) {
|
||||
continue;
|
||||
}
|
||||
for (WorkflowRequestTableRecord workflowRequestTableRecord : workflowRequestTableRecords) {
|
||||
WorkflowRequestTableField[] workflowRequestTableFields = workflowRequestTableRecord.getWorkflowRequestTableFields();
|
||||
if (Objects.isNull(workflowRequestTableFields)) {
|
||||
continue;
|
||||
}
|
||||
List<WorkflowRequestTableField> dataList
|
||||
= Arrays.asList(workflowRequestTableFields);
|
||||
checkData(checkDetailMap, checkConditionItemMap, dataList, user, detailDatum.getTableDBName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkData(Map<String, CheckCreateConfigDetail> checkDetailMap,
|
||||
Map<String, CheckConditionItem> checkConditionItemMap,
|
||||
List<WorkflowRequestTableField> dataList, User user, String tableDesc) {
|
||||
for (WorkflowRequestTableField dataItem : dataList) {
|
||||
String fieldName = dataItem.getFieldName();
|
||||
CheckCreateConfigDetail checkCreateConfigDetail = checkDetailMap.get(fieldName);
|
||||
if (Objects.isNull(checkCreateConfigDetail)) {
|
||||
continue;
|
||||
}
|
||||
checkDetailMap.remove(fieldName);
|
||||
CheckFunctionParam checkFunctionParam = new CheckFunctionParam();
|
||||
checkFunctionParam.setCheckCreateConfigDetail(checkCreateConfigDetail);
|
||||
checkFunctionParam.setCheckConditionMap(checkConditionItemMap);
|
||||
checkFunctionParam.setUser(user);
|
||||
checkFunctionParam.setWorkflowRequestTableField(dataItem);
|
||||
Integer checkRule = checkCreateConfigDetail.getCheckRule();
|
||||
Function<CheckFunctionParam, Boolean> function = CheckRuleMethodUtil.CHECK_RULE_MAP.get(checkRule);
|
||||
Boolean apply = function.apply(checkFunctionParam);
|
||||
if (!apply) {
|
||||
throw new CreateRequestException(Util.logStr("[{}] 表数据校验未通过,字段[{}],错误信息[{}]",
|
||||
tableDesc, fieldName, checkCreateConfigDetail.getErrorMsg()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.controller;
|
||||
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherOtherSystemInfoService;
|
||||
|
@ -33,6 +32,7 @@ public class GMGatherOtherSystemInfoController extends BaseCronJob {
|
|||
boolean insertDataBool = gmgatherOtherSystemInfoService.insertDataIntoGM(syncStandard,URL,formTableNameGM);
|
||||
if (insertDataBool){
|
||||
logger.info("GM集团获取GM集团下级单位合同台账信息执行成功!");
|
||||
logger.info("");
|
||||
}else {
|
||||
logger.error("GM集团获取GM集团下级单位合同台账信息执行失败!");
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.controller;
|
||||
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
* <h1>GM集团获取商密集团合同台账信息</h1>
|
||||
* @author hcy
|
||||
* @date 2023/5/9 18:20
|
||||
*/
|
||||
public class GMGatherSMInfoController extends BaseCronJob {
|
||||
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
}
|
|
@ -14,10 +14,8 @@ import weaver.interfaces.schedule.BaseCronJob;
|
|||
*/
|
||||
public class GMGatherSameSystemInfoController extends BaseCronJob {
|
||||
|
||||
|
||||
//业务主要逻辑
|
||||
private final GMGatherSameSystemInfoService gmgatherSameSystemInfoService = new GMGatherSameSystemInfoServiceImpl();
|
||||
|
||||
private final GMGatherSameSystemInfoService gmCountLowGroupData = new GMGatherSameSystemInfoServiceImpl();
|
||||
//日志处理
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
|
@ -33,7 +31,43 @@ public class GMGatherSameSystemInfoController extends BaseCronJob {
|
|||
//唯一标识
|
||||
public String uniqueIdentification;
|
||||
|
||||
|
||||
|
||||
public void execute() {
|
||||
gmgatherSameSystemInfoService.dealMainLogic(configurationMainTableName,configurationDetailTableName1,configurationDetailTableName2,uniqueIdentification);
|
||||
gmCountLowGroupData.dealMainLogic(configurationMainTableName,configurationDetailTableName1,configurationDetailTableName2,uniqueIdentification);//处理业务主要逻辑
|
||||
}
|
||||
|
||||
public String getConfigurationDetailTableName1() {
|
||||
return configurationDetailTableName1;
|
||||
}
|
||||
|
||||
public void setConfigurationDetailTableName1(String configurationDetailTableName1) {
|
||||
this.configurationDetailTableName1 = configurationDetailTableName1;
|
||||
}
|
||||
|
||||
public String getConfigurationDetailTableName2() {
|
||||
return configurationDetailTableName2;
|
||||
}
|
||||
|
||||
public void setConfigurationDetailTableName2(String configurationDetailTableName2) {
|
||||
this.configurationDetailTableName2 = configurationDetailTableName2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getConfigurationMainTableName() {
|
||||
return configurationMainTableName;
|
||||
}
|
||||
|
||||
public void setConfigurationMainTableName(String configurationMainTableName) {
|
||||
this.configurationMainTableName = configurationMainTableName;
|
||||
}
|
||||
|
||||
public String getUniqueIdentification() {
|
||||
return uniqueIdentification;
|
||||
}
|
||||
|
||||
public void setUniqueIdentification(String uniqueIdentification) {
|
||||
this.uniqueIdentification = uniqueIdentification;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
@SqlMapper
|
||||
public class GMGatherSMInfoMapper {
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.Delete;
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
@ -9,29 +10,50 @@ import java.util.Map;
|
|||
|
||||
@SqlMapper
|
||||
public interface GMGatherSameSystemInfoMapper {
|
||||
|
||||
|
||||
@Select("select * from #{configurationMainTableName} where wybs = #{uniqueIdentification}")
|
||||
@Select("select * from $t{configurationMainTableName} where wybs = #{uniqueIdentification}")
|
||||
List<Map<String, Object>> getConfigInformation(@ParamMapper("configurationMainTableName") String configurationMainTableName,
|
||||
@ParamMapper("uniqueIdentification") String uniqueIdentification);
|
||||
|
||||
@Select("select * from #{configurationDetailTableName1} where mainid = #{mainid}")
|
||||
@Select("select * from $t{configurationDetailTableName1} where mainid = #{mainid}")
|
||||
List<Map<String, Object>> getConfigDetal1Information(@ParamMapper("configurationDetailTableName1")String configurationDetailTableName1,
|
||||
@ParamMapper("mainid")String mainid);
|
||||
|
||||
@Select("select * from #{configurationDetailTableName2} where mainid = #{mainid}")
|
||||
@Select("select * from $t{configurationDetailTableName2} where mainid = #{mainid}")
|
||||
List<Map<String, Object>> getConfigDetal2Information(@ParamMapper("configurationDetailTableName2")String configurationDetailTableName2,
|
||||
@ParamMapper("mainid")String mainid);
|
||||
|
||||
@Select("select * from #{ejdwtzb_name} where LEFT(modedatacreatedate,7) = LEFT(#{yesterday},7)")
|
||||
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatacreatedate,7) = LEFT(#{yesterday},7) ")
|
||||
List<Map<String, Object>> getSMCountLowGroupdata(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||
@ParamMapper("yesterday")String yesterday);
|
||||
|
||||
@Select("select * from #{ejdwtzb_name} where LEFT(modedatacreatedate,7) = LEFT(#{yesterday},7)")
|
||||
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatamodifydatetime,7) = LEFT(#{yesterday},7)")
|
||||
List<Map<String, Object>> getSMCountLowGroupDataUpdate(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||
@ParamMapper("yesterday")String yesterday);
|
||||
|
||||
@Select("select * from #{jttzbd} where htbm = #{htbm}")
|
||||
@Select("select * from $t{jttzbd} where htbm = #{htbm}")
|
||||
List<Map<String, Object>> selectHtbmData(@ParamMapper("jttzbd")String jttzbd,
|
||||
@ParamMapper("htbm")String htbm);
|
||||
|
||||
@Select("select * from $t{ejdwtzb_name}")
|
||||
List<Map<String, Object>> getSMCountLowGroupTotalData(@ParamMapper("ejdwtzb_name") String ejdwtzb_name);
|
||||
|
||||
@Select("select id from $t{jttzbd} where htbm = #{htbm}")
|
||||
String selectIdByHtbm(@ParamMapper("jttzbd")String jttzbd,
|
||||
@ParamMapper("htbm")String htbm);
|
||||
|
||||
|
||||
@Delete("delete from $t{s} where mainid = #{id}")
|
||||
boolean deleteDetalDataByMainId(@ParamMapper("s")String s,
|
||||
@ParamMapper("id")String id);
|
||||
|
||||
|
||||
@Select("select id from $t{ejdwtzb_name} where htbm = #{htbm1}")
|
||||
String selectDetailTableSouceId(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||
@ParamMapper("htbm1")String htbm1);
|
||||
|
||||
|
||||
@Select("select * from $t{s} where mainid = #{ejdw_id}")
|
||||
List<Map<String, Object>> selectDetailTableSouceData(@ParamMapper("s")String s,
|
||||
@ParamMapper("ejdw_id")String ejdw_id);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service;
|
||||
|
||||
public interface GMGatherSMInfoService {
|
||||
}
|
|
@ -7,13 +7,17 @@ import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
|
|||
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
|
||||
import aiyh.utils.sqlUtil.whereUtil.impl.PrepWhereImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
import sun.misc.BASE64Decoder;
|
||||
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper.GMGatherOtherSystemInfoMapper;
|
||||
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherOtherSystemInfoService;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import weaver.general.TimeUtil;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -37,10 +41,11 @@ public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemIn
|
|||
//连接GM下级单位暴露的接口获取台账所有的数据
|
||||
this.getEntityInsertDB(syncStandard,URL,formTableNameGM);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.error("执行数据插入逻辑异常,e:"+e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向台账中同步数据
|
||||
|
@ -59,18 +64,28 @@ public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemIn
|
|||
}
|
||||
Map<String, Object> entityMap = responeVo.getResponseMap();
|
||||
List<Map<String,Object>> datas = (List<Map<String,Object>>) entityMap.get("data");
|
||||
logger.info("从异构系统的台账中获取的一次数据datas==="+datas);
|
||||
if (datas.isEmpty()) return false;//数据为空返回:数据为空
|
||||
logger.info("同步标准,syncStandard为:"+syncStandard+"]");
|
||||
if ("1".equals(syncStandard)) {
|
||||
int failNum = 0;//失败的次数
|
||||
for (Map<String,Object> totalDataMap : datas) {
|
||||
String imagefilename = Util.null2String(totalDataMap.get("imagefilename"));
|
||||
//用于存放全部主表数据,排除所有明细表数据
|
||||
Map<String, Object> newDataMap = new HashMap<>(totalDataMap.entrySet().stream()
|
||||
.filter(entry -> !("detailData".equals(entry.getKey()) || "id".equals(entry.getKey())))
|
||||
.filter(entry -> !("detailData".equals(entry.getKey()) || "id".equals(entry.getKey()) || "imagefilename".equals(entry.getKey())))
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
Map.Entry::getValue)));
|
||||
String htbm = Util.null2String(totalDataMap.get("htbm"));
|
||||
logger.info("合同编号,htbm:["+htbm+"]");
|
||||
//处理主表中特定字段的逻辑处理
|
||||
this.dealwithLcqzyj(newDataMap,imagefilename);
|
||||
if ("".equals(htbm)){//合同编号不能为空
|
||||
continue;
|
||||
}
|
||||
int countHtbm = gmGatherOtherSystemInfoMapper.selectCountHtbm(formTableNameGM,htbm);
|
||||
logger.info("合同编号的数量,countHtbm:["+countHtbm+"]");
|
||||
RecordSet recordSet = new RecordSet();
|
||||
if (countHtbm == 0){
|
||||
int mainid = this.createmodedata(formTableNameGM, 1, newDataMap);//先插入数据id,在根据数据id,插入所有明细数据
|
||||
|
@ -95,29 +110,35 @@ public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemIn
|
|||
}else {
|
||||
//先删明细数据
|
||||
String mainid = gmGatherOtherSystemInfoMapper.selectId(formTableNameGM,htbm);
|
||||
//开始插入明细表
|
||||
List<Map<String, Object>> detailData = (List<Map<String, Object>>) totalDataMap.get("detailData");
|
||||
for (Map<String, Object> detailDatum : detailData) {
|
||||
logger.info("mainid=="+mainid);
|
||||
//先删明细数据
|
||||
boolean deleteBool = gmGatherOtherSystemInfoMapper.deleteByMainId(formTableNameGM+"_dt1",Util.null2String(mainid));
|
||||
if (deleteBool){
|
||||
logger.info("deleteBool==="+deleteBool);
|
||||
//开始插入明细表
|
||||
List<Map<String, Object>> detailData = (List<Map<String, Object>>) totalDataMap.get("detailData");
|
||||
logger.info("detailData==="+detailData);
|
||||
if (deleteBool) {
|
||||
for (Map<String, Object> detailDatum : detailData) {
|
||||
logger.info("处理完明细表之前==="+detailDatum);
|
||||
detailDatum.put("mainid",mainid);
|
||||
logger.info("处理完明细表之前==="+detailDatum);
|
||||
insertSql(formTableNameGM,detailDatum);//插入明细表
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
logger.info("数据更新失败"+failNum+"次");
|
||||
} else if ("0".equals(syncStandard)){
|
||||
for (Map<String,Object> totalDataMap : datas) {
|
||||
String imagefilename = Util.null2String(totalDataMap.get("imagefilename"));
|
||||
//用于存放全部主表数据,排除所有明细表数据
|
||||
Map<String, Object> newDataMap = new HashMap<>(totalDataMap.entrySet().stream()
|
||||
.filter(entry -> !("detailData".equals(entry.getKey()) || "id".equals(entry.getKey())))
|
||||
.filter(entry -> !("detailData".equals(entry.getKey()) || "id".equals(entry.getKey()) || "imagefilename".equals(entry.getKey())))
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
Map.Entry::getValue)));
|
||||
this.dealwithLcqzyj(newDataMap, imagefilename);
|
||||
int createmodedata = createmodedata(formTableNameGM, 1, newDataMap);
|
||||
if (createmodedata>0){
|
||||
List<Map<String, Object>> detailData = (List<Map<String, Object>>) totalDataMap.get("detailData");
|
||||
|
@ -130,10 +151,11 @@ public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemIn
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.error("异常e:"+e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 访问国密下级单位暴露的接口,获取ResponeVo
|
||||
|
@ -180,7 +202,7 @@ public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemIn
|
|||
StringBuilder updatesql = new StringBuilder("update " + tablename + " set ");
|
||||
Set<String> keySet = map.keySet();
|
||||
for (String key : keySet) {
|
||||
updatesql.append(key).append("='").append(map.get(key).toString()).append("',");
|
||||
updatesql.append(key).append("='").append(Util.null2String(map.get(key))).append("',");
|
||||
}
|
||||
if (updatesql.toString().endsWith(",")) {
|
||||
updatesql = new StringBuilder(updatesql.substring(0, updatesql.length() - 1));
|
||||
|
@ -202,9 +224,9 @@ public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemIn
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取没一张表的modeid
|
||||
* 获取每一张表的modeid
|
||||
* @param tablename 表名称
|
||||
* @return
|
||||
* @return modeid
|
||||
*/
|
||||
public Integer getModeidByTableName(String tablename) {
|
||||
RecordSet rs = new RecordSet();
|
||||
|
@ -225,8 +247,57 @@ public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemIn
|
|||
PrepSqlResultImpl prepSqlResult = builderSql.insertSql(tableName + "_dt1", datas);
|
||||
RecordSet recordSet1 = new RecordSet();
|
||||
boolean insertBool = recordSet1.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||
logger.info("明细表是否插入成功---insertBool===="+insertBool);
|
||||
if (!insertBool){
|
||||
logger.error("数据插入失败,失败SQL:["+prepSqlResult+"]");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* base64转inputStream
|
||||
* @param base64string 包含输入流的字符串
|
||||
* @return inputStream
|
||||
*/
|
||||
private static InputStream base2InputStream(String base64string) {
|
||||
ByteArrayInputStream stream = null;
|
||||
try {
|
||||
BASE64Decoder decoder = new BASE64Decoder();
|
||||
byte[] bytes1 = decoder.decodeBuffer(base64string);
|
||||
stream = new ByteArrayInputStream(bytes1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理流程签字意见字段
|
||||
* @param newDataMap 一条数据
|
||||
* @param imagefilename
|
||||
*/
|
||||
public void dealwithLcqzyj(Map<String, Object> newDataMap, String imagefilename){
|
||||
String lcqzyj = Util.null2String(newDataMap.get("lcqzyj"));//流程签字意见:需要流程存为文档
|
||||
logger.info("文件名称==="+imagefilename);
|
||||
// logger.info("流程签字意见字段,处理之前==="+lcqzyj);
|
||||
if (!"".equals(lcqzyj)&&!"-1".equals(lcqzyj)){
|
||||
InputStream inputStream = base2InputStream(lcqzyj);
|
||||
if (inputStream!=null){
|
||||
int fileByInputSteam = Util.createFileByInputSteam(inputStream, imagefilename);
|
||||
logger.info("fileByInputSteam:"+fileByInputSteam);
|
||||
int docByImageFileId;
|
||||
try {
|
||||
String path = Util.getCusConfigValue("pathKey");//配置文档存放路径
|
||||
logger.info("文档存放路径,path:["+path+"]");
|
||||
docByImageFileId = Util.createDocByImageFileId(Util.getIntValue(path), fileByInputSteam, 1);
|
||||
if (docByImageFileId>0){
|
||||
newDataMap.put("lcqzyj",docByImageFileId);
|
||||
logger.info("流程签字意见字段,docid存放成功,docid为:["+docByImageFileId+"]");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("流程签字一键字段,docid存放失败,失败原因:["+e+"]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.impl;
|
||||
|
||||
|
||||
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherSMInfoService;
|
||||
|
||||
public class GMGatherSMInfoServiceImpl implements GMGatherSMInfoService {
|
||||
}
|
|
@ -1,33 +1,32 @@
|
|||
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.impl;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.google.common.base.Joiner;
|
||||
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
|
||||
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
|
||||
import aiyh.utils.sqlUtil.whereUtil.impl.PrepWhereImpl;
|
||||
import com.weaver.formmodel.util.DateHelper;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper.GMGatherSameSystemInfoMapper;
|
||||
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherSameSystemInfoService;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import weaver.general.TimeUtil;
|
||||
import java.util.*;
|
||||
|
||||
public class GMGatherSameSystemInfoServiceImpl implements GMGatherSameSystemInfoService {
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
//sql
|
||||
//处理sql
|
||||
private final GMGatherSameSystemInfoMapper gmGatherSameSystemInfoMapper = Util.getMapper(GMGatherSameSystemInfoMapper.class);
|
||||
|
||||
/**
|
||||
* 处理从国密集团下级单位台账数据库查询数据向国密集团总台账数据库中插入或者更新数据
|
||||
* @param configurationMainTableName 配置表主表名称
|
||||
* @param configurationDetailTableName1 配置表明细表1名称
|
||||
* @param configurationDetailTableName2 配置表明细表2名称
|
||||
* @param uniqueIdentification 唯一标识
|
||||
*/
|
||||
|
||||
|
||||
//构建inser、update 的sql语句
|
||||
private final BuilderSqlImpl builderSqlImpl = new BuilderSqlImpl();
|
||||
|
||||
//日志
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
@Override
|
||||
public void dealMainLogic(String configurationMainTableName, String configurationDetailTableName1, String configurationDetailTableName2, String uniqueIdentification) {
|
||||
//第一步获取配置表中数据
|
||||
if (configurationMainTableName.equals("") && configurationDetailTableName1.equals("") && uniqueIdentification.equals("")) return;
|
||||
|
@ -37,9 +36,9 @@ public class GMGatherSameSystemInfoServiceImpl implements GMGatherSameSystemInfo
|
|||
if (configMainTableData.isEmpty()) return;
|
||||
|
||||
String jttzbd = Util.null2String(configMainTableData.get(0).get("jttzbd"));//集团台账表单
|
||||
String mainid = Util.null2String(configMainTableData.get(0).get("mainid"));
|
||||
String mainid = Util.null2String(configMainTableData.get(0).get("id"));
|
||||
logger.info("配置表主表数据---mainid---"+mainid);
|
||||
if (mainid.equals("")) return;
|
||||
if (mainid.equals("") && "".equals(jttzbd)) return;
|
||||
|
||||
//配置表明细表1数据:用来统计商密下级单位台账名称
|
||||
List<Map<String,Object>> configDetal1TableData = gmGatherSameSystemInfoMapper.getConfigDetal1Information(configurationDetailTableName1,mainid);
|
||||
|
@ -47,9 +46,15 @@ public class GMGatherSameSystemInfoServiceImpl implements GMGatherSameSystemInfo
|
|||
//明细表2数据
|
||||
List<Map<String,Object>> configDetal2TableData = gmGatherSameSystemInfoMapper.getConfigDetal2Information(configurationDetailTableName2,mainid);
|
||||
logger.info("配置表明细表数据---configDetal2TableData---"+configDetal2TableData);
|
||||
List<String> keys = new ArrayList<>();//用于insert和update的key
|
||||
List<String> mainTablekeys = new ArrayList<>();//用于存放主表中insert和update的key
|
||||
List<String> detalTablekeys = new ArrayList<>();//用于存放主表中insert和update的key
|
||||
for (Map<String, Object> configdetal2 : configDetal2TableData) {
|
||||
keys.add(Util.null2String(configdetal2.get("tbzd")));
|
||||
String sfzb = Util.null2String(configdetal2.get("sfzb"));
|
||||
if ("0".equals(sfzb)){
|
||||
mainTablekeys.add(Util.null2String(configdetal2.get("tbzd")));
|
||||
}else if ("1".equals(sfzb)){
|
||||
detalTablekeys.add(Util.null2String(configdetal2.get("tbzd")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,9 +63,19 @@ public class GMGatherSameSystemInfoServiceImpl implements GMGatherSameSystemInfo
|
|||
for (Map<String, Object> config1 : configDetal1TableData) {
|
||||
String ejdwtzb_name = Util.null2String(config1.get("ejdwtzb")); //二级单位台账表数据库名称
|
||||
String bz = Util.null2String(config1.get("bz")); //备注
|
||||
logger.info("二级单位台账表数据库名称===="+ejdwtzb_name+" 二级单位台账表数名称==="+bz);
|
||||
String tbzt = Util.null2String(config1.get("tbzt"));
|
||||
logger.info("二级单位台账表数据库名称===="+ejdwtzb_name+" 二级单位台账表数名称==="+bz+" 同步状态==="+tbzt);
|
||||
|
||||
if ("0".equals(tbzt)){
|
||||
//查询全量数据
|
||||
List<Map<String,Object>> smCountLowGroupTotalData = gmGatherSameSystemInfoMapper.getSMCountLowGroupTotalData(ejdwtzb_name);//第一次同步数据
|
||||
logger.info("全量数据---smCountLowGroupTotalData==="+smCountLowGroupTotalData);
|
||||
if (smCountLowGroupTotalData.size()>0){
|
||||
this.insertData(smCountLowGroupTotalData,jttzbd,ejdwtzb_name,mainTablekeys,detalTablekeys,tbzt);//全增量主表数据执行插入 并且包含明细表的删除,和再次添加
|
||||
}
|
||||
}else if ("1".equals(tbzt)){ //非第一次同步数据
|
||||
//获取当天日期的前一天,如果和创建时间吻合,并且满足修改时间为空那么,这条数据就是纯插入的数据
|
||||
List<Map<String,Object>> smCountLowGroupDataInsert = gmGatherSameSystemInfoMapper.getSMCountLowGroupdata(ejdwtzb_name, DateHelper.getYesterday());
|
||||
List<Map<String,Object>> smCountLowGroupDataInsert = gmGatherSameSystemInfoMapper.getSMCountLowGroupdata(ejdwtzb_name,DateHelper.getYesterday());
|
||||
logger.info("smCountLowGroupDataInsert===="+smCountLowGroupDataInsert);
|
||||
|
||||
//获取当天日期的前一天,如果和修改时间吻合,那么这条数据就是更新操作的数据
|
||||
|
@ -69,48 +84,73 @@ public class GMGatherSameSystemInfoServiceImpl implements GMGatherSameSystemInfo
|
|||
|
||||
//数据插入商密集团总台账
|
||||
if (smCountLowGroupDataInsert.size()>0){
|
||||
this.insertData(smCountLowGroupDataInsert,jttzbd,keys);
|
||||
this.insertData(smCountLowGroupDataInsert,jttzbd,ejdwtzb_name,mainTablekeys,detalTablekeys, tbzt);
|
||||
}
|
||||
//数据更新商密集团总台账
|
||||
if (smCountLowGroupDataupdate.size()>0){
|
||||
this.updateData(smCountLowGroupDataupdate,jttzbd,keys);
|
||||
}
|
||||
this.updateData(smCountLowGroupDataupdate,jttzbd,ejdwtzb_name,mainTablekeys,detalTablekeys);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>插入数据</h2>
|
||||
* @param smCountLowGroupDataInsert 插入数据集合
|
||||
* @param jttzbd 集团台账数据库名
|
||||
* @param ejdwtzb_name 二级单位数据库名
|
||||
* @param keys 需要insert的字段key
|
||||
* @param detalTablekeys 需要插入的明细表字段数据库名组成的list
|
||||
* @param tbzt 同步状态用来判断是第一次同步还是非首次同步
|
||||
* @author hcy
|
||||
* 2023/5/6 17:41
|
||||
*/
|
||||
private void insertData(List<Map<String, Object>> smCountLowGroupDataInsert, String jttzbd,List<String> keys) {
|
||||
private void insertData(List<Map<String, Object>> smCountLowGroupDataInsert, String jttzbd, String ejdwtzb_name, List<String> keys, List<String> detalTablekeys, String tbzt) {
|
||||
|
||||
RecordSet recordSet = new RecordSet();
|
||||
int successNum = 0;
|
||||
int failNum = 0;
|
||||
for (Map<String, Object> insertDatas : smCountLowGroupDataInsert) {
|
||||
String htbm = Util.null2String(insertDatas.get("htbm"));
|
||||
List<Map<String,Object>> selectHtbmData = gmGatherSameSystemInfoMapper.selectHtbmData(jttzbd,htbm);
|
||||
if (selectHtbmData.size()==0){
|
||||
|
||||
String insertKey = Joiner.on(",").join((Iterable<?>) keys);//key
|
||||
ArrayList<String> valueList = new ArrayList<>();
|
||||
// String insertKey = Joiner.on(",").join((Iterable<?>) keys);//key
|
||||
Map<String, Object> keyValueMap = new HashMap<>();
|
||||
for (String key : keys) {
|
||||
String v = Util.null2String(insertDatas.get(key));
|
||||
valueList.add(v);
|
||||
// if("htzje".equals(key) || "htjrrmb".equals(key)){
|
||||
// String o = Util.null2String(insertDatas.get(key));
|
||||
// if ("".equals(o)){
|
||||
// keyValueMap.put(key, null);
|
||||
// }else {
|
||||
// keyValueMap.put(key, o);
|
||||
// }
|
||||
// }else {
|
||||
// Object o = insertDatas.get(key);
|
||||
// keyValueMap.put(key, o);
|
||||
// }
|
||||
Object o = insertDatas.get(key);
|
||||
keyValueMap.put(key, o);
|
||||
}
|
||||
// PrepSqlResultImpl prepSqlResult = builderSqlImpl.insertSql(jttzbd, keyValueMap);
|
||||
// boolean insertBool = recordSet.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||
|
||||
String insertValue = Joiner.on(",").join((Iterable<?>) valueList);//value
|
||||
|
||||
String insertSql = "insert into "+jttzbd + "(" +insertKey + ")"+ "value " +"("+insertValue+")";//拼接插入的sql语句
|
||||
boolean insertBool = recordSet.executeQuery(insertSql);
|
||||
if (insertBool){
|
||||
logger.info("数据插入成功");
|
||||
}else{
|
||||
logger.info("数据插入失败");
|
||||
int createmodedata = createmodedata(jttzbd, 1, keyValueMap);
|
||||
if (createmodedata>0){
|
||||
String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||
deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||
}
|
||||
// if(insertBool){
|
||||
// successNum++;
|
||||
// String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||
// //执行明细表的数据删除和数据插入
|
||||
// deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||
// }else{
|
||||
// failNum++;
|
||||
// logger.error("台账数据插入失败,失败SQL:["+ prepSqlResult +"----失败次数:"+failNum+"]");
|
||||
// }
|
||||
logger.info("台账数据插入成功 "+successNum+"次");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,44 +159,161 @@ public class GMGatherSameSystemInfoServiceImpl implements GMGatherSameSystemInfo
|
|||
* <h2>更新数据</h2>
|
||||
* @param smCountLowGroupDataupdate 更新语句集合
|
||||
* @param jttzbd 集团台账数据库名
|
||||
* @param ejdwtzb_name 二级单位数据库名
|
||||
* @param keys 数据更新的key组成的集合
|
||||
* @param detalTablekeys 需要插入的明细表字段数据库名组成的list
|
||||
* @author hcy
|
||||
* 2023/5/6 17:40
|
||||
*/
|
||||
|
||||
private void updateData(List<Map<String, Object>> smCountLowGroupDataupdate, String jttzbd, List<String> keys) {
|
||||
try {
|
||||
|
||||
private void updateData(List<Map<String, Object>> smCountLowGroupDataupdate, String jttzbd, String ejdwtzb_name, List<String> keys, List<String> detalTablekeys) {
|
||||
RecordSet recordSet = new RecordSet();
|
||||
int failNum = 0;
|
||||
int successNum = 0;
|
||||
for (Map<String, Object> updateDates : smCountLowGroupDataupdate) {
|
||||
String htbm = Util.null2String(updateDates.get("htbm"));
|
||||
List<Map<String, Object>> updateDatas = gmGatherSameSystemInfoMapper.selectHtbmData(jttzbd, htbm);
|
||||
if (updateDatas.size()>0){
|
||||
//拼接sql
|
||||
List<String> updateValueList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
String value = Util.null2String(updateDates.get(key));
|
||||
updateValueList.add(value);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
Joiner.on(", ").appendTo(builder, keys);
|
||||
builder.append(" = ");
|
||||
Joiner.on(", ").appendTo(builder, updateValueList);
|
||||
|
||||
|
||||
String updateSql = "update "+jttzbd + "set " + builder + " where htbm = ?";
|
||||
boolean updateBool = recordSet.executeQuery(updateSql, htbm);
|
||||
if (updateBool){
|
||||
logger.info("======数据更新成功======");
|
||||
List<Map<String, Object>> selecthtbmData = gmGatherSameSystemInfoMapper.selectHtbmData(jttzbd, htbm);
|
||||
if (selecthtbmData.size()>0){
|
||||
Map<String, Object> keyValueMap = getKeyValueMap(updateDates, keys);
|
||||
PrepWhereImpl prepWhere = new PrepWhereImpl();
|
||||
prepWhere.whereAnd("htbm = ?");
|
||||
prepWhere.addArgs(htbm);
|
||||
PrepSqlResultImpl prepSqlResult = builderSqlImpl.updateSql(jttzbd, keyValueMap, prepWhere);
|
||||
boolean insertBool = recordSet.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||
if (insertBool){
|
||||
String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||
//执行明细表的数据删除和数据插入
|
||||
deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||
successNum++;
|
||||
}else {
|
||||
logger.info("======数据更新失败======");
|
||||
failNum++;
|
||||
logger.error("台账数据更新失败,SQL:["+ prepSqlResult +"------失败次数:"+failNum+"]");
|
||||
}
|
||||
logger.info("台账数据更新成功 "+successNum + "次");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于封装insert或者update的key,value的map集合
|
||||
* @param datas 数据源
|
||||
* @param keys 需要更新或者插入的keys
|
||||
* @return 预期的key,value对应的map集合
|
||||
*/
|
||||
public Map<String, Object> getKeyValueMap(Map<String, Object> datas ,List<String> keys){
|
||||
Map<String, Object> keyValueMap = new HashMap<>();
|
||||
for (String key : keys) {
|
||||
String v = Util.null2String(datas.get(key));
|
||||
keyValueMap.put(key, v);
|
||||
}
|
||||
return keyValueMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除并插入明细表中的数据
|
||||
* @param htbm1 合同编号用来作为唯一标识
|
||||
* @param jttzbd 商密集团台账数据库名称
|
||||
* @param ejdwtzb_name 二级单位名称
|
||||
* @param detalTablekeys 需要插入的明细表字段数据库名组成的list
|
||||
*/
|
||||
public void deleteAndInsertDetailTable(String htbm1,String jttzbd,String ejdwtzb_name,List<String> detalTablekeys){
|
||||
|
||||
try {
|
||||
RecordSet insertDatailRS = new RecordSet();
|
||||
//执行明细表的插入语句
|
||||
String id = gmGatherSameSystemInfoMapper.selectIdByHtbm(jttzbd,htbm1);
|
||||
int successNum = 0;
|
||||
int failNum = 0;
|
||||
if (!"".equals(id)){
|
||||
boolean deleteBool = gmGatherSameSystemInfoMapper.deleteDetalDataByMainId(jttzbd+"_dt1",id);//明细表插入数据之前,先执行删除语句
|
||||
if (deleteBool){
|
||||
//执行明细表插入逻辑
|
||||
String ejdw_id = gmGatherSameSystemInfoMapper.selectDetailTableSouceId(ejdwtzb_name,htbm1);
|
||||
List<Map<String,Object>> souceDetailDatas = gmGatherSameSystemInfoMapper.selectDetailTableSouceData(ejdwtzb_name+"_dt1",ejdw_id);
|
||||
if (souceDetailDatas.size()==0) return;
|
||||
for (Map<String, Object> souceDetailData : souceDetailDatas) {
|
||||
Map<String, Object> dealwithData = new HashMap<>();//根据配置表处理完需要字段后的数据Map
|
||||
for (String key : detalTablekeys) {
|
||||
dealwithData.put(key,souceDetailData.get(key));
|
||||
}
|
||||
//将mainid拼进去
|
||||
dealwithData.put("mainid",id);
|
||||
//开始插入明细表数据
|
||||
PrepSqlResultImpl prepSqlResult = builderSqlImpl.insertSql(jttzbd+"_dt1", dealwithData);
|
||||
boolean detailInsertBool = insertDatailRS.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||
if (detailInsertBool){
|
||||
successNum++;
|
||||
}else {
|
||||
failNum++;
|
||||
logger.error("明细表数据插入失败,SQL:["+prepSqlResult+"------失败次数:"+failNum+"]");
|
||||
}
|
||||
logger.info("明细表数据插入成功数量:"+successNum);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("----GMGatherSameSystemInfoServiceImpl----smCountLowGroupDataupdate----异常如下===="+e);
|
||||
logger.error("报错=="+e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法描述 : 将数据插入表单建模
|
||||
* @param tablename 建模表明
|
||||
* @param userid 创建人id
|
||||
* @param map 数据map
|
||||
* @return int 返回数据id
|
||||
*/
|
||||
public int createmodedata(String tablename, int userid, Map<String, Object> map) {
|
||||
Integer modeid = getModeidByTableName(tablename);
|
||||
int dataid = 0;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String uuid = map.containsKey("modeuuid") ? map.get("modeuuid").toString() : UUID.randomUUID().toString();
|
||||
boolean flag = rs.execute("insert into " + tablename
|
||||
+ "(modeuuid,modedatacreater,modedatacreatedate,modedatacreatetime,formmodeid) values('" + uuid + "',"
|
||||
+ userid + ",'" + TimeUtil.getCurrentDateString() + "','" + TimeUtil.getOnlyCurrentTimeString() + "',"
|
||||
+ modeid + ")");
|
||||
if (flag) {
|
||||
rs.execute("select id from " + tablename + " where modeuuid='" + uuid + "'");
|
||||
rs.next();
|
||||
dataid = weaver.general.Util.getIntValue(rs.getString("id"));
|
||||
|
||||
if (dataid > 0) {
|
||||
// 遍历数据 进行update
|
||||
String updatesql = "update " + tablename + " set ";
|
||||
Set<String> keySet = map.keySet();
|
||||
for (String key : keySet) {
|
||||
updatesql += key + "='" + map.get(key).toString() + "',";
|
||||
}
|
||||
if (updatesql.endsWith(",")) {
|
||||
updatesql = updatesql.substring(0, updatesql.length() - 1);
|
||||
|
||||
updatesql += " where id=" + dataid;
|
||||
boolean execute = rs.execute(updatesql);
|
||||
if(!execute){
|
||||
logger.info("出错的sql==="+updatesql);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 进行权限重构
|
||||
*/
|
||||
ModeRightInfo moderight = new ModeRightInfo();
|
||||
moderight.editModeDataShare(userid, modeid, dataid);
|
||||
}
|
||||
}
|
||||
|
||||
return dataid;
|
||||
}
|
||||
|
||||
|
||||
public static Integer getModeidByTableName(String tablename) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "select b.TABLENAME,a.FORMID,a.id modeid from modeinfo a left join workflow_bill b on a.FORMID=b.id where b.TABLENAME= '"
|
||||
+ tablename + "'";
|
||||
rs.execute(sql);
|
||||
rs.next();
|
||||
return Math.abs(rs.getInt("modeid"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ public interface SMCountLowGroupDataMapper {
|
|||
List<Map<String, Object>> getConfigDetal2Information(@ParamMapper("configurationDetailTableName2")String configurationDetailTableName2,
|
||||
@ParamMapper("mainid")String mainid);
|
||||
|
||||
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatacreatedate,7) = LEFT(#{yesterday},7) ")
|
||||
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatacreatedate,10) = LEFT(#{yesterday},10) ")
|
||||
List<Map<String, Object>> getSMCountLowGroupdata(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||
@ParamMapper("yesterday")String yesterday);
|
||||
|
||||
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatamodifydatetime,7) = LEFT(#{yesterday},7)")
|
||||
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatamodifydatetime,10) = #{yesterday}")
|
||||
List<Map<String, Object>> getSMCountLowGroupDataUpdate(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||
@ParamMapper("yesterday")String yesterday);
|
||||
|
||||
|
|
|
@ -77,16 +77,21 @@ public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataServic
|
|||
if ("0".equals(tbzt)){
|
||||
//查询全量数据
|
||||
List<Map<String,Object>> smCountLowGroupTotalData = smCountLowGroupDataMapper.getSMCountLowGroupTotalData(ejdwtzb_name);//第一次同步数据
|
||||
logger.info("查询到的全量数据,smCountLowGroupTotalData:["+smCountLowGroupTotalData+"]");
|
||||
if (smCountLowGroupTotalData.size()>0){
|
||||
this.insertData(smCountLowGroupTotalData,jttzbd,ejdwtzb_name,mainTablekeys,detalTablekeys,tbzt);//全增量主表数据执行插入 并且包含明细表的删除,和再次添加
|
||||
}
|
||||
}else if ("1".equals(tbzt)){ //非第一次同步数据
|
||||
//获取当天日期的前一天,如果和创建时间吻合,并且满足修改时间为空那么,这条数据就是纯插入的数据
|
||||
String yesterday = DateHelper.getYesterday();
|
||||
List<Map<String,Object>> smCountLowGroupDataInsert = smCountLowGroupDataMapper.getSMCountLowGroupdata(ejdwtzb_name,DateHelper.getYesterday());
|
||||
logger.info("smCountLowGroupDataInsert===="+smCountLowGroupDataInsert);
|
||||
|
||||
//获取当天日期的前一天,如果和修改时间吻合,那么这条数据就是更新操作的数据
|
||||
|
||||
logger.info("yesterday:"+yesterday);
|
||||
List<Map<String,Object>> smCountLowGroupDataupdate = smCountLowGroupDataMapper.getSMCountLowGroupDataUpdate(ejdwtzb_name,DateHelper.getYesterday());
|
||||
|
||||
logger.info("smCountLowGroupDataupdate===="+smCountLowGroupDataupdate);
|
||||
|
||||
//数据插入商密集团总台账
|
||||
|
@ -116,47 +121,27 @@ public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataServic
|
|||
*/
|
||||
private void insertData(List<Map<String, Object>> smCountLowGroupDataInsert, String jttzbd, String ejdwtzb_name, List<String> keys, List<String> detalTablekeys, String tbzt) {
|
||||
|
||||
RecordSet recordSet = new RecordSet();
|
||||
int successNum = 0;
|
||||
int failNum = 0;
|
||||
for (Map<String, Object> insertDatas : smCountLowGroupDataInsert) {
|
||||
String htbm = Util.null2String(insertDatas.get("htbm"));
|
||||
logger.info("htbm:["+htbm+"]");
|
||||
List<Map<String,Object>> selectHtbmData = smCountLowGroupDataMapper.selectHtbmData(jttzbd,htbm);
|
||||
logger.info("selectHtbmData:["+selectHtbmData+"]");
|
||||
if (selectHtbmData.size()==0){
|
||||
// String insertKey = Joiner.on(",").join((Iterable<?>) keys);//key
|
||||
Map<String, Object> keyValueMap = new HashMap<>();
|
||||
for (String key : keys) {
|
||||
// if("htzje".equals(key) || "htjrrmb".equals(key)){
|
||||
// String o = Util.null2String(insertDatas.get(key));
|
||||
// if ("".equals(o)){
|
||||
// keyValueMap.put(key, null);
|
||||
// }else {
|
||||
// keyValueMap.put(key, o);
|
||||
// }
|
||||
// }else {
|
||||
// Object o = insertDatas.get(key);
|
||||
// keyValueMap.put(key, o);
|
||||
// }
|
||||
Object o = insertDatas.get(key);
|
||||
keyValueMap.put(key, o);
|
||||
}
|
||||
// PrepSqlResultImpl prepSqlResult = builderSqlImpl.insertSql(jttzbd, keyValueMap);
|
||||
// boolean insertBool = recordSet.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||
|
||||
logger.info("keyValueMap:["+keyValueMap+"]"+"jttzbd:["+jttzbd+"]");
|
||||
int createmodedata = createmodedata(jttzbd, 1, keyValueMap);
|
||||
logger.info("createmodedata:["+createmodedata+"]");
|
||||
if (createmodedata>0){
|
||||
String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||
logger.info("htbm1:["+htbm1+"]");
|
||||
deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||
successNum++;
|
||||
}
|
||||
// if(insertBool){
|
||||
// successNum++;
|
||||
// String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||
// //执行明细表的数据删除和数据插入
|
||||
// deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||
// }else{
|
||||
// failNum++;
|
||||
// logger.error("台账数据插入失败,失败SQL:["+ prepSqlResult +"----失败次数:"+failNum+"]");
|
||||
// }
|
||||
logger.info("台账数据插入成功 "+successNum+"次");
|
||||
|
||||
}
|
||||
|
@ -173,7 +158,6 @@ public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataServic
|
|||
* @author hcy
|
||||
* 2023/5/6 17:40
|
||||
*/
|
||||
|
||||
private void updateData(List<Map<String, Object>> smCountLowGroupDataupdate, String jttzbd, String ejdwtzb_name, List<String> keys, List<String> detalTablekeys) {
|
||||
RecordSet recordSet = new RecordSet();
|
||||
int failNum = 0;
|
||||
|
@ -229,15 +213,20 @@ public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataServic
|
|||
try {
|
||||
RecordSet insertDatailRS = new RecordSet();
|
||||
//执行明细表的插入语句
|
||||
logger.info("htbm1:["+htbm1+"] jttzbd:["+jttzbd+"] ejdwtzb_name:["+ejdwtzb_name+"] detalTablekeys:["+detalTablekeys+"]");
|
||||
String id = smCountLowGroupDataMapper.selectIdByHtbm(jttzbd,htbm1);
|
||||
logger.info("id:["+id+"]");
|
||||
int successNum = 0;
|
||||
int failNum = 0;
|
||||
if (!"".equals(id)){
|
||||
boolean deleteBool = smCountLowGroupDataMapper.deleteDetalDataByMainId(jttzbd+"_dt1",id);//明细表插入数据之前,先执行删除语句
|
||||
logger.info("是否删除成功deleteBool:["+deleteBool+"]");
|
||||
if (deleteBool){
|
||||
//执行明细表插入逻辑
|
||||
String ejdw_id = smCountLowGroupDataMapper.selectDetailTableSouceId(ejdwtzb_name,htbm1);
|
||||
logger.info("ejdw_id:["+ejdw_id+"]");
|
||||
List<Map<String,Object>> souceDetailDatas = smCountLowGroupDataMapper.selectDetailTableSouceData(ejdwtzb_name+"_dt1",ejdw_id);
|
||||
logger.info("souceDetailDatas:["+souceDetailDatas+"]");
|
||||
if (souceDetailDatas.size()==0) return;
|
||||
for (Map<String, Object> souceDetailData : souceDetailDatas) {
|
||||
Map<String, Object> dealwithData = new HashMap<>();//根据配置表处理完需要字段后的数据Map
|
||||
|
@ -246,9 +235,11 @@ public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataServic
|
|||
}
|
||||
//将mainid拼进去
|
||||
dealwithData.put("mainid",id);
|
||||
logger.info("dealwithData:["+dealwithData+"]");
|
||||
//开始插入明细表数据
|
||||
PrepSqlResultImpl prepSqlResult = builderSqlImpl.insertSql(jttzbd+"_dt1", dealwithData);
|
||||
boolean detailInsertBool = insertDatailRS.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||
logger.info("detailInsertBool:["+detailInsertBool+"]");
|
||||
if (detailInsertBool){
|
||||
successNum++;
|
||||
}else {
|
||||
|
@ -274,32 +265,42 @@ public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataServic
|
|||
* @return int 返回数据id
|
||||
*/
|
||||
public int createmodedata(String tablename, int userid, Map<String, Object> map) {
|
||||
try {
|
||||
Integer modeid = getModeidByTableName(tablename);
|
||||
logger.info("modeid:["+modeid+"]");
|
||||
int dataid = 0;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String uuid = map.containsKey("modeuuid") ? map.get("modeuuid").toString() : UUID.randomUUID().toString();
|
||||
boolean flag = rs.execute("insert into " + tablename
|
||||
logger.info("uuid:["+uuid+"]");
|
||||
String insertSql = "insert into " + tablename
|
||||
+ "(modeuuid,modedatacreater,modedatacreatedate,modedatacreatetime,formmodeid) values('" + uuid + "',"
|
||||
+ userid + ",'" + TimeUtil.getCurrentDateString() + "','" + TimeUtil.getOnlyCurrentTimeString() + "',"
|
||||
+ modeid + ")");
|
||||
+ modeid + ")";
|
||||
logger.info("insertSql:["+insertSql+"]");
|
||||
boolean flag = rs.execute(insertSql);
|
||||
logger.info("flag:["+flag+"]");
|
||||
if (flag) {
|
||||
rs.execute("select id from " + tablename + " where modeuuid='" + uuid + "'");
|
||||
rs.next();
|
||||
dataid = weaver.general.Util.getIntValue(rs.getString("id"));
|
||||
logger.info("dataid:["+dataid+"]");
|
||||
|
||||
if (dataid > 0) {
|
||||
// 遍历数据 进行update
|
||||
String updatesql = "update " + tablename + " set ";
|
||||
logger.info("updatesql:["+updatesql+"]");
|
||||
Set<String> keySet = map.keySet();
|
||||
for (String key : keySet) {
|
||||
updatesql += key + "='" + map.get(key).toString() + "',";
|
||||
updatesql += key + "='" + Util.null2String(map.get(key)) + "',";
|
||||
}
|
||||
logger.info("updatesql:["+updatesql+"]");
|
||||
if (updatesql.endsWith(",")) {
|
||||
updatesql = updatesql.substring(0, updatesql.length() - 1);
|
||||
|
||||
updatesql += " where id=" + dataid;
|
||||
logger.info("updatesql:["+updatesql+"]");
|
||||
boolean execute = rs.execute(updatesql);
|
||||
logger.info("execute:["+execute+"]");
|
||||
if(!execute){
|
||||
logger.info("出错的sql==="+updatesql);
|
||||
}
|
||||
|
@ -313,6 +314,11 @@ public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataServic
|
|||
}
|
||||
|
||||
return dataid;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("更新报错,e:["+e+"]");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package weaver.xuanran.wang.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import weaver.xuanran.wang.common.service.CusDataDecipher;
|
||||
|
||||
|
||||
/**
|
||||
* <h1>自定义请求条件</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/4/6 19:34
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CusSuccess {
|
||||
private String successField;
|
||||
private Object successValue;
|
||||
private String errorMsg;
|
||||
private String dataKey;
|
||||
private Object response;
|
||||
private CusDataDecipher cusDataDecipher;
|
||||
}
|
|
@ -121,4 +121,7 @@ public interface CommonMapper {
|
|||
|
||||
@BatchUpdate(custom = true)
|
||||
boolean updateModelInfoList(@SqlString String sql, @BatchSqlArgs List<Map<String, Object>> params);
|
||||
|
||||
@BatchInsert(custom = true)
|
||||
boolean batchInsertModel(@SqlString String sql,@BatchSqlArgs List<Map<String, Object>> collect);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package weaver.xuanran.wang.common.service;
|
||||
|
||||
import aiyh.utils.httpUtil.ResponeVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>自定义解密类</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/4/10 13:20
|
||||
*/
|
||||
public interface CusDataDecipher {
|
||||
Map<String, Object> decoder(ResponeVo responeVo);
|
||||
}
|
|
@ -708,5 +708,20 @@ public class CommonUtil {
|
|||
return tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>构建get url</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/8 16:51
|
||||
* @param url 接口地址
|
||||
* @param query 请求参数
|
||||
* @return url
|
||||
**/
|
||||
public static String buildGetUrl(String url, Map<String, Object> query){
|
||||
StringBuilder sb = new StringBuilder(url + "?");
|
||||
for (Map.Entry<String, Object> entry : query.entrySet()) {
|
||||
sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
||||
}
|
||||
return sb.substring(0, sb.lastIndexOf("&"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
package weaver.xuanran.wang.common.util;
|
||||
|
||||
import aiyh.utils.ThreadPoolConfig;
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.annotation.recordset.BatchUpdate;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.general.TimeUtil;
|
||||
import org.apache.axis2.databinding.types.xsd._float;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.formmode.data.ModeDataIdUpdate;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import weaver.xuanran.wang.common.mapper.CommonMapper;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* <h1>自定义数据写入oa</h1>
|
||||
|
@ -26,24 +33,25 @@ public class CusData2OA {
|
|||
private static final Logger log = Util.getLogger();
|
||||
private static final String TABLE_NAME_PLACEHOLDER = "#\\{tableName}";
|
||||
|
||||
private static final ExecutorService threadPoolInstance = ThreadPoolConfig.createThreadPoolInstance();
|
||||
|
||||
public static String writeToModel(String modelId, String uniqueSql, Map<String, Object> params){
|
||||
return baseExecute(modelId, uniqueSql, Collections.singletonList(params)).get(0);
|
||||
return baseExecute(modelId, uniqueSql, Collections.singletonList(params), null).get(0);
|
||||
}
|
||||
|
||||
public static String writeToModel(String modelId, Map<String, Object> params){
|
||||
return baseExecute(modelId, "", Collections.singletonList(params)).get(0);
|
||||
return baseExecute(modelId, "", Collections.singletonList(params), null).get(0);
|
||||
}
|
||||
|
||||
public static List<String> batchWriteToModel(String modelId, List<Map<String, Object>> params){
|
||||
return baseExecute(modelId, "", params);
|
||||
public static List<String> batchWriteToModel(String modelId, List<Map<String, Object>> params, CountDownLatch latch){
|
||||
return baseExecute(modelId, "", params, latch);
|
||||
}
|
||||
|
||||
public static List<String> batchWriteToModel(String modelId, String uniqueSql, List<Map<String, Object>> params){
|
||||
return baseExecute(modelId, uniqueSql, params);
|
||||
return baseExecute(modelId, uniqueSql, params, null);
|
||||
}
|
||||
|
||||
@BatchUpdate
|
||||
public static List<String> baseExecute(String modelId, String uniqueSql, List<Map<String, Object>> params){
|
||||
public static List<String> baseExecute(String modelId, String uniqueSql, List<Map<String, Object>> params, CountDownLatch latch){
|
||||
int modelIdInt = Util.getIntValue(modelId, -1);
|
||||
String tableName = CommonUtil.checkModelId(modelIdInt);
|
||||
if(modelIdInt < 0 || StringUtils.isBlank(tableName)){
|
||||
|
@ -51,39 +59,99 @@ public class CusData2OA {
|
|||
}
|
||||
uniqueSql = Util.sbc2dbcCase(uniqueSql);
|
||||
uniqueSql = uniqueSql.replaceAll(TABLE_NAME_PLACEHOLDER, tableName);
|
||||
String modelDataId = "";
|
||||
List<String> delList = new ArrayList<>();
|
||||
List<String> modelDataList = new ArrayList<>();
|
||||
String updateSql = "";
|
||||
|
||||
for (Map<String, Object> param : params) {
|
||||
log.info("写入日志参数 : " + com.alibaba.fastjson.JSONObject.toJSONString(param));
|
||||
String modelDataId = Util.null2DefaultStr(param.get("id"),"");
|
||||
if(StringUtils.isNotBlank(uniqueSql)){
|
||||
modelDataId = commonMapper.selectCustomerSql(uniqueSql, param);
|
||||
}
|
||||
if(StringUtils.isBlank(modelDataId)){
|
||||
modelDataId = Util.null2DefaultStr(Util.getModeDataId(tableName, modelIdInt, 1),"");
|
||||
delList.add(modelDataId);
|
||||
Util.rebuildModeDataShare(1, tableName, Util.getIntValue(modelDataId, -1));
|
||||
param.put("id",modelDataId);
|
||||
}
|
||||
if(StringUtils.isBlank(updateSql)){
|
||||
updateSql = buildUpdateSql(tableName, param);
|
||||
}
|
||||
param.put("id",modelDataId);
|
||||
modelDataList.add(modelDataId);
|
||||
}
|
||||
try {
|
||||
log.info("updateSql => " + updateSql);
|
||||
if (!commonMapper.updateModelInfoList(updateSql, params)) {
|
||||
throw new CustomerException("update model data sql execute error!");
|
||||
}
|
||||
threadPoolInstance.submit(()->{
|
||||
log.info("需要重构的数据 : " + JSONObject.toJSONString(modelDataList));
|
||||
for (String id : modelDataList) {
|
||||
if(StringUtils.isBlank(id)){
|
||||
continue;
|
||||
}
|
||||
Util.rebuildModeDataShare(1, tableName, Util.getIntValue(id, -1));
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
CommonUtil.deleteDataByIds(delList, tableName);
|
||||
throw new CustomerException(e);
|
||||
}
|
||||
if(latch != null){
|
||||
for (int i = 0; i < modelDataList.size(); i++) {
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
return modelDataList;
|
||||
}
|
||||
|
||||
public static void baseInsertAndUpdate(String modelId, List<Map<String, Object>> params, CountDownLatch latch){
|
||||
int modelIdInt = Util.getIntValue(modelId, -1);
|
||||
String tableName = CommonUtil.checkModelId(modelIdInt);
|
||||
if(modelIdInt < 0 || StringUtils.isBlank(tableName)){
|
||||
throw new CustomerException("modelId can not < 0 or modelTableName can not empty!");
|
||||
}
|
||||
String updateSql = "";
|
||||
String insertSql = "";
|
||||
List<Map<String, Object>> updateParams = new ArrayList<>();
|
||||
List<Map<String, Object>> insertParams = new ArrayList<>();
|
||||
for (Map<String, Object> param : params) {
|
||||
String modelDataId = Util.null2DefaultStr(param.get("id"),"");
|
||||
if(StringUtils.isBlank(modelDataId)){
|
||||
insertParams.add(param);
|
||||
param.put("modedatacreater","1");
|
||||
param.put("formmodeid", modelId);
|
||||
param.put("modedatacreatedate", TimeUtil.getCurrentDateString());
|
||||
param.put("modedatacreatetime", TimeUtil.getOnlyCurrentTimeString());
|
||||
}else {
|
||||
updateParams.add(param);
|
||||
}
|
||||
if(StringUtils.isBlank(updateSql)){
|
||||
updateSql = buildUpdateSql(tableName, param);
|
||||
}
|
||||
if(StringUtils.isBlank(insertSql)){
|
||||
insertSql = buildInsertSql(tableName, modelId, param);
|
||||
}
|
||||
}
|
||||
try {
|
||||
if(CollectionUtils.isNotEmpty(updateParams)){
|
||||
if (!commonMapper.updateModelInfoList(updateSql, params)) {
|
||||
throw new CustomerException("update model data sql execute error!");
|
||||
}
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(insertParams)){
|
||||
if (!commonMapper.batchInsertModel(insertSql, params)) {
|
||||
throw new CustomerException("insert model data sql execute error!");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
throw new CustomerException(e);
|
||||
}finally {
|
||||
if(latch != null){
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String buildUpdateSql(String tableName, Map<String, Object> params) {
|
||||
StringBuilder sqlSb = new StringBuilder("update ")
|
||||
.append(tableName)
|
||||
|
@ -98,4 +166,23 @@ public class CusData2OA {
|
|||
sqlSb.append(" where id = #{item.id}");
|
||||
return sqlSb.toString();
|
||||
}
|
||||
|
||||
public static String buildInsertSql(String tableName, String modelId,Map<String, Object> params) {
|
||||
StringBuilder sqlSb = new StringBuilder("insert into ")
|
||||
.append(tableName)
|
||||
.append(" (");
|
||||
StringBuilder fields = new StringBuilder();
|
||||
StringBuilder values = new StringBuilder();
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
fields.append(entry.getKey()).append(",");
|
||||
values.append("#{item.")
|
||||
.append(entry.getKey())
|
||||
.append("}")
|
||||
.append(",");
|
||||
}
|
||||
fields.deleteCharAt(fields.length() - 1);
|
||||
values.deleteCharAt(values.length() - 1);
|
||||
sqlSb.append(fields).append(" ) ").append(" values ( ").append(values).append(" )");
|
||||
return sqlSb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package weaver.xuanran.wang.common.util;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.httpUtil.ResponeVo;
|
||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>请求模版方法</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/4/4 11:51
|
||||
*/
|
||||
public class RequestMasterPlate {
|
||||
private final Logger log = Util.getLogger();
|
||||
private final HttpUtils httpUtils = new HttpUtils();
|
||||
private static final int HTTP_SUCCESS_CODE = 200;
|
||||
|
||||
public <T> T apiGet(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess){
|
||||
ResponeVo responeVo;
|
||||
try {
|
||||
responeVo = httpUtils.apiGet(url, params, headers);
|
||||
} catch (IOException e) {
|
||||
throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||
}
|
||||
return parseResponse(url, responeVo, params, cusSuccess);
|
||||
}
|
||||
|
||||
public <T> T apiPost(String url, Object o, Map<String, String> headers, CusSuccess cusSuccess){
|
||||
ResponeVo responeVo;
|
||||
try {
|
||||
responeVo = httpUtils.apiPostObject(url, o, headers);
|
||||
} catch (IOException e) {
|
||||
throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||
}
|
||||
return parseResponse(url, responeVo, o, cusSuccess);
|
||||
}
|
||||
|
||||
public <T> T parseResponse(String url, ResponeVo responseVo, Object o, CusSuccess cusSuccess){
|
||||
if (responseVo.getCode() != HTTP_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(o), JSON.toJSONString(httpUtils.getGlobalCache().header), responseVo.getCode(), // 相应状态码
|
||||
responseVo.getEntityString())); // 相应内容
|
||||
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||
}
|
||||
Map<String, Object> response;
|
||||
if(cusSuccess.getCusDataDecipher() != null){
|
||||
response = cusSuccess.getCusDataDecipher().decoder(responseVo);
|
||||
}else {
|
||||
response = responseVo.getResponseMap(); // 根据相应结果转化为map集合
|
||||
}
|
||||
cusSuccess.setResponse(response);
|
||||
String responseValue = Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), "");
|
||||
if (!responseValue.equals(Util.null2DefaultStr(cusSuccess.getSuccessValue(),""))) {
|
||||
throw new CustomerException(Util.logStr("接口地址:[{}], 接口响应码不为: [{}], 接口响应信息: {}", url, cusSuccess.getSuccessValue(), Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||
}
|
||||
String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\.");
|
||||
int len = split.length;
|
||||
if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){
|
||||
return (T)response;
|
||||
}
|
||||
for (int i = 0; i < len - 1; i++) {
|
||||
response = (Map) response.get(split[i]);
|
||||
}
|
||||
return (T) response.get(split[len - 1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package weaver.xuanran.wang.eny.data_async.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <h1>安永 - 建模数据同步配置明细表对象</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/8 15:21
|
||||
*/
|
||||
@Data
|
||||
public class DataAsyncConfigDetail {
|
||||
private String interface_field;
|
||||
private String model_field;
|
||||
private int get_value_type;
|
||||
private String value_context;
|
||||
private int primary_key;
|
||||
private String model_field_name;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package weaver.xuanran.wang.eny.data_async.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>安永 - 建模数据同步配置主表对象</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/8 15:21
|
||||
*/
|
||||
@Data
|
||||
public class DataAsyncConfigMain {
|
||||
private String model_id;
|
||||
private String model_table;
|
||||
private String async_url;
|
||||
private String only_mark;
|
||||
private String unique_sql;
|
||||
private String remark;
|
||||
private String table_name;
|
||||
private List<DataAsyncConfigDetail> configDetailList;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package weaver.xuanran.wang.eny.data_async.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <h1>token实体类</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/4/7 23:29
|
||||
*/
|
||||
@Data
|
||||
public class EyDataAsyncCusToken {
|
||||
/**
|
||||
* <h2>token</h2>
|
||||
**/
|
||||
private String accessToken;
|
||||
/**
|
||||
* <h2>过期时间戳</h2>
|
||||
**/
|
||||
private long expiresTime;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package weaver.xuanran.wang.eny.data_async.job;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.annotation.PrintParamMark;
|
||||
import aiyh.utils.annotation.RequiredMark;
|
||||
import lombok.Setter;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain;
|
||||
import weaver.xuanran.wang.eny.data_async.service.DataAsyncServiceImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* <h1>安永 接口数据同步到建模</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/8 15:17
|
||||
*/
|
||||
@Setter
|
||||
public class ModelDataAsyncJob extends BaseCronJob {
|
||||
|
||||
@RequiredMark(desc = "配置唯一标识")
|
||||
@PrintParamMark
|
||||
private String onlyMark;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark(desc = "token地址")
|
||||
private String tokenUrl;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark(desc = "clientId")
|
||||
private String clientId;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark(desc = "appId")
|
||||
private String appId;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark(desc = "appSecret")
|
||||
private String appSecret;
|
||||
|
||||
@PrintParamMark
|
||||
private String pageSize;
|
||||
|
||||
@PrintParamMark
|
||||
private String pageNo;
|
||||
|
||||
@PrintParamMark
|
||||
private String debug;
|
||||
|
||||
private final DataAsyncServiceImpl dataAsyncService = new DataAsyncServiceImpl();
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
Util.verifyRequiredField(this);
|
||||
dataAsyncService.setPageSize(Util.getIntValue(pageSize, 500));
|
||||
dataAsyncService.setPageNo(Util.getIntValue(pageNo, 1));
|
||||
dataAsyncService.setClientId(clientId);
|
||||
dataAsyncService.setDebug(debug);
|
||||
DataAsyncConfigMain config = dataAsyncService.getConfig(onlyMark);
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("clientId", clientId);
|
||||
params.put("appId", appId);
|
||||
params.put("appSecret", appSecret);
|
||||
dataAsyncService.asyncData(config, tokenUrl, params);
|
||||
}catch (Exception e){
|
||||
log.error("同步接口数据异常 : " + e.getMessage());
|
||||
log.error(Util.getErrString(e));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package weaver.xuanran.wang.eny.data_async.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>安永 - 建模数据同步 mapper</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/8 15:25
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface DataAsyncMapper {
|
||||
@Select("SELECT a.*,b.tablename as table_name, c.id as model_id " +
|
||||
"FROM uf_ey_data_async a " +
|
||||
"left join workflow_mode_table_view b " +
|
||||
"on a.model_table = b.id " +
|
||||
"left join modeinfo c " +
|
||||
"on a.model_table = c.formid " +
|
||||
"where only_mark = #{onlyMark}")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(property = "configDetailList",
|
||||
column = "id",
|
||||
id = @Id(value = Integer.class, methodId = 1))
|
||||
})
|
||||
DataAsyncConfigMain selectConfigByOnlyMark(@ParamMapper("onlyMark") String onlyMark);
|
||||
|
||||
/**
|
||||
* <h1>查询配置表明细表信息</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/3/1 16:39
|
||||
* @param mainId 主表数据id
|
||||
* @return 配置集合
|
||||
**/
|
||||
@Select("select a.*,b.fieldname model_field_name from uf_ey_data_async_dt1 a " +
|
||||
"left join workflow_field_table_view b " +
|
||||
"on a.model_field = b.id " +
|
||||
"where mainid = #{mainId} and enable = 0")
|
||||
@CollectionMethod(1)
|
||||
List<DataAsyncConfigDetail> selectConfigDetail(@ParamMapper("mainId") int mainId);
|
||||
|
||||
@Select(custom = true)
|
||||
Map<String, Object> selectCustomerSqlMap(@SqlString String sql, Map<String, Object> map);
|
||||
|
||||
@Select("select $t{foreignKey},id from $t{tableName} where $t{foreignKey} between #{min} and #{max}")
|
||||
@CaseConversion(value = false)
|
||||
List<Map<String, String>> selectDataIds(@ParamMapper("foreignKey") String foreignKey,
|
||||
@ParamMapper("tableName") String tableName,
|
||||
@ParamMapper("min") Integer min,
|
||||
@ParamMapper("max") Integer max);
|
||||
|
||||
@Select(custom = true)
|
||||
String selectCustomerSql(@SqlString String sql, Map<String, Object> map);
|
||||
}
|
|
@ -0,0 +1,385 @@
|
|||
package weaver.xuanran.wang.eny.data_async.service;
|
||||
|
||||
import aiyh.utils.ThreadPoolConfig;
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.cube.service.ModeAppService;
|
||||
import com.engine.cube.service.impl.ModeAppServiceImpl;
|
||||
import lombok.Setter;
|
||||
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.formmode.setup.ModeRightInfoThread;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.hrm.User;
|
||||
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||
import weaver.xuanran.wang.common.util.CommonUtil;
|
||||
import weaver.xuanran.wang.common.util.CusData2OA;
|
||||
import weaver.xuanran.wang.common.util.RequestMasterPlate;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain;
|
||||
import weaver.xuanran.wang.eny.data_async.mapper.DataAsyncMapper;
|
||||
import weaver.xuanran.wang.eny.data_async.util.EyDataAsyncTokenUtil;
|
||||
import weaver.xuanran.wang.eny.data_async.util.ValueRuleMethod;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionContext;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <h1>安永 - 建模数据同步</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/8 15:19
|
||||
*/
|
||||
@Setter
|
||||
public class DataAsyncServiceImpl {
|
||||
|
||||
private final DataAsyncMapper asyncMapper = Util.getMapper(DataAsyncMapper.class);
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate();
|
||||
|
||||
private final CusSuccess dataSuccess = CusSuccess.builder()
|
||||
.successField("code")
|
||||
.successValue(0)
|
||||
.dataKey("data")
|
||||
.errorMsg("msg")
|
||||
.build();
|
||||
|
||||
private int pageSize = 100;
|
||||
|
||||
private int pageNo = 1;
|
||||
|
||||
private String clientId = "";
|
||||
|
||||
private String debug = "0";
|
||||
|
||||
private final ExecutorService threadPoolInstance = ThreadPoolConfig.createThreadPoolInstance();
|
||||
|
||||
/**
|
||||
* <h1>根据模块id查询配置</h1>
|
||||
*
|
||||
* @param onlyMark 唯一标识
|
||||
* @return 配置对象
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/7 11:28
|
||||
**/
|
||||
public DataAsyncConfigMain getConfig(String onlyMark) {
|
||||
DataAsyncConfigMain config = asyncMapper.selectConfigByOnlyMark(onlyMark);
|
||||
if(Objects.isNull(config) || CollectionUtils.isEmpty(config.getConfigDetailList())){
|
||||
throw new CustomerException("该唯一标识在配置表中未找到对应的配置!或存在该配置但是明细数据为空!");
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>数据同步 有一个点 就是如果接口请求过程中报错了 怎么重新处理</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/9 13:28
|
||||
* @param config 配置对象
|
||||
* @param tokenUrl token地址
|
||||
* @param params token 参数
|
||||
**/
|
||||
public void asyncData(DataAsyncConfigMain config, String tokenUrl, Map<String, Object> params){
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("数据开始同步时间 : " + TimeUtil.getCurrentTimeString());
|
||||
String asyncUrl = config.getAsync_url();
|
||||
int total = Integer.MAX_VALUE;
|
||||
int pageNo = this.pageNo;
|
||||
int count = 0;
|
||||
// 请求头
|
||||
HashMap<String, String> header = new HashMap<>();
|
||||
header.put("client-id", clientId);
|
||||
// url地址参数
|
||||
HashMap<String, Object> query = new HashMap<>();
|
||||
query.put("pageSize", pageSize);
|
||||
CountDownLatch latch = null;
|
||||
int preNum = 0;
|
||||
// 如果不是第一页就先定位到指定位置
|
||||
if(pageNo > 1){
|
||||
count += (pageNo - 1) * pageSize;
|
||||
preNum = count;
|
||||
}
|
||||
boolean show = true;
|
||||
while (count < total){
|
||||
// 从缓存中获取token
|
||||
String token = EyDataAsyncTokenUtil.getToken(tokenUrl, params);
|
||||
header.put("Authorization", "Bearer " + token);
|
||||
query.put("pageNo", pageNo);
|
||||
// 构建请求url 拼接上分分页参数
|
||||
String url = CommonUtil.buildGetUrl(asyncUrl, query);
|
||||
Map<String, Object> data;
|
||||
List<Map<String, Object>> maps;
|
||||
try {
|
||||
// 获取接口数据
|
||||
data = requestMasterPlate.apiPost(url, new HashMap<>(), header, dataSuccess);
|
||||
total = Util.getIntValue(Util.null2DefaultStr(data.get("total"),""), -1);
|
||||
if(show){
|
||||
log.info("接口数据条数total : " + total);
|
||||
}
|
||||
if(latch == null){
|
||||
// 应该传入 total / pageSize
|
||||
latch = new CountDownLatch(total);
|
||||
}
|
||||
pageNo++;
|
||||
count += pageSize;
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) data.get("list");
|
||||
// 进行数据处理
|
||||
maps = dealData(config, list);
|
||||
show = false;
|
||||
}catch (Exception e){
|
||||
for (int i = 0; i < pageSize; i++) {
|
||||
if(latch != null){
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
log.error("请求异常 : " + e.getMessage() + " 当前页数 : " + pageNo);
|
||||
if(latch != null){
|
||||
log.info("当前latch信号数量 : " + latch.getCount());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
CountDownLatch finalLatch = latch;
|
||||
if(finalLatch.getCount() > 0 && maps.size() > 0){
|
||||
// 异步提交数据库处理
|
||||
threadPoolInstance.execute(()->{
|
||||
log.info("=======================================================================================");
|
||||
log.info(Thread.currentThread().getName() + " 入库之前信号数量 : " + finalLatch.getCount());
|
||||
CusData2OA.baseInsertAndUpdate(config.getModel_id(), maps, finalLatch);
|
||||
log.info(Thread.currentThread().getName() + " 入库之后信号数量 : " + finalLatch.getCount());
|
||||
log.info("=======================================================================================");
|
||||
});
|
||||
}
|
||||
}
|
||||
try {
|
||||
if(latch != null){
|
||||
log.info("preNum : " + preNum);
|
||||
while (preNum-- > 0){
|
||||
latch.countDown();
|
||||
}
|
||||
boolean await = latch.await(30, TimeUnit.MINUTES);
|
||||
if(!await){
|
||||
throw new CustomerException("线程等待时间超过最大时间限制!");
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("数据结束同步时间 : " + TimeUtil.getCurrentTimeString());
|
||||
rebuildRight(Util.getIntValue(config.getModel_id()));
|
||||
log.info("同步耗时时间 " + (endTime - startTime) / 1000 + " s");// 等待所有转换操作完成
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CustomerException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>同步处理数据</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/8 16:50
|
||||
* @param config 配置对象
|
||||
* @param data 接口数据
|
||||
**/
|
||||
public List<Map<String, Object>> dealData(DataAsyncConfigMain config, List<Map<String, Object>> data) {
|
||||
List<DataAsyncConfigDetail> configDetailList = config.getConfigDetailList();
|
||||
List<DataAsyncConfigDetail> primaryKey = configDetailList.stream().filter(item -> item.getPrimary_key() == 0).collect(Collectors.toList());
|
||||
List<Map<String, Object>> maps = new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(primaryKey)){
|
||||
// 模版-接口外键
|
||||
String modelFieldName = primaryKey.get(0).getModel_field_name();
|
||||
maps = data.stream().map(item -> convert(item, primaryKey.get(0).getInterface_field(), configDetailList)).filter(MapUtils::isNotEmpty).collect(Collectors.toList());
|
||||
// 进行排序
|
||||
Optional<Integer> minClassId = maps.stream()
|
||||
.map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(modelFieldName),""),-1))
|
||||
.min(Comparator.naturalOrder());
|
||||
Optional<Integer> maxClassId = maps.stream()
|
||||
.map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(modelFieldName),""),-1))
|
||||
.max(Comparator.naturalOrder());
|
||||
Integer min = minClassId.orElse(0);
|
||||
Integer max = maxClassId.orElse(0);
|
||||
// 按照外键排序并且在oa中范围查询出外键与oa数据的对应关系
|
||||
List<Map<String, String>> dataIdList = asyncMapper.selectDataIds(modelFieldName, config.getTable_name(), min, max);
|
||||
if("1".equals(debug)){
|
||||
log.info("dataIdList : " + JSONObject.toJSONString(dataIdList));
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(dataIdList)){
|
||||
HashMap<String, String> idMap = parseListMap2Map(modelFieldName, "id", dataIdList);
|
||||
if("1".equals(debug)){
|
||||
log.info("idMap : " + JSONObject.toJSONString(idMap));
|
||||
}
|
||||
maps.forEach(item->{
|
||||
if("1".equals(debug)){
|
||||
log.info("item : " + JSONObject.toJSONString(item));
|
||||
}
|
||||
String id = Util.null2DefaultStr(item.get(modelFieldName),"");
|
||||
if("1".equals(debug)){
|
||||
log.info("id : " + id);
|
||||
}
|
||||
if(idMap.containsKey(id)){
|
||||
String oaId = idMap.get(id);
|
||||
item.put("id",oaId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>将数据进行转换</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/9 13:27
|
||||
* @param data 原始数据
|
||||
* @param foreignKey 外键
|
||||
* @param configDetailList 配置集合
|
||||
* @return 转换后的数据
|
||||
**/
|
||||
public Map<String, Object> convert(Map<String, Object> data,
|
||||
String foreignKey,
|
||||
List<DataAsyncConfigDetail> configDetailList){
|
||||
String foreignVal = Util.null2DefaultStr(data.get(foreignKey), "");
|
||||
if(StringUtils.isBlank(foreignVal)){
|
||||
return new HashMap<>();
|
||||
}
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
for (DataAsyncConfigDetail detail : configDetailList) {
|
||||
map.put(detail.getModel_field_name(), ValueRuleMethod.VALUE_RULE_FUNCTION.get(detail.getGet_value_type()).apply(detail, data));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>将集合数据放到缓存中</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/4/10 18:33
|
||||
* @param listMap 集合数据
|
||||
**/
|
||||
public static HashMap<String, String> parseListMap2Map(String key, String value, List<Map<String, String>> listMap){
|
||||
if(CollectionUtils.isEmpty(listMap)){
|
||||
return new HashMap<>();
|
||||
}
|
||||
HashMap<String, String> res = new HashMap<>();
|
||||
listMap.forEach(map -> {
|
||||
String outKey = Util.null2DefaultStr(map.get(key),"");
|
||||
if(StringUtils.isNotBlank(outKey)){
|
||||
String id = Util.null2DefaultStr(map.get(value),"");
|
||||
res.put(outKey, id);
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
public static ModeAppService modeAppService = ServiceUtil.getService(ModeAppServiceImpl.class, new User(1));
|
||||
|
||||
/**
|
||||
* <h1>模块数据全量权限重构</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/6/9 13:28
|
||||
* @param modeId 模块id
|
||||
**/
|
||||
public static void rebuildRight(int modeId){
|
||||
ModeRightInfoThread var5 = new ModeRightInfoThread();
|
||||
var5.setModeId(modeId);
|
||||
var5.setRebulidFlag("1");
|
||||
var5.setSession(new HttpSession() {
|
||||
@Override
|
||||
public String getId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastAccessedTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxInactiveInterval(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInactiveInterval() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getAttributeNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSessionContext getSessionContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValueNames() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putValue(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValue(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
var5.setUser(new User(1));
|
||||
var5.resetModeRight();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package weaver.xuanran.wang.eny.data_async.service.convert;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail;
|
||||
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncCache;
|
||||
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigDetail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>自定义转换接口</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/4/11 16:49
|
||||
*/
|
||||
public interface CusAsyncConvert {
|
||||
Logger log = Util.getLogger();
|
||||
Object cusConvert(DataAsyncConfigDetail configDetail, Map<String, Object> maps, Map<String, String> pathParam);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package weaver.xuanran.wang.eny.data_async.service.convert;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>自定义转换</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/9 10:00
|
||||
*/
|
||||
public class CusSubStringConvert implements CusAsyncConvert{
|
||||
@Override
|
||||
public Object cusConvert(DataAsyncConfigDetail configDetail, Map<String, Object> maps, Map<String, String> pathParam) {
|
||||
try {
|
||||
String interfaceField = configDetail.getInterface_field();
|
||||
if(StringUtils.isBlank(interfaceField)){
|
||||
return "";
|
||||
}
|
||||
String value = Util.null2DefaultStr(maps.get(interfaceField),"");
|
||||
if(StringUtils.isBlank(value)){
|
||||
return "";
|
||||
}
|
||||
if (value.equals("00")) {
|
||||
return "0";
|
||||
} else {
|
||||
return value.replace("0", "");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("CusSubStringConvert error : ",e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package weaver.xuanran.wang.eny.data_async.service.convert;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>时间戳转自定义时间格式字符串</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/9 09:53
|
||||
*/
|
||||
public class CusTimeConvert implements CusAsyncConvert {
|
||||
@Override
|
||||
public Object cusConvert(DataAsyncConfigDetail configDetail, Map<String, Object> maps, Map<String, String> pathParam) {
|
||||
try {
|
||||
String interfaceField = configDetail.getInterface_field();
|
||||
String format = Util.null2DefaultStr(pathParam.get("format"),"yyyy-MM-dd");
|
||||
String time;
|
||||
if(StringUtils.isBlank(interfaceField)){
|
||||
time = String.valueOf(System.currentTimeMillis());
|
||||
}else {
|
||||
time = Util.null2DefaultStr(maps.get(interfaceField),"");
|
||||
if(StringUtils.isBlank(time)){
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Date date = new Date(Long.parseLong(time));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format); // 定义日期格式
|
||||
return Util.null2DefaultStr( sdf.format(date),""); // 将Date对象格式化为字
|
||||
}catch (Exception e){
|
||||
log.error("CusTimeConvert error : ",e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package weaver.xuanran.wang.eny.data_async.util;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||
import weaver.xuanran.wang.common.util.RequestMasterPlate;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.EyDataAsyncCusToken;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/8 15:55
|
||||
*/
|
||||
public class EyDataAsyncTokenUtil {
|
||||
private static volatile EyDataAsyncCusToken token;
|
||||
private static final CusSuccess tokenSuccess = CusSuccess.builder()
|
||||
.successField("code")
|
||||
.successValue(0)
|
||||
.dataKey("data")
|
||||
.build();
|
||||
private static final RequestMasterPlate requestMasterPlate = new RequestMasterPlate();
|
||||
private static final Logger log = Util.getLogger();
|
||||
/**
|
||||
* <h1>获取token</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/4/6 19:59
|
||||
* @return token
|
||||
**/
|
||||
public static String getToken(String url, Map<String, Object> params) {
|
||||
if(token == null){
|
||||
synchronized (EyDataAsyncTokenUtil.class){
|
||||
if(token == null){
|
||||
return getTokenByHTTP(url, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
long expiryTime = token.getExpiresTime();
|
||||
if(System.currentTimeMillis() >= expiryTime){
|
||||
synchronized (EyDataAsyncTokenUtil.class){
|
||||
expiryTime = token.getExpiresTime();
|
||||
if(System.currentTimeMillis() >= expiryTime){
|
||||
return getTokenByHTTP(url, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
return token.getAccessToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>从接口获取token</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/4/7 23:49
|
||||
* @return token
|
||||
**/
|
||||
private static String getTokenByHTTP(String url, Map<String, Object> params){
|
||||
HashMap<String, String> header = new HashMap<>();
|
||||
header.put("Content-Type", "application/json");
|
||||
Map<String, Object> response = requestMasterPlate.apiPost(url, params, header, tokenSuccess);
|
||||
token = JSONObject.parseObject(JSONObject.toJSONString(response), EyDataAsyncCusToken.class);
|
||||
String accessToken = Util.null2DefaultStr(response.get("accessToken"), "");
|
||||
long expiresTime = Long.parseLong(Util.null2DefaultStr(response.get("expiresTime"), ""));
|
||||
// 默认少5分钟过期
|
||||
token.setExpiresTime(expiresTime - (60 * 5 * 1000));
|
||||
log.info("token : " + JSONObject.toJSONString(token));
|
||||
return accessToken;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package weaver.xuanran.wang.eny.data_async.util;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail;
|
||||
import weaver.xuanran.wang.eny.data_async.mapper.DataAsyncMapper;
|
||||
import weaver.xuanran.wang.eny.data_async.service.convert.CusAsyncConvert;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* <h1>值处理方法</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 15:15</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class ValueRuleMethod {
|
||||
|
||||
|
||||
public static final Map<Integer, BiFunction<DataAsyncConfigDetail, Map<String, Object>, Object>> VALUE_RULE_FUNCTION = new HashMap<>();
|
||||
|
||||
private final DataAsyncMapper mapper = Util.getMapper(DataAsyncMapper.class);
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
static {
|
||||
Class<ValueRuleMethod> valueRuleMethodClass = ValueRuleMethod.class;
|
||||
Method[] methods = valueRuleMethodClass.getMethods();
|
||||
for (Method method : methods) {
|
||||
if (method.isAnnotationPresent(ValueRuleMethodNo.class)) {
|
||||
ValueRuleMethodNo annotation = method.getAnnotation(ValueRuleMethodNo.class);
|
||||
int value = annotation.value();
|
||||
VALUE_RULE_FUNCTION.put(value, (detail, map) -> {
|
||||
try {
|
||||
ValueRuleMethod valueRuleMethod = new ValueRuleMethod();
|
||||
return method.invoke(valueRuleMethod, detail, map);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ValueRuleMethodNo(value = 0, desc = "不转换")
|
||||
public Object getFixValue(DataAsyncConfigDetail configDetail,Map<String, Object> map) {
|
||||
return Util.null2DefaultStr(map.get(configDetail.getInterface_field()),"");
|
||||
}
|
||||
|
||||
|
||||
@ValueRuleMethodNo(value = 1, desc = "默认值")
|
||||
public Object getCusText(DataAsyncConfigDetail configDetail, Map<String, Object> map) {
|
||||
return Util.null2DefaultStr(configDetail.getValue_context(),"");
|
||||
}
|
||||
|
||||
|
||||
@ValueRuleMethodNo(value = 2, desc = "自定义sql")
|
||||
public Object getCustomerSqlValue(DataAsyncConfigDetail configDetail, Map<String, Object> map) {
|
||||
String cusText = configDetail.getValue_context();
|
||||
cusText = Util.sbc2dbcCase(cusText);
|
||||
if (Strings.isNullOrEmpty(cusText)) {
|
||||
return null;
|
||||
}
|
||||
if (!cusText.startsWith("select")) {
|
||||
return null;
|
||||
}
|
||||
// 接口字段值判断
|
||||
String interfaceField = configDetail.getInterface_field();
|
||||
String interfaceFieldVal = Util.null2DefaultStr(map.get(interfaceField),"");
|
||||
if(StringUtils.isBlank(interfaceFieldVal)){
|
||||
return "";
|
||||
}
|
||||
return Util.null2DefaultStr(mapper.selectCustomerSql(cusText, map),"");
|
||||
}
|
||||
|
||||
@ValueRuleMethodNo(value = 3, desc = "自定义接口")
|
||||
public Object getCusConvertInterface(DataAsyncConfigDetail configDetail, Map<String, Object> map) {
|
||||
String cusText = configDetail.getValue_context();
|
||||
if(Strings.isNullOrEmpty(cusText)){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Class<?> clazz = Class.forName(cusText);
|
||||
if(!CusAsyncConvert.class.isAssignableFrom(clazz)){
|
||||
throw new CustomerException(cusText + " not implements weaver.xuanran.wang.sh_bigdata.org_hrm_async.annotations.CusOrgHrmAsyncConvert");
|
||||
}
|
||||
CusAsyncConvert o = (CusAsyncConvert) clazz.newInstance();
|
||||
Map<String, String> pathParam = Util.parseCusInterfacePathParam(cusText);
|
||||
return o.cusConvert(configDetail, map, pathParam);
|
||||
}catch (Exception e){
|
||||
log.error("getCusConvertInterface error! " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package weaver.xuanran.wang.eny.data_async.util;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <h1>值处理方法编号注解</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 15:18</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface ValueRuleMethodNo {
|
||||
int value();
|
||||
String desc();
|
||||
}
|
|
@ -2,8 +2,10 @@ package weaver.xuanran.wang.immc.cusfieldvalue;
|
|||
|
||||
import aiyh.utils.Util;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
|
||||
import weaver.xiao.commons.config.interfacies.CusInterfaceListValue;
|
||||
import weaver.xuanran.wang.immc.mapper.ImMcMapper;
|
||||
|
@ -27,24 +29,31 @@ public class CusListValue implements CusInterfaceGetValue {
|
|||
log.info("pathParam : \n" + JSONObject.toJSONString(pathParam));
|
||||
String attachmentField = Util.null2DefaultStr(pathParam.get("attachmentField"), "");
|
||||
String cusSql = Util.null2DefaultStr(pathParam.get("cusSql"), "");
|
||||
// 如果fileName不为空则对集合中每个map添加"fileName":value value则是附件字段名称
|
||||
String fileName = Util.null2DefaultStr(pathParam.get("fileName"), "");
|
||||
if(StringUtils.isNotBlank(cusSql)){
|
||||
String docIds = "";
|
||||
if (StringUtils.isNotBlank(attachmentField)) {
|
||||
List<String> attachment = new ArrayList<>();
|
||||
for (String item : attachmentField.split(",")) {
|
||||
String filedValue = Util.null2DefaultStr(mainMap.get(item),"");
|
||||
if(StringUtils.isNotBlank(Util.null2DefaultStr(mainMap.get(item),""))){
|
||||
attachment.add(filedValue);
|
||||
}
|
||||
}
|
||||
docIds = StringUtils.join(attachment, ",");
|
||||
}
|
||||
if(StringUtils.isNotBlank(Util.null2DefaultStr(mainMap.get(filedValue),""))){
|
||||
cusSql = cusSql
|
||||
.replace("{?docIds}", "( " + docIds + " )")
|
||||
.replace("{?docIds}", "( " + filedValue + " )")
|
||||
.replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),""));
|
||||
List<Map<String, String>> attachmentInfo = mapper.getAttachmentInfo(cusSql);
|
||||
if(CollectionUtils.isEmpty(attachmentInfo)){
|
||||
continue;
|
||||
}
|
||||
// 往map中put附件字段名
|
||||
if(StringUtils.isBlank(fileName)){
|
||||
attachmentInfo.forEach(file ->{
|
||||
file.put(fileName, item);
|
||||
});
|
||||
}
|
||||
list.addAll(attachmentInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public class WorkFlowToVmsAndMQService {
|
|||
// 表单字段
|
||||
private static final String VMS_SUCCESS = "vms_success";
|
||||
private static final String SUCCESS = "0";
|
||||
|
||||
{
|
||||
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
|
||||
}
|
||||
|
@ -68,9 +69,9 @@ public class WorkFlowToVmsAndMQService {
|
|||
String url = requestMappingConfig.getRequestUrl();
|
||||
dealWithMapping.setMainTable(billTable);
|
||||
Map<String, Object> param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
|
||||
String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS),"");
|
||||
String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS),"");
|
||||
if(!SUCCESS.equals(vmsSuccess)){
|
||||
String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS), "");
|
||||
String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS), "");
|
||||
if (!SUCCESS.equals(vmsSuccess)) {
|
||||
ResponeVo responeVo;
|
||||
try {
|
||||
responeVo = httpUtils.apiPost(url, param);
|
||||
|
@ -80,7 +81,7 @@ public class WorkFlowToVmsAndMQService {
|
|||
parseResponseVo(responeVo, url, param, vmsResponseVoField);
|
||||
updateWorkFlow(VMS_SUCCESS, billTable, requestId);
|
||||
}
|
||||
if(!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)){
|
||||
if (!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)) {
|
||||
sendToMQ(config, param);
|
||||
updateWorkFlow(MQ_SUCCESS, billTable, requestId);
|
||||
}
|
||||
|
@ -88,13 +89,14 @@ public class WorkFlowToVmsAndMQService {
|
|||
|
||||
/**
|
||||
* <h1>解析响应对象</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/23 11:25
|
||||
*
|
||||
* @param responseVo 响应对象
|
||||
* @param url 地址
|
||||
* @param requestParam 请求
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/23 11:25
|
||||
**/
|
||||
private void parseResponseVo(ResponeVo responseVo, String url, Map<String, Object> requestParam, VmsResponseVoField vmsResponseVoField){
|
||||
private void parseResponseVo(ResponeVo responseVo, String url, Map<String, Object> requestParam, VmsResponseVoField vmsResponseVoField) {
|
||||
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 [{}]," +
|
||||
|
@ -112,45 +114,46 @@ public class WorkFlowToVmsAndMQService {
|
|||
|
||||
/**
|
||||
* <h1>将流程信息发送到kafka</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/3/30 14:56
|
||||
*
|
||||
* @param kafkaConfig kafka配置文件名称
|
||||
* @param message 消息对象
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/3/30 14:56
|
||||
**/
|
||||
public void sendToMQ(String kafkaConfig, Map<String, Object> message){
|
||||
public void sendToMQ(String kafkaConfig, Map<String, Object> message) {
|
||||
KafkaProducer<String, String> producer = null;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties";
|
||||
File configFile = new File(path);
|
||||
if(!configFile.exists()){
|
||||
if (!configFile.exists()) {
|
||||
throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties");
|
||||
}
|
||||
Properties prop = new Properties();
|
||||
inputStream= new BufferedInputStream(Files.newInputStream(configFile.toPath()));
|
||||
inputStream = new BufferedInputStream(Files.newInputStream(configFile.toPath()));
|
||||
prop.load(inputStream);
|
||||
log.info("prop => " + JSONObject.toJSONString(prop));
|
||||
log.info("msg => " + JSONObject.toJSONString(message));
|
||||
String topic = Util.null2DefaultStr(prop.getProperty("topic"),"");
|
||||
if(StringUtils.isBlank(topic)){
|
||||
String topic = Util.null2DefaultStr(prop.getProperty("topic"), "");
|
||||
if (StringUtils.isBlank(topic)) {
|
||||
throw new CustomerException("kafka properties topic can not null!");
|
||||
}
|
||||
producer = new KafkaProducer<>(prop);
|
||||
// 发送消息到指定主题
|
||||
ProducerRecord<String, String> record = new ProducerRecord<>(topic, JSONObject.toJSONString(message));
|
||||
producer.send(record).get();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error(Util.getErrString(e));
|
||||
throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage()));
|
||||
}finally {
|
||||
} finally {
|
||||
// 关闭Kafka生产者实例
|
||||
if(producer != null){
|
||||
if (producer != null) {
|
||||
producer.close();
|
||||
}
|
||||
if(inputStream != null){
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error("inputStream close error! " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -159,16 +162,17 @@ public class WorkFlowToVmsAndMQService {
|
|||
|
||||
/**
|
||||
* <h1>更新流程sql</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/3/30 19:18
|
||||
*
|
||||
* @param field 主表字段
|
||||
* @param tableName 表名
|
||||
* @param requestId 请求id
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/3/30 19:18
|
||||
**/
|
||||
public void updateWorkFlow(String field, String tableName, String requestId){
|
||||
public void updateWorkFlow(String field, String tableName, String requestId) {
|
||||
String updateSQL = "update " + tableName + " set " + field + " = " + SUCCESS + " where requestid = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
if(!recordSet.executeUpdate(updateSQL, requestId)){
|
||||
if (!recordSet.executeUpdate(updateSQL, requestId)) {
|
||||
log.error(Util.logStr("update field error! sql: {}, requestId: {}", updateSQL, requestId));
|
||||
throw new CustomerException("更新表单字段失败!");
|
||||
}
|
||||
|
|
|
@ -74,6 +74,11 @@ public class SendTodoTaskUtil {
|
|||
todoTask.setAgentid(agentId);
|
||||
todoTask.setTaskName(obj.getRequestnamenew());
|
||||
todoTask.setTaskDesc(obj.getRequestnamenew());
|
||||
String pcAgentId = ShBigDataUtil.getPropertiesValByKey("pcAgentId");
|
||||
if(StringUtils.isBlank(pcAgentId)){
|
||||
pcAgentId = agentId;
|
||||
}
|
||||
todoTask.setPcAgentId(pcAgentId);
|
||||
String todoSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoSSOCallBackUrl");
|
||||
StringBuilder sb = new StringBuilder(todoSSOCallBackUrl);
|
||||
sb.append("?user=")
|
||||
|
|
|
@ -37,6 +37,7 @@ public class ShBigDataUtil {
|
|||
WHILTE_LIST.add("getUserIdDebugOutKey");
|
||||
WHILTE_LIST.add("ssoInterfaceCompareField");
|
||||
WHILTE_LIST.add("ssoOaCompareField");
|
||||
WHILTE_LIST.add("pcAgentId");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,4 +26,5 @@ public class CusTodoTask {
|
|||
protected String mobileLinkUrl;
|
||||
protected String receiver;
|
||||
protected String sender;
|
||||
protected String pcAgentId;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
package weaver.youhong.ai.pcn.actioin.locationkeyword;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.action.SafeCusBaseAction;
|
||||
import aiyh.utils.annotation.ActionDefaultTestValue;
|
||||
import aiyh.utils.annotation.ActionDesc;
|
||||
import aiyh.utils.annotation.ActionOptionalParam;
|
||||
import aiyh.utils.annotation.RequiredMark;
|
||||
import aiyh.utils.entity.DocImageInfo;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.fileUtil.WordKeywordFinder;
|
||||
import aiyh.utils.fileUtil.pdf.PdfPointItem;
|
||||
import aiyh.utils.fileUtil.pdf.PdfUtil;
|
||||
import aiyh.utils.mapper.UtilMapper;
|
||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import lombok.Setter;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>定位查找关键字</h1>
|
||||
*
|
||||
* <p>create: 2023/6/16 16:38</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Setter
|
||||
@ActionDesc(author = "youhong.ai", value = "word文件和pdf文件关键字识别,是否存在关键字")
|
||||
public class LocationKeywordAction extends SafeCusBaseAction {
|
||||
|
||||
@RequiredMark(desc = "关键字,多个关键字之间使用;分割")
|
||||
@ActionDefaultTestValue("盖章关键字;日期关键字")
|
||||
private String keywords;
|
||||
|
||||
@RequiredMark(desc = "附件字段字段名")
|
||||
@ActionDefaultTestValue("fj")
|
||||
private String docField;
|
||||
|
||||
@ActionOptionalParam(value = "false", desc = "报错是否自动退回")
|
||||
@ActionDefaultTestValue("false")
|
||||
private String isBack = "false";
|
||||
|
||||
|
||||
private final UtilMapper mapper = Util.getMapper(UtilMapper.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||
|
||||
Map<String, String> mainData = getMainTableValue(requestInfo);
|
||||
String docIds = mainData.get(docField);
|
||||
if (StrUtil.isBlank(docIds)) {
|
||||
return;
|
||||
}
|
||||
List<DocImageInfo> docImageInfos = mapper.selectDocImageInfos(docIds);
|
||||
if (CollectionUtil.isEmpty(docImageInfos)) {
|
||||
log.error("未查询到物理文件信息!=>" + docIds);
|
||||
Util.actionFailException(requestInfo.getRequestManager(), "系统异常,请联系管理员");
|
||||
}
|
||||
String[] keywordArr = keywords.split(";");
|
||||
Map<String, Boolean> keyMap = new HashMap<>(8);
|
||||
for (DocImageInfo docImageInfo : docImageInfos) {
|
||||
Map<String, Boolean> keyword = findKeyWord(docImageInfo, keywordArr);
|
||||
for (Map.Entry<String, Boolean> entry : keyword.entrySet()) {
|
||||
if (keyMap.containsKey(entry.getKey())) {
|
||||
Boolean isKeyword = keyMap.get(entry.getKey());
|
||||
if (!isKeyword) {
|
||||
keyMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
keyMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Boolean.parseBoolean(isBack)) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<String, Boolean> entry : keyMap.entrySet()) {
|
||||
if (!entry.getValue()) {
|
||||
throw new CustomerException(Util.logStr("关键字[{}]定位异常!文件中不存在关键字!", entry.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Boolean> findKeyWord(DocImageInfo docImageInfo, String[] keywordArr) {
|
||||
String imageFileName = docImageInfo.getImageFileName();
|
||||
Integer imageFileId = docImageInfo.getImageFileId();
|
||||
Map<String, Boolean> result = new HashMap<>(8);
|
||||
InputStream inputStream = ImageFileManager.getInputStreamById(imageFileId);
|
||||
if (imageFileName.endsWith(".pdf")) {
|
||||
for (String keyword : keywordArr) {
|
||||
List<PdfPointItem> keywordPoints = PdfUtil.findKeywordPoints(inputStream, keyword);
|
||||
if (CollectionUtil.isEmpty(keywordPoints)) {
|
||||
result.put(keyword, false);
|
||||
} else {
|
||||
result.put(keyword, true);
|
||||
}
|
||||
}
|
||||
} else if (imageFileName.endsWith(".doc") || imageFileName.endsWith(".docx")) {
|
||||
for (String keyword : keywordArr) {
|
||||
List<WordKeywordFinder.KeywordLocation> keywordPoints = WordKeywordFinder.findKeywords(inputStream, keyword, imageFileName);
|
||||
if (CollectionUtil.isEmpty(keywordPoints)) {
|
||||
result.put(keyword, false);
|
||||
} else {
|
||||
result.put(keyword, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package weaver.youhong.ai.pcn.actioin.locationkeyword.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/6/16 16:56</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface LocationKeywordMapper {
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package selfdev.util.log;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.GCONST;
|
||||
|
||||
/**
|
||||
* 日志工具类
|
||||
* @author KangMD
|
||||
* 1、2019-01-29 add by KangMD
|
||||
*/
|
||||
|
||||
public class LogTool {
|
||||
private BufferedWriter logPrint;
|
||||
private String logFile = "";
|
||||
private String logPath="";
|
||||
private boolean systemlog=false;//是否写系统日记
|
||||
static SimpleDateFormat newDf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
static SimpleDateFormat df =new SimpleDateFormat("yyyy-MM-dd");
|
||||
static BaseBean log=new BaseBean();
|
||||
public LogTool(){
|
||||
//if(logFile == null || logFile.trim().equals("") || !logFile.equals(getLogFile())){
|
||||
// newLog();
|
||||
//}
|
||||
}
|
||||
public LogTool(String logPath,boolean systemlog){
|
||||
this.logPath=logPath;
|
||||
this.systemlog=systemlog;
|
||||
}
|
||||
private String getLogFile(){
|
||||
//获取当前系统路径
|
||||
String sysPath=GCONST.getRootPath();
|
||||
if(sysPath==null){
|
||||
sysPath=System.getProperty("user.dir");
|
||||
}
|
||||
if(!"".equals(logPath)){
|
||||
if(logPath.endsWith("/")){
|
||||
sysPath += logPath+df.format(new Date())+".log";
|
||||
}else{
|
||||
sysPath += logPath+"/"+df.format(new Date())+".log";
|
||||
}
|
||||
}else {
|
||||
sysPath += "/log/dev/"+df.format(new Date())+".log";
|
||||
}
|
||||
return sysPath;
|
||||
}
|
||||
|
||||
private void newLog(){
|
||||
logFile = getLogFile();
|
||||
try{
|
||||
//logPrint = new PrintWriter(new FileWriter(logFile, true), true);
|
||||
logPrint = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (logFile,true),"UTF-8"));
|
||||
}catch(IOException e){
|
||||
try{
|
||||
File file=new File(logFile);
|
||||
if(!file.getParentFile().exists()) {
|
||||
//如果目标文件所在的目录不存在,则创建父目录
|
||||
if(file.getParentFile().mkdirs()){
|
||||
file.createNewFile();
|
||||
}
|
||||
}
|
||||
//logPrint = new PrintWriter(new FileWriter(logFile, true), true);
|
||||
logPrint = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (logFile,true),"UTF-8"));
|
||||
}catch(IOException ex){
|
||||
log.writeLog("Log记录出错了",ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeLog(Object msg) {
|
||||
if(systemlog){
|
||||
log.writeLog(msg);
|
||||
}
|
||||
newLog();
|
||||
try {
|
||||
logPrint.write(newDf.format(new Date()) + ": " + msg);
|
||||
logPrint.newLine();//每次换行
|
||||
logPrint.flush();
|
||||
logPrint.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writeLog(String msg,Throwable e) {
|
||||
if(systemlog){
|
||||
log.writeLog(msg,e);
|
||||
}
|
||||
newLog();
|
||||
try {
|
||||
logPrint.write(newDf.format(new Date()) + ": " + msg);
|
||||
logPrint.newLine();//每次换行
|
||||
//e.printStackTrace(logPrint);
|
||||
logPrint.flush();
|
||||
logPrint.close();
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -391,8 +391,8 @@ public class BigDataTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void testG(){
|
||||
String oaOutKey = "111";
|
||||
String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}";
|
||||
String oaOutKey = "wld";
|
||||
String sql = "select id from hrmresource where loginid = #{outKey}";
|
||||
int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey);
|
||||
log.info("id => " + id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package xuanran.wang.eny;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.cube.service.ModeAppService;
|
||||
import com.engine.cube.service.impl.ModeAppServiceImpl;
|
||||
import org.junit.Test;
|
||||
import weaver.formmode.setup.ModeRightInfoThread;
|
||||
import weaver.hrm.User;
|
||||
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain;
|
||||
import weaver.xuanran.wang.eny.data_async.mapper.DataAsyncMapper;
|
||||
import weaver.xuanran.wang.eny.data_async.service.DataAsyncServiceImpl;
|
||||
|
||||
import javax.jms.Session;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionContext;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/6/8 16:20
|
||||
*/
|
||||
public class DataAsyncTest extends BaseTest {
|
||||
private DataAsyncServiceImpl dataAsyncService = new DataAsyncServiceImpl();
|
||||
@Test
|
||||
public void testA(){
|
||||
String onlyMark = "test";
|
||||
String tokenUrl = "http://47.94.138.180:48070/rpc-api/system/oauth2/token/client/create";
|
||||
String clientId = "6d067ac6c14211ed8fd700163e1331c6";
|
||||
String appId = "WEAVER";
|
||||
String appSecret = "7b09e5f7c14211ed8fd700163e1331c6";
|
||||
int pageSize = 500;
|
||||
int pageNo = 25;
|
||||
dataAsyncService.setPageSize(25);
|
||||
dataAsyncService.setPageSize(pageSize);
|
||||
dataAsyncService.setClientId(clientId);
|
||||
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("clientId", clientId);
|
||||
params.put("appId", appId);
|
||||
params.put("appSecret", appSecret);
|
||||
DataAsyncConfigMain config = dataAsyncService.getConfig(onlyMark);
|
||||
dataAsyncService.asyncData(config, tokenUrl, params);
|
||||
}
|
||||
|
||||
private final DataAsyncMapper asyncMapper = Util.getMapper(DataAsyncMapper.class);
|
||||
|
||||
@Test
|
||||
public void testb(){
|
||||
String json = "[{\"interfaceForeignKey\":\"12001\",\"id\":386455},{\"interfaceForeignKey\":\"12002\",\"id\":386457},{\"interfaceForeignKey\":\"12003\",\"id\":386459},{\"interfaceForeignKey\":\"12004\",\"id\":386460},{\"interfaceForeignKey\":\"12005\",\"id\":386462},{\"interfaceForeignKey\":\"12006\",\"id\":386464},{\"interfaceForeignKey\":\"12007\",\"id\":386466},{\"interfaceForeignKey\":\"12008\",\"id\":386468},{\"interfaceForeignKey\":\"12009\",\"id\":386469},{\"interfaceForeignKey\":\"12010\",\"id\":386471}]";
|
||||
// List<Map<String, String>> maps = asyncMapper.selectDataIds("classId", "uf_class", 1, 10);
|
||||
List<Map<String, String>> list = JSONObject.parseObject(json, List.class);
|
||||
System.out.println("maps : " + JSONObject.toJSONString(list));
|
||||
HashMap<String, String> stringStringHashMap = dataAsyncService.parseListMap2Map("interfaceForeignKey", "id", list);
|
||||
System.out.println("stringStringHashMap : " + JSONObject.toJSONString(stringStringHashMap));
|
||||
}
|
||||
|
||||
public static ModeAppService modeAppService = ServiceUtil.getService(ModeAppServiceImpl.class, new User(1));
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,10 +1,27 @@
|
|||
package xuanran.wang.eny;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.xuanran.wang.eny.export_excel.entity.CusExportExcelConfigMain;
|
||||
import com.api.xuanran.wang.eny.export_excel.mapper.ExportExcelMapper;
|
||||
import com.api.xuanran.wang.eny.export_excel.service.ExportExcelServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.Test;
|
||||
import weaver.general.GCONST;
|
||||
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
|
@ -15,10 +32,84 @@ import org.junit.Test;
|
|||
public class ExcelExportTest extends BaseTest {
|
||||
|
||||
private final ExportExcelServiceImpl exportExcelService = new ExportExcelServiceImpl();
|
||||
|
||||
private final ExportExcelMapper exportExcelMapper = Util.getMapper(ExportExcelMapper.class);
|
||||
@Test
|
||||
public void testA(){
|
||||
CusExportExcelConfigMain config = exportExcelService.getConfig(126);
|
||||
CusExportExcelConfigMain config = exportExcelService.getConfig("class");
|
||||
System.out.println("config : " + JSONObject.toJSONString(config));
|
||||
try {
|
||||
String suffix = config.getTemplate_path().substring(config.getTemplate_path().lastIndexOf("."));
|
||||
StreamingOutput streamingOutput = exportExcelService.exportExcel(config, "1", suffix);
|
||||
FileOutputStream fos = new FileOutputStream("/Users/wangxuanran/company/project/ebu_ecology_dev1/file/eny/" + System.currentTimeMillis() + ".xls");
|
||||
streamingOutput.write(fos);
|
||||
}catch (Exception e){
|
||||
System.out.println("e : " + e.getMessage());
|
||||
System.out.println(Util.getErrString(e));
|
||||
}
|
||||
}
|
||||
|
||||
public void service1(CusExportExcelConfigMain config, String dataId) throws IOException {
|
||||
String sql = "select * from " + config.getTable_name() + " where id in ( " + dataId + " )";
|
||||
Map<String, Object> map = exportExcelMapper.selectCustomerSqlMap(sql, new HashMap<>());
|
||||
String filePath = config.getTemplate_path();
|
||||
String suffix = filePath.substring(filePath.lastIndexOf("."));
|
||||
FileInputStream fis = new FileInputStream(parseConfigPath(filePath));
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
Workbook workbook;
|
||||
if (".xls".equals(suffix)) {
|
||||
workbook = new HSSFWorkbook(fis);
|
||||
}else {
|
||||
workbook = new XSSFWorkbook(fis);
|
||||
}
|
||||
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
||||
for (Row row : sheet) {
|
||||
for (Cell cell : row) {
|
||||
String cellValue = cell.getStringCellValue();
|
||||
if(StringUtils.isNotBlank(cellValue)){
|
||||
String replacedValue = replacePlaceholder(cellValue, map);
|
||||
cell.setCellValue(replacedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String replacePlaceholder(String cellValue, Map<String, Object> modelMap){
|
||||
Pattern pattern = Pattern.compile("\\{(.*?)}");
|
||||
Matcher matcher = pattern.matcher(cellValue);
|
||||
StringBuffer replacedValue = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String placeholder = matcher.group(1); // 获取{}中的内容
|
||||
Object replacement = Util.null2DefaultStr(modelMap.get(placeholder),""); // 根据需要进行替换的逻辑
|
||||
matcher.appendReplacement(replacedValue, replacement.toString());
|
||||
}
|
||||
matcher.appendTail(replacedValue);
|
||||
return replacedValue.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>解析请求xls模板位置</h1>
|
||||
* @param configFilePath 模板文件路径
|
||||
* @return 解析后的文件路径
|
||||
*/
|
||||
public String parseConfigPath(String configFilePath){
|
||||
StringBuilder filePath = new StringBuilder(GCONST.getSysFilePath());
|
||||
int beginIndex = configFilePath.indexOf(".");
|
||||
int endIndex = configFilePath.lastIndexOf(".");
|
||||
if(beginIndex == endIndex){
|
||||
filePath.append(configFilePath);
|
||||
}else {
|
||||
String[] pathArr = configFilePath.split("\\.");
|
||||
for (int i = 0; i < pathArr.length - 2; i++) {
|
||||
if(i != 0){
|
||||
filePath.append(File.separator);
|
||||
}
|
||||
filePath.append(pathArr[i]);
|
||||
}
|
||||
filePath.append(File.separator)
|
||||
.append(pathArr[pathArr.length - 2])
|
||||
.append(".")
|
||||
.append(pathArr[pathArr.length - 1]);
|
||||
}
|
||||
return filePath.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import aiyh.utils.Util;
|
|||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.api.doc.detail.util.DocDownloadCheckUtil;
|
||||
import com.api.youhong.ai.taibao.fcuntionlist.service.FunctionListService;
|
||||
import com.api.youhong.ai.taibao.qikan.service.PeriodicalService;
|
||||
import com.cloudstore.dev.api.util.Util_DataCache;
|
||||
|
@ -193,4 +194,10 @@ public class TestTaiBao extends BaseTest {
|
|||
System.out.println(JSON.toJSONString(subRequestEntities));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testjlsdfj() {
|
||||
System.out.println(DocDownloadCheckUtil.DncodeFileid("a1c0c56773deeff8d8f7f235f3eb3db0d2b34cbedb9ff32262414a3c6c4b9a393fc01656cc42ddaf07cd9319d68901a734f710fbddd167603"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.junit.Test;
|
||||
import weaver.youhong.ai.pcn.actioin.doctoavatar.DocToAvatarAction;
|
||||
import youhong.ai.utiltest.excel.ExcelCell;
|
||||
import youhong.ai.utiltest.excel.ExcelPort;
|
||||
import youhong.ai.utiltest.excel.ExcelRow;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
package youhong.ai.utiltest;
|
||||
|
||||
import aiyh.utils.httpUtil.ResponeVo;
|
||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||
import basetest.BaseTest;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <h1>测试调用api</h1>
|
||||
*
|
||||
* <p>create: 2023/6/13 20:04</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class TestApi extends BaseTest {
|
||||
|
||||
Map<String, String> SYSTEM_CACHE = new HashMap<>();
|
||||
|
||||
String APPID = "c6d2b3f5-5c1c-4b90-bad7-4a9b3b2c4bca";
|
||||
|
||||
@Test
|
||||
public void testApi() {
|
||||
// String api = "https://ecology.yeyaguitu.cn/api/aiyh/test/req-msg/test/cus-api";
|
||||
String api = "https://ecology.yeyaguitu.cn/api/workflow/paService/doCreateRequest";
|
||||
String token = (String) testGetoken("https://ecology.yeyaguitu.cn").get("token");
|
||||
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
// 封装请求头参数
|
||||
RSA rsa = new RSA(null, spk);
|
||||
// 对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64("1", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
Map<String, String> head = new HashMap<>();
|
||||
head.put("appid", APPID);
|
||||
head.put("token", token);
|
||||
head.put("userid", encryptUserid);
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("mainData", "[{\n" +
|
||||
"\t\"fieldName\":\"cs1\",\n" +
|
||||
"\t\"fieldValue\":\"api测试1\"\n" +
|
||||
"},{\n" +
|
||||
"\t\"fieldName\":\"cs2\",\n" +
|
||||
"\t\"fieldValue\":\"api测试2\"\n" +
|
||||
"},{\n" +
|
||||
"\t\"fieldName\":\"cs3\",\n" +
|
||||
"\t\"fieldValue\":\"api测试3\"\n" +
|
||||
"},{\n" +
|
||||
"\t\"fieldName\":\"sjid\",\n" +
|
||||
"\t\"fieldValue\":\"8\"\n" +
|
||||
"},{\n" +
|
||||
"\t\"fieldName\":\"bmllan\",\n" +
|
||||
"\t\"fieldValue\":\"5\"\n" +
|
||||
"},{\n" +
|
||||
"\t\"fieldName\":\"mc\",\n" +
|
||||
"\t\"fieldValue\":\"不1道\"\n" +
|
||||
"}]");
|
||||
body.put("requestName", "api流程测试调用接口校验参数");
|
||||
body.put("workflowId", "44");
|
||||
ResponeVo responeVo = null;
|
||||
head.put("Content-Type", MediaType.APPLICATION_FORM_URLENCODED + ";charset=utf-8");
|
||||
try {
|
||||
responeVo = httpUtils.apiPost(api, body, head);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
System.out.println(responeVo);
|
||||
// ResponeVo responeVo = null;
|
||||
// try {
|
||||
// responeVo = httpUtils.apiGet(api, head);
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// System.out.println(JSON.toJSONString(responeVo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一步:
|
||||
* <p>
|
||||
* 调用ecology注册接口,根据appid进行注册,将返回服务端公钥和Secret信息
|
||||
*/
|
||||
public Map<String, Object> testRegist(String address) {
|
||||
// 获取当前系统RSA加密的公钥
|
||||
RSA rsa = new RSA();
|
||||
String publicKey = rsa.getPublicKeyBase64();
|
||||
String privateKey = rsa.getPrivateKeyBase64();
|
||||
// 客户端RSA私钥
|
||||
SYSTEM_CACHE.put("LOCAL_PRIVATE_KEY", privateKey);
|
||||
// 客户端RSA公钥
|
||||
SYSTEM_CACHE.put("LOCAL_PUBLIC_KEY", publicKey);
|
||||
// 调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address + "/api/ec/dev/auth/regist")
|
||||
.header("appid", APPID)
|
||||
.header("cpk", publicKey)
|
||||
.timeout(2000)
|
||||
.execute().body();
|
||||
// 打印ECOLOGY响应信息
|
||||
System.out.println("testRegist():" + data);
|
||||
Map<String, Object> datas = JSONUtil.parseObj(data);
|
||||
// ECOLOGY返回的系统公钥
|
||||
SYSTEM_CACHE.put("SERVER_PUBLIC_KEY", StrUtil.nullToEmpty((String) datas.get("spk")));
|
||||
// ECOLOGY返回的系统密钥
|
||||
SYSTEM_CACHE.put("SERVER_SECRET", StrUtil.nullToEmpty((String) datas.get("secrit")));
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第二步:
|
||||
* <p>
|
||||
* 通过第一步中注册系统返回信息进行获取token信息
|
||||
*/
|
||||
public Map<String, Object> testGetoken(String address) {
|
||||
// 从系统缓存或者数据库中获取ECOLOGY系统公钥和Secret信息
|
||||
String secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
||||
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
// 如果为空,说明还未进行注册,调用注册接口进行注册认证与数据更新
|
||||
if (Objects.isNull(secret) || Objects.isNull(spk)) {
|
||||
testRegist(address);
|
||||
// 重新获取最新ECOLOGY系统公钥和Secret信息
|
||||
secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
||||
spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
}
|
||||
// 公钥加密,所以RSA对象私钥为null
|
||||
RSA rsa = new RSA(null, spk);
|
||||
// 对秘钥进行加密传输,防止篡改数据
|
||||
String encryptSecret = rsa.encryptBase64(secret, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
// 调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address + "/api/ec/dev/auth/applytoken")
|
||||
.header("appid", APPID)
|
||||
.header("secret", encryptSecret)
|
||||
.header("time", "3600")
|
||||
.execute().body();
|
||||
System.out.println("testGetoken():" + data);
|
||||
Map<String, Object> datas = JSONUtil.parseObj(data);
|
||||
// ECOLOGY返回的token
|
||||
// TODO 为Token缓存设置过期时间
|
||||
SYSTEM_CACHE.put("SERVER_TOKEN", StrUtil.nullToEmpty((String) datas.get("token")));
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三步:
|
||||
* <p>
|
||||
* 调用ecology系统的rest接口,请求头部带上token和用户标识认证信息
|
||||
*
|
||||
* @param address ecology系统地址
|
||||
* @param api rest api 接口地址(该测试代码仅支持GET请求)
|
||||
* @param jsonParams 请求参数json串
|
||||
* <p>
|
||||
* 注意:ECOLOGY系统所有POST接口调用请求头请设置 "Content-Type","application/x-www-form-urlencoded; charset=utf-8"
|
||||
*/
|
||||
public String testRestful(String address, String api, String jsonParams) {
|
||||
// ECOLOGY返回的token
|
||||
String token = SYSTEM_CACHE.get("SERVER_TOKEN");
|
||||
if (StrUtil.isEmpty(token)) {
|
||||
token = (String) testGetoken(address).get("token");
|
||||
}
|
||||
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||
// 封装请求头参数
|
||||
RSA rsa = new RSA(null, spk);
|
||||
// 对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64("1", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
// 调用ECOLOGY系统接口,注意此处的disableCookie,可翻阅hutool的文档查看
|
||||
String data = HttpRequest
|
||||
.get(address + api)
|
||||
.header("appid", APPID)
|
||||
.header("token", token)
|
||||
.header("userid", encryptUserid)
|
||||
.body(jsonParams)
|
||||
.execute().body();
|
||||
System.out.println("testRestful():" + data);
|
||||
return data;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -14,5 +14,5 @@ import lombok.ToString;
|
|||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ExcelBody extends ExcelCell{
|
||||
public class ExcelBody extends ExcelCell {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package youhong.ai.utiltest;
|
||||
package youhong.ai.utiltest.excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue