ic_excellent 2023-02-27 11:25:22 +08:00
commit 80d9200fdf
34 changed files with 2443 additions and 1538 deletions

View File

@ -484,3 +484,55 @@ $(() => {
})
})
/* ******************* 当明细数据未加载完成时 控制流程提交 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 ******************* */

12
pom.xml
View File

@ -64,7 +64,18 @@
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- -->
<!-- <dependency>-->
<!-- <groupId>eu.agno3.jcifs</groupId>-->
<!-- <artifactId>jcifs-ng</artifactId>-->
<!-- <version>2.1.9</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>smbj</artifactId>
<version>0.10.0</version>
</dependency>
<!-- easy excel -->
<dependency>
@ -87,7 +98,6 @@
</dependency>
</dependencies>
<repositories>

View File

@ -25,7 +25,7 @@ public class ThreadPoolConfig {
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(100),
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
*
@ -3687,4 +3715,8 @@ public class Util extends weaver.general.Util {
}
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

@ -17,5 +17,5 @@ public class DocImageInfo {
private Integer id;
private Integer detailId;
private Integer fileSize;
private Integer docFileType;
}

View File

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

View File

@ -4,6 +4,7 @@ package aiyh.utils.httpUtil;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -133,7 +134,11 @@ public class ResponeVo implements HttpResponse {
ObjectMapper mapper = new ObjectMapper();
this.entityMap = mapper.readValue(this.getEntityString(), Map.class);
} catch (JsonProcessingException ignored) {
try {
this.resultList = (List<Map>) JSONArray.parseArray(this.getEntityString(), Map.class);
} catch (JSONException e) {
Util.getLogger().error("Unable to convert the response result to array" + Util.getErrString(e));
}
} catch (Exception e) {
Util.getLogger().error("Unable to convert the response result to map or array" + Util.getErrString(e));
}

View File

@ -4,13 +4,15 @@ import aiyh.utils.Util;
import aiyh.utils.httpUtil.*;
import aiyh.utils.httpUtil.httpAsync.HttpAsyncThread;
import aiyh.utils.httpUtil.httpAsync.HttpAsyncThreadCallBack;
import aiyh.utils.zwl.common.ToolUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.spring.PropertyPreFilters;
import com.google.common.base.Strings;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.CredentialsProvider;
@ -41,32 +43,26 @@ import java.util.function.Function;
* @author EBU7-dev1-ayh
* @date 2021/8/31 0031 17:16 http HttpStaticUtils使HttpStaticUtils
*/
@ToString
public class HttpUtils {
public static final String JSON_PARAM_KEY = "JSON_PARAM_KEY";
public static final ThreadLocal<HttpUtilParamInfo> HTTP_UTIL_PARAM_INFO_THREAD_LOCAL = new ThreadLocal<>();
private static final Logger log = Util.getLogger("http_util");
private final ToolUtil toolUtil = new ToolUtil();
@Getter
private final GlobalCache globalCache = new GlobalCache();
// 线程池
private final ThreadPoolExecutor executorService;
private final PropertyPreFilters filters = new PropertyPreFilters();
private final PropertyPreFilters.MySimplePropertyPreFilter excludefilter = filters.addFilter();
// 默认编码
@Setter
private String DEFAULT_ENCODING = "UTF-8";
@Setter
private String sslKeyPath = "";
@Setter
private String password = "";
public void setSslKeyPath(String sslKeyPath) {
this.sslKeyPath = sslKeyPath;
}
public void setPassword(String password) {
this.password = password;
}
/**
* basic
@ -148,17 +144,6 @@ public class HttpUtils {
return str;
}
public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
this.credentialsProvider = credentialsProvider;
}
public GlobalCache getGlobalCache() {
return globalCache;
}
public void setDEFAULT_ENCODING() {
this.DEFAULT_ENCODING = DEFAULT_ENCODING;
}
public HttpPost getHttpPost(String url) {
HttpPost httpPost = new HttpPost(url);
@ -651,9 +636,15 @@ public class HttpUtils {
CloseableHttpResponse response = null;
try {
response = httpClient.execute(request);
} catch (Exception e) {
log.error(" http调用失败:" + Util.getErrString(e));
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove();
ExtendedIOUtils.closeQuietly(httpClient);
throw e;
}
try {
consumer.accept(response);
} catch (Exception e) {
toolUtil.writeErrorLog(" http调用失败:" + e);
throw e;
} finally {
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove();
@ -667,9 +658,15 @@ public class HttpUtils {
ResponeVo apply = null;
try {
response = httpClient.execute(request);
} catch (Exception e) {
log.error(" http调用失败:" + Util.getErrString(e));
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove();
ExtendedIOUtils.closeQuietly(httpClient);
throw e;
}
try {
apply = consumer.apply(response);
} catch (Exception e) {
toolUtil.writeErrorLog(" http调用失败:" + e);
throw e;
} finally {
HttpUtilParamInfo httpUtilParamInfo = HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.get();
@ -677,11 +674,13 @@ public class HttpUtils {
httpUtilParamInfo = new HttpUtilParamInfo();
}
httpUtilParamInfo.setResponse(apply);
if (apply != null) {
if (apply.getResponseMap() == null) {
httpUtilParamInfo.setResponseString(apply.getEntityString());
} else {
httpUtilParamInfo.setResponseMap(apply.getResponseMap());
}
}
httpUtilParamInfo.setResponseDate(new Date());
try {
log.info(Util.logStr("url [{}] request info : [\n{}\n];", httpUtilParamInfo.getUrl(),
@ -704,9 +703,16 @@ public class HttpUtils {
ResponeVo apply = null;
try {
response = httpClient.execute(request);
} catch (Exception e) {
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove();
log.error(" http调用失败:" + Util.getErrString(e));
ExtendedIOUtils.closeQuietly(httpClient);
throw e;
}
try {
apply = consumer.apply(requestParam, response);
} catch (Exception e) {
toolUtil.writeErrorLog(" http调用失败:" + e);
throw e;
} finally {
HttpUtilParamInfo httpUtilParamInfo = HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.get();
@ -714,11 +720,13 @@ public class HttpUtils {
httpUtilParamInfo = new HttpUtilParamInfo();
}
httpUtilParamInfo.setResponse(apply);
if (apply != null) {
if (apply.getResponseMap() == null) {
httpUtilParamInfo.setResponseString(apply.getEntityString());
} else {
httpUtilParamInfo.setResponseMap(apply.getResponseMap());
}
}
httpUtilParamInfo.setResponseDate(new Date());
HTTP_UTIL_PARAM_INFO_THREAD_LOCAL.remove();
try {
@ -769,7 +777,7 @@ public class HttpUtils {
}
} catch (Exception e) {
toolUtil.writeErrorLog(" http调用失败:" + Util.getErrString(e));
log.error(" http调用失败:" + Util.getErrString(e));
try {
httpUtilParamInfo.setResponseDate(new Date());
log.info(Util.logStr("url [{}] request info : [\n{}\n];", httpUtilParamInfo.getUrl(),
@ -1263,7 +1271,7 @@ public class HttpUtils {
total.append(line);
}
} catch (IOException e) {
toolUtil.writeErrorLog(e.getLocalizedMessage() + "\n" + e);
log.error(e.getLocalizedMessage() + "\n" + e);
}
return total.toString();
}

View File

@ -61,10 +61,14 @@ public interface UtilMapper {
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid = #{docId}")
DocImageInfo selectDocImageInfo(@ParamMapper("docId") String docId);
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in ($t{docIds})")
@Select("select id,docid doc_id," +
"imagefileid image_file_id, docfiletype doc_file_type," +
"imagefilename image_file_name from docimagefile where docid in ($t{docIds})")
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String docIds);
@Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in (${docIds})")
@Select("select id,docid doc_id,imagefileid image_file_id," +
"docfiletype doc_file_type," +
"imagefilename image_file_name from docimagefile where docid in (${docIds})")
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String[] docIds);

View File

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

View File

@ -7,6 +7,7 @@ import aiyh.utils.excention.TypeNonsupportException;
import com.google.common.base.Strings;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.conn.constant.DBConstant;
import java.beans.BeanInfo;
import java.beans.Introspector;
@ -272,7 +273,20 @@ public class ResultMapper {
public Object getObjectTrans(RecordSetTrans rs, Object o, Method method) {
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[] columnTypeName = rs.getColumnTypeName();
int[] columnTypes = rs.getColumnType();
@ -353,7 +367,6 @@ public class ResultMapper {
return o;
}
// Util.getLogger().info("获取对象:" + o.toString());
BeanInfo beanInfo = Introspector.getBeanInfo(o.getClass(), Object.class);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
@ -382,7 +395,20 @@ public class ResultMapper {
public Object getObject(RecordSet rs, Object o, Method method) {
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[] columnTypeName = rs.getColumnTypeName();
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" +
"YjzRr3MksyNX9BjFgjbBEaNNUbH8wwAR0ce6rgq8zIhQrvjT56DRPABFkBBgo7mn\n" +
"bBQlspm/x70xF5TEZdIb+YuLZakWu9TfYW8rilONkLde4LcSdp9yMDQP3nfA0USc\n" +
"+cVWURm/29+LazyJL9xlzHPP0ttbnX1jiHsZhtzqskyomxlPGwSpv+QbIqEjX8Yn\n" +
"JqIpf3Xv2QX0OkzqvtUT5/LB/gzoUI14mn1ZAAy3AQKBgQD5Uj/paaUNCZLkz1AR\n" +
"ajf/kW73nWdQuMk5mTSZK+9pqyX8UKlktxk/VqG+f8zxwh/BNowLMqwF5DV85rYQ\n" +
"tNJI8s4kRbnM2VRElCXelFDMpmxxWpY72M8xit9BHCkAPbC5fOBOq22YuS4YB104\n" +
"FbvE62FLUU2MaZcaM86JXYeaYQKBgQDBUusq7JWkPYieq1i86zDx1l1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AdX0\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")
private String ip;
@PrintParamMark
@ActionOptionalParam(desc = "是否删除生成的临时本地文件,true - 删除 false - 不删除", value = "false")
private String deleteTemp = "false";
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
try {
@ -86,8 +91,10 @@ public class ReceiptAndPaymentAction extends SafeCusBaseAction {
log.info("远程连接地址:" + "smb://" + ip + receiptPath);
log.info("本地文件地址: " + filePath);
smbjUtil.smbPut("smb://" + ip + receiptPath, filePath, userName, password, fileName);
if (Boolean.parseBoolean(deleteTemp)) {
Files.delete(Paths.get(filePath));
}
}
} else if (Integer.parseInt(voucherType) == 2) {
String tempFilePath = server.sendReceiptVoucher(onlyMark, requestId, billTable);
fileName = "Payment" + Util.getTime("yyyyMMddHHmmss") + ".txt";
@ -95,8 +102,10 @@ public class ReceiptAndPaymentAction extends SafeCusBaseAction {
log.info("远程连接地址:" + "smb://" + ip + paymentPath);
log.info("本地文件地址: " + tempFilePath);
smbjUtil.smbPut("smb://" + ip + paymentPath, tempFilePath, userName, password, fileName);
if (Boolean.parseBoolean(deleteTemp)) {
Files.delete(Paths.get(tempFilePath));
}
}
/* ******************* 是否提交流程 ******************* */
if (Boolean.parseBoolean(submitAction)) {
this.submitWorkflow(requestId, user.getUID());

View File

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

View File

@ -37,10 +37,10 @@ public class VoucherPayableService {
String sysFilePath = GCONST.getSysFilePath();
String filePath = "";
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";
} 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";
}
Path path = Paths.get(filePath);

View File

@ -12,6 +12,7 @@ import lombok.ToString;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.UpdateDetailRowDto;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionsSetValueConfigMain;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.service.WorkflowConditionsSetValueService;
import java.util.*;
@ -31,7 +32,7 @@ public class WorkflowConditionsSetValueAction extends SafeCusBaseAction {
@RequiredMark("流程条件赋值配置表唯一标识字段值")
@PrintParamMark
@ActionDefaultTestValue("test")
@ActionDefaultTestValue("getdata")
private String onlyMark;
@ActionOptionalParam(desc = "条件修改所在明细表,1-明细12-明细2", value = "")
@ -54,24 +55,26 @@ public class WorkflowConditionsSetValueAction extends SafeCusBaseAction {
try {
Map<String, Object> workflowData = new HashMap<>(16);
Map<String, Object> workflowMainData = super.getObjMainTableValue(requestInfo);
ConditionsSetValueConfigMain conditionsSetValueConfigMain = service.getConditionConfigMain(onlyMark);
if (Strings.isNullOrEmpty(detailNo)) {
/* ******************* 数据修改主表 ******************* */
Map<String, Object> conditionsValue = service.getConditionsValue(onlyMark, workflowData).get(billTable);
Map<String, Object> conditionsValue = service.getConditionsValue(conditionsSetValueConfigMain, workflowData).get(billTable);
service.updateWorkflowData(conditionsValue, billTable, requestId);
return;
}
/* ******************* 明细表 ******************* */
List<Map<String, Object>> detailData = super.getDetailTableObjValueByDetailNo(Integer.parseInt(detailNo), requestInfo);
List<Map<String, Object>> detailData = super.getDetailTableObjValueByDetailNo(Integer.parseInt(detailNo) - 1, requestInfo);
workflowData.put("main", workflowMainData);
workflowData.put("_user_", user);
workflowData.put("_workflowId_", workflowId);
workflowData.put("_requestId_", requestId);
workflowData.put("_billTable_", billTable);
workflowData.put("_detailTable_", billTable + "_dt" + detailNo);
List<UpdateDetailRowDto> main = new ArrayList<>();
List<UpdateDetailRowDto> detail = new ArrayList<>();
for (Map<String, Object> detailDatum : detailData) {
workflowData.put("detail_" + detailNo, detailDatum);
Map<String, Map<String, Object>> conditionsValues = service.getConditionsValue(onlyMark, workflowData);
Map<String, Map<String, Object>> conditionsValues = service.getConditionsValue(conditionsSetValueConfigMain, workflowData);
Map<String, Object> mainConditions = conditionsValues.get(billTable);
if (!Objects.isNull(mainConditions) && !mainConditions.isEmpty()) {
main.add(Builder.builder(UpdateDetailRowDto::new)
@ -101,6 +104,8 @@ public class WorkflowConditionsSetValueAction extends SafeCusBaseAction {
}
public void submitWorkflow(String requestId, Integer userId) {
Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "邮件发送附件提交流程!");
if (Boolean.parseBoolean(submitAction)) {
Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "流程条件赋值提交流程!");
}
}
}

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@ package weaver.youhong.ai.pcn.actioin.conditionssetvalue.service;
import aiyh.utils.Util;
import aiyh.utils.tool.Assert;
import com.alibaba.fastjson.JSON;
import org.jetbrains.annotations.NotNull;
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.entity.ConditionItem;
@ -28,17 +30,13 @@ public class WorkflowConditionsSetValueService {
/**
* <h2></h2>
*
* @param onlyMark
* @param conditionsSetValueConfigMain
* @param workflowData
* @return
*/
public Map<String, Map<String, Object>> getConditionsValue(String onlyMark, Map<String, Object> workflowData) {
/* ******************* 查询配置表 ******************* */
ConditionsSetValueConfigMain conditionsSetValueConfigMain = mapper.selectConfigByOnlyMark(onlyMark);
Assert.notNull(conditionsSetValueConfigMain, "can not query configuration by onlyMark [{}]", onlyMark);
public Map<String, Map<String, Object>> getConditionsValue(ConditionsSetValueConfigMain conditionsSetValueConfigMain, Map<String, Object> workflowData) {
List<ConditionItem> conditionItemList = conditionsSetValueConfigMain.getConditionItemList();
Assert.notEmpty(conditionItemList, "can not query conditionItemList by onlyMark [{}]", onlyMark);
/* ******************* 映射规则处理 ,责任链初始化 ******************* */
ConditionsTypeTreatment conditionsTypeTreatment = new ConditionsTypeTreatment(
new ConditionsTreatment(
@ -68,6 +66,16 @@ public class WorkflowConditionsSetValueService {
return result;
}
@NotNull
public ConditionsSetValueConfigMain getConditionConfigMain(String onlyMark) {
/* ******************* 查询配置表 ******************* */
ConditionsSetValueConfigMain conditionsSetValueConfigMain = mapper.selectConfigByOnlyMark(onlyMark);
Assert.notNull(conditionsSetValueConfigMain, "can not query configuration by onlyMark [{}]", onlyMark);
List<ConditionItem> conditionItemList = conditionsSetValueConfigMain.getConditionItemList();
Assert.notEmpty(conditionItemList, "can not query conditionItemList by onlyMark [{}]", onlyMark);
return conditionsSetValueConfigMain;
}
/**
* <h2></h2>
*
@ -86,32 +94,42 @@ public class WorkflowConditionsSetValueService {
return;
}
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();
updateData.put("_id_", updateDetailRow.getWhereValue());
updateData.put("_" + updateDetailRow.getWhereField() + "_", updateDetailRow.getWhereValue());
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 ");
sb.append(billTable).append(" set ");
for (Map.Entry<String, Object> entry : updateBatchData.get(0).entrySet()) {
for (Map.Entry<String, Object> entry : datum.entrySet()) {
if (("_" + updateDetailRow.getWhereField() + "_").equals(entry.getKey())) {
continue;
}
sb.append(entry.getKey())
.append(" = #{item.")
.append(" = #{")
.append(entry.getKey())
.append("},");
}
sb.deleteCharAt(sb.length() - 1);
sb.append(" where ")
.append(updateDetailRow.getWhereField())
.append(" = #{item._id_}");
.append(" = #{" + "_")
.append(updateDetailRow.getWhereField())
.append("_")
.append("}");
String sql = sb.toString();
boolean flag = mapper.batchUpdateWorkflowData(sql, updateBatchData);
boolean flag = mapper.batchUpdateWorkflowData(sql, datum);
if (!flag) {
try {
Thread.sleep(500);
} catch (InterruptedException ignore) {
Util.getLogger().info("更新条件字段值失败!" + sql + " " + JSON.toJSONString(datum));
}
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.annotation.MethodRuleNo;
import aiyh.utils.entity.FieldViewInfo;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.dto.ConditionValueDto;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.entity.ConditionItem;
@ -48,12 +49,21 @@ public class ConditionsTreatment {
public ConditionValueDto executeTreatment(ConditionItem conditionItem, Object value) {
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(
Util.null2String(sourceValue),
Util.null2String(value)
);
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 null;

View File

@ -51,6 +51,7 @@ public class ValueSetRulesTreatment {
return Builder.builder(ConditionValueDto::new)
.with(ConditionValueDto::setFieldName, conditionItem.getTargetField().getFieldName())
.with(ConditionValueDto::setValue, value)
.with(ConditionValueDto::setTableName, conditionItem.getTargetField().getTableName())
.build();
}

View File

@ -0,0 +1,100 @@
package weaver.youhong.ai.pcn.actioin.docfieltoattachment;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.entity.DocImageInfo;
import aiyh.utils.excention.CustomerException;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import weaver.file.ImageFileManager;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.youhong.ai.pcn.actioin.docfieltoattachment.mapper.CopyDocFileToAttachmentMapper;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023/2/21 18:40</p>
*
* @author youHong.ai
*/
@Getter
@Setter
@ToString
@ActionDesc(value = "文档字段中附件复制到附件字段中", author = "youhong.ai")
public class CopyDocFileToAttachmentAction extends SafeCusBaseAction {
@PrintParamMark
@ActionOptionalParam(value = "true", desc = "是否失败后阻断流程")
private String block = "true";
@PrintParamMark
@RequiredMark("字段映射配置字段: 文档字段:附件字段;文档字段:附件字段")
private String fieldMappings;
private final CopyDocFileToAttachmentMapper mapper = Util.getMapper(CopyDocFileToAttachmentMapper.class);
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
try {
String[] fieldMappingArr = fieldMappings.split(";");
Map<String, String> mainTableValue = super.getMainTableValue(requestInfo);
Map<String, Object> sqlValue = new HashMap<>();
for (String fieldMapping : fieldMappingArr) {
copyFile(fieldMapping, mainTableValue, sqlValue, String.valueOf(workflowId), billTable, user.getUID());
}
StringBuilder sb = new StringBuilder("update ");
sb.append(billTable).append(" set ");
for (Map.Entry<String, Object> entry : sqlValue.entrySet()) {
sb.append(entry.getKey()).append(" = ").append("#{").append(entry.getKey()).append("},");
}
sb.deleteCharAt(sb.length() - 1);
sb.append(" where requestid = ").append(requestId);
if (mapper.updateDocIds(sb.toString(), sqlValue)) {
Thread.sleep(500);
mapper.updateDocIds(sb.toString(), sqlValue);
}
} catch (Exception e) {
if (Boolean.parseBoolean(block)) {
throw new CustomerException(e.getMessage(), e);
}
}
}
private void copyFile(String fieldMapping, Map<String, String> mainTableValue,
Map<String, Object> sqlValue, String workflowId,
String billTable, int userId) {
List<Integer> docIds = new ArrayList<>();
String[] split = fieldMapping.split(":");
String docField = split[0];
String fileField = split[1];
String docId = mainTableValue.get(docField);
List<DocImageInfo> docImageInfos = Util.selectImageInfoByDocIds(docId);
for (DocImageInfo docImageInfo : docImageInfos) {
if (docImageInfo.getDocFileType() != 2) {
continue;
}
InputStream inputStreamById = ImageFileManager.getInputStreamById(docImageInfo.getImageFileId());
String docCategorysByTable = Util.getDocCategorysByTable(workflowId, fileField, billTable);
String[] categoryArr = docCategorysByTable.split(",");
String category = categoryArr[categoryArr.length - 1];
try {
int doc = Util.createDoc(docImageInfo.getImageFileName(), Integer.parseInt(category), inputStreamById, userId);
docIds.add(doc);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
sqlValue.put(fileField, Util.intJoin(docIds, ","));
}
}

View File

@ -0,0 +1,22 @@
package weaver.youhong.ai.pcn.actioin.docfieltoattachment.mapper;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.SqlString;
import aiyh.utils.annotation.recordset.Update;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023/2/21 19:13</p>
*
* @author youHong.ai
*/
@SqlMapper
public interface CopyDocFileToAttachmentMapper {
@Update(custom = true)
boolean updateDocIds(@SqlString String sql,
Map<String, Object> map);
}

View File

@ -0,0 +1,102 @@
package weaver.youhong.ai.pcn.actioin.generateloginid;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import com.google.common.base.Strings;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.youhong.ai.pcn.actioin.generateloginid.mapper.GenerateLoginIdMapper;
import java.text.NumberFormat;
import java.util.Map;
/**
* <h1>loginid</h1>
*
* <p>create: 2023/2/21 19:46</p>
*
* @author youHong.ai
*/
@Getter
@Setter
@ToString
@ActionDesc(value = "根据分部生成对应的登录名", author = "youhong.ai")
public class GenerateLoginIdAction extends SafeCusBaseAction {
@PrintParamMark
@RequiredMark("流程回写登录名字段名")
private String loginIdField;
@PrintParamMark
@RequiredMark("分部简称流程字段名")
private String subCompanyTextField;
@PrintParamMark
@ActionOptionalParam(value = "4", desc = "登录名序列数字位长度序列不足时前缀补0如0001默认长度4位")
private String numberFillQuantity = "4";
@PrintParamMark
@ActionOptionalParam(value = "true", desc = "是否失败后阻断流程")
private String block = "true";
private final GenerateLoginIdMapper mapper = Util.getMapper(GenerateLoginIdMapper.class);
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
try {
Map<String, String> mainTableValue = super.getMainTableValue(requestInfo);
String subCompanyName = mainTableValue.get(subCompanyTextField);
String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName);
Map<String, String> lastLoginIdInfo = mapper.selectLastLoginId(subCompanyName, subCompanyId, subCompanyName + "%");
String loginIdNo = lastLoginIdInfo.get("loginIdNo");
String loginId = prefixFill(loginIdNo, subCompanyName);
if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) {
try {
Thread.sleep(500);
} catch (Exception ignore) {
}
mapper.updateLoginId(billTable, requestId, loginId, loginIdField);
}
} catch (Exception e) {
if (Boolean.parseBoolean(block)) {
throw e;
}
}
}
/**
* <h2></h2>
*
* @param lastLoginIdNo
* @param prefix
* @return
*/
private String prefixFill(String lastLoginIdNo, String prefix) {
NumberFormat numberFormat = NumberFormat.getInstance();
// 禁用数字格式化分组。
numberFormat.setGroupingUsed(false);
// 保留最小位数
numberFormat.setMinimumIntegerDigits(Integer.parseInt(numberFillQuantity));
// 保留最大位数
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);
}
}

View File

@ -0,0 +1,64 @@
package weaver.youhong.ai.pcn.actioin.generateloginid.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.Update;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023/2/21 20:31</p>
*
* @author youHong.ai
*/
@SqlMapper
public interface GenerateLoginIdMapper {
/**
* <h2>id</h2>
*
* @param subCompanyName
* @return id
*/
@Select("select id from hrmsubcompany where SUBCOMPANYNAME = #{subCompanyName}")
String selectSubCompanyIdBySubCompanyName(String subCompanyName);
/**
* <h2></h2>
*
* @param loginIdPrefix
* @param subCompanyId id
* @param loginLike +%
* @return id
*/
@Select("select id,substring(LOGINID,length(#{loginIdPrefix}) + 1) login_id_no \n" +
"from hrmresource \n" +
"where SUBCOMPANYID1 = #{subCompanyId} and LOGINID like #{loginLike} \n" +
" order by cast(substring(LOGINID,length(#{loginIdPrefix}) + 1) as decimal) \n" +
" desc limit 1")
Map<String, String> selectLastLoginId(
@ParamMapper("loginIdPrefix") String loginIdPrefix,
@ParamMapper("subCompanyId") String subCompanyId,
@ParamMapper("loginLike") String loginLike
);
/**
* <h2>loginId</h2>
*
* @param billTable
* @param requestId id
* @param loginId id
* @param loginIdField id
* @return
*/
@Update("update $t{billTable} set $t{loginIdField} = #{loginId} where requestid = #{requestId}")
boolean updateLoginId(@ParamMapper("billTable") String billTable,
@ParamMapper("requestId") String requestId,
@ParamMapper("loginId") String loginId,
@ParamMapper("loginIdField") String loginIdField);
}

View File

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

View File

@ -20,4 +20,10 @@ public class TestHaRiPiJiu extends BaseTest {
GenerateFileUtil.createActionDocument(VoucherPayableAction.class);
GenerateFileUtil.createActionDocument(ReceiptAndPaymentAction.class);
}
@Test
public void test1() {
}
}

View File

@ -3,14 +3,20 @@ package youhong.ai.pcn;
import aiyh.utils.GenerateFileUtil;
import aiyh.utils.Util;
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.hrm.service.impl.RolesMembersServiceImpl;
import com.google.common.base.Strings;
import org.junit.Test;
import weaver.hrm.User;
import weaver.youhong.ai.pcn.actioin.conditionssetvalue.WorkflowConditionsSetValueAction;
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.addrolemember.RegisterRoleMemberCronJob;
import java.text.NumberFormat;
import java.util.HashMap;
import java.util.Map;
@ -62,10 +68,53 @@ public class RolesTest extends BaseTest {
@Test
public void test3() {
String value = "1";
System.out.println(Double.parseDouble(value));
// String value = "1";
// 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
public void testWorkflowConditionSetValue() {
@ -75,6 +124,6 @@ public class RolesTest extends BaseTest {
@Test
public void generateFile() {
GenerateFileUtil.createActionDocument(WorkflowConditionsSetValueAction.class);
GenerateFileUtil.createActionDocument(GenerateLoginIdAction.class);
}
}

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 =
"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCTWNWQiLBU7v5g" + "\n" +
"HdwWodocMRH8Hz2z3ZAMOsA0ObTD3oGkfczAG+XbNY/wK6zeeosmlMR/NraOSQmf" + "\n" +
"Vzr2hdzErEHS04RDEtcCV9clWIO7lS9lVDx0ob5IR+vMjk+HdobdEimQ06gJqYzI" + "\n" +
"PprUprrv5ZwuLwlyRHwAJJwyKE/MJLWBLw2641xLAjJ4v09UM5K74uBjXszDk1Ci" + "\n" +
"MSOsEtuGYJv60KGIO50MUDK5tj8cjUfK3VzGj2ILmf7c/WISMltcnW+8O/JJqpmX" + "\n" +
"Z+mltTKqJbdHQj2ig8/BxECIS1GyWkD3q0yB8FHkA1axdJZ+fxtt6q9AIws+Fil2" + "\n" +
"pvE5GLIvAgMBAAECggEAVBhza1ZYLWFp1Tm1j0U40rY+6YJ7GNjvictOP4Bf5xpr" + "\n" +
"K5KQ9WP2wDHFwPFsbF3MZWyq6WA0uOh+kW6bvG+SHL2jo8wMxKtQA4pWxH3MUZdH" + "\n" +
"wbFd/8MAcwh5T/o48bt4JVxkVMA4O6uFKhRxEcVHE/wcM0+tOIZVr081xnqzcHL1" + "\n" +
"YSgM1aSvDQnE3ds9j0jnd0LR0W+tidpHL/J8D+yZMIGyw7wQzZ4Xo4OmSOvb1NPY" + "\n" +
"TThPyRy1m8D5vP6etiI/tKlLMkvJvr1G5EPzTb/ECkqcTerOZwSfRkU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
String publicKey =
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk1jVkIiwVO7+YB3cFqHa" + "\n" +
"HDER/B89s92QDDrANDm0w96BpH3MwBvl2zWP8Cus3nqLJpTEfza2jkkJn1c69oXc" + "\n" +
"xKxB0tOEQxLXAlfXJViDu5UvZVQ8dKG+SEfrzI5Ph3aG3RIpkNOoCamMyD6a1Ka6" + "\n" +
"7+WcLi8JckR8ACScMihPzCS1gS8NuuNcSwIyeL9PVDOSu+LgY17Mw5NQojEjrBLb" + "\n" +
"hmCb+tChiDudDFAyubY/HI1Hyt1cxo9iC5n+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));
}
}

View File

@ -59,7 +59,8 @@ select wb.id,
when wb.FIELDHTMLTYPE = '3' then '流览框'
when wb.FIELDHTMLTYPE = '4' then 'check框'
when wb.FIELDHTMLTYPE = '5' then '选择框'
else '附件上传' end) fieldhtmltype
else '附件上传' end) fieldhtmltype,
wb.FIELDHTMLTYPE fieldtype
from workflow_billfield wb
left join htmllabelindex ht on wb.fieldlabel = ht.id;