2023-01-12 施罗德代码测试提交与mq部分代码
parent
4bbe6a2df8
commit
557afeaa25
|
@ -32,23 +32,8 @@ public class CheckUserController {
|
||||||
String checkContent = request.getParameter("checkContent");
|
String checkContent = request.getParameter("checkContent");
|
||||||
try {
|
try {
|
||||||
CheckUserService checkUserService = new CheckUserService();
|
CheckUserService checkUserService = new CheckUserService();
|
||||||
return ApiResult.success(checkUserService.checkADHasUser(checkContent),"ok");
|
boolean has = checkUserService.checkADHasUser(checkContent);
|
||||||
}catch (Exception e){
|
return ApiResult.success(has,"ok");
|
||||||
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){
|
}catch (Exception e){
|
||||||
String error = Util.logStr("AD查询接口发生异常:{}", e.getMessage());
|
String error = Util.logStr("AD查询接口发生异常:{}", e.getMessage());
|
||||||
log.error(error);
|
log.error(error);
|
||||||
|
|
|
@ -65,7 +65,8 @@ public class CheckUserService {
|
||||||
// 根据设置的域节点、过滤器类和搜索控制器搜索LDAP得到结果
|
// 根据设置的域节点、过滤器类和搜索控制器搜索LDAP得到结果
|
||||||
NamingEnumeration answer = ldapContext.search(searchBase, searchFilter, searchControl);
|
NamingEnumeration answer = ldapContext.search(searchBase, searchFilter, searchControl);
|
||||||
boolean has = answer.hasMoreElements();
|
boolean has = answer.hasMoreElements();
|
||||||
while (answer.hasMoreElements()) {
|
log.info("has " + has);
|
||||||
|
if(has){
|
||||||
SearchResult sr = (SearchResult) answer.next();
|
SearchResult sr = (SearchResult) answer.next();
|
||||||
String dn = sr.getName();
|
String dn = sr.getName();
|
||||||
log.info("dn " + dn);
|
log.info("dn " + dn);
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package com.api.xuanran.wang.schroeder.download_file.controller;
|
package com.api.xuanran.wang.schroeder.download_file.controller;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.api.xuanran.wang.schroeder.download_file.service.DownLoadFileService;
|
import com.api.xuanran.wang.schroeder.download_file.service.DownLoadFileService;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.docs.docs.DocInfo;
|
||||||
import weaver.file.ImageFileManager;
|
import weaver.file.ImageFileManager;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -43,6 +47,9 @@ public class DownLoadFileController {
|
||||||
Map<String, Object> fileInfo = downLoadFileService.getFileInfo(docId);
|
Map<String, Object> fileInfo = downLoadFileService.getFileInfo(docId);
|
||||||
String fileName = Util.null2String(fileInfo.get("fileName"));
|
String fileName = Util.null2String(fileInfo.get("fileName"));
|
||||||
int imageFileId = Util.getIntValue(Util.null2DefaultStr(fileInfo.get("imageFileId"),""), -1);
|
int imageFileId = Util.getIntValue(Util.null2DefaultStr(fileInfo.get("imageFileId"),""), -1);
|
||||||
|
if(StringUtils.isBlank(fileName) || imageFileId < 0){
|
||||||
|
throw new CustomerException(Util.logStr("文件信息部分字段查询为空!当前查询结果map:[{}]", JSONObject.toJSONString(fileInfo)));
|
||||||
|
}
|
||||||
InputStream is = ImageFileManager.getInputStreamById(imageFileId);
|
InputStream is = ImageFileManager.getInputStreamById(imageFileId);
|
||||||
byte[] bytes = IOUtils.toByteArray(is);
|
byte[] bytes = IOUtils.toByteArray(is);
|
||||||
StreamingOutput output = outputStream ->{
|
StreamingOutput output = outputStream ->{
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.api.xuanran.wang.schroeder.download_file.mapper;
|
|
||||||
|
|
||||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
|
||||||
import aiyh.utils.annotation.recordset.Select;
|
|
||||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h1>文件下载mapper</h1>
|
|
||||||
*
|
|
||||||
* @Author xuanran.wang
|
|
||||||
* @Date 2022/12/7 10:58
|
|
||||||
*/
|
|
||||||
@SqlMapper
|
|
||||||
public interface DownLoadFileMapper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h1>根据docId查询附件信息</h1>
|
|
||||||
* @author xuanran.wang
|
|
||||||
* @dateTime 2022/12/7 11:01
|
|
||||||
* @param docId docId
|
|
||||||
* @return 文件imageField以及文件名
|
|
||||||
**/
|
|
||||||
@Select("select t3.imagefileid imageFileId,t3.imagefilename fileName,t3.filerealpath filePath " +
|
|
||||||
"from DocDetail t1 " +
|
|
||||||
"left join DocImageFile t2 " +
|
|
||||||
"on t2.docid = t1.id " +
|
|
||||||
"left join ImageFile t3 " +
|
|
||||||
"on t3.imagefileid = t2.imagefileid " +
|
|
||||||
"where t1.id = #{docId}")
|
|
||||||
Map<String, Object> selectDocInfoByDocId(@ParamMapper("docId") String docId);
|
|
||||||
}
|
|
|
@ -2,11 +2,11 @@ package com.api.xuanran.wang.schroeder.download_file.service;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.api.xuanran.wang.schroeder.download_file.mapper.DownLoadFileMapper;
|
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,6 @@ public class DownLoadFileService {
|
||||||
* <h2>查询文件记录sql</h2>
|
* <h2>查询文件记录sql</h2>
|
||||||
**/
|
**/
|
||||||
private static final String SELECT_DOC_LOG_SQL = "select 1 from " + DOC_LOG_TABLE_NAME + " where docId = ? and enable = 0";
|
private static final String SELECT_DOC_LOG_SQL = "select 1 from " + DOC_LOG_TABLE_NAME + " where docId = ? and enable = 0";
|
||||||
private final DownLoadFileMapper downLoadFileMapper = Util.getMapper(DownLoadFileMapper.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>根据docId获取文件信息</h1>
|
* <h1>根据docId获取文件信息</h1>
|
||||||
|
@ -33,23 +32,29 @@ public class DownLoadFileService {
|
||||||
* @param docId docId
|
* @param docId docId
|
||||||
**/
|
**/
|
||||||
public Map<String, Object> getFileInfo(String docId) {
|
public Map<String, Object> getFileInfo(String docId) {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
if(StringUtils.isBlank(docId)) {
|
if(StringUtils.isBlank(docId)) {
|
||||||
throw new CustomerException(Util.logStr("下载文件失败, 请求路径中不包含指定的docId!当前请求docId:{}", docId));
|
throw new CustomerException(Util.logStr("下载文件失败, 请求路径中不包含指定的docId!当前请求docId:{}", docId));
|
||||||
}
|
}
|
||||||
RecordSet rs = new RecordSet();
|
|
||||||
if (!rs.executeQuery(SELECT_DOC_LOG_SQL, docId) || !rs.next()) {
|
if (!rs.executeQuery(SELECT_DOC_LOG_SQL, docId) || !rs.next()) {
|
||||||
throw new CustomerException("下载文件失败, 请确认文件记录表中是否存在docId = [ " + docId + " ]的文件!");
|
throw new CustomerException("下载文件失败, 请确认文件记录表中是否存在docId = [ " + docId + " ]的文件!");
|
||||||
}
|
}
|
||||||
Map<String, Object> fileInfoMap = downLoadFileMapper.selectDocInfoByDocId(docId);
|
String sql = " select t3.imagefileid imageFileId,t3.imagefilename fileName " +
|
||||||
if(MapUtils.isEmpty(fileInfoMap)){
|
" from DocDetail t1 " +
|
||||||
throw new CustomerException("执行查询文件信息sql失败!");
|
" left join DocImageFile t2 " +
|
||||||
|
" on t2.docid = t1.id " +
|
||||||
|
" left join ImageFile t3 " +
|
||||||
|
" on t3.imagefileid = t2.imagefileid " +
|
||||||
|
" where t1.id = ?";
|
||||||
|
HashMap<String, Object> res = new HashMap<>();
|
||||||
|
if (rs.executeQuery(sql, docId) && rs.next()) {
|
||||||
|
res.put("imageFileId", rs.getString("imageFileId"));
|
||||||
|
res.put("fileName", rs.getString("fileName"));
|
||||||
}
|
}
|
||||||
String fileName = Util.null2DefaultStr(fileInfoMap.get("fileName"),"");
|
if(MapUtils.isEmpty(res)){
|
||||||
int imageFileId = Util.getIntValue(Util.null2DefaultStr(fileInfoMap.get("imageFileId"),""), -1);
|
throw new CustomerException(Util.logStr("执行查询文件信息sql失败! 当前sql : {}", sql));
|
||||||
if(StringUtils.isBlank(fileName) ||imageFileId < 0){
|
|
||||||
throw new CustomerException(Util.logStr("文件信息部分字段查询为空!当前查询结果map:[{}]", JSONObject.toJSONString(fileInfoMap)));
|
|
||||||
}
|
}
|
||||||
return fileInfoMap;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import org.apache.log4j.Logger;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
import weaver.formmode.data.ModeDataApproval;
|
import weaver.formmode.data.ModeDataApproval;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||||
|
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||||
import weaver.xuanran.wang.common.annocation.CusDateFormat;
|
import weaver.xuanran.wang.common.annocation.CusDateFormat;
|
||||||
import weaver.xuanran.wang.common.annocation.ParamNotNull;
|
import weaver.xuanran.wang.common.annocation.ParamNotNull;
|
||||||
import weaver.xuanran.wang.common.mapper.CommonMapper;
|
import weaver.xuanran.wang.common.mapper.CommonMapper;
|
||||||
|
@ -594,6 +596,22 @@ public class CommonUtil {
|
||||||
return commonMapper.getModelNameByModelId(String.valueOf(modelId));
|
return commonMapper.getModelNameByModelId(String.valueOf(modelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>将建模配置表中的自定义数据条件进行拼接</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/1/4 15:10
|
||||||
|
* @param requestMappingConfig 建模配置对象
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return 添加建模配置表自定义数据条件只会的sql
|
||||||
|
**/
|
||||||
|
public static String getSelectSql( RequestMappingConfig requestMappingConfig, String tableName){
|
||||||
|
String cusWhere = Util.null2DefaultStr(requestMappingConfig.getCusWhereSql(), "");
|
||||||
|
if (StringUtils.isNotBlank(cusWhere)) {
|
||||||
|
cusWhere = " and " + DealWithMapping.sbc2dbcCase(cusWhere); // 全角转半角
|
||||||
|
}
|
||||||
|
return "select * from " + tableName + " where requestid = ? " + cusWhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import aiyh.utils.Util;
|
||||||
import aiyh.utils.action.SafeCusBaseAction;
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
import aiyh.utils.annotation.RequiredMark;
|
import aiyh.utils.annotation.RequiredMark;
|
||||||
import aiyh.utils.excention.CustomerException; // 自定义异常类 create 2022/3/9 2:20 PM
|
import aiyh.utils.excention.CustomerException; // 自定义异常类 create 2022/3/9 2:20 PM
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.JSONPObject;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
import weaver.conn.RecordSetTrans;
|
import weaver.conn.RecordSetTrans;
|
||||||
|
@ -119,20 +121,18 @@ public class PushSealTaskAction extends SafeCusBaseAction { // 基础的action
|
||||||
delSql = "delete from " + detailTable + " where mainid = ? ";
|
delSql = "delete from " + detailTable + " where mainid = ? ";
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
// 获取明细表数据
|
List<String> detailFileId = schroederQRCodeService.getDetailFileId(fileField, detailTable, mainId);
|
||||||
List<Map<String, String>> detailList = schroederQRCodeService.getDetailList(detailTable, mainId);
|
log.info(Util.logStr("明细docId集合 : {}", JSONObject.toJSONString(detailFileId)));
|
||||||
List<String> docIds = detailList.stream()
|
|
||||||
.map(item -> Util.null2DefaultStr(item.get(fileField), ""))
|
|
||||||
.filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
|
||||||
List<LinkedHashMap<String, Object>> docLogParamList = new ArrayList<>();
|
List<LinkedHashMap<String, Object>> docLogParamList = new ArrayList<>();
|
||||||
for (String docId : docIds) {
|
for (String docId : detailFileId) {
|
||||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||||
map.put("docId", docId);
|
map.put("docId", docId);
|
||||||
map.put("enable", 0);
|
map.put("enable", 0);
|
||||||
docLogParamList.add(map);
|
docLogParamList.add(map);
|
||||||
}
|
}
|
||||||
|
log.info(Util.logStr("docLogParamList集合 : {}", JSONObject.toJSONString(docLogParamList)));
|
||||||
// 将docLog数据写入建模
|
// 将docLog数据写入建模
|
||||||
docLogModelIdList = CusInfoToOAUtil.executeBatch(Util.getIntValue(docLogModelId, -1), docLogParamList, "select id from #{tableName} where docId = ?", docIds);
|
docLogModelIdList = CusInfoToOAUtil.executeBatch(Util.getIntValue(docLogModelId, -1), docLogParamList);
|
||||||
// requestLog写入建模
|
// requestLog写入建模
|
||||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||||
int count = schroederQRCodeService.getTaskIdByRequestId(requestId);
|
int count = schroederQRCodeService.getTaskIdByRequestId(requestId);
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package weaver.xuanran.wang.schroeder.action;
|
package weaver.xuanran.wang.schroeder.action;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.action.SafeCusBaseAction;
|
import weaver.interfaces.workflow.action.Action;
|
||||||
import aiyh.utils.annotation.RequiredMark;
|
|
||||||
import aiyh.utils.excention.CustomerException;
|
|
||||||
import weaver.hrm.User;
|
|
||||||
import weaver.soa.workflow.request.RequestInfo;
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
import weaver.xuanran.wang.schroeder.service.SchroederQRCodeService;
|
import weaver.xuanran.wang.schroeder.service.SchroederQRCodeService;
|
||||||
|
|
||||||
|
@ -14,32 +11,35 @@ import weaver.xuanran.wang.schroeder.service.SchroederQRCodeService;
|
||||||
* @Author xuanran.wang
|
* @Author xuanran.wang
|
||||||
* @Date 2022/12/23 10:49
|
* @Date 2022/12/23 10:49
|
||||||
*/
|
*/
|
||||||
public class SalesforceEndpointAction extends SafeCusBaseAction {
|
public class SalesforceEndpointAction implements Action {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>建模配置唯一标识</h2>
|
* <h2>建模配置唯一标识</h2>
|
||||||
**/
|
**/
|
||||||
@RequiredMark
|
|
||||||
private String onlyMark;
|
private String onlyMark;
|
||||||
/**
|
/**
|
||||||
* <h2>响应成功状态码</h2>
|
* <h2>响应成功状态码</h2>
|
||||||
**/
|
**/
|
||||||
@RequiredMark
|
|
||||||
private String successCode;
|
private String successCode;
|
||||||
/**
|
/**
|
||||||
* <h2>请求方式</h2>
|
* <h2>请求方式</h2>
|
||||||
**/
|
**/
|
||||||
@RequiredMark
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
private final SchroederQRCodeService schroederQRCodeService = new SchroederQRCodeService();
|
private final SchroederQRCodeService schroederQRCodeService = new SchroederQRCodeService();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
public String execute(RequestInfo requestInfo) {
|
||||||
try {
|
try {
|
||||||
|
String billTable = requestInfo.getRequestManager().getBillTableName();
|
||||||
|
String requestId = requestInfo.getRequestid();
|
||||||
schroederQRCodeService.pushSealTask(onlyMark, billTable, requestId,type, successCode,"","");
|
schroederQRCodeService.pushSealTask(onlyMark, billTable, requestId,type, successCode,"","");
|
||||||
|
return Action.SUCCESS;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
throw new CustomerException(Util.logStr("执行提交方法异常:{}", e.getMessage())); //
|
requestInfo.getRequestManager().setMessageid(String.valueOf(System.currentTimeMillis()));
|
||||||
|
requestInfo.getRequestManager().setMessagecontent(Util.logStr("执行提交方法异常:{}", e.getMessage()));
|
||||||
|
return Action.FAILURE_AND_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,12 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.conn.ConnStatementDataSource;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue; // 自定义获取参数值
|
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue; // 自定义获取参数值
|
||||||
import weaver.zwl.common.ToolUtil; // 常用工具方法-公用类
|
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1></h1>
|
* <h1></h1>
|
||||||
|
@ -20,7 +20,6 @@ import java.util.stream.Collectors;
|
||||||
* @Date 2022/12/2 16:10
|
* @Date 2022/12/2 16:10
|
||||||
*/
|
*/
|
||||||
public class PushSealTaskSealValue implements CusInterfaceGetValue { // 自定义获取参数值
|
public class PushSealTaskSealValue implements CusInterfaceGetValue { // 自定义获取参数值
|
||||||
private final ToolUtil toolUtil = new ToolUtil(); // 常用工具方法-公用类 构造方法
|
|
||||||
|
|
||||||
private final Logger logger = Util.getLogger(); // 获取日志对象
|
private final Logger logger = Util.getLogger(); // 获取日志对象
|
||||||
|
|
||||||
|
@ -46,11 +45,19 @@ public class PushSealTaskSealValue implements CusInterfaceGetValue { // 自定
|
||||||
int detailId = -1;
|
int detailId = -1;
|
||||||
if(MapUtils.isNotEmpty(detailMap)){
|
if(MapUtils.isNotEmpty(detailMap)){
|
||||||
detailId = Util.getIntValue(String.valueOf(detailMap.get("id")), -1);
|
detailId = Util.getIntValue(String.valueOf(detailMap.get("id")), -1);
|
||||||
|
if(detailId < 0){
|
||||||
|
detailId = Util.getIntValue(String.valueOf(detailMap.get("ID")), -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
String requestId = String.valueOf(mainMap.get("requestid"));
|
||||||
|
if(StringUtils.isBlank(requestId)){
|
||||||
|
requestId = String.valueOf(mainMap.get("REQUESTID"));
|
||||||
|
}
|
||||||
|
logger.info(Util.logStr("requestId : {}, detailId : {}", requestId, detailId));
|
||||||
for (String val : currentValue.split(",")) {
|
for (String val : currentValue.split(",")) {
|
||||||
// 印章类型转换执行自定义sql
|
// 印章类型转换执行自定义sql
|
||||||
String inSealVal = Util.null2DefaultStr(toolUtil.getValueByChangeRule(sealSnCusSql, val, String.valueOf(mainMap.get("requestid")), detailId),""); // 用数据库值,根据规则转换,获取其最终结果
|
String inSealVal = Util.null2DefaultStr(getValueByChangeRule(sealSnCusSql, val, requestId, detailId,""),""); // 用数据库值,根据规则转换,获取其最终结果
|
||||||
String inSealNumVal = Util.null2DefaultStr(toolUtil.getValueByChangeRule(sealNumCusSql, val, String.valueOf(mainMap.get("requestid")), detailId),""); // 用数据库值,根据规则转换,获取其最终结果
|
String inSealNumVal = Util.null2DefaultStr(getValueByChangeRule(sealNumCusSql, val, requestId, detailId,""),""); // 用数据库值,根据规则转换,获取其最终结果
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put(sealSnField, inSealVal);
|
map.put(sealSnField, inSealVal);
|
||||||
map.put(sealNumField, inSealNumVal);
|
map.put(sealNumField, inSealNumVal);
|
||||||
|
@ -59,6 +66,85 @@ public class PushSealTaskSealValue implements CusInterfaceGetValue { // 自定
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用数据库值,根据规则转换,获取其最终结果
|
||||||
|
* @param cus_sql 自定义转换的SQL
|
||||||
|
* @param value 参数值
|
||||||
|
* @param requestid 流程请求ID
|
||||||
|
* @param detailKeyvalue 明细表主键值
|
||||||
|
* @pram datasourceid 外部数据源ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getValueByChangeRule(String cus_sql,String value,String requestid,int detailKeyvalue,String datasourceid){
|
||||||
|
String endValue = "";
|
||||||
|
|
||||||
|
cus_sql = cus_sql.replace(" ", " ");
|
||||||
|
|
||||||
|
cus_sql = cus_sql.replace("{?dt.id}", String.valueOf(detailKeyvalue));
|
||||||
|
|
||||||
|
//参数进行替换
|
||||||
|
String sqlString = cus_sql.replace("{?requestid}", requestid);
|
||||||
|
|
||||||
|
sqlString = sqlString.replace("?", value);
|
||||||
|
|
||||||
|
sqlString = ToDBC(sqlString);
|
||||||
|
logger.info(Util.logStr("查询sql : {} ", sqlString));
|
||||||
|
try {
|
||||||
|
if(datasourceid != null && !"".equals(datasourceid)){
|
||||||
|
ConnStatementDataSource csds = new ConnStatementDataSource(datasourceid);
|
||||||
|
|
||||||
|
csds.setStatementSql(sqlString);
|
||||||
|
|
||||||
|
csds.executeQuery();
|
||||||
|
|
||||||
|
if(csds.next()){
|
||||||
|
endValue = weaver.general.Util.null2String(csds.getString(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
csds.close();
|
||||||
|
}else{
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
if(rs.executeQuery(sqlString)){
|
||||||
|
if (rs.next()) {
|
||||||
|
endValue = weaver.general.Util.null2String(rs.getString(1));
|
||||||
|
logger.info(Util.logStr("执行自定义sql 返回结果 : {}", endValue));
|
||||||
|
}else {
|
||||||
|
logger.error("当前查询没有查询结果!");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
logger.error("当前sql查询失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return endValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全角转半角
|
||||||
|
* @param input
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String ToDBC(String input) {
|
||||||
|
char c[] = input.toCharArray();
|
||||||
|
for (int i = 0; i < c.length; i++) {
|
||||||
|
if (c[i] == '\u3000') {
|
||||||
|
c[i] = ' ';
|
||||||
|
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||||
|
c[i] = (char) (c[i] - 65248);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String returnString = new String(c);
|
||||||
|
return returnString;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean checkBlank(String ... args){
|
public boolean checkBlank(String ... args){
|
||||||
return Arrays.stream(args).anyMatch(StringUtils::isBlank);
|
return Arrays.stream(args).anyMatch(StringUtils::isBlank);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,9 @@ public interface SchroederMapper {
|
||||||
* @return 明细表数据集合
|
* @return 明细表数据集合
|
||||||
**/
|
**/
|
||||||
@Select("select $t{fileField} from $t{tableName} where mainid = #{mainId}")
|
@Select("select $t{fileField} from $t{tableName} where mainid = #{mainId}")
|
||||||
List<Map<String, Object>> selectSealFileList(@ParamMapper("fileField") String fileField,
|
List<String> selectSealFileList(@ParamMapper("fileField") String fileField,
|
||||||
@ParamMapper("tableName") String tableName,
|
@ParamMapper("tableName") String tableName,
|
||||||
@ParamMapper("mainId") String mainId);
|
@ParamMapper("mainId") String mainId);
|
||||||
/**
|
/**
|
||||||
* <h1>得到任务Id</h1>
|
* <h1>得到任务Id</h1>
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
|
@ -56,6 +56,6 @@ public interface SchroederMapper {
|
||||||
Integer selectTaskId(@ParamMapper("cusRequestId") String cusRequestId);
|
Integer selectTaskId(@ParamMapper("cusRequestId") String cusRequestId);
|
||||||
|
|
||||||
@Select("select * from $t{tableName} where mainid = #{mainId}")
|
@Select("select * from $t{tableName} where mainid = #{mainId}")
|
||||||
List<Map<String, String>> detailList(@ParamMapper("tableName") String tableName,
|
List<Map<String, Object>> detailList(@ParamMapper("tableName") String tableName,
|
||||||
@ParamMapper("mainId") String mainId);
|
@ParamMapper("mainId") String mainId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import aiyh.utils.excention.CustomerException; // 自定义异常类 create 20
|
||||||
import aiyh.utils.httpUtil.ResponeVo;
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -188,22 +189,31 @@ public class SchroederQRCodeService {
|
||||||
**/
|
**/
|
||||||
public void changeRequestMap(Map<String, Object> requestParam, String billTable, String mainId, String filePeopleType) {
|
public void changeRequestMap(Map<String, Object> requestParam, String billTable, String mainId, String filePeopleType) {
|
||||||
List<Map<String, Object>> files = (List<Map<String, Object>>) requestParam.get("file");
|
List<Map<String, Object>> files = (List<Map<String, Object>>) requestParam.get("file");
|
||||||
List<Map<String, Object>> detail1List = schroederMapper.selectSealTaskInfoList(billTable, mainId);
|
if (CollectionUtils.isEmpty(files)) {
|
||||||
if (CollectionUtils.isEmpty(detail1List) || CollectionUtils.isEmpty(files)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 遍历明细数据
|
RecordSet detailRs = new RecordSet();
|
||||||
for (Map<String, Object> detailItem : detail1List) {
|
String sql = "select yywj,qfzzl,qfzcs from " + billTable + " where mainid = ? and sfjgqfz = 0";
|
||||||
|
if(!detailRs.executeQuery(sql, mainId)){
|
||||||
|
throw new CustomerException(Util.logStr("查询明细数据sql执行失败!sql : {}, mainId : {}", sql, mainId));
|
||||||
|
}
|
||||||
|
// 貌似有bug 把mapper改成原生recordSet
|
||||||
|
while (detailRs.next()) {
|
||||||
// 用印文件
|
// 用印文件
|
||||||
String sealFile = Util.null2String(detailItem.get("yywj"));
|
String sealFile = Util.null2String(detailRs.getString("yywj"));
|
||||||
|
if(StringUtils.isBlank(sealFile)){
|
||||||
|
sealFile = Util.null2String(detailRs.getString("YYWJ"));
|
||||||
|
}
|
||||||
// 从生成的请求参数map中开始匹配
|
// 从生成的请求参数map中开始匹配
|
||||||
|
String finalSealFile = sealFile;
|
||||||
List<Map<String, Object>> filterFiles = files.stream()
|
List<Map<String, Object>> filterFiles = files.stream()
|
||||||
.filter(item -> {
|
.filter(item -> {
|
||||||
String filePath = Util.null2DefaultStr(item.get("fileUrlPath"), "");
|
String filePath = Util.null2DefaultStr(item.get("fileUrlPath"), "");
|
||||||
String docId = Util.null2DefaultStr(filePath.substring(filePath.lastIndexOf("=") + 1), "");
|
String docId = Util.null2DefaultStr(filePath.substring(filePath.lastIndexOf("=") + 1), "");
|
||||||
return sealFile.equals(docId);
|
return finalSealFile.equals(docId);
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
log.info(Util.logStr("filterFiles : {} ", JSONObject.toJSONString(finalSealFile)));
|
||||||
if (CollectionUtils.isNotEmpty(filterFiles)) {
|
if (CollectionUtils.isNotEmpty(filterFiles)) {
|
||||||
// 只有一个能匹配
|
// 只有一个能匹配
|
||||||
Map<String, Object> o = filterFiles.get(0);
|
Map<String, Object> o = filterFiles.get(0);
|
||||||
|
@ -211,8 +221,19 @@ public class SchroederQRCodeService {
|
||||||
// 印章集合
|
// 印章集合
|
||||||
List<HashMap<String, Object>> sealList = new ArrayList<>();
|
List<HashMap<String, Object>> sealList = new ArrayList<>();
|
||||||
HashMap<String, Object> seal = new HashMap<>();
|
HashMap<String, Object> seal = new HashMap<>();
|
||||||
seal.put("sealSn", Util.null2DefaultStr(detailItem.get("qfzzl"), ""));
|
// 骑缝章总类
|
||||||
seal.put("sealNum", Util.null2DefaultStr(detailItem.get("qfzcs"), "0"));
|
String qfzzl = Util.null2DefaultStr(detailRs.getString("qfzzl"),"");
|
||||||
|
if(StringUtils.isBlank(qfzzl)){
|
||||||
|
qfzzl = Util.null2DefaultStr(detailRs.getString("QFZZL"),"");
|
||||||
|
}
|
||||||
|
log.info(Util.logStr("骑缝章总类 : {}", qfzzl));
|
||||||
|
seal.put("sealSn", qfzzl);
|
||||||
|
String qfzcs = Util.null2DefaultStr(detailRs.getString("qfzcs"),"");
|
||||||
|
if(StringUtils.isBlank(qfzcs)){
|
||||||
|
qfzcs = Util.null2DefaultStr(detailRs.getString("QFZCS"),"");
|
||||||
|
}
|
||||||
|
log.info(Util.logStr("骑缝章次数 : {}", qfzcs));
|
||||||
|
seal.put("sealNum", Util.null2DefaultStr(qfzcs, "0"));
|
||||||
sealList.add(seal);
|
sealList.add(seal);
|
||||||
tempMap.put("seal", sealList);
|
tempMap.put("seal", sealList);
|
||||||
tempMap.put("filePeopleType", filePeopleType);
|
tempMap.put("filePeopleType", filePeopleType);
|
||||||
|
@ -242,10 +263,25 @@ public class SchroederQRCodeService {
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
* @dateTime 2022/12/21 18:03
|
* @dateTime 2022/12/21 18:03
|
||||||
**/
|
**/
|
||||||
public List<Map<String, String>> getDetailList(String tableName, String mainId) {
|
public List<Map<String, Object>> getDetailList(String tableName, String mainId) {
|
||||||
return schroederMapper.detailList(tableName, mainId);
|
return schroederMapper.detailList(tableName, mainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>获取明细1文件数据id</h1>
|
||||||
|
*
|
||||||
|
* @param fileField 用印文件字段名
|
||||||
|
* @param tableName 明细表名
|
||||||
|
* @param mainId 主id
|
||||||
|
* @return 明细表数据
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2022/12/21 18:03
|
||||||
|
**/
|
||||||
|
public List<String> getDetailFileId(String fileField,String tableName, String mainId) {
|
||||||
|
return schroederMapper.selectSealFileList(fileField,tableName, mainId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>上海团校RocketMQListener</h1>
|
* <h1>上海团校RocketMQListener</h1>
|
||||||
|
@ -16,12 +15,12 @@ import java.util.Map;
|
||||||
* @Author xuanran.wang
|
* @Author xuanran.wang
|
||||||
* @Date 2022/12/29 12:25
|
* @Date 2022/12/29 12:25
|
||||||
*/
|
*/
|
||||||
public abstract class RocketMQListener extends HttpServlet {
|
public abstract class RocketMQConsumerListener extends HttpServlet {
|
||||||
private static final Logger log = Util.getLogger();
|
private static final Logger log = Util.getLogger();
|
||||||
private String configName;
|
private String configName;
|
||||||
public RocketMQListener() {
|
public RocketMQConsumerListener() {
|
||||||
}
|
}
|
||||||
public RocketMQListener(String configName) {
|
public RocketMQConsumerListener(String configName) {
|
||||||
this.configName = configName;
|
this.configName = configName;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
|
@ -4,6 +4,8 @@ import aiyh.utils.Util;
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
|
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
|
||||||
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
||||||
|
import org.apache.rocketmq.client.exception.MQClientException;
|
||||||
|
import org.apache.rocketmq.client.producer.DefaultMQProducer;
|
||||||
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
|
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
|
||||||
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
|
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
|
||||||
import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
|
import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
|
||||||
|
@ -11,6 +13,7 @@ import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>rocketMQ工厂</h1>
|
* <h1>rocketMQ工厂</h1>
|
||||||
|
@ -19,14 +22,28 @@ import java.util.Map;
|
||||||
* @Date 2022/12/29 14:21
|
* @Date 2022/12/29 14:21
|
||||||
*/
|
*/
|
||||||
public class RocketMQFactory {
|
public class RocketMQFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>配置文件本地存储对象</h2>
|
||||||
|
**/
|
||||||
public static Map<String, Map<String,Object>> CONFIG_MAPS = new HashMap<>(16);
|
public static Map<String, Map<String,Object>> CONFIG_MAPS = new HashMap<>(16);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>生产者map</h2>
|
||||||
|
**/
|
||||||
|
private static Map<String, DefaultMQProducer> PRODUCER_MAP = new ConcurrentHashMap<>(16);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>根据配置文件生成消费者对象</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/1/4 12:55
|
||||||
|
* @param configName 配置文件名称
|
||||||
|
* @param messageListenerConcurrently 消息监听处理业务方法
|
||||||
|
* @return 消费者
|
||||||
|
**/
|
||||||
public static DefaultMQPushConsumer getMQPushConsumer(String configName, MessageListenerConcurrently messageListenerConcurrently){
|
public static DefaultMQPushConsumer getMQPushConsumer(String configName, MessageListenerConcurrently messageListenerConcurrently){
|
||||||
try {
|
try {
|
||||||
Map<String, Object> configMap = new HashMap<>();
|
Map<String, Object> configMap = getConfigMapByName(configName);
|
||||||
if(!CONFIG_MAPS.containsKey(configName)){
|
|
||||||
configMap = RocketUtil.initMQConfigMap(configName);
|
|
||||||
CONFIG_MAPS.put(configName, configMap);
|
|
||||||
}
|
|
||||||
// 最大重试次数
|
// 最大重试次数
|
||||||
int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("MaxReconsumeTimes")), RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
|
int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("MaxReconsumeTimes")), RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
|
||||||
// 声明一个消费者consumer,需要传入一个组 weaver-consumer
|
// 声明一个消费者consumer,需要传入一个组 weaver-consumer
|
||||||
|
@ -49,4 +66,55 @@ public class RocketMQFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>根据配置文件获取生产者对象</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/1/4 12:59
|
||||||
|
* @param configName 配置文件名称
|
||||||
|
* @return 生产者对象
|
||||||
|
**/
|
||||||
|
public static DefaultMQProducer getMQProducer(String configName){
|
||||||
|
DefaultMQProducer defaultMQProducer = null;
|
||||||
|
if(PRODUCER_MAP.containsKey(configName)){
|
||||||
|
return PRODUCER_MAP.get(configName);
|
||||||
|
}else {
|
||||||
|
synchronized (RocketMQFactory.class){
|
||||||
|
if(PRODUCER_MAP.containsKey(configName)){
|
||||||
|
return PRODUCER_MAP.get(configName);
|
||||||
|
}else {
|
||||||
|
Map<String, Object> configMap = getConfigMapByName(configName);
|
||||||
|
defaultMQProducer = new DefaultMQProducer();
|
||||||
|
// 发送消息最大超时时间 默认60000
|
||||||
|
int sendMsgTimeOut = Util.getIntValue(Util.null2String(configMap.get("sendMsgTimeOut")), RocketMQConstant.PRODUCER_SEND_MSG_TIME_OUT);
|
||||||
|
defaultMQProducer.setSendMsgTimeout(sendMsgTimeOut);
|
||||||
|
try {
|
||||||
|
defaultMQProducer.start();
|
||||||
|
}catch (MQClientException e){
|
||||||
|
throw new CustomerException("producer start error!");
|
||||||
|
}
|
||||||
|
// mq地址
|
||||||
|
defaultMQProducer.setNamesrvAddr(Util.null2String(configMap.get("NameServer")));
|
||||||
|
PRODUCER_MAP.put(configName, defaultMQProducer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultMQProducer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>通过配置文件名称获取配置map</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/1/4 13:18
|
||||||
|
* @param configName 配置文件名称
|
||||||
|
* @return 配置文件map
|
||||||
|
**/
|
||||||
|
private synchronized static Map<String, Object> getConfigMapByName(String configName){
|
||||||
|
Map<String, Object> configMap = new HashMap<>();
|
||||||
|
if(!CONFIG_MAPS.containsKey(configName)){
|
||||||
|
configMap = RocketUtil.initMQConfigMap(configName);
|
||||||
|
CONFIG_MAPS.put(configName, configMap);
|
||||||
|
}
|
||||||
|
return configMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package weaver.xuanran.wang.shyl.mq.action;
|
||||||
|
|
||||||
|
import aiyh.utils.action.SafeCusBaseAction;
|
||||||
|
import aiyh.utils.annotation.RequiredMark;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>生产者action 将流程数据发送到mq中</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/1/4 14:47
|
||||||
|
*/
|
||||||
|
public class ProducerAction extends SafeCusBaseAction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>mq配置文件名称</h2>
|
||||||
|
**/
|
||||||
|
@RequiredMark
|
||||||
|
private String MQConfigName;
|
||||||
|
/**
|
||||||
|
* <h2>配置文件唯一标识</h2>
|
||||||
|
**/
|
||||||
|
@RequiredMark
|
||||||
|
private String onlyMark;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ public class RocketMQConstant {
|
||||||
public static final String ID_TYPE_STU_CARD = "4";
|
public static final String ID_TYPE_STU_CARD = "4";
|
||||||
public static final String ID_TYPE_SOLDIER_CARD = "5";
|
public static final String ID_TYPE_SOLDIER_CARD = "5";
|
||||||
public static final String DEFAULT_PASSWORD = "1";
|
public static final String DEFAULT_PASSWORD = "1";
|
||||||
|
public static final int PRODUCER_SEND_MSG_TIME_OUT = 60000;
|
||||||
|
|
||||||
public static Map<String, String> SEX_MAPPING = new HashMap<>();
|
public static Map<String, String> SEX_MAPPING = new HashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
package weaver.xuanran.wang.shyl.mq.consumer;
|
package weaver.xuanran.wang.shyl.mq.consumer;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
|
|
||||||
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
||||||
import org.apache.rocketmq.common.message.MessageExt;
|
import org.apache.rocketmq.common.message.MessageExt;
|
||||||
import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
|
import weaver.xuanran.wang.shyl.mq.RocketMQConsumerListener;
|
||||||
import weaver.xuanran.wang.shyl.mq.RocketMQListener;
|
|
||||||
import weaver.xuanran.wang.shyl.mq.service.impl.OrgServiceImpl;
|
import weaver.xuanran.wang.shyl.mq.service.impl.OrgServiceImpl;
|
||||||
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>部门队列消费者</h1>
|
* <h1>部门队列消费者</h1>
|
||||||
|
@ -21,7 +17,7 @@ import java.util.Map;
|
||||||
* @Author xuanran.wang
|
* @Author xuanran.wang
|
||||||
* @Date 2022/12/29 14:35
|
* @Date 2022/12/29 14:35
|
||||||
*/
|
*/
|
||||||
public class OrgConsumer extends RocketMQListener {
|
public class OrgConsumer extends RocketMQConsumerListener {
|
||||||
|
|
||||||
private static final Logger log = Util.getLogger();
|
private static final Logger log = Util.getLogger();
|
||||||
private static final String CONFIG_NAME = "OrgConsumer";
|
private static final String CONFIG_NAME = "OrgConsumer";
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
package weaver.xuanran.wang.shyl.mq.consumer;
|
package weaver.xuanran.wang.shyl.mq.consumer;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
|
|
||||||
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
||||||
import org.apache.rocketmq.common.message.MessageExt;
|
import org.apache.rocketmq.common.message.MessageExt;
|
||||||
import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
|
import weaver.xuanran.wang.shyl.mq.RocketMQConsumerListener;
|
||||||
import weaver.xuanran.wang.shyl.mq.RocketMQListener;
|
|
||||||
import weaver.xuanran.wang.shyl.mq.service.impl.PassWordServiceImpl;
|
import weaver.xuanran.wang.shyl.mq.service.impl.PassWordServiceImpl;
|
||||||
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>密码修改队列消费者</h1>
|
* <h1>密码修改队列消费者</h1>
|
||||||
|
@ -21,7 +17,7 @@ import java.util.Map;
|
||||||
* @Author xuanran.wang
|
* @Author xuanran.wang
|
||||||
* @Date 2022/12/29 14:35
|
* @Date 2022/12/29 14:35
|
||||||
*/
|
*/
|
||||||
public class PassWordConsumer extends RocketMQListener {
|
public class PassWordConsumer extends RocketMQConsumerListener {
|
||||||
|
|
||||||
private static final Logger log = Util.getLogger();
|
private static final Logger log = Util.getLogger();
|
||||||
public static final String CONFIG_NAME = "PassWordConsumer";
|
public static final String CONFIG_NAME = "PassWordConsumer";
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.apache.log4j.Logger;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
||||||
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
||||||
import org.apache.rocketmq.common.message.MessageExt;
|
import org.apache.rocketmq.common.message.MessageExt;
|
||||||
import weaver.xuanran.wang.shyl.mq.RocketMQListener;
|
import weaver.xuanran.wang.shyl.mq.RocketMQConsumerListener;
|
||||||
import weaver.xuanran.wang.shyl.mq.service.impl.UserServiceImpl;
|
import weaver.xuanran.wang.shyl.mq.service.impl.UserServiceImpl;
|
||||||
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||||
* @Author xuanran.wang
|
* @Author xuanran.wang
|
||||||
* @Date 2022/12/29 14:35
|
* @Date 2022/12/29 14:35
|
||||||
*/
|
*/
|
||||||
public class UserInfoConsumer extends RocketMQListener {
|
public class UserInfoConsumer extends RocketMQConsumerListener {
|
||||||
private static final Logger log = Util.getLogger();
|
private static final Logger log = Util.getLogger();
|
||||||
public static final String CONFIG_NAME = "UserInfoConsumer";
|
public static final String CONFIG_NAME = "UserInfoConsumer";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package weaver.xuanran.wang.shyl.mq.service;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||||
|
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||||
|
import weaver.xuanran.wang.common.util.CommonUtil;
|
||||||
|
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>生产者业务方法</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/1/4 14:54
|
||||||
|
*/
|
||||||
|
public class ProducerService {
|
||||||
|
|
||||||
|
private final DealWithMapping dealWithMapping = new DealWithMapping();
|
||||||
|
|
||||||
|
public void pushWorkFlowToMQ(String configName, String onlyMark, String requestId, String tableName){
|
||||||
|
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
|
||||||
|
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, tableName);
|
||||||
|
RecordSet recordSet = new RecordSet();
|
||||||
|
recordSet.executeQuery(selectMainSql, requestId);
|
||||||
|
Map<String, Object> requestParam = new HashMap<>();
|
||||||
|
if (recordSet.next()) {
|
||||||
|
dealWithMapping.setMainTable(tableName);
|
||||||
|
requestParam = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
|
||||||
|
}
|
||||||
|
if(MapUtils.isEmpty(requestParam)){
|
||||||
|
throw new CustomerException("convert workflow information to json error!");
|
||||||
|
}
|
||||||
|
RocketUtil.producerSendMsg(configName, JSONObject.toJSONString(requestParam));
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||||
* @Date 2022/12/30 15:05
|
* @Date 2022/12/30 15:05
|
||||||
*/
|
*/
|
||||||
public class OrgServiceImpl extends CusInfoActionService {
|
public class OrgServiceImpl extends CusInfoActionService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>部门创建</h1>
|
* <h1>部门创建</h1>
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
|
@ -41,7 +42,7 @@ public class OrgServiceImpl extends CusInfoActionService {
|
||||||
String subId = "";
|
String subId = "";
|
||||||
RecordSet insertRs = new RecordSet();
|
RecordSet insertRs = new RecordSet();
|
||||||
if(StringUtils.isBlank(subId)){
|
if(StringUtils.isBlank(subId)){
|
||||||
throw new CustomerException("SubCompany can not be empey!");
|
throw new CustomerException("SubCompany can not be empty!");
|
||||||
}
|
}
|
||||||
//使用存储过程新增分部
|
//使用存储过程新增分部
|
||||||
String para = org.getOrgName() + separator + org.getOrgName() + separator +
|
String para = org.getOrgName() + separator + org.getOrgName() + separator +
|
||||||
|
@ -83,6 +84,13 @@ public class OrgServiceImpl extends CusInfoActionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>部门更新</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/1/4 14:44
|
||||||
|
* @param message mq消息
|
||||||
|
* @return 成功/重试
|
||||||
|
**/
|
||||||
@Override
|
@Override
|
||||||
public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
|
public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
|
||||||
try {
|
try {
|
||||||
|
@ -102,6 +110,14 @@ public class OrgServiceImpl extends CusInfoActionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>更新部门信息</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/1/4 14:45
|
||||||
|
* @param depId 部门id
|
||||||
|
* @param subId 分部id
|
||||||
|
* @param org 部门对象
|
||||||
|
**/
|
||||||
public void updateDepartmentInfo(String depId, String subId, Org org){
|
public void updateDepartmentInfo(String depId, String subId, Org org){
|
||||||
String insertSQL = "update hrmdepartment set created = ?, creater = ?, modified = ?, modifier = ?," +
|
String insertSQL = "update hrmdepartment set created = ?, creater = ?, modified = ?, modifier = ?," +
|
||||||
" departmentcode = ?, tlevel = ?, showorder = ?, canceled = ?,departmentmark = ?, " +
|
" departmentcode = ?, tlevel = ?, showorder = ?, canceled = ?,departmentmark = ?, " +
|
||||||
|
|
|
@ -9,7 +9,15 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
|
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
|
||||||
|
import org.apache.rocketmq.client.exception.MQBrokerException;
|
||||||
|
import org.apache.rocketmq.client.exception.MQClientException;
|
||||||
|
import org.apache.rocketmq.client.producer.DefaultMQProducer;
|
||||||
|
import org.apache.rocketmq.client.producer.SendResult;
|
||||||
|
import org.apache.rocketmq.client.producer.SendStatus;
|
||||||
|
import org.apache.rocketmq.common.message.Message;
|
||||||
import org.apache.rocketmq.common.message.MessageExt;
|
import org.apache.rocketmq.common.message.MessageExt;
|
||||||
|
import org.apache.rocketmq.remoting.common.RemotingHelper;
|
||||||
|
import org.apache.rocketmq.remoting.exception.RemotingException;
|
||||||
import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
|
import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
|
||||||
import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
|
import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
|
||||||
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
|
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
|
||||||
|
@ -67,8 +75,8 @@ public class RocketUtil {
|
||||||
try {
|
try {
|
||||||
if (CollectionUtils.isNotEmpty(msg)) {
|
if (CollectionUtils.isNotEmpty(msg)) {
|
||||||
MessageExt messageExt = msg.get(0);
|
MessageExt messageExt = msg.get(0);
|
||||||
String msgBody = "";
|
String msgBody;
|
||||||
MQMessage mqMessage = null;
|
MQMessage mqMessage;
|
||||||
try {
|
try {
|
||||||
msgBody = new String(messageExt.getBody(), StandardCharsets.UTF_8);
|
msgBody = new String(messageExt.getBody(), StandardCharsets.UTF_8);
|
||||||
if(StringUtils.isBlank(msgBody)){
|
if(StringUtils.isBlank(msgBody)){
|
||||||
|
@ -107,6 +115,7 @@ public class RocketUtil {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 如果重试达到最大还是异常那么先返回成功 oa将错误日志记录到日志中
|
// 如果重试达到最大还是异常那么先返回成功 oa将错误日志记录到日志中
|
||||||
if (msg.get(0).getReconsumeTimes() == maxReconsumeTimes) {
|
if (msg.get(0).getReconsumeTimes() == maxReconsumeTimes) {
|
||||||
|
//TODO
|
||||||
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
|
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
|
||||||
|
@ -114,4 +123,40 @@ public class RocketUtil {
|
||||||
}
|
}
|
||||||
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>向mq中发送消息</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/1/4 14:30
|
||||||
|
* @param configName 配置文件名称
|
||||||
|
* @param msg 消息主体
|
||||||
|
**/
|
||||||
|
public static void producerSendMsg(String configName, String msg) {
|
||||||
|
// 先从本地缓存中获取生产者对象
|
||||||
|
DefaultMQProducer producer = RocketMQFactory.getMQProducer(configName);
|
||||||
|
// 获取配置信息
|
||||||
|
Map<String, Object> configMap = RocketMQFactory.CONFIG_MAPS.get(configName);
|
||||||
|
// 队列名
|
||||||
|
String topic = Util.null2DefaultStr(configMap.get("Topic"),"");
|
||||||
|
// tag
|
||||||
|
String tag = Util.null2DefaultStr(configMap.get("Tag"),"");
|
||||||
|
Message message;
|
||||||
|
try {
|
||||||
|
message = new Message(topic, tag, msg.getBytes(RemotingHelper.DEFAULT_CHARSET));
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException(Util.logStr("init message error : {} !", e.getMessage()));
|
||||||
|
}
|
||||||
|
SendResult result;
|
||||||
|
try {
|
||||||
|
result = producer.send(message);
|
||||||
|
} catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) {
|
||||||
|
throw new CustomerException(Util.logStr("producer send message error!", e.getMessage()));
|
||||||
|
}
|
||||||
|
SendStatus sendStatus = result.getSendStatus();
|
||||||
|
// 如果成功
|
||||||
|
if(SendStatus.SEND_OK.equals(sendStatus)){
|
||||||
|
log.error(Util.logStr("producer send message call back status is not ok! the message is {}, the status is {}.", msg, sendStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import aiyh.utils.Util;
|
||||||
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
|
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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 com.icbc.api.internal.apache.http.impl.cookie.S;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -32,19 +31,6 @@ import java.util.stream.Collectors;
|
||||||
* @Date 2022/12/7 11:58
|
* @Date 2022/12/7 11:58
|
||||||
*/
|
*/
|
||||||
public class DownLoadFileTest extends BaseTest {
|
public class DownLoadFileTest extends BaseTest {
|
||||||
private final DownLoadFileMapper downLoadFileMapper = Util.getMapper(DownLoadFileMapper.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSelectFileInfo() throws IOException {
|
|
||||||
Map<String, Object> fileInfo = downLoadFileMapper.selectDocInfoByDocId("95");
|
|
||||||
log.info("map " + fileInfo);
|
|
||||||
String fileName = Util.null2String(fileInfo.get("fileName"));
|
|
||||||
int imageFileId = Util.getIntValue(Util.null2DefaultStr(fileInfo.get("imageFileId"),""), -1);
|
|
||||||
log.info("imageFileId " + imageFileId);
|
|
||||||
InputStream is = ImageFileManager.getInputStreamById(imageFileId);
|
|
||||||
log.info(null == is);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testImageFileInputSteam(){
|
public void testImageFileInputSteam(){
|
||||||
|
|
Loading…
Reference in New Issue