Compare commits
2 Commits
7caba0236e
...
42f39f73b1
Author | SHA1 | Date |
---|---|---|
wangxuanran | 42f39f73b1 | |
wangxuanran | 1654d4f765 |
|
@ -32,6 +32,10 @@ public abstract class CusBaseAction implements Action {
|
|||
* 全局requestInfo对象
|
||||
*/
|
||||
protected RequestInfo globalRequestInfo;
|
||||
/**
|
||||
* <h2>线程局部变量</h2>
|
||||
**/
|
||||
protected static ThreadLocal<RequestInfo> requestInfoThreadLocal = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* <h2>初始化流程默认的处理方法</h2>
|
||||
|
@ -50,6 +54,7 @@ public abstract class CusBaseAction implements Action {
|
|||
|
||||
@Override
|
||||
public final String execute(RequestInfo requestInfo) {
|
||||
requestInfoThreadLocal.set(requestInfo);
|
||||
this.globalRequestInfo = requestInfo;
|
||||
RequestManager requestManager = requestInfo.getRequestManager();
|
||||
String billTable = requestManager.getBillTableName();
|
||||
|
@ -92,6 +97,9 @@ public abstract class CusBaseAction implements Action {
|
|||
if (this.exceptionCallback(e, requestManager)) {
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}finally {
|
||||
// 无论成功还是失败 都将该线程的requestInfo进行移除
|
||||
requestInfoThreadLocal.remove();
|
||||
}
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.api.xuanran.wang.ambofo.checkuser.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.xuanran.wang.ambofo.checkuser.service.CheckUserService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* <h1>安波福从AD域中校验用户是否存在</h1>
|
||||
*
|
||||
* @Author xuanran.wang
|
||||
* @Date 2022/12/12 14:24
|
||||
*/
|
||||
@Path("/wxr/ambofo/")
|
||||
public class CheckUserController {
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
@Path("checkUser")
|
||||
@POST
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String checkUser(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
String checkContent = request.getParameter("checkContent");
|
||||
try {
|
||||
CheckUserService checkUserService = new CheckUserService();
|
||||
return ApiResult.success(checkUserService.checkADHasUser(checkContent),"ok");
|
||||
}catch (Exception e){
|
||||
String error = Util.logStr("AD查询接口发生异常:{}", e.getMessage());
|
||||
log.error(error);
|
||||
log.error(Util.getErrString(e));
|
||||
return ApiResult.error(500, error);
|
||||
}
|
||||
}
|
||||
|
||||
@Path("logUser")
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String logUser(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
CheckUserService checkUserService = new CheckUserService();
|
||||
checkUserService.logAllUser();
|
||||
return ApiResult.successNoData();
|
||||
}catch (Exception e){
|
||||
String error = Util.logStr("AD查询接口发生异常:{}", e.getMessage());
|
||||
log.error(error);
|
||||
log.error(Util.getErrString(e));
|
||||
return ApiResult.error(500, error);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package com.api.xuanran.wang.ambofo.checkuser.service;
|
||||
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import javax.naming.directory.SearchResult;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>安波福从AD校验用户是否存在业务方法</h1>
|
||||
*
|
||||
* @Author xuanran.wang
|
||||
* @Date 2022/12/12 14:29
|
||||
*/
|
||||
public class CheckUserService {
|
||||
|
||||
private Map<String, Object> ADConfig = null;
|
||||
private final Logger log = Util.getLogger();
|
||||
/**
|
||||
* <h1>构造方法中初始化配置文件</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/12 15:31
|
||||
**/
|
||||
public CheckUserService(){
|
||||
// AD配置文件
|
||||
ADConfig = Util.getProperties2Map("AmbofoADConfig");
|
||||
if(MapUtils.isEmpty(ADConfig)){
|
||||
throw new CustomerException("请检查/filesystem/prop/prop2map 文件夹下是否存在AmbofoADConfig.properties文件!");
|
||||
}
|
||||
|
||||
log.info(Util.logStr("AD配置对象 : [{}]", JSONObject.toJSONString(ADConfig)));
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>校验AD是否存在指定用户</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/12 15:22
|
||||
* @param checkInfo 校验内容
|
||||
* @return true/false 有/没有
|
||||
**/
|
||||
public boolean checkADHasUser(String checkInfo) {
|
||||
//连接到AD
|
||||
LdapContext ldapContext = login();
|
||||
try {
|
||||
// 域节点
|
||||
String searchBase = Util.null2String(ADConfig.get("searchBase"));
|
||||
// LDAP搜索过滤器类 cn=*name*模糊查询 cn=name 精确查询 String searchFilter = "(objectClass="+type+")";
|
||||
//查询域帐号
|
||||
String searchFilter = Util.null2String(ADConfig.get("queryField")) + "=" + checkInfo;
|
||||
log.info("searchFilter : " + searchFilter);
|
||||
// 创建搜索控制器
|
||||
SearchControls searchControl = new SearchControls();
|
||||
// 设置搜索范围 深度
|
||||
searchControl.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||
// 根据设置的域节点、过滤器类和搜索控制器搜索LDAP得到结果
|
||||
NamingEnumeration answer = ldapContext.search(searchBase, searchFilter, searchControl);
|
||||
// 初始化搜索结果数为0
|
||||
return answer.hasMoreElements();
|
||||
} catch (NamingException e) {
|
||||
throw new CustomerException(Util.logStr("从AD搜索用户异常:[{}]",e.getMessage()));
|
||||
} finally {
|
||||
close(ldapContext);
|
||||
}
|
||||
}
|
||||
|
||||
public void logAllUser() {
|
||||
//连接到AD
|
||||
LdapContext ldapContext = login();
|
||||
try {
|
||||
// 域节点
|
||||
String searchBase = Util.null2String(ADConfig.get("searchBase"));
|
||||
// LDAP搜索过滤器类 cn=*name*模糊查询 cn=name 精确查询 String searchFilter = "(objectClass="+type+")";
|
||||
// 创建搜索控制器
|
||||
SearchControls searchControl = new SearchControls();
|
||||
// 设置搜索范围 深度
|
||||
searchControl.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||
// 根据设置的域节点、过滤器类和搜索控制器搜索LDAP得到结果
|
||||
NamingEnumeration answer = ldapContext.search(searchBase, "", searchControl);
|
||||
//4. 获取查询的内容
|
||||
while (answer.hasMoreElements()) {
|
||||
SearchResult sr = (SearchResult) answer.next();
|
||||
String dn = sr.getName();
|
||||
log.info("dn " + dn);
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw new CustomerException(Util.logStr("从AD搜索用户异常:[{}]",e.getMessage()));
|
||||
} finally {
|
||||
close(ldapContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>创建LDAP连接</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/12 15:21
|
||||
* @return LDAP连接对象
|
||||
**/
|
||||
private LdapContext login() {
|
||||
String userName = Util.null2String(ADConfig.get("userName"));
|
||||
String password = Util.null2String(ADConfig.get("password"));
|
||||
String server = Util.null2String(ADConfig.get("server"));
|
||||
String driver = Util.null2String(ADConfig.get("driver"));
|
||||
String authentication = Util.null2String(ADConfig.get("authentication"));
|
||||
try {
|
||||
Hashtable<String, String> env = new Hashtable<>();
|
||||
//用户名称,cn,ou,dc 分别:用户,组,域
|
||||
env.put(Context.SECURITY_PRINCIPAL, userName);
|
||||
//用户密码 cn 的密码
|
||||
env.put(Context.SECURITY_CREDENTIALS, password);
|
||||
//url 格式:协议://ip:端口/组,域 ,直接连接到域或者组上面
|
||||
env.put(Context.PROVIDER_URL, server);
|
||||
//LDAP 工厂
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, driver);
|
||||
//验证的类型 "none", "simple", "strong"
|
||||
env.put(Context.SECURITY_AUTHENTICATION, authentication);
|
||||
return new InitialLdapContext(env, null);
|
||||
} catch (NamingException e) {
|
||||
throw new CustomerException(Util.logStr("连接AD失败! : {}", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h1>关闭连接</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/12 15:30
|
||||
* @param lct AD连接对象
|
||||
**/
|
||||
private void close(LdapContext lct) {
|
||||
try {
|
||||
if (lct != null){
|
||||
//关闭连接
|
||||
lct.close();
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw new CustomerException(Util.logStr("关闭AD连接失败! : {}", e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ public class DownLoadFileService {
|
|||
/**
|
||||
* <h2>文件记录表</h2>
|
||||
**/
|
||||
private static final String DOC_LOG_TABLE_NAME = "doc_log";
|
||||
private static final String DOC_LOG_TABLE_NAME = "uf_doc_log";
|
||||
/**
|
||||
* <h2>查询文件记录sql</h2>
|
||||
**/
|
||||
|
|
|
@ -90,6 +90,29 @@ public class CusInfoToOAUtil {
|
|||
return executeBatch(modelId, params, "", Collections.emptyList(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>将自定义信息写入建模</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/11/23 17:00
|
||||
* @param modelId 模块id
|
||||
* @param params 需要插入的数据map
|
||||
* @param whereSql 重复数据条件sql
|
||||
* @param whereParams 重复数据参数集合
|
||||
* @return 建模数据id集合
|
||||
**/
|
||||
public static List<String> executeBatch( int modelId,
|
||||
List<LinkedHashMap<String, Object>> params,
|
||||
String whereSql,
|
||||
List<String> whereParams) {
|
||||
if(modelId < 0){
|
||||
throw new RuntimeException("建模模块id不能小于0!");
|
||||
}
|
||||
String tableName = commonMapper.getModelNameByModelId(String.valueOf(modelId));
|
||||
if(StringUtils.isBlank(tableName)){
|
||||
throw new CustomerException("模块id为 " + modelId + ", 在系统中暂没查询到对应表单!");
|
||||
}
|
||||
return executeBatch(modelId, tableName, params, whereSql, whereParams, true);
|
||||
}
|
||||
/**
|
||||
* <h1>将自定义信息写入建模</h1>
|
||||
* @author xuanran.wang
|
||||
|
@ -148,10 +171,11 @@ public class CusInfoToOAUtil {
|
|||
if(StringUtils.isNotBlank(whereSql)){
|
||||
whereSql = Util.sbc2dbcCase(whereSql);
|
||||
whereSql = whereSql.replaceAll(TABLE_NAME_PLACEHOLDER, tableName);
|
||||
log.info("whereSql : " + whereSql);
|
||||
log.info("参数 : " + whereParams);
|
||||
if (rs.executeQuery(whereSql, whereParams) && rs.next()) {
|
||||
mainId = Util.getIntValue(rs.getString(1),-1);
|
||||
}else {
|
||||
log.info("whereSql : " + whereSql);
|
||||
log.info("参数 : " + whereParams);
|
||||
}
|
||||
}
|
||||
if(mainId < 0){
|
||||
|
|
|
@ -4,11 +4,19 @@ import aiyh.utils.Util;
|
|||
import aiyh.utils.action.CusBaseAction; // 基础的action,实现一些基础的参数
|
||||
import aiyh.utils.annotation.RequiredMark;
|
||||
import aiyh.utils.excention.CustomerException; // 自定义异常类 create 2022/3/9 2:20 PM
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.request.RequestManager;
|
||||
import weaver.xuanran.wang.common.util.CommonUtil;
|
||||
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
|
||||
import weaver.xuanran.wang.schroeder.service.SchroederQRCodeService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* <h1>施罗德创建二维码action</h1>
|
||||
|
@ -30,25 +38,53 @@ public class PushSealTaskAction extends CusBaseAction { // 基础的action,
|
|||
@RequiredMark
|
||||
private String QRCodeField;
|
||||
|
||||
/**
|
||||
* <h2>用印文件字段 会将这个字段所有的值存到用印文件记录表中</h2>
|
||||
**/
|
||||
@RequiredMark
|
||||
private String fileField;
|
||||
|
||||
/**
|
||||
* <h2>文档记录表模块id</h2>
|
||||
**/
|
||||
@RequiredMark
|
||||
private String modelId;
|
||||
|
||||
private final SchroederQRCodeService schroederQRCodeService = new SchroederQRCodeService(); // 施罗德业务方法 施罗德业务方法
|
||||
|
||||
|
||||
|
||||
@Override // action 提交流程业务处理方法 具体业务逻辑实现
|
||||
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestManager requestManager) {
|
||||
log.info("---------- PushSealTaskSealValue Begin " + requestId + "----------");
|
||||
RequestInfo requestInfo = requestInfoThreadLocal.get();
|
||||
String scanNum = schroederQRCodeService.pushSealTask(onlyMark, billTable, requestId); // 推送数据创建任务 建模配置唯一标识
|
||||
RecordSetTrans trans = requestManager.getRsTrans();
|
||||
trans.setAutoCommit(false);
|
||||
String updateSql = "update " + billTable + " set " + QRCodeField + " = ? where requestid = ?"; // 二维码来源字段
|
||||
try{
|
||||
if(!trans.executeUpdate(updateSql, scanNum, requestId)){
|
||||
throw new CustomerException(Util.logStr("更新表单sql执行失败!sql : {}, 参数 scanNum : {}, requestId : {}", scanNum, requestId)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||
throw new CustomerException(Util.logStr("更新表单sql执行失败!sql : {}, 参数 scanNum : {}, requestId : {}", scanNum, requestId)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||
}
|
||||
// 获取明细表数据
|
||||
List<Map<String, String>> detailList = getDetailTableValueByDetailNo(1, requestInfo);
|
||||
List<String> docIds = detailList.stream()
|
||||
.map(item -> Util.null2DefaultStr(item.get(fileField), ""))
|
||||
.filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||
ArrayList<LinkedHashMap<String, Object>> list = new ArrayList<>();
|
||||
for (String docId : docIds) {
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("docId", docId);
|
||||
map.put("enable", 0);
|
||||
list.add(map);
|
||||
}
|
||||
// 将数据写入建模
|
||||
CusInfoToOAUtil.executeBatch(Util.getIntValue(modelId, -1), list, "select 1 from #{tableName} where docId = ?", docIds);
|
||||
}catch (Exception e){
|
||||
trans.rollback();
|
||||
throw new CustomerException(Util.logStr("执行提交方法异常:{}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||
}
|
||||
trans.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ public class PushSealTaskSealValue implements CusInterfaceGetValue { // 自定
|
|||
|
||||
@Override // 获取参数值
|
||||
public Object execute(Map<String, Object> mainMap, Map<String, Object> detailMap, String currentValue, Map<String, String> pathParam) {
|
||||
logger.info(Util.logStr("路径参数:[{}]", JSONObject.toJSONString(pathParam))); // 构建日志字符串
|
||||
logger.info(Util.logStr("路径参数:[{}]", JSONObject.toJSONString(pathParam)));
|
||||
logger.info("路径参数(字符串拼接) : " + JSONObject.toJSONString(pathParam));// 构建日志字符串
|
||||
// 接口字段
|
||||
String sealSnField = pathParam.get("sealSnField");
|
||||
String sealNumField = pathParam.get("sealNumField");
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package weaver.xuanran.wang.schroeder.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>施罗德查询方法</h1>
|
||||
*
|
||||
* @Author xuanran.wang
|
||||
* @Date 2022/12/13 13:05
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface SchroederMapper {
|
||||
|
||||
/**
|
||||
* <h1>查询明细一数据集</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/13 13:10
|
||||
* @param tableName 表名
|
||||
* @param mainId 主表id
|
||||
* @return 明细表数据集合
|
||||
**/
|
||||
@Select("select yywj,qfzzl,qfzcs from $t{tableName} where mainid = #{mainId} and sfjgqfz = 0")
|
||||
List<Map<String, Object>> selectSealTaskInfoList(@ParamMapper("tableName") String tableName,
|
||||
@ParamMapper("mainId") String mainId);
|
||||
|
||||
/**
|
||||
* <h1>查询明细一用印文件docId/h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/13 13:10
|
||||
* @param fileField 用印文件字段
|
||||
* @param tableName 表名
|
||||
* @param mainId 主表id
|
||||
* @return 明细表数据集合
|
||||
**/
|
||||
@Select("select $t{fileField} from $t{tableName} where mainid = #{mainId}")
|
||||
List<Map<String, Object>> selectSealFileList(@ParamMapper("fileField") String fileField,
|
||||
@ParamMapper("tableName") String tableName,
|
||||
@ParamMapper("mainId") String mainId);
|
||||
|
||||
}
|
|
@ -8,16 +8,27 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.google.zxing.qrcode.encoder.QRCode;
|
||||
import com.icbc.api.internal.apache.http.M;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.mobile.plugin.ecology.QRCodeComInfo;
|
||||
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||
import weaver.xuanran.wang.schroeder.mapper.SchroederMapper;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <h1>施罗德业务方法</h1>
|
||||
|
@ -49,6 +60,7 @@ public class SchroederQRCodeService {
|
|||
{
|
||||
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
|
||||
}
|
||||
private final SchroederMapper schroederMapper = Util.getMapper(SchroederMapper.class);
|
||||
|
||||
/**
|
||||
* <h1>推送数据创建任务</h1>
|
||||
|
@ -72,7 +84,10 @@ public class SchroederQRCodeService {
|
|||
recordSet.executeQuery(selectMainSql, requestId);
|
||||
if (recordSet.next()) {
|
||||
dealWithMapping.setMainTable(billTable);
|
||||
Map<String, Object> requestParam = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); // 解析请求参数配置树,转换成请求参数
|
||||
Map<String, Object> requestParam = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
|
||||
// 如果明细数据存在骑缝章时候增加一行数据进去
|
||||
changeRequestMap(requestParam, billTable + "_dt1", recordSet.getString("id"));
|
||||
// 解析请求参数配置树,转换成请求参数
|
||||
log.info(Util.logStr("请求json : {}", JSONObject.toJSONString(requestParam))); // 构建日志字符串
|
||||
String url = requestMappingConfig.getRequestUrl();
|
||||
ResponeVo responeVo = null;
|
||||
|
@ -111,6 +126,47 @@ public class SchroederQRCodeService {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>骑缝章修改请求参数</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2022/12/13 14:15
|
||||
* @param requestParam 请求参数
|
||||
* @param billTable 表名
|
||||
* @param mainId 主表id
|
||||
**/
|
||||
public void changeRequestMap(Map<String, Object> requestParam, String billTable, String mainId){
|
||||
List<Map<String, Object>> files = (List<Map<String, Object>>) requestParam.get("file");
|
||||
List<Map<String, Object>> detail1List = schroederMapper.selectSealTaskInfoList(billTable, mainId);
|
||||
if(CollectionUtils.isEmpty(detail1List) || CollectionUtils.isEmpty(files)){
|
||||
return;
|
||||
}
|
||||
// 遍历明细数据
|
||||
for (Map<String, Object> detailItem : detail1List) {
|
||||
// 用印文件
|
||||
String sealFile = Util.null2String(detailItem.get("yywj"));
|
||||
// 从生成的请求参数map中开始匹配
|
||||
List<Map<String, Object>> filterFiles = files.stream()
|
||||
.filter(item -> {
|
||||
String filePath = Util.null2DefaultStr(item.get("filePath"), "");
|
||||
String docId = Util.null2DefaultStr(filePath.substring(filePath.lastIndexOf("=") + 1),"");
|
||||
return sealFile.equals(docId);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(filterFiles)){
|
||||
// 只有一个能匹配
|
||||
Map<String, Object> o = filterFiles.get(0);
|
||||
HashMap<String, Object> tempMap = o.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a, HashMap::new));
|
||||
// 印章集合
|
||||
HashMap<String, Object> seal = new HashMap<>();
|
||||
seal.put("sealSn",Util.null2DefaultStr(detailItem.get("qfzzl"),""));
|
||||
seal.put("sealNum",Util.null2DefaultStr(detailItem.get("qfzcs"),"0"));
|
||||
tempMap.put("seal", seal);
|
||||
files.add(tempMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: aiyh.utils.Util
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
userName = SID_ECOLOGY
|
||||
password = BDw5FzWQ@
|
||||
server = ldap://LDAP_ASIA.Aptiv.com:389
|
||||
driver = com.sun.jndi.ldap.LdapCtxFactory
|
||||
authentication = simple
|
||||
searchBase=CN=Users,DC=aptiv,DC=com
|
||||
queryField=uid
|
|
@ -0,0 +1,27 @@
|
|||
package xuanran.wang.ambofo.checkuser;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import basetest.BaseTest;
|
||||
import com.api.xuanran.wang.ambofo.checkuser.service.CheckUserService;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* <h1>安波福校验用户测试类</h1>
|
||||
*
|
||||
* @Author xuanran.wang
|
||||
* @Date 2022/12/12 15:35
|
||||
*/
|
||||
public class CheckUserTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testProperties(){
|
||||
try{
|
||||
CheckUserService checkUserService = new CheckUserService();
|
||||
checkUserService.logAllUser();
|
||||
}catch (Exception e){
|
||||
String error = Util.logStr("AD查询接口发生异常:{}", e.getMessage());
|
||||
log.error(error);
|
||||
log.error(Util.getErrString(e));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,10 @@ import basetest.BaseTest;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.xuanran.wang.schroeder.download_file.mapper.DownLoadFileMapper;
|
||||
import com.icbc.api.internal.apache.http.impl.cookie.S;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.xuanran.wang.common.util.CommonUtil;
|
||||
|
@ -56,7 +58,6 @@ public class DownLoadFileTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void testParseStr(){
|
||||
|
||||
String str = "<Field name=\"apb02\" value=\"#{main.jdskadas}\"/>";
|
||||
String pattern = "(?<=\\{).+(?=})";
|
||||
Pattern compile = Pattern.compile(pattern);
|
||||
|
@ -75,4 +76,82 @@ public class DownLoadFileTest extends BaseTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddItem(){
|
||||
String json = "{\"requestId\":\"189567\",\"super\":\"luchenghong\",\"orgNo\":\"junhe\",\"title\":\"鲁诚鸿\",\"sealPlace\":\"2\",\"useSealType\":\"1\",\"userPassword\":\"672518\",\"useSealEquipment\":\"2\",\"file\":[{\"fileName\":\"拜访函(景德镇).docx\",\"filePath\":\"http://oa.junheland.com/hyu/seal.download?docId=12\",\"waterAndSeal\":\"2\",\"crosssealType\":\"2\",\"printCount\":\"1\",\"printType\":\"0\",\"seal\":[{\"sealType\":\"124\",\"sealNum\":\"1\"}]},{\"fileName\":\"附件6-变更签证办理协议.pdf\",\"filePath\":\"http://erp.junheland.com:9070/view?docId=13\",\"waterAndSeal\":\"2\",\"crosssealType\":\"1\",\"printCount\":\"6\",\"printType\":\"1\",\"seal\":[{\"sealType\":\"164\",\"sealNum\":\"6\"}]}]}";
|
||||
Map<String, Object> requestParam = JSONObject.parseObject(json, Map.class);
|
||||
log.info("requestParam " + requestParam);
|
||||
ArrayList<Map<String, Object>> detail1List = new ArrayList<>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
// yywj,qfzzl,qfzcs
|
||||
map.put("yywj","12");
|
||||
map.put("qfzzl","2");
|
||||
map.put("qfzcs","3");
|
||||
detail1List.add(map);
|
||||
// 过滤出集合类型的参数
|
||||
List<Map<String, Object>> files = (List<Map<String, Object>>) requestParam.get("file");
|
||||
if(CollectionUtils.isNotEmpty(files)){
|
||||
// 加盖骑缝章的明细数据
|
||||
if(CollectionUtils.isNotEmpty(detail1List)){
|
||||
// 遍历明细数据
|
||||
for (Map<String, Object> detailItem : detail1List) {
|
||||
// 用印文件
|
||||
String sealFile = Util.null2String(detailItem.get("yywj"));
|
||||
log.info("sealFile : " + sealFile);
|
||||
// 从生成的请求参数map中开始匹配
|
||||
List<Map<String, Object>> filterFiles = files.stream()
|
||||
.filter(item -> {
|
||||
String filePath = Util.null2DefaultStr(item.get("filePath"), "");
|
||||
String docId = Util.null2DefaultStr(filePath.substring(filePath.lastIndexOf("=") + 1),"");
|
||||
log.info("filePath : " + filePath + " , docId : " + docId);
|
||||
return sealFile.equals(docId);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
log.info("filterFiles " + JSONObject.toJSONString(filterFiles));
|
||||
if(CollectionUtils.isNotEmpty(filterFiles)){
|
||||
// 只有一个能匹配
|
||||
Map<String, Object> o = filterFiles.get(0);
|
||||
HashMap<String, Object> tempMap = o.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a, HashMap::new));
|
||||
// 印章集合
|
||||
HashMap<String, Object> seal = new HashMap<>();
|
||||
seal.put("sealSn",Util.null2DefaultStr(detailItem.get("qfzzl"),""));
|
||||
seal.put("sealNum",Util.null2DefaultStr(detailItem.get("qfzcs"),"0"));
|
||||
tempMap.put("seal", seal);
|
||||
log.info("tempMap " + tempMap);
|
||||
files.add(tempMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("requestParam : " + JSONObject.toJSONString(requestParam) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse(){
|
||||
String paramStr = "weaver.xuanran.wang.schroeder.cus_field_value.PushSealTaskSealValue?sealSnField=sealSn&sealNumField=sealNum&sealSnCusSql=`select\n" +
|
||||
" ? from jkfdjsfk where id\n" +
|
||||
" =1`&sealNumCusSql=`select case ? when 0 then htzyzcs when 1 then gzcs else frzcs end from formtable_main_22_dt1 where id = {?dt.id}`&hah=liuliu&cus=`select? * fr$%&#@!)(<>?/\\{}「」【【】[]~、asfom table where id = '' and teset = #{name}`&niua=卧槽";
|
||||
|
||||
String pattern = "&?(?<key>([#.\\w\\u4E00-\\u9FA5]+))=" +
|
||||
"(?<value>((`([^`]*)`)|" +
|
||||
"((#(\\{|sql\\{))?([():/\\-$#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?";
|
||||
Pattern compile = Pattern.compile(pattern);
|
||||
Matcher matcher = compile.matcher(paramStr);
|
||||
HashMap<String, Object> pathParamMap = new HashMap<>();
|
||||
while (matcher.find()) {
|
||||
String key = matcher.group("key");
|
||||
String paramValue = matcher.group("value");
|
||||
if (paramValue != null && paramValue.startsWith("`") && paramValue.endsWith("`")) {
|
||||
paramValue = paramValue.substring(1, paramValue.length() - 1);
|
||||
}
|
||||
pathParamMap.put(key, paramValue);
|
||||
}
|
||||
log.info("pathParamMap : " + JSONObject.toJSONString(pathParamMap));
|
||||
|
||||
String text ="123456";
|
||||
String replacement = "two$two";
|
||||
String resultString = text.replaceAll("2", replacement);
|
||||
log.info("resultString " + resultString);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue