添加文件
commit
a9835d1cdf
|
@ -9,6 +9,42 @@ const WfForm = {
|
||||||
isMobile: () => {
|
isMobile: () => {
|
||||||
// true表示是eMobile、微信、钉钉等移动终端,false代表PC端
|
// true表示是eMobile、微信、钉钉等移动终端,false代表PC端
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 4.6 函数式自定义渲染表单字段
|
||||||
|
* 最低版本要求:KB900190701
|
||||||
|
*
|
||||||
|
* 以函数返回值方式自定义渲染表单字段,支持全部的字段类型,可实现基于原组件追加/复写/重新布局等等
|
||||||
|
*
|
||||||
|
* 建议结合ecode工具,放到模块加载前调用,使用JSX,可实现与表单字段渲染有关的二次开发
|
||||||
|
*
|
||||||
|
* 此接口的优先级高于4.4、4.5,即使用此接口代理的字段,如再使用4.4、4.5会直接无效
|
||||||
|
*
|
||||||
|
* proxyFieldContentComp: function(fieldid,fn)
|
||||||
|
* @param convertFieldNameToId
|
||||||
|
* @param customerRender
|
||||||
|
*/
|
||||||
|
proxyFieldContentComp(convertFieldNameToId, customerRender = (info, compFn) => {
|
||||||
|
// console.log("字段id:",info.fieldid);
|
||||||
|
// console.log("明细行号:",info.rowIndex);
|
||||||
|
// console.log("字段只读必填属性:",info.viewAttr);
|
||||||
|
// console.log("字段值:",info.fieldValue);
|
||||||
|
// //返回自定义渲染的组件
|
||||||
|
// return React.createElement("div", {}, ["想怎么玩就怎么玩"]);
|
||||||
|
// //返回原组件
|
||||||
|
// return compFn();
|
||||||
|
// //返回基于原组件的复写组件
|
||||||
|
// return React.createElement("div", {}, ["前置组件",compFn(),"后置组件"]);
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* //如果此接口调用在代码块、custompage等(非模块加载前调用),需强制渲染字段一次
|
||||||
|
* WfForm.forceRenderField("field111");
|
||||||
|
* @param field
|
||||||
|
*/
|
||||||
|
forceRenderField(field) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WfForm.OPER_SAVE = '保存'
|
WfForm.OPER_SAVE = '保存'
|
||||||
WfForm.OPER_SUBMIT = '提交/批准/提交需反馈/不需反馈等'
|
WfForm.OPER_SUBMIT = '提交/批准/提交需反馈/不需反馈等'
|
||||||
|
|
|
@ -59,7 +59,7 @@ function initTimeoutDate(){
|
||||||
console.log('计算下次超时日期 ', computeTimeoutDate);
|
console.log('计算下次超时日期 ', computeTimeoutDate);
|
||||||
var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField));
|
var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField));
|
||||||
var detail2LineNum = WfForm.getDetailRowCount("detail_2");
|
var detail2LineNum = WfForm.getDetailRowCount("detail_2");
|
||||||
setTimeout(()=>{
|
setTimeout(function (){
|
||||||
WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate});
|
WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate});
|
||||||
// 判断流程提交走向
|
// 判断流程提交走向
|
||||||
console.log('主表跟踪触发行数 : ', trackingLine)
|
console.log('主表跟踪触发行数 : ', trackingLine)
|
||||||
|
@ -101,7 +101,10 @@ function getCurrentDate() {
|
||||||
|
|
||||||
function parseDate(date) {
|
function parseDate(date) {
|
||||||
var currentYear = date.getFullYear();
|
var currentYear = date.getFullYear();
|
||||||
var currentMonth = date.getMonth() + 1; // getMonth()返回0~11,需要加1
|
var currentMonth = date.getMonth() + 1;// getMonth()返回0~11,需要加1
|
||||||
|
if(currentMonth < 10){
|
||||||
|
currentMonth = '0' + currentMonth;
|
||||||
|
}
|
||||||
var currentDay = date.getDate();
|
var currentDay = date.getDate();
|
||||||
return currentYear + '-' + currentMonth + '-' + currentDay;
|
return currentYear + '-' + currentMonth + '-' + currentDay;
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,3 +788,125 @@ $(() => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
/* ******************* 年假计算 end ******************* */
|
/* ******************* 年假计算 end ******************* */
|
||||||
|
|
||||||
|
|
||||||
|
/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 start ******************* */
|
||||||
|
$(() => {
|
||||||
|
const config = {
|
||||||
|
// 明细表
|
||||||
|
detail: 'detail_3',
|
||||||
|
// 明细字段
|
||||||
|
detailField: 'jbxxnr',
|
||||||
|
// 主表字段
|
||||||
|
mainField: 'jbxxnr'
|
||||||
|
}
|
||||||
|
|
||||||
|
function runJs() {
|
||||||
|
let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail);
|
||||||
|
let rowIndexArr = rowIndexStr.split(",");
|
||||||
|
let value = ""
|
||||||
|
rowIndexArr.forEach(item => {
|
||||||
|
let fieldId = WfForm.convertFieldNameToId(config.detailField, config.detail) + "_" + item
|
||||||
|
let fieldValue = WfForm.getFieldValue(fieldId);
|
||||||
|
value += (+item + 1) + "、" + fieldValue + "\n";
|
||||||
|
})
|
||||||
|
WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.mainField), {value})
|
||||||
|
}
|
||||||
|
|
||||||
|
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => {
|
||||||
|
runJs()
|
||||||
|
callback()
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 end ******************* */
|
||||||
|
|
||||||
|
|
||||||
|
/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 start ******************* */
|
||||||
|
$(() => {
|
||||||
|
const config = {
|
||||||
|
// 明细表
|
||||||
|
detail: 'detail_1',
|
||||||
|
// 映射关系
|
||||||
|
mapping: [{
|
||||||
|
// 明细表字段
|
||||||
|
detailField: 'jbsj',
|
||||||
|
// 主表字段
|
||||||
|
mainField: 'zzjsrq',
|
||||||
|
}, {
|
||||||
|
// 明细表字段
|
||||||
|
detailField: 'jbtd',
|
||||||
|
// 主表字段
|
||||||
|
mainField: 'jbqd',
|
||||||
|
}],
|
||||||
|
dateSort: 'jbsj'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function runJs() {
|
||||||
|
let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail);
|
||||||
|
let rowIndexArray = rowIndexStr.split(",");
|
||||||
|
const detailData = []
|
||||||
|
rowIndexArray.forEach(item => {
|
||||||
|
let obj = {}
|
||||||
|
config.mapping.forEach(mapping => {
|
||||||
|
obj[mapping.detailField] = WfForm.getFieldValue(WfForm.convertFieldNameToId(mapping.detailField, config.detail) + "_" + item)
|
||||||
|
})
|
||||||
|
detailData.push(obj)
|
||||||
|
})
|
||||||
|
console.log(detailData)
|
||||||
|
let minDateObj = filterByMinDate(detailData, config.dateSort);
|
||||||
|
console.log(minDateObj)
|
||||||
|
config.mapping.forEach(item => {
|
||||||
|
WfForm.changeFieldValue(WfForm.convertFieldNameToId(item.mainField), {
|
||||||
|
value: minDateObj[item.detailField]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterByMinDate(arr, key) {
|
||||||
|
return arr.reduce((min, obj) => {
|
||||||
|
if (!min || new Date(obj[key]) <= new Date(min[key])) {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
return min;
|
||||||
|
}, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => {
|
||||||
|
runJs()
|
||||||
|
callback()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 end ******************* */
|
||||||
|
|
||||||
|
/* ******************* youhong.ai 主表选择框自定义渲染为进度条 start ******************* */
|
||||||
|
$(() => {
|
||||||
|
const field = 'jz'
|
||||||
|
const config = {
|
||||||
|
'-1': 0,
|
||||||
|
'0': 20,
|
||||||
|
'1': 40,
|
||||||
|
'2': 60,
|
||||||
|
'3': 80,
|
||||||
|
'4': 100,
|
||||||
|
}
|
||||||
|
|
||||||
|
function customerRender(info, compFn) {
|
||||||
|
let fieldValue = info.fieldValue;
|
||||||
|
if (!fieldValue) {
|
||||||
|
fieldValue = '-1'
|
||||||
|
}
|
||||||
|
let {WeaProgress} = ecCom
|
||||||
|
return React.createElement(WeaProgress, {
|
||||||
|
strokeColor: '#6c8dc1',
|
||||||
|
percent: config[fieldValue]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
WfForm.proxyFieldContentComp(WfForm.convertFieldNameToId(field).replace("field", ""), customerRender)
|
||||||
|
setTimeout(() => {
|
||||||
|
WfForm.forceRenderField(WfForm.convertFieldNameToId(field));
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
/* ******************* youhong.ai 主表选择框自定义渲染为进度条 end ******************* */
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
pom.xml
6
pom.xml
|
@ -38,6 +38,12 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.javassist</groupId>
|
||||||
|
<artifactId>javassist</artifactId>
|
||||||
|
<version>3.27.0-GA</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- mapstruct -->
|
<!-- mapstruct -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
|
|
|
@ -85,10 +85,11 @@ public class GenerateFileUtil {
|
||||||
if (hasRequired) {
|
if (hasRequired) {
|
||||||
// 必填参数
|
// 必填参数
|
||||||
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class);
|
||||||
String fieldDesc = requiredMark.value();
|
String fieldDesc = requiredMark.desc();
|
||||||
Map<String, String> param = new HashMap<>();
|
Map<String, String> param = new HashMap<>(8);
|
||||||
param.put("name", name);
|
param.put("name", name);
|
||||||
param.put("desc", fieldDesc);
|
param.put("desc", fieldDesc);
|
||||||
|
param.put("example", requiredMark.value());
|
||||||
param.put("isRequired", "是");
|
param.put("isRequired", "是");
|
||||||
boolean hasDefaultTestValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
boolean hasDefaultTestValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class);
|
||||||
if (hasDefaultTestValue) {
|
if (hasDefaultTestValue) {
|
||||||
|
@ -105,9 +106,10 @@ public class GenerateFileUtil {
|
||||||
ActionOptionalParam actionOptionalParam = declaredField.getAnnotation(ActionOptionalParam.class);
|
ActionOptionalParam actionOptionalParam = declaredField.getAnnotation(ActionOptionalParam.class);
|
||||||
String fieldDesc = actionOptionalParam.desc();
|
String fieldDesc = actionOptionalParam.desc();
|
||||||
String defaultValue = actionOptionalParam.value();
|
String defaultValue = actionOptionalParam.value();
|
||||||
Map<String, String> param = new HashMap<>();
|
Map<String, String> param = new HashMap<>(8);
|
||||||
param.put("name", name);
|
param.put("name", name);
|
||||||
param.put("desc", fieldDesc);
|
param.put("desc", fieldDesc);
|
||||||
|
param.put("example", defaultValue);
|
||||||
param.put("isRequired", "否");
|
param.put("isRequired", "否");
|
||||||
param.put("defaultValue", defaultValue);
|
param.put("defaultValue", defaultValue);
|
||||||
paramList.add(param);
|
paramList.add(param);
|
||||||
|
|
|
@ -12,14 +12,14 @@ import java.util.Map;
|
||||||
* @author youHong.ai
|
* @author youHong.ai
|
||||||
*/
|
*/
|
||||||
public class ScriptUtil {
|
public class ScriptUtil {
|
||||||
private static final JexlEngine jexl = new JexlBuilder().create();
|
private static final JexlEngine JEXL = new JexlBuilder().create();
|
||||||
|
|
||||||
public static Object invokeScript(String script, Map<String, Object> params) {
|
public static Object invokeScript(String script, Map<String, Object> params) {
|
||||||
JexlContext jc = new MapContext();
|
JexlContext jc = new MapContext();
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||||
jc.set(entry.getKey(), entry.getValue());
|
jc.set(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
JexlExpression expression = jexl.createExpression(script);
|
JexlExpression expression = JEXL.createExpression(script);
|
||||||
return expression.evaluate(jc);
|
return expression.evaluate(jc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1210,9 +1210,15 @@ public class Util extends weaver.general.Util {
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
|
InputStreamReader reader = null;
|
||||||
try {
|
try {
|
||||||
inputStream = new BufferedInputStream(new FileInputStream(path));
|
inputStream = new BufferedInputStream(new FileInputStream(path));
|
||||||
prop.load(inputStream);
|
/**
|
||||||
|
* <h2>解决配置文件中 值包含中文乱码问题</h2>
|
||||||
|
* <h2>xuanran.wang 2023-06-26 10:16</h2>
|
||||||
|
**/
|
||||||
|
reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||||
|
prop.load(reader);
|
||||||
Enumeration<?> enumeration = prop.propertyNames();
|
Enumeration<?> enumeration = prop.propertyNames();
|
||||||
while (enumeration.hasMoreElements()) {
|
while (enumeration.hasMoreElements()) {
|
||||||
String key = String.valueOf(enumeration.nextElement());
|
String key = String.valueOf(enumeration.nextElement());
|
||||||
|
@ -1222,6 +1228,9 @@ public class Util extends weaver.general.Util {
|
||||||
throw new RuntimeException("找不到文件:" + path);
|
throw new RuntimeException("找不到文件:" + path);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
if (reader != null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package aiyh.utils.function;
|
package aiyh.utils.function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>三个参数的function</h1>
|
* <h1>四个参数的function</h1>
|
||||||
*
|
*
|
||||||
* <p>create: 2023/6/14 21:30</p>
|
* <p>create: 2023/6/14 21:30</p>
|
||||||
*
|
*
|
||||||
|
|
|
@ -1066,9 +1066,18 @@ public class HttpUtils {
|
||||||
List<NameValuePair> nvps = new ArrayList<>();
|
List<NameValuePair> nvps = new ArrayList<>();
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||||
|
|
||||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||||
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
// 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.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
|
@ -1076,11 +1085,19 @@ public class HttpUtils {
|
||||||
List<NameValuePair> nvps = new ArrayList<>();
|
List<NameValuePair> nvps = new ArrayList<>();
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||||
|
|
||||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
// 修复请求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.setEntity(new UrlEncodedFormEntity(nvps));
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps, DEFAULT_ENCODING));
|
||||||
// } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
// } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
||||||
} else {
|
} else {
|
||||||
StringEntity stringEntity;
|
StringEntity stringEntity;
|
||||||
|
@ -1095,6 +1112,22 @@ public class HttpUtils {
|
||||||
return httpPost;
|
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 {
|
private HttpPost handleHttpPost(String url, Map<String, String> headerMap, Map<String, Object> paramsMap) throws UnsupportedEncodingException {
|
||||||
return handleHttpPostObject(url, headerMap, paramsMap);
|
return handleHttpPostObject(url, headerMap, paramsMap);
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1294,17 @@ public class HttpUtils {
|
||||||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||||
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
// 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.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||||
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
|
@ -1270,7 +1313,17 @@ public class HttpUtils {
|
||||||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||||
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
// nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
|
||||||
// 修复请求form表单提交时,参数值被双引号括了起来
|
// 修复请求form表单提交时,参数值被双引号括了起来
|
||||||
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
|
// 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));
|
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
||||||
|
|
|
@ -312,44 +312,60 @@ public class ResultMapper {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (o instanceof Map) {
|
if (o instanceof Map) {
|
||||||
|
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
|
||||||
for (int i = 0; i < columnName.length; i++) {
|
for (int i = 0; i < columnName.length; i++) {
|
||||||
String columnType = columnTypeName[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 ("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 (enable) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
continue;
|
((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;
|
||||||
|
}
|
||||||
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
||||||
|
}
|
||||||
|
((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));
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
|
||||||
}
|
|
||||||
((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;
|
continue;
|
||||||
}
|
}
|
||||||
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
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;
|
||||||
|
}
|
||||||
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
|
||||||
|
}
|
||||||
|
((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) {
|
if (enable) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
||||||
}
|
}
|
||||||
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1));
|
((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.getFloat(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.getFloat(i + 1));
|
((Map<? super Object, ? super Object>) o).put(columnName[i], rs.getString(i + 1));
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (enable) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
|
||||||
}
|
|
||||||
((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;
|
continue;
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
|
@ -451,6 +467,7 @@ public class ResultMapper {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (o instanceof Map) {
|
if (o instanceof Map) {
|
||||||
|
ToLowerCase toLowerCase = method.getAnnotation(ToLowerCase.class);
|
||||||
for (int i = 0; i < columnName.length; i++) {
|
for (int i = 0; i < columnName.length; i++) {
|
||||||
String columnType = "";
|
String columnType = "";
|
||||||
if (i >= columnTypeName.length) {
|
if (i >= columnTypeName.length) {
|
||||||
|
@ -459,29 +476,39 @@ public class ResultMapper {
|
||||||
columnType = columnTypeName[i];
|
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 ("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 (enable) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i]));
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
continue;
|
((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;
|
||||||
|
}
|
||||||
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
||||||
|
}
|
||||||
|
((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));
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
|
||||||
}
|
|
||||||
((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;
|
continue;
|
||||||
}
|
}
|
||||||
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
|
||||||
if (enable) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
continue;
|
((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;
|
||||||
|
}
|
||||||
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
||||||
|
}
|
||||||
|
((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));
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
|
||||||
}
|
|
||||||
((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;
|
continue;
|
||||||
}
|
}
|
||||||
if (method.isAnnotationPresent(Associations.class)) {
|
if (method.isAnnotationPresent(Associations.class)) {
|
||||||
|
@ -506,16 +533,23 @@ public class ResultMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (enable) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
|
if (Objects.nonNull(toLowerCase)) {
|
||||||
continue;
|
((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;
|
||||||
|
}
|
||||||
|
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
||||||
|
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
||||||
|
}
|
||||||
|
((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));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
|
|
||||||
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
|
|
||||||
}
|
|
||||||
((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;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.api.bokang.xiao.cus_login.controller;
|
||||||
|
|
||||||
|
import aiyh.utils.ApiResult;
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import com.api.bokang.xiao.cus_login.service.VerifyCodeService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName InvoiceSelectController
|
||||||
|
* @Author 肖博亢
|
||||||
|
* @Date 2023/2/2 16:21
|
||||||
|
* @Description <h1>发票勾选,查询</h1>
|
||||||
|
**/
|
||||||
|
|
||||||
|
@Path("/xbk/cusLogin")
|
||||||
|
public class VerifyController {
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
private final VerifyCodeService verifyCodeService = new VerifyCodeService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取验证码</h2>
|
||||||
|
* @param request 请求体
|
||||||
|
* @param response 响应体
|
||||||
|
* @param param 请求参数
|
||||||
|
* @return 请求结果
|
||||||
|
*/
|
||||||
|
@Path("/getCode")
|
||||||
|
@POST
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String getCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
||||||
|
try{
|
||||||
|
log.info("into getCode success params ==> "+param);
|
||||||
|
String verifyCode = verifyCodeService.getVerifyCode(param);
|
||||||
|
return ApiResult.success(verifyCode);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("getCode error ==> \n"+Util.getErrString(e));
|
||||||
|
return ApiResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>检查验证码</h2>
|
||||||
|
* @param request 请求体
|
||||||
|
* @param response 响应体
|
||||||
|
* @param param 请求参数
|
||||||
|
* @return 请求结果
|
||||||
|
*/
|
||||||
|
@Path("/checkCode")
|
||||||
|
@POST
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String checkCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
||||||
|
try{
|
||||||
|
log.info("into checkCode success params ==> "+param);
|
||||||
|
return ApiResult.success(verifyCodeService.checkVerifyCode(param));
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("checkCode error ==> \n"+Util.getErrString(e));
|
||||||
|
return ApiResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.api.bokang.xiao.cus_login.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Select;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Update;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DzInvoiceMapper
|
||||||
|
* @Author 肖博亢
|
||||||
|
* @Date 2023/2/2 17:03
|
||||||
|
* @Description <h1>发票信息查询</h1>
|
||||||
|
**/
|
||||||
|
|
||||||
|
@SqlMapper
|
||||||
|
public interface DzInvoiceMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>通过id查询发票信息</h2>
|
||||||
|
* @param ids 发票id字符串
|
||||||
|
* @return 发票信息集合
|
||||||
|
*/
|
||||||
|
@Select("select * from APInvoice where id in ($t{ids})")
|
||||||
|
List<Map<String,Object>> queryInvoiceList(@ParamMapper("ids") String ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新发票勾选状态</h2>
|
||||||
|
* @param checkStatus 勾选状态值
|
||||||
|
* @param fieldId 字段名
|
||||||
|
* @param fieldValue 字段值
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@Update("update fnaInvoiceLedger set check_status = #{checkStatus} where $t{fieldId} = #{fieldValue}")
|
||||||
|
boolean updateInvoiceCheckStatus(@ParamMapper("checkStatus") int checkStatus,
|
||||||
|
@ParamMapper("fieldId") String fieldId,
|
||||||
|
@ParamMapper("fieldValue") Object fieldValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新发票勾选状态</h2>
|
||||||
|
* @param checkStatus 勾选状态值
|
||||||
|
* @param fieldId 字段名
|
||||||
|
* @param fieldValue 字段值
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@Update("update fnaInvoiceLedger set check_status = #{checkStatus} where $t{fieldId} in ($t{fieldValue})")
|
||||||
|
boolean batchUpdateInvoiceCheckStatus(@ParamMapper("checkStatus") int checkStatus,
|
||||||
|
@ParamMapper("fieldId") String fieldId,
|
||||||
|
@ParamMapper("fieldValue") String fieldValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询已经勾选过的发票信息</h2>
|
||||||
|
* @return 发票信息集合
|
||||||
|
*/
|
||||||
|
@Select("select * from fnaInvoiceLedger where (check_status = 2 or check_status = 3) and hxjksflr = 'Y'")
|
||||||
|
List<Map<String,Object>> queryOnChooseInvoices();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.api.bokang.xiao.cus_login.service;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
|
import com.cloudstore.dev.api.util.Util_DataCache;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName VerifyCodeService
|
||||||
|
* @Author 肖博亢
|
||||||
|
* @Date 2023/6/14 14:49
|
||||||
|
* @Description <h1></h1>
|
||||||
|
**/
|
||||||
|
public class VerifyCodeService {
|
||||||
|
|
||||||
|
private final HttpUtils httpUtils = new HttpUtils();
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码
|
||||||
|
* @param param 参数信息
|
||||||
|
* @return 发送结果
|
||||||
|
*/
|
||||||
|
public String getVerifyCode(Map<String,Object> param){
|
||||||
|
String loginUser = Util.null2String(param.get("loginUser"));
|
||||||
|
//todo 发送请求获取验证码
|
||||||
|
//将验证码加入缓存中
|
||||||
|
Util_DataCache.setObjVal(loginUser,"9088",60);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证验证码
|
||||||
|
* @param param 参数信息
|
||||||
|
* @return 验证结果
|
||||||
|
*/
|
||||||
|
public boolean checkVerifyCode(Map<String,Object> param){
|
||||||
|
String loginUser = Util.null2String(param.get("loginUser"));
|
||||||
|
String verifyCode = Util.null2String(param.get("verifyCode"));
|
||||||
|
String tempVerifyCode = Util.null2String(Util_DataCache.getObjVal(loginUser));
|
||||||
|
if("".equals(tempVerifyCode)){
|
||||||
|
throw new CustomerException("验证码已过期!请重新获取验证码");
|
||||||
|
}
|
||||||
|
if(verifyCode.equals(tempVerifyCode)){
|
||||||
|
Util_DataCache.clearVal(loginUser);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
throw new CustomerException("验证码不正确!请重新输入");
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,11 +12,14 @@ import weaver.hrm.User;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.StreamingOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -77,4 +80,28 @@ public class BankController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/export")
|
||||||
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
public Response exportExcel(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) throws IOException {
|
||||||
|
try {
|
||||||
|
log.info("====== into exportExcel success =======");
|
||||||
|
log.info("param:"+param);
|
||||||
|
String dialogTitle = Util.null2String(param.get("dialogTitle"));
|
||||||
|
String fileName = dialogTitle + Util.getTime("yyyy-MM-dd") + ".xlsx";
|
||||||
|
StreamingOutput streamingOutput = outputStream -> {
|
||||||
|
bankService.export(outputStream,param);
|
||||||
|
};
|
||||||
|
log.info("fileName==>"+fileName);
|
||||||
|
String encodedFileName = URLEncoder.encode(fileName, "UTF-8");
|
||||||
|
return Response.ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
// 指定编码方式为 UTF-8
|
||||||
|
.header("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName)
|
||||||
|
.build();
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("exportExcel error ==> "+Util.getErrString(e));
|
||||||
|
return Response.ok(ApiResult.error("导出文件失败!"), MediaType.APPLICATION_JSON).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
package com.api.bokang.xiao.zhenn.service;
|
package com.api.bokang.xiao.zhenn.service;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.ExcelWriter;
|
||||||
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.api.bokang.xiao.zhenn.mapper.BankMapper;
|
import com.api.bokang.xiao.zhenn.mapper.BankMapper;
|
||||||
|
import com.api.bokang.xiao.zhenn.util.GenerateClassUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import weaver.bokang.xiao.common.CommonUtil;
|
import weaver.bokang.xiao.common.CommonUtil;
|
||||||
import weaver.bokang.xiao.common.mapper.WorkflowMapper;
|
import weaver.bokang.xiao.common.mapper.WorkflowMapper;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -107,8 +113,8 @@ public class BankService {
|
||||||
bankBaseInfo.put("bankAccount",bankAccount);
|
bankBaseInfo.put("bankAccount",bankAccount);
|
||||||
//求总和
|
//求总和
|
||||||
Map<String, Object> amountMap = new HashMap<>();
|
Map<String, Object> amountMap = new HashMap<>();
|
||||||
double bankDayAmount = this.queryBankDayAmount(param);
|
double bankDayAmount = this.queryBankStatementBalance(param);//sap余额信息
|
||||||
double bankStatementBalance = this.queryBankStatementBalance(param);
|
double bankStatementBalance = this.queryBankDayAmount(param);//银行余额信息
|
||||||
double bankInDifference = bankInTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum();
|
double bankInDifference = bankInTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum();
|
||||||
double oaInDifference = 0;
|
double oaInDifference = 0;
|
||||||
double bankOutDifference = bankOutTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum();
|
double bankOutDifference = bankOutTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum();
|
||||||
|
@ -165,4 +171,22 @@ public class BankService {
|
||||||
return bankMapper.queryBankStatementBalance(param);
|
return bankMapper.queryBankStatementBalance(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出Excel处理方法
|
||||||
|
* @param outputStream 请求输出流
|
||||||
|
* @param param 参数信息
|
||||||
|
*/
|
||||||
|
public void export(OutputStream outputStream, Map<String, Object> param) {
|
||||||
|
log.info("导出Excel export");
|
||||||
|
List<Map<String,Object>> columns = (List<Map<String, Object>>) param.get("columns");
|
||||||
|
List<Map<String,Object>> dataSource = (List<Map<String, Object>>) param.get("dataSource");
|
||||||
|
String className = Util.null2String(param.get("type"));
|
||||||
|
Map<String,Object> classMessage = new HashMap<>();
|
||||||
|
classMessage.put("columns",columns);
|
||||||
|
classMessage.put("className",className);
|
||||||
|
Class<?> aClass = GenerateClassUtil.generateClassByMap(classMessage);
|
||||||
|
List<Object> objects = GenerateClassUtil.covertClassList(dataSource, aClass);
|
||||||
|
log.info("excel List ==>"+objects.size());
|
||||||
|
EasyExcel.write(outputStream, aClass).sheet("Sheet1").doWrite(objects);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
package com.api.bokang.xiao.zhenn.util;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import javassist.*;
|
||||||
|
import javassist.bytecode.AnnotationsAttribute;
|
||||||
|
import javassist.bytecode.ConstPool;
|
||||||
|
import javassist.bytecode.annotation.Annotation;
|
||||||
|
import javassist.bytecode.annotation.ArrayMemberValue;
|
||||||
|
import javassist.bytecode.annotation.MemberValue;
|
||||||
|
import javassist.bytecode.annotation.StringMemberValue;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName GenerateClassUtil
|
||||||
|
* @Author 肖博亢
|
||||||
|
* @Date 2023/6/16 11:04
|
||||||
|
* @Description <h1></h1>
|
||||||
|
**/
|
||||||
|
public class GenerateClassUtil {
|
||||||
|
|
||||||
|
private static final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
private static final Map<String,Class<?>> CLASS_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 利用javassist动态生成class
|
||||||
|
* @param classMessage 类基础信息
|
||||||
|
* @return Class<?>
|
||||||
|
*/
|
||||||
|
public static Class<?> generateClassByMap(Map<String,Object> classMessage){
|
||||||
|
String className = Util.null2String(classMessage.get("className"));
|
||||||
|
//className = className+System.currentTimeMillis();
|
||||||
|
List<Map<String, String>> columns = (List<Map<String, String>>) classMessage.get("columns");
|
||||||
|
if(StringUtils.isBlank(className)){
|
||||||
|
throw new CustomerException("GenerateClass Exception 类名不能为空!!!");
|
||||||
|
}
|
||||||
|
if(Objects.isNull(columns) || columns.isEmpty()){
|
||||||
|
throw new CustomerException("GenerateClass Exception 列信息不能为空!!!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Class<?> cacheClass = CLASS_MAP.get(className);
|
||||||
|
if(Objects.nonNull(cacheClass)){
|
||||||
|
return cacheClass;
|
||||||
|
}
|
||||||
|
// 创建 ClassPool 对象
|
||||||
|
ClassPool pool = ClassPool.getDefault();
|
||||||
|
CtClass cc = null;
|
||||||
|
//从缓存中获取类
|
||||||
|
try {
|
||||||
|
cc = pool.getCtClass(className);
|
||||||
|
if(Objects.isNull(cc)) {
|
||||||
|
// 创建一个新的类
|
||||||
|
cc = pool.makeClass(className);
|
||||||
|
}
|
||||||
|
return cc.toClass();
|
||||||
|
}catch (NotFoundException e){
|
||||||
|
// 创建一个新的类
|
||||||
|
cc = pool.makeClass(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map<String, String> column : columns) {
|
||||||
|
String title = column.get("title");
|
||||||
|
String dataIndex = column.get("dataIndex");
|
||||||
|
CtField field = new CtField(ClassPool.getDefault().get(String.class.getName()), dataIndex, cc);
|
||||||
|
field.setModifiers(Modifier.PRIVATE);
|
||||||
|
cc.addField(field);
|
||||||
|
cc.addMethod(CtNewMethod.setter("set" + dataIndex.substring(0, 1).toUpperCase() + dataIndex.substring(1), field));
|
||||||
|
cc.addMethod(CtNewMethod.getter("get" + dataIndex.substring(0, 1).toUpperCase() + dataIndex.substring(1), field));
|
||||||
|
field.getFieldInfo().addAttribute(new AnnotationsAttribute(field.getFieldInfo().getConstPool(), AnnotationsAttribute.visibleTag));
|
||||||
|
// 添加 ExcelProperty 注解
|
||||||
|
ConstPool cp = cc.getClassFile().getConstPool();
|
||||||
|
AnnotationsAttribute annotationsAttribute = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
|
||||||
|
Annotation annotation = new Annotation(ExcelProperty.class.getName(), cp);
|
||||||
|
//annotation.addMemberValue("value", new StringMemberValue(Arrays.toString(new String[] {title}), cp));
|
||||||
|
StringMemberValue stringMemberValue = new StringMemberValue(title, cp);
|
||||||
|
MemberValue[] memberValues = new MemberValue[]{stringMemberValue};
|
||||||
|
ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cp);
|
||||||
|
arrayMemberValue.setValue(memberValues);
|
||||||
|
annotation.addMemberValue("value", arrayMemberValue);
|
||||||
|
annotationsAttribute.addAnnotation(annotation);
|
||||||
|
field.getFieldInfo().addAttribute(annotationsAttribute);
|
||||||
|
}
|
||||||
|
Class<?> aClass = cc.toClass();
|
||||||
|
CLASS_MAP.put(className,aClass);
|
||||||
|
return aClass;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("GenerateClass error!"+Util.getErrString(e));
|
||||||
|
throw new CustomerException("GenerateClass error "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将Map转为实体类
|
||||||
|
* @param dataSource map集合
|
||||||
|
* @param clazz 实体类类信息
|
||||||
|
* @return 转换后List
|
||||||
|
*/
|
||||||
|
public static List<Object> covertClassList(List<Map<String,Object>> dataSource,Class<?> clazz){
|
||||||
|
if(Objects.isNull(dataSource) || dataSource.isEmpty()){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return dataSource.stream().map(item ->{
|
||||||
|
try {
|
||||||
|
Object data = clazz.newInstance();
|
||||||
|
Field[] declaredFields = clazz.getDeclaredFields();
|
||||||
|
for (Field declaredField : declaredFields) {
|
||||||
|
declaredField.setAccessible(true);
|
||||||
|
String name = declaredField.getName();
|
||||||
|
String fieldVal = Util.null2String(item.get(name));
|
||||||
|
declaredField.set(data,fieldVal);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("covertClass error "+Util.getErrString(e));
|
||||||
|
throw new CustomerException("covertClass error 反射异常"+e.getMessage());
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -31,8 +31,30 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
|
||||||
|
|
||||||
private String interfaceName;
|
private String interfaceName;
|
||||||
|
|
||||||
|
/** 同步开始日期 */
|
||||||
|
private String fromDate;
|
||||||
|
|
||||||
|
/** 同步结束日期 */
|
||||||
|
private String toDate;
|
||||||
|
|
||||||
private final static String JobName = " SyncAccountTradeInfoJob ";
|
private final static String JobName = " SyncAccountTradeInfoJob ";
|
||||||
|
|
||||||
|
public String getFromDate() {
|
||||||
|
return fromDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromDate(String fromDate) {
|
||||||
|
this.fromDate = fromDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToDate() {
|
||||||
|
return toDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToDate(String toDate) {
|
||||||
|
this.toDate = toDate;
|
||||||
|
}
|
||||||
|
|
||||||
public String getInterfaceName() {
|
public String getInterfaceName() {
|
||||||
return interfaceName;
|
return interfaceName;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +70,7 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
|
||||||
ZennerApiService zennerApiService = new ZennerApiService();
|
ZennerApiService zennerApiService = new ZennerApiService();
|
||||||
try {
|
try {
|
||||||
logger.writeLog("-----" + JobName + " getInterfaceName------" + getInterfaceName());
|
logger.writeLog("-----" + JobName + " getInterfaceName------" + getInterfaceName());
|
||||||
|
logger.writeLog(String.format("params --- fromDate:%s toDate:%s",fromDate,toDate));
|
||||||
//银行
|
//银行
|
||||||
String bankApiUrl = zennerApiService.getSystemConfigValue("BANK_API_URL");
|
String bankApiUrl = zennerApiService.getSystemConfigValue("BANK_API_URL");
|
||||||
|
|
||||||
|
@ -103,8 +126,10 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
|
||||||
//xmlParams.put("from", "20220919");
|
//xmlParams.put("from", "20220919");
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.DAY_OF_MONTH, -1);
|
cal.set(Calendar.DAY_OF_MONTH, -1);
|
||||||
xmlParams.put("from", ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit));
|
String from = !"".equals(Util.null2String(this.fromDate)) ? this.fromDate : ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit);
|
||||||
xmlParams.put("to", ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit));
|
String to = !"".equals(Util.null2String(this.toDate)) ? this.toDate : ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit);
|
||||||
|
xmlParams.put("from", from);
|
||||||
|
xmlParams.put("to", to);
|
||||||
xmlParams.put("amountFrom", "1");
|
xmlParams.put("amountFrom", "1");
|
||||||
xmlParams.put("amountTo", "100000");
|
xmlParams.put("amountTo", "100000");
|
||||||
xmlParams.put("begnum", start + "");
|
xmlParams.put("begnum", start + "");
|
||||||
|
@ -312,6 +337,11 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
|
||||||
tradeInfo.setDirection(l4Element.getStringValue());
|
tradeInfo.setDirection(l4Element.getStringValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ("insid".equals(l4Element.getName())) {
|
||||||
|
if (!"".equals(l4Element.getStringValue())){
|
||||||
|
tradeInfo.setInsid(l4Element.getStringValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tradeInfoList.add(tradeInfo);
|
tradeInfoList.add(tradeInfo);
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.api.xuanran.wang.immc.controller;
|
||||||
|
|
||||||
|
import aiyh.utils.ApiResult;
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.xuanran.wang.immc.dto.ImmcWorkFlowToKafkaDto;
|
||||||
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.xuanran.wang.immc.service.WorkFlowToVmsAndMQService;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Context;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>智己流程操作下发kafka</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/6/21 15:40
|
||||||
|
*/
|
||||||
|
@Path("/wxr/immc/workflow/kafka")
|
||||||
|
public class ApiImmcWorkFlowToKafka {
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
private final WorkFlowToVmsAndMQService service = new WorkFlowToVmsAndMQService();
|
||||||
|
|
||||||
|
@Path("/del")
|
||||||
|
@POST
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public String delWorkFlowToKafka(@Context HttpServletRequest request,
|
||||||
|
@Context HttpServletResponse response,
|
||||||
|
@RequestBody ImmcWorkFlowToKafkaDto config){
|
||||||
|
try {
|
||||||
|
log.info("删除流程下发kafka配置对象 : " + JSONObject.toJSONString(config));
|
||||||
|
// ImmcWorkFlowToKafkaDto dto = JSONObject.parseObject(JSONObject.toJSONString(config), ImmcWorkFlowToKafkaDto.class);
|
||||||
|
service.workFlowToKafkaByDto(config);
|
||||||
|
return ApiResult.successNoData();
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("删除流程下发kafka执行失败 : [ " + e.getMessage() + " ]");
|
||||||
|
log.error(Util.getErrString(e));
|
||||||
|
return ApiResult.error("下发kafka失败! " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.api.xuanran.wang.immc.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>vo 智己流程下发kafka</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/6/21 16:08
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class ImmcWorkFlowToKafkaDto {
|
||||||
|
private String onlyMark;
|
||||||
|
private Integer billTable;
|
||||||
|
private String config;
|
||||||
|
private Integer requestId;
|
||||||
|
private String skip;
|
||||||
|
}
|
|
@ -44,7 +44,7 @@ public interface UserInfoMapper {
|
||||||
"or concat(',',fbleader,',') like concat(',',#{uID},',')\n" +
|
"or concat(',',fbleader,',') like concat(',',#{uID},',')\n" +
|
||||||
"or concat(',',hrleader,',') like concat(',',#{uID},',')\n" +
|
"or concat(',',hrleader,',') like concat(',',#{uID},',')\n" +
|
||||||
"or concat(',',generalmanager,',') like concat(',', #{uID},',')")*/
|
"or concat(',',generalmanager,',') like concat(',', #{uID},',')")*/
|
||||||
@Select("select count(id) from uf_hotelinfo where\n" +
|
@Select("select * from uf_hotelinfo where\n" +
|
||||||
"concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
"concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||||
|
@ -61,7 +61,7 @@ public interface UserInfoMapper {
|
||||||
"or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',headofengineering,',') like concat(',',#{userId},',')")
|
"or concat(',',headofengineering,',') like concat(',',#{userId},',')")
|
||||||
Integer selectIsHotel(int uid);
|
List<Map<String, Object>> selectIsHotel(int uid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>查询酒店信息</h2>
|
* <h2>查询酒店信息</h2>
|
||||||
|
@ -85,12 +85,11 @@ public interface UserInfoMapper {
|
||||||
/**
|
/**
|
||||||
* <h2>查询角色信息</h2>
|
* <h2>查询角色信息</h2>
|
||||||
*
|
*
|
||||||
* @param uid 当前人员
|
* @param uid 当前人员
|
||||||
* @param hotelIndex 酒店编码
|
|
||||||
* @return 角色信息
|
* @return 角色信息
|
||||||
*/
|
*/
|
||||||
@Select("select * from uf_hotelinfo where\n" +
|
@Select("select * from uf_hotelinfo where\n" +
|
||||||
"(concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
"concat(',',olt,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',vpo,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',subregionadmin,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',subregionadmin,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" +
|
||||||
|
@ -112,9 +111,8 @@ public interface UserInfoMapper {
|
||||||
"or concat(',',revenueleader,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',revenueleader,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',financeleader,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',financeleader,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',fbleader,',') like concat(',',#{userId},',')\n" +
|
"or concat(',',fbleader,',') like concat(',',#{userId},',')\n" +
|
||||||
"or concat(',',hrleader,',') like concat(',',#{userId},',')) " +
|
"or concat(',',hrleader,',') like concat(',',#{userId},',')")
|
||||||
"and holidex = #{hotelIndex}")
|
List<Map<String, Object>> selectRoles(@ParamMapper("userId") int uid);
|
||||||
List<Map<String, Object>> selectRoles(@ParamMapper("userId") int uid, @ParamMapper("hotelIndex") String hotelIndex);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>查询部门信息</h2>
|
* <h2>查询部门信息</h2>
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class UserInfoService {
|
||||||
userInfoVo.setTaskAcceptance(true);
|
userInfoVo.setTaskAcceptance(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
Map<String, Object> userInfo = this.mapper.selectHrmInfo(user.getUID());
|
Map<String, Object> userInfo = this.mapper.selectHrmInfo(user.getUID());
|
||||||
if (CollectionUtil.isNotEmpty(userInfo)) {
|
if (CollectionUtil.isNotEmpty(userInfo)) {
|
||||||
|
@ -70,8 +69,32 @@ public class UserInfoService {
|
||||||
// 支持中心,显示部门信息
|
// 支持中心,显示部门信息
|
||||||
userInfoVo.setDepartmentInfo(department);
|
userInfoVo.setDepartmentInfo(department);
|
||||||
}
|
}
|
||||||
|
List<Map<String, Object>> hotelList = mapper.selectRoles(user.getUID());
|
||||||
// 如果存在酒店信息
|
// 如果存在酒店信息
|
||||||
if (StrUtil.isNotBlank(hotelIndex)) {
|
Set<String> roleNames = new HashSet<>();
|
||||||
|
if (CollectionUtil.isNotEmpty(hotelList)) {
|
||||||
|
for (Map<String, Object> hotel : hotelList) {
|
||||||
|
// 循环酒店角色名称
|
||||||
|
for (Map.Entry<String, String> entry : ROLES_MAP.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
if (!hotel.containsKey(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String value = Util.null2String(hotel.get(key));
|
||||||
|
// 如果在酒店名称中找到对应的人,则为角色名
|
||||||
|
if (StrUtil.isBlank(value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] split = value.split(",");
|
||||||
|
List<String> strings = Arrays.asList(split);
|
||||||
|
if (strings.contains(Util.null2String(user.getUID()))) {
|
||||||
|
roleNames.add(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userInfoVo.setRoleNames(roleNames);
|
||||||
|
/*if (StrUtil.isNotBlank(hotelIndex)) {
|
||||||
List<Map<String, Object>> hotelRoles = this.mapper.selectRoles(user.getUID(), hotelIndex);
|
List<Map<String, Object>> hotelRoles = this.mapper.selectRoles(user.getUID(), hotelIndex);
|
||||||
if (CollectionUtil.isEmpty(hotelRoles)) {
|
if (CollectionUtil.isEmpty(hotelRoles)) {
|
||||||
return userInfoVo;
|
return userInfoVo;
|
||||||
|
@ -98,7 +121,7 @@ public class UserInfoService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
userInfoVo.setRoleNames(roleNames);
|
userInfoVo.setRoleNames(roleNames);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
return userInfoVo;
|
return userInfoVo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,10 @@ public class OrgChartService {
|
||||||
/* ******************* 次账号处理逻辑 ******************* */
|
/* ******************* 次账号处理逻辑 ******************* */
|
||||||
String accountType = logInUser.getAccount_type();
|
String accountType = logInUser.getAccount_type();
|
||||||
if ("1".equals(accountType)) {
|
if ("1".equals(accountType)) {
|
||||||
return secondaryAccountTree(hrmResourceDtoList);
|
// 对当前账号过滤当前分部信息
|
||||||
|
List<HrmResourceDto> collect = hrmResourceDtoList.stream().filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return secondaryAccountTree(collect);
|
||||||
}
|
}
|
||||||
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
||||||
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy impleme
|
||||||
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();
|
private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ServiceMethodDynamicProxy(desc = "子流程触发时,做流程转数据")
|
@ServiceMethodDynamicProxy(desc = "流程创建校验流程参数")
|
||||||
public PAResponseEntity doCreateRequest(User user, ReqOperateRequestEntity requestParam) {
|
public PAResponseEntity doCreateRequest(User user, ReqOperateRequestEntity requestParam) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||||
public interface CheckWorkflowRequestParamsMapper {
|
public interface CheckWorkflowRequestParamsMapper {
|
||||||
|
|
||||||
|
|
||||||
@Select("select * from table where workflow_type = #{workflowId}")
|
@Select("select * from uf_check_request_create where workflow_type = #{workflowId}")
|
||||||
@CollectionMappings({
|
@CollectionMappings({
|
||||||
@CollectionMapping(
|
@CollectionMapping(
|
||||||
property = "detailList",
|
property = "detailList",
|
||||||
|
@ -36,7 +36,7 @@ public interface CheckWorkflowRequestParamsMapper {
|
||||||
CheckCreateConfig selectCheckConfig(int workflowId);
|
CheckCreateConfig selectCheckConfig(int workflowId);
|
||||||
|
|
||||||
|
|
||||||
@Select("select * from table_dt1 where mainid = #{mainId}")
|
@Select("select * from uf_check_request_create_dt1 where mainid = #{mainId}")
|
||||||
@Associations({
|
@Associations({
|
||||||
@Association(
|
@Association(
|
||||||
property = "workflowField",
|
property = "workflowField",
|
||||||
|
@ -49,12 +49,13 @@ public interface CheckWorkflowRequestParamsMapper {
|
||||||
List<CheckCreateConfigDetail> selectCheckDetail(String mainId);
|
List<CheckCreateConfigDetail> selectCheckDetail(String mainId);
|
||||||
|
|
||||||
|
|
||||||
@Select("select * from table_dt2 where mainid = #{mainId}")
|
@Select("select * from uf_check_request_create_dt2 where mainid = #{mainId}")
|
||||||
@CollectionMethod(value = 2, desc = "查询明细表2,条件配置参数")
|
@CollectionMethod(value = 2, desc = "查询明细表2,条件配置参数")
|
||||||
List<CheckConditionItem> selectConditionDetail(String mainId);
|
List<CheckConditionItem> selectConditionDetail(String mainId);
|
||||||
|
|
||||||
|
|
||||||
@Select(custom = true)
|
@Select(custom = true)
|
||||||
|
@ToLowerCase
|
||||||
Map<String, Object> selectCustomerSql(@SqlString String sql,
|
Map<String, Object> selectCustomerSql(@SqlString String sql,
|
||||||
@ParamMapper("value") String value,
|
@ParamMapper("value") String value,
|
||||||
@ParamMapper("user") User user);
|
@ParamMapper("user") User user);
|
||||||
|
|
|
@ -18,10 +18,10 @@ import java.util.List;
|
||||||
@ToString
|
@ToString
|
||||||
public class CheckCreateConfig {
|
public class CheckCreateConfig {
|
||||||
/** 流程id */
|
/** 流程id */
|
||||||
private Integer workflowId;
|
private Integer workflowType;
|
||||||
|
|
||||||
/** 描述 */
|
/** 描述 */
|
||||||
private String desc;
|
private String description;
|
||||||
|
|
||||||
/** 检查配置明细 */
|
/** 检查配置明细 */
|
||||||
private List<CheckCreateConfigDetail> detailList;
|
private List<CheckCreateConfigDetail> detailList;
|
||||||
|
|
|
@ -23,11 +23,11 @@ public class CheckCreateConfigDetail {
|
||||||
/** 流程字段 */
|
/** 流程字段 */
|
||||||
private FieldViewInfo workflowField;
|
private FieldViewInfo workflowField;
|
||||||
|
|
||||||
/** 是否允许为null */
|
/** 错误提示消息 */
|
||||||
private String allowNull;
|
private String errorMsg;
|
||||||
|
|
||||||
/** 校验规则 */
|
/** 校验规则 */
|
||||||
private String checkRule;
|
private Integer checkRule;
|
||||||
|
|
||||||
/** 自定义值 */
|
/** 自定义值 */
|
||||||
private String customerValue;
|
private String customerValue;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ package com.customization.youhong.pcn.createrworkflow.util;
|
||||||
import aiyh.utils.ScriptUtil;
|
import aiyh.utils.ScriptUtil;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.annotation.MethodRuleNo;
|
import aiyh.utils.annotation.MethodRuleNo;
|
||||||
import aiyh.utils.function.Bi4Function;
|
|
||||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper;
|
||||||
|
@ -13,11 +12,9 @@ import org.apache.log4j.Logger;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
import java.util.function.Function;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>检查方法校验工具</h1>
|
* <h1>检查方法校验工具</h1>
|
||||||
|
@ -28,17 +25,11 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class CheckRuleMethodUtil {
|
public class CheckRuleMethodUtil {
|
||||||
|
|
||||||
private static final Logger log = Util.getLogger();
|
private static final Logger log = Util.getLogger("workflow");
|
||||||
|
|
||||||
private static final CheckWorkflowRequestParamsMapper MAPPER = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
private static final CheckWorkflowRequestParamsMapper MAPPER = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||||
public static final Map<Integer,
|
public static final Map<Integer,
|
||||||
Bi4Function<
|
Function<CheckFunctionParam, Boolean>
|
||||||
WorkflowRequestTableField,
|
|
||||||
CheckCreateConfigDetail,
|
|
||||||
CheckConditionItem,
|
|
||||||
User,
|
|
||||||
Boolean
|
|
||||||
>
|
|
||||||
> CHECK_RULE_MAP = new HashMap<>(8);
|
> CHECK_RULE_MAP = new HashMap<>(8);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -46,14 +37,14 @@ public class CheckRuleMethodUtil {
|
||||||
Class<CheckRuleMethodUtil> checkRuleMethodUtilClass = CheckRuleMethodUtil.class;
|
Class<CheckRuleMethodUtil> checkRuleMethodUtilClass = CheckRuleMethodUtil.class;
|
||||||
Method[] methods = checkRuleMethodUtilClass.getDeclaredMethods();
|
Method[] methods = checkRuleMethodUtilClass.getDeclaredMethods();
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
|
|
||||||
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
if (method.isAnnotationPresent(MethodRuleNo.class)) {
|
||||||
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
|
||||||
int value = annotation.value();
|
int value = annotation.value();
|
||||||
CHECK_RULE_MAP.put(value, (workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user) -> {
|
CHECK_RULE_MAP.put(value, (checkFunctionParam) -> {
|
||||||
try {
|
try {
|
||||||
return (Boolean) method.invoke(null, workflowRequestTableField, checkCreateConfigDetail, checkConditionItem, user);
|
return (Boolean) method.invoke(null, checkFunctionParam);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (Exception e) {
|
||||||
|
log.error("调用CheckRuleMethodUtil类中注解方法失败!" + Util.getErrString(e));
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -62,21 +53,18 @@ public class CheckRuleMethodUtil {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("初始化CheckRuleMethodUtil失败!" + Util.getErrString(e));
|
log.error("初始化CheckRuleMethodUtil失败!" + Util.getErrString(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodRuleNo(value = 0, desc = "不为null")
|
@MethodRuleNo(value = 0, desc = "不为null")
|
||||||
public static boolean noNull(WorkflowRequestTableField workflowRequestTableField,
|
private static boolean noNull(CheckFunctionParam checkFunctionParam) {
|
||||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||||
CheckConditionItem checkConditionItem, User user) {
|
|
||||||
return StrUtil.isNotBlank(workflowRequestTableField.getFieldValue());
|
return StrUtil.isNotBlank(workflowRequestTableField.getFieldValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodRuleNo(value = 1, desc = "整数类型")
|
@MethodRuleNo(value = 1, desc = "整数类型")
|
||||||
public static boolean isNumber(WorkflowRequestTableField workflowRequestTableField,
|
private static boolean isNumber(CheckFunctionParam checkFunctionParam) {
|
||||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
|
||||||
CheckConditionItem checkConditionItem, User user) {
|
|
||||||
try {
|
try {
|
||||||
|
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||||
Integer.parseInt(workflowRequestTableField.getFieldValue());
|
Integer.parseInt(workflowRequestTableField.getFieldValue());
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -85,9 +73,8 @@ public class CheckRuleMethodUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodRuleNo(value = 2, desc = "小数类型")
|
@MethodRuleNo(value = 2, desc = "小数类型")
|
||||||
public static boolean isDouble(WorkflowRequestTableField workflowRequestTableField,
|
private static boolean isDouble(CheckFunctionParam checkFunctionParam) {
|
||||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||||
CheckConditionItem checkConditionItem, User user) {
|
|
||||||
try {
|
try {
|
||||||
Double.parseDouble(workflowRequestTableField.getFieldValue());
|
Double.parseDouble(workflowRequestTableField.getFieldValue());
|
||||||
return true;
|
return true;
|
||||||
|
@ -97,11 +84,15 @@ public class CheckRuleMethodUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodRuleNo(value = 3, desc = "枚举值")
|
@MethodRuleNo(value = 3, desc = "枚举值")
|
||||||
public static boolean isEnumerate(WorkflowRequestTableField workflowRequestTableField,
|
private static boolean isEnumerate(CheckFunctionParam checkFunctionParam) {
|
||||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||||
CheckConditionItem checkConditionItem, User user) {
|
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||||
|
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||||
|
if (Objects.nonNull(checkConditionItem)) {
|
||||||
|
customerValue = checkConditionItem.getCustomerValue();
|
||||||
|
}
|
||||||
if (StrUtil.isNotBlank(customerValue)) {
|
if (StrUtil.isNotBlank(customerValue)) {
|
||||||
String[] split = customerValue.split(",");
|
String[] split = customerValue.split(",");
|
||||||
return Arrays.asList(split).contains(fieldValue);
|
return Arrays.asList(split).contains(fieldValue);
|
||||||
|
@ -110,21 +101,36 @@ public class CheckRuleMethodUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodRuleNo(value = 4, desc = "自定义sql存在值")
|
@MethodRuleNo(value = 4, desc = "自定义sql存在值")
|
||||||
public static boolean customerSqlHasValue(WorkflowRequestTableField workflowRequestTableField,
|
private static boolean customerSqlHasValue(CheckFunctionParam checkFunctionParam) {
|
||||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
CheckConditionItem checkConditionItem = checkFunctionParam.getCheckConditionItem();
|
||||||
CheckConditionItem checkConditionItem, User user) {
|
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||||
|
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||||
|
User user = checkFunctionParam.getUser();
|
||||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
String customerValue;
|
||||||
|
if (Objects.nonNull(checkConditionItem)) {
|
||||||
|
// 条件组调用方法
|
||||||
|
customerValue = checkConditionItem.getCustomerValue();
|
||||||
|
} else {
|
||||||
|
customerValue = checkCreateConfigDetail.getCustomerValue();
|
||||||
|
}
|
||||||
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
|
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
|
||||||
return CollectionUtil.isNotEmpty(map);
|
return CollectionUtil.isNotEmpty(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodRuleNo(value = 5, desc = "自定义sql校验表达式")
|
@MethodRuleNo(value = 5, desc = "自定义sql校验表达式")
|
||||||
public static boolean customerSqlCheck(WorkflowRequestTableField workflowRequestTableField,
|
private static boolean customerSqlCheck(CheckFunctionParam checkFunctionParam) {
|
||||||
CheckCreateConfigDetail checkCreateConfigDetail,
|
WorkflowRequestTableField workflowRequestTableField = checkFunctionParam.getWorkflowRequestTableField();
|
||||||
CheckConditionItem checkConditionItem, User user) {
|
CheckCreateConfigDetail checkCreateConfigDetail = checkFunctionParam.getCheckCreateConfigDetail();
|
||||||
|
User user = checkFunctionParam.getUser();
|
||||||
String fieldValue = workflowRequestTableField.getFieldValue();
|
String fieldValue = workflowRequestTableField.getFieldValue();
|
||||||
String customerValue = checkCreateConfigDetail.getCustomerValue();
|
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);
|
Map<String, Object> map = MAPPER.selectCustomerSql(customerValue, fieldValue, user);
|
||||||
if (CollectionUtil.isNotEmpty(map)) {
|
if (CollectionUtil.isNotEmpty(map)) {
|
||||||
String checkExpression = checkCreateConfigDetail.getCheckExpression();
|
String checkExpression = checkCreateConfigDetail.getCheckExpression();
|
||||||
|
@ -136,4 +142,78 @@ public class CheckRuleMethodUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,14 @@ import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem;
|
||||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig;
|
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfig;
|
||||||
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
import com.customization.youhong.pcn.createrworkflow.pojo.CheckCreateConfigDetail;
|
||||||
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
|
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.hrm.User;
|
||||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||||
|
import weaver.workflow.webservices.WorkflowRequestTableRecord;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.function.Function;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +29,7 @@ public class CheckWorkflowRequestParamsUtil {
|
||||||
|
|
||||||
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class);
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger("workflow");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ************************************************************
|
* ************************************************************
|
||||||
|
@ -70,15 +72,81 @@ public class CheckWorkflowRequestParamsUtil {
|
||||||
value -> value
|
value -> value
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
checkMainData(checkDetailMap, checkConditionItemMap, requestParam);
|
// 校验主表数据
|
||||||
|
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,
|
private void checkMainData(Map<String, CheckCreateConfigDetail> checkDetailMap,
|
||||||
Map<String, CheckConditionItem> checkConditionItemMap,
|
Map<String, CheckConditionItem> checkConditionItemMap,
|
||||||
ReqOperateRequestEntity requestParam) {
|
ReqOperateRequestEntity requestParam, User user) {
|
||||||
List<WorkflowRequestTableField> mainData = requestParam.getMainData();
|
List<WorkflowRequestTableField> mainData = requestParam.getMainData();
|
||||||
for (WorkflowRequestTableField mainDatum : mainData) {
|
checkData(checkDetailMap, checkConditionItemMap, mainData, user, "主表");
|
||||||
String fieldName = mainDatum.getFieldName();
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// TODO 主表明细表字段一致可能出现问题
|
||||||
|
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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,10 @@ public class WorkFlowToVmsAndMQ extends SafeCusBaseAction {
|
||||||
@PrintParamMark
|
@PrintParamMark
|
||||||
@ActionOptionalParam(value = "message", desc = "报错返回信息字段")
|
@ActionOptionalParam(value = "message", desc = "报错返回信息字段")
|
||||||
private String msg;
|
private String msg;
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionOptionalParam(value = "0", desc = "发送mq跳过校验")
|
||||||
|
private String mqSkip;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||||
|
@ -59,6 +63,6 @@ public class WorkFlowToVmsAndMQ extends SafeCusBaseAction {
|
||||||
.successVal(Util.null2DefaultStr(successVal, "200"))
|
.successVal(Util.null2DefaultStr(successVal, "200"))
|
||||||
.message(Util.null2DefaultStr(msg, "message"))
|
.message(Util.null2DefaultStr(msg, "message"))
|
||||||
.build();
|
.build();
|
||||||
workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig);
|
workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig, mqSkip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,19 +32,20 @@ public class CusListValue implements CusInterfaceGetValue {
|
||||||
// 如果fileName不为空则对集合中每个map添加"fileName":value value则是附件字段名称
|
// 如果fileName不为空则对集合中每个map添加"fileName":value value则是附件字段名称
|
||||||
String fileName = Util.null2DefaultStr(pathParam.get("fileName"), "");
|
String fileName = Util.null2DefaultStr(pathParam.get("fileName"), "");
|
||||||
if(StringUtils.isNotBlank(cusSql)){
|
if(StringUtils.isNotBlank(cusSql)){
|
||||||
|
cusSql = cusSql.replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),""));
|
||||||
if (StringUtils.isNotBlank(attachmentField)) {
|
if (StringUtils.isNotBlank(attachmentField)) {
|
||||||
for (String item : attachmentField.split(",")) {
|
String[] fields = attachmentField.split(",");
|
||||||
|
for (String item : fields) {
|
||||||
String filedValue = Util.null2DefaultStr(mainMap.get(item),"");
|
String filedValue = Util.null2DefaultStr(mainMap.get(item),"");
|
||||||
if(StringUtils.isNotBlank(Util.null2DefaultStr(mainMap.get(filedValue),""))){
|
String fileSql = cusSql;
|
||||||
cusSql = cusSql
|
if(StringUtils.isNotBlank(filedValue)){
|
||||||
.replace("{?docIds}", "( " + filedValue + " )")
|
fileSql = fileSql.replace("{?docIds}", "( " + filedValue + " )");
|
||||||
.replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),""));
|
List<Map<String, String>> attachmentInfo = mapper.getAttachmentInfo(fileSql);
|
||||||
List<Map<String, String>> attachmentInfo = mapper.getAttachmentInfo(cusSql);
|
|
||||||
if(CollectionUtils.isEmpty(attachmentInfo)){
|
if(CollectionUtils.isEmpty(attachmentInfo)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 往map中put附件字段名
|
// 往map中put附件字段名
|
||||||
if(StringUtils.isBlank(fileName)){
|
if(StringUtils.isNotBlank(fileName)){
|
||||||
attachmentInfo.forEach(file ->{
|
attachmentInfo.forEach(file ->{
|
||||||
file.put(fileName, item);
|
file.put(fileName, item);
|
||||||
});
|
});
|
||||||
|
@ -52,6 +53,11 @@ public class CusListValue implements CusInterfaceGetValue {
|
||||||
list.addAll(attachmentInfo);
|
list.addAll(attachmentInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
List<Map<String, String>> attachmentInfo = mapper.getAttachmentInfo(cusSql);
|
||||||
|
if(CollectionUtils.isNotEmpty(attachmentInfo)){
|
||||||
|
list.addAll(attachmentInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package weaver.xuanran.wang.immc.entity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>请求url, 请求参数</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/6/21 15:50
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public class CusRequestParam {
|
||||||
|
private String url;
|
||||||
|
private RecordSet rs;
|
||||||
|
private Map<String, Object> param;
|
||||||
|
private String requestId;
|
||||||
|
}
|
|
@ -6,24 +6,25 @@ import aiyh.utils.httpUtil.ResponeVo;
|
||||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import com.api.xuanran.wang.immc.dto.ImmcWorkFlowToKafkaDto;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
import org.apache.kafka.clients.producer.RecordMetadata;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
import weaver.general.GCONST;
|
import weaver.general.GCONST;
|
||||||
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||||
import weaver.xiao.commons.config.service.DealWithMapping;
|
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||||
import weaver.xuanran.wang.common.util.CommonUtil;
|
import weaver.xuanran.wang.common.util.CommonUtil;
|
||||||
|
import weaver.xuanran.wang.immc.entity.CusRequestParam;
|
||||||
import weaver.xuanran.wang.immc.entity.VmsResponseVoField;
|
import weaver.xuanran.wang.immc.entity.VmsResponseVoField;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,35 +44,48 @@ public class WorkFlowToVmsAndMQService {
|
||||||
private static final String VMS_SUCCESS = "vms_success";
|
private static final String VMS_SUCCESS = "vms_success";
|
||||||
private static final String SUCCESS = "0";
|
private static final String SUCCESS = "0";
|
||||||
|
|
||||||
|
private static final String SKIP = "1";
|
||||||
|
|
||||||
{
|
{
|
||||||
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
|
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>将流程数据下发到kafka中</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/6/21 16:14
|
||||||
|
* @param dto 接口封装对象
|
||||||
|
**/
|
||||||
|
public void workFlowToKafkaByDto(ImmcWorkFlowToKafkaDto dto){
|
||||||
|
this.checkDtoFieldValueNotNull(dto);
|
||||||
|
this.workFlowToVmsAndMQ(dto.getOnlyMark(), "formtable_main_" + Math.abs(dto.getBillTable()),
|
||||||
|
String.valueOf(dto.getRequestId()), null, dto.getConfig(), dto.getSkip());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>推送数据</h1>
|
* <h1>推送数据</h1>
|
||||||
*
|
*
|
||||||
* @param onlyMark 唯一编码
|
* @param onlyMark 唯一编码
|
||||||
* @param billTable 表名
|
* @param billTable 表名
|
||||||
* @param requestId 请求id
|
* @param requestId 请求id
|
||||||
* @param vmsResponseVoField vms成功标识
|
* @param vmsResponseVoField vms成功标识
|
||||||
* @param config kafka配置文件名称
|
* @param config kafka配置文件名称
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
* @dateTime 2022/12/5 17:05
|
* @dateTime 2022/12/5 17:05
|
||||||
**/
|
**/
|
||||||
public void workFlowToVmsAndMQ(String onlyMark, String billTable, String requestId, VmsResponseVoField vmsResponseVoField, String config) {
|
public void workFlowToVmsAndMQ(String onlyMark, String billTable,
|
||||||
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构
|
String requestId, VmsResponseVoField vmsResponseVoField,
|
||||||
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable);
|
String config, String skip) {
|
||||||
log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId));
|
CusRequestParam requestParam = getRequestParam(onlyMark, billTable, requestId);
|
||||||
RecordSet recordSet = new RecordSet();
|
if(Objects.isNull(requestParam)){
|
||||||
recordSet.executeQuery(selectMainSql, requestId);
|
return;
|
||||||
recordSet.next();
|
}
|
||||||
String url = requestMappingConfig.getRequestUrl();
|
RecordSet rs = requestParam.getRs();
|
||||||
dealWithMapping.setMainTable(billTable);
|
Map<String, Object> param = requestParam.getParam();
|
||||||
Map<String, Object> param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
|
String url = requestParam.getUrl();
|
||||||
String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS), "");
|
String vmsSuccess = Util.null2DefaultStr(rs.getString(VMS_SUCCESS),"");
|
||||||
String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS), "");
|
String mqSuccess = Util.null2DefaultStr(rs.getString(MQ_SUCCESS),"");
|
||||||
if (!SUCCESS.equals(vmsSuccess)) {
|
if(!SUCCESS.equals(vmsSuccess) && !Objects.isNull(vmsResponseVoField)){
|
||||||
ResponeVo responeVo;
|
ResponeVo responeVo;
|
||||||
try {
|
try {
|
||||||
responeVo = httpUtils.apiPost(url, param);
|
responeVo = httpUtils.apiPost(url, param);
|
||||||
|
@ -81,22 +95,70 @@ public class WorkFlowToVmsAndMQService {
|
||||||
parseResponseVo(responeVo, url, param, vmsResponseVoField);
|
parseResponseVo(responeVo, url, param, vmsResponseVoField);
|
||||||
updateWorkFlow(VMS_SUCCESS, billTable, requestId);
|
updateWorkFlow(VMS_SUCCESS, billTable, requestId);
|
||||||
}
|
}
|
||||||
if (!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)) {
|
if((!SUCCESS.equals(mqSuccess) || SKIP.equals(skip)) && StringUtils.isNotBlank(config)){
|
||||||
sendToMQ(config, param);
|
sendToMQ(config, param);
|
||||||
updateWorkFlow(MQ_SUCCESS, billTable, requestId);
|
updateWorkFlow(MQ_SUCCESS, billTable, requestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>校验对象中字段值是否为空</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/6/21 16:17
|
||||||
|
* @param object 对象
|
||||||
|
**/
|
||||||
|
public void checkDtoFieldValueNotNull(Object object){
|
||||||
|
try {
|
||||||
|
Field[] fields = object.getClass().getDeclaredFields();
|
||||||
|
for (Field field : fields) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
Object o = field.get(object);
|
||||||
|
if(Objects.isNull(o)){
|
||||||
|
throw new CustomerException("该对象中 " + field.getName() + " 字段值为空!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
throw new CustomerException("校验对象失败 : [ " + e.getMessage() + " ]", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>对发送对数据参数进行封装</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/6/21 15:56
|
||||||
|
* @param onlyMark 建模配置唯一标识
|
||||||
|
* @param billTable 流程表名
|
||||||
|
* @param requestId 请求id
|
||||||
|
* @return 封装的数据
|
||||||
|
**/
|
||||||
|
public CusRequestParam getRequestParam(String onlyMark, String billTable, String requestId){
|
||||||
|
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构
|
||||||
|
if(Objects.isNull(requestMappingConfig)){
|
||||||
|
throw new CustomerException("唯一标识为 : " + onlyMark + " ,在参数配置表中没有找到对应的配置!");
|
||||||
|
}
|
||||||
|
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable);
|
||||||
|
// log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId));
|
||||||
|
RecordSet recordSet = new RecordSet();
|
||||||
|
if (recordSet.executeQuery(selectMainSql, requestId) && recordSet.next()) {
|
||||||
|
String url = requestMappingConfig.getRequestUrl();
|
||||||
|
dealWithMapping.setMainTable(billTable);
|
||||||
|
Map<String, Object> param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
|
||||||
|
return CusRequestParam.builder().url(url).rs(recordSet).requestId(requestId).param(param).build();
|
||||||
|
}else {
|
||||||
|
log.error("该流程暂未查到数据! requestId : " + requestId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>解析响应对象</h1>
|
* <h1>解析响应对象</h1>
|
||||||
*
|
|
||||||
* @param responseVo 响应对象
|
|
||||||
* @param url 地址
|
|
||||||
* @param requestParam 请求
|
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
* @dateTime 2022/12/23 11:25
|
* @dateTime 2022/12/23 11:25
|
||||||
|
* @param responseVo 响应对象
|
||||||
|
* @param url 地址
|
||||||
|
* @param requestParam 请求
|
||||||
**/
|
**/
|
||||||
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) { // 相应状态码
|
if (responseVo.getCode() != SUCCESS_CODE) { // 相应状态码
|
||||||
log.error(Util.logStr("can not fetch [{}],this request params is [{}]," + // 构建日志字符串
|
log.error(Util.logStr("can not fetch [{}],this request params is [{}]," + // 构建日志字符串
|
||||||
"this request heard is [{}],but response status code is [{}]," +
|
"this request heard is [{}],but response status code is [{}]," +
|
||||||
|
@ -114,65 +176,63 @@ public class WorkFlowToVmsAndMQService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>将流程信息发送到kafka</h1>
|
* <h1>将流程信息发送到kafka</h1>
|
||||||
*
|
|
||||||
* @param kafkaConfig kafka配置文件名称
|
|
||||||
* @param message 消息对象
|
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
* @dateTime 2023/3/30 14:56
|
* @dateTime 2023/3/30 14:56
|
||||||
|
* @param kafkaConfig kafka配置文件名称
|
||||||
|
* @param message 消息对象
|
||||||
**/
|
**/
|
||||||
public void sendToMQ(String kafkaConfig, Map<String, Object> message) {
|
public void sendToMQ(String kafkaConfig, Map<String, Object> message){
|
||||||
KafkaProducer<String, String> producer = null;
|
KafkaProducer<String, String> producer = null;
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties";
|
String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties";
|
||||||
File configFile = new File(path);
|
File configFile = new File(path);
|
||||||
if (!configFile.exists()) {
|
if(!configFile.exists()){
|
||||||
throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties");
|
throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties");
|
||||||
}
|
}
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
inputStream = new BufferedInputStream(Files.newInputStream(configFile.toPath()));
|
inputStream= new BufferedInputStream(Files.newInputStream(configFile.toPath()));
|
||||||
prop.load(inputStream);
|
prop.load(inputStream);
|
||||||
log.info("prop => " + JSONObject.toJSONString(prop));
|
log.info("prop => " + JSONObject.toJSONString(prop));
|
||||||
log.info("msg => " + JSONObject.toJSONString(message));
|
log.info("msg => " + JSONObject.toJSONString(message));
|
||||||
String topic = Util.null2DefaultStr(prop.getProperty("topic"), "");
|
String topic = Util.null2DefaultStr(prop.getProperty("topic"),"");
|
||||||
if (StringUtils.isBlank(topic)) {
|
if(StringUtils.isBlank(topic)){
|
||||||
throw new CustomerException("kafka properties topic can not null!");
|
throw new CustomerException("kafka properties topic can not null!");
|
||||||
}
|
}
|
||||||
producer = new KafkaProducer<>(prop);
|
producer = new KafkaProducer<>(prop);
|
||||||
// 发送消息到指定主题
|
// 发送消息到指定主题
|
||||||
ProducerRecord<String, String> record = new ProducerRecord<>(topic, JSONObject.toJSONString(message));
|
ProducerRecord<String, String> record = new ProducerRecord<>(topic, JSONObject.toJSONString(message));
|
||||||
producer.send(record).get();
|
producer.send(record).get();
|
||||||
} catch (Exception e) {
|
}catch (Exception e){
|
||||||
log.error(Util.getErrString(e));
|
log.error(Util.getErrString(e));
|
||||||
throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage()));
|
throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage()));
|
||||||
} finally {
|
}finally {
|
||||||
// 关闭Kafka生产者实例
|
// 关闭Kafka生产者实例
|
||||||
if (producer != null) {
|
if(producer != null){
|
||||||
producer.close();
|
producer.close();
|
||||||
}
|
}
|
||||||
if (inputStream != null) {
|
if(inputStream != null){
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (Exception e) {
|
}catch (Exception e){
|
||||||
log.error("inputStream close error! " + e.getMessage());
|
log.error("inputStream close error! " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>更新流程sql</h1>
|
* <h1>更新流程sql</h1>
|
||||||
*
|
|
||||||
* @param field 主表字段
|
|
||||||
* @param tableName 表名
|
|
||||||
* @param requestId 请求id
|
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
* @dateTime 2023/3/30 19:18
|
* @dateTime 2023/3/30 19:18
|
||||||
|
* @param field 主表字段
|
||||||
|
* @param tableName 表名
|
||||||
|
* @param requestId 请求id
|
||||||
**/
|
**/
|
||||||
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 = ?";
|
String updateSQL = "update " + tableName + " set " + field + " = " + SUCCESS + " where requestid = ?";
|
||||||
RecordSet recordSet = new RecordSet();
|
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));
|
log.error(Util.logStr("update field error! sql: {}, requestId: {}", updateSQL, requestId));
|
||||||
throw new CustomerException("更新表单字段失败!");
|
throw new CustomerException("更新表单字段失败!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,16 @@ package weaver.xuanran.wang.sh_bigdata.common.util;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.icbc.api.internal.apache.http.impl.cookie.S;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import weaver.workflow.request.todo.RequestStatusObj;
|
import weaver.workflow.request.todo.RequestStatusObj;
|
||||||
import weaver.xuanran.wang.common.mapper.CommonMapper;
|
import weaver.xuanran.wang.common.mapper.CommonMapper;
|
||||||
import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusDoneTask;
|
import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusDoneTask;
|
||||||
|
import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoLeaderTask;
|
||||||
import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask;
|
import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask;
|
||||||
import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper;
|
import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper;
|
||||||
|
|
||||||
|
@ -63,8 +66,8 @@ public class SendTodoTaskUtil {
|
||||||
* @param objs 任务对象
|
* @param objs 任务对象
|
||||||
* @return 三方系统任务接收对象
|
* @return 三方系统任务接收对象
|
||||||
**/
|
**/
|
||||||
public List<CusTodoTask> getTodoTaskInfo(List<RequestStatusObj> objs){
|
public List<Object> getTodoTaskInfo(List<RequestStatusObj> objs){
|
||||||
ArrayList<CusTodoTask> res = new ArrayList<>();
|
ArrayList<Object> res = new ArrayList<>();
|
||||||
for (RequestStatusObj obj : objs) {
|
for (RequestStatusObj obj : objs) {
|
||||||
String taskId = getTaskId(0, obj);
|
String taskId = getTaskId(0, obj);
|
||||||
CusTodoTask todoTask = new CusTodoTask();
|
CusTodoTask todoTask = new CusTodoTask();
|
||||||
|
@ -80,22 +83,64 @@ public class SendTodoTaskUtil {
|
||||||
}
|
}
|
||||||
todoTask.setPcAgentId(pcAgentId);
|
todoTask.setPcAgentId(pcAgentId);
|
||||||
String todoSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoSSOCallBackUrl");
|
String todoSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoSSOCallBackUrl");
|
||||||
StringBuilder sb = new StringBuilder(todoSSOCallBackUrl);
|
String todoPcSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoPcSSOCallBackUrl");
|
||||||
sb.append("?user=")
|
if(StringUtils.isBlank(todoPcSSOCallBackUrl)){
|
||||||
.append(userId)
|
todoPcSSOCallBackUrl = todoSSOCallBackUrl;
|
||||||
.append("&requestId=")
|
}
|
||||||
.append(requestId);
|
// 移动端链接
|
||||||
// todoTask.setLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskPcUrl"), oaAddress) + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestId);
|
StringBuilder mobileUrl = new StringBuilder(todoSSOCallBackUrl);
|
||||||
// todoTask.setMobileLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskMobileUrl"), oaAddress) + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestId);
|
// pc端链接
|
||||||
todoTask.setLinkUrl(sb.toString());
|
StringBuilder pcUrl = new StringBuilder(todoPcSSOCallBackUrl);
|
||||||
todoTask.setMobileLinkUrl(sb.append("&mobile=1").toString());
|
todoTask.setLinkUrl(appendParam(pcUrl, userId, requestId).toString());
|
||||||
|
todoTask.setMobileLinkUrl(appendParam(mobileUrl, userId, requestId).append("&mobile=1").toString());
|
||||||
todoTask.setSender(getConvertHrm(0, obj, String.valueOf(obj.getCreator().getUID())));
|
todoTask.setSender(getConvertHrm(0, obj, String.valueOf(obj.getCreator().getUID())));
|
||||||
todoTask.setReceiver(getConvertHrm(1, obj, String.valueOf(userId)));
|
todoTask.setReceiver(getConvertHrm(1, obj, String.valueOf(userId)));
|
||||||
|
// 是否领导待办逻辑处理
|
||||||
|
int nodeId = obj.getNodeid();
|
||||||
|
String nodeNme = obj.getNodename();
|
||||||
|
if(strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeId"), String.valueOf(nodeId))
|
||||||
|
|| strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeName"), nodeNme)){
|
||||||
|
CusTodoLeaderTask leaderTask = new CusTodoLeaderTask();
|
||||||
|
// 进行数据拷贝
|
||||||
|
BeanUtils.copyProperties(todoTask, leaderTask);
|
||||||
|
leaderTask.setLeader(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderValue"),"1"));
|
||||||
|
res.add(leaderTask);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
res.add(todoTask);
|
res.add(todoTask);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>判断字符串中是否含有指定字符</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/6/25 13:24
|
||||||
|
* @param str 字符串
|
||||||
|
* @param key 标识
|
||||||
|
* @return true/false
|
||||||
|
**/
|
||||||
|
public static boolean strContainsKey(String str, String key){
|
||||||
|
return StringUtils.isNotBlank(str) && Arrays.asList(str.split(",")).contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>参数拼接</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/6/25 13:22
|
||||||
|
* @param sb stringBuilder
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param requestId 请求id
|
||||||
|
* @return 进行字符串拼接
|
||||||
|
**/
|
||||||
|
public static StringBuilder appendParam(StringBuilder sb, int userId, int requestId){
|
||||||
|
sb.append("?user=")
|
||||||
|
.append(userId)
|
||||||
|
.append("&requestId=")
|
||||||
|
.append(requestId);
|
||||||
|
return sb;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>将oa任务对象转换成三方系统任务对象</h1>
|
* <h1>将oa任务对象转换成三方系统任务对象</h1>
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.stream.Collectors;
|
||||||
public class ShBigDataUtil {
|
public class ShBigDataUtil {
|
||||||
|
|
||||||
private static final String CONFIG_NAME = "ShBigdataConf";
|
private static final String CONFIG_NAME = "ShBigdataConf";
|
||||||
|
// 白名单
|
||||||
private static final List<String> WHILTE_LIST = new ArrayList<>();
|
private static final List<String> WHILTE_LIST = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -38,6 +38,12 @@ public class ShBigDataUtil {
|
||||||
WHILTE_LIST.add("ssoInterfaceCompareField");
|
WHILTE_LIST.add("ssoInterfaceCompareField");
|
||||||
WHILTE_LIST.add("ssoOaCompareField");
|
WHILTE_LIST.add("ssoOaCompareField");
|
||||||
WHILTE_LIST.add("pcAgentId");
|
WHILTE_LIST.add("pcAgentId");
|
||||||
|
// pc回调地址
|
||||||
|
WHILTE_LIST.add("todoPcSSOCallBackUrl");
|
||||||
|
// 统一待办推送领导节点id
|
||||||
|
WHILTE_LIST.add("taskAsyncLeaderNodeId");
|
||||||
|
// 统一待办推送领导节点名称
|
||||||
|
WHILTE_LIST.add("taskAsyncLeaderNodeName");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package weaver.xuanran.wang.sh_bigdata.task_async.entity;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>领导待办计划任务</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/6/25 10:50
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CusTodoLeaderTask extends CusTodoTask{
|
||||||
|
private String leader;
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService {
|
||||||
.dataKey("")
|
.dataKey("")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<CusTodoTask> taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList);
|
List<Object> taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList);
|
||||||
log.info("---------------- todoTaskInfo ---------------- \n" + JSONObject.toJSONString(taskInfo));
|
log.info("---------------- todoTaskInfo ---------------- \n" + JSONObject.toJSONString(taskInfo));
|
||||||
Map<String, Object> response = null;
|
Map<String, Object> response = null;
|
||||||
int success = 0;
|
int success = 0;
|
||||||
|
@ -74,8 +74,8 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService {
|
||||||
success = 1;
|
success = 1;
|
||||||
}
|
}
|
||||||
ArrayList<CusTodoTaskToOADetail> details = new ArrayList<>();
|
ArrayList<CusTodoTaskToOADetail> details = new ArrayList<>();
|
||||||
for (CusTodoTask cusTodoTask : taskInfo) {
|
for (Object obj : taskInfo) {
|
||||||
|
CusTodoTask cusTodoTask = (CusTodoTask) obj;
|
||||||
CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail();
|
CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail();
|
||||||
detail.setTaskNum(cusTodoTask.getTaskNum());
|
detail.setTaskNum(cusTodoTask.getTaskNum());
|
||||||
detail.setRequestUrl(addTodoTaskUrl);
|
detail.setRequestUrl(addTodoTaskUrl);
|
||||||
|
|
|
@ -58,9 +58,6 @@ public class GenerateLoginIdAction extends SafeCusBaseAction {
|
||||||
Map<String, String> mainTableValue = super.getMainTableValue(requestInfo);
|
Map<String, String> mainTableValue = super.getMainTableValue(requestInfo);
|
||||||
String subCompanyName = mainTableValue.get(subCompanyTextField);
|
String subCompanyName = mainTableValue.get(subCompanyTextField);
|
||||||
String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName);
|
String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName);
|
||||||
// Map<String, String> lastLoginIdInfo = mapper.selectLastLoginId(subCompanyName, subCompanyId, subCompanyName + "%");
|
|
||||||
// String loginIdNo = lastLoginIdInfo.get("loginIdNo");
|
|
||||||
// String loginId = prefixFill(loginIdNo, subCompanyName);
|
|
||||||
List<String> loginIdList = mapper.selectLoginIdList(subCompanyId);
|
List<String> loginIdList = mapper.selectLoginIdList(subCompanyId);
|
||||||
String loginId = subCompanyName + formatList(loginIdList, Integer.parseInt(numberFillQuantity));
|
String loginId = subCompanyName + formatList(loginIdList, Integer.parseInt(numberFillQuantity));
|
||||||
if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) {
|
if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) {
|
||||||
|
|
|
@ -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,81 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.todwfworkflow;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
|
import aiyh.utils.annotation.ActionDesc;
|
||||||
|
import aiyh.utils.annotation.ActionOptionalParam;
|
||||||
|
import aiyh.utils.annotation.RequiredMark;
|
||||||
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||||
|
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>推送流程数据到dwf</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/6/25 21:56</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@ActionDesc(author = "youhong.ai", value = "推送流程数据到dwf")
|
||||||
|
public class PushWorkflowDataToDWFAction extends SafeCusBaseAction {
|
||||||
|
|
||||||
|
@RequiredMark(desc = "请求参数配置表的唯一标识")
|
||||||
|
private String onlyMark;
|
||||||
|
|
||||||
|
|
||||||
|
@ActionOptionalParam(desc = "流程失败是否退回", value = "true")
|
||||||
|
private String isBlack = "true";
|
||||||
|
|
||||||
|
|
||||||
|
@ActionOptionalParam(desc = "成功标识", value = "200")
|
||||||
|
private String successCode = "200";
|
||||||
|
|
||||||
|
|
||||||
|
private final HttpUtils httpUtils = new HttpUtils();
|
||||||
|
|
||||||
|
private final DealWithMapping dealWithMapping = new DealWithMapping();
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||||
|
dealWithMapping.setMainTable(billTable);
|
||||||
|
try {
|
||||||
|
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
|
||||||
|
String requestUrl = requestMappingConfig.getRequestUrl();
|
||||||
|
Map<String, Object> objMainTableValue = getObjMainTableValue(requestInfo);
|
||||||
|
Map<String, Object> requestParam = dealWithMapping.getRequestParam(objMainTableValue, requestMappingConfig);
|
||||||
|
ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam);
|
||||||
|
if (responeVo.getCode() != 200) {
|
||||||
|
log.error(Util.logStr("接口请求出错:[]", responeVo.getEntityString()));
|
||||||
|
}
|
||||||
|
Map<String, Object> responseMap = responeVo.getResponseMap();
|
||||||
|
String code = Util.null2String(responseMap.get("code"));
|
||||||
|
if (!successCode.equals(code)) {
|
||||||
|
black(requestInfo, Util.null2String(responseMap.get("msg")));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
black(requestInfo, "system error!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void black(RequestInfo requestInfo, String msg) {
|
||||||
|
if (Boolean.parseBoolean(isBlack)) {
|
||||||
|
Util.actionFailException(requestInfo.getRequestManager(), msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.api.taojw.boge.api;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.boge.webservice.ERPIServiceLocator;
|
||||||
|
import com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.taojw.common.CommonSqlUtil;
|
||||||
|
import weaver.taojw.common.DaoUtil;
|
||||||
|
import weaver.taojw.common.ModelDataToJsonUtil;
|
||||||
|
import weaver.taojw.common.TjwModelUtil;
|
||||||
|
import weaver.taojw.common.logging.MyLogger;
|
||||||
|
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.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 勃格建模查询勾选记录 调用webservice接口
|
||||||
|
*/
|
||||||
|
@Path("/bogetjw")
|
||||||
|
public class CreateBomApi {
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
//接口调用成功后,将建模的是否成功推送字段改为是
|
||||||
|
private String updateModeStatusSql = "update uf_js03 set sfcgts = 0,spph = ? where id = ?";
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/createBom")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String createBom(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
result.put("success","1");
|
||||||
|
|
||||||
|
String errMsg = "";
|
||||||
|
List<String> errIds = new ArrayList<>();
|
||||||
|
//勾选的记录id
|
||||||
|
String selectedIds = request.getParameter("selectedIds");
|
||||||
|
String configId = CommonSqlUtil.getSystemParamValue("modedatatojson_bom",rs);
|
||||||
|
String url = CommonSqlUtil.getSystemParamValue("bomurl",rs);
|
||||||
|
|
||||||
|
String getStatusSql = "select id from uf_js03 where sfcgts = 0 and id in (" + selectedIds + ")";
|
||||||
|
List<Map<String, String>> data = DaoUtil.getData(rs, getStatusSql);
|
||||||
|
if(data.size() > 0){
|
||||||
|
for(Map<String, String> m : data){
|
||||||
|
String id = m.get("id");
|
||||||
|
errIds.add(id);
|
||||||
|
}
|
||||||
|
result.put("success","0");
|
||||||
|
errMsg = "数据id为:" + errIds + "的记录已成功调用过接口,请取消勾选后再提交!";
|
||||||
|
result.put("errMsg",errMsg);
|
||||||
|
logger.info("CreateBomApi.createBom end;result:" + result.toJSONString());
|
||||||
|
return result.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
|
URL wbUrl = new URL(url);
|
||||||
|
//根据配置将建模转json
|
||||||
|
String[] selectedIdArr = selectedIds.split(",");
|
||||||
|
for(String id : selectedIdArr){
|
||||||
|
JSONObject o = ModelDataToJsonUtil.getJsonByModelData(id,configId);
|
||||||
|
ERPIServiceLocator locator = new ERPIServiceLocator();
|
||||||
|
ERPIServiceSoap11BindingStub stub = new ERPIServiceSoap11BindingStub(wbUrl,locator);
|
||||||
|
String product4OA = stub.createProduct4OA(o.toJSONString());
|
||||||
|
JSONObject msg = JSONObject.parseObject(product4OA);
|
||||||
|
String code = msg.getString("code");
|
||||||
|
String phData = msg.getString("data");
|
||||||
|
JSONObject loggerInfo = new JSONObject();
|
||||||
|
if(!"0".equals(code)){
|
||||||
|
result.put("success","0");
|
||||||
|
errIds.add(id);
|
||||||
|
loggerInfo.put("cgbz",1);
|
||||||
|
}else{
|
||||||
|
DaoUtil.updateData(rs,updateModeStatusSql,phData,id);
|
||||||
|
loggerInfo.put("cgbz",0);
|
||||||
|
}
|
||||||
|
loggerInfo.put("sjid",id);
|
||||||
|
loggerInfo.put("qqbw",o.toJSONString());
|
||||||
|
loggerInfo.put("xybw",product4OA);
|
||||||
|
TjwModelUtil.addModelData(rs,"uf_bomjkrz",loggerInfo);
|
||||||
|
}
|
||||||
|
errMsg = "数据id为:" + errIds + "的记录接口调用失败!";
|
||||||
|
result.put("errMsg",errMsg);
|
||||||
|
logger.info("CreateBomApi.createBom end;result:" + result.toJSONString());
|
||||||
|
return result.toJSONString();
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CreateBomApi.createBom end;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return result.toJSONString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**
|
||||||
|
* ERPIService.java
|
||||||
|
*
|
||||||
|
* This file was auto-generated from WSDL
|
||||||
|
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.api.taojw.boge.webservice;
|
||||||
|
|
||||||
|
public interface ERPIService extends javax.xml.rpc.Service {
|
||||||
|
public java.lang.String getERPIServiceHttpSoap12EndpointAddress();
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint() throws javax.xml.rpc.ServiceException;
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
|
||||||
|
public java.lang.String getERPIServiceHttpSoap11EndpointAddress();
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint() throws javax.xml.rpc.ServiceException;
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
|
||||||
|
}
|
|
@ -0,0 +1,202 @@
|
||||||
|
/**
|
||||||
|
* ERPIServiceLocator.java
|
||||||
|
*
|
||||||
|
* This file was auto-generated from WSDL
|
||||||
|
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.api.taojw.boge.webservice;
|
||||||
|
|
||||||
|
public class ERPIServiceLocator extends org.apache.axis.client.Service implements com.api.taojw.boge.webservice.ERPIService {
|
||||||
|
|
||||||
|
public ERPIServiceLocator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ERPIServiceLocator(org.apache.axis.EngineConfiguration config) {
|
||||||
|
super(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ERPIServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException {
|
||||||
|
super(wsdlLoc, sName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use to get a proxy class for ERPIServiceHttpSoap12Endpoint
|
||||||
|
private java.lang.String ERPIServiceHttpSoap12Endpoint_address = "http://58.211.172.10:88/axis2/services/ERPIService.ERPIServiceHttpSoap12Endpoint/";
|
||||||
|
|
||||||
|
public java.lang.String getERPIServiceHttpSoap12EndpointAddress() {
|
||||||
|
return ERPIServiceHttpSoap12Endpoint_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The WSDD service name defaults to the port name.
|
||||||
|
private java.lang.String ERPIServiceHttpSoap12EndpointWSDDServiceName = "ERPIServiceHttpSoap12Endpoint";
|
||||||
|
|
||||||
|
public java.lang.String getERPIServiceHttpSoap12EndpointWSDDServiceName() {
|
||||||
|
return ERPIServiceHttpSoap12EndpointWSDDServiceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setERPIServiceHttpSoap12EndpointWSDDServiceName(java.lang.String name) {
|
||||||
|
ERPIServiceHttpSoap12EndpointWSDDServiceName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint() throws javax.xml.rpc.ServiceException {
|
||||||
|
java.net.URL endpoint;
|
||||||
|
try {
|
||||||
|
endpoint = new java.net.URL(ERPIServiceHttpSoap12Endpoint_address);
|
||||||
|
}
|
||||||
|
catch (java.net.MalformedURLException e) {
|
||||||
|
throw new javax.xml.rpc.ServiceException(e);
|
||||||
|
}
|
||||||
|
return getERPIServiceHttpSoap12Endpoint(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap12Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
|
||||||
|
try {
|
||||||
|
com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub(portAddress, this);
|
||||||
|
_stub.setPortName(getERPIServiceHttpSoap12EndpointWSDDServiceName());
|
||||||
|
return _stub;
|
||||||
|
}
|
||||||
|
catch (org.apache.axis.AxisFault e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setERPIServiceHttpSoap12EndpointEndpointAddress(java.lang.String address) {
|
||||||
|
ERPIServiceHttpSoap12Endpoint_address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Use to get a proxy class for ERPIServiceHttpSoap11Endpoint
|
||||||
|
private java.lang.String ERPIServiceHttpSoap11Endpoint_address = "http://58.211.172.10:88/axis2/services/ERPIService.ERPIServiceHttpSoap11Endpoint/";
|
||||||
|
|
||||||
|
public java.lang.String getERPIServiceHttpSoap11EndpointAddress() {
|
||||||
|
return ERPIServiceHttpSoap11Endpoint_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The WSDD service name defaults to the port name.
|
||||||
|
private java.lang.String ERPIServiceHttpSoap11EndpointWSDDServiceName = "ERPIServiceHttpSoap11Endpoint";
|
||||||
|
|
||||||
|
public java.lang.String getERPIServiceHttpSoap11EndpointWSDDServiceName() {
|
||||||
|
return ERPIServiceHttpSoap11EndpointWSDDServiceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setERPIServiceHttpSoap11EndpointWSDDServiceName(java.lang.String name) {
|
||||||
|
ERPIServiceHttpSoap11EndpointWSDDServiceName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint() throws javax.xml.rpc.ServiceException {
|
||||||
|
java.net.URL endpoint;
|
||||||
|
try {
|
||||||
|
endpoint = new java.net.URL(ERPIServiceHttpSoap11Endpoint_address);
|
||||||
|
}
|
||||||
|
catch (java.net.MalformedURLException e) {
|
||||||
|
throw new javax.xml.rpc.ServiceException(e);
|
||||||
|
}
|
||||||
|
return getERPIServiceHttpSoap11Endpoint(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public com.api.taojw.boge.webservice.ERPIServicePortType getERPIServiceHttpSoap11Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
|
||||||
|
try {
|
||||||
|
com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub(portAddress, this);
|
||||||
|
_stub.setPortName(getERPIServiceHttpSoap11EndpointWSDDServiceName());
|
||||||
|
return _stub;
|
||||||
|
}
|
||||||
|
catch (org.apache.axis.AxisFault e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setERPIServiceHttpSoap11EndpointEndpointAddress(java.lang.String address) {
|
||||||
|
ERPIServiceHttpSoap11Endpoint_address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the given interface, get the stub implementation.
|
||||||
|
* If this service has no port for the given interface,
|
||||||
|
* then ServiceException is thrown.
|
||||||
|
* This service has multiple ports for a given interface;
|
||||||
|
* the proxy implementation returned may be indeterminate.
|
||||||
|
*/
|
||||||
|
public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
|
||||||
|
try {
|
||||||
|
if (com.api.taojw.boge.webservice.ERPIServicePortType.class.isAssignableFrom(serviceEndpointInterface)) {
|
||||||
|
com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap12BindingStub(new java.net.URL(ERPIServiceHttpSoap12Endpoint_address), this);
|
||||||
|
_stub.setPortName(getERPIServiceHttpSoap12EndpointWSDDServiceName());
|
||||||
|
return _stub;
|
||||||
|
}
|
||||||
|
if (com.api.taojw.boge.webservice.ERPIServicePortType.class.isAssignableFrom(serviceEndpointInterface)) {
|
||||||
|
com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub _stub = new com.api.taojw.boge.webservice.ERPIServiceSoap11BindingStub(new java.net.URL(ERPIServiceHttpSoap11Endpoint_address), this);
|
||||||
|
_stub.setPortName(getERPIServiceHttpSoap11EndpointWSDDServiceName());
|
||||||
|
return _stub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (java.lang.Throwable t) {
|
||||||
|
throw new javax.xml.rpc.ServiceException(t);
|
||||||
|
}
|
||||||
|
throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the given interface, get the stub implementation.
|
||||||
|
* If this service has no port for the given interface,
|
||||||
|
* then ServiceException is thrown.
|
||||||
|
*/
|
||||||
|
public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
|
||||||
|
if (portName == null) {
|
||||||
|
return getPort(serviceEndpointInterface);
|
||||||
|
}
|
||||||
|
java.lang.String inputPortName = portName.getLocalPart();
|
||||||
|
if ("ERPIServiceHttpSoap12Endpoint".equals(inputPortName)) {
|
||||||
|
return getERPIServiceHttpSoap12Endpoint();
|
||||||
|
}
|
||||||
|
else if ("ERPIServiceHttpSoap11Endpoint".equals(inputPortName)) {
|
||||||
|
return getERPIServiceHttpSoap11Endpoint();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
java.rmi.Remote _stub = getPort(serviceEndpointInterface);
|
||||||
|
((org.apache.axis.client.Stub) _stub).setPortName(portName);
|
||||||
|
return _stub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public javax.xml.namespace.QName getServiceName() {
|
||||||
|
return new javax.xml.namespace.QName("http://service.dcis", "ERPIService");
|
||||||
|
}
|
||||||
|
|
||||||
|
private java.util.HashSet ports = null;
|
||||||
|
|
||||||
|
public java.util.Iterator getPorts() {
|
||||||
|
if (ports == null) {
|
||||||
|
ports = new java.util.HashSet();
|
||||||
|
ports.add(new javax.xml.namespace.QName("http://service.dcis", "ERPIServiceHttpSoap12Endpoint"));
|
||||||
|
ports.add(new javax.xml.namespace.QName("http://service.dcis", "ERPIServiceHttpSoap11Endpoint"));
|
||||||
|
}
|
||||||
|
return ports.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the endpoint address for the specified port name.
|
||||||
|
*/
|
||||||
|
public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException {
|
||||||
|
|
||||||
|
if ("ERPIServiceHttpSoap12Endpoint".equals(portName)) {
|
||||||
|
setERPIServiceHttpSoap12EndpointEndpointAddress(address);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if ("ERPIServiceHttpSoap11Endpoint".equals(portName)) {
|
||||||
|
setERPIServiceHttpSoap11EndpointEndpointAddress(address);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Unknown Port Name
|
||||||
|
throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the endpoint address for the specified port name.
|
||||||
|
*/
|
||||||
|
public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException {
|
||||||
|
setEndpointAddress(portName.getLocalPart(), address);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
/**
|
||||||
|
* ERPIServicePortType.java
|
||||||
|
*
|
||||||
|
* This file was auto-generated from WSDL
|
||||||
|
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.api.taojw.boge.webservice;
|
||||||
|
|
||||||
|
public interface ERPIServicePortType extends java.rmi.Remote {
|
||||||
|
public java.lang.String invokeSrv(java.lang.String paramXML) throws java.rmi.RemoteException;
|
||||||
|
public java.lang.String setT100JobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException;
|
||||||
|
public java.lang.String createFileData(java.lang.String paramXML) throws java.rmi.RemoteException;
|
||||||
|
public java.lang.String exportDataToErp(java.lang.String endPoint, java.lang.String xml) throws java.rmi.RemoteException;
|
||||||
|
public java.lang.String createProduct4OA(java.lang.String requestJson) throws java.rmi.RemoteException;
|
||||||
|
public java.lang.String setERPJobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException;
|
||||||
|
public java.lang.String syncProd(java.lang.String paramXML) throws java.rmi.RemoteException;
|
||||||
|
public java.lang.String callbackSrv(java.lang.String paramXML) throws java.rmi.RemoteException;
|
||||||
|
}
|
|
@ -0,0 +1,459 @@
|
||||||
|
/**
|
||||||
|
* ERPIServiceSoap11BindingStub.java
|
||||||
|
*
|
||||||
|
* This file was auto-generated from WSDL
|
||||||
|
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.api.taojw.boge.webservice;
|
||||||
|
|
||||||
|
public class ERPIServiceSoap11BindingStub extends org.apache.axis.client.Stub implements com.api.taojw.boge.webservice.ERPIServicePortType {
|
||||||
|
private java.util.Vector cachedSerClasses = new java.util.Vector();
|
||||||
|
private java.util.Vector cachedSerQNames = new java.util.Vector();
|
||||||
|
private java.util.Vector cachedSerFactories = new java.util.Vector();
|
||||||
|
private java.util.Vector cachedDeserFactories = new java.util.Vector();
|
||||||
|
|
||||||
|
static org.apache.axis.description.OperationDesc [] _operations;
|
||||||
|
|
||||||
|
static {
|
||||||
|
_operations = new org.apache.axis.description.OperationDesc[8];
|
||||||
|
_initOperationDesc1();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void _initOperationDesc1(){
|
||||||
|
org.apache.axis.description.OperationDesc oper;
|
||||||
|
org.apache.axis.description.ParameterDesc param;
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("invokeSrv");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[0] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("setT100JobStatus");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[1] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("createFileData");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[2] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("exportDataToErp");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "endPoint"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xml"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[3] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("createProduct4OA");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "requestJson"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[4] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("setERPJobStatus");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[5] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("syncProd");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[6] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("callbackSrv");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[7] = oper;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ERPIServiceSoap11BindingStub() throws org.apache.axis.AxisFault {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ERPIServiceSoap11BindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
|
||||||
|
this(service);
|
||||||
|
super.cachedEndpoint = endpointURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ERPIServiceSoap11BindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
|
||||||
|
if (service == null) {
|
||||||
|
super.service = new org.apache.axis.client.Service();
|
||||||
|
} else {
|
||||||
|
super.service = service;
|
||||||
|
}
|
||||||
|
((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
|
||||||
|
try {
|
||||||
|
org.apache.axis.client.Call _call = super._createCall();
|
||||||
|
if (super.maintainSessionSet) {
|
||||||
|
_call.setMaintainSession(super.maintainSession);
|
||||||
|
}
|
||||||
|
if (super.cachedUsername != null) {
|
||||||
|
_call.setUsername(super.cachedUsername);
|
||||||
|
}
|
||||||
|
if (super.cachedPassword != null) {
|
||||||
|
_call.setPassword(super.cachedPassword);
|
||||||
|
}
|
||||||
|
if (super.cachedEndpoint != null) {
|
||||||
|
_call.setTargetEndpointAddress(super.cachedEndpoint);
|
||||||
|
}
|
||||||
|
if (super.cachedTimeout != null) {
|
||||||
|
_call.setTimeout(super.cachedTimeout);
|
||||||
|
}
|
||||||
|
if (super.cachedPortName != null) {
|
||||||
|
_call.setPortName(super.cachedPortName);
|
||||||
|
}
|
||||||
|
java.util.Enumeration keys = super.cachedProperties.keys();
|
||||||
|
while (keys.hasMoreElements()) {
|
||||||
|
java.lang.String key = (java.lang.String) keys.nextElement();
|
||||||
|
_call.setProperty(key, super.cachedProperties.get(key));
|
||||||
|
}
|
||||||
|
return _call;
|
||||||
|
}
|
||||||
|
catch (java.lang.Throwable _t) {
|
||||||
|
throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String invokeSrv(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[0]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:invokeSrv");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "invokeSrv"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String setT100JobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[1]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:setT100JobStatus");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setT100JobStatus"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String createFileData(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[2]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:createFileData");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createFileData"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String exportDataToErp(java.lang.String endPoint, java.lang.String xml) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[3]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:exportDataToErp");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "exportDataToErp"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {endPoint, xml});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String createProduct4OA(java.lang.String requestJson) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[4]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:createProduct4OA");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createProduct4OA"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {requestJson});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String setERPJobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[5]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:setERPJobStatus");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setERPJobStatus"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String syncProd(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[6]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:syncProd");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "syncProd"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String callbackSrv(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[7]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:callbackSrv");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "callbackSrv"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,459 @@
|
||||||
|
/**
|
||||||
|
* ERPIServiceSoap12BindingStub.java
|
||||||
|
*
|
||||||
|
* This file was auto-generated from WSDL
|
||||||
|
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.api.taojw.boge.webservice;
|
||||||
|
|
||||||
|
public class ERPIServiceSoap12BindingStub extends org.apache.axis.client.Stub implements com.api.taojw.boge.webservice.ERPIServicePortType {
|
||||||
|
private java.util.Vector cachedSerClasses = new java.util.Vector();
|
||||||
|
private java.util.Vector cachedSerQNames = new java.util.Vector();
|
||||||
|
private java.util.Vector cachedSerFactories = new java.util.Vector();
|
||||||
|
private java.util.Vector cachedDeserFactories = new java.util.Vector();
|
||||||
|
|
||||||
|
static org.apache.axis.description.OperationDesc [] _operations;
|
||||||
|
|
||||||
|
static {
|
||||||
|
_operations = new org.apache.axis.description.OperationDesc[8];
|
||||||
|
_initOperationDesc1();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void _initOperationDesc1(){
|
||||||
|
org.apache.axis.description.OperationDesc oper;
|
||||||
|
org.apache.axis.description.ParameterDesc param;
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("invokeSrv");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[0] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("setT100JobStatus");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[1] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("createFileData");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[2] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("exportDataToErp");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "endPoint"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xml"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[3] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("createProduct4OA");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "requestJson"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[4] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("setERPJobStatus");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "xmlContext"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[5] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("syncProd");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[6] = oper;
|
||||||
|
|
||||||
|
oper = new org.apache.axis.description.OperationDesc();
|
||||||
|
oper.setName("callbackSrv");
|
||||||
|
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("http://service.dcis", "paramXML"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
|
||||||
|
param.setOmittable(true);
|
||||||
|
param.setNillable(true);
|
||||||
|
oper.addParameter(param);
|
||||||
|
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
|
oper.setReturnClass(java.lang.String.class);
|
||||||
|
oper.setReturnQName(new javax.xml.namespace.QName("http://service.dcis", "return"));
|
||||||
|
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
|
||||||
|
oper.setUse(org.apache.axis.constants.Use.LITERAL);
|
||||||
|
_operations[7] = oper;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ERPIServiceSoap12BindingStub() throws org.apache.axis.AxisFault {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ERPIServiceSoap12BindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
|
||||||
|
this(service);
|
||||||
|
super.cachedEndpoint = endpointURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ERPIServiceSoap12BindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
|
||||||
|
if (service == null) {
|
||||||
|
super.service = new org.apache.axis.client.Service();
|
||||||
|
} else {
|
||||||
|
super.service = service;
|
||||||
|
}
|
||||||
|
((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
|
||||||
|
try {
|
||||||
|
org.apache.axis.client.Call _call = super._createCall();
|
||||||
|
if (super.maintainSessionSet) {
|
||||||
|
_call.setMaintainSession(super.maintainSession);
|
||||||
|
}
|
||||||
|
if (super.cachedUsername != null) {
|
||||||
|
_call.setUsername(super.cachedUsername);
|
||||||
|
}
|
||||||
|
if (super.cachedPassword != null) {
|
||||||
|
_call.setPassword(super.cachedPassword);
|
||||||
|
}
|
||||||
|
if (super.cachedEndpoint != null) {
|
||||||
|
_call.setTargetEndpointAddress(super.cachedEndpoint);
|
||||||
|
}
|
||||||
|
if (super.cachedTimeout != null) {
|
||||||
|
_call.setTimeout(super.cachedTimeout);
|
||||||
|
}
|
||||||
|
if (super.cachedPortName != null) {
|
||||||
|
_call.setPortName(super.cachedPortName);
|
||||||
|
}
|
||||||
|
java.util.Enumeration keys = super.cachedProperties.keys();
|
||||||
|
while (keys.hasMoreElements()) {
|
||||||
|
java.lang.String key = (java.lang.String) keys.nextElement();
|
||||||
|
_call.setProperty(key, super.cachedProperties.get(key));
|
||||||
|
}
|
||||||
|
return _call;
|
||||||
|
}
|
||||||
|
catch (java.lang.Throwable _t) {
|
||||||
|
throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String invokeSrv(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[0]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:invokeSrv");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "invokeSrv"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String setT100JobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[1]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:setT100JobStatus");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setT100JobStatus"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String createFileData(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[2]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:createFileData");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createFileData"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String exportDataToErp(java.lang.String endPoint, java.lang.String xml) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[3]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:exportDataToErp");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "exportDataToErp"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {endPoint, xml});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String createProduct4OA(java.lang.String requestJson) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[4]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:createProduct4OA");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "createProduct4OA"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {requestJson});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String setERPJobStatus(java.lang.String xmlContext) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[5]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:setERPJobStatus");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "setERPJobStatus"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {xmlContext});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String syncProd(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[6]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:syncProd");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "syncProd"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.lang.String callbackSrv(java.lang.String paramXML) throws java.rmi.RemoteException {
|
||||||
|
if (super.cachedEndpoint == null) {
|
||||||
|
throw new org.apache.axis.NoEndPointException();
|
||||||
|
}
|
||||||
|
org.apache.axis.client.Call _call = createCall();
|
||||||
|
_call.setOperation(_operations[7]);
|
||||||
|
_call.setUseSOAPAction(true);
|
||||||
|
_call.setSOAPActionURI("urn:callbackSrv");
|
||||||
|
_call.setEncodingStyle(null);
|
||||||
|
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
|
||||||
|
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
|
||||||
|
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
|
||||||
|
_call.setOperationName(new javax.xml.namespace.QName("http://service.dcis", "callbackSrv"));
|
||||||
|
|
||||||
|
setRequestHeaders(_call);
|
||||||
|
setAttachments(_call);
|
||||||
|
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {paramXML});
|
||||||
|
|
||||||
|
if (_resp instanceof java.rmi.RemoteException) {
|
||||||
|
throw (java.rmi.RemoteException)_resp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extractAttachments(_call);
|
||||||
|
try {
|
||||||
|
return (java.lang.String) _resp;
|
||||||
|
} catch (java.lang.Exception _exception) {
|
||||||
|
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (org.apache.axis.AxisFault axisFaultException) {
|
||||||
|
throw axisFaultException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.api.taojw.bomei;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.hrm.HrmUserVarify;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.taojw.common.DaoUtil;
|
||||||
|
import weaver.taojw.common.logging.MyLogger;
|
||||||
|
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;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 柏美收付款提醒
|
||||||
|
*/
|
||||||
|
@Path("/bmfzckb")
|
||||||
|
public class FzcKbApi {
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
//获取下一条提醒
|
||||||
|
@GET
|
||||||
|
@Path("/getNextSfkTx")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String getNextSfkTx(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||||
|
//响应数据
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
//当前展示的是第几条数据
|
||||||
|
String currentId = request.getParameter("currentId");
|
||||||
|
if("".equals(currentId) || currentId == null){
|
||||||
|
currentId = "0";
|
||||||
|
}
|
||||||
|
//当前用户
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
logger.info("FzcKbApi.getNextSfkTx begin;currentId:" + currentId + ";user:" + user.getUID() + ";name:" + user.getLastname());
|
||||||
|
//查询比currentId大的下一条数据进行展示
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getNextTxSql =
|
||||||
|
"select " +
|
||||||
|
"top 1 " +
|
||||||
|
"t1.id,t4.khmc,t5.xmmc,t2.bcsqskje,t2.yskje," +
|
||||||
|
"case when t2.htzje is null or t2.htzje = 0 then '1.00' else FORMAT(t2.bcsqskje/t2.htzje,'N') end as bl," +
|
||||||
|
"t1.skrq " +
|
||||||
|
"from " +
|
||||||
|
"uf_skqd t1 " +
|
||||||
|
"inner join uf_skqd_dt1 t2 on t2.mainid = t1.id " +
|
||||||
|
"left join Modeviewlog_90 t3 on t3.operateuserid = ? and t3.relatedid = t1.id and t3.operatetype = 4 " +
|
||||||
|
"inner join uf_kh t4 on t4.id = t1.khmc " +
|
||||||
|
"inner join formtable_main_151 t5 on t5.id = t2.cwxm " +
|
||||||
|
"where " +
|
||||||
|
"t3.id is null " +
|
||||||
|
"and t1.id > ? " +
|
||||||
|
"order by " +
|
||||||
|
"t1.id ";
|
||||||
|
Map<String, String> txData = DaoUtil.getFirstData(rs, getNextTxSql, user.getUID(), currentId);
|
||||||
|
for(String key:txData.keySet()){
|
||||||
|
result.put(key,txData.get(key));
|
||||||
|
}
|
||||||
|
logger.info("FzcKbApi.getNextSfkTx end;result:" + result.toJSONString());
|
||||||
|
return result.toJSONString();
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("FzcKbApi.getNextSfkTx exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return result.toJSONString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.api.taojw.bomei.cronjob;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
import weaver.taojw.common.TjwModelUtil;
|
||||||
|
import weaver.taojw.common.DaoUtil;
|
||||||
|
import weaver.taojw.common.logging.MyLogger;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MakeDataCronJob extends BaseCronJob {
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
try{
|
||||||
|
logger.info("MakeDataCronJob.execute() begin");
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getCountSql =
|
||||||
|
"select " +
|
||||||
|
"sum(case when xmzt in (31,38,39,40,48) then 1 else 0 end) as zjxms," +
|
||||||
|
"sum(case when xmzt in (41,42,43) then 1 else 0 end) as ysxms," +
|
||||||
|
"sum(case when mqsjscjd not in (9,10) then 1 else 0 end) as gzxms," +
|
||||||
|
"format(DATEADD(YEAR,-1,GETDATE()),'yyyy') as nf " +
|
||||||
|
"from " +
|
||||||
|
"uf_xm t1 " +
|
||||||
|
"where " +
|
||||||
|
"substring(t1.modedatacreatedate,1,4) = format(DATEADD(YEAR,-1,GETDATE()),'yyyy') ";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getCountSql);
|
||||||
|
String zjxms = firstData.get("zjxms");
|
||||||
|
String ysxms = firstData.get("ysxms");
|
||||||
|
String gzxms = firstData.get("gzxms");
|
||||||
|
String nf = firstData.get("nf");
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("zjxms",zjxms);
|
||||||
|
json.put("ysxms",ysxms);
|
||||||
|
json.put("gzxms",gzxms);
|
||||||
|
json.put("nf",nf);
|
||||||
|
TjwModelUtil.addModelData(rs,"uf_zjxms",json);
|
||||||
|
|
||||||
|
logger.info("MakeDataCronJob.execute() end");
|
||||||
|
}catch(Throwable e){
|
||||||
|
logger.error("MakeDataCronJob.execute() exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,206 @@
|
||||||
|
package com.api.taojw.bozhongjgj;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.doc.detail.util.DocDownloadCheckUtil;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
|
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||||
|
import sun.misc.BASE64Encoder;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.file.ImageFileManager;
|
||||||
|
import weaver.hrm.HrmUserVarify;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.taojw.common.CommonSqlUtil;
|
||||||
|
import weaver.taojw.common.DaoUtil;
|
||||||
|
import weaver.taojw.common.TjwDocumentUtil;
|
||||||
|
import weaver.taojw.common.logging.MyLogger;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
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;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Path("/fpdy")
|
||||||
|
public class GetFpImageApi {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/getImageDataById")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String getImageDataById(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//发票台账id
|
||||||
|
String requestId = request.getParameter("requestId");
|
||||||
|
String fieldNames = request.getParameter("fieldNames");
|
||||||
|
|
||||||
|
/*String workFlowIds = request.getParameter("workFlowIds");
|
||||||
|
String[] workFlowIdArr = workFlowIds.split(",");
|
||||||
|
String nodeIds = request.getParameter("nodeIds");
|
||||||
|
String[] nodeIdArr = nodeIds.split(",");
|
||||||
|
String requestIds = request.getParameter("requestIds");
|
||||||
|
List<String> requestIdList = new ArrayList<>();*/
|
||||||
|
String getBaseInfoSql =
|
||||||
|
"select workflowid,currentnodeid from workflow_requestbase where requestid = ?";
|
||||||
|
/*for(String requestIdInArr : requestIds.split(",")){
|
||||||
|
boolean requestIdInWorkflow = false;
|
||||||
|
boolean requestIdInNode = false;
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getBaseInfoSql, requestIdInArr);
|
||||||
|
String workflowid = firstData.get("firstData");
|
||||||
|
String currentnodeid = firstData.get("currentnodeid");
|
||||||
|
if(workflowid != null && !"".equals(workflowid) && currentnodeid != null && !"".equals(currentnodeid)){
|
||||||
|
for(String workFlowId : workFlowIdArr){
|
||||||
|
if(workFlowId.equals(workflowid)){
|
||||||
|
requestIdInWorkflow = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(String nodeid : nodeIdArr){
|
||||||
|
if(nodeid.equals(currentnodeid)){
|
||||||
|
requestIdInNode = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(requestIdInWorkflow && requestIdInNode){
|
||||||
|
requestIdList.add(requestIdInArr);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs);
|
||||||
|
List<String> fpIdList = new ArrayList<>();
|
||||||
|
if(!"".equals(requestId) && requestId != null){
|
||||||
|
if(!"".equals(fieldNames) && fieldNames != null){
|
||||||
|
String[] fieldNameArr = fieldNames.split(",");
|
||||||
|
for(String fieldName : fieldNameArr){
|
||||||
|
String getTableNameSql = "select t1." + fieldName + " from " + tableName + "_dt1 t1 inner join " + tableName + " t2 on t2.id = t1.mainid where t2.requestid = ?";
|
||||||
|
List<Map<String, String>> data = DaoUtil.getData(rs, getTableNameSql, requestId);
|
||||||
|
for(Map<String, String> m : data){
|
||||||
|
String fpIds = m.get(fieldName.toLowerCase(Locale.ROOT));
|
||||||
|
if(fpIds != null && !"".equals(fpIds)){
|
||||||
|
String[] fpIdArr = fpIds.split(",");
|
||||||
|
for(String fpId : fpIdArr){
|
||||||
|
fpIdList.add(fpId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*for(String requestIdInArr : requestIdList){
|
||||||
|
if(!"".equals(fieldNames) && fieldNames != null){
|
||||||
|
String[] fieldNameArr = fieldNames.split(",");
|
||||||
|
for(String fieldName : fieldNameArr){
|
||||||
|
String getTableNameSql = "select t1." + fieldName + " from " + tableName + "_dt1 t1 inner join " + tableName + " t2 on t2.id = t1.mainid where t2.requestid = ?";
|
||||||
|
List<Map<String, String>> data = DaoUtil.getData(rs, getTableNameSql, requestIdInArr);
|
||||||
|
for(Map<String, String> m : data){
|
||||||
|
String fpIds = m.get(fieldName.toLowerCase(Locale.ROOT));
|
||||||
|
if(fpIds != null && !"".equals(fpIds)){
|
||||||
|
String[] fpIdArr = fpIds.split(",");
|
||||||
|
for(String fpId : fpIdArr){
|
||||||
|
fpIdList.add(fpId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
JSONArray res = new JSONArray();
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
|
||||||
|
for(String id : fpIdList){
|
||||||
|
JSONObject o = new JSONObject();
|
||||||
|
//获取发票imageFileId
|
||||||
|
String imageFileId = "";
|
||||||
|
String imageFileType = "";
|
||||||
|
String fileSize = "";
|
||||||
|
String getImageFileIdSql = "select t1.imageid,t2.imagefilename,t2.filesize from fnainvoiceledger t1 inner join imagefile t2 on t2.imageFileId = t1.imageid where t1.id = ?";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getImageFileIdSql, id);
|
||||||
|
if(firstData.size() > 0){
|
||||||
|
imageFileId = firstData.get("imageid");
|
||||||
|
String imageFileName = firstData.get("imagefilename");
|
||||||
|
fileSize = firstData.get("filesize");
|
||||||
|
imageFileType = imageFileName.substring(imageFileName.lastIndexOf(".")+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
String newImageFileId = "";
|
||||||
|
try{
|
||||||
|
logger.info("DocDownloadCheckUtil.checkPermission begin;imageFileId:" + imageFileId + ";user:" + user.getUID());
|
||||||
|
newImageFileId = DocDownloadCheckUtil.checkPermission(imageFileId,user);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("DocDownloadCheckUtil.checkPermission exception;imageFileId:" + imageFileId + ";user:"+user.getUID()+";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
o.put("imageFileType",imageFileType);
|
||||||
|
o.put("imageFileId",imageFileId);
|
||||||
|
o.put("newImageFileId",newImageFileId);
|
||||||
|
String imageImageFileId = pdfToImage(imageFileId);
|
||||||
|
o.put("base64",imageToBase64(imageImageFileId,fileSize));
|
||||||
|
res.add(o);
|
||||||
|
}
|
||||||
|
result.put("data",res);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("getImageDataById exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
|
||||||
|
public static String imageToBase64(String imageFileId,String fileSize) {
|
||||||
|
byte[] data = null;
|
||||||
|
// 读取图片字节数组
|
||||||
|
try {
|
||||||
|
ImageFileManager imageFileManager = new ImageFileManager();
|
||||||
|
InputStream in = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId));
|
||||||
|
data = new byte[Integer.parseInt(fileSize)*12];
|
||||||
|
in.read(data);
|
||||||
|
in.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("imageToBase64 exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
// 对字节数组Base64编码
|
||||||
|
BASE64Encoder encoder = new BASE64Encoder();
|
||||||
|
return encoder.encode(data);// 返回Base64编码过的字节数组字符串
|
||||||
|
}
|
||||||
|
|
||||||
|
public String pdfToImage(String pdfImageFileId){
|
||||||
|
try {
|
||||||
|
ImageFileManager imageFileManager = new ImageFileManager();
|
||||||
|
InputStream in = imageFileManager.getInputStreamById(Integer.parseInt(pdfImageFileId));
|
||||||
|
PDDocument doc = PDDocument.load(in);
|
||||||
|
PDFRenderer renderer = new PDFRenderer(doc);
|
||||||
|
int pageCount = doc.getNumberOfPages();
|
||||||
|
int fileByInputSteam = 0;
|
||||||
|
for(int i=0;i<pageCount;i++){
|
||||||
|
BufferedImage image = renderer.renderImageWithDPI(i, 296);
|
||||||
|
//BufferedImage image = renderer.renderImage(i, 2.5f);
|
||||||
|
File imageFile = new File(pdfImageFileId+"image.png");
|
||||||
|
ImageIO.write(image, "PNG", imageFile);
|
||||||
|
fileByInputSteam = TjwDocumentUtil.createFileByInputSteam(new FileInputStream(imageFile), pdfImageFileId + "image.png");
|
||||||
|
}
|
||||||
|
return fileByInputSteam + "";
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("pdfToImage exception;message:" + e.getMessage() + ";id:" + pdfImageFileId);
|
||||||
|
return pdfImageFileId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.api.taojw.chuanbo.api;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.hrm.HrmUserVarify;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.taojw.common.CommonSqlUtil;
|
||||||
|
import weaver.taojw.common.DaoUtil;
|
||||||
|
import weaver.taojw.common.TjwWorkFlowUtil;
|
||||||
|
import weaver.taojw.common.logging.MyLogger;
|
||||||
|
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;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中船
|
||||||
|
* 查询列表中点击批量提交按钮 调用此api 批量创建流程
|
||||||
|
*/
|
||||||
|
@Path("/zctjw")
|
||||||
|
public class StartWorkFlowApi {
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/startWorkFlowApi")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String startWorkFlowApi(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||||
|
//响应数据
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
logger.info("StartWorkFlowApi.multiSubmitApi begin;");
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//发起的流程workFlowId
|
||||||
|
String workFlowId = Util.null2String(request.getParameter("workFlowId"));
|
||||||
|
//建模id
|
||||||
|
String modeId = Util.null2String(request.getParameter("modeId"));
|
||||||
|
String modeTableName = CommonSqlUtil.getTableNameByModeId(modeId,rs);
|
||||||
|
//勾选的id
|
||||||
|
String selectedIds = Util.null2String(request.getParameter("selectedIds"));
|
||||||
|
if(selectedIds == null || "".equals(selectedIds)){
|
||||||
|
result.put("flag","3");
|
||||||
|
return result.toJSONString();
|
||||||
|
}
|
||||||
|
String[] selectedIdArr = selectedIds.split(",");
|
||||||
|
String getModeDataSql = "select * from " + modeTableName + " where id = ?";
|
||||||
|
for(String id : selectedIdArr){
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getModeDataSql, id);
|
||||||
|
Map<String, String> mainTable = new HashMap<>();
|
||||||
|
mainTable.put("xgya",firstData.get("xgyt"));
|
||||||
|
String requestName = firstData.get("dbmc");
|
||||||
|
TjwWorkFlowUtil.createWorkFlow(requestName,user.getUID()+"",workFlowId,"1",mainTable,null);
|
||||||
|
}
|
||||||
|
result.put("flag","1");
|
||||||
|
return result.toJSONString();
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("MultiSubmitApi.multiSubmitApi exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return result.toJSONString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.api.taojw.chuanbo.servlet;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.taojw.common.CommonSqlUtil;
|
||||||
|
import weaver.taojw.common.DaoUtil;
|
||||||
|
import weaver.taojw.common.TjwDocumentUtil;
|
||||||
|
import weaver.taojw.common.logging.MyLogger;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class FileDownloadServlet extends HttpServlet{
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
|
||||||
|
this.doGet(req, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//获取参数
|
||||||
|
|
||||||
|
String modeId = Util.null2String(req.getParameter("modeId"));
|
||||||
|
String tableName = CommonSqlUtil.getTableNameByModeId(modeId,rs);
|
||||||
|
String columns = Util.null2String(req.getParameter("columns"));
|
||||||
|
String ids = Util.null2String(req.getParameter("ids"));
|
||||||
|
String fileName = Util.null2String(req.getParameter("ids"));
|
||||||
|
|
||||||
|
logger.info("FileDownloadServlet.param: modeId:" + modeId + ";columns:" + columns + ";ids:" + ids);
|
||||||
|
if("".equals(ids) || ids == null || columns == null || "".equals(columns)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] idArr = ids.split(",");
|
||||||
|
String[] columnArr = columns.split(",");
|
||||||
|
String getDocIdSql = "SELECT " + columns + " from " + tableName + " where id = ?";
|
||||||
|
String getImageFileInfoSql = "select imagefilename,imagefileid from docimagefile where docid = ? order by versionid desc";
|
||||||
|
List<String> docIdList = new ArrayList<>();
|
||||||
|
for(String id : idArr){
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getDocIdSql, id);
|
||||||
|
for(String column : columnArr){
|
||||||
|
String docId = firstData.get(column.toLowerCase(Locale.ROOT));
|
||||||
|
if(docId != null && !"".equals(docId)){
|
||||||
|
docIdList.add(firstData.get(column.toLowerCase(Locale.ROOT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Map<String,String>> imageFileInfos = new ArrayList<>();
|
||||||
|
for(String docId : docIdList){
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getImageFileInfoSql, docId);
|
||||||
|
Map<String, String> m = new HashMap<>();
|
||||||
|
m.put("imageFileId",firstData.get("imagefileid"));
|
||||||
|
m.put("imageFileName",firstData.get("imagefilename"));
|
||||||
|
imageFileInfos.add(m);
|
||||||
|
}
|
||||||
|
//响应文件
|
||||||
|
downloadExcel(res,imageFileInfos,fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downloadExcel(HttpServletResponse res,List<Map<String,String>> imageFileInfos,String fileName){
|
||||||
|
try {
|
||||||
|
res.setContentType("application/octet-stream");
|
||||||
|
res.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(fileName,"UTF-8"));
|
||||||
|
//res.setHeader("Content-Length", String.valueOf(fis.getChannel().size()));
|
||||||
|
ServletOutputStream servletOutputStream = res.getOutputStream();
|
||||||
|
try{
|
||||||
|
TjwDocumentUtil.toZip(imageFileInfos,servletOutputStream);
|
||||||
|
//关闭资源
|
||||||
|
servletOutputStream.close();
|
||||||
|
}catch(Throwable e){
|
||||||
|
logger.error("FileDownloadServlet.return file exception;exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
}finally {
|
||||||
|
servletOutputStream.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("FileDownloadServlet exception;e:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
logger.info("FileDownloadServlet done");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,460 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.conn.RecordSetTrans;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CommonSqlUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static List<Map<String, String>> getDoneInfo(String userId){
|
||||||
|
try {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getDoneInfoSql =
|
||||||
|
"select " +
|
||||||
|
"a.requestId as id, a.requestId as requestId, " +
|
||||||
|
"a.workflowId, a.requestName, a.requestnamenew,a.creater, a.creatertype, a.createDate, a.createTime, " +
|
||||||
|
"c.workflowname,b.viewtype,b.nodeid,b.isremark,b.agentorbyagentid,b.agenttype,b.isprocessed ,b.viewDate," +
|
||||||
|
"b.viewTime,a.lastFeedBackDate,a.lastFeedBackTime,b.needwfback,a.lastFeedBackOperator,b.userid," +
|
||||||
|
"(case WHEN b.operatedate IS NULL THEN b.receivedate ELSE b.operatedate END) operatedatenew,(case WHEN b.operatetime IS NULL THEN b.receivetime ELSE b.operatetime END) operatetimenew " +
|
||||||
|
"FROM " +
|
||||||
|
"Workflow_CurrentOperator b " +
|
||||||
|
"inner join Workflow_RequestBase a on a.requestId = b.requestId " +
|
||||||
|
"inner join workflow_base c on a.workflowid = c.id " +
|
||||||
|
"WHERE " +
|
||||||
|
"b.userId = ? " +
|
||||||
|
"AND (b.isRemark in ('2', '4') or (b.isremark=0 and b.takisremark =-2)) " +
|
||||||
|
"AND b.userType = 0 " +
|
||||||
|
"AND b.isLastTimes = 1 " +
|
||||||
|
"and (a.deleted<>1 or a.deleted is null or a.deleted='') " +
|
||||||
|
"AND (b.isComplete = 1 OR b.agenttype<>1)";
|
||||||
|
List<Map<String, String>> data = DaoUtil.getData(rs, getDoneInfoSql, userId);
|
||||||
|
return data;
|
||||||
|
}catch(Throwable e){
|
||||||
|
logger.error("CommonSqlUtil.getDoneInfo error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Map<String, String>> getWorkFlowCurrentUser(String requestId){
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//数据库类型
|
||||||
|
String dbType = rs.getDBType();
|
||||||
|
//查询人员待办数量、邮箱地址、人员id
|
||||||
|
String sql = "";
|
||||||
|
if("mysql".equalsIgnoreCase(dbType)){
|
||||||
|
sql =
|
||||||
|
"select " +
|
||||||
|
"t3.id " +
|
||||||
|
"from " +
|
||||||
|
"workflow_requestbase t1 " +
|
||||||
|
"inner join workflow_currentoperator t2 on t1.requestid = t2.requestid " +
|
||||||
|
"inner join workflow_nodebase t5 on t5.id = t1.currentnodeid " +
|
||||||
|
"inner join hrmresource t3 on t3.id = t2.userid " +
|
||||||
|
"where " +
|
||||||
|
"((isremark='0' and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " +
|
||||||
|
"and islasttimes = 1 " +
|
||||||
|
"and (ifnull(t1.currentstatus,-1) = -1 or (ifnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " +
|
||||||
|
"and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " +
|
||||||
|
"and (t2.isprocessing = '' or t2.isprocessing is null) " +
|
||||||
|
"and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " +
|
||||||
|
"and t1.requestid = ?";
|
||||||
|
}
|
||||||
|
|
||||||
|
if("sqlserver".equalsIgnoreCase(dbType)){
|
||||||
|
sql =
|
||||||
|
"select " +
|
||||||
|
"t3.id " +
|
||||||
|
"from " +
|
||||||
|
"workflow_currentoperator t2 " +
|
||||||
|
"inner join workflow_requestbase t1 on t1.requestid = t2.requestid " +
|
||||||
|
"inner join hrmresource t3 on t3.id = t2.userid " +
|
||||||
|
"where " +
|
||||||
|
"((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " +
|
||||||
|
"and islasttimes=1 " +
|
||||||
|
"and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " +
|
||||||
|
"and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " +
|
||||||
|
"and (t2.isprocessing = '' or t2.isprocessing is null) " +
|
||||||
|
"and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " +
|
||||||
|
"and t1.requestid = ?";
|
||||||
|
}
|
||||||
|
|
||||||
|
if("oracle".equalsIgnoreCase(dbType)){
|
||||||
|
sql =
|
||||||
|
"select " +
|
||||||
|
"t3.id " +
|
||||||
|
"from " +
|
||||||
|
"workflow_currentoperator t2," +
|
||||||
|
"workflow_requestbase t1," +
|
||||||
|
"hrmresource t3 " +
|
||||||
|
"where " +
|
||||||
|
"t1.requestid = t2.requestid " +
|
||||||
|
"and t3.id = t2.userid " +
|
||||||
|
"and ((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " +
|
||||||
|
"and islasttimes=1 " +
|
||||||
|
"and (NVL(t1.currentstatus,-1) = -1 or (NVL(t1.currentstatus,-1)=0 and t1.creater in (1))) " +
|
||||||
|
"and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " +
|
||||||
|
"and (t2.isprocessing = '' or t2.isprocessing is null) " +
|
||||||
|
"and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " +
|
||||||
|
"and t1.requestid = ?";
|
||||||
|
}
|
||||||
|
List<Map<String, String>> data = DaoUtil.getData(rs, sql, requestId);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Map<String, String>> getTodoInfo(String userId){
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//数据库类型
|
||||||
|
String dbType = rs.getDBType();
|
||||||
|
//查询人员待办数量、邮箱地址、人员id
|
||||||
|
String sql = "";
|
||||||
|
if("mysql".equalsIgnoreCase(dbType)){
|
||||||
|
sql =
|
||||||
|
"select " +
|
||||||
|
"t1.requestid,t1.workflowid " +
|
||||||
|
"from " +
|
||||||
|
"workflow_requestbase t1 " +
|
||||||
|
"inner join workflow_currentoperator t2 on t1.requestid = t2.requestid " +
|
||||||
|
"inner join workflow_nodebase t5 on t5.id = t1.currentnodeid " +
|
||||||
|
"inner join hrmresource t3 on t3.id = t2.userid " +
|
||||||
|
"where " +
|
||||||
|
"((isremark='0' and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " +
|
||||||
|
"and islasttimes = 1 " +
|
||||||
|
"and (ifnull(t1.currentstatus,-1) = -1 or (ifnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " +
|
||||||
|
"and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " +
|
||||||
|
"and (t2.isprocessing = '' or t2.isprocessing is null) " +
|
||||||
|
"and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " +
|
||||||
|
"and t3.id = ?";
|
||||||
|
}
|
||||||
|
|
||||||
|
if("sqlserver".equalsIgnoreCase(dbType)){
|
||||||
|
sql =
|
||||||
|
"select " +
|
||||||
|
"t1.requestid,t1.workflowid " +
|
||||||
|
"from " +
|
||||||
|
"workflow_currentoperator t2 " +
|
||||||
|
"inner join workflow_requestbase t1 on t1.requestid = t2.requestid " +
|
||||||
|
"inner join hrmresource t3 on t3.id = t2.userid " +
|
||||||
|
"where " +
|
||||||
|
"((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " +
|
||||||
|
"and islasttimes=1 " +
|
||||||
|
"and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater in (1))) " +
|
||||||
|
"and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " +
|
||||||
|
"and (t2.isprocessing = '' or t2.isprocessing is null) " +
|
||||||
|
"and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " +
|
||||||
|
"and t3.id = ?";
|
||||||
|
}
|
||||||
|
|
||||||
|
if("oracle".equalsIgnoreCase(dbType)){
|
||||||
|
sql =
|
||||||
|
"select " +
|
||||||
|
"t1.requestid,t1.workflowid " +
|
||||||
|
"from " +
|
||||||
|
"workflow_currentoperator t2," +
|
||||||
|
"workflow_requestbase t1," +
|
||||||
|
"hrmresource t3 " +
|
||||||
|
"where " +
|
||||||
|
"t1.requestid = t2.requestid " +
|
||||||
|
"and t3.id = t2.userid " +
|
||||||
|
"and ((isremark='0'and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9','11')) " +
|
||||||
|
"and islasttimes=1 " +
|
||||||
|
"and (NVL(t1.currentstatus,-1) = -1 or (NVL(t1.currentstatus,-1)=0 and t1.creater in (1))) " +
|
||||||
|
"and (t1.deleted<>1 or t1.deleted is null or t1.deleted='') " +
|
||||||
|
"and (t2.isprocessing = '' or t2.isprocessing is null) " +
|
||||||
|
"and ((t2.isremark not in('1','8','9','11') or (t2.isremark='1' and t2.takisremark='2'))) " +
|
||||||
|
"and t3.id = ?";
|
||||||
|
}
|
||||||
|
List<Map<String, String>> data = DaoUtil.getData(rs, sql, userId);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有上级部门id
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void getAllParentDepartment(List<String> result,String id){
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getParentDepartmentSql = "select supdepid from hrmdepartment where id = ?";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getParentDepartmentSql, id);
|
||||||
|
String parentId = Util.null2String(firstData.get("supdepid"));
|
||||||
|
if("".equals(parentId)){
|
||||||
|
return ;
|
||||||
|
}else{
|
||||||
|
result.add(parentId);
|
||||||
|
getAllParentDepartment(result,parentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有下级部门id
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void getAllSonDepartment(List<String> result,String id){
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getParentDepartmentSql = "select id from hrmdepartment where supdepid = ?";
|
||||||
|
List<Map<String, String>> data = DaoUtil.getData(rs, getParentDepartmentSql, id);
|
||||||
|
if(data.size() == 0){
|
||||||
|
return ;
|
||||||
|
}else{
|
||||||
|
for(Map<String, String> m : data){
|
||||||
|
result.add(m.get("id"));
|
||||||
|
getAllSonDepartment(result,m.get("id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统参数设置值
|
||||||
|
* @param uuid 参数标识
|
||||||
|
* @return 返回配置值
|
||||||
|
*/
|
||||||
|
public static String getSystemParamValue(String uuid,RecordSet rs){
|
||||||
|
String result = "";
|
||||||
|
try{
|
||||||
|
String getDataByUuidSql =
|
||||||
|
"select paramvalue as result from uf_systemconfig where uuid = ?";
|
||||||
|
if(rs.executeQuery(getDataByUuidSql,uuid)){
|
||||||
|
if(rs.next()){
|
||||||
|
result = Util.null2String(rs.getString("result"));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getSystemParamValue.getDataByUuidSql execute error;sql:" + getDataByUuidSql);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("CommonSqlUtil.getSystemParamValue exception;uuid:" + uuid);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据流程类型ID获取其对应的表单名称
|
||||||
|
* @param workFlowId 流程类型ID
|
||||||
|
* @return 字符串
|
||||||
|
*/
|
||||||
|
public static String getTableNameByWorkflowId(String workFlowId,RecordSet rs){
|
||||||
|
String tableName = "";
|
||||||
|
try{
|
||||||
|
String getTableNameByWorkFlowIdSql =
|
||||||
|
"select tablename from workflow_bill where id in (select formid from workflow_base where id = ?)";
|
||||||
|
if(rs.executeQuery(getTableNameByWorkFlowIdSql,workFlowId)){
|
||||||
|
if(rs.next()){
|
||||||
|
tableName = Util.null2String(rs.getString("tablename"));
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByWorkflowId.getTableNameByWorkFlowIdSql execute success but found nothing;sql:" + getTableNameByWorkFlowIdSql);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByWorkflowId.getTableNameByWorkFlowIdSql execute error;sql:" + getTableNameByWorkFlowIdSql);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByWorkflowId exception;workFlowId:" + workFlowId);
|
||||||
|
}
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据requestId查询主表表名
|
||||||
|
* @param requestId
|
||||||
|
* @param rs 数据库链接
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getTableNameByRequetId(String requestId, RecordSet rs){
|
||||||
|
String tableName = "";
|
||||||
|
try{
|
||||||
|
String getTableNameByRequetIdSql =
|
||||||
|
"select tablename from workflow_bill where id = (Select formid from workflow_base where id = (select workflowid from workflow_requestbase where requestid = ? ))";
|
||||||
|
if(rs.executeQuery(getTableNameByRequetIdSql,requestId)){
|
||||||
|
if(rs.next()){
|
||||||
|
tableName = Util.null2String(rs.getString("tablename"));
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByRequetId.getTableNameByRequetIdSql execute success but found nothing;sql:" + getTableNameByRequetIdSql);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByRequetId.getTableNameByRequetIdSql execute error;sql:" + getTableNameByRequetIdSql);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByRequetId exception;requestId:" + requestId);
|
||||||
|
}
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据modeId查询建模表表名
|
||||||
|
* @param modeId 建模表表名
|
||||||
|
* @param rs 数据库链接
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getTableNameByModeId(String modeId, RecordSet rs){
|
||||||
|
String tableName = "";
|
||||||
|
try{
|
||||||
|
String getTableNameSql =
|
||||||
|
"select t2.tablename from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid where t1.id = ?";
|
||||||
|
if(rs.executeQuery(getTableNameSql,modeId)){
|
||||||
|
if(rs.next()){
|
||||||
|
tableName = Util.null2String(rs.getString("tablename"));
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql execute success but found nothing;sql:" + getTableNameSql + ";modeId:" + modeId);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql execute error;sql:" + getTableNameSql+ ";modeId:" + modeId);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("CommonSqlUtil.getTableNameByModeId.getTableNameSql exception;modeId:" + modeId);
|
||||||
|
}
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据建模表表名查询modeId
|
||||||
|
* @param tableName 建模表表名
|
||||||
|
* @param rs 数据库链接
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static int getModeIdByTableName(String tableName, RecordSet rs){
|
||||||
|
int modeId = -1;
|
||||||
|
try{
|
||||||
|
String getModeIdSql =
|
||||||
|
"select t1.id from modeinfo t1 inner join workflow_bill t2 on t2.id = t1.formid where t2.tablename = '" + tableName + "' and t1.isdelete = 0";
|
||||||
|
if(rs.executeQuery(getModeIdSql)){
|
||||||
|
if(rs.next()){
|
||||||
|
modeId = Util.getIntValue(rs.getString("id"),0);
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql execute success but found nothing;sql:" + getModeIdSql);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql execute error;sql:" + getModeIdSql);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("CommonSqlUtil.getModeIdByTableName.getModeIdSql exception;tableName:" + tableName);
|
||||||
|
}
|
||||||
|
return modeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据requestId获取流程审批意见
|
||||||
|
* @param requestId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<Map<String,String>> getProcessInfoList(String requestId,RecordSet rs){
|
||||||
|
List<Map<String,String>> result = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
if(rs == null){
|
||||||
|
rs = new RecordSet();
|
||||||
|
}
|
||||||
|
String selectSQL =
|
||||||
|
"Select " +
|
||||||
|
"t2.departmentid as deptid," +
|
||||||
|
"t3.departmentname as deptname," +
|
||||||
|
"t1.operator as createuserid," +
|
||||||
|
"t2.lastname as createusername," +
|
||||||
|
"t1.operatedate as operatedate," +
|
||||||
|
"t1.operatetime as operatetime," +
|
||||||
|
"t1.logtype as serviceactioncode," +
|
||||||
|
"t1.remark as suggestion " +
|
||||||
|
"from " +
|
||||||
|
"workflow_requestlog t1 " +
|
||||||
|
"left join Hrmresource t2 on t2.id= t1.operator " +
|
||||||
|
"left join hrmdepartment t3 on t3.id= t2.departmentid " +
|
||||||
|
"where " +
|
||||||
|
"t1.requestid = ? " +
|
||||||
|
"order by " +
|
||||||
|
"t1.operatedate asc,t1.operatetime asc";
|
||||||
|
if(rs.executeQuery(selectSQL,requestId)){
|
||||||
|
while(rs.next()){
|
||||||
|
Map<String,String> processInfo = new HashMap<>();
|
||||||
|
processInfo.put("deptid",Util.null2String(rs.getString("deptid")));
|
||||||
|
processInfo.put("deptname",Util.null2String(rs.getString("deptname")));
|
||||||
|
processInfo.put("createuserid",Util.null2String(rs.getString("createuserid")));
|
||||||
|
processInfo.put("createusername",Util.null2String(rs.getString("createusername")));
|
||||||
|
processInfo.put("serviceactiontime",Util.null2String(rs.getString("operatedate")) + " " + Util.null2String(rs.getString("operatetime")));
|
||||||
|
String serviceactioncode = Util.null2String(rs.getString("serviceactioncode"));
|
||||||
|
String serviceaction = "";
|
||||||
|
switch (serviceactioncode){
|
||||||
|
case "0": serviceaction = "批准"; break;
|
||||||
|
case "1": serviceaction = "保存"; break;
|
||||||
|
case "2": serviceaction = "提交"; break;
|
||||||
|
case "3": serviceaction = "退回"; break;
|
||||||
|
case "4": serviceaction = "重新打开"; break;
|
||||||
|
case "5": serviceaction = "删除"; break;
|
||||||
|
case "6": serviceaction = "激活"; break;
|
||||||
|
case "7": serviceaction = "转发"; break;
|
||||||
|
case "9": serviceaction = "批注"; break;
|
||||||
|
case "a": serviceaction = "意见征询"; break;
|
||||||
|
case "b": serviceaction = "意见征询回复"; break;
|
||||||
|
case "e": serviceaction = "强制归档"; break;
|
||||||
|
case "h": serviceaction = "转办"; break;
|
||||||
|
case "i": serviceaction = "干预"; break;
|
||||||
|
case "j": serviceaction = "转办反馈"; break;
|
||||||
|
case "s": serviceaction = "督办"; break;
|
||||||
|
case "t": serviceaction = "抄送"; break;
|
||||||
|
default: serviceaction = "其他"; break;
|
||||||
|
}
|
||||||
|
processInfo.put("serviceaction",serviceaction);
|
||||||
|
String suggestion = Util.null2String(rs.getString("suggestion"));
|
||||||
|
if(!"".equals(suggestion)){
|
||||||
|
suggestion = CommonUtil.delHTMLTag(suggestion);
|
||||||
|
}
|
||||||
|
processInfo.put("suggestion",suggestion);
|
||||||
|
result.add(processInfo);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getProcessInfoList.sql error;sql:" + selectSQL + ";requestId:" + requestId);
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonSqlUtil.getProcessInfoList exception;requestId:" + requestId + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据requestid,获取流程审批意见
|
||||||
|
* @param rs
|
||||||
|
* @param requestId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getWorkFlowSuggestion(RecordSetTrans rs, String requestId){
|
||||||
|
String result = "";
|
||||||
|
String getWorkFlowSuggestionSql =
|
||||||
|
"Select " +
|
||||||
|
"t2.departmentid as deptid," +
|
||||||
|
"t3.departmentname as deptname," +
|
||||||
|
"t1.operator as createuserid," +
|
||||||
|
"t2.lastname as createusername," +
|
||||||
|
"t1.operatedate as operatedate," +
|
||||||
|
"t1.operatetime as operatetime," +
|
||||||
|
"t1.logtype as logtype," +
|
||||||
|
"t1.remark as suggestion " +
|
||||||
|
"from " +
|
||||||
|
"workflow_requestlog t1 " +
|
||||||
|
"left join Hrmresource t2 on t2.id= t1.operator " +
|
||||||
|
"left join hrmdepartment t3 on t3.id= t2.departmentid " +
|
||||||
|
"where " +
|
||||||
|
"requestid = ? " +
|
||||||
|
"order by " +
|
||||||
|
"t1.operatedate desc,t1.operatetime desc";
|
||||||
|
try{
|
||||||
|
if(rs.executeQuery(getWorkFlowSuggestionSql,requestId)){
|
||||||
|
if(rs.next()){
|
||||||
|
result = Util.null2String(rs.getString("suggestion"));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("CommonSqlUtil.getWorkFlowSuggestion execute error;getWorkFlowSuggestionSql:" + getWorkFlowSuggestionSql);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("CommonSqlUtil.getFormatTimeByTimeMillis execute error;getWorkFlowSuggestionSql:" + getWorkFlowSuggestionSql + "exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,318 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class CommonUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
static SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
static DecimalFormat jeFormat = new DecimalFormat("###,##0.00");
|
||||||
|
static DecimalFormat twoXsFormat = new DecimalFormat("0.00");
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JSONObject getLastMonthDate(){
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
SimpleDateFormat df =new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.MONTH, -1);
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
String berforeFirstDay = df.format(calendar.getTime());
|
||||||
|
result.put("lastMonthBegin",berforeFirstDay);
|
||||||
|
Calendar calendar1 = Calendar.getInstance();
|
||||||
|
calendar1.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
calendar1.add(Calendar.DATE, -1);
|
||||||
|
String berforeLastDay = df.format(calendar1.getTime());
|
||||||
|
result.put("berforeLastDay",berforeLastDay);
|
||||||
|
//logger.error("CommonUtil.getLastMonthDate done;result:" + result.toJSONString());
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.getLastMonthDate exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 减法
|
||||||
|
* @param js
|
||||||
|
* @param bjs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String minusString(String js,String bjs) {
|
||||||
|
try{
|
||||||
|
Float jsFloat;
|
||||||
|
try {
|
||||||
|
jsFloat = Float.parseFloat(js);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.minusString.parseFloat data error;js:" + js);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
Float bjsFloat;
|
||||||
|
try {
|
||||||
|
bjsFloat = Float.parseFloat(bjs);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.minusString.parseFloat data error;bjs:" + bjs);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
return twoXsFormat.format(bjsFloat - jsFloat);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.multiplyHundred exception;js:" + js + ";bjs:" + bjs + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字符串转为乘100
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String multiplyHundred(String data) {
|
||||||
|
try{
|
||||||
|
Float dataFloat;
|
||||||
|
try {
|
||||||
|
dataFloat = Float.parseFloat(data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.multiplyHundred.parseFloat data error;data:" + data);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
dataFloat = dataFloat * 100;
|
||||||
|
return twoXsFormat.format(dataFloat);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.multiplyHundred exception;data:" + data + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字符串转为带逗号的金额
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String formatMoney(String data) {
|
||||||
|
try{
|
||||||
|
Float dataFloat;
|
||||||
|
try {
|
||||||
|
dataFloat = Float.parseFloat(data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.formatMoney.parseFloat data error;data:" + data);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
return jeFormat.format(dataFloat);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.formatMoney exception;data:" + data + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算占比,保留两位小数返回字符串
|
||||||
|
* 已乘100
|
||||||
|
* @param fz 分子
|
||||||
|
* @param fm 分母
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getBl(String fz,String fm,String needMultiplyHundred) {
|
||||||
|
try {
|
||||||
|
String result = "";
|
||||||
|
Float fzFloat;
|
||||||
|
Float fmFloat;
|
||||||
|
try {
|
||||||
|
fzFloat = Float.parseFloat(fz);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.getBl.parseFloat fz error;fz:" + fz);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
fmFloat = Float.parseFloat(fm);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.getBl.parseFloat fm error;fm:" + fm);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal oldDataBd = new BigDecimal(fm);
|
||||||
|
if(oldDataBd.compareTo(BigDecimal.ZERO)==0){
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
|
||||||
|
if("1".equals(needMultiplyHundred)){
|
||||||
|
result = twoXsFormat.format(100 * fzFloat / fmFloat);
|
||||||
|
}else{
|
||||||
|
result = twoXsFormat.format(fzFloat / fmFloat);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.getBl exception;fz:" + fz + ";fm:"+ fm + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算增长率,保留两位小数返回字符串
|
||||||
|
* 已乘100
|
||||||
|
* @param oldData
|
||||||
|
* @param newData
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getGrowthRate(String oldData,String newData) {
|
||||||
|
try {
|
||||||
|
String result = "";
|
||||||
|
Float oldDataFloat;
|
||||||
|
Float newDataFloat;
|
||||||
|
try {
|
||||||
|
oldDataFloat = Float.parseFloat(oldData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.getGrowthRate.parseFloat oldData error;oldData:" + oldData);
|
||||||
|
return "100.00";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
newDataFloat = Float.parseFloat(newData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.getGrowthRate.parseFloat newData error;newData:" + newData);
|
||||||
|
return "-100.00";
|
||||||
|
}
|
||||||
|
BigDecimal oldDataBd = new BigDecimal(oldData);
|
||||||
|
if(oldDataBd.compareTo(BigDecimal.ZERO)==0){
|
||||||
|
return "100.00";
|
||||||
|
}
|
||||||
|
result = twoXsFormat.format(100*(newDataFloat - oldDataFloat) / oldDataFloat);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("CommonUtil.getGrowthRate exception;oldData:" + oldData + ";newData:"+ newData + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 剔除字符串中的html标签
|
||||||
|
* @param htmlStr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String delHTMLTag(String htmlStr){
|
||||||
|
String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
|
||||||
|
String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
|
||||||
|
String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式
|
||||||
|
|
||||||
|
Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher m_script=p_script.matcher(htmlStr);
|
||||||
|
htmlStr=m_script.replaceAll(""); //过滤script标签
|
||||||
|
|
||||||
|
Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher m_style=p_style.matcher(htmlStr);
|
||||||
|
htmlStr=m_style.replaceAll(""); //过滤style标签
|
||||||
|
|
||||||
|
Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher m_html=p_html.matcher(htmlStr);
|
||||||
|
htmlStr=m_html.replaceAll(""); //过滤html标签
|
||||||
|
|
||||||
|
return htmlStr.trim(); //返回文本字符串
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取json指定路径的JSONArray 路径中有数组,则获取数组的第一个明细中的数据
|
||||||
|
* @param obj 待查询的JSONObject
|
||||||
|
* @param path 格式为a/b/c
|
||||||
|
* @return JSONArray
|
||||||
|
*/
|
||||||
|
public static JSONArray getJsonArrayByPath(JSONObject obj, String path){
|
||||||
|
try{
|
||||||
|
int index = path.indexOf("/");
|
||||||
|
if(index > -1){
|
||||||
|
JSONObject son;
|
||||||
|
Object sons = obj.get(path.substring(0,index));
|
||||||
|
if(sons instanceof JSONArray){
|
||||||
|
son = (JSONObject) ((JSONArray) sons).get(0);
|
||||||
|
}else{
|
||||||
|
son = obj.getJSONObject(path.substring(0,index));
|
||||||
|
}
|
||||||
|
return getJsonArrayByPath(son,path.substring(index+1));
|
||||||
|
}else{
|
||||||
|
return obj.getJSONArray(path);
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.getJsonArrayByPath error;exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
return new JSONArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取json指定路径的值 路径中有数组,则获取数组的第一个明细中的数据
|
||||||
|
* @param obj 待查询的JSONObject
|
||||||
|
* @param path 格式为a/b/c
|
||||||
|
* @return 值
|
||||||
|
*/
|
||||||
|
public static String getJsonValueByPath(JSONObject obj, String path){
|
||||||
|
try{
|
||||||
|
int index = path.indexOf("/");
|
||||||
|
if(index > -1){
|
||||||
|
JSONObject son;
|
||||||
|
Object sons = obj.get(path.substring(0,index));
|
||||||
|
if(sons instanceof JSONArray){
|
||||||
|
son = (JSONObject) ((JSONArray) sons).get(0);
|
||||||
|
}else{
|
||||||
|
son = obj.getJSONObject(path.substring(0,index));
|
||||||
|
}
|
||||||
|
return getJsonValueByPath(son,path.substring(index+1));
|
||||||
|
}else{
|
||||||
|
return obj.get(path).toString();
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.getJsonValueByPath error;path:" + path + ";obj" + obj + "exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多行文本转字符串 剔除<br>、 标签; 全角转半角
|
||||||
|
* @param input 待转换的字符串
|
||||||
|
* @return 转换后的字符串
|
||||||
|
*/
|
||||||
|
public static String manyLineToString(String input) {
|
||||||
|
if("".equals(input) || input == null){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String result = "";
|
||||||
|
input = input.replaceAll("<br>"," ");
|
||||||
|
input = input.replaceAll(" "," ");
|
||||||
|
result = fullToHalfAngle(input);
|
||||||
|
char c[] = input.toCharArray();
|
||||||
|
for (int i = 0; i < c.length; i++) {
|
||||||
|
if (c[i] == '\u3000') {
|
||||||
|
c[i] = ' ';
|
||||||
|
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||||
|
c[i] = (char) (c[i] - 65248);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全角转半角
|
||||||
|
* @param input 待转换的字符串
|
||||||
|
* @return 转换后的字符串
|
||||||
|
*/
|
||||||
|
public static String fullToHalfAngle(String input) {
|
||||||
|
char c[] = input.toCharArray();
|
||||||
|
for (int i = 0; i < c.length; i++) {
|
||||||
|
if (c[i] == '\u3000') {
|
||||||
|
c[i] = ' ';
|
||||||
|
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||||
|
c[i] = (char) (c[i] - 65248);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String returnString = new String(c);
|
||||||
|
return returnString;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一些静态常量定义
|
||||||
|
*/
|
||||||
|
public class Constant {
|
||||||
|
|
||||||
|
//action接口调用配置表名称
|
||||||
|
public static String CONFIG_TABLE_NAME = "uf_lcdyjkpzxxbd";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口请求日志表名及字段
|
||||||
|
//action调用接口日志记录表表名
|
||||||
|
public static String LOG_TABLE_NAME = "uf_lcdyjkrzjlbd";
|
||||||
|
//action调用接口日志记录表requestId字段名称
|
||||||
|
public static String LOG_REQUESTID_COLUMN = "lcrequestid";
|
||||||
|
//action调用接口日志记录表请求正文字段名称
|
||||||
|
public static String LOG_REQUEST_COLUMN = "qqbw";
|
||||||
|
//action调用接口日志记录表响应文字段名称
|
||||||
|
public static String LOG_RESPONSE_COLUMN = "xybw";
|
||||||
|
//action调用接口日志记录表响应码字段名称
|
||||||
|
public static String LOG_RESPONSECODE_COLUMN = "xym";
|
||||||
|
//action调用接口日志记录表请求地址字段名称
|
||||||
|
public static String LOG_REQUEST_ADDRESS_COLUMN = "qqdz";
|
||||||
|
//action调用接口日志记录表请求头字段名称
|
||||||
|
public static String LOG_REQUEST_HEADER_COLUMN = "qqt";
|
||||||
|
//action调用接口日志记录表请求头字段名称
|
||||||
|
public static String LOG_REQUEST_RESULT_COLUMN = "qqjg";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------自定义sql、接口地址中参数的开始标志
|
||||||
|
public static final String PARAM_BEGIN = "{";
|
||||||
|
public static final String PARAM_END = "}";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口调用成功失败标识 0-失败 1-成功
|
||||||
|
public static final String CALL_SUCCESS = "1";
|
||||||
|
public static final String CALL_FAILED = "0";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------选择框 0-否 1-是
|
||||||
|
public static final String SELECT_TYPE_IS = "1";
|
||||||
|
public static final String SELECT_TYPE_NOT = "0";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口调用类型 0-仅调用一次 1-每条明细调用一次
|
||||||
|
public static final String CALL_TYPE_ONLY_ONE = "0";
|
||||||
|
public static final String CALL_TYPE_EVERY_DETAIL = "1";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口请求类型 0-get 1-post
|
||||||
|
//GET
|
||||||
|
public static final String REQUEST_METHOD_GET = "0";
|
||||||
|
//POST
|
||||||
|
public static final String REQUEST_METHOD_POST = "1";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口报文类型 0-xml 1-json 2-键值对
|
||||||
|
//xml
|
||||||
|
public static final String REQUEST_DATA_TYPE_XML = "0";
|
||||||
|
//json
|
||||||
|
public static final String REQUEST_DATA_TYPE_JSON = "1";
|
||||||
|
//键值对
|
||||||
|
public static final String REQUEST_DATA_TYPE_PAIR = "2";
|
||||||
|
//MultipartFile
|
||||||
|
public static final String REQUEST_DATA_TYPE_MULTIPARTFILE = "3";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口响应报文类型 0-xml 1-json
|
||||||
|
//xml
|
||||||
|
public static final String RESPONSE_DATA_TYPE_XML = "0";
|
||||||
|
//json
|
||||||
|
public static final String RESPONSE_DATA_TYPE_JSON = "1";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------节点类型
|
||||||
|
//文本
|
||||||
|
public static final String NODE_TYPE_STRING = "0";
|
||||||
|
//对象
|
||||||
|
public static final String NODE_TYPE_OBJECT = "1";
|
||||||
|
//文本数组
|
||||||
|
public static final String NODE_TYPE_STRING_ARRAY = "2";
|
||||||
|
//数组
|
||||||
|
public static final String NODE_TYPE_ARRAY = "3";
|
||||||
|
//json对象字符串
|
||||||
|
public static final String NODE_TYPE_JSONSTRING = "4";
|
||||||
|
//数字
|
||||||
|
public static final String NODE_TYPE_NUMBER = "5";
|
||||||
|
//布尔
|
||||||
|
public static final String NODE_TYPE_BOOLEAN = "6";
|
||||||
|
//浮点数
|
||||||
|
public static final String NODE_TYPE_FLOAT = "7";
|
||||||
|
//辅助核算项
|
||||||
|
public static final String NODE_TYPE_FZHSX = "8";
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------转换规则
|
||||||
|
//不转换
|
||||||
|
public static final String CHANGE_TYPE_NONE = "0";
|
||||||
|
//固定值
|
||||||
|
public static final String CHANGE_TYPE_FIXED = "1";
|
||||||
|
//自定义sql
|
||||||
|
public static final String CHANGE_TYPE_SQL = "2";
|
||||||
|
//字段求和
|
||||||
|
public static final String CHANGE_TYPE_SUM = "3";
|
||||||
|
//文本数组
|
||||||
|
public static final String CHANGE_TYPE_STRING_ARRAY = "4";
|
||||||
|
//明细序号
|
||||||
|
public static final String CHANGE_TYPE_ROW_NUMBER = "5";
|
||||||
|
//流程审批意见
|
||||||
|
public static final String CHANGE_TYPE_SUGGESTION = "6";
|
||||||
|
//加密处理
|
||||||
|
public static final String CHANGE_TYPE_MD5 = "7";
|
||||||
|
//requestId
|
||||||
|
public static final String CHANGE_TYPE_REQUEST_ID = "8";
|
||||||
|
//流程标题
|
||||||
|
public static final String CHANGE_TYPE_REQUEST_NAME = "9";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------sql转义
|
||||||
|
//默认换行符
|
||||||
|
public static final String Default_Line_Break = "<br>";
|
||||||
|
//默认空格HTML代码
|
||||||
|
public static final String Default_Html_Blank = " ";
|
||||||
|
//默认空格字符
|
||||||
|
public static final String Default_Blank_Char = " ";
|
||||||
|
}
|
|
@ -0,0 +1,218 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库操作添加try catch 以及日志输出
|
||||||
|
*/
|
||||||
|
public class DaoUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将结果行转为map
|
||||||
|
* @param rs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String,String> setRsToMap(RecordSet rs){
|
||||||
|
try{
|
||||||
|
Map<String,String> result = new HashMap<>();
|
||||||
|
for(String name:rs.getColumnName()){
|
||||||
|
result.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name)));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.setRsToMap execute error;exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断数据是否存在
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isDataExists(String sql,Object...params) {
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
return isDataExists(rs,sql,params);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.isDataExists Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断数据是否存在
|
||||||
|
* @param rs
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isDataExists(RecordSet rs,String sql,Object...params) {
|
||||||
|
try{
|
||||||
|
int count = 0;
|
||||||
|
if(rs.executeQuery(sql,params)){
|
||||||
|
if(rs.next()){
|
||||||
|
count = Util.getIntValue(rs.getString(1),0);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("DaoUtil.isDataExists sql error;sql:" + sql + ";params:" + Arrays.toString(params));
|
||||||
|
}
|
||||||
|
if(count > 0){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.isDataExists Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询第一行数据
|
||||||
|
* @param rs
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String,String> getFirstData(RecordSet rs, String sql, Object...params){
|
||||||
|
Map<String,String> result = new HashMap<>();
|
||||||
|
try{
|
||||||
|
if(rs.executeQuery(sql,params)){
|
||||||
|
if(rs.next()){
|
||||||
|
for(String name:rs.getColumnName()){
|
||||||
|
result.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name)));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("DaoUtil.getFirstData sql found nothing;sql:" + sql + ";params:" + Arrays.toString(params));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("DaoUtil.getFirstData sql error;sql:" + sql + ";params:" + Arrays.toString(params));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.getFirstData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String,String> getFirstData(String sql, Object...params){
|
||||||
|
Map<String,String> result = new HashMap<>();
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
result = getFirstData(rs,sql,params);
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.getFirstData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
* @param rs
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<Map<String,String>> getData(RecordSet rs, String sql, Object...params){
|
||||||
|
List<Map<String,String>> result = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
if(rs.executeQuery(sql,params)){
|
||||||
|
while(rs.next()){
|
||||||
|
Map<String,String> m = new HashMap<>();
|
||||||
|
for(String name:rs.getColumnName()){
|
||||||
|
if("zdysql".equalsIgnoreCase(name) || Util.null2String(name).toLowerCase(Locale.ROOT).indexOf("zdysql") > -1){
|
||||||
|
String zdysql = Util.null2String(rs.getString(name));
|
||||||
|
if(!"".equals(zdysql)){
|
||||||
|
zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char);
|
||||||
|
zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char);
|
||||||
|
zdysql = CommonUtil.fullToHalfAngle(zdysql);
|
||||||
|
}
|
||||||
|
m.put(name.toLowerCase(Locale.ROOT),zdysql);
|
||||||
|
}else{
|
||||||
|
m.put(name.toLowerCase(Locale.ROOT),Util.null2String(rs.getString(name)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.add(m);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("DaoUtil.getData sql error;sql:" + sql + ";params:" + Arrays.toString(params));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.getData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<Map<String,String>> getData(String sql, Object...params){
|
||||||
|
List<Map<String,String>> result = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
result = getData(rs,sql,params);
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.getData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据
|
||||||
|
* @param rs
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean updateData(RecordSet rs,String sql, Object...params){
|
||||||
|
try{
|
||||||
|
if(!rs.executeUpdate(sql,params)){
|
||||||
|
logger.error("DaoUtil.updateData sql error;sql:" + sql + ";params:" + Arrays.toString(params));
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.updateData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + e.getMessage() + ";e:" + e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据
|
||||||
|
* @param sql
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
public static boolean updateData(String sql, Object...params){
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
return updateData(rs,sql,params);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("DaoUtil.updateData Exception;sql:" + sql + ";params:" + Arrays.toString(params) + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import com.weaver.general.Util;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.hrm.finance.SalaryManager;
|
||||||
|
import weaver.hrm.resource.ResourceComInfo;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HrmCommonUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static Map<String,String> addUser(Map<String,String> userInfo,RecordSet rsSch){
|
||||||
|
Map<String,String> result = new HashMap<>();
|
||||||
|
try{
|
||||||
|
if(rsSch == null){
|
||||||
|
rsSch = new RecordSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
char separator = Util.getSeparator();
|
||||||
|
Calendar todaycal = Calendar.getInstance();
|
||||||
|
String today = Util.add0(todaycal.get(Calendar.YEAR), 4) + "-" +
|
||||||
|
Util.add0(todaycal.get(Calendar.MONTH) + 1, 2) + "-" +
|
||||||
|
Util.add0(todaycal.get(Calendar.DAY_OF_MONTH), 2);
|
||||||
|
String userpara = "" + 1 + separator + today;
|
||||||
|
|
||||||
|
rsSch.executeProc("HrmResourceMaxId_Get", "");
|
||||||
|
rsSch.next();
|
||||||
|
//新增的人员id
|
||||||
|
String newId = "" + rsSch.getInt(1);
|
||||||
|
//使用sql新增人员
|
||||||
|
String insertSql =
|
||||||
|
"insert into HrmResource(" +
|
||||||
|
"id,systemlanguage,workcode,departmentid,subcompanyid1," +
|
||||||
|
"jobtitle,status,createrid,createdate,lastmodid," +
|
||||||
|
"lastmoddate,lastname,sex,loginid,password," +
|
||||||
|
"managerid,seclevel,dsporder) " +
|
||||||
|
"values(" +
|
||||||
|
"?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
boolean addUser = DaoUtil.updateData(insertSql,
|
||||||
|
newId, userInfo.get("systemlanguage"), userInfo.get("workcode"), userInfo.get("departmentid"), userInfo.get("subcompanyid1"),
|
||||||
|
userInfo.get("jobtitle"), userInfo.get("status"), userInfo.get("createrid"), userInfo.get("createdate"), userInfo.get("lastmodid"),
|
||||||
|
userInfo.get("lastmoddate"), userInfo.get("lastname"), userInfo.get("sex"), userInfo.get("loginid"), userInfo.get("password"),
|
||||||
|
userInfo.get("managerid"), userInfo.get("seclevel"), userInfo.get("dsporder"));
|
||||||
|
if(addUser){
|
||||||
|
rsSch.executeProc("HrmResource_CreateInfo", "" + newId + separator + userpara + separator + userpara);
|
||||||
|
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||||
|
resourceComInfo.addResourceInfoCache(newId);
|
||||||
|
SalaryManager salaryManager = new SalaryManager();
|
||||||
|
salaryManager.initResourceSalary(newId);
|
||||||
|
String para1 = "" + newId + separator + "" + separator + userInfo.get("departmentid") + separator + userInfo.get("subcompanyid1") + separator + "0" + separator + "0";
|
||||||
|
rsSch.executeProc("HrmResource_Trigger_Insert", para1);
|
||||||
|
String sql_1 = ("insert into HrmInfoStatus (itemid,hrmid) values(1," + newId + ")");
|
||||||
|
rsSch.execute(sql_1);
|
||||||
|
String sql_2 = ("insert into HrmInfoStatus (itemid,hrmid) values(2," + newId + ")");
|
||||||
|
rsSch.execute(sql_2);
|
||||||
|
String sql_3 = ("insert into HrmInfoStatus (itemid,hrmid) values(3," + newId + ")");
|
||||||
|
rsSch.execute(sql_3);
|
||||||
|
String sql_10 = ("insert into HrmInfoStatus (itemid,hrmid) values(10," + newId + ")");
|
||||||
|
rsSch.execute(sql_10);
|
||||||
|
resourceComInfo.updateResourceInfoCache(newId);
|
||||||
|
result.put("newId",newId);
|
||||||
|
}else{
|
||||||
|
logger.error("HrmCommonUtil.addUser.addUserSql error;userInfo:" + userInfo);
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("HrmCommonUtil.addUser exception;userInfo:" + userInfo + "message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
public class HttpGetWithEntity extends HttpEntityEnclosingRequestBase {
|
||||||
|
private final static String METHOD_NAME = "GET";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethod() {
|
||||||
|
return METHOD_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpGetWithEntity() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpGetWithEntity(final URI uri) {
|
||||||
|
super();
|
||||||
|
setURI(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpGetWithEntity(final String uri) {
|
||||||
|
super();
|
||||||
|
setURI(URI.create(uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JsonConvertUtil {
|
||||||
|
|
||||||
|
public static JSONObject convertJsonByConfig(JSONObject oldJson,String configId){
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//获取配置信息
|
||||||
|
String getConfigSql =
|
||||||
|
"select " +
|
||||||
|
"t2.zhgz,t2.zdysql,t2.xzdmc,t2.yzdmc " +
|
||||||
|
"from " +
|
||||||
|
"uf_jsontojson t1 " +
|
||||||
|
"inner join uf_jsontojson_dt1 t2 on t2.mainid = t1.id " +
|
||||||
|
"where " +
|
||||||
|
"t1.id = ?";
|
||||||
|
List<Map<String, String>> configData = DaoUtil.getData(rs, getConfigSql, configId);
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
for(Map<String, String> configMap : configData){
|
||||||
|
String oldValue = oldJson.getString(configMap.get("yzdmc"));
|
||||||
|
String newValue = WorkFlowDataToJsonUtil.convertDataByZhgz(oldValue,configMap);
|
||||||
|
result.put(configMap.get("xzdmc"),newValue);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import com.weaverboot.tools.logTools.LogTools;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
|
public class Md5Util {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static String MD5Encode(String originalString) {
|
||||||
|
try {
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
md.update(originalString.getBytes());
|
||||||
|
byte[] digest = md.digest();
|
||||||
|
String hash = DatatypeConverter.printHexBinary(digest).toUpperCase();
|
||||||
|
return hash;
|
||||||
|
} catch (Exception var5) {
|
||||||
|
logger.error("");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对文件全文生成MD5摘要
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* 要加密的文件
|
||||||
|
* @return MD5摘要码
|
||||||
|
*/
|
||||||
|
public static String getMD5OfFile(final File file) throws IOException {
|
||||||
|
FileInputStream fis = null;
|
||||||
|
try {
|
||||||
|
final MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
final byte[] buffer = new byte[2048];
|
||||||
|
int length = -1;
|
||||||
|
final long s = System.currentTimeMillis();
|
||||||
|
while ((length = fis.read(buffer)) != -1) {
|
||||||
|
md.update(buffer, 0, length);
|
||||||
|
}
|
||||||
|
final byte[] b = md.digest();
|
||||||
|
return byteToHexStringSingle(b);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
LogTools.error(file.getName()+"生成md5码时发生异常:"+ex.getMessage());
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 独立把byte[]数组转换成十六进制字符串表示形式
|
||||||
|
*
|
||||||
|
* @param byteArray
|
||||||
|
* 字节数组
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static String byteToHexStringSingle(final byte[] byteArray) {
|
||||||
|
final StringBuffer md5StrBuff = new StringBuffer();
|
||||||
|
for (int i = 0; i < byteArray.length; i++) {
|
||||||
|
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) {
|
||||||
|
md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));
|
||||||
|
} else {
|
||||||
|
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return md5StrBuff.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,498 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ModelDataToJsonUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static JSONObject getJsonByModelData(String billId,String configId){
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
logger.info("ModelDataToJsonUtil.getJsonByModelData begin;billId:" + billId + ";configId:" + configId);
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//-----------------------根据配置id获取配置信息
|
||||||
|
//根节点配置信息
|
||||||
|
List<Map<String,String>> rootJsonConfigInfo = new ArrayList<>();
|
||||||
|
//明细配置信息
|
||||||
|
List<Map<String,String>> requestBodyConfigList = new ArrayList<>();
|
||||||
|
getConfigInfo(rs,configId,requestBodyConfigList,rootJsonConfigInfo);
|
||||||
|
|
||||||
|
String modeId = "";
|
||||||
|
String getModeIdSql = "select mkid from uf_jmsjzjson where id = ?";
|
||||||
|
if(rs.executeQuery(getModeIdSql,configId)){
|
||||||
|
if(rs.next()){
|
||||||
|
modeId = Util.null2String(rs.getString("mkid"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] base_array = new String[5];
|
||||||
|
base_array[0] = "";
|
||||||
|
base_array[1] = "";
|
||||||
|
base_array[2] = "";
|
||||||
|
base_array[3] = CommonSqlUtil.getTableNameByModeId(modeId,rs);
|
||||||
|
base_array[4] = billId;
|
||||||
|
|
||||||
|
//-----------------------获取主表数据 用于拼装json
|
||||||
|
Map<String,String> mainTableData = new HashMap<>();
|
||||||
|
String getMainTableDataSql = "select * from " + base_array[3] + " where id = " + base_array[4];
|
||||||
|
if(rs.executeQuery(getMainTableDataSql)) {
|
||||||
|
if (rs.next()) {
|
||||||
|
mainTableData = DaoUtil.setRsToMap(rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-----------------------生成json
|
||||||
|
logger.info("recursionGenerateJson begin;");
|
||||||
|
recursionGenerateJson(null,rs,rs,0,result,rootJsonConfigInfo,base_array,mainTableData,requestBodyConfigList,"","");
|
||||||
|
}catch(Throwable e){
|
||||||
|
logger.error("WorkFlowDataToJsonUtil.getJsonByWorkFlowData exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据转换规则 获取转换后的数据
|
||||||
|
*/
|
||||||
|
public static String convertDataByZhgz(String oldValue,Map<String,String> configMap){
|
||||||
|
//函数返回值
|
||||||
|
String result = "";
|
||||||
|
try{
|
||||||
|
//转换规则
|
||||||
|
String zhgz = configMap.get("zhgz");
|
||||||
|
//自定义sql
|
||||||
|
String zdysql = configMap.get("zdysql");
|
||||||
|
String requestId = Util.null2String(configMap.get("requestId"));
|
||||||
|
//不同转换规则处理
|
||||||
|
switch(zhgz){
|
||||||
|
//不转换
|
||||||
|
case "0":
|
||||||
|
result = oldValue;
|
||||||
|
break;
|
||||||
|
//固定值
|
||||||
|
case "1":
|
||||||
|
result = zdysql;
|
||||||
|
break;
|
||||||
|
//自定义sql
|
||||||
|
case "2":
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?}",oldValue);
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?requestId}",requestId);
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(zdysql);
|
||||||
|
for(String key : firstData.keySet()){
|
||||||
|
result = firstData.get(key);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//日期格式化
|
||||||
|
case "3":
|
||||||
|
result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd").parse(oldValue));
|
||||||
|
break;
|
||||||
|
//日期时间格式化
|
||||||
|
case "4":
|
||||||
|
result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(oldValue));
|
||||||
|
break;
|
||||||
|
//当前日期
|
||||||
|
case "5":
|
||||||
|
result = new SimpleDateFormat(zdysql).format(new Date());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
result = "";
|
||||||
|
logger.error("DealWorkFlowDataToRequestUtil.convertDataByZhgz error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据configId获取配置信息
|
||||||
|
* @param rs 数据库链接
|
||||||
|
* @param configId 配置id
|
||||||
|
* @param requestBodyConfigList 明细配置
|
||||||
|
* @param rootJsonConfigInfo 根节点配置
|
||||||
|
*/
|
||||||
|
public static void getConfigInfo(RecordSet rs,String configId,List<Map<String,String>> requestBodyConfigList,List<Map<String,String>> rootJsonConfigInfo){
|
||||||
|
//获取明细表 请求体字段详细配置信息
|
||||||
|
String selectDetailSQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from uf_jmsjzjson_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?";
|
||||||
|
if(rs.executeQuery(selectDetailSQL,configId)){
|
||||||
|
while(rs.next()){
|
||||||
|
//节点序号
|
||||||
|
String xmljdxh = Util.null2String(rs.getString("jdxh"));
|
||||||
|
//xml节点名称
|
||||||
|
String xmljdmc = Util.null2String(rs.getString("jdmc"));
|
||||||
|
//字段归属
|
||||||
|
String zdgz = Util.null2String(rs.getString("zdgz"));
|
||||||
|
//xml节点类型
|
||||||
|
String xmljdlx = Util.null2String(rs.getString("jdlx"));
|
||||||
|
//父节点序号
|
||||||
|
String fjdxh = Util.null2String(rs.getString("fjdxh"));
|
||||||
|
//流程表单字段
|
||||||
|
String lcbdzd = Util.null2String(rs.getString("lcbdzd"));
|
||||||
|
//流程表单字段类型
|
||||||
|
String viewType = Util.null2String(rs.getString("viewType"));
|
||||||
|
//流程表单字段
|
||||||
|
String fieldName = Util.null2String(rs.getString("fieldName"));
|
||||||
|
//字段所属明细表表名
|
||||||
|
String detailtable = Util.null2String(rs.getString("detailtable"));
|
||||||
|
//转换规则
|
||||||
|
String zhgz = Util.null2String(rs.getString("zhgz"));
|
||||||
|
//自定义sql
|
||||||
|
String zdysql = Util.null2String(rs.getString("zdysql"));
|
||||||
|
if(!"".equals(zdysql)){
|
||||||
|
zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char);
|
||||||
|
zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char);
|
||||||
|
zdysql = CommonUtil.fullToHalfAngle(zdysql);
|
||||||
|
}
|
||||||
|
//数据条件
|
||||||
|
String sjtj = Util.null2String(rs.getString("sjtj"));
|
||||||
|
if(!"".equals(sjtj)){
|
||||||
|
sjtj = sjtj.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char);
|
||||||
|
sjtj = sjtj.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char);
|
||||||
|
sjtj = CommonUtil.fullToHalfAngle(sjtj);
|
||||||
|
}
|
||||||
|
Map<String,String> dtMap = new HashMap<>();
|
||||||
|
dtMap.put("jdxh",xmljdxh);
|
||||||
|
dtMap.put("jdmc",xmljdmc);
|
||||||
|
dtMap.put("jdlx",xmljdlx);
|
||||||
|
dtMap.put("fjdxh",fjdxh);
|
||||||
|
dtMap.put("lcbdzd",lcbdzd);
|
||||||
|
dtMap.put("viewType",viewType);
|
||||||
|
dtMap.put("zhgz",zhgz);
|
||||||
|
dtMap.put("zdysql",zdysql);
|
||||||
|
dtMap.put("sjtj",sjtj);
|
||||||
|
dtMap.put("zdgz",zdgz);
|
||||||
|
dtMap.put("detailtable",detailtable);
|
||||||
|
dtMap.put("fieldName",fieldName.toLowerCase());
|
||||||
|
if("".equals(fjdxh)){
|
||||||
|
rootJsonConfigInfo.add(dtMap);
|
||||||
|
}
|
||||||
|
requestBodyConfigList.add(dtMap);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL sql execute error;sql:" + selectDetailSQL);
|
||||||
|
}
|
||||||
|
logger.info("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL done;requestBodyConfigList:" + requestBodyConfigList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归生成json报文
|
||||||
|
*/
|
||||||
|
public static Object recursionGenerateJson(Map<String,String> configMap,RecordSet rs,
|
||||||
|
RecordSet detailRs,int sequence,JSONObject jsonDoc,
|
||||||
|
List<Map<String,String>> rootJsonConfigInfo,
|
||||||
|
String[] baseArray,Map<String,String> mainTableData,
|
||||||
|
List<Map<String,String>> requestBodyConfigList,String currentTableIndex,String currentDetailDataId){
|
||||||
|
String getMainDataByConditionSql = "select count(1) as c from " + baseArray[3] + " t1 where ";
|
||||||
|
String getDetailDataByConditionSql = "select count(1) as c from " + baseArray[3] + " t1 inner join " + baseArray[3] + "_dt" + currentTableIndex + " t2 where t2.id = ? and ";
|
||||||
|
|
||||||
|
if(configMap == null){
|
||||||
|
for(Map<String,String> configInfo:rootJsonConfigInfo){
|
||||||
|
|
||||||
|
String sjtj = configInfo.get("sjtj");
|
||||||
|
if(!"".equals(sjtj) && sjtj != null && !Constant.NODE_TYPE_ARRAY.equals(configInfo.get("jdlx"))){
|
||||||
|
getMainDataByConditionSql = getMainDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getMainDataByConditionSql)){
|
||||||
|
jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,"",""));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,"",""));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
switch(configMap.get("jdlx")){
|
||||||
|
case Constant.NODE_TYPE_STRING:
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
return getFieldValue(configMap,rs,detailRs,baseArray,mainTableData);
|
||||||
|
case Constant.NODE_TYPE_BOOLEAN:
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
return "true".equals(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData));
|
||||||
|
case Constant.NODE_TYPE_NUMBER:
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
int r = 0;
|
||||||
|
try{
|
||||||
|
r = Integer.parseInt(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData));
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("change data to int error;configMap:" + configMap + ";e:" + e);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
case Constant.NODE_TYPE_FLOAT:
|
||||||
|
double d = 0;
|
||||||
|
try{
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
String f = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData);
|
||||||
|
d = Double.parseDouble(f);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("change data to float error;configMap:" + configMap + ";e:" + e);
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
case Constant.NODE_TYPE_OBJECT:
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
for(Map<String,String> m : requestBodyConfigList) {
|
||||||
|
if (m.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
|
||||||
|
String sjtj = m.get("sjtj");
|
||||||
|
if(!"".equals(sjtj) && sjtj != null){
|
||||||
|
//若当前currentTableIndex不为空,用明细校验
|
||||||
|
if("".equals(currentTableIndex)){
|
||||||
|
getMainDataByConditionSql = getMainDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getMainDataByConditionSql)){
|
||||||
|
json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){
|
||||||
|
json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
case Constant.NODE_TYPE_JSONSTRING:
|
||||||
|
JSONObject jsonObj = new JSONObject();
|
||||||
|
for(Map<String,String> m : requestBodyConfigList) {
|
||||||
|
if (m.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
String sjtj = m.get("sjtj");
|
||||||
|
if(!"".equals(sjtj) && sjtj != null){
|
||||||
|
//若当前currentTableIndex不为空,用明细校验
|
||||||
|
if("".equals(currentTableIndex)){
|
||||||
|
getMainDataByConditionSql = getMainDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getMainDataByConditionSql)){
|
||||||
|
jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){
|
||||||
|
jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonObj.toString();
|
||||||
|
case Constant.NODE_TYPE_STRING_ARRAY:
|
||||||
|
String stringArrayValue = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData);
|
||||||
|
JSONArray stringArray = new JSONArray();
|
||||||
|
stringArray.addAll(Arrays.asList(stringArrayValue.split(",")));
|
||||||
|
return stringArray;
|
||||||
|
case Constant.NODE_TYPE_ARRAY:
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
if("".equals(configMap.get("zdgz")) && Constant.CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){
|
||||||
|
for(Map<String,String> son : requestBodyConfigList) {
|
||||||
|
if (son.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
|
||||||
|
String sjtj = son.get("sjtj");
|
||||||
|
if(!"".equals(sjtj) && sjtj != null){
|
||||||
|
//若当前currentTableIndex不为空,用明细校验
|
||||||
|
if("".equals(currentTableIndex)){
|
||||||
|
getMainDataByConditionSql = getMainDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getMainDataByConditionSql)){
|
||||||
|
array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){
|
||||||
|
array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
if("".equals(configMap.get("zdgz"))){
|
||||||
|
JSONObject o = new JSONObject();
|
||||||
|
for(Map<String,String> son : requestBodyConfigList) {
|
||||||
|
if (son.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
|
||||||
|
String sjtj = son.get("sjtj");
|
||||||
|
if(!"".equals(sjtj) && sjtj != null){
|
||||||
|
//若当前currentTableIndex不为空,用明细校验
|
||||||
|
if("".equals(currentTableIndex)){
|
||||||
|
getMainDataByConditionSql = getMainDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getMainDataByConditionSql)){
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,currentTableIndex,currentDetailDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array.add(o);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
//查询明细表数据
|
||||||
|
String getDetailDataSql = "select t2.id as detailid,* from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " t2 inner join " + baseArray[3] + " t1 on t1.id = t2.mainid where t2.mainid = " + baseArray[4] + " and ";
|
||||||
|
if(!"".equals(configMap.get("sjtj"))){
|
||||||
|
getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj");
|
||||||
|
}
|
||||||
|
RecordSet detailDataRs = new RecordSet();
|
||||||
|
if(detailDataRs.executeQuery(getDetailDataSql)){
|
||||||
|
sequence = 0;
|
||||||
|
while(detailDataRs.next()){
|
||||||
|
JSONObject o = new JSONObject();
|
||||||
|
sequence = sequence + 1;
|
||||||
|
for(Map<String,String> son : requestBodyConfigList) {
|
||||||
|
if (son.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
|
||||||
|
String sjtj = son.get("sjtj");
|
||||||
|
if(!"".equals(sjtj) && sjtj != null){
|
||||||
|
//若当前currentTableIndex不为空,用明细校验
|
||||||
|
if("".equals(currentTableIndex)){
|
||||||
|
getMainDataByConditionSql = getMainDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getMainDataByConditionSql)){
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid")));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
getDetailDataByConditionSql = getDetailDataByConditionSql + sjtj;
|
||||||
|
if(DaoUtil.isDataExists(getDetailDataByConditionSql,currentDetailDataId)){
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList,configMap.get("zdgz"),detailDataRs.getString("detailid")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array.add(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字段实际值
|
||||||
|
* @param configMap 配置信息,包含字段归属、字段名称、转换规则等
|
||||||
|
* @param rs 数据库链接
|
||||||
|
* @param detailRs 明细表数据
|
||||||
|
*/
|
||||||
|
public static String getFieldValue(Map<String,String> configMap,RecordSet rs,RecordSet detailRs,String[] baseArray,Map<String,String> mainTableData){
|
||||||
|
//函数返回值
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
try{
|
||||||
|
Map<String,String> detailDataMap = DaoUtil.setRsToMap(detailRs);
|
||||||
|
//字段类型 0-主表 1-明细表
|
||||||
|
String viewType = configMap.get("viewType");
|
||||||
|
//转换规则
|
||||||
|
String zhgz = configMap.get("zhgz");
|
||||||
|
//字段名称
|
||||||
|
String fieldName = configMap.get("fieldName");
|
||||||
|
//自定义sql
|
||||||
|
String zdysql = configMap.get("zdysql");
|
||||||
|
//字段所属明细表表名
|
||||||
|
String detailtable = configMap.get("detailtable");
|
||||||
|
//不同转换规则处理
|
||||||
|
switch(zhgz){
|
||||||
|
case Constant.CHANGE_TYPE_REQUEST_ID:
|
||||||
|
result = new StringBuilder(baseArray[0]);
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_REQUEST_NAME:
|
||||||
|
result = new StringBuilder(baseArray[1]);
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_MD5:
|
||||||
|
result = new StringBuilder("Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes()));
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_SUGGESTION:
|
||||||
|
result = new StringBuilder(baseArray[2]);
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_ROW_NUMBER:
|
||||||
|
result = new StringBuilder(configMap.get("detailRowNum"));
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_FIXED:
|
||||||
|
result = new StringBuilder(configMap.get("zdysql"));
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_NONE:
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
result = new StringBuilder(mainTableData.get(fieldName));
|
||||||
|
}else{
|
||||||
|
result = new StringBuilder(detailDataMap.get(fieldName));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_SQL:
|
||||||
|
String oldValue;
|
||||||
|
if(!"".equals(viewType) && !"".equals(fieldName)){
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
oldValue = mainTableData.get(fieldName);
|
||||||
|
}else{
|
||||||
|
oldValue = detailDataMap.get(fieldName);
|
||||||
|
}
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?}",oldValue);
|
||||||
|
}
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?requestId}",baseArray[0]);
|
||||||
|
if(rs.executeQuery(zdysql)){
|
||||||
|
if(rs.next()){
|
||||||
|
result = new StringBuilder(Util.null2String(rs.getString(1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_SUM:
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
logger.error("want sum but config main field");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String getSumSql = "select sum(" + fieldName + ") as val from " + detailtable + " where mainid = " + baseArray[4];
|
||||||
|
if(rs.executeQuery(getSumSql)){
|
||||||
|
if(rs.next()){
|
||||||
|
result = new StringBuilder(Util.null2String(rs.getString("val")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_STRING_ARRAY:
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
logger.error("want array but config main field");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String getArraySql = "select " + fieldName + " as val from " + detailtable + " where mainid = " + baseArray[4];
|
||||||
|
if(rs.executeQuery(getArraySql)){
|
||||||
|
int i = 0;
|
||||||
|
while(rs.next()){
|
||||||
|
if(i == 0){
|
||||||
|
result = new StringBuilder(Util.null2String(rs.getString(1)));
|
||||||
|
}else{
|
||||||
|
result.append(",").append(Util.null2String(rs.getString(1)));
|
||||||
|
}
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = new StringBuilder();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}catch(Exception e){
|
||||||
|
result = new StringBuilder();
|
||||||
|
logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import oauth.signpost.OAuthConsumer;
|
||||||
|
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
|
||||||
|
import oauth.signpost.http.HttpParameters;
|
||||||
|
import oauth.signpost.signature.AuthorizationHeaderSigningStrategy;
|
||||||
|
import oauth.signpost.signature.HmacSha1MessageSigner;
|
||||||
|
import oauth.signpost.signature.HmacSha256MessageSigner;
|
||||||
|
import org.apache.http.client.methods.HttpRequestBase;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth1.0接口调用工具类
|
||||||
|
* jar包
|
||||||
|
* signpost-commonshttp4-1.2.jar
|
||||||
|
* signpost-core-2.1.1.jar
|
||||||
|
*/
|
||||||
|
public class OauthOneHttpUtil {
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public String consumerKey = "";
|
||||||
|
public String consumerSecret = "";
|
||||||
|
public String accessToken = "";
|
||||||
|
public String accessTokenSecret = "";
|
||||||
|
public String realmID = "";
|
||||||
|
public String encryption = "";
|
||||||
|
|
||||||
|
public void authorize(HttpRequestBase httpRequest){
|
||||||
|
try {
|
||||||
|
OAuthConsumer oAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
|
||||||
|
if("HMAC-SHA256".equalsIgnoreCase(encryption)){
|
||||||
|
oAuthConsumer.setMessageSigner(new HmacSha256MessageSigner());
|
||||||
|
}else if("HMAC-SHA1".equalsIgnoreCase(encryption)){
|
||||||
|
oAuthConsumer.setMessageSigner(new HmacSha1MessageSigner());
|
||||||
|
}
|
||||||
|
if(realmID != null && !"".equals(realmID)){
|
||||||
|
HttpParameters parameters = new HttpParameters();
|
||||||
|
parameters.put("realm", realmID);
|
||||||
|
oAuthConsumer.setAdditionalParameters(parameters);
|
||||||
|
}
|
||||||
|
oAuthConsumer.setTokenWithSecret(accessToken, accessTokenSecret);
|
||||||
|
oAuthConsumer.setSigningStrategy(new AuthorizationHeaderSigningStrategy());
|
||||||
|
oAuthConsumer.sign(httpRequest);
|
||||||
|
}catch(Throwable e) {
|
||||||
|
logger.info("OauthOneHttpUtil.authorize error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.file.AESCoder;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
|
public class TjwAesUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static String aesEncrypt(String param,String key){
|
||||||
|
String result = "";
|
||||||
|
try{
|
||||||
|
result = AESCoder.encrypt(param,key);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("AesUtil.aesEncrypt error;message" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
logger.info("aesEncrypt result:" + result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加密
|
||||||
|
public static String Encrypt(String sKey, String sSrc) throws Exception {
|
||||||
|
byte[] raw = sKey.getBytes("utf-8");
|
||||||
|
SecretKeySpec sks = new SecretKeySpec(raw, "AES");
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式"
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, sks);
|
||||||
|
byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8"));
|
||||||
|
return bytesToHexString(encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解密
|
||||||
|
public static String Decrypt(String sKey, String sSrc) throws Exception {
|
||||||
|
byte[] raw = sKey.getBytes("utf-8");
|
||||||
|
SecretKeySpec sks = new SecretKeySpec(raw, "AES");
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, sks);
|
||||||
|
byte[] encrypted1 = hexStringToBytes(sSrc); //new BASE64Decoder().decodeBuffer(sSrc);//先用base64解密
|
||||||
|
byte[] original = cipher.doFinal(encrypted1);
|
||||||
|
String originalString = new String(original,"utf-8");
|
||||||
|
return originalString;
|
||||||
|
}
|
||||||
|
|
||||||
|
//字节数组转16进制字符串
|
||||||
|
public static String bytesToHexString(byte[] b){
|
||||||
|
StringBuffer result = new StringBuffer();
|
||||||
|
for(int i = 0;i < b.length;i++){
|
||||||
|
result.append(String.format("%02X",b[i]));
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//16进制字符串转字节数组
|
||||||
|
public static byte[] hexStringToBytes(String src){
|
||||||
|
int l = src.length()/2;
|
||||||
|
byte[] ret = new byte[l];
|
||||||
|
for(int i = 0;i<l;i++){
|
||||||
|
ret[i] = Integer.valueOf(src.substring(i*2,i*2+2),16).byteValue();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,382 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import sun.misc.BASE64Encoder;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.docs.docs.DocComInfo;
|
||||||
|
import weaver.docs.docs.DocImageManager;
|
||||||
|
import weaver.docs.docs.DocManager;
|
||||||
|
import weaver.docs.docs.DocViewer;
|
||||||
|
import weaver.docs.webservices.DocInfo;
|
||||||
|
import weaver.docs.webservices.DocServiceImpl;
|
||||||
|
import weaver.file.ImageFileManager;
|
||||||
|
import weaver.general.IOUtils;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
|
||||||
|
public class TjwDocumentUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件转pdf
|
||||||
|
* 需要jar包
|
||||||
|
*/
|
||||||
|
/*public static void convertFileToPdf(InputStream docxInputStream,OutputStream outputStream,String fileType){
|
||||||
|
try {
|
||||||
|
logger.info(fileType + " begin convertFileToPdf");
|
||||||
|
IConverter converter = LocalConverter.builder().build();
|
||||||
|
if("doc".equalsIgnoreCase(fileType)){
|
||||||
|
converter.convert(docxInputStream).as(DocumentType.DOC).to(outputStream).as(DocumentType.PDF).execute();
|
||||||
|
}
|
||||||
|
if("docx".equalsIgnoreCase(fileType)){
|
||||||
|
converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
|
||||||
|
}
|
||||||
|
outputStream.close();
|
||||||
|
System.out.println("success");
|
||||||
|
logger.info(fileType + " convertFileToPdf success");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error(fileType + " convertFileToPdf error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static void copyInputStreamToFile(InputStream inputStream, File file) {
|
||||||
|
try (FileOutputStream outputStream = new FileOutputStream(file)) {
|
||||||
|
int read;
|
||||||
|
byte[] bytes = new byte[1024];
|
||||||
|
while ((read = inputStream.read(bytes)) != -1) {
|
||||||
|
outputStream.write(bytes, 0, read);
|
||||||
|
}
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("copyInputStreamToFile error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 压缩成ZIP
|
||||||
|
* @param srcFiles 需要压缩的文件列表
|
||||||
|
* @param out 压缩文件输出流
|
||||||
|
* @throws RuntimeException 压缩失败会抛出运行时异常
|
||||||
|
*/
|
||||||
|
public static void toZip(List<Map<String,String>> srcFiles , OutputStream out) {
|
||||||
|
ZipOutputStream zos = null;
|
||||||
|
try{
|
||||||
|
zos = new ZipOutputStream(out);
|
||||||
|
for (Map<String,String> imageFileInfo : srcFiles) {
|
||||||
|
String imageFileId = imageFileInfo.get("imageFileId");
|
||||||
|
String imageFileName = imageFileInfo.get("imageFileName");
|
||||||
|
byte[] buf = new byte[2 * 1024];
|
||||||
|
zos.putNextEntry(new ZipEntry(imageFileName));
|
||||||
|
int len;
|
||||||
|
ImageFileManager imageFileManager = new ImageFileManager();
|
||||||
|
InputStream in = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId));
|
||||||
|
while ((len = in.read(buf)) != -1){
|
||||||
|
zos.write(buf, 0, len);
|
||||||
|
}
|
||||||
|
zos.closeEntry();
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwDocumentUtil.toZip error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}finally{
|
||||||
|
if(zos != null){
|
||||||
|
try {
|
||||||
|
zos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("TjwDocumentUtil.toZip zos close error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getBase64StringByImageFileId(String imageFileId){
|
||||||
|
String base64 = "";
|
||||||
|
InputStream is = null;
|
||||||
|
try {
|
||||||
|
ImageFileManager imageFileManager = new ImageFileManager();
|
||||||
|
is = imageFileManager.getInputStreamById(Integer.parseInt(imageFileId));
|
||||||
|
String getFileSizeSql = "select filesize from imagefile where imagefileid = ?";
|
||||||
|
String filesize = DaoUtil.getFirstData(new RecordSet(), getFileSizeSql, imageFileId).get("filesize");
|
||||||
|
byte[] bytes = new byte[Integer.parseInt(filesize)];
|
||||||
|
is.read(bytes);
|
||||||
|
BASE64Encoder encoder = new BASE64Encoder();
|
||||||
|
base64 = encoder.encode(bytes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("TjwDocumentUtil.getBase64StringByImageFileId exception;imageFileId:" + imageFileId + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
} finally {
|
||||||
|
if (is != null) {
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("TjwDocumentUtil.getBase64StringByImageFileId io close exception;imageFileId:" + imageFileId + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据docId复制文档;返回新docId
|
||||||
|
* @param olddocid 被复制的docId
|
||||||
|
* @param userid
|
||||||
|
* @param docsubject 新的文件名称
|
||||||
|
* @param seccategory 目录id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static int copyDocToNewDoc(int olddocid, int userid,String docsubject,int seccategory){
|
||||||
|
int newdocid = -1;
|
||||||
|
try {
|
||||||
|
logger.info("TjwDocumentUtil.copyDocToNewDoc begin;olddocid:" + olddocid + ";userid:" + userid + ";docsubject:" + docsubject + ";seccategory:" + seccategory);
|
||||||
|
//复制文档
|
||||||
|
DocComInfo dc = new DocComInfo();
|
||||||
|
DocViewer dv = new DocViewer();
|
||||||
|
DocManager docManager = new DocManager();
|
||||||
|
docManager.setId(olddocid);
|
||||||
|
docManager.setUserid(userid);
|
||||||
|
docManager.setUsertype("0");
|
||||||
|
docManager.setDocsubject(docsubject);
|
||||||
|
docManager.setClientAddress("127.0.0.1");
|
||||||
|
docManager.setSeccategory(seccategory);
|
||||||
|
docManager.copyDoc();
|
||||||
|
newdocid = docManager.getId();
|
||||||
|
// 文档赋权操作
|
||||||
|
DocManager docNewManager = new DocManager();
|
||||||
|
docNewManager.setIsreply("0");
|
||||||
|
docNewManager.setId(newdocid);
|
||||||
|
docNewManager.setSeccategory(seccategory);
|
||||||
|
docNewManager.setUserid(userid);
|
||||||
|
docNewManager.setUsertype("1");
|
||||||
|
docManager.AddShareInfo();
|
||||||
|
dc.addDocInfoCache("" + newdocid);
|
||||||
|
dv.setDocShareByDoc("" + newdocid);
|
||||||
|
//TODO 据我观察 上面虽然传了docsubject,但代码并未更新文件名称,因此在下面更新文件名称
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String oldname = "";
|
||||||
|
String docfiletype = "";
|
||||||
|
String getExtendSql = "select imagefilename,docfiletype from DocImageFile where docid = ?";
|
||||||
|
if(rs.executeQuery(getExtendSql,olddocid)){
|
||||||
|
if(rs.next()){
|
||||||
|
oldname = Util.null2String(rs.getString("imagefilename"));
|
||||||
|
docfiletype = Util.null2String(rs.getString("docfiletype"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("oldname:" + oldname + ";docfiletype:" + docfiletype);
|
||||||
|
String extend = "";
|
||||||
|
switch (docfiletype){
|
||||||
|
case "7":
|
||||||
|
extend = ".docx";
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
extend = ".doc";
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
extend = ".xls";
|
||||||
|
break;
|
||||||
|
case "5":
|
||||||
|
extend = ".ppt";
|
||||||
|
break;
|
||||||
|
case "6":
|
||||||
|
extend = ".wps";
|
||||||
|
break;
|
||||||
|
case "8":
|
||||||
|
extend = ".xlsx";
|
||||||
|
break;
|
||||||
|
case "9":
|
||||||
|
extend = ".pptx";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String newName = docsubject + extend;
|
||||||
|
String updateDocImageFileNameSql = "update DocImageFile set imagefilename = ? where docid = ?";
|
||||||
|
if(!rs.executeUpdate(updateDocImageFileNameSql,newName,newdocid)){
|
||||||
|
logger.error("updateDocImageFileNameSql error");
|
||||||
|
}
|
||||||
|
String updateImagefileName2Sql = "update imagefile set imagefilename = ? where imagefileid in (select imagefileid from DocImageFile where docid = ?)";
|
||||||
|
if(!rs.executeUpdate(updateImagefileName2Sql,newName,newdocid)){
|
||||||
|
logger.error("updateImagefileName2Sql error");
|
||||||
|
}
|
||||||
|
String updateDocdetailSql = "update docdetail set docsubject = ?,keyword = ? where id = ?";
|
||||||
|
if(!rs.executeUpdate(updateDocdetailSql,docsubject,docsubject,newdocid)){
|
||||||
|
logger.error("updateDocdetailSql error");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("TjwDocumentUtil.copyDocToNewDoc exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return newdocid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int addDocImageInfo(int docId,String fileName, int imageFileId) {
|
||||||
|
try{
|
||||||
|
DocImageManager imgManger = new DocImageManager();
|
||||||
|
imgManger.resetParameter();
|
||||||
|
imgManger.setDocid(docId);
|
||||||
|
imgManger.setImagefileid(imageFileId);
|
||||||
|
imgManger.setImagefilename(fileName);
|
||||||
|
imgManger.setIsextfile("1");
|
||||||
|
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||||
|
if ("doc".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("3");
|
||||||
|
} else if ("xls".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("4");
|
||||||
|
} else if ("ppt".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("5");
|
||||||
|
} else if ("wps".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("6");
|
||||||
|
} else if ("docx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("7");
|
||||||
|
} else if ("xlsx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("8");
|
||||||
|
} else if ("pptx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("9");
|
||||||
|
} else {
|
||||||
|
imgManger.setDocfiletype("2");
|
||||||
|
}
|
||||||
|
imgManger.AddDocImageInfo();
|
||||||
|
return docId;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";imageFileId" + imageFileId + ";docId:" + docId + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据imageFileId生成docId
|
||||||
|
* @param fileName 文件名称
|
||||||
|
* @param seccategory 文件目录
|
||||||
|
* @param imageFileId 物理文件ID
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return docId
|
||||||
|
*/
|
||||||
|
public static int createDocByImageFileId(String docSubject, String fileName, int seccategory, int imageFileId, Integer userId) {
|
||||||
|
try{
|
||||||
|
DocInfo docInfo = new DocInfo();
|
||||||
|
docInfo.setImagefileId(imageFileId);
|
||||||
|
docInfo.setSeccategory(seccategory);
|
||||||
|
docInfo.setDocSubject(docSubject);
|
||||||
|
docInfo.setDoccontent("");
|
||||||
|
DocServiceImpl docService = new DocServiceImpl();
|
||||||
|
int docId = docService.createDocByUser(docInfo, new User(userId));
|
||||||
|
DocImageManager imgManger = new DocImageManager();
|
||||||
|
imgManger.resetParameter();
|
||||||
|
imgManger.setDocid(docId);
|
||||||
|
imgManger.setImagefileid(imageFileId);
|
||||||
|
imgManger.setImagefilename(fileName);
|
||||||
|
imgManger.setIsextfile("1");
|
||||||
|
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||||
|
if ("doc".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("3");
|
||||||
|
} else if ("xls".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("4");
|
||||||
|
} else if ("ppt".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("5");
|
||||||
|
} else if ("wps".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("6");
|
||||||
|
} else if ("docx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("7");
|
||||||
|
} else if ("xlsx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("8");
|
||||||
|
} else if ("pptx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("9");
|
||||||
|
} else {
|
||||||
|
imgManger.setDocfiletype("2");
|
||||||
|
}
|
||||||
|
imgManger.AddDocImageInfo();
|
||||||
|
return docId;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";seccategory:" + seccategory + ";imageFileId" + imageFileId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据imageFileId生成docId
|
||||||
|
* @param fileName 文件名称
|
||||||
|
* @param seccategory 文件目录
|
||||||
|
* @param imageFileId 物理文件ID
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return docId
|
||||||
|
*/
|
||||||
|
public static int createDocByImageFileId(String fileName, int seccategory, int imageFileId, Integer userId) {
|
||||||
|
try{
|
||||||
|
DocInfo docInfo = new DocInfo();
|
||||||
|
docInfo.setImagefileId(imageFileId);
|
||||||
|
docInfo.setSeccategory(seccategory);
|
||||||
|
docInfo.setDocSubject(fileName);
|
||||||
|
docInfo.setDoccontent("");
|
||||||
|
DocServiceImpl docService = new DocServiceImpl();
|
||||||
|
int docId = docService.createDocByUser(docInfo, new User(userId));
|
||||||
|
DocImageManager imgManger = new DocImageManager();
|
||||||
|
imgManger.resetParameter();
|
||||||
|
imgManger.setDocid(docId);
|
||||||
|
imgManger.setImagefileid(imageFileId);
|
||||||
|
imgManger.setImagefilename(fileName);
|
||||||
|
imgManger.setIsextfile("1");
|
||||||
|
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||||
|
if ("doc".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("3");
|
||||||
|
} else if ("xls".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("4");
|
||||||
|
} else if ("ppt".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("5");
|
||||||
|
} else if ("wps".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("6");
|
||||||
|
} else if ("docx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("7");
|
||||||
|
} else if ("xlsx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("8");
|
||||||
|
} else if ("pptx".equalsIgnoreCase(ext)) {
|
||||||
|
imgManger.setDocfiletype("9");
|
||||||
|
} else {
|
||||||
|
imgManger.setDocfiletype("2");
|
||||||
|
}
|
||||||
|
imgManger.AddDocImageInfo();
|
||||||
|
return docId;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.createDocByImageFileId exception;fileName:" + fileName + ";seccategory:" + seccategory + ";imageFileId" + imageFileId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建物理文件
|
||||||
|
*
|
||||||
|
* @param content 文件流
|
||||||
|
* @param fileName 文件名
|
||||||
|
* @return 文件id
|
||||||
|
*/
|
||||||
|
public static int createFileByInputSteam(InputStream content, String fileName) {
|
||||||
|
try{
|
||||||
|
/*byte[] bytes = IOUtils.toBytes(content);
|
||||||
|
logger.info("bytes.size:" + bytes.length);*/
|
||||||
|
ImageFileManager imageFileManager = new ImageFileManager();
|
||||||
|
int imgFileId = -1;
|
||||||
|
try {
|
||||||
|
ImageFileManager.class.getMethod("saveImageFileByInputStream", InputStream.class, String.class);
|
||||||
|
imgFileId = imageFileManager.saveImageFileByInputStream(content, fileName);
|
||||||
|
}catch (NoSuchMethodException e) {
|
||||||
|
logger.error("createFileByInputSteam.NoSuchMethodException");
|
||||||
|
imageFileManager.setImagFileName(fileName);
|
||||||
|
try {
|
||||||
|
imageFileManager.setData(IOUtils.toBytes(content));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("CommonUtil.createFileByInputSteam toBytes exception;fileName:" + fileName + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
throw new Exception("创建文件失败,文件流转换失败", e);
|
||||||
|
}
|
||||||
|
imgFileId = imageFileManager.saveImageFile();
|
||||||
|
}
|
||||||
|
return imgFileId;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("CommonUtil.createFileByInputSteam exception;fileName:" + fileName + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,249 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.fna.invoice.utils.InvoiceCloudUtil;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class TjwFpUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static String getTimestamp(String date){
|
||||||
|
String timestamp = "";
|
||||||
|
try {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date d = sdf.parse(date);
|
||||||
|
timestamp = Util.null2String(d.getTime()/1000);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwFpUtil.getTimestamp error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cloudIdParam 发票的cloudid
|
||||||
|
* @param user
|
||||||
|
* @param sreim 0-取消 1-报销 2-核销
|
||||||
|
* @param je 金额
|
||||||
|
* @param requestId
|
||||||
|
* @param requestmark
|
||||||
|
* @param requestName
|
||||||
|
*/
|
||||||
|
public static void updateFpStatusInCloudCommon(User user,String cloudIdParam,String sreim,String je,String requestId,String requestmark,String requestName){
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
String getTimeSql = "select CREATEDATE,CREATETIME from workflow_requestbase where requestid = ?";
|
||||||
|
Map<String, String> firstData1 = DaoUtil.getFirstData(rs, getTimeSql, requestId);
|
||||||
|
String CREATEDATE = firstData1.get("createdate");
|
||||||
|
String CREATETIME = firstData1.get("createtime");
|
||||||
|
|
||||||
|
String tableName = CommonSqlUtil.getTableNameByRequetId(requestId,rs);
|
||||||
|
String getdjbhSql = "select djbh from " + tableName + " where requestid = ?";
|
||||||
|
Map<String, String> firstData2 = DaoUtil.getFirstData(rs, getdjbhSql, requestId);
|
||||||
|
requestmark = Util.null2String(firstData2.get("djbh"));
|
||||||
|
|
||||||
|
|
||||||
|
String getDataSql = "select * from fnainvoiceledger where cloudid = ?";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam);
|
||||||
|
String userId = firstData.get("userid_new");
|
||||||
|
//其中key为userid_new, value为的List
|
||||||
|
Map<String,List<String>> mapCloud = new HashMap<>();
|
||||||
|
List<String> cloudIds = new ArrayList<>();
|
||||||
|
cloudIds.add(cloudIdParam);
|
||||||
|
mapCloud.put(userId,cloudIds);
|
||||||
|
//发票云报销修改发票云数据
|
||||||
|
for(Map.Entry<String, List<String>> entry : mapCloud.entrySet()){
|
||||||
|
String userid_new = entry.getKey();
|
||||||
|
int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0);
|
||||||
|
JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true);
|
||||||
|
JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud");
|
||||||
|
|
||||||
|
String cid = Util.null2String(cloudInfo.getString("cid"));
|
||||||
|
String userName = Util.null2String(cloudInfo.getString("userName"));
|
||||||
|
String password = Util.null2String(cloudInfo.getString("password"));
|
||||||
|
String aesKey = Util.null2String(cloudInfo.getString("aesKey"));
|
||||||
|
String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl"));
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject bodyJson = new JSONObject();
|
||||||
|
bodyJson.put("cid",cid);
|
||||||
|
bodyJson.put("userId",user.getUID());
|
||||||
|
//2表示修改状态 3表示校验
|
||||||
|
bodyJson.put("flag","2");
|
||||||
|
JSONArray fnaInvoiceReimburseInfoJa = new JSONArray();
|
||||||
|
|
||||||
|
JSONObject fnaInvoiceReimburseInfoJo = new JSONObject();
|
||||||
|
fnaInvoiceReimburseInfoJo.put("dataid", requestId);
|
||||||
|
fnaInvoiceReimburseInfoJo.put("number", requestmark);
|
||||||
|
DecimalFormat df = new DecimalFormat("#####################0.00");
|
||||||
|
fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00)));
|
||||||
|
fnaInvoiceReimburseInfoJo.put("uid", user.getUID());
|
||||||
|
//fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2)));
|
||||||
|
fnaInvoiceReimburseInfoJo.put("date", getTimestamp(CREATEDATE+" "+CREATETIME));
|
||||||
|
fnaInvoiceReimburseInfoJo.put("name", requestName);
|
||||||
|
fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam);
|
||||||
|
fnaInvoiceReimburseInfoJo.put("cid", cid);
|
||||||
|
fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo);
|
||||||
|
|
||||||
|
//1表示报销中 2表示已报销
|
||||||
|
bodyJson.put("sreim",sreim);
|
||||||
|
|
||||||
|
JSONArray reimburseInfoJa = new JSONArray();
|
||||||
|
reimburseInfoJa.add(fnaInvoiceReimburseInfoJo);
|
||||||
|
bodyJson.put("infos", reimburseInfoJa);
|
||||||
|
JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据");
|
||||||
|
logger.info("reimburseJson:" + reimburseJson);
|
||||||
|
}
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cloudIdParam 发票的cloudid
|
||||||
|
* @param user 当前操作用户
|
||||||
|
*/
|
||||||
|
public static void updateFpStatusInCloud3(User user,String cloudIdParam,String flag,String je,String requestId,String requestmark,String requestName){
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getDataSql = "select * from fnainvoiceledger where cloudid = ?";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam);
|
||||||
|
String userId = firstData.get("userid_new");
|
||||||
|
DecimalFormat df = new DecimalFormat("#####################0.00");
|
||||||
|
//其中key为userid_new, value为的List
|
||||||
|
Map<String,List<String>> mapCloud = new HashMap<>();
|
||||||
|
List<String> cloudIds = new ArrayList<>();
|
||||||
|
cloudIds.add(cloudIdParam);
|
||||||
|
mapCloud.put(userId,cloudIds);
|
||||||
|
//发票云报销修改发票云数据
|
||||||
|
RecordSet rs5= new RecordSet();
|
||||||
|
for(Map.Entry<String, List<String>> entry : mapCloud.entrySet()){
|
||||||
|
String userid_new = entry.getKey();
|
||||||
|
int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0);
|
||||||
|
JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true);
|
||||||
|
JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud");
|
||||||
|
boolean existEffectCloud = cloudInfo.getBoolean("existEffectCloud");
|
||||||
|
logger.info("existEffectCloud:" + existEffectCloud);
|
||||||
|
|
||||||
|
String cid = Util.null2String(cloudInfo.getString("cid"));
|
||||||
|
String userName = Util.null2String(cloudInfo.getString("userName"));
|
||||||
|
String password = Util.null2String(cloudInfo.getString("password"));
|
||||||
|
String aesKey = Util.null2String(cloudInfo.getString("aesKey"));
|
||||||
|
String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl"));
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject bodyJson = new JSONObject();
|
||||||
|
bodyJson.put("cid",cid);
|
||||||
|
bodyJson.put("userId",user.getUID());
|
||||||
|
bodyJson.put("flag",flag);
|
||||||
|
JSONArray fnaInvoiceReimburseInfoJa = new JSONArray();
|
||||||
|
|
||||||
|
logger.info("requestid:" + requestId);
|
||||||
|
logger.info("requestmark:" + requestmark);
|
||||||
|
logger.info("je:" + je);
|
||||||
|
|
||||||
|
JSONObject fnaInvoiceReimburseInfoJo = new JSONObject();
|
||||||
|
fnaInvoiceReimburseInfoJo.put("dataid", requestId);//requestid
|
||||||
|
fnaInvoiceReimburseInfoJo.put("number", requestmark);//requestmark
|
||||||
|
fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00)));
|
||||||
|
fnaInvoiceReimburseInfoJo.put("uid", user.getUID());
|
||||||
|
fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2)));
|
||||||
|
fnaInvoiceReimburseInfoJo.put("name", requestName);
|
||||||
|
fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam);
|
||||||
|
fnaInvoiceReimburseInfoJo.put("cid", cid);
|
||||||
|
fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo);
|
||||||
|
|
||||||
|
bodyJson.put("sreim","2");
|
||||||
|
|
||||||
|
JSONArray reimburseInfoJa = new JSONArray();
|
||||||
|
reimburseInfoJa.add(fnaInvoiceReimburseInfoJo);
|
||||||
|
bodyJson.put("infos", reimburseInfoJa);
|
||||||
|
JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据");
|
||||||
|
logger.info("reimburseJson:" + reimburseJson);
|
||||||
|
}
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cloudIdParam 发票的cloudid
|
||||||
|
* @param user 当前操作用户
|
||||||
|
*/
|
||||||
|
public static void updateFpStatusInCloud(User user,String cloudIdParam,String flag,String je,String requestId,String requestmark,String requestName){
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getDataSql = "select * from fnainvoiceledger where cloudid = ?";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getDataSql, cloudIdParam);
|
||||||
|
String userId = firstData.get("userid_new");
|
||||||
|
DecimalFormat df = new DecimalFormat("#####################0.00");
|
||||||
|
//其中key为userid_new, value为的List
|
||||||
|
Map<String,List<String>> mapCloud = new HashMap<>();
|
||||||
|
List<String> cloudIds = new ArrayList<>();
|
||||||
|
cloudIds.add(cloudIdParam);
|
||||||
|
mapCloud.put(userId,cloudIds);
|
||||||
|
//发票云报销修改发票云数据
|
||||||
|
RecordSet rs5= new RecordSet();
|
||||||
|
for(Map.Entry<String, List<String>> entry : mapCloud.entrySet()){
|
||||||
|
String userid_new = entry.getKey();
|
||||||
|
int userid_newInt = Util.getIntValue(Util.null2String(userid_new),0);
|
||||||
|
JSONObject interfaceInfo = InvoiceCloudUtil.getInterfaceInfo(new User(userid_newInt), false, false, true);
|
||||||
|
JSONObject cloudInfo = interfaceInfo.getJSONObject("cloud");
|
||||||
|
boolean existEffectCloud = cloudInfo.getBoolean("existEffectCloud");
|
||||||
|
logger.info("existEffectCloud:" + existEffectCloud);
|
||||||
|
|
||||||
|
String cid = Util.null2String(cloudInfo.getString("cid"));
|
||||||
|
String userName = Util.null2String(cloudInfo.getString("userName"));
|
||||||
|
String password = Util.null2String(cloudInfo.getString("password"));
|
||||||
|
String aesKey = Util.null2String(cloudInfo.getString("aesKey"));
|
||||||
|
String reimburseUrl = Util.null2String(cloudInfo.getString("reimburseUrl"));
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject bodyJson = new JSONObject();
|
||||||
|
bodyJson.put("cid",cid);
|
||||||
|
bodyJson.put("userId",user.getUID());
|
||||||
|
bodyJson.put("flag",flag);
|
||||||
|
JSONArray fnaInvoiceReimburseInfoJa = new JSONArray();
|
||||||
|
|
||||||
|
logger.info("requestid:" + requestId);
|
||||||
|
logger.info("requestmark:" + requestmark);
|
||||||
|
logger.info("je:" + je);
|
||||||
|
|
||||||
|
JSONObject fnaInvoiceReimburseInfoJo = new JSONObject();
|
||||||
|
fnaInvoiceReimburseInfoJo.put("dataid", requestId);//requestid
|
||||||
|
fnaInvoiceReimburseInfoJo.put("number", requestmark);//requestmark
|
||||||
|
fnaInvoiceReimburseInfoJo.put("amount", df.format(Util.getDoubleValue(je, 0.00)));
|
||||||
|
fnaInvoiceReimburseInfoJo.put("uid", user.getUID());
|
||||||
|
fnaInvoiceReimburseInfoJo.put("date", getTimestamp(Util.date(2)));
|
||||||
|
fnaInvoiceReimburseInfoJo.put("name", requestName);
|
||||||
|
fnaInvoiceReimburseInfoJo.put("fid", cloudIdParam);
|
||||||
|
fnaInvoiceReimburseInfoJo.put("cid", cid);
|
||||||
|
fnaInvoiceReimburseInfoJa.add(fnaInvoiceReimburseInfoJo);
|
||||||
|
|
||||||
|
bodyJson.put("sreim","1");
|
||||||
|
|
||||||
|
JSONArray reimburseInfoJa = new JSONArray();
|
||||||
|
reimburseInfoJa.add(fnaInvoiceReimburseInfoJo);
|
||||||
|
bodyJson.put("infos", reimburseInfoJa);
|
||||||
|
JSONObject reimburseJson = InvoiceCloudUtil.reimburseInvoice(reimburseUrl, aesKey, bodyJson, userName, password, "锁定报销修改数据");
|
||||||
|
logger.info("reimburseJson:" + reimburseJson);
|
||||||
|
}
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwFpUtil.updateFpStatusInCloud error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,272 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.Principal;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TjwHttpServletRequest 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,119 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.Principal;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TjwHttpSession 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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,679 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.http.Header;
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.client.methods.*;
|
||||||
|
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||||
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||||
|
import org.apache.http.conn.ssl.TrustStrategy;
|
||||||
|
import org.apache.http.entity.BufferedHttpEntity;
|
||||||
|
import org.apache.http.entity.ByteArrayEntity;
|
||||||
|
import org.apache.http.entity.ContentType;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.entity.mime.HttpMultipartMode;
|
||||||
|
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||||
|
import org.apache.http.entity.mime.content.StringBody;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.file.ImageFileManager;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import javax.net.ssl.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class TjwHttpUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件上传
|
||||||
|
*/
|
||||||
|
public static JSONObject uploadFileUtil(String url, String imageFileIds, Map<String,String> headers,Map<String,String> textParams,String fileParamName){
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
logger.info("TjwHttpUtil.uploadFileUtil begin;url:" + url + ";imageFileIds:" + imageFileIds);
|
||||||
|
//根据docIds获取文件信息
|
||||||
|
String[] imageFileIdsArray = imageFileIds.split(",");
|
||||||
|
if(imageFileIdsArray == null || imageFileIdsArray.length == 0){
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
List<Map<String,String>> fileInfos = new ArrayList<>();
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getFileInfoSql = "select t2.imagefilename,t2.imagefileid from docimagefile t1 inner join imagefile t2 on t2.imagefileid = t1.imagefileid where t2.imagefileid = ?";
|
||||||
|
for(String imageFileId:imageFileIdsArray){
|
||||||
|
if(rs.executeQuery(getFileInfoSql,imageFileId)){
|
||||||
|
while(rs.next()){
|
||||||
|
Map<String,String> file = new HashMap<>();
|
||||||
|
file.put("imagefileid", Util.null2String(rs.getString("imagefileid")));
|
||||||
|
file.put("imagefilename", Util.null2String(rs.getString("imagefilename")));
|
||||||
|
fileInfos.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloseableHttpClient httpClient = createSSLClientDefault(url);
|
||||||
|
HttpPost httpPost = new HttpPost(url);
|
||||||
|
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
|
||||||
|
multipartEntityBuilder.setCharset(StandardCharsets.UTF_8);
|
||||||
|
multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||||
|
ImageFileManager imageFileManager = new ImageFileManager();
|
||||||
|
for(Map<String,String> file:fileInfos){
|
||||||
|
String fileName = file.get("imagefilename");
|
||||||
|
fileName = fileName.replaceAll("&","&");
|
||||||
|
fileName = fileName.replaceAll(">",">");
|
||||||
|
fileName = fileName.replaceAll("<","<");
|
||||||
|
fileName = fileName.replaceAll("'","'");
|
||||||
|
fileName = fileName.replaceAll(""","\"");
|
||||||
|
InputStream imagefileid = imageFileManager.getInputStreamById(Integer.parseInt(file.get("imagefileid")));
|
||||||
|
multipartEntityBuilder.addBinaryBody(fileParamName,imagefileid, ContentType.MULTIPART_FORM_DATA,fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentType contentType = ContentType.create("text/plain", StandardCharsets.UTF_8);
|
||||||
|
for(String key : textParams.keySet()){
|
||||||
|
StringBody stringBody = new StringBody(String.valueOf(textParams.get(key)), contentType);
|
||||||
|
multipartEntityBuilder.addPart(key, stringBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpEntity httpEntity = multipartEntityBuilder.build();
|
||||||
|
httpPost.setEntity(httpEntity);
|
||||||
|
|
||||||
|
//请求头设置
|
||||||
|
if(headers != null && headers.size() > 0){
|
||||||
|
for(String key:headers.keySet()){
|
||||||
|
if(!"Content-Type".equals(key)){
|
||||||
|
httpPost.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("FilePostUtil.uploadFileUtil.httpClient.execute begin;imageFileIds:" + imageFileIds + ";url:" + url);
|
||||||
|
|
||||||
|
CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
|
||||||
|
HttpEntity responseEntity = httpResponse.getEntity();
|
||||||
|
int statusCode= httpResponse.getStatusLine().getStatusCode();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
String str = "";
|
||||||
|
while((str = reader.readLine()) != null) {
|
||||||
|
buffer.append(str);
|
||||||
|
}
|
||||||
|
logger.info("FilePostUtil.uploadFileUtil.httpClient.execute done;statusCode:" + statusCode + ";message:" + buffer);
|
||||||
|
result = JSONObject.parseObject(buffer.toString());
|
||||||
|
httpClient.close();
|
||||||
|
if(httpResponse!=null){
|
||||||
|
httpResponse.close();
|
||||||
|
}
|
||||||
|
}catch(Throwable e){
|
||||||
|
logger.error("FilePostUtil.uploadFileUtil exception;url:" + url + ";imageFileIds:" + imageFileIds);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addLogInMode(String url,int code,String requestParam,String responseData){
|
||||||
|
try{
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
JSONObject loggerJson = new JSONObject();
|
||||||
|
loggerJson.put("qqdz",url);
|
||||||
|
loggerJson.put("qqxx",requestParam);
|
||||||
|
loggerJson.put("xyxx",responseData);
|
||||||
|
loggerJson.put("xym",code);
|
||||||
|
TjwModelUtil.addModelData(rs,"uf_tjwhttplog",loggerJson);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwHttpUtil.addLogInMode error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addLogInModeWithCusLog(String url,int code,String requestParam,String responseData,Map<String,String> cusLogInfo){
|
||||||
|
try{
|
||||||
|
if(responseData.length() > 1000){
|
||||||
|
responseData = "报文长度过长,请在日志文件中查看!";
|
||||||
|
}
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
JSONObject loggerJson = new JSONObject();
|
||||||
|
loggerJson.put("qqdz",url);
|
||||||
|
loggerJson.put("qqxx",requestParam);
|
||||||
|
loggerJson.put("xyxx",responseData);
|
||||||
|
loggerJson.put("xym",code);
|
||||||
|
if(cusLogInfo != null && cusLogInfo.size() > 0){
|
||||||
|
for(String key : cusLogInfo.keySet()){
|
||||||
|
loggerJson.put(key,cusLogInfo.get(cusLogInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TjwModelUtil.addModelData(rs,"uf_tjwhttplog",loggerJson);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwHttpUtil.addLogInMode error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
* @param url
|
||||||
|
* @param headMap 请求头
|
||||||
|
* @param fileName 文件名称
|
||||||
|
*/
|
||||||
|
public static InputStream httpGetDownloadFile(String url,Map<String, String> headMap,String fileName) {
|
||||||
|
CloseableHttpClient httpclient = createSSLClientDefault(url);
|
||||||
|
try {
|
||||||
|
HttpGet httpGet = new HttpGet(url);
|
||||||
|
if (headMap != null && headMap.size() > 0) {
|
||||||
|
Set<String> keySet = headMap.keySet();
|
||||||
|
for (String key : keySet) {
|
||||||
|
httpGet.addHeader(key, headMap.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = httpclient.execute(httpGet);
|
||||||
|
try {
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
logger.info("url:" + url + ";download file end;code:" + statusCode);
|
||||||
|
HttpEntity httpEntity = response.getEntity();
|
||||||
|
InputStream is = httpEntity.getContent();
|
||||||
|
// 根据InputStream 下载文件
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int r = 0;
|
||||||
|
while ((r = is.read(buffer)) > 0) {
|
||||||
|
output.write(buffer, 0, r);
|
||||||
|
}
|
||||||
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(output.toByteArray());
|
||||||
|
output.flush();
|
||||||
|
output.close();
|
||||||
|
EntityUtils.consume(httpEntity);
|
||||||
|
logger.info("url:" + url + ";download file success");
|
||||||
|
return byteArrayInputStream;
|
||||||
|
} finally {
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error("httpGetDownloadFile exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
httpclient.close();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error("httpGetDownloadFile httpclient close exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void oauthOneSignHeader(HttpRequestBase httpRequest,Map<String,String> oauthConfigMap){
|
||||||
|
OauthOneHttpUtil oAuthUtil = new OauthOneHttpUtil();
|
||||||
|
oAuthUtil.consumerKey = oauthConfigMap.get("consumerKey");
|
||||||
|
oAuthUtil.consumerSecret = oauthConfigMap.get("consumerSecret");
|
||||||
|
oAuthUtil.accessToken = oauthConfigMap.get("accessToken");
|
||||||
|
oAuthUtil.accessTokenSecret = oauthConfigMap.get("accessTokenSecret");
|
||||||
|
oAuthUtil.realmID = oauthConfigMap.get("realmID");
|
||||||
|
oAuthUtil.encryption = oauthConfigMap.get("encryption");
|
||||||
|
oAuthUtil.authorize(httpRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送http请求 获取响应
|
||||||
|
* @param url
|
||||||
|
* @param param 请求报文
|
||||||
|
* @param method
|
||||||
|
* @param contentType
|
||||||
|
* @return 响应报文
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static Map<String,String> sendHttpOAuthRequest(String url, String param, String method, ContentType contentType,Map<String,String> headers,Map<String,String> oauthConfigMap){
|
||||||
|
Map<String,String> result = new HashMap<>();
|
||||||
|
CloseableHttpClient client = createSSLClientDefault(url);
|
||||||
|
try{
|
||||||
|
logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method);
|
||||||
|
if("post".equalsIgnoreCase(method)){
|
||||||
|
HttpPost post=new HttpPost(url);
|
||||||
|
oauthOneSignHeader(post,oauthConfigMap);
|
||||||
|
StringEntity entity = new StringEntity(param, contentType);
|
||||||
|
//StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON);
|
||||||
|
post.setEntity(entity);
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
post.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(post);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("get".equalsIgnoreCase(method)){
|
||||||
|
HttpGet get=new HttpGet(url);
|
||||||
|
oauthOneSignHeader(get,oauthConfigMap);
|
||||||
|
CloseableHttpResponse response = client.execute(get);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("put".equalsIgnoreCase(method)){
|
||||||
|
HttpPut put = new HttpPut(url);
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
put.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(put);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}
|
||||||
|
}catch(Throwable e){
|
||||||
|
logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
client.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送http请求 获取响应
|
||||||
|
* @param url
|
||||||
|
* @param param 请求报文
|
||||||
|
* @param method
|
||||||
|
* @param contentType
|
||||||
|
* @return 响应报文
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static Map<String,String> sendHttpRequest(String url, String param, String method, ContentType contentType,Map<String,String> headers,int imageFileId){
|
||||||
|
Map<String,String> result = new HashMap<>();
|
||||||
|
CloseableHttpClient client = createSSLClientDefault(url);
|
||||||
|
try{
|
||||||
|
logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method);
|
||||||
|
if("post".equalsIgnoreCase(method)){
|
||||||
|
HttpPost post=new HttpPost(url);
|
||||||
|
StringEntity entity = new StringEntity(param, contentType);
|
||||||
|
//StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON);
|
||||||
|
post.setEntity(entity);
|
||||||
|
|
||||||
|
if(imageFileId > 0){
|
||||||
|
ImageFileManager ifm = new ImageFileManager();
|
||||||
|
InputStream is = ifm.getInputStreamById(imageFileId);
|
||||||
|
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(IOUtils.toByteArray(is));
|
||||||
|
post.setEntity(byteArrayEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
post.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(post);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("get".equalsIgnoreCase(method)){
|
||||||
|
HttpGet get=new HttpGet(url);
|
||||||
|
CloseableHttpResponse response = client.execute(get);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("put".equalsIgnoreCase(method)){
|
||||||
|
HttpPut put = new HttpPut(url);
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
put.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(imageFileId > 0){
|
||||||
|
ImageFileManager ifm = new ImageFileManager();
|
||||||
|
InputStream is = ifm.getInputStreamById(imageFileId);
|
||||||
|
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(IOUtils.toByteArray(is));
|
||||||
|
put.setEntity(byteArrayEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseableHttpResponse response = client.execute(put);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
client.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送http请求 获取响应
|
||||||
|
* @param url
|
||||||
|
* @param param 请求报文
|
||||||
|
* @param method
|
||||||
|
* @param contentType
|
||||||
|
* @return 响应报文
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static Map<String,Object> sendHttpRequestWithCusLog(String url, String param, String method, ContentType contentType,Map<String,String> headers,Map<String,String> cusLogInfo){
|
||||||
|
Map<String,Object> result = new HashMap<>();
|
||||||
|
CloseableHttpClient client = createSSLClientDefault(url);
|
||||||
|
try{
|
||||||
|
logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method);
|
||||||
|
if("post".equalsIgnoreCase(method)){
|
||||||
|
HttpPost post=new HttpPost(url);
|
||||||
|
StringEntity entity = new StringEntity(param, contentType);
|
||||||
|
//StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON);
|
||||||
|
post.setEntity(entity);
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
post.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(post);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo);
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("get".equalsIgnoreCase(method)){
|
||||||
|
HttpGet get=new HttpGet(url);
|
||||||
|
if(headers != null && headers.size() > 0){
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
get.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(get);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
JSONObject responseHeaders = new JSONObject();
|
||||||
|
Header[] allHeaders = response.getAllHeaders();
|
||||||
|
for(Header header:allHeaders){
|
||||||
|
responseHeaders.put(header.getName(),header.getValue());
|
||||||
|
}
|
||||||
|
result.put("responseHeaders",responseHeaders.toJSONString());
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo);
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("put".equalsIgnoreCase(method)){
|
||||||
|
HttpPut put = new HttpPut(url);
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
put.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(put);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo);
|
||||||
|
logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("getWithEntity".equalsIgnoreCase(method)){
|
||||||
|
HttpGetWithEntity get=new HttpGetWithEntity(url);
|
||||||
|
if(headers != null && headers.size() > 0){
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
get.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HttpEntity httpEntity = new StringEntity(param, contentType);
|
||||||
|
get.setEntity(httpEntity);
|
||||||
|
CloseableHttpResponse response = client.execute(get);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
Header[] allHeaders = response.getAllHeaders();
|
||||||
|
Header[] clone = allHeaders.clone();
|
||||||
|
result.put("responseHeaders",clone);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInModeWithCusLog(url,statusCode,param,EntityUtils.toString(en, "utf-8"),cusLogInfo);
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
client.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送http请求 获取响应
|
||||||
|
* @param url
|
||||||
|
* @param param 请求报文
|
||||||
|
* @param method
|
||||||
|
* @param contentType
|
||||||
|
* @return 响应报文
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static Map<String,Object> sendHttpRequest(String url, String param, String method, ContentType contentType,Map<String,String> headers){
|
||||||
|
Map<String,Object> result = new HashMap<>();
|
||||||
|
CloseableHttpClient client = createSSLClientDefault(url);
|
||||||
|
try{
|
||||||
|
logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method);
|
||||||
|
if("post".equalsIgnoreCase(method)){
|
||||||
|
HttpPost post=new HttpPost(url);
|
||||||
|
StringEntity entity = new StringEntity(param, contentType);
|
||||||
|
//StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON);
|
||||||
|
post.setEntity(entity);
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
post.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(post);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("get".equalsIgnoreCase(method)){
|
||||||
|
HttpGet get=new HttpGet(url);
|
||||||
|
if(headers != null && headers.size() > 0){
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
get.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(get);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
JSONObject responseHeaders = new JSONObject();
|
||||||
|
Header[] allHeaders = response.getAllHeaders();
|
||||||
|
for(Header header:allHeaders){
|
||||||
|
responseHeaders.put(header.getName(),header.getValue());
|
||||||
|
}
|
||||||
|
result.put("responseHeaders",responseHeaders.toJSONString());
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("put".equalsIgnoreCase(method)){
|
||||||
|
HttpPut put = new HttpPut(url);
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
put.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
CloseableHttpResponse response = client.execute(put);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + statusCode + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("getWithEntity".equalsIgnoreCase(method)){
|
||||||
|
HttpGetWithEntity get=new HttpGetWithEntity(url);
|
||||||
|
if(headers != null && headers.size() > 0){
|
||||||
|
for(String key : headers.keySet()){
|
||||||
|
get.setHeader(key,headers.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HttpEntity httpEntity = new StringEntity(param, contentType);
|
||||||
|
get.setEntity(httpEntity);
|
||||||
|
CloseableHttpResponse response = client.execute(get);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
Header[] allHeaders = response.getAllHeaders();
|
||||||
|
Header[] clone = allHeaders.clone();
|
||||||
|
result.put("responseHeaders",clone);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
client.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送http请求 获取响应
|
||||||
|
* @param url
|
||||||
|
* @param param 请求报文
|
||||||
|
* @param method
|
||||||
|
* @param contentType
|
||||||
|
* @return 响应报文
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static Map<String,String> sendHttpRequest(String url, String param, String method, ContentType contentType){
|
||||||
|
Map<String,String> result = new HashMap<>();
|
||||||
|
CloseableHttpClient client = createSSLClientDefault(url);
|
||||||
|
try{
|
||||||
|
logger.info("sendHttpRequest begin;url:" + url + ";param:" + param + ";method:" + method);
|
||||||
|
if("post".equalsIgnoreCase(method)){
|
||||||
|
HttpPost post=new HttpPost(url);
|
||||||
|
StringEntity entity = new StringEntity(param, contentType);
|
||||||
|
//StringEntity entity = new StringEntity(param, ContentType.APPLICATION_JSON);
|
||||||
|
post.setEntity(entity);
|
||||||
|
CloseableHttpResponse response = client.execute(post);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}else if("get".equalsIgnoreCase(method)){
|
||||||
|
HttpGet get=new HttpGet(url);
|
||||||
|
CloseableHttpResponse response = client.execute(get);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
HttpEntity en = response.getEntity();
|
||||||
|
en = new BufferedHttpEntity(en);
|
||||||
|
result.put("code", String.valueOf(statusCode));
|
||||||
|
result.put("data",EntityUtils.toString(en, "utf-8"));
|
||||||
|
addLogInMode(url,statusCode,param,EntityUtils.toString(en, "utf-8"));
|
||||||
|
logger.info("sendHttpRequest done;code:" + String.valueOf(statusCode) + ";data:" + EntityUtils.toString(en, "utf-8"));
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("sendHttpRequest exception;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
client.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("sendHttpRequest client.close;url:" + url + ";param:" + param + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回CloseableHttpClient 如果接口为https协议 信任所有证书
|
||||||
|
* @return
|
||||||
|
* @throws MalformedURLException
|
||||||
|
*/
|
||||||
|
public static CloseableHttpClient createSSLClientDefault(String urlString){
|
||||||
|
URL url = null;
|
||||||
|
try {
|
||||||
|
url = new URL(urlString);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("url error;urlString:" + urlString);
|
||||||
|
}
|
||||||
|
String protocol = url.getProtocol();
|
||||||
|
if("https".equals(protocol)){
|
||||||
|
try {
|
||||||
|
//使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书
|
||||||
|
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
|
||||||
|
@Override
|
||||||
|
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}).build();
|
||||||
|
//NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何
|
||||||
|
//有效的SSL会话并匹配到目标主机。
|
||||||
|
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
|
||||||
|
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
|
||||||
|
CloseableHttpClient build = HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
||||||
|
return build;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("createSSLClientDefault error;exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
CloseableHttpClient aDefault = HttpClients.createDefault();
|
||||||
|
return aDefault;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
CloseableHttpClient aDefault = HttpClients.createDefault();
|
||||||
|
return aDefault;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
|
new X509TrustManager() {
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
||||||
|
}
|
||||||
|
public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final HostnameVerifier NOT_VERYFY = new HostnameVerifier() {
|
||||||
|
@Override
|
||||||
|
public boolean verify(String s, SSLSession sslSession) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.workflow.webservices.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TjwJsonToWorkflowByConfigUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
public static String getValueByConfig(Map<String, String> configMap, JSONObject jsonData, RecordSet rs){
|
||||||
|
String result = "";
|
||||||
|
try{
|
||||||
|
String path = configMap.get("jsonbwzdlj");
|
||||||
|
String zhgz = configMap.get("zhgz");
|
||||||
|
String zdysql = configMap.get("zdysql");
|
||||||
|
String oldValue = CommonUtil.getJsonValueByPath(jsonData,path);
|
||||||
|
switch(zhgz){
|
||||||
|
case "0":
|
||||||
|
result = oldValue;
|
||||||
|
break;
|
||||||
|
case "1":
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?}",oldValue);
|
||||||
|
if(rs.executeQuery(zdysql)){
|
||||||
|
if(rs.next()){
|
||||||
|
result = Util.null2String(rs.getString(1));
|
||||||
|
}else{
|
||||||
|
logger.error("zdysql execute but find nothing;sql:" + zdysql);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("zdysql execute error;sql:" + zdysql);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
result = zdysql;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("TjwJsonToWorkflowByConfigUtil.getValueByConfig exception;configMap:" + configMap + ";jsonData:" + jsonData + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dealWorkflowRequestInfoByConfigId(String configId, WorkflowRequestInfo info,JSONObject jsonData){
|
||||||
|
try{
|
||||||
|
logger.info("dealWorkflowRequestInfoByConfigId begin;configId:" + configId + ";jsonData:" + jsonData.toJSONString());
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String getConfigDataSql =
|
||||||
|
"select " +
|
||||||
|
"t1.lclx," +
|
||||||
|
"t2.bdzd," +
|
||||||
|
"t2.zdgz," +
|
||||||
|
"t2.jsonbwzdlj," +
|
||||||
|
"t2.zhgz," +
|
||||||
|
"t2.zdysql," +
|
||||||
|
"wb.fieldName," +
|
||||||
|
"wb.viewType," +
|
||||||
|
"wb.detailtable " +
|
||||||
|
"from " +
|
||||||
|
"uf_jsonzlcbdsj t1 " +
|
||||||
|
"inner join uf_jsonzlcbdsj_dt1 t2 on t2.mainid = t1.id " +
|
||||||
|
"inner join workflow_billField wb on t2.bdzd = wb.id " +
|
||||||
|
"where " +
|
||||||
|
"t1.id = ?";
|
||||||
|
List<Map<String, String>> configData = DaoUtil.getData(rs, getConfigDataSql, configId);
|
||||||
|
|
||||||
|
//主表字段数量
|
||||||
|
int mainTableFieldCount = 0;
|
||||||
|
//主表字段配置信息
|
||||||
|
List<Map<String, String>> mainFieldConfigInfoList = new ArrayList<>();
|
||||||
|
//明细表字段配置信息
|
||||||
|
Map<String,List<Map<String, String>>> detailFieldConfigInfo = new HashMap<>();
|
||||||
|
|
||||||
|
for(Map<String, String> m : configData){
|
||||||
|
String zdgz = m.get("zdgz");
|
||||||
|
if("".equals(zdgz) || "0".equals(zdgz)){
|
||||||
|
mainTableFieldCount = mainTableFieldCount + 1;
|
||||||
|
mainFieldConfigInfoList.add(m);
|
||||||
|
}else{
|
||||||
|
List<Map<String, String>> detailFieldConfigInfoList = detailFieldConfigInfo.get(zdgz);
|
||||||
|
if(detailFieldConfigInfoList == null){
|
||||||
|
detailFieldConfigInfoList = new ArrayList<>();
|
||||||
|
detailFieldConfigInfoList.add(m);
|
||||||
|
detailFieldConfigInfo.put(zdgz,detailFieldConfigInfoList);
|
||||||
|
}else{
|
||||||
|
detailFieldConfigInfoList.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////处理主表字段
|
||||||
|
WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[mainTableFieldCount];
|
||||||
|
for(int i = 0; i < mainTableFieldCount; i ++){
|
||||||
|
String fieldName = mainFieldConfigInfoList.get(i).get("fieldName");
|
||||||
|
String value = getValueByConfig(mainFieldConfigInfoList.get(i),jsonData,rs);
|
||||||
|
wrti[i]=new WorkflowRequestTableField();
|
||||||
|
wrti[i].setFieldName(fieldName);
|
||||||
|
wrti[i].setFieldValue(value);
|
||||||
|
wrti[i].setEdit(true);//是否能编辑
|
||||||
|
wrti[i].setView(true);//是否可以查看
|
||||||
|
wrti[i].setMand(false);//是否必填
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkflowRequestTableRecord[] tablre = new WorkflowRequestTableRecord[1]; //主字段只有一行数据
|
||||||
|
tablre[0]=new WorkflowRequestTableRecord();
|
||||||
|
tablre[0].setWorkflowRequestTableFields(wrti);
|
||||||
|
WorkflowMainTableInfo maininfo=new WorkflowMainTableInfo();
|
||||||
|
maininfo.setRequestRecords(tablre);
|
||||||
|
info.setWorkflowMainTableInfo(maininfo);
|
||||||
|
|
||||||
|
/////////////处理明细表字段
|
||||||
|
WorkflowDetailTableInfo[] WorkflowDetailTableInfo = new WorkflowDetailTableInfo[detailFieldConfigInfo.size()];
|
||||||
|
for(int i = 0;i<detailFieldConfigInfo.size();i++){
|
||||||
|
List<Map<String, String>> detailFieldConfigInfoList = detailFieldConfigInfo.get(i);
|
||||||
|
//根据path查询有多少行明细
|
||||||
|
String path = detailFieldConfigInfoList.get(0).get("jsonbwzdlj");
|
||||||
|
path = path.substring(0,path.lastIndexOf("/"));
|
||||||
|
JSONArray array = CommonUtil.getJsonArrayByPath(jsonData,path);
|
||||||
|
if(array == null || array.size() == 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
WorkflowRequestTableRecord[] tablre1 = new WorkflowRequestTableRecord[array.size()];
|
||||||
|
for(int j = 0;j< array.size();j++){
|
||||||
|
wrti = new WorkflowRequestTableField[detailFieldConfigInfoList.size()];
|
||||||
|
for(int k = 0;j<detailFieldConfigInfoList.size();j++){
|
||||||
|
String fieldName = detailFieldConfigInfoList.get(i).get("fieldName");
|
||||||
|
String value = getValueByConfig(detailFieldConfigInfoList.get(i),jsonData,rs);
|
||||||
|
wrti[k] = new WorkflowRequestTableField();
|
||||||
|
wrti[k].setFieldName(fieldName);
|
||||||
|
wrti[k].setFieldValue(value);
|
||||||
|
wrti[k].setView(true);
|
||||||
|
wrti[k].setEdit(true);
|
||||||
|
}
|
||||||
|
tablre1[j] = new WorkflowRequestTableRecord();
|
||||||
|
tablre1[j].setWorkflowRequestTableFields(wrti);
|
||||||
|
}
|
||||||
|
WorkflowDetailTableInfo[i] = new WorkflowDetailTableInfo();
|
||||||
|
WorkflowDetailTableInfo[i].setWorkflowRequestTableRecords(tablre1);
|
||||||
|
}
|
||||||
|
info.setWorkflowDetailTableInfos(WorkflowDetailTableInfo);
|
||||||
|
logger.info("dealWorkflowRequestInfoByConfigId done");
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("dealWorkflowRequestInfoByConfigId exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,194 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
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.conn.RecordSet;
|
||||||
|
import weaver.formmode.data.ModeDataIdUpdate;
|
||||||
|
import weaver.formmode.setup.ModeRightInfo;
|
||||||
|
import weaver.general.TimeUtil;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import javax.jms.Session;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TjwModelUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance();
|
||||||
|
public static ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo();
|
||||||
|
public static ModeAppService modeAppService = ServiceUtil.getService(ModeAppServiceImpl .class, new User(1));
|
||||||
|
|
||||||
|
public static void rebuildRight(String modeId){
|
||||||
|
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 TjwHttpSession());
|
||||||
|
modeAppService.saveModeRightList(param,new User(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增建模数据
|
||||||
|
* @param rs
|
||||||
|
* @param tableName
|
||||||
|
* @param dataInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static int addModelData(RecordSet rs,String tableName, JSONObject dataInfo){
|
||||||
|
try{
|
||||||
|
logger.info("dataInfo:" + dataInfo.toJSONString());
|
||||||
|
String currentDate = TimeUtil.getCurrentDateString();
|
||||||
|
String currentTime = TimeUtil.getOnlyCurrentTimeString();
|
||||||
|
int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs);
|
||||||
|
int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime);
|
||||||
|
//拼接字段名称
|
||||||
|
String setString = "";
|
||||||
|
Object[] data = new Object[dataInfo.size()+1];
|
||||||
|
int index = 0;
|
||||||
|
for(Object key : dataInfo.keySet()){
|
||||||
|
setString = setString + key + " = ? ,";
|
||||||
|
data[index] = dataInfo.get(key);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
data[index] = newDataId;
|
||||||
|
setString = setString.substring(0,setString.length() - 1);
|
||||||
|
String updateDataSql =
|
||||||
|
"update " + tableName + " set " + setString + " where id = ?";
|
||||||
|
DaoUtil.updateData(rs,updateDataSql,data);
|
||||||
|
//权限重构
|
||||||
|
MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId);
|
||||||
|
return newDataId;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("TjwModelUtil addModelData;tableName:" + tableName + ";dataInfo:" + dataInfo.toJSONString() + ";messahe:" + e.getMessage() + ";e:" + e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或更新建模数据
|
||||||
|
*/
|
||||||
|
public static int addOrUpdateModelData(RecordSet rs, String tableName, JSONObject dataInfo, List<String> keyList){
|
||||||
|
try{
|
||||||
|
//根据dataKey判断数据是否存在,有则更新 无则新增
|
||||||
|
String idWhere = " 1 = 1 ";
|
||||||
|
Object[] keyData = new Object[keyList.size()];
|
||||||
|
for(int i = 0;i < keyList.size(); i++){
|
||||||
|
keyData[i] = dataInfo.get(keyList.get(i));
|
||||||
|
}
|
||||||
|
for(String key:keyList){
|
||||||
|
idWhere = idWhere + " and " + key + " = ?";
|
||||||
|
}
|
||||||
|
|
||||||
|
String getDataSql = "select id from " + tableName + " where " + idWhere;
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getDataSql, keyData);
|
||||||
|
String id = firstData.get("id");
|
||||||
|
if("".equals(id) || id == null){
|
||||||
|
String currentDate = TimeUtil.getCurrentDateString();
|
||||||
|
String currentTime = TimeUtil.getOnlyCurrentTimeString();
|
||||||
|
int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs);
|
||||||
|
int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime);
|
||||||
|
//拼接字段名称
|
||||||
|
String setString = "";
|
||||||
|
Object[] data = new Object[dataInfo.size()+1];
|
||||||
|
int index = 0;
|
||||||
|
for(Object key : dataInfo.keySet()){
|
||||||
|
setString = setString + key + " = ? ,";
|
||||||
|
data[index] = dataInfo.get(key);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
data[index] = newDataId;
|
||||||
|
setString = setString.substring(0,setString.length() - 1);
|
||||||
|
String updateDataSql =
|
||||||
|
"update " + tableName + " set " + setString + " where id = ?";
|
||||||
|
DaoUtil.updateData(rs,updateDataSql,data);
|
||||||
|
//权限重构
|
||||||
|
MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId);
|
||||||
|
return newDataId;
|
||||||
|
}else{
|
||||||
|
//拼接字段名称
|
||||||
|
String setString = "";
|
||||||
|
Object[] data = new Object[dataInfo.size()+1];
|
||||||
|
int index = 0;
|
||||||
|
for(Object key : dataInfo.keySet()){
|
||||||
|
setString = setString + key + " = ? ,";
|
||||||
|
data[index] = dataInfo.get(key);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
data[index] = id;
|
||||||
|
setString = setString.substring(0,setString.length() - 1);
|
||||||
|
String updateDataSql =
|
||||||
|
"update " + tableName + " set " + setString + " where id = ?";
|
||||||
|
DaoUtil.updateData(rs,updateDataSql,data);
|
||||||
|
return Integer.parseInt(id);
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("TjwModelUtil addOrUpdateModelData;tableName:" + tableName + ";dataInfo:" + dataInfo + ";messahe:" + e.getMessage() + ";e:" + e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或更新建模数据
|
||||||
|
*/
|
||||||
|
public static int addOrUpdateModelData(RecordSet rs, String tableName, JSONObject dataInfo,String dataKey){
|
||||||
|
try{
|
||||||
|
//根据dataKey判断数据是否存在,有则更新 无则新增
|
||||||
|
String getDataSql = "select id from " + tableName + " where " + dataKey + " = ?";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(rs, getDataSql, dataInfo.get(dataKey));
|
||||||
|
String id = firstData.get("id");
|
||||||
|
if("".equals(id) || id == null){
|
||||||
|
String currentDate = TimeUtil.getCurrentDateString();
|
||||||
|
String currentTime = TimeUtil.getOnlyCurrentTimeString();
|
||||||
|
int modelId = CommonSqlUtil.getModeIdByTableName(tableName,rs);
|
||||||
|
int newDataId = mdu.getModeDataNewId(tableName, modelId, 1, 0, currentDate, currentTime);
|
||||||
|
//拼接字段名称
|
||||||
|
String setString = "";
|
||||||
|
Object[] data = new Object[dataInfo.size()+1];
|
||||||
|
int index = 0;
|
||||||
|
for(Object key : dataInfo.keySet()){
|
||||||
|
setString = setString + key + " = ? ,";
|
||||||
|
data[index] = dataInfo.get(key);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
data[index] = newDataId;
|
||||||
|
setString = setString.substring(0,setString.length() - 1);
|
||||||
|
String updateDataSql =
|
||||||
|
"update " + tableName + " set " + setString + " where id = ?";
|
||||||
|
DaoUtil.updateData(rs,updateDataSql,data);
|
||||||
|
//权限重构
|
||||||
|
MODE_RIGHT_INFO.rebuildModeDataShareByEdit(1, modelId,newDataId);
|
||||||
|
return newDataId;
|
||||||
|
}else{
|
||||||
|
//拼接字段名称
|
||||||
|
String setString = "";
|
||||||
|
Object[] data = new Object[dataInfo.size()+1];
|
||||||
|
int index = 0;
|
||||||
|
for(Object key : dataInfo.keySet()){
|
||||||
|
setString = setString + key + " = ? ,";
|
||||||
|
data[index] = dataInfo.get(key);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
data[index] = id;
|
||||||
|
setString = setString.substring(0,setString.length() - 1);
|
||||||
|
String updateDataSql =
|
||||||
|
"update " + tableName + " set " + setString + " where id = ?";
|
||||||
|
DaoUtil.updateData(rs,updateDataSql,data);
|
||||||
|
return Integer.parseInt(id);
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("TjwModelUtil addOrUpdateModelData;tableName:" + tableName + ";dataInfo:" + dataInfo + ";messahe:" + e.getMessage() + ";e:" + e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class TjwRightMoveUtil {
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static JSONObject moveRight(JSONObject param){
|
||||||
|
try{
|
||||||
|
logger.info("TjwRightMoveUtil.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 TjwHttpServletRequest(){
|
||||||
|
@Override
|
||||||
|
public String getParameter(String s) {
|
||||||
|
return param.getString(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpSession getSession(boolean b) {
|
||||||
|
HttpSession session = new TjwHttpSession(){
|
||||||
|
@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);
|
||||||
|
logger.info("moveRight.result:" + execute.toString());
|
||||||
|
return null;
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwRightMoveUtil.moveRight error;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class TjwTimeUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
static SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
public static String getLastDay(){
|
||||||
|
//获取今天的日期
|
||||||
|
Date today = new Date();
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(today);
|
||||||
|
c.add(Calendar.DAY_OF_MONTH, -1);
|
||||||
|
//这是昨天
|
||||||
|
Date yesterday = c.getTime();
|
||||||
|
String lastDay = new SimpleDateFormat("yyyy-MM-dd").format(yesterday);
|
||||||
|
return lastDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将时间戳转换为固定格式
|
||||||
|
* @param format 日期格式
|
||||||
|
* @param time 时间戳 毫秒
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getFormatTimeByTimeMillis(String format, long time){
|
||||||
|
try{
|
||||||
|
String result = "";
|
||||||
|
Date date= new Date(time);
|
||||||
|
switch (format){
|
||||||
|
case "yyyy-MM-dd HH:mm:ss":
|
||||||
|
result = sdfDateAndTime.format(date);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("CommonUtil.getFormatTimeByTimeMillis execute error;exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,176 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.interfaces.action.WorkflowToMode;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
import weaver.soa.workflow.request.RequestService;
|
||||||
|
import weaver.workflow.request.RequestManager;
|
||||||
|
import weaver.workflow.webservices.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TjwWorkFlowUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static String createWorkFlow(String requestName, String creator, String workFlowId, String isNextFlow, Map<String,String> mainTableData, List<List<Map<String,String>>> detailTableData){
|
||||||
|
try{
|
||||||
|
logger.info("TjwWorkFlowUtil.createWorkFlow begin;requestName:" + requestName);
|
||||||
|
WorkflowService service = new WorkflowServiceImpl();
|
||||||
|
WorkflowRequestInfo info = new WorkflowRequestInfo();
|
||||||
|
info.setRequestName(requestName);
|
||||||
|
//创建人
|
||||||
|
info.setCreatorId(creator);
|
||||||
|
//0正常,1重要,2紧急
|
||||||
|
info.setRequestLevel("0");
|
||||||
|
WorkflowBaseInfo base = new WorkflowBaseInfo();
|
||||||
|
//流程id
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
base.setWorkflowId(workFlowId);
|
||||||
|
info.setWorkflowBaseInfo(base);
|
||||||
|
//流转到下一个节点
|
||||||
|
info.setIsnextflow(isNextFlow);
|
||||||
|
|
||||||
|
WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[mainTableData.size()];
|
||||||
|
int i = 0;
|
||||||
|
for(String key : mainTableData.keySet()){
|
||||||
|
wrti[i]=new WorkflowRequestTableField();
|
||||||
|
wrti[i].setFieldName(key);
|
||||||
|
wrti[i].setFieldValue(mainTableData.get(key));
|
||||||
|
wrti[i].setEdit(true);//是否能编辑
|
||||||
|
wrti[i].setView(true);//是否可以查看
|
||||||
|
wrti[i].setMand(true);//是否必填
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkflowRequestTableRecord[] tablre = new WorkflowRequestTableRecord[1]; //主字段只有一行数据
|
||||||
|
tablre[0]=new WorkflowRequestTableRecord();
|
||||||
|
tablre[0].setWorkflowRequestTableFields(wrti);
|
||||||
|
WorkflowMainTableInfo mainInfo=new WorkflowMainTableInfo();
|
||||||
|
mainInfo.setRequestRecords(tablre);
|
||||||
|
//添加主字段数据
|
||||||
|
info.setWorkflowMainTableInfo(mainInfo);
|
||||||
|
|
||||||
|
//添加到明细表中
|
||||||
|
if(detailTableData != null && detailTableData.size() > 0){
|
||||||
|
WorkflowDetailTableInfo WorkflowDetailTableInfo[] = new WorkflowDetailTableInfo[detailTableData.size()];
|
||||||
|
for(int j = 0; j<detailTableData.size(); j++){
|
||||||
|
List<Map<String,String>> tableData = detailTableData.get(j);
|
||||||
|
if(tableData != null && tableData.size() > 0){
|
||||||
|
WorkflowRequestTableRecord[] detailTablre = new WorkflowRequestTableRecord[tableData.size()];
|
||||||
|
for(int m = 0;m < tableData.size();m ++){
|
||||||
|
Map<String,String> datas = tableData.get(m);
|
||||||
|
WorkflowRequestTableField[] d = new WorkflowRequestTableField[datas.size()];
|
||||||
|
int n = 0;
|
||||||
|
for(String key : datas.keySet()){
|
||||||
|
d[n] = new WorkflowRequestTableField();
|
||||||
|
d[n].setFieldName(key);
|
||||||
|
d[n].setFieldValue(datas.get(key));
|
||||||
|
d[n].setView(true);//字段是否可见
|
||||||
|
d[n].setEdit(true);//字段是否可编辑
|
||||||
|
}
|
||||||
|
detailTablre[n] = new WorkflowRequestTableRecord();
|
||||||
|
detailTablre[n].setWorkflowRequestTableFields(d);
|
||||||
|
}
|
||||||
|
WorkflowDetailTableInfo[j] = new WorkflowDetailTableInfo();
|
||||||
|
WorkflowDetailTableInfo[j].setWorkflowRequestTableRecords(detailTablre);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info.setWorkflowDetailTableInfos(WorkflowDetailTableInfo);//添加明细数据
|
||||||
|
}
|
||||||
|
//发起流程
|
||||||
|
String returnMsg = service.doCreateWorkflowRequest(info, Integer.parseInt(creator));
|
||||||
|
logger.info("TjwWorkFlowUtil.createWorkFlow end;returnMsg:" + returnMsg);
|
||||||
|
return returnMsg;
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.error("TjwWorkFlowUtil.createWorkFlow error;requestName:" + requestName);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交流程至下一节点
|
||||||
|
* @param requestId
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
public static boolean submitWorkFlow(int requestId,int userId){
|
||||||
|
try{
|
||||||
|
WorkflowService service = new WorkflowServiceImpl();
|
||||||
|
String message = service.submitWorkflowRequest(null, requestId, userId,"submit","");
|
||||||
|
if("success".equals(message)){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
logger.error("TjwWorkFlowUtil.submitWorkFlow false;requestId:" + requestId + ";userId:" + userId + ";message:" + message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("TjwWorkFlowUtil.submitWorkFlow exception;requestId:" + requestId + ";userId:" + userId + ";message:" + e.getMessage() + ";e:" + e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 触发流程转数据
|
||||||
|
* @param requestId 流程请求id
|
||||||
|
* @param configId 流程转数据的配置id
|
||||||
|
* @param rs 数据库连接
|
||||||
|
* @return 1-成功;
|
||||||
|
*/
|
||||||
|
public static String doWorkFlowToMode(int requestId,int configId,RecordSet rs){
|
||||||
|
try{
|
||||||
|
if(rs == null){
|
||||||
|
rs = new RecordSet();
|
||||||
|
}
|
||||||
|
//获取流程转数据的配置信息
|
||||||
|
String getWorkFlowToModeSetInfoSql = "select triggernodeid,actionid from mode_workflowtomodeset where id = ?";
|
||||||
|
Map<String,String> configInfo = DaoUtil.getFirstData(rs,getWorkFlowToModeSetInfoSql,configId);
|
||||||
|
int nodeId = Integer.parseInt(configInfo.get("triggernodeid"));
|
||||||
|
int actionId = Integer.parseInt(configInfo.get("actionid"));
|
||||||
|
//获取流程基本信息
|
||||||
|
String getRequestBaseInfoSql = "select t1.workflowid,t2.formid,t1.creater,t1.requestname from workflow_requestbase t1 inner join workflow_base t2 on t2.id = t1.workflowid where t1.requestid = ?";
|
||||||
|
Map<String,String> requestBaseInfo = DaoUtil.getFirstData(rs,getRequestBaseInfoSql,requestId);
|
||||||
|
int workFlowId = Integer.parseInt(requestBaseInfo.get("workflowid"));
|
||||||
|
int formId = Integer.parseInt(requestBaseInfo.get("formid"));
|
||||||
|
int creater = Integer.parseInt(requestBaseInfo.get("creater"));
|
||||||
|
User user = new User(creater);
|
||||||
|
String requestName = requestBaseInfo.get("requestname");
|
||||||
|
//构造请求参数
|
||||||
|
RequestService x = new RequestService();
|
||||||
|
RequestInfo requestInfo = x.getRequest(requestId);
|
||||||
|
//只记录日志 triggerType
|
||||||
|
requestInfo.setIspreadd("0");
|
||||||
|
RequestManager requestManager = new RequestManager();
|
||||||
|
requestManager.setNodeid(nodeId);
|
||||||
|
//只记录日志
|
||||||
|
requestManager.setNextNodeid(0);
|
||||||
|
requestManager.setWorkflowid(workFlowId);
|
||||||
|
requestManager.setFormid(formId);
|
||||||
|
requestManager.setRequestid(requestId);
|
||||||
|
requestManager.setCreater(creater);
|
||||||
|
//用于区分流程类型
|
||||||
|
requestManager.setIsbill(1);
|
||||||
|
requestManager.setUser(user);
|
||||||
|
requestManager.setRequestname(requestName);
|
||||||
|
requestInfo.setRequestManager(requestManager);
|
||||||
|
WorkflowToMode wtm = new WorkflowToMode();
|
||||||
|
Class classType = WorkflowToMode.class;
|
||||||
|
Field field = classType.getDeclaredField("actionid");
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(wtm, actionId);
|
||||||
|
String result = wtm.execute(requestInfo);
|
||||||
|
logger.info("doWorkFlowToMode done;requestId:" + requestId + ";configId:" + configId + ";result:" + result);
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("doWorkFlowToMode exception;requestId:" + requestId + ";configId:" + configId + ";messahe:" + e.getMessage() + ";e:" + e);
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,404 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.ConnStatementDataSource;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.BaseBean;
|
||||||
|
import weaver.general.GCONST;
|
||||||
|
import weaver.general.TimeUtil;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 常用工具方法-公用类
|
||||||
|
* @author bleach
|
||||||
|
* @date 2018-01-18
|
||||||
|
* @version 2.0 Modify By Weilin.Zhu 添加日志级别 2018-12-05
|
||||||
|
* @version 3.0 Modify By Weilin.Zhu 修改日志输出方式,使用log4j 2020-03-10
|
||||||
|
* @version 4.0 Modify By Weilin.Zhu 去除根据建模配置来控制日志输出功能 2021-06-29
|
||||||
|
*/
|
||||||
|
public class ToolUtil extends BaseBean {
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
private RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造方法
|
||||||
|
*/
|
||||||
|
public ToolUtil() {
|
||||||
|
//logger = LoggerFactory.getLogger("cus");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据流程类型ID获取其对应的表单名称
|
||||||
|
* @param workflowid 流程类型ID
|
||||||
|
* @return 字符串
|
||||||
|
*/
|
||||||
|
public String getBillTableNameByWorkflowId(String workflowid){
|
||||||
|
String tablename = "";
|
||||||
|
|
||||||
|
if(!"".equals(workflowid)){
|
||||||
|
String select_data = "select tablename from workflow_bill where id in (select formid from workflow_base where id = ?)";
|
||||||
|
|
||||||
|
if(rs.executeQuery(select_data, workflowid)){
|
||||||
|
if(rs.next()){
|
||||||
|
tablename = Util.null2String(rs.getString(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tablename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询满足模糊查询的所有标识集合
|
||||||
|
* @param likestr 模糊条件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String,String> getSystemParamValueMap(String likestr){
|
||||||
|
return getSystemParamList(likestr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统中所有参数配置
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String,String> getAllSystemParamValue(){
|
||||||
|
return getSystemParamList("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取参数集合
|
||||||
|
* @param likestr 模糊查询的条件
|
||||||
|
* @return 集合
|
||||||
|
*/
|
||||||
|
private Map<String,String> getSystemParamList(String likestr){
|
||||||
|
Map<String,String> param_map = new HashMap<String, String>();
|
||||||
|
|
||||||
|
String select_sql = "select uuid,paramvalue from uf_systemconfig";
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
if(!"".equals(likestr)){
|
||||||
|
select_sql += " where uuid like '%" + likestr + "%'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rs.execute(select_sql)){
|
||||||
|
while(rs.next()){
|
||||||
|
String uuid = Util.null2String(rs.getString(1));
|
||||||
|
String paramvalue = Util.null2String(rs.getString(2));
|
||||||
|
param_map.put(uuid, paramvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return param_map;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统参数设置值
|
||||||
|
* @param uuid 参数标识
|
||||||
|
* @return 返回配置值
|
||||||
|
*/
|
||||||
|
public static String getSystemParamValue(String uuid){
|
||||||
|
String paramvalue = "";
|
||||||
|
|
||||||
|
if(!"".equals(uuid)){
|
||||||
|
String select_sql = "select paramvalue from uf_systemconfig where uuid = ?";
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
rs.executeQuery(select_sql,uuid);
|
||||||
|
if(rs.next()){
|
||||||
|
paramvalue = Util.null2String(rs.getString(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return paramvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用数据库值,根据规则转换,获取其最终结果
|
||||||
|
* @param cus_sql 自定义转换的SQL
|
||||||
|
* @param value 参数值
|
||||||
|
* @return 配置值
|
||||||
|
*/
|
||||||
|
public String getValueByChangeRule(String userId,String cus_sql,String value){
|
||||||
|
|
||||||
|
return getValueByChangeRule(userId,cus_sql,value,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用数据库值,根据规则转换,获取其最终结果
|
||||||
|
* @param cus_sql 自定义转换的SQL
|
||||||
|
* @param value 参数值
|
||||||
|
* @param requestid 流程请求ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid){
|
||||||
|
|
||||||
|
return getValueByChangeRule(userId,cus_sql,value,requestid,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用数据库值,根据规则转换,获取其最终结果
|
||||||
|
* @param cus_sql 自定义转换的SQL
|
||||||
|
* @param value 参数值
|
||||||
|
* @param requestid 流程请求ID
|
||||||
|
* @param detailKeyvalue 明细表主键值
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid,int detailKeyvalue){
|
||||||
|
return getValueByChangeRule(userId,cus_sql,value,requestid,detailKeyvalue,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用数据库值,根据规则转换,获取其最终结果
|
||||||
|
* @param cus_sql 自定义转换的SQL
|
||||||
|
* @param value 参数值
|
||||||
|
* @param requestid 流程请求ID
|
||||||
|
* @param detailKeyvalue 明细表主键值
|
||||||
|
* @pram datasourceid 外部数据源ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getValueByChangeRule(String userId,String cus_sql,String value,String requestid,int detailKeyvalue,String datasourceid){
|
||||||
|
String endValue = "";
|
||||||
|
cus_sql = ToDBC(cus_sql);
|
||||||
|
|
||||||
|
cus_sql = cus_sql.replace(" ", " ");
|
||||||
|
|
||||||
|
cus_sql = cus_sql.replace("{?dt.id}", String.valueOf(detailKeyvalue));
|
||||||
|
|
||||||
|
cus_sql = cus_sql.replace("{?currentUserId}", String.valueOf(userId));
|
||||||
|
|
||||||
|
//参数进行替换
|
||||||
|
String sqlString = cus_sql.replace("{?requestid}", requestid);
|
||||||
|
|
||||||
|
sqlString = sqlString.replace("?", value);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(datasourceid != null && !"".equals(datasourceid)){
|
||||||
|
ConnStatementDataSource csds = new ConnStatementDataSource(datasourceid);
|
||||||
|
|
||||||
|
csds.setStatementSql(sqlString);
|
||||||
|
|
||||||
|
csds.executeQuery();
|
||||||
|
|
||||||
|
if(csds.next()){
|
||||||
|
endValue = Util.null2String(csds.getString(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
csds.close();
|
||||||
|
}else{
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
if(rs.executeQuery(sqlString)){
|
||||||
|
rs.next();
|
||||||
|
|
||||||
|
endValue = Util.null2String(rs.getString(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return endValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用数据库值,根据规则转换,获取其最终结果
|
||||||
|
* @param cus_sql 自定义转换的SQL
|
||||||
|
* @param value 参数值
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getValueByChangeRule_SingleParam(String cus_sql,String value){
|
||||||
|
String endValue = "";
|
||||||
|
|
||||||
|
cus_sql = cus_sql.replace(" ", " ");
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
if(rs.executeQuery(cus_sql,value)){
|
||||||
|
rs.next();
|
||||||
|
|
||||||
|
endValue = Util.null2String(rs.getString(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return endValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全角转半角
|
||||||
|
* @param input
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String ToDBC(String input) {
|
||||||
|
char c[] = input.toCharArray();
|
||||||
|
for (int i = 0; i < c.length; i++) {
|
||||||
|
if (c[i] == '\u3000') {
|
||||||
|
c[i] = ' ';
|
||||||
|
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||||
|
c[i] = (char) (c[i] - 65248);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String returnString = new String(c);
|
||||||
|
return returnString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字段ID获取其对应的字段名称
|
||||||
|
* @param fieldid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getFieldNameByFieldid(int fieldid){
|
||||||
|
if(fieldid > 0){
|
||||||
|
return getFieldNameByFieldid(String.valueOf(fieldid));
|
||||||
|
}else{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字段ID获取其对应的字段名称
|
||||||
|
* @param fieldid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getFieldNameByFieldid(String fieldid){
|
||||||
|
String fieldname = "";
|
||||||
|
|
||||||
|
if(!"".equals(fieldid)){
|
||||||
|
|
||||||
|
if(fieldid.startsWith(",")){
|
||||||
|
fieldid = fieldid.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fieldid.endsWith(",")){
|
||||||
|
fieldid =fieldid.substring(0,fieldid.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
String select_sql = "select fieldname from workflow_billfield where id in (" + fieldid + ")";
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
if(rs.execute(select_sql)){
|
||||||
|
while(rs.next()){
|
||||||
|
|
||||||
|
fieldname += "," + Util.null2String(rs.getString(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fieldname.startsWith(",")){
|
||||||
|
fieldname = fieldname.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fieldname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出调试日志
|
||||||
|
* @param className 类名称
|
||||||
|
* @param logstr 日志信息
|
||||||
|
*/
|
||||||
|
public void writeDebuggerLog(String className,String logstr){
|
||||||
|
logger.info(logstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出警告日志
|
||||||
|
* @param className 类名称
|
||||||
|
* @param logstr 日志信息
|
||||||
|
*/
|
||||||
|
public void writeWarningLog(String className,String logstr){
|
||||||
|
logger.warn(logstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出错误日志
|
||||||
|
* @param className 类名称
|
||||||
|
* @param logstr 日志信息
|
||||||
|
*/
|
||||||
|
public void writeErrorLog(String className,String logstr){
|
||||||
|
logger.error(logstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志输出
|
||||||
|
* @param logstr
|
||||||
|
*/
|
||||||
|
public void writeDebugLog(Object logstr){
|
||||||
|
logger.info(logstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志输出
|
||||||
|
* @param logstr
|
||||||
|
*/
|
||||||
|
public void writeErrorLog(Object logstr){
|
||||||
|
logger.error(logstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志输出
|
||||||
|
* @param logstr
|
||||||
|
*/
|
||||||
|
public void writeNewDebuggerLog(Object o,Object logstr){
|
||||||
|
logger.info(logstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写入同步的日志文件
|
||||||
|
* @param o
|
||||||
|
* @param s
|
||||||
|
* @deprecated 该写入文件的日志输出方式删除
|
||||||
|
*/
|
||||||
|
protected void writeNewLog(String o,String s){
|
||||||
|
try {
|
||||||
|
String filename = "cus_" + TimeUtil.getCurrentDateString() + "_ecology.log";
|
||||||
|
|
||||||
|
|
||||||
|
String folder = GCONST.getRootPath() + "log" + File.separatorChar + "cus";
|
||||||
|
|
||||||
|
//this.writeDebugLog("folder:[" + folder + "]");
|
||||||
|
|
||||||
|
File f = new File(folder);
|
||||||
|
|
||||||
|
// 创建文件夹
|
||||||
|
if (!f.exists()) {
|
||||||
|
f.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
f = new File(folder + File.separatorChar + filename);
|
||||||
|
//文件不存在,则直接创建
|
||||||
|
if(!f.exists()){
|
||||||
|
f.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, true)));
|
||||||
|
|
||||||
|
out.write("[" + o + "][" + TimeUtil.getCurrentTimeString() + "]:"+ s + "\r\n");
|
||||||
|
|
||||||
|
//关闭写入流
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
writeDebugLog("创建日志文件存在异常:[" + e.getMessage() + "/" + e.toString() + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.EncodeHintType;
|
||||||
|
import com.google.zxing.MultiFormatWriter;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TwoDimensionalCodeUtil {
|
||||||
|
|
||||||
|
private static final int BLACK = 0xFF000000;
|
||||||
|
private static final int WHITE = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在指定位置生成二维码图片
|
||||||
|
* @param content 二维码内容;eg:https://www.baidu.com
|
||||||
|
* @param path 生成的图片路径;eg:F:/测试
|
||||||
|
* @param codeName 生成的图片名称;eg:UUID.randomUUID().toString()
|
||||||
|
* @param imageType 生成的图片类型;eg:jpg
|
||||||
|
*/
|
||||||
|
public static void getImage(String content,String path,String codeName,String imageType) {
|
||||||
|
try {
|
||||||
|
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
|
||||||
|
Map<EncodeHintType, String> hints = new HashMap<>();
|
||||||
|
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||||
|
BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints);
|
||||||
|
File file = new File(path, codeName + "." + imageType);
|
||||||
|
writeToFile(bitMatrix, imageType, file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("TwoDimensionalCodeUtil.getImage exception;content:" + content + "message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeToFile(BitMatrix matrix, String format, File file) throws IOException {
|
||||||
|
BufferedImage image = toBufferedImage(matrix);
|
||||||
|
if (!ImageIO.write(image, format, file)) {
|
||||||
|
throw new IOException("Could not write an image of format " + format + " to " + file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedImage toBufferedImage(BitMatrix matrix) {
|
||||||
|
int width = matrix.getWidth();
|
||||||
|
int height = matrix.getHeight();
|
||||||
|
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,434 @@
|
||||||
|
package com.api.taojw.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.conn.RecordSetTrans;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class WorkFlowDataToJsonUtil {
|
||||||
|
|
||||||
|
static Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
public static String[] getRequestBaseInfo(String requestId,RecordSetTrans rsts,String requestMark,String billTableName){
|
||||||
|
//--------------------------------------基于文件发起签署
|
||||||
|
//流程基础数据数组[流程请求ID\流程标题\签字意见\表单名称\主表主键值]
|
||||||
|
String[] base_array = new String[5];
|
||||||
|
//获取请求中的数据库链接
|
||||||
|
try {
|
||||||
|
if(rsts == null){
|
||||||
|
rsts = new RecordSetTrans();
|
||||||
|
}
|
||||||
|
String select_base_sql = "select * from workflow_requestBase where requestId = ?";
|
||||||
|
String requestName = "";
|
||||||
|
if(rsts.executeQuery(select_base_sql,requestId)){
|
||||||
|
while(rsts.next()){
|
||||||
|
requestName = Util.null2String(rsts.getString("requestName"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
base_array[0] = requestId;
|
||||||
|
base_array[1] = requestName;
|
||||||
|
base_array[2] = requestMark;
|
||||||
|
base_array[3] = billTableName;
|
||||||
|
String getBaseInfoSql = "select id from " + billTableName + " where requestid = ?";
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(new RecordSet(), getBaseInfoSql, requestId);
|
||||||
|
if(firstData.size() > 0){
|
||||||
|
base_array[4] = firstData.get("id");
|
||||||
|
}
|
||||||
|
return base_array;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error("WorkFlowDataToJsonUtil getRequestBaseInfo error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据转换规则 获取转换后的数据
|
||||||
|
*/
|
||||||
|
public static String convertDataByZhgz(String oldValue,Map<String,String> configMap){
|
||||||
|
//函数返回值
|
||||||
|
String result = "";
|
||||||
|
try{
|
||||||
|
//转换规则
|
||||||
|
String zhgz = configMap.get("zhgz");
|
||||||
|
//自定义sql
|
||||||
|
String zdysql = configMap.get("zdysql");
|
||||||
|
String requestId = Util.null2String(configMap.get("requestId"));
|
||||||
|
//不同转换规则处理
|
||||||
|
switch(zhgz){
|
||||||
|
//不转换
|
||||||
|
case "0":
|
||||||
|
result = oldValue;
|
||||||
|
break;
|
||||||
|
//固定值
|
||||||
|
case "1":
|
||||||
|
result = zdysql;
|
||||||
|
break;
|
||||||
|
//自定义sql
|
||||||
|
case "2":
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?}",oldValue);
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?requestId}",requestId);
|
||||||
|
Map<String, String> firstData = DaoUtil.getFirstData(zdysql);
|
||||||
|
for(String key : firstData.keySet()){
|
||||||
|
result = firstData.get(key);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//日期格式化
|
||||||
|
case "3":
|
||||||
|
result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd").parse(oldValue));
|
||||||
|
break;
|
||||||
|
//日期时间格式化
|
||||||
|
case "4":
|
||||||
|
result = new SimpleDateFormat(zdysql).format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(oldValue));
|
||||||
|
break;
|
||||||
|
//当前日期
|
||||||
|
case "5":
|
||||||
|
result = new SimpleDateFormat(zdysql).format(new Date());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch(Exception e){
|
||||||
|
result = "";
|
||||||
|
logger.error("DealWorkFlowDataToRequestUtil.convertDataByZhgz error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JSONObject getJsonByWorkFlowData(String requestId,String configId,String[] base_array){
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try{
|
||||||
|
logger.info("WorkFlowDataToJsonUtil.getJsonByWorkFlowData begin;requestId:" + requestId + ";configId:" + configId);
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
//-----------------------根据配置id获取配置信息
|
||||||
|
//根节点配置信息
|
||||||
|
List<Map<String,String>> rootJsonConfigInfo = new ArrayList<>();
|
||||||
|
//明细配置信息
|
||||||
|
List<Map<String,String>> requestBodyConfigList = new ArrayList<>();
|
||||||
|
getConfigInfo(rs,configId,requestBodyConfigList,rootJsonConfigInfo);
|
||||||
|
//-----------------------获取主表数据 用于拼装json
|
||||||
|
Map<String,String> mainTableData = new HashMap<>();
|
||||||
|
String getMainTableDataSql = "select * from " + base_array[3] + " where id = " + base_array[4];
|
||||||
|
if(rs.executeQuery(getMainTableDataSql)) {
|
||||||
|
if (rs.next()) {
|
||||||
|
mainTableData = DaoUtil.setRsToMap(rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-----------------------生成json
|
||||||
|
logger.info("recursionGenerateJson begin;");
|
||||||
|
recursionGenerateJson(null,rs,rs,0,result,rootJsonConfigInfo,base_array,mainTableData,requestBodyConfigList);
|
||||||
|
}catch(Throwable e){
|
||||||
|
logger.error("WorkFlowDataToJsonUtil.getJsonByWorkFlowData exception;message:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据configId获取配置信息
|
||||||
|
* @param rs 数据库链接
|
||||||
|
* @param configId 配置id
|
||||||
|
* @param requestBodyConfigList 明细配置
|
||||||
|
* @param rootJsonConfigInfo 根节点配置
|
||||||
|
*/
|
||||||
|
public static void getConfigInfo(RecordSet rs,String configId,List<Map<String,String>> requestBodyConfigList,List<Map<String,String>> rootJsonConfigInfo){
|
||||||
|
//获取明细表 请求体字段详细配置信息
|
||||||
|
String selectDetailSQL = "select dt.*,wb.fieldName,wb.viewType,wb.detailtable from uf_lcsjzjson_dt1 dt left join workflow_billField wb on dt.lcbdzd = wb.id where dt.mainId = ?";
|
||||||
|
if(rs.executeQuery(selectDetailSQL,configId)){
|
||||||
|
while(rs.next()){
|
||||||
|
//节点序号
|
||||||
|
String xmljdxh = Util.null2String(rs.getString("jdxh"));
|
||||||
|
//xml节点名称
|
||||||
|
String xmljdmc = Util.null2String(rs.getString("jdmc"));
|
||||||
|
//字段归属
|
||||||
|
String zdgz = Util.null2String(rs.getString("zdgz"));
|
||||||
|
//xml节点类型
|
||||||
|
String xmljdlx = Util.null2String(rs.getString("jdlx"));
|
||||||
|
//父节点序号
|
||||||
|
String fjdxh = Util.null2String(rs.getString("fjdxh"));
|
||||||
|
//流程表单字段
|
||||||
|
String lcbdzd = Util.null2String(rs.getString("lcbdzd"));
|
||||||
|
//流程表单字段类型
|
||||||
|
String viewType = Util.null2String(rs.getString("viewType"));
|
||||||
|
//流程表单字段
|
||||||
|
String fieldName = Util.null2String(rs.getString("fieldName"));
|
||||||
|
//字段所属明细表表名
|
||||||
|
String detailtable = Util.null2String(rs.getString("detailtable"));
|
||||||
|
//转换规则
|
||||||
|
String zhgz = Util.null2String(rs.getString("zhgz"));
|
||||||
|
//自定义sql
|
||||||
|
String zdysql = Util.null2String(rs.getString("zdysql"));
|
||||||
|
if(!"".equals(zdysql)){
|
||||||
|
zdysql = zdysql.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char);
|
||||||
|
zdysql = zdysql.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char);
|
||||||
|
zdysql = CommonUtil.fullToHalfAngle(zdysql);
|
||||||
|
}
|
||||||
|
//数据条件
|
||||||
|
String sjtj = Util.null2String(rs.getString("sjtj"));
|
||||||
|
if(!"".equals(sjtj)){
|
||||||
|
sjtj = sjtj.replace(Constant.Default_Line_Break, Constant.Default_Blank_Char);
|
||||||
|
sjtj = sjtj.replace(Constant.Default_Html_Blank, Constant.Default_Blank_Char);
|
||||||
|
sjtj = CommonUtil.fullToHalfAngle(sjtj);
|
||||||
|
}
|
||||||
|
Map<String,String> dtMap = new HashMap<>();
|
||||||
|
dtMap.put("jdxh",xmljdxh);
|
||||||
|
dtMap.put("jdmc",xmljdmc);
|
||||||
|
dtMap.put("jdlx",xmljdlx);
|
||||||
|
dtMap.put("fjdxh",fjdxh);
|
||||||
|
dtMap.put("lcbdzd",lcbdzd);
|
||||||
|
dtMap.put("viewType",viewType);
|
||||||
|
dtMap.put("zhgz",zhgz);
|
||||||
|
dtMap.put("zdysql",zdysql);
|
||||||
|
dtMap.put("sjtj",sjtj);
|
||||||
|
dtMap.put("zdgz",zdgz);
|
||||||
|
dtMap.put("detailtable",detailtable);
|
||||||
|
dtMap.put("fieldName",fieldName.toLowerCase());
|
||||||
|
if("".equals(fjdxh)){
|
||||||
|
rootJsonConfigInfo.add(dtMap);
|
||||||
|
}
|
||||||
|
requestBodyConfigList.add(dtMap);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL sql execute error;sql:" + selectDetailSQL);
|
||||||
|
}
|
||||||
|
logger.info("WorkFlowDataToJsonUtil.getConfigInfo.selectDetailSQL done;requestBodyConfigList:" + requestBodyConfigList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归生成json报文
|
||||||
|
*/
|
||||||
|
public static Object recursionGenerateJson(Map<String,String> configMap,RecordSet rs,
|
||||||
|
RecordSet detailRs,int sequence,JSONObject jsonDoc,
|
||||||
|
List<Map<String,String>> rootJsonConfigInfo,
|
||||||
|
String[] baseArray,Map<String,String> mainTableData,
|
||||||
|
List<Map<String,String>> requestBodyConfigList){
|
||||||
|
if(configMap == null){
|
||||||
|
for(Map<String,String> configInfo:rootJsonConfigInfo){
|
||||||
|
jsonDoc.put(configInfo.get("jdmc"),recursionGenerateJson(configInfo,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
switch(configMap.get("jdlx")){
|
||||||
|
case Constant.NODE_TYPE_STRING:
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
return getFieldValue(configMap,rs,detailRs,baseArray,mainTableData);
|
||||||
|
case Constant.NODE_TYPE_BOOLEAN:
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
return "true".equals(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData));
|
||||||
|
case Constant.NODE_TYPE_NUMBER:
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
int r = 0;
|
||||||
|
try{
|
||||||
|
r = Integer.parseInt(getFieldValue(configMap,rs,detailRs,baseArray,mainTableData));
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("change data to int error;configMap:" + configMap + ";e:" + e);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
case Constant.NODE_TYPE_FLOAT:
|
||||||
|
double d = 0;
|
||||||
|
try{
|
||||||
|
configMap.put("detailRowNum", String.valueOf(sequence));
|
||||||
|
String f = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData);
|
||||||
|
d = Double.parseDouble(f);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("change data to float error;configMap:" + configMap + ";e:" + e);
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
case Constant.NODE_TYPE_OBJECT:
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
for(Map<String,String> m : requestBodyConfigList) {
|
||||||
|
if (m.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
json.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
case Constant.NODE_TYPE_JSONSTRING:
|
||||||
|
JSONObject jsonObj = new JSONObject();
|
||||||
|
for(Map<String,String> m : requestBodyConfigList) {
|
||||||
|
if (m.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
jsonObj.put(m.get("jdmc"),recursionGenerateJson(m,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonObj.toString();
|
||||||
|
case Constant.NODE_TYPE_STRING_ARRAY:
|
||||||
|
String stringArrayValue = getFieldValue(configMap,rs,detailRs,baseArray,mainTableData);
|
||||||
|
JSONArray stringArray = new JSONArray();
|
||||||
|
stringArray.addAll(Arrays.asList(stringArrayValue.split(",")));
|
||||||
|
return stringArray;
|
||||||
|
case Constant.NODE_TYPE_ARRAY:
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
if("".equals(configMap.get("zdgz")) && Constant.CHANGE_TYPE_FIXED.equals(configMap.get("zhgz"))){
|
||||||
|
for(Map<String,String> son : requestBodyConfigList) {
|
||||||
|
if (son.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
if("".equals(configMap.get("zdgz"))){
|
||||||
|
JSONObject o = new JSONObject();
|
||||||
|
for(Map<String,String> son : requestBodyConfigList) {
|
||||||
|
if (son.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array.add(o);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
//查询明细表数据
|
||||||
|
String getDetailDataSql = "select * from " + baseArray[3] + "_dt" + configMap.get("zdgz") + " where mainid = " + baseArray[4];
|
||||||
|
if(!"".equals(configMap.get("sjtj"))){
|
||||||
|
getDetailDataSql = getDetailDataSql + " " + configMap.get("sjtj");
|
||||||
|
}
|
||||||
|
RecordSet detailDataRs = new RecordSet();
|
||||||
|
if(detailDataRs.executeQuery(getDetailDataSql)){
|
||||||
|
sequence = 0;
|
||||||
|
while(detailDataRs.next()){
|
||||||
|
JSONObject o = new JSONObject();
|
||||||
|
sequence = sequence + 1;
|
||||||
|
for(Map<String,String> son : requestBodyConfigList) {
|
||||||
|
if (son.get("fjdxh").equals(configMap.get("jdxh"))) {
|
||||||
|
o.put(son.get("jdmc"),recursionGenerateJson(son,rs,detailDataRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array.add(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Map<String,String> son : requestBodyConfigList) {
|
||||||
|
if (son.get("fjdxh").equals(configMap.get("jdxh")) && Constant.NODE_TYPE_OBJECT.equals(son.get("jdlx"))) {
|
||||||
|
array.add(recursionGenerateJson(son,rs,detailRs,sequence,jsonDoc,rootJsonConfigInfo,baseArray,mainTableData,requestBodyConfigList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字段实际值
|
||||||
|
* @param configMap 配置信息,包含字段归属、字段名称、转换规则等
|
||||||
|
* @param rs 数据库链接
|
||||||
|
* @param detailRs 明细表数据
|
||||||
|
*/
|
||||||
|
public static String getFieldValue(Map<String,String> configMap,RecordSet rs,RecordSet detailRs,String[] baseArray,Map<String,String> mainTableData){
|
||||||
|
//函数返回值
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
try{
|
||||||
|
Map<String,String> detailDataMap = DaoUtil.setRsToMap(detailRs);
|
||||||
|
//字段类型 0-主表 1-明细表
|
||||||
|
String viewType = configMap.get("viewType");
|
||||||
|
//转换规则
|
||||||
|
String zhgz = configMap.get("zhgz");
|
||||||
|
//字段名称
|
||||||
|
String fieldName = configMap.get("fieldName");
|
||||||
|
//自定义sql
|
||||||
|
String zdysql = configMap.get("zdysql");
|
||||||
|
//数据条件
|
||||||
|
String sjtj = configMap.get("sjtj");
|
||||||
|
//字段所属明细表表名
|
||||||
|
String detailtable = configMap.get("detailtable");
|
||||||
|
//不同转换规则处理
|
||||||
|
switch(zhgz){
|
||||||
|
case Constant.CHANGE_TYPE_REQUEST_ID:
|
||||||
|
result = new StringBuilder(baseArray[0]);
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_REQUEST_NAME:
|
||||||
|
result = new StringBuilder(baseArray[1]);
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_MD5:
|
||||||
|
result = new StringBuilder("Basic " + Base64.getUrlEncoder().encodeToString(zdysql.getBytes()));
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_SUGGESTION:
|
||||||
|
result = new StringBuilder(baseArray[2]);
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_ROW_NUMBER:
|
||||||
|
result = new StringBuilder(configMap.get("detailRowNum"));
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_FIXED:
|
||||||
|
result = new StringBuilder(configMap.get("zdysql"));
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_NONE:
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
result = new StringBuilder(mainTableData.get(fieldName));
|
||||||
|
}else{
|
||||||
|
result = new StringBuilder(detailDataMap.get(fieldName));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_SQL:
|
||||||
|
String oldValue;
|
||||||
|
if(!"".equals(viewType) && !"".equals(fieldName)){
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
oldValue = mainTableData.get(fieldName);
|
||||||
|
}else{
|
||||||
|
oldValue = detailDataMap.get(fieldName);
|
||||||
|
}
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?}",oldValue);
|
||||||
|
}
|
||||||
|
zdysql = zdysql.replaceAll("\\{\\?requestId}",baseArray[0]);
|
||||||
|
if(rs.executeQuery(zdysql)){
|
||||||
|
if(rs.next()){
|
||||||
|
result = new StringBuilder(Util.null2String(rs.getString(1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_SUM:
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
logger.error("want sum but config main field");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String getSumSql = "select sum(" + fieldName + ") as val from " + detailtable + " where mainid = " + baseArray[4];
|
||||||
|
if(!"".equals(sjtj)){
|
||||||
|
getSumSql = getSumSql + " " + sjtj;
|
||||||
|
}
|
||||||
|
if(rs.executeQuery(getSumSql)){
|
||||||
|
if(rs.next()){
|
||||||
|
result = new StringBuilder(Util.null2String(rs.getString("val")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Constant.CHANGE_TYPE_STRING_ARRAY:
|
||||||
|
if("0".equals(viewType)){
|
||||||
|
logger.error("want array but config main field");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String getArraySql = "select " + fieldName + " as val from " + detailtable + " where mainid = " + baseArray[4];
|
||||||
|
if(!"".equals(sjtj)){
|
||||||
|
getArraySql = getArraySql + " " + sjtj;
|
||||||
|
}
|
||||||
|
if(rs.executeQuery(getArraySql)){
|
||||||
|
int i = 0;
|
||||||
|
while(rs.next()){
|
||||||
|
if(i == 0){
|
||||||
|
result = new StringBuilder(Util.null2String(rs.getString(1)));
|
||||||
|
}else{
|
||||||
|
result.append(",").append(Util.null2String(rs.getString(1)));
|
||||||
|
}
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = new StringBuilder();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}catch(Exception e){
|
||||||
|
result = new StringBuilder();
|
||||||
|
logger.error("DealWorkFlowDataToRequestUtil.getFieldValue error;configMap:" + configMap + ";info:" + e.getMessage() + ";e:" + e);
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
package com.api.taojw.common.action;
|
||||||
|
|
||||||
|
import com.api.taojw.common.action.util.CallApiByWorkFlowDataUtil;
|
||||||
|
import com.api.taojw.common.logging.MyLogger;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.conn.RecordSetTrans;
|
||||||
|
import weaver.general.TimeUtil;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.interfaces.workflow.action.Action;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* taojingwei @2022-05-26
|
||||||
|
* 1、获取建模配置,将流程数据封装成需要的请求报文
|
||||||
|
* 2、调用http接口传输报文信息,获取接口返回信息
|
||||||
|
*/
|
||||||
|
public class RequestDataToApiAction implements Action {
|
||||||
|
|
||||||
|
//自定义参数值
|
||||||
|
private String cusParam = "";
|
||||||
|
|
||||||
|
Logger logger = MyLogger.getLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现父类方法
|
||||||
|
* 具体的业务实现
|
||||||
|
* @param requestInfo 流程请求信息
|
||||||
|
* @return 流程是否允许提交标识
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String execute(RequestInfo requestInfo) {
|
||||||
|
//流程请求ID
|
||||||
|
String requestId = "";
|
||||||
|
try {
|
||||||
|
logger.info("----------------------" + this.getClass() + " action begin ----------------------");
|
||||||
|
//流程请求ID
|
||||||
|
requestId = requestInfo.getRequestid();
|
||||||
|
//流程类型ID
|
||||||
|
String workflowId = requestInfo.getWorkflowid();
|
||||||
|
//流程表单名称
|
||||||
|
String billTableName = requestInfo.getRequestManager().getBillTableName();
|
||||||
|
//流程基础数据数组[流程请求ID\流程标题\流程编号\表单名称\主表主键值]
|
||||||
|
String[] base_array = new String[5];
|
||||||
|
//获取请求中的数据库链接
|
||||||
|
RecordSetTrans rsts = requestInfo.getRsTrans();
|
||||||
|
try {
|
||||||
|
if(rsts == null){
|
||||||
|
rsts = new RecordSetTrans();
|
||||||
|
}
|
||||||
|
String select_base_sql = "select * from workflow_requestBase where requestId = ?";
|
||||||
|
String requestName = "";
|
||||||
|
String requestMark = "";
|
||||||
|
if(rsts.executeQuery(select_base_sql,requestId)){
|
||||||
|
while(rsts.next()){
|
||||||
|
requestName = Util.null2String(rsts.getString("requestName"));
|
||||||
|
requestMark = Util.null2String(rsts.getString("requestMark"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
base_array[0] = requestId;
|
||||||
|
base_array[1] = requestName;
|
||||||
|
base_array[2] = requestMark;
|
||||||
|
base_array[3] = billTableName;
|
||||||
|
logger.info("requestName:[" + requestName + "],requestMark:[" + requestMark + "],workflowId:["+workflowId+"],requestId:[" + requestId + "],billTableName:[" + billTableName + "],cusParam[" + cusParam + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
requestInfo.getRequestManager().setMessageid("2022052791002");
|
||||||
|
requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!");
|
||||||
|
logger.error("VoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
return Action.FAILURE_AND_CONTINUE;
|
||||||
|
}
|
||||||
|
//获取当前流程信息
|
||||||
|
String selectData = "select * from " + billTableName + " where requestId = ?";
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
if(rs.executeQuery(selectData,requestId)){
|
||||||
|
rs.next();
|
||||||
|
base_array[4] = Util.null2String(rs.getString("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
CallApiByWorkFlowDataUtil callApiByWorkFlowDataUtil = new CallApiByWorkFlowDataUtil();
|
||||||
|
callApiByWorkFlowDataUtil.setBaseArray(base_array);
|
||||||
|
callApiByWorkFlowDataUtil.setRsts(rsts);
|
||||||
|
Map<String, String> result = callApiByWorkFlowDataUtil.execute(workflowId, cusParam);
|
||||||
|
if("CALL_FAILED".equals(result.get("code"))){
|
||||||
|
requestInfo.getRequestManager().setMessageid("2022052791402");
|
||||||
|
requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",接口响应:" + result.get("message"));
|
||||||
|
return Action.FAILURE_AND_CONTINUE;
|
||||||
|
}
|
||||||
|
return Action.SUCCESS;
|
||||||
|
}catch (Throwable e) {
|
||||||
|
requestInfo.getRequestManager().setMessageid(TimeUtil.getCurrentTimeString()+requestId);
|
||||||
|
requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +";" + "请联系管理员TJW!异常信息:" + e.getMessage());
|
||||||
|
logger.error("Action Exception;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e);
|
||||||
|
return Action.FAILURE_AND_CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCusParam() {
|
||||||
|
return cusParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCusParam(String cusParam) {
|
||||||
|
this.cusParam = cusParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
package com.api.taojw.common.action.constant;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一些静态常量定义
|
||||||
|
*/
|
||||||
|
public class Constant {
|
||||||
|
|
||||||
|
//action接口调用配置表名称
|
||||||
|
public static String CONFIG_TABLE_NAME = "uf_lcdyjkpzxxbd";
|
||||||
|
//action调用接口日志记录表表名
|
||||||
|
public static String LOG_TABLE_NAME = "uf_lcdyjkrzjlbd";
|
||||||
|
//action调用接口日志记录表requestId字段名称
|
||||||
|
public static String LOG_REQUESTID_COLUMN = "lcrequestid";
|
||||||
|
//action调用接口日志记录表请求正文字段名称
|
||||||
|
public static String LOG_REQUEST_COLUMN = "qqbw";
|
||||||
|
//action调用接口日志记录表响应文字段名称
|
||||||
|
public static String LOG_RESPONSE_COLUMN = "xybw";
|
||||||
|
//action调用接口日志记录表响应码字段名称
|
||||||
|
public static String LOG_RESPONSECODE_COLUMN = "xym";
|
||||||
|
//action调用接口日志记录表请求地址字段名称
|
||||||
|
public static String LOG_REQUESTURL_COLUMN = "qqdz";
|
||||||
|
//action调用接口日志记录表请求头字段名称
|
||||||
|
public static String LOG_REQUESTHEADER_COLUMN = "qqt";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------自定义sql、接口地址中参数的开始标志
|
||||||
|
public static final String PARAM_BEGIN = "{";
|
||||||
|
public static final String PARAM_END = "}";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口调用成功失败标识 0-失败 1-成功
|
||||||
|
public static final String CALL_SUCCESS = "1";
|
||||||
|
public static final String CALL_FAILED = "0";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------选择框 0-否 1-是
|
||||||
|
public static final String SELECT_TYPE_IS = "1";
|
||||||
|
public static final String SELECT_TYPE_NOT = "0";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口调用类型 0-仅调用一次 1-每条明细调用一次
|
||||||
|
public static final String CALL_TYPE_ONLY_ONE = "0";
|
||||||
|
public static final String CALL_TYPE_EVERY_DETAIL = "1";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口请求类型 0-get 1-post
|
||||||
|
//GET
|
||||||
|
public static final String REQUEST_METHOD_GET = "0";
|
||||||
|
//POST
|
||||||
|
public static final String REQUEST_METHOD_POST = "1";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口报文类型 0-xml 1-json 2-键值对
|
||||||
|
//xml
|
||||||
|
public static final String REQUEST_DATA_TYPE_XML = "0";
|
||||||
|
//json
|
||||||
|
public static final String REQUEST_DATA_TYPE_JSON = "1";
|
||||||
|
//键值对
|
||||||
|
public static final String REQUEST_DATA_TYPE_PAIR = "2";
|
||||||
|
//MultipartFile
|
||||||
|
public static final String REQUEST_DATA_TYPE_MULTIPARTFILE = "3";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------接口响应报文类型 0-xml 1-json
|
||||||
|
//xml
|
||||||
|
public static final String RESPONSE_DATA_TYPE_XML = "0";
|
||||||
|
//json
|
||||||
|
public static final String RESPONSE_DATA_TYPE_JSON = "1";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------节点类型
|
||||||
|
//文本
|
||||||
|
public static final String NODE_TYPE_STRING = "0";
|
||||||
|
//对象
|
||||||
|
public static final String NODE_TYPE_OBJECT = "1";
|
||||||
|
//文本数组
|
||||||
|
public static final String NODE_TYPE_STRING_ARRAY = "2";
|
||||||
|
//数组
|
||||||
|
public static final String NODE_TYPE_ARRAY = "3";
|
||||||
|
//json对象字符串
|
||||||
|
public static final String NODE_TYPE_JSONSTRING = "4";
|
||||||
|
//数字
|
||||||
|
public static final String NODE_TYPE_NUMBER = "5";
|
||||||
|
//布尔
|
||||||
|
public static final String NODE_TYPE_BOOLEAN = "6";
|
||||||
|
//浮点数
|
||||||
|
public static final String NODE_TYPE_FLOAT = "7";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------转换规则
|
||||||
|
//不转换
|
||||||
|
public static final String CHANGE_TYPE_NONE = "0";
|
||||||
|
//固定值
|
||||||
|
public static final String CHANGE_TYPE_FIXED = "1";
|
||||||
|
//自定义sql
|
||||||
|
public static final String CHANGE_TYPE_SQL = "2";
|
||||||
|
//字段求和
|
||||||
|
public static final String CHANGE_TYPE_SUM = "3";
|
||||||
|
//文本数组
|
||||||
|
public static final String CHANGE_TYPE_STRING_ARRAY = "4";
|
||||||
|
//明细序号
|
||||||
|
public static final String CHANGE_TYPE_ROW_NUMBER = "5";
|
||||||
|
//流程审批意见
|
||||||
|
public static final String CHANGE_TYPE_SUGGESTION = "6";
|
||||||
|
//加密处理
|
||||||
|
public static final String CHANGE_TYPE_MD5 = "7";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------sql转义
|
||||||
|
//默认换行符
|
||||||
|
public static final String Default_Line_Break = "<br>";
|
||||||
|
//默认空格HTML代码
|
||||||
|
public static final String Default_Html_Blank = " ";
|
||||||
|
//默认空格字符
|
||||||
|
public static final String Default_Blank_Char = " ";
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.api.taojw.common.action.entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ConfigInfoEntity {
|
||||||
|
|
||||||
|
//接口调用类型 0-仅调用一次 1-每条明细调用一次
|
||||||
|
public String callType;
|
||||||
|
//请求方式 0-get 1-post
|
||||||
|
public String requestMethod;
|
||||||
|
//失败是否阻止流程提交
|
||||||
|
public String failedAndReturn;
|
||||||
|
//明细表下标 值为1时表示对明细表1中的每条记录都调用一次接口
|
||||||
|
public String detailTableIndex;
|
||||||
|
//数据条件
|
||||||
|
public String sqlCondition;
|
||||||
|
//接口报文类型 0-xml 1-json 2-键值对
|
||||||
|
public String requestDataType;
|
||||||
|
//响应报文类型 0-xml 1-json
|
||||||
|
public String responseDataType;
|
||||||
|
//接口地址
|
||||||
|
public String callAddress;
|
||||||
|
//日志记录表名称
|
||||||
|
public String logTableName;
|
||||||
|
//日志记录表requestid字段名称
|
||||||
|
public String logRequestIdFieldName;
|
||||||
|
//日志记录表接口地址字段名称
|
||||||
|
public String logRequestUrlFieldName;
|
||||||
|
//日志记录表请求头字段名称
|
||||||
|
public String logRequestHeaderFieldName;
|
||||||
|
//日志记录表请求报文字段名称
|
||||||
|
public String logRequestBodyFieldName;
|
||||||
|
//日志记录表响应报文字段名称
|
||||||
|
public String logResponseBodyFieldName;
|
||||||
|
//日志记录表响应码字段名称
|
||||||
|
public String logResponseStatusFieldName;
|
||||||
|
//接口地址参数配置详情
|
||||||
|
public List<Map<String,String>> requestAddressConfigList = new ArrayList<>();
|
||||||
|
//请求头参数配置详情
|
||||||
|
public List<Map<String,String>> requestHeaderConfigList = new ArrayList<>();
|
||||||
|
//请求体字段详细配置
|
||||||
|
public List<Map<String,String>> requestBodyConfigList = new ArrayList<>();
|
||||||
|
//xml节点属性详细配置
|
||||||
|
public List<Map<String,String>> xmlNodeAttrConfigList = new ArrayList<>();
|
||||||
|
//响应信息详细配置
|
||||||
|
public List<Map<String,String>> responseConfigList = new ArrayList<>();
|
||||||
|
|
||||||
|
//json请求报文根节点配置信息
|
||||||
|
public List<Map<String,String>> rootJsonConfigInfo = new ArrayList<>();
|
||||||
|
//xml请求报文根节点配置信息
|
||||||
|
public Map<String,String> rootXmlConfigInfo;
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.api.taojw.common.action.entity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.DocumentHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class RequestAndResponseInfoEntity {
|
||||||
|
|
||||||
|
//请求头参数
|
||||||
|
public Map<String,String> headers = new HashMap<>();
|
||||||
|
//生成的xml请求报文对象
|
||||||
|
public Document xmlDoc = DocumentHelper.createDocument();
|
||||||
|
//生成的json请求报文对象
|
||||||
|
public JSONObject jsonDoc = new JSONObject();
|
||||||
|
//生成的键值对参数
|
||||||
|
public List<BasicNameValuePair> pairList = new ArrayList<>();
|
||||||
|
//文件信息参数
|
||||||
|
public List<Map<String,String>> multiPartFileInfos = new ArrayList<>();
|
||||||
|
//接口响应信息
|
||||||
|
public CloseableHttpResponse response;
|
||||||
|
//接口响应体
|
||||||
|
public String responseString;
|
||||||
|
//接口响应码
|
||||||
|
public int responseCode;
|
||||||
|
//JSON类型响应体
|
||||||
|
public JSONObject responseJson;
|
||||||
|
//XML类型响应体
|
||||||
|
public Document responseXml;
|
||||||
|
//响应的成功失败标识值
|
||||||
|
public String resultValue = "";
|
||||||
|
//接口调用提示信息
|
||||||
|
public String responseMessage = "";
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,89 @@
|
||||||
|
package com.api.taojw.common.logging;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写日志(log4j)
|
||||||
|
* @date 2020-03-10
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Log4JLogger implements Logger {
|
||||||
|
|
||||||
|
private org.apache.log4j.Logger log;
|
||||||
|
//类名
|
||||||
|
private String classname;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getClassname() {
|
||||||
|
return classname;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setClassname(String classname) {
|
||||||
|
this.classname = classname;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return log.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return log.isInfoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object message) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.debug(classname+"."+method+"() - "+message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object message, Throwable exception) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.debug(classname+"."+method+"() - "+message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object message) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.info(classname+"."+method+"() - "+message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object message, Throwable exception) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.info(classname+"."+method+"() - "+message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object message) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.warn(classname+"."+method+"() - "+message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object message, Throwable exception) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.warn(classname+"."+method+"() - "+message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object message) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.error(classname+"."+method+"() - "+message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object message, Throwable exception) {
|
||||||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||||
|
log.error(classname+"."+method+"() - "+message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(String name) {
|
||||||
|
if("".equals(name)) {
|
||||||
|
name = "cuslog";
|
||||||
|
}
|
||||||
|
log = org.apache.log4j.Logger.getLogger(name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.api.taojw.common.logging;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志接口(写)
|
||||||
|
*
|
||||||
|
* @author zwl
|
||||||
|
* @date 2020-03-10
|
||||||
|
*/
|
||||||
|
public interface Logger extends weaver.integration.logging.Logger {
|
||||||
|
|
||||||
|
public boolean isDebugEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印debug日志
|
||||||
|
* @param message 消息
|
||||||
|
*/
|
||||||
|
public void debug(Object message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印debug日志
|
||||||
|
* @param message 消息
|
||||||
|
* @param exception 异常
|
||||||
|
*/
|
||||||
|
public void debug(Object message, Throwable exception);
|
||||||
|
|
||||||
|
public boolean isInfoEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印info日志
|
||||||
|
* @param message 消息
|
||||||
|
*/
|
||||||
|
public void info(Object message);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印info日志
|
||||||
|
* @param message 消息
|
||||||
|
* @param exception 异常
|
||||||
|
*/
|
||||||
|
public void info(Object message, Throwable exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印warn日志
|
||||||
|
* @param message 消息
|
||||||
|
*/
|
||||||
|
public void warn(Object message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印warn日志
|
||||||
|
* @param message 消息
|
||||||
|
* @param exception 异常
|
||||||
|
*/
|
||||||
|
public void warn(Object message, Throwable exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印error日志
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public void error(Object message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印error日志
|
||||||
|
* @param message 消息
|
||||||
|
* @param exception 异常
|
||||||
|
*/
|
||||||
|
public void error(Object message, Throwable exception);
|
||||||
|
|
||||||
|
public String getClassname();
|
||||||
|
|
||||||
|
public void setClassname(String classname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*
|
||||||
|
* @param name logger名称
|
||||||
|
*/
|
||||||
|
public void init(String name);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue