处理冲突
dev
ic_excellent 2023-07-15 10:03:16 +08:00
commit ae93310168
60 changed files with 5283 additions and 541 deletions

4
.gitignore vendored
View File

@ -50,8 +50,10 @@ target/
*.back
!/src/main/youhong_ai_jitu_src/selfdev/util/log
node_modules
!/src/test/java/xuanran/wang/log
# 老项目代码
#/lib/jitulib/
#/lib/classbean
#src/main/youhong_ai_old_src/
#src/main/youhong_ai_jitu_src/
#src/main/youhong_ai_jitu_src/
/src/main/java/com/cloudstore/dev/api/service/Service_devTable.java

View File

@ -1,4 +1,33 @@
(function runJs() {
function findReact(dom, traverseUp = 0) {
const key = Object.keys(dom).find(key => {
return key.startsWith("__reactFiber$")
|| key.startsWith("__reactInternalInstance$")
|| key.startsWith("__reactEventHandlers$");
});
const domFiber = dom[key];
if (domFiber == null) return null;
if (domFiber._currentElement) {
let compFiber = domFiber._currentElement._owner;
for (let i = 0; i < traverseUp; i++) {
compFiber = compFiber._currentElement._owner;
}
return compFiber._instance;
}
const GetCompFiber = fiber => {
let parentFiber = fiber.return;
while (typeof parentFiber.type == "string") {
parentFiber = parentFiber.return;
}
return parentFiber;
};
let compFiber = GetCompFiber(domFiber);
for (let i = 0; i < traverseUp; i++) {
compFiber = GetCompFiber(compFiber);
}
return compFiber.stateNode;
}
let currentYear = new Date().getFullYear();
let currentMonth = new Date().getMonth() + 1;
let currentDate = new Date().getDate();
@ -23,9 +52,13 @@
wf.changeFieldValue("100003720000000611", {value: "外出技术支持"});
wf.changeFieldValue("100003720000008715", {value: '2'});
wf.changeFieldValue("877132351682273302", {value: '1'});
let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"]');
let workflowTitleObj = document.querySelector('.weapp-form-flowpage-content-FlowPageSysFieldReqName input');
let workflowTitle = workflowTitleObj.value;
workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay;
let newValue = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay;
workflowTitleObj.setAttribute("value", newValue);
workflowTitleObj.value = newValue;
let input = findReact(workflowTitleObj);
input.props.onChange(newValue);
const container = document.getElementById("widget_100003720000000664");
const svgIcon = container.querySelector(".associative-search-icon svg");
if (svgIcon) {
@ -43,6 +76,35 @@
})()
(function runJs() {
function findReact(dom, traverseUp = 0) {
const key = Object.keys(dom).find(key => {
return key.startsWith("__reactFiber$")
|| key.startsWith("__reactInternalInstance$")
|| key.startsWith("__reactEventHandlers$");
});
const domFiber = dom[key];
if (domFiber == null) return null;
if (domFiber._currentElement) {
let compFiber = domFiber._currentElement._owner;
for (let i = 0; i < traverseUp; i++) {
compFiber = compFiber._currentElement._owner;
}
return compFiber._instance;
}
const GetCompFiber = fiber => {
let parentFiber = fiber.return;
while (typeof parentFiber.type == "string") {
parentFiber = parentFiber.return;
}
return parentFiber;
};
let compFiber = GetCompFiber(domFiber);
for (let i = 0; i < traverseUp; i++) {
compFiber = GetCompFiber(compFiber);
}
return compFiber.stateNode;
}
let currentYear = new Date().getFullYear();
let currentMonth = new Date().getMonth() + 1;
let currentDate = new Date().getDate();
@ -62,9 +124,13 @@
wf.changeFieldValue("100003720000000611", {value: "外出技术支持"});
wf.changeFieldValue("100003720000008715", {value: '4'});
wf.changeFieldValue("877132351682273302", {value: '1'});
let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"]');
let workflowTitleObj = document.querySelector('.weapp-form-flowpage-content-FlowPageSysFieldReqName input');
let workflowTitle = workflowTitleObj.value;
workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay;
let newValue = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay;
workflowTitleObj.setAttribute("value", newValue);
workflowTitleObj.value = newValue;
let input = findReact(workflowTitleObj);
input.props.onChange(newValue);
window.open("/sp/workflow/flowpage/fullCreate/100003460000000746?workflowId=100003460000000746&isCreate=1", "_blank");
document.querySelector("button[weid='3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_t03ihg@0_xomsa1@0']").click();
})()

View File

@ -0,0 +1,26 @@
$(()=>{
const config = {
// 子流程主表帐套号字段名
zth:'zth',
filterConfig:{
// 子流程明细表帐套号字段名
zthm:'zthm',
// 子流程明细表索引
detailNo: 1
}
}
const mainZth = WfForm.convertFieldNameToId(config.zth);
const detailTable = "detail_" + config.filterConfig.detailNo;
const detailZth = WfForm.convertFieldNameToId(config.filterConfig.zthm, detailTable);
let rowArr = WfForm.getDetailAllRowIndexStr(detailTable).split(",");
let mainZthVal = WfForm.getFieldValue(mainZth);
for(let i=0; i < rowArr.length; i++){
let rowIndex = rowArr[i];
if(rowIndex !== ""){
let fieldValue = WfForm.getFieldValue(`${detailZth}_${rowIndex}`);
if(mainZthVal !== fieldValue){
$(`#oTable${+config.filterConfig.detailNo - 1} tr[data-rowindex='${rowIndex}']`).css("display","none")
}
}
}
})

View File

@ -927,7 +927,11 @@ $(() => {
// 表名
tableName: "uf_hgpxtz",
// 文档字段
docIdField: 'clwd'
docIdField: 'clwd',
// 阅读时长字段
timeField: '',
// 版本 1 - 2
version: '2'
}
function pxlx() {

View File

@ -20,6 +20,7 @@ import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.Objects;
/**
@ -66,6 +67,13 @@ public class HttpManager {
* @return
*/
public static CloseableHttpClient getHttpConnection(String url, CredentialsProvider credentialsProvider) {
return getHttpConnection(url, credentialsProvider, null);
}
public static CloseableHttpClient getHttpConnection(String url, CredentialsProvider credentialsProvider, RequestConfig cusRequestConfigs) {
if(Objects.isNull(cusRequestConfigs)){
cusRequestConfigs = requestConfig;
}
if (url.trim().toUpperCase().startsWith(HttpArgsType.HTTP_HTTPS.toUpperCase())) {
SSLContext sslContext;
SSLConnectionSocketFactory sslsf = null;
@ -84,66 +92,74 @@ public class HttpManager {
throw new RuntimeException(e);
}
HttpClientBuilder httpClientBuilder = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setConnectionManager(manager)
.setConnectionManagerShared(true)
.setDefaultRequestConfig(requestConfig);
.setSSLSocketFactory(sslsf)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setConnectionManager(manager)
.setConnectionManagerShared(true)
.setDefaultRequestConfig(cusRequestConfigs);
if (credentialsProvider != null) {
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
return httpClientBuilder
.build();
.build();
} else {
HttpClientBuilder httpClientBuilder = HttpClients.custom()
.setConnectionManager(manager)
.setDefaultRequestConfig(requestConfig)
.setConnectionManagerShared(true);
.setConnectionManager(manager)
.setDefaultRequestConfig(cusRequestConfigs)
.setConnectionManagerShared(true);
if (credentialsProvider != null) {
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
return httpClientBuilder
.build();
.build();
}
}
public static CloseableHttpClient getHttpConnection(String url, CredentialsProvider credentialsProvider, String sslPath, String password) {
return getHttpConnection(url, credentialsProvider, sslPath, password, null);
}
public static CloseableHttpClient getHttpConnection(String url, CredentialsProvider credentialsProvider, String sslPath,
String password, RequestConfig cusRequestConfigs) {
if(Objects.isNull(cusRequestConfigs)){
cusRequestConfigs = requestConfig;
}
if (url.trim().toUpperCase().startsWith(HttpArgsType.HTTP_HTTPS.toUpperCase())) {
SSLContext sslContext;
SSLConnectionSocketFactory sslsf = null;
try {
sslContext = SSLContexts.custom()
.loadTrustMaterial(new File(sslPath), password.toCharArray(),
new TrustSelfSignedStrategy())
.build();
.loadTrustMaterial(new File(sslPath), password.toCharArray(),
new TrustSelfSignedStrategy())
.build();
sslsf = new SSLConnectionSocketFactory(sslContext,
new String[]{"TLSv1"},
null,
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
} catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException | CertificateException |
IOException e) {
IOException e) {
throw new RuntimeException(e);
}
HttpClientBuilder httpClientBuilder = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.setConnectionManager(manager)
.setConnectionManagerShared(true)
.setDefaultRequestConfig(requestConfig);
.setSSLSocketFactory(sslsf)
.setConnectionManager(manager)
.setConnectionManagerShared(true)
.setDefaultRequestConfig(cusRequestConfigs);
if (credentialsProvider != null) {
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
return httpClientBuilder
.build();
.build();
} else {
HttpClientBuilder httpClientBuilder = HttpClients.custom()
.setConnectionManager(manager)
.setDefaultRequestConfig(requestConfig)
.setConnectionManagerShared(true);
.setConnectionManager(manager)
.setDefaultRequestConfig(cusRequestConfigs)
.setConnectionManagerShared(true);
if (credentialsProvider != null) {
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
return httpClientBuilder
.build();
.build();
}
}
}

View File

@ -63,6 +63,8 @@ public class HttpUtils {
private String sslKeyPath = "";
@Setter
private String password = "";
@Setter
private RequestConfig requestConfig;
/**
@ -185,12 +187,12 @@ public class HttpUtils {
*/
private CloseableHttpClient getHttpClient(String url) {
if (Strings.isNullOrEmpty(this.sslKeyPath)) {
return HttpManager.getHttpConnection(url, this.credentialsProvider);
return HttpManager.getHttpConnection(url, this.credentialsProvider, requestConfig);
} else {
return HttpManager.getHttpConnection(url, this.credentialsProvider, sslKeyPath, password);
return HttpManager.getHttpConnection(url, this.credentialsProvider, sslKeyPath, password, requestConfig);
}
}
/**
* get
*

View File

@ -61,8 +61,8 @@ public interface UtilMapper {
"dc.DOCCREATEDATE doc_create_date,dc.DOCCREATETIME doc_create_time," +
"(case when di.imagefilename = '' or di.imagefilename is null then dc.DOCSUBJECT else di.imagefilename end) image_file_name " +
"from DocDetail dc " +
"left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " +
"left join docimagefile di on (dc.id = #{docId} and dc.id = di.docid) " +
"left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " +
"where dc.id = #{docId} ")
DocImageInfo selectDocImageInfo(@ParamMapper("docId") String docId);
@ -72,8 +72,8 @@ public interface UtilMapper {
"dc.DOCCREATEDATE doc_create_date,dc.DOCCREATETIME doc_create_time," +
"(case when di.imagefilename = '' or di.imagefilename is null then dc.DOCSUBJECT else di.imagefilename end) image_file_name " +
"from DocDetail dc " +
"left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " +
"left join docimagefile di on (dc.id in ($t{docIds}) and dc.id = di.docid )" +
"left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " +
"where dc.id in ($t{docIds})")
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String docIds);
@ -83,8 +83,8 @@ public interface UtilMapper {
"dc.DOCCREATEDATE doc_create_date,dc.DOCCREATETIME doc_create_time," +
"(case when di.imagefilename = '' or di.imagefilename is null then dc.DOCSUBJECT else di.imagefilename end) image_file_name " +
"from DocDetail dc " +
"left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " +
"left join docimagefile di on (dc.id in ($t{docIds}) and dc.id = di.docid )" +
"left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " +
"where dc.id in ($t{docIds})")
List<DocImageInfo> selectDocImageInfos(@ParamMapper("docIds") String[] docIds);

View File

@ -37,68 +37,105 @@ public class ResponseMappingDeal {
private final Logger logger = Util.getLogger("json_util");
private final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class);
/** 表数据回调 */
private TableDefinitionCallback tableCallback;
/** 行数据回调 */
private RowDefinitionCallback rowCallback;
/** 字段数据回调 */
private FieldDefinitionCallback fieldDefinitionCallback;
/** 状态map的key */
private Class<?> stateClassKey;
public void doResponseSync(String uniqueCode, ResponeVo responeVo) {
Map<String, Object> responseMap = responeVo.getResponseMap();
ResponseUtil.parameterJudgment(responseMap,"接口返回都为空 你处理个勾");
this.doResponseSync(uniqueCode,responseMap);
ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾");
this.doResponseSync(uniqueCode, responseMap);
}
/**
* <h2> note by youhong.ai</h2>
*
* @param uniqueCode
* @param responseMap map
*/
public void doResponseSync(String uniqueCode, Map<String, Object> responseMap) {
// note by youhong.ai 查询配置表
List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode);
logger.info(String.format("%s 相关响应配置信息==> %s",uniqueCode, JSON.toJSONString(responseConfigList)));
ResponseUtil.parameterJudgment(responseConfigList,"response config is empty please check!!! ");
logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
// note by youhong.ai 自定义校验
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! ");
Map<String, ResponseConfig> tableNameConfig;
try {
// note by youhong.ai 对查询到的多个配置进行整合以同步表表名作为key 配置作为value
tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v));
} catch (Exception e) {
logger.error("response config error please check!!! " + Util.getErrString(e));
throw new ResponseException("response config error please check!!! ");
}
ResponseUtil.parameterJudgment(responseMap,"接口返回都为空 你处理个勾");
ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾");
// note by youhong.ai 循环同步每一个表
tableNameConfig.forEach((key, value) -> doResponseSync(value, responseMap));
}
public void doResponseSync(ResponseConfig responseConfig, Map<String, Object> responseMap){
/**
* <h2>note by youhong.ai </h2>
*
* @param responseConfig
* @param responseMap
*/
public void doResponseSync(ResponseConfig responseConfig, Map<String, Object> responseMap) {
// note by youhong.ai 获取别名配置明细数据
List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList();
ResponseUtil.parameterJudgment(responseConfigAliasList,"responseConfigAliasList config is empty please check!!!");
ResponseUtil.parameterJudgment(responseConfigAliasList, "responseConfigAliasList config is empty please check!!!");
// note by youhong.ai 获取转换值配置明细
List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList();
ResponseUtil.parameterJudgment(valueChangeList,"valueChangeList config is empty please check!!!");
//数据信息按是否主表分组
ResponseUtil.parameterJudgment(valueChangeList, "valueChangeList config is empty please check!!!");
// 数据信息按是否主表分组
Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType));
// note by youhong.ai 获取主表别名配置数据
List<ResponseConfigAlias> mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE);
// note by youhong.ai 按照表类型分组
Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
// note by youhong.ai 获取主表值配置
List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
TableDefinition tableDefinition;
if(ResponseUtil.parameterIsNotNull(mainConfigList)) {
// note by youhong.ai 如果有主表配置
if (ResponseUtil.parameterIsNotNull(mainConfigList)) {
// note by youhong.ai 解析json为表描述对象
tableDefinition = this.parsingJsonToTable(responseConfig.getModelTableName(), responseConfig, mainConfigList, mainValueChangeList, responseMap, true, this::detailTableDeal);
}else{
Map<String,TableDefinition> detailTable = new HashMap<>();
this.detailTableDeal(responseConfig,responseMap,detailTable);
} else {
// note by youhong.ai 如果没有主表配置,纯配置明细同步
Map<String, TableDefinition> detailTable = new HashMap<>();
// note by youhong.ai 处理明细表
this.detailTableDeal(responseConfig, responseMap, detailTable);
tableDefinition = TableDefinition.builder()
.detailTableMap(detailTable)
.tableDefinitionCallback(this.tableCallback)
.tableType(responseConfig.getTableType())
.assignType(ResponseConfigConstant.NO_HANDLE)
.assignTable(responseConfig.getModelTableName()).build();
.detailTableMap(detailTable)
.tableDefinitionCallback(this.tableCallback)
.tableType(responseConfig.getTableType())
.assignType(ResponseConfigConstant.NO_HANDLE)
.assignTable(responseConfig.getModelTableName()).build();
}
//做数据处理
// 做数据处理
tableDefinition.setDefaultState(stateClassKey);
tableDefinition.dataProcess();
}
/**
* <h2>note by youhon.ai json</h2>
*
* @param tableName
* @param responseConfig
* @param responseConfigAliasList
* @param valueChangeList
* @param responseMap
* @param isMainTable
* @param detailCallBack
* @return
*/
public TableDefinition parsingJsonToTable(
String tableName,
ResponseConfig responseConfig,
@ -106,152 +143,157 @@ public class ResponseMappingDeal {
List<ResponseConfigValueChange> valueChangeList,
Map<String, Object> responseMap,
boolean isMainTable,
Bi3Function<ResponseConfig,Map<String, Object>,Map<String,TableDefinition>,String> detailCallBack) {
Bi3Function<ResponseConfig, Map<String, Object>, Map<String, TableDefinition>, String> detailCallBack) {
// note by youhong.ai 过滤出主表别名主数据配置
List<ResponseConfigAlias> mainAliasList = responseConfigAliasList.stream().filter(item -> item.getMainData() == ResponseConfigConstant.MAIN_DATA).collect(Collectors.toList());
if(responseConfigAliasList.size() > 1) {
// note by youhong.ai 主表别名有且只能有一个主数据
if (responseConfigAliasList.size() > 1) {
throw new ResponseException("The master data cannot be multiple please check !!! ");
}
if(responseConfigAliasList.isEmpty()){
if (responseConfigAliasList.isEmpty()) {
throw new ResponseException("The configuration is missing master data please check !!! ");
}
Map<String,Object> aliasData = new HashMap<>(responseMap);
//处理别名数据
Map<String, Object> aliasData = new HashMap<>(responseMap);
// 处理别名数据
responseConfigAliasList.forEach(item -> {
String dataPath = item.getDataPath();
String dataAlias = item.getDataAlias();
// node by youhong.ai 通过路径获取对应的值
Object parsingData = Util.getValueByKeyStr(dataPath, responseMap);
aliasData.put(dataAlias,parsingData);
// node by youhong.ai 别名->值
aliasData.put(dataAlias, parsingData);
});
//Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
//List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
ResponseUtil.parameterJudgment(valueChangeList,"main table valueChangeList config is empty please check!!!");
//获取主表的主数据信息
// Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
// List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
ResponseUtil.parameterJudgment(valueChangeList, "main table valueChangeList config is empty please check!!!");
// 获取主表的主数据信息
ResponseConfigAlias mainDataAlias = mainAliasList.get(0);
int tableMainOrDetail = isMainTable ? ResponseConfigConstant.MAIN_TABLE : ResponseConfigConstant.DETAIL_TABLE;
//构建表信息
// 构建表信息
TableDefinition tableDefinition = TableDefinition.builder().assignTable(tableName)
.conditionScript(mainDataAlias.getConditionScript())
.judgmentScript(mainDataAlias.getJudgmentScript())
.tableType(responseConfig.getTableType())
.mainOrDetail(tableMainOrDetail)
.tableDefinitionCallback(this.tableCallback)
.assignType(mainDataAlias.getAssignType()).build();
.conditionScript(mainDataAlias.getConditionScript())
.judgmentScript(mainDataAlias.getJudgmentScript())
.tableType(responseConfig.getTableType())
.mainOrDetail(tableMainOrDetail)
.tableDefinitionCallback(this.tableCallback)
.assignType(mainDataAlias.getAssignType()).build();
String dataPath = mainDataAlias.getDataPath();
List<RowDefinition> rowDefinitionList = new ArrayList<>();
Map<String,TableDefinition> detailTable = isMainTable ? new HashMap<>() : null;
if(mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY){
List<Map<String,Object>> mainList = (List<Map<String,Object>>) Util.getValueByKeyStr(dataPath, aliasData);
Map<String, TableDefinition> detailTable = isMainTable ? new HashMap<>() : null;
// note by youhong.ai 如果是json数组
if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY) {
List<Map<String, Object>> mainList = (List<Map<String, Object>>) Util.getValueByKeyStr(dataPath, aliasData);
for (Map<String, Object> mainItem : mainList) {
aliasData.put(mainDataAlias.getDataAlias(),mainItem);
//处理配置信息
aliasData.put(mainDataAlias.getDataAlias(), mainItem);
// 处理配置信息
List<FieldDefinition> fieldDefinitions = parsingJsonToConfig(valueChangeList, aliasData);
RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions,tableName, mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript());
RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions, tableName, mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript());
rowDefinition.setMainOrDetail(ResponseConfigConstant.DETAIL_TABLE);
if(isMainTable) {
if (isMainTable) {
rowDefinition.setMainOrDetail(ResponseConfigConstant.MAIN_TABLE);
detailCallBack.apply(responseConfig,aliasData,detailTable);
detailCallBack.apply(responseConfig, aliasData, detailTable);
rowDefinition.setDetailTableMap(detailTable);
}
rowDefinitionList.add(rowDefinition);
}
}else if(mainDataAlias.getDataType() == ResponseConfigConstant.JSON_OBJECT){
Map<String,Object> jsonObj = (Map<String, Object>) Util.getValueByKeyStr(dataPath, aliasData);
aliasData.put(mainDataAlias.getDataAlias(),jsonObj);
//处理配置信息
} else if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_OBJECT) {
Map<String, Object> jsonObj = (Map<String, Object>) Util.getValueByKeyStr(dataPath, aliasData);
aliasData.put(mainDataAlias.getDataAlias(), jsonObj);
// 处理配置信息
List<FieldDefinition> fieldDefinitions = parsingJsonToConfig(valueChangeList, aliasData);
RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions,tableName,mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript());
RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions, tableName, mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript());
rowDefinition.setMainOrDetail(ResponseConfigConstant.DETAIL_TABLE);
if(isMainTable) {
if (isMainTable) {
rowDefinition.setMainOrDetail(ResponseConfigConstant.MAIN_TABLE);
detailCallBack.apply(responseConfig,aliasData,detailTable);
detailCallBack.apply(responseConfig, aliasData, detailTable);
rowDefinition.setDetailTableMap(detailTable);
}
rowDefinitionList.add(rowDefinition);
}else {
} else {
throw new ResponseException("please set the primary data type !!!");
}
//设置表的行信息
// 设置表的行信息
tableDefinition.setRowDefinitionList(rowDefinitionList);
return tableDefinition;
}
private RowDefinition buildRowDefinition(List<FieldDefinition> fieldDefinitionList,
String tableName,
int assignType,
String conditionScript,
String judgmentScript){
Map<String,Object> updateParam = new HashMap<>();
Map<String,Object> wherePram = new HashMap<>();
String tableName,
int assignType,
String conditionScript,
String judgmentScript) {
Map<String, Object> updateParam = new HashMap<>();
Map<String, Object> wherePram = new HashMap<>();
fieldDefinitionList.forEach(fieldDefinition -> {
int fieldType = fieldDefinition.getFieldType();
if(fieldType == ResponseConfigConstant.WHERE_FIELD){
wherePram.put(fieldDefinition.getFieldName(),fieldDefinition.getFieldValue());
}else {
updateParam.put(fieldDefinition.getFieldName(),fieldDefinition.getFieldValue());
wherePram.put(fieldDefinition.getFieldName(),fieldDefinition.getFieldValue());
if (fieldType == ResponseConfigConstant.WHERE_FIELD) {
wherePram.put(fieldDefinition.getFieldName(), fieldDefinition.getFieldValue());
} else {
updateParam.put(fieldDefinition.getFieldName(), fieldDefinition.getFieldValue());
wherePram.put(fieldDefinition.getFieldName(), fieldDefinition.getFieldValue());
}
});
return RowDefinition.builder().assignType(assignType)
.conditionScript(conditionScript)
.updateParam(updateParam)
.assignTable(tableName)
.whereParam(wherePram)
.fieldDefinitionList(fieldDefinitionList)
.rowDefinitionCallback(this.rowCallback)
.judgmentScript(judgmentScript).build();
.conditionScript(conditionScript)
.updateParam(updateParam)
.assignTable(tableName)
.whereParam(wherePram)
.fieldDefinitionList(fieldDefinitionList)
.rowDefinitionCallback(this.rowCallback)
.judgmentScript(judgmentScript).build();
}
private String detailTableDeal(ResponseConfig responseConfig,Map<String, Object> param,Map<String,TableDefinition> detailTable){
private String detailTableDeal(ResponseConfig responseConfig, Map<String, Object> param, Map<String, TableDefinition> detailTable) {
List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList();
List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList();
//数据信息按是否主表分组
// 数据信息按是否主表分组
Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType));
List<ResponseConfigAlias> detailAliases = aliasMap.get(ResponseConfigConstant.DETAIL_TABLE);
//没有明细相关配置不处理
if(ResponseUtil.parameterIsNull(detailAliases)){
// 没有明细相关配置不处理
if (ResponseUtil.parameterIsNull(detailAliases)) {
return "";
}
Map<String, List<ResponseConfigAlias>> detailAliasMap = detailAliases.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getDetailTableName));
Map<String, List<ResponseConfigValueChange>> detailValueChangeMap = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getAssignTable));
detailAliasMap.forEach((key,value) ->{
detailAliasMap.forEach((key, value) -> {
List<ResponseConfigValueChange> detailValueChangeList = detailValueChangeMap.get(key);
TableDefinition tableDefinition = parsingJsonToTable(key, responseConfig, value, detailValueChangeList, param, false, this::detailTableDeal);
detailTable.put(key,tableDefinition);
detailTable.put(key, tableDefinition);
});
return "";
}
/**
* json
*
* @param responseConfigValueChangeList
* @param parsingData json
* @param parsingData json
* @return
*/
public List<FieldDefinition> parsingJsonToConfig(List<ResponseConfigValueChange> responseConfigValueChangeList,
Map<String,Object> parsingData){
Map<String,Object> param = new HashMap<>();
responseConfigValueChangeList.forEach(item ->{
Map<String, Object> parsingData) {
Map<String, Object> param = new HashMap<>();
responseConfigValueChangeList.forEach(item -> {
Object value = item.getDataChange() == ResponseConfigConstant.DEFAULT_VALUE
? null
: Util.getValueByKeyStr(Util.null2String(item.getValuePath()), parsingData);
? null
: Util.getValueByKeyStr(Util.null2String(item.getValuePath()), parsingData);
item.setJsonData(value);
param.put(item.getAssignFieldName(),value);
param.put(item.getAssignFieldName(), value);
});
return responseConfigValueChangeList.stream().map(item ->{
return responseConfigValueChangeList.stream().map(item -> {
BiFunction<ResponseConfigValueChange, Map<String, Object>, String> dataChangeFunction = DataChangeProcess.MODE_METHOD_MAP.get(item.getDataChange());
ResponseUtil.parameterJudgment(dataChangeFunction,"The corresponding data conversion mode processing method is not found !!!");
dataChangeFunction.apply(item,param);
ResponseUtil.parameterJudgment(dataChangeFunction, "The corresponding data conversion mode processing method is not found !!!");
dataChangeFunction.apply(item, param);
Function<Object, Object> typeChangeFunction = TypeChangeProcess.MODE_METHOD_MAP.get(item.getTypeChange());
ResponseUtil.parameterJudgment(typeChangeFunction,"The corresponding type conversion method could not be found !!!");
ResponseUtil.parameterJudgment(typeChangeFunction, "The corresponding type conversion method could not be found !!!");
Object targetValue = typeChangeFunction.apply(item.getJsonData());
return FieldDefinition.builder().fieldType(item.getFieldType())
.tableType(item.getTableType())
.tableName(item.getAssignTable())
.fieldName(item.getAssignFieldName())
.fieldDefinitionCallback(fieldDefinitionCallback)
.fieldValue(targetValue).build();
.tableType(item.getTableType())
.tableName(item.getAssignTable())
.fieldName(item.getAssignFieldName())
.fieldDefinitionCallback(fieldDefinitionCallback)
.fieldValue(targetValue).build();
}).collect(Collectors.toList());
}
}

View File

@ -0,0 +1,56 @@
package com.api.xuanran.wang.eny.workflow.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/14 15:02
*/
@Path("/wxr/eny/workflow/rate")
public class GetExchangeRate {
private final Logger log = Util.getLogger();
private final ExchangeRateMapper mapper = Util.getMapper(ExchangeRateMapper.class);
@POST
@Path("/exchange")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_JSON)
public String exchangeRate(@Context HttpServletRequest request,
@Context HttpServletResponse response,
@RequestBody Map<String, String> params){
try {
// 地区
String area = Util.null2DefaultStr(params.get("area"),"");
// 本位币
String baseCurrency = Util.null2DefaultStr(params.get("baseCurrency"),"");
// 接口币种
String interfaceCurrency = Util.null2DefaultStr(params.get("interfaceCurrency"),"");
if(StringUtils.isBlank(area) || StringUtils.isBlank(baseCurrency) || StringUtils.isBlank(interfaceCurrency)){
log.error("params : " + JSONObject.toJSONString(params));
throw new CustomerException("参数不可为空!");
}
String interfac = mapper.selectCurrencyIdByCurrencyName(interfaceCurrency);
return "";
}catch (Exception e){
return ApiResult.error("汇率转换error : " + e.getMessage());
}
}
}

View File

@ -0,0 +1,17 @@
package com.api.xuanran.wang.eny.workflow.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/14 15:23
*/
@SqlMapper
public interface ExchangeRateMapper {
@Select("select id from fnacurrency where currencyname = #{currencyName}")
String selectCurrencyIdByCurrencyName(@ParamMapper("currencyName") String currencyName);
}

View File

@ -1,9 +1,6 @@
package com.api.youhong.ai.ihgzhouji.userinfoel.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.SqlString;
import aiyh.utils.annotation.recordset.*;
import weaver.hrm.User;
import java.util.List;
@ -112,6 +109,7 @@ public interface UserInfoMapper {
"or concat(',',financeleader,',') like concat(',',#{userId},',')\n" +
"or concat(',',fbleader,',') like concat(',',#{userId},',')\n" +
"or concat(',',hrleader,',') like concat(',',#{userId},',')")
@ToLowerCase
List<Map<String, Object>> selectRoles(@ParamMapper("userId") int uid);
/**

View File

@ -2,6 +2,7 @@ package com.api.youhong.ai.pcn.examcontrol.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import com.api.youhong.ai.pcn.examcontrol.service.ExamBtnControlService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
@ -105,8 +106,9 @@ public class ExamBtnControlController {
public String readTimeDoc(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody Map<String, Object> params) {
try {
log.info("阅读文档数据: " + JSON.toJSONString(params));
User user = HrmUserVarify.getUser(request, response);
return ApiResult.success(service.readTimeDoc(user,params));
return ApiResult.success(service.readTimeDoc(user, params));
} catch (Exception e) {
log.error("is read doc error!\n" + Util.getErrString(e));
return ApiResult.error("system error!");

View File

@ -286,9 +286,10 @@ public class ExamBtnControlService {
int currentReadTimeInt = Util.getIntValue(currentReadTime, 0);
// 查询是否存在已读的数据
Map<String, Object> readTimeDocInfo = mapper.selectReadTimeTag(user.getUID(), docId);
int dataId = Util.getIntValue(Util.null2String(readTimeDocInfo.get("id")), 0);
int dataId = -1;
// 如果存在,吧原来的已读时长加上现在的已读时长
if (CollectionUtil.isNotEmpty(readTimeDocInfo)) {
dataId = Util.getIntValue(Util.null2String(readTimeDocInfo.get("id")), 0);
String readTime = Util.null2String(readTimeDocInfo.get("readTime"));
int readTimeInt = Util.getIntValue(readTime, 0);
currentReadTimeInt += readTimeInt;

View File

@ -0,0 +1,96 @@
package com.customization.youhong.guoxiaojun.sso.impl;
import aiyh.utils.Util;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import com.weaverboot.frame.ioc.anno.classAnno.WeaSsoIocComponent;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaSsoIoc;
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaSsoParam;
import org.apache.log4j.Logger;
import weaver.integration.util.SessionUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Objects;
/**
* <h1>poc</h1>
*
* <p>create: 2023/7/13 15:25</p>
*
* @author youHong.ai
*/
@WeaSsoIocComponent("SsoGuoXiaoJunPocService")
public class SsoGuoXiaoJunPocImpl {
public static final String API_SSO_URL = "/api/aiyh/guoxiaojun/sso";
public static final String LOGIN_URL = "/wui/index.html";
public static final String API_CHECK_OUT_URI = "/api/hrm/login/checkLogout";
private final Logger log = Util.getLogger();
/**
* weaSsoParam request response paramMap
*
* @param weaSsoParam
*/
@WeaSsoIoc(order = 1, description = "单点登录逻辑1")
public void ssoLogin(WeaSsoParam weaSsoParam) {
try {
HttpServletRequest request = weaSsoParam.getRequest();
String requestURI = request.getRequestURI();
HttpServletResponse response = weaSsoParam.getResponse();
HttpSession session = request.getSession(true);
Object weaverUser = session.getAttribute("weaver_user@bean");
if (Objects.isNull(weaverUser)) {
session.removeAttribute("outUserId");
}
if (requestURI.equals(API_SSO_URL)) {
// 登录oa系统
loginOa(request, response);
return;
}
if (requestURI.equals(API_CHECK_OUT_URI)) {
// 退出登录
session.removeAttribute("outUserId");
String logOutUrl = Util.getCusConfigValue("oauth2-proxy-logout-url");
response.setHeader("logOutUrl", logOutUrl);
return;
}
// sso 认证
if (session.getAttribute("outUserId") == null) {
authorSso(response, session);
}
} catch (IOException e) {
log.error("重定地址失败!" + Util.getErrString(e));
}
}
//
private void loginOa(HttpServletRequest request, HttpServletResponse response) throws IOException {
HttpSession session;
String outUserId = request.getHeader("X-Credential-Identifier");
// 登录处理
// String userId = Util.getCusConfigValueNullOrEmpty(outUserId,"1");
String userId = Util.getCusConfigValue(outUserId);
if (StrUtil.isBlank(userId)) {
return;
}
SessionUtil.createSession(userId, request, response);
session = request.getSession();
session.setAttribute("outUserId", Objects.isNull(outUserId) ? userId : outUserId);
response.sendRedirect(Util.getCusConfigValueNullOrEmpty("SSO_SUCCESS_REDIRECT_URL", "/wui/index.html"));
}
private void authorSso(HttpServletResponse response, HttpSession session) throws IOException {
Object outUserId = session.getAttribute("outUserId");
if (Objects.nonNull(outUserId)) {
return;
}
// 地址重定向到国小君aut2认证地址
response.sendRedirect(Util.getCusConfigValue("oauth2-proxy-url") + "?url="
+ URLEncoder.encode(Util.getCusConfigValue("OA_URL") + API_SSO_URL, "UTF-8"));
}
}

View File

@ -0,0 +1,151 @@
package com.customization.youhong.pcn.datasmultilingual;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <h1></h1>
*
* <p>create: 2023/7/13 15:37</p>
*
* @author youHong.ai
*/
public class MultilingualUtil {
/**
* <h2></h2>
*
* @param rspJson json
* @param user
*/
public static void parseMultilingual(JSONObject rspJson, User user) {
if (Objects.isNull(rspJson) || Objects.isNull(user)) {
return;
}
if (!rspJson.containsKey("datas")) {
return;
}
List<Map<String, String>> datas = (List<Map<String, String>>) rspJson.get("datas");
if (CollectionUtil.isEmpty(datas)) {
return;
}
String startPattern = "~`~`";
String endPattern = "`~`~";
String pattern = Pattern.quote(startPattern) + "(.*?)" + Pattern.quote(endPattern);
for (Map<String, String> data : datas) {
for (Map.Entry<String, String> entry : data.entrySet()) {
String value = entry.getValue();
if (Objects.isNull(value)) {
continue;
}
String multilingualStr = findString(value, startPattern, endPattern);
if (StrUtil.isBlank(multilingualStr)) {
continue;
}
Map<Integer, String> languageMap = getLanguageMap(multilingualStr);
if (CollectionUtil.isEmpty(languageMap)) {
continue;
}
String label = languageMap.get(user.getLanguage());
if (StrUtil.isBlank(label)) {
continue;
}
entry.setValue(value.replaceAll(pattern, label));
}
}
}
/**
* <h2>map</h2>
*
* @param multilingualStr
* @return map
*/
public static Map<Integer, String> getLanguageMap(String multilingualStr) {
String[] split = multilingualStr.split("`~`");
Map<Integer, String> result = new HashMap<>(8);
for (String str : split) {
LabelEntity labelEntity = parseLanguageStr(str);
result.put(labelEntity.getLanguageId(), labelEntity.getLabel());
}
return result;
}
/**
* <h2></h2>
*
* @param input
* @param startPattern
* @param endPattern
* @return
*/
public static String findString(String input, String startPattern, String endPattern) {
if (StrUtil.isBlank(input)) {
return null;
}
// 构建正则表达式模式
String pattern = Pattern.quote(startPattern) + "(.*?)" + Pattern.quote(endPattern);
Pattern regex = Pattern.compile(pattern);
Matcher matcher = regex.matcher(input);
if (matcher.find()) {
// 返回第一个匹配的结果
return matcher.group(1);
} else {
// 未找到匹配的结果
return null;
}
}
/**
* <h2></h2>
*
* @param input
* @return
*/
public static LabelEntity parseLanguageStr(String input) {
int number = 0;
String remainingString = input;
// 正则表达式匹配开头的数字
String regex = "^\\d+";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
String matchedNumber = matcher.group();
number = Integer.parseInt(matchedNumber);
// 从原始字符串中去除开头的数字部分
remainingString = input.substring(matchedNumber.length()).trim();
}
return new LabelEntity(number, remainingString);
}
public static class LabelEntity {
private final int languageId;
private final String label;
public LabelEntity(int languageId, String label) {
this.languageId = languageId;
this.label = label;
}
public int getLanguageId() {
return languageId;
}
public String getLabel() {
return label;
}
}
}

View File

@ -0,0 +1,342 @@
package weaver.formmode.interfaces.impl.ey.zhang;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import weaver.conn.RecordSet;
import weaver.file.ExcelParseForPOI;
import weaver.formmode.interfaces.ImportPreInterfaceForPOIAction;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.seconddev.ey.zhangm.didi.util.DaoUtils;
import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 6/22/23
*/
public class ImportExtValidateTemplate implements ImportPreInterfaceForPOIAction {
@Override
public String checkImportData(Map <String, Object> param, User user, ExcelParseForPOI excelParse) {
EYSeconddevUtil eySeconddevUtil = new EYSeconddevUtil();
String ssids="ey_clentid_col,budget_version_col,plan_source_col,ey_bucode_col,ey_oucode_col,ey_mucode_col,ey_smucode_col,ey_engagementname_col,ey_ep_col,ey_em_col,ey_pfma_col,";
ssids=ssids+"ey_local_service_code_col,ey_mercury_code_col,ey_pycode_col,ey_pacelink_col,ey_oppr_code_col,ey_blocking_level_col,opencheckcustom,";
ssids=ssids+"opencheckbudget,opencheckcodeblock,opencheckgpn,opencheckengagementname,opencheckpycode,opencheckcodeblockByBcp,openchecklocalservicecode,";
ssids=ssids+"opencheckconfidential,opencheckopprCode,opencheckmercury,opencheckblocklevel";
Map<String, String> ey_params_map =eySeconddevUtil.getSystemParamValues(ssids);
int ey_clentid_col = Util.getIntValue(ey_params_map.get("ey_clentid_col"));
int budget_version_col = Util.getIntValue(ey_params_map.get("budget_version_col"));
int plan_source_col = Util.getIntValue(ey_params_map.get("plan_source_col"));
int ey_bucode_col = Util.getIntValue(ey_params_map.get("ey_bucode_col"));
int ey_oucode_col = Util.getIntValue(ey_params_map.get("ey_oucode_col"));
int ey_mucode_col = Util.getIntValue(ey_params_map.get("ey_mucode_col"));
int ey_smucode_col = Util.getIntValue(ey_params_map.get("ey_smucode_col"));
int ey_engagementname_col = Util.getIntValue(ey_params_map.get("ey_engagementname_col"));
int ey_ep_col = Util.getIntValue(ey_params_map.get("ey_ep_col"));
int ey_em_col = Util.getIntValue(ey_params_map.get("ey_em_col"));
int ey_pfma_col = Util.getIntValue(ey_params_map.get("ey_pfma_col"));
int ey_local_service_code_col = Util.getIntValue(ey_params_map.get("ey_local_service_code_col"));
int ey_mercury_code_col = Util.getIntValue(ey_params_map.get("ey_mercury_code_col"));
int ey_pycode_col = Util.getIntValue(ey_params_map.get("ey_pycode_col"));
int ey_pacelink_col = Util.getIntValue(ey_params_map.get("ey_pacelink_col"));
int ey_oppr_code_col = Util.getIntValue(ey_params_map.get("ey_oppr_code_col"));
int ey_blocking_level_col = Util.getIntValue(ey_params_map.get("ey_blocking_level_col"));
String opencheckcustom = Util.null2String(ey_params_map.get("opencheckcustom"));
String opencheckbudget = Util.null2String(ey_params_map.get("opencheckbudget"));
String opencheckcodeblock = Util.null2String(ey_params_map.get("opencheckcodeblock"));
String opencheckgpn = Util.null2String(ey_params_map.get("opencheckgpn"));
String opencheckengagementname = Util.null2String(ey_params_map.get("opencheckengagementname"));
String opencheckpycode = Util.null2String(ey_params_map.get("opencheckpycode"));
String opencheckcodeblockByBcp = Util.null2String(ey_params_map.get("opencheckcodeblockByBcp"));
String openchecklocalservicecode = Util.null2String(ey_params_map.get("openchecklocalservicecode"));
String opencheckconfidential = Util.null2String(ey_params_map.get("opencheckconfidential"));
String opencheckopprCode =Util.null2String(ey_params_map.get("opencheckopprCode"));
String opencheckmercury =Util.null2String(ey_params_map.get("opencheckmercury"));
String opencheckblocklevel =Util.null2String(ey_params_map.get("opencheckblocklevel"));
new BaseBean().writeLog("opencheckcustom==>" + opencheckcustom+",opencheckbudget==>"+opencheckbudget+",opencheckcodeblock==>"+opencheckcodeblock);
new BaseBean().writeLog("opencheckgpn==>" + opencheckgpn+",opencheckengagementname==>"+opencheckengagementname+",opencheckpycode==>"+opencheckpycode);
new BaseBean().writeLog("opencheckcodeblockByBcp==>" + opencheckcodeblockByBcp+",openchecklocalservicecode==>"+openchecklocalservicecode+",opencheckconfidential==>"+opencheckconfidential);
new BaseBean().writeLog("opencheckopprCode==>" + opencheckopprCode+",opencheckmercury==>"+opencheckmercury);
// 获取模块ID
Integer modeId = Util.getIntValue(param.get("modeid").toString());
//表单id
Integer formId = Util.getIntValue(param.get("formid").toString());
// 获取当前登录人员ID
Integer userId = user.getUID();
String sheetname = "1";
//获取第 sheetindex 个sheet的第row行第col列的单元格的值 (下标都是从1开始)
//String value = excelParse.getValue("1", 2, 2);
Workbook wb = excelParse.getWb();
Sheet sheet = wb.getSheetAt(Util.getIntValue(sheetname) - 1);
StringBuilder error = new StringBuilder();
Pattern DATE_PATTERN = Pattern.compile("^\\d{4}-\\d{2}$");
if (sheet != null) {
int rowSum = sheet.getPhysicalNumberOfRows();
new BaseBean().writeLog("rowSum==>" + rowSum);
int current_row = 0;
for (int i = 2; i <= rowSum; i++) {
current_row = i - 1;
String client_id = Util.null2String(excelParse.getValue("1", i, ey_clentid_col));
String budget_version_id = Util.null2String(excelParse.getValue("1", i, budget_version_col));
String bucode = Util.null2String(excelParse.getValue("1", i, ey_bucode_col));
String oucode = Util.null2String(excelParse.getValue("1", i, ey_oucode_col));
String mucode = Util.null2String(excelParse.getValue("1", i, ey_mucode_col));
String plan_source = Util.null2String(excelParse.getValue("1", i, plan_source_col));
String smucode = Util.null2String(excelParse.getValue("1", i, ey_smucode_col));
String engagement_name = Util.null2String(excelParse.getValue("1", i, ey_engagementname_col)).trim();
String ep = Util.null2String(excelParse.getValue("1", i, ey_ep_col));
String em = Util.null2String(excelParse.getValue("1", i, ey_em_col));
String pfma = Util.null2String(excelParse.getValue("1", i, ey_pfma_col));
String pycode = Util.null2String(excelParse.getValue("1", i, ey_pycode_col)).trim();
String blocking_level= Util.null2String(excelParse.getValue("1", i, ey_blocking_level_col)).trim();
new BaseBean().writeLog("pycode==>"+pycode);
String pace_link = Util.null2String(excelParse.getValue("1", i, ey_pacelink_col)).trim();
String local_service_code =Util.null2String(excelParse.getValue("1", i, ey_local_service_code_col)).trim();
String opprCode =Util.null2String(excelParse.getValue("1", i, ey_oppr_code_col)).trim();
String mercury_code =Util.null2String(excelParse.getValue("1", i, ey_mercury_code_col)).trim();
String countryregioncode =Util.null2String(DaoUtils.querySingleVal("select countryregioncode from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?",bucode, oucode, mucode, smucode));
String local_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_service_code where Servicecode=?",local_service_code);
new BaseBean().writeLog("====1、mercury_code===="+mercury_code );
String mercury_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_msc_gsc where mercury_service_code=?",mercury_code);
//1、Excel模版 BU 、OU、MU、SMU校验是否存在对应codeblock Done
if (opencheckcodeblock.equals("1")) {
new BaseBean().writeLog("====1、opencheckcodeblock.start====" );
RecordSet recordSet = DaoUtils.executeQuery("select " +
" count(1) as rowcount " +
" from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode);
if (recordSet.next()) {
int rowcount = recordSet.getInt("rowcount");
if (rowcount > 1) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认codeblock是否唯一!").append("<BR />");
} else if (rowcount == 0) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未匹配到对应codeblock数据").append("<BR />");
}
}
new BaseBean().writeLog("====1、opencheckcodeblock.end====" );
}
//2、Excel模版 BU 、OU、MU、SMU校验调用业务核心接口 Done
if (opencheckcodeblockByBcp.equals("1")) {
new BaseBean().writeLog("====2、opencheckcodeblockByBcp.start====" );
boolean flag =eySeconddevUtil.getLegalEffective(bucode,oucode,mucode,smucode);
new BaseBean().writeLog("getLegalEffective===>"+flag);
if(!flag){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Bu,Ou,Mu,Smu有效性! ").append("<BR />");
}
new BaseBean().writeLog("====2、opencheckcodeblockByBcp.end====" );
}
//3、Excel模版商机校验国家编号不是MNG商机id必填 Done
if (opencheckopprCode.equals("1") ) {
new BaseBean().writeLog("====3、opencheckopprCode.start====" );
new BaseBean().writeLog("====3、countryregioncode===="+countryregioncode );
if(StringUtils.isNotBlank(countryregioncode)){
if( !countryregioncode.equals("MNG") && opprCode.equals("")){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,商机id必填! ").append("<BR />");
}
}
new BaseBean().writeLog("====3、opencheckopprCode.end====" );
}
//4、Excel模版Client_id校验 Done
if (opencheckcustom.equals("1")) {
new BaseBean().writeLog("====4、opencheckcustom.start====" );
Map <String, Object> custominfo = eySeconddevUtil.getCustomInfo(client_id);
String code = Util.null2String((String)custominfo.get("code"));
new BaseBean().writeLog("getCustomInfo===>"+code);
if (!code.equals("100")) {
//return "数据验证失败:第一个sheet第"+current_row+"行数据的,请确认客户中心系统中已存在该客户!";
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认客户中心系统中已存在该客户! ")
.append("<BR />");
}
new BaseBean().writeLog("====4、opencheckcustom.end====" );
}
//5、Excel模版Client_id商机idPACE_ID截取PACE_link 校验项 前置条件国家编号不是MNG
// 调用商机接口传入Client_id,商机idPACE_ID 是否有效有效返回IsConfidential Done
if (opencheckconfidential.equals("1")) {
new BaseBean().writeLog("====5、opencheckconfidential.start====" );
String pace_id ="";
if(StringUtils.isNotBlank(pace_link)){
int beginindex =pace_link.lastIndexOf("Assessment/")+11;
String endstr =pace_link.substring(beginindex,pace_link.length());
int endindex = endstr.lastIndexOf("/");
pace_id =pace_link.substring(beginindex,beginindex+endindex);
new BaseBean().writeLog("ModeExpandForExtCodeImport,pace_id==>"+pace_id);
}
Map<String,Object > result =eySeconddevUtil.getConfidentialInfo(opprCode,pace_id,client_id);
String errstr =Util.null2String(result.get("errorstr"));
if(StringUtils.isNotBlank(errstr)){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据,请确认"+errstr.substring(0,errstr.length()-1)+"等问题! ")
.append("<BR />");
}
new BaseBean().writeLog("====5、opencheckconfidential.end====" );
}
//6、Excel模版”PY_Code” 校验: PY code 历史上是否存在对应的.engagement_code Done
if (opencheckpycode.equals("1")) {
new BaseBean().writeLog("====6、opencheckpycode.start====" );
new BaseBean().writeLog("====6、opencheckpycode.pycode===="+pycode );
if(StringUtils.isNotBlank(pycode)){
RecordSet rs2 = new RecordSet();
rs2.executeQuery("select id from uf_xmjbxxjmbd where engagement_code=?", pycode);
if (!rs2.next()) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,该项目PY_CODE未关联! ").append("<BR />");
}
}
new BaseBean().writeLog("====6、opencheckpycode.end====" );
}
//7、Excel模版“本地服务编码”校验uf_service_code.Servicecode 是否存在 Done
if (openchecklocalservicecode.equals("1")) {
new BaseBean().writeLog("====7、openchecklocalservicecode.start====" );
RecordSet rs2 = new RecordSet();
new BaseBean().writeLog("====7、openchecklocalservicecode.local_service_code====" +local_service_code);
rs2.executeQuery("select id from uf_service_code where Servicecode=? ",local_service_code);
if(!rs2.next()){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认本地服务编码是否有效! ").append("<BR />");
}
new BaseBean().writeLog("====7、openchecklocalservicecode.end====" );
}
//8、Excel模版“计划编号”校验项 根据“计划来源”调用CCT&MMT或者SmartHub接口是否存在 Done
if (opencheckbudget.equals("1")) {
new BaseBean().writeLog("==8、opencheckbudget。start==");
Map <String, Object> budgetinfo = new HashMap <String, Object>();
new BaseBean().writeLog("==plan_source=="+plan_source);
if(!(plan_source.equals("CCT") || plan_source.equals("MMT") || plan_source.equals("SmartHub") )){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,计划来源填写错误只允许填写CCT、MMT、SmartHub!").append("<BR />");
}
if (plan_source.equals("CCT") || plan_source.equals("MMT")) {
budgetinfo = eySeconddevUtil.getBudgetInfo("mmtplandetail", budget_version_id);
} else {
budgetinfo = eySeconddevUtil.getBudgetInfo("smarthubbudgetdetail", budget_version_id);
}
new BaseBean().writeLog("==budgetinfo=="+ JSON.toJSONString(budgetinfo));
if (budgetinfo.isEmpty() || budgetinfo==null) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认预算系统中是否存在该预算!").append("<BR />");
}
new BaseBean().writeLog("==8、opencheckbudget。end==");
}
//9、Excel模版GPN是否存在 Done
if (opencheckgpn.equals("1")) {
new BaseBean().writeLog("==9、opencheckgpn。start==");
new BaseBean().writeLog("em==>"+em);
new BaseBean().writeLog("ep==>"+ep);
new BaseBean().writeLog("pfma==>"+pfma);
if (StringUtils.isNotBlank(ep)) {
RecordSet recordSet=new RecordSet();
recordSet.executeQuery("select id from hrmresource where workcode=?",ep);
if(!recordSet.next()){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("<BR />");
}
}
if (StringUtils.isNotBlank(em)) {
RecordSet recordSet=new RecordSet();
recordSet.executeQuery("select id from hrmresource where workcode=?",em);
if(!recordSet.next()){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("<BR />");
}
}
if (StringUtils.isNotBlank(pfma)) {
RecordSet recordSet=new RecordSet();
recordSet.executeQuery("select id from hrmresource where workcode=?",pfma);
if(!recordSet.next()){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认PFMA的GPN不存在系统中!").append("<BR />");
}
}
new BaseBean().writeLog("==9、opencheckgpn。end==");
}
//10、mercury_service_code校验 Done
if(opencheckmercury.equals("1")){
new BaseBean().writeLog("==10、opencheckmercury。start==");
new BaseBean().writeLog("====10、mercury_global_service_code===="+mercury_global_service_code );
new BaseBean().writeLog("====10、local_global_service_code===="+local_global_service_code );
if(!mercury_global_service_code.equals(local_global_service_code)){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认MercuryCode与global_service_code不匹配!").append("<BR />");
}
new BaseBean().writeLog("==10、opencheckmercury。end==");
}
//11、Excel的项目名称 Done
if (opencheckengagementname.equals("1")) {
new BaseBean().writeLog("==11、opencheckengagementname。start==");
new BaseBean().writeLog("==11、opencheckengagementname。engagement_name=="+engagement_name);
RecordSet recordSet = new RecordSet();
recordSet.executeQuery("select " +
" servicelinecode, subservicelinecode " +
" from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode);
if(recordSet.next()){
String servicelinecode =Util.null2String(recordSet.getString("servicelinecode"));
String subservicelinecode =Util.null2String(recordSet.getString("subservicelinecode"));
if(servicelinecode.equals("01") && subservicelinecode.equals("0101")){ //serviceline=01和subserviceline=0101时触发项目名称校验
//检验 0~3位 必须是AUT 或者 INT
boolean flag = EYSeconddevUtil.vaildateImportEnagementName(engagement_name,local_global_service_code);
String datestr = engagement_name.substring(3, 10);
if(!flag){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认前3位是否合规! ").append("<BR />");
}else if(!DATE_PATTERN.matcher(datestr).matches()){ //检验4~10位 必须是YYYY-MM
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认4到10位是否日期字段如:2001-01! ").append("<BR />");
}
}
}
new BaseBean().writeLog("==11、opencheckengagementname。end==");
}
//12、BlockLevel Done
if(opencheckblocklevel.equals("1")){
new BaseBean().writeLog("==12、opencheckblocklevel.start==");
if (StringUtils.isNotBlank(ep)) {
RecordSet recordSet=new RecordSet();
recordSet.executeQuery("select id from uf_bl where engblocklevel =?",blocking_level);
if(!recordSet.next()){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,blocking_level填写有误请检查!").append("<BR />");
}
}
new BaseBean().writeLog("==12、opencheckblocklevel.end==");
}
// 12、校验项目EP Rank
if (!"".equals(ep) && !eySeconddevUtil.validateEngagementRoleRank(ep,"1","0")) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EP填写有误请检查!").append("<BR />");
}
// 13、校验项目EM Rank
if (!"".equals(em) && !eySeconddevUtil.validateEngagementRoleRank(em,"1","0")) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EM填写有误请检查!").append("<BR />");
}
}
}
String returnstr =error.toString();
new BaseBean().writeLog("returnstr===>"+returnstr);
return returnstr;
}
}

View File

@ -0,0 +1,307 @@
package weaver.formmode.interfaces.impl.ey.zhang;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import weaver.conn.RecordSet;
import weaver.file.ExcelParseForPOI;
import weaver.formmode.interfaces.ImportPreInterfaceForPOIAction;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.seconddev.ey.zhangm.didi.util.DaoUtils;
import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 6/22/23
*/
public class ImportNtoOValidateTemplate implements ImportPreInterfaceForPOIAction {
@Override
public String checkImportData(Map <String, Object> param, User user, ExcelParseForPOI excelParse) {
EYSeconddevUtil eySeconddevUtil = new EYSeconddevUtil();
String ssids="ey_nto_clentid_col,ey_nto_budget_version_col,ey_nto_bucode_col,ey_nto_oucode_col,ey_nto_mucode_col,ey_nto_smucode_col,ey_nto_engagementname_col,ey_nto_ep_col,ey_nto_em_col,ey_nto_pfma_col,";
ssids=ssids+"ey_nto_engagementcode_col,ey_nto_mercurycode_col,ey_nto_pacelink_col,opencheckntooengagementstatus,";
ssids=ssids+"opencheckntooservicecode,opencheckntooserviceline,opencheckntopycode,opencheckntoengagementname,opencheckntocustom,opencheckntocodeblock,opencheckntogpn,";
ssids=ssids+"opencheckntobudget,opencheckntomercury,opencheckntopaceid";
Map<String, String> ey_params_map =eySeconddevUtil.getSystemParamValues(ssids);
int ey_clentid_col = Util.getIntValue(ey_params_map.get("ey_nto_clentid_col"));
int budget_version_col = Util.getIntValue(ey_params_map.get("ey_nto_budget_version_col"));
int ey_bucode_col = Util.getIntValue(ey_params_map.get("ey_nto_bucode_col"));
int ey_oucode_col = Util.getIntValue(ey_params_map.get("ey_nto_oucode_col"));
int ey_mucode_col = Util.getIntValue(ey_params_map.get("ey_nto_mucode_col"));
int ey_smucode_col = Util.getIntValue(ey_params_map.get("ey_nto_smucode_col"));
int ey_engagementname_col = Util.getIntValue(ey_params_map.get("ey_nto_engagementname_col"));
int ey_ep_col = Util.getIntValue(ey_params_map.get("ey_nto_ep_col"));
int ey_em_col = Util.getIntValue(ey_params_map.get("ey_nto_em_col"));
int ey_pfma_col = Util.getIntValue(ey_params_map.get("ey_nto_pfma_col"));
int ey_engagementcode_col = Util.getIntValue(ey_params_map.get("ey_nto_engagementcode_col"));
int ey_mercurycode_col = Util.getIntValue(ey_params_map.get("ey_nto_mercurycode_col"));
int ey_pacelink_col = Util.getIntValue(ey_params_map.get("ey_nto_pacelink_col"));
String opencheckntooengagementstatus = Util.null2String(ey_params_map.get("opencheckntooengagementstatus"));
String opencheckntoservicecode = Util.null2String(ey_params_map.get("opencheckntooservicecode"));
String opencheckntoserviceline = Util.null2String(ey_params_map.get("opencheckntooserviceline"));
String opencheckntopycode = Util.null2String(ey_params_map.get("opencheckntopycode"));
String opencheckntoengagementname = Util.null2String(ey_params_map.get("opencheckntoengagementname"));
String opencheckntocustom = Util.null2String(ey_params_map.get("opencheckntocustom"));
String opencheckntocodeblock= Util.null2String(ey_params_map.get("opencheckntocodeblock"));
String opencheckntogpn= Util.null2String(ey_params_map.get("opencheckntogpn"));
String opencheckntobudget = Util.null2String(ey_params_map.get("opencheckntobudget"));
String opencheckntomercury= Util.null2String(ey_params_map.get("opencheckntomercury"));
String opencheckntopaceid = Util.null2String(ey_params_map.get("opencheckntopaceid"));
new BaseBean().writeLog("opencheckntooengagementstatus==>" + opencheckntooengagementstatus+",opencheckntoservicecode==>"+opencheckntoservicecode+",opencheckntoserviceline==>"+opencheckntoserviceline);
new BaseBean().writeLog("opencheckntopycode==>" + opencheckntopycode+",opencheckntoengagementname==>"+opencheckntoengagementname+",opencheckntocustom==>"+opencheckntocustom);
new BaseBean().writeLog("opencheckntocodeblock==>" + opencheckntocodeblock+",opencheckntogpn==>"+opencheckntogpn+",opencheckntobudget==>"+opencheckntobudget);
new BaseBean().writeLog("opencheckntomercury==>" + opencheckntomercury+",opencheckntopaceid==>"+opencheckntopaceid);
// 获取模块ID
Integer modeId = Util.getIntValue(param.get("modeid").toString());
//表单id
Integer formId = Util.getIntValue(param.get("formid").toString());
// 获取当前登录人员ID
Integer userId = user.getUID();
String sheetname = "1";
//获取第 sheetindex 个sheet的第row行第col列的单元格的值 (下标都是从1开始)
//String value = excelParse.getValue("1", 2, 2);
Workbook wb = excelParse.getWb();
Sheet sheet = wb.getSheetAt(Util.getIntValue(sheetname) - 1);
StringBuilder error = new StringBuilder();
Pattern DATE_PATTERN = Pattern.compile("^\\d{4}-\\d{2}$");
if (sheet != null) {
int rowSum = sheet.getPhysicalNumberOfRows();
new BaseBean().writeLog("rowSum==>" + rowSum);
int current_row = 0;
for (int i = 2; i <= rowSum; i++) {
current_row = i - 1;
String client_id = Util.null2String(excelParse.getValue("1", i, ey_clentid_col));
String budget_version_id = Util.null2String(excelParse.getValue("1", i, budget_version_col));
String bucode = Util.null2String(excelParse.getValue("1", i, ey_bucode_col));
String oucode = Util.null2String(excelParse.getValue("1", i, ey_oucode_col));
String mucode = Util.null2String(excelParse.getValue("1", i, ey_mucode_col));
String smucode = Util.null2String(excelParse.getValue("1", i, ey_smucode_col));
String engagement_name = Util.null2String(excelParse.getValue("1", i, ey_engagementname_col)).trim();
String ep = Util.null2String(excelParse.getValue("1", i, ey_ep_col));
String em = Util.null2String(excelParse.getValue("1", i, ey_em_col));
String pfma = Util.null2String(excelParse.getValue("1", i, ey_pfma_col));
String engagement_code = Util.null2String(excelParse.getValue("1", i, ey_engagementcode_col)).trim();
String mercury_code = Util.null2String(excelParse.getValue("1", i, ey_mercurycode_col)).trim();
String pace_link = Util.null2String(excelParse.getValue("1", i, ey_pacelink_col)).trim();
RecordSet rs2 = new RecordSet();
rs2.executeQuery("select engagement_status,local_service_code,global_service_code,service_line,sub_service_line,py_code from uf_xmjbxxjmbd where engagement_code=? ", engagement_code);
if(rs2.next()) {
String local_service_code = Util.null2String(rs2.getString("local_service_code"));
String service_line = Util.null2String(rs2.getString("service_line"));
String global_service_code = Util.null2String(rs2.getString("global_service_code"));
String sub_service_line = Util.null2String(rs2.getString("sub_service_line"));
String temp_py_code = Util.null2String(rs2.getString("py_code"));
String engagement_status = Util.null2String(rs2.getString("engagement_status"));
//String local_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_service_code where Servicecode=?",local_service_code);
String mercury_global_service_code = DaoUtils.querySingleVal("select global_service_code from uf_msc_gsc where mercury_service_code=?", mercury_code);
String old_pace_id = DaoUtils.querySingleVal("select pace_id from uf_xmjbxxjmbd where engagement_code=?", temp_py_code);
String py_engagement_name = DaoUtils.querySingleVal("select engagement_name from uf_xmjbxxjmbd where engagement_code=?", temp_py_code);
//1、校验该项目编号在项目档案中的 通过engcode查询项目状态为N
if (opencheckntooengagementstatus.equals("1")) {
new BaseBean().writeLog("====1、opencheckntooengagementstatus.start====");
new BaseBean().writeLog("engagement_status==>" + engagement_status);
if (!engagement_status.equals("N")) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目状态不为N! ").append("<BR />");
}
new BaseBean().writeLog("====1、opencheckntooengagementstatus.end====");
}
//2、校验GSC为031、035。通过engcode查询GSC为GSC =031、GSC=035 local_serivce_code=03500 or local_serivce_code=03100
if (opencheckntoservicecode.equals("1")) {
new BaseBean().writeLog("====2、opencheckntoservicecode.start====");
new BaseBean().writeLog("local_service_code==>" + local_service_code);
if (!local_service_code.equals("03500") && !local_service_code.equals("03100")) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目本地服务编码是03500或03100! ").append("<BR />");
}
new BaseBean().writeLog("====2、opencheckntoservicecode.end====");
}
//3、原项目业务线必须是ASU!
if (opencheckntoserviceline.equals("1")) {
new BaseBean().writeLog("====3、opencheckntoserviceline.start====");
new BaseBean().writeLog("====3、service_line====" + service_line);
new BaseBean().writeLog("====3、sub_service_line====" + sub_service_line);
if (!(service_line.equals("01") && sub_service_line.equals("0101"))) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目业务线必须是ASU,子业务线是Audit! ").append("<BR />");
}
new BaseBean().writeLog("====3、opencheckntoserviceline.end====");
}
//4、校该项目编号在项目档案中关联的PY Code不能为空
if (opencheckntopycode.equals("1")) {
new BaseBean().writeLog("====4、opencheckntopycode.start====");
new BaseBean().writeLog("====4、opencheckntopycode.temp_py_code====" + temp_py_code);
if (temp_py_code.equals("")) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目原PY_CODE不能为空! ").append("<BR />");
}
new BaseBean().writeLog("====4、opencheckntopycode.end====");
}
//5、Excel的项目名称 Done
if (opencheckntoengagementname.equals("1")) {
new BaseBean().writeLog("====5、opencheckntoengagementname.start====");
if (engagement_name.equals(py_engagement_name)) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规请确认项目名称是否重复或名称格式是否错误正确格式如AUD2023-01XXXXX! ").append("<BR />");
}else if(engagement_name.length()<=10){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规请确认项目名称是否重复或名称格式是否错误正确格式如AUD2023-01XXXXX! ").append("<BR />");
}else if (engagement_name.length()>10 ){
String datestr = engagement_name.substring(3, 10);
//String perfix = engagement_name.substring(0, 3);
boolean flag = EYSeconddevUtil.vaildateImportEnagementName(engagement_name,global_service_code);
//检验4~10位 必须是YYYY-MM
if (!DATE_PATTERN.matcher(datestr).matches()) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规请确认项目名称是否重复或名称格式是否错误正确格式如AUD2023-01XXXXX! ").append("<BR />");
}else if(!flag) { //检验 0~3位 必须是AUT 或者 INT
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规请确认项目名称是否重复或名称格式是否错误正确格式如AUD2023-01XXXXX! ").append("<BR />");
}
}else if (engagement_name.length()<=10){
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规请确认项目名称是否重复或名称格式是否错误正确格式如AUD2023-01XXXXX! ").append("<BR />");
}
new BaseBean().writeLog("====5、opencheckntoengagementname.end====");
}
//6、客户信息 Done
if (opencheckntocustom.equals("1")) {
new BaseBean().writeLog("====6、opencheckntocustom.start====");
Map <String, Object> custominfo = eySeconddevUtil.getCustomInfo(client_id);
String code = Util.null2String(custominfo.get("code"));
if (!code.equals("100")) {
//return "数据验证失败:第一个sheet第"+current_row+"行数据的,请确认客户中心系统中已存在该客户!";
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认客户中心系统中已存在该客户! ")
.append("<BR />");
}
new BaseBean().writeLog("====6、opencheckntocustom.end====");
}
//7、pace_id校验
if (opencheckntopaceid.equals("1")) {
new BaseBean().writeLog("====7、opencheckntopaceid.start====");
String pace_id = "";
if (StringUtils.isNotBlank(pace_link)) {
int beginindex = pace_link.lastIndexOf("Assessment/") + 11;
String endstr = pace_link.substring(beginindex, pace_link.length());
int endindex = endstr.lastIndexOf("/");
pace_id = pace_link.substring(beginindex, beginindex + endindex);
new BaseBean().writeLog("ModeExpandForExtCodeImport,pace_id==>" + pace_id);
}
if (pace_id.equals(old_pace_id)) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未创建新的PACE!").append("<BR />");
}
new BaseBean().writeLog("====7、opencheckntopaceid.end====");
}
//8、CodeBlock信息 Done
if (opencheckntocodeblock.equals("1")) {
new BaseBean().writeLog("====8、opencheckntocodeblock.start====");
RecordSet recordSet = DaoUtils.executeQuery("select " +
" id " +
" from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode);
if (!recordSet.next()) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未匹配到对应codeblock数据").append("<BR />");
}
new BaseBean().writeLog("====8、opencheckntocodeblock.end====");
}
//9、GPN是否存在 Done
if (opencheckntogpn.equals("1")) {
new BaseBean().writeLog("====9、opencheckntogpn.start====");
new BaseBean().writeLog("em==>" + em);
new BaseBean().writeLog("ep==>" + ep);
new BaseBean().writeLog("pfma==>" + pfma);
if (StringUtils.isNotBlank(ep)) {
RecordSet recordSet = new RecordSet();
recordSet.executeQuery("select id from hrmresource where workcode=?", ep);
if (!recordSet.next()) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("<BR />");
}
}
if (StringUtils.isNotBlank(em)) {
RecordSet recordSet = new RecordSet();
recordSet.executeQuery("select id from hrmresource where workcode=?", em);
if (!recordSet.next()) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("<BR />");
}
}
if (StringUtils.isNotBlank(pfma)) {
RecordSet recordSet = new RecordSet();
recordSet.executeQuery("select id from hrmresource where workcode=?", pfma);
if (!recordSet.next()) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认PFMA的GPN不存在系统中!").append("<BR />");
}
}
new BaseBean().writeLog("====9、opencheckntogpn.end====");
}
// 10、SmartHub检查
if (opencheckntobudget.equals("1")) {
new BaseBean().writeLog("====10、opencheckntobudget.start====");
Map <String, Object> budgetinfo = new HashMap <String, Object>();
budgetinfo = eySeconddevUtil.getBudgetInfo("smarthubbudgetdetail", budget_version_id);
//}
if (budgetinfo.size() == 0) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认预算系统中已存在该预算!").append("<BR />");
}
new BaseBean().writeLog("====10、opencheckntobudget.end====");
}
// 11、mercury_service_code校验 Done
if (opencheckntomercury.equals("1")) {
new BaseBean().writeLog("====11、opencheckntomercury.start====");
new BaseBean().writeLog("global_service_code==>" + global_service_code);
new BaseBean().writeLog("mercury_global_service_code==>" + mercury_global_service_code);
if (!(mercury_global_service_code.equals(global_service_code))) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Mercury Service Code与Global Service Code不匹配!").append("<BR />");
}
new BaseBean().writeLog("====11、opencheckntomercury.end====");
}
}else{
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Engagement Code不存在!").append("<BR />");
}
// 12、校验项目EP Rank
if (!"".equals(ep) && !eySeconddevUtil.validateEngagementRoleRank(ep,"1","0")) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EP填写有误请检查!").append("<BR />");
}
// 13、校验项目EM Rank
if (!"".equals(em) && !eySeconddevUtil.validateEngagementRoleRank(em,"1","0")) {
error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EM填写有误请检查!").append("<BR />");
}
}
}
if (error.toString().equals("")) {
return "";
} else {
return error.toString();
}
}
}

