commit
ef8230a395
|
@ -12,6 +12,7 @@ import aiyh.utils.mapUtil.UtilHashMap;
|
|||
import aiyh.utils.mapUtil.UtilLinkedHashMap;
|
||||
import aiyh.utils.mapper.UtilMapper;
|
||||
import aiyh.utils.recordset.RecordsetUtil;
|
||||
import aiyh.utils.recordset.RsThreadLocalManager;
|
||||
import aiyh.utils.service.UtilService;
|
||||
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
|
||||
import aiyh.utils.sqlUtil.whereUtil.Where;
|
||||
|
@ -106,6 +107,7 @@ public class Util extends weaver.general.Util {
|
|||
static ToolUtil toolUtil = new ToolUtil();
|
||||
private static RecordSet rs;
|
||||
private static volatile Logger log = null;
|
||||
private static final RsThreadLocalManager LOCAL_MANAGER = new RsThreadLocalManager();
|
||||
|
||||
static {
|
||||
try {
|
||||
|
@ -4093,5 +4095,83 @@ public class Util extends weaver.general.Util {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>获取下一个部门id</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/7/19 11:24
|
||||
* @return 部门id
|
||||
**/
|
||||
public static int getNextDepartmentId(){
|
||||
return getNextDepartmentId(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>获取下一个部门id</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/7/19 11:24
|
||||
* @param subId 分部id
|
||||
* @return 部门id
|
||||
**/
|
||||
public static int getNextDepartmentId(int subId){
|
||||
char separator = weaver.general.Util.getSeparator();
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String empty = "";
|
||||
String para = uuid + separator +uuid + separator +
|
||||
empty + separator + empty + separator + subId + separator + 1 + separator + empty;
|
||||
RecordSet procRs = getThreadRecord();
|
||||
procRs.executeProc("HrmDepartment_Insert", para);
|
||||
if(procRs.next()){
|
||||
return procRs.getInt(1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <h1>获取下一个人员id</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/4/12 13:24
|
||||
* @return 人员id
|
||||
**/
|
||||
public static int getNextHrmId(){
|
||||
RecordSet procRs = getThreadRecord();
|
||||
procRs.executeProc("HrmResourceMaxId_Get", "");
|
||||
if (procRs.next()) {
|
||||
return procRs.getInt(1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>获取当前线程rs对象</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/7/19 15:28
|
||||
* @return recordSet对象
|
||||
**/
|
||||
public static RecordSet getThreadRecord(){
|
||||
String name = Thread.currentThread().getId() + "_" + Thread.currentThread().getName();
|
||||
return getRecordFromRsManger(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1>通过名字获取rs池中rs对象</h1>
|
||||
* @author xuanran.wang
|
||||
* @dateTime 2023/7/19 15:29
|
||||
* @param name rs池中的key
|
||||
* @return recordSet对象
|
||||
**/
|
||||
public static RecordSet getRecordFromRsManger(String name){
|
||||
RecordSet rs = LOCAL_MANAGER.getRs(name);
|
||||
if(null == rs){
|
||||
LOCAL_MANAGER.setRecordSet(name);
|
||||
rs = LOCAL_MANAGER.getRs(name);
|
||||
if(null == rs){
|
||||
rs = new RecordSet();
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package aiyh.utils.httpUtil.cushttpclasses;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.Principal;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -95,6 +93,11 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeSessionId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestedSessionId() {
|
||||
return null;
|
||||
|
@ -143,6 +146,36 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void login(String s, String s1) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Part> getParts() throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Part getPart(String s) throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return null;
|
||||
|
@ -218,6 +251,11 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentLengthLong() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return null;
|
||||
|
@ -271,4 +309,59 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
public String getRealPath(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemotePort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalAddr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLocalPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync() throws IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncStarted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext getAsyncContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DispatcherType getDispatcherType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package aiyh.utils.recordset;
|
|||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.icbc.api.internal.apache.http.E;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -27,7 +28,7 @@ public class FormatSqlUtil {
|
|||
}
|
||||
try {
|
||||
return SQLUtils.format(sql, dbType);
|
||||
} catch (ParserException e) {
|
||||
} catch (Exception e) {
|
||||
return toSqlString(sql);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,16 @@ public class ResponseMappingDeal {
|
|||
logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
|
||||
// 自定义校验
|
||||
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! ");
|
||||
// 将所有跟sql有关的字段全部全角转半角
|
||||
responseConfigList.forEach(item-> {
|
||||
item.getResponseConfigAliasList().forEach(responseConfigAlias -> {
|
||||
responseConfigAlias.setConditionScript(Util.sbc2dbcCase(responseConfigAlias.getConditionScript()));
|
||||
responseConfigAlias.setJudgmentScript(Util.sbc2dbcCase(responseConfigAlias.getJudgmentScript()));
|
||||
});
|
||||
item.getValueChangeList().forEach(responseConfigValueChange -> {
|
||||
responseConfigValueChange.setCusText(Util.sbc2dbcCase(responseConfigValueChange.getCusText()));
|
||||
});
|
||||
});
|
||||
Map<String, ResponseConfig> tableNameConfig;
|
||||
try {
|
||||
// 对查询到的多个配置进行整合,以同步表表名作为key 配置作为value
|
||||
|
@ -117,6 +127,7 @@ public class ResponseMappingDeal {
|
|||
.tableDefinitionCallback(this.tableCallback)
|
||||
.tableType(responseConfig.getTableType())
|
||||
.assignType(ResponseConfigConstant.NO_HANDLE)
|
||||
.tableDefinitionCallback(tableCallback)
|
||||
.assignTable(responseConfig.getModelTableName()).build();
|
||||
}
|
||||
// 做数据处理
|
||||
|
@ -176,7 +187,7 @@ public class ResponseMappingDeal {
|
|||
.mainOrDetail(tableMainOrDetail)
|
||||
.tableDefinitionCallback(this.tableCallback)
|
||||
.assignType(mainDataAlias.getAssignType()).build();
|
||||
String dataPath = mainDataAlias.getDataPath();
|
||||
String dataPath = mainDataAlias.getDataAlias();
|
||||
List<RowDefinition> rowDefinitionList = new ArrayList<>();
|
||||
Map<String, TableDefinition> detailTable = isMainTable ? new HashMap<>() : null;
|
||||
// 如果是json数组
|
||||
|
|
|
@ -13,4 +13,6 @@ public interface TableDefinitionCallback {
|
|||
|
||||
void tableHandle(TableDefinition tableDefinition);
|
||||
|
||||
void afterHandle(TableDefinition tableDefinition,boolean flag);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import aiyh.utils.response_deal.entity.ResponseConfigValueChange;
|
|||
import aiyh.utils.response_deal.exception.ResponseException;
|
||||
import aiyh.utils.response_deal.intfaces.DataChangeInterface;
|
||||
import aiyh.utils.response_deal.mapper.ConfigMapper;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -33,7 +34,7 @@ public class DataChangeProcess {
|
|||
|
||||
private static final ConfigMapper CONFIG_MAPPER = Util.getMapper(ConfigMapper.class);
|
||||
|
||||
public static final Logger logger = Util.getLogger();
|
||||
public static final Logger logger = Util.getLogger("json_util");
|
||||
|
||||
static {
|
||||
try {
|
||||
|
@ -66,7 +67,7 @@ public class DataChangeProcess {
|
|||
@MethodRuleNo(value = 0, desc = "默认值")
|
||||
public static String defaultValue(ResponseConfigValueChange responseConfigValueChange,Map<String,Object> param){
|
||||
String cusText = responseConfigValueChange.getCusText();
|
||||
cusText = Util.dbc2sbcCase(cusText);
|
||||
cusText = Util.sbc2dbcCase(cusText);
|
||||
responseConfigValueChange.setJsonData(cusText);
|
||||
return "";
|
||||
}
|
||||
|
@ -80,13 +81,14 @@ public class DataChangeProcess {
|
|||
@MethodRuleNo(value = 1, desc = "sql转换")
|
||||
public static String sqlChange(ResponseConfigValueChange responseConfigValueChange,Map<String,Object> param){
|
||||
String cusText = responseConfigValueChange.getCusText();
|
||||
cusText = Util.dbc2sbcCase(cusText);
|
||||
cusText = Util.sbc2dbcCase(cusText);
|
||||
if(StringUtils.isBlank(cusText)){
|
||||
throw new CustomerException("when selecting Custom sql, the sql string cannot be empty !!!");
|
||||
throw new ResponseException("when selecting Custom sql, the sql string cannot be empty !!!");
|
||||
}
|
||||
if(!cusText.startsWith("select ")){
|
||||
throw new CustomerException("When you select custom sql, you are not allowed to perform dangerous operations other than SELECT !!!");
|
||||
throw new ResponseException("When you select custom sql, you are not allowed to perform dangerous operations other than SELECT !!!");
|
||||
}
|
||||
logger.info(Util.logStr("cus sql : {}, params : {}", cusText, JSONObject.toJSONString(param)));
|
||||
String tempValue = CONFIG_MAPPER.executeCusQuerySql(cusText, param,new HashMap<>());
|
||||
responseConfigValueChange.setJsonData(tempValue);
|
||||
return "";
|
||||
|
@ -102,7 +104,7 @@ public class DataChangeProcess {
|
|||
public static String dateChange(ResponseConfigValueChange responseConfigValueChange,Map<String,Object> param){
|
||||
String cusText = responseConfigValueChange.getCusText();
|
||||
Object jsonData = responseConfigValueChange.getJsonData();
|
||||
cusText = Util.dbc2sbcCase(cusText);
|
||||
cusText = Util.sbc2dbcCase(cusText);
|
||||
String fromStr = getDateFormat(cusText,"from:\\{(.*?)\\}");
|
||||
String toStr = getDateFormat(cusText,"to:\\{(.*?)\\}");
|
||||
responseConfigValueChange.setJsonData(formatDateTime(Util.null2String(jsonData),fromStr,toStr));
|
||||
|
@ -118,7 +120,7 @@ public class DataChangeProcess {
|
|||
@MethodRuleNo(value = 3, desc = "自定义接口")
|
||||
public static String cusInterface(ResponseConfigValueChange responseConfigValueChange,Map<String,Object> param){
|
||||
String cusText = responseConfigValueChange.getCusText();
|
||||
cusText = Util.dbc2sbcCase(cusText);
|
||||
cusText = Util.sbc2dbcCase(cusText);
|
||||
if(StringUtils.isBlank(cusText)){
|
||||
throw new CustomerException("The operation full path cannot be empty !!!");
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class TypeChangeProcess {
|
|||
|
||||
public static final Map<Integer, Function<Object,Object>> MODE_METHOD_MAP = new HashMap<>();
|
||||
|
||||
public static final Logger logger = Util.getLogger();
|
||||
public static final Logger logger = Util.getLogger("json_util");
|
||||
|
||||
static {
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package aiyh.utils.response_deal.state;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.excention.ParseSqlException;
|
||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||
|
@ -7,6 +10,7 @@ import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
|
|||
import aiyh.utils.response_deal.util.ResponseUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -22,9 +26,6 @@ public class InsertOrUpdateState extends State{
|
|||
|
||||
@Override
|
||||
public void handle() {
|
||||
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
|
||||
this.context.getTableDefinitionCallback().tableHandle(this.context);
|
||||
}
|
||||
List<RowDefinition> rowDefinitionList = this.context.getRowDefinitionList();
|
||||
List<RowDefinition> updateRowList = new ArrayList<>();
|
||||
List<RowDefinition> insertRowList = new ArrayList<>();
|
||||
|
@ -55,16 +56,24 @@ public class InsertOrUpdateState extends State{
|
|||
BeanUtil.copyProperties(this.context,tableDefinition);
|
||||
tableDefinition.setState(null);
|
||||
tableDefinition.setRowDefinitionList(rowDefinitionList);
|
||||
tableDefinition.setTableDefinitionCallback(null);
|
||||
tableDefinition.setAssignType(assignType);
|
||||
tableDefinition.setDefaultState(null);
|
||||
tableDefinition.dataProcess();
|
||||
}
|
||||
|
||||
private boolean judgmentRepetition(RowDefinition rowDefinition){
|
||||
String conditionScript = rowDefinition.getConditionScript();
|
||||
String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript());
|
||||
String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
|
||||
String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
|
||||
String dataId;
|
||||
try {
|
||||
dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
|
||||
}catch (ParseSqlException e){
|
||||
logger.error(Util.logStr("parse sql error, current sql : [{}], whereParam : [{}]", cusQuerySql, JSONObject.toJSONString(rowDefinition.getWhereParam())));
|
||||
throw new CustomerException(e);
|
||||
}
|
||||
if(StrUtil.isNotBlank(dataId)){
|
||||
rowDefinition.setDataId(Util.getIntValue(dataId, -1));
|
||||
}
|
||||
return StrUtil.isNotBlank(dataId);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package aiyh.utils.response_deal.state;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.excention.ParseSqlException;
|
||||
import aiyh.utils.recordset.MapperBuilderSql;
|
||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
|
||||
import aiyh.utils.response_deal.util.ResponseUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -44,6 +47,7 @@ public class InsertSate extends State{
|
|||
}
|
||||
});
|
||||
RowDefinition tempRowDefinition = rowDefinitionList.get(0);
|
||||
boolean flag;
|
||||
if(tableType == ResponseConfigConstant.MODEL_TABLE && mainOrDetail == ResponseConfigConstant.MAIN_TABLE){
|
||||
List<Map<String, Object>> updateList = new ArrayList<>();
|
||||
List<Map<String, Object>> whereList = new ArrayList<>();
|
||||
|
@ -61,19 +65,38 @@ public class InsertSate extends State{
|
|||
}
|
||||
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, tempRowDefinition.getUpdateParam(),"upItem");
|
||||
updateSql = updateSql + " where id = #{whereItem.id}";
|
||||
boolean flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
||||
try {
|
||||
flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
||||
}catch (ParseSqlException e){
|
||||
logger.error(Util.logStr("parse sql error, current sql : [{}], updateList : [{}], whereList : [{}]", updateSql, JSONObject.toJSONString(updateList), JSONObject.toJSONString(whereList)));
|
||||
throw new CustomerException(e);
|
||||
}
|
||||
String modeId = Util.getModeIdByTableName(assignTable);
|
||||
Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList);
|
||||
if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){
|
||||
detailTableMap.forEach((key,value)->{
|
||||
value.setDefaultState(null);
|
||||
value.dataProcess();
|
||||
});
|
||||
}
|
||||
}else {
|
||||
String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item");
|
||||
List<Map<String, Object>> insertList = rowDefinitionList.stream().map(RowDefinition::getUpdateParam).collect(Collectors.toList());
|
||||
boolean flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList);
|
||||
List<Map<String, Object>> insertList = new ArrayList<>();
|
||||
rowDefinitionList.forEach(item ->{
|
||||
if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){
|
||||
detailTableDeal(item,detailTableMap);
|
||||
}
|
||||
insertList.add(item.getUpdateParam());
|
||||
});
|
||||
try {
|
||||
flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList);
|
||||
}catch (ParseSqlException e){
|
||||
logger.error(Util.logStr("parse sql error, current sql : [{}], insertList : [{}]", insertSql, JSONObject.toJSONString(insertList)));
|
||||
throw new CustomerException(e);
|
||||
}
|
||||
}
|
||||
if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){
|
||||
detailTableMap.forEach((key,value)->{
|
||||
value.setDefaultState(null);
|
||||
value.dataProcess();
|
||||
});
|
||||
}
|
||||
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
|
||||
this.context.getTableDefinitionCallback().afterHandle(this.context,flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,6 +110,7 @@ public class InsertSate extends State{
|
|||
}
|
||||
rowDefinitionList.forEach(item ->{
|
||||
item.getUpdateParam().put("mainid",mainId);
|
||||
item.getWhereParam().put("mainid",mainId);
|
||||
});
|
||||
if(mainDetailMap.containsKey(key)){
|
||||
TableDefinition tableDefinition = mainDetailMap.get(key);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package aiyh.utils.response_deal.state;
|
||||
|
||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||
import aiyh.utils.response_deal.util.ResponseUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName NoHandleState
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/19 16:51
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
public class NoHandleState extends State{
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
if(this.context.getMainOrDetail() == ResponseConfigConstant.MAIN_TABLE) {
|
||||
Map<String, TableDefinition> detailTableMap = this.context.getDetailTableMap();
|
||||
if (ResponseUtil.parameterIsNotNull(detailTableMap)) {
|
||||
detailTableMap.forEach((key, value) -> {
|
||||
value.setDefaultState(null);
|
||||
value.dataProcess();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ public abstract class State {
|
|||
protected final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class);
|
||||
|
||||
/** 日志对象 */
|
||||
protected final Logger logger = Util.getLogger();
|
||||
protected final Logger logger = Util.getLogger("json_util");
|
||||
|
||||
/** 上下文对象 */
|
||||
protected TableDefinition context;
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package aiyh.utils.response_deal.state;
|
||||
|
||||
import aiyh.utils.ScriptUtil;
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.excention.ParseSqlException;
|
||||
import aiyh.utils.recordset.MapperBuilderSql;
|
||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||
import aiyh.utils.response_deal.exception.ResponseException;
|
||||
import aiyh.utils.response_deal.util.ResponseUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -52,13 +56,23 @@ public class UpdateState extends State {
|
|||
definition.getRowDefinitionCallback().rowHandle(definition);
|
||||
}
|
||||
updateList.add(definition.getUpdateParam());
|
||||
updateList.add(definition.getWhereParam());
|
||||
whereList.add(definition.getWhereParam());
|
||||
}
|
||||
RowDefinition rowDefinition = rowDefinitionList.get(0);
|
||||
String tempConditionScript = rowDefinition.getConditionScript();
|
||||
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, rowDefinition.getUpdateParam(),"upItem");
|
||||
updateSql = updateSql + " " + conditionScript;
|
||||
boolean flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
||||
updateSql = updateSql + " where " + tempConditionScript;
|
||||
boolean flag;
|
||||
try {
|
||||
flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
||||
}catch (ParseSqlException e){
|
||||
logger.error(Util.logStr("parse sql error, current sql : [{}], updateList : [{}], whereList : [{}]", updateSql, JSONObject.toJSONString(updateList), JSONObject.toJSONString(whereList)));
|
||||
throw new CustomerException(e);
|
||||
}
|
||||
logger.info("批量更新处理结果 ==>"+flag);
|
||||
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
|
||||
this.context.getTableDefinitionCallback().afterHandle(this.context,flag);
|
||||
}
|
||||
//如果为主表则处理明细数据
|
||||
if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){
|
||||
detailTableDeal(detailTableMap);
|
||||
|
@ -79,6 +93,12 @@ public class UpdateState extends State {
|
|||
return;
|
||||
}
|
||||
detailTableMap.forEach((key,value) ->{
|
||||
if(item.getDataId() > 0){
|
||||
for (RowDefinition rowDefinition : value.getRowDefinitionList()) {
|
||||
rowDefinition.getUpdateParam().put("mainid", item.getDataId());
|
||||
rowDefinition.getWhereParam().put("mainid", item.getDataId());
|
||||
}
|
||||
}
|
||||
if(mainDetailMap.containsKey(key)){
|
||||
mainDetailMap.get(key).getRowDefinitionList().addAll(value.getRowDefinitionList());
|
||||
}else {
|
||||
|
|
|
@ -37,12 +37,15 @@ public interface ReportMapper {
|
|||
@CaseConversion(value = false)
|
||||
List<Map<String, Object>> queryReportData2(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
|
||||
|
||||
@Select("select id,hbwb,ysclwb,gzrywb,gzclwb,ldrwb,sfsjyc,ddsjyc,dlsk,yslx,hbcc,sfsj,ddsj,sfd,ddd,wdwcl,dwcljsy,wdwclqt,xcap,lxr," +
|
||||
" lxrdh,bz,gzcl,gzry,zs,dyjbr,djr,ldr,lddw,rwzt,ykdh,gbs, " +
|
||||
" (select LISTAGG(concat(wb, ',', zw), '-') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx, " +
|
||||
" dyjbr, (select lastname from hrmresource where id = dyjbr) dyjbr_span," +
|
||||
" djr, (select lastname from hrmresource where id = djr) djr_span " +
|
||||
" from uf_zwfwdjjmb main $t{param.whereSql} order by dlsk ")
|
||||
@Select("select main.*," +
|
||||
" (select lastname from hrmresource where id = dyjbr) dyjbr_span," +
|
||||
" (select lastname from hrmresource where id = djr) djr_span," +
|
||||
" (select LISTAGG(concat(wb, ',', dw), '-') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx," +
|
||||
" (select LISTAGG(concat(dwclwb,'(', dwcljsywb,')'), ',') WITHIN GROUP (ORDER BY dwclwb) from uf_zwfwdjjmb_dt3 where mainid = main.id) car_people," +
|
||||
" (select LISTAGG(concat(gzclwb,'(', gzcljsywb,')'), ',') WITHIN GROUP (ORDER BY gzclwb) from uf_zwfwdjjmb_dt4 where mainid = main.id) work_people," +
|
||||
" (select LISTAGG(concat(fjhwb,'(', ysdxwb,')'), ',') WITHIN GROUP (ORDER BY fjhwb) from uf_zwfwdjjmb_dt2 where mainid = main.id) put_up " +
|
||||
"from uf_zwfwdjjmb main $t{param.whereSql} " +
|
||||
"order by dlsk1 ")
|
||||
@CaseConversion(value = false)
|
||||
List<Map<String, Object>> queryReportData3(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
|
||||
|
||||
|
@ -53,19 +56,21 @@ public interface ReportMapper {
|
|||
*/
|
||||
@Select("select xxhm from uf_bjxxjmbd_dt1 where xxrq = #{currentDate}")
|
||||
@CaseConversion(value = false)
|
||||
List<String> queryTrafficControl(@ParamMapper("param") Map<String,Object> param);
|
||||
List<String> queryTrafficControl(Map<String,Object> param);
|
||||
|
||||
/**
|
||||
* 查询当日值班人员
|
||||
* @param param 查询参数
|
||||
* @return 当日值班人员
|
||||
*/
|
||||
@Select("select hrm.lastname,ry.zblx,ry.zbry " +
|
||||
@Select("select hrm.lastname head_watch,ry.zbry,hrm1.lastname organ_watch,ry.zbry1,hrm2.lastname today_welcome,ry.zbry2 " +
|
||||
" from uf_ryzbjlbzjb_dt1 ry " +
|
||||
" inner join hrmresource hrm on ry.zbry = hrm.id" +
|
||||
" where #{currentDate} >= ry.zbksrq and #{currentDate} <= ry.zbjsrq }")
|
||||
" inner join hrmresource hrm on ry.zbry = hrm.id " +
|
||||
" inner join hrmresource hrm1 on ry.zbry1 = hrm1.id " +
|
||||
" inner join hrmresource hrm2 on ry.zbry2 = hrm2.id " +
|
||||
" where ry.zbksrq = #{currentDate}")
|
||||
@CaseConversion(value = false)
|
||||
List<Map<String, Object>> queryDutyData(@ParamMapper("param") Map<String,Object> param);
|
||||
List<Map<String, Object>> queryDutyData(Map<String,Object> param);
|
||||
|
||||
/**
|
||||
* 查询车队排班信息
|
||||
|
@ -74,9 +79,9 @@ public interface ReportMapper {
|
|||
*/
|
||||
@Select("select hrm.lastname " +
|
||||
" from uf_jsyzbap_dt1 jsy " +
|
||||
" inner join hrmresource hrm on jsy.zbry = hrm.id" +
|
||||
" where jsy.zblx = #{dutyType} and #{currentDate} >= jsy.zbksrq and #{currentDate} <= jsy.zbjsrq }")
|
||||
" inner join hrmresource hrm on jsy.$t{field} = hrm.id" +
|
||||
" where jsy.zbksrq = #{currentDate}")
|
||||
@CaseConversion(value = false)
|
||||
List<String> queryCarSchedule(@ParamMapper("param") Map<String,Object> param);
|
||||
List<String> queryCarSchedule(Map<String,Object> param);
|
||||
|
||||
}
|
||||
|
|
|
@ -41,24 +41,26 @@ public class ReportService {
|
|||
//开始日期
|
||||
String beginDate = Util.null2String(param.get("beginDate"));
|
||||
//结束日期
|
||||
String endData = Util.null2String(param.get("endData"));
|
||||
String endDate = Util.null2String(param.get("endDate"));
|
||||
//航班车次
|
||||
String flightAndTrain = Util.null2String(param.get("flightAndTrain"));
|
||||
String whereSql = "";
|
||||
if(!"".equals(beginDate) && !"".equals(endData)){
|
||||
whereSql += " and (dlsk between #{param.beginDate} and #{param.endData} )";
|
||||
}else {
|
||||
param.put("today", TimeUtil.getCurrentDateString());
|
||||
whereSql += " and dlsk >= #{param.today} ";
|
||||
String whereSql = " and (frhsz = 0 or frhsz is null) ";
|
||||
if(!"".equals(beginDate) && !"".equals(endDate)){
|
||||
whereSql += " and (dlsk1 between #{param.beginDate} and #{param.endDate} )";
|
||||
}
|
||||
if(!"".equals(registrationPeople)){
|
||||
whereSql += " and dyjbr = #{param.registrationPeople} ";
|
||||
}
|
||||
if(!"".equals(flightAndTrain)){
|
||||
whereSql += " and hbwb = #{param.flightAndTrain} ";
|
||||
whereSql += " and hbcc like '%"+flightAndTrain+"%' ";
|
||||
}
|
||||
if(!"".equals(project)){
|
||||
whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and ysdx = #{param.project}) ";
|
||||
//whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and ysdx = #{param.project}) ";
|
||||
whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and wb like '%"+project+"%') ";
|
||||
}
|
||||
if(("".equals(beginDate) || "".equals(endDate)) && "".equals(registrationPeople) && "".equals(flightAndTrain)){
|
||||
param.put("today", TimeUtil.getCurrentDateString());
|
||||
whereSql += " and dlsk1 >= #{param.today} ";
|
||||
}
|
||||
whereSql = whereSql.replaceFirst(" and "," where ");
|
||||
return whereSql;
|
||||
|
@ -72,30 +74,31 @@ public class ReportService {
|
|||
//查询值班信息
|
||||
List<Map<String, Object>> dutyData = reportMapper.queryDutyData(param);
|
||||
if(Objects.nonNull(dutyData) && !dutyData.isEmpty()) {
|
||||
Map<String, List<Map<String, Object>>> dutyTypeMap = dutyData.stream().collect(Collectors.groupingBy(item -> Util.null2String(item.get("zblx"))));
|
||||
//带班值班员
|
||||
filterAndPut(dutyTypeMap.get("0"),titleData,"headWatch");
|
||||
String headWatch = convertToString(dutyData, "head_watch");
|
||||
titleData.put("headWatch",headWatch);
|
||||
//机关值班员
|
||||
filterAndPut(dutyTypeMap.get("1"),titleData,"organWatch");
|
||||
String organWatch = convertToString(dutyData, "organ_watch");
|
||||
titleData.put("organWatch",organWatch);
|
||||
//今日迎送人员
|
||||
filterAndPut(dutyTypeMap.get("2"),titleData,"todayWelcome");
|
||||
String todayWelcome = convertToString(dutyData, "today_welcome");
|
||||
titleData.put("todayWelcome",todayWelcome);
|
||||
}
|
||||
titleData.put("dutyData",dutyData);
|
||||
//查询当日送报人员
|
||||
param.put("dutyType",1);
|
||||
param.put("field","zbry1");
|
||||
List<String> strings = reportMapper.queryCarSchedule(param);
|
||||
judgeEmptyAndPut(strings,titleData,"currentNewsboy");
|
||||
//查询驾驶值班员
|
||||
param.put("dutyType",0);
|
||||
param.put("field","zbry");
|
||||
List<String> pilots = reportMapper.queryCarSchedule(param);
|
||||
judgeEmptyAndPut(pilots,titleData,"pilot");
|
||||
//查询明日送报人员
|
||||
param.put("dutyType",1);
|
||||
String currentDate = Util.null2String(param.get("currentDate"));
|
||||
currentDate = TimeUtil.dateAdd(currentDate,-1);
|
||||
currentDate = TimeUtil.dateAdd(currentDate,1);
|
||||
param.put("field","zbry1");
|
||||
param.put("currentDate",currentDate);
|
||||
List<String> tomorrowNewsboys = reportMapper.queryCarSchedule(param);
|
||||
judgeEmptyAndPut(tomorrowNewsboys,titleData,"currentNewsboy");
|
||||
judgeEmptyAndPut(tomorrowNewsboys,titleData,"tomorrowNewsboy");
|
||||
return titleData;
|
||||
}
|
||||
|
||||
|
@ -112,4 +115,22 @@ public class ReportService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将列表中特定键的值转换为逗号分隔的字符串
|
||||
*
|
||||
* @param list 列表
|
||||
* @param key 要提取的键
|
||||
* @return 逗号分隔的字符串
|
||||
*/
|
||||
public String convertToString(List<Map<String, Object>> list, String key) {
|
||||
if(Objects.isNull(list) || list.isEmpty()){
|
||||
return "";
|
||||
}
|
||||
return list.stream()
|
||||
.map(map -> map.get(key))
|
||||
.filter(Objects::nonNull)
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public interface GenerateMapper {
|
|||
* @return 更新结果
|
||||
*/
|
||||
@Update("update uf_contract_num_log set workflow_info = #{workflowInfo},file_info = #{fileInfo},detail_id = #{detailId}," +
|
||||
"row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum},contract_month = #{contractMonth} where id = #{dataId}")
|
||||
"row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum},contract_month = #{contractMonth},contract_year = #{contractYear} where id = #{dataId}")
|
||||
boolean updateContractLog(Map<String,Object> param);
|
||||
|
||||
/**
|
||||
|
@ -34,8 +34,8 @@ public interface GenerateMapper {
|
|||
* <h2>查询最大的流水号</h2>
|
||||
* @return 最大的流水号
|
||||
*/
|
||||
@Select("select max(flow_num) from uf_contract_num_log where contract_month = #{month}")
|
||||
int getMaxFlowByMonth(@ParamMapper("month")int month);
|
||||
@Select("select max(flow_num) from uf_contract_num_log where contract_month = #{month} and contract_year = {year}")
|
||||
int getMaxFlowByMonth(@ParamMapper("month")int month,@ParamMapper("year")int year);
|
||||
|
||||
/**
|
||||
* <h2>删除编号信息</h2>
|
||||
|
|
|
@ -32,8 +32,9 @@ public class GenerateContractNoService {
|
|||
public String generateCode(Map<String,Object> param){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int month = calendar.get(Calendar.MONTH);
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
//int maxFlow = generateMapper.getMaxFlow();
|
||||
int maxFlow = generateMapper.getMaxFlowByMonth(month);
|
||||
int maxFlow = generateMapper.getMaxFlowByMonth(month,year);
|
||||
maxFlow = Math.max(maxFlow,0);
|
||||
maxFlow++;
|
||||
String contractNo = "";
|
||||
|
@ -52,6 +53,7 @@ public class GenerateContractNoService {
|
|||
param.put("contractNum",contractNo);
|
||||
param.put("flowNum",maxFlow);
|
||||
param.put("contractMonth",month);
|
||||
param.put("contractYear",year);
|
||||
boolean updateFlag = generateMapper.updateContractLog(param);
|
||||
Util.rebuildModeDataShareByAsync(1,TABLE_NAME,dataId);
|
||||
if(updateFlag){
|
||||
|
|
|
@ -27,6 +27,9 @@ public class SyncAccountInfoFromSapJob extends BaseCronJob {
|
|||
|
||||
private final static String JobName = " SyncAccountInfoFromSapJob ";
|
||||
|
||||
/** 模块id */
|
||||
private String modelId;
|
||||
|
||||
private String interfaceName;
|
||||
|
||||
private String theNearPeriod;
|
||||
|
@ -122,7 +125,7 @@ public class SyncAccountInfoFromSapJob extends BaseCronJob {
|
|||
periodBalance.setEvCurrency(Util.null2String(balanceResponse.getString("EvCurrency")));
|
||||
periodBalance.setGlAccount(glAccount);
|
||||
|
||||
periodBalance.save(periodBalance, 52, "uf_period_balance");
|
||||
periodBalance.save(periodBalance, Util.getIntValue(this.modelId), "uf_period_balance");
|
||||
|
||||
// String result = "";
|
||||
//// String url = "http://127.0.0.1/uapws/service/nc65to63projectsysplugin";//这是接口地址,注意去掉.wsdl,否则会报错
|
||||
|
|
|
@ -32,8 +32,19 @@ public class SyncAccountStatementJob extends BaseCronJob {
|
|||
|
||||
private String interfaceName;
|
||||
|
||||
/** 模块id */
|
||||
private String modelId;
|
||||
|
||||
private final static String JobName = " SyncAccountStatementJob ";
|
||||
|
||||
public String getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
public void setModelId(String modelId) {
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
public String getInterfaceName() {
|
||||
return interfaceName;
|
||||
}
|
||||
|
@ -253,7 +264,7 @@ public class SyncAccountStatementJob extends BaseCronJob {
|
|||
}
|
||||
}
|
||||
}
|
||||
dayBalance.save(dayBalance, 50, "uf_bank_day_balance");
|
||||
dayBalance.save(dayBalance, Util.getIntValue(this.modelId), "uf_bank_day_balance");
|
||||
logger.writeLog(JobName + " result dayBalance: " + dayBalance.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import org.dom4j.DocumentHelper;
|
|||
import org.dom4j.Element;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Time;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import java.io.File;
|
||||
|
@ -29,6 +31,9 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
|
|||
|
||||
BaseBean logger = new BaseBean();
|
||||
|
||||
/** 模块id */
|
||||
private String modelId;
|
||||
|
||||
private String interfaceName;
|
||||
|
||||
/** 同步开始日期 */
|
||||
|
@ -125,9 +130,13 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
|
|||
xmlParams.put("actacn", actacn);
|
||||
//xmlParams.put("from", "20220919");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.DAY_OF_MONTH, -1);
|
||||
String from = !"".equals(Util.null2String(this.fromDate)) ? this.fromDate : ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit);
|
||||
String to = !"".equals(Util.null2String(this.toDate)) ? this.toDate : ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit);
|
||||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||||
String to = !"".equals(Util.null2String(this.fromDate)) ? this.fromDate : ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit);
|
||||
cal.add(Calendar.DAY_OF_MONTH,-1);
|
||||
String from = !"".equals(Util.null2String(this.toDate))
|
||||
? this.toDate
|
||||
: ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit);
|
||||
//String to = !"".equals(Util.null2String(this.toDate)) ? this.toDate : ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit);
|
||||
xmlParams.put("from", from);
|
||||
xmlParams.put("to", to);
|
||||
xmlParams.put("amountFrom", "1");
|
||||
|
@ -354,7 +363,7 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
|
|||
logger.writeLog(JobName + " result tradeInfoList size: " + tradeInfoList.size());
|
||||
for (TradeInfo tradeInfo : tradeInfoList){
|
||||
if (!"".equals(tradeInfo.getIbknum())){
|
||||
tradeInfo.save(tradeInfo, 51, "uf_bank_trade_info");
|
||||
tradeInfo.save(tradeInfo, Util.getIntValue(this.modelId), "uf_bank_trade_info");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@ import aiyh.utils.Util;
|
|||
import aiyh.utils.excention.CustomerException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil;
|
||||
|
@ -16,8 +18,10 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -40,9 +44,9 @@ public class GetExchangeRate {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String exchangeRate(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response,
|
||||
@RequestBody Map<String, Object> params){
|
||||
@Context HttpServletResponse response){
|
||||
try {
|
||||
Map<String, Object> params = parseBody(request);
|
||||
if(eySeconddevUtil == null){
|
||||
eySeconddevUtil = new EYSeconddevUtil();
|
||||
}
|
||||
|
@ -101,4 +105,25 @@ public class GetExchangeRate {
|
|||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> parseBody(HttpServletRequest request) {
|
||||
try {
|
||||
InputStream inputStream = request.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder requestBody = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
requestBody.append(line);
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> body = objectMapper.readValue(requestBody.toString(), Map.class);
|
||||
if(MapUtils.isEmpty(body)){
|
||||
throw new CustomerException("parse body map is empty!");
|
||||
}
|
||||
return body;
|
||||
}catch (Exception e){
|
||||
throw new CustomerException("解析请求体json error : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@ package com.api.xuanran.wang.xk_hospital.data_async.controller;
|
|||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -23,19 +28,27 @@ public class CommonDataAsyncController {
|
|||
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
private final XkHospitalCommonDataAsyncService service = new XkHospitalCommonDataAsyncServiceImpl();
|
||||
|
||||
@POST
|
||||
@Path("/{configId}}")
|
||||
@Path("/{type}/{configId}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String async(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response,
|
||||
@PathParam("configId") String configId,
|
||||
@RequestBody Map<String, Object> params){
|
||||
@Context HttpServletResponse response,
|
||||
@PathParam("configId") String configId,
|
||||
@PathParam("type") String type,
|
||||
@RequestBody Map<String, Object> params){
|
||||
try {
|
||||
return "";
|
||||
if(StrUtil.isBlank(configId) || StrUtil.isBlank(type)){
|
||||
throw new CustomerException("configId or type can not be empty!");
|
||||
}
|
||||
logger.info(Util.logStr("configId : {}, type : {}, params : {}", configId, type, JSONObject.toJSONString(params)));
|
||||
service.async(configId, type, params);
|
||||
return ApiResult.successNoData();
|
||||
}catch (Exception e){
|
||||
logger.error("CommonDataAsyncController error : " + e.getMessage());
|
||||
Util.logErrorStr(e, logger);
|
||||
Util.logErrorStr(e);
|
||||
return ApiResult.error("数据同步失败! [ " + e.getMessage() + " ]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.definitions;
|
||||
|
||||
import aiyh.utils.ThreadPoolConfig;
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.response_deal.mapper.ConfigMapper;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.mapper.XkHospitalDataAsyncMapper;
|
||||
import com.engine.common.service.impl.ThemeServiceImpl;
|
||||
import ln.LN;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/19 10:22
|
||||
*/
|
||||
public class XkHospitalCommonDefinition {
|
||||
/**
|
||||
* <h2>部门表名</h2>
|
||||
**/
|
||||
public static final String DEPARTMENT = "hrmdepartment";
|
||||
/**
|
||||
* <h2>人员表名</h2>
|
||||
**/
|
||||
public static final String HRM_RESOURCE = "hrmresource";
|
||||
/**
|
||||
* <h2>日志对象</h2>
|
||||
**/
|
||||
protected static final Logger log = Util.getLogger();
|
||||
/**
|
||||
* <h2>数据同步mapper</h2>
|
||||
**/
|
||||
protected final XkHospitalDataAsyncMapper dataAsyncMapper = Util.getMapper(XkHospitalDataAsyncMapper.class);
|
||||
/**
|
||||
* <h2>执行自定义sql</h2>
|
||||
**/
|
||||
protected final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class);
|
||||
/**
|
||||
* <h2>线程池对象</h2>
|
||||
**/
|
||||
protected final ExecutorService threadPoolInstance = ThreadPoolConfig.createThreadPoolInstance();
|
||||
/**
|
||||
* <h2>部门缓存</h2>
|
||||
**/
|
||||
protected static final DepartmentComInfo DEPARTMENT_COM_INFO = new DepartmentComInfo();
|
||||
|
||||
/**
|
||||
* <h2>系统主题接口</h2>
|
||||
**/
|
||||
protected static final ThemeServiceImpl THEME_SERVICE = new ThemeServiceImpl();
|
||||
/**
|
||||
* <h2>人员缓存</h2>
|
||||
**/
|
||||
protected static ResourceComInfo RESOURCE_COM_INFO = null;
|
||||
|
||||
protected final LN ln = new LN();
|
||||
|
||||
static {
|
||||
try {
|
||||
RESOURCE_COM_INFO = new ResourceComInfo();
|
||||
}catch (Exception e){
|
||||
log.error("人员缓存类初始化失败! " + e.getMessage());
|
||||
Util.logErrorStr(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.definitions.row;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
|
||||
import aiyh.utils.response_deal.mapper.ConfigMapper;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition;
|
||||
import ln.LN;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/18 11:13
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HrmDepartmentRowDefinition extends XkHospitalCommonDefinition implements RowDefinitionCallback {
|
||||
|
||||
private String table;
|
||||
|
||||
@Override
|
||||
public void rowHandle(RowDefinition rowDefinition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean judgmentRepetition(RowDefinition rowDefinition) {
|
||||
int orDetail = rowDefinition.getMainOrDetail();
|
||||
String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript());
|
||||
String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
|
||||
String dataId = configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
|
||||
if(ResponseConfigConstant.MAIN_TABLE == orDetail){
|
||||
if(StrUtil.isBlank(dataId)){
|
||||
int nextId = -1;
|
||||
if(HRM_RESOURCE.equals(table)){
|
||||
int licenseNum = ln.CkHrmnum();
|
||||
if(licenseNum < 1){
|
||||
throw new CustomerException("当前可用license数量不足!");
|
||||
}
|
||||
nextId = Util.getNextHrmId();
|
||||
}else if(DEPARTMENT.equals(table)){
|
||||
nextId = Util.getNextDepartmentId();
|
||||
}
|
||||
if(nextId < 0){
|
||||
throw new CustomerException("从 " + table + " 获取下一个id失败!");
|
||||
}
|
||||
rowDefinition.setDataId(nextId);
|
||||
if(HRM_RESOURCE.equals(table)){
|
||||
rowDefinition.getUpdateParam().put("id", nextId);
|
||||
rowDefinition.setConditionScript("");
|
||||
return false;
|
||||
}else {
|
||||
rowDefinition.getWhereParam().put("id", nextId);
|
||||
rowDefinition.setConditionScript(" id = #{whereItem.id}");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return StringUtils.isNotBlank(dataId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.definitions.table;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||
import aiyh.utils.response_deal.intfaces.TableDefinitionCallback;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import weaver.matrix.MatrixUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <h1>部门/人员同步表回调</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/19 10:11
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class HrmDepartmentTableDefinition extends XkHospitalCommonDefinition implements TableDefinitionCallback {
|
||||
|
||||
private String table;
|
||||
|
||||
@Override
|
||||
public void tableHandle(TableDefinition tableDefinition) {
|
||||
if(ResponseConfigConstant.DETAIL_TABLE == tableDefinition.getMainOrDetail()){
|
||||
List<RowDefinition> list = tableDefinition.getRowDefinitionList();
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
return;
|
||||
}
|
||||
for (RowDefinition rowDefinition : list) {
|
||||
Object mainId = rowDefinition.getUpdateParam().remove("mainid");
|
||||
if(!Objects.isNull(mainId)){
|
||||
rowDefinition.getUpdateParam().put("id", mainId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterHandle(TableDefinition tableDefinition, boolean flag) {
|
||||
List<Integer> idList = tableDefinition.getRowDefinitionList()
|
||||
.stream()
|
||||
.map(RowDefinition::getDataId)
|
||||
.filter(dataId -> dataId > 0)
|
||||
.collect(Collectors.toList());
|
||||
if (!flag) {
|
||||
if (CollectionUtils.isNotEmpty(idList) && !this.dataAsyncMapper.deleteHrmDepart(idList)) {
|
||||
log.error("删除 " + table + " 表数据失败!");
|
||||
}
|
||||
throw new CustomerException("同步 " + table + " 表数据失败!");
|
||||
} else {
|
||||
if (HRM_RESOURCE.equals(table)) {
|
||||
try {
|
||||
if(CollectionUtils.isNotEmpty(idList)) {
|
||||
List<Map<String, Integer>> hrmSubList = dataAsyncMapper.selectHrmSubByHrmIdList(idList);
|
||||
hrmSubList.forEach(map -> {
|
||||
THEME_SERVICE.createSubCompanyMenu(map.get("id"), map.get("sub"));
|
||||
});
|
||||
}
|
||||
RESOURCE_COM_INFO.removeCache();
|
||||
} catch (Exception e) {
|
||||
log.error("同步系统人员缓存error : " + e.getMessage());
|
||||
Util.logErrorStr(e);
|
||||
}
|
||||
} else if (DEPARTMENT.equals(table)) {
|
||||
threadPoolInstance.execute(() -> {
|
||||
try {
|
||||
DEPARTMENT_COM_INFO.removeCache();
|
||||
MatrixUtil.sysDepartmentData();
|
||||
} catch (Exception e) {
|
||||
log.error("同步系统部门缓存error : " + e.getMessage());
|
||||
Util.logErrorStr(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.entity;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/17 16:49
|
||||
*/
|
||||
public class XkDataAsyncConfig {
|
||||
private String modelTable;
|
||||
private String configId;
|
||||
private String tableType;
|
||||
private String cusTable;
|
||||
private String deleteInterface;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.entity;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/17 16:53
|
||||
*/
|
||||
public class XkDataAsyncConfigDetail {
|
||||
private String interfaceField;
|
||||
private int interfaceFieldType;
|
||||
private String modelField;
|
||||
private String cusField;
|
||||
private String oaFieldType;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>胸科医院数据同步mapper</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/19 10:19
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface XkHospitalDataAsyncMapper {
|
||||
|
||||
@Delete("delete from hrmdepartment where id in ($t{idList})")
|
||||
boolean deleteHrmDepart(@ParamMapper("idList") List<Integer> idList);
|
||||
|
||||
@Select("select id, subcompanyid1 as sub from hrmresource where id in ($t{idList})")
|
||||
@ToLowerCase
|
||||
List<Map<String, Integer>> selectHrmSubByHrmIdList(@ParamMapper("idList") List<Integer> idList);
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.service;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/18 10:36
|
||||
*/
|
||||
public interface XkHospitalCommonDataAsyncService {
|
||||
void async(String configCode, String type, Map<String, Object> params);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.service.impl;
|
||||
|
||||
import aiyh.utils.response_deal.ResponseMappingDeal;
|
||||
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
|
||||
import aiyh.utils.response_deal.intfaces.TableDefinitionCallback;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.definitions.row.HrmDepartmentRowDefinition;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.definitions.table.HrmDepartmentTableDefinition;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>数据同步</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/18 11:15
|
||||
*/
|
||||
public class XkHospitalCommonDataAsyncServiceImpl implements XkHospitalCommonDataAsyncService {
|
||||
|
||||
private static final Map<String, RowDefinitionCallback> CUS_ROW_DEFINITIONS = new HashMap<>();
|
||||
|
||||
private static final Map<String, TableDefinitionCallback> CUS_TABLE_DEFINITIONS = new HashMap<>();
|
||||
|
||||
static {
|
||||
CUS_ROW_DEFINITIONS.put("dept", new HrmDepartmentRowDefinition(XkHospitalCommonDefinition.DEPARTMENT));
|
||||
CUS_ROW_DEFINITIONS.put("hrm", new HrmDepartmentRowDefinition(XkHospitalCommonDefinition.HRM_RESOURCE));
|
||||
|
||||
CUS_TABLE_DEFINITIONS.put("dept", new HrmDepartmentTableDefinition(XkHospitalCommonDefinition.DEPARTMENT));
|
||||
CUS_TABLE_DEFINITIONS.put("hrm", new HrmDepartmentTableDefinition(XkHospitalCommonDefinition.HRM_RESOURCE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void async(String configCode, String type, Map<String, Object> params){
|
||||
ResponseMappingDeal deal = new ResponseMappingDeal();
|
||||
if(StrUtil.isNotBlank(type)){
|
||||
RowDefinitionCallback rowDefinitionCallback = CUS_ROW_DEFINITIONS.get(type);
|
||||
if(null != rowDefinitionCallback){
|
||||
deal.setRowCallback(rowDefinitionCallback);
|
||||
}
|
||||
TableDefinitionCallback tableDefinitionCallback = CUS_TABLE_DEFINITIONS.get(type);
|
||||
if(null != tableDefinitionCallback){
|
||||
deal.setTableCallback(tableDefinitionCallback);
|
||||
}
|
||||
}
|
||||
deal.doResponseSync(configCode, params);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package weaver.bokang.xiao.zxyh.depart_sync.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Depart 类是表示部门信息的实体类。
|
||||
*
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/21 11:11
|
||||
* @Description 此类用于封装部门信息,用于数据同步。
|
||||
**/
|
||||
@Data
|
||||
@XmlRootElement(name = "dept")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Depart {
|
||||
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private int deptId;
|
||||
|
||||
/**
|
||||
* 系统类型
|
||||
*/
|
||||
private String systemType;
|
||||
|
||||
/**
|
||||
* 系统编码
|
||||
*/
|
||||
private String systemCode;
|
||||
|
||||
/**
|
||||
* 业务名称
|
||||
*/
|
||||
private String businessName;
|
||||
|
||||
/**
|
||||
* 业务ID
|
||||
*/
|
||||
private String businessId;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package weaver.bokang.xiao.zxyh.depart_sync.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DepartVO 类是用于传递部门信息的实体类。
|
||||
*
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/21 11:10
|
||||
* @Description 此类用于封装发送部门信息的数据。
|
||||
**/
|
||||
@Data
|
||||
@XmlRootElement(name = "root")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class DepartVO {
|
||||
/**
|
||||
* 发送者名称
|
||||
*/
|
||||
private String sender;
|
||||
|
||||
/**
|
||||
* 接收者名称
|
||||
*/
|
||||
private String receiver;
|
||||
|
||||
/**
|
||||
* 传输数据
|
||||
*/
|
||||
private String trans;
|
||||
|
||||
/**
|
||||
* 交易流水号
|
||||
*/
|
||||
private String serials;
|
||||
|
||||
/**
|
||||
* 返回代码
|
||||
*/
|
||||
private String retCode;
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
private String retmsg;
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private boolean success;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 代码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*/
|
||||
@XmlElementWrapper(name = "deptList")
|
||||
private List<Depart> dept;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package weaver.bokang.xiao.zxyh.depart_sync.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* SendDTO 类是用于传递数据的实体类。
|
||||
*
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/21 11:10
|
||||
* @Description 此类用于封装发送数据的信息。
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@XmlRootElement(name = "root")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class SendDTO {
|
||||
|
||||
/**
|
||||
* 发送者名称
|
||||
*/
|
||||
private String sender;
|
||||
|
||||
/**
|
||||
* 接收者名称
|
||||
*/
|
||||
private String receiver;
|
||||
|
||||
/**
|
||||
* 传输数据
|
||||
*/
|
||||
private String trans;
|
||||
|
||||
/**
|
||||
* 交易流水号
|
||||
*/
|
||||
private String serials;
|
||||
|
||||
/**
|
||||
* 系统编码
|
||||
*/
|
||||
private String systemCode;
|
||||
|
||||
/**
|
||||
* 发送类型
|
||||
*/
|
||||
private String sendType;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package weaver.bokang.xiao.zxyh.depart_sync.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
import weaver.bokang.xiao.zxyh.depart_sync.entity.Depart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName SyncMapper
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/21 11:09
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
@SqlMapper
|
||||
public interface SyncMapper {
|
||||
|
||||
@Select("select * from uf_depart_info")
|
||||
List<Depart> queryDepartList();
|
||||
|
||||
@BatchUpdate("update uf_depart_info set dept_name = #{item.deptName}, dept_id = #{item.deptId}, system_type = #{item.systemType}, system_code = #{item.systemCode}, " +
|
||||
" business_name= #{item.businessName}, business_id = #{item.businessId} " +
|
||||
"where id = #{item.id}")
|
||||
boolean updateDepart(@BatchSqlArgs List<Depart> departList);
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package weaver.bokang.xiao.zxyh.depart_sync.schedule;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.action.CusBaseCronJob;
|
||||
import aiyh.utils.annotation.ActionDesc;
|
||||
import aiyh.utils.annotation.PrintParamMark;
|
||||
import aiyh.utils.annotation.RequiredMark;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.Setter;
|
||||
import weaver.bokang.xiao.zxyh.depart_sync.entity.Depart;
|
||||
import weaver.bokang.xiao.zxyh.depart_sync.entity.DepartVO;
|
||||
import weaver.bokang.xiao.zxyh.depart_sync.entity.SendDTO;
|
||||
import weaver.bokang.xiao.zxyh.depart_sync.mapper.SyncMapper;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.xiao.commons.utils.RequestUtil;
|
||||
import weaver.xiao.commons.utils.VerifyUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName DepartSyncSchedule
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/21 11:07
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
@Setter
|
||||
@ActionDesc(value = "同步总行部门信息", author = "bokang.xiao")
|
||||
public class DepartSyncSchedule extends CusBaseCronJob {
|
||||
|
||||
@RequiredMark("发送请求地址")
|
||||
@PrintParamMark
|
||||
private String sendUrl;
|
||||
|
||||
@RequiredMark("部门模块ID")
|
||||
@PrintParamMark
|
||||
private String departModeId;
|
||||
|
||||
@RequiredMark("发送者名称")
|
||||
@PrintParamMark
|
||||
private String sender;
|
||||
|
||||
@RequiredMark("接收者名称")
|
||||
@PrintParamMark
|
||||
private String receiver;
|
||||
|
||||
@RequiredMark("传输数据")
|
||||
@PrintParamMark
|
||||
private String trans;
|
||||
|
||||
@RequiredMark("系统编码")
|
||||
@PrintParamMark
|
||||
private String systemCode;
|
||||
|
||||
@RequiredMark("发送类型")
|
||||
@PrintParamMark
|
||||
private String sendType;
|
||||
|
||||
private final SyncMapper syncMapper = Util.getMapper(SyncMapper.class);
|
||||
|
||||
@Override
|
||||
public void runCode() throws IOException {
|
||||
try {
|
||||
List<Depart> sourceDepartList = syncMapper.queryDepartList();
|
||||
Map<Integer, Integer> departMap = new HashMap<>();
|
||||
if(Objects.nonNull(sourceDepartList) && !sourceDepartList.isEmpty()) {
|
||||
departMap = sourceDepartList.stream().collect(Collectors.toMap(Depart::getDeptId, Depart::getId));
|
||||
}
|
||||
log.info("sync depart departMap ==>"+JSON.toJSONString(departMap));
|
||||
SendDTO sendDTO = SendDTO.builder()
|
||||
.sendType(this.sendType)
|
||||
.sender(this.sender)
|
||||
.receiver(this.receiver)
|
||||
.trans(this.trans)
|
||||
.systemCode(this.systemCode)
|
||||
.serials(this.sender + TimeUtil.getFormartString(new Date(),"yyyyMMddHHmmSSsss")).build();
|
||||
log.info("sendDTO =>"+sendDTO);
|
||||
String sendXml = VerifyUtil.beanToXml(sendDTO);
|
||||
log.info("depart req param ==>"+sendXml);
|
||||
String resultXml = RequestUtil.sendToTPCG2(sendXml, sendUrl);
|
||||
if (!"".equals(resultXml)) {
|
||||
DepartVO departVO = VerifyUtil.xmlStrToObject(DepartVO.class, resultXml);
|
||||
log.info("depart List ==>"+ JSON.toJSONString(departVO));
|
||||
if(!departVO.isSuccess()){
|
||||
log.error("请求不成功");
|
||||
return;
|
||||
}
|
||||
List<Depart> departList = departVO.getDept();
|
||||
if(Objects.nonNull(departList) && !departList.isEmpty()){
|
||||
List<Integer> dataIdList = new ArrayList<>();
|
||||
for (Depart depart : departList) {
|
||||
if(departMap.containsKey(depart.getDeptId())){
|
||||
depart.setId(departMap.get(depart.getDeptId()));
|
||||
}else {
|
||||
int dataId = Util.getModeDataId("uf_depart_info", Util.getIntValue(departModeId), 1);
|
||||
depart.setId(dataId);
|
||||
dataIdList.add(dataId);
|
||||
}
|
||||
}
|
||||
syncMapper.updateDepart(departList);
|
||||
Util.rebuildModeDataShareByAsyncList(1,Util.getIntValue(departModeId),dataIdList);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("同步发生异常 ==>"+ Util.getErrString(e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -63,23 +63,31 @@ public class PushEmployeeCronJob extends BaseCronJob {
|
|||
HttpUtils httpUtils = new HttpUtils();
|
||||
|
||||
if(employeeList != null && employeeList.size() > 0){//遍历结果集
|
||||
|
||||
logger.info("人员记录条数:[" + employeeList.size() + "]");
|
||||
|
||||
for(Map<String,Object> employeeMap : employeeList){
|
||||
|
||||
int keyId = (int) employeeMap.get("code");
|
||||
int keyId = Util.getIntValue(Util.null2String(employeeMap.get("code")));
|
||||
|
||||
Map<String,String> dataMap = new HashMap<>();
|
||||
dataMap.put("code",Util.null2String(employeeMap.get("code")));
|
||||
dataMap.put("name",Util.null2String(employeeMap.get("name")));
|
||||
dataMap.put("id",Util.null2String(employeeMap.get("id")));
|
||||
|
||||
Map<String,String> header = new HashMap<>();
|
||||
header.put("Content-Type", HttpArgsType.APPLICATION_JSON);
|
||||
|
||||
try {
|
||||
ResponeVo responeVo = httpUtils.apiPostObject(pushEmployeeRequestURL,employeeMap,header);
|
||||
ResponeVo responeVo = httpUtils.apiPostObject(pushEmployeeRequestURL,dataMap,header);
|
||||
|
||||
if(responeVo.getCode() == VoucherConstants.REQUEST_SUCCESS_CODE){
|
||||
Map<String,Object> resultMap = responeVo.getResponseMap();
|
||||
|
||||
if(!resultMap.isEmpty()){
|
||||
int code = (int) resultMap.get("code");
|
||||
int code = Util.getIntValue(Util.null2String(resultMap.get("code")));
|
||||
|
||||
if(code == 1){
|
||||
if(code == 0){
|
||||
String pk = (String) resultMap.get("pk");
|
||||
|
||||
sqlMapper.writeBackKeyToEmployee(pk,keyId);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class PushModeDataUtil {
|
|||
*/
|
||||
private Map<String, Object> getConfiguration(Map<String, Object> configMap) {
|
||||
if(configMap != null && configMap.size() > 0){
|
||||
int mainKeyId = (int) configMap.get("id");
|
||||
int mainKeyId = Util.getIntValue(configMap.get("id").toString());
|
||||
|
||||
List<Map<String, Object>> fieldList = sqlMapper.getPushDataDetailConfiguration(mainKeyId);
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class PushModeDataUtil {
|
|||
//建模字段名称
|
||||
String fieldName = Util.null2String(fieldMap.get("fieldName"));
|
||||
//转换规则
|
||||
int changeRule = (int) fieldMap.get("changeRule");
|
||||
int changeRule = Util.getIntValue(fieldMap.get("changeRule").toString());
|
||||
//自定义规则
|
||||
String cusSQL = Util.null2String(fieldMap.get("cusSQL"));
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package weaver.weilin.zhu.asc.workflow;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.httpUtil.HttpArgsType;
|
||||
import aiyh.utils.httpUtil.ResponeVo;
|
||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.file.Prop;
|
||||
|
@ -11,6 +11,7 @@ import weaver.weilin.zhu.common.util.CommonUtil;
|
|||
import weaver.weilin.zhu.common.voucher.action.CusActionPostInterface;
|
||||
import weaver.weilin.zhu.common.voucher.action.ResultMessageUtil;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -29,7 +30,6 @@ public class VoucherPushAction implements CusActionPostInterface {
|
|||
private final Logger logger = Util.getLogger();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 后置处理方法
|
||||
*
|
||||
|
@ -44,6 +44,7 @@ public class VoucherPushAction implements CusActionPostInterface {
|
|||
JSONObject postObj = (JSONObject) params.get("pushJsonObject");
|
||||
Map<String,Object> workflowBaseMap = (Map<String,Object>) params.get("workflowBaseMap");
|
||||
Map<String,String> pathParam = (Map<String,String>) params.get("pathParam");
|
||||
String isArray = Util.null2String(params.get("isArray"));
|
||||
|
||||
|
||||
Map<String,Object> logMap = new HashMap<>();
|
||||
|
@ -57,13 +58,22 @@ public class VoucherPushAction implements CusActionPostInterface {
|
|||
String requestURL = Util.null2String(Prop.getPropValue("AscVoucher", "url"));
|
||||
|
||||
Map<String,String> headerMap = new HashMap<>();
|
||||
headerMap.put("Content-Type", HttpArgsType.APPLICATION_JSON);
|
||||
headerMap.put("Content-Type", MediaType.APPLICATION_JSON);
|
||||
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
|
||||
try {
|
||||
//进行接口数据推送
|
||||
ResponeVo responeVo = httpUtils.apiPostObject(requestURL, postObj, headerMap);
|
||||
ResponeVo responeVo ;
|
||||
|
||||
if("Y".equals(isArray)){
|
||||
JSONArray postArray = new JSONArray();
|
||||
postArray.add(postObj);
|
||||
|
||||
responeVo = httpUtils.apiPostObject(requestURL, postArray, headerMap);
|
||||
} else {
|
||||
responeVo = httpUtils.apiPostObject(requestURL, postObj, headerMap);
|
||||
}
|
||||
|
||||
if(responeVo != null && responeVo.getCode() == 200){
|
||||
logMap.put("message",responeVo.getEntityString());
|
||||
|
@ -71,6 +81,8 @@ public class VoucherPushAction implements CusActionPostInterface {
|
|||
//接口返回所有信息
|
||||
resultMessageUtil.setResponseBody(responeVo.getEntityString());
|
||||
|
||||
logger.info("接口响应信息:[" + responeVo.getEntityString() + "]");
|
||||
|
||||
Map<String,Object> resultMap = responeVo.getResponseMap();
|
||||
|
||||
if(resultMap != null){
|
||||
|
@ -97,7 +109,11 @@ public class VoucherPushAction implements CusActionPostInterface {
|
|||
|
||||
int modeid = Util.getIntValue(Prop.getPropValue("global", "interfacelog_modeid"));
|
||||
|
||||
CommonUtil.insertNewDataToMode(modeid,"uf_interface_log",logMap);
|
||||
CommonUtil commonUtil = new CommonUtil();
|
||||
|
||||
logger.info("日志信息:[" + logMap.toString() + "]");
|
||||
|
||||
commonUtil.insertNewDataToMode(modeid,"uf_interface_log",logMap);
|
||||
|
||||
return resultMessageUtil;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class CommonUtil {
|
|||
/**
|
||||
* 获取数据库操作接口
|
||||
*/
|
||||
private static final CommonSqlMapper sqlMapper = Util.getMapper(CommonSqlMapper.class);
|
||||
private final CommonSqlMapper sqlMapper = Util.getMapper(CommonSqlMapper.class);
|
||||
|
||||
/**
|
||||
* 获取字段详细信息
|
||||
|
@ -66,7 +66,7 @@ public class CommonUtil {
|
|||
* @param modeTableName 模块表名称
|
||||
* @return 模块ID
|
||||
*/
|
||||
public static int getModeIdByTableName(String modeTableName) {
|
||||
public int getModeIdByTableName(String modeTableName) {
|
||||
return sqlMapper.getModeIdByTableName(modeTableName);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class CommonUtil {
|
|||
* @param modeTableName 模块表名称
|
||||
* @param dataMap 数据集
|
||||
*/
|
||||
public static void insertNewDataToMode(int modeId,String modeTableName, Map<String,Object> dataMap){
|
||||
public void insertNewDataToMode(int modeId,String modeTableName, Map<String,Object> dataMap){
|
||||
//获取新的记录ID
|
||||
int newDataId = Util.getModeDataId(modeTableName,modeId,1);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||
* @author bleach
|
||||
* @version 2023-07-12
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface CommonSqlMapper {
|
||||
|
||||
/**
|
||||
|
@ -33,10 +34,10 @@ public interface CommonSqlMapper {
|
|||
|
||||
/**
|
||||
* 删除建模数据
|
||||
*
|
||||
* @param tableName 表单名称
|
||||
* @param dataId 数据ID
|
||||
* @return 更新结果
|
||||
* @param dataId 数据ID
|
||||
*/
|
||||
@Delete("delete from $t{tableName} where id = #{dataId}")
|
||||
boolean deleteRedundancyData(@ParamMapper("tableName") String tableName, @ParamMapper("dataId") int dataId);
|
||||
void deleteRedundancyData(@ParamMapper("tableName") String tableName, @ParamMapper("dataId") int dataId);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,12 @@ package weaver.weilin.zhu.common.voucher.action;
|
|||
import aiyh.utils.Util;
|
||||
import aiyh.utils.action.SafeCusBaseAction;
|
||||
import aiyh.utils.annotation.ActionDefaultTestValue;
|
||||
import aiyh.utils.annotation.ActionOptionalParam;
|
||||
import aiyh.utils.annotation.PrintParamMark;
|
||||
import aiyh.utils.annotation.RequiredMark;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.conn.RecordSet;
|
||||
|
@ -27,6 +30,8 @@ import java.util.Map;
|
|||
* @author bleach
|
||||
* @version 2023-07-10
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class CommonVoucherAction extends SafeCusBaseAction {
|
||||
|
||||
/**
|
||||
|
@ -42,8 +47,14 @@ public class CommonVoucherAction extends SafeCusBaseAction {
|
|||
/**
|
||||
* 自定义参数值
|
||||
*/
|
||||
@PrintParamMark
|
||||
@ActionOptionalParam(value = "", desc = "自定义参数值")
|
||||
private String cusParamValue;
|
||||
|
||||
@PrintParamMark
|
||||
@ActionOptionalParam(value = "N", desc = "推送的JSON数据是否为数组")
|
||||
private String isArray = "N";
|
||||
|
||||
/**
|
||||
* 后置实现类接口路径
|
||||
*/
|
||||
|
@ -81,7 +92,10 @@ public class CommonVoucherAction extends SafeCusBaseAction {
|
|||
|
||||
assert baseConfigDao != null;
|
||||
|
||||
voucherUtil.setThisUser(user);
|
||||
if(user != null){
|
||||
voucherUtil.setThisUser(user);
|
||||
}
|
||||
|
||||
voucherUtil.setObjectMappingDaoList(baseConfigDao.getObjectMappingDaoList());
|
||||
voucherUtil.setNodeFieldMappingDaoList(baseConfigDao.getNodeFieldMappingDaoList());
|
||||
|
||||
|
@ -99,18 +113,32 @@ public class CommonVoucherAction extends SafeCusBaseAction {
|
|||
logger.info("当前流程不满足自定义条件!");
|
||||
}
|
||||
|
||||
rs.beforFirst();
|
||||
Map<String,Object> mainTableInfo = Util.recordSet2Map(rs);
|
||||
|
||||
logger.info("主表字段信息:[" + JSONObject.toJSONString(mainTableInfo) + "]");
|
||||
|
||||
voucherUtil.setMainTableInfo(mainTableInfo);
|
||||
|
||||
workflowBaseMap.put("requestId",requestId);
|
||||
workflowBaseMap.put("billTableName",billTable);
|
||||
workflowBaseMap.put("mainId",Util.null2String(rs.getString("id")));
|
||||
|
||||
logger.info(workflowBaseMap.toString());
|
||||
|
||||
//推送的报文
|
||||
JSONObject postJsonObj = new JSONObject();
|
||||
|
||||
StringBuilder postXmlObj = new StringBuilder();
|
||||
|
||||
if(baseConfigDao.getDataFormat() == 1){
|
||||
postXmlObj = voucherUtil.recursionGenerateXML("",null,null,0,0,0);
|
||||
postXmlObj = voucherUtil.generateXML(mainTableInfo);
|
||||
|
||||
logger.info("请求的XML报文信息:[" + postXmlObj + "]");
|
||||
} else {
|
||||
//推送的报文
|
||||
postJsonObj = voucherUtil.recursionGenerateJsonObject("",null,null,0,0,0);
|
||||
postJsonObj = voucherUtil.generateJsonObject(mainTableInfo);
|
||||
logger.info("请求的JSON报文信息:[" + postJsonObj + "]");
|
||||
}
|
||||
|
||||
if(postJsonObj != null || postXmlObj.length() > 0){
|
||||
|
@ -126,6 +154,7 @@ public class CommonVoucherAction extends SafeCusBaseAction {
|
|||
paramsMap.put("requestInfo",requestInfo);
|
||||
paramsMap.put("workflowBaseMap",workflowBaseMap);
|
||||
paramsMap.put("userInfo",user);
|
||||
paramsMap.put("isArray",isArray);
|
||||
|
||||
ResultMessageUtil resultMessageUtil = executePostProcessor(className,paramsMap);
|
||||
|
||||
|
@ -190,6 +219,7 @@ public class CommonVoucherAction extends SafeCusBaseAction {
|
|||
try {
|
||||
aClass = Class.forName(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error(Util.getErrString(e));
|
||||
throw new IllegalArgumentException("未能找到自定义action接口处理方法:" + className);
|
||||
}
|
||||
Constructor<?> constructor;
|
||||
|
@ -206,25 +236,9 @@ public class CommonVoucherAction extends SafeCusBaseAction {
|
|||
try {
|
||||
o = (CusActionPostInterface) constructor.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
logger.error(Util.getErrString(e));
|
||||
throw new IllegalArgumentException("无法构造" + className + "对象!");
|
||||
}
|
||||
return o.postProcessor(params);
|
||||
}
|
||||
|
||||
|
||||
public String getCusParamValue() {
|
||||
return cusParamValue;
|
||||
}
|
||||
|
||||
public void setCusParamValue(String cusParamValue) {
|
||||
this.cusParamValue = cusParamValue;
|
||||
}
|
||||
|
||||
public String getImplementorPath() {
|
||||
return implementorPath;
|
||||
}
|
||||
|
||||
public void setImplementorPath(String implementorPath) {
|
||||
this.implementorPath = implementorPath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,13 @@ public class FieldChangeRuleMethod {
|
|||
if(StringUtils.isNotBlank(fieldName)){
|
||||
int viewType = fieldInfo.getViewType();
|
||||
|
||||
if(viewType == 0){
|
||||
fieldValue = Util.null2String(param.getRs().getString(fieldName));
|
||||
if(viewType == 0 && param.getMainTableInfo() != null){
|
||||
//fieldValue = Util.null2String(param.getRs().getString(fieldName));
|
||||
Map<String, Object> mainTableInfo = param.getMainTableInfo();
|
||||
|
||||
if(mainTableInfo.containsKey(fieldName)){
|
||||
fieldValue = Util.null2String(mainTableInfo.get(fieldName));
|
||||
}
|
||||
} else if(viewType == 1 && param.getRs_detail() != null){
|
||||
fieldValue = Util.null2String(param.getRs_detail().getString(fieldName));
|
||||
}
|
||||
|
@ -173,11 +178,11 @@ public class FieldChangeRuleMethod {
|
|||
}
|
||||
|
||||
if(param.getThisUser() != null){
|
||||
cusSQL = cusSQL.replace("{userId}", String.valueOf(param.getThisUser().getUID()));
|
||||
cusSQL = cusSQL.replace("{?userId}", String.valueOf(param.getThisUser().getUID()));
|
||||
|
||||
cusSQL = cusSQL.replace("{departmentId}", String.valueOf(param.getThisUser().getUserDepartment()));
|
||||
cusSQL = cusSQL.replace("{?departmentId}", String.valueOf(param.getThisUser().getUserDepartment()));
|
||||
|
||||
cusSQL = cusSQL.replace("{subCompanyId}", String.valueOf(param.getThisUser().getUserSubCompany1()));
|
||||
cusSQL = cusSQL.replace("{?subCompanyId}", String.valueOf(param.getThisUser().getUserSubCompany1()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ public class RuleMethodParam {
|
|||
*/
|
||||
private Map<String,Object> workflowBaseMap;
|
||||
|
||||
/**
|
||||
* 流程主表信息
|
||||
*/
|
||||
private Map<String,Object> mainTableInfo;
|
||||
|
||||
/**
|
||||
* 明细序列
|
||||
*/
|
||||
|
|
|
@ -2,6 +2,7 @@ package weaver.weilin.zhu.common.voucher.mapper;
|
|||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.weilin.zhu.common.util.FieldDetailInfo;
|
||||
import weaver.weilin.zhu.common.voucher.entity.BaseConfigDao;
|
||||
import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao;
|
||||
import weaver.weilin.zhu.common.voucher.entity.ObjectMappingDao;
|
||||
|
@ -21,7 +22,7 @@ public interface CommVoucherSqlMapper {
|
|||
* @param workflowIds 流程类型ID
|
||||
* @return 配置信息
|
||||
*/
|
||||
@Select("select * from uf_comm_voucher where wfId in ($t{workflowIds})")
|
||||
@Select("select * from uf_comm_voucher where workflowId in ($t{workflowIds})")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(
|
||||
property = "objectMappingDaoList",
|
||||
|
@ -34,6 +35,7 @@ public interface CommVoucherSqlMapper {
|
|||
id = @Id(value = Integer.class,methodId = 2)
|
||||
)
|
||||
})
|
||||
@CaseConversion(value = false)
|
||||
BaseConfigDao getConfigurationByWorkflowId(@ParamMapper("workflowIds") String workflowIds);
|
||||
|
||||
|
||||
|
@ -43,7 +45,7 @@ public interface CommVoucherSqlMapper {
|
|||
* @param workflowIds 流程类型ID
|
||||
* @return 配置信息
|
||||
*/
|
||||
@Select("select * from uf_comm_voucher where wfId in ($t{workflowIds}) and cusParamValue = #{cusParamValue}")
|
||||
@Select("select * from uf_comm_voucher where workflowId in ($t{workflowIds}) and cusParamValue = #{cusParamValue}")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(
|
||||
property = "objectMappingDaoList",
|
||||
|
@ -56,6 +58,7 @@ public interface CommVoucherSqlMapper {
|
|||
id = @Id(value = Integer.class,methodId = 2)
|
||||
)
|
||||
})
|
||||
@CaseConversion(value = false)
|
||||
BaseConfigDao getConfigurationByWorkflowIdAndCondition(@ParamMapper("workflowIds") String workflowIds,@ParamMapper("cusParamValue") String cusParamValue);
|
||||
|
||||
|
||||
|
@ -66,11 +69,11 @@ public interface CommVoucherSqlMapper {
|
|||
* @return 映射详细信息
|
||||
*/
|
||||
@Select("select * from uf_comm_voucher_dt1 where mainId = #{mainId}")
|
||||
@CaseConversion(value = false)
|
||||
@CollectionMethod(value = 1,desc = "获取对象与流程明细表映射配置信息")
|
||||
List<ObjectMappingDao> getObjectMappingByMainKeyId(@ParamMapper("mainId") int mainId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取对象与流程明细表映射配置信息
|
||||
* @param mainId 主表主键ID
|
||||
|
@ -81,8 +84,7 @@ public interface CommVoucherSqlMapper {
|
|||
@Association(
|
||||
property = "wfField",
|
||||
column = "wfField",
|
||||
select = "weaver.weilin.zhu.common.util.CommonUtil.getFieldDetailInfo",
|
||||
id = @Id(Integer.class)
|
||||
id = @Id(value = Integer.class,methodId = 3)
|
||||
)
|
||||
})
|
||||
@CaseConversion(value = false)
|
||||
|
@ -90,6 +92,30 @@ public interface CommVoucherSqlMapper {
|
|||
List<NodeFieldMappingDao> getNodeFieldMappingByMainKeyId(@ParamMapper("mainId") int mainId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取字段信息
|
||||
* @param fieldId 字段ID
|
||||
* @return 字段信息
|
||||
*/
|
||||
@Select("select id,fieldName,viewType,detailTable,fieldDbType from workflow_billField where id = #{fieldId}")
|
||||
@CaseConversion(value = false)
|
||||
@AssociationMethod(value = 3,desc = "获取字段详细信息")
|
||||
FieldDetailInfo getFieldDetailInfo(@ParamMapper("fieldId") int fieldId);
|
||||
/*
|
||||
@Select("select id,fieldName,viewType,detailTable,fieldDbType,case when VIEWTYPE = 1 and CHARINDEX('_dt',DETAILTABLE) > 0 then \n" +
|
||||
"\t substring(DETAILTABLE,CHARINDEX('_dt',DETAILTABLE) + 3)\n" +
|
||||
"else 0\n" +
|
||||
"end detailIndex from workflow_billField where id = #{fieldId}")
|
||||
|
||||
|
||||
@Select("select id,fieldName,viewType,detailTable,fieldDbType,case when VIEWTYPE = 1 and LOCATE('_dt',DETAILTABLE) > 0 then \n" +
|
||||
"\t substr(DETAILTABLE,LOCATE('_dt',DETAILTABLE) + 3)\n" +
|
||||
"else 0\n" +
|
||||
"end detailIndex from workflow_billField where id = #{fieldId}")
|
||||
@CaseConversion(value = false)
|
||||
@AssociationMethod(value = 3,desc = "获取字段详细信息")
|
||||
FieldDetailInfo getFieldDetailInfo(@ParamMapper("fieldId") int fieldId);
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查询流程主表的信息
|
||||
|
|
|
@ -3,7 +3,10 @@ package weaver.weilin.zhu.common.voucher.util;
|
|||
import aiyh.utils.Util;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.hrm.User;
|
||||
import weaver.weilin.zhu.common.util.FieldDetailInfo;
|
||||
|
@ -27,6 +30,8 @@ import java.util.Map;
|
|||
* @author bleach
|
||||
* @version 2023-07-10
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class CommonVoucherUtil {
|
||||
|
||||
/**
|
||||
|
@ -34,12 +39,19 @@ public class CommonVoucherUtil {
|
|||
*/
|
||||
private final CommVoucherSqlMapper sqlMapper = Util.getMapper(CommVoucherSqlMapper.class);
|
||||
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
/**
|
||||
* 流程基础信息
|
||||
*/
|
||||
private Map<String,Object> workflowBaseMap;
|
||||
|
||||
|
||||
/**
|
||||
* 流程主表信息
|
||||
*/
|
||||
private Map<String,Object> mainTableInfo;
|
||||
|
||||
/**
|
||||
* 当前用户
|
||||
*/
|
||||
|
@ -65,7 +77,7 @@ public class CommonVoucherUtil {
|
|||
* @return 配置信息
|
||||
*/
|
||||
public BaseConfigDao getConfigurationByWorkflowId(String workflowId,String cusParamValue){
|
||||
BaseConfigDao dao = new BaseConfigDao();
|
||||
BaseConfigDao dao ;
|
||||
|
||||
//获取该流程类型对应的所有版本ID
|
||||
String allWorkflowIds = WorkflowVersion.getAllVersionStringByWFIDs(workflowId);
|
||||
|
@ -79,20 +91,49 @@ public class CommonVoucherUtil {
|
|||
return dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置生成JSON对象
|
||||
* @return 返回生成JSON对象
|
||||
*/
|
||||
public JSONObject generateJsonObject(Map<String,Object> mainTableInfo){
|
||||
|
||||
if(this.mainTableInfo == null || this.mainTableInfo.size() == 0){
|
||||
this.mainTableInfo = mainTableInfo;
|
||||
}
|
||||
|
||||
return recursionGenerateJsonObject("",null,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据配置生成JSON对象
|
||||
* @return 返回生成JSON对象
|
||||
*/
|
||||
public StringBuilder generateXML(Map<String,Object> mainTableInfo){
|
||||
|
||||
if(this.mainTableInfo == null || this.mainTableInfo.size() == 0){
|
||||
this.mainTableInfo = mainTableInfo;
|
||||
}
|
||||
|
||||
return recursionGenerateXML("",null,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归生成JSON对象
|
||||
* @param parentNode 父节点名称
|
||||
* @param rs 流程主表数据集
|
||||
* @param rs_detail 流程某个明细表某行数据集
|
||||
* @param dtIndex 明细序列
|
||||
* @param itemDirection 借贷方向
|
||||
* @param rowNum 明细序号
|
||||
* @return JSON对象
|
||||
*/
|
||||
public JSONObject recursionGenerateJsonObject(String parentNode, RecordSet rs,RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){
|
||||
public JSONObject recursionGenerateJsonObject(String parentNode, RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
for(NodeFieldMappingDao nodeFieldMappingDao : nodeFieldMappingDaoList){
|
||||
logger.info("nodeFieldMappingDao:" + nodeFieldMappingDao.toString());
|
||||
|
||||
//节点名称
|
||||
String _nodeName = nodeFieldMappingDao.getNodeName();
|
||||
|
||||
|
@ -109,9 +150,12 @@ public class CommonVoucherUtil {
|
|||
|
||||
int _nodeType = nodeFieldMappingDao.getNodeType();
|
||||
|
||||
|
||||
if(itemDirection > 0){//说明为会计分录
|
||||
String _entriesDirection = nodeFieldMappingDao.getEntriesDirection();
|
||||
|
||||
//System.out.println("_entriesDirection:" + _entriesDirection );
|
||||
|
||||
if(!_entriesDirection.contains(String.valueOf(itemDirection))){//传进来的会计分录方向与当前不一致
|
||||
continue;
|
||||
}
|
||||
|
@ -124,20 +168,29 @@ public class CommonVoucherUtil {
|
|||
int _viewType = workflowField.getViewType();
|
||||
|
||||
int _detailIndex = workflowField.getDetailIndex();
|
||||
|
||||
String _detailTableName = Util.null2String(workflowField.getDetailTable());
|
||||
|
||||
if(_detailIndex == -1 && StringUtils.isNotBlank(_detailTableName)){
|
||||
_detailIndex = Util.getIntValue(_detailTableName.substring(_detailTableName.indexOf("_dt") + 3),-1);
|
||||
}
|
||||
|
||||
if(_viewType == 1 && _detailIndex != dtIndex){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
RuleMethodParam param = new RuleMethodParam();
|
||||
param.setRs(rs);
|
||||
//param.setRs(rs);
|
||||
param.setRs_detail(rs_detail);
|
||||
param.setWorkflowBaseMap(workflowBaseMap);
|
||||
param.setRowNum(rowNum);
|
||||
param.setThisUser(thisUser);
|
||||
param.setMainTableInfo(mainTableInfo);
|
||||
|
||||
switch (_nodeType){
|
||||
case VoucherConstants.Node_Type_Comm_Text:
|
||||
|
||||
String nodeValue = FieldChangeRuleMethod.VALUE_RULE_FUNCTION.get(nodeFieldMappingDao.getChangeRule()).apply(nodeFieldMappingDao, param);
|
||||
|
||||
if(nodeFieldMappingDao.getSpecialAttr() == 1 && Util.getDoubleValue(nodeValue,0.0) == 0){
|
||||
|
@ -148,7 +201,7 @@ public class CommonVoucherUtil {
|
|||
|
||||
break;
|
||||
case VoucherConstants.Node_Type_Comm_Object:
|
||||
JSONObject commObj = recursionGenerateJsonObject(_nodeName,rs,rs_detail,dtIndex,itemDirection,rowNum);
|
||||
JSONObject commObj = recursionGenerateJsonObject(_nodeName,rs_detail,dtIndex,itemDirection,rowNum);
|
||||
|
||||
jsonObject.put(_nodeName,commObj);
|
||||
break;
|
||||
|
@ -170,12 +223,13 @@ public class CommonVoucherUtil {
|
|||
int _rowNum = 1;
|
||||
|
||||
for(ObjectMappingDao objectMappingDao : objectMappingDaoList){
|
||||
|
||||
String _objectName = objectMappingDao.getObjectName();
|
||||
|
||||
//别名
|
||||
String alias = objectMappingDao.getAlias();
|
||||
|
||||
if(!_objectName.equals(_nodeName) || (StringUtils.isNotBlank(alias) && !alias.equals(_nodeName))){//对象节点名称 与当前节点不一致
|
||||
if(!_objectName.equals(_nodeName)){//对象节点名称 与当前节点不一致
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -204,7 +258,7 @@ public class CommonVoucherUtil {
|
|||
|
||||
while(_rs_detail.next()){
|
||||
for(String direction : Util.TokenizerString2(_entriesDirection,",")) {
|
||||
JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode, rs, _rs_detail, _dtIndex, Util.getIntValue(direction), _rowNum++);
|
||||
JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode, _rs_detail, _dtIndex, Util.getIntValue(direction), _rowNum++);
|
||||
|
||||
if(itemObj == null || itemObj.isEmpty()){
|
||||
_rowNum--;
|
||||
|
@ -215,7 +269,7 @@ public class CommonVoucherUtil {
|
|||
}
|
||||
} else {//说明信息来自主表
|
||||
for(String direction : Util.TokenizerString2(_entriesDirection,",")){
|
||||
JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode,rs,null,0,Util.getIntValue(direction),_rowNum++);
|
||||
JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode,null,0,Util.getIntValue(direction),_rowNum++);
|
||||
|
||||
if(itemObj == null || itemObj.isEmpty()){
|
||||
_rowNum--;
|
||||
|
@ -235,17 +289,17 @@ public class CommonVoucherUtil {
|
|||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归生成XML字符串
|
||||
* @param parentNode 父节点名称
|
||||
* @param rs 流程主表数据集
|
||||
* @param rs_detail 流程某个明细表某行数据集
|
||||
* @param dtIndex 明细序列
|
||||
* @param itemDirection 借贷方向
|
||||
* @param rowNum 明细序号
|
||||
* @return XML字符串
|
||||
*/
|
||||
public StringBuilder recursionGenerateXML(String parentNode, RecordSet rs,RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){
|
||||
public StringBuilder recursionGenerateXML(String parentNode, RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){
|
||||
StringBuilder xmlBuilder = new StringBuilder();
|
||||
for(NodeFieldMappingDao nodeFieldMappingDao : nodeFieldMappingDaoList) {
|
||||
//节点名称
|
||||
|
@ -279,17 +333,25 @@ public class CommonVoucherUtil {
|
|||
int _viewType = workflowField.getViewType();
|
||||
|
||||
int _detailIndex = workflowField.getDetailIndex();
|
||||
if (_viewType == 1 && _detailIndex != dtIndex) {
|
||||
|
||||
String _detailTableName = Util.null2String(workflowField.getDetailTable());
|
||||
|
||||
if(_detailIndex == -1 && StringUtils.isNotBlank(_detailTableName)){
|
||||
_detailIndex = Util.getIntValue(_detailTableName.substring(_detailTableName.indexOf("_dt") + 3),-1);
|
||||
}
|
||||
|
||||
if(_viewType == 1 && _detailIndex != dtIndex){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
RuleMethodParam param = new RuleMethodParam();
|
||||
param.setRs(rs);
|
||||
//param.setRs(rs);
|
||||
param.setRs_detail(rs_detail);
|
||||
param.setWorkflowBaseMap(workflowBaseMap);
|
||||
param.setRowNum(rowNum);
|
||||
param.setThisUser(thisUser);
|
||||
param.setMainTableInfo(mainTableInfo);
|
||||
|
||||
switch (_nodeType) {
|
||||
case VoucherConstants.Node_Type_Comm_Text:
|
||||
|
@ -306,7 +368,7 @@ public class CommonVoucherUtil {
|
|||
break;
|
||||
|
||||
case VoucherConstants.Node_Type_Comm_Object:
|
||||
StringBuilder innerXML = recursionGenerateXML(_nodeName,rs,rs_detail,dtIndex,itemDirection,rowNum);
|
||||
StringBuilder innerXML = recursionGenerateXML(_nodeName,rs_detail,dtIndex,itemDirection,rowNum);
|
||||
xmlBuilder.append("<").append(_nodeName).append(">");
|
||||
xmlBuilder.append(innerXML);
|
||||
xmlBuilder.append("</").append(_nodeName).append(">\n");
|
||||
|
@ -321,7 +383,7 @@ public class CommonVoucherUtil {
|
|||
//别名
|
||||
String alias = objectMappingDao.getAlias();
|
||||
|
||||
if (!_objectName.equals(_nodeName) || (StringUtils.isNotBlank(alias) && !alias.equals(_nodeName))) {//对象节点名称 与当前节点不一致
|
||||
if(!_objectName.equals(_nodeName)){//对象节点名称 与当前节点不一致
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -350,7 +412,7 @@ public class CommonVoucherUtil {
|
|||
|
||||
while (_rs_detail.next()) {
|
||||
for (String direction : Util.TokenizerString2(_entriesDirection, ",")) {
|
||||
StringBuilder innerItem = recursionGenerateXML(tmpParentNode,rs,_rs_detail,_dtIndex,Util.getIntValue(direction),_rowNum);
|
||||
StringBuilder innerItem = recursionGenerateXML(tmpParentNode,_rs_detail,_dtIndex,Util.getIntValue(direction),_rowNum);
|
||||
|
||||
if(innerItem != null && innerItem.length() > 0){
|
||||
xmlBuilder.append("<").append(_nodeName).append(">");
|
||||
|
@ -363,7 +425,7 @@ public class CommonVoucherUtil {
|
|||
}
|
||||
} else { //说明数据来自主表
|
||||
for(String direction : Util.TokenizerString2(_entriesDirection,",")){
|
||||
StringBuilder innerItem = recursionGenerateXML(tmpParentNode,rs,null,0,Util.getIntValue(direction),_rowNum++);
|
||||
StringBuilder innerItem = recursionGenerateXML(tmpParentNode,null,0,Util.getIntValue(direction),_rowNum++);
|
||||
|
||||
if(innerItem != null && innerItem.length() > 0){
|
||||
xmlBuilder.append("<").append(_nodeName).append(">");
|
||||
|
@ -381,36 +443,4 @@ public class CommonVoucherUtil {
|
|||
}
|
||||
return xmlBuilder;
|
||||
}
|
||||
|
||||
public User getThisUser() {
|
||||
return thisUser;
|
||||
}
|
||||
|
||||
public void setThisUser(User thisUser) {
|
||||
this.thisUser = thisUser;
|
||||
}
|
||||
|
||||
public Map<String, Object> getWorkflowBaseMap() {
|
||||
return workflowBaseMap;
|
||||
}
|
||||
|
||||
public void setWorkflowBaseMap(Map<String, Object> workflowBaseMap) {
|
||||
this.workflowBaseMap = workflowBaseMap;
|
||||
}
|
||||
|
||||
public List<ObjectMappingDao> getObjectMappingDaoList() {
|
||||
return objectMappingDaoList;
|
||||
}
|
||||
|
||||
public void setObjectMappingDaoList(List<ObjectMappingDao> objectMappingDaoList) {
|
||||
this.objectMappingDaoList = objectMappingDaoList;
|
||||
}
|
||||
|
||||
public List<NodeFieldMappingDao> getNodeFieldMappingDaoList() {
|
||||
return nodeFieldMappingDaoList;
|
||||
}
|
||||
|
||||
public void setNodeFieldMappingDaoList(List<NodeFieldMappingDao> nodeFieldMappingDaoList) {
|
||||
this.nodeFieldMappingDaoList = nodeFieldMappingDaoList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package weaver.weilin.zhu.xyzq.scheduled.entity;
|
||||
|
||||
import aiyh.utils.entity.FieldViewInfo;
|
||||
import lombok.Data;
|
||||
import weaver.weilin.zhu.common.util.FieldDetailInfo;
|
||||
|
||||
/**
|
||||
* 兴业证券
|
||||
|
@ -15,7 +15,7 @@ public class SyncConfigDetailDao {
|
|||
/**
|
||||
* 建模模块字段信息
|
||||
*/
|
||||
private FieldViewInfo modeField;
|
||||
private FieldDetailInfo modeField;
|
||||
|
||||
/**
|
||||
* 接口字段名称
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package weaver.weilin.zhu.xyzq.scheduled.sqlmapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
import weaver.weilin.zhu.common.util.FieldDetailInfo;
|
||||
import weaver.weilin.zhu.xyzq.scheduled.entity.SyncConfigDao;
|
||||
import weaver.weilin.zhu.xyzq.scheduled.entity.SyncConfigDetailDao;
|
||||
|
||||
|
@ -32,10 +33,10 @@ public interface OrganizationSyncSqlMapper {
|
|||
@Association(
|
||||
property = "foreignKeyField",
|
||||
column = "foreignKeyField",
|
||||
select = "weaver.common.util.CommonUtil.getFieldInfo",
|
||||
id = @Id(Integer.class)
|
||||
id = @Id(value = Integer.class,methodId = 2)
|
||||
)
|
||||
})
|
||||
@CaseConversion(value = false)
|
||||
SyncConfigDao getConfigurationByKeyId(@ParamMapper("keyId") int keyId);
|
||||
|
||||
/**
|
||||
|
@ -48,13 +49,23 @@ public interface OrganizationSyncSqlMapper {
|
|||
@Association(
|
||||
property = "modeField",
|
||||
column = "modeField",
|
||||
select = "weaver.weilin.zhu.common.util.CommonUtil.getFieldDetailInfo",
|
||||
id = @Id(Integer.class)
|
||||
id = @Id(value = Integer.class,methodId = 2)
|
||||
)
|
||||
})
|
||||
@CollectionMethod(value = 1,desc = "获取详细的字段配置信息")
|
||||
List<SyncConfigDetailDao> getConfigurationDetailByMainKeyId(@ParamMapper("mainId") int mainId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取字段信息
|
||||
* @param fieldId 字段ID
|
||||
* @return 字段信息
|
||||
*/
|
||||
@Select("select id,fieldName,viewType,detailTable,fieldDbType from workflow_billField where id = #{fieldId}")
|
||||
@CaseConversion(value = false)
|
||||
@AssociationMethod(value = 2,desc = "获取字段详细信息")
|
||||
FieldDetailInfo getFieldDetailInfo(@ParamMapper("fieldId") int fieldId);
|
||||
|
||||
/**
|
||||
* 获取当前模块中已存在记录集合
|
||||
* @param foreignKeyFieldName 外键字段名称
|
||||
|
|
|
@ -2,6 +2,7 @@ package weaver.xiao.commons.utils;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.entity.ContentType;
|
||||
|
@ -13,12 +14,13 @@ import org.apache.http.util.EntityUtils;
|
|||
import weaver.wechat.request.HttpManager;
|
||||
import weaver.xiao.commons.exception.RequestException;
|
||||
import weaver.zwl.common.ToolUtil;
|
||||
import weaver.zwl.common.logging.Logger;
|
||||
import weaver.zwl.common.logging.LoggerFactory;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -30,6 +32,8 @@ import java.util.Map;
|
|||
|
||||
public class RequestUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger();
|
||||
|
||||
public static <T> T apiRequest(RequestBaseInfo requestInfo, Class<T> tClass){
|
||||
|
||||
Map<String,String> headers = requestInfo.getHeaders();
|
||||
|
@ -135,6 +139,50 @@ public class RequestUtil {
|
|||
return res;
|
||||
}
|
||||
|
||||
public static String sendToTPCG2(String xml, String URL) {
|
||||
byte[] data = xml.getBytes();
|
||||
InputStream instr = null;
|
||||
String res = "";
|
||||
try {
|
||||
logger.info("--- 开始调用外联平台接口 url => " + URL + " ---");
|
||||
java.net.URL url = new URL(URL);
|
||||
URLConnection urlCon = url.openConnection();
|
||||
int time = 180000;
|
||||
urlCon.setConnectTimeout(time);
|
||||
urlCon.setReadTimeout(time);
|
||||
urlCon.setDoOutput(true);
|
||||
urlCon.setDoInput(true);
|
||||
urlCon.setUseCaches(false);
|
||||
urlCon.setRequestProperty("content-Type", "application/xml");
|
||||
urlCon.setRequestProperty("charset", "utf-8");
|
||||
DataOutputStream printout = new DataOutputStream(
|
||||
urlCon.getOutputStream());
|
||||
printout.write(data);
|
||||
printout.flush();
|
||||
printout.close();
|
||||
instr = urlCon.getInputStream();
|
||||
byte[] bis = IOUtils.toByteArray(instr);
|
||||
res = new String(bis, StandardCharsets.UTF_8);
|
||||
if ("".equals(res.trim())) {
|
||||
throw new RuntimeException("调用 " +URL + " 接口响应为空!");
|
||||
}
|
||||
logger.info("外联平台返回信息 => " + res);
|
||||
return res;
|
||||
} catch (IOException e) {
|
||||
logger.info("异常[" + e.getMessage() + "]");
|
||||
throw new RuntimeException(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (instr != null) {
|
||||
instr.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String serializableUrl(String url,Map<String,Object> params){
|
||||
if(params == null || params.isEmpty()){
|
||||
return url;
|
||||
|
|
|
@ -130,6 +130,27 @@ public class VerifyUtil {
|
|||
return xmlStr;
|
||||
}
|
||||
|
||||
public static <T> String beanToXml(T t){
|
||||
String xmlStr = "";
|
||||
try {
|
||||
//1、创建上下文
|
||||
JAXBContext context = JAXBContext.newInstance(t.getClass());
|
||||
StringWriter writer = new StringWriter();
|
||||
//2、创建Marshaller 这个是用于转换成xml的
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
//3、设置marshaller的属性
|
||||
//JAXB_FORMATTED_OUTPUT:格式化
|
||||
//JAXB_ENCODING:编码格式
|
||||
// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||
//4、将实体类读取到writer中
|
||||
marshaller.marshal(t, writer);
|
||||
xmlStr = writer.toString();
|
||||
}catch (Exception e){
|
||||
logger.info("java bean 转换 xml异常 ==>"+LogUtil.getExceptionStr(e));
|
||||
}
|
||||
return xmlStr;
|
||||
}
|
||||
|
||||
public static String mapToXml(Map<String, Object> map) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append("\n").append("<root>").append("\n");
|
||||
|
|
|
@ -431,7 +431,7 @@ public class ToolUtilNew extends ToolUtil{
|
|||
public static String getModeTableById(int modeId){
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
if(rs.executeQuery("select wb.tablename from modeInfo m inner join workflow_bill wb on m.formid = wb.id where m.id = ?") && rs.next()){
|
||||
if(rs.executeQuery("select wb.tablename from modeInfo m inner join workflow_bill wb on m.formid = wb.id where m.id = ?",modeId) && rs.next()){
|
||||
return Util.null2String(rs.getString(1));
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -56,6 +56,7 @@ import weaver.bokang.xiao.zscq.action.StatusChangeAction;
|
|||
import weaver.bokang.xiao.zscq.config.service.ModeChangeService;
|
||||
import weaver.bokang.xiao.zscq.store.TableNameStore;
|
||||
import weaver.bokang.xiao.zxyh.RepeatSubmitAction;
|
||||
import weaver.bokang.xiao.zxyh.depart_sync.schedule.DepartSyncSchedule;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.hrm.User;
|
||||
|
@ -85,7 +86,7 @@ public class NormalTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void testWord(){
|
||||
GenerateFileUtil.createCronJobDocument(SyncTeachDataSchedule.class);
|
||||
GenerateFileUtil.createCronJobDocument(DepartSyncSchedule.class);
|
||||
//GenerateFileUtil.createActionDocument(DataPushAction.class);
|
||||
//GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class);
|
||||
}
|
||||
|
@ -122,11 +123,28 @@ public class NormalTest extends BaseTest {
|
|||
examineSchedule.runCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDatea(){
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DAY_OF_MONTH,-1);
|
||||
// 获取修改后的日期并赋值给 from
|
||||
String to = new SimpleDateFormat("yyyyMMdd").format(cal.getTime());
|
||||
// 将日期减一天
|
||||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||||
|
||||
// 获取修改后的日期并赋值给 to
|
||||
String from = new SimpleDateFormat("yyyyMMdd").format(cal.getTime());
|
||||
|
||||
System.out.println("From: " + from);
|
||||
System.out.println("To: " + to);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResponseSync(){
|
||||
ParseTest parseTest = new ParseTest();
|
||||
Map<String, Object> resultData = parseTest.getResultData();
|
||||
System.out.println(JSON.toJSONString(resultData));
|
||||
|
||||
//ResponseMappingDeal responseMappingDeal = new ResponseMappingDeal();
|
||||
//responseMappingDeal.doResponseSync("test1",resultData);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
package xuanran.wang.xk_hospital.test;
|
||||
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/18 14:31
|
||||
*/
|
||||
public class XkHospitalTest extends BaseTest {
|
||||
|
||||
private final XkHospitalCommonDataAsyncService service = new XkHospitalCommonDataAsyncServiceImpl();
|
||||
|
||||
@Test
|
||||
public void testA(){
|
||||
String json = "{\n" +
|
||||
"\t\"ID\":\"1\",\n" +
|
||||
"\t\"DeptCode\":\"test3\",\n" +
|
||||
"\t\"DeptName\":\"科室测试名称3\",\n" +
|
||||
"\t\"DeptLevel\": null, \n" +
|
||||
"\t\"ParentDeptCode\": \"test2\",\n" +
|
||||
"\t\"IsDelete\": false, \n" +
|
||||
"\t\"Remark\":\"备注\"\n" +
|
||||
"}\n";
|
||||
|
||||
Map map = JSONObject.parseObject(json, Map.class);
|
||||
service.async("4bce0693734a","dept",map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testB(){
|
||||
// String json2 = "{\n" +
|
||||
// "\t\"ID\":\"1\",\n" +
|
||||
// "\t\"DeptCode\":\"test3\",\n" +
|
||||
// "\t\"DeptName\":\"科室测试名称3\",\n" +
|
||||
// "\t\"DeptLevel\": null, \n" +
|
||||
// "\t\"ParentDeptCode\": \"test2\",\n" +
|
||||
// "\t\"IsDelete\": false, \n" +
|
||||
// "\t\"Remark\":\"备注\"\n" +
|
||||
// "}\n";
|
||||
//
|
||||
// Map map2 = JSONObject.parseObject(json2, Map.class);
|
||||
// service.async("4bce0693734a","dept",map2);
|
||||
|
||||
String json = "{\n" +
|
||||
"\t\"ID\":\"1\",\n" +
|
||||
"\t\"EmplCode\":\"TEST10\",\n" +
|
||||
"\t\"EmplName\":\"测试人员10\",\n" +
|
||||
"\t\"EmplType\":\"人员类型代码\",\n" +
|
||||
"\t\"EmplTypeCaption\":\"人员类型名称\",\n" +
|
||||
"\t\"Gender\":\"男\",\n" +
|
||||
"\t\"DeptCode\":\"test3\",\n" +
|
||||
"\t\"DeptName\":\"科室名称\",\n" +
|
||||
"\t\"EmplTitle\":\"职称代码\",\n" +
|
||||
"\t\"EmplTitleCaption\":\"职称名称\",\n" +
|
||||
"\t\"EmplPosition\":\"职务代码\",\n" +
|
||||
"\t\"EmplPositionCaption\":\"职务名称\",\n" +
|
||||
"\t\"Remark\":\"备注\"\n" +
|
||||
"}\n";
|
||||
Map map = JSONObject.parseObject(json, Map.class);
|
||||
Util.null2DefaultStr(null,"");
|
||||
service.async("4bce0693734c","hrm",map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testC(){
|
||||
String json = "{\n" +
|
||||
" \"ID\":\"主键\",\n" +
|
||||
" \"GroupID\":\"test_yl_01\",\n" +
|
||||
" \"GroupCode\":\"test_yl_dm_03\",\n" +
|
||||
" \"GroupName\":\"医疗组名称1\",\n" +
|
||||
" \"DeptCode\":\"test03\",\n" +
|
||||
" \"DeptName\":\"测试科室03\",\n" +
|
||||
" \"WardCode\":\"testbq_dm_1\",\n" +
|
||||
" \"WardName\":\"测试主表病区名称1\",\n" +
|
||||
" \"Ward_BedNumber\":\"病区床位数,int类型\",\n" +
|
||||
" \"IsDelete\":\"是否停用,bool类型\",\n" +
|
||||
" \"Remark\":\"备注\",\n" +
|
||||
" \"Wards\":[\n" +
|
||||
" {\n" +
|
||||
" \"ID\":\"1\",\n" +
|
||||
" \"WardCode\":\"bq_01\",\n" +
|
||||
" \"WardName\":\"病区名称01_2_3\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"ID\":\"2\",\n" +
|
||||
" \"WardCode\":\"bq_03\",\n" +
|
||||
" \"WardName\":\"病区名称02_1_3\"\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"WardHeads\":[\n" +
|
||||
" {\n" +
|
||||
" \"ID\":\"1\",\n" +
|
||||
" \"EmplCode\":\"TEST10\",\n" +
|
||||
" \"EmplName\":\"傻逼01\",\n" +
|
||||
" \"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"ID\":\"2\",\n" +
|
||||
" \"EmplCode\":\"TEST10\",\n" +
|
||||
" \"EmplName\":\"傻逼02\",\n" +
|
||||
" \"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
System.out.println(json);
|
||||
Map map = JSONObject.parseObject(json, Map.class);
|
||||
Util.null2DefaultStr(null,"");
|
||||
service.async("4bce0693734d","common", map);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue