单点登录、修改线程池

main
youHong.ai 2023-02-24 15:28:54 +08:00
parent 09ea2f1bdb
commit 12870f6339
24 changed files with 829 additions and 257 deletions

View File

@ -484,3 +484,55 @@ $(() => {
}) })
}) })
/* ******************* 当明细数据未加载完成时 控制流程提交 end ******************* */ /* ******************* 当明细数据未加载完成时 控制流程提交 end ******************* */
/* ******************* 流程明细字段包含某个字符串时给某个字段赋值为某个东西start ******************* */
$(() => {
let config = [{
table: 'detail_1',
mapping: [{
sourceField: '',
targetField: '',
sourceIncludes: '',
targetSet: ''
}]
}]
function runJs() {
config.forEach(item => {
let tableName = item.table
let mapping = item.mapping
if (tableName === "main") {
mapping.forEach(row => {
let sourceValue = WfForm.getFieldValue(WfForm.convertFieldNameToId(row.sourceField, tableName));
if (sourceValue.indexOf(row.sourceIncludes) !== -1) {
WfForm.changeFieldValue(WfForm.convertFieldNameToId(row.targetField, tableName, {
value: row.targetSet
}))
}
})
} else {
let rowIndexArr = WfForm.getDetailAllRowIndexStr(tableName).split(",");
rowIndexArr.forEach(rowIndex => {
mapping.forEach(row => {
let sourceValue = WfForm.getFieldValue(WfForm.convertFieldNameToId(row.sourceField, tableName));
if (sourceValue.indexOf(row.sourceIncludes) !== -1) {
WfForm.changeFieldValue(WfForm.convertFieldNameToId(row.targetField, tableName) + "_" + rowIndex, {
value: row.targetSet
})
}
})
})
}
})
}
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, callback => {
runJs()
callback()
})
})
/* ******************* 流程明细字段包含某个字符串时给某个字段赋值为某个东西end ******************* */

View File

@ -25,7 +25,7 @@ public class ThreadPoolConfig {
TimeUnit.SECONDS, TimeUnit.SECONDS,
new ArrayBlockingQueue<>(100), new ArrayBlockingQueue<>(100),
threadFactory, threadFactory,
new ThreadPoolExecutor.AbortPolicy()); new ThreadPoolExecutor.CallerRunsPolicy());
} }
} }
} }

View File

@ -1151,6 +1151,34 @@ public class Util extends weaver.general.Util {
} }
public static String getProperties(String fileName, String key) {
String propertyPath = GCONST.getPropertyPath();
if (StringUtil.isNullOrEmpty(fileName)) {
return null;
}
if (fileName.contains(".properties")) {
fileName.replace(".properties", "");
}
String path = propertyPath + "prop2map" + File.separator + fileName + ".properties";
Properties prop = new Properties();
InputStream inputStream = null;
try {
inputStream = new BufferedInputStream(new FileInputStream(path));
prop.load(inputStream);
return prop.getProperty(key);
} catch (IOException e) {
throw new RuntimeException("找不到文件:" + path);
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/** /**
* map * map
* *
@ -3687,4 +3715,8 @@ public class Util extends weaver.general.Util {
} }
return Util.getValueByKeyStr("main." + fieldInfo.getFieldName(), workflowData); return Util.getValueByKeyStr("main." + fieldInfo.getFieldName(), workflowData);
} }
public static <K, V> Map<K, V> createFunctionMap() {
return null;
}
} }

View File

@ -0,0 +1,19 @@
package aiyh.utils.annotation.recordset;
import java.lang.annotation.*;
/**
* <h1>sql</h1>
*
* <p>create: 2023-02-07 17:31</p>
*
* @author youHong.ai
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface SqlOracleDbFieldAnn {
String value();
}

View File

@ -1,5 +1,6 @@
package aiyh.utils.entity; package aiyh.utils.entity;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
@ -17,20 +18,32 @@ import lombok.ToString;
public class FieldViewInfo { public class FieldViewInfo {
/** 字段id */ /** 字段id */
@SqlOracleDbFieldAnn("ID")
private Integer id; private Integer id;
/** 字段名 */ /** 字段名 */
@SqlOracleDbFieldAnn("FIELD_NAME")
private String fieldName; private String fieldName;
/** 字段表名 */ /** 字段表名 */
@SqlOracleDbFieldAnn("TABLE_NAME")
private String tableName; private String tableName;
/** 表id */ /** 表id */
@SqlOracleDbFieldAnn("BILL_ID")
private Integer billId; private Integer billId;
/** 字段类型 */ /** 字段类型 */
@SqlOracleDbFieldAnn("FIELD_TYPE")
private Integer fieldType; private Integer fieldType;
/** 字段类型名称 */ /** 字段类型名称 */
@SqlOracleDbFieldAnn("FIELD_HTML_TYPE")
private String fieldHtmlType; private String fieldHtmlType;
} }

View File

@ -1,10 +1,12 @@
package aiyh.utils.recordset; package aiyh.utils.recordset;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn; import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans; import weaver.conn.RecordSetTrans;
import weaver.conn.constant.DBConstant;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -22,10 +24,25 @@ public class GetRsValueUtil {
public static String getRsValue(RecordSet rs, String fieldName, Field declaredField) { public static String getRsValue(RecordSet rs, String fieldName, Field declaredField) {
String value = rs.getString(fieldName); String value = rs.getString(fieldName);
if (StringUtils.isNullOrEmpty(value) && declaredField != null) { if (StringUtils.isNullOrEmpty(value) && declaredField != null) {
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
SqlOracleDbFieldAnn oracleDbFieldAnn = declaredField.getAnnotation(SqlOracleDbFieldAnn.class);
if (oracleDbFieldAnn != null) {
value = rs.getString(oracleDbFieldAnn.value());
}
return value;
} else {
SqlDbFieldAnn annotation = declaredField.getAnnotation(SqlDbFieldAnn.class); SqlDbFieldAnn annotation = declaredField.getAnnotation(SqlDbFieldAnn.class);
if (annotation != null) { if (annotation != null) {
value = rs.getString(annotation.value()); value = rs.getString(annotation.value());
return value;
} }
SqlOracleDbFieldAnn oracleDbFieldAnn = declaredField.getAnnotation(SqlOracleDbFieldAnn.class);
if (oracleDbFieldAnn != null) {
value = rs.getString(oracleDbFieldAnn.value());
}
}
} }
return value; return value;
} }
@ -34,10 +51,25 @@ public class GetRsValueUtil {
public static String getRsValue(RecordSetTrans rs, String fieldName, Field declaredField) { public static String getRsValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String value = rs.getString(fieldName); String value = rs.getString(fieldName);
if (StringUtils.isNullOrEmpty(value) && declaredField != null) { if (StringUtils.isNullOrEmpty(value) && declaredField != null) {
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
SqlOracleDbFieldAnn oracleDbFieldAnn = declaredField.getAnnotation(SqlOracleDbFieldAnn.class);
if (oracleDbFieldAnn != null) {
value = rs.getString(oracleDbFieldAnn.value());
}
return value;
} else {
SqlDbFieldAnn annotation = declaredField.getAnnotation(SqlDbFieldAnn.class); SqlDbFieldAnn annotation = declaredField.getAnnotation(SqlDbFieldAnn.class);
if (annotation != null) { if (annotation != null) {
value = rs.getString(annotation.value()); value = rs.getString(annotation.value());
return value;
} }
SqlOracleDbFieldAnn oracleDbFieldAnn = declaredField.getAnnotation(SqlOracleDbFieldAnn.class);
if (oracleDbFieldAnn != null) {
value = rs.getString(oracleDbFieldAnn.value());
}
}
} }
return value; return value;
} }

View File

@ -7,6 +7,7 @@ import aiyh.utils.excention.TypeNonsupportException;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans; import weaver.conn.RecordSetTrans;
import weaver.conn.constant.DBConstant;
import java.beans.BeanInfo; import java.beans.BeanInfo;
import java.beans.Introspector; import java.beans.Introspector;
@ -268,7 +269,20 @@ public class ResultMapper {
public Object getObjectTrans(RecordSetTrans rs, Object o, Method method) { public Object getObjectTrans(RecordSetTrans rs, Object o, Method method) {
CaseConversion annotation = method.getAnnotation(CaseConversion.class); CaseConversion annotation = method.getAnnotation(CaseConversion.class);
boolean enable = annotation == null || annotation.value(); boolean enable = false;
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
if (annotation == null) {
enable = false;
} else {
enable = annotation.value();
}
} else {
if (annotation == null) {
enable = true;
} else {
enable = annotation.value();
}
}
String[] columnName = rs.getColumnName(); String[] columnName = rs.getColumnName();
String[] columnTypeName = rs.getColumnTypeName(); String[] columnTypeName = rs.getColumnTypeName();
int[] columnTypes = rs.getColumnType(); int[] columnTypes = rs.getColumnType();
@ -349,7 +363,6 @@ public class ResultMapper {
return o; return o;
} }
// Util.getLogger().info("获取对象:" + o.toString());
BeanInfo beanInfo = Introspector.getBeanInfo(o.getClass(), Object.class); BeanInfo beanInfo = Introspector.getBeanInfo(o.getClass(), Object.class);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
@ -378,7 +391,20 @@ public class ResultMapper {
public Object getObject(RecordSet rs, Object o, Method method) { public Object getObject(RecordSet rs, Object o, Method method) {
CaseConversion annotation = method.getAnnotation(CaseConversion.class); CaseConversion annotation = method.getAnnotation(CaseConversion.class);
boolean enable = annotation == null || annotation.value(); boolean enable = false;
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
if (annotation == null) {
enable = false;
} else {
enable = annotation.value();
}
} else {
if (annotation == null) {
enable = true;
} else {
enable = annotation.value();
}
}
String[] columnName = rs.getColumnName(); String[] columnName = rs.getColumnName();
String[] columnTypeName = rs.getColumnTypeName(); String[] columnTypeName = rs.getColumnTypeName();
int[] columnTypes = rs.getColumnType(); int[] columnTypes = rs.getColumnType();

View File

@ -0,0 +1,43 @@
package com.api.youhong.ai.pcn.ssoyunzhao.controller;
import aiyh.utils.Util;
import com.api.youhong.ai.pcn.ssoyunzhao.service.SsoYunZhaoService;
import com.sun.jersey.api.view.Viewable;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
/**
* <h1></h1>
*
* <p>create: 2023/2/22 23:17</p>
*
* @author youHong.ai
*/
@Path("/aiyh/sso/yunzhao/")
public class SsoYunZhaoController {
private final SsoYunZhaoService service = new SsoYunZhaoService();
private final Logger logger = Util.getLogger();
@Path("/send-redirect")
@GET
public Viewable ssoSendRedirect(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
String redirectPath = service.getRedirectPath(user);
response.sendRedirect(redirectPath);
} catch (Exception e) {
logger.error("单点登录跳转失败!错误信息:" + Util.getErrString(e));
}
return null;
}
}

View File

@ -0,0 +1,78 @@
package com.api.youhong.ai.pcn.ssoyunzhao.service;
/**
* <h1></h1>
*
* <p>create: 2023/2/22 23:24</p>
*
* @author youHong.ai
*/
public class SsoYunZhaoConstant {
protected final static String PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8R8OPv/yVtzuz\n" +
"G/kKbhC9wr+z9I7Hfk9rFsTlJ/iHis94Wmy6HxYimUF+03Awqpap4CimwPUoKIiz\n" +
"UOkPVrlj0sOrDIWEbcJGBysveYeocACV1lLfAS4WpnH2xRrz5N7BpNey67aCeUsD\n" +
"UKtgv/1zxV8G0VM0xOmx7VxDnY+KBbPYptVC++IxaKfCn1K00T+d2Q3OZ47Tkaa1\n" +
"T8tP2hZt3nrQVTpmSlk+LRDKRYorilxALTtLhdXLv7TfkWdk81YKPkt5CGtB0IhS\n" +
"KCMOuxr3Hs1Q3QGafetrA5wugfDzsDy7WQuVdaVu22nUr1xK002NW9wzjgy+sEOG\n" +
"fX03Qq6lAgMBAAECggEAMLT3+GYYN7rxLMKdyH70wcJxyWII1b7tWKzJPub6OkZE\n" +
"qcPqwLNuDIFNGjwkl9Jpq4Sbv5fHVB44Tvstb5Rl3VcW21cf60Rhr7AHEf8EgySG\n" +
"YjzRr3MksyNX9BjFgjbBEaNNUbH8wwAR0ce6rgq8zIhQrvj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Q4QC3Qm4JEBouNy61sX7uLFBWTot5DcPvlWQtFC09qejYXl8V\n" +
"isFFLZd/OdlX0bHGjuOfcoo=";
protected final static String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvEfDj7/8lbc7sxv5Cm4Q\n" +
"vcK/s/SOx35PaxbE5Sf4h4rPeFpsuh8WIplBftNwMKqWqeAopsD1KCiIs1DpD1a5\n" +
"Y9LDqwyFhG3CRgcrL3mHqHAAldZS3wEuFqZx9sUa8+TewaTXsuu2gnlLA1CrYL/9\n" +
"c8VfBtFTNMTpse1cQ52PigWz2KbVQvviMWinwp9StNE/ndkNzmeO05GmtU/LT9oW\n" +
"bd560FU6ZkpZPi0QykWKK4pcQC07S4XVy7+035FnZPNWCj5LeQhrQdCIUigjDrsa\n" +
"9x7NUN0Bmn3rawOcLoHw87A8u1kLlXWlbttp1K9cStNNjVvcM44MvrBDhn19N0Ku\n" +
"pQIDAQAB";
protected final static String PRO_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQJMdNMq9yXD4X\n" +
"hV8Pn9G9QPoWSQvVrdz6MSaBMt8vaBqIcHUr1Escs/VcU9MTFRycmCH9FQxAm0k9\n" +
"E1DmGEwj37CaGWVFpCgVncpD04oQg34rF9DibvW3FANYsl2DmYLkHPQ5c4IUhX1w\n" +
"Z+4B1fSC2zTzog4KkLbqowXL7jz4/o9SSZoZm+2Q0ldF+2soXw1Se7s5urM988is\n" +
"IKQN08tKgGxHs2T1XFwGQKVMDC6Z6W2sYHPCf7yk3YDhG/XqVRfR2L/JozmOl1CH\n" +
"z1igrMYJUF601IJugPVmbDjWXS5BLq45xAt70/3yYyH+i1dguqcf9HGLDqUa7T3v\n" +
"FBpKkNKJAgMBAAECggEACbI86pa635v2dIgNBqBOV/+n5tPeTkT8L1eM0KX7Ca1S\n" +
"1xpOCw2nth2YB4YMJi5sl8rqgmyxlmzle4fj0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fbD5j7x5QRH6F\n" +
"5UG3P1RB6NM2wJ6Y/oDui2SawHaF4uWce5c7uJKnhELIQ5bNlDxJNfewQLKugFht\n" +
"Pbsp7Ld1j29jqqebnmC+2hOUsfGdtj8jxaEA7FwqaNWenvdiV7LktpUhCuiR/HD/\n" +
"F4oFFAlOJPm3xV9gAigsvU0=\n";
protected final static String PRO_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0CTHTTKvclw+F4VfD5/R\n" +
"vUD6FkkL1a3c+jEmgTLfL2gaiHB1K9RLHLP1XFPTExUcnJgh/RUMQJtJPRNQ5hhM\n" +
"I9+wmhllRaQoFZ3KQ9OKEIN+KxfQ4m71txQDWLJdg5mC5Bz0OXOCFIV9cGfuAdX0\n" +
"gts086IOCpC26qMFy+48+P6PUkmaGZvtkNJXRftrKF8NUnu7ObqzPfPIrCCkDdPL\n" +
"SoBsR7Nk9VxcBkClTAwumeltrGBzwn+8pN2A4Rv16lUX0di/yaM5jpdQh89YoKzG\n" +
"CVBetNSCboD1Zmw41l0uQS6uOcQLe9P98mMh/otXYLqnH/Rxiw6lGu097xQaSpDS\n" +
"iQIDAQAB";
}

View File

@ -0,0 +1,104 @@
package com.api.youhong.ai.pcn.ssoyunzhao.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.tool.Assert;
import weaver.hrm.User;
import javax.crypto.Cipher;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
/**
* <h1></h1>
*
* <p>create: 2023/2/22 23:19</p>
*
* @author youHong.ai
*/
public class SsoYunZhaoService {
/**
* <h2></h2>
*
* @param user
* @return
* @throws Exception
*/
private final String environment = Util.getProperties("PcnYunZhaoSsoRsaKey", "yunzhao.environment");
public String getRedirectPath(User user) throws Exception {
String userCodeMethod = Util.getCusConfigValueNullOrEmpty("YunZhaoSSOUserCodeMethod", "getEmail");
Method method = User.class.getMethod(userCodeMethod);
String value = Util.null2String(method.invoke(user));
long currentTime = System.currentTimeMillis();
String token = this.rsaEncryptedUserInfo(value + "\"" + String.valueOf(currentTime).substring(0, 10));
String yunZhaoSsoPathUrl = Util.getCusConfigValue("YunZhaoSSOPathURL");
Assert.notEmpty(yunZhaoSsoPathUrl, "can not find [YunZhaoSSOPathURL] from table [uf_cus_dev_config]");
return yunZhaoSsoPathUrl + URLEncoder.encode(token, "UTF-8");
}
/**
* <h2></h2>
*
* @param str
* @return
* @throws Exception
*/
public String rsaEncryptedUserInfo(String str) throws Exception {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
String privateKey = "";
if ("test".equals(environment)) {
privateKey = SsoYunZhaoConstant.PRIVATE_KEY;
}
if ("pro".equals(environment)) {
privateKey = SsoYunZhaoConstant.PRO_PRIVATE_KEY;
}
byte[] privBuffer = Base64.getDecoder().decode(privateKey.replace("\n", ""));
PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(privBuffer);
PrivateKey privKey = keyFactory.generatePrivate(privSpec);
cipher.init(Cipher.ENCRYPT_MODE, privKey);
byte[] encrypted = cipher.doFinal(str.getBytes());
String result = Base64.getEncoder().encodeToString(encrypted);
String checkSource = this.rsaDecryptUserInfo(result);
if (!checkSource.equals(str)) {
throw new CustomerException("加解密用户信息失败!");
}
return result;
}
/**
* <h2></h2>
*
* @param str
* @return
* @throws Exception
*/
public String rsaDecryptUserInfo(String str) throws Exception {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
String publicKey = "";
if ("test".equals(environment)) {
publicKey = SsoYunZhaoConstant.PUBLIC_KEY;
}
if ("pro".equals(environment)) {
publicKey = SsoYunZhaoConstant.PRO_PUBLIC_KEY;
}
byte[] pubBuffer = Base64.getDecoder().decode(publicKey.replace("\n", ""));
X509EncodedKeySpec pubSpec = new X509EncodedKeySpec(pubBuffer);
PublicKey pubKey = keyFactory.generatePublic(pubSpec);
cipher.init(Cipher.DECRYPT_MODE, pubKey);
byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(str.getBytes()));
return new String(decrypted);
}
}

View File

@ -71,6 +71,11 @@ public class ReceiptAndPaymentAction extends SafeCusBaseAction {
@RequiredMark("ip") @RequiredMark("ip")
private String ip; private String ip;
@PrintParamMark
@ActionOptionalParam(desc = "是否删除生成的临时本地文件,true - 删除 false - 不删除", value = "false")
private String deleteTemp = "false";
@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) {
try { try {
@ -86,8 +91,10 @@ public class ReceiptAndPaymentAction extends SafeCusBaseAction {
log.info("远程连接地址:" + "smb://" + ip + receiptPath); log.info("远程连接地址:" + "smb://" + ip + receiptPath);
log.info("本地文件地址: " + filePath); log.info("本地文件地址: " + filePath);
smbjUtil.smbPut("smb://" + ip + receiptPath, filePath, userName, password, fileName); smbjUtil.smbPut("smb://" + ip + receiptPath, filePath, userName, password, fileName);
if (Boolean.parseBoolean(deleteTemp)) {
Files.delete(Paths.get(filePath)); Files.delete(Paths.get(filePath));
} }
}
} else if (Integer.parseInt(voucherType) == 2) { } else if (Integer.parseInt(voucherType) == 2) {
String tempFilePath = server.sendReceiptVoucher(onlyMark, requestId, billTable); String tempFilePath = server.sendReceiptVoucher(onlyMark, requestId, billTable);
fileName = "Payment" + Util.getTime("yyyyMMddHHmmss") + ".txt"; fileName = "Payment" + Util.getTime("yyyyMMddHHmmss") + ".txt";
@ -95,8 +102,10 @@ public class ReceiptAndPaymentAction extends SafeCusBaseAction {
log.info("远程连接地址:" + "smb://" + ip + paymentPath); log.info("远程连接地址:" + "smb://" + ip + paymentPath);
log.info("本地文件地址: " + tempFilePath); log.info("本地文件地址: " + tempFilePath);
smbjUtil.smbPut("smb://" + ip + paymentPath, tempFilePath, userName, password, fileName); smbjUtil.smbPut("smb://" + ip + paymentPath, tempFilePath, userName, password, fileName);
if (Boolean.parseBoolean(deleteTemp)) {
Files.delete(Paths.get(tempFilePath)); Files.delete(Paths.get(tempFilePath));
} }
}
/* ******************* 是否提交流程 ******************* */ /* ******************* 是否提交流程 ******************* */
if (Boolean.parseBoolean(submitAction)) { if (Boolean.parseBoolean(submitAction)) {
this.submitWorkflow(requestId, user.getUID()); this.submitWorkflow(requestId, user.getUID());

View File

@ -72,6 +72,10 @@ public class VoucherPayableAction extends SafeCusBaseAction {
@RequiredMark("ip") @RequiredMark("ip")
private String ip; private String ip;
@PrintParamMark
@ActionOptionalParam(desc = "是否删除生成的临时本地文件,true - 删除 false - 不删除", value = "false")
private String deleteTemp = "false";
@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) {
@ -91,7 +95,9 @@ public class VoucherPayableAction extends SafeCusBaseAction {
log.info("远程连接地址:" + "smb://" + ip + remotePath); log.info("远程连接地址:" + "smb://" + ip + remotePath);
log.info("本地文件地址: " + tempFilePath); log.info("本地文件地址: " + tempFilePath);
smbjUtil.smbPut("smb://" + ip + remotePath, tempFilePath, userName, password, fileName); smbjUtil.smbPut("smb://" + ip + remotePath, tempFilePath, userName, password, fileName);
if (Boolean.parseBoolean(deleteTemp)) {
Files.delete(Paths.get(tempFilePath)); Files.delete(Paths.get(tempFilePath));
}
/* ******************* 是否提交流程 ******************* */ /* ******************* 是否提交流程 ******************* */
if (Boolean.parseBoolean(submitAction)) { if (Boolean.parseBoolean(submitAction)) {
this.submitWorkflow(requestId, user.getUID()); this.submitWorkflow(requestId, user.getUID());

View File

@ -37,10 +37,10 @@ public class VoucherPayableService {
String sysFilePath = GCONST.getSysFilePath(); String sysFilePath = GCONST.getSysFilePath();
String filePath = ""; String filePath = "";
if (sysFilePath.endsWith(File.separator)) { if (sysFilePath.endsWith(File.separator)) {
filePath = sysFilePath + "temp" + File.separator + "voucher" + File.separator + filePath = sysFilePath + "cus_temp" + File.separator + "voucher" + File.separator +
System.currentTimeMillis() + "-voucher-" + UUID.randomUUID() + ".txt"; System.currentTimeMillis() + "-voucher-" + UUID.randomUUID() + ".txt";
} else { } else {
filePath = sysFilePath + File.separator + "temp" + File.separator + "voucher" + File.separator + filePath = sysFilePath + File.separator + "cus_temp" + File.separator + "voucher" + File.separator +
System.currentTimeMillis() + "-voucher-" + UUID.randomUUID() + ".txt"; System.currentTimeMillis() + "-voucher-" + UUID.randomUUID() + ".txt";
} }
Path path = Paths.get(filePath); Path path = Paths.get(filePath);

View File

@ -4,7 +4,6 @@ import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction; import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.*; import aiyh.utils.annotation.*;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import ebu7common.youhong.ai.bean.Builder; import ebu7common.youhong.ai.bean.Builder;
import lombok.Getter; import lombok.Getter;
@ -70,6 +69,7 @@ public class WorkflowConditionsSetValueAction extends SafeCusBaseAction {
workflowData.put("_workflowId_", workflowId); workflowData.put("_workflowId_", workflowId);
workflowData.put("_requestId_", requestId); workflowData.put("_requestId_", requestId);
workflowData.put("_billTable_", billTable); workflowData.put("_billTable_", billTable);
workflowData.put("_detailTable_", billTable + "_dt" + detailNo);
List<UpdateDetailRowDto> main = new ArrayList<>(); List<UpdateDetailRowDto> main = new ArrayList<>();
List<UpdateDetailRowDto> detail = new ArrayList<>(); List<UpdateDetailRowDto> detail = new ArrayList<>();
for (Map<String, Object> detailDatum : detailData) { for (Map<String, Object> detailDatum : detailData) {
@ -92,8 +92,6 @@ public class WorkflowConditionsSetValueAction extends SafeCusBaseAction {
.build()); .build());
} }
} }
log.info("条件值: " + JSON.toJSONString(main));
log.info("条件值: " + JSON.toJSONString(detail));
service.updateWorkflowDetailData(main, billTable, null); service.updateWorkflowDetailData(main, billTable, null);
service.updateWorkflowDetailData(detail, billTable + "_dt" + detailNo, detailNo); service.updateWorkflowDetailData(detail, billTable + "_dt" + detailNo, detailNo);
} catch (Exception e) { } catch (Exception e) {

View File

@ -1,5 +1,6 @@
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity; package weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import aiyh.utils.entity.FieldViewInfo; import aiyh.utils.entity.FieldViewInfo;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -16,23 +17,30 @@ import lombok.ToString;
@Getter @Getter
@ToString @ToString
public class ConditionItem { public class ConditionItem {
@SqlOracleDbFieldAnn("ID")
private Integer id; private Integer id;
/** 赋值字段 */ /** 赋值字段 */
@SqlOracleDbFieldAnn("ID")
private FieldViewInfo targetField; private FieldViewInfo targetField;
/** 条件取值字段 */ /** 条件取值字段 */
private FieldViewInfo conditionsField; private FieldViewInfo conditionsField;
/** 条件 */ /** 条件 */
@SqlOracleDbFieldAnn("CONDITIONS")
private Integer conditions; private Integer conditions;
/** 条件对比方式 */ /** 条件对比方式 */
@SqlOracleDbFieldAnn("CONDITIONS_TYPE")
private Integer conditionsType; private Integer conditionsType;
/** 条件对比字段 */ /** 条件对比字段 */
private FieldViewInfo conditionsContrastField; private FieldViewInfo conditionsContrastField;
/** 条件自定义值 */ /** 条件自定义值 */
@SqlOracleDbFieldAnn("CUSTOMER_CONDITIONS_VALUE")
private String customerConditionsValue; private String customerConditionsValue;
/** 赋值规则 */ /** 赋值规则 */
@SqlOracleDbFieldAnn("VALUE_SET_RULES")
private Integer valueSetRules; private Integer valueSetRules;
/** 自定义赋值 */ /** 自定义赋值 */
@SqlOracleDbFieldAnn("CUSTOMER_SET_VALUE")
private String customerSetValue; private String customerSetValue;
/** 取值字段 */ /** 取值字段 */

View File

@ -1,5 +1,6 @@
package weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity; package weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
@ -19,12 +20,15 @@ import java.util.List;
public class ConditionsSetValueConfigMain { public class ConditionsSetValueConfigMain {
/** id */ /** id */
@SqlOracleDbFieldAnn("ID")
private Integer id; private Integer id;
/** 唯一标识 */ /** 唯一标识 */
@SqlOracleDbFieldAnn("ONLY_MARK")
private String onlyMark; private String onlyMark;
/** 流程类型 */ /** 流程类型 */
@SqlOracleDbFieldAnn("WORKFLOW_TYPE")
private Integer workflowType; private Integer workflowType;
/** 明细配置表,条件配置 */ /** 明细配置表,条件配置 */

View File

@ -85,9 +85,9 @@ public interface WorkflowConditionsSetValueMapper {
* <h2></h2> * <h2></h2>
* *
* @param sql sql * @param sql sql
* @param updateBatchData * @param updateBatchData
* @return * @return
*/ */
@BatchUpdate(custom = true) @Update(custom = true)
boolean batchUpdateWorkflowData(@SqlString String sql, @BatchSqlArgs List<Map<String, Object>> updateBatchData); boolean batchUpdateWorkflowData(@SqlString String sql, Map<String, Object> updateBatchData);
} }

View File

@ -2,6 +2,7 @@ package weaver.youhong.ai.pcn.actioin.conditionssetvalue.service;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.tool.Assert; import aiyh.utils.tool.Assert;
import com.alibaba.fastjson.JSON;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto; import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.UpdateDetailRowDto; import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.UpdateDetailRowDto;
@ -93,35 +94,42 @@ public class WorkflowConditionsSetValueService {
return; return;
} }
List<Map<String, Object>> updateBatchData = new ArrayList<>(updateDetailRowDtoList.size()); List<Map<String, Object>> updateBatchData = new ArrayList<>(updateDetailRowDtoList.size());
for (UpdateDetailRowDto updateDetailRowDto : updateDetailRowDtoList) { for (int i = 0; i < updateDetailRowDtoList.size(); i++) {
UpdateDetailRowDto updateDetailRowDto = updateDetailRowDtoList.get(i);
updateDetailRow = updateDetailRowDtoList.get(i);
Map<String, Object> updateData = updateDetailRowDto.getUpdateData(); Map<String, Object> updateData = updateDetailRowDto.getUpdateData();
updateData.put("_id_", updateDetailRow.getWhereValue()); updateData.put("_" + updateDetailRow.getWhereField() + "_", updateDetailRow.getWhereValue());
updateBatchData.add(updateData); updateBatchData.add(updateData);
} }
for (int i = 0; i < updateBatchData.size(); i++) {
Map<String, Object> datum = updateBatchData.get(i);
updateDetailRow = updateDetailRowDtoList.get(i);
StringBuilder sb = new StringBuilder("update "); StringBuilder sb = new StringBuilder("update ");
sb.append(billTable).append(" set "); sb.append(billTable).append(" set ");
for (Map.Entry<String, Object> entry : updateBatchData.get(0).entrySet()) { for (Map.Entry<String, Object> entry : datum.entrySet()) {
if (entry.getKey().equals("_id_")) { if (("_" + updateDetailRow.getWhereField() + "_").equals(entry.getKey())) {
continue; continue;
} }
sb.append(entry.getKey()) sb.append(entry.getKey())
.append(" = #{item.") .append(" = #{")
.append(entry.getKey()) .append(entry.getKey())
.append("},"); .append("},");
} }
sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(sb.length() - 1);
sb.append(" where ") sb.append(" where ")
.append(updateDetailRow.getWhereField()) .append(updateDetailRow.getWhereField())
.append(" = #{item._id_}"); .append(" = #{" + "_")
.append(updateDetailRow.getWhereField())
.append("_")
.append("}");
String sql = sb.toString(); String sql = sb.toString();
boolean flag = mapper.batchUpdateWorkflowData(sql, updateBatchData); boolean flag = mapper.batchUpdateWorkflowData(sql, datum);
if (!flag) { if (!flag) {
try { Util.getLogger().info("更新条件字段值失败!" + sql + " " + JSON.toJSONString(datum));
Thread.sleep(500);
} catch (InterruptedException ignore) {
} }
mapper.batchUpdateWorkflowData(sql, updateBatchData);
} }
} }

View File

@ -2,6 +2,7 @@ package weaver.youhong.ai.pcn.actioin.conditionssetvalue.util;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo; import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.entity.FieldViewInfo;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto; import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem; import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem;
@ -48,12 +49,21 @@ public class ConditionsTreatment {
public ConditionValueDto executeTreatment(ConditionItem conditionItem, Object value) { public ConditionValueDto executeTreatment(ConditionItem conditionItem, Object value) {
Map<String, Object> workflowData = ConditionsTypeTreatment.WORKFLOW_DATA.get(); Map<String, Object> workflowData = ConditionsTypeTreatment.WORKFLOW_DATA.get();
Object sourceValue = workflowData.get(conditionItem.getConditionsField().getFieldName()); FieldViewInfo conditionsField = conditionItem.getConditionsField();
Object sourceValue = Util.getValueByFieldViwInfo(conditionsField, workflowData);
Boolean apply = METHOD_MAP.get(conditionItem.getConditions()).apply( Boolean apply = METHOD_MAP.get(conditionItem.getConditions()).apply(
Util.null2String(sourceValue), Util.null2String(sourceValue),
Util.null2String(value) Util.null2String(value)
); );
if (apply) { if (apply) {
FieldViewInfo targetField = conditionItem.getTargetField();
String tableName = targetField.getTableName();
if (tableName.contains("_dt")) {
String[] dts = tableName.split("_dt");
((Map<String, Object>) workflowData.get("detail_" + dts[1])).put(targetField.getFieldName(), value);
} else {
((Map<String, Object>) workflowData.get("main")).put(targetField.getFieldName(), value);
}
return this.valueSetRulesTreatment.createConditionValue(conditionItem); return this.valueSetRulesTreatment.createConditionValue(conditionItem);
} }
return null; return null;

View File

@ -6,6 +6,7 @@ import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam; import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.PrintParamMark; import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark; import aiyh.utils.annotation.RequiredMark;
import com.google.common.base.Strings;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
@ -87,8 +88,15 @@ public class GenerateLoginIdAction extends SafeCusBaseAction {
// 保留最小位数 // 保留最小位数
numberFormat.setMinimumIntegerDigits(Integer.parseInt(numberFillQuantity)); numberFormat.setMinimumIntegerDigits(Integer.parseInt(numberFillQuantity));
// 保留最大位数 // 保留最大位数
numberFormat.setMaximumIntegerDigits(Integer.parseInt(numberFillQuantity)); numberFormat.setMaximumIntegerDigits(10);
int newLoginId = Integer.parseInt(lastLoginIdNo) + 1; long i = 0L;
try {
if (!Strings.isNullOrEmpty(lastLoginIdNo)) {
i = Long.parseLong(lastLoginIdNo);
}
} catch (NumberFormatException ignore) {
}
long newLoginId = i + 1;
return prefix + numberFormat.format(newLoginId); return prefix + numberFormat.format(newLoginId);
} }
} }

View File

@ -56,7 +56,7 @@ public interface GenerateLoginIdMapper {
* @param loginIdField id * @param loginIdField id
* @return * @return
*/ */
@Update("update $t{billTable} set $t{loginIdField} where requestid = #{requestId}") @Update("update $t{billTable} set $t{loginIdField} = #{loginId} where requestid = #{requestId}")
boolean updateLoginId(@ParamMapper("billTable") String billTable, boolean updateLoginId(@ParamMapper("billTable") String billTable,
@ParamMapper("requestId") String requestId, @ParamMapper("requestId") String requestId,
@ParamMapper("loginId") String loginId, @ParamMapper("loginId") String loginId,

View File

@ -0,0 +1 @@
yunzhao.environment=test

View File

@ -3,15 +3,20 @@ package youhong.ai.pcn;
import aiyh.utils.GenerateFileUtil; import aiyh.utils.GenerateFileUtil;
import aiyh.utils.Util; import aiyh.utils.Util;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.fastjson.JSON;
import com.api.youhong.ai.pcn.ssoyunzhao.service.SsoYunZhaoService;
import com.engine.common.util.ServiceUtil; import com.engine.common.util.ServiceUtil;
import com.engine.hrm.service.impl.RolesMembersServiceImpl; import com.engine.hrm.service.impl.RolesMembersServiceImpl;
import com.google.common.base.Strings;
import org.junit.Test; import org.junit.Test;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.WorkflowConditionsSetValueAction; import weaver.youhong.ai.pcn.actioin.conditionssetvalue.WorkflowConditionsSetValueAction;
import weaver.youhong.ai.pcn.actioin.generateloginid.GenerateLoginIdAction; import weaver.youhong.ai.pcn.actioin.generateloginid.GenerateLoginIdAction;
import weaver.youhong.ai.pcn.actioin.generateloginid.mapper.GenerateLoginIdMapper;
import weaver.youhong.ai.pcn.schedule.addrolebyhasundering.RegisterRoleMemberByHasUnderingCronJob; import weaver.youhong.ai.pcn.schedule.addrolebyhasundering.RegisterRoleMemberByHasUnderingCronJob;
import weaver.youhong.ai.pcn.schedule.addrolemember.RegisterRoleMemberCronJob; import weaver.youhong.ai.pcn.schedule.addrolemember.RegisterRoleMemberCronJob;
import java.text.NumberFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -63,10 +68,53 @@ public class RolesTest extends BaseTest {
@Test @Test
public void test3() { public void test3() {
String value = "1"; // String value = "1";
System.out.println(Double.parseDouble(value)); // System.out.println(Double.parseDouble(value));
GenerateLoginIdMapper mapper = Util.getMapper(GenerateLoginIdMapper.class);
Map<String, String> wld = mapper.selectLastLoginId("wld", "3", "wld%");
System.out.println(JSON.toJSONString(wld));
System.out.println(this.prefixFill(wld.get("loginIdNo"), "PCN"));
} }
private String prefixFill(String lastLoginIdNo, String prefix) {
NumberFormat numberFormat = NumberFormat.getInstance();
// 禁用数字格式化分组。
numberFormat.setGroupingUsed(false);
// 保留最小位数
numberFormat.setMinimumIntegerDigits(Integer.parseInt("4"));
// 保留最大位数
numberFormat.setMaximumIntegerDigits(10);
long i = 0L;
try {
if (!Strings.isNullOrEmpty(lastLoginIdNo)) {
i = Long.parseLong(lastLoginIdNo);
}
} catch (NumberFormatException ignore) {
}
long newLoginId = i + 1;
return prefix + numberFormat.format(newLoginId);
}
@Test
public void testsso() throws Exception {
User user = new User(22);
SsoYunZhaoService service = new SsoYunZhaoService();
System.out.println(service.getRedirectPath(user));
String s = service.rsaEncryptedUserInfo("test_public_decrypt@email.test.com\"1234567891011");
System.out.println(s);
System.out.println("1234567891011".substring(0, 10));
System.out.println(service.rsaDecryptUserInfo(s));
}
@Test
public void testToken() throws Exception {
SsoYunZhaoService service = new SsoYunZhaoService();
String s = service.rsaDecryptUserInfo("rO76Ung4eKvIXUK5+r9s26SQ1jyBfKjjOSUaV3Wmw6ZLE/kMHD07HOraAGdKdl9B4gwbbpYinBXT/S9O/6Jj3dDL2R81PkOYG/q+dYWkTFdAn5KsItdF6mKY/4wzPd0+5axPa5KjD7LUUwxb+G+jD3x4nTRU3HYJaCxNyjeXc5ndY/zrQKUsyLPlmgTWG1LrS2enoPg+9rZKiix/81N16O9F1om/X8LmS/N5Byh9bzYXbJrBK2AeDuF83ricyLNeKW/Wh5ZUnqfKWjeeER2uDgw9hq6njkIYYw7JLXsMeyUbNKA1R1Ng2XzxuoaBo/WRix7+5phX/4wbspMb6d/nOg==");
System.out.println(s);
}
@Test @Test
public void testWorkflowConditionSetValue() { public void testWorkflowConditionSetValue() {

View File

@ -0,0 +1,73 @@
package youhong.ai.pcn;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
public class Rsa {
public static void main(String[] args) throws Exception {
String privateKey =
"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCTWNWQiL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iC5n+3P1iEjJbXJ1vvDvySaqZl2fppbUy" + "\n" +
"qiW3R0I9ooPPwcRAiEtRslpA96tMgfBR5ANWsXSWfn8bbeqvQCMLPhYpdqbxORiy" + "\n" +
"LwIDAQAB" + "\n";
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
byte[] privBuffer = Base64.decodeBase64(privateKey);
PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(privBuffer);
PrivateKey privKey = keyFactory.generatePrivate(privSpec);
cipher.init(Cipher.ENCRYPT_MODE, privKey);
byte[] encrypted = cipher.doFinal("user@example.com\"1422331953".getBytes());
System.out.println("Encrypted with private key:");
System.out.println(Base64.encodeBase64String(encrypted));
byte[] pubBuffer = Base64.decodeBase64(publicKey);
X509EncodedKeySpec pubSpec = new X509EncodedKeySpec(pubBuffer);
PublicKey pubKey = keyFactory.generatePublic(pubSpec);
cipher.init(Cipher.DECRYPT_MODE, pubKey);
byte[] decrypted = cipher.doFinal(encrypted);
System.out.println("Decrypted with public key:");
System.out.println(new String(decrypted));
}
}