View File

@ -0,0 +1,20 @@
package weaver.seconddev.ey.zhangm.didi.annotation;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/2/22
*/
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface DaoField {
boolean value() default true;
}

View File

@ -0,0 +1,18 @@
package weaver.seconddev.ey.zhangm.didi.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/2/22
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface DaoTableField {
String value() default "";
}

View File

@ -0,0 +1,55 @@
package weaver.seconddev.ey.zhangm.didi.entity;
import org.jetbrains.annotations.NotNull;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 12/9/22
*/
public class DidiInvoiceOrder implements Comparable<DidiInvoiceOrder> {
private String orderid;
private String businessunit;
private String amount;
@Override
public int compareTo(@NotNull DidiInvoiceOrder o) {
return getBusinessunit().compareTo(o.getBusinessunit());
}
@Override
public String toString() {
return "DidiInvoiceOrder{" +
"orderid='" + orderid + '\'' +
", businessunit='" + businessunit + '\'' +
", account='" + amount + '\'' +
'}';
}
public String getOrderid() {
return orderid;
}
public void setOrderid(String orderid) {
this.orderid = orderid;
}
public String getBusinessunit() {
return businessunit;
}
public void setBusinessunit(String businessunit) {
this.businessunit = businessunit;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
}

View File

@ -0,0 +1,543 @@
package weaver.seconddev.ey.zhangm.didi.entity;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/2/22
*/
public class DidiOrder {
private String order_id;
private String create_time;
private String use_car_type;
private String require_level;
private String city;
private String city_name;
private String start_name;
private String end_name;
private String actual_start_name;
private String actual_end_name;
private String actual_flat;
private String actual_flng;
private String actual_tlat;
private String actual_tlng;
private String departure_time;
private String finish_time;
private String status;
private String pay_type;
private String member_id;
private String pay_time;
private String normal_distance;
private String total_price;
private String actual_price;
private String refund_time;
private String refund_price;
private String company_pay;
private String company_card_pay;
private String personal_pay;
private String company_real_pay;
private String company_card_real_pay;
private String personal_real_pay;
private String company_real_refund;
private String company_card_real_refund;
private String personal_real_refund;
private String is_invoice;
private String call_phone;
private String passenger_phone;
private String passenger_name;
private String budget_center_id;
private String budget_item_id;
private String use_car_config_id;
private String order_source;
private String is_carpool;
private String encrypted_info;
private String approval_id;
private String out_approval_id;
private String callback_info;
private String engcode;
@Override
public String toString() {
return "DidiOrder{" +
"order_id='" + order_id + '\'' +
", create_time='" + create_time + '\'' +
", use_car_type='" + use_car_type + '\'' +
", require_level='" + require_level + '\'' +
", city='" + city + '\'' +
", city_name='" + city_name + '\'' +
", start_name='" + start_name + '\'' +
", end_name='" + end_name + '\'' +
", actual_start_name='" + actual_start_name + '\'' +
", actual_end_name='" + actual_end_name + '\'' +
", actual_flat='" + actual_flat + '\'' +
", actual_flng='" + actual_flng + '\'' +
", actual_tlat='" + actual_tlat + '\'' +
", actual_tlng='" + actual_tlng + '\'' +
", departure_time='" + departure_time + '\'' +
", finish_time='" + finish_time + '\'' +
", status='" + status + '\'' +
", pay_type='" + pay_type + '\'' +
", member_id='" + member_id + '\'' +
", pay_time='" + pay_time + '\'' +
", normal_distance='" + normal_distance + '\'' +
", total_price='" + total_price + '\'' +
", actual_price='" + actual_price + '\'' +
", refund_time='" + refund_time + '\'' +
", refund_price='" + refund_price + '\'' +
", company_pay='" + company_pay + '\'' +
", company_card_pay='" + company_card_pay + '\'' +
", personal_pay='" + personal_pay + '\'' +
", company_real_pay='" + company_real_pay + '\'' +
", company_card_real_pay='" + company_card_real_pay + '\'' +
", personal_real_pay='" + personal_real_pay + '\'' +
", company_real_refund='" + company_real_refund + '\'' +
", company_card_real_refund='" + company_card_real_refund + '\'' +
", personal_real_refund='" + personal_real_refund + '\'' +
", is_invoice='" + is_invoice + '\'' +
", call_phone='" + call_phone + '\'' +
", passenger_phone='" + passenger_phone + '\'' +
", passenger_name='" + passenger_name + '\'' +
", budget_center_id='" + budget_center_id + '\'' +
", budget_item_id='" + budget_item_id + '\'' +
", use_car_config_id='" + use_car_config_id + '\'' +
", order_source='" + order_source + '\'' +
", is_carpool='" + is_carpool + '\'' +
", encrypted_info='" + encrypted_info + '\'' +
", approval_id='" + approval_id + '\'' +
", out_approval_id='" + out_approval_id + '\'' +
", callback_info='" + callback_info + '\'' +
", engcode='" + engcode + '\'' +
'}';
}
public String getOrder_id() {
return order_id;
}
public DidiOrder setOrder_id(String order_id) {
this.order_id = order_id;
return this;
}
public String getCreate_time() {
return create_time;
}
public DidiOrder setCreate_time(String create_time) {
this.create_time = create_time;
return this;
}
public String getUse_car_type() {
return use_car_type;
}
public DidiOrder setUse_car_type(String use_car_type) {
this.use_car_type = use_car_type;
return this;
}
public String getRequire_level() {
return require_level;
}
public DidiOrder setRequire_level(String require_level) {
this.require_level = require_level;
return this;
}
public String getCity() {
return city;
}
public DidiOrder setCity(String city) {
this.city = city;
return this;
}
public String getCity_name() {
return city_name;
}
public DidiOrder setCity_name(String city_name) {
this.city_name = city_name;
return this;
}
public String getStart_name() {
return start_name;
}
public DidiOrder setStart_name(String start_name) {
this.start_name = start_name;
return this;
}
public String getEnd_name() {
return end_name;
}
public DidiOrder setEnd_name(String end_name) {
this.end_name = end_name;
return this;
}
public String getActual_start_name() {
return actual_start_name;
}
public DidiOrder setActual_start_name(String actual_start_name) {
this.actual_start_name = actual_start_name;
return this;
}
public String getActual_end_name() {
return actual_end_name;
}
public DidiOrder setActual_end_name(String actual_end_name) {
this.actual_end_name = actual_end_name;
return this;
}
public String getActual_flat() {
return actual_flat;
}
public DidiOrder setActual_flat(String actual_flat) {
this.actual_flat = actual_flat;
return this;
}
public String getActual_flng() {
return actual_flng;
}
public DidiOrder setActual_flng(String actual_flng) {
this.actual_flng = actual_flng;
return this;
}
public String getActual_tlat() {
return actual_tlat;
}
public DidiOrder setActual_tlat(String actual_tlat) {
this.actual_tlat = actual_tlat;
return this;
}
public String getActual_tlng() {
return actual_tlng;
}
public DidiOrder setActual_tlng(String actual_tlng) {
this.actual_tlng = actual_tlng;
return this;
}
public String getDeparture_time() {
return departure_time;
}
public DidiOrder setDeparture_time(String departure_time) {
this.departure_time = departure_time;
return this;
}
public String getFinish_time() {
return finish_time;
}
public DidiOrder setFinish_time(String finish_time) {
this.finish_time = finish_time;
return this;
}
public String getStatus() {
return status;
}
public DidiOrder setStatus(String status) {
this.status = status;
return this;
}
public String getPay_type() {
return pay_type;
}
public DidiOrder setPay_type(String pay_type) {
this.pay_type = pay_type;
return this;
}
public String getMember_id() {
return member_id;
}
public DidiOrder setMember_id(String member_id) {
this.member_id = member_id;
return this;
}
public String getPay_time() {
return pay_time;
}
public DidiOrder setPay_time(String pay_time) {
this.pay_time = pay_time;
return this;
}
public String getNormal_distance() {
return normal_distance;
}
public DidiOrder setNormal_distance(String normal_distance) {
this.normal_distance = normal_distance;
return this;
}
public String getTotal_price() {
return total_price;
}
public DidiOrder setTotal_price(String total_price) {
this.total_price = total_price;
return this;
}
public String getActual_price() {
return actual_price;
}
public DidiOrder setActual_price(String actual_price) {
this.actual_price = actual_price;
return this;
}
public String getRefund_time() {
return refund_time;
}
public DidiOrder setRefund_time(String refund_time) {
this.refund_time = refund_time;
return this;
}
public String getRefund_price() {
return refund_price;
}
public DidiOrder setRefund_price(String refund_price) {
this.refund_price = refund_price;
return this;
}
public String getCompany_pay() {
return company_pay;
}
public DidiOrder setCompany_pay(String company_pay) {
this.company_pay = company_pay;
return this;
}
public String getCompany_card_pay() {
return company_card_pay;
}
public DidiOrder setCompany_card_pay(String company_card_pay) {
this.company_card_pay = company_card_pay;
return this;
}
public String getPersonal_pay() {
return personal_pay;
}
public DidiOrder setPersonal_pay(String personal_pay) {
this.personal_pay = personal_pay;
return this;
}
public String getCompany_real_pay() {
return company_real_pay;
}
public DidiOrder setCompany_real_pay(String company_real_pay) {
this.company_real_pay = company_real_pay;
return this;
}
public String getCompany_card_real_pay() {
return company_card_real_pay;
}
public DidiOrder setCompany_card_real_pay(String company_card_real_pay) {
this.company_card_real_pay = company_card_real_pay;
return this;
}
public String getPersonal_real_pay() {
return personal_real_pay;
}
public DidiOrder setPersonal_real_pay(String personal_real_pay) {
this.personal_real_pay = personal_real_pay;
return this;
}
public String getCompany_real_refund() {
return company_real_refund;
}
public DidiOrder setCompany_real_refund(String company_real_refund) {
this.company_real_refund = company_real_refund;
return this;
}
public String getCompany_card_real_refund() {
return company_card_real_refund;
}
public DidiOrder setCompany_card_real_refund(String company_card_real_refund) {
this.company_card_real_refund = company_card_real_refund;
return this;
}
public String getPersonal_real_refund() {
return personal_real_refund;
}
public DidiOrder setPersonal_real_refund(String personal_real_refund) {
this.personal_real_refund = personal_real_refund;
return this;
}
public String getIs_invoice() {
return is_invoice;
}
public DidiOrder setIs_invoice(String is_invoice) {
this.is_invoice = is_invoice;
return this;
}
public String getCall_phone() {
return call_phone;
}
public DidiOrder setCall_phone(String call_phone) {
this.call_phone = call_phone;
return this;
}
public String getPassenger_phone() {
return passenger_phone;
}
public DidiOrder setPassenger_phone(String passenger_phone) {
this.passenger_phone = passenger_phone;
return this;
}
public String getPassenger_name() {
return passenger_name;
}
public DidiOrder setPassenger_name(String passenger_name) {
this.passenger_name = passenger_name;
return this;
}
public String getBudget_center_id() {
return budget_center_id;
}
public DidiOrder setBudget_center_id(String budget_center_id) {
this.budget_center_id = budget_center_id;
return this;
}
public String getBudget_item_id() {
return budget_item_id;
}
public DidiOrder setBudget_item_id(String budget_item_id) {
this.budget_item_id = budget_item_id;
return this;
}
public String getUse_car_config_id() {
return use_car_config_id;
}
public DidiOrder setUse_car_config_id(String use_car_config_id) {
this.use_car_config_id = use_car_config_id;
return this;
}
public String getOrder_source() {
return order_source;
}
public DidiOrder setOrder_source(String order_source) {
this.order_source = order_source;
return this;
}
public String getIs_carpool() {
return is_carpool;
}
public DidiOrder setIs_carpool(String is_carpool) {
this.is_carpool = is_carpool;
return this;
}
public String getEncrypted_info() {
return encrypted_info;
}
public DidiOrder setEncrypted_info(String encrypted_info) {
this.encrypted_info = encrypted_info;
return this;
}
public String getApproval_id() {
return approval_id;
}
public DidiOrder setApproval_id(String approval_id) {
this.approval_id = approval_id;
return this;
}
public String getOut_approval_id() {
return out_approval_id;
}
public DidiOrder setOut_approval_id(String out_approval_id) {
this.out_approval_id = out_approval_id;
return this;
}
public String getCallback_info() {
return callback_info;
}
public void setCallback_info(String callback_info) {
this.callback_info = callback_info;
}
public String getEngcode() {
return engcode;
}
public void setEngcode(String engcode) {
this.engcode = engcode;
}
}

View File

@ -0,0 +1,109 @@
package weaver.seconddev.ey.zhangm.didi.entity;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/29/22
*/
public class DidiQualification {
private String id;
private String company_id;
private String invoice_title;
private String tax_registration_number;
private String registered_address;
private String telephone;
private String deposit_bank;
private String bank_account;
private String subcompanyid;
@Override
public String toString() {
return "DidiQualification{" +
"pkid='" + id + '\'' +
", company_id='" + company_id + '\'' +
", invoice_title='" + invoice_title + '\'' +
", tax_registration_number='" + tax_registration_number + '\'' +
", registered_address='" + registered_address + '\'' +
", telephone='" + telephone + '\'' +
", deposit_bank='" + deposit_bank + '\'' +
", bank_account='" + bank_account + '\'' +
", subcompanyid='" + subcompanyid + '\'' +
'}';
}
public String getId() {
return id;
}
public void setPkid(String id) {
this.id = id;
}
public String getCompany_id() {
return company_id;
}
public void setCompany_id(String company_id) {
this.company_id = company_id;
}
public String getInvoice_title() {
return invoice_title;
}
public void setInvoice_title(String invoice_title) {
this.invoice_title = invoice_title;
}
public String getTax_registration_number() {
return tax_registration_number;
}
public void setTax_registration_number(String tax_registration_number) {
this.tax_registration_number = tax_registration_number;
}
public String getRegistered_address() {
return registered_address;
}
public void setRegistered_address(String registered_address) {
this.registered_address = registered_address;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getDeposit_bank() {
return deposit_bank;
}
public void setDeposit_bank(String deposit_bank) {
this.deposit_bank = deposit_bank;
}
public String getBank_account() {
return bank_account;
}
public void setBank_account(String bank_account) {
this.bank_account = bank_account;
}
public String getSubcompanyid() {
return subcompanyid;
}
public void setSubcompanyid(String subcompanyid) {
this.subcompanyid = subcompanyid;
}
}

View File

@ -0,0 +1,68 @@
package weaver.seconddev.ey.zhangm.didi.entity;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/29/22
*/
public class DidiTitle {
private String id;
private String company_id;
private String invoice_title;
private String tax_registration_number;
private String subcompanyid;
@Override
public String toString() {
return "DidiTitle{" +
"pkid='" + id + '\'' +
", company_id='" + company_id + '\'' +
", invoice_title='" + invoice_title + '\'' +
", tax_registration_number='" + tax_registration_number + '\'' +
", subcompanyid='" + subcompanyid + '\'' +
'}';
}
public String getId() {
return id;
}
public void setPkid(String id) {
this.id = id;
}
public String getCompany_id() {
return company_id;
}
public void setCompany_id(String company_id) {
this.company_id = company_id;
}
public String getInvoice_title() {
return invoice_title;
}
public void setInvoice_title(String invoice_title) {
this.invoice_title = invoice_title;
}
public String getTax_registration_number() {
return tax_registration_number;
}
public void setTax_registration_number(String tax_registration_number) {
this.tax_registration_number = tax_registration_number;
}
public String getSubcompanyid() {
return subcompanyid;
}
public void setSubcompanyid(String subcompanyid) {
this.subcompanyid = subcompanyid;
}
}

View File

@ -0,0 +1,119 @@
package weaver.seconddev.ey.zhangm.didi.entity;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 10/24/22
*/
public class RequestLog {
private String qqsj;
private String url;
private String qqt;
private String qqcs;
private String xynr;
private String errno;
private String errmsg;
private String data;
private String httpstatus;
@Override
public String toString() {
return "RequestLog{" +
"qqsj='" + qqsj + '\'' +
", url='" + url + '\'' +
", qqt='" + qqt + '\'' +
", qqcs='" + qqcs + '\'' +
", xynr='" + xynr + '\'' +
", errno='" + errno + '\'' +
", errmsg='" + errmsg + '\'' +
", data='" + data + '\'' +
", httpstatus='" + httpstatus + '\'' +
'}';
}
public String getQqsj() {
return qqsj;
}
public RequestLog setQqsj(String qqsj) {
this.qqsj = qqsj;
return this;
}
public String getUrl() {
return url;
}
public RequestLog setUrl(String url) {
this.url = url;
return this;
}
public String getQqt() {
return qqt;
}
public RequestLog setQqt(String qqt) {
this.qqt = qqt;
return this;
}
public String getQqcs() {
return qqcs;
}
public RequestLog setQqcs(String qqcs) {
this.qqcs = qqcs;
return this;
}
public String getXynr() {
return xynr;
}
public RequestLog setXynr(String xynr) {
this.xynr = xynr;
return this;
}
public String getErrno() {
return errno;
}
public RequestLog setErrno(String errno) {
this.errno = errno;
return this;
}
public String getErrmsg() {
return errmsg;
}
public RequestLog setErrmsg(String errmsg) {
this.errmsg = errmsg;
return this;
}
public String getData() {
return data;
}
public RequestLog setData(String data) {
this.data = data;
return this;
}
public String getHttpstatus() {
return httpstatus;
}
public RequestLog setHttpstatus(String httpstatus) {
this.httpstatus = httpstatus;
return this;
}
}

View File

@ -0,0 +1,111 @@
package weaver.seconddev.ey.zhangm.didi.entity;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 10/24/22
*/
public class Result {
private int code;
private String content;
private String errmsg;
private Object data;
public boolean isOk() {
return this.code == 0;
}
public static Result create(int code, String content, String errmsg, Object data) {
return new Result()
.setCode(code)
.setContent(content)
.setErrmsg(errmsg)
.setData(data);
}
public static Result create(int code, String content, String errmsg) {
return Result.create(code, content, errmsg, null);
}
public static Result create(int code, String errmsg) {
return Result.create(code, null, errmsg, null);
}
public static Result success() {
return Result.success(null);
}
public static Result success(String content) {
return Result.success(content, null);
}
public static Result success(String content, Object data) {
return Result.create(0, content, null, data);
}
public static Result fail(String content, String errmsg, Object data) {
return Result.create(-1, content, errmsg, data);
}
public static Result fail(String content) {
return Result.create(-1, content, null, null);
}
public Result() { }
@Override
public String toString() {
return "Result{" +
"code=" + code +
", content='" + content + '\'' +
", errmsg='" + errmsg + '\'' +
", data=" + data +
'}';
}
public Result(int code, String content, String errmsg, Object data) {
this.code = code;
this.content = content;
this.errmsg = errmsg;
this.data = data;
}
public int getCode() {
return code;
}
public Result setCode(int code) {
this.code = code;
return this;
}
public String getContent() {
return content;
}
public Result setContent(String content) {
this.content = content;
return this;
}
public String getErrmsg() {
return errmsg;
}
public Result setErrmsg(String errmsg) {
this.errmsg = errmsg;
return this;
}
public Object getData() {
return data;
}
public Result setData(Object data) {
this.data = data;
return this;
}
}

View File

@ -0,0 +1,80 @@
package weaver.seconddev.ey.zhangm.didi.util;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/2/22
*/
public class BUtils {
public static List<Object> beanToAttrListWithSq(Object object, List<String> fields) throws Exception {
List<Object> objectList = Lists.newArrayList();
// for (Field declaredField : object.getClass().getDeclaredFields()) {
// System.out.println(declaredField.getName());
// }
for (String fieldStr : fields) {
Field field = object.getClass().getDeclaredField(fieldStr);
field.setAccessible(true);
objectList.add(field.get(object));
}
return objectList;
}
public static List<Object> beanToAttrListWithSq(Object object, List<String> fields,String apipkfield) throws Exception {
List<Object> objectList = Lists.newArrayList();
// for (Field declaredField : object.getClass().getDeclaredFields()) {
// System.out.println(declaredField.getName());
// }
for (String fieldStr : fields) {
Field field = object.getClass().getDeclaredField(fieldStr);
field.setAccessible(true);
objectList.add(field.get(object));
}
//????????????
if(!apipkfield.equals("")){
Field field = object.getClass().getDeclaredField(apipkfield);
field.setAccessible(true);
objectList.add(field.get(object));
}
return objectList;
}
public static Map<String, Object> beanToAttrMap(Object object) throws IllegalAccessException {
Field[] fields = object.getClass().getDeclaredFields();
Map<String, Object> res = Maps.newHashMap();
for (Field field : fields) {
field.setAccessible(true);
res.put(field.getName(), field.get(object));
}
return res;
}
public static List<String> beanAttrNameList(Class clazz) {
return Arrays.stream(clazz.getDeclaredFields()).map(Field::getName).collect(Collectors.toList());
}
public static Map<String, String> beanToAttrMapNoNull(Object object) throws IllegalAccessException {
Field[] fields = object.getClass().getDeclaredFields();
Map<String, String> res = Maps.newHashMap();
for (Field field : fields) {
field.setAccessible(true);
if (Objects.isNull(field.get(object))) {
continue;
}
res.put(field.getName(), StringUtils.val(field.get(object)));
}
return res;
}
}

View File

@ -0,0 +1,514 @@
package weaver.seconddev.ey.zhangm.didi.util;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import weaver.conn.BatchRecordSet;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.seconddev.ey.zhangm.didi.annotation.DaoField;
import java.lang.reflect.Field;
import java.util.*;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/2/22
*/
public class DaoUtils {
private static BaseBean baseBean = new BaseBean();
/**
*
*
* @return dbType
*/
public static String dbType() {
RecordSet recordSet = new RecordSet();
return recordSet.getDBType();
}
/**
* map
*
* @param tableName
* @param params
*/
public static void insert(String tableName, Map<String, Object> params) {
if (StringUtils.isEmpty(tableName)) {
baseBean.writeLog("执行插入语句 => 表名为空");
return;
}
if (Objects.isNull(params) || params.isEmpty()) {
baseBean.writeLog("执行插入语句 => map为空");
return;
}
List<String> paramList = Lists.newArrayList();
List<Object> valueList = Lists.newArrayList();
params.forEach((key, value) -> {
paramList.add(key);
valueList.add(value);
});
executeUpdate(createInsertSql(tableName, paramList), valueList);
}
public static void insert(String tableName, List<String> params, List<Object> data) {
if (StringUtils.isEmpty(tableName)) {
baseBean.writeLog("执行插入语句 => 表名为空");
return;
}
if (Objects.isNull(params) || params.isEmpty() || Objects.isNull(data) || data.isEmpty()) {
baseBean.writeLog("执行插入语句 => 字段集合为空或数据集合为空");
return;
}
executeUpdate(createInsertSql(tableName, params), data);
}
public static void batchInsert(String tableName, List<String> params, List<List<Object>> data) {
if (StringUtils.isEmpty(tableName)) {
baseBean.writeLog("批量执行插入语句 => 表名为空");
return;
}
if (Objects.isNull(params) || params.isEmpty() || Objects.isNull(data) || data.isEmpty()) {
baseBean.writeLog("批量执行插入语句 => 字段集合为空或数据集合为空");
return;
}
batchExecute(createInsertSql(tableName, params), data);
}
public static String createInsertSql(String tableName, List<String> params) {
StringBuilder sql = new StringBuilder(String.format("insert into %s (", tableName));
StringBuilder addParam = new StringBuilder(" values (");
int i = 0;
List<Object> paramList = Lists.newArrayList();
for (String param : params) {
if (i++ == 0) {
sql.append(" " + param);
addParam.append(" ?");
} else {
sql.append(", " + param);
addParam.append(", ?");
}
}
return sql.toString() + ")" + addParam.toString() + ")";
}
/**
* RecordSetJavaBean
*
* @param recordSet
* @param clazz
* @param <T>
* @return
*/
public static <T> T recordSetMapToBean(RecordSet recordSet, Class<T> clazz) {
try {
T t = clazz.newInstance();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
// 获取是否有注解
DaoField daoField = field.getAnnotation(DaoField.class);
if (Objects.nonNull(daoField)) {
if (!daoField.value()) { // 为false
continue;
}
}
field.setAccessible(true);
String fieldName = field.getName();
String value = recordSet.getString(fieldName);
field.set(t, value);
}
return t;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
public static <T> T recordSetMapToBean(RecordSet recordSet, Class<T> clazz, Map<String, String> fieldMap) {
try {
T t = clazz.newInstance();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
String fieldName = field.getName();
String value = recordSet.getString(fieldMap.get(fieldName));
field.setAccessible(true);
field.set(t, value);
}
return t;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
/**
*
*
* @param tableName
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> queryTableToBean(String tableName, Class<T> clazz) {
RecordSet recordSet = new RecordSet();
String sql = String.format("select * from %s", tableName);
List<T> tList = Lists.newArrayList();
baseBean.writeLog("执行SQL => " + sql);
recordSet.executeQuery(sql);
while (recordSet.next())
tList.add(recordSetMapToBean(recordSet, clazz));
return tList;
}
public static <T> List<T> querySqlToBean(String sql, Class<T> clazz, Map<String, String> fields) {
RecordSet recordSet = new RecordSet();
List<T> tList = Lists.newArrayList();
baseBean.writeLog("执行SQL => " + sql);
recordSet.executeQuery(sql);
while (recordSet.next())
tList.add(recordSetMapToBean(recordSet, clazz));
return tList;
}
public static <T> List<T> queryTableToBean(String tableName, Class<T> clazz, Map<String, String> fields) {
// BiMap<String, String> biMap = HashBiMap.create(fields);
// biMap.inverse();
RecordSet recordSet = new RecordSet();
String sql = String.format("select * from %s", tableName);
List<T> tList = Lists.newArrayList();
baseBean.writeLog("执行SQL => " + sql);
recordSet.executeQuery(sql);
while (recordSet.next())
tList.add(recordSetMapToBean(recordSet, clazz, fields));
return tList;
}
public static <T> T queryTableToSingleBean(String tableName, Class<T> clazz, Map<String, String> fields) {
RecordSet recordSet = new RecordSet();
String sql = String.format("select * from %s", tableName);
baseBean.writeLog("执行SQL => " + sql);
recordSet.executeQuery(sql);
if (recordSet.next())
return recordSetMapToBean(recordSet, clazz, fields);
return null;
}
public static <T> T queryTableToSingleBean(String tableName, Class<T> clazz) {
RecordSet recordSet = new RecordSet();
String sql = String.format("select * from %s", tableName);
baseBean.writeLog("执行SQL => " + sql);
recordSet.executeQuery(sql);
if (recordSet.next())
return recordSetMapToBean(recordSet, clazz);
return null;
}
public static String querySingleVal(String sql, Object... objs) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
recordSet.executeQuery(sql, objs);
if (recordSet.next()) {
return recordSet.getString(1);
}
return null;
}
/**
*
*
* @param clazz clazz
* @param tableName tableName
* @param list list
* @throws Exception Exception
*/
public static void saveList(Class clazz, String tableName, List<?> list) throws Exception {
List<String> fields = BUtils.beanAttrNameList(clazz);
StringBuilder stringBuffer = new StringBuilder(String.format("insert into %s (", tableName));
StringBuilder temp = new StringBuilder();
for (int i = 0; i < fields.size(); i++) {
if (i == 0) {
stringBuffer.append(fields.get(i));
temp.append("?");
} else {
stringBuffer.append(", " + fields.get(i));
temp.append(", ?");
}
}
List<List<Object>> params = Lists.newArrayList();
for (Object obj : list) {
params.add(BUtils.beanToAttrListWithSq(obj, fields));
}
stringBuffer.append(") values (" + temp.toString() + ")");
baseBean.writeLog("执行SQL => " + stringBuffer.toString());
batchExecute(stringBuffer.toString(), params);
}
/**
*
*
* @param fields clazz
* @param tableName tableName
* @param list list
* @throws Exception Exception
*/
public static void saveList(Map<String, String> fields, String tableName, List<?> list) throws Exception {
StringBuffer stringBuffer = new StringBuffer(String.format("insert into %s (", tableName));
List<String> keyList = Lists.newArrayList(fields.keySet());
List<String> valueList = Lists.newArrayList();
StringBuffer temp = new StringBuffer();
for (int i = 0; i < keyList.size(); i++) {
String value = fields.get(keyList.get(i));
valueList.add(value);
if (i == 0) {
stringBuffer.append(value);
temp.append("?");
} else {
stringBuffer.append(", " + value);
temp.append(", ?");
}
}
List<List<Object>> params = Lists.newArrayList();
for (Object obj : list) {
params.add(BUtils.beanToAttrListWithSq(obj, keyList));
}
stringBuffer.append(") values (" + temp.toString() + ")");
baseBean.writeLog("执行SQL => " + stringBuffer.toString());
batchExecute(stringBuffer.toString(), params);
}
/**
* SQL
*
* @param clazz
* @param sql
* @param objs
* @param <T>
* @return
*/
public static <T> List<T> querySqlToBean(String sql, Class<T> clazz, Object... objs) {
RecordSet recordSet = new RecordSet();
List<T> tList = Lists.newArrayList();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
recordSet.executeQuery(sql, objs);
while (recordSet.next())
tList.add(recordSetMapToBean(recordSet, clazz));
return tList;
}
public static <T> T findSqlToBean(Class<T> clazz, String sql, Object... objs) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
recordSet.executeQuery(sql, objs);
if (recordSet.next())
return recordSetMapToBean(recordSet, clazz);
return null;
}
public static RecordSet executeQuery(String sql, Object... objs) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
if (recordSet.executeQuery(sql, objs))
return recordSet;
return null;
}
public static List<Map<String, String>> executeQueryToMapList(String sql, Object... objs) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
List<Map<String, String>> res = Lists.newArrayList();
if (recordSet.executeQuery(sql, objs)) {
while (recordSet.next()) {
res.add(recordSetToMap(recordSet));
}
}
return res;
}
public static List<Map<String, String>> executeQueryToMapListPage(String primaryKey, String table, String criteria, List<String> fields, int start, int limit, Object... objs) {
RecordSet recordSet = new RecordSet();
String dbType = recordSet.getDBType().toUpperCase();
// 判断数据库类型
baseBean.writeLog("dbType ===> " + dbType);
String sql = "";
String fieldStr = Joiner.on(",").skipNulls().join(fields.toArray());
// 判断当前数据库类型
if (dbType.contains("MYSQL")) { // MySQL
sql = String.format("select %s from %s %s limit %s, %s", fieldStr, table, criteria, start, limit);
} else { // 默认 SQL SERVER
sql = String.format(
"select top (%s) * from ( " +
"select row_number() over(order by %s.%s) as rownumber, %s from %s %s" +
") temp_row where rownumber > %s"
, limit, table, primaryKey, fieldStr, table, criteria, start);
}
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
List<Map<String, String>> res = Lists.newArrayList();
if (recordSet.executeQuery(sql, objs)) {
while (recordSet.next()) {
res.add(recordSetToMap(recordSet));
}
}
return res;
}
/**
* List<Map<String><String>>
*/
public static List<Map<String, String>> executeQueryToMapListPage(String table, String criteria, List<String> fields, int start, int limit, Object... objs) {
return executeQueryToMapListPage("id", table, criteria, fields, start, limit, objs);
}
public static Map<String, String> executeQueryToMap(String sql, Object... objs) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
if (recordSet.executeQuery(sql, objs)) {
if (recordSet.next()) {
return recordSetToMap(recordSet);
}
}
return null;
}
private static Map<String, String> recordSetToMap(RecordSet recordSet) {
Map<String, String> map = Maps.newHashMap();
for (String s : recordSet.getColumnName()) {
map.put(s, recordSet.getString(s));
}
return map;
}
public static void executeUpdate(String sql, List<Object> param) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(param.toArray()));
recordSet.executeUpdate(sql, param.toArray(new Object[]{}));
}
public static void executeUpdate(String sql, Object... objs) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
baseBean.writeLog("SQL参数 => " + Arrays.toString(objs));
recordSet.executeUpdate(sql, objs);
}
public static void execute(String sql, List<Object> param) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("解析前SQL => " + sql);
sql = toSingleSql(sql, param);
baseBean.writeLog("执行SQL => " + sql);
recordSet.execute(sql);
}
public static void batchExecute(String sql, List<List<Object>> param) {
BatchRecordSet batchRecordSet = new BatchRecordSet();
baseBean.writeLog("执行SQL => " + sql);
batchRecordSet.executeBatchSql(sql, param);
}
private static String toSingleSql(String sql, List<Object> param) {
int pos = 0;
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < sql.length(); i++) {
if (sql.charAt(i) == '?') {
stringBuffer.append(String.format("'%s'", param.get(pos++)));
} else {
stringBuffer.append(sql.charAt(i));
}
}
return stringBuffer.toString();
}
public static void saveBean(String tableName, Object obj) throws IllegalAccessException {
Map<String, Object> param = BUtils.beanToAttrMap(obj);
StringBuilder sqlStr = new StringBuilder(String.format("insert into %s (", tableName));
StringBuilder temp = new StringBuilder(" values (");
List<Object> objects = Lists.newArrayList();
int i = 0;
for (Map.Entry<String, Object> entry : param.entrySet()) {
if (i++ == 0) {
sqlStr.append(entry.getKey());
temp.append("?");
} else {
sqlStr.append(", " + entry.getKey());
temp.append(", ?");
}
objects.add(entry.getValue());
}
String sql = sqlStr.toString() + " )" + temp.toString() + " )";
executeUpdate(sql, objects);
}
public static void saveBean(String tableName, Object obj, Map<String, String> fields) throws Exception {
// Map<String, Object> param = BUtils.beanToAttrMap(obj);
StringBuffer sqlStr = new StringBuffer(String.format("insert into %s (", tableName));
StringBuffer temp = new StringBuffer(" values (");
int i = 0;
List<String> keys = Lists.newArrayList();
for (Map.Entry<String, String> entry : fields.entrySet()) {
if (i++ == 0) {
sqlStr.append(entry.getValue());
temp.append("?");
} else {
sqlStr.append(", " + entry.getValue());
temp.append(", ?");
}
keys.add(entry.getKey());
}
List<Object> objects = BUtils.beanToAttrListWithSq(obj, keys);
String sql = sqlStr.toString() + " )" + temp.toString() + " )";
executeUpdate(sql, objects);
}
public static String analyzeInsertSql(String tableName, Map<String, String> param) {
StringBuffer sql = new StringBuffer(String.format("insert into %s (", tableName));
StringBuffer temp = new StringBuffer(" ) values (");
int i = 0;
for (Map.Entry<String, String> entry : param.entrySet()) {
if (i++ == 0) {
sql.append(entry.getValue());
temp.append("?");
} else {
sql.append(", " + entry.getValue());
temp.append(", ?");
}
}
return sql.toString() + temp.toString() + ")";
}
public static List<List<Object>> analyzeObjList(List<?> list, List<String> fields) throws Exception {
List<List<Object>> params = Lists.newArrayList();
for (Object obj : list) {
params.add(BUtils.beanToAttrListWithSq(obj, fields));
}
return params;
}
public static List<List<Object>> analyzeObjList(List<?> list, Map<String, String> fields) throws Exception {
return analyzeObjList(list, new ArrayList<>(fields.keySet()));
}
public static <T> T querySqlToSingleBean(String sql, Class<T> clazz, Map<String, String> fields, Object... objs) {
RecordSet recordSet = new RecordSet();
baseBean.writeLog("执行SQL => " + sql);
recordSet.executeQuery(sql, objs);
if (recordSet.next())
return recordSetMapToBean(recordSet, clazz, fields);
return null;
}
}

View File

@ -0,0 +1,354 @@
package weaver.seconddev.ey.zhangm.didi.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 11/2/22
*/
public class DateUtils {
private static final long ONE_MINUTE = 60000L;
private static final long ONE_HOUR = 3600000L;
private static final long ONE_DAY = 86400000L;
private static final long ONE_WEEK = 604800000L;
private static final String ONE_SECOND_AGO = "秒前";
private static final String ONE_MINUTE_AGO = "分钟前";
private static final String ONE_HOUR_AGO = "小时前";
private static final String ONE_DAY_AGO = "天前";
private static final String ONE_MONTH_AGO = "月前";
private static final String ONE_YEAR_AGO = "年前";
public static String relative(Date date) {
return relative(date, ONE_DAY * 3, "yyyy-MM-dd HH:mm:ss");
}
public static String relative(Date date, long maxOffset) {
return relative(date, maxOffset, "yyyy-MM-dd HH:mm:ss");
}
public static String relative(Date date, String partten) {
return relative(date, ONE_DAY * 3, partten);
}
/**
* 19
*
* @param date
* @param maxOffset
* @param partten
* @return
*/
public static String relative(Date date, long maxOffset, String partten) {
long delta = new Date().getTime() - date.getTime();
if (delta > maxOffset) {
return DateUtils.date(date, partten);
}
if (delta < 1L * ONE_MINUTE) {
long seconds = toSeconds(delta);
return (seconds <= 0 ? 1 : seconds) + ONE_SECOND_AGO;
}
if (delta < 45L * ONE_MINUTE) {
long minutes = toMinutes(delta);
return (minutes <= 0 ? 1 : minutes) + ONE_MINUTE_AGO;
}
if (delta < 24L * ONE_HOUR) {
long hours = toHours(delta);
return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO;
}
if (delta < 48L * ONE_HOUR) {
return "昨天";
}
if (delta < 30L * ONE_DAY) {
long days = toDays(delta);
return (days <= 0 ? 1 : days) == 2 ? "前天" : (days <= 0 ? 1 : days) + ONE_DAY_AGO;
}
if (delta < 12L * 4L * ONE_WEEK) {
long months = toYears(delta);
return (months <= 0 ? 1 : months) + ONE_MONTH_AGO;
} else {
long years = delta / 365L;
return (years <= 0 ? 1 : years) + ONE_YEAR_AGO;
}
}
private static long toSeconds(long date) {
return date / 1000L;
}
private static long toMinutes(long date) {
return toSeconds(date) / 60L;
}
private static long toHours(long date) {
return toMinutes(date) / 60L;
}
private static long toDays(long date) {
return toHours(date) / 24L;
}
private static long toMonths(long date) {
return toDays(date) / 30L;
}
private static long toYears(long date) {
return toMonths(date) / 365L;
}
public static String min(String date1, String date2) {
try {
if (StringUtils.isEmpty(date1)) return date2;
if (StringUtils.isEmpty(date2)) return date1;
long time1 = parse(date1).getTime();
long time2 = parse(date2).getTime();
return time1 < time2 ? date1 : date2;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
public static String max(String date1, String date2) {
try {
if (StringUtils.isEmpty(date1)) return date2;
if (StringUtils.isEmpty(date2)) return date1;
long time1 = parse(date1).getTime();
long time2 = parse(date2).getTime();
return time1 > time2 ? date1 : date2;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
public static boolean checkBetween(String datetime, String date1, String date2) {
try {
long time1 = parse(date1).getTime();
long time2 = parse(date2).getTime();
long check = parse(datetime, "yyyy-MM-dd HH:mm:ss").getTime();
return check >= time1 && check <= time2;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
public static Date now() {
return new Date();
}
public static Date parse(String date) throws ParseException {
return parse(date, "yyyy-MM-dd");
}
public static Date parse(String date, String pattern) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
return dateFormat.parse(date);
}
/**
*
*
* @param date
* @param partten
* @return
*/
public static String date(Date date, String partten) {
SimpleDateFormat dateFormat = new SimpleDateFormat(partten);
return dateFormat.format(date);
}
public static Date getDate(Date date, String pattern) throws ParseException {
return new SimpleDateFormat(pattern).parse(date(date, pattern));
}
public static Date getDate(Date date) throws ParseException {
return new SimpleDateFormat("yyyy-MM-dd").parse(date(date, "yyyy-MM-dd"));
}
public static Date getDate() throws ParseException {
return new SimpleDateFormat("yyyy-MM-dd").parse(date(new Date(), "yyyy-MM-dd"));
}
public static Date getDate(String pattern) throws ParseException {
return new SimpleDateFormat(pattern).parse(date(new Date(), pattern));
}
/**
*
*
* @param pattern
* @return
*/
public static String date(String pattern) {
return date(new Date(), pattern);
}
/**
* yyyy-MM-dd
*
* @param date
* @return yyyy-MM-dd
*/
public static String date(Date date) {
return date(date, "yyyy-MM-dd");
}
/**
* yyyy-MM-dd
*
* @return yyyy-MM-dd
*/
public static String date() {
return date("yyyy-MM-dd");
}
/**
*
*
* @param date
* @param offset ()
* @return (yyyy-MM-dd)
*/
public static String date(Date date, int offset) {
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.DATE, offset);
return date(calendar.getTime());
}
public static String offset(int offset) {
return date(new Date(), offset);
}
/**
*
*
* @param offset ()
* @return (yyyy-MM-dd)
*/
public static String date(int offset) {
return date(new Date(), offset);
}
/**
* yyyy-MM-dd HH:mm:ss
*
* @return yyyy-MM-dd HH:mm:ss
*/
public static String datetime() {
return date("yyyy-MM-dd HH:mm:ss");
}
/**
* HH:mm:ss
*
* @return HH:mm:ss
*/
public static String time() {
return date("HH:mm:ss");
}
/**
*
*
* @param date
* @param offset
* @return
*/
public static Date dayStart(Date date, int offset) {
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.DATE, offset);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
*
*
* @return
*/
public static Date dayStart() {
return dayStart(new Date(), 0);
}
/**
*
*
* @param offset
* @return
*/
public static Date dayStart(int offset) {
return dayStart(new Date(), offset);
}
/**
*
*
* @param date
* @param offset
* @return
*/
public static Date dayEnd(Date date, int offset) {
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.DATE, offset);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTime();
}
/**
*
*
* @return
*/
public static Date dayEnd() {
return dayEnd(new Date(), 0);
}
/**
*
*
* @param offset
* @return
*/
public static Date dayEnd(int offset) {
return dayEnd(new Date(), offset);
}
/**
*
*
* @return
*/
public static String timestamp() {
return String.valueOf(System.currentTimeMillis());
}
public static boolean equals(Date date1, Date date2) {
if (date1 == null && date2 != null)
return false;
if (date1 == date2)
return true;
if (date1.equals(date2))
return true;
return date1.getTime() == date2.getTime();
}
}

View File

@ -0,0 +1,291 @@
package weaver.seconddev.ey.zhangm.didi.util;
/**
* @Description
* @Author miao.zhang <yyem954135@163.com>
* @Version V1.0.0
* @Since 1.0
* @Date 10/24/22
*/
public class StringUtils {
// 为了兼容apache StringUtils
public static String replace(String text, String repl, String with) {
return replace(text, repl, with, -1);
}
public static String replace(String text, String repl, String with, int max) {
if (!isEmpty(text) && !isEmpty(repl) && with != null && max != 0) {
int start = 0;
int end = text.indexOf(repl, start);
if (end == -1) {
return text;
} else {
int replLength = repl.length();
int increase = with.length() - replLength;
increase = Math.max(increase, 0);
increase *= max < 0 ? 16 : (Math.min(max, 64));
StringBuffer buf;
for (buf = new StringBuffer(text.length() + increase); end != -1; end = text.indexOf(repl, start)) {
buf.append(text.substring(start, end)).append(with);
start = end + replLength;
--max;
if (max == 0) {
break;
}
}
buf.append(text.substring(start));
return buf.toString();
}
} else {
return text;
}
}
/**
*
*
* @param text
* @param maxLength
* @return
*/
public static String subStringByChar(String text, Integer maxLength) {
if (StringUtils.isBlank(text)) {
return text;
}
//名称最多展示14个字符一个汉字算两个字符超过展示...
StringBuilder sBuilder = new StringBuilder();
char[] chars = text.toCharArray();
int length = 0;
for (char ch : chars) {
boolean chineseChar = isChineseChar(ch) || isSymbol(ch);
length = length + (chineseChar ? 2 : 1);
if (length > maxLength) {
break;
}
sBuilder.append(ch);
}
String testResult = sBuilder.toString();
if (length > maxLength) {
testResult = testResult;
}
return testResult;
}
/**
*
*
* @param ch
* @return
*/
public static boolean isSymbol(char ch) {
if (isCnSymbol(ch)) return true;
if (isEnSymbol(ch)) return true;
if (0x2010 <= ch && ch <= 0x2017) return true;
if (0x2020 <= ch && ch <= 0x2027) return true;
if (0x2B00 <= ch && ch <= 0x2BFF) return true;
if (0xFF03 <= ch && ch <= 0xFF06) return true;
if (0xFF08 <= ch && ch <= 0xFF0B) return true;
if (ch == 0xFF0D || ch == 0xFF0F) return true;
if (0xFF1C <= ch && ch <= 0xFF1E) return true;
if (ch == 0xFF20 || ch == 0xFF65) return true;
if (0xFF3B <= ch && ch <= 0xFF40) return true;
if (0xFF5B <= ch && ch <= 0xFF60) return true;
if (ch == 0xFF62 || ch == 0xFF63) return true;
if (ch == 0x0020 || ch == 0x3000) return true;
return false;
}
public static boolean isCnSymbol(char ch) {
if (0x3004 <= ch && ch <= 0x301C) return true;
if (0x3020 <= ch && ch <= 0x303F) return true;
return false;
}
public static boolean isEnSymbol(char ch) {
if (ch == 0x40) return true;
if (ch == 0x2D || ch == 0x2F) return true;
if (0x23 <= ch && ch <= 0x26) return true;
if (0x28 <= ch && ch <= 0x2B) return true;
if (0x3C <= ch && ch <= 0x3E) return true;
if (0x5B <= ch && ch <= 0x60) return true;
if (0x7B <= ch && ch <= 0x7E) return true;
return false;
}
/**
*
*
* @param c
* @return
*/
public static boolean isChineseChar(char c) {
return String.valueOf(c).matches("[\u4e00-\u9fa5]");
}
public static boolean isBlank(String str) {
int strLen;
if (str != null && (strLen = str.length()) != 0) {
for (int i = 0; i < strLen; ++i) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
} else {
return true;
}
}
/**
* Unicode
*
* @param str
* @return
*/
public static String chinaToUnicode(String str) {
String result = "";
for (int i = 0; i < str.length(); i++) {
int chr1 = (char) str.charAt(i);
if (chr1 >= 19968 && chr1 <= 171941) {// 汉字范围 \u4e00-\u9fa5 (中文)
result += "\\u" + Integer.toHexString(chr1);
} else {
result += str.charAt(i);
}
}
return result;
}
public static String val(Object obj, String txt) {
if (obj == null)
return txt;
return obj.toString();
}
public static String valNotEmpty(Object obj, String txt) {
String val = val(obj);
return isEmpty(val) ? txt : val;
}
public static String val(Object obj) {
return val(obj, null);
}
/**
*
*
* @param str
* @param len
* @return
*/
public static String tailSubstring(String str, int len) {
if (len <= 0) return str;
if (str.length() < len) throw new RuntimeException("截取长度大于字符串本身");
return str.substring(str.length() - len);
}
public static String tailChar(String str) {
return tailSubstring(str, 1);
}
public static String headChar(String str) {
return str.substring(0, 1);
}
/**
*
*
* @param str
* @return
*/
public static boolean isEmpty(String str) {
if (str == null || str.length() == 0) return true;
return false;
}
public static boolean isNotEmpty(String str) {
return !isEmpty(str);
}
/**
*
*
* @param str1
* @param str2
* @return
*/
public static boolean equals(String str1, String str2) {
if (str1 == null && str2 == null) return true;
if (str1 == null || str2 == null) return false;
else return str1.equals(str2);
}
/**
*
*
* @param str1
* @param str2
* @return
*/
public static boolean equalsIgnoreCase(String str1, String str2) {
if (str1 == null && str2 == null) return true;
if (str1 == null || str2 == null) return false;
else return str1.equalsIgnoreCase(str2);
}
/**
* Object 使toString
*
* @param obj
* @param str
* @return
*/
public static boolean equals(Object obj, String str) {
if (obj == null) return equals(null, str);
return equals(obj.toString(), str);
}
public static boolean equals(Object obj1, Object obj2) {
if ((obj1 == null && obj2 != null) || (obj1 != null && obj2 == null)) {
return false;
}
if (obj1 == null || obj1.equals(obj2)) {
return true;
}
return equals(obj1.toString(), obj2.toString());
}
/**
* Object 使toString
*
* @param obj
* @param str
* @return
*/
public static boolean equalsIgnoreCase(Object obj, String str) {
if (obj == null) return equals(null, str);
return equalsIgnoreCase(obj.toString(), str);
}
@FunctionalInterface
public interface ComputeFn {
String fn();
}
public static String compute(ComputeFn computeFn) {
return computeFn.fn();
}
}

View File

@ -0,0 +1,721 @@
package weaver.seconddev.ey.zhangm.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wbi.util.StringUtil;
import com.weaver.esb.client.EsbClient;
import com.weaver.esb.spi.EsbService;
import okhttp3.*;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;
import weaver.seconddev.ey.zhangm.didi.entity.Result;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
public class EYSeconddevUtil extends BaseBean {
/**
* EMEP rank
* @param gpn
* @param mark 0 1
* @param role 0 EP1 EM
* @return
*/
public boolean validateEngagementRoleRank(String gpn,String mark,String role){
RecordSet rs=new RecordSet();
rs.executeQuery("select id from hrmresource where workcode=?",gpn);
String userId="";
if(rs.next()){
userId=Util.null2String(rs.getString(1));
}
// 查询rank
String rank="";
rs.executeQuery("select concat(field2,field24) from cus_fielddata scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=?",userId);
if(rs.next()){
rank=Util.null2String(rs.getString(1));
}
// 校验rank
rs.executeQuery("select id from uf_xmjsrankjyb where rankcode=? and mark=? and role=?",rank,mark,role);
return rs.getCounts()>0;
}
public String getSystemParamValue(String ssid){
String paramvalue ="";
if(!"".equals(ssid)){
String select_sql="select paramvalue from uf_dd_prmt where ssid ='"+ssid+"'";
RecordSet rs =new RecordSet();
rs.executeSql(select_sql);
if(rs.next()){
paramvalue = Util.null2String(rs.getString("paramvalue"));
}
}
return paramvalue;
}
public Map<String,String> getSystemParamValues(String ssids){
HashMap<String,String> paramvalues=new HashMap<String, String>();
String ssidsstr="";
if(!"".equals(ssids)){
String [] ssidsArray = ssids.split(",");
for (String s:ssidsArray){
if(!"".equals(s)) {
ssidsstr = ssidsstr + "'" + s + "',";
}
}
if(!"".equals(ssidsstr)) {
ssidsstr = ssidsstr.substring(0, ssidsstr.length() - 1);
String select_sql="select ssid,paramvalue from uf_dd_prmt where ssid in("+ssidsstr+")";
RecordSet rs =new RecordSet();
rs.executeSql(select_sql);
while (rs.next()){
paramvalues.put(rs.getString("ssid"),rs.getString("paramvalue"));
}
}
}
return paramvalues;
}
public String getUserAllRole(Integer userid){
String returnStr = "";
RecordSet rs = new RecordSet();
rs.executeSql("select roleid from hrmrolemembers where resourceid=" + userid);
while (rs.next()) {
returnStr = returnStr + Util.null2String(rs.getString("roleid")) + ",";
}
if (!"".equals(returnStr)) {
returnStr = returnStr.substring(0, returnStr.length() - 1);
}
if ("".equals(returnStr)) {
returnStr = "0";
}
return returnStr;
}
public String getMD5Str(String plainText){
//定义一个字节数组
byte[] secretBytes = null;
try {
// 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5");
//对字符串进行加密
md.update(plainText.getBytes());
//获得加密后的数据
secretBytes = md.digest();
} catch (NoSuchAlgorithmException e) {
//throw new RuntimeException("没有md5这个算法");
//throw new RuntimeException(SystemEnv.getHtmlLabelName(517545,userLanguage));
}
//将加密后的数据转换为16进制数字
String md5code = new BigInteger(1, secretBytes).toString(16);
// 如果生成数字未满32位需要前面补0
// 不能把变量放到循环条件值改变之后会导致条件变化。如果生成30位 只能生成31位md5
int tempIndex = 32 - md5code.length();
for (int i = 0; i < tempIndex; i++) {
md5code = "0" + md5code;
}
return md5code;
}
public static String getCurrentTime() {
Date newdate = new Date();
long datetime = newdate.getTime();
Timestamp timestamp = new Timestamp(datetime);
String currenttime = (timestamp.toString()).substring(11, 13) + ":" + (timestamp.toString()).substring(14, 16) + ":"
+ (timestamp.toString()).substring(17, 19);
return currenttime;
}
public static String getCurrentDate() {
Date newdate = new Date();
long datetime = newdate.getTime();
Timestamp timestamp = new Timestamp(datetime);
String currentdate = (timestamp.toString()).substring(0, 4) + "-" + (timestamp.toString()).substring(5, 7) + "-"
+ (timestamp.toString()).substring(8, 10);
return currentdate;
}
/**
* YYYY-MM-DD HH:MM:SS
* @return
*/
public static String getCurDateTime() {
Date newdate = new Date();
long datetime = newdate.getTime();
Timestamp timestamp = new Timestamp(datetime);
return (timestamp.toString()).substring(0, 19);
}
/**
* 19990101235959
* @return
*/
public static String getTimestamp(){
return getCurDateTime().replace("-", "").replace(":", "").replace(" ", "");
}
public static String doAction(Map<String,Object> paramDatajson,String url,String method){
String resultstr="";
try{
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
new BaseBean().writeLog("json==>"+ JSON.toJSONString(paramDatajson));
RequestBody body = RequestBody.create(mediaType, "datajson="+ JSON.toJSONString(paramDatajson));
Request request = new Request.Builder()
.url(url)
.method(method, body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
Response result = client.newCall(request).execute();
resultstr = result.body().string();
}catch (Exception e){
new BaseBean().writeLog("请求失败"+getCurrentDate()+" "+getCurrentDate()+"====errormsg:"+e.getMessage());
}
return resultstr;
}
/**
*
*
* @param beginTime
* @param endTime
* @return
* @throws Exception
*/
public static List <String> findEveryDay(String beginTime, String endTime)
throws Exception {
//创建一个放所有日期的集合
List<String> dates = new ArrayList();
//创建时间解析对象规定解析格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//将传入的时间解析成Date类型,相当于格式化
Date dBegin = sdf.parse(beginTime);
Date dEnd = sdf.parse(endTime);
//将格式化后的第一天添加进集合
dates.add(sdf.format(dBegin));
//使用本地的时区和区域获取日历
Calendar calBegin = Calendar.getInstance();
//传入起始时间将此日历设置为起始日历
calBegin.setTime(dBegin);
//判断结束日期前一天是否在起始日历的日期之后
while (dEnd.after(calBegin.getTime())) {
//根据日历的规则:月份中的每一天,为起始日历加一天
calBegin.add(Calendar.DAY_OF_MONTH, 1);
//得到的每一天就添加进集合
dates.add(sdf.format(calBegin.getTime()));
//如果当前的起始日历超过结束日期后,就结束循环
}
return dates;
}
public String createHrToken() throws Exception{
String accessToken="";
OkHttpClient client = new OkHttpClient().newBuilder().build();
String clientId =getSystemParamValue("eyhrclientId");
String appId =getSystemParamValue("eyhrappId");
String appSecret =getSystemParamValue("eyhrappSecret");
String hrsynccreatetokenurl =getSystemParamValue("hrsynccreatetokenurl");
String hrsyncaddress =getSystemParamValue("hrsyncaddress");
Map<String,String >params =new HashMap <String,String>();
params.put("clientId",clientId);
params.put("appId",appId);
params.put("appSecret",appSecret);
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params));
Request request = new Request.Builder()
.url(hrsyncaddress+hrsynccreatetokenurl)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
Result result = Result.success(Objects.requireNonNull(response.body()).string());
if (result.isOk()) {
JSONObject data = JSON.parseObject(result.getContent());
String code = Objects.requireNonNull(data).getString("code");
String msg = Objects.requireNonNull(data).getString("msg");
if(code.equals("0")){
// 将组织机构数据封装至List
accessToken = Objects.requireNonNull(data).getJSONObject("data").getString("accessToken");
//new BaseBean().writeLog("Token授权==>"+accessToken);
}else{
//new BaseBean().writeLog("Token授权异常code==>"+code+",msg==>"+msg);
}
}
}
//new BaseBean().writeLog("Token授权accessToken==>"+accessToken);
return accessToken;
}
public String createToken(String clientId,String appId,String appSecret,String address,String tokenurl) throws Exception{
String accessToken="";
OkHttpClient client = new OkHttpClient().newBuilder().build();
Map<String,String >params =new HashMap <String,String>();
params.put("clientId",clientId);
params.put("appId",appId);
params.put("appSecret",appSecret);
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params));
Request request = new Request.Builder()
.url(address+tokenurl)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
Result result = Result.success(Objects.requireNonNull(response.body()).string());
if (result.isOk()) {
JSONObject data = JSON.parseObject(result.getContent());
String code = Objects.requireNonNull(data).getString("code");
String msg = Objects.requireNonNull(data).getString("msg");
if(code.equals("0")){
// 将组织机构数据封装至List
accessToken = Objects.requireNonNull(data).getJSONObject("data").getString("accessToken");
//new BaseBean().writeLog("Token授权==>"+accessToken);
}else{
//new BaseBean().writeLog("Token授权异常code==>"+code+",msg==>"+msg);
}
}
}
//new BaseBean().writeLog("Token授权accessToken==>"+accessToken);
return accessToken;
}
/**
*
*/
public String getEyCustomRigthSql(int userid,String tablename){
String returnStr = " select id from "+tablename+" where ";
String matchsql ="select * from uf_stand_match_conf where tablename=?";
RecordSet recordSet=new RecordSet();
recordSet.executeQuery(matchsql,tablename);
if(recordSet.next()){
try {
ResourceComInfo resourceComInfo=new ResourceComInfo();
String workcode=resourceComInfo.getWorkcode(userid+"");//员工工号
String currentroleids =getUserAllRole(userid);//获取当前人员所有角色id
String georegion_fieldname =Util.null2String(recordSet.getString("georegion_fieldname"));
String legalentity_fieldname =Util.null2String(recordSet.getString("legalentity_fieldname"));
String type_fieldname =Util.null2String(recordSet.getString("type_fieldname"));
String codeblock_fieldname =Util.null2String(recordSet.getString("codeblock_fieldname"));
String engagementcode_fieldname =Util.null2String(recordSet.getString("engagementcode_fieldname"));
//业务维度
if(StringUtil.isNotBlank(codeblock_fieldname)){
String codeblocksql = getEyCodeBlockRightSql(workcode,codeblock_fieldname);
if(StringUtil.isNotBlank(codeblocksql)){
returnStr =returnStr+codeblocksql;
}
}
//3.1先查询中间匹配表-firm
//判断台账中间表是否配置完全
if(StringUtil.isNotBlank(georegion_fieldname)&&StringUtil.isNotBlank(legalentity_fieldname)) {
String firmsql = getEyfirmRightSql(type_fieldname,georegion_fieldname, legalentity_fieldname, currentroleids);
if (StringUtil.isNotBlank(firmsql)) {
returnStr = returnStr + firmsql;
}
}
//3.2先查询中间匹配表-gds
if(StringUtil.isNotBlank(type_fieldname)) {
String typesql =getEyGdsRightSql(type_fieldname,currentroleids);
if(StringUtil.isNotBlank(typesql)){
returnStr = returnStr + typesql;
}
}
writeLog("getEyCustomRigthSql,returnStr==>"+returnStr);
} catch (Exception e) {
e.printStackTrace();
}
}
return returnStr;
}
/**
*
*/
public String getEyCodeBlockRightSql(String workcode,String codeblock_fieldname){
String result="";
//1、项目卡片中所有成员
String codeblocksql ="select codeblock from uf_xmjbxxjmbd where id in (" +
"select mainid from uf_xmjbxxjmbd_dt2 where role_gpn='"+workcode+"' " +
")";
//2、通过第三接口获取公司高层维护的codeblock
codeblocksql = codeblocksql +" union " +
" select codeblock from uf_permisson_conf_business where gpn='"+workcode+"' ";
result = " ( "+codeblock_fieldname+" in ("+codeblocksql+") ) or";
writeLog("codeblocksql==>"+codeblocksql);
return result;
}
/**
*FIRM
*/
public String getEyfirmRightSql(String type_fieldname,String georegion_fieldname,String legalentity_fieldname,String currentroleids) {
String result="";
RecordSet rs =new RecordSet();
String firmrolesql =" select legalentity,georegion,roleids from uf_permissionconfig where isopen=0";
rs.executeQuery(firmrolesql,new Object[0]);
List<Map<String,String>> firmmatchlist =new ArrayList <Map<String,String>>();
while(rs.next()){
String roleids =Util.null2String(rs.getString("roleids"));
String legalentity =Util.null2String(rs.getString("legalentity"));
String georegion =Util.null2String(rs.getString("georegion"));
//判断规则中间表是否配置完全
if(!legalentity.equals("")&&!georegion.equals("")){
String[] currentroleidarry =currentroleids.split(",");
//判断当前用户所有角色与规则表的角色是否匹配
for(String roleid:currentroleidarry){
if((","+roleid+",").indexOf(","+roleids+",")>=0){
//legalentity和georegion封装
HashMap<String,String> rolematch =new HashMap <String,String>();
rolematch.put("legalentity",legalentity);
rolematch.put("georegion",georegion);
firmmatchlist.add(rolematch);
break;
}
}
}
}
//遍历legalentity和georegion封装的map 转换sql
if(firmmatchlist.size()>0){
for(Map<String,String> match:firmmatchlist){
String type =Util.null2String(match.get("type"));
String legalentity =Util.null2String(match.get("legalentity"));
String georegion =Util.null2String(match.get("georegion"));
if(StringUtil.isNotBlank(type)){
String firmsql ="";
String lesql = legalentity_fieldname + " in (";
String geosql = georegion_fieldname + " in (";
String[] typearry =type.split(",");
for(String t:typearry){
firmsql =firmsql+type_fieldname+"='"+t+"' and";
if(StringUtil.isNotBlank(legalentity)){
String[] legalentityarry =legalentity.split(",");
for(String le:legalentityarry){
lesql =lesql+"'"+le+"',";
}
lesql=lesql.substring(0,lesql.length()-1)+")";
firmsql =firmsql+lesql+" and";
}
if(StringUtil.isNotBlank(georegion)){
String[] georegionarry =georegion.split(",");
for(String geo:georegionarry){
geosql =geosql+"'"+geo+"',";
}
geosql=geosql.substring(0,geosql.length()-1)+")";
firmsql =firmsql+geosql+" and";
}
}
result =result+"("+firmsql.substring(0,firmsql.length()-3)+"or";
}
}
}
writeLog("result==>"+result);
return result;
}
/**
*GDS
*/
public String getEyGdsRightSql(String type_fieldname,String currentroleids){
String result ="";
List<Map<String,String>> gdsmatchlist =new ArrayList <Map<String,String>>();
RecordSet rs =new RecordSet();
String gdsrolesql =" select type,legalentity,roleids from uf_permisson_conf_gds where isopen=0 ";
rs.executeQuery(gdsrolesql,new Object[0]);
while(rs.next()){
String roleids =Util.null2String(rs.getString("roleids"));
String type =Util.null2String(rs.getString("type"));
if(!type.equals("")){
String[] currentroleidarry =currentroleids.split(",");
//判断当前用户所有角色与规则表的角色是否匹配
for(String roleid:currentroleidarry){
if((","+roleid+",").indexOf(","+roleids+",")>=0){
//legalentity和georegion封装
HashMap<String,String> rolematch =new HashMap <String,String>();
rolematch.put("type",type);
gdsmatchlist.add(rolematch);
break;
}
}
}
}
if(gdsmatchlist.size()>0){
Set<String> typeset =new HashSet<String>();
for(Map<String,String> match:gdsmatchlist){
String type =Util.null2String(match.get("type"));
String[] typearry =type.split(",");
for(String value:typearry){
typeset.add(value);
}
}
for(String s:typeset){
result =result + "("+type_fieldname+"='"+s+"') or";
}
}
return result;
}
public Map<String,Object> getConfidentialInfo(String opprCode,String paceFolderId,String clientId){
Map<String,Object> result =new HashMap <>();
String eventKey = "checkopportunitypaceandclient"; //事件标识
Map<String,Object> body =new HashMap <String,Object>();
Map<String,String> params =new HashMap <String,String>();
List<Map<String,String>> reqdata =new ArrayList <>();
params.put("opprCode",opprCode);
params.put("paceFolderId",paceFolderId);
params.put("clientId",clientId);
reqdata.add(params);
body.put("body",reqdata);
String paramsstr = JSON.toJSONString(body); //事件请求参数
//EsbService其他方法及说明见ESB API接口说明文档
EsbService service = EsbClient.getService(); //获取 ESB 服务
String clientdetailjsonstr = service.execute(eventKey, paramsstr);
new BaseBean().writeLog("getConfidentialInfo,JsonStr==>"+clientdetailjsonstr);
if(StringUtils.isNotBlank(clientdetailjsonstr)){
JSONObject jsonObject=JSON.parseObject(clientdetailjsonstr);
JSONArray resultdata =jsonObject.getJSONObject("data").getJSONArray("data");
String errorStr ="";
String isConfidential ="1";
for(int i=0;i<resultdata.size();i++){
JSONObject single =resultdata.getJSONObject(i);
String errortype =Util.null2String(single.getString("errorType"));
if(errortype.equals("10")){
errorStr =errorStr+"商机Id不存在、";
}else if (errortype.equals("20")){
errorStr =errorStr+"PACEId不存在、";
}else if (errortype.equals("30")){
errorStr =errorStr+"商机Id 和 PACEId无关联、";
}else if(errortype.equals("40")){
errorStr =errorStr+"客户Id不存在、";
}else if(errortype.equals("50")){
errorStr =errorStr+"客户Id和 PACEId无关联、";
}
JSONArray opprsIsConfidential = single.getJSONArray("opprsIsConfidential");
if(opprsIsConfidential!=null && opprsIsConfidential.size()>0) {
for (int j = 0; j < opprsIsConfidential.size(); j++) {
String isConfidentialflag =Util.null2String(opprsIsConfidential.getJSONObject(j).getString("isConfidential"));
if (isConfidentialflag.equals("true")) {
isConfidential = "0";
}
}
}
}
result.put("errorstr",errorStr);
result.put("isConfidential",isConfidential);
}
return result;
}
public boolean getLegalEffective(String bucode,String oucode,String mucode,String smucode){
boolean result =false;
String eventKey = "getLegalEffective"; //事件标识
Map<String,String> params =new HashMap <String,String>();
params.put("buCode",bucode);
params.put("ouCode",oucode);
params.put("muCode",mucode);
params.put("smuCode",smucode);
String paramsstr = JSON.toJSONString(params); //事件请求参数
//EsbService其他方法及说明见ESB API接口说明文档
EsbService service = EsbClient.getService(); //获取 ESB 服务
String clientdetailjsonstr = service.execute(eventKey, paramsstr);
new BaseBean().writeLog("clientdetailjsonstr,getLegalEffective==>"+clientdetailjsonstr);
if (StringUtils.isNotBlank(clientdetailjsonstr)) {
JSONObject jsonObject = JSON.parseObject(clientdetailjsonstr);
JSONObject resultdata = jsonObject.getJSONObject("data").getJSONObject("data");
result = resultdata.getBoolean("isLegal");
}
return result;
}
/**
*
* @param eventKey key
* @param eventKey primaryKey
*/
public Map<String,Object> getBudgetInfo(String eventKey,String primaryKey){
Map<String,Object> result =new HashMap <>();
//事件标识
Map<String,String> params_mmt =new HashMap <String,String>();
params_mmt.put("PrimaryKey",primaryKey);
String paramsstr_mmt = JSON.toJSONString(params_mmt); //事件请求参数
//EsbService其他方法及说明见ESB API接口说明文档
EsbService service = EsbClient.getService(); //获取 ESB 服务
String mmtdetailjsonstr = service.execute(eventKey, paramsstr_mmt);
new BaseBean().writeLog("getBudgetInfo===>"+mmtdetailjsonstr);
if(StringUtils.isNotBlank(mmtdetailjsonstr)){
JSONObject jsonObject=JSON.parseObject(mmtdetailjsonstr);
if(jsonObject.getJSONObject("data").getJSONArray("list")!=null) {
JSONObject resultdata = jsonObject.getJSONObject("data").getJSONArray("list").getJSONObject(0);
if (eventKey.equals("smarthubbudgetdetail")) {
String startDate =resultdata.getString("startDate");
String closeDate =resultdata.getString("closeDate");
if(!startDate.equals("")){
result.put("estimated_start_date", startDate.substring(0,10));
}else{
result.put("estimated_start_date", "");
}
if(!closeDate.equals("")){
result.put("estimated_close_date", closeDate.substring(0,10));
}else{
result.put("estimated_close_date", "");
}
} else {
result.put("estimated_start_date", formatDate(resultdata.getString("estimatedStartDate")));
result.put("estimated_close_date", formatDate(resultdata.getString("estimatedEndDate")));
}
if (eventKey.equals("smarthubbudgetdetail")) {
result.put("eaf", formatDouble(Util.null2String(resultdata.getString("eaf"))));
} else {
result.put("eaf", formatDouble(Util.null2String(resultdata.getString("engagementAdjustedFactor"))));
}
result.put("standard_engagement_revenue", resultdata.getString("ser"));
result.put("net_engagement_revenue", resultdata.getString("ner"));
if (eventKey.equals("smarthubbudgetdetail")) {
result.put("current_year_total_revenue", formatDouble(Util.null2String(resultdata.getString("ter"))));
} else {
result.put("current_year_total_revenue", Util.null2String(resultdata.getString("currentFyTer")));
}
if (eventKey.equals("smarthubbudgetdetail")) {
result.put("margin", "0.00");
} else {
result.put("margin", formatDouble(Util.null2String(resultdata.getString("marginPercent"))));
}
if (eventKey.equals("smarthubbudgetdetail")) {
result.put("partner_involvement", formatDouble(Util.null2String(resultdata.getString("partnerInvolvement"))));
} else {
result.put("partner_involvement", formatDouble(Util.null2String(resultdata.getString("partnerLeverage"))));
}
result.put("erp1", formatDouble(Util.null2String(resultdata.getString("erp"))));
String expenses =Util.null2String(resultdata.getString("totalExpense"));
if(expenses.equals("")){
expenses ="0.00";
}
result.put("expenses",expenses);
if (eventKey.equals("smarthubbudgetdetail")) {
result.put("margin1", "0.00");
} else {
result.put("margin1", resultdata.getString("margin"));
}
if (eventKey.equals("smarthubbudgetdetail")) {
result.put("total_cost", "0.00");
} else {
result.put("total_cost", Util.null2String(resultdata.getString("stdCost")));
}
String hours =Util.null2String(resultdata.getString("totalHours"));
if(hours.equals("")){
hours ="0.00";
}
result.put("hours",hours );
}
new BaseBean().writeLog(JSON.toJSONString(result));
}
return result;
}
/**
*
* @param clientId id
*/
public Map<String,Object> getCustomInfo(String clientId){
Map<String,Object> result =new HashMap <>();
String eventKey = "clientdetail"; //事件标识
Map<String,String> params =new HashMap <String,String>();
params.put("clientId",clientId);
String paramsstr = JSON.toJSONString(params); //事件请求参数
//EsbService其他方法及说明见ESB API接口说明文档
EsbService service = EsbClient.getService(); //获取 ESB 服务
String clientdetailjsonstr = service.execute(eventKey, paramsstr);
String clientScope ="";
String chineseName ="";
new BaseBean().writeLog("clientdetailjsonstr,getCustomInfo==>"+clientdetailjsonstr);
if(StringUtils.isNotBlank(clientdetailjsonstr)){
JSONObject jsonObject=JSON.parseObject(clientdetailjsonstr);
String returncode =jsonObject.getString("code");
if(returncode.equals("100")){
JSONObject resultdata =jsonObject.getJSONObject("data").getJSONObject("result");
clientScope =Util.null2String(resultdata.getString("clientScope"));
chineseName =Util.null2String(resultdata.getString("chineseName"));
result.put("client_name",chineseName);
if(clientScope.equals("100")){
result.put("client_type","0");
}else if (clientScope.equals("101")){
result.put("client_type","1");
}else if (clientScope.equals("102")){
result.put("client_type","2");
}
}
result.put("code",returncode);
}else{
result.put("code","-1");
result.put("client_name","");
result.put("client_type","");
}
new BaseBean().writeLog("getCustomInfo,returnmap==>"+JSON.toJSONString(result));
return result;
}
private static String formatDouble(String value){
String result="";
if(value.equals("")){
result ="0.00";
}else{
BigDecimal bigDecimal =new BigDecimal(value);
result = bigDecimal.divide(new BigDecimal(100)).toString();
}
return result;
}
private static String formatDate(String datestr){
long time = Long.parseLong(datestr);
Date date = new Date(time);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String str = dateFormat.format(date);
return str;
}
public static boolean vaildateImportEnagementName(String engagementname,String global_service_code){
boolean flag=false;
if(engagementname.equals("")||global_service_code.equals("")){
return flag;
}
RecordSet recordSet1=new RecordSet();
String perfix = engagementname.substring(0, 3);
recordSet1.executeQuery("select id from uf_mcgzb where global_service_code=? and mcgz=?",global_service_code,perfix);
if(recordSet1.next()){
flag =true;
}
return flag;
}
}

View File

@ -76,6 +76,9 @@ public class ChildWorkFlowSplitAction extends SafeCusBaseAction {
if (!mapper.updateMainTable(billTable, hasMoreAccountField, null, requestId)) {
throw new CustomerException("更新主表是否包含多账套字段失败!");
}
if(!mapper.selectAccountNumber(id, billTable + "_dt" + insertDetailNo)){
throw new CustomerException("删除明细表数据失败!");
}
return;
}
if (!mapper.updateMainTable(billTable, hasMoreAccountField, hasMoreAccountFieldValue, requestId)) {

View File

@ -10,6 +10,8 @@ import weaver.xuanran.wang.common.interfaces.CusAbstractTokenConf;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* <h1>token </h1>
@ -21,6 +23,7 @@ public class TokenUtil {
private static final Map<String, CusAbstractTokenConf> TOKEN_MAP = new HashMap<>(8);
private static Util_Redis instance = null;
private static boolean redis = false;
private static final Lock lock = new ReentrantLock();
{
try {
@ -41,25 +44,22 @@ public class TokenUtil {
if(Objects.isNull(conf)){
throw new CustomerException("conf cant not be null!");
}
CusAbstractTokenConf token = TOKEN_MAP.get(key);
if(token == null){
synchronized (TokenUtil.class){
token = TOKEN_MAP.get(key);
if(token == null){
return getTokenByHttp(key, conf);
}
lock.lock();
try {
CusAbstractTokenConf token = TOKEN_MAP.get(key);
if(token == null){
return getTokenByHttp(key, conf);
}
}
long expiryTime = token.getExpiryTime();
if(System.currentTimeMillis() >= expiryTime){
synchronized (TokenUtil.class){
expiryTime = token.getExpiryTime();
if(System.currentTimeMillis() >= expiryTime){
return getTokenByHttp(key, conf);
}
long expiryTime = token.getExpiryTime();
if(System.currentTimeMillis() >= expiryTime){
return getTokenByHttp(key, conf);
}
return token.getToken();
}catch (Exception e){
throw new CustomerException("get token error : current key is [ " + key + " ]",e);
}finally {
lock.unlock();
}
return token.getToken();
}
/**
@ -70,7 +70,7 @@ public class TokenUtil {
* @param obj token
* @return token
**/
private static synchronized String getTokenByHttp(String key, CusAbstractTokenConf obj){
private static String getTokenByHttp(String key, CusAbstractTokenConf obj){
Map<String, Object> response = obj.tokenByHttp();
obj.buildTokenObj(response);
TOKEN_MAP.put(key, obj);

View File

@ -33,20 +33,11 @@ public class EyDataAsyncTokenUtil {
**/
public static String getToken(String url, Map<String, Object> params) {
if(token == null){
synchronized (EyDataAsyncTokenUtil.class){
if(token == null){
return getTokenByHTTP(url, params);
}
}
return getTokenByHTTP(url, params);
}
long expiryTime = token.getExpiresTime();
if(System.currentTimeMillis() >= expiryTime){
synchronized (EyDataAsyncTokenUtil.class){
expiryTime = token.getExpiresTime();
if(System.currentTimeMillis() >= expiryTime){
return getTokenByHTTP(url, params);
}
}
return getTokenByHTTP(url, params);
}
return token.getAccessToken();
}

View File

@ -6,6 +6,7 @@ import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.config.RequestConfig;
import org.apache.log4j.Logger;
import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess;
@ -23,6 +24,23 @@ public class RequestMasterPlate{
private final HttpUtils httpUtils = new HttpUtils();
private static final int HTTP_SUCCESS_CODE = 200;
private static final int CONNECT_TIMEOUT = 1000 * 60 * 3;
private static final int CONNECTION_REQUEST_TIMEOUT = 1000 * 60 * 3;
private static final int SOCKET_TIMEOUT = 1000 * 60 * 3;
static RequestConfig requestConfig = RequestConfig.custom()
// 网络请求的超时时间
.setConnectTimeout(CONNECT_TIMEOUT)
// 连接池去获取连接的超时时间
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT)
// 设置socket超时时间
.setSocketTimeout(SOCKET_TIMEOUT)
.build();
{
httpUtils.setRequestConfig(requestConfig);
}
public <T> T apiGet(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess){
ResponeVo responeVo;
try {

View File

@ -1,6 +1,7 @@
package weaver.xuanran.wang.sh_bigdata.common.util;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject;
import org.apache.dubbo.common.serialize.fastjson.FastJsonObjectOutput;
import org.apache.log4j.Logger;
@ -11,6 +12,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* <h1>token </h1>
@ -38,25 +41,19 @@ public class TokenUtil {
* @param secret
**/
public static String getToken(String secret) {
CusToken token = TOKEN_MAP.get(secret);
if(token == null){
synchronized (TokenUtil.class){
token = TOKEN_MAP.get(secret);
if(token == null){
return getTokenByHTTP(secret);
}
try {
CusToken token = TOKEN_MAP.get(secret);
if(token == null){
return getTokenByHTTP(secret);
}
}
long expiryTime = token.getExpiryTime();
if(new Date().getTime() >= expiryTime){
synchronized (TokenUtil.class){
expiryTime = token.getExpiryTime();
if(new Date().getTime() >= expiryTime){
return getTokenByHTTP(secret);
}
long expiryTime = token.getExpiryTime();
if(new Date().getTime() >= expiryTime){
return getTokenByHTTP(secret);
}
return token.getAccess_token();
}catch (Exception e){
throw new CustomerException("get token error : current secret is [ " + secret + " ]",e);
}
return token.getAccess_token();
}
/**

View File

@ -16,7 +16,6 @@ import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
@ -118,7 +117,7 @@ public class SignFtService {
Map<String, Object> result = new HashMap<>(16);
try {
tokenUtils.setAlgorithm(Algorithm.HMAC256(clientSecret));
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
String tokenExpires = Util.getCusConfigValueNullOrEmpty("TOKEN_EXPIRES", "3600");
@ -166,7 +165,7 @@ public class SignFtService {
try {
try {
tokenUtils.setAlgorithm(Algorithm.HMAC256(secretMap.get("clientSecret")));
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
tokenUtils.setExpiresAt(new Date());

View File

@ -12,7 +12,6 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
@ -68,7 +67,7 @@ public class TokenUtils {
this.secret = secret;
try {
this.algorithm = Algorithm.HMAC256(secret);
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
this.claims = claims;

View File

@ -22,7 +22,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
@ -35,228 +34,219 @@ import java.util.Map;
*/
@Path("/fadada")
public class FaDDController {
private final FaDDServiceImpl faDDService = new FaDDServiceImpl();
private final FaDDServiceMapping faDDServiceMapping = new FaDDServiceMapping();
private final ToolUtil toolUtil = new ToolUtil();
/**
*
*
* @param workflowId
* id
* @return
*/
@GET
@Path("/getConfig/{workflowId}")
public String getConfig(@PathParam("workflowId") String workflowId) {
try {
Map<String, Object> configParam = faDDService.getConfigParam(workflowId);
return ApiResult.success(configParam);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param params
*
* @return
*/
@Path("/signature")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String checkCertification(@RequestBody Map<String, Object> params) {
try {
Map<String, Object> certificationResult = faDDService.checkCertification(params);
return ApiResult.success(certificationResult);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId
* id
* @param requestId
* id
* @return
*/
@Path("/signedContract/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContract(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.queryContractStatus(workflowId, requestId, 0);
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("rushInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId
* id
* @param requestId
* id
* @return
*/
@Path("/signedContract/own/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContractOwn(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.signedContractOwn(workflowId, requestId);
String mainTable = faDDServiceMapping.getMainTable(workflowId);
// TODO 更新本方签署
PrepSqlResultImpl sqlResult =
Util.createSqlBuilder().updateSql(mainTable, ParaMap.create().put("signed_oneself", 1),
Util.createPrepWhereImpl().whereAnd("requestid").whereEqual(requestId));
RecordSet rs = new RecordSet();
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("contractSignedInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param requestId
* id
* @return
*/
@Path("/contract/download/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response contractDownload(@PathParam("requestId") String requestId,
@PathParam("workflowId") String workflowId) {
toolUtil.writeErrorLog("进入请求方法获取到请求id" + requestId);
try {
StreamingOutput contractZipStream = faDDService.contractDownload(requestId, workflowId);
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/zip")
.header("Content-Disposition", "attachment;filename=contracts.zip").build();
} catch (Exception e) {
toolUtil.writeErrorLog("转换失败," + e.toString());
return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.APPLICATION_JSON).build();
}
}
/**
*
*
* @param workflowId
* id
* @return id
*/
@Path("/getAllVersion/{workflowId}/{markOnly}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String getAllVersion(@PathParam("workflowId") String workflowId, @PathParam("markOnly") String markOnly) {
try {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId, markOnly);
return ApiResult.success(allVersion);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param requestId
* id
* @return
*/
@Path("/isAllSigned/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String isAllSinged(@PathParam("requestId") String requestId, @PathParam("workflowId") String workflowId) {
try {
faDDService.queryContractStatus(workflowId, requestId, 1);
boolean isAllSinged = faDDService.isAllSinged(requestId, workflowId);
boolean isSingedOneself = faDDService.isSingedOneself(requestId, workflowId);
Map<String, Object> result =
ParaMap.create().put("isAllSinged", isAllSinged).put("isSingedOneself", isSingedOneself);
return ApiResult.success(result);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
@Path("/getLanguage/{languageGroupId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getLanguage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
Map<String, String> map = Util.queryLanguage(languageGroupId, user.getLanguage());
return ApiResult.success(map);
}
@Path("/callback/signed")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String callBackSigned(@RequestBody Map<String, Object> params) {
toolUtil.writeErrorLog("回调方法:" + JSONObject.toJSONString(params));
Map<String, Object> result = new HashMap<>();
String bizContent = String.valueOf(params.get("bizContent"));
if (StringUtils.isNullOrEmpty(bizContent)) {
toolUtil.writeErrorLog("参数没获取到!");
result.put("code", "200");
result.put("msg", "操作失败!");
return JSONObject.toJSONString(result);
}
byte[] decode = Base64.getDecoder().decode(bizContent.getBytes(StandardCharsets.UTF_8));
String decodeStr = null;
try {
decodeStr = new String(decode, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String jsonStr = null;
try {
jsonStr = URLDecoder.decode(decodeStr, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
JSONObject jsonObject = JSON.parseObject(jsonStr);
String resultCode = String.valueOf(jsonObject.getString("resultCode"));
String docNo = String.valueOf(jsonObject.getString("docNo"));
if (!"1".equals(resultCode)) {
toolUtil.writeErrorLog("重复签署合同!" + docNo);
}
// Util.createSqlBuilder().updateSql()
this.toolUtil.writeErrorLog(jsonObject.toJSONString());
result.put("code", "200");
result.put("msg", "操作成功!");
return JSONObject.toJSONString(result);
}
private final FaDDServiceImpl faDDService = new FaDDServiceImpl();
private final FaDDServiceMapping faDDServiceMapping = new FaDDServiceMapping();
private final ToolUtil toolUtil = new ToolUtil();
/**
*
*
* @param workflowId id
* @return
*/
@GET
@Path("/getConfig/{workflowId}")
public String getConfig(@PathParam("workflowId") String workflowId) {
try {
Map<String, Object> configParam = faDDService.getConfigParam(workflowId);
return ApiResult.success(configParam);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param params
* @return
*/
@Path("/signature")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String checkCertification(@RequestBody Map<String, Object> params) {
try {
Map<String, Object> certificationResult = faDDService.checkCertification(params);
return ApiResult.success(certificationResult);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId id
* @param requestId id
* @return
*/
@Path("/signedContract/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContract(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.queryContractStatus(workflowId, requestId, 0);
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("rushInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId id
* @param requestId id
* @return
*/
@Path("/signedContract/own/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContractOwn(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.signedContractOwn(workflowId, requestId);
String mainTable = faDDServiceMapping.getMainTable(workflowId);
// TODO 更新本方签署
PrepSqlResultImpl sqlResult =
Util.createSqlBuilder().updateSql(mainTable, ParaMap.create().put("signed_oneself", 1),
Util.createPrepWhereImpl().whereAnd("requestid").whereEqual(requestId));
RecordSet rs = new RecordSet();
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("contractSignedInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param requestId id
* @return
*/
@Path("/contract/download/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response contractDownload(@PathParam("requestId") String requestId,
@PathParam("workflowId") String workflowId) {
toolUtil.writeErrorLog("进入请求方法获取到请求id" + requestId);
try {
StreamingOutput contractZipStream = faDDService.contractDownload(requestId, workflowId);
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/zip")
.header("Content-Disposition", "attachment;filename=contracts.zip").build();
} catch (Exception e) {
toolUtil.writeErrorLog("转换失败," + e);
return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.APPLICATION_JSON).build();
}
}
/**
*
*
* @param workflowId id
* @return id
*/
@Path("/getAllVersion/{workflowId}/{markOnly}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String getAllVersion(@PathParam("workflowId") String workflowId, @PathParam("markOnly") String markOnly) {
try {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId, markOnly);
return ApiResult.success(allVersion);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param requestId id
* @return
*/
@Path("/isAllSigned/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String isAllSinged(@PathParam("requestId") String requestId, @PathParam("workflowId") String workflowId) {
try {
faDDService.queryContractStatus(workflowId, requestId, 1);
boolean isAllSinged = faDDService.isAllSinged(requestId, workflowId);
boolean isSingedOneself = faDDService.isSingedOneself(requestId, workflowId);
Map<String, Object> result =
ParaMap.create().put("isAllSinged", isAllSinged).put("isSingedOneself", isSingedOneself);
return ApiResult.success(result);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
@Path("/getLanguage/{languageGroupId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getLanguage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
Map<String, String> map = Util.queryLanguage(languageGroupId, user.getLanguage());
return ApiResult.success(map);
}
@Path("/callback/signed")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String callBackSigned(@RequestBody Map<String, Object> params) {
toolUtil.writeErrorLog("回调方法:" + JSONObject.toJSONString(params));
Map<String, Object> result = new HashMap<>();
String bizContent = String.valueOf(params.get("bizContent"));
if (StringUtils.isNullOrEmpty(bizContent)) {
toolUtil.writeErrorLog("参数没获取到!");
result.put("code", "200");
result.put("msg", "操作失败!");
return JSONObject.toJSONString(result);
}
byte[] decode = Base64.getDecoder().decode(bizContent.getBytes(StandardCharsets.UTF_8));
String decodeStr = null;
try {
decodeStr = new String(decode, StandardCharsets.UTF_8);
} catch (Exception e) {
e.printStackTrace();
}
String jsonStr = null;
try {
jsonStr = URLDecoder.decode(decodeStr, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jsonObject = JSON.parseObject(jsonStr);
String resultCode = String.valueOf(jsonObject.getString("resultCode"));
String docNo = String.valueOf(jsonObject.getString("docNo"));
if (!"1".equals(resultCode)) {
toolUtil.writeErrorLog("重复签署合同!" + docNo);
}
// Util.createSqlBuilder().updateSql()
this.toolUtil.writeErrorLog(jsonObject.toJSONString());
result.put("code", "200");
result.put("msg", "操作成功!");
return JSONObject.toJSONString(result);
}
}

View File

@ -213,6 +213,7 @@ public class BuilderPackageEcology extends Application {
checkBox = new CheckBox();
checkBox.getStyleClass().add("check-box");
checkBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
FileInfo item = getItem();
item.setSelected(newValue);
String filePath = item.getFilePath();
@ -223,6 +224,15 @@ public class BuilderPackageEcology extends Application {
} else {
filePaths.remove(filePath);
}
String iconName = "icons/folder.png";
if (item.isSelected()) {
iconName = "icons/folder_active.png";
}
Node rootIcon = new ImageView(
new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream(iconName)))
);// 定义一个图片类型节点对象
checkBox.setGraphic(rootIcon);
});
}
@ -236,8 +246,12 @@ public class BuilderPackageEcology extends Application {
checkBox.setSelected(item.isSelected());
checkBox.setText(item.getFileName().replace("_", "__"));
if (item.isDirectory()) {
String iconName = "icons/folder.png";
if (item.isSelected()) {
iconName = "icons/folder_active.png";
}
Node rootIcon = new ImageView(
new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream("icons/folder.png")))
new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream(iconName)))
);// 定义一个图片类型节点对象
checkBox.setGraphic(rootIcon);

View File

@ -203,4 +203,8 @@ public class TestA extends BaseTest {
}
return dataObject;
}
@Test
public void testC(){
System.out.println(new Date().getTime());
}
}

View File

@ -3,19 +3,11 @@ package xuanran.wang.http_test.test;
import aiyh.utils.httpUtil.ResponeVo;
import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject;
import com.cloudstore.api.util.Util_Redis;
import com.fapiao.neon.client.base.impl.RedisClientImpl;
import com.weaver.base.cache.redis.RedisCache;
import org.docx4j.wml.R;
import org.junit.Test;
import weaver.session.util.RedisClient;
import weaver.session.util.RedisTemplate;
import weaver.xuanran.wang.common.entity.CusResponseSuccess;
import xuanran.wang.http_test.rest_test.CusRestTemplate;
import xuanran.wang.http_test.rest_test.Stu;
import xuanran.wang.rest_test.pojo.CusRestTemplateResponse;
import xuanran.wang.rest_test.CusRestTemplate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -28,26 +20,20 @@ public class TestMain extends BaseTest {
@Test
public void testA(){
CusResponseSuccess builder =
CusResponseSuccess.builder()
CusRestTemplateResponse builder =
CusRestTemplateResponse.builder()
.checkResponse(true)
.successField("code")
.successValue(0)
.errorMsg("msg")
.build();
CusRestTemplate restTemplate = new CusRestTemplate();
Map<String, Object> map = new HashMap<>();
builder.setCall(e->{
map.put("msg", e.getMessage());
map.put("status", false);
});
try {
ResponeVo vo = restTemplate.apiGet("https://gl.shstx.cn:48002/auth/oauth/token?grant_type=client_credentials&client_id=fanwei&client_secret=b7c20b12cb124cbebb0b8833caac6b87", new HashMap<>(), new HashMap<>(), builder);
Map<String, Object> o = restTemplate.parseObj(vo.getResponseMap(), "", Map.class);
System.out.println("token : " + o);
}catch (Exception e){
System.out.println("error : " + e.getMessage());
System.out.println("e map : " + JSONObject.toJSONString(map));
System.out.println("cusSuccess : " + JSONObject.toJSONString(builder));
}

View File

@ -0,0 +1,109 @@
package xuanran.wang.log.cus_api_log;
import aiyh.utils.Util;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.recordset.MapperBuilderSql;
import org.apache.commons.lang3.StringUtils;
import weaver.soa.workflow.request.RequestInfo;
import xuanran.wang.log.cus_api_log.annotations.CusApiLogTable;
import xuanran.wang.log.cus_api_log.dto.CusApiLogBaseDto;
import xuanran.wang.log.cus_api_log.mapper.CusApiLogMapper;
import xuanran.wang.log.cus_api_log.pojo.CusApiLogPojo;
import java.lang.reflect.Field;
import java.util.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 11:39
*/
public class CusApiLogUtil {
private static final CusApiLogMapper mapper = Util.getMapper(CusApiLogMapper.class);
public static void insertApiLog(CusApiLogBaseDto dto){
insertApiLog(dto, -1);
}
public static void insertApiLog(CusApiLogBaseDto dto, int modelId){
CusApiLogPojo pojo = parseDto(dto);
String tableName = pojo.getTableName();
if(modelId < 0){
modelId = Util.getIntValue(Util.getModeIdByTableName(tableName),-1);
if(modelId < 0){
throw new CustomerException(tableName + " not found model id!");
}
}
int modeDataId = Util.getModeDataId(tableName, modelId, 1);
Map<String, Object> params = pojo.getParams();
Map<String, Object> whereMap = new HashMap<>();
whereMap.put("id", modeDataId);
String where = MapperBuilderSql.builderNoWhereAndEn(whereMap);
String updateSql = MapperBuilderSql.builderUpdateSql(tableName, pojo.getParams());
params.putAll(whereMap);
if (!mapper.insertApiLog(updateSql + " where " + where, params)) {
mapper.deleteErrorLog(tableName, modeDataId);
throw new CustomerException("insert log sql execute error! please check ecology.log and /cus/sql_log/cus.log");
}
Util.rebuildModeDataShare(modeDataId, modelId, 1);
}
public static <T extends CusApiLogBaseDto> T initCusApiLogDto(RequestInfo requestInfo, Class<T> clazz){
T obj;
try {
obj = clazz.newInstance();
}catch (Exception e){
throw new CustomerException("class : " + clazz.getName() + " new instance error!");
}
if(Objects.isNull(requestInfo)){
return obj;
}
obj.setUserWorkflow(requestInfo.getWorkflowid());
String requestId = requestInfo.getRequestid();
obj.setSourceRequestId(requestId);
String requestMark = Util.null2DefaultStr(mapper.selectRequestMark(requestId),"");
obj.setWorkflowNo(requestMark);
obj.setCreateUser(requestInfo.getRequestManager().getUser().getUID());
return obj;
}
private static CusApiLogPojo parseDto(CusApiLogBaseDto dto){
String tableName = null;
Class<? extends CusApiLogBaseDto> childClass = dto.getClass();
Field[] childFields = childClass.getDeclaredFields();
List<Field> fieldList = new ArrayList<>(Arrays.asList(childFields));
Class<?> superClass = childClass.getSuperclass();
Map<String, Object> params = new HashMap<>();
if(superClass.isAssignableFrom(CusApiLogBaseDto.class)){
fieldList.addAll(Arrays.asList(superClass.getDeclaredFields()));
tableName = parseTableName(superClass);
}
String childTableName = parseTableName(childClass);
if(StringUtils.isNotBlank(childTableName)){
tableName = childTableName;
}
for (Field field : fieldList) {
SqlDbFieldAnn sqlDbFieldAnn = field.getAnnotation(SqlDbFieldAnn.class);
if(null != sqlDbFieldAnn){
try {
field.setAccessible(true);
params.put(sqlDbFieldAnn.value(), field.get(dto));
}catch (IllegalAccessException e){
throw new IllegalArgumentException("field get value error! current field is [ " + field.getName() + " ]", e);
}
}
}
return CusApiLogPojo.builder().tableName(tableName).params(params).build();
}
private static String parseTableName(Class<?> clazz){
CusApiLogTable apiLogTable = clazz.getAnnotation(CusApiLogTable.class);
if(apiLogTable != null){
return apiLogTable.value();
}
return "";
}
}

View File

@ -0,0 +1,16 @@
package xuanran.wang.log.cus_api_log.annotations;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 13:05
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
public @interface CusApiLogTable {
String value();
}

View File

@ -0,0 +1,81 @@
package xuanran.wang.log.cus_api_log.dto;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import xuanran.wang.log.cus_api_log.annotations.CusApiLogTable;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 11:40
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@CusApiLogTable(value = "uf_api_log")
public class CusApiLogBaseDto{
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "user_workflow")
private String userWorkflow;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "workflow_no")
private String workflowNo;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "unique_code")
private String uniqueCode;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "request_url")
private String requestUrl;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "request_desc")
private String requestDesc;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "request_param")
private String requestParam;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "response")
private String response;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "exception")
private String exception;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "create_user")
private int createUser;
/**
* <h2></h2>
**/
@SqlDbFieldAnn(value = "response_msg")
private String responseMsg;
/**
* <h2>id</h2>
**/
@SqlDbFieldAnn(value = "source_request_id")
private String sourceRequestId;
/**
* <h2>/</h2>
**/
@SqlDbFieldAnn(value = "request_success")
private int requestSuccess;
}

View File

@ -0,0 +1,20 @@
package xuanran.wang.log.cus_api_log.dto;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.*;
import xuanran.wang.log.cus_api_log.annotations.CusApiLogTable;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 12:45
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DemoDto extends CusApiLogBaseDto{
@SqlDbFieldAnn(value = "ext")
private String ext;
}

View File

@ -0,0 +1,10 @@
package xuanran.wang.log.cus_api_log.interfaces;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 12:44
*/
public interface CusLogDtoInterface {
}

View File

@ -0,0 +1,21 @@
package xuanran.wang.log.cus_api_log.mapper;
import aiyh.utils.annotation.recordset.*;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 13:24
*/
@SqlMapper
public interface CusApiLogMapper {
@Update(custom = true)
boolean insertApiLog(@SqlString String sql, Map<String, Object> params);
@Select("select requestMark from workflow_requestBase where requestId = #{requestId}")
String selectRequestMark(@ParamMapper("requestId") String requestId);
@Delete("delete from $t{tableName} where id = #{id}")
void deleteErrorLog(@ParamMapper("tableName") String tableName,
@ParamMapper("id") Integer id);
}

View File

@ -0,0 +1,20 @@
package xuanran.wang.log.cus_api_log.pojo;
import lombok.*;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 13:08
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CusApiLogPojo {
private String tableName;
private Map<String, Object> params;
}

View File

@ -0,0 +1,63 @@
package xuanran.wang.log.cus_api_log.test;
import aiyh.utils.httpUtil.ResponeVo;
import basetest.BaseTest;
import org.junit.Test;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;
import xuanran.wang.rest_test.pojo.CusRestTemplateResponse;
import xuanran.wang.log.cus_api_log.CusApiLogUtil;
import xuanran.wang.log.cus_api_log.dto.DemoDto;
import xuanran.wang.rest_test.CusRestTemplate;
import java.util.HashMap;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/11 12:47
*/
public class CusApiLogUtilTest extends BaseTest {
private final CusRestTemplate cusRestTemplate = new CusRestTemplate();
@Test
public void test(){
RequestInfo info = new RequestInfo();
info.setWorkflowid("1");
info.setRequestid("123");
RequestManager manager = new RequestManager();
manager.setUser(new User(1));
info.setRequestManager(manager);
DemoDto demoDto = CusApiLogUtil.initCusApiLogDto(info, DemoDto.class);
Map<String, Object> param = new HashMap<>();
param.put("grant_type","client_credentials");
param.put("client_id","fanwei");
param.put("client_secret","b7c20b12cb124cbebb0b8833caac6b87");
CusRestTemplateResponse success = CusRestTemplateResponse
.builder()
.successField("code")
.successValue(0)
.errorMsg("msg")
.logDto(demoDto)
.build();
success.setSuccessCallBack(cusLogDtoInterface -> {
DemoDto dto = (DemoDto) cusLogDtoInterface;
dto.setExt("1");
});
success.setErrorCallBack((exception,cusLogDtoInterface)->{
DemoDto dto = (DemoDto) cusLogDtoInterface;
dto.setExt("失败了");
} );
ResponeVo responeVo = cusRestTemplate.apiGet("https://gl.shstx.cn:48002/auth/oauth/token", param, new HashMap<>(), success);
String token = cusRestTemplate.parseCommon(responeVo.getResponseMap(), "data.access_token", String.class);
System.out.println("token => " + token);
}
}

View File

@ -0,0 +1,188 @@
package xuanran.wang.rest_test;
import aiyh.utils.ThreadPoolConfig;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.ResponeVo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.MapUtils;
import org.apache.log4j.Logger;
import xuanran.wang.rest_test.pojo.CusRestTemplateResponse;
import xuanran.wang.log.cus_api_log.CusApiLogUtil;
import xuanran.wang.log.cus_api_log.dto.CusApiLogBaseDto;
import xuanran.wang.rest_test.impl.CusGetRequest;
import xuanran.wang.rest_test.impl.CusPostRequest;
import xuanran.wang.rest_test.interfaces.CusApiRequestInterface;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/13 09:55
*/
public abstract class AbstractCusRestTemplate {
private static final int HTTP_SUCCESS_CODE = 200;
protected Logger log = Util.getLogger();
private static final Map<Integer, CusApiRequestInterface> FUN = new HashMap<>();
private static final ExecutorService EXECUTOR_SERVICE = ThreadPoolConfig.createThreadPoolInstance();
protected static final Integer GET = 1;
protected static final Integer POST = 2;
protected static final Integer PUT = 3;
protected static final Integer DELETE = 4;
static {
FUN.put(GET, new CusGetRequest());
FUN.put(POST, new CusPostRequest());
}
protected ResponeVo sendRequest(String url, Object params, Map<String, String> headers,
CusRestTemplateResponse cusSuccess, Integer type){
try {
requestBeforeInit(url, params, cusSuccess);
ResponeVo vo = FUN.get(type).execute(url, params, headers, cusSuccess);
requestAfterInit(cusSuccess, vo);
checkResponse(url, vo, params, headers, cusSuccess);
successCallBack(cusSuccess);
return vo;
}catch (Exception e){
errorCallBack(e, cusSuccess);
throw new CustomerException("send request error! : [ " + e.getMessage() + " ]", e);
}
}
/**
* <h1>cusSuccess</h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:17
* @param url
* @param responseVo
* @param o
* @param cusSuccess
**/
private void checkResponse(String url, ResponeVo responseVo,
Object o, Map<String, String> header,
CusRestTemplateResponse cusSuccess) {
if (Objects.isNull(cusSuccess) || !cusSuccess.isCheckResponse()) {
return;
}
if (responseVo.getCode() != HTTP_SUCCESS_CODE) { // 相应状态码
log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串
"this request heard is [{}]but response status code is [{}]" +
"this response is [{}]", url, JSON.toJSON(o), JSON.toJSONString(header), responseVo.getCode(), // 相应状态码
responseVo.getEntityString())); // 相应内容
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
Map<String, Object> response;
if (cusSuccess.getCusDataDecipher() != null) {
response = cusSuccess.getCusDataDecipher().decoder(responseVo);
} else {
response = responseVo.getResponseMap(); // 根据相应结果转化为map集合
}
if(MapUtils.isEmpty(response)){
return;
}
String responseValue = Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), "");
String msg = Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), "");
cusSuccess.setMsg(msg);
if (!responseValue.equals(Util.null2DefaultStr(cusSuccess.getSuccessValue(), ""))) {
throw new CustomerException(Util.logStr("接口地址:[{}], 接口响应码不为: [{}], 接口响应信息: {}", url, cusSuccess.getSuccessValue(), msg)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:20
* @param url url
* @param params
* @param cusSuccess
**/
private void requestBeforeInit(String url, Object params, CusRestTemplateResponse cusSuccess){
if(!Objects.isNull(cusSuccess)){
cusSuccess.setUrl(url);
cusSuccess.setRequestParam(params);
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:20
* @param cusSuccess
* @param vo
**/
private void requestAfterInit(CusRestTemplateResponse cusSuccess, ResponeVo vo){
if(!Objects.isNull(cusSuccess)){
cusSuccess.setVo(vo);
cusSuccess.setResponse(vo.getResponseMap());
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:21
* @param cusSuccess
**/
private void successCallBack(CusRestTemplateResponse cusSuccess){
if(!Objects.isNull(cusSuccess) && !Objects.isNull(cusSuccess.getSuccessCallBack())){
cusSuccess.getSuccessCallBack().accept(cusSuccess.getLogDto());
}
writeLog(cusSuccess);
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:21
* @param e
* @param cusSuccess
**/
private void errorCallBack(Exception e, CusRestTemplateResponse cusSuccess){
if(!Objects.isNull(cusSuccess) && !Objects.isNull(cusSuccess.getErrorCallBack())){
cusSuccess.setException(e);
cusSuccess.getErrorCallBack().accept(e,cusSuccess.getLogDto());
}
writeLog(cusSuccess);
}
private void writeLog(CusRestTemplateResponse cusResponseSuccess){
if(!Objects.isNull(cusResponseSuccess) && cusResponseSuccess.isWriteLog()){
if(cusResponseSuccess.isAsyncWriteLog()){
EXECUTOR_SERVICE.execute(()-> executeWriteLog(cusResponseSuccess));
}else {
executeWriteLog(cusResponseSuccess);
}
}
}
private void executeWriteLog(CusRestTemplateResponse cusResponseSuccess){
try {
CusApiLogBaseDto dto = cusResponseSuccess.getLogDto();
dto.setRequestParam(JSONObject.toJSONString(cusResponseSuccess.getRequestParam()));
dto.setRequestUrl(cusResponseSuccess.getUrl());
dto.setResponseMsg(cusResponseSuccess.getMsg());
dto.setResponse(JSONObject.toJSONString(cusResponseSuccess.getResponse()));
dto.setRequestSuccess(0);
dto.setResponseMsg(dto.getResponseMsg());
Exception error = cusResponseSuccess.getException();
if(null != error){
dto.setRequestSuccess(1);
dto.setException(error.getMessage());
}
CusApiLogUtil.insertApiLog(dto, Util.getIntValue(cusResponseSuccess.getLogModelId(),-1));
}catch (Exception e){
log.error("write log error : " + e.getMessage(), e);
}
}
}

View File

@ -1,10 +1,7 @@
package xuanran.wang.http_test.rest_test;
package xuanran.wang.rest_test;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
@ -12,8 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.xuanran.wang.common.entity.CusResponseSuccess;
import xuanran.wang.rest_test.pojo.CusRestTemplateResponse;
import java.util.List;
import java.util.Map;
@ -25,11 +21,8 @@ import java.util.Objects;
* @author xuanran.wang
* @date 2023/7/7 10:56
*/
public class CusRestTemplate {
public class CusRestTemplate extends AbstractCusRestTemplate{
private static final ObjectMapper objectMapper = new ObjectMapper();
private final Logger log = Util.getLogger();
private final HttpUtils httpUtils = new HttpUtils();
private static final int HTTP_SUCCESS_CODE = 200;
/**
* <h1>get</h1>
@ -43,17 +36,8 @@ public class CusRestTemplate {
**/
public ResponeVo apiGet(String url, Map<String, Object> params,
Map<String, String> headers,
CusResponseSuccess cusSuccess) {
ResponeVo responeVo;
try {
requestBeforeInit(url, params, cusSuccess);
responeVo = httpUtils.apiGet(url, params, headers);
checkResponse(url, responeVo, params, cusSuccess);
return responeVo;
} catch (Exception e) {
callBack(e,cusSuccess);
throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
CusRestTemplateResponse cusSuccess) {
return sendRequest(url, params, headers, cusSuccess, GET);
}
@ -67,51 +51,8 @@ public class CusRestTemplate {
* @param cusSuccess
* @return
**/
public ResponeVo apiPost(String url, Object params, Map<String, String> headers, CusResponseSuccess cusSuccess) {
ResponeVo responeVo;
try {
requestBeforeInit(url, params, cusSuccess);
responeVo = httpUtils.apiPostObject(url, params, headers);
checkResponse(url, responeVo, params, cusSuccess);
return responeVo;
} catch (Exception e) {
callBack(e,cusSuccess);
throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
}
/**
* <h1>cusSuccess</h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:17
* @param url
* @param responseVo
* @param o
* @param cusSuccess
**/
private void checkResponse(String url, ResponeVo responseVo, Object o, CusResponseSuccess cusSuccess) {
if (Objects.isNull(cusSuccess) || !cusSuccess.isCheckResponse()) {
return;
}
cusSuccess.setVo(responseVo);
if (responseVo.getCode() != HTTP_SUCCESS_CODE) { // 相应状态码
log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串
"this request heard is [{}]but response status code is [{}]" +
"this response is [{}]", url, JSON.toJSON(o), JSON.toJSONString(httpUtils.getGlobalCache().header), responseVo.getCode(), // 相应状态码
responseVo.getEntityString())); // 相应内容
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
Map<String, Object> response;
if (cusSuccess.getCusDataDecipher() != null) {
response = cusSuccess.getCusDataDecipher().decoder(responseVo);
} else {
response = responseVo.getResponseMap(); // 根据相应结果转化为map集合
}
cusSuccess.setResponse(response);
String responseValue = Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), "");
if (!responseValue.equals(Util.null2DefaultStr(cusSuccess.getSuccessValue(), ""))) {
throw new CustomerException(Util.logStr("接口地址:[{}], 接口响应码不为: [{}], 接口响应信息: {}", url, cusSuccess.getSuccessValue(), Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
public ResponeVo apiPost(String url, Object params, Map<String, String> headers, CusRestTemplateResponse cusSuccess) {
return sendRequest(url, params, headers, cusSuccess, POST);
}
/**
@ -208,33 +149,4 @@ public class CusRestTemplate {
return dataObject;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:20
* @param url url
* @param params
* @param cusSuccess
**/
private void requestBeforeInit(String url, Object params, CusResponseSuccess cusSuccess){
if(!Objects.isNull(cusSuccess)){
cusSuccess.setUrl(url);
cusSuccess.setRequestParam(params);
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/7/7 17:21
* @param e
* @param cusSuccess
**/
public void callBack(Exception e, CusResponseSuccess cusSuccess){
if(!Objects.isNull(cusSuccess.getCall())){
cusSuccess.setE(e);
cusSuccess.getCall().accept(e);
}
}
}

View File

@ -1,4 +1,4 @@
package xuanran.wang.http_test.rest_test;
package xuanran.wang.rest_test;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

View File

@ -0,0 +1,25 @@
package xuanran.wang.rest_test.impl;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import xuanran.wang.rest_test.pojo.CusRestTemplateResponse;
import xuanran.wang.rest_test.interfaces.CusApiRequestInterface;
import java.io.IOException;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/13 10:07
*/
public class CusGetRequest implements CusApiRequestInterface {
private final HttpUtils httpUtils = new HttpUtils();
@Override
public ResponeVo execute(String url, Object params, Map<String, String> headers, CusRestTemplateResponse cusSuccess) throws IOException {
return httpUtils.apiGet(url, (Map<String, Object>) params, headers);
}
}

View File

@ -0,0 +1,24 @@
package xuanran.wang.rest_test.impl;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import xuanran.wang.rest_test.pojo.CusRestTemplateResponse;
import xuanran.wang.rest_test.interfaces.CusApiRequestInterface;
import java.io.IOException;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/13 10:09
*/
public class CusPostRequest implements CusApiRequestInterface {
private final HttpUtils httpUtils = new HttpUtils();
@Override
public ResponeVo execute(String url, Object params, Map<String, String> headers, CusRestTemplateResponse cusSuccess) throws IOException {
return httpUtils.apiPostObject(url, params, headers);
}
}

View File

@ -0,0 +1,19 @@
package xuanran.wang.rest_test.interfaces;
import aiyh.utils.httpUtil.ResponeVo;
import xuanran.wang.rest_test.pojo.CusRestTemplateResponse;
import java.io.IOException;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/7/13 10:06
*/
public interface CusApiRequestInterface {
ResponeVo execute(String url, Object params,
Map<String, String> headers,
CusRestTemplateResponse cusSuccess) throws IOException;
}

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.common.entity;
package xuanran.wang.rest_test.pojo;
import aiyh.utils.httpUtil.ResponeVo;
import lombok.AllArgsConstructor;
@ -6,10 +6,11 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import weaver.xuanran.wang.common.service.CusDataDecipher;
import xuanran.wang.log.cus_api_log.dto.CusApiLogBaseDto;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
/**
@ -22,17 +23,28 @@ import java.util.function.Function;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CusResponseSuccess {
public class CusRestTemplateResponse {
private ResponeVo vo;
private Object requestParam;
private String successField;
private Object successValue;
private String errorMsg;
private String dataKey;
private String msg;
private Map<String, Object> response;
private CusDataDecipher cusDataDecipher;
private String url;
private Exception e;
private Exception exception;
@Builder.Default
private boolean checkResponse = true;
private Consumer<Exception> call;
private BiConsumer<Exception, CusApiLogBaseDto> errorCallBack;
@Builder.Default
private boolean writeLog = false;
private CusApiLogBaseDto logDto;
private String logModelId;
private Consumer<CusApiLogBaseDto> successCallBack;
@Builder.Default
private boolean asyncWriteLog = true;
}

View File

@ -0,0 +1,40 @@
package youhong.ai.pcn.multilingual;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringFinder {
public static String findString(String input, String startPattern, String endPattern) {
// 构建正则表达式模式
String pattern = Pattern.quote(startPattern) + "(.*?)" + Pattern.quote(endPattern);
Pattern regex = Pattern.compile(pattern);
Matcher matcher = regex.matcher(input);
String str = input;
System.out.println(str.replaceAll(pattern, "woshiyigeshabi"));
if (matcher.find()) {
// 返回第一个匹配的结果
return matcher.group(1);
} else {
// 未找到匹配的结果
return null;
}
}
public static void main(String[] args) {
String input = "<span><p>~`~`7当与商业伙伴、客户或第三方打交道时必须避免留下任何保时捷进行不寻常的业务实践或有针对性的措施以对业务决策施加不公平的影响的印象。`~`8When dealing with Business Partners, Customers or Third Parties, it is essential to avoid any impression that PCN engages in unusual business practices or targeted measures to exercise unfair influence on business decisions. `~`~</p></span>";
String startPattern = "~`~`";
String endPattern = "`~`~";
String output = findString(input, startPattern, endPattern);
System.out.println("Result: " + output);
String[] split = output.split("`~`");
for (String s : split) {
System.out.println(s);
StringParser.StringEntity stringEntity = StringParser.parseString(s);
System.out.println(stringEntity.getNumber());
String remainingString = stringEntity.getRemainingString();
System.out.println(remainingString);
}
}
}

View File

@ -0,0 +1,50 @@
package youhong.ai.pcn.multilingual;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringParser {
public static class StringEntity {
private final int number;
private final String remainingString;
public StringEntity(int number, String remainingString) {
this.number = number;
this.remainingString = remainingString;
}
public int getNumber() {
return number;
}
public String getRemainingString() {
return remainingString;
}
}
public static StringEntity parseString(String input) {
int number = 0;
String remainingString = input;
// 正则表达式匹配开头的数字
String regex = "^\\d+";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
String matchedNumber = matcher.group();
number = Integer.parseInt(matchedNumber);
// 从原始字符串中去除开头的数字部分
remainingString = input.substring(matchedNumber.length());
}
return new StringEntity(number, remainingString);
}
public static void main(String[] args) {
String input = "123Hello World!";
StringEntity result = parseString(input);
System.out.println("Number: " + result.getNumber());
System.out.println("Remaining String: " + result.getRemainingString());
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B