提交报错文件依赖

dev
wangxuanran 2023-07-03 12:57:57 +08:00
parent cdc579284c
commit 7b3bc4bcf0
35 changed files with 3140 additions and 0 deletions

View File

@ -0,0 +1,108 @@
package com.api.customization.ey.jiahx.web;
import com.alibaba.fastjson.JSONObject;
import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl;
import com.weaver.general.TimeUtil;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.Util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.List;
/**
* @Description
* @Author
* @Date 2023/5/22
* @Other
* @Version
*/
@Path("/pushData")
public class ButtonTriggeringGenerateData {
private static final BaseBean baseBean = new BaseBean();
private static weaver.formmode.setup.ModeRightInfo ModeRightInfo = new ModeRightInfo();//模块信息
private static String currentdate = TimeUtil.getCurrentDateString();//当前日期
private static String currenttime = TimeUtil.getOnlyCurrentTimeString();//当前时间
private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl();
@GET
@Path("/doPushData")
@Produces({MediaType.TEXT_PLAIN})
public JSONObject doPushData(@Context HttpServletRequest request, @Context HttpServletResponse response){
baseBean.writeLog("点击按钮获得进行流程主表数据传递到明细表开始>>>>>>>>");
RecordSet rs = new RecordSet();
String sql = "select m.invoiceNo invoiceNo,d.mainid mainid,d.totalAmount totalAmount,m.yjthzje yjthzje,m.customerCode customerCode" +
",m.customerName customerName,m.groupinvoiceno groupinvoiceno,m.finishedTime finishedTime,m.orifinishedTime orifinishedTime," +
"m.hzjtyqz hzjtyqz,m.arState arState,m.yskje yskje,m.qskje qskje,m.wskje wskje,m.kpzt kpzt,m.sckprq sckprq,m.ykpje ykpje,m.wkpje wkpje from uf_zdjmbd_dt2 d left join uf_zdjmbd m on m.id = d.mainid ";
baseBean.writeLog("查询明细表2的数据sql为=====" + sql);
rs.executeQuery(sql);
JSONObject jsonObject = new JSONObject();
List<Boolean> list = new ArrayList<>();
boolean flag = false;
while (rs.next()) {
String invoiceNo = Util.null2String(rs.getString("invoiceNo"));
if (!invoiceNo.equals("")) {
String mainid = Util.null2String(rs.getString("mainid"));//id
String zdje = Util.null2String(rs.getString("totalAmount"));//总金额
String jyjtje = Util.null2String(rs.getString("yjthzje"));//计划计提金额
String customerCode = Util.null2String(rs.getString("customerCode"));//客户编码
String customerName = Util.null2String(rs.getString("customerName"));//客户名称
String group_invoice_no = Util.null2String(rs.getString("groupinvoiceno"));//组账单ID
String finishedTime = Util.null2String(rs.getString("finishedTime"));//账单开具日期
String orifinishedTime = Util.null2String(rs.getString("orifinishedTime"));//原账单开具日期
String sqjtyqrq = Util.null2String(rs.getString("hzjtyqz"));//坏账计提延期至
String skzt = Util.null2String(rs.getString("arState"));//实收状态
String yskje = Util.null2String(rs.getString("yskje"));//收款金额
String qskje = Util.null2String(rs.getString("qskje"));//其他收款金额
String wskje = Util.null2String(rs.getString("wskje"));//未收款金额
String kpzt = Util.null2String(rs.getString("kpzt"));//开票状态
String sckprq = Util.null2String(rs.getString("sckprq"));//首次开票日期
String ykpje = Util.null2String(rs.getString("ykpje"));//已开票金额
String wkpje = Util.null2String(rs.getString("wkpje"));//客户编码
String fbmxzt = "0";//客户编码
String sjjtje = wskje;//实际计提金额
RecordSet recordSet = new RecordSet();
String insertSql = "insert into uf_zdjmbd_dt4 (mainid,group_invoice_no,invoiceNo,finishedTime," +
"orifinishedTime,sqjtyqrq,zdje,skzt,yskje,qskje,wskje,kpzt,sckprq,ykpje,wkpje,jyjtje,sjjtje,customerCode,customerName,fbmxzt) values (?,?,?,?,?,?," +
"?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
baseBean.writeLog("插入的明细表的sql为" + insertSql);
if (!"".equals(skzt)) {
baseBean.writeLog("我进入判断了>>>>>");
boolean b = recordSet.executeUpdate(insertSql, mainid, group_invoice_no, invoiceNo, finishedTime, orifinishedTime, sqjtyqrq, zdje, skzt, yskje, qskje, wskje, kpzt, sckprq, ykpje, wkpje, jyjtje, sjjtje, customerCode, customerName, fbmxzt);
list.add(b);
}
/**
*
* @author xuanran.wang
* @date 2023-06-27
*/
service.asyncDataByClassName(this.getClass().getSimpleName(), mainid);
}
}
baseBean.writeLog("list===" + list);
if(!list.isEmpty()){
if (list.contains(false)) {
baseBean.writeLog("aaaaaaaaaaaaa");
jsonObject.put("result", flag);
}else {
flag = true;
jsonObject.put("result", flag);
}
}else {
jsonObject.put("result", flag);
}
return jsonObject;
}
}

View File

@ -0,0 +1,58 @@
package com.api.ebu7dev1.common.getlog.enums;
import weaver.xiao.commons.config.enumtype.DataSourceEnum;
import java.io.File;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/1 16:24
*/
public enum LogTypeEnum {
THREAD(1, "0", "log" + File.separator + "thread","thread"),
ECOLOGY(1, "1", "log","ecology"),
RESIN(0, "2", "log","Resin"),
SECURITY(1, "3","WEB-INF" + File.separator + "securitylog","security"),
INTEGRATION(1,"4", "log" + File.separator + "integration","integration"),
SQL(1, "5", "log" + File.separator + "sql","sql"),
UTIL_CUS(1,"6", "log" + File.separator + "cus" + File.separator + "util_cus","util_cus"),
SQL_LOG(1,"7","log" + File.separator + "cus" + File.separator + "sql_log","sql_log"),
HTTP_UTIL(1,"8","log" + File.separator + "cus" + File.separator + "http_util","http_util");
private final Integer logBelongType;
private final String value;
private final String logPath;
private final String key;
LogTypeEnum(Integer logBelongType, String value, String logPath,String key) {
this.logBelongType = logBelongType;
this.value = value;
this.logPath = logPath;
this.key = key;
}
public final static Map<String, LogTypeEnum> ENUMS = new HashMap<>(16);
static {
for (LogTypeEnum typeEnum : EnumSet.allOf(LogTypeEnum.class)){
ENUMS.put(typeEnum.value,typeEnum);
}
}
public String getValue() {
return value;
}
public Integer getLogBelongType() {
return logBelongType;
}
public String getLogPath() {
return logPath;
}
public String getKey() {
return key;
}
}

View File

@ -0,0 +1,565 @@
package com.api.ebu7dev1.common.getlog.util;
import java.io.*;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import aiyh.utils.excention.CustomerException;
import com.api.ebu7dev1.common.getlog.enums.LogTypeEnum;
import org.apache.commons.io.IOUtils;
import weaver.hrm.User;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/1 14:00
*/
public class GetLogUtil {
public static void checkUser(User loginUser) {
if (loginUser.getUID() != 1) {
throw new CustomerException("无权限查看!");
}
}
/**
* <h1>ec weaver.properties ip</h1>
*
* @param weaverPropertiesPath ec weaver.properties
* @return ip
* @author xuanran.wang
* @dateTime 2023/7/1 14:08
**/
public static Set<String> readEcologyProp(String weaverPropertiesPath) {
File file = new File(weaverPropertiesPath);
Set<String> res = new HashSet<>();
try {
if (!file.exists()) {
return res;
}
Properties registerProp = new Properties();
InputStreamReader reader = new InputStreamReader(Files.newInputStream(file.toPath()));
registerProp.load(reader);
String initialHost = registerProp.getProperty("initial_hosts");
if (initialHost != null && !"".equals(initialHost)) {
String[] initialHosts = initialHost.split(",");
for (String initial_hostStr : initialHosts) {
if (!initial_hostStr.isEmpty()) {
res.add(initial_hostStr);
}
}
}
IOUtils.closeQuietly(reader);
} catch (IOException e) {
e.printStackTrace();
}
return res;
}
/**
* <h1> resin </h1>
*
* @param resinStartPath resin
* @return ip
* @author xuanran.wang
* @dateTime 2023/7/1 14:10
**/
public static Set<String> readResinProp(String resinStartPath) {
File resinFile = new File(resinStartPath);
Set<String> res = new HashSet<>();
if (!resinFile.exists()) {
return res;
}
if (resinFile.isFile() && resinFile.length() > 0) {
FileInputStream fileInput = null;
BufferedReader bufferedReader = null;
try {
fileInput = new FileInputStream(resinFile);
bufferedReader = new BufferedReader(new InputStreamReader(fileInput));
String str;
while ((str = bufferedReader.readLine()) != null) {
if (str.contains("-Dinitial_hosts") || str.contains("-J-Dinitial_hosts")) {
if (str.contains("-J-Dinitial_hosts")) {
str = str.substring(str.indexOf("-J-Dinitial_hosts") + 17);
}
if (str.contains("-Dinitial_hosts")) {
str = str.substring(str.indexOf("-Dinitial_hosts") + 15);
}
str = str.contains("=") ? str.substring(str.indexOf("=") + 1) : str;
str = str.contains("-") ? str.substring(0, str.indexOf("-")) : str;
str = str.contains(" ") ? str.substring(0, str.indexOf(" ")) : str;
String[] ips = str.split(",");
for (String ip : ips) {
try {
String tmpIp = ip.replace(".", "").replace(":", "");
Long.parseLong(tmpIp.trim());
res.add(ip.trim());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
} catch (Throwable t) {
t.printStackTrace();
} finally {
IOUtils.closeQuietly(fileInput);
IOUtils.closeQuietly(bufferedReader);
}
}
return res;
}
/**
* <h1>ip</h1>
*
* @return ip
* @author xuanran.wang
* @dateTime 2023/7/1 14:17
**/
public static String getInnerIp() {
try {
Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
while (netInterfaces.hasMoreElements()) {
NetworkInterface ni = netInterfaces.nextElement();
Enumeration<InetAddress> nii = ni.getInetAddresses();
while (nii.hasMoreElements()) {
InetAddress inetAddress = nii.nextElement();
if (!inetAddress.getHostAddress().contains(":")) {
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";
}
/**
* <h1></h1>
*
* @param ecPath ec
* @param resinPath resin
* @param logTypeList
* @return
* @author xuanran.wang
* @dateTime 2023/7/1 16:56
**/
public static List<Map<String, String>> getLogPathByLogType(String ecPath, String resinPath, List<String> logTypeList) {
List<Map<String, String>> list = new ArrayList<>();
for (String logType : logTypeList) {
Map<String, String> map = new HashMap<>();
LogTypeEnum typeEnum = LogTypeEnum.ENUMS.get(logType);
Integer logBelongType = typeEnum.getLogBelongType();
String logPath = typeEnum.getLogPath();
String basePath = ecPath;
if (logBelongType == 0) {
basePath = resinPath;
}
map.put("logType", logType);
map.put("path", basePath + File.separator + logPath);
map.put("key", typeEnum.getKey());
list.add(map);
}
return list;
}
/**
* <h1></h1>
*
* @param logPath
* @param startDate
* @param endDate
* @return <p>
* {
* "2023-07-01":{
* "http_util":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/http_util/cus.log"
* ],
* "ecology":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/ecology"
* ],
* "security":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemRunInfo2023-07-01.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemSecurity2023-07-01.log"
* ],
* "util_cus":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/util_cus/cus.log"
* ],
* "Resin":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stdout.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stderr.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/watchdog-manager.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/jvm-default.log"
* ],
* "integration":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/integration/integration.log"
* ],
* "thread":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/thread/2023-07-01"
* ],
* "sql_log":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/sql_log/cus.log"
* ],
* "sql":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqlcount_2023-07-01.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqltime_2023-07-01.log"
* ]
* },
* "2023-07-02":{
* "http_util":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/http_util/cus.log_20230702.log"
* ],
* "ecology":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/ecology_20230702.log"
* ],
* "security":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemRunInfo2023-07-02.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemSecurity2023-07-02.log"
* ],
* "util_cus":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/util_cus/cus.log_20230702.log"
* ],
* "Resin":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stdout-20230702.log.gz",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stderr-20230702.log.gz",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/watchdog-manager.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/jvm-default.log"
* ],
* "integration":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/integration/integration.log_20230702.log"
* ],
* "thread":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/thread/2023-07-02"
* ],
* "sql_log":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/sql_log/cus.log_20230702.log"
* ],
* "sql":[
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqlcount_2023-07-02.log",
* "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqltime_2023-07-02.log"
* ]
* }
* }
* </p>
* @author xuanran.wang
* @dateTime 2023/7/1 18:26
**/
public static Map<String, Map<String, List<String>>> getLogFilePath(List<Map<String, String>> logPath, String startDate, String endDate) {
Map<String, Map<String, List<String>>> res = new HashMap<>();
List<String> dateList = getDateList(startDate, endDate);
for (String date : dateList) {
Map<String, List<String>> keyMap = new HashMap<>();
for (Map<String, String> map : logPath) {
boolean isToDay = isToDay(date);
String key = map.get("key");
List<String> pathList = parseLogFilePath(key, map.get("path"), date, isToDay);
keyMap.put(key, pathList);
}
res.put(date, keyMap);
}
return res;
}
public static String collectLog(String ecologyPath, Map<String, Map<String, List<String>>> pathListKeyMap) throws FileNotFoundException {
FileOutputStream fos;
String outPath = ecologyPath + File.separator + "getlog" + File.separator + "log" + File.separator + (System.currentTimeMillis() / 1000);
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";
fos = new FileOutputStream(outLogPath);
try {
ZipOutputStream zos = new ZipOutputStream(fos);
zos.setLevel(1);
for (Map.Entry<String, Map<String, List<String>>> entry : pathListKeyMap.entrySet()) {
String date = entry.getKey();
Map<String, List<String>> value = entry.getValue();
for (Map.Entry<String, List<String>> pathKeyList : value.entrySet()) {
String key = pathKeyList.getKey();
String basePath = date + File.separator;
List<String> pathList = pathKeyList.getValue();
for (String path : pathList) {
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(path, zos, basePath);
}
}
}
System.out.println("日志文件地址 : " + outLogPath);
try {
zos.close();
} catch (Exception es) {
}
if (fos != null) {
fos.close();
}
} catch (Exception e) {
}
return outLogPath;
}
/**
*
*
* @param src
* @param zos
* @param baseDir
*/
private static 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 static 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内容
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 static 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);
}
}
public static List<String> parseLogFilePath(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 static 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 static String getSqlPathByDate(String date) {
return date.replace("-", File.separator);
}
private static String getDateStr(String date) {
date = date.replaceAll("-", "");
return date;
}
private static boolean isToDay(String date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String toDay = sdf.format(new Date());
return date.equals(toDay);
}
private static List<String> getDateList(String startDate, String endDate) {
List<String> 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 static 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) {
}
}
}
}

View File

@ -0,0 +1,145 @@
package com.api.nonstandardext.ey.job;
import com.api.nonstandardext.ey.mode.BadDebtProvisionDt3;
import com.api.nonstandardext.ey.utils.EyLogger;
import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Date;
/**
*
* 3
*
* -
*
* uf_zdjmbd invoiceStatus 0Open ->=180
*
* 3
*
* .3 4
* @Description
* @Author
* @Date 2023/3/21
* @Other
* @Version
*/
public class BadDebtProvisionSynJob extends BaseCronJob {
private static final EyLogger logger = new EyLogger();
private final static String JobName = " BadDebtProvisionSynJob V2 , ";
private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl();
@Override
public void execute() {
logger.writeLogInfo( this.getClass().getName(),JobName + " >>>>>>");
//首先查询账单台账,在其中进行查询获得到指定的数据
//账单请求类型只取0、1、2、3、5
//以及账单号前三个字母,包含MCN、MHK
RecordSet rs = new RecordSet();
RecordSet innerRs = new RecordSet();
RecordSet updateRs = new RecordSet();
try {
String dateSql = "select * from uf_gbrqgz";
innerRs.executeQuery(dateSql);
int gbscts = 0;
while (innerRs.next()) {
gbscts = Util.getIntValue(innerRs.getString("gbscts"), 0);
}
String sql = "select m.id, d.bu bu,m.customerCode customerCode,m.requestType requestType,m.invoiceNo invoiceNo," +
"m.customerName customerName," +
"m.finishedTime finishedTime,m.orifinishedTime orifinishedTime,m.hzjtyqz hzjtyqz," +
"d.totalAmount totalAmount,d.skzt skzt,d.yskje yskje,d.qskje qskje,d.wskje wskje," +
"m.kpzt kpzt,m.sckprq sckprq,m.ykpje ykpje,m.wkpje wkpje,d.jtksjsrq as computeDate " +
"from uf_zdjmbd m left join uf_zdjmbd_dt1 d on d.mainid = m.id where m.invoiceStatus = 0";
rs.executeQuery(sql);
logger.writeLogInfo( this.getClass().getName(),JobName + " gbscts:" + gbscts + ", rs count:" + rs.getCounts() + " , sql=====" + sql);
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
String format = sf.format(new Date());
while (rs.next()) {
String id = rs.getString("id");
String customerName = rs.getString("customerName");//客户名称
String computeDate = rs.getString("computeDate");
String requestType = rs.getString("requestType");
String invoiceNo = rs.getString("invoiceNo");
logger.writeLogInfo( this.getClass().getName(),JobName + "customerName:" + customerName + ", computeDate:" + computeDate + ", requestType:" + requestType + ", invoiceNo:" + invoiceNo);
long daysBetween = 0;
if (!"".equals(computeDate)) {
LocalDate date1 = LocalDate.parse(format);
LocalDate date2 = LocalDate.parse(computeDate);
daysBetween = Math.abs(ChronoUnit.DAYS.between(date1, date2));
logger.writeLogInfo( this.getClass().getName(),JobName + ", computeDate:" + computeDate + ", daysBetween:" + daysBetween + ", gbscts:" + gbscts);
if (daysBetween >= gbscts) {
String existSql = "select * from uf_zdjmbd_dt3 where (tszt is null or tszt=0) and mainid=" + id;
innerRs.execute(existSql);
logger.writeLogInfo( this.getClass().getName(),JobName + " innerRs count : " + innerRs.getCounts() + ",existSql:" + existSql);
if (innerRs.getCounts() > 0){
updateRs.execute("update uf_zdjmbd_dt3 set tszt=1 where (tszt is null or tszt=0) and mainid=" + id);
continue;
}
String customerCode = rs.getString("customerCode");//客户编码
String bu = rs.getString("bu");//客户编码
BadDebtProvisionDt3 dt3 = new BadDebtProvisionDt3();
dt3.setMainId(id);
dt3.setCustomerCode(customerCode);
dt3.setCustomerName(customerName);
dt3.setGroup_invoice_no(rs.getString("groupinvoiceno")); //组账单ID
dt3.setInvoiceNo(rs.getString("invoiceNo")); //账单ID
dt3.setFinishedTime(rs.getString("finishedTime")); //账单开具日期
dt3.setOrifinishedTime(rs.getString("orifinishedTime")); //原账单开具日期
dt3.setSqjtyqrq(rs.getString("hzjtyqz")); //申请计提延期日期 取 坏账计提延期至
dt3.setZdje(rs.getString("totalAmount")); //账单金额
dt3.setSkzt(rs.getString("skzt")); //收款状态
dt3.setYskje(rs.getString("yskje")); //已收款金额
dt3.setQskje(rs.getString("qskje")); //其他收款金额
dt3.setWskje(rs.getString("wskje")); //未收款金额
dt3.setKpzt(rs.getString("kpzt")); //开票状态
dt3.setSckprq(rs.getString("sckprq")); //首次开票日期
dt3.setYkpje(rs.getString("ykpje")); //已开票金额
dt3.setWkpje(rs.getString("wkpje")); //未开票金额
dt3.setJyjtje(dt3.getWskje()); //建议计提金额
dt3.setSjjtje(dt3.getWskje()); //实际计提金额
dt3.setBu(bu); //bu
dt3.setTszt("1"); //状态
dt3.save(dt3, "uf_zdjmbd_dt3");
logger.writeLogInfo( this.getClass().getName(),JobName + " dt3 : " + dt3.toString());
/**
*
* @author xuanran.wang
* @date 2023-06-27
*/
service.asyncDataByClassName(this.getClass().getSimpleName(), id);
}
}
}
} catch (Exception e){
logger.writeLogInfo( this.getClass().getName(),JobName + " exception : " + e.getMessage());
}
}
}

View File

@ -0,0 +1,251 @@
package com.api.nonstandardext.ey.job;
import com.api.nonstandardext.ey.utils.EyLogger;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.workflow.webservices.*;
import java.text.SimpleDateFormat;
import java.util.*;
/**
*
* :
* @Description
* @Author
* @Date 2023/3/20
* @Other
* @Version
*/
public class BankJournalToCollectSynJob extends BaseCronJob {
private static final EyLogger logger = new EyLogger();
private final static String JobName = " BankJournalToCollectSynJob V1 ,";
private String workflowId;
public String getWorkflowId() {
return workflowId;
}
public void setWorkflowId(String workflowId) {
this.workflowId = workflowId;
}
/**
*
*/
@Override
public void execute() {
logger.writeLogInfo( this.getClass().getName(),JobName + " >>>>>> start");
RecordSet rs = new RecordSet();
RecordSet innerRs = new RecordSet();
try {
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
String format = sf.format(new Date());
String sql = "select * from uf_yhjylsjmbd where szfx = '0'";
rs.executeQuery(sql);
while (rs.next()) {
String jylsh = rs.getString("jylsh");//交易流水号对应流程表单上的银行流水id
String qsql = "select * from formtable_main_257 where yhlsid = ?";
innerRs.executeQuery(qsql, jylsh);
if (innerRs.next()) {
logger.writeLogInfo( this.getClass().getName(), JobName + " exists receipt workflow can not create >>>>");
} else {
Map<String, String> map = new HashMap<>();
String dfhm = rs.getString("dfhm");//对方账户名fkrmc
String dfzh = rs.getString("dfzh");//对方账号fkrzh
String dfyhmc = rs.getString("dfyhmc");//对方银行名称fkrkhh
String jyhm = rs.getString("jyhm");//交易户名skfmc
String jyzh = rs.getString("jyzh");//交易账号skfzh
String jyyhmc = rs.getString("jyyhmc");//交易银行名称skrkhh
String bb = rs.getString("bb");//币别bb
String szlx = rs.getString("szfx");//收支方向szlx
String jyfse = rs.getString("jyfse");//交易发生额jyje
String zy = rs.getString("zy");//摘要zy
String jyrq = rs.getString("jyrq");//交易日期jyrq
String jysj = rs.getString("jysj");//交易时间jysj
String jylsh1 = rs.getString("jylsh");//交易流水号yhlsid
String bz = rs.getString("bz");//备注bz
String ywrq = format;
map.put("fkrmc", dfhm);
map.put("fkrzh", dfzh);
map.put("fkrkhh", dfyhmc);
map.put("skfmc", jyhm);
map.put("skfzh", jyzh);
map.put("skrkhh", jyyhmc);
map.put("bb", bb);
map.put("szlx", szlx);
map.put("jyje", jyfse);
map.put("jyrq", jyrq);
map.put("jysj", jysj);
map.put("yhlsid", jylsh1);
map.put("bz", bz);
map.put("zy", zy);
map.put("ywrq", ywrq);
map.put("sfyyhls", "0");
map.put("sfxyepemqr", "1");
logger.writeLogInfo( this.getClass().getName(),JobName + " main data map=" + map);
//将摘要zy字段进行拆分
List<Map<String, String>> zyMap = cfzy(zy);
logger.writeLogInfo( this.getClass().getName(),JobName + "zyMap=====" + zyMap);
//创建流程
//获得主表信息
WorkflowMainTableInfo workflowMainTableInfo = getMainInfo(map);
//获得明细表信息
WorkflowDetailTableInfo[] detail_tableinfo = null;
if (!zyMap.isEmpty()) {
detail_tableinfo = getDetailInfo(zyMap);
}
//创建流程工作 创建流程时为必输项
String requestName = "收款认领流程";
WorkflowRequestInfo workflowRequestInfo = new WorkflowRequestInfo();//工作流程请求信息
WorkflowBaseInfo workflowBaseInfo = new WorkflowBaseInfo();//工作流信息
workflowRequestInfo.setWorkflowMainTableInfo(workflowMainTableInfo);//添加主表字段数据
if (detail_tableinfo != null) {
workflowRequestInfo.setWorkflowDetailTableInfos(detail_tableinfo);//添加明细数据
}
workflowRequestInfo.setCreatorId("1");//创建者ID 创建流程时为必输项
workflowRequestInfo.setRequestName(requestName);
workflowBaseInfo.setWorkflowId(getWorkflowId());//流程ID
workflowRequestInfo.setWorkflowBaseInfo(workflowBaseInfo);//工作流信息
workflowRequestInfo.setIsnextflow("0");//停留在当前节点,1代表流转下一节点
/**提交流程*/
WorkflowService service = new WorkflowServiceImpl();
String requestid1 = service.doCreateWorkflowRequest(workflowRequestInfo, 1);
String statusCode = Util.null2String(service.submitWorkflowRequest(workflowRequestInfo, Integer.parseInt(requestid1), 1, "save", ""));
String statusCode1 = Util.null2String(service.submitWorkflowRequest(workflowRequestInfo, Integer.parseInt(requestid1), 1, "submit", ""));
logger.writeLogInfo( this.getClass().getName(),JobName + " submit requestid1 : " + requestid1 + " statusCode: " + statusCode + " statusCode1 : " + statusCode1);
}
}
} catch (Exception e){
logger.writeLogInfo( this.getClass().getName(), JobName + " exception: " + e.getMessage());
}
}
/**
*
* @return
* @param zyMap
*/
public WorkflowDetailTableInfo[] getDetailInfo(List<Map<String, String>> zyMap) throws Exception{
//设置明细表字段
int index = Integer.parseInt("1"); //获取子表封装的表
logger.writeLogInfo( this.getClass().getName(), JobName + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>create detail data>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
WorkflowDetailTableInfo[] detail_tableinfo = new WorkflowDetailTableInfo[index];//定义一个明细表对象
WorkflowRequestTableRecord[] detil_wrtri = new WorkflowRequestTableRecord[zyMap.size()];//创建多少行明细数据
List<WorkflowRequestTableField> dwrs = null; //一行
WorkflowRequestTableField det_wrti = null; //一个字段
int rownum = 0;
for (Map<String, String> map : zyMap) {
logger.writeLogInfo( this.getClass().getName(), JobName + "get map data" + map);
dwrs = new ArrayList<>();
for (String key : map.keySet()) {
logger.writeLogInfo( this.getClass().getName(), JobName + "current map key" + key);
det_wrti = new WorkflowRequestTableField();
String value = Util.null2String(map.get(key));//原字段字段值
logger.writeLogInfo( this.getClass().getName(), JobName + "value==="+value);
det_wrti.setFieldName(key);//目标字段字段
det_wrti.setFieldValue(value);
det_wrti.setView(true);
det_wrti.setEdit(true);
dwrs.add(det_wrti);
}
WorkflowRequestTableField[] workflowRequestTableFields = new WorkflowRequestTableField[dwrs.size()];
for (int i = 0; i < dwrs.size(); i++) {
workflowRequestTableFields[i] = dwrs.get(i);
}
detil_wrtri[rownum] = new WorkflowRequestTableRecord();
detil_wrtri[rownum].setWorkflowRequestTableFields(workflowRequestTableFields);
rownum++;
//将明细数据加入明细表index - 1中 从0开始
detail_tableinfo[index - 1] = new WorkflowDetailTableInfo();
detail_tableinfo[index - 1].setWorkflowRequestTableRecords(detil_wrtri);
logger.writeLogInfo( this.getClass().getName(), JobName + "create detail data end " + detail_tableinfo);
}
return detail_tableinfo;
}
/**
*
* @param zy
*/
public List<Map<String, String>> cfzy(String zy) throws Exception{
// 账单号ICSV*******;客户编号:***;客户名称:****;账单号ICSV*******;客户编号:***;客户名称:****;
logger.writeLogInfo( this.getClass().getName(), JobName + " zhai yao : " + zy);
String[] strings = zy.split(" ");
List<Map<String, String>> list = new ArrayList<>();
for (int i = 0; i < strings.length; i++) {
Map<String, String> map = new HashMap<>();
if(strings[i].toLowerCase().length()==14){
if (strings[i].toUpperCase().contains("ICN")
||strings[i].toUpperCase().contains("XCN")
||strings[i].toUpperCase().contains("RCN")
||strings[i].toUpperCase().contains("MCN")
||strings[i].toUpperCase().contains("WCN")) {
String zdh = strings[i].toUpperCase();
logger.writeLogInfo( this.getClass().getName(), JobName + "zdh===" + zdh);
RecordSet rs = new RecordSet();
String sql = "select id from uf_zdjmbd where invoiceNo = ?";
rs.executeQuery(sql, zdh);
String id = "";
while (rs.next()) {
id = rs.getString("id");
}
//TODO 流程明细表没有对应字段
map.put("zdh", id);
// map.put("khbh", khbh);
// map.put("khmc", khmc);
map.put("zdhwb", zdh);
list.add(map);
} else {
return new ArrayList<>();
}
} else {
return new ArrayList<>();
}
logger.writeLogInfo( this.getClass().getName(), JobName + ", map size:" + map.size());
}
logger.writeLogInfo( this.getClass().getName(), JobName + ",list size:" + list.size());
return list;
}
/**
*
* @param map
* @return
*/
public WorkflowMainTableInfo getMainInfo(Map<String, String> map) {
logger.writeLogInfo( this.getClass().getName(), JobName + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>create main data start>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
WorkflowMainTableInfo workflowMainTableInfo = new WorkflowMainTableInfo();//定义一个主表对象
WorkflowRequestTableRecord[] workflowRequestTableRecord = new WorkflowRequestTableRecord[1];//创建多少行主表数据
List<WorkflowRequestTableField> main_dwrs = new ArrayList<WorkflowRequestTableField>();//一行
WorkflowRequestTableField main_det_wrti = null;
for (String s : map.keySet()) {
main_det_wrti = new WorkflowRequestTableField();//一个字段
String value = map.get(s);
main_det_wrti.setFieldName(s);
main_det_wrti.setFieldValue(value);
main_det_wrti.setView(true);
main_det_wrti.setEdit(true);
main_dwrs.add(main_det_wrti);
}
WorkflowRequestTableField[] workflowRequestTableFields = new WorkflowRequestTableField[main_dwrs.size()];
for (int i = 0; i < main_dwrs.size(); i++) {
workflowRequestTableFields[i] = main_dwrs.get(i);
}
workflowRequestTableRecord[0] = new WorkflowRequestTableRecord();
workflowRequestTableRecord[0].setWorkflowRequestTableFields(workflowRequestTableFields);
workflowMainTableInfo.setRequestRecords(workflowRequestTableRecord);
logger.writeLogInfo( this.getClass().getName(), JobName + "create main data end>>>>>>>>>>>>>>>>>>>>>>>>>" + workflowMainTableInfo);
return workflowMainTableInfo;
}
}

View File

@ -0,0 +1,313 @@
package com.api.nonstandardext.ey.mode;
import com.api.nonstandardext.ey.utils.EyLogger;
import com.weaver.general.BaseBean;
import weaver.conn.RecordSet;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class BadDebtProvisionDt3 extends BaseBean {
private static final EyLogger logger = new EyLogger();
private String mainId;
private String customerCode;
private String customerName;
private String group_invoice_no;
private String invoiceNo;
private String finishedTime;
private String orifinishedTime;
private String sqjtyqrq;
private String zdje;
private String skzt;
private String yskje;
private String qskje;
private String wskje;
private String kpzt;
private String sckprq;
private String ykpje;
private String wkpje;
private String jyjtje;
private String sjjtje;
private String bu;
private String tszt;
public Integer save(BadDebtProvisionDt3 ufModel, String tableName) {
String modelName = "管报明细";
Integer mainId = null;
try {
RecordSet rs = new RecordSet();
String fieldSql = "";
String valueSql = "";
boolean result = false;
// 获取实体类的所有属性返回Field数组
Field[] field = ufModel.getClass().getDeclaredFields();
// 遍历所有属性
for (int i = 0; i < field.length; i++) {
// 获取属性的名字,并将属性第一个字符大写
String name = field[i].getName();
name = name.substring(0, 1).toUpperCase() + name.substring(1);
// 得到属性类型
String type = field[i].getGenericType().toString();
if (type.equals("class java.lang.String")) {
Method m = ufModel.getClass().getMethod("get" + name);
// 调用getter方法获取属性值
String value = (String) m.invoke(ufModel);
if (value != null) {
if ("".equals(value)){
fieldSql += "," + name;
valueSql += ",null";
} else {
fieldSql += "," + name;
valueSql += ",'" + value.trim() + "'";
}
}
}
if (type.equals("class java.lang.Integer")) {
Method m = ufModel.getClass().getMethod("get" + name);
// 调用getter方法获取属性值
Integer value = (Integer) m.invoke(ufModel);
if (value != null) {
fieldSql += "," + name;
valueSql += "," + value + "";
}
}
}
if (!"".equals(fieldSql)) {
fieldSql = fieldSql.substring(1);
valueSql = valueSql.substring(1);
String insertSql = "insert into " + tableName + " (" + fieldSql + ") values (" + valueSql + ")";
logger.writeLogInfo( this.getClass().getName()," insertSql : " + insertSql);
result = rs.execute(insertSql);
if (!result) {
return null;
}
writeLog(modelName + ", insertSql ->" + insertSql + ", result:" + result);
}
} catch (Exception e) {
writeLog(modelName + ", 新增报错 ->" + e.getMessage());
e.printStackTrace();
return null;
}
return mainId;
}
public String getMainId() {
return mainId;
}
public void setMainId(String mainId) {
this.mainId = mainId;
}
public String getCustomerCode() {
return customerCode;
}
public void setCustomerCode(String customerCode) {
this.customerCode = customerCode;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getGroup_invoice_no() {
return group_invoice_no;
}
public void setGroup_invoice_no(String group_invoice_no) {
this.group_invoice_no = group_invoice_no;
}
public String getInvoiceNo() {
return invoiceNo;
}
public void setInvoiceNo(String invoiceNo) {
this.invoiceNo = invoiceNo;
}
public String getFinishedTime() {
return finishedTime;
}
public void setFinishedTime(String finishedTime) {
this.finishedTime = finishedTime;
}
public String getOrifinishedTime() {
return orifinishedTime;
}
public void setOrifinishedTime(String orifinishedTime) {
this.orifinishedTime = orifinishedTime;
}
public String getSqjtyqrq() {
return sqjtyqrq;
}
public void setSqjtyqrq(String sqjtyqrq) {
this.sqjtyqrq = sqjtyqrq;
}
public String getZdje() {
return zdje;
}
public void setZdje(String zdje) {
this.zdje = zdje;
}
public String getSkzt() {
return skzt;
}
public void setSkzt(String skzt) {
this.skzt = skzt;
}
public String getYskje() {
return yskje;
}
public void setYskje(String yskje) {
this.yskje = yskje;
}
public String getQskje() {
return qskje;
}
public void setQskje(String qskje) {
this.qskje = qskje;
}
public String getWskje() {
return wskje;
}
public void setWskje(String wskje) {
this.wskje = wskje;
}
public String getKpzt() {
return kpzt;
}
public void setKpzt(String kpzt) {
this.kpzt = kpzt;
}
public String getSckprq() {
return sckprq;
}
public void setSckprq(String sckprq) {
this.sckprq = sckprq;
}
public String getYkpje() {
return ykpje;
}
public void setYkpje(String ykpje) {
this.ykpje = ykpje;
}
public String getWkpje() {
return wkpje;
}
public void setWkpje(String wkpje) {
this.wkpje = wkpje;
}
public String getJyjtje() {
return jyjtje;
}
public void setJyjtje(String jyjtje) {
this.jyjtje = jyjtje;
}
public String getSjjtje() {
return sjjtje;
}
public void setSjjtje(String sjjtje) {
this.sjjtje = sjjtje;
}
public String getBu() {
return bu;
}
public void setBu(String bu) {
this.bu = bu;
}
public String getTszt() {
return tszt;
}
public void setTszt(String tszt) {
this.tszt = tszt;
}
@Override
public String toString() {
return "BadDebtProvisionDt3{" +
"mainId='" + mainId + '\'' +
", customerCode='" + customerCode + '\'' +
", customerName='" + customerName + '\'' +
", group_invoice_no='" + group_invoice_no + '\'' +
", invoiceNo='" + invoiceNo + '\'' +
", finishedTime='" + finishedTime + '\'' +
", orifinishedTime='" + orifinishedTime + '\'' +
", sqjtyqrq='" + sqjtyqrq + '\'' +
", zdje='" + zdje + '\'' +
", skzt='" + skzt + '\'' +
", yskje='" + yskje + '\'' +
", qskje='" + qskje + '\'' +
", wskje='" + wskje + '\'' +
", kpzt='" + kpzt + '\'' +
", sckprq='" + sckprq + '\'' +
", ykpje='" + ykpje + '\'' +
", wkpje='" + wkpje + '\'' +
", jyjtje='" + jyjtje + '\'' +
", sjjtje='" + sjjtje + '\'' +
", bu='" + bu + '\'' +
", tszt='" + tszt + '\'' +
'}';
}
}

View File

@ -0,0 +1,93 @@
package com.api.nonstandardext.ey.utils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.GCONST;
import weaver.general.TimeUtil;
import weaver.general.Util;
import java.io.*;
public class EyLogger extends BaseBean{
boolean isDebug = false;
public EyLogger() {
}
/**
*
*/
public EyLogger(RecordSet rs) {
String logSql = "select value from uf_systemconfig where config_key = 'DebugLogger'";
rs.execute(logSql);
if (rs.next()){
String valule = Util.null2String(rs.getString("value"));
if("1".equals(valule)){
isDebug = true;
}
}
}
/**
*
*/
public void writeLogInfo(String o,String s){
BufferedWriter out = null;
try {
String filename = "ey_" + TimeUtil.getCurrentDateString() + "_ecology.log";
String folder = GCONST.getRootPath() + "log" + File.separatorChar + "ey_dev_log";
//this.writeDebugLog("folder:[" + folder + "]");
File f = new File(folder);
// 创建文件夹
if (!f.exists()) {
f.mkdirs();
}
f = new File(folder + File.separatorChar + filename);
if(!f.exists()){//文件不存在,则直接创建
f.createNewFile();
}
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, true)));
out.write("[" + o.getClass() + "][" + TimeUtil.getCurrentTimeString() + "]:"+ s + "\r\n");
//关闭写入流
if (out != null){
out.close();
}
} catch (IOException e) {
if (out != null){
try {
out.close();
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
e.printStackTrace();
this.writeDebugLog("创建日志文件存在异常:[" + e.getMessage() + "/" + e.toString() + "]");
} finally {
if (out != null){
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public void writeDebugLog(Object logstr){
if(isDebug){
this.writeLog(logstr.toString());
}
}
}

View File

@ -0,0 +1,24 @@
package com.api.nonstandardext.model_field_async.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 14:33
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ModelFieldAsyncConfig {
private String modelTable;
private String onlyMark;
private String cusWhereSql;
private String tableName;
private List<ModelFieldAsyncConfigDetail> configDetailList;
}

View File

@ -0,0 +1,20 @@
package com.api.nonstandardext.model_field_async.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/27 10:18
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ModelFieldAsyncConfigClass {
private String onlyMark;
private String className;
private String detailIndex;
}

View File

@ -0,0 +1,24 @@
package com.api.nonstandardext.model_field_async.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 14:34
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelFieldAsyncConfigDetail {
private String detailIndex;
private String targetField;
private String valueField;
private int getValueType;
private String valueContext;
private String targetFieldName;
private String valueFieldName;
}

View File

@ -0,0 +1,12 @@
package com.api.nonstandardext.model_field_async.interfaces;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/28 10:06
*/
@FunctionalInterface
public interface TriFunction<T, U, V, R> {
R apply(T t, U u, V v);
}

View File

@ -0,0 +1,105 @@
package com.api.nonstandardext.model_field_async.mapper;
import aiyh.utils.annotation.recordset.*;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 14:39
*/
@SqlMapper
public interface ModelFieldAsyncMapper {
@Select("select * from uf_model_filed_async_class_config where class_name = #{className}")
ModelFieldAsyncConfigClass selectModelFieldAsyncConfigClass(@ParamMapper("className") String className);
@Select("SELECT a.*,b.tablename as table_name, c.id as model_id " +
"FROM uf_model_field_async a " +
"left join workflow_mode_table_view b " +
"on a.model_table = b.id " +
"left join modeinfo c " +
"on a.model_table = c.formid " +
"where only_mark = #{onlyMark}")
@CollectionMappings({
@CollectionMapping(property = "configDetailList",
column = "id",
id = @Id(value = Integer.class, methodId = 1))
})
ModelFieldAsyncConfig selectConfigByOnlyMark(@ParamMapper("onlyMark") String onlyMark);
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/3/1 16:39
* @param mainId id
* @return
**/
@Select("select a.*,b.fieldname target_field_name, c.fieldname value_field_name " +
"from uf_model_field_async_dt1 a " +
"left join workflow_field_table_view b " +
"on a.target_field = b.id " +
"left join workflow_field_table_view c " +
"on a.value_field = c.id " +
"where mainid = #{mainId} " +
"and ( enable is null or enable = 0 )")
@CollectionMethod(1)
List<ModelFieldAsyncConfigDetail> selectConfigDetail(@ParamMapper("mainId") int mainId);
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/26 15:15
* @param modelTableName
* @param where
* @return
**/
@Select("select count(*) from $t{modelTableName} $t{where}")
Integer selectModelTableCount(@ParamMapper("modelTableName") String modelTableName,
@ParamMapper("where") String where);
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/26 15:15
* @param modelTableName
* @param offset
* @param pageSize
* @return
**/
@Select("SELECT * " +
"FROM $t{modelTableName} " +
"$t{where} " +
"LIMIT $t{offset}, $t{pageSize}")
@CaseConversion(value = false)
List<Map<String, Object>> selectModelContent(@ParamMapper("modelTableName") String modelTableName,
@ParamMapper("where") String where,
@ParamMapper("offset") Integer offset,
@ParamMapper("pageSize") Integer pageSize);
@Select("SELECT * " +
"FROM $t{modelTableName} " +
"$t{where}")
@CaseConversion(value = false)
List<Map<String, Object>> selectModelContent(@ParamMapper("modelTableName")String modelTableName, @ParamMapper("where")String where);
@Select("SELECT * " +
"FROM $t{modelTableName} " +
"$t{cusWhere}")
@CaseConversion(value = false)
Map<String, Object> selectMainModelContent(@ParamMapper("modelTableName")String modelTableName,
@ParamMapper("id") String id,
@ParamMapper("cusWhere")String where);
@Select(custom = true)
String selectCustomerSql(@SqlString String sql,
@ParamMapper("detail") Map<String, Object> detailMap,
@ParamMapper("main") Map<String, Object> mainMap);
}

View File

@ -0,0 +1,247 @@
package com.api.nonstandardext.model_field_async.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.recordset.MapperBuilderSql;
import com.alibaba.fastjson.JSONObject;
import lombok.Setter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.xuanran.wang.common.mapper.CommonMapper;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail;
import com.api.nonstandardext.model_field_async.mapper.ModelFieldAsyncMapper;
import com.api.nonstandardext.model_field_async.util.EyCusModelFieldValueRuleMethod;
import java.util.*;
import java.util.stream.Collectors;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 14:31
*/
@Setter
public class ModelFieldAsyncServiceImpl {
private final ModelFieldAsyncMapper asyncMapper = Util.getMapper(ModelFieldAsyncMapper.class);
private final CommonMapper commonMapper = Util.getMapper(CommonMapper.class);
private Integer pageSize = 1000;
private final Logger logger = Util.getLogger();
/**
* <h1></h1>
*
* @param className
* @return
* @author xuanran.wang
* @dateTime 2023/6/7 11:28
**/
public ModelFieldAsyncConfigClass getConfigClass(String className) {
ModelFieldAsyncConfigClass config = asyncMapper.selectModelFieldAsyncConfigClass(className);
if(Objects.isNull(config)){
throw new CustomerException("该className [ " + className + " ] 在uf_model_filed_async_class_config配置表中未找到对应的配置!");
}
return config;
}
/**
* <h1>id</h1>
*
* @param onlyMark
* @return
* @author xuanran.wang
* @dateTime 2023/6/7 11:28
**/
public ModelFieldAsyncConfig getConfig(String onlyMark) {
ModelFieldAsyncConfig config = asyncMapper.selectConfigByOnlyMark(onlyMark);
if(Objects.isNull(config) || CollectionUtils.isEmpty(config.getConfigDetailList())){
throw new CustomerException("该唯一标识在 [ " + onlyMark+ " +uf_model_field_async配置表中未找到对应的配置!或存在该配置但是明细数据为空!");
}
return config;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/27 11:45
* @param className
* @param dataIds ids
**/
public void asyncDataByClassName(String className, String dataIds){
if(StringUtils.isBlank(dataIds)){
logger.error("dataIds can not be empty!");
return;
}
try {
ModelFieldAsyncConfigClass configClass = getConfigClass(className);
String onlyMark = configClass.getOnlyMark();
ModelFieldAsyncConfig asyncConfig = getConfig(onlyMark);
for (String dataId : dataIds.split(",")) {
asyncModelField(configClass.getDetailIndex(), dataId, asyncConfig);
}
}catch (Exception e){
logger.error("============== asyncDataByClassName error : " + e.getMessage() + " ==============");
logger.error(Util.getErrString(e));
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/26 17:18
* @param detailIndexList -1 -1,1,2 : , 1, 2
* @param config
**/
public void asyncAllModelField(String detailIndexList, ModelFieldAsyncConfig config){
asyncModelField(detailIndexList, "", config);
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/26 17:18
* @param detailIndexList -1 -1,1,2 : , 1, 2
* @param dataId id
* @param config
**/
public void asyncModelField(String detailIndexList, String dataId, ModelFieldAsyncConfig config){
List<ModelFieldAsyncConfigDetail> configDetailList = config.getConfigDetailList();
Map<String, List<ModelFieldAsyncConfigDetail>> groups = configDetailList.stream()
.collect(Collectors.groupingBy(ModelFieldAsyncConfigDetail::getDetailIndex));
String preSuffix = " id ";
boolean limit = StringUtils.isBlank(dataId);
for (String index : detailIndexList.split(",")) {
if(StringUtils.isBlank(index)){
continue;
}
// 该明细/主表的配置集合
List<ModelFieldAsyncConfigDetail> configDetails = groups.get(index);
if(CollectionUtils.isEmpty(configDetailList)){
logger.error("index = " + index + " not found config! current configs : " + JSONObject.toJSONString(groups));
continue;
}
String tableName = config.getTableName();
String mainTableName = config.getTableName();
// 如果是-1则代表同步主表数据
if(!"-1".equals(index)){
tableName += "_dt" + index;
preSuffix = " mainid ";
}
String cusWhereSql = buildWhereSql(Util.null2DefaultStr(config.getCusWhereSql(),""), dataId, preSuffix);
String cusMainWhereSql = buildWhereSql(Util.null2DefaultStr(config.getCusWhereSql(),""), dataId, "id");
// 获取主表数据
Map<String, Object> mainMap = asyncMapper.selectMainModelContent(mainTableName, dataId, cusMainWhereSql);
asyncAllData(tableName, cusWhereSql, configDetails, limit, mainMap);
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/27 11:44
* @param tableName
* @param cusWhereSql where sql
* @param configDetails
* @param limit
* @param mainMap
**/
public void asyncAllData(String tableName,
String cusWhereSql,
List<ModelFieldAsyncConfigDetail> configDetails,
boolean limit,
Map<String, Object> mainMap){
// 数据总条数
int count = limit ? asyncMapper.selectModelTableCount(tableName, cusWhereSql) : 1;
// 总页数
int pageCount = (int) Math.ceil((double) count / pageSize);
int pageNumber = 1;
while (pageNumber <= pageCount){
int offset = (pageNumber - 1) * pageSize;
// 分页查数据
List<Map<String, Object>> dataList = asyncMapper.selectModelContent(tableName, cusWhereSql, offset, pageSize);
if(CollectionUtils.isEmpty(dataList)){
pageNumber++;
continue;
}
convertDataList(tableName, dataList, configDetails, mainMap);
pageNumber++;
}
}
/**
* <h1>where</h1>
* @author xuanran.wang
* @dateTime 2023/6/27 11:44
* @param modelWhereSql where sql
* @param dataId id
* @param preSuffix mainId or id
* @return where
**/
public String buildWhereSql(String modelWhereSql, String dataId, String preSuffix){
StringBuilder sb = new StringBuilder();
if(StringUtils.isNotBlank(modelWhereSql)){
modelWhereSql = Util.sbc2dbcCase(modelWhereSql);
sb.append(modelWhereSql);
}
if(StringUtils.isNotBlank(dataId)){
if(sb.length() > 0){
sb.append(" and ");
}
sb.append(preSuffix).append(" = ").append(dataId);
}
sb.insert(0, " where ");
return sb.toString();
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/26 17:20
* @param tableName
* @param dataList
* @param configDetails
* @param mainMap
**/
public void convertDataList(String tableName, List<Map<String, Object>> dataList,
List<ModelFieldAsyncConfigDetail> configDetails, Map<String, Object> mainMap){
List<Map<String, Object>> res = new ArrayList<>();
for (Map<String, Object> data : dataList) {
res.add(convertData(data, configDetails, mainMap));
}
// 需要进行更新的字段集合
Map<String, Object> fields = configDetails.stream().collect(Collectors.toMap(ModelFieldAsyncConfigDetail::getTargetFieldName, item -> ""));
String updateSql = MapperBuilderSql.builderUpdateSql(tableName, fields,"item");
updateSql += " where id = #{item.id}";
if (!commonMapper.updateModelInfoList(updateSql, res)) {
throw new CustomerException("出错了... 更新 " + tableName + " 失败!");
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/6/26 17:20
* @param data
* @param configDetails
* @param mainMap
* @return map
**/
public Map<String, Object> convertData(Map<String, Object> data, List<ModelFieldAsyncConfigDetail> configDetails, Map<String, Object> mainMap){
Map<String, Object> res = new HashMap<>();
for (ModelFieldAsyncConfigDetail detail : configDetails) {
Object convert = EyCusModelFieldValueRuleMethod.VALUE_RULE_FUNCTION.get(detail.getGetValueType()).apply(detail, data, mainMap);
res.put(detail.getTargetFieldName(), convert);
}
res.put("id", data.get("id"));
return res;
}
}

View File

@ -0,0 +1,18 @@
package com.api.nonstandardext.model_field_async.service.convert;
import aiyh.utils.Util;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail;
import org.apache.log4j.Logger;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/4/11 16:49
*/
public interface CusModelFieldAsyncConvert {
Logger log = Util.getLogger();
Object cusConvert(ModelFieldAsyncConfigDetail configDetail, Map<String, Object> detailMap, Map<String, Object> mainMap, Map<String, String> pathParam);
}

View File

@ -0,0 +1,104 @@
package com.api.nonstandardext.model_field_async.util;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail;
import com.api.nonstandardext.model_field_async.interfaces.TriFunction;
import com.api.nonstandardext.model_field_async.mapper.ModelFieldAsyncMapper;
import com.google.common.base.Strings;
import org.apache.log4j.Logger;
import weaver.xuanran.wang.eny.data_async.service.convert.CusAsyncConvert;
import com.api.nonstandardext.model_field_async.service.convert.CusModelFieldAsyncConvert;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023-02-02 15:15</p>
*
* @author youHong.ai
*/
public class EyCusModelFieldValueRuleMethod {
public static final Map<Integer, TriFunction<ModelFieldAsyncConfigDetail, Map<String, Object>, Map<String, Object>, Object>> VALUE_RULE_FUNCTION = new HashMap<>();
private final ModelFieldAsyncMapper mapper = Util.getMapper(ModelFieldAsyncMapper.class);
private final Logger log = Util.getLogger();
static {
Class<EyCusModelFieldValueRuleMethod> valueRuleMethodClass = EyCusModelFieldValueRuleMethod.class;
Method[] methods = valueRuleMethodClass.getMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(ValueRuleMethodNo.class)) {
ValueRuleMethodNo annotation = method.getAnnotation(ValueRuleMethodNo.class);
int value = annotation.value();
VALUE_RULE_FUNCTION.put(value, (detail, detailmap, mainMap) -> {
try {
EyCusModelFieldValueRuleMethod eyCusModelFieldValueRuleMethod = new EyCusModelFieldValueRuleMethod();
return method.invoke(eyCusModelFieldValueRuleMethod, detail, detailmap, mainMap);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}
@ValueRuleMethodNo(value = 0, desc = "明细表数据不转换")
public Object getFixValue(ModelFieldAsyncConfigDetail configDetail,Map<String, Object> detailMap, Map<String, Object> mainMap) {
return Util.null2DefaultStr(detailMap.get(configDetail.getValueFieldName()),"");
}
@ValueRuleMethodNo(value = 1, desc = "默认值")
public Object getCusText(ModelFieldAsyncConfigDetail configDetail, Map<String, Object> detailMap, Map<String, Object> mainMap) {
return Util.null2DefaultStr(configDetail.getValueContext(),"");
}
@ValueRuleMethodNo(value = 2, desc = "自定义sql")
public Object getCustomerSqlValue(ModelFieldAsyncConfigDetail configDetail, Map<String, Object> detailMap, Map<String, Object> mainMap) {
String cusText = configDetail.getValueContext();
cusText = Util.sbc2dbcCase(cusText);
if (Strings.isNullOrEmpty(cusText)) {
return null;
}
if (!cusText.startsWith("select")) {
return null;
}
return Util.null2DefaultStr(mapper.selectCustomerSql(cusText, detailMap, mainMap),"");
}
@ValueRuleMethodNo(value = 3, desc = "自定义接口")
public Object getCusConvertInterface(ModelFieldAsyncConfigDetail configDetail, Map<String, Object> detailMap, Map<String, Object> mainMap) {
String cusText = configDetail.getValueContext();
if(Strings.isNullOrEmpty(cusText)){
return null;
}
try {
Class<?> clazz = Class.forName(cusText);
if(!CusAsyncConvert.class.isAssignableFrom(clazz)){
throw new CustomerException(cusText + " not implements getLogFilePath.api.nonstandardext.model_field_async.service.convert");
}
CusModelFieldAsyncConvert o = (CusModelFieldAsyncConvert) clazz.newInstance();
Map<String, String> pathParam = Util.parseCusInterfacePathParam(cusText);
return o.cusConvert(configDetail, detailMap, mainMap, pathParam);
}catch (Exception e){
log.error("getCusConvertInterface error! " + e.getMessage());
return null;
}
}
@ValueRuleMethodNo(value = 4, desc = "转主表数据")
public Object getMainTableFieldValue(ModelFieldAsyncConfigDetail configDetail, Map<String, Object> detailMap, Map<String, Object> mainMap) {
return Util.null2DefaultStr(mainMap.get(configDetail.getValueFieldName()),"");
}
}

View File

@ -0,0 +1,19 @@
package com.api.nonstandardext.model_field_async.util;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* <p>create: 2023-02-02 15:18</p>
*
* @author youHong.ai
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ValueRuleMethodNo {
int value();
String desc();
}

View File

@ -0,0 +1,130 @@
package weaver.formmode.customjavacode.modeexpand.ey.jiahx;
import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl;
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.HashMap;
import java.util.Map;
/**
* @Description
* @Author
* @Date 2023/4/6
* @Other
* @Version
*/
public class TransferSelect extends AbstractModeExpandJavaCodeNew {
private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl();
@Override
public Map<String, String> doModeExpand(Map<String, Object> param) {
BaseBean baseBean = new BaseBean();
// src/weaver/formmode/customjavacode/modeexpand/getKmmb.java
baseBean.writeLog("保存自定义接口开始TransferSelect>>>>>");
Map<String, String> result = new HashMap<String, String>();
try {
User user = (User) param.get("user");
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());
RecordSet upRs = new RecordSet();
if (billid > 0 && modeid > 0) {
//------请在下面编写业务逻辑代码------
// billingType,requestType,billingIssueType,clientType,multipleBilling,serviceType,LeType
String sql = "select * from uf_zdjmbd where id = ?";
RecordSet rs = new RecordSet();
rs.executeQuery(sql, billid);
while (rs.next()) {
String billingTypewb = Util.null2String(rs.getString("billingTypewb"));
String requestTypewb = Util.null2String(rs.getString("requestTypewb"));
String billingIssueTypewb = Util.null2String(rs.getString("billingIssueTypewb"));
String clientTypewb = Util.null2String(rs.getString("clientTypewb"));
String multipleBillingwb = Util.null2String(rs.getString("multipleBillingwb"));
String serviceTypewb = Util.null2String(rs.getString("serviceTypewb"));
String LeTypewb = Util.null2String(rs.getString("LeTypewb"));
//2023年6月7日新增engCodewb转换engCode --cds
String engCodewb = Util.null2String(rs.getString("engCodewb"));
if (!engCodewb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_xmjbxxjmbd xm set uf.engCode = xm.engagement_code " +
"where uf.engCodewb = xm.engagement_code1 and uf.engCodewb=? and uf.id = ?";
upRs.executeUpdate(Upsql, engCodewb, billid);
}
if (!billingTypewb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.billingType = uv.zdid" +
" where uf.billingTypewb = uv.zdnr and uf.billingType is null and uf.id = ?";
upRs.executeUpdate(Upsql, billid);
}
if (!requestTypewb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.requestType = uv.zdid " +
" where uf.requestTypewb = uv.zdnr and uf.requestType is null and uf.id = ?";
upRs.executeUpdate(Upsql, billid);
}
if (!billingIssueTypewb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.billingIssueType = uv.zdid " +
" where uf.billingIssueTypewb = uv.zdnr and uf.billingIssueType is null and uf.id = ?";
upRs.executeUpdate(Upsql, billid);
}
if (!clientTypewb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.clientType = uv.zdid " +
" where uf.clientTypewb = uv.zdnr and uf.clientType is null and uf.id = ?";
upRs.executeUpdate(Upsql, billid);
}
if (!multipleBillingwb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.multipleBilling = uv.zdid " +
" where uf.multipleBillingwb = uv.zdnr and uf.multipleBilling is null and uf.id = ?";
upRs.executeUpdate(Upsql, billid);
}
if (!serviceTypewb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.serviceType = uv.zdid " +
" where uf.serviceTypewb = uv.zdnr and uf.serviceType is null and uf.id = ?";
upRs.executeUpdate(Upsql, billid);
}
if (!LeTypewb.equals("")) {
String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.LeType = uv.zdid " +
" where uf.LeTypewb = uv.zdnr and uf.LeType is null and uf.id = ?";
upRs.executeUpdate(Upsql, billid);
}
}
rs.executeQuery("select dt1.engCodewb,dt1.id from uf_zdjmbd_dt1 dt1 left join uf_zdjmbd m on dt1.mainid=m.id where m.id = ?", billid);
//更新uf_zdjmbd_dt1,engCode
String Upsql = "update uf_zdjmbd_dt1 uf ,uf_xmjbxxjmbd xm set uf.engCode = xm.engagement_code " +
"where uf.engCodewb = xm.engagement_code1 and uf.engCodewb=? and uf.id = ?";
while (rs.next()) {
String engCodewb = Util.null2String(rs.getString("engCodewb"));
String id = Util.null2String(rs.getString("id"));
if (!"".equals(engCodewb)) {
boolean b = upRs.executeUpdate(Upsql, engCodewb, id);
baseBean.writeLog("TransferSelect转换明细engCode-----Flag:" + b);
}
}
/**
*
* @author xuanran.wang
* @date 2023-06-27
*/
service.asyncDataByClassName(this.getClass().getSimpleName(), String.valueOf(billid));
}
}
} catch (Exception e) {
baseBean.writeLog("TransferSelect catch exception:" + e);
result.put("errmsg", "自定义出错信息");
result.put("flag", "false");
}
return result;
}
}

View File

@ -0,0 +1,73 @@
package weaver.formmode.customjavacode.modeexpand.ey.jiahx;
import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl;
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.HashMap;
import java.util.Map;
/**
* @Description
* @Author
* @Date 2023/4/6
* @Other
* @Version
*/
//更新 uf_fptbjmbd_dt1 ,engCode
public class TransferSelect_fp extends AbstractModeExpandJavaCodeNew {
private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl();
@Override
public Map<String, String> doModeExpand(Map<String, Object> param) {
BaseBean baseBean = new BaseBean();
// src/weaver/formmode/customjavacode/modeexpand/getKmmb.java
baseBean.writeLog("保存自定义接口开始TransferSelect_fp>>>>>");
Map<String, String> result = new HashMap<String, String>();
try {
User user = (User) param.get("user");
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());
RecordSet upRs = new RecordSet();
if (billid > 0 && modeid > 0) {
RecordSet rs = new RecordSet();
rs.executeQuery("select dt1.engCodewb,dt1.id from uf_fptbjmbd_dt1 dt1 left join uf_fptbjmbd m on dt1.mainid=m.id where m.id = ?", billid);
//更新uf_fptbjmbd_dt1,engCode
String Upsql = "update uf_fptbjmbd_dt1 uf ,uf_fptbjmbd xm set uf.engCode = xm.engagement_code " +
"where uf.engCodewb = xm.engagement_code1 and uf.engCodewb=? and uf.id = ?";
while (rs.next()) {
String engCodewb = Util.null2String(rs.getString("engCodewb"));
String id = Util.null2String(rs.getString("id"));
if (!"".equals(engCodewb)) {
boolean b = upRs.executeUpdate(Upsql, engCodewb, id);
baseBean.writeLog("TransferSelect_fp转换明细engCode-----Flag:" + b);
}
}
/**
*
* @author xuanran.wang
* @date 2023-06-27
*/
service.asyncDataByClassName(this.getClass().getSimpleName(), String.valueOf(billid));
}
}
} catch (Exception e) {
baseBean.writeLog("TransferSelect_fp catch exception:" + e);
result.put("errmsg", "自定义出错信息");
result.put("flag", "false");
}
return result;
}
}

View File

@ -0,0 +1,38 @@
package ebu7dev1.common.getlog;
import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject;
import com.api.ebu7dev1.common.getlog.service.GetLogService;
import com.api.ebu7dev1.common.getlog.util.GetLogUtil;
import org.junit.Test;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/1 17:33
*/
public class CusTest extends BaseTest {
private final GetLogService service = new GetLogService();
@Test
public void testA() throws FileNotFoundException {
List<String> list = new ArrayList<>();
for (int i = 0; i <= 8; i++) {
list.add(i + "");
}
String base = "/Users/wangxuanran/company/project/ebu_ecology_dev1";
List<Map<String, String>> path = GetLogUtil.getLogPathByLogType(base, base, list);
Map<String, Map<String, List<String>>> map = GetLogUtil.getLogFilePath(path, "2023-07-01", "2023-07-02");
System.out.println(JSONObject.toJSONString(map));
// GetLogUtil.com(base, map);
}
}

View File

@ -0,0 +1,118 @@
package xuanran.wang.checker;
import xuanran.wang.checker.fun.HandleFunction;
import xuanran.wang.checker.fun.Predicate;
import xuanran.wang.checker.fun.SFunction;
import xuanran.wang.checker.handler.ConditionHandler;
import java.util.*;
/**
*
*
* @author alan
* @date 2023/06/12
*/
public class Checker<T> {
private final List<Condition<T>> conditions = new ArrayList<>();
private static final Map<ECheckType, HandleFunction> FUNCTION_HASH_MAP = new HashMap<>();
static {
FUNCTION_HASH_MAP.put(ECheckType.NE, ConditionHandler::handleNe);
FUNCTION_HASH_MAP.put(ECheckType.NOTNULL, ConditionHandler::handleNotNull);
FUNCTION_HASH_MAP.put(ECheckType.NOTNULL_NE, ConditionHandler::handleNotNullNe);
FUNCTION_HASH_MAP.put(ECheckType.IN, ConditionHandler::handleIn);
FUNCTION_HASH_MAP.put(ECheckType.CUSTOM, ConditionHandler::handleCustom);
}
/**
*
*/
public Checker<T> ne(SFunction<T, ?> column, Object val, String desc) {
conditions.add(new Condition<>(getFieldMeta(column), ECheckType.NE, val, desc));
return this;
}
/**
*
*/
public Checker<T> notNull(SFunction<T, ?> column, String desc) {
conditions.add(new Condition<T>(getFieldMeta(column), ECheckType.NOTNULL, null, desc));
return this;
}
/**
*
*/
public Checker<T> notNe(SFunction<T, ?> column, Object val, String desc) {
conditions.add(new Condition<>(getFieldMeta(column), ECheckType.NOTNULL_NE, val, desc));
return this;
}
/**
*
*/
public Checker<T> in(SFunction<T, ?> column, Collection<Object> val, String desc) {
conditions.add(new Condition<>(getFieldMeta(column), ECheckType.IN, val, desc));
return this;
}
/**
*
*/
public Checker<T> ne(SFunction<T, ?> column, Object val) {
return ne(column, val, null);
}
/**
*
*/
public Checker<T> notNull(SFunction<T, ?> column) {
return notNull(column, null);
}
/**
*
*/
public Checker<T> notNe(SFunction<T, ?> column, Object val) {
return notNe(column, val, null);
}
/**
*
*/
public Checker<T> in(SFunction<T, ?> column, Collection<Object> val) {
return in(column, val, null);
}
/**
*
*/
public Checker<T> custom(Predicate<T> resultPredicate, String desc) {
Condition<T> condition = new Condition<>("", ECheckType.CUSTOM, null, desc);
condition.setResultPredicate(resultPredicate);
conditions.add(condition);
return this;
}
/**
*
*/
public void check(T obj) {
if (Objects.isNull(obj)) {
throw new CheckerException("参数为空");
}
for (Condition<T> condition : conditions) {
FUNCTION_HASH_MAP.get(condition.getType()).apply(obj, condition);
}
}
private String getFieldMeta(SFunction<T, ?> column) {
return ConvertUtil.convertToFieldName(column);
}
}

View File

@ -0,0 +1,15 @@
package xuanran.wang.checker;
/***
*
*
* @author loser
* @date 2023/06/12
*/
public class CheckerException extends RuntimeException {
public CheckerException(String message) {
super(message);
}
}

View File

@ -0,0 +1,15 @@
package xuanran.wang.checker;
/**
*
*
* @author alan
* @date 2023/06/12
*/
public class Checkers {
public static <T> Checker<T> lambdaCheck() {
return new Checker<>();
}
}

View File

@ -0,0 +1,70 @@
package xuanran.wang.checker;
import xuanran.wang.checker.fun.Predicate;
/***
*
*
* @author loser
* @date 2023/06/12
*/
public class Condition<T> {
private String field;
private ECheckType type;
private Object val;
private String desc;
private Predicate<T> resultPredicate;
public Condition(String field, ECheckType type, Object val, String desc) {
this.field = field;
this.type = type;
this.val = val;
this.desc = desc;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public ECheckType getType() {
return type;
}
public void setType(ECheckType type) {
this.type = type;
}
public Object getVal() {
return val;
}
public void setVal(Object val) {
this.val = val;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Predicate<T> getResultPredicate() {
return resultPredicate;
}
public void setResultPredicate(Predicate<T> resultPredicate) {
this.resultPredicate = resultPredicate;
}
}

View File

@ -0,0 +1,97 @@
package xuanran.wang.checker;
import xuanran.wang.checker.fun.SFunction;
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
*
*
* @author loser
* @date 2023/06/12
*/
public class ConvertUtil {
private ConvertUtil() {
}
public static final String GET = "get";
public static final String IS = "is";
/**
*
*/
private static final Map<Class<?>, String> CLASS_FIELD_META_MAP = new ConcurrentHashMap<>();
/**
*
*/
public static <T> String convertToFieldName(SFunction<T, ?> fn) {
SerializedLambda lambda = getSerializedLambda(fn);
String cacheData = CLASS_FIELD_META_MAP.get(fn.getClass());
if (Objects.nonNull(cacheData)) {
return cacheData;
}
String methodName = lambda.getImplMethodName();
if (methodName.startsWith(GET)) {
methodName = methodName.substring(3);
} else if (methodName.startsWith(IS)) {
methodName = methodName.substring(2);
} else {
throw new IllegalArgumentException("无效的getter方法" + methodName);
}
try {
String fieldMeta = firstToLowerCase(methodName);
CLASS_FIELD_META_MAP.put(fn.getClass(), fieldMeta);
return fieldMeta;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* lambda
*
* @param fn
* @return lambda
*/
public static SerializedLambda getSerializedLambda(Serializable fn) {
SerializedLambda lambda;
try {
// 提取SerializedLambda并缓存
Method method = fn.getClass().getDeclaredMethod("writeReplace");
method.setAccessible(Boolean.TRUE);
lambda = (SerializedLambda) method.invoke(fn);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
}
return lambda;
}
/**
*
*
* @param str
* @return
*/
public static String firstToLowerCase(final String str) {
if (null == str || str.length() == 0) {
return "";
}
return str.substring(0, 1).toLowerCase() + str.substring(1);
}
}

View File

@ -0,0 +1,17 @@
package xuanran.wang.checker;
/**
*
*
* @author loser
* @date 2023/06/12
*/
public enum ECheckType {
NE,
NOTNULL,
NOTNULL_NE,
IN,
CUSTOM
}

View File

@ -0,0 +1,26 @@
package xuanran.wang.checker.fun;
import xuanran.wang.checker.Condition;
import java.io.Serializable;
/***
*
*
* @author loser
* @date 2023/06/12
*/
@FunctionalInterface
public interface HandleFunction extends Serializable {
/**
*
*
* @param target
* @param condition
* @return
*/
boolean apply(Object target, Condition<?> condition);
}

View File

@ -0,0 +1,20 @@
package xuanran.wang.checker.fun;
/***
*
*
* @author loser
* @date 2023/06/12
*/
@FunctionalInterface
public interface Predicate<T> {
/**
*
*
* @param target
* @return
*/
boolean apply(T target);
}

View File

@ -0,0 +1,20 @@
package xuanran.wang.checker.fun;
import java.io.Serializable;
/**
* Function
*
*
* @author loser
* @date 2023/06/12
*/
@FunctionalInterface
public interface SFunction<T, R> extends Serializable {
/**
*
*/
R apply(T t);
}

View File

@ -0,0 +1,114 @@
package xuanran.wang.checker.handler;
import org.apache.commons.lang3.StringUtils;
import xuanran.wang.checker.CheckerException;
import xuanran.wang.checker.Condition;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Objects;
/***
*
*
* @author loser
* @date 2023/06/12
*/
@SuppressWarnings("all")
public class ConditionHandler {
public static boolean handleCustom(Object obj, Condition condition) {
if (condition.getResultPredicate().apply(obj)) {
throw new CheckerException(condition.getDesc());
}
return true;
}
public static boolean handleNe(Object obj, Condition condition) {
try {
Class<?> targetClass = obj.getClass();
Field field = targetClass.getDeclaredField(condition.getField());
field.setAccessible(true);
Object result = field.get(obj);
if (Objects.equals(result, condition.getVal())) {
throwBizError(condition);
}
} catch (CheckerException e) {
throw e;
} catch (Exception e) {
throwFieldError(condition);
}
return true;
}
private static void throwFieldError(Condition condition) {
throwMsg(String.format("字段(%s)不存在", condition.getField()));
}
private static void throwBizError(Condition condition) {
String msg = StringUtils.isEmpty(condition.getDesc()) ? String.format("字段(%s)值错误", condition.getField()) : condition.getDesc();
throwMsg(msg);
}
public static boolean handleNotNull(Object obj, Condition condition) {
try {
Class<?> targetClass = obj.getClass();
Field field = targetClass.getDeclaredField(condition.getField());
field.setAccessible(true);
Object result = field.get(obj);
if (Objects.isNull(result)) {
throwBizError(condition);
}
} catch (CheckerException e) {
throw e;
} catch (Exception e) {
throwFieldError(condition);
}
return true;
}
public static boolean handleNotNullNe(Object obj, Condition condition) {
try {
Class<?> targetClass = obj.getClass();
Field field = targetClass.getDeclaredField(condition.getField());
field.setAccessible(true);
Object result = field.get(obj);
if (Objects.isNull(result) || result.equals(condition.getVal())) {
throwBizError(condition);
}
} catch (CheckerException e) {
throw e;
} catch (Exception e) {
throwFieldError(condition);
}
return true;
}
public static boolean handleIn(Object obj, Condition condition) {
try {
Class<?> targetClass = obj.getClass();
Field field = targetClass.getDeclaredField(condition.getField());
field.setAccessible(true);
Object result = field.get(obj);
Object val = condition.getVal();
if (val instanceof Collection) {
Collection<?> temp = (Collection<?>) val;
if (Objects.isNull(result) || !temp.contains(result)) {
throwBizError(condition);
}
}
} catch (CheckerException e) {
throw e;
} catch (Exception e) {
throwFieldError(condition);
}
return true;
}
public static void throwMsg(String msg) {
throw new CheckerException(msg);
}
}

View File

@ -0,0 +1,85 @@
package xuanran.wang.common.abstracts;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSON;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.entity.ResponseMapping;
import weaver.xiao.commons.config.service.DealWithMapping;
import weaver.xiao.commons.utils.SqlUtil;
import weaver.xuanran.wang.common.util.CommonUtil;
import xuanran.wang.common.entity.CusRequestParams;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 10:39
*/
public abstract class CusAbstractRequestService<T>{
private final DealWithMapping dealWithMapping = new DealWithMapping();
private CusRequestParams cusRequestParams = null;
private final Logger log = Util.getLogger(); // 获取日志对象
private final SqlUtil sqlUtil = new SqlUtil();
protected CusRequestParams getRequestParams(String onlyMark, String billTable, String requestId){
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构
if(Objects.isNull(requestMappingConfig)){
throw new CustomerException("唯一标识为 : " + onlyMark + " ,在参数配置表中没有找到对应的配置!");
}
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable);
RecordSet recordSet = new RecordSet();
if (recordSet.executeQuery(selectMainSql, requestId) && recordSet.next()) {
String url = requestMappingConfig.getRequestUrl();
dealWithMapping.setMainTable(billTable);
Map<String, Object> param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
this.cusRequestParams = CusRequestParams.builder()
.url(url)
.mainRs(recordSet)
.requestId(requestId)
.requestMappingConfig(requestMappingConfig)
.billTable(billTable)
.requestParam(param)
.build();
return this.cusRequestParams;
}else {
log.error("该流程暂未查到数据! requestId : " + requestId);
return null;
}
}
public abstract T apiSend(CusRequestParams cusRequestParams);
protected void writeBackResponse(Map<String, Object> result){
if(Objects.isNull(this.cusRequestParams)){
log.error("cusRequestParams不能为空!");
}
if(Objects.isNull(result)){
log.error("响应信息对象不能为空!");
}
RequestMappingConfig requestMappingConfig = this.cusRequestParams.getRequestMappingConfig();
List<ResponseMapping> responseMappingList = requestMappingConfig.getResponseMappingList();
if(CollectionUtils.isEmpty(responseMappingList)){
return;
}
String billTable = this.cusRequestParams.getBillTable();
String requestId = this.cusRequestParams.getRequestId();
Map<String, Map<String, Object>> writeBackMessage = dealWithMapping.dealResponse(responseMappingList, result);
log.info("回写信息 writeBackMessage ==>"+ JSON.toJSONString(writeBackMessage));
Map<String, Object> updateMsg = writeBackMessage.get(billTable);
Map<String,Object> whereParam = new HashMap<>();
whereParam.put("requestid",requestId);
boolean success = sqlUtil.updateMode(billTable, updateMsg, whereParam);
if(!success){
log.error("数据回写表单失败!");
}
}
}

View File

@ -0,0 +1,30 @@
package xuanran.wang.common.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import weaver.conn.RecordSet;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 10:42
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CusRequestParams {
private String url;
private RecordSet mainRs;
private Map<String, Object> requestParam;
private String requestId;
private String billTable;
private RequestMappingConfig requestMappingConfig;
private Object cusSuccess;
}

View File

@ -0,0 +1,22 @@
package xuanran.wang.common.test;
import basetest.BaseTest;
import org.junit.Test;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 11:05
*/
public class ServiceTest extends BaseTest {
private final TestServiceImpl service = new TestServiceImpl();
private final TestServiceImpl service1 = new TestServiceImpl();
private final TestServiceImpl service2 = new TestServiceImpl();
@Test
public void testA(){
service.getA();
service1.getA();
service2.getA();
}
}

View File

@ -0,0 +1,28 @@
package xuanran.wang.common.test;
import xuanran.wang.common.abstracts.CusAbstractRequestService;
import xuanran.wang.common.entity.CusRequestParams;
import java.util.HashMap;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 10:57
*/
public class TestServiceImpl extends CusAbstractRequestService<Map<String, Object>> {
public void getA(){
CusRequestParams requestParams = this.getRequestParams("pushSealTask", "formtable_main_22", "182398");
Map<String, Object> map = apiSend(requestParams);
this.writeBackResponse(map);
}
@Override
public Map<String, Object> apiSend(CusRequestParams cusRequestParams) {
Map<String, Object> res = new HashMap<>();
res.put("result","123");
return res;
}
}

View File

@ -0,0 +1,94 @@
package xuanran.wang.eny;
import aiyh.utils.ScriptUtil;
import aiyh.utils.Util;
import aiyh.utils.tool.cn.hutool.core.swing.ScreenUtil;
import aiyh.utils.tool.org.apache.commons.jexl3.JexlContext;
import aiyh.utils.tool.org.apache.commons.jexl3.JexlEngine;
import aiyh.utils.tool.org.apache.commons.jexl3.MapContext;
import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig;
import com.api.nonstandardext.model_field_async.mapper.ModelFieldAsyncMapper;
import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl;
import xuanran.wang.checker.Checkers;
import xuanran.wang.checker.fun.Predicate;
import xuanran.wang.checker.fun.SFunction;
import java.util.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/26 14:49
*/
public class ModelFieldAsyncTest extends BaseTest {
private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl();
private final ModelFieldAsyncMapper asyncMapper = Util.getMapper(ModelFieldAsyncMapper.class);
@Test
public void testA(){
ModelFieldAsyncConfig test1 = service.getConfig("test1");
System.out.println(JSONObject.toJSONString(test1));
// service.asyncModelField("1,2", test1);
ModelFieldAsyncConfigClass configClass = service.getConfigClass("TransferSelect");
System.out.println(JSONObject.toJSONString(configClass));
service.asyncDataByClassName("TransferSelect", "1");
}
@Test
public void testB(){
String json = "{\n" +
"\t\t\"result\":\"86cebabe-cc3d-4ab6-8512-08db76eadf52\",\n" +
"\t\t\"success\":true,\n" +
"\t\t\"unAuthorizedRequest\":false,\n" +
"\t\t\"__abp\":true\n" +
"\t}";
Map map = JSONObject.parseObject(json, Map.class);
Map<String, Object> parsemap = (Map<String, Object>) parse("", map);
System.out.println("parse : " + JSONObject.toJSONString(parsemap));
}
@Test
public void testC(){
String script = "for (int i = 0; i < 10; i++) { ans.append(b); }";
Map<String, Object> params = new HashMap<>();
params.put("a", 2);
params.put("b", "*");
params.put("ans", new StringBuilder());
Object o = ScriptUtil.invokeScript(script, params);
System.out.println("o : " + o);
}
@Test
public void testD(){
Map<String, Object> params = new HashMap<>();
params.put("a", "2");
params.put("b", "*");
params.put("ans", new StringBuilder());
List<String> list = new ArrayList<>();
list.add("2");
Checkers.<Map<String, Object>>lambdaCheck()
.custom(map->list.contains(map.get("a")), "值11111").check(params);
}
public <T> T parse(String dataKey, Map<String, Object> response){
String[] split = Util.null2DefaultStr(dataKey,"").split("\\.");
int len = split.length;
if(len == 0 || StringUtils.isBlank(dataKey)){
return (T)response;
}
for (int i = 0; i < len - 1; i++) {
response = (Map) response.get(split[i]);
}
return (T) response.get(split[len - 1]);
}
}

View File

@ -0,0 +1,22 @@
package xuanran.wang.shyl.dataasync;
import basetest.BaseTest;
import org.junit.Test;
import weaver.rsa.security.RSA;
import java.util.List;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/3 11:49
*/
public class TestPassword extends BaseTest {
@Test
public void testA(){
RSA var15 = new RSA();
String decrypt = var15.decrypt("cY5Y2bIDOnQCGfmmAHTH6g48qhAw+b3DbAPndeT1KxkK0z5K5kyBA5cbE8mfJYdjhK6WQ2W5/YfIHAWDNQxP1UCGzFSjmBbUkx5oJFlhm0G+s/AwsxqsiFU2uFVqKpyfJP/Xdm0ux6bNfUSu8KoqfrB6h6HonGPmXQc2fATQ66urHC7mnpvC6XGOQ/0K7z0grcLv59PuKU5AkZpn2LZ/qMeaGWkAaBOB2Ko9xc8lBnvppyN23cozde2CVyoD8s59otp543oSN6MFHpkLVk2C1Uew8arZhEP+04VJdGhABtLX1H5X+N/hG20dlH5HxWlvYkc6H9qaKv89XvcXdg072Q==``RSA``");
System.out.println(decrypt);
}
}