commit
2af595ad81
|
@ -8,8 +8,8 @@ const threeMonthIndex = 1;
|
||||||
const submitWaitNode = WfForm.convertFieldNameToId("sftjddjd");
|
const submitWaitNode = WfForm.convertFieldNameToId("sftjddjd");
|
||||||
// 下次超时提醒日期
|
// 下次超时提醒日期
|
||||||
const timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq");
|
const timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq");
|
||||||
// 跟踪天数
|
// 跟踪天数 <= 1 ? 15 : 30;
|
||||||
const trackingDays = WfForm.getFieldValue(trackTimeField) <= 1 ? 15 : 30;
|
const trackingDaysField = WfForm.convertFieldNameToId("gzts")
|
||||||
// 跟踪触发行数
|
// 跟踪触发行数
|
||||||
const trackingLineField = WfForm.convertFieldNameToId("gzcfxs");
|
const trackingLineField = WfForm.convertFieldNameToId("gzcfxs");
|
||||||
$(() => {
|
$(() => {
|
||||||
|
@ -44,6 +44,7 @@ function getNodeNum(){
|
||||||
let currentDate = getCurrentDate();
|
let currentDate = getCurrentDate();
|
||||||
let dayDiff = getDaysDiff(firstSaleDate, currentDate);
|
let dayDiff = getDaysDiff(firstSaleDate, currentDate);
|
||||||
console.log('当前天数与首台销售日期相差天数 : ', dayDiff)
|
console.log('当前天数与首台销售日期相差天数 : ', dayDiff)
|
||||||
|
let trackingDays = WfForm.getFieldValue(trackingDaysField);
|
||||||
return Math.floor(dayDiff / trackingDays) + 1;
|
return Math.floor(dayDiff / trackingDays) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ function initTimeoutDate(){
|
||||||
let firstSaleDate = WfForm.getFieldValue(firstSaleDateField);
|
let firstSaleDate = WfForm.getFieldValue(firstSaleDateField);
|
||||||
const nodeNum = getNodeNum();
|
const nodeNum = getNodeNum();
|
||||||
console.log('到达节点次数 ', nodeNum);
|
console.log('到达节点次数 ', nodeNum);
|
||||||
|
let trackingDays = WfForm.getFieldValue(trackingDaysField);
|
||||||
console.log('跟踪天数 ', trackingDays);
|
console.log('跟踪天数 ', trackingDays);
|
||||||
let computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays);
|
let computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays);
|
||||||
console.log('计算下次超时日期 ', computeTimeoutDate);
|
console.log('计算下次超时日期 ', computeTimeoutDate);
|
||||||
|
|
|
@ -688,15 +688,17 @@ $(() => {
|
||||||
$(() => {
|
$(() => {
|
||||||
const config = [{
|
const config = [{
|
||||||
// 源字段
|
// 源字段
|
||||||
sourceField: '',
|
sourceField: 'htksrq',
|
||||||
// 目标字段
|
// 目标字段
|
||||||
targetField: '',
|
targetField: 'htjsrq',
|
||||||
// 日期加月份字段
|
// 日期加月份字段
|
||||||
numberField: ''
|
numberField: 'contractperiod',
|
||||||
|
monthBase: 12
|
||||||
}, {
|
}, {
|
||||||
sourceField: '',
|
sourceField: 'syqksrq',
|
||||||
targetField: '',
|
targetField: 'syqjsrq',
|
||||||
numberField: ''
|
numberField: 'probationperiod',
|
||||||
|
monthBase: 1
|
||||||
}]
|
}]
|
||||||
|
|
||||||
runJs();
|
runJs();
|
||||||
|
@ -711,22 +713,26 @@ $(() => {
|
||||||
let fieldId = WfForm.convertFieldNameToId(configItem.numberField)
|
let fieldId = WfForm.convertFieldNameToId(configItem.numberField)
|
||||||
WfForm.bindFieldChangeEvent(fieldId, (obj, id, value) => {
|
WfForm.bindFieldChangeEvent(fieldId, (obj, id, value) => {
|
||||||
if ("" == value) {
|
if ("" == value) {
|
||||||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField, {value: ""}))
|
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField), {value: ""})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let sourceValue = WfForm.getFieldValue(WfForm.convertFieldNameToId(configItem.sourceField));
|
let sourceValue = WfForm.getFieldValue(WfForm.convertFieldNameToId(configItem.sourceField));
|
||||||
|
if ("" == sourceValue) {
|
||||||
|
setTimeout(() => {
|
||||||
|
WfForm.changeFieldValue(fieldId, {value: ""})
|
||||||
|
}, 10)
|
||||||
|
}
|
||||||
let date = new Date(sourceValue)
|
let date = new Date(sourceValue)
|
||||||
date.setMonth(date.getMonth() + +value)
|
date.setMonth(date.getMonth() + +value * configItem.monthBase)
|
||||||
let objectDate = new Date();
|
date.setDate(date.getDate() - 1)
|
||||||
|
let day = date.getDate();
|
||||||
|
let month = date.getMonth() + 1;
|
||||||
let day = objectDate.getDate();
|
let year = date.getFullYear();
|
||||||
let month = objectDate.getMonth() + 1;
|
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField), {
|
||||||
let year = objectDate.getFullYear();
|
|
||||||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField, {
|
|
||||||
value: `${year}-${fullNum(month)}-${fullNum(day)}`
|
value: `${year}-${fullNum(month)}-${fullNum(day)}`
|
||||||
}))
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fullNum(i) {
|
function fullNum(i) {
|
||||||
|
@ -738,4 +744,46 @@ $(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
/* ******************* 计算年月日 end ******************* */
|
/* ******************* 计算年月日 end ******************* */
|
||||||
|
|
||||||
|
|
||||||
|
/* ******************* 年假计算 start ******************* */
|
||||||
|
$(() => {
|
||||||
|
let config = {
|
||||||
|
// 基础年假
|
||||||
|
base: 21,
|
||||||
|
// 入职日期
|
||||||
|
dateField: 'jrbsjjtsj',
|
||||||
|
// 年假
|
||||||
|
targetField: 'nj'
|
||||||
|
}
|
||||||
|
|
||||||
|
runJs()
|
||||||
|
|
||||||
|
function runJs() {
|
||||||
|
WfForm.bindFieldChangeEvent(WfForm.convertFieldNameToId(config.dateField), (obj, id, value) => {
|
||||||
|
let date = new Date(value)
|
||||||
|
let nowDate = new Date()
|
||||||
|
let njValue = calculateBonus(date, nowDate, config)
|
||||||
|
if (value !== 0) {
|
||||||
|
WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.targetField), {value: njValue})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateBonus(startDate, endDate, config) {
|
||||||
|
const diffInMs = endDate.getTime() - startDate.getTime();
|
||||||
|
const diffInYears = diffInMs / (1000 * 60 * 60 * 24 * 365);
|
||||||
|
|
||||||
|
if (diffInYears < 3) {
|
||||||
|
return 0;
|
||||||
|
} else if (diffInYears >= 3 && diffInYears < 6) {
|
||||||
|
return config.base;
|
||||||
|
} else {
|
||||||
|
const extraYears = Math.floor((diffInYears - 3) / 3);
|
||||||
|
return config.base + extraYears * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
/* ******************* 年假计算 end ******************* */
|
|
@ -71,6 +71,7 @@ import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -98,7 +99,7 @@ public class Util extends weaver.general.Util {
|
||||||
public static final char DBC_SBC_STEP = 65248; // 全角半角转换间隔
|
public static final char DBC_SBC_STEP = 65248; // 全角半角转换间隔
|
||||||
public static final ExecutorService threadPool = ThreadPoolConfig.createThreadPoolInstance();
|
public static final ExecutorService threadPool = ThreadPoolConfig.createThreadPoolInstance();
|
||||||
public static final String UF_CUS_DEV_CONFIG = "uf_cus_dev_config";
|
public static final String UF_CUS_DEV_CONFIG = "uf_cus_dev_config";
|
||||||
private static final UtilService utilService = new UtilService();
|
private static UtilService utilService = null;
|
||||||
private static final RecordsetUtil recordsetUtil = new RecordsetUtil();
|
private static final RecordsetUtil recordsetUtil = new RecordsetUtil();
|
||||||
private static final RecordsetUtil recordsetTransUtil = new RecordsetUtil();
|
private static final RecordsetUtil recordsetTransUtil = new RecordsetUtil();
|
||||||
private static final UtilMapper mapper = recordsetUtil.getMapper(UtilMapper.class);
|
private static final UtilMapper mapper = recordsetUtil.getMapper(UtilMapper.class);
|
||||||
|
@ -110,12 +111,20 @@ public class Util extends weaver.general.Util {
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
rs = new RecordSet();
|
rs = new RecordSet();
|
||||||
|
utilService = new UtilService();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
new ToolUtil().writeErrorLog("\n初始化RecordSet失败!请检查系统是否正常启动!\n");
|
new ToolUtil().writeErrorLog("\n初始化RecordSet失败!请检查系统是否正常启动!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UtilService getUtilService() {
|
||||||
|
if (utilService == null) {
|
||||||
|
return new UtilService();
|
||||||
|
}
|
||||||
|
return utilService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定格式的当前时间
|
* 获取指定格式的当前时间
|
||||||
*
|
*
|
||||||
|
@ -1582,12 +1591,12 @@ public class Util extends weaver.general.Util {
|
||||||
|
|
||||||
public static ApiConfigMainDTO queryApiConfig(String id) {
|
public static ApiConfigMainDTO queryApiConfig(String id) {
|
||||||
// System.out.println(JSON.toJSONString(apiConfigMain));
|
// System.out.println(JSON.toJSONString(apiConfigMain));
|
||||||
return utilService.getApiConfigMain(id);
|
return getUtilService().getApiConfigMain(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApiConfigMainDTO queryApiConfigTree(String id) {
|
public static ApiConfigMainDTO queryApiConfigTree(String id) {
|
||||||
// System.out.println(JSON.toJSONString(apiConfigMain));
|
// System.out.println(JSON.toJSONString(apiConfigMain));
|
||||||
return utilService.getApiConfigMainTree(id);
|
return getUtilService().getApiConfigMainTree(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> AZipOutputStream createZip(List<T> inputList) throws IOException {
|
public static <T> AZipOutputStream createZip(List<T> inputList) throws IOException {
|
||||||
|
@ -1711,13 +1720,13 @@ public class Util extends weaver.general.Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> queryLanguage(int groupId, int languageId) {
|
public static Map<String, String> queryLanguage(int groupId, int languageId) {
|
||||||
return utilService.queryLanguage(groupId, languageId);
|
return getUtilService().queryLanguage(groupId, languageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> queryLanguage(int groupId, HttpServletRequest request, HttpServletResponse response) {
|
public static Map<String, String> queryLanguage(int groupId, HttpServletRequest request, HttpServletResponse response) {
|
||||||
User user = HrmUserVarify.getUser(request, response);
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
int languageId = user.getLanguage();
|
int languageId = user.getLanguage();
|
||||||
return utilService.queryLanguage(groupId, languageId);
|
return getUtilService().queryLanguage(groupId, languageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2920,6 +2929,17 @@ public class Util extends weaver.general.Util {
|
||||||
submitWorkflowThread(requestId, userId, remark, 60);
|
submitWorkflowThread(requestId, userId, remark, 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>异步提交流程,一般作用于action在节点前</h2>
|
||||||
|
*
|
||||||
|
* @param requestId 流程ID
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param remark 签字意见
|
||||||
|
*/
|
||||||
|
public static void submitWorkflowThread(Integer requestId, Integer userId, String remark, Consumer<Boolean> callback) {
|
||||||
|
submitWorkflowThread(requestId, userId, remark, 60, callback);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>异步提交流程,一般作用于action在节点前</h2>
|
* <h2>异步提交流程,一般作用于action在节点前</h2>
|
||||||
*
|
*
|
||||||
|
@ -2929,6 +2949,10 @@ public class Util extends weaver.general.Util {
|
||||||
* @param seconds 延时多少秒提交
|
* @param seconds 延时多少秒提交
|
||||||
*/
|
*/
|
||||||
public static void submitWorkflowThread(Integer requestId, Integer userId, String remark, int seconds) {
|
public static void submitWorkflowThread(Integer requestId, Integer userId, String remark, int seconds) {
|
||||||
|
submitWorkflowThread(requestId, userId, remark, seconds, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void submitWorkflowThread(Integer requestId, Integer userId, String remark, int seconds, Consumer<Boolean> callback) {
|
||||||
if (seconds <= 0) {
|
if (seconds <= 0) {
|
||||||
seconds = 1;
|
seconds = 1;
|
||||||
}
|
}
|
||||||
|
@ -2941,7 +2965,9 @@ public class Util extends weaver.general.Util {
|
||||||
Util.getLogger().error("线程休眠失败", e);
|
Util.getLogger().error("线程休眠失败", e);
|
||||||
}
|
}
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
while (!Util.submitWorkflow(requestId, userId, remark)) {
|
while (!Util.submitWorkflow(requestId, userId, remark)) {
|
||||||
|
log.info("异步提交流程失败,正在进行重试!!");
|
||||||
n++;
|
n++;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000 * 10);
|
Thread.sleep(1000 * 10);
|
||||||
|
@ -2949,10 +2975,17 @@ public class Util extends weaver.general.Util {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (n > 5) {
|
if (n > 5) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.accept(false);
|
||||||
|
}
|
||||||
Util.getLogger().error("异步流程自动提交失败!");
|
Util.getLogger().error("异步流程自动提交失败!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("异步提交流程成功!");
|
||||||
|
if (callback != null) {
|
||||||
|
callback.accept(true);
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4020,4 +4053,30 @@ public class Util extends weaver.general.Util {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String createTempFile(InputStream inputStream, String imageFileName, String tempDir) {
|
||||||
|
String filePath = getTempFilePath(tempDir, imageFileName);
|
||||||
|
try {
|
||||||
|
writeToFile(inputStream, filePath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CustomerException("create temp file error!", e);
|
||||||
|
}
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeToFile(InputStream inputStream, String filePath) throws IOException {
|
||||||
|
Path path = Paths.get(filePath);
|
||||||
|
Path parentDir = path.getParent();
|
||||||
|
if (parentDir != null) {
|
||||||
|
Files.createDirectories(parentDir);
|
||||||
|
}
|
||||||
|
Files.createFile(path);
|
||||||
|
|
||||||
|
try (FileOutputStream outputStream = new FileOutputStream(filePath)) {
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ public abstract class SafeCusBaseAction implements Action {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Util.verifyRequiredField(this);
|
Util.verifyRequiredField(this);
|
||||||
|
log.info("action trigger by " + src);
|
||||||
if (!Strings.isNullOrEmpty(src)) {
|
if (!Strings.isNullOrEmpty(src)) {
|
||||||
src = "submit";
|
src = "submit";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,8 @@ import java.lang.annotation.*;
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface AssociationMethod {
|
public @interface AssociationMethod {
|
||||||
|
|
||||||
int value();
|
int value();
|
||||||
|
|
||||||
|
String desc() default "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,6 @@ import java.lang.annotation.*;
|
||||||
@Documented
|
@Documented
|
||||||
public @interface CollectionMethod {
|
public @interface CollectionMethod {
|
||||||
int value();
|
int value();
|
||||||
|
|
||||||
|
String desc() default "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,28 +17,28 @@ import java.util.List;
|
||||||
|
|
||||||
public class UtilDao {
|
public class UtilDao {
|
||||||
private final RecordSet rs = new RecordSet();
|
private final RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
|
||||||
public ApiConfigMainDTO getApiConfigMain(String id) {
|
public ApiConfigMainDTO getApiConfigMain(String id) {
|
||||||
String query = "select id,workflow_type,api_url,api_name from uf_api_param_config where id = ?";
|
String query = "select id,workflow_type,api_url,api_name from uf_api_param_config where id = ?";
|
||||||
rs.executeQuery(query, id);
|
rs.executeQuery(query, id);
|
||||||
return Util.recordeSet2Entity(rs, ApiConfigMainDTO.class, true);
|
return Util.recordeSet2Entity(rs, ApiConfigMainDTO.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiConfigDetailDTO> getApiConfigDetail(int mainId) {
|
public List<ApiConfigDetailDTO> getApiConfigDetail(int mainId) {
|
||||||
String query = "select dt.id,dt.line_num,dt.param_name,dt.param_type,dt.object_child,dt.parent_line,dt.change_rule, " +
|
String query = "select dt.id,dt.line_num,dt.param_name,dt.param_type,dt.object_child,dt.parent_line,dt.change_rule, " +
|
||||||
"dt.param_value,wf.fieldname workflow_field,wf.tablename tablename,dt.array_sql " +
|
"dt.param_value,wf.fieldname workflow_field,wf.tablename tablename,dt.array_sql " +
|
||||||
"from uf_api_param_config_dt1 dt " +
|
"from uf_api_param_config_dt1 dt " +
|
||||||
"left join workflow_field_table_view wf on wf.id = dt.workflow_field " +
|
"left join workflow_field_table_view wf on wf.id = dt.workflow_field " +
|
||||||
"where mainid = ? and (are_use is null or are_use = 1)";
|
"where mainid = ? and (are_use is null or are_use = 1)";
|
||||||
rs.executeQuery(query, mainId);
|
rs.executeQuery(query, mainId);
|
||||||
return Util.recordeSet2Array(rs, ApiConfigDetailDTO.class, true);
|
return Util.recordeSet2Array(rs, ApiConfigDetailDTO.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MultiLanguageDTO> queryLanguage(int groupId) {
|
public List<MultiLanguageDTO> queryLanguage(int groupId) {
|
||||||
String query = "select * from uf_multi_language_dt1 where mainid = ?";
|
String query = "select * from uf_multi_language_dt1 where mainid = ?";
|
||||||
rs.executeQuery(query, groupId);
|
rs.executeQuery(query, groupId);
|
||||||
return Util.recordeSet2Array(rs, MultiLanguageDTO.class, true);
|
return Util.recordeSet2Array(rs, MultiLanguageDTO.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class PdfUtil {
|
||||||
FileOutputStream outputStreamTem;
|
FileOutputStream outputStreamTem;
|
||||||
try {
|
try {
|
||||||
outputStreamTem = new FileOutputStream(tempPath);
|
outputStreamTem = new FileOutputStream(tempPath);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (Exception e) {
|
||||||
throw new CustomerException("创建临时文件流和路径转换失败!", e);
|
throw new CustomerException("创建临时文件流和路径转换失败!", e);
|
||||||
}
|
}
|
||||||
PdfStamper pdfStamper = null;
|
PdfStamper pdfStamper = null;
|
||||||
|
|
|
@ -45,12 +45,12 @@ public class OtherSystemToOAController {
|
||||||
// 获取重定向地址和secret
|
// 获取重定向地址和secret
|
||||||
Map<String, String> redirectUrlAndCorpsecret = service.getRedirectUrlAndCorpsecret(appId);
|
Map<String, String> redirectUrlAndCorpsecret = service.getRedirectUrlAndCorpsecret(appId);
|
||||||
String redirectUrl = Util.null2DefaultStr(redirectUrlAndCorpsecret.get("REDIRECTURL"),"");
|
String redirectUrl = Util.null2DefaultStr(redirectUrlAndCorpsecret.get("REDIRECTURL"),"");
|
||||||
log.info("successSendRedirectUrl : " + redirectUrl);
|
|
||||||
if(StringUtils.isBlank(redirectUrl)){
|
if(StringUtils.isBlank(redirectUrl)){
|
||||||
throw new CustomerException("redirectUrl is null! " + JSONObject.toJSONString(redirectUrlAndCorpsecret));
|
throw new CustomerException("redirectUrl is null! " + JSONObject.toJSONString(redirectUrlAndCorpsecret));
|
||||||
}
|
}
|
||||||
int userId = service.getUserFromOtherSys(code, redirectUrlAndCorpsecret);
|
int userId = service.getUserFromOtherSys(code, redirectUrlAndCorpsecret);
|
||||||
SessionUtil.createSession(userId + "", request, response);
|
SessionUtil.createSession(String.valueOf(userId), request, response);
|
||||||
|
log.info("successSendRedirectUrl : " + redirectUrl);
|
||||||
response.sendRedirect(redirectUrl);
|
response.sendRedirect(redirectUrl);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("sso error : " + e.getMessage());
|
log.error("sso error : " + e.getMessage());
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.api.xuanran.wang.sh_bigdata.sso.mapper;
|
package com.api.xuanran.wang.sh_bigdata.sso.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
import aiyh.utils.annotation.recordset.Select;
|
import aiyh.utils.annotation.recordset.Select;
|
||||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlString;
|
||||||
|
import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -21,8 +24,8 @@ public interface OtherSystemToOAMapper {
|
||||||
* @param outKey 外键id
|
* @param outKey 外键id
|
||||||
* @return oa ID
|
* @return oa ID
|
||||||
**/
|
**/
|
||||||
@Select("select id from hrmresource where outkey = #{outKey}")
|
@Select(custom = true)
|
||||||
int selectUserIdByOutKey(@ParamMapper("outKey") String outKey);
|
int selectUserIdByOutKey(@SqlString String sql, @ParamMapper("outKey") String outKey);
|
||||||
/**
|
/**
|
||||||
* <h1>根据appId 查跳转的地址</h1>
|
* <h1>根据appId 查跳转的地址</h1>
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
|
|
|
@ -21,7 +21,7 @@ public interface OtherSystemToOAService {
|
||||||
* @param cusSuccess 自定义接口成功/失败标识
|
* @param cusSuccess 自定义接口成功/失败标识
|
||||||
* @return 接口响应字段
|
* @return 接口响应字段
|
||||||
**/
|
**/
|
||||||
int getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret);
|
Object getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret);
|
||||||
/**
|
/**
|
||||||
* <h1>根据第三方系统人员code匹配oa人员id</h1>
|
* <h1>根据第三方系统人员code匹配oa人员id</h1>
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
|
|
|
@ -28,12 +28,13 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService {
|
||||||
.successField("code")
|
.successField("code")
|
||||||
.successValue(0)
|
.successValue(0)
|
||||||
.errorMsg("msg")
|
.errorMsg("msg")
|
||||||
.dataKey("data.id")
|
.dataKey("data." + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoInterfaceCompareField"), "id"))
|
||||||
.build();
|
.build();
|
||||||
private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class);
|
private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class);
|
||||||
private final Logger log = Util.getLogger();
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret) {
|
public Object getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret) {
|
||||||
String secret = Util.null2DefaultStr(redirectUrlSecret.get("SECRET"), "");
|
String secret = Util.null2DefaultStr(redirectUrlSecret.get("SECRET"), "");
|
||||||
log.info("secret : " + secret);
|
log.info("secret : " + secret);
|
||||||
if(StringUtils.isBlank(secret)){
|
if(StringUtils.isBlank(secret)){
|
||||||
|
@ -48,7 +49,7 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService {
|
||||||
params.put("code", code);
|
params.put("code", code);
|
||||||
// 获取第三方系统id
|
// 获取第三方系统id
|
||||||
String getUserInfoByCodeUrl = ShBigDataUtil.getPropertiesValByKey("getUserInfoByCodeUrl");
|
String getUserInfoByCodeUrl = ShBigDataUtil.getPropertiesValByKey("getUserInfoByCodeUrl");
|
||||||
int codeId;
|
Object codeId;
|
||||||
try {
|
try {
|
||||||
codeId = getUserIdByCode(getUserInfoByCodeUrl, params, new HashMap<>(), cusSuccess, redirectUrlSecret);
|
codeId = getUserIdByCode(getUserInfoByCodeUrl, params, new HashMap<>(), cusSuccess, redirectUrlSecret);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
@ -61,10 +62,12 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService {
|
||||||
throw new CustomerException(e.getMessage());
|
throw new CustomerException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(codeId < 0){
|
String oaOutKey = Util.null2DefaultStr(codeId, "");
|
||||||
|
if(StringUtils.isBlank(oaOutKey)){
|
||||||
throw new CustomerException(Util.logStr("code : {}, not found in {} .", code, getUserInfoByCodeUrl));
|
throw new CustomerException(Util.logStr("code : {}, not found in {} .", code, getUserInfoByCodeUrl));
|
||||||
}
|
}
|
||||||
int id = otherSystemToOAMapper.selectUserIdByOutKey(codeId + "");
|
String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}";
|
||||||
|
int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey);
|
||||||
if(id < 0){
|
if(id < 0){
|
||||||
throw new CustomerException(Util.logStr("code : {} not found in OA!", id));
|
throw new CustomerException(Util.logStr("code : {} not found in OA!", id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,58 +18,58 @@ import java.util.List;
|
||||||
|
|
||||||
@SqlMapper
|
@SqlMapper
|
||||||
public interface OrgChartMapper {
|
public interface OrgChartMapper {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>查询所有的在职状态人员</h2>
|
* <h2>查询所有的在职状态人员</h2>
|
||||||
* <i>2022/12/5 11:05</i>
|
* <i>2022/12/5 11:05</i>
|
||||||
* ******************************************
|
* ******************************************
|
||||||
*
|
*
|
||||||
* @param typeOfEmploymentField 人员自定义字段
|
* @param typeOfEmploymentField 人员自定义字段
|
||||||
* @return List<HrmResource> 返回的人员信息
|
* @return List<HrmResource> 返回的人员信息
|
||||||
* @author youHong.ai ******************************************
|
* @author youHong.ai ******************************************
|
||||||
*/
|
*/
|
||||||
@Select("select hrm.id, " +
|
@Select("select hrm.id, " +
|
||||||
" hrm.subcompanyid1 sub_company_id," +
|
" hrm.subcompanyid1 sub_company_id," +
|
||||||
" hrm.messagerurl avatar," +
|
" hrm.messagerurl avatar," +
|
||||||
" (case when cus.$t{lastNameEnField} is null then hrm.lastname " +
|
" (case when cus.$t{lastNameEnField} is null then hrm.lastname " +
|
||||||
" else cus.$t{lastNameEnField} end) last_name, " +
|
" else cus.$t{lastNameEnField} end) last_name, " +
|
||||||
" hrm.managerstr manager_str, " +
|
" hrm.managerstr manager_str, " +
|
||||||
" hrm.jobtitle job_title_id, " +
|
" hrm.jobtitle job_title_id, " +
|
||||||
" hrm.managerid manager_id, " +
|
" hrm.managerid manager_id, " +
|
||||||
" hrm.departmentid department_id, " +
|
" hrm.departmentid department_id, " +
|
||||||
" dept.DEPARTMENTNAME department_name, " +
|
" dept.DEPARTMENTNAME department_name, " +
|
||||||
" job.JOBTITLENAME job_title_name, " +
|
" job.JOBTITLENAME job_title_name, " +
|
||||||
" uftb.$t{parentField} type_of_employment " +
|
" uftb.$t{parentField} type_of_employment " +
|
||||||
"from hrmresource hrm " +
|
"from hrmresource hrm " +
|
||||||
" inner join hrmjobtitles job on hrm.JOBTITLE = job.id " +
|
" left join hrmjobtitles job on hrm.JOBTITLE = job.id " +
|
||||||
" inner join cus_fielddata cus on cus.ID = hrm.ID " +
|
" left join cus_fielddata cus on cus.ID = hrm.ID " +
|
||||||
" and cus.SCOPE = 'HrmCustomFieldByInfoType' " +
|
" and cus.SCOPE = 'HrmCustomFieldByInfoType' " +
|
||||||
" and cus.SCOPEID = 1 " +
|
" and cus.SCOPEID = 1 " +
|
||||||
" inner join cus_fielddata cus1 on cus1.id = hrm.id" +
|
" left join cus_fielddata cus1 on cus1.id = hrm.id" +
|
||||||
" and cus1.scope = 'HrmCustomFieldByInfoType' " +
|
" and cus1.scope = 'HrmCustomFieldByInfoType' " +
|
||||||
" and cus1.scopeid = -1" +
|
" and cus1.scopeid = -1" +
|
||||||
" inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
" left join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
||||||
" inner join $t{typeOfEmploymentTable} uftb on uftb.$t{typeOfEmploymentIdField} = cus1.$t{typeOfEmploymentFiled} " +
|
" left join $t{typeOfEmploymentTable} uftb on uftb.$t{typeOfEmploymentIdField} = cus1.$t{typeOfEmploymentFiled} " +
|
||||||
"where hrm.status in (0, 1)")
|
"where hrm.status in (0, 1)")
|
||||||
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
|
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
|
||||||
@ParamMapper("lastNameEnField") String lastNameEnField,
|
@ParamMapper("lastNameEnField") String lastNameEnField,
|
||||||
@ParamMapper("typeOfEmploymentTable") String typeOfEmploymentTable,
|
@ParamMapper("typeOfEmploymentTable") String typeOfEmploymentTable,
|
||||||
@ParamMapper("parentField") String parentField,
|
@ParamMapper("parentField") String parentField,
|
||||||
@ParamMapper("typeOfEmploymentIdField") String typeOfEmploymentIdField);
|
@ParamMapper("typeOfEmploymentIdField") String typeOfEmploymentIdField);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>查询当前人员配置信息,是否全部展开,是否显示小红点点</h2>
|
* <h2>查询当前人员配置信息,是否全部展开,是否显示小红点点</h2>
|
||||||
* <i>2022/12/5 11:51</i>
|
* <i>2022/12/5 11:51</i>
|
||||||
* ******************************************
|
* ******************************************
|
||||||
*
|
*
|
||||||
* @param userId 当前用户id
|
* @param userId 当前用户id
|
||||||
* @return ShowPointOrAll 展示与否的人员信息
|
* @return ShowPointOrAll 展示与否的人员信息
|
||||||
* @author youHong.ai ******************************************
|
* @author youHong.ai ******************************************
|
||||||
*/
|
*/
|
||||||
@Select("select id,resources,show_all,show_type from uf_show_point_or_all " +
|
@Select("select id,resources,show_all,show_type from uf_show_point_or_all " +
|
||||||
"where concat(',',resources,',') like concat('%,',#{userId},',%')")
|
"where concat(',',resources,',') like concat('%,',#{userId},',%')")
|
||||||
ShowPointOrAll selectShowPointOrAll(@ParamMapper("userId") int userId);
|
ShowPointOrAll selectShowPointOrAll(@ParamMapper("userId") int userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,258 +27,266 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class OrgChartService {
|
public class OrgChartService {
|
||||||
|
|
||||||
private final OrgChartMapper mapper = Util.getMapper(OrgChartMapper.class);
|
private final OrgChartMapper mapper = Util.getMapper(OrgChartMapper.class);
|
||||||
|
|
||||||
private final OrgChartMapStruct struct = OrgChartMapStruct.INSTANCE;
|
private final OrgChartMapStruct struct = OrgChartMapStruct.INSTANCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取人员组织架构图数据</h2>
|
* <h2>获取人员组织架构图数据</h2>
|
||||||
*
|
*
|
||||||
* @param logInUser 当前登陆对象
|
* @param logInUser 当前登陆对象
|
||||||
* @return 组织架构图数据
|
* @return 组织架构图数据
|
||||||
* @author youHong.ai
|
* @author youHong.ai
|
||||||
*/
|
*/
|
||||||
public List<OrgChartNodeVo> getOrgChartTree(User logInUser) {
|
public List<OrgChartNodeVo> getOrgChartTree(User logInUser) {
|
||||||
int userId = logInUser.getUID();
|
int userId = logInUser.getUID();
|
||||||
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
|
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
|
||||||
List<HrmResourceDto> hrmResourceDtoList = getHrmResourceDtoList(userId, currentUser);
|
List<HrmResourceDto> hrmResourceDtoList = getHrmResourceDtoList(userId, currentUser);
|
||||||
/* ******************* 系统管理员默认全部展开哦 ******************* */
|
/* ******************* 系统管理员默认全部展开哦 ******************* */
|
||||||
if (userId == 1) {
|
if (userId == 1) {
|
||||||
return systemAdminTree(hrmResourceDtoList);
|
return systemAdminTree(hrmResourceDtoList);
|
||||||
}
|
}
|
||||||
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
||||||
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
||||||
ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId);
|
ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId);
|
||||||
List<OrgChartNodeVo> orgChartNodeVoList = null;
|
List<OrgChartNodeVo> orgChartNodeVoList = null;
|
||||||
if (Objects.isNull(showPointOrAll)) {
|
if (Objects.isNull(showPointOrAll)) {
|
||||||
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||||
orgChartNodeVoList = hrmResourceDtoList.stream()
|
orgChartNodeVoList = hrmResourceDtoList.stream()
|
||||||
.map(struct::hrmResourceDtoToVo)
|
.map(struct::hrmResourceDtoToVo)
|
||||||
.peek(item -> item.setType(-1))
|
.peek(item -> item.setType(-1))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||||
orgChartNodeVoList = hrmResourceDtoList.stream()
|
orgChartNodeVoList = hrmResourceDtoList.stream()
|
||||||
.map(struct::hrmResourceDtoToVo)
|
.map(struct::hrmResourceDtoToVo)
|
||||||
.peek(item -> {
|
.peek(item -> {
|
||||||
if (showPointOrAll.isShowAll()) {
|
if (showPointOrAll.isShowAll()) {
|
||||||
Builder.startSet(item)
|
Builder.startSet(item)
|
||||||
.with(OrgChartNodeVo::setShow, 1)
|
.with(OrgChartNodeVo::setShow, 1)
|
||||||
.with(OrgChartNodeVo::setShowBrother, 1)
|
.with(OrgChartNodeVo::setShowBrother, 1)
|
||||||
.with(OrgChartNodeVo::setShowChildren, 1)
|
.with(OrgChartNodeVo::setShowChildren, 1)
|
||||||
.endSet();
|
.endSet();
|
||||||
}
|
}
|
||||||
if (!showPointOrAll.isShowType()) {
|
if (!showPointOrAll.isShowType()) {
|
||||||
item.setType(-1);
|
item.setType(-1);
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
}
|
}
|
||||||
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
|
sortByNameFirstLetter(orgChartNodeVoList);
|
||||||
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
|
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
|
||||||
OrgChartNodeVo::setChildren,
|
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
|
||||||
parentId -> parentId == null || parentId <= 0)
|
OrgChartNodeVo::setChildren,
|
||||||
.stream()
|
parentId -> parentId == null || parentId <= 0)
|
||||||
.peek(item -> item.setIsRoot(true))
|
.stream()
|
||||||
.peek(item -> recursionChildrenNums(item, 0))
|
.peek(item -> item.setIsRoot(true))
|
||||||
.collect(Collectors.toList());
|
.peek(item -> recursionChildrenNums(item, 0))
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public static void sortByNameFirstLetter(List<OrgChartNodeVo> nodeList) {
|
||||||
* <h2>getOrgChartTreeAll 获取所有的数据并默认展开</h2>
|
nodeList.sort((node1, node2) -> {
|
||||||
* <i>2022/12/16 17:21</i>
|
String name1 = node1.getName();
|
||||||
* ************************************************************
|
String name2 = node2.getName();
|
||||||
*
|
return name1.compareToIgnoreCase(name2);
|
||||||
* @param logInUser 当前登陆id
|
});
|
||||||
* @return List<OrgChartNodeVo> 最终树
|
}
|
||||||
* @author youHong.ai ******************************************
|
|
||||||
*/
|
/**
|
||||||
public List<OrgChartNodeVo> getOrgChartTreeAll(User logInUser) {
|
* <h2>getOrgChartTreeAll 获取所有的数据并默认展开</h2>
|
||||||
int userId = logInUser.getUID();
|
* <i>2022/12/16 17:21</i>
|
||||||
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
|
* ************************************************************
|
||||||
List<HrmResourceDto> hrmResourceDtoList = getHrmResourceDtoList(userId, currentUser);
|
*
|
||||||
/* ******************* 系统管理员默认全部展开哦 ******************* */
|
* @param logInUser 当前登陆id
|
||||||
if (userId == 1) {
|
* @return List<OrgChartNodeVo> 最终树
|
||||||
return systemAdminTree(hrmResourceDtoList);
|
* @author youHong.ai ******************************************
|
||||||
}
|
*/
|
||||||
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
public List<OrgChartNodeVo> getOrgChartTreeAll(User logInUser) {
|
||||||
List<OrgChartNodeVo> orgChartNodeVoList = null;
|
int userId = logInUser.getUID();
|
||||||
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
|
||||||
orgChartNodeVoList = hrmResourceDtoList.stream()
|
List<HrmResourceDto> hrmResourceDtoList = getHrmResourceDtoList(userId, currentUser);
|
||||||
.map(struct::hrmResourceDtoToVo)
|
/* ******************* 系统管理员默认全部展开哦 ******************* */
|
||||||
.peek(item ->
|
if (userId == 1) {
|
||||||
Builder.startSet(item)
|
return systemAdminTree(hrmResourceDtoList);
|
||||||
.with(OrgChartNodeVo::setShow, 1)
|
}
|
||||||
.with(OrgChartNodeVo::setShowBrother, 1)
|
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
|
||||||
.with(OrgChartNodeVo::setShowChildren, 1)
|
List<OrgChartNodeVo> orgChartNodeVoList = null;
|
||||||
.endSet()
|
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||||
).collect(Collectors.toList());
|
orgChartNodeVoList = hrmResourceDtoList.stream()
|
||||||
|
.map(struct::hrmResourceDtoToVo)
|
||||||
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
|
.peek(item ->
|
||||||
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
|
Builder.startSet(item)
|
||||||
OrgChartNodeVo::setChildren,
|
.with(OrgChartNodeVo::setShow, 1)
|
||||||
parentId -> parentId == null || parentId <= 0)
|
.with(OrgChartNodeVo::setShowBrother, 1)
|
||||||
.stream()
|
.with(OrgChartNodeVo::setShowChildren, 1)
|
||||||
.peek(item -> item.setIsRoot(true))
|
.endSet()
|
||||||
.peek(item -> recursionChildrenNums(item, 0))
|
).collect(Collectors.toList());
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
|
||||||
|
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
|
||||||
|
OrgChartNodeVo::setChildren,
|
||||||
/**
|
parentId -> parentId == null || parentId <= 0)
|
||||||
* <h2>filterCurrentSubCom 过滤当前分部的人员,并且设置用户上级标识</h2>
|
.stream()
|
||||||
* <i>2022/12/16 17:16</i>
|
.peek(item -> item.setIsRoot(true))
|
||||||
* ************************************************************
|
.peek(item -> recursionChildrenNums(item, 0))
|
||||||
*
|
.collect(Collectors.toList());
|
||||||
* @param hrmResourceDtoList 人力资源dtolist
|
}
|
||||||
* @param currentUser 当前用户
|
|
||||||
* @param logInUser 当前登陆用户
|
|
||||||
* @author youHong.ai ******************************************
|
/**
|
||||||
*/
|
* <h2>filterCurrentSubCom 过滤当前分部的人员,并且设置用户上级标识</h2>
|
||||||
private void filterCurrentSubCom(List<HrmResourceDto> hrmResourceDtoList,
|
* <i>2022/12/16 17:16</i>
|
||||||
AtomicReference<HrmResourceDto> currentUser,
|
* ************************************************************
|
||||||
User logInUser) {
|
*
|
||||||
Assert.notNull(currentUser.get(), "not find current login user info!");
|
* @param hrmResourceDtoList 人力资源dtolist
|
||||||
/* ******************* 根据当前登陆人的分部来过滤 ******************* */
|
* @param currentUser 当前用户
|
||||||
hrmResourceDtoList = hrmResourceDtoList.stream()
|
* @param logInUser 当前登陆用户
|
||||||
.filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId())
|
* @author youHong.ai ******************************************
|
||||||
.collect(Collectors.toList());
|
*/
|
||||||
/* ******************* 查找当前登陆人员的所有上级 ******************* */
|
private void filterCurrentSubCom(List<HrmResourceDto> hrmResourceDtoList,
|
||||||
String currentUserManagerStr = currentUser.get().getManagerStr();
|
AtomicReference<HrmResourceDto> currentUser,
|
||||||
if (Objects.isNull(currentUserManagerStr) || "".equals(currentUserManagerStr)) {
|
User logInUser) {
|
||||||
currentUserManagerStr = "0";
|
Assert.notNull(currentUser.get(), "not find current login user info!");
|
||||||
}
|
/* ******************* 根据当前登陆人的分部来过滤 ******************* */
|
||||||
currentUserManagerStr = Util.removeSeparator(currentUserManagerStr, ",");
|
hrmResourceDtoList = hrmResourceDtoList.stream()
|
||||||
List<Integer> currentUserManagerList = Arrays.stream(currentUserManagerStr.split(","))
|
.filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId())
|
||||||
.map(Integer::parseInt)
|
.collect(Collectors.toList());
|
||||||
.collect(Collectors.toList());
|
/* ******************* 查找当前登陆人员的所有上级 ******************* */
|
||||||
/* ******************* 对当前用户的所有直接上级设置标识 ******************* */
|
String currentUserManagerStr = currentUser.get().getManagerStr();
|
||||||
hrmResourceDtoList.stream()
|
if (Objects.isNull(currentUserManagerStr) || "".equals(currentUserManagerStr)) {
|
||||||
.filter(item -> currentUserManagerList.contains(item.getId()))
|
currentUserManagerStr = "0";
|
||||||
.forEach(item -> Builder.startSet(item)
|
}
|
||||||
.with(HrmResourceDto::setShowChildren, 1)
|
currentUserManagerStr = Util.removeSeparator(currentUserManagerStr, ",");
|
||||||
.with(HrmResourceDto::setCurrentParent, true)
|
List<Integer> currentUserManagerList = Arrays.stream(currentUserManagerStr.split(","))
|
||||||
.endSet());
|
.map(Integer::parseInt)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
/* ******************* 对当前用户的所有直接上级设置标识 ******************* */
|
||||||
|
hrmResourceDtoList.stream()
|
||||||
|
.filter(item -> currentUserManagerList.contains(item.getId()))
|
||||||
/**
|
.forEach(item -> Builder.startSet(item)
|
||||||
* <h2>systemAdminTree 系统管理员返回全部展开的数据</h2>
|
.with(HrmResourceDto::setShowChildren, 1)
|
||||||
* <i>2022/12/16 17:15</i>
|
.with(HrmResourceDto::setCurrentParent, true)
|
||||||
* ************************************************************
|
.endSet());
|
||||||
*
|
|
||||||
* @param hrmResourceDtoList 人力资源dtolist
|
}
|
||||||
* @return List<OrgChartNodeVo> 树型list
|
|
||||||
* @author youHong.ai ******************************************
|
|
||||||
*/
|
/**
|
||||||
private List<OrgChartNodeVo> systemAdminTree(List<HrmResourceDto> hrmResourceDtoList) {
|
* <h2>systemAdminTree 系统管理员返回全部展开的数据</h2>
|
||||||
List<OrgChartNodeVo> collect = hrmResourceDtoList.stream()
|
* <i>2022/12/16 17:15</i>
|
||||||
.map(struct::hrmResourceDtoToVo)
|
* ************************************************************
|
||||||
.peek(item -> Builder.startSet(item)
|
*
|
||||||
.with(OrgChartNodeVo::setShow, 1)
|
* @param hrmResourceDtoList 人力资源dtolist
|
||||||
.with(OrgChartNodeVo::setShowBrother, 1)
|
* @return List<OrgChartNodeVo> 树型list
|
||||||
.with(OrgChartNodeVo::setShowChildren, 1)
|
* @author youHong.ai ******************************************
|
||||||
.with(OrgChartNodeVo::setCurrent, true)
|
*/
|
||||||
.endSet())
|
private List<OrgChartNodeVo> systemAdminTree(List<HrmResourceDto> hrmResourceDtoList) {
|
||||||
.collect(Collectors.toList());
|
List<OrgChartNodeVo> collect = hrmResourceDtoList.stream()
|
||||||
return Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
.map(struct::hrmResourceDtoToVo)
|
||||||
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
|
.peek(item -> Builder.startSet(item)
|
||||||
parentId -> parentId == null || parentId <= 0)
|
.with(OrgChartNodeVo::setShow, 1)
|
||||||
.stream().peek(item -> Builder.startSet(item)
|
.with(OrgChartNodeVo::setShowBrother, 1)
|
||||||
.with(OrgChartNodeVo::setIsRoot, true)
|
.with(OrgChartNodeVo::setShowChildren, 1)
|
||||||
.with(OrgChartNodeVo::setCurrent, true)
|
.with(OrgChartNodeVo::setCurrent, true)
|
||||||
.endSet())
|
.endSet())
|
||||||
.peek(item -> recursionChildrenNums(item, 0))
|
.collect(Collectors.toList());
|
||||||
.collect(Collectors.toList());
|
return Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
|
||||||
}
|
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
|
||||||
|
parentId -> parentId == null || parentId <= 0)
|
||||||
/**
|
.stream().peek(item -> Builder.startSet(item)
|
||||||
* <h2>getHrmResourceDtoList 获取人力资源dto对象list</h2>
|
.with(OrgChartNodeVo::setIsRoot, true)
|
||||||
* <i>2022/12/16 17:09</i>
|
.with(OrgChartNodeVo::setCurrent, true)
|
||||||
* ************************************************************
|
.endSet())
|
||||||
*
|
.peek(item -> recursionChildrenNums(item, 0))
|
||||||
* @param userId 当前登陆用户ID
|
.collect(Collectors.toList());
|
||||||
* @param currentUser 当前登陆用户对象
|
}
|
||||||
* @return List<HrmResourceDto> 人力资源dto对象list
|
|
||||||
* @author youHong.ai ******************************************
|
/**
|
||||||
*/
|
* <h2>getHrmResourceDtoList 获取人力资源dto对象list</h2>
|
||||||
private List<HrmResourceDto> getHrmResourceDtoList(Integer userId, AtomicReference<HrmResourceDto> currentUser) {
|
* <i>2022/12/16 17:09</i>
|
||||||
// 人员类型自定义字段
|
* ************************************************************
|
||||||
String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField");
|
*
|
||||||
Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!");
|
* @param userId 当前登陆用户ID
|
||||||
// 英文自定义名称字段
|
* @param currentUser 当前登陆用户对象
|
||||||
String lastNameEnField = Util.getCusConfigValue("lastNameEnField");
|
* @return List<HrmResourceDto> 人力资源dto对象list
|
||||||
Assert.notBlank(lastNameEnField, "config [lastNameEnField] is null or blank!");
|
* @author youHong.ai ******************************************
|
||||||
// 人员类型id字段 建模表
|
*/
|
||||||
String typeOfEmploymentIdField = Util.getCusConfigValue("typeOfEmploymentIdField");
|
private List<HrmResourceDto> getHrmResourceDtoList(Integer userId, AtomicReference<HrmResourceDto> currentUser) {
|
||||||
Assert.notBlank(typeOfEmploymentIdField, "config [typeOfEmploymentIdField] is null or blank!");
|
// 人员类型自定义字段
|
||||||
// 人员类型父级字段 建模表
|
String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField");
|
||||||
String parentField = Util.getCusConfigValue("parentField");
|
Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!");
|
||||||
Assert.notBlank(parentField, "config [parentField] is null or blank!");
|
// 英文自定义名称字段
|
||||||
// 人员类型建模表表名
|
String lastNameEnField = Util.getCusConfigValue("lastNameEnField");
|
||||||
String typeOfEmploymentTable = Util.getCusConfigValue("typeOfEmploymentTable");
|
Assert.notBlank(lastNameEnField, "config [lastNameEnField] is null or blank!");
|
||||||
Assert.notBlank(typeOfEmploymentTable, "config [typeOfEmploymentTable] is null or blank!");
|
// 人员类型id字段 建模表
|
||||||
// 查询所有人员信息
|
String typeOfEmploymentIdField = Util.getCusConfigValue("typeOfEmploymentIdField");
|
||||||
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField,
|
Assert.notBlank(typeOfEmploymentIdField, "config [typeOfEmploymentIdField] is null or blank!");
|
||||||
typeOfEmploymentTable, parentField, typeOfEmploymentIdField);
|
// 人员类型父级字段 建模表
|
||||||
if (Objects.isNull(hrmResourceList) || hrmResourceList.isEmpty()) {
|
String parentField = Util.getCusConfigValue("parentField");
|
||||||
throw new CustomerException("查询不到相关人员!");
|
Assert.notBlank(parentField, "config [parentField] is null or blank!");
|
||||||
}
|
// 人员类型建模表表名
|
||||||
//List<HrmResourceDto> hrmResourceDtoList = new ArrayList();
|
String typeOfEmploymentTable = Util.getCusConfigValue("typeOfEmploymentTable");
|
||||||
/* ******************* 将pojo转换为Dto对象,对节点属性默认值赋值,找出当前用户并设置显示 ******************* */
|
Assert.notBlank(typeOfEmploymentTable, "config [typeOfEmploymentTable] is null or blank!");
|
||||||
List<HrmResourceDto> hrmResourceDtoList = hrmResourceList.stream()
|
// 查询所有人员信息
|
||||||
.map(struct::hrmResourceToDto)
|
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField,
|
||||||
.peek(item -> Builder.startSet(item)
|
typeOfEmploymentTable, parentField, typeOfEmploymentIdField);
|
||||||
.with(HrmResourceDto::setShow, 0)
|
if (Objects.isNull(hrmResourceList) || hrmResourceList.isEmpty()) {
|
||||||
.with(HrmResourceDto::setShowBrother, 0)
|
throw new CustomerException("查询不到相关人员!");
|
||||||
.with(HrmResourceDto::setShowChildren, 0)
|
}
|
||||||
.endSet())
|
// List<HrmResourceDto> hrmResourceDtoList = new ArrayList();
|
||||||
.collect(Collectors.toList());
|
/* ******************* 将pojo转换为Dto对象,对节点属性默认值赋值,找出当前用户并设置显示 ******************* */
|
||||||
hrmResourceDtoList.stream()
|
List<HrmResourceDto> hrmResourceDtoList = hrmResourceList.stream()
|
||||||
.peek(item -> {
|
.map(struct::hrmResourceToDto)
|
||||||
if (Objects.equals(item.getManagerId(), userId)) {
|
.peek(item -> Builder.startSet(item)
|
||||||
item.setShow(1);
|
.with(HrmResourceDto::setShow, 0)
|
||||||
}
|
.with(HrmResourceDto::setShowBrother, 0)
|
||||||
})
|
.with(HrmResourceDto::setShowChildren, 0)
|
||||||
.filter(item -> Objects.equals(item.getId(), userId))
|
.endSet())
|
||||||
.forEach(item -> {
|
.collect(Collectors.toList());
|
||||||
Builder.startSet(item)
|
hrmResourceDtoList.stream()
|
||||||
.with(HrmResourceDto::setShow, 1)
|
.peek(item -> {
|
||||||
.with(HrmResourceDto::setShowBrother, 1)
|
if (Objects.equals(item.getManagerId(), userId)) {
|
||||||
.with(HrmResourceDto::setShowChildren, 1)
|
item.setShow(1);
|
||||||
.with(HrmResourceDto::setCurrent, true)
|
}
|
||||||
.endSet();
|
})
|
||||||
currentUser.set(item);
|
.filter(item -> Objects.equals(item.getId(), userId))
|
||||||
});
|
.forEach(item -> {
|
||||||
return hrmResourceDtoList;
|
Builder.startSet(item)
|
||||||
}
|
.with(HrmResourceDto::setShow, 1)
|
||||||
|
.with(HrmResourceDto::setShowBrother, 1)
|
||||||
/**
|
.with(HrmResourceDto::setShowChildren, 1)
|
||||||
* <h2>计算节点所有子节点的数量</h2>
|
.with(HrmResourceDto::setCurrent, true)
|
||||||
* <i>2022/12/3 17:55</i>
|
.endSet();
|
||||||
* ******************************************
|
currentUser.set(item);
|
||||||
*
|
});
|
||||||
* @param chartNodeVo 节点对象
|
return hrmResourceDtoList;
|
||||||
* @return Integer 对应节点的所有子节点的数量
|
}
|
||||||
* @author youHong.ai ******************************************
|
|
||||||
*/
|
/**
|
||||||
private Integer recursionChildrenNums(OrgChartNodeVo chartNodeVo, int n) {
|
* <h2>计算节点所有子节点的数量</h2>
|
||||||
List<OrgChartNodeVo> children = chartNodeVo.getChildren();
|
* <i>2022/12/3 17:55</i>
|
||||||
if (Objects.isNull(children) || children.size() == 0) {
|
* ******************************************
|
||||||
chartNodeVo.setChildrenNum(0);
|
*
|
||||||
return 0;
|
* @param chartNodeVo 节点对象
|
||||||
}
|
* @return Integer 对应节点的所有子节点的数量
|
||||||
n += children.size();
|
* @author youHong.ai ******************************************
|
||||||
for (OrgChartNodeVo child : children) {
|
*/
|
||||||
child.setChildrenNum(recursionChildrenNums(child, 0));
|
private Integer recursionChildrenNums(OrgChartNodeVo chartNodeVo, int n) {
|
||||||
n += child.getChildrenNum();
|
List<OrgChartNodeVo> children = chartNodeVo.getChildren();
|
||||||
}
|
if (Objects.isNull(children) || children.size() == 0) {
|
||||||
chartNodeVo.setChildrenNum(n);
|
chartNodeVo.setChildrenNum(0);
|
||||||
return n;
|
return 0;
|
||||||
}
|
}
|
||||||
|
n += children.size();
|
||||||
|
for (OrgChartNodeVo child : children) {
|
||||||
|
child.setChildrenNum(recursionChildrenNums(child, 0));
|
||||||
|
n += child.getChildrenNum();
|
||||||
|
}
|
||||||
|
chartNodeVo.setChildrenNum(n);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ public class SsoYunZhaoService {
|
||||||
Method method = User.class.getMethod(userCodeMethod);
|
Method method = User.class.getMethod(userCodeMethod);
|
||||||
String value = Util.null2String(method.invoke(user));
|
String value = Util.null2String(method.invoke(user));
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
String token = this.rsaEncryptedUserInfo(value + "\"" + String.valueOf(currentTime).substring(0, 10));
|
String str = value + "\"" + String.valueOf(currentTime).substring(0, 10);
|
||||||
|
String token = this.rsaEncryptedUserInfo(str);
|
||||||
String yunZhaoSsoPathUrl = Util.getCusConfigValue("YunZhaoSSOPathURL");
|
String yunZhaoSsoPathUrl = Util.getCusConfigValue("YunZhaoSSOPathURL");
|
||||||
Assert.notEmpty(yunZhaoSsoPathUrl, "can not find [YunZhaoSSOPathURL] from table [uf_cus_dev_config]");
|
Assert.notEmpty(yunZhaoSsoPathUrl, "can not find [YunZhaoSSOPathURL] from table [uf_cus_dev_config]");
|
||||||
return yunZhaoSsoPathUrl + URLEncoder.encode(token, "UTF-8");
|
return yunZhaoSsoPathUrl + URLEncoder.encode(token, "UTF-8");
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.poi.xssf.streaming.SXSSFCell;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFRow;
|
import org.apache.poi.xssf.streaming.SXSSFRow;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
@ -46,6 +47,8 @@ public class OpenTheBillService {
|
||||||
|
|
||||||
private final Logger log = Util.getLogger();
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
private final RecordSet res = new RecordSet();
|
||||||
|
|
||||||
public Map<String, Object> getOpenBillListData(String startDate, String endDate, String orderNo) {
|
public Map<String, Object> getOpenBillListData(String startDate, String endDate, String orderNo) {
|
||||||
return getData(startDate, endDate, orderNo);
|
return getData(startDate, endDate, orderNo);
|
||||||
}
|
}
|
||||||
|
@ -150,6 +153,7 @@ public class OpenTheBillService {
|
||||||
SXSSFCell cell,
|
SXSSFCell cell,
|
||||||
SXSSFSheet sheet, Map<Integer, CellStyle> singularLine, Map<Integer, CellStyle> evenNumberLine) {
|
SXSSFSheet sheet, Map<Integer, CellStyle> singularLine, Map<Integer, CellStyle> evenNumberLine) {
|
||||||
|
|
||||||
|
|
||||||
int columnWidth = sheet.getColumnWidth(colIndex);
|
int columnWidth = sheet.getColumnWidth(colIndex);
|
||||||
String value = cell.getStringCellValue();
|
String value = cell.getStringCellValue();
|
||||||
/** 计算字符串中中文字符的数量 */
|
/** 计算字符串中中文字符的数量 */
|
||||||
|
@ -160,27 +164,17 @@ public class OpenTheBillService {
|
||||||
if (length >= columnWidth && length < 256 * 256) {
|
if (length >= columnWidth && length < 256 * 256) {
|
||||||
sheet.setColumnWidth(colIndex, length);
|
sheet.setColumnWidth(colIndex, length);
|
||||||
}
|
}
|
||||||
if (rowIndex % 2 == 1) {
|
if (singularLine.containsKey(-1)) {
|
||||||
if (singularLine.containsKey(colIndex)) {
|
return singularLine.get(-1);
|
||||||
return singularLine.get(colIndex);
|
|
||||||
}
|
|
||||||
CellStyle cellStyle = getCellStyle(workbook, rowIndex, colIndex, cell, sheet);
|
|
||||||
singularLine.put(colIndex, cellStyle);
|
|
||||||
return cellStyle;
|
|
||||||
} else {
|
|
||||||
if (evenNumberLine.containsKey(colIndex)) {
|
|
||||||
return evenNumberLine.get(colIndex);
|
|
||||||
}
|
|
||||||
CellStyle cellStyle = getCellStyle(workbook, rowIndex, colIndex, cell, sheet);
|
|
||||||
// 设置字体格式
|
|
||||||
Font font = workbook.createFont();
|
|
||||||
font.setFontName("微软雅黑");
|
|
||||||
font.setFontHeightInPoints((short) 10);
|
|
||||||
|
|
||||||
cellStyle.setFont(font);
|
|
||||||
evenNumberLine.put(colIndex, cellStyle);
|
|
||||||
return cellStyle;
|
|
||||||
}
|
}
|
||||||
|
// 设置字体格式
|
||||||
|
Font font = workbook.createFont();
|
||||||
|
font.setFontName("微软雅黑");
|
||||||
|
font.setFontHeightInPoints((short) 10);
|
||||||
|
CellStyle cellStyle = getCellStyle(workbook, rowIndex, colIndex, cell, sheet);
|
||||||
|
cellStyle.setFont(font);
|
||||||
|
singularLine.put(-1, cellStyle);
|
||||||
|
return cellStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CellStyle getCellStyle(SXSSFWorkbook workbook, Integer rowIndex, Integer colIndex, SXSSFCell cell, SXSSFSheet sheet) {
|
private CellStyle getCellStyle(SXSSFWorkbook workbook, Integer rowIndex, Integer colIndex, SXSSFCell cell, SXSSFSheet sheet) {
|
||||||
|
@ -232,6 +226,16 @@ public class OpenTheBillService {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> findMapByField(String filterString, List<Map<String, Object>> list) {
|
||||||
|
for (Map<String, Object> map : list) {
|
||||||
|
if (map.containsKey("field") && map.get("field").equals(filterString)) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果找不到匹配的 Map,则返回 null
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Object> getData(String startDate, String endDate, String orderNo) {
|
public Map<String, Object> getData(String startDate, String endDate, String orderNo) {
|
||||||
Map<String, Object> config = Util.readProperties2Map("esteeLauderExcelExport", "export");
|
Map<String, Object> config = Util.readProperties2Map("esteeLauderExcelExport", "export");
|
||||||
Assert.notEmpty(config, "esteeLauderExcelExport.properties文件读取配置为空,请检查配置信息");
|
Assert.notEmpty(config, "esteeLauderExcelExport.properties文件读取配置为空,请检查配置信息");
|
||||||
|
@ -246,7 +250,8 @@ public class OpenTheBillService {
|
||||||
Util.null2String(config.get("createDate")),
|
Util.null2String(config.get("createDate")),
|
||||||
condition);
|
condition);
|
||||||
} else {
|
} else {
|
||||||
dataList = mapper.selectList(Util.null2String(config.get("tableName")));
|
// dataList = mapper.selectList(Util.null2String(config.get("tableName")));
|
||||||
|
dataList = Collections.emptyList();
|
||||||
}
|
}
|
||||||
Object head = config.get("head");
|
Object head = config.get("head");
|
||||||
Map<String, Object> result = new HashMap<>(16);
|
Map<String, Object> result = new HashMap<>(16);
|
||||||
|
@ -309,6 +314,7 @@ public class OpenTheBillService {
|
||||||
if (finalBgm.equals("Y")) {
|
if (finalBgm.equals("Y")) {
|
||||||
// 都过了bgm
|
// 都过了bgm
|
||||||
for (Map<String, Object> item : list) {
|
for (Map<String, Object> item : list) {
|
||||||
|
item.put(Util.null2String(config.get("additional")), "");
|
||||||
item.put(Util.null2String(config.get("openBillKey")), "");
|
item.put(Util.null2String(config.get("openBillKey")), "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -319,6 +325,7 @@ public class OpenTheBillService {
|
||||||
// 不全部都是y或者n
|
// 不全部都是y或者n
|
||||||
for (Map<String, Object> item : list) {
|
for (Map<String, Object> item : list) {
|
||||||
item.put(Util.null2String(config.get("openBillKey")), "全部订单总金额达到GM审批标准,拆分后无法到达GM审批节点。");
|
item.put(Util.null2String(config.get("openBillKey")), "全部订单总金额达到GM审批标准,拆分后无法到达GM审批节点。");
|
||||||
|
item.put(Util.null2String(config.get("additional")), "此单为系统判定疑似拆单");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,10 +407,12 @@ public class OpenTheBillService {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
for (Map<String, Object> item : list) {
|
for (Map<String, Object> item : list) {
|
||||||
item.put(Util.null2String(config.get("openBillKey")), "全部订单总金额达到GM审批标准,拆分后无法到达GM审批节点。");
|
item.put(Util.null2String(config.get("openBillKey")), "全部订单总金额达到GM审批标准,拆分后无法到达GM审批节点。");
|
||||||
|
item.put(Util.null2String(config.get("additional")), "此单为系统判定疑似拆单");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Map<String, Object> item : list) {
|
for (Map<String, Object> item : list) {
|
||||||
item.put(Util.null2String(config.get("openBillKey")), "");
|
item.put(Util.null2String(config.get("openBillKey")), "");
|
||||||
|
item.put(Util.null2String(config.get("additional")), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,6 +477,7 @@ public class OpenTheBillService {
|
||||||
|
|
||||||
|
|
||||||
private void calculationCondition(List<Map<String, Object>> dataList, Map<String, Object> config) {
|
private void calculationCondition(List<Map<String, Object>> dataList, Map<String, Object> config) {
|
||||||
|
Map<String, Object> convert = (Map<String, Object>) config.get("convert");
|
||||||
for (Map<String, Object> map : dataList) {
|
for (Map<String, Object> map : dataList) {
|
||||||
// 订单分类
|
// 订单分类
|
||||||
String orderType = Util.null2String(map.get(Util.null2String(config.get("orderType"))));
|
String orderType = Util.null2String(map.get(Util.null2String(config.get("orderType"))));
|
||||||
|
@ -485,7 +495,7 @@ public class OpenTheBillService {
|
||||||
// 内部领用
|
// 内部领用
|
||||||
// orderUse + " " + shipTo + " " + costCenter + " " + sku
|
// orderUse + " " + shipTo + " " + costCenter + " " + sku
|
||||||
// condition = "订单用途:" + orderUse + " " + "ShipTo:" + shipTo + " CostCenter:" + costCenter + " sku:" + sku;
|
// condition = "订单用途:" + orderUse + " " + "ShipTo:" + shipTo + " CostCenter:" + costCenter + " sku:" + sku;
|
||||||
condition = orderUse + " :" + shipTo + ":" + costCenter + ":" + sku;
|
condition = "订单用途:" + orderUse + "、" + "shipTo:" + shipTo + "、" + "CostCenter:" + costCenter + "、" + "sku:" + sku;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "1":
|
case "1":
|
||||||
|
@ -494,13 +504,28 @@ public class OpenTheBillService {
|
||||||
// 第三方 + 柜台订单
|
// 第三方 + 柜台订单
|
||||||
// orderUse + ":" + shipTo + ":" + sku
|
// orderUse + ":" + shipTo + ":" + sku
|
||||||
// condition = "订单用途:" + orderUse + " " + "ShipTo:" + shipTo + " sku:" + sku + " 订单分类:" + orderType;
|
// condition = "订单用途:" + orderUse + " " + "ShipTo:" + shipTo + " sku:" + sku + " 订单分类:" + orderType;
|
||||||
condition = orderUse + ":" + shipTo + ":" + sku + ":" + orderType;
|
condition = "订单用途:" + orderUse + "、" + "shipTo:" + shipTo + "、" + "sku:" + sku + "、" + "订单分类:" + orderType;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
map.put(Util.null2String(config.get("additional")), "");
|
||||||
map.put(Util.null2String(config.get("conditionKey")), condition);
|
map.put(Util.null2String(config.get("conditionKey")), condition);
|
||||||
|
if (Objects.nonNull(convert)) {
|
||||||
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
|
if (convert.containsKey(entry.getKey())) {
|
||||||
|
String sql = Util.null2String(convert.get(entry.getKey()));
|
||||||
|
if (StrUtil.isNotBlank(sql)) {
|
||||||
|
res.executeQuery(sql, entry.getValue());
|
||||||
|
if (res.next()) {
|
||||||
|
entry.setValue(res.getInt(1));
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -47,8 +48,10 @@ public class SingleSignOnController {
|
||||||
Map<String, Object> param = new HashMap<>(8);
|
Map<String, Object> param = new HashMap<>(8);
|
||||||
param.put("user", value);
|
param.put("user", value);
|
||||||
param.put("ts", System.currentTimeMillis());
|
param.put("ts", System.currentTimeMillis());
|
||||||
String encrypt = AES.encrypt(key, initVector, JSON.toJSONString(param));
|
String json = JSON.toJSONString(param);
|
||||||
response.sendRedirect(url + "?params=" + encrypt);
|
String encrypt = AES.encrypt(key, initVector, json);
|
||||||
|
Util.getLogger().info("加密内容: " + json + " 加密结果: " + encrypt);
|
||||||
|
response.sendRedirect(url + "?params=" + URLEncoder.encode(encrypt, "UTF-8"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("单点登录路径处理失败!" + e.getMessage() + "\n" + Util.getErrString(e));
|
log.error("单点登录路径处理失败!" + e.getMessage() + "\n" + Util.getErrString(e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.customization.youhong.taibao.trisubreq.impl;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestEntity;
|
||||||
|
import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataConfig;
|
||||||
|
import com.engine.core.cfg.annotation.ServiceDynamicProxy;
|
||||||
|
import com.engine.core.impl.aop.AbstractServiceProxy;
|
||||||
|
import com.engine.workflow.service.SubRequestService;
|
||||||
|
import com.engine.workflow.service.impl.SubRequestServiceImpl;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.workflow.request.DiffWfTriggerSetting;
|
||||||
|
import weaver.workflow.request.SameWfTriggerSetting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>触发子流程</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/24 22:52</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@ServiceDynamicProxy(target = SubRequestServiceImpl.class, desc = "拦截签字意见信息,是否需要隐私控制")
|
||||||
|
public class TriSubRequestAfterInterceptImpl extends AbstractServiceProxy implements SubRequestService {
|
||||||
|
|
||||||
|
private final TriSubRequestAfterMapper mapper = Util.getMapper(TriSubRequestAfterMapper.class);
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void triSameSubRequestBefore(int i, List<SameWfTriggerSetting> list) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void triDiffSubRequestBefore(int i, List<DiffWfTriggerSetting> list) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void triSubRequestAfter(int i) {
|
||||||
|
List<SubRequestEntity> subRequestEntities = mapper.selectSubRequestByMainRequest(i);
|
||||||
|
if (CollectionUtil.isEmpty(subRequestEntities)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SubRequestToDataConfig> subRequestToDataConfigs = mapper.selectConfig();
|
||||||
|
if (CollectionUtil.isEmpty(subRequestToDataConfigs)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, SubRequestToDataConfig> collect = subRequestToDataConfigs
|
||||||
|
.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
SubRequestToDataConfig::getWorkflowType,
|
||||||
|
value -> value
|
||||||
|
));
|
||||||
|
|
||||||
|
List<Map<String, Object>> requestDataList = new ArrayList<>();
|
||||||
|
for (SubRequestEntity subRequestEntity : subRequestEntities) {
|
||||||
|
// 查询流程对应的配置信息
|
||||||
|
Map<String, Object> requestData = getRequestData(subRequestEntity);
|
||||||
|
requestDataList.add(requestData);
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isEmpty(requestDataList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, Object> mainRequestData = mapper.selectRequestBase(Util.null2String(i));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> getRequestData(SubRequestEntity subRequestEntity) {
|
||||||
|
String tableName = subRequestEntity.getWorkflowTable();
|
||||||
|
Map<String, Object> requestData = mapper.selectWorkflowData(tableName, subRequestEntity.getRequestId());
|
||||||
|
Map<String, Object> requestBaseData = mapper.selectRequestBase(subRequestEntity.getRequestId());
|
||||||
|
if (CollectionUtil.isEmpty(requestBaseData)) {
|
||||||
|
throw new CustomerException("查询流程基本信息失败!");
|
||||||
|
}
|
||||||
|
requestBaseData.putAll(requestData);
|
||||||
|
return requestBaseData;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
package com.customization.youhong.taibao.trisubreq.impl;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.*;
|
||||||
|
import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestEntity;
|
||||||
|
import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataConfig;
|
||||||
|
import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>sql查询</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/24 23:09</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@SqlMapper
|
||||||
|
public interface TriSubRequestAfterMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询子流程信息</h2>
|
||||||
|
*
|
||||||
|
* @param mainRequestId 主流程信息
|
||||||
|
* @return 子流程信息
|
||||||
|
*/
|
||||||
|
@Select("select requestid request_id,workflowid workflow_id from " +
|
||||||
|
"workflow_requestbase where mainrequestid = #{mainRequestId}")
|
||||||
|
@Associations({
|
||||||
|
@Association(
|
||||||
|
property = "workflowTable",
|
||||||
|
column = "workflowid",
|
||||||
|
id = @Id(value = String.class, methodId = 2)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
List<SubRequestEntity> selectSubRequestByMainRequest(@ParamMapper("mainRequestId") Integer mainRequestId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询流程表名</h2>
|
||||||
|
*
|
||||||
|
* @param billId 流程表id
|
||||||
|
* @return 流程表
|
||||||
|
*/
|
||||||
|
@Select("select tablename workflow_table from workflow_base wb\n" +
|
||||||
|
"inner join workflow_table_view wv on wv.id = wb.id\n" +
|
||||||
|
"where wb.id = #{billId}")
|
||||||
|
@AssociationMethod(value = 2, desc = "查询流程对应的表表名")
|
||||||
|
String selectWorkflowTable(@ParamMapper("billId") String billId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询配置表信息</h2>
|
||||||
|
*
|
||||||
|
* @return 配置表信息
|
||||||
|
*/
|
||||||
|
@Select("select * from uf_sub_wf_to_mode")
|
||||||
|
@Associations({
|
||||||
|
@Association(
|
||||||
|
property = "modelTableName",
|
||||||
|
column = "model_table",
|
||||||
|
select = "aiyh.utils.mapper.UtilMapper.selectModelTableInfo",
|
||||||
|
id = @Id(value = Integer.class)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
@CollectionMappings({
|
||||||
|
@CollectionMapping(
|
||||||
|
property = "mappings",
|
||||||
|
column = "id",
|
||||||
|
id = @Id(value = String.class, methodId = 1)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
List<SubRequestToDataConfig> selectConfig();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询配置表明细信息</h2>
|
||||||
|
*
|
||||||
|
* @param mainId 主表id
|
||||||
|
* @return 明细数据
|
||||||
|
*/
|
||||||
|
@CollectionMethod(value = 1, desc = "查询配置表明细信息")
|
||||||
|
@Select("select * from uf_sub_wf_to_mode_dt1 where mainid = #{mainId}")
|
||||||
|
@Associations({
|
||||||
|
@Association(
|
||||||
|
property = "modelField",
|
||||||
|
column = "model_field",
|
||||||
|
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||||
|
id = @Id(value = Integer.class)
|
||||||
|
),
|
||||||
|
@Association(
|
||||||
|
property = "workflowField",
|
||||||
|
column = "workflow_field",
|
||||||
|
select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo",
|
||||||
|
id = @Id(value = Integer.class)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
List<SubRequestToDataMapping> selectConfigDt(String mainId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询流程数据</h2>
|
||||||
|
*
|
||||||
|
* @param tableName 表名称
|
||||||
|
* @param requestId 请求id
|
||||||
|
* @return 流程数据
|
||||||
|
*/
|
||||||
|
@Select("select $t{tableName} where requestid = #{requestId}")
|
||||||
|
Map<String, Object> selectWorkflowData(@ParamMapper("tableName") String tableName, @ParamMapper("requestId") String requestId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>查询流程信息</h2>
|
||||||
|
*
|
||||||
|
* @param requestId 流程id
|
||||||
|
* @return 流程信息
|
||||||
|
*/
|
||||||
|
@Select("select * from workflow_requestbase where requestid = #{requestId}")
|
||||||
|
Map<String, Object> selectRequestBase(@ParamMapper("requestId") String requestId);
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.customization.youhong.taibao.trisubreq.impl.entity;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>子流程实体类</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/24 23:13</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class SubRequestEntity {
|
||||||
|
@SqlOracleDbFieldAnn("REQUEST_ID")
|
||||||
|
private String requestId;
|
||||||
|
@SqlOracleDbFieldAnn("WORKFLOW_ID")
|
||||||
|
private String workflowId;
|
||||||
|
|
||||||
|
@SqlOracleDbFieldAnn("WORKFLOW_TABLE")
|
||||||
|
private String workflowTable;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.customization.youhong.taibao.trisubreq.impl.entity;
|
||||||
|
|
||||||
|
import aiyh.utils.entity.ModelTableInfo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>配置表实体类</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/29 10:31</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class SubRequestToDataConfig {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 流程 */
|
||||||
|
private String workflowType;
|
||||||
|
/** 建模 */
|
||||||
|
private String modelTable;
|
||||||
|
/** 更新条件 */
|
||||||
|
private String conditionUpdate;
|
||||||
|
|
||||||
|
/** 建模表 */
|
||||||
|
private ModelTableInfo modelTableName;
|
||||||
|
|
||||||
|
private List<SubRequestToDataMapping> mappings;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.customization.youhong.taibao.trisubreq.impl.entity;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
|
||||||
|
import aiyh.utils.entity.FieldViewInfo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>字段映射</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/29 10:37</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class SubRequestToDataMapping {
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@SqlDbFieldAnn("mainid")
|
||||||
|
private Integer mainId;
|
||||||
|
|
||||||
|
/** 建模字段 */
|
||||||
|
private FieldViewInfo modelField;
|
||||||
|
/** 流程字段 */
|
||||||
|
private FieldViewInfo workflowField;
|
||||||
|
}
|
|
@ -0,0 +1,156 @@
|
||||||
|
package com.engine.yunjinshan.modeDelete.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
|
||||||
|
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
|
||||||
|
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceBefore;
|
||||||
|
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
|
||||||
|
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaBeforeReplaceParam;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.file.Prop;
|
||||||
|
import weaver.general.BaseBean;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.yunjinshan.formmode.action.CostIncomeUpdate;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云锦山
|
||||||
|
* 建模记录删除方法拦截方法
|
||||||
|
*/
|
||||||
|
@WeaIocReplaceComponent("CubeExpandService")
|
||||||
|
public class DeleteModeDataServiceImp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义一个当前线程
|
||||||
|
*/
|
||||||
|
private static final ThreadLocal<List<Map<String, String>>> threadLocal = new ThreadLocal<>();
|
||||||
|
|
||||||
|
private final static BaseBean bean = new BaseBean();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用删除前 进行方法拦截
|
||||||
|
* 人员成本管理、合同管理建模进行处理
|
||||||
|
*
|
||||||
|
* @param weaBeforeReplaceParam 拦截参数
|
||||||
|
*/
|
||||||
|
@WeaReplaceBefore(value = "/api/cube/expand/deleteData", order = 1, description = "删除建模数据,在数据删除前进行拦截")
|
||||||
|
public void before(WeaBeforeReplaceParam weaBeforeReplaceParam) {
|
||||||
|
// 获取请求参数
|
||||||
|
Map<String, Object> param = weaBeforeReplaceParam.getParamMap();
|
||||||
|
|
||||||
|
bean.writeLog("进入删除拦截:" + JSON.toJSONString(param));
|
||||||
|
// 模块ID
|
||||||
|
String modeId = Util.null2String(param.get("modeId"));
|
||||||
|
// 具体的数据ID
|
||||||
|
String billids = Util.null2String(param.get("billids"));
|
||||||
|
|
||||||
|
// 人力成本管理模块ID
|
||||||
|
String humanCostModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "HumanCostModeId"), "4");
|
||||||
|
// 合同管理模块ID
|
||||||
|
String contractManagementModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "ContractManagementModeId"), "3");
|
||||||
|
|
||||||
|
if ("".equals(humanCostModeId)) {
|
||||||
|
humanCostModeId = "4";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("".equals(contractManagementModeId)) {
|
||||||
|
contractManagementModeId = "3";
|
||||||
|
}
|
||||||
|
// 人员成本管理、合同管理 建模模块
|
||||||
|
if (contractManagementModeId.equals(modeId) || humanCostModeId.equals(modeId)) {
|
||||||
|
// 将待删除的记录写入临时表
|
||||||
|
String selectData = "";
|
||||||
|
|
||||||
|
bean.writeLog("删除建模数据!模块id: " + modeId);
|
||||||
|
bean.writeLog("删除的数据id: " + billids);
|
||||||
|
|
||||||
|
if (contractManagementModeId.equals(modeId)) {
|
||||||
|
selectData = "select qdny,yjbm,khmc from uf_hetongguanli where id in (" + billids + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (humanCostModeId.equals(modeId)) {
|
||||||
|
selectData = "select ny,yjbm,kh from uf_renlichengben where id in (" + billids + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
// 从当前线程中获取已删除的记录
|
||||||
|
List<Map<String, String>> dataList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (rs.executeQuery(selectData)) {
|
||||||
|
while (rs.next()) {
|
||||||
|
// 年月
|
||||||
|
String yearMonth = Util.null2String(rs.getString(1));
|
||||||
|
// 一级部门
|
||||||
|
String superiorDepartment = Util.null2String(rs.getString(2));
|
||||||
|
// 客户
|
||||||
|
String customer = Util.null2String(rs.getString(3));
|
||||||
|
|
||||||
|
Map<String, String> detailMap = new HashMap<>(8);
|
||||||
|
detailMap.put("yearMonth", yearMonth);
|
||||||
|
detailMap.put("superiorDepartment", superiorDepartment);
|
||||||
|
detailMap.put("customer", customer);
|
||||||
|
detailMap.put("modeId", modeId);
|
||||||
|
dataList.add(detailMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
threadLocal.set(dataList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用删除后 进行方法拦截
|
||||||
|
* 人员成本管理、合同管理建模进行处理
|
||||||
|
*
|
||||||
|
* @param weaAfterReplaceParam 拦截参数
|
||||||
|
*/
|
||||||
|
@WeaReplaceAfter(value = "/api/cube/expand/deleteData", order = 1, description = "删除建模数据,在数据删除后进行拦截,处理特殊业务")
|
||||||
|
public void after(WeaAfterReplaceParam weaAfterReplaceParam) {
|
||||||
|
|
||||||
|
bean.writeLog("----------------删除拦截后!");
|
||||||
|
try {
|
||||||
|
// 从当前线程中获取已删除的记录
|
||||||
|
List<Map<String, String>> dataList = threadLocal.get();
|
||||||
|
|
||||||
|
if (Objects.nonNull(dataList) && dataList.size() > 0) {
|
||||||
|
bean.writeLog("删除的数据信息: " + JSON.toJSONString(dataList));
|
||||||
|
// 人力成本管理模块ID
|
||||||
|
String humanCostModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "HumanCostModeId"), "4");
|
||||||
|
// 合同管理模块ID
|
||||||
|
String contractManagementModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "ContractManagementModeId"), "3");
|
||||||
|
if ("".equals(humanCostModeId)) {
|
||||||
|
humanCostModeId = "4";
|
||||||
|
}
|
||||||
|
if ("".equals(contractManagementModeId)) {
|
||||||
|
contractManagementModeId = "3";
|
||||||
|
}
|
||||||
|
CostIncomeUpdate incomeUpdate = new CostIncomeUpdate();
|
||||||
|
for (Map<String, String> detailMap : dataList) {
|
||||||
|
// 年月
|
||||||
|
String yearMonth = Util.null2String(detailMap.get("yearMonth"));
|
||||||
|
// 一级部门
|
||||||
|
String superiorDepartment = Util.null2String(detailMap.get("superiorDepartment"));
|
||||||
|
// 客户
|
||||||
|
String customer = Util.null2String(detailMap.get("customer"));
|
||||||
|
|
||||||
|
String modeId = Util.null2String(detailMap.get("modeId"));
|
||||||
|
|
||||||
|
if (humanCostModeId.equals(modeId)) {
|
||||||
|
incomeUpdate.updateByHumanCost(yearMonth, superiorDepartment, customer);
|
||||||
|
}
|
||||||
|
if (contractManagementModeId.equals(modeId)) {
|
||||||
|
incomeUpdate.updateByContract(yearMonth, superiorDepartment, customer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
bean.writeLog("处理删除数据信息异常!异常信息:" + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
threadLocal.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherOtherSystemInfoService;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.impl.GMGatherOtherSystemInfoServiceImpl;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>GM集团获取GM集团下级单位合同台账信息</h1>
|
||||||
|
* @author hcy
|
||||||
|
* @date 2023/5/9 13:56
|
||||||
|
*/
|
||||||
|
public class GMGatherOtherSystemInfoController extends BaseCronJob {
|
||||||
|
|
||||||
|
//日志处理
|
||||||
|
private final Logger logger = Util.getLogger();
|
||||||
|
|
||||||
|
private final GMGatherOtherSystemInfoService gmgatherOtherSystemInfoService = new GMGatherOtherSystemInfoServiceImpl();
|
||||||
|
|
||||||
|
//同步标准:0 同步全量数据 1 同步前一天的数据
|
||||||
|
public String syncStandard;
|
||||||
|
|
||||||
|
//GM集团获取GM集团下级单位的url
|
||||||
|
public String URL;
|
||||||
|
|
||||||
|
//GM集团数据库表名
|
||||||
|
public String formTableNameGM;
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
boolean insertDataBool = gmgatherOtherSystemInfoService.insertDataIntoGM(syncStandard,URL,formTableNameGM);
|
||||||
|
if (insertDataBool){
|
||||||
|
logger.info("GM集团获取GM集团下级单位合同台账信息执行成功!");
|
||||||
|
}else {
|
||||||
|
logger.error("GM集团获取GM集团下级单位合同台账信息执行失败!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.controller;
|
||||||
|
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>GM集团获取商密集团合同台账信息</h1>
|
||||||
|
* @author hcy
|
||||||
|
* @date 2023/5/9 18:20
|
||||||
|
*/
|
||||||
|
public class GMGatherSMInfoController extends BaseCronJob {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.controller;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherSameSystemInfoService;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.impl.GMGatherSameSystemInfoServiceImpl;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>前提条件:GM集团与GM下级单位使用同一套系统,由GM集团每日执行定时任务,将对应的下级单位台账信息进行数据同步</h1>
|
||||||
|
* @author hcy
|
||||||
|
* @date 2023/5/9 17:16
|
||||||
|
*/
|
||||||
|
public class GMGatherSameSystemInfoController extends BaseCronJob {
|
||||||
|
|
||||||
|
|
||||||
|
//业务主要逻辑
|
||||||
|
private final GMGatherSameSystemInfoService gmgatherSameSystemInfoService = new GMGatherSameSystemInfoServiceImpl();
|
||||||
|
|
||||||
|
//日志处理
|
||||||
|
private final Logger logger = Util.getLogger();
|
||||||
|
|
||||||
|
//配置表主表名称
|
||||||
|
public String configurationMainTableName;
|
||||||
|
|
||||||
|
//配置表明细表1名称
|
||||||
|
public String configurationDetailTableName1;
|
||||||
|
|
||||||
|
//配置表明细表2名称
|
||||||
|
public String configurationDetailTableName2;
|
||||||
|
|
||||||
|
//唯一标识
|
||||||
|
public String uniqueIdentification;
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
gmgatherSameSystemInfoService.dealMainLogic(configurationMainTableName,configurationDetailTableName1,configurationDetailTableName2,uniqueIdentification);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.Delete;
|
||||||
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Select;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
|
||||||
|
@SqlMapper
|
||||||
|
public interface GMGatherOtherSystemInfoMapper {
|
||||||
|
|
||||||
|
@Select("insert into $t{formTableNameGM} $t{keys} value $t{values}")
|
||||||
|
boolean insertData(@ParamMapper("formTableNameGM") String formTableNameGM,
|
||||||
|
@ParamMapper("keys") String keys,
|
||||||
|
@ParamMapper("values") String values);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select count(*) from $t{formTableNameGM} where htbm = #{htbm}")
|
||||||
|
int selectCountHtbm(@ParamMapper("formTableNameGM")String formTableNameGM,
|
||||||
|
@ParamMapper("htbm")String htbm);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select id from $t{formTableNameGM} where htbm = #{htbm}")
|
||||||
|
String selectId(@ParamMapper("formTableNameGM") String formTableNameGM,
|
||||||
|
@ParamMapper("htbm")String htbm);
|
||||||
|
|
||||||
|
@Delete("delete from $t{s} where mainid = #{mainid}")
|
||||||
|
boolean deleteByMainId(@ParamMapper("s")String s, @ParamMapper("mainid")String mainid);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
|
||||||
|
@SqlMapper
|
||||||
|
public class GMGatherSMInfoMapper {
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Select;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SqlMapper
|
||||||
|
public interface GMGatherSameSystemInfoMapper {
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select * from #{configurationMainTableName} where wybs = #{uniqueIdentification}")
|
||||||
|
List<Map<String, Object>> getConfigInformation(@ParamMapper("configurationMainTableName") String configurationMainTableName,
|
||||||
|
@ParamMapper("uniqueIdentification") String uniqueIdentification);
|
||||||
|
|
||||||
|
@Select("select * from #{configurationDetailTableName1} where mainid = #{mainid}")
|
||||||
|
List<Map<String, Object>> getConfigDetal1Information(@ParamMapper("configurationDetailTableName1")String configurationDetailTableName1,
|
||||||
|
@ParamMapper("mainid")String mainid);
|
||||||
|
|
||||||
|
@Select("select * from #{configurationDetailTableName2} where mainid = #{mainid}")
|
||||||
|
List<Map<String, Object>> getConfigDetal2Information(@ParamMapper("configurationDetailTableName2")String configurationDetailTableName2,
|
||||||
|
@ParamMapper("mainid")String mainid);
|
||||||
|
|
||||||
|
@Select("select * from #{ejdwtzb_name} where LEFT(modedatacreatedate,7) = LEFT(#{yesterday},7)")
|
||||||
|
List<Map<String, Object>> getSMCountLowGroupdata(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||||
|
@ParamMapper("yesterday")String yesterday);
|
||||||
|
|
||||||
|
@Select("select * from #{ejdwtzb_name} where LEFT(modedatacreatedate,7) = LEFT(#{yesterday},7)")
|
||||||
|
List<Map<String, Object>> getSMCountLowGroupDataUpdate(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||||
|
@ParamMapper("yesterday")String yesterday);
|
||||||
|
|
||||||
|
@Select("select * from #{jttzbd} where htbm = #{htbm}")
|
||||||
|
List<Map<String, Object>> selectHtbmData(@ParamMapper("jttzbd")String jttzbd,
|
||||||
|
@ParamMapper("htbm")String htbm);
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service;
|
||||||
|
|
||||||
|
public interface GMGatherOtherSystemInfoService {
|
||||||
|
|
||||||
|
boolean insertDataIntoGM(String syncStandard, String url,String formTableNameGM);
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service;
|
||||||
|
|
||||||
|
public interface GMGatherSMInfoService {
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service;
|
||||||
|
|
||||||
|
public interface GMGatherSameSystemInfoService {
|
||||||
|
void dealMainLogic(String configurationMainTableName, String configurationDetailTableName1, String configurationDetailTableName2, String uniqueIdentification);
|
||||||
|
}
|
|
@ -0,0 +1,232 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.impl;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
|
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
|
||||||
|
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
|
||||||
|
import aiyh.utils.sqlUtil.whereUtil.impl.PrepWhereImpl;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper.GMGatherOtherSystemInfoMapper;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherOtherSystemInfoService;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.setup.ModeRightInfo;
|
||||||
|
import weaver.general.TimeUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class GMGatherOtherSystemInfoServiceImpl implements GMGatherOtherSystemInfoService {
|
||||||
|
|
||||||
|
|
||||||
|
//日志处理
|
||||||
|
private final Logger logger = Util.getLogger();
|
||||||
|
//sql
|
||||||
|
private final GMGatherOtherSystemInfoMapper gmGatherOtherSystemInfoMapper = Util.getMapper(GMGatherOtherSystemInfoMapper.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行数据插入逻辑
|
||||||
|
* @param syncStandard 同步标准:0 同步全量数据 1 同步前一天的数据
|
||||||
|
* @param URL 访问url
|
||||||
|
* @param formTableNameGM 需要插入的表名
|
||||||
|
* @return 是否插入成功
|
||||||
|
*/
|
||||||
|
public boolean insertDataIntoGM(String syncStandard, String URL,String formTableNameGM) {
|
||||||
|
try {
|
||||||
|
//连接GM下级单位暴露的接口获取台账所有的数据
|
||||||
|
this.getEntityInsertDB(syncStandard,URL,formTableNameGM);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向台账中同步数据
|
||||||
|
* @param syncStandard 同步标准:0 同步全量数据 1 同步前一天的数据
|
||||||
|
* @param URL 访问url
|
||||||
|
* @param formTableNameGM 需要插入的表名
|
||||||
|
* @return 是否插入成功
|
||||||
|
*/
|
||||||
|
public boolean getEntityInsertDB(String syncStandard, String URL,String formTableNameGM) {
|
||||||
|
try {
|
||||||
|
ResponeVo responeVo = getEntityMap(syncStandard, URL);
|
||||||
|
int code = responeVo.getCode();
|
||||||
|
if (code != 200) {
|
||||||
|
logger.info("对方接口状态码为:" + code + " 程序执行错误");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Map<String, Object> entityMap = responeVo.getResponseMap();
|
||||||
|
List<Map<String,Object>> datas = (List<Map<String,Object>>) entityMap.get("data");
|
||||||
|
if (datas.isEmpty()) return false;//数据为空返回:数据为空
|
||||||
|
if ("1".equals(syncStandard)) {
|
||||||
|
int failNum = 0;//失败的次数
|
||||||
|
for (Map<String,Object> totalDataMap : datas) {
|
||||||
|
//用于存放全部主表数据,排除所有明细表数据
|
||||||
|
Map<String, Object> newDataMap = new HashMap<>(totalDataMap.entrySet().stream()
|
||||||
|
.filter(entry -> !("detailData".equals(entry.getKey()) || "id".equals(entry.getKey())))
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
Map.Entry::getKey,
|
||||||
|
Map.Entry::getValue)));
|
||||||
|
String htbm = Util.null2String(totalDataMap.get("htbm"));
|
||||||
|
int countHtbm = gmGatherOtherSystemInfoMapper.selectCountHtbm(formTableNameGM,htbm);
|
||||||
|
RecordSet recordSet = new RecordSet();
|
||||||
|
if (countHtbm == 0){
|
||||||
|
int mainid = this.createmodedata(formTableNameGM, 1, newDataMap);//先插入数据id,在根据数据id,插入所有明细数据
|
||||||
|
if (mainid>0){
|
||||||
|
//开始插入明细表
|
||||||
|
List<Map<String, Object>> detailData = (List<Map<String, Object>>) totalDataMap.get("detailData");
|
||||||
|
for (Map<String, Object> detailDatum : detailData) {
|
||||||
|
detailDatum.put("mainid",mainid);
|
||||||
|
insertSql(formTableNameGM,detailDatum);//插入明细表
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if (countHtbm > 0 ){
|
||||||
|
BuilderSqlImpl builderSql = new BuilderSqlImpl();
|
||||||
|
PrepWhereImpl prepWhere = new PrepWhereImpl();
|
||||||
|
prepWhere.whereAnd("htbm = ?");
|
||||||
|
prepWhere.addArgs(htbm);
|
||||||
|
PrepSqlResultImpl prepSqlResult = builderSql.updateSql(formTableNameGM, newDataMap, prepWhere);
|
||||||
|
boolean updateBool = recordSet.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||||
|
if (!updateBool){
|
||||||
|
logger.error("数据更新失败,SQL:["+prepSqlResult+"]");
|
||||||
|
failNum++;
|
||||||
|
}else {
|
||||||
|
//先删明细数据
|
||||||
|
String mainid = gmGatherOtherSystemInfoMapper.selectId(formTableNameGM,htbm);
|
||||||
|
//开始插入明细表
|
||||||
|
List<Map<String, Object>> detailData = (List<Map<String, Object>>) totalDataMap.get("detailData");
|
||||||
|
for (Map<String, Object> detailDatum : detailData) {
|
||||||
|
//先删明细数据
|
||||||
|
boolean deleteBool = gmGatherOtherSystemInfoMapper.deleteByMainId(formTableNameGM+"_dt1",Util.null2String(mainid));
|
||||||
|
if (deleteBool){
|
||||||
|
detailDatum.put("mainid",mainid);
|
||||||
|
insertSql(formTableNameGM,detailDatum);//插入明细表
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("数据更新失败"+failNum+"次");
|
||||||
|
} else if ("0".equals(syncStandard)){
|
||||||
|
for (Map<String,Object> totalDataMap : datas) {
|
||||||
|
//用于存放全部主表数据,排除所有明细表数据
|
||||||
|
Map<String, Object> newDataMap = new HashMap<>(totalDataMap.entrySet().stream()
|
||||||
|
.filter(entry -> !("detailData".equals(entry.getKey()) || "id".equals(entry.getKey())))
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
Map.Entry::getKey,
|
||||||
|
Map.Entry::getValue)));
|
||||||
|
int createmodedata = createmodedata(formTableNameGM, 1, newDataMap);
|
||||||
|
if (createmodedata>0){
|
||||||
|
List<Map<String, Object>> detailData = (List<Map<String, Object>>) totalDataMap.get("detailData");
|
||||||
|
if (detailData.isEmpty()) continue;
|
||||||
|
for (Map<String, Object> detailDatum : detailData) {
|
||||||
|
detailDatum.put("mainid",createmodedata);
|
||||||
|
insertSql(formTableNameGM,detailDatum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问国密下级单位暴露的接口,获取ResponeVo
|
||||||
|
* @param syncStandard 同步标准:0 同步全量数据 1 同步前一天的数据
|
||||||
|
* @param URL 接口访问路径
|
||||||
|
* @return ResponeVo
|
||||||
|
*/
|
||||||
|
public ResponeVo getEntityMap(String syncStandard, String URL){
|
||||||
|
try {
|
||||||
|
HttpUtils httpUtils = new HttpUtils();
|
||||||
|
Map<String, Object> paramsMap = new HashMap<>();
|
||||||
|
paramsMap.put("syncStandard", syncStandard);
|
||||||
|
return httpUtils.apiPost(URL, paramsMap);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将数据插入表单建模
|
||||||
|
* @param tablename 建模表名
|
||||||
|
* @param userid 创建人id
|
||||||
|
* @param map 数据map
|
||||||
|
* @return int 返回数据id
|
||||||
|
*/
|
||||||
|
public int createmodedata(String tablename, int userid, Map<String, Object> map) {
|
||||||
|
Integer modeid = getModeidByTableName(tablename);
|
||||||
|
int dataid = 0;
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
String uuid = map.containsKey("modeuuid") ? map.get("modeuuid").toString() : UUID.randomUUID().toString();
|
||||||
|
boolean flag = rs.execute("insert into " + tablename
|
||||||
|
+ "(modeuuid,modedatacreater,modedatacreatedate,modedatacreatetime,formmodeid) values('" + uuid + "',"
|
||||||
|
+ userid + ",'" + TimeUtil.getCurrentDateString() + "','" + TimeUtil.getOnlyCurrentTimeString() + "',"
|
||||||
|
+ modeid + ")");
|
||||||
|
if (flag) {
|
||||||
|
rs.execute("select id from " + tablename + " where modeuuid='" + uuid + "'");
|
||||||
|
rs.next();
|
||||||
|
dataid = weaver.general.Util.getIntValue(rs.getString("id"));
|
||||||
|
|
||||||
|
if (dataid > 0) {
|
||||||
|
// 遍历数据 进行update
|
||||||
|
StringBuilder updatesql = new StringBuilder("update " + tablename + " set ");
|
||||||
|
Set<String> keySet = map.keySet();
|
||||||
|
for (String key : keySet) {
|
||||||
|
updatesql.append(key).append("='").append(map.get(key).toString()).append("',");
|
||||||
|
}
|
||||||
|
if (updatesql.toString().endsWith(",")) {
|
||||||
|
updatesql = new StringBuilder(updatesql.substring(0, updatesql.length() - 1));
|
||||||
|
|
||||||
|
updatesql.append(" where id=").append(dataid);
|
||||||
|
boolean execute = rs.execute(updatesql.toString());
|
||||||
|
if(!execute){
|
||||||
|
logger.info("出错的sql==="+updatesql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 进行权限重构
|
||||||
|
*/
|
||||||
|
ModeRightInfo moderight = new ModeRightInfo();
|
||||||
|
moderight.editModeDataShare(userid, modeid, dataid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取没一张表的modeid
|
||||||
|
* @param tablename 表名称
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer getModeidByTableName(String tablename) {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String sql = "select b.TABLENAME,a.FORMID,a.id modeid from modeinfo a left join workflow_bill b on a.FORMID=b.id where b.TABLENAME= '"
|
||||||
|
+ tablename + "'";
|
||||||
|
rs.execute(sql);
|
||||||
|
rs.next();
|
||||||
|
return Math.abs(rs.getInt("modeid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行数据插入操作
|
||||||
|
* @param tableName 表名
|
||||||
|
* @param datas 数据集合 <key,value>
|
||||||
|
*/
|
||||||
|
public void insertSql(String tableName,Map<String,Object> datas){
|
||||||
|
BuilderSqlImpl builderSql = new BuilderSqlImpl();
|
||||||
|
PrepSqlResultImpl prepSqlResult = builderSql.insertSql(tableName + "_dt1", datas);
|
||||||
|
RecordSet recordSet1 = new RecordSet();
|
||||||
|
boolean insertBool = recordSet1.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||||
|
if (!insertBool){
|
||||||
|
logger.error("数据插入失败,失败SQL:["+prepSqlResult+"]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherSMInfoService;
|
||||||
|
|
||||||
|
public class GMGatherSMInfoServiceImpl implements GMGatherSMInfoService {
|
||||||
|
}
|
|
@ -0,0 +1,162 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.impl;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.weaver.formmodel.util.DateHelper;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.mapper.GMGatherSameSystemInfoMapper;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.gmgetdatafromlowgroup.service.GMGatherSameSystemInfoService;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GMGatherSameSystemInfoServiceImpl implements GMGatherSameSystemInfoService {
|
||||||
|
/**
|
||||||
|
* 日志
|
||||||
|
*/
|
||||||
|
private final Logger logger = Util.getLogger();
|
||||||
|
|
||||||
|
//sql
|
||||||
|
private final GMGatherSameSystemInfoMapper gmGatherSameSystemInfoMapper = Util.getMapper(GMGatherSameSystemInfoMapper.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理从国密集团下级单位台账数据库查询数据向国密集团总台账数据库中插入或者更新数据
|
||||||
|
* @param configurationMainTableName 配置表主表名称
|
||||||
|
* @param configurationDetailTableName1 配置表明细表1名称
|
||||||
|
* @param configurationDetailTableName2 配置表明细表2名称
|
||||||
|
* @param uniqueIdentification 唯一标识
|
||||||
|
*/
|
||||||
|
public void dealMainLogic(String configurationMainTableName, String configurationDetailTableName1, String configurationDetailTableName2, String uniqueIdentification) {
|
||||||
|
//第一步获取配置表中数据
|
||||||
|
if (configurationMainTableName.equals("") && configurationDetailTableName1.equals("") && uniqueIdentification.equals("")) return;
|
||||||
|
//主表数据
|
||||||
|
List<Map<String,Object>> configMainTableData = gmGatherSameSystemInfoMapper.getConfigInformation(configurationMainTableName,uniqueIdentification);
|
||||||
|
logger.info("配置表主表数据---configMainTableData---"+configMainTableData);
|
||||||
|
if (configMainTableData.isEmpty()) return;
|
||||||
|
|
||||||
|
String jttzbd = Util.null2String(configMainTableData.get(0).get("jttzbd"));//集团台账表单
|
||||||
|
String mainid = Util.null2String(configMainTableData.get(0).get("mainid"));
|
||||||
|
logger.info("配置表主表数据---mainid---"+mainid);
|
||||||
|
if (mainid.equals("")) return;
|
||||||
|
|
||||||
|
//配置表明细表1数据:用来统计商密下级单位台账名称
|
||||||
|
List<Map<String,Object>> configDetal1TableData = gmGatherSameSystemInfoMapper.getConfigDetal1Information(configurationDetailTableName1,mainid);
|
||||||
|
logger.info("配置表明细表数据---configDetal1TableData---"+configDetal1TableData);
|
||||||
|
//明细表2数据
|
||||||
|
List<Map<String,Object>> configDetal2TableData = gmGatherSameSystemInfoMapper.getConfigDetal2Information(configurationDetailTableName2,mainid);
|
||||||
|
logger.info("配置表明细表数据---configDetal2TableData---"+configDetal2TableData);
|
||||||
|
List<String> keys = new ArrayList<>();//用于insert和update的key
|
||||||
|
for (Map<String, Object> configdetal2 : configDetal2TableData) {
|
||||||
|
keys.add(Util.null2String(configdetal2.get("tbzd")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//第二步:其次我们需要根据数据创建时间,和数据修改时间来判断二级单位中的这条数据是第一次进来的,还是二次进来修改的,如果只有创建时间没有修改时间那么就对这条数据进行增加,如果既有创建时间又有修改时间,那么就需要将这条数据进行修改
|
||||||
|
if (configDetal1TableData.isEmpty()) return;
|
||||||
|
for (Map<String, Object> config1 : configDetal1TableData) {
|
||||||
|
String ejdwtzb_name = Util.null2String(config1.get("ejdwtzb")); //二级单位台账表数据库名称
|
||||||
|
String bz = Util.null2String(config1.get("bz")); //备注
|
||||||
|
logger.info("二级单位台账表数据库名称===="+ejdwtzb_name+" 二级单位台账表数名称==="+bz);
|
||||||
|
//获取当天日期的前一天,如果和创建时间吻合,并且满足修改时间为空那么,这条数据就是纯插入的数据
|
||||||
|
List<Map<String,Object>> smCountLowGroupDataInsert = gmGatherSameSystemInfoMapper.getSMCountLowGroupdata(ejdwtzb_name, DateHelper.getYesterday());
|
||||||
|
logger.info("smCountLowGroupDataInsert===="+smCountLowGroupDataInsert);
|
||||||
|
|
||||||
|
//获取当天日期的前一天,如果和修改时间吻合,那么这条数据就是更新操作的数据
|
||||||
|
List<Map<String,Object>> smCountLowGroupDataupdate = gmGatherSameSystemInfoMapper.getSMCountLowGroupDataUpdate(ejdwtzb_name,DateHelper.getYesterday());
|
||||||
|
logger.info("smCountLowGroupDataupdate===="+smCountLowGroupDataupdate);
|
||||||
|
|
||||||
|
//数据插入商密集团总台账
|
||||||
|
if (smCountLowGroupDataInsert.size()>0){
|
||||||
|
this.insertData(smCountLowGroupDataInsert,jttzbd,keys);
|
||||||
|
}
|
||||||
|
//数据更新商密集团总台账
|
||||||
|
if (smCountLowGroupDataupdate.size()>0){
|
||||||
|
this.updateData(smCountLowGroupDataupdate,jttzbd,keys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>插入数据</h2>
|
||||||
|
* @param smCountLowGroupDataInsert 插入数据集合
|
||||||
|
* @param jttzbd 集团台账数据库名
|
||||||
|
* @param keys 需要insert的字段key
|
||||||
|
* @author hcy
|
||||||
|
* 2023/5/6 17:41
|
||||||
|
*/
|
||||||
|
private void insertData(List<Map<String, Object>> smCountLowGroupDataInsert, String jttzbd,List<String> keys) {
|
||||||
|
|
||||||
|
RecordSet recordSet = new RecordSet();
|
||||||
|
for (Map<String, Object> insertDatas : smCountLowGroupDataInsert) {
|
||||||
|
String htbm = Util.null2String(insertDatas.get("htbm"));
|
||||||
|
List<Map<String,Object>> selectHtbmData = gmGatherSameSystemInfoMapper.selectHtbmData(jttzbd,htbm);
|
||||||
|
if (selectHtbmData.size()==0){
|
||||||
|
|
||||||
|
String insertKey = Joiner.on(",").join((Iterable<?>) keys);//key
|
||||||
|
ArrayList<String> valueList = new ArrayList<>();
|
||||||
|
for (String key : keys) {
|
||||||
|
String v = Util.null2String(insertDatas.get(key));
|
||||||
|
valueList.add(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
String insertValue = Joiner.on(",").join((Iterable<?>) valueList);//value
|
||||||
|
|
||||||
|
String insertSql = "insert into "+jttzbd + "(" +insertKey + ")"+ "value " +"("+insertValue+")";//拼接插入的sql语句
|
||||||
|
boolean insertBool = recordSet.executeQuery(insertSql);
|
||||||
|
if (insertBool){
|
||||||
|
logger.info("数据插入成功");
|
||||||
|
}else{
|
||||||
|
logger.info("数据插入失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新数据</h2>
|
||||||
|
* @param smCountLowGroupDataupdate 更新语句集合
|
||||||
|
* @param jttzbd 集团台账数据库名
|
||||||
|
* @param keys 数据更新的key组成的集合
|
||||||
|
* @author hcy
|
||||||
|
* 2023/5/6 17:40
|
||||||
|
*/
|
||||||
|
|
||||||
|
private void updateData(List<Map<String, Object>> smCountLowGroupDataupdate, String jttzbd, List<String> keys) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
RecordSet recordSet = new RecordSet();
|
||||||
|
for (Map<String, Object> updateDates : smCountLowGroupDataupdate) {
|
||||||
|
String htbm = Util.null2String(updateDates.get("htbm"));
|
||||||
|
List<Map<String, Object>> updateDatas = gmGatherSameSystemInfoMapper.selectHtbmData(jttzbd, htbm);
|
||||||
|
if (updateDatas.size()>0){
|
||||||
|
//拼接sql
|
||||||
|
List<String> updateValueList = new ArrayList<>();
|
||||||
|
for (String key : keys) {
|
||||||
|
String value = Util.null2String(updateDates.get(key));
|
||||||
|
updateValueList.add(value);
|
||||||
|
}
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
Joiner.on(", ").appendTo(builder, keys);
|
||||||
|
builder.append(" = ");
|
||||||
|
Joiner.on(", ").appendTo(builder, updateValueList);
|
||||||
|
|
||||||
|
|
||||||
|
String updateSql = "update "+jttzbd + "set " + builder + " where htbm = ?";
|
||||||
|
boolean updateBool = recordSet.executeQuery(updateSql, htbm);
|
||||||
|
if (updateBool){
|
||||||
|
logger.info("======数据更新成功======");
|
||||||
|
}else {
|
||||||
|
logger.info("======数据更新失败======");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.info("----GMGatherSameSystemInfoServiceImpl----smCountLowGroupDataupdate----异常如下===="+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.controller;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.service.SMCountLowGroupDataService;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.service.impl.SMCountLowGroupDataServiceImpl;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>由于商密集团与商密下级单位使用同一套环境,所以可以使用定时任务的方式,商密集团每日执行定时任务,将下级单位的台账信息同步到商密集团的台账中</h1>
|
||||||
|
* @Author hcy
|
||||||
|
* @Date 2023/4/26 18:14
|
||||||
|
*/
|
||||||
|
public class SMCountLowGroupDataController extends BaseCronJob {
|
||||||
|
|
||||||
|
//业务主要逻辑
|
||||||
|
private final SMCountLowGroupDataService smCountLowGroupData = new SMCountLowGroupDataServiceImpl();
|
||||||
|
|
||||||
|
//日志处理
|
||||||
|
private final Logger logger = Util.getLogger();
|
||||||
|
|
||||||
|
//配置表主表名称
|
||||||
|
public String configurationMainTableName;
|
||||||
|
|
||||||
|
//配置表明细表1名称
|
||||||
|
public String configurationDetailTableName1;
|
||||||
|
|
||||||
|
//配置表明细表2名称
|
||||||
|
public String configurationDetailTableName2;
|
||||||
|
|
||||||
|
//唯一标识
|
||||||
|
public String uniqueIdentification;
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public void execute() {
|
||||||
|
smCountLowGroupData.dealMainLogic(configurationMainTableName,configurationDetailTableName1,configurationDetailTableName2,uniqueIdentification);//处理业务主要逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigurationDetailTableName1() {
|
||||||
|
return configurationDetailTableName1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigurationDetailTableName1(String configurationDetailTableName1) {
|
||||||
|
this.configurationDetailTableName1 = configurationDetailTableName1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigurationDetailTableName2() {
|
||||||
|
return configurationDetailTableName2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigurationDetailTableName2(String configurationDetailTableName2) {
|
||||||
|
this.configurationDetailTableName2 = configurationDetailTableName2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getConfigurationMainTableName() {
|
||||||
|
return configurationMainTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigurationMainTableName(String configurationMainTableName) {
|
||||||
|
this.configurationMainTableName = configurationMainTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUniqueIdentification() {
|
||||||
|
return uniqueIdentification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniqueIdentification(String uniqueIdentification) {
|
||||||
|
this.uniqueIdentification = uniqueIdentification;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.mapper;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.Delete;
|
||||||
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Select;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SqlMapper
|
||||||
|
public interface SMCountLowGroupDataMapper {
|
||||||
|
|
||||||
|
@Select("select * from $t{configurationMainTableName} where wybs = #{uniqueIdentification}")
|
||||||
|
List<Map<String, Object>> getConfigInformation(@ParamMapper("configurationMainTableName") String configurationMainTableName,
|
||||||
|
@ParamMapper("uniqueIdentification") String uniqueIdentification);
|
||||||
|
|
||||||
|
@Select("select * from $t{configurationDetailTableName1} where mainid = #{mainid}")
|
||||||
|
List<Map<String, Object>> getConfigDetal1Information(@ParamMapper("configurationDetailTableName1")String configurationDetailTableName1,
|
||||||
|
@ParamMapper("mainid")String mainid);
|
||||||
|
|
||||||
|
@Select("select * from $t{configurationDetailTableName2} where mainid = #{mainid}")
|
||||||
|
List<Map<String, Object>> getConfigDetal2Information(@ParamMapper("configurationDetailTableName2")String configurationDetailTableName2,
|
||||||
|
@ParamMapper("mainid")String mainid);
|
||||||
|
|
||||||
|
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatacreatedate,7) = LEFT(#{yesterday},7) ")
|
||||||
|
List<Map<String, Object>> getSMCountLowGroupdata(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||||
|
@ParamMapper("yesterday")String yesterday);
|
||||||
|
|
||||||
|
@Select("select * from $t{ejdwtzb_name} where LEFT(modedatamodifydatetime,7) = LEFT(#{yesterday},7)")
|
||||||
|
List<Map<String, Object>> getSMCountLowGroupDataUpdate(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||||
|
@ParamMapper("yesterday")String yesterday);
|
||||||
|
|
||||||
|
@Select("select * from $t{jttzbd} where htbm = #{htbm}")
|
||||||
|
List<Map<String, Object>> selectHtbmData(@ParamMapper("jttzbd")String jttzbd,
|
||||||
|
@ParamMapper("htbm")String htbm);
|
||||||
|
|
||||||
|
@Select("select * from $t{ejdwtzb_name}")
|
||||||
|
List<Map<String, Object>> getSMCountLowGroupTotalData(@ParamMapper("ejdwtzb_name") String ejdwtzb_name);
|
||||||
|
|
||||||
|
@Select("select id from $t{jttzbd} where htbm = #{htbm}")
|
||||||
|
String selectIdByHtbm(@ParamMapper("jttzbd")String jttzbd,
|
||||||
|
@ParamMapper("htbm")String htbm);
|
||||||
|
|
||||||
|
|
||||||
|
@Delete("delete from $t{s} where mainid = #{id}")
|
||||||
|
boolean deleteDetalDataByMainId(@ParamMapper("s")String s,
|
||||||
|
@ParamMapper("id")String id);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select id from $t{ejdwtzb_name} where htbm = #{htbm1}")
|
||||||
|
String selectDetailTableSouceId(@ParamMapper("ejdwtzb_name")String ejdwtzb_name,
|
||||||
|
@ParamMapper("htbm1")String htbm1);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select * from $t{s} where mainid = #{ejdw_id}")
|
||||||
|
List<Map<String, Object>> selectDetailTableSouceData(@ParamMapper("s")String s,
|
||||||
|
@ParamMapper("ejdw_id")String ejdw_id);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface SMCountLowGroupDataService {
|
||||||
|
|
||||||
|
|
||||||
|
void dealMainLogic(String configurationMainTableName, String configurationDetailTableName1, String configurationDetailTableName2, String uniqueIdentification) throws IOException;
|
||||||
|
}
|
|
@ -0,0 +1,329 @@
|
||||||
|
package weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.service.impl;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
|
||||||
|
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
|
||||||
|
import aiyh.utils.sqlUtil.whereUtil.impl.PrepWhereImpl;
|
||||||
|
import com.weaver.formmodel.util.DateHelper;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.mapper.SMCountLowGroupDataMapper;
|
||||||
|
import weaver.chaoyang.he.hcy_hangtiankeji.smcountlowgruop.service.SMCountLowGroupDataService;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.setup.ModeRightInfo;
|
||||||
|
import weaver.general.TimeUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
// 3、开发补充详细开发方案
|
||||||
|
// (1)我们现在要做的事情就是要将商密下级单位台账表中的数据同步到商密集团台账表uf_hthpjtz中
|
||||||
|
// (2)首先我们需要根据合同台账同步表uf_httztb来获取数据库二级单位表名称和想要同步不来的字段名称,这里要求做成配置的是因为后续便于字段增删
|
||||||
|
// (3)其次我们需要根据数据创建时间,和数据修改时间来判断二级单位中的这条数据是第一次进来的,还是二次进来修改的,如果只有创建时间没有修改时间那么就对这条数据进行增加,如果既有创建时间又有修改时间,那么就需要将这条数据进行修改
|
||||||
|
// (4)在向商密集团总台账插入数据的时候,同时为了保证数据的准确性,我们首先需要根据合同编码来查询合同总台账中查询本条数据是否已经存在,如果存在执行更新操作,如果不存在执行插入操作。
|
||||||
|
public class SMCountLowGroupDataServiceImpl implements SMCountLowGroupDataService {
|
||||||
|
|
||||||
|
//处理sql
|
||||||
|
private final SMCountLowGroupDataMapper smCountLowGroupDataMapper = Util.getMapper(SMCountLowGroupDataMapper.class);
|
||||||
|
|
||||||
|
//构建inser、update 的sql语句
|
||||||
|
private final BuilderSqlImpl builderSqlImpl = new BuilderSqlImpl();
|
||||||
|
|
||||||
|
//日志
|
||||||
|
private final Logger logger = Util.getLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>处理从商密二级单位台账数据库查询数据向商密集团总台账数据库中插入或者更新数据</h2>
|
||||||
|
* @author hcy 2023/5/6 14:59
|
||||||
|
*/
|
||||||
|
public void dealMainLogic(String configurationMainTableName, String configurationDetailTableName1, String configurationDetailTableName2, String uniqueIdentification) throws IOException {
|
||||||
|
//第一步获取配置表中数据
|
||||||
|
if (configurationMainTableName.equals("") && configurationDetailTableName1.equals("") && uniqueIdentification.equals("")) return;
|
||||||
|
//主表数据
|
||||||
|
List<Map<String,Object>> configMainTableData = smCountLowGroupDataMapper.getConfigInformation(configurationMainTableName,uniqueIdentification);
|
||||||
|
logger.info("配置表主表数据---configMainTableData---"+configMainTableData);
|
||||||
|
if (configMainTableData.isEmpty()) return;
|
||||||
|
|
||||||
|
String jttzbd = Util.null2String(configMainTableData.get(0).get("jttzbd"));//集团台账表单
|
||||||
|
String mainid = Util.null2String(configMainTableData.get(0).get("id"));
|
||||||
|
logger.info("配置表主表数据---mainid---"+mainid);
|
||||||
|
if (mainid.equals("") && "".equals(jttzbd)) return;
|
||||||
|
|
||||||
|
//配置表明细表1数据:用来统计商密下级单位台账名称
|
||||||
|
List<Map<String,Object>> configDetal1TableData = smCountLowGroupDataMapper.getConfigDetal1Information(configurationDetailTableName1,mainid);
|
||||||
|
logger.info("配置表明细表数据---configDetal1TableData---"+configDetal1TableData);
|
||||||
|
//明细表2数据
|
||||||
|
List<Map<String,Object>> configDetal2TableData = smCountLowGroupDataMapper.getConfigDetal2Information(configurationDetailTableName2,mainid);
|
||||||
|
logger.info("配置表明细表数据---configDetal2TableData---"+configDetal2TableData);
|
||||||
|
List<String> mainTablekeys = new ArrayList<>();//用于存放主表中insert和update的key
|
||||||
|
List<String> detalTablekeys = new ArrayList<>();//用于存放主表中insert和update的key
|
||||||
|
for (Map<String, Object> configdetal2 : configDetal2TableData) {
|
||||||
|
String sfzb = Util.null2String(configdetal2.get("sfzb"));
|
||||||
|
if ("0".equals(sfzb)){
|
||||||
|
mainTablekeys.add(Util.null2String(configdetal2.get("tbzd")));
|
||||||
|
}else if ("1".equals(sfzb)){
|
||||||
|
detalTablekeys.add(Util.null2String(configdetal2.get("tbzd")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//第二步:其次我们需要根据数据创建时间,和数据修改时间来判断二级单位中的这条数据是第一次进来的,还是二次进来修改的,如果只有创建时间没有修改时间那么就对这条数据进行增加,如果既有创建时间又有修改时间,那么就需要将这条数据进行修改
|
||||||
|
if (configDetal1TableData.isEmpty()) return;
|
||||||
|
for (Map<String, Object> config1 : configDetal1TableData) {
|
||||||
|
String ejdwtzb_name = Util.null2String(config1.get("ejdwtzb")); //二级单位台账表数据库名称
|
||||||
|
String bz = Util.null2String(config1.get("bz")); //备注
|
||||||
|
String tbzt = Util.null2String(config1.get("tbzt"));
|
||||||
|
logger.info("二级单位台账表数据库名称===="+ejdwtzb_name+" 二级单位台账表数名称==="+bz+" 同步状态==="+tbzt);
|
||||||
|
|
||||||
|
if ("0".equals(tbzt)){
|
||||||
|
//查询全量数据
|
||||||
|
List<Map<String,Object>> smCountLowGroupTotalData = smCountLowGroupDataMapper.getSMCountLowGroupTotalData(ejdwtzb_name);//第一次同步数据
|
||||||
|
if (smCountLowGroupTotalData.size()>0){
|
||||||
|
this.insertData(smCountLowGroupTotalData,jttzbd,ejdwtzb_name,mainTablekeys,detalTablekeys,tbzt);//全增量主表数据执行插入 并且包含明细表的删除,和再次添加
|
||||||
|
}
|
||||||
|
}else if ("1".equals(tbzt)){ //非第一次同步数据
|
||||||
|
//获取当天日期的前一天,如果和创建时间吻合,并且满足修改时间为空那么,这条数据就是纯插入的数据
|
||||||
|
List<Map<String,Object>> smCountLowGroupDataInsert = smCountLowGroupDataMapper.getSMCountLowGroupdata(ejdwtzb_name,DateHelper.getYesterday());
|
||||||
|
logger.info("smCountLowGroupDataInsert===="+smCountLowGroupDataInsert);
|
||||||
|
|
||||||
|
//获取当天日期的前一天,如果和修改时间吻合,那么这条数据就是更新操作的数据
|
||||||
|
List<Map<String,Object>> smCountLowGroupDataupdate = smCountLowGroupDataMapper.getSMCountLowGroupDataUpdate(ejdwtzb_name,DateHelper.getYesterday());
|
||||||
|
logger.info("smCountLowGroupDataupdate===="+smCountLowGroupDataupdate);
|
||||||
|
|
||||||
|
//数据插入商密集团总台账
|
||||||
|
if (smCountLowGroupDataInsert.size()>0){
|
||||||
|
this.insertData(smCountLowGroupDataInsert,jttzbd,ejdwtzb_name,mainTablekeys,detalTablekeys, tbzt);
|
||||||
|
}
|
||||||
|
//数据更新商密集团总台账
|
||||||
|
if (smCountLowGroupDataupdate.size()>0){
|
||||||
|
this.updateData(smCountLowGroupDataupdate,jttzbd,ejdwtzb_name,mainTablekeys,detalTablekeys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>插入数据</h2>
|
||||||
|
* @param smCountLowGroupDataInsert 插入数据集合
|
||||||
|
* @param jttzbd 集团台账数据库名
|
||||||
|
* @param ejdwtzb_name 二级单位数据库名
|
||||||
|
* @param keys 需要insert的字段key
|
||||||
|
* @param detalTablekeys 需要插入的明细表字段数据库名组成的list
|
||||||
|
* @param tbzt 同步状态用来判断是第一次同步还是非首次同步
|
||||||
|
* @author hcy
|
||||||
|
* 2023/5/6 17:41
|
||||||
|
*/
|
||||||
|
private void insertData(List<Map<String, Object>> smCountLowGroupDataInsert, String jttzbd, String ejdwtzb_name, List<String> keys, List<String> detalTablekeys, String tbzt) {
|
||||||
|
|
||||||
|
RecordSet recordSet = new RecordSet();
|
||||||
|
int successNum = 0;
|
||||||
|
int failNum = 0;
|
||||||
|
for (Map<String, Object> insertDatas : smCountLowGroupDataInsert) {
|
||||||
|
String htbm = Util.null2String(insertDatas.get("htbm"));
|
||||||
|
List<Map<String,Object>> selectHtbmData = smCountLowGroupDataMapper.selectHtbmData(jttzbd,htbm);
|
||||||
|
if (selectHtbmData.size()==0){
|
||||||
|
// String insertKey = Joiner.on(",").join((Iterable<?>) keys);//key
|
||||||
|
Map<String, Object> keyValueMap = new HashMap<>();
|
||||||
|
for (String key : keys) {
|
||||||
|
// if("htzje".equals(key) || "htjrrmb".equals(key)){
|
||||||
|
// String o = Util.null2String(insertDatas.get(key));
|
||||||
|
// if ("".equals(o)){
|
||||||
|
// keyValueMap.put(key, null);
|
||||||
|
// }else {
|
||||||
|
// keyValueMap.put(key, o);
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// Object o = insertDatas.get(key);
|
||||||
|
// keyValueMap.put(key, o);
|
||||||
|
// }
|
||||||
|
Object o = insertDatas.get(key);
|
||||||
|
keyValueMap.put(key, o);
|
||||||
|
}
|
||||||
|
// PrepSqlResultImpl prepSqlResult = builderSqlImpl.insertSql(jttzbd, keyValueMap);
|
||||||
|
// boolean insertBool = recordSet.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||||
|
|
||||||
|
int createmodedata = createmodedata(jttzbd, 1, keyValueMap);
|
||||||
|
if (createmodedata>0){
|
||||||
|
String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||||
|
deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||||
|
}
|
||||||
|
// if(insertBool){
|
||||||
|
// successNum++;
|
||||||
|
// String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||||
|
// //执行明细表的数据删除和数据插入
|
||||||
|
// deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||||
|
// }else{
|
||||||
|
// failNum++;
|
||||||
|
// logger.error("台账数据插入失败,失败SQL:["+ prepSqlResult +"----失败次数:"+failNum+"]");
|
||||||
|
// }
|
||||||
|
logger.info("台账数据插入成功 "+successNum+"次");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新数据</h2>
|
||||||
|
* @param smCountLowGroupDataupdate 更新语句集合
|
||||||
|
* @param jttzbd 集团台账数据库名
|
||||||
|
* @param ejdwtzb_name 二级单位数据库名
|
||||||
|
* @param keys 数据更新的key组成的集合
|
||||||
|
* @param detalTablekeys 需要插入的明细表字段数据库名组成的list
|
||||||
|
* @author hcy
|
||||||
|
* 2023/5/6 17:40
|
||||||
|
*/
|
||||||
|
|
||||||
|
private void updateData(List<Map<String, Object>> smCountLowGroupDataupdate, String jttzbd, String ejdwtzb_name, List<String> keys, List<String> detalTablekeys) {
|
||||||
|
RecordSet recordSet = new RecordSet();
|
||||||
|
int failNum = 0;
|
||||||
|
int successNum = 0;
|
||||||
|
for (Map<String, Object> updateDates : smCountLowGroupDataupdate) {
|
||||||
|
String htbm = Util.null2String(updateDates.get("htbm"));
|
||||||
|
List<Map<String, Object>> selecthtbmData = smCountLowGroupDataMapper.selectHtbmData(jttzbd, htbm);
|
||||||
|
if (selecthtbmData.size()>0){
|
||||||
|
Map<String, Object> keyValueMap = getKeyValueMap(updateDates, keys);
|
||||||
|
PrepWhereImpl prepWhere = new PrepWhereImpl();
|
||||||
|
prepWhere.whereAnd("htbm = ?");
|
||||||
|
prepWhere.addArgs(htbm);
|
||||||
|
PrepSqlResultImpl prepSqlResult = builderSqlImpl.updateSql(jttzbd, keyValueMap, prepWhere);
|
||||||
|
boolean insertBool = recordSet.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||||
|
if (insertBool){
|
||||||
|
String htbm1 = Util.null2String(keyValueMap.get("htbm"));
|
||||||
|
//执行明细表的数据删除和数据插入
|
||||||
|
deleteAndInsertDetailTable(htbm1,jttzbd,ejdwtzb_name,detalTablekeys);
|
||||||
|
successNum++;
|
||||||
|
}else {
|
||||||
|
failNum++;
|
||||||
|
logger.error("台账数据更新失败,SQL:["+ prepSqlResult +"------失败次数:"+failNum+"]");
|
||||||
|
}
|
||||||
|
logger.info("台账数据更新成功 "+successNum + "次");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于封装insert或者update的key,value的map集合
|
||||||
|
* @param datas 数据源
|
||||||
|
* @param keys 需要更新或者插入的keys
|
||||||
|
* @return 预期的key,value对应的map集合
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getKeyValueMap(Map<String, Object> datas ,List<String> keys){
|
||||||
|
Map<String, Object> keyValueMap = new HashMap<>();
|
||||||
|
for (String key : keys) {
|
||||||
|
String v = Util.null2String(datas.get(key));
|
||||||
|
keyValueMap.put(key, v);
|
||||||
|
}
|
||||||
|
return keyValueMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除并插入明细表中的数据
|
||||||
|
* @param htbm1 合同编号用来作为唯一标识
|
||||||
|
* @param jttzbd 商密集团台账数据库名称
|
||||||
|
* @param ejdwtzb_name 二级单位名称
|
||||||
|
* @param detalTablekeys 需要插入的明细表字段数据库名组成的list
|
||||||
|
*/
|
||||||
|
public void deleteAndInsertDetailTable(String htbm1,String jttzbd,String ejdwtzb_name,List<String> detalTablekeys){
|
||||||
|
|
||||||
|
try {
|
||||||
|
RecordSet insertDatailRS = new RecordSet();
|
||||||
|
//执行明细表的插入语句
|
||||||
|
String id = smCountLowGroupDataMapper.selectIdByHtbm(jttzbd,htbm1);
|
||||||
|
int successNum = 0;
|
||||||
|
int failNum = 0;
|
||||||
|
if (!"".equals(id)){
|
||||||
|
boolean deleteBool = smCountLowGroupDataMapper.deleteDetalDataByMainId(jttzbd+"_dt1",id);//明细表插入数据之前,先执行删除语句
|
||||||
|
if (deleteBool){
|
||||||
|
//执行明细表插入逻辑
|
||||||
|
String ejdw_id = smCountLowGroupDataMapper.selectDetailTableSouceId(ejdwtzb_name,htbm1);
|
||||||
|
List<Map<String,Object>> souceDetailDatas = smCountLowGroupDataMapper.selectDetailTableSouceData(ejdwtzb_name+"_dt1",ejdw_id);
|
||||||
|
if (souceDetailDatas.size()==0) return;
|
||||||
|
for (Map<String, Object> souceDetailData : souceDetailDatas) {
|
||||||
|
Map<String, Object> dealwithData = new HashMap<>();//根据配置表处理完需要字段后的数据Map
|
||||||
|
for (String key : detalTablekeys) {
|
||||||
|
dealwithData.put(key,souceDetailData.get(key));
|
||||||
|
}
|
||||||
|
//将mainid拼进去
|
||||||
|
dealwithData.put("mainid",id);
|
||||||
|
//开始插入明细表数据
|
||||||
|
PrepSqlResultImpl prepSqlResult = builderSqlImpl.insertSql(jttzbd+"_dt1", dealwithData);
|
||||||
|
boolean detailInsertBool = insertDatailRS.executeUpdate(prepSqlResult.getSqlStr(), prepSqlResult.getArgs());
|
||||||
|
if (detailInsertBool){
|
||||||
|
successNum++;
|
||||||
|
}else {
|
||||||
|
failNum++;
|
||||||
|
logger.error("明细表数据插入失败,SQL:["+prepSqlResult+"------失败次数:"+failNum+"]");
|
||||||
|
}
|
||||||
|
logger.info("明细表数据插入成功数量:"+successNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("报错=="+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方法描述 : 将数据插入表单建模
|
||||||
|
* @param tablename 建模表明
|
||||||
|
* @param userid 创建人id
|
||||||
|
* @param map 数据map
|
||||||
|
* @return int 返回数据id
|
||||||
|
*/
|
||||||
|
public int createmodedata(String tablename, int userid, Map<String, Object> map) {
|
||||||
|
Integer modeid = getModeidByTableName(tablename);
|
||||||
|
int dataid = 0;
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
String uuid = map.containsKey("modeuuid") ? map.get("modeuuid").toString() : UUID.randomUUID().toString();
|
||||||
|
boolean flag = rs.execute("insert into " + tablename
|
||||||
|
+ "(modeuuid,modedatacreater,modedatacreatedate,modedatacreatetime,formmodeid) values('" + uuid + "',"
|
||||||
|
+ userid + ",'" + TimeUtil.getCurrentDateString() + "','" + TimeUtil.getOnlyCurrentTimeString() + "',"
|
||||||
|
+ modeid + ")");
|
||||||
|
if (flag) {
|
||||||
|
rs.execute("select id from " + tablename + " where modeuuid='" + uuid + "'");
|
||||||
|
rs.next();
|
||||||
|
dataid = weaver.general.Util.getIntValue(rs.getString("id"));
|
||||||
|
|
||||||
|
if (dataid > 0) {
|
||||||
|
// 遍历数据 进行update
|
||||||
|
String updatesql = "update " + tablename + " set ";
|
||||||
|
Set<String> keySet = map.keySet();
|
||||||
|
for (String key : keySet) {
|
||||||
|
updatesql += key + "='" + map.get(key).toString() + "',";
|
||||||
|
}
|
||||||
|
if (updatesql.endsWith(",")) {
|
||||||
|
updatesql = updatesql.substring(0, updatesql.length() - 1);
|
||||||
|
|
||||||
|
updatesql += " where id=" + dataid;
|
||||||
|
boolean execute = rs.execute(updatesql);
|
||||||
|
if(!execute){
|
||||||
|
logger.info("出错的sql==="+updatesql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 进行权限重构
|
||||||
|
*/
|
||||||
|
ModeRightInfo moderight = new ModeRightInfo();
|
||||||
|
moderight.editModeDataShare(userid, modeid, dataid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Integer getModeidByTableName(String tablename) {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String sql = "select b.TABLENAME,a.FORMID,a.id modeid from modeinfo a left join workflow_bill b on a.FORMID=b.id where b.TABLENAME= '"
|
||||||
|
+ tablename + "'";
|
||||||
|
rs.execute(sql);
|
||||||
|
rs.next();
|
||||||
|
return Math.abs(rs.getInt("modeid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import com.google.common.base.Strings;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.apache.commons.collections.MapUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
|
@ -61,7 +60,7 @@ public class DealWithMapping extends ToolUtil {
|
||||||
private RecordSet tempRs;
|
private RecordSet tempRs;
|
||||||
|
|
||||||
private DealWithMapper mapper = null;
|
private DealWithMapper mapper = null;
|
||||||
|
|
||||||
private final Logger logger = aiyh.utils.Util.getLogger("json-util");
|
private final Logger logger = aiyh.utils.Util.getLogger("json-util");
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -115,19 +114,23 @@ public class DealWithMapping extends ToolUtil {
|
||||||
|| "NUMBER".equalsIgnoreCase(type) || "INTEGER".equalsIgnoreCase(type)
|
|| "NUMBER".equalsIgnoreCase(type) || "INTEGER".equalsIgnoreCase(type)
|
||||||
|| "TINYINT".equalsIgnoreCase(type) || "SMALLINT".equalsIgnoreCase(type)) {
|
|| "TINYINT".equalsIgnoreCase(type) || "SMALLINT".equalsIgnoreCase(type)) {
|
||||||
map.put(key, rs.getInt(i) == -1 ? rs.getString(i) : rs.getInt(i));
|
map.put(key, rs.getInt(i) == -1 ? rs.getString(i) : rs.getInt(i));
|
||||||
|
map.put(key.toLowerCase(), rs.getInt(i) == -1 ? rs.getString(i) : rs.getInt(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("FLOAT".equalsIgnoreCase(type)) {
|
if ("FLOAT".equalsIgnoreCase(type)) {
|
||||||
map.put(key, rs.getFloat(i));
|
map.put(key, rs.getFloat(i));
|
||||||
|
map.put(key.toLowerCase(), rs.getFloat(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("DATE".equalsIgnoreCase(type) || "TIMESTAMP".equalsIgnoreCase(type)
|
if ("DATE".equalsIgnoreCase(type) || "TIMESTAMP".equalsIgnoreCase(type)
|
||||||
|| "DATETIME".equalsIgnoreCase(type)) {
|
|| "DATETIME".equalsIgnoreCase(type)) {
|
||||||
map.put(key, rs.getString(i));
|
map.put(key, rs.getString(i));
|
||||||
|
map.put(key.toLowerCase(), rs.getString(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("DOUBLE".equalsIgnoreCase(type)) {
|
if ("DOUBLE".equalsIgnoreCase(type)) {
|
||||||
map.put(key, Util.getDoubleValue(rs.getString(i)));
|
map.put(key, Util.getDoubleValue(rs.getString(i)));
|
||||||
|
map.put(key.toLowerCase(), Util.getDoubleValue(rs.getString(i)));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) {
|
if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) {
|
||||||
|
@ -144,10 +147,12 @@ public class DealWithMapping extends ToolUtil {
|
||||||
decimal = new BigDecimal(val);
|
decimal = new BigDecimal(val);
|
||||||
}
|
}
|
||||||
map.put(key, decimal);
|
map.put(key, decimal);
|
||||||
|
map.put(key.toLowerCase(), decimal);
|
||||||
// map.put(key, rs.getDouble(i));
|
// map.put(key, rs.getDouble(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
map.put(key, rs.getString(i));
|
map.put(key, rs.getString(i));
|
||||||
|
map.put(key.toLowerCase(), rs.getString(i));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -675,6 +680,12 @@ public class DealWithMapping extends ToolUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 自定义sql用{mainTable}代替当前表名 解决极兔ncc问题
|
||||||
|
if(StringUtils.isNotBlank(mainTable)){
|
||||||
|
valueContext = valueContext.replace("{mainTable}", mainTable);
|
||||||
|
}else {
|
||||||
|
logger.error("mainTable is null!");
|
||||||
|
}
|
||||||
String requestId = Util.null2String(mainMap.get("requestid"));
|
String requestId = Util.null2String(mainMap.get("requestid"));
|
||||||
tempValue = "'" + tempValue + "'";
|
tempValue = "'" + tempValue + "'";
|
||||||
value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId);
|
value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId);
|
||||||
|
@ -688,7 +699,9 @@ public class DealWithMapping extends ToolUtil {
|
||||||
// 数据id
|
// 数据id
|
||||||
case MAIN_DATA_ID: {
|
case MAIN_DATA_ID: {
|
||||||
if ("1".equals(childSource)) {
|
if ("1".equals(childSource)) {
|
||||||
value = Util.null2String(detailMap.get("id"));
|
if (Objects.nonNull(detailMap)) {
|
||||||
|
value = Util.null2String(detailMap.get("id"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
value = Util.null2String(mainMap.get("id"));
|
value = Util.null2String(mainMap.get("id"));
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1020,7 @@ public class DealWithMapping extends ToolUtil {
|
||||||
} else if ("0".equals(childSource)) {
|
} else if ("0".equals(childSource)) {
|
||||||
tempValue = Util.null2String(mainMap.get(fieldName));
|
tempValue = Util.null2String(mainMap.get(fieldName));
|
||||||
if ("".equals(tempValue)) {
|
if ("".equals(tempValue)) {
|
||||||
tempValue = Util.null2String(detailMap.get(fieldNameLower));
|
tempValue = Util.null2String(mainMap.get(fieldNameLower));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tempValue = Util.null2String(relationRs.getString(fieldName));
|
tempValue = Util.null2String(relationRs.getString(fieldName));
|
||||||
|
@ -1021,6 +1034,12 @@ public class DealWithMapping extends ToolUtil {
|
||||||
tempValue = Util.null2String(tempRs.getString(fieldName));
|
tempValue = Util.null2String(tempRs.getString(fieldName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 自定义sql用{mainTable}代替当前表名 解决极兔ncc问题
|
||||||
|
if(StringUtils.isNotBlank(mainTable)){
|
||||||
|
valueContext = valueContext.replace("{mainTable}", mainTable);
|
||||||
|
}else {
|
||||||
|
logger.error("mainTable is null!");
|
||||||
|
}
|
||||||
tempValue = "'" + tempValue + "'";
|
tempValue = "'" + tempValue + "'";
|
||||||
value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId);
|
value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId);
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1087,7 @@ public class DealWithMapping extends ToolUtil {
|
||||||
} else {
|
} else {
|
||||||
value = Util.null2String(mainMap.get(fieldName));
|
value = Util.null2String(mainMap.get(fieldName));
|
||||||
if ("".equals(value)) {
|
if ("".equals(value)) {
|
||||||
value = Util.null2String(detailMap.get(fieldNameLower));
|
value = Util.null2String(mainMap.get(fieldNameLower));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fileIds = Util.null2String(value);
|
String fileIds = Util.null2String(value);
|
||||||
|
@ -1108,7 +1127,7 @@ public class DealWithMapping extends ToolUtil {
|
||||||
} else {
|
} else {
|
||||||
value = Util.null2String(mainMap.get(fieldName));
|
value = Util.null2String(mainMap.get(fieldName));
|
||||||
if ("".equals(value)) {
|
if ("".equals(value)) {
|
||||||
value = Util.null2String(detailMap.get(fieldNameLower));
|
value = Util.null2String(mainMap.get(fieldNameLower));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1521,33 +1540,6 @@ public class DealWithMapping extends ToolUtil {
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
paramStr = Arrays.stream(split).skip(1).collect(Collectors.joining("?"));
|
paramStr = Arrays.stream(split).skip(1).collect(Collectors.joining("?"));
|
||||||
}
|
}
|
||||||
/* 获取?后的参数:"weaver.aiyh_jitu.pushdata.service.toones.GetRequestValueCusGetValueImpl?" +
|
|
||||||
"requestType=get&apiOnlyMark=getAssign&valueKey=data&assign=#{main.zd2}&" +
|
|
||||||
"#processorClass=weaver.aiyh_jitu.pushdata.service.toones.GetAssignProcessorProcessorImpl" +
|
|
||||||
"&afterProcessor.hrmId=#{main.zd2}&beforeProcessor.hrmId=#{main.zd2}&高=udh高殿下g" +
|
|
||||||
"&assignValue=#sql{select workcode from hrmresource where id = #{main.zd1} and test = #{h-hah} and a in (${hrmids})}&hah=haode";
|
|
||||||
最终获取到的map,如下
|
|
||||||
key:requestType
|
|
||||||
value:get
|
|
||||||
key:apiOnlyMark
|
|
||||||
value:getAssign
|
|
||||||
key:valueKey
|
|
||||||
value:data
|
|
||||||
key:assign
|
|
||||||
value:#{main.zd2}
|
|
||||||
key:#processorClass
|
|
||||||
value:weaver.aiyh_jitu.pushdata.service.toones.GetAssignProcessorProcessorImpl
|
|
||||||
key:afterProcessor.hrmId
|
|
||||||
value:#{main.zd2}
|
|
||||||
key:beforeProcessor.hrmId
|
|
||||||
value:#{main.zd2}
|
|
||||||
key:高
|
|
||||||
value:udh高殿下g
|
|
||||||
key:assignValue
|
|
||||||
value:#sql{select workcode from hrmresource where id = #{main.zd1} and test = #{h-hah} and a in (${hrmids})}
|
|
||||||
key:hah
|
|
||||||
value:haode*/
|
|
||||||
// 最终通过反射调用weaver.aiyh_jitu.pushdata.service.GetAssignProcessorProcessorImpl类,将参数传递给这个类, 使用``包裹的字符串会被解析为一个字符串
|
|
||||||
String pattern = "&?(?<key>([#.\\w\\u4E00-\\u9FA5]+))=" +
|
String pattern = "&?(?<key>([#.\\w\\u4E00-\\u9FA5]+))=" +
|
||||||
"(?<value>((`([^`]*)`)|" +
|
"(?<value>((`([^`]*)`)|" +
|
||||||
"((#(\\{|sql\\{))?([():/\\-$_#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?";
|
"((#(\\{|sql\\{))?([():/\\-$_#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?";
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
package weaver.xuanran.wang.eighty_five_degreec.sap.action;
|
package weaver.xuanran.wang.eighty_five_degreec.sap.action;
|
||||||
|
|
||||||
import aiyh.utils.ThreadPoolConfig;
|
|
||||||
import aiyh.utils.action.SafeCusBaseAction;
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
import aiyh.utils.annotation.ActionDesc;
|
import aiyh.utils.annotation.*;
|
||||||
import aiyh.utils.annotation.PrintParamMark;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import aiyh.utils.annotation.RequiredMark;
|
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
import weaver.soa.workflow.request.RequestInfo;
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>将流程数据推送到sap中</h1>
|
* <h1>将流程数据推送到sap中</h1>
|
||||||
|
@ -23,31 +20,53 @@ import java.util.concurrent.ExecutorService;
|
||||||
public class WorkflowToSap extends SafeCusBaseAction {
|
public class WorkflowToSap extends SafeCusBaseAction {
|
||||||
|
|
||||||
private final WorkflowToSapService service = new WorkflowToSapServiceImpl();
|
private final WorkflowToSapService service = new WorkflowToSapServiceImpl();
|
||||||
private final ExecutorService pool = ThreadPoolConfig.createThreadPoolInstance();
|
|
||||||
@PrintParamMark
|
@PrintParamMark
|
||||||
@RequiredMark("配置表唯一标识")
|
@RequiredMark("配置表唯一标识")
|
||||||
|
@ActionDefaultTestValue(value = "****")
|
||||||
private String uniqueCode;
|
private String uniqueCode;
|
||||||
@PrintParamMark
|
@PrintParamMark
|
||||||
@RequiredMark("日志表模块id")
|
@RequiredMark("日志表模块id")
|
||||||
|
@ActionDefaultTestValue(value = "11")
|
||||||
private String modelId;
|
private String modelId;
|
||||||
|
@PrintParamMark
|
||||||
|
@RequiredMark("成功失败/标识字段")
|
||||||
|
@ActionDefaultTestValue(value = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.TYPE")
|
||||||
|
private String successField;
|
||||||
|
@PrintParamMark
|
||||||
|
@RequiredMark("成功时候的值")
|
||||||
|
@ActionDefaultTestValue(value = "T")
|
||||||
|
private String successVal;
|
||||||
|
@PrintParamMark
|
||||||
|
@RequiredMark("消息提示字段")
|
||||||
|
@ActionDefaultTestValue(value = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.MESSAGE")
|
||||||
|
private String messageField;
|
||||||
|
|
||||||
@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) {
|
||||||
|
String xml = "";
|
||||||
|
String response = "";
|
||||||
|
String url = "";
|
||||||
|
String error = "";
|
||||||
|
boolean success = true;
|
||||||
try {
|
try {
|
||||||
MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable);
|
MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable);
|
||||||
String xml = service.convertXml(config, requestId, billTable);
|
url = config.getRequestUrl();
|
||||||
String response = service.sendToSap();
|
xml = service.convertXml(config, requestId, billTable);
|
||||||
pool.execute(()->{
|
response = service.sendToSap(config.getRequestUrl(), xml);
|
||||||
try {
|
service.parseResponse(response, successField, successVal, messageField);
|
||||||
service.logToOA(modelId, config.getRequestUrl(), requestId, xml, response);
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error("日志数据写入建模失败! " + e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("流程数据推送SAP error : " + e.getMessage());
|
log.error("流程数据推送SAP error : " + e.getMessage());
|
||||||
|
error = e.getMessage();
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
service.logToOA(modelId, url, requestId, xml, response, error);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("日志数据写入建模失败! " + e.getMessage());
|
||||||
|
}
|
||||||
|
if(!success){
|
||||||
|
throw new CustomerException("WorkflowToSap Action execute error : " + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class DetailRequestConfig {
|
public class DetailRequestConfig {
|
||||||
|
@SqlDbFieldAnn("nodeType")
|
||||||
|
@SqlOracleDbFieldAnn("NODETYPE")
|
||||||
|
private String nodeType;
|
||||||
@SqlDbFieldAnn("paramName")
|
@SqlDbFieldAnn("paramName")
|
||||||
@SqlOracleDbFieldAnn("PARAMNAME")
|
@SqlOracleDbFieldAnn("PARAMNAME")
|
||||||
private String paramName;
|
private String paramName;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConf
|
||||||
public interface WorkflowToSapService {
|
public interface WorkflowToSapService {
|
||||||
MainRequestConfig getRequestConfig(String uniqueCode, String tableName);
|
MainRequestConfig getRequestConfig(String uniqueCode, String tableName);
|
||||||
String convertXml(MainRequestConfig config, String requestId, String tableName);
|
String convertXml(MainRequestConfig config, String requestId, String tableName);
|
||||||
String sendToSap();
|
String sendToSap(String url, String xml);
|
||||||
void logToOA(String modelId, String url, String requestId, String requestXml, String response);
|
String parseResponse(String response, String responseField, String successField, String messageField);
|
||||||
|
void logToOA(String modelId, String url, String requestId, String requestXml, String response, String error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package weaver.xuanran.wang.eighty_five_degreec.sap.service.impl;
|
package weaver.xuanran.wang.eighty_five_degreec.sap.service.impl;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.json.XML;
|
||||||
|
import weaver.xuanran.wang.common.util.CusData2OA;
|
||||||
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
|
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
|
||||||
|
@ -8,6 +13,7 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +24,7 @@ import java.util.HashMap;
|
||||||
*/
|
*/
|
||||||
public class WorkflowToSapServiceImpl implements WorkflowToSapService {
|
public class WorkflowToSapServiceImpl implements WorkflowToSapService {
|
||||||
private final ReadConfigUtil configUtil = new ReadConfigUtil();
|
private final ReadConfigUtil configUtil = new ReadConfigUtil();
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
@Override
|
@Override
|
||||||
public MainRequestConfig getRequestConfig(String uniqueCode, String tableName) {
|
public MainRequestConfig getRequestConfig(String uniqueCode, String tableName) {
|
||||||
return configUtil.getConfigByUniqueCode(uniqueCode, tableName);
|
return configUtil.getConfigByUniqueCode(uniqueCode, tableName);
|
||||||
|
@ -30,20 +36,40 @@ public class WorkflowToSapServiceImpl implements WorkflowToSapService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String sendToSap() {
|
public String sendToSap(String url, String xml) {
|
||||||
// TODO sap接口调用方式暂时搞不了
|
return configUtil.callSap(url, xml);
|
||||||
return "";
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parseResponse(String response, String successField, String successVal, String messageField) {
|
||||||
|
String responseVal;
|
||||||
|
JSONObject xmlResponseObj;
|
||||||
|
try {
|
||||||
|
xmlResponseObj = XML.toJSONObject(response);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException("xml to jsonObj error : " + e.getMessage());
|
||||||
|
}
|
||||||
|
Map<String, Object> responseMap = com.alibaba.fastjson.JSONObject.parseObject(xmlResponseObj.toString(), Map.class);
|
||||||
|
responseVal = configUtil.parseMap(responseMap, successField);
|
||||||
|
if(!successVal.equals(responseVal)){
|
||||||
|
throw new CustomerException("successVal not equals responseVal! current responseVal is : "
|
||||||
|
+ responseVal + ", the successVal is " + successVal + ", responseMsg is " + configUtil.parseMap(responseMap, messageField));
|
||||||
|
}
|
||||||
|
return responseVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logToOA(String modelId, String url, String requestId,
|
public void logToOA(String modelId, String url, String requestId,
|
||||||
String requestXml, String response) {
|
String requestXml, String response, String error) {
|
||||||
HashMap<String, Object> params = new HashMap<>();
|
HashMap<String, Object> params = new HashMap<>();
|
||||||
params.put("requestUrlAndFunName", url);
|
params.put("requestUrl", url);
|
||||||
params.put("reqId", requestId);
|
params.put("reqId", requestId);
|
||||||
params.put("requestXml", requestXml);
|
params.put("requestXml", requestXml);
|
||||||
params.put("responseCode","");
|
params.put("responseCode","");
|
||||||
params.put("erpResponse", response);
|
params.put("sapResponse", response);
|
||||||
CusInfoToOAUtil.getDataId(Util.getIntValue(modelId, -1), params, "select id from #{tableName} where reqId = ?", Collections.singletonList(requestId));
|
params.put("error", error);
|
||||||
|
log.info("写入日志参数 : " + com.alibaba.fastjson.JSONObject.toJSONString(params));
|
||||||
|
CusData2OA.writeToModel(modelId, "select id from #{tableName} where reqId = " + requestId, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package weaver.xuanran.wang.eighty_five_degreec.sap.util;
|
package weaver.xuanran.wang.eighty_five_degreec.sap.util;
|
||||||
|
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -12,11 +13,10 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.DetailRequestCo
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
||||||
import weaver.zwl.common.ToolUtil;
|
import weaver.zwl.common.ToolUtil;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
@ -55,7 +55,7 @@ public class ReadConfigUtil extends ToolUtil {
|
||||||
}
|
}
|
||||||
int mainId = Util.getIntValue(res.getId());
|
int mainId = Util.getIntValue(res.getId());
|
||||||
// 配置明细表
|
// 配置明细表
|
||||||
sql = "select paramName,paramType,parentName,getValueType,workflowField,valueContext,fv.tableName," +
|
sql = "select nodeType,paramName,paramType,parentName,getValueType,workflowField,valueContext,fv.tableName," +
|
||||||
" fv.id fieldId,fv.fieldname,fv.indexdesc " +
|
" fv.id fieldId,fv.fieldname,fv.indexdesc " +
|
||||||
" from uf_memsic_createXml_dt1 config " +
|
" from uf_memsic_createXml_dt1 config " +
|
||||||
" left join workflow_field_table_view fv on config.workflowField = fv.id " +
|
" left join workflow_field_table_view fv on config.workflowField = fv.id " +
|
||||||
|
@ -88,7 +88,7 @@ public class ReadConfigUtil extends ToolUtil {
|
||||||
* @return 返回类对象
|
* @return 返回类对象
|
||||||
**/
|
**/
|
||||||
public static <T> T getInstance(RecordSet queryRs, Class<T> clazz) {
|
public static <T> T getInstance(RecordSet queryRs, Class<T> clazz) {
|
||||||
T res = null;
|
T res;
|
||||||
try {
|
try {
|
||||||
res = clazz.newInstance();
|
res = clazz.newInstance();
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
|
@ -443,15 +443,35 @@ public class ReadConfigUtil extends ToolUtil {
|
||||||
// 明细
|
// 明细
|
||||||
String[] detailIdArr = detailIndex.split(",");
|
String[] detailIdArr = detailIndex.split(",");
|
||||||
StringBuilder detailSb = new StringBuilder();
|
StringBuilder detailSb = new StringBuilder();
|
||||||
|
|
||||||
for (String detailId : detailIdArr) {
|
for (String detailId : detailIdArr) {
|
||||||
|
String nodeName;
|
||||||
|
List<DetailRequestConfig> nodeList = requestConfigList.stream()
|
||||||
|
.filter(item -> "0".equals(item.getNodeType())).collect(Collectors.toList());
|
||||||
|
if(CollectionUtils.isNotEmpty(nodeList)){
|
||||||
|
nodeName = nodeList.get(0).getParamName();
|
||||||
|
} else {
|
||||||
|
nodeName = "";
|
||||||
|
}
|
||||||
List<DetailRequestConfig> detailCollect = requestConfigList.stream()
|
List<DetailRequestConfig> detailCollect = requestConfigList.stream()
|
||||||
.filter(item -> "detailRecord".equals(item.getParentName())
|
.filter(item -> {
|
||||||
).collect(Collectors.toList());
|
if(StringUtils.isNotBlank(nodeName)){
|
||||||
|
return nodeName.equals(item.getParentName());
|
||||||
|
}else {
|
||||||
|
return "detailRecord".equals(item.getParentName());
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
String detailSql = "select * from " + tableName + "_dt" + detailId + " where mainid = ?";
|
String detailSql = "select * from " + tableName + "_dt" + detailId + " where mainid = ?";
|
||||||
if (detailRs.executeQuery(detailSql, mainId)) {
|
if (detailRs.executeQuery(detailSql, mainId)) {
|
||||||
int count = 1;
|
int count = 1;
|
||||||
while (detailRs.next()) {
|
while (detailRs.next()) {
|
||||||
|
if(StringUtils.isNotBlank(nodeName)){
|
||||||
|
detailSb.append("<").append(nodeName).append(">\n");
|
||||||
|
}
|
||||||
appendXml(detailSb, detailCollect, mainRs, detailRs, count++);
|
appendXml(detailSb, detailCollect, mainRs, detailRs, count++);
|
||||||
|
if(StringUtils.isNotBlank(nodeName)){
|
||||||
|
detailSb.append("</").append(nodeName).append(">\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,7 +494,7 @@ public class ReadConfigUtil extends ToolUtil {
|
||||||
.append(paramName)
|
.append(paramName)
|
||||||
.append(">")
|
.append(">")
|
||||||
.append(getParamValue(requestConfig, mainRs, detailRs,count))
|
.append(getParamValue(requestConfig, mainRs, detailRs,count))
|
||||||
.append("<")
|
.append("</")
|
||||||
.append(paramName)
|
.append(paramName)
|
||||||
.append(">")
|
.append(">")
|
||||||
.append("\n");
|
.append("\n");
|
||||||
|
@ -544,22 +564,80 @@ public class ReadConfigUtil extends ToolUtil {
|
||||||
* @return 响应数据
|
* @return 响应数据
|
||||||
*/
|
*/
|
||||||
public String parseMap(Map<String, Object> responseMap, String responseField){
|
public String parseMap(Map<String, Object> responseMap, String responseField){
|
||||||
String[] strArr = responseField.split("\\.");
|
try {
|
||||||
int i = 0;
|
String[] strArr = responseField.split("\\.");
|
||||||
while (i < strArr.length - 1){
|
int i = 0;
|
||||||
Object o = responseMap.get(strArr[i]);
|
while (i < strArr.length - 1){
|
||||||
if(o instanceof Map){
|
Object o = responseMap.get(strArr[i]);
|
||||||
responseMap = (Map<String, Object>) o;
|
if(o instanceof Map){
|
||||||
}else if(o instanceof List){
|
responseMap = (Map<String, Object>) o;
|
||||||
List<Map<String, Object>> list = (List<Map<String, Object>>) o;
|
}else if(o instanceof List){
|
||||||
if(CollectionUtils.isEmpty(list)){
|
List<Map<String, Object>> list = (List<Map<String, Object>>) o;
|
||||||
return "";
|
if(CollectionUtils.isEmpty(list)){
|
||||||
}
|
return "";
|
||||||
responseMap = list.get(0);
|
}
|
||||||
}
|
responseMap = list.get(0);
|
||||||
i++;
|
}
|
||||||
}
|
i++;
|
||||||
return Util.null2String(responseMap.get(strArr[strArr.length - 1]));
|
}
|
||||||
|
return Util.null2String(responseMap.get(strArr[strArr.length - 1]));
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException("parseMap error : " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>调用sap接口</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/5/15 14:05
|
||||||
|
* @param url 接口地址
|
||||||
|
* @param xml 报文xml
|
||||||
|
* @return 接口响应
|
||||||
|
**/
|
||||||
|
public String callSap(String url, String xml){
|
||||||
|
OutputStreamWriter writer = null;
|
||||||
|
BufferedReader reader = null;
|
||||||
|
try {
|
||||||
|
String userName = aiyh.utils.Util.null2DefaultStr(getSystemParamValue("sapUserName"),"");
|
||||||
|
String password = aiyh.utils.Util.null2DefaultStr(getSystemParamValue("sapPassword"),"");
|
||||||
|
log.info("callSap userName : [ " + userName + " ], password : [ " + password + " ]");
|
||||||
|
String authString = userName + ":" + password;
|
||||||
|
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||||
|
String authStringEnc = new String(authEncBytes);
|
||||||
|
URL serviceUrl = new URL(url);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection();
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
|
||||||
|
connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
writer = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
|
||||||
|
writer.write(xml);
|
||||||
|
writer.close();
|
||||||
|
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||||
|
String line;
|
||||||
|
StringBuilder responseBuilder = new StringBuilder();
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
responseBuilder.append(line);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
String response = responseBuilder.toString();
|
||||||
|
if(StringUtils.isBlank(response)){
|
||||||
|
throw new CustomerException("sap response is empty!");
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException("callSap error : " + e.getMessage());
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(writer != null){
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
if(reader != null){
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("关流异常 : " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ public class ShBigDataUtil {
|
||||||
WHILTE_LIST.add("loginErrorSendRedirectUrl");
|
WHILTE_LIST.add("loginErrorSendRedirectUrl");
|
||||||
WHILTE_LIST.add("getUserIdDebug");
|
WHILTE_LIST.add("getUserIdDebug");
|
||||||
WHILTE_LIST.add("getUserIdDebugOutKey");
|
WHILTE_LIST.add("getUserIdDebugOutKey");
|
||||||
|
WHILTE_LIST.add("ssoInterfaceCompareField");
|
||||||
|
WHILTE_LIST.add("ssoOaCompareField");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
package weaver.youhong.ai.geerde.action.submitfirst;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
|
import aiyh.utils.annotation.*;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
import weaver.youhong.ai.geerde.action.submitfirst.mapper.AutoSubmitFirstMapper;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>自动提交第一次经过节点的流程</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/17 18:52</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@ActionDesc(author = "youhong.ai", value = "自动流程提交,需要挂在需要提交的流程节点的节点前或者前一个节点的节点后或者两个节点的流转出口线上")
|
||||||
|
public class AutoSubmitFirstAction extends SafeCusBaseAction {
|
||||||
|
|
||||||
|
private final AutoSubmitFirstMapper mapper = Util.getMapper(AutoSubmitFirstMapper.class);
|
||||||
|
|
||||||
|
@RequiredMark(value = "account", desc = "主表流程经过标识字段,整数或单行文本字段名都可以")
|
||||||
|
@PrintParamMark
|
||||||
|
@ActionDefaultTestValue("account")
|
||||||
|
private String accountField;
|
||||||
|
|
||||||
|
@ActionOptionalParam(value = "1", desc = "流程操作人id,默认为1-系统管理员")
|
||||||
|
@PrintParamMark
|
||||||
|
private String operator = "1";
|
||||||
|
|
||||||
|
private static final Map<String, Integer> oneRequestLock = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public void doSubmit(String requestId, String billTable,
|
||||||
|
int workflowId, User user,
|
||||||
|
RequestInfo requestInfo) {
|
||||||
|
// 如果存在当前流程id的值,表示当前action属于锁住状态,需要进入线程睡眠等待
|
||||||
|
if (oneRequestLock.containsKey(requestId)) {
|
||||||
|
log.info("流程正在异步提交中,使用线程排队");
|
||||||
|
new Thread(() -> {
|
||||||
|
log.info("开始异步等待上一个节点提交");
|
||||||
|
while (oneRequestLock.containsKey(requestId)) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000L * 60 * oneRequestLock.get(requestId));
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.error("线程休眠失败!");
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("开始提交流程!");
|
||||||
|
oneRequestLock.put(requestId, 2);
|
||||||
|
Map<String, Object> mainMap = mapper.selectMainMap(billTable, requestId);
|
||||||
|
String currentNode = mapper.selectCurrentNodeId(requestId);
|
||||||
|
if (mainMap.containsKey(accountField)) {
|
||||||
|
String mark = Util.null2String(mainMap.get(accountField));
|
||||||
|
String nodesStr = currentNode;
|
||||||
|
if (StrUtil.isNotBlank(mark)) {
|
||||||
|
String[] split = mark.split(",");
|
||||||
|
List<String> nodes = Arrays.asList(split);
|
||||||
|
if (nodes.contains(currentNode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nodesStr += "," + Util.join(nodes, ",");
|
||||||
|
}
|
||||||
|
int creatorId = requestInfo.getRequestManager().getCreater();
|
||||||
|
String finalNodesStr = nodesStr;
|
||||||
|
Util.submitWorkflowThread(Integer.parseInt(requestId), creatorId,
|
||||||
|
"", 60, flag -> {
|
||||||
|
oneRequestLock.remove(requestId);
|
||||||
|
if (flag) {
|
||||||
|
mapper.updateMark(billTable, accountField, finalNodesStr,
|
||||||
|
Util.null2String(mainMap.get("id")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 如果没有锁住,异步延时提交,延时3分钟
|
||||||
|
log.info("没有锁住流程,开始异步提交流程");
|
||||||
|
oneRequestLock.put(requestId, 2);
|
||||||
|
Map<String, String> mainTableValue = getMainTableValue(requestInfo);
|
||||||
|
String currentNode = mapper.selectCurrentNodeId(requestId);
|
||||||
|
int creatorId = requestInfo.getRequestManager().getCreater();
|
||||||
|
// 判断是否存在统计字段
|
||||||
|
if (mainTableValue.containsKey(accountField)) {
|
||||||
|
// 获取统计字段的值
|
||||||
|
String mark = mainTableValue.get(accountField);
|
||||||
|
String nodesStr = currentNode;
|
||||||
|
if (StrUtil.isNotBlank(mark)) {
|
||||||
|
String[] split = mark.split(",");
|
||||||
|
List<String> nodes = Arrays.asList(split);
|
||||||
|
if (nodes.contains(currentNode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nodesStr += "," + Util.join(nodes, ",");
|
||||||
|
}
|
||||||
|
String finalNodesStr = nodesStr;
|
||||||
|
Util.submitWorkflowThread(Integer.parseInt(requestId), creatorId,
|
||||||
|
"", 60, flag -> {
|
||||||
|
oneRequestLock.remove(requestId);
|
||||||
|
if (flag) {
|
||||||
|
log.info("异步提交流程完成!");
|
||||||
|
// 提交成功,更新标识
|
||||||
|
mapper.updateMark(billTable, accountField, finalNodesStr,
|
||||||
|
mainTableValue.get("id"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package weaver.youhong.ai.geerde.action.submitfirst.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.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>自动提交流程标识更新</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/17 18:56</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@SqlMapper
|
||||||
|
public interface AutoSubmitFirstMapper {
|
||||||
|
|
||||||
|
@Update("update $t{tableName} set $t{fieldName} = #{value} where id = #{id}")
|
||||||
|
boolean updateMark(@ParamMapper("tableName") String tableName,
|
||||||
|
@ParamMapper("fieldName") String fieldName,
|
||||||
|
@ParamMapper("value") String value,
|
||||||
|
@ParamMapper("id") String id);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select * from $t{tableName} where requestid = #{requestId}")
|
||||||
|
Map<String, Object> selectMainMap(@ParamMapper("tableName") String tableName, @ParamMapper("requestId") String requestId);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select currentnodeid from workflow_requestbase where requestid = #{requestId}")
|
||||||
|
String selectCurrentNodeId(@ParamMapper("requestId") String requestId);
|
||||||
|
}
|
|
@ -20,8 +20,10 @@ import javax.ws.rs.core.MediaType;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>知识产权局ca电子签</h1>
|
* <h1>知识产权局ca电子签</h1>
|
||||||
|
@ -87,8 +89,13 @@ public class CaElectronicSignatureAction extends SafeCusBaseAction {
|
||||||
throw new CustomerException(responeVo.getCode() + ", fetch ca sign fail! ");
|
throw new CustomerException(responeVo.getCode() + ", fetch ca sign fail! ");
|
||||||
}
|
}
|
||||||
Map<String, Object> responseMap = responeVo.getResponseMap();
|
Map<String, Object> responseMap = responeVo.getResponseMap();
|
||||||
String documentNo = Util.null2String(responseMap.get("document_no"));
|
Map<String, Object> data = (Map<String, Object>) responseMap.get("data");
|
||||||
String pdf = Util.null2String(responseMap.get("ofd"));
|
if (Objects.isNull(data)) {
|
||||||
|
Util.actionFail(requestInfo.getRequestManager(), URLDecoder.decode(Util.null2String(responseMap.get("ret_msg")), "UTF-8"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String documentNo = Util.null2String(data.get("document_no"));
|
||||||
|
String pdf = Util.null2String(data.get("ofd"));
|
||||||
InputStream inputStream = base64ContentToFile(pdf);
|
InputStream inputStream = base64ContentToFile(pdf);
|
||||||
String docCategorys = Util.getDocCategorysByTable(String.valueOf(workflowId), signFileField, billTable);
|
String docCategorys = Util.getDocCategorysByTable(String.valueOf(workflowId), signFileField, billTable);
|
||||||
String[] docCategoryArr = docCategorys.split(",");
|
String[] docCategoryArr = docCategorys.split(",");
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package weaver.youhong.ai.intellectualproperty.cusgetvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.entity.DocImageInfo;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.file.ImageFileManager;
|
||||||
|
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
|
||||||
|
import weaver.youhong.ai.intellectualproperty.util.OFDReader;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>获取关键字页码</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/18 16:56</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class GetOfdKeywordPageValue implements CusInterfaceGetValue {
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(Map<String, Object> mainMap, Map<String, Object> detailMap, String currentValue, Map<String, String> pathParam) {
|
||||||
|
try {
|
||||||
|
DocImageInfo docImageInfo = Util.selectImageInfoByDocId(currentValue);
|
||||||
|
InputStream inputStream = ImageFileManager.getInputStreamById(docImageInfo.getImageFileId());
|
||||||
|
String filePath = Util.createTempFile(inputStream, docImageInfo.getImageFileName(), "ofd");
|
||||||
|
String keywordType = pathParam.get("keywordType");
|
||||||
|
String keywordValue = "";
|
||||||
|
String keyword = pathParam.get("keyword");
|
||||||
|
if (StrUtil.isNotBlank(keywordType)) {
|
||||||
|
if ("1".equals(keywordType)) {
|
||||||
|
keywordValue = Util.null2String(mainMap.get(keyword));
|
||||||
|
} else {
|
||||||
|
keywordValue = keyword;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
keywordValue = keyword;
|
||||||
|
}
|
||||||
|
OFDReader reader = new OFDReader(filePath, keywordValue);
|
||||||
|
List<OFDReader.KeywordInfoRange> keywordInfos = reader.findKeywords();
|
||||||
|
Files.delete(Paths.get(filePath));
|
||||||
|
if (keywordInfos.isEmpty()) {
|
||||||
|
throw new CustomerException("关键字定位异常!未找到关键字");
|
||||||
|
} else {
|
||||||
|
String pageNumber = keywordInfos.get(keywordInfos.size() - 1).getStart().getPageNumber();
|
||||||
|
return Integer.parseInt(pageNumber) + 1;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("关键字定位异常: " + Util.getErrString(e));
|
||||||
|
throw new CustomerException("关键字定位异常!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
package weaver.youhong.ai.intellectualproperty.util;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>ofd读区关键字</h2>
|
||||||
|
*/
|
||||||
|
public class OFDReader {
|
||||||
|
|
||||||
|
private final String ofdFilePath;
|
||||||
|
private final String keyword;
|
||||||
|
|
||||||
|
public OFDReader(String ofdFilePath, String keyword) {
|
||||||
|
this.ofdFilePath = ofdFilePath;
|
||||||
|
this.keyword = keyword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<KeywordInfoRange> findKeywords() throws Exception {
|
||||||
|
// 解析OFD.xml文件,获取OFD的根目录路径
|
||||||
|
String rootDirPath = parseOFDXmlAndGetRootDirPath();
|
||||||
|
if (rootDirPath == null) {
|
||||||
|
throw new Exception("Failed to parse OFD.xml file!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开OFD文件并获取ZipFile对象
|
||||||
|
ZipFile zipFile = new ZipFile(ofdFilePath);
|
||||||
|
|
||||||
|
// 获取Pages目录下的所有页面文件夹
|
||||||
|
List<String> pageFolders = getPageFolders(zipFile, rootDirPath);
|
||||||
|
if (pageFolders == null || pageFolders.isEmpty()) {
|
||||||
|
throw new Exception("No page found in the OFD file!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找所有关键字的位置信息
|
||||||
|
List<KeywordInfoRange> result = new ArrayList<>();
|
||||||
|
for (String pageFolder : pageFolders) {
|
||||||
|
KeywordInfoRange keywordInfo = findKeywordInPage(zipFile, pageFolder);
|
||||||
|
if (keywordInfo != null) {
|
||||||
|
result.add(keywordInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zipFile.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析OFD.xml文件并获取OFD的根目录路径
|
||||||
|
private String parseOFDXmlAndGetRootDirPath() throws Exception {
|
||||||
|
ZipFile zipFile = new ZipFile(ofdFilePath);
|
||||||
|
ZipEntry ofdXmlEntry = zipFile.getEntry("OFD.xml");
|
||||||
|
InputStream inputStream = zipFile.getInputStream(ofdXmlEntry);
|
||||||
|
|
||||||
|
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
|
||||||
|
NodeList docRootNodes = doc.getElementsByTagName("ofd:DocRoot");
|
||||||
|
if (docRootNodes.getLength() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String docRootPath = docRootNodes.item(0).getTextContent();
|
||||||
|
String[] docRootPathSegments = docRootPath.split("/");
|
||||||
|
if (docRootPathSegments.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return docRootPathSegments[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取Pages目录下的所有页面文件夹
|
||||||
|
private List<String> getPageFolders(ZipFile zipFile, String rootDirPath) {
|
||||||
|
List<String> pageFolders = new ArrayList<>();
|
||||||
|
String pagesDirPath = rootDirPath + "/Pages/";
|
||||||
|
String pagesPrefix = pagesDirPath + "Page_";
|
||||||
|
String pagesSuffix = "Content.xml";
|
||||||
|
// 遍历OFD文件中所有的ZipEntry对象,查找所有页面文件夹
|
||||||
|
zipFile.stream().forEach(entry -> {
|
||||||
|
if (entry.getName().startsWith(pagesDirPath) && entry.getName().startsWith(pagesPrefix) && entry.getName().endsWith(pagesSuffix) && !entry.getName().equals(pagesDirPath)) {
|
||||||
|
pageFolders.add(entry.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return pageFolders;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在指定页面中查找关键字
|
||||||
|
private KeywordInfoRange findKeywordInPage(ZipFile zipFile, String pageFolder) throws Exception {
|
||||||
|
ZipEntry contentXmlEntry = zipFile.getEntry(pageFolder);
|
||||||
|
InputStream inputStream = zipFile.getInputStream(contentXmlEntry);
|
||||||
|
|
||||||
|
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
|
||||||
|
NodeList textNodes = doc.getElementsByTagName("ofd:TextObject");
|
||||||
|
int startK = 0;
|
||||||
|
List<KeywordInfo> keywordInfos = new ArrayList<>();
|
||||||
|
for (int i = 0; i < textNodes.getLength(); i++) {
|
||||||
|
Node textNode = textNodes.item(i);
|
||||||
|
String textContent = textNode.getTextContent();
|
||||||
|
char[] chars = textContent.toCharArray();
|
||||||
|
char[] keywordChars = keyword.toCharArray();
|
||||||
|
for (int j = 0; j < chars.length; j++) {
|
||||||
|
for (int k = startK; k < keywordChars.length; k++) {
|
||||||
|
char contentChar = chars[j];
|
||||||
|
char keywordChar = keywordChars[k];
|
||||||
|
if (contentChar == keywordChar) {
|
||||||
|
j++;
|
||||||
|
if (j == chars.length) {
|
||||||
|
startK = j;
|
||||||
|
Node boundaryNode = textNode.getAttributes().getNamedItem("Boundary");
|
||||||
|
String boundary = boundaryNode.getNodeValue();
|
||||||
|
String[] boundarySegments = boundary.split(" ");
|
||||||
|
double x = Double.parseDouble(boundarySegments[0]);
|
||||||
|
double y = Double.parseDouble(boundarySegments[1]);
|
||||||
|
double width = Double.parseDouble(boundarySegments[2]);
|
||||||
|
double height = Double.parseDouble(boundarySegments[3]);
|
||||||
|
KeywordInfo keywordInfo = new KeywordInfo(pageFolder, x, y, width, height);
|
||||||
|
keywordInfos.add(keywordInfo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
startK = 0;
|
||||||
|
keywordInfos.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keywordInfos.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new KeywordInfoRange(keywordInfos.get(0), keywordInfos.get(keywordInfos.size() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class KeywordInfoRange {
|
||||||
|
private final KeywordInfo start;
|
||||||
|
|
||||||
|
private final KeywordInfo end;
|
||||||
|
|
||||||
|
public KeywordInfoRange(KeywordInfo start, KeywordInfo end) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeywordInfo getStart() {
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeywordInfo getEnd() {
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class KeywordInfo {
|
||||||
|
private final String pageFolder;
|
||||||
|
private final double x;
|
||||||
|
private final double y;
|
||||||
|
private final double width;
|
||||||
|
private final double height;
|
||||||
|
|
||||||
|
|
||||||
|
public KeywordInfo(String pageFolder, double x, double y, double width, double height) {
|
||||||
|
this.pageFolder = pageFolder;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPageNumber() {
|
||||||
|
int pageNumber = Integer.parseInt(pageFolder.substring(pageFolder.lastIndexOf('_') + 1, pageFolder.length() - "/Content.xml".length()));
|
||||||
|
return String.valueOf(pageNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBoundingBox() {
|
||||||
|
return "(" + x + ", " + y + ", " + width + ", " + height + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.doctoavatar;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
|
import aiyh.utils.annotation.ActionDesc;
|
||||||
|
import aiyh.utils.annotation.PrintParamMark;
|
||||||
|
import aiyh.utils.annotation.RequiredMark;
|
||||||
|
import aiyh.utils.entity.DocImageInfo;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.IdUtil;
|
||||||
|
import com.weaver.esb.server.cache.ResourceComInfo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import weaver.file.ImageFileManager;
|
||||||
|
import weaver.general.GCONST;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>生成头像</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/29 17:40</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@ActionDesc(value = "生成头像", author = "youhong.ai")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DocToAvatarAction extends SafeCusBaseAction {
|
||||||
|
|
||||||
|
@PrintParamMark
|
||||||
|
@RequiredMark(value = "sctxzp", desc = "上传头像的字段名称")
|
||||||
|
private String iconDocField;
|
||||||
|
|
||||||
|
@RequiredMark(value = "dqyh", desc = "上传头像的字段名称")
|
||||||
|
@PrintParamMark
|
||||||
|
private String userField;
|
||||||
|
|
||||||
|
|
||||||
|
private final DocToAvatarActionMapper mapper = Util.getMapper(DocToAvatarActionMapper.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||||
|
Map<String, String> mainTable = getMainTableValue(requestInfo);
|
||||||
|
String docIds = "";
|
||||||
|
if (mainTable.containsKey(iconDocField)) {
|
||||||
|
docIds = mainTable.get(iconDocField);
|
||||||
|
}
|
||||||
|
String[] docArr = docIds.split(",");
|
||||||
|
if (docArr.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String avatarDoc = docArr[0];
|
||||||
|
DocImageInfo docImageInfo = Util.selectImageInfoByDocId(avatarDoc);
|
||||||
|
if (Objects.isNull(docImageInfo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
InputStream inputStreamById = ImageFileManager.getInputStreamById(docImageInfo.getImageFileId());
|
||||||
|
String avatarPath = GCONST.getRootPath();
|
||||||
|
if (avatarPath.endsWith(File.separator)) {
|
||||||
|
avatarPath += File.separator;
|
||||||
|
}
|
||||||
|
String uuid = IdUtil.randomUUID();
|
||||||
|
String imgName = docImageInfo.getImageFileName();
|
||||||
|
int dotIndex = imgName.lastIndexOf(".");
|
||||||
|
if (dotIndex > 0) {
|
||||||
|
String extension = imgName.substring(dotIndex + 1);
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
String imageFileName = "/messager/usericon/" + uuid + "-" + time + "." + extension;
|
||||||
|
avatarPath += "messager" + File.separator + "usericon" + File.separator;
|
||||||
|
File imageFile = new File(avatarPath + uuid + "-" + time + "." + extension);
|
||||||
|
if (!imageFile.getParentFile().exists()) {
|
||||||
|
imageFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
OutputStream os = null;
|
||||||
|
try {
|
||||||
|
os = Files.newOutputStream(imageFile.toPath());
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = inputStreamById.read(buffer)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("写入头像文件失败!" + Util.getErrString(e));
|
||||||
|
throw new CustomerException("头像生成失败!");
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (inputStreamById != null) {
|
||||||
|
inputStreamById.close();
|
||||||
|
}
|
||||||
|
if (os != null) {
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("关闭文件流失败!!" + Util.getErrString(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mainTable.containsKey(userField)) {
|
||||||
|
String currentUser = mainTable.get(userField);
|
||||||
|
if (!mapper.updateAvatar(currentUser, imageFileName, docImageInfo.getImageFileId())) {
|
||||||
|
log.info("头像更新失败!sql出错!");
|
||||||
|
} else {
|
||||||
|
ResourceComInfo rsc = new ResourceComInfo();
|
||||||
|
rsc.removeCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package weaver.youhong.ai.pcn.actioin.doctoavatar;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
|
import aiyh.utils.annotation.recordset.Update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>更新头像</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/5/29 18:02</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
@SqlMapper
|
||||||
|
public interface DocToAvatarActionMapper {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>更新人员头像信息</h2>
|
||||||
|
*
|
||||||
|
* @param currentUser 当前用户
|
||||||
|
* @param avatarImg 更新头像
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
@Update("update hrmresource set messagerurl = #{avatarImg},resourceimageid = #{imageId} where id = #{currentUser}")
|
||||||
|
boolean updateAvatar(@ParamMapper("currentUser") String currentUser,
|
||||||
|
@ParamMapper("avatarImg") String avatarImg,
|
||||||
|
@ParamMapper("imageId") Integer imgId);
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
package weaver.yunjinshan.formmode.action;
|
||||||
|
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
|
||||||
|
import weaver.general.BaseBean;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.soa.workflow.request.MainTableInfo;
|
||||||
|
import weaver.soa.workflow.request.Property;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云锦山
|
||||||
|
* 合同管理模块 新建、编辑保存和导入时,自定义扩展功能
|
||||||
|
*/
|
||||||
|
public class ContractExpandAction extends AbstractModeExpandJavaCodeNew {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块主表名称
|
||||||
|
*/
|
||||||
|
private final static String modeTableName = "uf_hetongguanli";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浮点数格式化
|
||||||
|
*/
|
||||||
|
private final DecimalFormat df = new DecimalFormat("##############################0.0000");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行模块扩展动作
|
||||||
|
* @param param
|
||||||
|
* param包含(但不限于)以下数据
|
||||||
|
* user 当前用户
|
||||||
|
* importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加,2覆盖,3更新,获取方式(int)param.get("importtype")
|
||||||
|
* 导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输),比如a=1,可通过param.get("a")获取参数值
|
||||||
|
* 页面链接拼接的参数,比如b=2,可以通过param.get("b")来获取参数
|
||||||
|
* @return 返回执行结果
|
||||||
|
*/
|
||||||
|
public Map<String, String> doModeExpand(Map<String, Object> param) {
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
BaseBean bean = new BaseBean();
|
||||||
|
|
||||||
|
bean.writeLog("-------------ContractExpandAction Begin----------------");
|
||||||
|
|
||||||
|
bean.writeLog("param:[" + param.toString() + "]");
|
||||||
|
|
||||||
|
int billid;//数据id
|
||||||
|
int modeid;//模块id
|
||||||
|
RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo");
|
||||||
|
if (requestInfo != null) {
|
||||||
|
billid = Util.getIntValue(requestInfo.getRequestid());
|
||||||
|
modeid = Util.getIntValue(requestInfo.getWorkflowid());
|
||||||
|
|
||||||
|
bean.writeLog("billid:[" + billid + "],modeid:[" + modeid + "]");
|
||||||
|
|
||||||
|
if (billid > 0 && modeid > 0) {
|
||||||
|
//String selectData = "select * from " + modeTableName + " where id = ?";
|
||||||
|
|
||||||
|
//年月
|
||||||
|
String yearMonth = "";
|
||||||
|
//一级部门
|
||||||
|
String superiorDepartment = "";
|
||||||
|
//客户
|
||||||
|
String customer = "";
|
||||||
|
|
||||||
|
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
|
||||||
|
|
||||||
|
for(Property p : mainTableInfo.getProperty()){
|
||||||
|
if("qdny".equalsIgnoreCase(p.getName())) {
|
||||||
|
yearMonth = p.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if("yjbm".equalsIgnoreCase(p.getName())){
|
||||||
|
superiorDepartment = p.getValue();
|
||||||
|
}
|
||||||
|
if("khmc".equalsIgnoreCase(p.getName())){
|
||||||
|
customer = p.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
if(rs.executeQuery(selectData,billid)){
|
||||||
|
if(rs.next()){
|
||||||
|
yearMonth = Util.null2String(rs.getString("qdny"));
|
||||||
|
superiorDepartment = Util.null2String(rs.getString("yjbm"));
|
||||||
|
customer = Util.null2String(rs.getString("khmc"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
CostIncomeUpdate incomeUpdate = new CostIncomeUpdate();
|
||||||
|
incomeUpdate.updateByContract(yearMonth,superiorDepartment,customer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bean.writeLog("-------------ContractExpandAction End----------------");
|
||||||
|
result.put("flag", "true");
|
||||||
|
} catch (Exception e) {
|
||||||
|
result.put("errmsg",e.getMessage());
|
||||||
|
result.put("flag", "false");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
package weaver.yunjinshan.formmode.action;
|
||||||
|
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.BaseBean;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云锦山
|
||||||
|
* 成本收入更新操作
|
||||||
|
*/
|
||||||
|
public class CostIncomeUpdate {
|
||||||
|
|
||||||
|
private final static String contractModeTableName = "uf_hetongguanli";
|
||||||
|
|
||||||
|
private final static BaseBean bean = new BaseBean();
|
||||||
|
|
||||||
|
private final static RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浮点数格式化
|
||||||
|
*/
|
||||||
|
private final DecimalFormat df = new DecimalFormat("##############################0.0000");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据合同管理 变更成本收入
|
||||||
|
*
|
||||||
|
* @param yearMonth 年月
|
||||||
|
* @param superiorDepartment 一级部门
|
||||||
|
* @param customer 客户
|
||||||
|
*/
|
||||||
|
public void updateByContract(String yearMonth, String superiorDepartment, String customer) {
|
||||||
|
bean.writeLog("yearMonth:[" + yearMonth + "],superiorDepartment:[" + superiorDepartment + "],customer:[" + customer + "]");
|
||||||
|
|
||||||
|
// 合同金额合计
|
||||||
|
double contractAmount = 0.0;
|
||||||
|
// 收款金额合计
|
||||||
|
double receivableAmount = 0.0;
|
||||||
|
// 开票金额合计
|
||||||
|
double invoiceAmount = 0.0;
|
||||||
|
// 获取该模块相同年月、一级部门、客户的合同金额合计
|
||||||
|
String selectData = "select sum(isnull(htje,0.0)) from " + contractModeTableName + " where qdny = ? and yjbm = ? and khmc = ?";
|
||||||
|
|
||||||
|
if (rs.executeQuery(selectData, yearMonth, superiorDepartment, customer)) {
|
||||||
|
if (rs.next()) {
|
||||||
|
contractAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
selectData = "select sum(isnull(dt.ysje,0.0)) from " + contractModeTableName + "_dt1 dt inner join " + contractModeTableName + " m on dt.mainId = m.id " +
|
||||||
|
"where m.yjbm = ? and m.khmc = ? and (dt.skrq is not null and substring(dt.skrq,1,7) = ?)";
|
||||||
|
|
||||||
|
if (rs.executeQuery(selectData, superiorDepartment, customer, yearMonth) && rs.next()) {
|
||||||
|
receivableAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
selectData = "select sum(isnull(dt.jshjje,0.0)) from " + contractModeTableName + "_dt2 dt inner join " + contractModeTableName + " m on dt.mainId = m.id " +
|
||||||
|
"where m.yjbm = ? and m.khmc = ? and (dt.kprq is not null and substring(dt.kprq,1,7) = ?)";
|
||||||
|
|
||||||
|
if (rs.executeQuery(selectData, superiorDepartment, customer, yearMonth) && rs.next()) {
|
||||||
|
invoiceAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
String updateSQL = "update uf_chengbenshouru set yqhtjekkpje = " + df.format(contractAmount) + "," +
|
||||||
|
"yskje = " + df.format(receivableAmount) + "," +
|
||||||
|
"ykpjehs = " + df.format(invoiceAmount) +
|
||||||
|
" where ny = ? and yjbm = ? and kh = ?";
|
||||||
|
|
||||||
|
boolean isSuccess = rs.executeUpdate(updateSQL, yearMonth, superiorDepartment, customer);
|
||||||
|
|
||||||
|
bean.writeLog("updateSQL:[" + updateSQL + "],执行结果:[" + isSuccess + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据人力成本更新成本收入
|
||||||
|
*
|
||||||
|
* @param yearMonth 年月
|
||||||
|
* @param superiorDepartment 一级部门
|
||||||
|
* @param customer 客户名称
|
||||||
|
*/
|
||||||
|
public void updateByHumanCost(String yearMonth, String superiorDepartment, String customer) {
|
||||||
|
bean.writeLog("yearMonth:[" + yearMonth + "],superiorDepartment:[" + superiorDepartment + "],customer:[" + customer + "]");
|
||||||
|
|
||||||
|
double totalAmount = 0.0;
|
||||||
|
String selectData = "select sum(isnull(gszzffy,0.0)) from uf_renlichengben where ny = ? and yjbm = ? and kh = ?";
|
||||||
|
|
||||||
|
if (rs.executeQuery(selectData, yearMonth, superiorDepartment, customer)) {
|
||||||
|
if (rs.next()) {
|
||||||
|
totalAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String updateSQL = "update uf_chengbenshouru set rycb = " + df.format(totalAmount) + " where ny = ? and yjbm = ? and kh = ?";
|
||||||
|
|
||||||
|
boolean isSuccess = rs.executeUpdate(updateSQL, yearMonth, superiorDepartment, customer);
|
||||||
|
|
||||||
|
bean.writeLog("updateSQL:[" + updateSQL + "],执行结果:[" + isSuccess + "]");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
package weaver.yunjinshan.formmode.action;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
|
||||||
|
import weaver.general.BaseBean;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.soa.workflow.request.MainTableInfo;
|
||||||
|
import weaver.soa.workflow.request.Property;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云锦山
|
||||||
|
* 人力成本建模 新建、编辑保存和导入数据时,自定义扩展操作
|
||||||
|
*/
|
||||||
|
public class HumanCostExpandAction extends AbstractModeExpandJavaCodeNew {
|
||||||
|
|
||||||
|
private final DecimalFormat df = new DecimalFormat("##############################0.0000");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行模块扩展动作
|
||||||
|
* @param param
|
||||||
|
* param包含(但不限于)以下数据
|
||||||
|
* user 当前用户
|
||||||
|
* importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加,2覆盖,3更新,获取方式(int)param.get("importtype")
|
||||||
|
* 导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输),比如a=1,可通过param.get("a")获取参数值
|
||||||
|
* 页面链接拼接的参数,比如b=2,可以通过param.get("b")来获取参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String, String> doModeExpand(Map<String, Object> param) {
|
||||||
|
Map<String, String> result = new HashMap<String, String>();
|
||||||
|
try {
|
||||||
|
BaseBean bean = new BaseBean();
|
||||||
|
|
||||||
|
bean.writeLog("-------------HumanCostExpandAction Begin----------------");
|
||||||
|
|
||||||
|
bean.writeLog("param:[" + param.toString() + "]");
|
||||||
|
|
||||||
|
int billid = -1;//数据id
|
||||||
|
int modeid = -1;//模块id
|
||||||
|
RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
|
||||||
|
if(requestInfo!=null){
|
||||||
|
billid = Util.getIntValue(requestInfo.getRequestid());
|
||||||
|
modeid = Util.getIntValue(requestInfo.getWorkflowid());
|
||||||
|
|
||||||
|
bean.writeLog("billid:[" + billid + "],modeid:[" + modeid + "]");
|
||||||
|
if(billid>0&&modeid>0){
|
||||||
|
//年月
|
||||||
|
String yearMonth = "";
|
||||||
|
//一级部门
|
||||||
|
String superiorDepartment = "";
|
||||||
|
//客户
|
||||||
|
String customer = "";
|
||||||
|
|
||||||
|
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
|
||||||
|
|
||||||
|
for(Property p : mainTableInfo.getProperty()){
|
||||||
|
if("ny".equalsIgnoreCase(p.getName())) {
|
||||||
|
yearMonth = p.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if("yjbm".equalsIgnoreCase(p.getName())){
|
||||||
|
superiorDepartment = p.getValue();
|
||||||
|
}
|
||||||
|
if("kh".equalsIgnoreCase(p.getName())){
|
||||||
|
customer = p.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//查询该记录对应的信息
|
||||||
|
String selectData = "select * from uf_renlichengben where id = ?";
|
||||||
|
|
||||||
|
if(rs.executeQuery(selectData,billid)){
|
||||||
|
if(rs.next()){
|
||||||
|
yearMonth = Util.null2String(rs.getString("ny"));
|
||||||
|
superiorDepartment = Util.null2String(rs.getString("yjbm"));
|
||||||
|
customer = Util.null2String(rs.getString("kh"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bean.writeLog("yearMonth:[" + yearMonth + "],superiorDepartment:[" + superiorDepartment + "],customer:[" + customer + "]");
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
double totalAmount = 0.0;
|
||||||
|
String selectData = "select sum(isnull(gszzffy,0.0)) from uf_renlichengben where ny = ? and yjbm = ? and kh = ?";
|
||||||
|
|
||||||
|
if(rs.executeQuery(selectData,yearMonth,superiorDepartment,customer)){
|
||||||
|
if(rs.next()){
|
||||||
|
totalAmount = Util.getDoubleValue(rs.getString(1),0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String updateSQL = "update uf_chengbenshouru set rycb = " + df.format(totalAmount) + " where ny = ? and yjbm = ? and kh = ?";
|
||||||
|
|
||||||
|
boolean isSuccess = rs.executeUpdate(updateSQL,yearMonth,superiorDepartment,customer);
|
||||||
|
|
||||||
|
bean.writeLog("updateSQL:[" + updateSQL + "],执行结果:[" + isSuccess + "]");
|
||||||
|
*/
|
||||||
|
|
||||||
|
CostIncomeUpdate incomeUpdate = new CostIncomeUpdate();
|
||||||
|
incomeUpdate.updateByHumanCost(yearMonth,superiorDepartment,customer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.put("flag", "true");
|
||||||
|
|
||||||
|
bean.writeLog("-------------HumanCostExpandAction End----------------");
|
||||||
|
} catch (Exception e) {
|
||||||
|
result.put("errmsg","自定义出错信息");
|
||||||
|
result.put("flag", "false");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#修改当前配置文件后需要重启, you must restart service at change the config file after
|
#修改当前配置文件后需要重启, you must restart service at change the config file after
|
||||||
#
|
#
|
||||||
# 当前需要同步的语言, current active language
|
# 当前需要同步的语言, current active language
|
||||||
cus.multilingual.active=ZHS,IDN
|
cus.multilingual.active="ZHS,IDN"
|
||||||
#中文
|
#中文
|
||||||
cus.multilingual.ZHS=7
|
cus.multilingual.ZHS=7
|
||||||
#印尼
|
#印尼
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
yunzhao.environment=test
|
yunzhao.environment=pro
|
|
@ -18,6 +18,8 @@ export.createType=yyyy-MM-dd
|
||||||
export.costCenter=cbzxyh
|
export.costCenter=cbzxyh
|
||||||
# 条件key
|
# 条件key
|
||||||
export.conditionKey=condition
|
export.conditionKey=condition
|
||||||
|
#附加信息
|
||||||
|
export.additional=ddsm
|
||||||
#流水号-requestId
|
#流水号-requestId
|
||||||
export.requestId=lcid
|
export.requestId=lcid
|
||||||
# bgm字段
|
# bgm字段
|
||||||
|
@ -41,72 +43,114 @@ export.sku=sku
|
||||||
#导出表头设置
|
#导出表头设置
|
||||||
export.head.title[0]=序号
|
export.head.title[0]=序号
|
||||||
export.head.field[0]=no
|
export.head.field[0]=no
|
||||||
export.head.title[1]=分组编号
|
#export.head.title[1]=分组编号
|
||||||
export.head.field[1]=groupId
|
#export.head.field[1]=groupId
|
||||||
export.head.title[2]=ID
|
#export.head.title[2]=ID
|
||||||
export.head.field[2]=id
|
#export.head.field[2]=id
|
||||||
export.head.title[3]=条件
|
export.head.title[1]=条件
|
||||||
export.head.field[3]=condition
|
export.head.field[1]=condition
|
||||||
export.head.title[4]=疑似拆单
|
#export.head.title[4]=疑似拆单
|
||||||
export.head.field[4]=openBill
|
export.head.title[2]=拆单方式
|
||||||
export.head.title[5]=流水号
|
export.head.field[2]=openBill
|
||||||
export.head.field[5]=lcid
|
export.head.title[3]=月份
|
||||||
export.head.title[6]=shipTo
|
export.head.field[3]=sqtjrq
|
||||||
export.head.field[6]=shipto
|
export.head.title[4]=SKU
|
||||||
export.head.title[7]=推送时间
|
export.head.field[4]=ZWMS
|
||||||
export.head.field[7]=insertTime
|
export.head.title[5]=部门
|
||||||
export.head.title[8]=审批开始时间
|
export.head.field[5]=SPART
|
||||||
export.head.field[8]=createdate
|
export.head.title[6]=订单编号
|
||||||
export.head.title[9]=申请提交时间
|
export.head.field[6]=ddbh
|
||||||
export.head.field[9]=sqtjrq
|
export.head.title[7]=备注信息
|
||||||
export.head.title[10]=审批开始时间
|
export.head.field[7]=bz
|
||||||
export.head.field[10]=LASTOPERATEDATE
|
export.head.title[8]=附加信息
|
||||||
export.head.title[11]=收方限制
|
export.head.field[8]=ddsm
|
||||||
export.head.field[11]=ddlxms
|
export.head.title[9]=成本中心
|
||||||
export.head.title[12]=部门团队
|
export.head.field[9]=KOSTL
|
||||||
export.head.field[12]=SPART
|
export.head.title[10]=活动编号
|
||||||
export.head.title[13]=品牌部门
|
export.head.field[10]=hdbh
|
||||||
export.head.field[13]=yjpp
|
export.head.title[11]=流水号
|
||||||
export.head.title[14]=订单编号
|
export.head.field[11]=lcid
|
||||||
export.head.field[14]=ddbh
|
export.head.title[12]=用户
|
||||||
export.head.title[15]=订单说明
|
export.head.field[12]=cbzxyh
|
||||||
export.head.field[15]=ddsm
|
export.head.title[13]=订单类型
|
||||||
export.head.title[16]=备注
|
export.head.field[13]=AUART
|
||||||
export.head.field[16]=bz
|
export.head.title[14]=订单用途
|
||||||
export.head.title[17]=成本中心-sap
|
export.head.field[14]=ddyt
|
||||||
export.head.field[17]=KOSTL
|
export.head.title[15]=shipTo
|
||||||
export.head.title[18]=成本中心-用户
|
export.head.field[15]=shipto
|
||||||
export.head.field[18]=cbzxyh
|
export.head.title[16]=办公室员工
|
||||||
export.head.title[19]=财务科目
|
export.head.field[16]=KUNNRSHIPTO
|
||||||
export.head.field[19]=cwkm
|
export.head.title[17]=提交时间
|
||||||
export.head.title[20]=审批开始时间
|
export.head.field[17]=LASTOPERATEDATE
|
||||||
export.head.field[20]=LASTOPERATEDATE
|
export.head.title[18]=总数
|
||||||
export.head.title[21]=活动编号
|
export.head.field[18]=SL
|
||||||
export.head.field[21]=hdbh
|
export.head.title[19]=成本总额
|
||||||
export.head.title[22]=businessKey
|
export.head.field[19]=kxpmxzlsj
|
||||||
export.head.field[22]=businesskey
|
export.head.title[20]=总税额
|
||||||
export.head.title[23]=申请人
|
export.head.field[20]=
|
||||||
export.head.field[23]=SQRRLZY
|
export.head.title[21]=总价格
|
||||||
export.head.title[24]=订单类型
|
export.head.field[21]=
|
||||||
export.head.field[24]=AUART
|
export.head.title[22]=订单时间
|
||||||
export.head.title[25]=订单用途
|
export.head.field[22]=LASTOPERATEDATE
|
||||||
export.head.field[25]=VKAUS
|
export.head.title[23]=到货方
|
||||||
export.head.title[26]=收货人
|
export.head.field[23]=
|
||||||
export.head.field[26]=KUNNRSHIPTO
|
#export.head.title[5]=流水号
|
||||||
export.head.title[27]=收货人地址
|
#export.head.field[5]=lcid
|
||||||
export.head.field[27]=shdz
|
#export.head.title[6]=shipTo
|
||||||
export.head.title[28]=收货编号
|
#export.head.field[6]=shipto
|
||||||
export.head.field[28]=hwbh
|
#export.head.title[7]=推送时间
|
||||||
export.head.title[29]=收货类型
|
#export.head.field[7]=insertTime
|
||||||
export.head.field[29]=fl
|
#export.head.title[8]=审批开始时间
|
||||||
export.head.title[30]=收货中文名
|
#export.head.field[8]=createdate
|
||||||
export.head.field[30]=ZWMS
|
#export.head.title[9]=申请提交时间
|
||||||
export.head.title[31]=数量
|
#export.head.field[9]=sqtjrq
|
||||||
export.head.field[31]=SL
|
#export.head.title[10]=审批开始时间
|
||||||
export.head.title[32]=零售总额
|
#export.head.field[10]=LASTOPERATEDATE
|
||||||
export.head.field[32]=kxpmxzlsj
|
#export.head.title[11]=收方限制
|
||||||
export.head.title[33]=订单分类
|
#export.head.field[11]=ddlxms
|
||||||
export.head.field[33]=ddlx
|
#export.head.title[12]=部门团队
|
||||||
export.head.title[34]=gbm
|
#export.head.field[12]=SPART
|
||||||
export.head.field[34]=bgm
|
#export.head.title[13]=品牌部门
|
||||||
|
#export.head.field[13]=yjpp
|
||||||
|
#export.head.title[14]=订单编号
|
||||||
|
#export.head.field[14]=ddbh
|
||||||
|
#export.head.title[15]=订单说明
|
||||||
|
#export.head.field[15]=ddsm
|
||||||
|
#export.head.title[16]=备注
|
||||||
|
#export.head.field[16]=bz
|
||||||
|
#export.head.title[17]=成本中心-sap
|
||||||
|
#export.head.field[17]=KOSTL
|
||||||
|
#export.head.title[18]=成本中心-用户
|
||||||
|
#export.head.field[18]=cbzxyh
|
||||||
|
#export.head.title[19]=财务科目
|
||||||
|
#export.head.field[19]=cwkm
|
||||||
|
#export.head.title[20]=审批开始时间
|
||||||
|
#export.head.field[20]=LASTOPERATEDATE
|
||||||
|
#export.head.title[21]=活动编号
|
||||||
|
#export.head.field[21]=hdbh
|
||||||
|
#export.head.title[22]=businessKey
|
||||||
|
#export.head.field[22]=businesskey
|
||||||
|
#export.head.title[23]=申请人
|
||||||
|
#export.head.field[23]=SQRRLZY
|
||||||
|
#export.head.title[24]=订单类型
|
||||||
|
#export.head.field[24]=AUART
|
||||||
|
#export.head.title[25]=订单用途
|
||||||
|
#export.head.field[25]=VKAUS
|
||||||
|
#export.head.title[26]=收货人
|
||||||
|
#export.head.field[26]=KUNNRSHIPTO
|
||||||
|
#export.head.title[27]=收货人地址
|
||||||
|
#export.head.field[27]=shdz
|
||||||
|
#export.head.title[28]=收货编号
|
||||||
|
#export.head.field[28]=hwbh
|
||||||
|
#export.head.title[29]=收货类型
|
||||||
|
#export.head.field[29]=fl
|
||||||
|
#export.head.title[30]=收货中文名
|
||||||
|
#export.head.field[30]=ZWMS
|
||||||
|
#export.head.title[31]=数量
|
||||||
|
#export.head.field[31]=SL
|
||||||
|
#export.head.title[32]=零售总额
|
||||||
|
#export.head.field[32]=kxpmxzlsj
|
||||||
|
#export.head.title[33]=订单分类
|
||||||
|
##xport.head.title[34]=gbm
|
||||||
|
#export.head.field[34]=bgm
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
body{
|
||||||
|
background-color: rgb(241, 241, 241);
|
||||||
|
font-family: PingFangSC-Regular;
|
||||||
|
color: #333333 ;
|
||||||
|
}
|
||||||
|
.box{
|
||||||
|
width: 1000px;
|
||||||
|
margin:0 auto;
|
||||||
|
margin-top: 100px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.mytitle{
|
||||||
|
width: 100%;
|
||||||
|
background-color: #F6F6F6 ;
|
||||||
|
height: 40px;
|
||||||
|
font-size: 14px;
|
||||||
|
background: #F6F6F6;
|
||||||
|
border: 1px solid #E2E2E2;
|
||||||
|
|
||||||
|
}
|
||||||
|
.clusterIp{
|
||||||
|
display: inline-block;
|
||||||
|
width: 120px;
|
||||||
|
|
||||||
|
}
|
||||||
|
input[type='checkbox']{
|
||||||
|
}
|
||||||
|
|
||||||
|
.cluster{
|
||||||
|
border-bottom: 1px solid #E2E2E2;
|
||||||
|
width: 80%;
|
||||||
|
margin-left: 39px;
|
||||||
|
height: 100px;
|
||||||
|
padding-top: 26px;
|
||||||
|
}
|
||||||
|
.Button{
|
||||||
|
color: #fff;
|
||||||
|
background-color: #2DB7F5;
|
||||||
|
border-color: #4cae4c;
|
||||||
|
|
||||||
|
display: inline-block;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 300;
|
||||||
|
line-height: 1.42857143;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
vertical-align: middle;
|
||||||
|
-ms-touch-action: manipulation;
|
||||||
|
touch-action: manipulation;
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
width:70px;
|
||||||
|
height:30px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Wdate{
|
||||||
|
width: 150px;
|
||||||
|
height: 30px !important;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clusterPlan{
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-left:30px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contend{
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-left: 1px solid #E2E2E2;
|
||||||
|
border-right: 1px solid #E2E2E2;
|
||||||
|
border-bottom: 1px solid #E2E2E2;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.messages{
|
||||||
|
color:red;
|
||||||
|
}
|
||||||
|
|
||||||
|
#start[disabled]{
|
||||||
|
background-color: #A9A9A9;
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
<%@ page language="java" %>
|
||||||
|
<%@ page import="org.apache.commons.httpclient.HttpClient" %>
|
||||||
|
<%@ page import="org.apache.commons.httpclient.methods.GetMethod" %>
|
||||||
|
<%@ page import="javax.servlet.http.HttpServletRequest" %>
|
||||||
|
<%@ page import="javax.servlet.http.HttpServletResponse" %>
|
||||||
|
<%@ page import="java.io.File" %>
|
||||||
|
<%@ page import="java.io.FileInputStream" %>
|
||||||
|
<%@ page import="java.io.InputStream" %>
|
||||||
|
<%@ page import="java.io.OutputStream" %>
|
||||||
|
<%@ page import="java.util.regex.Matcher" %>
|
||||||
|
<%@ page import="java.util.regex.Pattern" %>
|
||||||
|
<%
|
||||||
|
|
||||||
|
String logName = request.getParameter("logName");
|
||||||
|
String otherIp = request.getParameter("otherIp");
|
||||||
|
|
||||||
|
weaver.hrm.User user = (weaver.hrm.User) request.getSession(true).getAttribute("weaver_user@bean");
|
||||||
|
String ip = getIpAddress(request);
|
||||||
|
if (user == null || !"sysadmin".equals(user.getLoginid())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (otherIp != null) {
|
||||||
|
otherIp = otherIp.replace("-", ":");
|
||||||
|
downotherlog(logName, otherIp, response);
|
||||||
|
} else {
|
||||||
|
deal(request, response);
|
||||||
|
}
|
||||||
|
%><%!
|
||||||
|
public static boolean innerIP(String ip) {
|
||||||
|
String pattern = "((192\\.168|172\\.([1][6-9]|[2]\\d|3[01]))"
|
||||||
|
+ "(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){2}|"
|
||||||
|
+ "^(\\D)*10(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){3})";
|
||||||
|
Pattern reg = Pattern.compile(pattern);
|
||||||
|
Matcher match = reg.matcher(ip);
|
||||||
|
return match.find() || ip.equals("127.0.0.1");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIpAddress(HttpServletRequest request) {
|
||||||
|
String ip = request.getHeader("x-forwarded-for");
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
|
ip = request.getHeader("Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
|
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
|
ip = request.getRemoteAddr();
|
||||||
|
}
|
||||||
|
if (ip.contains(",")) {
|
||||||
|
return ip.split(",")[0];
|
||||||
|
} else {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deal(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
response.reset();
|
||||||
|
String logName = request.getParameter("logName");
|
||||||
|
if (!logName.endsWith(".zip") || logName.indexOf("/") != -1 || logName.indexOf("\\") != -1 || logName.indexOf("..") != -1) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FileInputStream in = null;
|
||||||
|
OutputStream outs = null;
|
||||||
|
try {
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setHeader("content-disposition", "attachment;filename=" + logName);
|
||||||
|
response.setCharacterEncoding("ISO8859-1");
|
||||||
|
String ecologyPathtmp = request.getRealPath("/");
|
||||||
|
if (!ecologyPathtmp.endsWith(File.separator)) {
|
||||||
|
ecologyPathtmp = ecologyPathtmp + File.separator;
|
||||||
|
}
|
||||||
|
if (logName.indexOf("..") != -1 || logName.indexOf("\0") != -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
in = new FileInputStream(ecologyPathtmp + "cus_getlog" + File.separator + "log" + File.separator + logName);
|
||||||
|
outs = response.getOutputStream();
|
||||||
|
outs.flush();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len = 0;
|
||||||
|
while ((len = in.read(buffer)) > 0) {
|
||||||
|
outs.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
if (outs != null) {
|
||||||
|
outs.flush();
|
||||||
|
outs.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downotherlog(String logName, String otherIp, HttpServletResponse response) {
|
||||||
|
response.reset();
|
||||||
|
|
||||||
|
InputStream in = null;
|
||||||
|
OutputStream outs = null;
|
||||||
|
try {
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setHeader("content-disposition", "attachment;filename=" + logName);
|
||||||
|
response.setCharacterEncoding("ISO8859-1");
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
GetMethod httpget = new GetMethod("http://" + otherIp + "/cus_getlog/downlog.jsp?logName=" + logName);
|
||||||
|
client.executeMethod(httpget);
|
||||||
|
in = httpget.getResponseBodyAsStream();
|
||||||
|
outs = response.getOutputStream();
|
||||||
|
outs.flush();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len = 0;
|
||||||
|
while ((len = in.read(buffer)) > 0) {
|
||||||
|
outs.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
if (outs != null) {
|
||||||
|
outs.flush();
|
||||||
|
outs.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%>
|
|
@ -0,0 +1,481 @@
|
||||||
|
<%@ page language="java" contentType="text/html; charset=utf-8" %>
|
||||||
|
<%@ page import="java.io.*" %>
|
||||||
|
<%@ page import="java.math.BigDecimal" %>
|
||||||
|
<%@ page import="java.math.RoundingMode" %>
|
||||||
|
<%@ page import="java.net.InetAddress" %>
|
||||||
|
<%@ page import="java.net.NetworkInterface" %>
|
||||||
|
<%@ page import="java.text.SimpleDateFormat" %>
|
||||||
|
<%@ page import="java.util.*" %>
|
||||||
|
<%@ page import="java.util.regex.Matcher" %>
|
||||||
|
<%@ page import="java.util.regex.Pattern" %>
|
||||||
|
<%@ page import="java.util.zip.ZipEntry" %>
|
||||||
|
<%@ page import="java.util.zip.ZipOutputStream" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
|
||||||
|
weaver.hrm.User user = (weaver.hrm.User) request.getSession(true).getAttribute("weaver_user@bean");
|
||||||
|
String ip = getIpAddress(request);
|
||||||
|
if (user == null || !"sysadmin".equals(user.getLoginid())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String startStr = request.getParameter("startDate");
|
||||||
|
String endStr = request.getParameter("endDate");
|
||||||
|
String logTypeStr = request.getParameter("loytype");
|
||||||
|
messageStr = new StringBuilder();
|
||||||
|
|
||||||
|
|
||||||
|
String ecologyPathtmp = request.getRealPath("/");
|
||||||
|
if (!ecologyPathtmp.endsWith(File.separator)) {
|
||||||
|
ecologyPathtmp = ecologyPathtmp + File.separator;
|
||||||
|
}
|
||||||
|
final String ecologyPath = ecologyPathtmp;
|
||||||
|
final String ResinPath = System.getProperty("user.dir") + File.separator;
|
||||||
|
//out.println(ResinPath+"<br>");
|
||||||
|
String outPath = ecologyPath + File.separator + "getlog" + File.separator + "log"; // 日志输出目录
|
||||||
|
List dates = getDateList(startStr, endStr);
|
||||||
|
File outFile = null;
|
||||||
|
try {
|
||||||
|
outFile = new File(outPath);
|
||||||
|
if (!outFile.exists()) {
|
||||||
|
outFile.mkdirs();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
String outLogPath = outFile + File.separator + getInnerIp() + "downLog.zip";
|
||||||
|
Map logtype = new HashMap() { // 日志类型路径
|
||||||
|
{
|
||||||
|
put("thread", ecologyPath + "log" + File.separator + "thread");
|
||||||
|
put("mem", ecologyPath + "log" + File.separator + "mem");
|
||||||
|
put("ecology", ecologyPath + "log");
|
||||||
|
put("sql", ecologyPath + "log" + File.separator + "sql");
|
||||||
|
|
||||||
|
put("sqllog", ecologyPath + "sqllog");
|
||||||
|
|
||||||
|
put("security", ecologyPath + "WEB-INF" + File.separator + "securitylog");
|
||||||
|
put("Resin", ResinPath + "log");
|
||||||
|
put("integration", ecologyPath + "log" + File.separator + "integration");
|
||||||
|
|
||||||
|
put("monitorevent", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "event"); //运维平台的事件日志
|
||||||
|
put("monitorPool", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "pool");
|
||||||
|
put("monitorcpu", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "cpu");
|
||||||
|
put("resinconf", ResinPath + "conf" + File.separator + "resin.conf");
|
||||||
|
put("ecoloyweaver", ecologyPath + "WEB-INF" + File.separator + "prop" + File.separator);
|
||||||
|
put("monitorlog", ResinPath + "monitor" + File.separator + "resin" + File.separator + "log");
|
||||||
|
put("monitorconcurrent", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "concurrent");
|
||||||
|
|
||||||
|
put("cus", ecologyPath + "log" + File.separator + "cus");
|
||||||
|
put("util_cus", ecologyPath + "log" + File.separator + "cus" + File.separator + "util_cus");
|
||||||
|
put("sql_log", ecologyPath + "log" + File.separator + "cus" + File.separator + "sql_log");
|
||||||
|
put("http_util", ecologyPath + "log" + File.separator + "cus" + File.separator + "http_util");
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Map logMap = getLogType(logTypeStr, logtype);
|
||||||
|
Set keys = logMap.keySet();
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
fos = new FileOutputStream(outLogPath);
|
||||||
|
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||||
|
zos.setLevel(1);
|
||||||
|
Iterator it = keys.iterator();
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
String key = (String) it.next();
|
||||||
|
for (int i = 0; i < dates.size(); i++) {
|
||||||
|
String date = (String) dates.get(i);
|
||||||
|
boolean isToDay = isToDay(date);
|
||||||
|
List fileNames = transition(key, (String) logtype.get(key), date, isToDay);
|
||||||
|
for (int j = 0; j < fileNames.size(); j++) {
|
||||||
|
String fileName = (String) fileNames.get(j);
|
||||||
|
//out.println(fileName+"<br>");
|
||||||
|
String basePath = date + File.separator;
|
||||||
|
if ("sqllog".equals(key)) {
|
||||||
|
basePath += ("sqllog" + File.separator);
|
||||||
|
}
|
||||||
|
if ("monitorevent".equals(key)) {
|
||||||
|
basePath += ("event" + File.separator);
|
||||||
|
}
|
||||||
|
if ("monitorlog".equals(key)) {
|
||||||
|
basePath += ("monitorlog" + File.separator);
|
||||||
|
}
|
||||||
|
if (key.equals("cus")) {
|
||||||
|
basePath += ("cus" + File.separator);
|
||||||
|
}
|
||||||
|
if (key.equals("util_cus")) {
|
||||||
|
basePath += ("util_cus" + File.separator);
|
||||||
|
}
|
||||||
|
if (key.equals("sql_log")) {
|
||||||
|
basePath += ("sql_log" + File.separator);
|
||||||
|
}
|
||||||
|
if (key.equals("http_util")) {
|
||||||
|
basePath += ("http_util" + File.separator);
|
||||||
|
}
|
||||||
|
compressbyType(fileName, zos, basePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
zos.close();
|
||||||
|
} catch (Exception es) {
|
||||||
|
}
|
||||||
|
if (fos != null)
|
||||||
|
fos.close();
|
||||||
|
File outLog = new File(outLogPath);
|
||||||
|
String fileSize = getFileSize(outLog);
|
||||||
|
out.println(fileSize + "," + messageStr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
// out.println(end - start);
|
||||||
|
%>
|
||||||
|
<%!
|
||||||
|
|
||||||
|
public static boolean innerIP(String ip) {
|
||||||
|
String pattern = "((192\\.168|172\\.([1][6-9]|[2]\\d|3[01]))"
|
||||||
|
+ "(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){2}|"
|
||||||
|
+ "^(\\D)*10(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){3})";
|
||||||
|
Pattern reg = Pattern.compile(pattern);
|
||||||
|
Matcher match = reg.matcher(ip);
|
||||||
|
return match.find() || ip.equals("127.0.0.1");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIpAddress(HttpServletRequest request) {
|
||||||
|
String ip = request.getHeader("x-forwarded-for");
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
|
ip = request.getHeader("Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
|
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
|
ip = request.getRemoteAddr();
|
||||||
|
}
|
||||||
|
if (ip.contains(",")) {
|
||||||
|
return ip.split(",")[0];
|
||||||
|
} else {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private StringBuilder messageStr = new StringBuilder();
|
||||||
|
|
||||||
|
private Map getLogType(String logTypeStr, Map logtype) {
|
||||||
|
Map resultmap = new HashMap();
|
||||||
|
String[] strs = logTypeStr.split(",");
|
||||||
|
for (int i = 0; i < strs.length; i++) {
|
||||||
|
String str = strs[i];
|
||||||
|
if (str.equals("monitor")) {
|
||||||
|
resultmap.put("thread", logtype.get("thread"));
|
||||||
|
resultmap.put("mem", logtype.get("mem"));
|
||||||
|
resultmap.put("sql", logtype.get("sql"));
|
||||||
|
resultmap.put("monitorevent", logtype.get("monitorevent"));
|
||||||
|
resultmap.put("monitorPool", logtype.get("monitorPool"));
|
||||||
|
resultmap.put("monitorcpu", logtype.get("monitorcpu"));
|
||||||
|
resultmap.put("resinconf", logtype.get("resinconf"));
|
||||||
|
resultmap.put("ecoloyweaver", logtype.get("ecoloyweaver"));
|
||||||
|
resultmap.put("monitorconcurrent", logtype.get("monitorconcurrent"));
|
||||||
|
resultmap.put("monitorlog", logtype.get("monitorlog"));
|
||||||
|
}
|
||||||
|
if (str.equals("Resin")) {
|
||||||
|
resultmap.put("Resin", logtype.get("Resin"));
|
||||||
|
}
|
||||||
|
if (str.equals("security")) {
|
||||||
|
resultmap.put("security", logtype.get("security"));
|
||||||
|
}
|
||||||
|
if (str.equals("ecology")) {
|
||||||
|
resultmap.put("ecology", logtype.get("ecology"));
|
||||||
|
}
|
||||||
|
if (str.equals("sql")) {
|
||||||
|
resultmap.put("sql", logtype.get("sql"));
|
||||||
|
}
|
||||||
|
if (str.equals("integration")) {
|
||||||
|
resultmap.put("integration", logtype.get("integration"));
|
||||||
|
}
|
||||||
|
if (str.equals("cus")) {
|
||||||
|
resultmap.put("cus", logtype.get("cus"));
|
||||||
|
}
|
||||||
|
if (str.equals("util_cus")) {
|
||||||
|
resultmap.put("util_cus", logtype.get("util_cus"));
|
||||||
|
}
|
||||||
|
if (str.equals("sql_log")) {
|
||||||
|
resultmap.put("sql_log", logtype.get("sql_log"));
|
||||||
|
}
|
||||||
|
if (str.equals("http_util")) {
|
||||||
|
resultmap.put("http_util", logtype.get("http_util"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List getDateList(String startDate, String endDate) {
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
try {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date start = sdf.parse(startDate);
|
||||||
|
Date end = sdf.parse(endDate);
|
||||||
|
Calendar tempStart = Calendar.getInstance();
|
||||||
|
tempStart.setTime(start);
|
||||||
|
while (start.getTime() <= end.getTime()) {
|
||||||
|
list.add(sdf.format(tempStart.getTime()));
|
||||||
|
tempStart.add(Calendar.DAY_OF_YEAR, 1);
|
||||||
|
start = tempStart.getTime();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isToDay(String date) {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String toDay = sdf.format(new Date());
|
||||||
|
return date.equals(toDay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List transition(String key, String path, String date, boolean isToDay) {//转换真实的日志文件
|
||||||
|
List list = new ArrayList();
|
||||||
|
if ("thread".equals(key)) {
|
||||||
|
list.add(path + File.separator + date);
|
||||||
|
} else if ("mem".equals(key)) {
|
||||||
|
list.add(path + File.separator + "memory_" + date + ".log");
|
||||||
|
} else if ("ecology".equals(key)) {
|
||||||
|
if (isToDay) {
|
||||||
|
list.add(path + File.separator + "ecology");
|
||||||
|
} else {
|
||||||
|
list.add(path + File.separator + "ecology_" + getDateStr(date) + ".log");
|
||||||
|
}
|
||||||
|
} else if ("sql".equals(key)) {
|
||||||
|
list.add(path + File.separator + "sqlcount_" + date + ".log");
|
||||||
|
list.add(path + File.separator + "sqltime_" + date + ".log");
|
||||||
|
} else if ("integration".equals(key)) {
|
||||||
|
if (isToDay) {
|
||||||
|
list.add(path + File.separator + "integration.log");
|
||||||
|
} else {
|
||||||
|
list.add(path + File.separator + "integration.log_" + getDateStr(date) + ".log");
|
||||||
|
}
|
||||||
|
} else if ("security".equals(key)) {
|
||||||
|
list.add(path + File.separator + "systemRunInfo" + date + ".log");
|
||||||
|
list.add(path + File.separator + "systemSecurity" + date + ".log");
|
||||||
|
} else if ("Resin".equals(key)) {
|
||||||
|
if (isToDay) {
|
||||||
|
list.add(path + File.separator + "stdout.log");
|
||||||
|
list.add(path + File.separator + "stderr.log");
|
||||||
|
} else {
|
||||||
|
list.add(path + File.separator + "stdout-" + getDateStr(date) + ".log.gz");
|
||||||
|
list.add(path + File.separator + "stderr-" + getDateStr(date) + ".log.gz");
|
||||||
|
}
|
||||||
|
list.add(path + File.separator + "watchdog-manager.log");
|
||||||
|
list.add(path + File.separator + "jvm-default.log");
|
||||||
|
} else if ("sqllog".equals(key)) {
|
||||||
|
list.add(path + File.separator + getSqlPathByDate(date));
|
||||||
|
list.add(path + File.separator);
|
||||||
|
} else if ("monitorevent".equals(key)) {
|
||||||
|
list.addAll(eventLog(path, date));
|
||||||
|
} else if ("monitorPool".equals(key)) {
|
||||||
|
list.add(path + File.separator + "pool_" + getDateStr(date) + "_ecology.log");
|
||||||
|
list.add(path + File.separator + "pool_" + getDateStr(date) + "_ecology.zip");
|
||||||
|
} else if ("monitorlog".equals(key)) {
|
||||||
|
if (isToDay) {
|
||||||
|
list.add(path + File.separator + "stdout.log");
|
||||||
|
list.add(path + File.separator + "stderr-log");
|
||||||
|
} else {
|
||||||
|
list.add(path + File.separator + "stdout-" + getDateStr(date) + ".log.gz");
|
||||||
|
list.add(path + File.separator + "stderr-" + getDateStr(date) + ".log.gz");
|
||||||
|
}
|
||||||
|
} else if ("monitorconcurrent".equals(key)) {
|
||||||
|
list.add(path + File.separator + "concurrent_" + getDateStr(date) + ".log");
|
||||||
|
list.add(path + File.separator + "concurrent_" + getDateStr(date) + ".zip");
|
||||||
|
} else if ("monitorcpu".equals(key)) {
|
||||||
|
list.add(path + File.separator + "cpu_" + getDateStr(date) + ".log");
|
||||||
|
list.add(path + File.separator + "cpu_" + getDateStr(date) + ".zip");
|
||||||
|
} else if ("resinconf".equals(key)) {
|
||||||
|
list.add(path);
|
||||||
|
} else if ("ecoloyweaver".equals(key)) {
|
||||||
|
dealWidthWeaverProp(path + "weaver.properties", new File(path + "weaversecurity.properties"));
|
||||||
|
list.add(path + "weaversecurity.properties");
|
||||||
|
} else if ("cus".equals(key) || "util_cus".equals(key) || "sql_log".equals(key) || "http_util".equals(key)) {
|
||||||
|
if (isToDay) {
|
||||||
|
list.add(path + File.separator + "cus.log");
|
||||||
|
} else {
|
||||||
|
list.add(path + File.separator + "cus.log_" + getDateStr(date) + ".log");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dealWidthWeaverProp(String path, File outFile) {//处理weaver.prop密码问题
|
||||||
|
File file = new File(path);
|
||||||
|
if (!file.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
InputStreamReader reader = null;
|
||||||
|
java.io.Writer outWriter = null;
|
||||||
|
try {
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.createNewFile();
|
||||||
|
}
|
||||||
|
Properties registerProp = new Properties();
|
||||||
|
reader = new InputStreamReader(new FileInputStream(file));
|
||||||
|
registerProp.load(reader);
|
||||||
|
reader.close();
|
||||||
|
outWriter = new FileWriter(outFile);
|
||||||
|
registerProp.put("ecology.password", "***********");
|
||||||
|
registerProp.store(outWriter, "");
|
||||||
|
outWriter.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (reader != null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
if (outWriter != null) {
|
||||||
|
outWriter.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List eventLog(String path, String date) {
|
||||||
|
List list = new ArrayList();
|
||||||
|
File file = new File(path);
|
||||||
|
if (!file.exists()) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
File[] filelists = new File(path).listFiles();
|
||||||
|
date = getDateStr(date);
|
||||||
|
for (int i = 0; i < filelists.length; i++) {
|
||||||
|
File filelist = filelists[i];
|
||||||
|
if (filelist.getName().indexOf(date) != -1) {
|
||||||
|
list.add(filelist.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSqlPathByDate(String date) {
|
||||||
|
return date.replace("-", File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileSize(File file) {
|
||||||
|
if (!file.exists()) {
|
||||||
|
return "0KB";
|
||||||
|
}
|
||||||
|
long length = file.length();
|
||||||
|
|
||||||
|
BigDecimal b1 = new BigDecimal(Double.toString(length));
|
||||||
|
BigDecimal b2 = new BigDecimal(Double.toString(1024));
|
||||||
|
BigDecimal b3 = b1.divide(b2, 2, RoundingMode.HALF_UP);
|
||||||
|
b3.floatValue();
|
||||||
|
if (b3.floatValue() > 1024) {
|
||||||
|
return b3.divide(b2, 2, RoundingMode.HALF_UP).floatValue() + "M";
|
||||||
|
} else {
|
||||||
|
return b3.floatValue() + "KB";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getInnerIp() {
|
||||||
|
try {
|
||||||
|
Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
while (netInterfaces.hasMoreElements()) {
|
||||||
|
NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
|
||||||
|
Enumeration nii = ni.getInetAddresses();
|
||||||
|
while (nii.hasMoreElements()) {
|
||||||
|
InetAddress inetAddress = (InetAddress) nii.nextElement();
|
||||||
|
if (inetAddress.getHostAddress().indexOf(":") == -1) {
|
||||||
|
String ip = inetAddress.getHostAddress();
|
||||||
|
if (ip.startsWith("10.") || ip.startsWith("192.168.")) {// ||
|
||||||
|
return ip;
|
||||||
|
} else {
|
||||||
|
if (ip.startsWith("172.")) {
|
||||||
|
|
||||||
|
return ip;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "127.0.0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDateStr(String date) {
|
||||||
|
date = date.replaceAll("-", "");
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照原路径的类型就行压缩。文件路径直接把文件压缩
|
||||||
|
* @param src
|
||||||
|
* @param zos
|
||||||
|
* @param baseDir
|
||||||
|
*/
|
||||||
|
private void compressbyType(String src, ZipOutputStream zos, String baseDir) {
|
||||||
|
File srcFile = new File(src);
|
||||||
|
if (!srcFile.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//判断文件是否是文件,如果是文件调用compressFile方法,如果是路径,则调用compressDir方法;
|
||||||
|
if (srcFile.isFile()) {
|
||||||
|
//src是文件,调用此方法
|
||||||
|
compressFile(srcFile, zos, baseDir);
|
||||||
|
} else if (srcFile.isDirectory()) {
|
||||||
|
compressDir(srcFile, zos, baseDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 压缩文件,取后面的80M内容
|
||||||
|
*/
|
||||||
|
private void compressFile(File file, ZipOutputStream zos, String baseDir) {
|
||||||
|
if (!file.exists())
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
RandomAccessFile fileRead = new RandomAccessFile(file, "r"); //用读模式
|
||||||
|
long fileLength = fileRead.length();//获得文件长度
|
||||||
|
if (file.getName().endsWith(".log") && fileLength > 1073741820) {//如果文件超过80M,则只取文件倒数80M内容
|
||||||
|
messageStr.append("、").append(file.getName());
|
||||||
|
fileRead.seek(fileLength - 1073741820);
|
||||||
|
} else {
|
||||||
|
fileRead.seek(0);
|
||||||
|
}
|
||||||
|
ZipEntry entry = new ZipEntry(baseDir + file.getName());
|
||||||
|
zos.putNextEntry(entry);
|
||||||
|
int hasRead;
|
||||||
|
byte[] buf = new byte[1024];
|
||||||
|
while ((hasRead = fileRead.read(buf)) != -1) {
|
||||||
|
zos.write(buf, 0, hasRead);
|
||||||
|
}
|
||||||
|
fileRead.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 压缩文件夹
|
||||||
|
*/
|
||||||
|
private void compressDir(File dir, ZipOutputStream zos, String baseDir) {
|
||||||
|
if (!dir.exists())
|
||||||
|
return;
|
||||||
|
File[] files = dir.listFiles();
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
File file = files[i];
|
||||||
|
compressFile(file, zos, baseDir + dir.getName() + File.separator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%>
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -0,0 +1,469 @@
|
||||||
|
<%@ page language="java" contentType="text/html; charset=utf-8" %>
|
||||||
|
<%@ page import="org.apache.commons.io.IOUtils" %>
|
||||||
|
<%@ page import="java.io.*" %>
|
||||||
|
<%@ page import="java.net.InetAddress" %>
|
||||||
|
<%@ page import="java.net.NetworkInterface" %>
|
||||||
|
<%@ page import="java.util.Enumeration" %>
|
||||||
|
<%@ page import="java.util.HashSet" %>
|
||||||
|
<%@ page import="java.util.Properties" %>
|
||||||
|
<%@ page import="java.util.Set" %>
|
||||||
|
<%
|
||||||
|
|
||||||
|
final String ecologyPath = request.getRealPath("/");
|
||||||
|
weaver.hrm.User user = (weaver.hrm.User) request.getSession(true).getAttribute("weaver_user@bean");
|
||||||
|
if (user == null || !"sysadmin".equals(user.getLoginid())) {
|
||||||
|
response.sendRedirect("/");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String ResinPath = System.getProperty("user.dir") + File.separator;
|
||||||
|
boolean isResin = ResinPath.toLowerCase().indexOf("resin") != -1;
|
||||||
|
String ecologyWeaverPath = "";
|
||||||
|
if (ecologyPath.endsWith(File.separator)) {
|
||||||
|
ecologyWeaverPath = ecologyPath + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties";
|
||||||
|
} else {
|
||||||
|
ecologyWeaverPath = ecologyPath + File.separator + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties";
|
||||||
|
}
|
||||||
|
|
||||||
|
File ecolpogyProp = new File(ecologyWeaverPath);
|
||||||
|
File resinProp = new File(ResinPath + "bin" + File.separator + "startresin.sh");
|
||||||
|
|
||||||
|
Set ipList = readEcologyProp(ecolpogyProp);
|
||||||
|
String localIp = getInnerIp();
|
||||||
|
if (ipList.size() == 0) {
|
||||||
|
ipList.addAll(readResinProp(resinProp));
|
||||||
|
}
|
||||||
|
boolean isCluster = true;
|
||||||
|
if (ipList.size() == 0) {//没有集群的时候
|
||||||
|
//ipList.add(localIp);
|
||||||
|
isCluster = false;
|
||||||
|
} else {
|
||||||
|
boolean status = false;
|
||||||
|
java.util.Iterator it = ipList.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
String ip = (String) it.next();
|
||||||
|
if (ip.indexOf(localIp) != -1 || "127.0.0.1".equals(ip) || "127.0.0.1".equals(localIp)) {
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!status) {
|
||||||
|
ipList.add(localIp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
/**
|
||||||
|
* 当前机器内网ip
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getInnerIp() {
|
||||||
|
try {
|
||||||
|
Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
while (netInterfaces.hasMoreElements()) {
|
||||||
|
NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
|
||||||
|
Enumeration nii = ni.getInetAddresses();
|
||||||
|
while (nii.hasMoreElements()) {
|
||||||
|
InetAddress inetAddress = (InetAddress) nii.nextElement();
|
||||||
|
if (inetAddress.getHostAddress().indexOf(":") == -1) {
|
||||||
|
String ip = inetAddress.getHostAddress();
|
||||||
|
if (ip.startsWith("10.") || ip.startsWith("192.168.")) {// ||
|
||||||
|
return ip;
|
||||||
|
} else {
|
||||||
|
if (ip.startsWith("172.")) {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "127.0.0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set readResinProp(File startResinFile) {
|
||||||
|
Set liststr = new HashSet();
|
||||||
|
if (!startResinFile.exists()) {
|
||||||
|
return liststr;
|
||||||
|
}
|
||||||
|
if (startResinFile.isFile() && startResinFile.length() > 0) {
|
||||||
|
FileInputStream fileInput = null;
|
||||||
|
BufferedReader bufferedReader = null;
|
||||||
|
try {
|
||||||
|
fileInput = new FileInputStream(startResinFile);
|
||||||
|
bufferedReader = new BufferedReader(new InputStreamReader(fileInput));
|
||||||
|
String str = null;
|
||||||
|
while ((str = bufferedReader.readLine()) != null) {
|
||||||
|
if (str.indexOf("-Dinitial_hosts") != -1 || str.indexOf("-J-Dinitial_hosts") != -1) {
|
||||||
|
if (str.indexOf("-J-Dinitial_hosts") != -1) {
|
||||||
|
str = str.substring(str.indexOf("-J-Dinitial_hosts") + 17);
|
||||||
|
}
|
||||||
|
if (str.indexOf("-Dinitial_hosts") != -1) {
|
||||||
|
str = str.substring(str.indexOf("-Dinitial_hosts") + 15);
|
||||||
|
}
|
||||||
|
str = str.indexOf("=") != -1 ? str.substring(str.indexOf("=") + 1) : str;
|
||||||
|
str = str.indexOf("-") != -1 ? str.substring(0, str.indexOf("-")) : str;
|
||||||
|
str = str.indexOf(" ") != -1 ? str.substring(0, str.indexOf(" ")) : str;
|
||||||
|
String[] ips = str.split(",");
|
||||||
|
for (int i = 0; i < ips.length; i++) {
|
||||||
|
String ip = ips[i];
|
||||||
|
try {
|
||||||
|
String tmpip = ip.replace(".", "").replace(":", "");
|
||||||
|
Long.parseLong(tmpip.trim());
|
||||||
|
liststr.add(ip.trim());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(fileInput);
|
||||||
|
IOUtils.closeQuietly(bufferedReader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return liststr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Set readEcologyProp(File file) {
|
||||||
|
Set liststr = new HashSet();
|
||||||
|
try {
|
||||||
|
if (!file.exists()) {
|
||||||
|
return liststr;
|
||||||
|
}
|
||||||
|
Properties registerProp = new Properties();
|
||||||
|
InputStreamReader reader = new InputStreamReader(new FileInputStream(file));
|
||||||
|
registerProp.load(reader);
|
||||||
|
String initial_host = registerProp.getProperty("initial_hosts");
|
||||||
|
if (initial_host != null && !"".equals(initial_host)) {
|
||||||
|
String[] initial_hosts = initial_host.split(",");
|
||||||
|
for (int i = 0; i < initial_hosts.length; i++) {
|
||||||
|
String initial_hostStr = initial_hosts[i];
|
||||||
|
if (!initial_hostStr.isEmpty()) {
|
||||||
|
liststr.add(initial_hostStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IOUtils.closeQuietly(reader);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return liststr;
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="css/index.css">
|
||||||
|
|
||||||
|
<script type="text/javascript" src="js/jquery.js"></script>
|
||||||
|
<script type="text/javascript" src="js/data.js"></script>
|
||||||
|
<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
$("#downstartlogDate").val(new Date().format("yyyy-MM-dd"));
|
||||||
|
$("#downendlogDate").val(new Date().format("yyyy-MM-dd"));
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
function collectLog() {
|
||||||
|
var clusterips = "";
|
||||||
|
$("[name='clusterip']:checked").each(function () {
|
||||||
|
clusterips += $(this).val() + ",";
|
||||||
|
|
||||||
|
})
|
||||||
|
if (<%=isCluster%>&&
|
||||||
|
clusterips == ''
|
||||||
|
)
|
||||||
|
{
|
||||||
|
alert("请选择服务器节点!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clusterips = clusterips.substr(0, clusterips.length - 1);
|
||||||
|
|
||||||
|
var loytype = "";
|
||||||
|
$("[name='loytype']:checked").each(function () {
|
||||||
|
loytype += $(this).val() + ",";
|
||||||
|
})
|
||||||
|
if (loytype == '') {
|
||||||
|
alert("请选择日志类型!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loytype = loytype.substr(0, loytype.length - 1);
|
||||||
|
var startDate = $("#downstartlogDate").val();
|
||||||
|
var endDate = $("#downendlogDate").val();
|
||||||
|
if (startDate == '') {
|
||||||
|
alert("请选择开始日期!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (endDate == '') {
|
||||||
|
alert("请选择结束日期!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var oDate1 = new Date(startDate);
|
||||||
|
var oDate2 = new Date(endDate);
|
||||||
|
if (oDate1.getTime() > oDate2.getTime()) {
|
||||||
|
alert("结束日志不能少于开始日期!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
waitInt = 0;
|
||||||
|
$("#start").attr("disabled", "disabled");
|
||||||
|
var clts = clusterips.split(",");
|
||||||
|
for (var i = 0; i < clts.length && clts.length > 0; i++) {
|
||||||
|
var ip = clts[i];
|
||||||
|
var clt = ip.replace(/\./g, "");
|
||||||
|
clt = clt.replace(/\:/g, "");
|
||||||
|
if (clt.indexOf("<%=localIp%>") != -1) {
|
||||||
|
waitInt += 1
|
||||||
|
getLog(clt, ip, loytype, startDate, endDate);
|
||||||
|
} else {
|
||||||
|
waitInt += 1
|
||||||
|
getOtherLog(clt, ip, loytype, startDate, endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (<%=!isCluster%>) {
|
||||||
|
waitInt += 1
|
||||||
|
getLog('log', '<%=localIp%>', loytype, startDate, endDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getold7Day() {
|
||||||
|
var now = new Date();
|
||||||
|
var date = new Date(now.getTime() - 7 * 24 * 3600 * 1000);
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var month = date.getMonth() + 1;
|
||||||
|
var day = date.getDate();
|
||||||
|
return year + '-' + month + '-' + day;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLog(div, ip, loytype, startDate, endDate) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
contentType: " charset=utf-8",
|
||||||
|
url: '/cus_getlog/getlog.jsp?loytype=' + loytype + '&startDate=' + startDate + '&endDate=' + endDate,
|
||||||
|
beforeSend: function () {
|
||||||
|
$("#" + div + "div").html('<img alt="" style = "width: 20px;height: 20px;" src="img/loading.gif">')
|
||||||
|
$("#" + div + "messagediv").html('')
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
waitInt--;
|
||||||
|
if (waitInt == 0) {
|
||||||
|
$("#start").removeAttr("disabled");
|
||||||
|
}
|
||||||
|
var dataTmp = data.split(",");
|
||||||
|
if (dataTmp[0] != '0KB' && dataTmp[0].trim() != '') {
|
||||||
|
var iptmp = ip.indexOf(":") > 0 ? ip.substr(0, ip.indexOf(":")) : ip;
|
||||||
|
|
||||||
|
$("#" + div + "div").html('<a href="/getlog/downlog.jsp?logName=' + iptmp + 'downLog.zip">' + iptmp + 'downLog.zip(' + dataTmp[0] + ') 下载</a>')
|
||||||
|
if (dataTmp[1] != null && dataTmp[1] != undefined && dataTmp[1].trim() != '') {
|
||||||
|
var messtr = dataTmp[1];
|
||||||
|
$("#" + div + "messagediv").html(messtr.substr(1, messtr.length) + '日志内容大于1G,此次日志收集内容只取日志后面的1G内容,如需完整日志,请在服务器器上获取.请知晓!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var waitInt = 0;
|
||||||
|
|
||||||
|
function getOtherLog(div, clusterIp, loytype, startDate, endDate) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
contentType: " charset=utf-8",
|
||||||
|
url: '/cus_getlog/sendUrl.jsp?clusterIp=' + clusterIp + '&loytype=' + loytype + '&startDate=' + startDate + '&endDate=' + endDate,
|
||||||
|
beforeSend: function () {
|
||||||
|
$("#" + div + "div").html('<img alt="" style = "width: 20px;height: 20px;" src="img/loading.gif">');
|
||||||
|
$("#" + div + "messagediv").html('')
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
var dataTmp = data.split(",");
|
||||||
|
waitInt--;
|
||||||
|
if (waitInt == 0) {
|
||||||
|
$("#start").removeAttr("disabled");
|
||||||
|
}
|
||||||
|
if (data.trim() == '1') {
|
||||||
|
$("#" + div + "div").html('收集失败,系统参数不全!')
|
||||||
|
} else if (data.trim() == '2') {
|
||||||
|
$("#" + div + "div").html(clusterIp + '请求被拦截,请将/getlog/getlog.jsp请求')
|
||||||
|
} else if (data.trim() == '3') {
|
||||||
|
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||||
|
} else if (data.trim() == '4') {
|
||||||
|
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||||
|
} else if (data.trim() != '0KB' && dataTmp[0].trim() != '') {
|
||||||
|
var iptmp = clusterIp.indexOf(":") > 0 ? clusterIp.substr(0, clusterIp.indexOf(":")) : clusterIp;
|
||||||
|
var otherIp = clusterIp.replace(":", "-");
|
||||||
|
//console.info('<a href="/getlog/downlog.jsp?logName='+iptmp+'downLog.zip&otherIp='+otherIp+'">'+iptmp+'downLog.zip('+data+') 下载</a>')
|
||||||
|
$("#" + div + "div").html('<a href="/getlog/downlog.jsp?logName=' + iptmp + 'downLog.zip&otherIp=' + otherIp + '">' + iptmp + 'downLog.zip(' + data + ') 下载</a>')
|
||||||
|
|
||||||
|
if (dataTmp[1] != null && dataTmp[1] != undefined && dataTmp[1].trim() != '') {
|
||||||
|
var messtr = dataTmp[1];
|
||||||
|
$("#" + div + "messagediv").html(messtr.substr(1, messtr.length) + '日志内容大于1G,此次日志收集内容只取日志后面的1G内容,如需完整日志,请在服务器器上获取.请知晓!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body style="margin-top: 0px;">
|
||||||
|
<div class="box" style="margin-top: 0px;">
|
||||||
|
<div class="mytitle">
|
||||||
|
<div style="padding-top: 10px;padding-left: 16px">
|
||||||
|
ecology日志下载
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="" class="contend">
|
||||||
|
<%if (isCluster) { %>
|
||||||
|
<div class="cluster">
|
||||||
|
<div>服务器节点</div>
|
||||||
|
<div class="clusterPlan">
|
||||||
|
<%
|
||||||
|
java.util.Iterator it = ipList.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
String ip = (String) it.next();
|
||||||
|
%>
|
||||||
|
<div class="clusterIp" style="width:180px">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="clusterip" value="<%=ip %>" checked>
|
||||||
|
<span></span>
|
||||||
|
<%=ip %>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<%}%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%}%>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="cluster">
|
||||||
|
<div>日志类型</div>
|
||||||
|
<div class="clusterPlan">
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="monitor">
|
||||||
|
性能日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clusterIp" style="width: 140px">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="ecology" checked>
|
||||||
|
ecology日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="Resin">
|
||||||
|
Resin日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="security">
|
||||||
|
安全日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="integration">
|
||||||
|
集成日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="sql">
|
||||||
|
sql日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="cus" checked>
|
||||||
|
cus日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="http_util" checked>
|
||||||
|
http_util日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="sql_log" checked>
|
||||||
|
sql_log日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="clusterIp">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="checkbox" name="loytype" value="util_cus" checked>
|
||||||
|
util_cus日志
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="cluster">
|
||||||
|
<div>时间范围</div>
|
||||||
|
<div class="clusterPlan">
|
||||||
|
<div style="text-algin:center;font-family: PingFangSC-Regular;font-size: 12px;color: #999999;letter-spacing: -0.07px;">
|
||||||
|
<span style="padding-right:10px;color:#6d6d6d;">开始时间</span>
|
||||||
|
<input id="downstartlogDate" class="Wdate" type="text"
|
||||||
|
onclick="WdatePicker({minDate:'#F{getold7Day()}',maxDate:'%y-%M-%d'})" size="16" readonly/>
|
||||||
|
-
|
||||||
|
<span style="padding-right:10px;color:#6d6d6d;">结束时间</span>
|
||||||
|
<input id="downendlogDate" class="Wdate" type="text"
|
||||||
|
onclick="WdatePicker({minDate:'#F{getold7Day()}',maxDate:'%y-%M-%d'})" size="16" readonly/>
|
||||||
|
<span style="width: 10px;display:inline-block"></span>
|
||||||
|
<button class="Button" id="start" onclick="collectLog()">收集日志</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cluster" style="height: 300px;max-height: 300px;overflow-y:auto ">
|
||||||
|
<div>下载列表</div>
|
||||||
|
<div class="clusterPlan">
|
||||||
|
<%
|
||||||
|
java.util.Iterator it = ipList.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
String ip = (String) it.next();
|
||||||
|
ip = ip.replaceAll("\\.", "");
|
||||||
|
ip = ip.replaceAll(":", "");
|
||||||
|
%>
|
||||||
|
<div id="<%=ip%>div">
|
||||||
|
</div>
|
||||||
|
<div id="<%=ip%>messagediv" class="messages"></div>
|
||||||
|
<%}%>
|
||||||
|
|
||||||
|
<%if (!isCluster) { %>
|
||||||
|
<div id="logdiv"></div>
|
||||||
|
<div id="logmessagediv" class="messages"></div>
|
||||||
|
<%} %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,14 @@
|
||||||
|
var $lang={
|
||||||
|
errAlertMsg: "Invalid date or the date out of range,redo or not?",
|
||||||
|
aWeekStr: ["wk", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||||||
|
aLongWeekStr:["wk","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
|
||||||
|
aMonStr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||||
|
aLongMonStr: ["January","February","March","April","May","June","July","August","September","October","November","December"],
|
||||||
|
clearStr: "Clear",
|
||||||
|
todayStr: "Today",
|
||||||
|
okStr: "OK",
|
||||||
|
updateStr: "OK",
|
||||||
|
timeStr: "Time",
|
||||||
|
quickStr: "Quick Selection",
|
||||||
|
err_1: 'MinDate Cannot be bigger than MaxDate!'
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
var $lang={
|
||||||
|
errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u8303\u56F4,\u9700\u8981\u64A4\u9500\u5417?",
|
||||||
|
aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],
|
||||||
|
aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],
|
||||||
|
aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"],
|
||||||
|
aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],
|
||||||
|
clearStr: "\u6E05\u7A7A",
|
||||||
|
todayStr: "\u4ECA\u5929",
|
||||||
|
okStr: "\u786E\u5B9A",
|
||||||
|
updateStr: "\u786E\u5B9A",
|
||||||
|
timeStr: "\u65F6\u95F4",
|
||||||
|
quickStr: "\u5FEB\u901F\u9009\u62E9",
|
||||||
|
err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u65E5\u671F!'
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
var $lang={
|
||||||
|
errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u7BC4\u570D,\u9700\u8981\u64A4\u92B7\u55CE?",
|
||||||
|
aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],
|
||||||
|
aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],
|
||||||
|
aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"],
|
||||||
|
aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],
|
||||||
|
clearStr: "\u6E05\u7A7A",
|
||||||
|
todayStr: "\u4ECA\u5929",
|
||||||
|
okStr: "\u78BA\u5B9A",
|
||||||
|
updateStr: "\u78BA\u5B9A",
|
||||||
|
timeStr: "\u6642\u9593",
|
||||||
|
quickStr: "\u5FEB\u901F\u9078\u64C7",
|
||||||
|
err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u65BC\u6700\u5927\u65E5\u671F!'
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
.Wdate{
|
||||||
|
border:#999 1px solid;
|
||||||
|
height:20px;
|
||||||
|
background:#fff url(datePicker.gif) no-repeat right;
|
||||||
|
}
|
||||||
|
.Wdate::-ms-clear{display:none;}
|
||||||
|
|
||||||
|
.WdateFmtErr{
|
||||||
|
font-weight:bold;
|
||||||
|
color:red;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -0,0 +1,246 @@
|
||||||
|
/*
|
||||||
|
* My97 DatePicker 4.8
|
||||||
|
*/
|
||||||
|
|
||||||
|
.WdateDiv{
|
||||||
|
width:180px;
|
||||||
|
background-color:#FFFFFF;
|
||||||
|
border:#bbb 1px solid;
|
||||||
|
padding:2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv2{
|
||||||
|
width:360px;
|
||||||
|
}
|
||||||
|
.WdateDiv *{font-size:9pt;}
|
||||||
|
|
||||||
|
.WdateDiv .NavImg a{
|
||||||
|
display:block;
|
||||||
|
cursor:pointer;
|
||||||
|
height:16px;
|
||||||
|
width:16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .NavImgll a{
|
||||||
|
float:left;
|
||||||
|
background:transparent url(img.gif) no-repeat scroll 0 0;
|
||||||
|
}
|
||||||
|
.WdateDiv .NavImgl a{
|
||||||
|
float:left;
|
||||||
|
background:transparent url(img.gif) no-repeat scroll -16px 0;
|
||||||
|
}
|
||||||
|
.WdateDiv .NavImgr a{
|
||||||
|
float:right;
|
||||||
|
background:transparent url(img.gif) no-repeat scroll -32px 0;
|
||||||
|
}
|
||||||
|
.WdateDiv .NavImgrr a{
|
||||||
|
float:right;
|
||||||
|
background:transparent url(img.gif) no-repeat scroll -48px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTitle{
|
||||||
|
height:24px;
|
||||||
|
margin-bottom:2px;
|
||||||
|
padding:1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .yminput{
|
||||||
|
margin-top:2px;
|
||||||
|
text-align:center;
|
||||||
|
height:20px;
|
||||||
|
border:0px;
|
||||||
|
width:50px;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .yminputfocus{
|
||||||
|
margin-top:2px;
|
||||||
|
text-align:center;
|
||||||
|
font-weight:bold;
|
||||||
|
height:20px;
|
||||||
|
color:blue;
|
||||||
|
border:#ccc 1px solid;
|
||||||
|
width:50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .menuSel{
|
||||||
|
z-index:1;
|
||||||
|
position:absolute;
|
||||||
|
background-color:#FFFFFF;
|
||||||
|
border:#ccc 1px solid;
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .menu{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .menuOn{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#BEEBEE;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .invalidMenu{
|
||||||
|
color:#aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .YMenu{
|
||||||
|
margin-top:20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .MMenu{
|
||||||
|
margin-top:20px;
|
||||||
|
*width:62px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .hhMenu{
|
||||||
|
margin-top:-90px;
|
||||||
|
margin-left:26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .mmMenu{
|
||||||
|
margin-top:-46px;
|
||||||
|
margin-left:26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .ssMenu{
|
||||||
|
margin-top:-24px;
|
||||||
|
margin-left:26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .Wweek {
|
||||||
|
text-align:center;
|
||||||
|
background:#DAF3F5;
|
||||||
|
border-right:#BDEBEE 1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .MTitle{
|
||||||
|
background-color:#BDEBEE;
|
||||||
|
}
|
||||||
|
.WdateDiv .WdayTable2{
|
||||||
|
border-collapse:collapse;
|
||||||
|
border:#c5d9e8 1px solid;
|
||||||
|
}
|
||||||
|
.WdateDiv .WdayTable2 table{
|
||||||
|
border:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WdayTable{
|
||||||
|
line-height:20px;
|
||||||
|
border:#c5d9e8 1px solid;
|
||||||
|
}
|
||||||
|
.WdateDiv .WdayTable td{
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .Wday{
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WdayOn{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#C0EBEF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .Wwday{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#FF2F2F;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WwdayOn{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#000;
|
||||||
|
background-color:#C0EBEF;
|
||||||
|
}
|
||||||
|
.WdateDiv .Wtoday{
|
||||||
|
cursor:pointer;
|
||||||
|
color:blue;
|
||||||
|
}
|
||||||
|
.WdateDiv .Wselday{
|
||||||
|
background-color:#A9E4E9;
|
||||||
|
}
|
||||||
|
.WdateDiv .WspecialDay{
|
||||||
|
background-color:#66F4DF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WotherDay{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#6A6AFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WotherDayOn{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#C0EBEF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WinvalidDay{
|
||||||
|
color:#aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime{
|
||||||
|
float:left;
|
||||||
|
margin-top:3px;
|
||||||
|
margin-right:30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime #dpTimeStr{
|
||||||
|
margin-left:1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime input{
|
||||||
|
width:18px;
|
||||||
|
height:20px;
|
||||||
|
text-align:center;
|
||||||
|
border:#ccc 1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime .tB{
|
||||||
|
border-right:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime .tE{
|
||||||
|
border-left:0;
|
||||||
|
border-right:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime .tm{
|
||||||
|
width:7px;
|
||||||
|
border-left:0;
|
||||||
|
border-right:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime #dpTimeUp{
|
||||||
|
height:10px;
|
||||||
|
width:13px;
|
||||||
|
border:0px;
|
||||||
|
background:url(img.gif) no-repeat -32px -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime #dpTimeDown{
|
||||||
|
height:10px;
|
||||||
|
width:13px;
|
||||||
|
border:0px;
|
||||||
|
background:url(img.gif) no-repeat -48px -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpQS {
|
||||||
|
float:left;
|
||||||
|
margin-right:3px;
|
||||||
|
margin-top:3px;
|
||||||
|
background:url(img.gif) no-repeat 0px -16px;
|
||||||
|
width:20px;
|
||||||
|
height:20px;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
.WdateDiv #dpControl {
|
||||||
|
text-align:right;
|
||||||
|
}
|
||||||
|
.WdateDiv .dpButton{
|
||||||
|
height:20px;
|
||||||
|
width:45px;
|
||||||
|
border:#ccc 1px solid;
|
||||||
|
margin-top:2px;
|
||||||
|
margin-right:1px;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 307 B |
|
@ -0,0 +1,256 @@
|
||||||
|
/*
|
||||||
|
* My97 DatePicker 4.8 Skin:whyGreen
|
||||||
|
*/
|
||||||
|
.WdateDiv{
|
||||||
|
width:180px;
|
||||||
|
background-color:#fff;
|
||||||
|
border:#C5E1E4 1px solid;
|
||||||
|
padding:2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv2{
|
||||||
|
width:360px;
|
||||||
|
}
|
||||||
|
.WdateDiv *{font-size:9pt;}
|
||||||
|
|
||||||
|
.WdateDiv .NavImg a{
|
||||||
|
cursor:pointer;
|
||||||
|
display:block;
|
||||||
|
width:16px;
|
||||||
|
height:16px;
|
||||||
|
margin-top:1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .NavImgll a{
|
||||||
|
float:left;
|
||||||
|
background:url(img.gif) no-repeat;
|
||||||
|
}
|
||||||
|
.WdateDiv .NavImgl a{
|
||||||
|
float:left;
|
||||||
|
background:url(img.gif) no-repeat -16px 0px;
|
||||||
|
}
|
||||||
|
.WdateDiv .NavImgr a{
|
||||||
|
float:right;
|
||||||
|
background:url(img.gif) no-repeat -32px 0px;
|
||||||
|
}
|
||||||
|
.WdateDiv .NavImgrr a{
|
||||||
|
float:right;
|
||||||
|
background:url(img.gif) no-repeat -48px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTitle{
|
||||||
|
height:24px;
|
||||||
|
padding:1px;
|
||||||
|
border:#c5d9e8 1px solid;
|
||||||
|
background:url(bg.jpg);
|
||||||
|
margin-bottom:2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .yminput{
|
||||||
|
margin-top:2px;
|
||||||
|
text-align:center;
|
||||||
|
border:0px;
|
||||||
|
height:20px;
|
||||||
|
width:50px;
|
||||||
|
color:#034c50;
|
||||||
|
background-color:transparent;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .yminputfocus{
|
||||||
|
margin-top:2px;
|
||||||
|
text-align:center;
|
||||||
|
border:#939393 1px solid;
|
||||||
|
font-weight:bold;
|
||||||
|
color:#034c50;
|
||||||
|
height:20px;
|
||||||
|
width:50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .menuSel{
|
||||||
|
z-index:1;
|
||||||
|
position:absolute;
|
||||||
|
background-color:#FFFFFF;
|
||||||
|
border:#A3C6C8 1px solid;
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .menu{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#fff;
|
||||||
|
color:#11777C;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .menuOn{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#BEEBEE;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .invalidMenu{
|
||||||
|
color:#aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .YMenu{
|
||||||
|
margin-top:20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .MMenu{
|
||||||
|
margin-top:20px;
|
||||||
|
*width:62px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .hhMenu{
|
||||||
|
margin-top:-90px;
|
||||||
|
margin-left:26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .mmMenu{
|
||||||
|
margin-top:-46px;
|
||||||
|
margin-left:26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .ssMenu{
|
||||||
|
margin-top:-24px;
|
||||||
|
margin-left:26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .Wweek {
|
||||||
|
text-align:center;
|
||||||
|
background:#DAF3F5;
|
||||||
|
border-right:#BDEBEE 1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .MTitle{
|
||||||
|
color:#13777e;
|
||||||
|
background-color:#bdebee;
|
||||||
|
}
|
||||||
|
.WdateDiv .WdayTable2{
|
||||||
|
border-collapse:collapse;
|
||||||
|
border:#BEE9F0 1px solid;
|
||||||
|
}
|
||||||
|
.WdateDiv .WdayTable2 table{
|
||||||
|
border:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WdayTable{
|
||||||
|
line-height:20px;
|
||||||
|
color:#13777e;
|
||||||
|
background-color:#edfbfb;
|
||||||
|
border:#BEE9F0 1px solid;
|
||||||
|
}
|
||||||
|
.WdateDiv .WdayTable td{
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .Wday{
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WdayOn{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#74d2d9 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .Wwday{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#ab1e1e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WwdayOn{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#74d2d9;
|
||||||
|
}
|
||||||
|
.WdateDiv .Wtoday{
|
||||||
|
cursor:pointer;
|
||||||
|
color:blue;
|
||||||
|
}
|
||||||
|
.WdateDiv .Wselday{
|
||||||
|
background-color:#A7E2E7;
|
||||||
|
}
|
||||||
|
.WdateDiv .WspecialDay{
|
||||||
|
background-color:#66F4DF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WotherDay{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#0099CC;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WotherDayOn{
|
||||||
|
cursor:pointer;
|
||||||
|
background-color:#C0EBEF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv .WinvalidDay{
|
||||||
|
color:#aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime{
|
||||||
|
float:left;
|
||||||
|
margin-top:3px;
|
||||||
|
margin-right:30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime #dpTimeStr{
|
||||||
|
margin-left:1px;
|
||||||
|
color:#497F7F;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime input{
|
||||||
|
height:20px;
|
||||||
|
width:18px;
|
||||||
|
text-align:center;
|
||||||
|
color:#333;
|
||||||
|
border:#61CAD0 1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime .tB{
|
||||||
|
border-right:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime .tE{
|
||||||
|
border-left:0;
|
||||||
|
border-right:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime .tm{
|
||||||
|
width:7px;
|
||||||
|
border-left:0;
|
||||||
|
border-right:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime #dpTimeUp{
|
||||||
|
height:10px;
|
||||||
|
width:13px;
|
||||||
|
border:0px;
|
||||||
|
background:url(img.gif) no-repeat -32px -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpTime #dpTimeDown{
|
||||||
|
height:10px;
|
||||||
|
width:13px;
|
||||||
|
border:0px;
|
||||||
|
background:url(img.gif) no-repeat -48px -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WdateDiv #dpQS {
|
||||||
|
float:left;
|
||||||
|
margin-right:3px;
|
||||||
|
margin-top:3px;
|
||||||
|
background:url(img.gif) no-repeat 0px -16px;
|
||||||
|
width:20px;
|
||||||
|
height:20px;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
.WdateDiv #dpControl {
|
||||||
|
text-align:right;
|
||||||
|
margin-top:3px;
|
||||||
|
}
|
||||||
|
.WdateDiv .dpButton{
|
||||||
|
height:20px;
|
||||||
|
width:45px;
|
||||||
|
margin-top:2px;
|
||||||
|
border:#38B1B9 1px solid;
|
||||||
|
background-color:#CFEBEE;
|
||||||
|
color:#08575B;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -0,0 +1,19 @@
|
||||||
|
Date.prototype.format = function(format) //author: meizz
|
||||||
|
{
|
||||||
|
var o = {
|
||||||
|
"M+" : this.getMonth()+1, //month
|
||||||
|
"d+" : this.getDate(), //day
|
||||||
|
"h+" : this.getHours(), //hour
|
||||||
|
"m+" : this.getMinutes(), //minute
|
||||||
|
"s+" : this.getSeconds(), //second
|
||||||
|
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
|
||||||
|
"S" : this.getMilliseconds() //millisecond
|
||||||
|
}
|
||||||
|
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
|
||||||
|
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
|
||||||
|
for(var k in o)if(new RegExp("("+ k +")").test(format))
|
||||||
|
format = format.replace(RegExp.$1,
|
||||||
|
RegExp.$1.length==1 ? o[k] :
|
||||||
|
("00"+ o[k]).substr((""+ o[k]).length));
|
||||||
|
return format;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,38 @@
|
||||||
|
<%@ page language="java"%><%@ page import="java.util.Properties" %><%@ page import="java.text.*" %><%@ page import="java.util.*" %><%@ page import="java.util.zip.*" %><%@ page import="org.apache.commons.httpclient.HttpClient" %><%@ page import="org.apache.commons.httpclient.methods.GetMethod" %><%
|
||||||
|
|
||||||
|
String clusterIp = request.getParameter("clusterIp");
|
||||||
|
String loytype = request.getParameter("loytype");
|
||||||
|
String startDate = request.getParameter("startDate");
|
||||||
|
String endDate = request.getParameter("endDate");
|
||||||
|
String result = ""; //0,成功,1、参数不对,2、被拦截,3、ecology不能访问
|
||||||
|
|
||||||
|
weaver.hrm.User user = (weaver.hrm.User)request.getSession(true).getAttribute("weaver_user@bean");
|
||||||
|
if(user==null || !"sysadmin".equals(user.getLoginid())){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(clusterIp ==null || clusterIp.equals("") || loytype ==null || loytype.equals("") || startDate ==null || startDate.equals("")){
|
||||||
|
result = "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.getHttpConnectionManager().getParams().setSoTimeout(60000*10);
|
||||||
|
client.getHttpConnectionManager().getParams().setConnectionTimeout(6000*10);
|
||||||
|
try {
|
||||||
|
String url = "http://"+clusterIp+"/cus_getlog/getlog.jsp?loytype="+loytype+"&startDate="+startDate+"&endDate="+endDate;
|
||||||
|
GetMethod gets = new GetMethod(url);
|
||||||
|
client.executeMethod(gets);
|
||||||
|
int code = gets.getStatusCode();
|
||||||
|
if(code==200){
|
||||||
|
result = new String(gets.getResponseBody(),"UTF-8");
|
||||||
|
}else if(code == 302){
|
||||||
|
result="2";
|
||||||
|
}else{
|
||||||
|
result="3";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
result = "4";
|
||||||
|
}
|
||||||
|
out.println(result);
|
||||||
|
%>
|
|
@ -33,6 +33,7 @@ public class JobTitleMultilingualUtil {
|
||||||
private static void extracted() {
|
private static void extracted() {
|
||||||
try {
|
try {
|
||||||
Map<String, Object> jituMultilingual = Util.readProperties2Map("JituMultilingual", "cus.multilingual");
|
Map<String, Object> jituMultilingual = Util.readProperties2Map("JituMultilingual", "cus.multilingual");
|
||||||
|
Util.getLogger().info("配置文件:" + JSON.toJSONString(jituMultilingual));
|
||||||
if (!isEmpty(jituMultilingual)) {
|
if (!isEmpty(jituMultilingual)) {
|
||||||
for (Map.Entry<String, Object> entry : jituMultilingual.entrySet()) {
|
for (Map.Entry<String, Object> entry : jituMultilingual.entrySet()) {
|
||||||
LANGUAGE_MAP.put(entry.getKey(), Util.null2String(entry.getValue()));
|
LANGUAGE_MAP.put(entry.getKey(), Util.null2String(entry.getValue()));
|
||||||
|
@ -159,30 +160,29 @@ public class JobTitleMultilingualUtil {
|
||||||
// 对比缓存数据,如果是上一次传递进来的总数组,则不用再次分组
|
// 对比缓存数据,如果是上一次传递进来的总数组,则不用再次分组
|
||||||
if (!jsonArray.equals(this.jsonArray)) {
|
if (!jsonArray.equals(this.jsonArray)) {
|
||||||
this.jsonArray = jsonArray;
|
this.jsonArray = jsonArray;
|
||||||
|
extracted();
|
||||||
this.groupMap = list.stream().collect(Collectors.groupingBy(getKey));
|
this.groupMap = list.stream().collect(Collectors.groupingBy(getKey));
|
||||||
log.info("job title group : " + JSON.toJSONString(this.groupMap));
|
|
||||||
}
|
}
|
||||||
String active = LANGUAGE_MAP.get("active");
|
String active = LANGUAGE_MAP.get("active");
|
||||||
if (isBlank(active)) {
|
if (isBlank(active)) {
|
||||||
return getName.apply(JSONObject.toJavaObject(currentObj, Map.class));
|
return getName.apply(JSONObject.toJavaObject(currentObj, Map.class));
|
||||||
}
|
}
|
||||||
// 默认添加中文
|
// 默认添加中文
|
||||||
active += ",ZHS";
|
|
||||||
String[] activeLanguageArray = active.split(",");
|
String[] activeLanguageArray = active.split(",");
|
||||||
List<String> activeList = Arrays.stream(activeLanguageArray).distinct().collect(Collectors.toList());
|
Set<String> set = new HashSet<>();
|
||||||
log.info("active language: " + JSON.toJSONString(activeList));
|
Collections.addAll(set, activeLanguageArray);
|
||||||
log.info("language map: " + JSON.toJSONString(LANGUAGE_MAP));
|
set.add("ZHS");
|
||||||
groupMap = this.groupMap;
|
groupMap = this.groupMap;
|
||||||
if (!isEmpty(groupMap)) {
|
if (!isEmpty(groupMap)) {
|
||||||
List<Map> maps = groupMap.get(getKey.apply(JSONObject.toJavaObject(currentObj, Map.class)));
|
List<Map> maps = groupMap.get(getKey.apply(JSONObject.toJavaObject(currentObj, Map.class)));
|
||||||
log.info("current job Maps: " + JSON.toJSONString(maps));
|
|
||||||
if (!isEmpty(maps)) {
|
if (!isEmpty(maps)) {
|
||||||
sb.append("~`");
|
sb.append("~`");
|
||||||
for (Map map : maps) {
|
for (Map map : maps) {
|
||||||
String name = getName.apply(map);
|
String name = getName.apply(map);
|
||||||
String languageCd = getLanguageCd.apply(map);
|
String languageCd = getLanguageCd.apply(map);
|
||||||
// 当语言转换映射map中存在并且已经开启语言同步时,将对语言进行序列化
|
// 当语言转换映射map中存在并且已经开启语言同步时,将对语言进行序列化
|
||||||
if (LANGUAGE_MAP.containsKey(languageCd) && activeList.contains(languageCd)) {
|
if (LANGUAGE_MAP.containsKey(languageCd) && set.contains(languageCd)) {
|
||||||
String languageId = LANGUAGE_MAP.get(languageCd);
|
String languageId = LANGUAGE_MAP.get(languageCd);
|
||||||
sb.append("~`").append(languageId).append(" ").append(name).append("`");
|
sb.append("~`").append(languageId).append(" ").append(name).append("`");
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.h2.util.StringUtils;
|
||||||
import weaver.aiyh_pcn.common_fadada.entity.CreateFileEntity;
|
import weaver.aiyh_pcn.common_fadada.entity.CreateFileEntity;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
@ -36,6 +35,10 @@ public class FaRequestUtils {
|
||||||
private final static Logger log = Util.getLogger();
|
private final static Logger log = Util.getLogger();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
try {
|
try {
|
||||||
String appId = TOOL_UTIL.getSystemParamValue("FDD_appId");
|
String appId = TOOL_UTIL.getSystemParamValue("FDD_appId");
|
||||||
if (StringUtils.isNullOrEmpty(appId)) {
|
if (StringUtils.isNullOrEmpty(appId)) {
|
||||||
|
@ -281,6 +284,7 @@ public class FaRequestUtils {
|
||||||
* @return 构建结果
|
* @return 构建结果
|
||||||
*/
|
*/
|
||||||
private static String builderSign(Object data) {
|
private static String builderSign(Object data) {
|
||||||
|
init();
|
||||||
HEADER.put("timestamp", Util.getTime("yyyy-MM-dd HH:mm:ss"));
|
HEADER.put("timestamp", Util.getTime("yyyy-MM-dd HH:mm:ss"));
|
||||||
HEADER.put("bizContent", builderBizContent(data));
|
HEADER.put("bizContent", builderBizContent(data));
|
||||||
String signStr = "appId=" + HEADER.get("appId") +
|
String signStr = "appId=" + HEADER.get("appId") +
|
||||||
|
@ -344,12 +348,12 @@ public class FaRequestUtils {
|
||||||
log.info("排序后json编码:" + bizContent);
|
log.info("排序后json编码:" + bizContent);
|
||||||
// 将 JSON 字符串内特殊字符进行编码
|
// 将 JSON 字符串内特殊字符进行编码
|
||||||
bizContent = cn.hutool.core.util.URLUtil.encodeAll(bizContent,
|
bizContent = cn.hutool.core.util.URLUtil.encodeAll(bizContent,
|
||||||
Charset.forName("UTF-8"));
|
StandardCharsets.UTF_8);
|
||||||
log.info("bizContent进行JSON编码后URLEncoder编码:" + bizContent);
|
log.info("bizContent进行JSON编码后URLEncoder编码:" + bizContent);
|
||||||
// 将编码后的 JSON 字符串进行 base64 加密
|
// 将编码后的 JSON 字符串进行 base64 加密
|
||||||
bizContent =
|
bizContent =
|
||||||
cn.hutool.core.codec.Base64.encode(cn.hutool.core.util.StrUtil.bytes(bizContent,
|
cn.hutool.core.codec.Base64.encode(cn.hutool.core.util.StrUtil.bytes(bizContent,
|
||||||
Charset.forName("UTF-8")));
|
StandardCharsets.UTF_8));
|
||||||
log.info("bizContent进行JSON编码后URLEncoder编码后进行base64编码:" + bizContent);
|
log.info("bizContent进行JSON编码后URLEncoder编码后进行base64编码:" + bizContent);
|
||||||
return bizContent;
|
return bizContent;
|
||||||
|
|
||||||
|
|
|
@ -326,13 +326,6 @@ public class PdfMultipleWaterAction implements Action {
|
||||||
keyword, allMark, pdfWaterConfig.getOpacity(),
|
keyword, allMark, pdfWaterConfig.getOpacity(),
|
||||||
pdfWaterConfig.getPicWidth(), pdfWaterConfig.getPciHeight(),
|
pdfWaterConfig.getPicWidth(), pdfWaterConfig.getPciHeight(),
|
||||||
pdfWaterConfig.getOffsetX(), pdfWaterConfig.getOffsetY());
|
pdfWaterConfig.getOffsetX(), pdfWaterConfig.getOffsetY());
|
||||||
} catch (CustomerException e) {
|
|
||||||
if (e.getCode() != null) {
|
|
||||||
if (e.getCode() == -2) {
|
|
||||||
throw new CustomerException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Util.getLogger().error("水印文件生成失败!" + e.getMessage());
|
Util.getLogger().error("水印文件生成失败!" + e.getMessage());
|
||||||
throw new CustomerException("水印文件生成失败!" + e.getMessage(), e);
|
throw new CustomerException("水印文件生成失败!" + e.getMessage(), e);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package xuanran.wang;
|
||||||
|
|
||||||
|
import aiyh.utils.GenerateFileUtil;
|
||||||
|
import basetest.BaseTest;
|
||||||
|
import org.junit.Test;
|
||||||
|
import weaver.xuanran.wang.eighty_five_degreec.sap.action.WorkflowToSap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/5/19 16:48
|
||||||
|
*/
|
||||||
|
public class NormalTest extends BaseTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWord(){
|
||||||
|
GenerateFileUtil.createActionDocument(WorkflowToSap.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package xuanran.wang.big_data;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.xuanran.wang.sh_bigdata.sso.mapper.OtherSystemToOAMapper;
|
||||||
import com.icbc.api.internal.apache.http.impl.cookie.S;
|
import com.icbc.api.internal.apache.http.impl.cookie.S;
|
||||||
import com.weaver.esb.server.cache.ResourceComInfo;
|
import com.weaver.esb.server.cache.ResourceComInfo;
|
||||||
import emo.macro.ob.OB;
|
import emo.macro.ob.OB;
|
||||||
|
@ -13,6 +14,7 @@ import weaver.email.EmailWorkRunnable;
|
||||||
import weaver.general.TimeUtil;
|
import weaver.general.TimeUtil;
|
||||||
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
|
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
|
||||||
import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess;
|
import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess;
|
||||||
|
import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil;
|
||||||
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys;
|
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys;
|
||||||
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain;
|
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain;
|
||||||
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment;
|
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment;
|
||||||
|
@ -32,369 +34,366 @@ import java.util.stream.Collectors;
|
||||||
* @date 2023/4/10 10:49
|
* @date 2023/4/10 10:49
|
||||||
*/
|
*/
|
||||||
public class BigDataTest extends BaseTest {
|
public class BigDataTest extends BaseTest {
|
||||||
private final OrgHrmAsyncServiceImpl orgHrmAsyncService = new OrgHrmAsyncServiceImpl();
|
// private final OrgHrmAsyncServiceImpl orgHrmAsyncService = new OrgHrmAsyncServiceImpl();
|
||||||
private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl();
|
// private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl();
|
||||||
private final List<String> departmentWhiteList;
|
// private final List<String> departmentWhiteList;
|
||||||
private final List<String> subCompanyWhiteList;
|
// private final List<String> subCompanyWhiteList;
|
||||||
private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class);
|
// private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class);
|
||||||
|
//
|
||||||
{
|
// {
|
||||||
departmentWhiteList = orgHrmAsyncMapper.selectCusDepart();
|
// departmentWhiteList = orgHrmAsyncMapper.selectCusDepart();
|
||||||
subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany();
|
// subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void testA() throws IOException {
|
// public void testA() throws IOException {
|
||||||
// List<OtherSysDepartment> rootDepList = departmentInfo
|
//// List<OtherSysDepartment> rootDepList = departmentInfo
|
||||||
// .stream()
|
//// .stream()
|
||||||
// .filter(item -> 1 == item.getHasChild())
|
//// .filter(item -> 1 == item.getHasChild())
|
||||||
// .sorted(Comparator.comparing(OtherSysDepartment::getId))
|
//// .sorted(Comparator.comparing(OtherSysDepartment::getId))
|
||||||
// .collect(Collectors.toList());
|
//// .collect(Collectors.toList());
|
||||||
// for (OtherSysDepartment department : rootDepList) {
|
//// for (OtherSysDepartment department : rootDepList) {
|
||||||
// setChildList(department, departmentInfo);
|
//// setChildList(department, departmentInfo);
|
||||||
|
//// }
|
||||||
|
//// List<OtherSysDepartment> departmentInfo = orgHrmAsyncApiService.getDepartmentInfo();
|
||||||
|
//// List<OtherSysDepartment> convert = Util.listToTree(departmentInfo,
|
||||||
|
//// OtherSysDepartment::getId, OtherSysDepartment::getParentid,
|
||||||
|
//// OtherSysDepartment::getChildList, OtherSysDepartment::setChildList,
|
||||||
|
//// parentid -> parentid == -1);
|
||||||
|
//// System.out.println("convert => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect));
|
||||||
|
//// List<OtherSysDepartment> hrmSubCompany = new ArrayList<>();
|
||||||
|
//// List<OtherSysDepartment> hrmDepartment = new ArrayList<>();
|
||||||
|
//// int maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3);
|
||||||
|
//// System.out.println(countNodes(convert.get(0)));
|
||||||
|
//// parseSubCompanyAndDepartment(convert, 0,maxLevel, hrmSubCompany, hrmDepartment);
|
||||||
|
//// parseSubCompanyAndDepartment(convert, hrmSubCompany);
|
||||||
|
//// System.out.println("hrmSubCompany => " + hrmSubCompany.size());
|
||||||
|
//// System.out.println("convertLevel => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect));
|
||||||
|
//// System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany));
|
||||||
|
//// System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment));
|
||||||
|
//// orgHrmAsyncService.asyncDepartment();
|
||||||
|
// Map res = JSONObject.parseObject("{\n" +
|
||||||
|
// "\t\t\"code\":0,\n" +
|
||||||
|
// "\t\t\"msg\":\"ok\",\n" +
|
||||||
|
// "\t\t\"data\":{\n" +
|
||||||
|
// "\t\t\t\"UserId\":\"13800000000\",\n" +
|
||||||
|
// "\t\t\t\"errcode\":0,\n" +
|
||||||
|
// "\t\t\t\"errmsg\":\"ok\",\n" +
|
||||||
|
// "\t\t\t\"id\":109,\n" +
|
||||||
|
// "\t\t\t\"userid\":\"13800000000\",\n" +
|
||||||
|
// "\t\t\t\"name\":\"祝芳\",\n" +
|
||||||
|
// "\t\t\t\"mobile\":\"13800000000\",\n" +
|
||||||
|
// "\t\t\t\"gender\":1,\n" +
|
||||||
|
// "\t\t\t\"department\":[\n" +
|
||||||
|
// "\t\t\t\t539\n" +
|
||||||
|
// "\t\t\t],\n" +
|
||||||
|
// "\t\t\t\"order\":[\n" +
|
||||||
|
// "\t\t\t\t6\n" +
|
||||||
|
// "\t\t\t]\n" +
|
||||||
|
// "\t\t}\n" +
|
||||||
|
// "\t}", Map.class);
|
||||||
|
// System.out.println(getRes(res));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String getRes(Map res){
|
||||||
|
// return (String) parseRes(res, cusSuccess);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private final CusSuccess cusSuccess = CusSuccess.builder()
|
||||||
|
// .successField("code")
|
||||||
|
// .successValue(0)
|
||||||
|
// .errorMsg("msg")
|
||||||
|
// .dataKey("data.id")
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// public <T> T parseRes(Map<String, Object> response, CusSuccess cusSuccess){
|
||||||
|
// String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\.");
|
||||||
|
// int len = split.length;
|
||||||
|
// if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){
|
||||||
|
// return (T)response;
|
||||||
// }
|
// }
|
||||||
// List<OtherSysDepartment> departmentInfo = orgHrmAsyncApiService.getDepartmentInfo();
|
// for (int i = 0; i < len - 1; i++) {
|
||||||
// List<OtherSysDepartment> convert = Util.listToTree(departmentInfo,
|
// response = (Map) response.get(split[i]);
|
||||||
// OtherSysDepartment::getId, OtherSysDepartment::getParentid,
|
// }
|
||||||
// OtherSysDepartment::getChildList, OtherSysDepartment::setChildList,
|
// return (T) response.get(split[len - 1]);
|
||||||
// parentid -> parentid == -1);
|
// }
|
||||||
// System.out.println("convert => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect));
|
//
|
||||||
// List<OtherSysDepartment> hrmSubCompany = new ArrayList<>();
|
// @Test
|
||||||
// List<OtherSysDepartment> hrmDepartment = new ArrayList<>();
|
// public void testMap(){
|
||||||
// int maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3);
|
// List<Map<String, Object>> list = orgHrmAsyncApiService.getDepartmentInfoMap();
|
||||||
// System.out.println(countNodes(convert.get(0)));
|
// // 将列表转换为以id为键的Map
|
||||||
// parseSubCompanyAndDepartment(convert, 0,maxLevel, hrmSubCompany, hrmDepartment);
|
// List<Map<String, Object>> tree = convertListToTree(list);
|
||||||
// parseSubCompanyAndDepartment(convert, hrmSubCompany);
|
// List<Map<String, Object>> department = new ArrayList<>();
|
||||||
// System.out.println("hrmSubCompany => " + hrmSubCompany.size());
|
// List<Map<String, Object>> subCompany = new ArrayList<>();
|
||||||
// System.out.println("convertLevel => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect));
|
// orgHrmAsyncService.parseSubCompanyAndDepartmentMap(tree, 0, 3, department, subCompany);
|
||||||
// System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany));
|
// System.out.println(JSONObject.toJSONString(department));
|
||||||
// System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment));
|
// System.out.println(JSONObject.toJSONString(subCompany));
|
||||||
// orgHrmAsyncService.asyncDepartment();
|
// }
|
||||||
Map res = JSONObject.parseObject("{\n" +
|
//
|
||||||
"\t\t\"code\":0,\n" +
|
// @Test
|
||||||
"\t\t\"msg\":\"ok\",\n" +
|
// public void testMapper(){
|
||||||
"\t\t\"data\":{\n" +
|
//// System.setProperty("_isDebug", "false");
|
||||||
"\t\t\t\"UserId\":\"13800000000\",\n" +
|
//// System.out.println("分部执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(0)));
|
||||||
"\t\t\t\"errcode\":0,\n" +
|
//// System.out.println("部门执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(1)));
|
||||||
"\t\t\t\"errmsg\":\"ok\",\n" +
|
//// List<OrgHrmAsyncConfigMain> orgHrmAsyncConfigMains = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2);
|
||||||
"\t\t\t\"id\":109,\n" +
|
//// System.out.println(JSONObject.toJSONString(orgHrmAsyncConfigMains));
|
||||||
"\t\t\t\"userid\":\"13800000000\",\n" +
|
// ArrayList<String> ids = new ArrayList<>();
|
||||||
"\t\t\t\"name\":\"祝芳\",\n" +
|
// for (int i = 0; i < 100; i++) {
|
||||||
"\t\t\t\"mobile\":\"13800000000\",\n" +
|
// ids.add("'" + UUID.randomUUID().toString().replace("-","") + "'");
|
||||||
"\t\t\t\"gender\":1,\n" +
|
// }
|
||||||
"\t\t\t\"department\":[\n" +
|
// String updateDelStatus = "update cus_fielddata set field0 = 1 where " +
|
||||||
"\t\t\t\t539\n" +
|
// weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"field2","not in");
|
||||||
"\t\t\t],\n" +
|
// System.out.println(updateDelStatus);
|
||||||
"\t\t\t\"order\":[\n" +
|
// }
|
||||||
"\t\t\t\t6\n" +
|
//
|
||||||
"\t\t\t]\n" +
|
// @Test
|
||||||
"\t\t}\n" +
|
// public void testAsync(){
|
||||||
"\t}", Map.class);
|
// System.out.println(TimeUtil.getCurrentTimeString());
|
||||||
System.out.println(getRes(res));
|
// OrganizationHrmSyncFromOtherSys async = new OrganizationHrmSyncFromOtherSys();
|
||||||
}
|
// async.SynTimingToOASubCompany();
|
||||||
|
// async.SynTimingToOADepartment();
|
||||||
public String getRes(Map res){
|
// HashMap synResult = async.getSynResult();
|
||||||
return (String) parseRes(res, cusSuccess);
|
// System.out.println("res => \n" + JSONObject.toJSONString(synResult));
|
||||||
}
|
// System.out.println(TimeUtil.getCurrentTimeString());
|
||||||
|
// }
|
||||||
private final CusSuccess cusSuccess = CusSuccess.builder()
|
//
|
||||||
.successField("code")
|
// @Test
|
||||||
.successValue(0)
|
// public void testExtra(){
|
||||||
.errorMsg("msg")
|
// orgHrmAsyncService.asyncHrm();
|
||||||
.dataKey("data.id")
|
// }
|
||||||
.build();
|
//
|
||||||
|
// public List<Map<String, Object>> convertListToTree(List<Map<String, Object>> list){
|
||||||
public <T> T parseRes(Map<String, Object> response, CusSuccess cusSuccess){
|
// Map<Integer, Map<String, Object>> map = new HashMap<>();
|
||||||
String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\.");
|
// for (Map<String, Object> item : list) {
|
||||||
int len = split.length;
|
// map.put((Integer) item.get("id"), item);
|
||||||
if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){
|
// }
|
||||||
return (T)response;
|
//
|
||||||
}
|
// // 构建树形结构
|
||||||
for (int i = 0; i < len - 1; i++) {
|
// List<Map<String, Object>> tree = new ArrayList<>();
|
||||||
response = (Map) response.get(split[i]);
|
// for (Map<String, Object> item : list) {
|
||||||
}
|
// int parentId = (Integer) item.get("parentid");
|
||||||
return (T) response.get(split[len - 1]);
|
// if (parentId == -1) {
|
||||||
}
|
// // 添加根节点
|
||||||
|
// tree.add(item);
|
||||||
@Test
|
// } else {
|
||||||
public void testMap(){
|
// // 添加子节点
|
||||||
List<Map<String, Object>> list = orgHrmAsyncApiService.getDepartmentInfoMap();
|
// Map<String, Object> parent = map.get(parentId);
|
||||||
// 将列表转换为以id为键的Map
|
// if (parent != null) {
|
||||||
List<Map<String, Object>> tree = convertListToTree(list);
|
// List<Map<String, Object>> childList = (List<Map<String, Object>>) parent.get("childList");
|
||||||
List<Map<String, Object>> department = new ArrayList<>();
|
// if (childList == null) {
|
||||||
List<Map<String, Object>> subCompany = new ArrayList<>();
|
// childList = new ArrayList<>();
|
||||||
orgHrmAsyncService.parseSubCompanyAndDepartmentMap(tree, 0, 3, department, subCompany);
|
// parent.put("childList", childList);
|
||||||
System.out.println(JSONObject.toJSONString(department));
|
// }
|
||||||
System.out.println(JSONObject.toJSONString(subCompany));
|
// childList.add(item);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Test
|
// }
|
||||||
public void testMapper(){
|
// return tree;
|
||||||
// System.setProperty("_isDebug", "false");
|
// }
|
||||||
// System.out.println("分部执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(0)));
|
// public int countNodes(OtherSysDepartment node) {
|
||||||
// System.out.println("部门执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(1)));
|
// int count = 1; // 当前节点也算一条数据
|
||||||
// List<OrgHrmAsyncConfigMain> orgHrmAsyncConfigMains = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2);
|
// List<OtherSysDepartment> childList = node.getChildList();
|
||||||
// System.out.println(JSONObject.toJSONString(orgHrmAsyncConfigMains));
|
// if (CollectionUtils.isNotEmpty(childList)) {
|
||||||
ArrayList<String> ids = new ArrayList<>();
|
// for (OtherSysDepartment otherSysDepartment : childList) {
|
||||||
for (int i = 0; i < 100; i++) {
|
// count += countNodes(otherSysDepartment);
|
||||||
ids.add("'" + UUID.randomUUID().toString().replace("-","") + "'");
|
// }
|
||||||
}
|
// }
|
||||||
String updateDelStatus = "update cus_fielddata set field0 = 1 where " +
|
// return count;
|
||||||
weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"field2","not in");
|
// }
|
||||||
System.out.println(updateDelStatus);
|
//
|
||||||
}
|
// public int countNodes(Map<String, Object> node) {
|
||||||
|
// int count = 1; // 当前节点也算一条数据
|
||||||
@Test
|
// List<Map<String, Object>> childList = (List<Map<String, Object>>) node.get("childList");
|
||||||
public void testAsync(){
|
// if (CollectionUtils.isNotEmpty(childList)) {
|
||||||
System.out.println(TimeUtil.getCurrentTimeString());
|
// for (Map<String, Object> map : childList) {
|
||||||
OrganizationHrmSyncFromOtherSys async = new OrganizationHrmSyncFromOtherSys();
|
// count += countNodes(map);
|
||||||
async.SynTimingToOASubCompany();
|
// }
|
||||||
async.SynTimingToOADepartment();
|
// }
|
||||||
HashMap synResult = async.getSynResult();
|
// return count;
|
||||||
System.out.println("res => \n" + JSONObject.toJSONString(synResult));
|
// }
|
||||||
System.out.println(TimeUtil.getCurrentTimeString());
|
//
|
||||||
}
|
//
|
||||||
|
// /**
|
||||||
@Test
|
// * <h1>解析部门or分部</h1>
|
||||||
public void testExtra(){
|
// * @author xuanran.wang
|
||||||
orgHrmAsyncService.asyncHrm();
|
// * @dateTime 2023/4/10 12:13
|
||||||
}
|
// * @param list 树形集合
|
||||||
|
// * @param hrmDepartment 部门
|
||||||
public List<Map<String, Object>> convertListToTree(List<Map<String, Object>> list){
|
// **/
|
||||||
Map<Integer, Map<String, Object>> map = new HashMap<>();
|
// public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, List<OtherSysDepartment> hrmDepartment){
|
||||||
for (Map<String, Object> item : list) {
|
// for (OtherSysDepartment department : list) {
|
||||||
map.put((Integer) item.get("id"), item);
|
// List<OtherSysDepartment> childList = department.getChildList();
|
||||||
}
|
// if(CollectionUtils.isNotEmpty(childList)){
|
||||||
|
// parseSubCompanyAndDepartment(childList,hrmDepartment);
|
||||||
// 构建树形结构
|
// department.setChildList(null);
|
||||||
List<Map<String, Object>> tree = new ArrayList<>();
|
// }
|
||||||
for (Map<String, Object> item : list) {
|
// hrmDepartment.add(department);
|
||||||
int parentId = (Integer) item.get("parentid");
|
// }
|
||||||
if (parentId == -1) {
|
// }
|
||||||
// 添加根节点
|
//
|
||||||
tree.add(item);
|
//
|
||||||
} else {
|
// /**
|
||||||
// 添加子节点
|
// * <h1>解析部门or分部</h1>
|
||||||
Map<String, Object> parent = map.get(parentId);
|
// * @author xuanran.wang
|
||||||
if (parent != null) {
|
// * @dateTime 2023/4/10 12:13
|
||||||
List<Map<String, Object>> childList = (List<Map<String, Object>>) parent.get("childList");
|
// * @param list 树形集合
|
||||||
if (childList == null) {
|
// * @param n 层级
|
||||||
childList = new ArrayList<>();
|
// * @param hrmSubCompany 分部
|
||||||
parent.put("childList", childList);
|
// * @param hrmDepartment 部门
|
||||||
}
|
// **/
|
||||||
childList.add(item);
|
// public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, int n, int maxLevel,List<OtherSysDepartment> hrmSubCompany, List<OtherSysDepartment> hrmDepartment){
|
||||||
}
|
// n++;
|
||||||
}
|
// for (OtherSysDepartment department : list) {
|
||||||
}
|
// department.setLevel(n);
|
||||||
return tree;
|
// List<OtherSysDepartment> childList = department.getChildList();
|
||||||
}
|
// String departmentId = department.getId() + "";
|
||||||
public int countNodes(OtherSysDepartment node) {
|
// if(CollectionUtils.isNotEmpty(childList)){
|
||||||
int count = 1; // 当前节点也算一条数据
|
// List<String> collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList());
|
||||||
List<OtherSysDepartment> childList = node.getChildList();
|
// if(departmentWhiteList.contains(departmentId)){
|
||||||
if (CollectionUtils.isNotEmpty(childList)) {
|
// departmentWhiteList.addAll(collect);
|
||||||
for (OtherSysDepartment otherSysDepartment : childList) {
|
// }else if(subCompanyWhiteList.contains(departmentId)){
|
||||||
count += countNodes(otherSysDepartment);
|
// subCompanyWhiteList.addAll(collect);
|
||||||
}
|
// }
|
||||||
}
|
// parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment);
|
||||||
return count;
|
// department.setChildList(null);
|
||||||
}
|
// }
|
||||||
|
// if(n > maxLevel || departmentWhiteList.contains(departmentId)){
|
||||||
public int countNodes(Map<String, Object> node) {
|
// hrmDepartment.add(department);
|
||||||
int count = 1; // 当前节点也算一条数据
|
// }else {
|
||||||
List<Map<String, Object>> childList = (List<Map<String, Object>>) node.get("childList");
|
// hrmSubCompany.add(department);
|
||||||
if (CollectionUtils.isNotEmpty(childList)) {
|
// }
|
||||||
for (Map<String, Object> map : childList) {
|
//
|
||||||
count += countNodes(map);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
return count;
|
// @Test
|
||||||
}
|
// public void testParseObj(){
|
||||||
|
// String json = "{\n" +
|
||||||
|
// " \"code\":0,\n" +
|
||||||
/**
|
// " \"msg\":\"ok\",\n" +
|
||||||
* <h1>解析部门or分部</h1>
|
// " \"data\":\n" +
|
||||||
* @author xuanran.wang
|
// " {\n" +
|
||||||
* @dateTime 2023/4/10 12:13
|
// " \"errcode\": 0,\n" +
|
||||||
* @param list 树形集合
|
// " \"errmsg\": \"ok\",\n" +
|
||||||
* @param hrmDepartment 部门
|
// " \"id\": \"1\",\n" +
|
||||||
**/
|
// " \"userid\": \"superAdmin\",\n" +
|
||||||
public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, List<OtherSysDepartment> hrmDepartment){
|
// " \"name\": \"超级管理员\",\n" +
|
||||||
for (OtherSysDepartment department : list) {
|
// " \"mobile\":\"12345678911\",\n" +
|
||||||
List<OtherSysDepartment> childList = department.getChildList();
|
// " \"email\":\"123@321.com\",\n" +
|
||||||
if(CollectionUtils.isNotEmpty(childList)){
|
// " \"gender\":0,\n" +
|
||||||
parseSubCompanyAndDepartment(childList,hrmDepartment);
|
// " \"position\":\"position\",\n" +
|
||||||
department.setChildList(null);
|
// " \"avatarImg\":\"avatarImg\",\n" +
|
||||||
}
|
// " \"workPhone\":\"workPhone\",\n" +
|
||||||
hrmDepartment.add(department);
|
// " \"fixedTelephone\":\"fixedTelephone\",\n" +
|
||||||
}
|
// " \"extName\":\"extName\",\n" +
|
||||||
}
|
// " \"userType\":0,\n" +
|
||||||
|
// " \"department\": [\n" +
|
||||||
|
// " 1\n" +
|
||||||
/**
|
// " ],\n" +
|
||||||
* <h1>解析部门or分部</h1>
|
// " \"order\": [\n" +
|
||||||
* @author xuanran.wang
|
// " 0\n" +
|
||||||
* @dateTime 2023/4/10 12:13
|
// " ],\n" +
|
||||||
* @param list 树形集合
|
// " \"rank\":\"rank\"\n" +
|
||||||
* @param n 层级
|
// " }\n" +
|
||||||
* @param hrmSubCompany 分部
|
// "}";
|
||||||
* @param hrmDepartment 部门
|
// Map response = JSONObject.parseObject(json, Map.class);
|
||||||
**/
|
// String obj = Util.null2DefaultStr(getObj("data.id", response),"");
|
||||||
public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, int n, int maxLevel,List<OtherSysDepartment> hrmSubCompany, List<OtherSysDepartment> hrmDepartment){
|
// System.out.println("obj => " + obj);
|
||||||
n++;
|
// }
|
||||||
for (OtherSysDepartment department : list) {
|
//
|
||||||
department.setLevel(n);
|
// public <T> T getObj(String dataKey, Map<String, Object> response){
|
||||||
List<OtherSysDepartment> childList = department.getChildList();
|
// String[] split = Util.null2DefaultStr(dataKey,"").split("\\.");
|
||||||
String departmentId = department.getId() + "";
|
// int len = split.length;
|
||||||
if(CollectionUtils.isNotEmpty(childList)){
|
// if(len == 0 || StringUtils.isBlank(dataKey)){
|
||||||
List<String> collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList());
|
// return (T)response;
|
||||||
if(departmentWhiteList.contains(departmentId)){
|
// }
|
||||||
departmentWhiteList.addAll(collect);
|
// for (int i = 0; i < len - 1; i++) {
|
||||||
}else if(subCompanyWhiteList.contains(departmentId)){
|
// response = (Map) response.get(split[i]);
|
||||||
subCompanyWhiteList.addAll(collect);
|
// }
|
||||||
}
|
// return (T) response.get(split[len - 1]);
|
||||||
parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment);
|
// }
|
||||||
department.setChildList(null);
|
//
|
||||||
}
|
// @Test
|
||||||
if(n > maxLevel || departmentWhiteList.contains(departmentId)){
|
// public void testMsg(){
|
||||||
hrmDepartment.add(department);
|
// String html = "<!DOCTYPE html>\n" +
|
||||||
}else {
|
// "<html>\n" +
|
||||||
hrmSubCompany.add(department);
|
// "<head>\n" +
|
||||||
}
|
// "\t<title>Investment Calculator</title>\n" +
|
||||||
|
// "\t<style>\n" +
|
||||||
}
|
// "\t\ttable {\n" +
|
||||||
}
|
// "\t\t\tborder-collapse: collapse;\n" +
|
||||||
|
// "\t\t\twidth: 80%;\n" +
|
||||||
@Test
|
// "\t\t\tmargin: 0 auto;\n" +
|
||||||
public void testParseObj(){
|
// "\t\t\tmargin-top: 50px;\n" +
|
||||||
String json = "{\n" +
|
// "\t\t\tmargin-bottom: 50px;\n" +
|
||||||
" \"code\":0,\n" +
|
// "\t\t}\n" +
|
||||||
" \"msg\":\"ok\",\n" +
|
// "\t\tth, td {\n" +
|
||||||
" \"data\":\n" +
|
// "\t\t\tborder: 1px solid black;\n" +
|
||||||
" {\n" +
|
// "\t\t\tpadding: 10px;\n" +
|
||||||
" \"errcode\": 0,\n" +
|
// "\t\t\ttext-align: center;\n" +
|
||||||
" \"errmsg\": \"ok\",\n" +
|
// "\t\t}\n" +
|
||||||
" \"id\": \"1\",\n" +
|
// "\t\tth {\n" +
|
||||||
" \"userid\": \"superAdmin\",\n" +
|
// "\t\t\tbackground-color: #f2f2f2;\n" +
|
||||||
" \"name\": \"超级管理员\",\n" +
|
// "\t\t}\n" +
|
||||||
" \"mobile\":\"12345678911\",\n" +
|
// "\t\t.first-row {\n" +
|
||||||
" \"email\":\"123@321.com\",\n" +
|
// "\t\t\ttext-align: center;\n" +
|
||||||
" \"gender\":0,\n" +
|
// "\t\t\tfont-size: 24px;\n" +
|
||||||
" \"position\":\"position\",\n" +
|
// "\t\t\tfont-weight: bold;\n" +
|
||||||
" \"avatarImg\":\"avatarImg\",\n" +
|
// "\t\t\theight: 50px;\n" +
|
||||||
" \"workPhone\":\"workPhone\",\n" +
|
// "\t\t\tline-height: 50px;\n" +
|
||||||
" \"fixedTelephone\":\"fixedTelephone\",\n" +
|
// "\t\t}\n" +
|
||||||
" \"extName\":\"extName\",\n" +
|
// "\t</style>\n" +
|
||||||
" \"userType\":0,\n" +
|
// "</head>\n" +
|
||||||
" \"department\": [\n" +
|
// "<body>\n" +
|
||||||
" 1\n" +
|
// "\t<table>\n" +
|
||||||
" ],\n" +
|
// "\t\t<tr class=\"first-row\">\n" +
|
||||||
" \"order\": [\n" +
|
// "\t\t\t<td colspan=\"26\">投资试算(场外基金)</td>\n" +
|
||||||
" 0\n" +
|
// "\t\t</tr>\n" +
|
||||||
" ],\n" +
|
// "\t\t<tr>\n" +
|
||||||
" \"rank\":\"rank\"\n" +
|
// "\t\t\t<td>A</td>\n" +
|
||||||
" }\n" +
|
// "\t\t\t<td>B</td>\n" +
|
||||||
"}";
|
// "\t\t\t<td>C</td>\n" +
|
||||||
Map response = JSONObject.parseObject(json, Map.class);
|
// "\t\t\t<td>D</td>\n" +
|
||||||
String obj = Util.null2DefaultStr(getObj("data.id", response),"");
|
// "\t\t\t<td>E</td>\n" +
|
||||||
System.out.println("obj => " + obj);
|
// "\t\t\t<td>F</td>\n" +
|
||||||
}
|
// "\t\t\t<td>G</td>\n" +
|
||||||
|
// "\t\t\t<td>H</td>\n" +
|
||||||
public <T> T getObj(String dataKey, Map<String, Object> response){
|
// "\t\t\t<td>I</td>\n" +
|
||||||
String[] split = Util.null2DefaultStr(dataKey,"").split("\\.");
|
// "\t\t\t<td>J</td>\n" +
|
||||||
int len = split.length;
|
// "\t\t\t<td>K</td>\n" +
|
||||||
if(len == 0 || StringUtils.isBlank(dataKey)){
|
// "\t\t\t<td>L</td>\n" +
|
||||||
return (T)response;
|
// "\t\t\t<td>M</td>\n" +
|
||||||
}
|
// "\t\t\t\n" +
|
||||||
for (int i = 0; i < len - 1; i++) {
|
// "\t\t</tr>\n" +
|
||||||
response = (Map) response.get(split[i]);
|
// "\t\t<tr>\n" +
|
||||||
}
|
// "\t\t\t<td>Cell A1</td>\n" +
|
||||||
return (T) response.get(split[len - 1]);
|
// "\t\t\t<td>Cell B1</td>\n" +
|
||||||
}
|
// "\t\t\t<td>Cell C1</td>\n" +
|
||||||
|
// "\t\t\t<td>Cell D1</td>\n" +
|
||||||
@Test
|
// "\t\t\t<td>Cell E1</td>\n" +
|
||||||
public void testMsg(){
|
// "\t\t\t<td>Cell F1</td>\n" +
|
||||||
String html = "<!DOCTYPE html>\n" +
|
// "\t\t\t<td>Cell G1</td>\n" +
|
||||||
"<html>\n" +
|
// "\t\t\t<td>Cell H1</td>\n" +
|
||||||
"<head>\n" +
|
// "\t\t\t<td>Cell I1</td>\n" +
|
||||||
"\t<title>Investment Calculator</title>\n" +
|
// "\t\t\t<td>Cell J1</td>\n" +
|
||||||
"\t<style>\n" +
|
// "\t\t\t<td>Cell K1</td>\n" +
|
||||||
"\t\ttable {\n" +
|
// "\t\t\t<td>Cell L1</td>\n" +
|
||||||
"\t\t\tborder-collapse: collapse;\n" +
|
// "\t\t\t<td>Cell M1</td>\n" +
|
||||||
"\t\t\twidth: 80%;\n" +
|
// "\t\t\n" +
|
||||||
"\t\t\tmargin: 0 auto;\n" +
|
// "\t\t</tr>\n" +
|
||||||
"\t\t\tmargin-top: 50px;\n" +
|
// " \t</table>\n" +
|
||||||
"\t\t\tmargin-bottom: 50px;\n" +
|
// " </body>\n" +
|
||||||
"\t\t}\n" +
|
// "\n";
|
||||||
"\t\tth, td {\n" +
|
// EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html);
|
||||||
"\t\t\tborder: 1px solid black;\n" +
|
//
|
||||||
"\t\t\tpadding: 10px;\n" +
|
// }
|
||||||
"\t\t\ttext-align: center;\n" +
|
private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class);
|
||||||
"\t\t}\n" +
|
|
||||||
"\t\tth {\n" +
|
|
||||||
"\t\t\tbackground-color: #f2f2f2;\n" +
|
|
||||||
"\t\t}\n" +
|
|
||||||
"\t\t.first-row {\n" +
|
|
||||||
"\t\t\ttext-align: center;\n" +
|
|
||||||
"\t\t\tfont-size: 24px;\n" +
|
|
||||||
"\t\t\tfont-weight: bold;\n" +
|
|
||||||
"\t\t\theight: 50px;\n" +
|
|
||||||
"\t\t\tline-height: 50px;\n" +
|
|
||||||
"\t\t}\n" +
|
|
||||||
"\t</style>\n" +
|
|
||||||
"</head>\n" +
|
|
||||||
"<body>\n" +
|
|
||||||
"\t<table>\n" +
|
|
||||||
"\t\t<tr class=\"first-row\">\n" +
|
|
||||||
"\t\t\t<td colspan=\"26\">投资试算(场外基金)</td>\n" +
|
|
||||||
"\t\t</tr>\n" +
|
|
||||||
"\t\t<tr>\n" +
|
|
||||||
"\t\t\t<td>A</td>\n" +
|
|
||||||
"\t\t\t<td>B</td>\n" +
|
|
||||||
"\t\t\t<td>C</td>\n" +
|
|
||||||
"\t\t\t<td>D</td>\n" +
|
|
||||||
"\t\t\t<td>E</td>\n" +
|
|
||||||
"\t\t\t<td>F</td>\n" +
|
|
||||||
"\t\t\t<td>G</td>\n" +
|
|
||||||
"\t\t\t<td>H</td>\n" +
|
|
||||||
"\t\t\t<td>I</td>\n" +
|
|
||||||
"\t\t\t<td>J</td>\n" +
|
|
||||||
"\t\t\t<td>K</td>\n" +
|
|
||||||
"\t\t\t<td>L</td>\n" +
|
|
||||||
"\t\t\t<td>M</td>\n" +
|
|
||||||
"\t\t\t\n" +
|
|
||||||
"\t\t</tr>\n" +
|
|
||||||
"\t\t<tr>\n" +
|
|
||||||
"\t\t\t<td>Cell A1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell B1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell C1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell D1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell E1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell F1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell G1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell H1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell I1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell J1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell K1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell L1</td>\n" +
|
|
||||||
"\t\t\t<td>Cell M1</td>\n" +
|
|
||||||
"\t\t\n" +
|
|
||||||
"\t\t</tr>\n" +
|
|
||||||
" \t</table>\n" +
|
|
||||||
" </body>\n" +
|
|
||||||
"\n";
|
|
||||||
EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testG(){
|
public void testG(){
|
||||||
// String sql =" select case '$t{test1}' when '03' then '场外基金' when '04' then '基金赎回' else '测试下' end";
|
String oaOutKey = "111";
|
||||||
// HashMap<String, Object> param = new HashMap<>();
|
String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}";
|
||||||
// param.put("test1","04");
|
int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey);
|
||||||
// String s = orgHrmAsyncMapper.selectCustomerSql(sql, param);
|
log.info("id => " + id);
|
||||||
// System.out.println("s => " + s);
|
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
|
||||||
map.put("tiem", new Date());
|
|
||||||
System.out.println("map => " + JSONObject.toJSONString(map));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package xuanran.wang.cssc;
|
package xuanran.wang.cssc;
|
||||||
|
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
@ -201,4 +202,9 @@ public class FileTest extends BaseTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testB(){
|
||||||
|
HttpUtils httpUtils = new HttpUtils();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
package xuanran.wang.eighty_five_degreec;
|
package xuanran.wang.eighty_five_degreec;
|
||||||
|
|
||||||
|
import aiyh.utils.annotation.PrintParamMark;
|
||||||
|
import aiyh.utils.annotation.RequiredMark;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
import aiyh.utils.tool.cn.hutool.core.lang.UUID;
|
import aiyh.utils.tool.cn.hutool.core.lang.UUID;
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
|
import com.alibaba.excel.util.CollectionUtils;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.json.XML;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import weaver.general.GCONST;
|
||||||
|
import weaver.general.Util;
|
||||||
import weaver.xuanran.wang.common.util.CusData2OA;
|
import weaver.xuanran.wang.common.util.CusData2OA;
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
|
||||||
|
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
|
||||||
|
import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl;
|
||||||
import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil;
|
import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,15 +32,116 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class SAPTest extends BaseTest {
|
public class SAPTest extends BaseTest {
|
||||||
|
|
||||||
|
private final WorkflowToSapService service = new WorkflowToSapServiceImpl();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testXml(){
|
public void testXml(){
|
||||||
ReadConfigUtil configUtil = new ReadConfigUtil();
|
|
||||||
String uniqueCode = "test1";
|
String uniqueCode = "test1";
|
||||||
String tableName = "formtable_main_161";
|
String billTable = "formtable_main_161";
|
||||||
String requestId = "419420";
|
String requestId = "419420";
|
||||||
MainRequestConfig config = configUtil.getConfigByUniqueCode(uniqueCode, tableName);
|
|
||||||
String xml = configUtil.getXml(config, requestId, tableName);
|
String response = "";
|
||||||
System.out.println("xml => \n " + xml);
|
String url = "";
|
||||||
|
String error = "";
|
||||||
|
String xml = "";
|
||||||
|
boolean success = true;
|
||||||
|
String modelId = "119";
|
||||||
|
String successField = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.TYPE";
|
||||||
|
String successVal = "N";
|
||||||
|
String messageField = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.MESSAGE";
|
||||||
|
|
||||||
|
try {
|
||||||
|
MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable);
|
||||||
|
url = config.getRequestUrl();
|
||||||
|
xml = service.convertXml(config, requestId, billTable);
|
||||||
|
// response = service.sendToSap(config.getRequestUrl(), xml);
|
||||||
|
response = "<soap-env:Envelope\n" +
|
||||||
|
" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
||||||
|
" <soap-env:Header/>\n" +
|
||||||
|
" <soap-env:Body>\n" +
|
||||||
|
" <n0:ZFI_OA_DOC_POSTINGResponse\n" +
|
||||||
|
" xmlns:n0=\"urn:sap-com:document:sap:rfc:functions\">\n" +
|
||||||
|
" <ES_OA_OUTPUT>\n" +
|
||||||
|
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
|
||||||
|
" <BELNR/>\n" +
|
||||||
|
" <BUKRS>1200</BUKRS>\n" +
|
||||||
|
" <BUDAT>2023-05-01</BUDAT>\n" +
|
||||||
|
" <BKTXT>t?·???????é??è????¨</BKTXT>\n" +
|
||||||
|
" <TYPE>E</TYPE>\n" +
|
||||||
|
" <MESSAGE> 1000 上不存在成本中心 1200180001/2023/05/01 。</MESSAGE>\n" +
|
||||||
|
" <ERDAT>2023-05-15</ERDAT>\n" +
|
||||||
|
" <ERZET>13:46:11</ERZET>\n" +
|
||||||
|
" </ES_OA_OUTPUT>\n" +
|
||||||
|
" <IT_OA_ITEMS>\n" +
|
||||||
|
" <item>\n" +
|
||||||
|
" <ZOAPZ>clbx000002</ZOAPZ>\n" +
|
||||||
|
" <ZOAXM>1</ZOAXM>\n" +
|
||||||
|
" <SGTXT>item1</SGTXT>\n" +
|
||||||
|
" <LIFNR>CN07010001</LIFNR>\n" +
|
||||||
|
" <HKONT/>\n" +
|
||||||
|
" <KOSTL/>\n" +
|
||||||
|
" <PSWBT>123.23</PSWBT>\n" +
|
||||||
|
" <PSWSL>CNY</PSWSL>\n" +
|
||||||
|
" <SHKZG>H</SHKZG>\n" +
|
||||||
|
" <BOAPZ>string..............</BOAPZ>\n" +
|
||||||
|
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
|
||||||
|
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
|
||||||
|
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
|
||||||
|
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
|
||||||
|
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
|
||||||
|
" </item>\n" +
|
||||||
|
" <item>\n" +
|
||||||
|
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
|
||||||
|
" <ZOAXM>2</ZOAXM>\n" +
|
||||||
|
" <SGTXT>item2</SGTXT>\n" +
|
||||||
|
" <LIFNR/>\n" +
|
||||||
|
" <HKONT>90010601</HKONT>\n" +
|
||||||
|
" <KOSTL>1200180001</KOSTL>\n" +
|
||||||
|
" <PSWBT>100.23</PSWBT>\n" +
|
||||||
|
" <PSWSL>CNY</PSWSL>\n" +
|
||||||
|
" <SHKZG>S</SHKZG>\n" +
|
||||||
|
" <BOAPZ>string..............</BOAPZ>\n" +
|
||||||
|
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
|
||||||
|
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
|
||||||
|
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
|
||||||
|
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
|
||||||
|
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
|
||||||
|
" </item>\n" +
|
||||||
|
" <item>\n" +
|
||||||
|
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
|
||||||
|
" <ZOAXM>3</ZOAXM>\n" +
|
||||||
|
" <SGTXT>item3</SGTXT>\n" +
|
||||||
|
" <LIFNR/>\n" +
|
||||||
|
" <HKONT>90010602</HKONT>\n" +
|
||||||
|
" <KOSTL>1200180001</KOSTL>\n" +
|
||||||
|
" <PSWBT>23.0</PSWBT>\n" +
|
||||||
|
" <PSWSL>CNY</PSWSL>\n" +
|
||||||
|
" <SHKZG>S</SHKZG>\n" +
|
||||||
|
" <BOAPZ>string..............</BOAPZ>\n" +
|
||||||
|
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
|
||||||
|
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
|
||||||
|
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
|
||||||
|
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
|
||||||
|
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
|
||||||
|
" </item>\n" +
|
||||||
|
" </IT_OA_ITEMS>\n" +
|
||||||
|
" </n0:ZFI_OA_DOC_POSTINGResponse>\n" +
|
||||||
|
" </soap-env:Body>\n" +
|
||||||
|
"</soap-env:Envelope>";
|
||||||
|
response = service.parseResponse(response, successField, successVal, messageField);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("流程数据推送SAP error : " + e.getMessage());
|
||||||
|
error = e.getMessage();
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
service.logToOA(modelId, url, requestId, xml, response, error);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("日志数据写入建模失败! " + e.getMessage());
|
||||||
|
}
|
||||||
|
if(!success){
|
||||||
|
throw new CustomerException("WorkflowToSap Action execute error : " + error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,4 +162,149 @@ public class SAPTest extends BaseTest {
|
||||||
List<String> strings = CusData2OA.batchWriteToModel(modelId, sql, list);
|
List<String> strings = CusData2OA.batchWriteToModel(modelId, sql, list);
|
||||||
System.out.println("data => " + strings);
|
System.out.println("data => " + strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testResponse() throws JSONException {
|
||||||
|
String response = "<soap-env:Envelope\n" +
|
||||||
|
" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
||||||
|
" <soap-env:Header/>\n" +
|
||||||
|
" <soap-env:Body>\n" +
|
||||||
|
" <n0:ZFI_OA_DOC_POSTINGResponse\n" +
|
||||||
|
" xmlns:n0=\"urn:sap-com:document:sap:rfc:functions\">\n" +
|
||||||
|
" <ES_OA_OUTPUT>\n" +
|
||||||
|
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
|
||||||
|
" <BELNR/>\n" +
|
||||||
|
" <BUKRS>1200</BUKRS>\n" +
|
||||||
|
" <BUDAT>2023-05-01</BUDAT>\n" +
|
||||||
|
" <BKTXT>t?·???????é??è????¨</BKTXT>\n" +
|
||||||
|
" <TYPE>E</TYPE>\n" +
|
||||||
|
" <MESSAGE> 1000 上不存在成本中心 1200180001/2023/05/01 。</MESSAGE>\n" +
|
||||||
|
" <ERDAT>2023-05-15</ERDAT>\n" +
|
||||||
|
" <ERZET>13:46:11</ERZET>\n" +
|
||||||
|
" </ES_OA_OUTPUT>\n" +
|
||||||
|
" <IT_OA_ITEMS>\n" +
|
||||||
|
" <item>\n" +
|
||||||
|
" <ZOAPZ>clbx000002</ZOAPZ>\n" +
|
||||||
|
" <ZOAXM>1</ZOAXM>\n" +
|
||||||
|
" <SGTXT>item1</SGTXT>\n" +
|
||||||
|
" <LIFNR>CN07010001</LIFNR>\n" +
|
||||||
|
" <HKONT/>\n" +
|
||||||
|
" <KOSTL/>\n" +
|
||||||
|
" <PSWBT>123.23</PSWBT>\n" +
|
||||||
|
" <PSWSL>CNY</PSWSL>\n" +
|
||||||
|
" <SHKZG>H</SHKZG>\n" +
|
||||||
|
" <BOAPZ>string..............</BOAPZ>\n" +
|
||||||
|
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
|
||||||
|
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
|
||||||
|
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
|
||||||
|
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
|
||||||
|
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
|
||||||
|
" </item>\n" +
|
||||||
|
" <item>\n" +
|
||||||
|
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
|
||||||
|
" <ZOAXM>2</ZOAXM>\n" +
|
||||||
|
" <SGTXT>item2</SGTXT>\n" +
|
||||||
|
" <LIFNR/>\n" +
|
||||||
|
" <HKONT>90010601</HKONT>\n" +
|
||||||
|
" <KOSTL>1200180001</KOSTL>\n" +
|
||||||
|
" <PSWBT>100.23</PSWBT>\n" +
|
||||||
|
" <PSWSL>CNY</PSWSL>\n" +
|
||||||
|
" <SHKZG>S</SHKZG>\n" +
|
||||||
|
" <BOAPZ>string..............</BOAPZ>\n" +
|
||||||
|
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
|
||||||
|
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
|
||||||
|
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
|
||||||
|
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
|
||||||
|
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
|
||||||
|
" </item>\n" +
|
||||||
|
" <item>\n" +
|
||||||
|
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
|
||||||
|
" <ZOAXM>3</ZOAXM>\n" +
|
||||||
|
" <SGTXT>item3</SGTXT>\n" +
|
||||||
|
" <LIFNR/>\n" +
|
||||||
|
" <HKONT>90010602</HKONT>\n" +
|
||||||
|
" <KOSTL>1200180001</KOSTL>\n" +
|
||||||
|
" <PSWBT>23.0</PSWBT>\n" +
|
||||||
|
" <PSWSL>CNY</PSWSL>\n" +
|
||||||
|
" <SHKZG>S</SHKZG>\n" +
|
||||||
|
" <BOAPZ>string..............</BOAPZ>\n" +
|
||||||
|
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
|
||||||
|
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
|
||||||
|
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
|
||||||
|
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
|
||||||
|
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
|
||||||
|
" </item>\n" +
|
||||||
|
" </IT_OA_ITEMS>\n" +
|
||||||
|
" </n0:ZFI_OA_DOC_POSTINGResponse>\n" +
|
||||||
|
" </soap-env:Body>\n" +
|
||||||
|
"</soap-env:Envelope>";
|
||||||
|
JSONObject xmlResponseObj = XML.toJSONObject(response);
|
||||||
|
log.info("接口响应 : \n" + xmlResponseObj);
|
||||||
|
Map<String, Object> responseMap = com.alibaba.fastjson.JSONObject.parseObject(xmlResponseObj.toString(), Map.class);
|
||||||
|
System.out.println("responseMap : " + com.alibaba.fastjson.JSONObject.toJSONString(responseMap));
|
||||||
|
// code = Util.null2String(parseMap(responseMap, RESPONSE_CODE));
|
||||||
|
// if(!successCode.equals(code)){
|
||||||
|
// throw new RuntimeException("推送erp接口失败! " + Util.null2String(readConfigUtil.parseMap(responseMap, RESPONSE_DESCRIPTION)));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>解析响应数据</h1>
|
||||||
|
* @param responseMap 响应map
|
||||||
|
* @param responseField 需要从map中获取指定字段的标识 Response.Execution
|
||||||
|
* @return 响应数据
|
||||||
|
*/
|
||||||
|
public String parseMap(Map<String, Object> responseMap, String responseField){
|
||||||
|
String[] strArr = responseField.split("\\.");
|
||||||
|
int i = 0;
|
||||||
|
while (i < strArr.length - 1){
|
||||||
|
Object o = responseMap.get(strArr[i]);
|
||||||
|
if(o instanceof Map){
|
||||||
|
responseMap = (Map<String, Object>) o;
|
||||||
|
}else if(o instanceof List){
|
||||||
|
List<Map<String, Object>> list = (List<Map<String, Object>>) o;
|
||||||
|
if(CollectionUtils.isEmpty(list)){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
responseMap = list.get(0);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return Util.null2String(responseMap.get(strArr[strArr.length - 1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testB(){
|
||||||
|
String path = "sap.sap.xml";
|
||||||
|
System.out.println(parseConfigPath(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>解析请求xml模板位置</h1>
|
||||||
|
* wxr.memsic.test.xml = /wxr/memsic/test.xml
|
||||||
|
* @param configFilePath 模板文件路径
|
||||||
|
* @return 解析后的文件路径
|
||||||
|
*/
|
||||||
|
public String parseConfigPath(String configFilePath){
|
||||||
|
StringBuilder filePath = new StringBuilder(GCONST.getSysFilePath());
|
||||||
|
int beginIndex = configFilePath.indexOf(".");
|
||||||
|
int endIndex = configFilePath.lastIndexOf(".");
|
||||||
|
if(beginIndex == endIndex){
|
||||||
|
filePath.append(configFilePath);
|
||||||
|
}else {
|
||||||
|
String[] pathArr = configFilePath.split("\\.");
|
||||||
|
for (int i = 0; i < pathArr.length - 2; i++) {
|
||||||
|
if(i != 0){
|
||||||
|
filePath.append(File.separator);
|
||||||
|
}
|
||||||
|
filePath.append(pathArr[i]);
|
||||||
|
}
|
||||||
|
filePath.append(File.separator)
|
||||||
|
.append(pathArr[pathArr.length - 2])
|
||||||
|
.append(".")
|
||||||
|
.append(pathArr[pathArr.length - 1]);
|
||||||
|
}
|
||||||
|
return filePath.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package xuanran.wang.http_test.annotations;
|
||||||
|
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/5/25 14:42
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
@Documented
|
||||||
|
public @interface CusJsonMappingConfig {
|
||||||
|
String configCode() default "";
|
||||||
|
String tableName() default "";
|
||||||
|
|
||||||
|
}
|
|
@ -15,5 +15,5 @@ import java.lang.annotation.*;
|
||||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||||
@Documented
|
@Documented
|
||||||
public @interface CusReqAfterHandleRegister {
|
public @interface CusReqAfterHandleRegister {
|
||||||
Class<?> afterHandle();
|
Class<?>[] afterHandle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,6 @@ public @interface CusRequestPost {
|
||||||
|
|
||||||
@AliasFor(annotation = CusRequestType.class, attribute = "requestType")
|
@AliasFor(annotation = CusRequestType.class, attribute = "requestType")
|
||||||
int requestType() default CusRequestClientConstant.POST;
|
int requestType() default CusRequestClientConstant.POST;
|
||||||
|
|
||||||
|
String configCode() default "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,9 @@ import lombok.Setter;
|
||||||
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
|
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
|
||||||
import xuanran.wang.http_test.handle.CusRequestAfterHandle;
|
import xuanran.wang.http_test.handle.CusRequestAfterHandle;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@ -31,8 +33,8 @@ public class CusRequestEntity{
|
||||||
private boolean async = false;
|
private boolean async = false;
|
||||||
private String host = "";
|
private String host = "";
|
||||||
private int port;
|
private int port;
|
||||||
private Class<?> returnType;
|
private Type returnType;
|
||||||
private CusRequestAfterHandle cusRequestAfter;
|
private List<CusRequestAfterHandle> cusRequestAfter;
|
||||||
private CusResponseSuccessHandle responseSuccessHandle;
|
private CusResponseSuccessHandle responseSuccessHandle;
|
||||||
private Map<String, Object> responseMap;
|
private Map<String, Object> responseMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import aiyh.utils.tool.cn.hutool.core.annotation.AnnotationUtil;
|
||||||
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.CollectionUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister;
|
import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister;
|
||||||
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
|
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
|
||||||
|
@ -85,16 +86,17 @@ public class CusHandleCenter{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object requestAfterHandle(Method method, CusRequestEntity cusRequest, ResponeVo responseVo){
|
public Object requestAfterHandle(Method method, CusRequestEntity cusRequest, ResponeVo responseVo){
|
||||||
if(cusRequest.getCusRequestAfter() == null){
|
CusReqAfterHandleRegister cusReqAfterHandleRegister = method.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
|
||||||
CusReqAfterHandleRegister cusReqAfterHandleRegister = method.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
|
if(cusReqAfterHandleRegister != null){
|
||||||
if(cusReqAfterHandleRegister != null){
|
RequestUtil.setCusRequestAfter(cusReqAfterHandleRegister, cusRequest);
|
||||||
RequestUtil.setCusRequestAfter(cusReqAfterHandleRegister, cusRequest);
|
}else {
|
||||||
}
|
List<CusRequestAfterHandle> tempList = new ArrayList<>();
|
||||||
|
tempList.add(new CusDefaultRequestAfterHandle());
|
||||||
|
cusRequest.setCusRequestAfter(tempList);
|
||||||
}
|
}
|
||||||
// Type genericReturnType = method.getGenericReturnType();
|
cusRequest.setReturnType(method.getGenericReturnType());
|
||||||
cusRequest.setReturnType(method.getReturnType());
|
|
||||||
CusResponseSuccessHandle cusResponseSuccessHandle = method.getDeclaredAnnotation(CusResponseSuccessHandle.class);
|
CusResponseSuccessHandle cusResponseSuccessHandle = method.getDeclaredAnnotation(CusResponseSuccessHandle.class);
|
||||||
if(cusResponseSuccessHandle != null && cusRequest.getResponseSuccessHandle() == null){
|
if(cusResponseSuccessHandle != null && cusRequest.getResponseSuccessHandle() != null){
|
||||||
cusRequest.setResponseSuccessHandle(cusResponseSuccessHandle);
|
cusRequest.setResponseSuccessHandle(cusResponseSuccessHandle);
|
||||||
}
|
}
|
||||||
return requestAfterHandle(cusRequest, responseVo);
|
return requestAfterHandle(cusRequest, responseVo);
|
||||||
|
@ -113,11 +115,19 @@ public class CusHandleCenter{
|
||||||
responseVo.getEntityString()));
|
responseVo.getEntityString()));
|
||||||
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); //
|
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); //
|
||||||
}
|
}
|
||||||
CusRequestAfterHandle handle = cusRequest.getCusRequestAfter() == null ? new CusDefaultRequestAfterHandle() : cusRequest.getCusRequestAfter();
|
cusRequest.setResponseMap(responseVo.getResponseMap());
|
||||||
cusRequest.setCusRequestAfter(handle);
|
List<CusRequestAfterHandle> cusRequestAfter = cusRequest.getCusRequestAfter();
|
||||||
|
Object res = null;
|
||||||
log.info(Util.logStr("cusRequest: {}", JSONObject.toJSONString(cusRequest)));
|
log.info(Util.logStr("cusRequest: {}", JSONObject.toJSONString(cusRequest)));
|
||||||
Object res = handle.parseResponse(cusRequest, responseVo);
|
for (CusRequestAfterHandle handle : cusRequestAfter) {
|
||||||
handle.service(cusRequest, responseVo);
|
if(RequestUtil.isMethodOverridden(handle.getClass(), CusDefaultRequestAfterHandle.class, "parseResponse")){
|
||||||
|
res = handle.parseResponse(cusRequest, responseVo);
|
||||||
|
}else {
|
||||||
|
CusDefaultRequestAfterHandle defaultRequestAfterHandle = new CusDefaultRequestAfterHandle();
|
||||||
|
res = defaultRequestAfterHandle.parseResponse(cusRequest, responseVo);
|
||||||
|
}
|
||||||
|
handle.service(cusRequest, responseVo);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,10 @@ public abstract class CusRequestHandle {
|
||||||
realRequestUrl.append(url);
|
realRequestUrl.append(url);
|
||||||
}else {
|
}else {
|
||||||
realRequestUrl.append(host);
|
realRequestUrl.append(host);
|
||||||
if(!host.endsWith(":")){
|
if(port > 0 && !host.endsWith(":")){
|
||||||
realRequestUrl.append(":");
|
realRequestUrl.append(":").append(port);
|
||||||
}
|
}
|
||||||
realRequestUrl.append(port);
|
if(!host.endsWith("/") && !url.startsWith("/")){
|
||||||
if(!url.endsWith("/")){
|
|
||||||
realRequestUrl.append("/");
|
realRequestUrl.append("/");
|
||||||
}
|
}
|
||||||
realRequestUrl.append(url);
|
realRequestUrl.append(url);
|
||||||
|
|
|
@ -72,10 +72,14 @@ public class RequestHeaderHandle implements CusRequestBeforeHandle {
|
||||||
Parameter parameter = parameters[i];
|
Parameter parameter = parameters[i];
|
||||||
CusRequestHeader requestHeader = parameter.getAnnotation(CusRequestHeader.class);
|
CusRequestHeader requestHeader = parameter.getAnnotation(CusRequestHeader.class);
|
||||||
if(requestHeader != null){
|
if(requestHeader != null){
|
||||||
String val = Util.null2DefaultStr(args[i], "").trim();
|
if(Map.class.isAssignableFrom(parameter.getType())){
|
||||||
String key = requestHeader.value().trim();
|
headers.putAll((Map<? extends String, ? extends String>) args[i]);
|
||||||
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){
|
}else {
|
||||||
headers.put(key, val);
|
String val = Util.null2DefaultStr(args[i], "").trim();
|
||||||
|
String key = requestHeader.value().trim();
|
||||||
|
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){
|
||||||
|
headers.put(key, val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import xuanran.wang.http_test.constant.CusRequestClientConstant;
|
||||||
import xuanran.wang.http_test.entity.CusRequestEntity;
|
import xuanran.wang.http_test.entity.CusRequestEntity;
|
||||||
import xuanran.wang.http_test.handle.CusRequestAfterHandle;
|
import xuanran.wang.http_test.handle.CusRequestAfterHandle;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,12 +23,11 @@ public class CusDefaultRequestAfterHandle implements CusRequestAfterHandle {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object parseResponse(CusRequestEntity cusRequest, ResponeVo responseVo) {
|
public Object parseResponse(CusRequestEntity cusRequest, ResponeVo responseVo) {
|
||||||
Class<?> returnType = cusRequest.getReturnType();
|
Type returnType = cusRequest.getReturnType();
|
||||||
if(ResponeVo.class.isAssignableFrom(returnType)) {
|
if(ResponeVo.class.isAssignableFrom(returnType.getClass())) {
|
||||||
return responseVo;
|
return responseVo;
|
||||||
}
|
}
|
||||||
String json = responseVo.getEntityString();
|
String json = responseVo.getEntityString();
|
||||||
cusRequest.setResponseMap(responseVo.getResponseMap());
|
|
||||||
CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle();
|
CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle();
|
||||||
if(responseSuccessHandle != null){
|
if(responseSuccessHandle != null){
|
||||||
String successCondition = responseSuccessHandle.successCondition();
|
String successCondition = responseSuccessHandle.successCondition();
|
||||||
|
|
|
@ -8,6 +8,8 @@ import xuanran.wang.http_test.entity.CusRequestEntity;
|
||||||
import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
|
import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>方法路径拼接处理</h1>
|
* <h1>方法路径拼接处理</h1>
|
||||||
|
@ -23,7 +25,6 @@ public class CusUrlHandle implements CusRequestBeforeHandle {
|
||||||
throw new CustomerException("method not found CusRequestUrl!");
|
throw new CustomerException("method not found CusRequestUrl!");
|
||||||
}
|
}
|
||||||
cusRequest.setUrl(requestUrl.url());
|
cusRequest.setUrl(requestUrl.url());
|
||||||
Class<?> returnType = method.getReturnType();
|
cusRequest.setReturnType(method.getGenericReturnType());
|
||||||
cusRequest.setReturnType(returnType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,12 +31,13 @@ public class RequestUtil implements InvocationHandler {
|
||||||
private CusRequestAddress cusRequestAddress = null;
|
private CusRequestAddress cusRequestAddress = null;
|
||||||
private final Logger log = Util.getLogger();
|
private final Logger log = Util.getLogger();
|
||||||
private final CusHandleCenter handleCenter = new CusHandleCenter();
|
private final CusHandleCenter handleCenter = new CusHandleCenter();
|
||||||
private final CusRequestEntity cusRequest = new CusRequestEntity();
|
private CusRequestEntity cusRequest;
|
||||||
public <T> T getRequestClient(Class<?> clazz){
|
public <T> T getRequestClient(Class<?> clazz){
|
||||||
Annotation annotation = clazz.getDeclaredAnnotation(CusRequestClient.class);
|
Annotation annotation = clazz.getDeclaredAnnotation(CusRequestClient.class);
|
||||||
if(annotation == null){
|
if(annotation == null){
|
||||||
throw new CustomerException(Util.logStr(clazz.getName() + " not found CusRequestClient annotation!"));
|
throw new CustomerException(Util.logStr(clazz.getName() + " not found CusRequestClient annotation!"));
|
||||||
}
|
}
|
||||||
|
cusRequest = new CusRequestEntity();
|
||||||
// 请求后处理
|
// 请求后处理
|
||||||
CusReqAfterHandleRegister cusReqAfterHandleRegister = clazz.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
|
CusReqAfterHandleRegister cusReqAfterHandleRegister = clazz.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
|
||||||
if(cusReqAfterHandleRegister != null){
|
if(cusReqAfterHandleRegister != null){
|
||||||
|
@ -62,7 +65,6 @@ public class RequestUtil implements InvocationHandler {
|
||||||
cusRequest.setPort(port);
|
cusRequest.setPort(port);
|
||||||
}
|
}
|
||||||
handleCenter.requestBeforeHandle(cusRequest, method, args);
|
handleCenter.requestBeforeHandle(cusRequest, method, args);
|
||||||
log.info("requestHandle : \n" + JSONObject.toJSONString(cusRequest));
|
|
||||||
ResponeVo responeVo = handleCenter.requestHandle(cusRequest, method);
|
ResponeVo responeVo = handleCenter.requestHandle(cusRequest, method);
|
||||||
return handleCenter.requestAfterHandle(method, cusRequest, responeVo);
|
return handleCenter.requestAfterHandle(method, cusRequest, responeVo);
|
||||||
}
|
}
|
||||||
|
@ -70,16 +72,33 @@ public class RequestUtil implements InvocationHandler {
|
||||||
public static void setCusRequestAfter(CusReqAfterHandleRegister cusReqAfterHandleRegister,
|
public static void setCusRequestAfter(CusReqAfterHandleRegister cusReqAfterHandleRegister,
|
||||||
CusRequestEntity cusRequest){
|
CusRequestEntity cusRequest){
|
||||||
if(cusReqAfterHandleRegister != null){
|
if(cusReqAfterHandleRegister != null){
|
||||||
Class<?> clazz = cusReqAfterHandleRegister.afterHandle();
|
Class<?>[] clazz = cusReqAfterHandleRegister.afterHandle();
|
||||||
if (CusRequestAfterHandle.class.isAssignableFrom(clazz)) {
|
List<CusRequestAfterHandle> requestAfter = cusRequest.getCusRequestAfter();
|
||||||
try {
|
if(requestAfter == null){
|
||||||
Object cusRequestAfter = clazz.newInstance();
|
requestAfter = new ArrayList<>();
|
||||||
cusRequest.setCusRequestAfter((CusRequestAfterHandle) cusRequestAfter);
|
}
|
||||||
}catch (Exception e){
|
cusRequest.setCusRequestAfter(requestAfter);
|
||||||
throw new CustomerException(Util.logStr("class : {}, newInstance error!", e.getMessage()));
|
for (Class<?> aClass : clazz) {
|
||||||
|
if (CusRequestAfterHandle.class.isAssignableFrom(aClass)) {
|
||||||
|
try {
|
||||||
|
CusRequestAfterHandle cusRequestAfter = (CusRequestAfterHandle) aClass.newInstance();
|
||||||
|
requestAfter.add(cusRequestAfter);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException(Util.logStr("class : {}, newInstance error!", e.getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMethodOverridden(Class<?> subclass, Class<?> superclass, String methodName) {
|
||||||
|
try {
|
||||||
|
Method method = subclass.getDeclaredMethod(methodName);
|
||||||
|
Method superMethod = superclass.getDeclaredMethod(methodName);
|
||||||
|
return !method.equals(superMethod);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package xuanran.wang.http_test.service;
|
||||||
|
|
||||||
|
import xuanran.wang.http_test.annotations.CusRequestClient;
|
||||||
|
import xuanran.wang.http_test.annotations.header.CusRequestHeader;
|
||||||
|
import xuanran.wang.http_test.annotations.request_type.CusRequestPost;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1></h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/5/24 14:53
|
||||||
|
*/
|
||||||
|
@CusRequestClient(host = "https://ecology.yeyaguitu.cn")
|
||||||
|
public interface EcTestService {
|
||||||
|
|
||||||
|
@CusRequestPost(url = "/api/ec/dev/auth/regist")
|
||||||
|
@CusRequestHeader(cusHeaders = {"appid:JYZ", "loginid:sysadmin","Content-type:"+ MediaType.APPLICATION_JSON})
|
||||||
|
Map<String, Object> register();
|
||||||
|
|
||||||
|
@CusRequestPost(url = "/api/ec/dev/auth/regist")
|
||||||
|
@CusRequestHeader(cusHeaders = {"Content-type:"+ MediaType.APPLICATION_JSON})
|
||||||
|
Map<String, Object> register(@CusRequestHeader("appid") String appId,
|
||||||
|
@CusRequestHeader Map<String, String> headers);
|
||||||
|
}
|
|
@ -2,12 +2,15 @@ package xuanran.wang.http_test.service;
|
||||||
|
|
||||||
import xuanran.wang.http_test.annotations.*;
|
import xuanran.wang.http_test.annotations.*;
|
||||||
import xuanran.wang.http_test.annotations.body.CusRequestBody;
|
import xuanran.wang.http_test.annotations.body.CusRequestBody;
|
||||||
|
import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister;
|
||||||
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
|
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
|
||||||
import xuanran.wang.http_test.annotations.header.CusRequestHeader;
|
import xuanran.wang.http_test.annotations.header.CusRequestHeader;
|
||||||
import xuanran.wang.http_test.annotations.request_path.CusPathQuery;
|
import xuanran.wang.http_test.annotations.request_path.CusPathQuery;
|
||||||
import xuanran.wang.http_test.annotations.request_type.CusRequestGet;
|
import xuanran.wang.http_test.annotations.request_type.CusRequestGet;
|
||||||
import xuanran.wang.http_test.annotations.request_type.CusRequestPost;
|
import xuanran.wang.http_test.annotations.request_type.CusRequestPost;
|
||||||
import xuanran.wang.http_test.constant.CusRequestClientConstant;
|
import xuanran.wang.http_test.constant.CusRequestClientConstant;
|
||||||
|
import xuanran.wang.http_test.test.Student;
|
||||||
|
import xuanran.wang.http_test.test.TestRequestAfterHandle;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -19,7 +22,6 @@ import java.util.Map;
|
||||||
* @date 2023/3/10 12:39
|
* @date 2023/3/10 12:39
|
||||||
*/
|
*/
|
||||||
@CusRequestClient(host = "http://114.115.168.220", port = 8191)
|
@CusRequestClient(host = "http://114.115.168.220", port = 8191)
|
||||||
//@CusReqAfterHandleRegister(afterHandle = TestRequestAfterHandle.class)
|
|
||||||
public interface TestService {
|
public interface TestService {
|
||||||
|
|
||||||
@CusRequestGet(url = "educate-plat/api/v1/class/getClassList")
|
@CusRequestGet(url = "educate-plat/api/v1/class/getClassList")
|
||||||
|
@ -30,8 +32,9 @@ public interface TestService {
|
||||||
errorMsg = "msg",
|
errorMsg = "msg",
|
||||||
data = "data"
|
data = "data"
|
||||||
)
|
)
|
||||||
Map<String, Object> getStu(Map<String, Object> path,
|
@CusReqAfterHandleRegister(afterHandle = {TestRequestAfterHandle.class})
|
||||||
@CusRequestBody Map<String, Object> body,
|
List<Student> getStu(Map<String, Object> path,
|
||||||
@CusRequestHeader("hsjhdsad") String test,
|
@CusRequestBody Map<String, Object> body,
|
||||||
@CusPathQuery("test") String test1);
|
@CusRequestHeader("hsjhdsad") String test,
|
||||||
|
@CusPathQuery("test") String test1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package xuanran.wang.http_test.test;
|
||||||
|
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.api.doc.migrate.util.FtpUtil;
|
import com.api.doc.migrate.util.FtpUtil;
|
||||||
import com.jcraft.jsch.ChannelSftp;
|
import com.jcraft.jsch.ChannelSftp;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -9,6 +10,7 @@ import weaver.backup.utils.ZipUtil;
|
||||||
import xuanran.wang.http_test.entity.CusHandleEntity;
|
import xuanran.wang.http_test.entity.CusHandleEntity;
|
||||||
import xuanran.wang.http_test.handle.util.HandleUtil;
|
import xuanran.wang.http_test.handle.util.HandleUtil;
|
||||||
import xuanran.wang.http_test.proxy.CusUtil;
|
import xuanran.wang.http_test.proxy.CusUtil;
|
||||||
|
import xuanran.wang.http_test.service.EcTestService;
|
||||||
import xuanran.wang.http_test.service.TestService;
|
import xuanran.wang.http_test.service.TestService;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -23,6 +25,7 @@ import java.util.stream.Collectors;
|
||||||
public class RequestTest extends BaseTest {
|
public class RequestTest extends BaseTest {
|
||||||
private TestService requestClient = CusUtil.getRequestClient(TestService.class);
|
private TestService requestClient = CusUtil.getRequestClient(TestService.class);
|
||||||
|
|
||||||
|
private EcTestService ecTestService = CusUtil.getRequestClient(EcTestService.class);
|
||||||
@Test
|
@Test
|
||||||
public void test(){
|
public void test(){
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
@ -36,9 +39,11 @@ public class RequestTest extends BaseTest {
|
||||||
|
|
||||||
path.put("e","5");
|
path.put("e","5");
|
||||||
path.put("f","6");
|
path.put("f","6");
|
||||||
Map<String, Object> stu = requestClient.getStu(map, body, "a", "test1111");
|
// List<Student> stu = requestClient.getStu(map, body, "a", "test1111");
|
||||||
log.info("stu : \n" + JSONObject.toJSONString(stu));
|
List<Student> stu = requestClient.getStu(map, body, "a", "test1111");
|
||||||
|
for (Student student : stu) {
|
||||||
|
System.out.println("stu => " + student);
|
||||||
|
}
|
||||||
// String json = "{\"xuanran.wang.http_test.requestBeforeHandle.path_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.CusPathParseHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"},{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.TestHandle\",\"order\":99,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"}],\"xuanran.wang.http_test.requestBeforeHandle.header_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle.RequestHeaderHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle\"}]}";
|
// String json = "{\"xuanran.wang.http_test.requestBeforeHandle.path_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.CusPathParseHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"},{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.TestHandle\",\"order\":99,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"}],\"xuanran.wang.http_test.requestBeforeHandle.header_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle.RequestHeaderHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle\"}]}";
|
||||||
// System.out.println(JSONObject.parseObject(JSONObject.toJSONString(json), Map.class));
|
// System.out.println(JSONObject.parseObject(JSONObject.toJSONString(json), Map.class));
|
||||||
// String stu1 = requestClient.getStu(body);
|
// String stu1 = requestClient.getStu(body);
|
||||||
|
@ -61,4 +66,16 @@ public class RequestTest extends BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testB(){
|
||||||
|
Map<String, Object> register = ecTestService.register();
|
||||||
|
System.out.printf("register : " + JSONObject.toJSONString(register));
|
||||||
|
|
||||||
|
HashMap<String, String> header = new HashMap<>();
|
||||||
|
header.put("loginid","123");
|
||||||
|
header.put("dadsada","sasas");
|
||||||
|
Map<String, Object> register1 = ecTestService.register("JYZ1", header);
|
||||||
|
System.out.printf("register1 : " + JSONObject.toJSONString(register1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue