合并
jingwei
youhong.ai 2023-06-02 11:29:29 +08:00
commit 78de340044
82 changed files with 4591 additions and 502 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ log
/log/ /log/
.DS_Store .DS_Store
/src/main/resources/WEB-INF/prop/weaver.properties /src/main/resources/WEB-INF/prop/weaver.properties
/src/main/resources/ajzx/
/file/ /file/
/src/test/resources/application.properties /src/test/resources/application.properties

View File

@ -8,8 +8,8 @@ const threeMonthIndex = 1;
const submitWaitNode = WfForm.convertFieldNameToId("sftjddjd"); const submitWaitNode = WfForm.convertFieldNameToId("sftjddjd");
// 下次超时提醒日期 // 下次超时提醒日期
const timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq"); const timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq");
// 跟踪天数 // 跟踪天数 <= 1 ? 15 : 30;
const trackingDays = WfForm.getFieldValue(trackTimeField) <= 1 ? 15 : 30; const trackingDaysField = WfForm.convertFieldNameToId("gzts")
// 跟踪触发行数 // 跟踪触发行数
const trackingLineField = WfForm.convertFieldNameToId("gzcfxs"); const trackingLineField = WfForm.convertFieldNameToId("gzcfxs");
$(() => { $(() => {
@ -44,6 +44,7 @@ function getNodeNum(){
let currentDate = getCurrentDate(); let currentDate = getCurrentDate();
let dayDiff = getDaysDiff(firstSaleDate, currentDate); let dayDiff = getDaysDiff(firstSaleDate, currentDate);
console.log('当前天数与首台销售日期相差天数 : ', dayDiff) console.log('当前天数与首台销售日期相差天数 : ', dayDiff)
let trackingDays = WfForm.getFieldValue(trackingDaysField);
return Math.floor(dayDiff / trackingDays) + 1; return Math.floor(dayDiff / trackingDays) + 1;
} }
@ -52,6 +53,7 @@ function initTimeoutDate(){
let firstSaleDate = WfForm.getFieldValue(firstSaleDateField); let firstSaleDate = WfForm.getFieldValue(firstSaleDateField);
const nodeNum = getNodeNum(); const nodeNum = getNodeNum();
console.log('到达节点次数 ', nodeNum); console.log('到达节点次数 ', nodeNum);
let trackingDays = WfForm.getFieldValue(trackingDaysField);
console.log('跟踪天数 ', trackingDays); console.log('跟踪天数 ', trackingDays);
let computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays); let computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays);
console.log('计算下次超时日期 ', computeTimeoutDate); console.log('计算下次超时日期 ', computeTimeoutDate);

View File

@ -5,6 +5,8 @@ import aiyh.utils.excention.CustomerException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import weaver.interfaces.schedule.BaseCronJob; import weaver.interfaces.schedule.BaseCronJob;
import java.io.IOException;
/** /**
* <h1></h1> * <h1></h1>
* *
@ -41,7 +43,7 @@ public abstract class CusBaseCronJob extends BaseCronJob {
* *
* @author youHong.ai ****************************************** * @author youHong.ai ******************************************
*/ */
public abstract void runCode(); public abstract void runCode() throws IOException;
/** /**

View File

@ -586,7 +586,7 @@ public class ResultMapper {
if (collectionMapping != null) { if (collectionMapping != null) {
Object collection = collection(rs, collectionMapping, method); Object collection = collection(rs, collectionMapping, method);
try { try {
if (Objects.nonNull(value)) { if (Objects.nonNull(collection)) {
propertyDescriptor.getWriteMethod().invoke(o, collection); propertyDescriptor.getWriteMethod().invoke(o, collection);
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -0,0 +1,54 @@
package com.api.bokang.xiao.porsche_repush.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.bokang.xiao.porsche_repush.service.ContractRePushService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
/**
* @ClassName ContractRePushController
* @Author
* @Date 2023/5/10 10:47
* @Description <h1></h1>
**/
@Path("/xbk/porsche_repush")
public class ContractRePushController {
private final Logger log = Util.getLogger();
private final ContractRePushService contractRePushService = new ContractRePushService();
/**
* <h2></h2>
* @param request
* @param response
* @param param
* @return
*/
@Path("/contractRePush")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String contractRePush(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("into contractRePush success params ==> "+param);
User loginUser = HrmUserVarify.getUser(request, response);
List<Map<String,Boolean>> result = contractRePushService.contractRePushService(param,loginUser);
return ApiResult.success(result);
}catch (Exception e){
log.error("contractRePush error ==> "+ Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
}

View File

@ -0,0 +1,24 @@
package com.api.bokang.xiao.porsche_repush.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.List;
import java.util.Map;
/**
* @ClassName QueryMapper
* @Author
* @Date 2023/5/10 11:00
* @Description <h1></h1>
**/
@SqlMapper
public interface QueryMapper {
@Select("select * from uf_zcht where id in $t{ids}")
List<Map<String,Object>> queryContractByIds(@ParamMapper("ids")String ids);
@Select("select * from actionsettingdetail where ACTIONID = (select id from actionsetting where actionname = #{actionName})")
List<Map<String,Object>> queryActionParam(@ParamMapper("actionName")String actionName);
}

View File

@ -0,0 +1,91 @@
package com.api.bokang.xiao.porsche_repush.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSON;
import com.api.bokang.xiao.porsche_repush.mapper.QueryMapper;
import org.apache.log4j.Logger;
import weaver.aiyh_pcn.common_fadada.action.CommonContractRevocationAction;
import weaver.aiyh_pcn.common_fadada.action.CommonCreateContractAction;
import weaver.aiyh_pcn.common_fadada.action.CommonOneselfSignAction;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ClassName ContractRePushService
* @Author
* @Date 2023/5/10 10:48
* @Description <h1></h1>
**/
public class ContractRePushService {
private final Logger log = Util.getLogger();
private final QueryMapper queryMapper = Util.getMapper(QueryMapper.class);
public List<Map<String, Boolean>> contractRePushService(Map<String,Object> param, User loginUser) {
String ids = Util.null2String(param.get("ids"));
int labelId = Util.getIntValue(String.valueOf(param.get("labelId")));
String contractCreateAction = Util.null2String(param.get("contractCreateAction"));
String signOtherAction = Util.null2String(param.get("signOtherAction"));
String contractRevocationAction = Util.null2String(param.get("ContractRevocationAction"));
String workflowField = Util.null2String(param.get("workflowField"));
List<Map<String, Object>> createList = queryMapper.queryActionParam(contractCreateAction);
List<Map<String, Object>> signOtherList = queryMapper.queryActionParam(signOtherAction);
List<Map<String, Object>> contractRevocationList = queryMapper.queryActionParam(contractRevocationAction);
Map<String, String> contractActionParam = createList.stream().collect(Collectors
.toMap(
item -> Util.null2String(item.get("attrname")),
item -> Util.null2String(item.get("attrvalue"))
)
);
Map<String, String> signOtherActionParam = signOtherList.stream().collect(Collectors
.toMap(
item -> Util.null2String(item.get("attrname")),
item -> Util.null2String(item.get("attrvalue"))
)
);
Map<String, String> contractRevocationParam = contractRevocationList.stream().collect(Collectors
.toMap(
item -> Util.null2String(item.get("attrname")),
item -> Util.null2String(item.get("attrvalue"))
)
);
log.info(String.format("contractCreateAction ==> param:%s signOtherAction ==> param:%s contractRevocationAction ==> param:%s",
JSON.toJSONString(contractRevocationParam),
JSON.toJSONString(contractActionParam),
JSON.toJSONString(signOtherActionParam)
));
List<Map<String,Object>> contractList = queryMapper.queryContractByIds(ids);
List<Map<String, Boolean>> result = new ArrayList<>();
for (Map<String, Object> contract : contractList) {
String signStatus = Util.null2String(contract.get("zcgsqszt"));
if("1".equals(signStatus)){
throw new CustomerException(SystemEnv.getHtmlLabelName(labelId, loginUser.getLanguage()));
}
}
for (Map<String, Object> contract : contractList) {
Map<String,Boolean> info = new HashMap<>();
int requestId = Util.getIntValue(String.valueOf(contract.get(workflowField)));
try{
//合同撤回
Util.actionTest(CommonContractRevocationAction.class,requestId,contractRevocationParam);
//合同创建
Util.actionTest(CommonCreateContractAction.class,requestId,contractActionParam);
//对方签署
Util.actionTest(CommonOneselfSignAction.class,requestId,signOtherActionParam);
}catch (CustomerException exception){
info.put(String.valueOf(requestId),false);
}
info.put(String.valueOf(requestId),true);
result.add(info);
}
return result;
}
}

View File

@ -0,0 +1,55 @@
package com.api.bokang.xiao.sh_bigdata.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.bokang.xiao.sh_bigdata.service.ReportService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
/**
* @ClassName YearReviewController
* @Author
* @Date 2023/2/14 17:00
* @Description <h1></h1>
**/
@Path("/xbk/sh_bigdata")
public class ReportController {
private final Logger log = Util.getLogger();
ReportService reportService = new ReportService();
/**
* <h2></h2>
* @param request
* @param response
* @param param
* @return
*/
@Path("/getReportData")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("into getReportData success params ==> "+param);
User loginUser = HrmUserVarify.getUser(request, response);
List<Map<String, Object>> reportData = reportService.queryReportData(param, loginUser);
return ApiResult.success(reportData);
}catch (Exception e){
log.error("getReportData error ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
}

View File

@ -0,0 +1,39 @@
package com.api.bokang.xiao.sh_bigdata.mapper;
import aiyh.utils.annotation.recordset.*;
import java.util.List;
import java.util.Map;
/**
* @ClassName ReviewMapper
* @Author
* @Date 2023/2/14 17:02
* @Description <h1></h1>
**/
@SqlMapper
public interface ReportMapper {
/**
* <h2></h2>
* @param uid id
* @param param
* @return
*/
@Select("select id, ysdx, hdlb, ysrq, ysclhjsy, hbcc, xcap, gzryhcl, zs, ykdhhgbs, " +
" dyjbr, (select lastname from hrmresource where id = dyjbr) dyjbr_span," +
" djr, (select lastname from hrmresource where id = djr) djr_span," +
" ldrlddw, rwzt, bz, ysjsy, ysrs, cfsj1, ddsj1, sfz, ddz, gzcl, gbs, lddw, lxr, lxrdh " +
" from $t{param.table} $t{param.whereSql} order by ysrq ")
@CaseConversion(value = false)
List<Map<String, Object>> queryReportData(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
@Select("select id,dlsk,yslx,hbcc,sfsj,ddsj,sfd,ddd,wdwcl,dwcljsy,wdwclqt,xcap,lxr,lxrdh,bz,gzcl,gzry,zs,dyjbr,djr,ldr,lddw,rwzt,ykdh,gbs, " +
" (select LISTAGG(wb, ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx, " +
" dyjbr, (select lastname from åhrmresource where id = dyjbr) dyjbr_span," +
" djr, (select lastname from hrmresource where id = djr) djr_span " +
" from uf_zwfwdjjmb main $t{param.whereSql} order by dlsk ")
@CaseConversion(value = false)
List<Map<String, Object>> queryReportData2(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
}

View File

@ -0,0 +1,47 @@
package com.api.bokang.xiao.sh_bigdata.service;
import aiyh.utils.Util;
import com.api.bokang.xiao.sh_bigdata.mapper.ReportMapper;
import weaver.general.TimeUtil;
import weaver.hrm.User;
import java.util.List;
import java.util.Map;
/**
* @ClassName ReviewService
* @Author
* @Date 2023/2/14 17:01
* @Description <h1></h1>
**/
public class ReportService {
private final ReportMapper reportMapper = Util.getMapper(ReportMapper.class);
/**
* <h2>top5</h2>
* @param param
* @param user
* @return
*/
public List<Map<String,Object>> queryReportData(Map<String,Object> param, User user){
String currentDate = Util.null2String(param.get("currentDate"));
String registrationPeople = Util.null2String(param.get("registrationPeople"));
String registrationPeopleSpan = Util.null2String(param.get("registrationPeopleSpan"));
param.put("whereSql","");
String whereSql = "";
if(!"".equals(currentDate)){
whereSql += " and dlsk = #{param.currentDate} ";
}else {
param.put("today", TimeUtil.getCurrentDateString());
whereSql += " and dlsk >= #{param.today} ";
}
if(!"".equals(registrationPeople)){
whereSql += " and djr = #{param.registrationPeople} ";
}
whereSql = whereSql.replaceFirst(" and "," where ");
param.put("whereSql",whereSql);
return reportMapper.queryReportData2(param,user.getUID());
}
}

View File

@ -0,0 +1,80 @@
package com.api.bokang.xiao.zhenn.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.bokang.xiao.wx_report.service.ReportService;
import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl;
import com.api.bokang.xiao.zhenn.service.BankService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
/**
* @ClassName ContractController
* @Author
* @Date 2023/5/8 16:16
* @Description <h1></h1>
**/
@Path("/xbk/zhenn")
public class BankController {
private final Logger log = Util.getLogger();
private final BankService bankService = new BankService();
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/getBankData")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getBankData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("====== into getBankData success =======");
log.info("param:"+param);
User loginUser = HrmUserVarify.getUser(request, response);
Map<String,Map<String,Object>> bankData = bankService.getBankData(loginUser, param);
return ApiResult.success(bankData);
}catch (Exception e){
log.error("getBankData error ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/getCommonSelect")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getCommonSelect(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("====== into getCommonSelect success =======");
log.info("param:"+param);
User loginUser = HrmUserVarify.getUser(request, response);
List<Map<String, Object>> bankSelectInfo = bankService.getBankSelectInfo(loginUser, param);
return ApiResult.success(bankSelectInfo);
}catch (Exception e){
log.error("getCommonSelect error ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
}

View File

@ -0,0 +1,109 @@
package com.api.bokang.xiao.zhenn.mapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.List;
import java.util.Map;
/**
* @ClassName ContractMapper
* @Author
* @Date 2023/5/8 16:16
* @Description <h1></h1>
**/
@SqlMapper
public interface BankMapper {
/**
* <h2></h2>
* @param param
* @return
*/
@Select("SELECT t.requestid requestId,t.$t{amountField} amount,t.$t{amountField} outAmount," +
" $t{inCompany} inCompany,wb.lastoperatedate outDate," +
" (select top 1 xmlsend from workflowToFinanceUrl where wb.requestid = t.requestId and xmlsend IS NOT NULL order by id desc) xmlsend " +
"FROM $t{tableName} t " +
"INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " +
"WHERE wb.currentnodetype = 3 " +
" AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} " +
" AND $t{currencyField} = #{currency}")
List<Map<String,Object>> queryOaOutList(Map<String, Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("SELECT t.requestid requestId,t.$t{amountField} amount,t.$t{amountField} outAmount," +
" $t{inCompany} inCompany,wb.lastoperatedate outDate," +
" (select top 1 xmlsend from workflowToFinanceUrl where wb.requestid = t.requestId and xmlsend IS NOT NULL order by id desc) xmlsend " +
"FROM $t{tableName} t " +
"INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " +
"WHERE wb.currentnodetype = 3 " +
" AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} " +
" AND $t{currencyField} = #{currency}" +
" AND t.$t{bankAccountField} = #{currentBankAccount}")
List<Map<String,Object>> queryOaOutBank(Map<String, Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("SELECT t.requestid,t.$t{amountField} amount,t.$t{amountField} inAmount," +
" $t{inCompany} outCompany,wb.lastoperatedate inDate,wfu.xmlsend,t.$t{payInfoField} payInfo " +
"FROM $t{tableName} t " +
"INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " +
"WHERE wb.currentnodetype = 3 " +
" AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} " +
" AND $t{currencyField} = #{currency}" +
" AND t.$t{bankAccountField} = #{currentBank}")
List<Map<String,Object>> queryOaInBank(Map<String, Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select id,txnamt amount,txnamt difAmount,txnamt outAmount,insid," +
" insid outFlowNo,txndate_time,actacn,tobank inCompany from uf_bank_trade_info " +
"where txndate_time BETWEEN #{beginDate} AND #{endDate} " +
" and trncur = #{currencySpan}" +
" and actacn = #{currentBankAccount}")
List<Map<String,Object>> queryBankOutInfo(Map<String,Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select id,id payInfo,txnamt amount,txnamt difAmount,txnamt inAmount,insid," +
" insid inFlowNo,txndate_time,actacn,ibkname outCompany from uf_bank_trade_info " +
"where txndate_time BETWEEN #{beginDate} AND #{endDate} " +
" and trncur = #{currencySpan}" +
" and actacn_receipt = #{currentBankAccount}")
List<Map<String,Object>> queryBankInInfo(Map<String,Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select sum(avabal) from uf_bank_day_balance " +
"where actacn = #{currentBankAccount} and curcde = #{currencySpan} and baldat BETWEEN #{beginDate} AND #{endDate} ")
double queryBankDayAmount(Map<String, Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select sum(EvBalance) from uf_period_balance " +
"where glAccount = #{bankSubject} " +
" and EvCurrency = #{currencySpan} " +
" and IvFiscYear = YEAR(#{beginDate}) " +
" and IvFisPeriod = MONTH(#{beginDate})")
double queryBankStatementBalance(Map<String, Object> param);
}

View File

@ -0,0 +1,168 @@
package com.api.bokang.xiao.zhenn.service;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import com.api.bokang.xiao.zhenn.mapper.BankMapper;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.CommonUtil;
import weaver.bokang.xiao.common.mapper.WorkflowMapper;
import weaver.hrm.User;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ClassName ContractService
* @Author
* @Date 2023/5/8 16:16
* @Description <h1></h1>
**/
public class BankService {
private final BankMapper bankMapper = Util.getMapper(BankMapper.class);
private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class);
private final Logger log = Util.getLogger();
/**
* <h2></h2>
*
* <p>
* param{
* currentBank:"当前银行下拉框索引",
* currentBankAccount:"当前银行下拉框账号",
* currentBankSpan:"当前银行名称",
* outParam:[{
* table:"流程表名",
* workflowId:"流程id",
* amountField:"金额字段名",
* bankAccountField:"银行账号字段",
* queryTye:"1、付款账号固定2、付款账号不固定"
* }]:"付款参数条件",
* inParam:[{
* table:"流程表名",
* workflowId:"流程id",
* amountField:"金额字段名",
* bankAccountField:"银行账号字段",
* }]:"收款参数条件"
* }
* </p
*
* @param loginUser
* @param param
* @return
*/
public Map<String,Map<String,Object>> getBankData(User loginUser, Map<String, Object> param) {
Map<String,Map<String,Object>> bankData = new HashMap<>();
Map<String,Object> bankBaseInfo = new HashMap<>();
String currentBankSpan = Util.null2String(param.get("currentBankSpan"));
String bankAccount = Util.null2String(param.get("currentBankAccount"));
List<Map<String,Object>> outParam = (List<Map<String, Object>>) param.get("outParam");
List<Map<String,Object>> inParam = (List<Map<String, Object>>) param.get("inParam");
//查询数据
List<Map<String, Object>> oaOutList = outParam.stream()
.flatMap(item -> {
String queryTye = Util.null2String(item.get("queryTye"));
item.put("currentBankAccount",bankAccount);
item.put("beginDate",Util.null2String(param.get("beginDate")));
item.put("endDate",Util.null2String(param.get("endDate")));
item.put("currency",Util.null2String(param.get("currency")));
item.put("currencySpan",Util.null2String(param.get("endDate")));
item.put("bankSubject",Util.null2String(param.get("bankSubject")));
item.put("currentBank",Util.null2String(param.get("currentBank")));
List<Map<String, Object>> tempOutList = "1".equals(queryTye) ? bankMapper.queryOaOutList(item) : bankMapper.queryOaOutBank(item);
for (Map<String, Object> tempOut : tempOutList) {
String xmlSend = Util.null2String(tempOut.get("xmlsend"));
String insId = CommonUtil.getNodeValue(xmlSend, "insid");
tempOut.put("insId",insId);
}
return tempOutList.stream();
})
.collect(Collectors.toList());
List<Map<String, Object>> oaInList = inParam.stream()
.flatMap(item -> {
item.put("currentBankAccount",bankAccount);
item.put("beginDate",Util.null2String(param.get("beginDate")));
item.put("endDate",Util.null2String(param.get("endDate")));
item.put("currency",Util.null2String(param.get("currency")));
item.put("currencySpan",Util.null2String(param.get("endDate")));
item.put("bankSubject",Util.null2String(param.get("bankSubject")));
item.put("currentBank",Util.null2String(param.get("currentBank")));
return bankMapper.queryOaInBank(item).stream();
})
.collect(Collectors.toList());
List<Map<String, Object>> bankOutList = bankMapper.queryBankOutInfo(param);
List<Map<String, Object>> bankInList = bankMapper.queryBankInInfo(param);
//计算有差异的集合
List<Map<String, Object>> oaOutTable = CommonUtil.difference(oaOutList, bankOutList, map -> map.get("insid"));
List<Map<String, Object>> bankOutTable = CommonUtil.difference(bankOutList,oaOutList, map -> map.get("insid"));
List<Map<String, Object>> bankInTable = CommonUtil.difference(bankInList,oaInList, map -> map.get("payInfo"));
List<Map<String, Object>> oaInTable = new ArrayList<>();
//银行信息
bankBaseInfo.put("bankName",currentBankSpan);
bankBaseInfo.put("bankAccount",bankAccount);
//求总和
Map<String, Object> amountMap = new HashMap<>();
double bankDayAmount = this.queryBankDayAmount(param);
double bankStatementBalance = this.queryBankStatementBalance(param);
double bankInDifference = bankInTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum();
double oaInDifference = 0;
double bankOutDifference = bankOutTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum();
double oaOutDifference = oaOutTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum();
double bankDayAmountUpdate = bankDayAmount + bankInDifference - bankOutDifference;
double bankStatementBalanceUpdate = bankStatementBalance + oaInDifference - oaOutDifference;
//返回数据组装
amountMap.put("bankInDifference",bankInDifference);
amountMap.put("oaInDifference",oaInDifference);
amountMap.put("bankOutDifference",bankOutDifference);
amountMap.put("oaOutDifference",oaOutDifference);
amountMap.put("bankDayAmount",bankDayAmount);
amountMap.put("bankStatementBalance",bankStatementBalance);
amountMap.put("bankDayAmountUpdate",bankDayAmountUpdate);
amountMap.put("bankStatementBalanceUpdate",bankStatementBalanceUpdate);
Map<String, Object> bankTableListData = new HashMap<>();
bankTableListData.put("oaOutTable",oaOutTable);
bankTableListData.put("bankOutTable",bankOutTable);
bankTableListData.put("bankInTable",bankInTable);
bankTableListData.put("oaInTable",oaInTable);
bankData.put("bankBaseData",bankBaseInfo);
bankData.put("bankAmountData",amountMap);
bankData.put("bankTableListData",bankTableListData);
log.info("getBankData bankData 对账单报表信息==>"+ JSON.toJSONString(bankData));
return bankData;
}
/**
* <h2></h2>
* @param loginUser
* @param param
* @return
*/
public List<Map<String,Object>> getBankSelectInfo(User loginUser, Map<String, Object> param){
String fieldName = Util.null2String(param.get("fieldName"));
return workflowMapper.queryCommonSelect(fieldName);
}
/**
* <h2></h2>
* @param param
* @return <
*/
private double queryBankDayAmount(Map<String, Object> param){
return bankMapper.queryBankDayAmount(param);
}
/**
* <h2></h2>
* @param param
* @return <
*/
private double queryBankStatementBalance(Map<String, Object> param){
return bankMapper.queryBankStatementBalance(param);
}
}

View File

@ -38,7 +38,7 @@ public interface ReserveSelectMapper {
* @param param * @param param
* @return * @return
*/ */
@Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where concat(',',concat($t{dateField},',')) like #{datePicker} and ($t{markField} <> 0 or $t{markField} is not null)") @Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where concat(',',concat($t{dateField},',')) like #{datePicker} and ($t{markField} <> 0 or $t{markField} is null)")
@CaseConversion(value = false) @CaseConversion(value = false)
List<Map<String, Object>> queryModeList(Map<String, Object> param); List<Map<String, Object>> queryModeList(Map<String, Object> param);

View File

@ -142,6 +142,7 @@ public class ReserveServiceImpl implements ReserveService {
String workflowInfoField = Util.null2String(param.get("workflowInfoField")); String workflowInfoField = Util.null2String(param.get("workflowInfoField"));
String formId = Util.null2String(param.get("formId")); String formId = Util.null2String(param.get("formId"));
List<Map<String, Object>> modeList = reserveSelectMapper.queryModeList(param); List<Map<String, Object>> modeList = reserveSelectMapper.queryModeList(param);
log.info("triggerModeList ==>"+JSON.toJSONString(modeList));
if(Objects.nonNull(modeList) && !modeList.isEmpty()){ if(Objects.nonNull(modeList) && !modeList.isEmpty()){
for (Map<String, Object> modeMap : modeList) { for (Map<String, Object> modeMap : modeList) {
Map<String,Object> dealResult = new HashMap<>(); Map<String,Object> dealResult = new HashMap<>();

View File

@ -100,10 +100,11 @@ public class SyncAccountTradeInfoJob extends BaseCronJob {
xmlParams.put("type", "2002"); xmlParams.put("type", "2002");
xmlParams.put("ibknum", ibknum); xmlParams.put("ibknum", ibknum);
xmlParams.put("actacn", actacn); xmlParams.put("actacn", actacn);
xmlParams.put("from", "20220919"); //xmlParams.put("from", "20220919");
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, -1); cal.set(Calendar.DAY_OF_MONTH, -1);
xmlParams.put("to", ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit)); xmlParams.put("from", ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit));
xmlParams.put("to", ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit));
xmlParams.put("amountFrom", "1"); xmlParams.put("amountFrom", "1");
xmlParams.put("amountTo", "100000"); xmlParams.put("amountTo", "100000");
xmlParams.put("begnum", start + ""); xmlParams.put("begnum", start + "");

View File

@ -45,12 +45,12 @@ public class OtherSystemToOAController {
// 获取重定向地址和secret // 获取重定向地址和secret
Map<String, String> redirectUrlAndCorpsecret = service.getRedirectUrlAndCorpsecret(appId); Map<String, String> redirectUrlAndCorpsecret = service.getRedirectUrlAndCorpsecret(appId);
String redirectUrl = Util.null2DefaultStr(redirectUrlAndCorpsecret.get("REDIRECTURL"),""); String redirectUrl = Util.null2DefaultStr(redirectUrlAndCorpsecret.get("REDIRECTURL"),"");
log.info("successSendRedirectUrl : " + redirectUrl);
if(StringUtils.isBlank(redirectUrl)){ if(StringUtils.isBlank(redirectUrl)){
throw new CustomerException("redirectUrl is null! " + JSONObject.toJSONString(redirectUrlAndCorpsecret)); throw new CustomerException("redirectUrl is null! " + JSONObject.toJSONString(redirectUrlAndCorpsecret));
} }
int userId = service.getUserFromOtherSys(code, redirectUrlAndCorpsecret); int userId = service.getUserFromOtherSys(code, redirectUrlAndCorpsecret);
SessionUtil.createSession(userId + "", request, response); SessionUtil.createSession(String.valueOf(userId), request, response);
log.info("successSendRedirectUrl : " + redirectUrl);
response.sendRedirect(redirectUrl); response.sendRedirect(redirectUrl);
}catch (Exception e){ }catch (Exception e){
log.error("sso error : " + e.getMessage()); log.error("sso error : " + e.getMessage());

View File

@ -1,8 +1,11 @@
package com.api.xuanran.wang.sh_bigdata.sso.mapper; package com.api.xuanran.wang.sh_bigdata.sso.mapper;
import aiyh.utils.Util;
import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper; import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.SqlString;
import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil;
import java.util.Map; import java.util.Map;
@ -21,8 +24,8 @@ public interface OtherSystemToOAMapper {
* @param outKey id * @param outKey id
* @return oa ID * @return oa ID
**/ **/
@Select("select id from hrmresource where outkey = #{outKey}") @Select(custom = true)
int selectUserIdByOutKey(@ParamMapper("outKey") String outKey); int selectUserIdByOutKey(@SqlString String sql, @ParamMapper("outKey") String outKey);
/** /**
* <h1>appId </h1> * <h1>appId </h1>
* @author xuanran.wang * @author xuanran.wang

View File

@ -21,7 +21,7 @@ public interface OtherSystemToOAService {
* @param cusSuccess / * @param cusSuccess /
* @return * @return
**/ **/
int getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret); Object getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret);
/** /**
* <h1>codeoaid</h1> * <h1>codeoaid</h1>
* @author xuanran.wang * @author xuanran.wang

View File

@ -28,12 +28,13 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService {
.successField("code") .successField("code")
.successValue(0) .successValue(0)
.errorMsg("msg") .errorMsg("msg")
.dataKey("data.id") .dataKey("data." + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoInterfaceCompareField"), "id"))
.build(); .build();
private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class); private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class);
private final Logger log = Util.getLogger(); private final Logger log = Util.getLogger();
@Override @Override
public int getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret) { public Object getUserIdByCode(String url, Map<String, Object> params, Map<String, String> headers, CusSuccess cusSuccess, Map<String, String> redirectUrlSecret) {
String secret = Util.null2DefaultStr(redirectUrlSecret.get("SECRET"), ""); String secret = Util.null2DefaultStr(redirectUrlSecret.get("SECRET"), "");
log.info("secret : " + secret); log.info("secret : " + secret);
if(StringUtils.isBlank(secret)){ if(StringUtils.isBlank(secret)){
@ -48,7 +49,7 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService {
params.put("code", code); params.put("code", code);
// 获取第三方系统id // 获取第三方系统id
String getUserInfoByCodeUrl = ShBigDataUtil.getPropertiesValByKey("getUserInfoByCodeUrl"); String getUserInfoByCodeUrl = ShBigDataUtil.getPropertiesValByKey("getUserInfoByCodeUrl");
int codeId; Object codeId;
try { try {
codeId = getUserIdByCode(getUserInfoByCodeUrl, params, new HashMap<>(), cusSuccess, redirectUrlSecret); codeId = getUserIdByCode(getUserInfoByCodeUrl, params, new HashMap<>(), cusSuccess, redirectUrlSecret);
}catch (Exception e){ }catch (Exception e){
@ -61,10 +62,12 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService {
throw new CustomerException(e.getMessage()); throw new CustomerException(e.getMessage());
} }
} }
if(codeId < 0){ String oaOutKey = Util.null2DefaultStr(codeId, "");
if(StringUtils.isBlank(oaOutKey)){
throw new CustomerException(Util.logStr("code : {}, not found in {} .", code, getUserInfoByCodeUrl)); throw new CustomerException(Util.logStr("code : {}, not found in {} .", code, getUserInfoByCodeUrl));
} }
int id = otherSystemToOAMapper.selectUserIdByOutKey(codeId + ""); String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}";
int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey);
if(id < 0){ if(id < 0){
throw new CustomerException(Util.logStr("code : {} not found in OA!", id)); throw new CustomerException(Util.logStr("code : {} not found in OA!", id));
} }

View File

@ -0,0 +1,233 @@
package weaver.bokang.xiao.common;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.util.*;
import java.util.function.BiPredicate;
import java.util.function.Function;
/**
* @ClassName CommonUtil
* @Author
* @Date 2023/5/11 20:10
* @Description <h1></h1>
**/
public class CommonUtil {
/**
* <h2></h2>
* @param tableName
* @param updateParam
* @param whereParam
* @return sql
*/
public static String getCusUpdateSql(String tableName, Map<String, Object> updateParam, Map<String, Object> whereParam){
return buildUpdateSql(tableName,updateParam) + buildWhereSql(whereParam);
}
/**
* <h2>sql</h2>
* @param tableName
* @param updateParam
* @return
*/
public static String buildUpdateSql(String tableName, Map<String, Object> updateParam){
StringBuilder updateBuilder = new StringBuilder("update ");
updateBuilder.append(tableName).append(" set ");
Set<Map.Entry<String, Object>> updateEntries = updateParam.entrySet();
for (Map.Entry<String, Object> updateEntry : updateEntries) {
if("cusSql".equals(updateEntry.getKey())){
updateBuilder.append(updateEntry.getValue());
continue;
}
updateBuilder.append(updateEntry.getKey())
.append(" = ")
.append("#{updateParam.").append(updateEntry.getKey()).append("},");
}
return updateBuilder.substring(0, updateBuilder.length() - 1) + " ";
}
/**
* <h2>sql</h2>
* @param whereParam
* @return
*/
public static String buildWhereSql(Map<String, Object> whereParam){
StringBuilder whereBuilder = new StringBuilder();
Set<Map.Entry<String, Object>> whereEntries = whereParam.entrySet();
for (Map.Entry<String, Object> whereEntry : whereEntries) {
if("cusSql".equals(whereEntry.getKey())){
whereBuilder.append(" and ").append(whereEntry.getValue());
continue;
}
whereBuilder.append(" and ")
.append(whereEntry.getKey())
.append(" = ")
.append("#{whereParam.").append(whereEntry.getKey()).append("},");
}
String fixStr = whereBuilder.toString();
if(!"".equals(fixStr)){
fixStr = fixStr.replaceFirst(" and "," where ");
}
return fixStr.substring(0, fixStr.length() - 1) + " ";
}
/**
* XML
* @param xml XML
* @param nodeName
* @return
*/
public static String getNodeValue(String xml, String nodeName) {
try {
// 创建 SAXBuilder 对象
SAXBuilder builder = new SAXBuilder();
// 创建 StringReader 对象,并将 XML 字符串作为参数传入
StringReader reader = new StringReader(xml);
// 使用 SAXBuilder 对象解析 XML得到 Document 对象
Document doc = builder.build(reader);
// 获取根节点
Element root = doc.getRootElement();
// 调用递归方法获取节点值
String nodeValue = getNodeValue(root, nodeName);
// 如果节点值为空,则返回空字符串
return nodeValue == null ? "" : nodeValue;
} catch (Exception e) {
// 如果解析 XML 异常,则返回空字符串
return "";
}
}
/**
*
* @param element
* @param nodeName
* @return null
*/
private static String getNodeValue(Element element, String nodeName) {
// 获取当前节点的子节点
Element node = element.getChild(nodeName);
// 如果子节点中存在指定的节点,则返回节点的值
if (node != null) {
return node.getValue();
} else {
// 否则遍历子节点,递归调用 getNodeValue 方法,直到找到指定节点为止
List<Element> children = element.getChildren();
if (Objects.nonNull(children) && children.size() > 0) {
for (Element child : children) {
String value = getNodeValue(child, nodeName);
if (value != null) {
return value;
}
}
}
// 如果遍历完所有子节点都没有找到指定节点,则返回 null
return null;
}
}
/**
* List
*
* @param list1 List
* @param list2 List
* @param fieldName
* @param <T>
* @return
* @throws NoSuchFieldException
* @throws IllegalAccessException 访
*/
public static <T> List<T> intersection(List<? extends T> list1, List<? extends T> list2, String fieldName) throws NoSuchFieldException, IllegalAccessException {
return CommonUtil.intersection(list1, list2, (t1, t2) -> {
try {
Object fieldValue1 = getFieldValue(t1, fieldName);
Object fieldValue2 = getFieldValue(t2, fieldName);
return fieldValue1 != null && fieldValue1.equals(fieldValue2);
} catch (NoSuchFieldException | IllegalAccessException e) {
return false;
}
});
}
/**
* List
*
* @param list1 List
* @param list2 List
* @param matcher truefalse
* @param <T>
* @return
*/
public static <T> List<T> intersection(List<? extends T> list1, List<? extends T> list2, BiPredicate<? super T, ? super T> matcher) {
Set<T> set = new HashSet<>(list1);
List<T> result = new ArrayList<>();
for (T t2 : list2) {
if (set.contains(t2) && matcher.test(set.iterator().next(), t2)) {
result.add(t2);
}
}
return result;
}
/**
* ListListList
*
* @param list1 List
* @param list2 List
* @param matcher truefalse
* @param <T>
* @return
*/
public static <T> List<T> difference(List<? extends T> list1, List<? extends T> list2, BiPredicate<? super T, ? super T> matcher) {
Set<T> set2 = new HashSet<>(list2);
List<T> result = new ArrayList<>();
for (T t1 : list1) {
if (!set2.contains(t1) || !matcher.test(t1, set2.iterator().next())) {
result.add(t1);
}
}
return result;
}
/**
* ListListList
*
* @param list1 List
* @param list2 List
* @param keyFunc Key
* @param <T>
* @param <K> Key
* @return
*/
public static <T, K> List<T> difference(List<? extends T> list1, List<? extends T> list2, Function<? super T, ? extends K> keyFunc) {
BiPredicate<? super T, ? super T> matcher = (t1, t2) -> Objects.equals(keyFunc.apply(t1), keyFunc.apply(t2));
return difference(list1, list2, matcher);
}
private static Object getFieldValue(Object obj, String fieldName) throws NoSuchFieldException, IllegalAccessException {
if (obj instanceof Map) {
// 如果对象是Map类型则直接返回指定键的值
Map<?, ?> map = (Map<?, ?>) obj;
return map.get(fieldName);
} else {
// 如果对象是JavaBean类型则通过反射获取指定属性的值
Class<?> clazz = obj.getClass();
while (clazz != null) {
try {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException e) {
// 如果当前类没有指定的属性,则向上查找父类
clazz = clazz.getSuperclass();
}
}
// 如果所有父类都没有指定的属性,则抛出异常
throw new NoSuchFieldException(fieldName);
}
}
}

View File

@ -1,11 +1,10 @@
package weaver.bokang.xiao.common.mapper; package weaver.bokang.xiao.common.mapper;
import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.*;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.Update;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* @ClassName WorkflowMapper * @ClassName WorkflowMapper
@ -38,4 +37,21 @@ public interface WorkflowMapper {
@ParamMapper("fieldName") String fieldName, @ParamMapper("fieldName") String fieldName,
@ParamMapper("fieldValue") String fieldValue, @ParamMapper("fieldValue") String fieldValue,
@ParamMapper("requestId") String requestId); @ParamMapper("requestId") String requestId);
@Select("select detail.id as `key`,detail.name as showname " +
"from mode_selectitempage page " +
"inner join mode_selectitempagedetail detail on page.id = detail.mainid " +
"where page.selectitemname = #{fieldName}")
List<Map<String,Object>> queryCommonSelect(@ParamMapper("fieldName")String fieldName);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param updateParam
* @param whereParam
* @return
*/
@Update(custom = true)
boolean executeUpdateCusSql(@SqlString String cusSql, @ParamMapper("updateParam")Map<String,Object> updateParam, @ParamMapper("whereParam")Map<String,Object> whereParam);
} }

View File

@ -0,0 +1,38 @@
package weaver.bokang.xiao.common.model_update.entity;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import lombok.Data;
/**
* @ClassName AssignmentEntity
* @Author
* @Date 2023/4/4 15:42
* @Description <h1></h1>
**/
@Data
public class AssignmentEntity {
/** 赋值字段 */
@SqlOracleDbFieldAnn("ASSIGNMENT_FIELD")
private String assignmentField;
/** 值选择 */
@SqlOracleDbFieldAnn("VALUE_SELECT")
private Integer valueSelect;
/** 源字段 */
@SqlOracleDbFieldAnn("SOURCE_FIELD")
private String sourceField;
/** 赋值字段名 */
@SqlOracleDbFieldAnn("ASSIGNMENT_FIELD_NAME")
private String assignmentFieldName;
/** 源字段名 */
@SqlOracleDbFieldAnn("SOURCE_FIELD_NAME")
private String sourceFieldName;
/** 文本框 */
@SqlOracleDbFieldAnn("CUS_CONTEXT")
private String cusContext;
}

View File

@ -0,0 +1,46 @@
package weaver.bokang.xiao.common.model_update.entity;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import lombok.Data;
/**
* @ClassName ConditionEntity
* @Author
* @Date 2023/4/4 15:39
* @Description <h1></h1>
**/
@Data
public class ConditionEntity {
/** 条件类型 */
@SqlOracleDbFieldAnn("CONDITION_TYPE")
private Integer conditionType;
/** 条件 */
@SqlOracleDbFieldAnn("CONDITION_VALUE")
private Integer conditionValue;
/** 源字段 */
@SqlOracleDbFieldAnn("CONDITION_SOURCE_FIELD")
private String conditionSourceField;
/** 值类型 */
@SqlOracleDbFieldAnn("VALUE_TYPE")
private Integer valueType;
/** 目标字段 */
@SqlOracleDbFieldAnn("CONDITION_TARGET_FIELD")
private String conditionTargetField;
/** 源字段名 */
@SqlOracleDbFieldAnn("CONDITION_SOURCE_FIELD_NAME")
private String conditionSourceFieldName;
/** 目标字段名 */
@SqlOracleDbFieldAnn("CONDITION_TARGET_FIELD_NAME")
private String conditionTargetFieldName;
/** 文本框 */
@SqlOracleDbFieldAnn("CUS_TEXT")
private String cusText;
}

View File

@ -0,0 +1,59 @@
package weaver.bokang.xiao.common.model_update.entity;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import lombok.Data;
import java.util.List;
/**
* @ClassName UpdateModeConf
* @Author
* @Date 2023/4/4 15:32
* @Description <h1></h1>
**/
@Data
public class UpdateModeConf {
/** 源建模 */
@SqlOracleDbFieldAnn("SOURCE_MODE")
private String sourceMode;
/** 触发建模 */
@SqlOracleDbFieldAnn("TARGET_MODE")
private String targetMode;
/** 说明 */
@SqlOracleDbFieldAnn("DESCRIPTION")
private String description;
/** 唯一标识 */
@SqlOracleDbFieldAnn("UNIQUE_CODE")
private String uniqueCode;
/** 源表名 */
@SqlOracleDbFieldAnn("SOURCE_TABLE_NAME")
private String sourceTableName;
/** 触发表名 */
@SqlOracleDbFieldAnn("TARGET_TABLE_NAME")
private String targetTableName;
/** 数据写入方式 */
@SqlOracleDbFieldAnn("DATA_IN_TYPE")
private Integer dataInType;
/** 自定义操作类全路径 */
@SqlOracleDbFieldAnn("OPERATE_PATH")
private String operatePath;
/** 无条件触发 */
@SqlOracleDbFieldAnn("NO_RULE")
private Integer noRule;
/** 条件列表 */
private List<ConditionEntity> conditionList;
/** 赋值列表 */
private List<AssignmentEntity> assignmentList;
}

View File

@ -0,0 +1,20 @@
package weaver.bokang.xiao.common.model_update.function;
/**
* @ClassName ConditionFunction
* @Author
* @Date 2023/4/4 17:58
* @Description <h1></h1>
**/
@FunctionalInterface
public interface ConditionFunction <R,P,Q,K>{
/**
* <h2></h2>
* @param p
* @param q
* @param k
* @return
*/
R apply(P p,Q q,K k);
}

View File

@ -0,0 +1,36 @@
package weaver.bokang.xiao.common.model_update.function;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import java.util.Map;
/**
* @ClassName CusOperateInterface
* @Author
* @Date 2023/4/7 14:52
* @Description <h1></h1>
**/
public interface CusOperateInterface {
Logger logger = Util.getLogger();
/**
* <h2><h2/>
*
* <p>
* whereParam: key
* param{
* tableName:"更新数据表名",
* whereSql:"条件sql",
* operatePath:"接口全路径类名"
* }
* pathParam:
* </p>
*
* @param whereParam
* @param param
* @param pathParam
*/
void execute(Map<String,Object> whereParam, Map<String,String> param,Map<String,String> pathParam);
}

View File

@ -0,0 +1,108 @@
package weaver.bokang.xiao.common.model_update.mapper;
import aiyh.utils.annotation.recordset.*;
import weaver.bokang.xiao.common.model_update.entity.AssignmentEntity;
import weaver.bokang.xiao.common.model_update.entity.ConditionEntity;
import weaver.bokang.xiao.common.model_update.entity.UpdateModeConf;
import java.util.List;
import java.util.Map;
/**
* @ClassName UpdateModeMapper
* @Author
* @Date 2023/4/4 15:47
* @Description <h1></h1>
**/
@SqlMapper
public interface UpdateModeMapper {
/**
* <h2>formId</h2>
* @param formId id
* @return
*/
@Select("select * from uf_update_mode_conf where source_mode = #{formId}")
@CollectionMappings({
@CollectionMapping(property = "conditionList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
@CollectionMapping(property = "assignmentList", column = "id", id = @Id(value = Integer.class, methodId = 2)),
})
List<UpdateModeConf> queryUpdateModeConfByFormId(@ParamMapper("formId")String formId);
/**
* <h2>formId</h2>
* @return
*/
@Select("select * from uf_update_mode_conf")
@CollectionMappings({
@CollectionMapping(property = "conditionList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
@CollectionMapping(property = "assignmentList", column = "id", id = @Id(value = Integer.class, methodId = 2)),
})
List<UpdateModeConf> queryUpdateModeConf();
/**
* <h2></h2>
* @param mainId id
* @return
*/
@Select("select * from uf_update_mode_conf_dt1 where mainid = #{mainId}")
@CollectionMethod(1)
List<ConditionEntity> queryConditionList(@ParamMapper("mainId")int mainId);
/**
* <h2></h2>
* @param mainId id
* @return
*/
@Select("select * from uf_update_mode_conf_dt2 where mainid = #{mainId}")
@CollectionMethod(2)
List<AssignmentEntity> queryAssignmentList(@ParamMapper("mainId")int mainId);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param param
* @param cusParam
* @return
*/
@Select(custom = true)
String executeCusSql(@SqlString String cusSql, @ParamMapper("param")Map<String,Object> param,Map<String,Object> cusParam);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param whereParam
* @param cusParam
* @return
*/
@Select(custom = true)
Map<String,Object> executeCusSqlMap(@SqlString String cusSql,
@ParamMapper("whereParam")Map<String,Object> whereParam,
@ParamMapper("cusParam")Map<String,Object> cusParam);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param whereParam
* @param cusParam
* @return
*/
@Select(custom = true)
List<Map<String,Object>> executeCusSqlList(@SqlString String cusSql,
@ParamMapper("whereParam")Map<String,Object> whereParam,
@ParamMapper("cusParam")Map<String,Object> cusParam);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param updateParam
* @param whereParam
* @return
*/
@Update(custom = true)
boolean executeUpdateCusSql(@SqlString String cusSql,
@ParamMapper("updateParam")Map<String,Object> updateParam,
@ParamMapper("whereParam")Map<String,Object> whereParam);
}

View File

@ -0,0 +1,131 @@
package weaver.bokang.xiao.common.model_update.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.model_update.function.ConditionFunction;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName ConditionTargetProcess
* @Author
* @Date 2023/4/4 17:54
* @Description <h1>sql</h1>
**/
public class ConditionTargetProcess {
public static final Map<Integer, ConditionFunction<String,Map<String,Object>,Map<String,Object>,String>> TARGET_MODE_METHOD_MAP = new HashMap<>();
public static final Logger logger = Util.getLogger();
static {
try {
Class<ConditionTargetProcess> valueRuleMethodClass = ConditionTargetProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
TARGET_MODE_METHOD_MAP.put(value, (whereParam,param,whereSql) -> {
try {
return (String) method.invoke(null,whereParam,param,whereSql);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ConditionTargetProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 0, desc = "等于")
public static String equals(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" = #{whereParam."+targetFieldName+"}";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 1, desc = "不等于")
public static String noEquals(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" <> #{whereParam."+targetFieldName+"}";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 6, desc = "in")
public static String in(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" in ( $t{whereParam."+targetFieldName+"})";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 7, desc = "not in")
public static String notIn(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" not in ( $t{whereParam."+targetFieldName+"})";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 8, desc = "自定义sql")
public static String cusSql(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetStr = " and "+Util.sbc2dbcCase(conditionValue);
whereSql += targetStr;
return whereSql;
}
}

View File

@ -0,0 +1,98 @@
package weaver.bokang.xiao.common.model_update.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import org.apache.log4j.Logger;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
/**
* @ClassName ConditionValueProcess
* @Author
* @Date 2023/4/4 16:19
* @Description <h1></h1>
**/
public class ConditionValueProcess {
public static final Map<Integer, BiFunction<String,String, Boolean>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
public static final Logger logger = Util.getLogger();
static {
try {
Class<ConditionValueProcess> valueRuleMethodClass = ConditionValueProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (sourceValue, conditionValue) -> {
try {
return (Boolean) method.invoke(null,sourceValue, conditionValue);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ConditionValueProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param sourceValue
* @param value
* @return
*/
@MethodRuleNo(value = 0, desc = "等于")
public static boolean equals(String sourceValue, String value) {
return sourceValue.equals(value);
}
/**
* <h2></h2>
* @param sourceValue
* @param value
* @return
*/
@MethodRuleNo(value = 1, desc = "不等于")
public static boolean noEquals(String sourceValue, String value) {
return !sourceValue.equals(value);
}
/**
* <h2></h2>
* @param sourceValue
* @param value
* @return
*/
@MethodRuleNo(value = 6, desc = "in")
public static boolean in(String sourceValue, String value) {
if("".equals(sourceValue) || "".equals(value)){
return false;
}
String tempStr = ","+value+",";
sourceValue = "," + sourceValue + ",";
return tempStr.contains(sourceValue);
}
/**
* <h2></h2>
* @param sourceValue
* @param value
* @return
*/
@MethodRuleNo(value = 7, desc = "not in")
public static boolean notIn(String sourceValue, String value) {
return !in(sourceValue, value);
}
}

View File

@ -0,0 +1,130 @@
package weaver.bokang.xiao.common.model_update.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.model_update.function.ConditionFunction;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName ConditionWhereProcess
* @Author
* @Date 2023/5/15 14:40
* @Description <h1></h1>
**/
public class ConditionWhereProcess {
public static final Map<Integer, ConditionFunction<String,Map<String,Object>,Map<String,Object>,String>> MODE_METHOD_MAP = new HashMap<>();
public static final Logger logger = Util.getLogger();
static {
try {
Class<ConditionTargetProcess> valueRuleMethodClass = ConditionTargetProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
MODE_METHOD_MAP.put(value, (whereParam,param,whereSql) -> {
try {
return (String) method.invoke(null,whereParam,param,whereSql);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ConditionTargetProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 0, desc = "等于")
public static String equals(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" = #{whereParam."+targetFieldName+"}";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 1, desc = "不等于")
public static String noEquals(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" <> #{whereParam."+targetFieldName+"}";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 6, desc = "in")
public static String in(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" in ( $t{whereParam."+targetFieldName+"})";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 7, desc = "not in")
public static String notIn(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" not in ( $t{whereParam."+targetFieldName+"})";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 8, desc = "自定义sql")
public static String cusSql(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetStr = " and "+Util.sbc2dbcCase(conditionValue);
whereSql += targetStr;
return whereSql;
}
}

View File

@ -0,0 +1,253 @@
package weaver.bokang.xiao.common.model_update.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.model_update.function.ConditionFunction;
import weaver.bokang.xiao.common.model_update.function.CusOperateInterface;
import weaver.bokang.xiao.common.model_update.mapper.UpdateModeMapper;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @ClassName DataTypeProcess
* @Author
* @Date 2023/4/6 13:10
* @Description <h1></h1>
**/
public class DataTypeProcess {
public static final Map<Integer, ConditionFunction<Boolean,Map<String,Object>,Map<String,Object>, Map<String,String>>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class);
public static final Logger logger = Util.getLogger();
static {
try {
Class<DataTypeProcess> valueRuleMethodClass = DataTypeProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (updateParam, whereParam,param) -> {
try {
return (boolean) method.invoke(null,updateParam, whereParam,param);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("DataTypeProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 0, desc = "更新")
public static boolean update(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
String tableName = Util.null2String(param.get("tableName"));
String whereSql = Util.null2String(param.get("whereSql"));
String updateSql = DataTypeProcess.buildUpdateSql(tableName, updateParam);
if(!"".equals(whereSql)){
whereSql = whereSql.replaceFirst(" and "," where ");
}
updateSql = updateSql + whereSql;
logger.info(String.format("updateSql ==> %s updateParam ==> %s whereParam ==> %s",updateSql,updateParam,whereParam));
return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql, updateParam, whereParam);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 1, desc = "插入")
public static boolean insert(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
String tableName = Util.null2String(param.get("tableName"));
String modeId = Util.getModeIdByTableName(tableName);
int dataId = Util.getModeDataId(tableName, Util.getIntValue(modeId), 1);
whereParam.clear();
whereParam.put("id",dataId);
String updateSql = buildUpdateSql(tableName, updateParam);
String whereSql = DataTypeProcess.buildWhereSql(whereParam);
updateSql = updateSql + " " + whereSql;
logger.info(String.format("updateSql ==> %s updateParam ==> %s whereParam ==> %s",updateSql,updateParam,whereParam));
return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql,updateParam,whereParam);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 2,desc = "自定义操作")
public static boolean cusOperate(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
String operatePath = Util.null2String(param.get("operatePath"));
if(StringUtils.isBlank(operatePath)){
throw new CustomerException("操作全路径不能为空");
}
Map<String,String> pathParam = new HashMap<>();
try {
CusOperateInterface cusInterfaceObj = getCusInterfaceObj(operatePath, CusOperateInterface.class, pathParam);
cusInterfaceObj.execute(whereParam,param,pathParam);
}catch (Exception e){
logger.error("自定义处理类执行异常 ==>"+Util.getErrString(e));
throw new CustomerException(e);
}
return true;
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 3,desc = "更新并执行自定义操作")
public static boolean cusAndUpdate(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
return update(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 4,desc = "插入并执行自定义操作")
public static boolean cusAndInsert(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
return insert(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 5,desc = "执行自定义操作并更新")
public static boolean updateAndCus(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
return cusOperate(updateParam,whereParam,param) && update(updateParam,whereParam,param);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 6,desc = "执行自定义操作并插入")
public static boolean insertAndCus(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
return cusOperate(updateParam,whereParam,param) && insert(updateParam,whereParam,param);
}
/**
* <h2>sql</h2>
* @param tableName
* @param updateParam
* @return
*/
public static String buildUpdateSql(String tableName, Map<String, Object> updateParam){
StringBuilder updateBuilder = new StringBuilder("update ");
updateBuilder.append(tableName).append(" set ");
Set<Map.Entry<String, Object>> updateEntries = updateParam.entrySet();
for (Map.Entry<String, Object> updateEntry : updateEntries) {
if("cusSql".equals(updateEntry.getKey())){
updateBuilder.append(updateEntry.getValue());
continue;
}
updateBuilder.append(updateEntry.getKey())
.append(" = ")
.append("#{updateParam.").append(updateEntry.getKey()).append("},");
}
return updateBuilder.substring(0, updateBuilder.length() - 1) + " ";
}
/**
* <h2>sql</h2>
* @param whereParam
* @return
*/
public static String buildWhereSql(Map<String, Object> whereParam){
StringBuilder whereBuilder = new StringBuilder();
Set<Map.Entry<String, Object>> whereEntries = whereParam.entrySet();
for (Map.Entry<String, Object> whereEntry : whereEntries) {
if("cusSql".equals(whereEntry.getKey())){
whereBuilder.append(" and ").append(whereEntry.getValue());
continue;
}
whereBuilder.append(" and ")
.append(whereEntry.getKey())
.append("#{whereParam.").append(whereEntry.getKey()).append("},");
}
String fixStr = whereBuilder.toString();
if(!"".equals(fixStr)){
fixStr = fixStr.replaceFirst(" and "," where ");
}
return fixStr;
}
/**
* <h2></h2>
* @param path
* @param clazz
* @param pathParamMap
* @return
* @param <T>
*/
public static <T> T getCusInterfaceObj(String path, Class<T> clazz, Map<String, String> pathParamMap) {
path = Util.sbc2dbcCase(path);
String[] split = path.split("\\?");
String classPath = split[0];
Class<?> aClass;
try {
aClass = Class.forName(classPath);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("未能找到自定义接口:" + classPath);
}
if (!clazz.isAssignableFrom(aClass)) {
throw new IllegalArgumentException("自定义接口:" + classPath + " 不是"
+ clazz.getName() + "的子类或实现类!");
}
Constructor<?> constructor;
try {
constructor = aClass.getConstructor();
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(classPath + "没有空参构造方法,无法获取构造方法对象!");
}
T o;
try {
o = (T) constructor.newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalArgumentException("无法构造" + classPath + "对象!");
}
pathParamMap.putAll(Util.parseCusInterfacePathParam(path));
return o;
}
}

View File

@ -0,0 +1,106 @@
package weaver.bokang.xiao.common.model_update.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.model_update.entity.AssignmentEntity;
import weaver.bokang.xiao.common.model_update.mapper.UpdateModeMapper;
import weaver.general.TimeUtil;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
/**
* @ClassName ValueSelectProcess
* @Author
* @Date 2023/4/6 12:42
* @Description <h1> - </h1>
**/
public class ValueSelectProcess {
public static final Map<Integer, BiFunction<Map<String,Object>, AssignmentEntity, String>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class);
public static final Logger logger = Util.getLogger();
static {
try {
Class<ValueSelectProcess> valueRuleMethodClass = ValueSelectProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (modeMap, assignment) -> {
try {
return (String) method.invoke(null,modeMap, assignment);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ValueTypeProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 0, desc = "默认值")
public static String defaultValue(Map<String,Object> modeMap, AssignmentEntity assignment) {
return assignment.getCusContext();
}
/**
* <h2></h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 1, desc = "建模字段")
public static String modeField(Map<String,Object> modeMap, AssignmentEntity assignment) {
return Util.null2String(modeMap.get(assignment.getSourceFieldName()));
}
/**
* <h2>sql</h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 2, desc = "自定义sql")
public static String cusSql(Map<String,Object> modeMap, AssignmentEntity assignment) {
String cusSqlStr = Util.null2String(assignment.getCusContext());
cusSqlStr = Util.dbc2sbcCase(cusSqlStr);
if(StringUtils.isBlank(cusSqlStr)){
throw new CustomerException("选择自定义sql时sql字符串不能为空");
}
if(!cusSqlStr.startsWith("select ")){
throw new CustomerException("选择自定义sql时不允许执行除select之外的其他危险操作 ");
}
return UPDATE_MODE_MAPPER.executeCusSql(cusSqlStr, modeMap,new HashMap<>());
}
/**
* <h2></h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 3, desc = "当前时间")
public static String currentTime(Map<String,Object> modeMap, AssignmentEntity assignment) {
return TimeUtil.getCurrentTimeString();
}
}

View File

@ -0,0 +1,106 @@
package weaver.bokang.xiao.common.model_update.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.model_update.entity.ConditionEntity;
import weaver.bokang.xiao.common.model_update.mapper.UpdateModeMapper;
import weaver.general.TimeUtil;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
/**
* @ClassName ValueTypeProcess
* @Author
* @Date 2023/4/4 16:18
* @Description <h1> - </h1>
**/
public class ValueTypeProcess {
public static final Map<Integer,BiFunction<Map<String,Object>, ConditionEntity, String>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class);
public static final Logger logger = Util.getLogger();
static {
try {
Class<ValueTypeProcess> valueRuleMethodClass = ValueTypeProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (modeMap, condition) -> {
try {
return (String) method.invoke(null,modeMap, condition);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ValueTypeProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 0, desc = "默认值")
public static String defaultValue(Map<String,Object> modeMap, ConditionEntity condition) {
return condition.getCusText();
}
/**
* <h2></h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 1, desc = "建模字段")
public static String modeField(Map<String,Object> modeMap, ConditionEntity condition) {
return Util.null2String(modeMap.get(condition.getConditionSourceFieldName()));
}
/**
* <h2>sql</h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 2, desc = "自定义sql")
public static String cusSql(Map<String,Object> modeMap, ConditionEntity condition) {
String cusSqlStr = Util.null2String(condition.getCusText());
cusSqlStr = Util.dbc2sbcCase(cusSqlStr);
if(StringUtils.isBlank(cusSqlStr)){
throw new CustomerException("选择自定义sql时sql字符串不能为空");
}
if(!cusSqlStr.startsWith("select ")){
throw new CustomerException("选择自定义sql时不允许执行除select之外的其他危险操作 ");
}
return UPDATE_MODE_MAPPER.executeCusSql(cusSqlStr, modeMap,new HashMap<>());
}
/**
* <h2></h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 3, desc = "当前时间")
public static String currentTime(Map<String,Object> modeMap, ConditionEntity condition) {
return TimeUtil.getCurrentTimeString();
}
}

View File

@ -0,0 +1,248 @@
package weaver.bokang.xiao.common.model_update.service;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.model_update.entity.AssignmentEntity;
import weaver.bokang.xiao.common.model_update.entity.ConditionEntity;
import weaver.bokang.xiao.common.model_update.entity.UpdateModeConf;
import weaver.bokang.xiao.common.model_update.function.ConditionFunction;
import weaver.bokang.xiao.common.model_update.mapper.UpdateModeMapper;
import weaver.bokang.xiao.common.model_update.process.*;
import weaver.bokang.xiao.common.model_update.store.TableNameStore;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
/**
* @ClassName ModeChangeService
* @Author
* @Date 2023/4/6 11:28
* @Description <h1></h1>
**/
public class ModeChangeService {
public final Logger logger = Util.getLogger();
private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class);
/**
* <h2></h2>
* @param modeMap
* @param formId id
* @param triggerType 0:; 1:; 2:
*/
public void changeOtherMode(Map<String,Object> modeMap, String formId,int triggerType){
Map<String, List<UpdateModeConf>> triggerStore = TableNameStore.getInstance().getTriggerStore();
List<UpdateModeConf> updateModeConfList = triggerStore.get(formId);
if(Objects.isNull(updateModeConfList) || updateModeConfList.isEmpty()){
logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId));
return;
}
List<UpdateModeConf> collect = updateModeConfList.stream().filter(item -> item.getNoRule() == triggerType).collect(Collectors.toList());
if(collect.isEmpty()){
logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId));
return;
}
doChange(modeMap,collect);
}
/**
* <h2></h2>
* @param formId ID
*/
public void changeOtherMode(String formId){
Map<String, List<UpdateModeConf>> triggerStore = TableNameStore.getInstance().getTriggerStore();
List<UpdateModeConf> updateModeConfList = triggerStore.get(formId);
if(Objects.isNull(updateModeConfList) || updateModeConfList.isEmpty()){
logger.error(String.format("此建模[%s] 未配置相关更新信息,请检查!!!",formId));
return;
}
doChange(updateModeConfList);
}
/**
* <h2></h2>
* @param updateModeConfList
*/
private void doChange(List<UpdateModeConf> updateModeConfList){
for (UpdateModeConf updateModeConf : updateModeConfList) {
List<ConditionEntity> conditionList = updateModeConf.getConditionList();
Integer noRule = updateModeConf.getNoRule();
String sourceTableName = updateModeConf.getSourceTableName();
if(noRule == 1 && conditionList.isEmpty()){
logger.error(String.format("没有条件设置,不允许建模 %s 更新",updateModeConf.getTargetTableName()));
continue;
}
logger.info(String.format("处理配置 deal config [%s - %s]",updateModeConf.getUniqueCode(),updateModeConf.getDescription()));
if(Objects.nonNull(conditionList) && !conditionList.isEmpty()){
//条件数据
Map<String,Object> whereParam = new HashMap<>(8);
Map<Integer, List<ConditionEntity>> collect = conditionList.stream().collect(Collectors.groupingBy(ConditionEntity::getConditionType));
//获取源建模数据判断条件配置列表
List<ConditionEntity> sourceConditions = collect.get(0);
//获取目标建模条件生成配置列表
List<ConditionEntity> targetConditions = collect.get(1);
//生成查询sql
if(Objects.nonNull(sourceConditions) && !sourceConditions.isEmpty()) {
String whereSql = getWhereSql(new HashMap<>(), sourceConditions, whereParam);
String querySql = "select * from " + sourceTableName + whereSql;
List<Map<String, Object>> modeDataList = updateModeMapper.executeCusSqlList(querySql, whereParam, new HashMap<>());
if(Objects.nonNull(modeDataList) && !modeDataList.isEmpty()){
for (Map<String, Object> modeMap : modeDataList) {
updateOtherModel(modeMap,updateModeConf,targetConditions);
}
}
}
}
}
}
/**
* <h2></h2>
* @param modeMap
* @param updateModeConf
* @param targetConditions
*/
private void updateOtherModel(Map<String,Object> modeMap,UpdateModeConf updateModeConf,List<ConditionEntity> targetConditions){
List<AssignmentEntity> assignmentList = updateModeConf.getAssignmentList();
Integer dataInType = updateModeConf.getDataInType();
//赋值数据
Map<String,Object> assignmentMap = new HashMap<>(8);
//条件sql
String whereSql = "";
//条件数据
Map<String,Object> whereParam = new HashMap<>(8);
//根据赋值配置组装数据
if(Objects.nonNull(assignmentList) && !assignmentList.isEmpty()){
//根据配置信息生成条件sql
if(Objects.nonNull(targetConditions) && !targetConditions.isEmpty()) {
getWhereSql(modeMap,targetConditions,whereParam);
}
for (AssignmentEntity assignmentEntity : assignmentList) {
BiFunction<Map<String, Object>, AssignmentEntity, String> valueFunction = ValueSelectProcess.SOURCE_MODE_METHOD_MAP.get(assignmentEntity.getValueSelect());
String assignmentValue = valueFunction.apply(modeMap, assignmentEntity);
assignmentMap.put(assignmentEntity.getAssignmentFieldName(),assignmentValue);
}
//执行数据操作
ConditionFunction<Boolean, Map<String, Object>, Map<String, Object>, Map<String,String>> dataInFunction = DataTypeProcess.SOURCE_MODE_METHOD_MAP.get(dataInType);
Map<String,String> tableMap = new HashMap<>(8);
tableMap.put("tableName",updateModeConf.getTargetTableName());
tableMap.put("whereSql",whereSql);
tableMap.put("operatePath",updateModeConf.getOperatePath());
boolean executeFlag = dataInFunction.apply(assignmentMap, whereParam, tableMap);
logger.info("更新结果 executeFlag ==>"+executeFlag);
}
}
/**
* <h2>sql</h2>
* @param modeMap
* @param conditions
* @param whereParam
* @return whereSql
*/
private String getWhereSql(Map<String,Object> modeMap,List<ConditionEntity> conditions,Map<String,Object> whereParam){
//条件sql
String whereSql = "";
for (ConditionEntity targetCondition : conditions) {
BiFunction<Map<String, Object>, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(targetCondition.getValueType());
ConditionFunction<String, Map<String, Object>, Map<String, Object>, String> conditionFunction = ConditionTargetProcess.TARGET_MODE_METHOD_MAP.get(targetCondition.getConditionValue());
String sourceValue = Util.null2String(modeMap.get(targetCondition.getConditionSourceFieldName()));
String conditionValue = valueFunction.apply(modeMap, targetCondition);
Map<String, Object> param = new HashMap<>(8);
param.put("sourceValue", sourceValue);
param.put("conditionValue", conditionValue);
param.put("targetFieldName", targetCondition.getConditionTargetFieldName());
whereSql = conditionFunction.apply(whereParam, param, whereSql);
}
return whereSql;
}
/**
* <h2></h2>
* @param modeMap
* @param updateModeConfList
*/
private void doChange(Map<String,Object> modeMap,List<UpdateModeConf> updateModeConfList){
for (UpdateModeConf updateModeConf : updateModeConfList) {
List<ConditionEntity> conditionList = updateModeConf.getConditionList();
List<AssignmentEntity> assignmentList = updateModeConf.getAssignmentList();
Integer dataInType = updateModeConf.getDataInType();
Integer noRule = updateModeConf.getNoRule();
if(noRule == 1 && conditionList.isEmpty()){
logger.error(String.format("没有条件设置,不允许建模 %s 更新",updateModeConf.getTargetTableName()));
continue;
}
logger.info(String.format("处理配置 deal config [%s - %s]",updateModeConf.getUniqueCode(),updateModeConf.getDescription()));
//条件sql
String whereSql = "";
//条件数据
Map<String,Object> whereParam = new HashMap<>(8);
//赋值数据
Map<String,Object> assignmentMap = new HashMap<>(8);
if(Objects.nonNull(conditionList) && !conditionList.isEmpty()){
Map<Integer, List<ConditionEntity>> collect = conditionList.stream().collect(Collectors.groupingBy(ConditionEntity::getConditionType));
//获取源建模数据判断条件配置列表
List<ConditionEntity> sourceConditions = collect.get(0);
//获取目标建模条件生成配置列表
List<ConditionEntity> targetConditions = collect.get(1);
boolean flag = false;
//判断源建模数据是否需要触发更新
if(Objects.nonNull(sourceConditions) && !sourceConditions.isEmpty()) {
for (ConditionEntity sourceCondition : sourceConditions) {
BiFunction<Map<String, Object>, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getValueType());
BiFunction<String, String, Boolean> conditionFunction = ConditionValueProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getConditionValue());
String sourceValue = Util.null2String(modeMap.get(sourceCondition.getConditionSourceFieldName()));
String conditionValue = valueFunction.apply(modeMap, sourceCondition);
Boolean result = conditionFunction.apply(sourceValue, conditionValue);
if (!result) {
flag = true;
break;
}
}
if (flag) {
logger.info("源建模条件判断不通过,此条数据跳过 sourceMode condition fail !!! "+JSON.toJSONString(modeMap));
continue;
}
}
//根据配置信息生成条件sql
if(Objects.nonNull(targetConditions) && !targetConditions.isEmpty()) {
for (ConditionEntity targetCondition : targetConditions) {
BiFunction<Map<String, Object>, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(targetCondition.getValueType());
ConditionFunction<String, Map<String, Object>, Map<String, Object>, String> conditionFunction = ConditionTargetProcess.TARGET_MODE_METHOD_MAP.get(targetCondition.getConditionValue());
String sourceValue = Util.null2String(modeMap.get(targetCondition.getConditionSourceFieldName()));
String conditionValue = valueFunction.apply(modeMap, targetCondition);
Map<String, Object> param = new HashMap<>(8);
param.put("sourceValue", sourceValue);
param.put("conditionValue", conditionValue);
param.put("targetFieldName", targetCondition.getConditionTargetFieldName());
whereSql = conditionFunction.apply(whereParam, param, whereSql);
}
}
}
//根据赋值配置组装数据
if(Objects.nonNull(assignmentList) && !assignmentList.isEmpty()){
for (AssignmentEntity assignmentEntity : assignmentList) {
BiFunction<Map<String, Object>, AssignmentEntity, String> valueFunction = ValueSelectProcess.SOURCE_MODE_METHOD_MAP.get(assignmentEntity.getValueSelect());
String assignmentValue = valueFunction.apply(modeMap, assignmentEntity);
assignmentMap.put(assignmentEntity.getAssignmentFieldName(),assignmentValue);
}
}
//执行数据操作
ConditionFunction<Boolean, Map<String, Object>, Map<String, Object>, Map<String,String>> dataInFunction = DataTypeProcess.SOURCE_MODE_METHOD_MAP.get(dataInType);
Map<String,String> tableMap = new HashMap<>(8);
tableMap.put("tableName",updateModeConf.getTargetTableName());
tableMap.put("whereSql",whereSql);
tableMap.put("operatePath",updateModeConf.getOperatePath());
boolean executeFlag = dataInFunction.apply(assignmentMap, whereParam, tableMap);
logger.info("更新结果 executeFlag ==>"+executeFlag);
}
}
}

View File

@ -0,0 +1,68 @@
package weaver.bokang.xiao.common.model_update.store;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.model_update.entity.UpdateModeConf;
import weaver.bokang.xiao.common.model_update.mapper.UpdateModeMapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @ClassName VendorStore
* @Author
* @Date 2023/3/17 18:31
* @Description <h1></h1>
**/
@Getter
public class TableNameStore {
private final Map<String,String> tableNameStore = new HashMap<>();
private final Map<String,List<UpdateModeConf>> triggerStore = new HashMap<>();
private final Map<String,List<UpdateModeConf>> uniqueTriggerStore = new HashMap<>();
private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class);
private static final Logger logger = Util.getLogger();
private TableNameStore(){init();}
private void init(){
try {
triggerStore.clear();
List<UpdateModeConf> updateModeConfList = updateModeMapper.queryUpdateModeConf();
if (Objects.nonNull(updateModeConfList) && !updateModeConfList.isEmpty()) {
Map<String, List<UpdateModeConf>> collect = updateModeConfList.stream().collect(Collectors.groupingBy(UpdateModeConf::getSourceMode));
Map<String, List<UpdateModeConf>> configMap = updateModeConfList.stream().collect(Collectors.groupingBy(UpdateModeConf::getUniqueCode));
triggerStore.putAll(collect);
uniqueTriggerStore.putAll(configMap);
}
logger.info(String.format("TableNameStore init success!!! triggerStore:%s \n uniqueTriggerStore: %s", JSON.toJSONString(triggerStore), JSON.toJSONString(uniqueTriggerStore)));
}catch (Exception e){
logger.error("TableNameStore init error "+Util.getErrString(e));
}
}
public void refresh(){
this.init();
}
public static TableNameStore getInstance(){
return VendorStoreHolder.VENDOR_STORE;
}
private static class VendorStoreHolder{
private VendorStoreHolder(){
}
private static final TableNameStore VENDOR_STORE = new TableNameStore();
}
}

View File

@ -42,8 +42,8 @@ public class RepeatCheckAction extends SafeCusBaseAction {
private final RepeatCheckMapper repeatCheckMapper = Util.getMapper(RepeatCheckMapper.class); private final RepeatCheckMapper repeatCheckMapper = Util.getMapper(RepeatCheckMapper.class);
@Override @Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo)
log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); {log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId));
Map<String, String> mainTable = this.getMainTableValue(requestInfo); Map<String, String> mainTable = this.getMainTableValue(requestInfo);
String workflowNum = Util.null2String(mainTable.get(workflowNumField)); String workflowNum = Util.null2String(mainTable.get(workflowNumField));
int workflowCount = repeatCheckMapper.getWorkflowCount(billTable,workflowNumField,requestId, workflowNum); int workflowCount = repeatCheckMapper.getWorkflowCount(billTable,workflowNumField,requestId, workflowNum);

View File

@ -0,0 +1,84 @@
package weaver.bokang.xiao.porsche.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSON;
import lombok.Setter;
import weaver.bokang.xiao.common.CommonUtil;
import weaver.bokang.xiao.common.mapper.WorkflowMapper;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @ClassName DateFieldUpdateAction
* @Author
* @Date 2023/5/11 14:46
* @Description <h1></h1>
**/
@Setter
@ActionDesc(value = "时间自定义格式化",author = "bokang.xiao")
public class DateFieldUpdateAction extends SafeCusBaseAction {
@RequiredMark("原时间字段集合")
@PrintParamMark
private String sourceDateFields;
@RequiredMark("修改时间字段结合")
@PrintParamMark
private String targetDateFields;
@ActionOptionalParam(value = "MMMM d','yyyy",desc = "时间格式化字符串")
@PrintParamMark
private String formationString = "MMMM d','yyyy";
private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class);
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(), requestId));
Map<String, Object> workflowData = workflowMapper.queryWorkflowByRequestId(requestId, billTable);
String[] sourceDateFieldArray = sourceDateFields.split(",");
String[] targetDateFieldArray = targetDateFields.split(",");
if(sourceDateFieldArray.length != targetDateFieldArray.length){
throw new CustomerException("请确保需要格式化的字段数量与存储字段数量一致");
}
log.info("workflowData ==>"+ JSON.toJSONString(workflowData));
Map<String,Object> dateFormat = new HashMap<>();
for (int i = 0; i < sourceDateFieldArray.length; i++) {
String sourceDateField = sourceDateFieldArray[i];
String targetDateField = targetDateFieldArray[i];
String sourceDate = Util.null2String(workflowData.get(sourceDateField));
String targetDate = formatDate(sourceDate);
log.info(String.format("sourceDateField:[%s],targetDateField:[%s],sourceDate:[%s],targetDate:[%s]",sourceDateField,targetDateField,sourceDate,targetDate));
dateFormat.put(targetDateField,targetDate);
}
Map<String,Object> whereParam = new HashMap<>();
whereParam.put("requestid",requestId);
String updateSql = CommonUtil.getCusUpdateSql(billTable, dateFormat, whereParam);
log.info("DateFieldUpdateAction updateSql ==>"+updateSql+" updateParam =>"+dateFormat+" whereParam =>"+whereParam);
boolean flag = workflowMapper.executeUpdateCusSql(updateSql, dateFormat, whereParam);
log.info("更新格式化日期结果 ==>"+flag);
}
private String formatDate(String dateStr){
try {
SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat targetFormat = new SimpleDateFormat(formationString, Locale.US);
Date parse = sourceFormat.parse(dateStr);
return targetFormat.format(parse);
}catch (ParseException parseException){
log.error("时间格式化异常 format error!!!"+Util.getErrString(parseException));
return "";
}
}
}

View File

@ -0,0 +1,24 @@
package weaver.bokang.xiao.porsche.mapper;
import aiyh.utils.annotation.recordset.*;
import java.util.List;
import java.util.Map;
/**
* @ClassName PorscheMapper
* @Author
* @Date 2023/5/9 17:56
* @Description <h1></h1>
**/
@SqlMapper
public interface PorscheMapper {
@Select("select * from uf_zcgsxx where $t{statusField} = 0")
List<Map<String,Object>> queryCompanyInfo(@ParamMapper("statusField")String statusField);
@Update("update uf_zcgsxx set sfrz = #{authenticationStatus},fadadaid = #{contractId} where id = #{dataId}")
boolean updateAuthenticationStatus(@ParamMapper("authenticationStatus")String authenticationStatus,
@ParamMapper("contractId")String contractId,
@ParamMapper("dataId")int dataId);
}

View File

@ -0,0 +1,69 @@
package weaver.bokang.xiao.porsche.schedule;
import aiyh.utils.Util;
import aiyh.utils.action.CusBaseCronJob;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.httpUtil.ResponeVo;
import lombok.Data;
import lombok.Setter;
import weaver.aiyh_pcn.common_fadada.util.FaRequestUtils;
import weaver.bokang.xiao.porsche.mapper.PorscheMapper;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @ClassName CompanyWriteBackSchedule
* @Author
* @Date 2023/5/9 17:50
* @Description <h1></h1>
**/
@Setter
@ActionDesc(value = "公司认证信息同步", author = "bokang.xiao")
public class CompanyWriteBackSchedule extends CusBaseCronJob {
@RequiredMark("请求唯一标识")
@PrintParamMark
private String requestMark;
@RequiredMark("状态字段名")
@PrintParamMark
private String statusField;
private final DealWithMapping dealWithMapping = new DealWithMapping();
private final PorscheMapper porscheMapper = Util.getMapper(PorscheMapper.class);
@Override
public void runCode() throws IOException {
log.info("======= CompanyWriteBackSchedule execute ======");
List<Map<String,Object>> maps = porscheMapper.queryCompanyInfo(statusField);
if(Objects.nonNull(maps) && !maps.isEmpty()){
log.info("company list info ==>"+maps.size());
for (Map<String, Object> map : maps) {
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(requestMark);
Map<String,Object> requestParam = dealWithMapping.getRequestParam(map, requestMappingConfig);
ResponeVo responeVo = FaRequestUtils.companyAuthentication(requestParam, requestMappingConfig.getRequestUrl());
if(responeVo.getCode() == 200){
Map<String,Object> result = responeVo.getResponseMap();
String code = Util.null2String(result.get("code"));
if("200".equals(code)){
List<Map<String,Object>> data = (List<Map<String, Object>>) result.get("data");
Map<String, Object> companyInfo = data.get(0);
Map<String,Object> certificationStatusResource = (Map<String, Object>) companyInfo.get("certificationStatusResource");
int dataId = Util.getIntValue(String.valueOf(map.get("id")));
String authenticationStatus = Util.null2String(certificationStatusResource.get("verifiedStatus"));
String companyNo = Util.null2String(companyInfo.get("companyNo"));
porscheMapper.updateAuthenticationStatus(authenticationStatus,companyNo,dataId);
}
}
}
}
}
}

View File

@ -0,0 +1,32 @@
package weaver.bokang.xiao.porsche.schedule;
import aiyh.utils.action.CusBaseCronJob;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import lombok.Setter;
import weaver.bokang.xiao.common.model_update.service.ModeChangeService;
import java.io.IOException;
/**
* @ClassName SalaryUpdateSchedule
* @Author
* @Date 2023/5/11 17:59
* @Description <h1></h1>
**/
@Setter
@ActionDesc(value = "定时更新薪酬信息", author = "bokang.xiao")
public class SalaryUpdateSchedule extends CusBaseCronJob {
@RequiredMark("原建模表单ID")
@PrintParamMark
private String formId;
private final ModeChangeService modeChangeService = new ModeChangeService();
@Override
public void runCode() throws IOException {
modeChangeService.changeOtherMode(formId);
}
}

View File

@ -0,0 +1,62 @@
package weaver.bokang.xiao.sh_bigdata.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import com.alibaba.fastjson.JSON;
import lombok.Setter;
import weaver.bokang.xiao.common.mapper.WorkflowMapper;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping;
import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess;
import weaver.xuanran.wang.sh_bigdata.common.util.RequestMasterPlate;
import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName DataPushAction
* @Author
* @Date 2023/5/12 10:30
* @Description <h1></h1>
**/
@Setter
@ActionDesc(value = "数据采集对接-数据推送action",author = "bokang.xiao")
public class DataPushAction extends SafeCusBaseAction {
/** 数据推送接口唯一标识 */
@PrintParamMark
@RequiredMark(value = "",desc = "数据推送接口唯一标识")
private String requestUnique;
private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class);
private final DealWithMapping dealWithMapping = new DealWithMapping();
private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate();
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId));
Map<String, Object> workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable);
dealWithMapping.setMainTable(billTable);
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(requestUnique);
Map<String, Object> requestParam = dealWithMapping.getRequestParam(workflowMessage, requestMappingConfig);
Map<String,String> header = new HashMap<>();
header.put("Content-Type","application/json");
CusSuccess cusSuccess = CusSuccess.builder()
.successField("code")
.successValue(0)
.errorMsg("msg")
.dataKey("data.data")
.build();
Map<String,Object> result = requestMasterPlate.apiPost(ShBigDataUtil.addToken2Url(requestMappingConfig.getRequestUrl()), requestParam, header, cusSuccess);
log.info("DataPushAction push data result ==>"+ JSON.toJSONString(result));
}
}

View File

@ -26,8 +26,7 @@ import java.util.stream.Collectors;
* @Date 2023/3/17 19:58 * @Date 2023/3/17 19:58
* @Description <h1></h1> * @Description <h1></h1>
**/ **/
@Data
@ActionDesc(value = "生成报表信息", author = "bokang.xiao")
public class GenerateReportSchedule extends CusBaseCronJob { public class GenerateReportSchedule extends CusBaseCronJob {

View File

@ -33,7 +33,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* @ClassName OneNetcomAction * @ClassName OneNetComAction
* @Author * @Author
* @Date 2023/3/27 14:04 * @Date 2023/3/27 14:04
* @Description <h1>action</h1> * @Description <h1>action</h1>
@ -71,6 +71,9 @@ public class OneNetComAction extends SafeCusBaseAction {
@ActionOptionalParam(value = "",desc = "网关调用办理接口的apiId") @ActionOptionalParam(value = "",desc = "网关调用办理接口的apiId")
private String handleApiName; private String handleApiName;
@ActionOptionalParam(value = "已办结办件不允许修改",desc = "错误信息不阻止流程")
private String continueError = "已办结办件不允许修改";
private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class);
private final DealWithMapping dealWithMapping = new DealWithMapping(); private final DealWithMapping dealWithMapping = new DealWithMapping();
@ -82,8 +85,10 @@ public class OneNetComAction extends SafeCusBaseAction {
@Override @Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId));
Map<String, Object> workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable); //Map<String, Object> workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable);
Map<String, Object> workflowMessage = this.getObjMainTableValue(requestInfo);
dealWithMapping.setMainTable(billTable); dealWithMapping.setMainTable(billTable);
log.info("workflowMessage ==>"+JSON.toJSONString(workflowMessage));
try{ try{
if(StringUtils.isNotBlank(acceptUnique) && StringUtils.isNotBlank(acceptApiName)) { if(StringUtils.isNotBlank(acceptUnique) && StringUtils.isNotBlank(acceptApiName)) {
requestHandle(workflowMessage,acceptUnique,acceptApiName,requestId,billTable,"受理请求"); requestHandle(workflowMessage,acceptUnique,acceptApiName,requestId,billTable,"受理请求");
@ -128,6 +133,10 @@ public class OneNetComAction extends SafeCusBaseAction {
whereParam.put("requestid",requestId); whereParam.put("requestid",requestId);
sqlUtil.updateMode(billTable, updateMsg, whereParam); sqlUtil.updateMode(billTable, updateMsg, whereParam);
}else { }else {
if(continueError.equals(message)){
log.info("The error message for this request is related to whitelist content and will not block the submission of the action message:"+message );
return;
}
throw new CustomerException(desc+"请求失败 ==>"+message); throw new CustomerException(desc+"请求失败 ==>"+message);
} }
}else { }else {

View File

@ -76,7 +76,9 @@ public interface UpdateModeMapper {
* @return * @return
*/ */
@Select(custom = true) @Select(custom = true)
Map<String,Object> executeCusSqlMap(@SqlString String cusSql, @ParamMapper("whereParam")Map<String,Object> whereParam,@ParamMapper("cusParam")Map<String,Object> cusParam); Map<String,Object> executeCusSqlMap(@SqlString String cusSql,
@ParamMapper("whereParam")Map<String,Object> whereParam,
@ParamMapper("cusParam")Map<String,Object> cusParam);
/** /**
* <h2>sql</h2> * <h2>sql</h2>
@ -86,6 +88,8 @@ public interface UpdateModeMapper {
* @return * @return
*/ */
@Update(custom = true) @Update(custom = true)
boolean executeUpdateCusSql(@SqlString String cusSql, @ParamMapper("updateParam")Map<String,Object> updateParam,@ParamMapper("whereParam")Map<String,Object> whereParam); boolean executeUpdateCusSql(@SqlString String cusSql,
@ParamMapper("updateParam")Map<String,Object> updateParam,
@ParamMapper("whereParam")Map<String,Object> whereParam);
} }

View File

@ -125,7 +125,7 @@ public class DataTypeProcess {
* @param param * @param param
* @return * @return
*/ */
@MethodRuleNo(value = 3,desc = "插入并执行自定义操作") @MethodRuleNo(value = 3,desc = "更新并执行自定义操作")
public static boolean cusAndUpdate(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) { public static boolean cusAndUpdate(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
return update(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param); return update(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param);
} }

View File

@ -0,0 +1,42 @@
package weaver.bokang.xiao.zscq.fun;
import aiyh.utils.Util;
import weaver.bokang.xiao.zscq.config.function.CusOperateInterface;
import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper;
import weaver.bokang.xiao.zscq.mapper.StatusMapper;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* @ClassName OdocUpdate
* @Author
* @Date 2023/5/9 15:24
* @Description <h1></h1>
**/
public class ODocUpdate implements CusOperateInterface {
private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class);
private final StatusMapper statusMapper = Util.getMapper(StatusMapper.class);
@Override
public void execute(Map<String, Object> whereParam, Map<String, String> param, Map<String, String> pathParam) {
logger.info("==== ODocUpdate 自定义处理 ==== ");
String tableName = Util.null2String(param.get("tableName"));
String numField = Util.null2String(pathParam.get("numField"));
String querySql = "select * from " + tableName +" where "+ numField +"= #{whereParam."+numField+"}";
Map<String, Object> modeData = updateModeMapper.executeCusSqlMap(querySql, whereParam,new HashMap<>());
logger.info("modeData ==>"+modeData);
if(Objects.nonNull(modeData)){
String oDocRequestField = Util.null2String(pathParam.get("oDocRequestField"));
String oDocTextField = Util.null2String(pathParam.get("oDocTextField"));
String workflowTextField = Util.null2String(pathParam.get("workflowTextField"));
String requestId = Util.null2String(modeData.get("requestid"));
String workflowText = Util.null2String(modeData.get(workflowTextField));
boolean flag = statusMapper.updateODocField(oDocTextField, workflowText, oDocRequestField, requestId);
logger.info("更新odoc表数据结果 ==>"+flag);
}
}
}

View File

@ -26,7 +26,7 @@ public class WorkflowOverOperate implements CusOperateInterface {
@Override @Override
public void execute(Map<String, Object> whereParam, Map<String, String> param, Map<String, String> pathParam) { public void execute(Map<String, Object> whereParam, Map<String, String> param, Map<String, String> pathParam) {
logger.info(String.format("WorkflowOverOperate 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam)); logger.info("===== WorkflowOverOperate 自定义处理 ===== ");
String tableName = Util.null2String(param.get("tableName")); String tableName = Util.null2String(param.get("tableName"));
String whereSql = Util.null2String(param.get("whereSql")); String whereSql = Util.null2String(param.get("whereSql"));
if(!"".equals(whereSql)){ if(!"".equals(whereSql)){

View File

@ -29,7 +29,7 @@ public class WorkflowRepossessedSign implements CusOperateInterface {
@Override @Override
public void execute(Map<String, Object> whereParam, Map<String, String> param, Map<String, String> pathParam) { public void execute(Map<String, Object> whereParam, Map<String, String> param, Map<String, String> pathParam) {
logger.info(String.format("WorkflowRepossessedSign 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam)); logger.info("==== WorkflowRepossessedSign 自定义处理 ====");
String tableName = Util.null2String(param.get("tableName")); String tableName = Util.null2String(param.get("tableName"));
String whereSql = Util.null2String(param.get("whereSql")); String whereSql = Util.null2String(param.get("whereSql"));
if(!"".equals(whereSql)){ if(!"".equals(whereSql)){

View File

@ -32,4 +32,10 @@ public interface StatusMapper {
@Select("select currentnodetype from workflow_requestbase where requestid = #{requestId}") @Select("select currentnodetype from workflow_requestbase where requestid = #{requestId}")
int queryWorkflowStatus(@ParamMapper("requestId")String requestId); int queryWorkflowStatus(@ParamMapper("requestId")String requestId);
@Update("update odoc_requestdoc set $t{fieldName} = #{fieldValue} where $t{oDocRequestField} = #{requestId}")
boolean updateODocField(@ParamMapper("fieldName")String fieldName,
@ParamMapper("fieldValue")String fieldValue,
@ParamMapper("oDocRequestField")String oDocRequestField,
@ParamMapper("requestId")String requestId);
} }

View File

@ -680,6 +680,12 @@ public class DealWithMapping extends ToolUtil {
} }
} }
} }
// 自定义sql用{mainTable}代替当前表名 解决极兔ncc问题
if(StringUtils.isNotBlank(mainTable)){
valueContext = valueContext.replace("{mainTable}", mainTable);
}else {
logger.error("mainTable is null!");
}
String requestId = Util.null2String(mainMap.get("requestid")); String requestId = Util.null2String(mainMap.get("requestid"));
tempValue = "'" + tempValue + "'"; tempValue = "'" + tempValue + "'";
value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId); value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId);
@ -1028,6 +1034,12 @@ public class DealWithMapping extends ToolUtil {
tempValue = Util.null2String(tempRs.getString(fieldName)); tempValue = Util.null2String(tempRs.getString(fieldName));
} }
} }
// 自定义sql用{mainTable}代替当前表名 解决极兔ncc问题
if(StringUtils.isNotBlank(mainTable)){
valueContext = valueContext.replace("{mainTable}", mainTable);
}else {
logger.error("mainTable is null!");
}
tempValue = "'" + tempValue + "'"; tempValue = "'" + tempValue + "'";
value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId); value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId);
} }

View File

@ -1,17 +1,14 @@
package weaver.xuanran.wang.eighty_five_degreec.sap.action; package weaver.xuanran.wang.eighty_five_degreec.sap.action;
import aiyh.utils.ThreadPoolConfig;
import aiyh.utils.action.SafeCusBaseAction; import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc; import aiyh.utils.annotation.*;
import aiyh.utils.annotation.PrintParamMark; import aiyh.utils.excention.CustomerException;
import aiyh.utils.annotation.RequiredMark;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo; import weaver.soa.workflow.request.RequestInfo;
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService; import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl; import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl;
import java.util.concurrent.ExecutorService;
/** /**
* <h1>sap</h1> * <h1>sap</h1>
@ -23,31 +20,53 @@ import java.util.concurrent.ExecutorService;
public class WorkflowToSap extends SafeCusBaseAction { public class WorkflowToSap extends SafeCusBaseAction {
private final WorkflowToSapService service = new WorkflowToSapServiceImpl(); private final WorkflowToSapService service = new WorkflowToSapServiceImpl();
private final ExecutorService pool = ThreadPoolConfig.createThreadPoolInstance();
@PrintParamMark @PrintParamMark
@RequiredMark("配置表唯一标识") @RequiredMark("配置表唯一标识")
@ActionDefaultTestValue(value = "****")
private String uniqueCode; private String uniqueCode;
@PrintParamMark @PrintParamMark
@RequiredMark("日志表模块id") @RequiredMark("日志表模块id")
@ActionDefaultTestValue(value = "11")
private String modelId; private String modelId;
@PrintParamMark
@RequiredMark("成功失败/标识字段")
@ActionDefaultTestValue(value = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.TYPE")
private String successField;
@PrintParamMark
@RequiredMark("成功时候的值")
@ActionDefaultTestValue(value = "T")
private String successVal;
@PrintParamMark
@RequiredMark("消息提示字段")
@ActionDefaultTestValue(value = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.MESSAGE")
private String messageField;
@Override @Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
String xml = "";
String response = "";
String url = "";
String error = "";
boolean success = true;
try { try {
MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable); MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable);
String xml = service.convertXml(config, requestId, billTable); url = config.getRequestUrl();
String response = service.sendToSap(); xml = service.convertXml(config, requestId, billTable);
pool.execute(()->{ response = service.sendToSap(config.getRequestUrl(), xml);
try { service.parseResponse(response, successField, successVal, messageField);
service.logToOA(modelId, config.getRequestUrl(), requestId, xml, response);
}catch (Exception e){
log.error("日志数据写入建模失败! " + e.getMessage());
}
});
}catch (Exception e){ }catch (Exception e){
log.error("流程数据推送SAP error : " + e.getMessage()); log.error("流程数据推送SAP error : " + e.getMessage());
error = e.getMessage();
success = false;
}
try {
service.logToOA(modelId, url, requestId, xml, response, error);
}catch (Exception e){
log.error("日志数据写入建模失败! " + e.getMessage());
}
if(!success){
throw new CustomerException("WorkflowToSap Action execute error : " + error);
} }
} }
} }

View File

@ -11,6 +11,9 @@ import lombok.Data;
*/ */
@Data @Data
public class DetailRequestConfig { public class DetailRequestConfig {
@SqlDbFieldAnn("nodeType")
@SqlOracleDbFieldAnn("NODETYPE")
private String nodeType;
@SqlDbFieldAnn("paramName") @SqlDbFieldAnn("paramName")
@SqlOracleDbFieldAnn("PARAMNAME") @SqlOracleDbFieldAnn("PARAMNAME")
private String paramName; private String paramName;

View File

@ -11,6 +11,7 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConf
public interface WorkflowToSapService { public interface WorkflowToSapService {
MainRequestConfig getRequestConfig(String uniqueCode, String tableName); MainRequestConfig getRequestConfig(String uniqueCode, String tableName);
String convertXml(MainRequestConfig config, String requestId, String tableName); String convertXml(MainRequestConfig config, String requestId, String tableName);
String sendToSap(); String sendToSap(String url, String xml);
void logToOA(String modelId, String url, String requestId, String requestXml, String response); String parseResponse(String response, String responseField, String successField, String messageField);
void logToOA(String modelId, String url, String requestId, String requestXml, String response, String error);
} }

View File

@ -1,6 +1,11 @@
package weaver.xuanran.wang.eighty_five_degreec.sap.service.impl; package weaver.xuanran.wang.eighty_five_degreec.sap.service.impl;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.json.XML;
import weaver.xuanran.wang.common.util.CusData2OA;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil; import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService; import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
@ -8,6 +13,7 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/** /**
@ -18,7 +24,7 @@ import java.util.HashMap;
*/ */
public class WorkflowToSapServiceImpl implements WorkflowToSapService { public class WorkflowToSapServiceImpl implements WorkflowToSapService {
private final ReadConfigUtil configUtil = new ReadConfigUtil(); private final ReadConfigUtil configUtil = new ReadConfigUtil();
private final Logger log = Util.getLogger();
@Override @Override
public MainRequestConfig getRequestConfig(String uniqueCode, String tableName) { public MainRequestConfig getRequestConfig(String uniqueCode, String tableName) {
return configUtil.getConfigByUniqueCode(uniqueCode, tableName); return configUtil.getConfigByUniqueCode(uniqueCode, tableName);
@ -30,20 +36,40 @@ public class WorkflowToSapServiceImpl implements WorkflowToSapService {
} }
@Override @Override
public String sendToSap() { public String sendToSap(String url, String xml) {
// TODO sap接口调用方式暂时搞不了 return configUtil.callSap(url, xml);
return ""; }
@Override
public String parseResponse(String response, String successField, String successVal, String messageField) {
String responseVal;
JSONObject xmlResponseObj;
try {
xmlResponseObj = XML.toJSONObject(response);
}catch (Exception e){
throw new CustomerException("xml to jsonObj error : " + e.getMessage());
}
Map<String, Object> responseMap = com.alibaba.fastjson.JSONObject.parseObject(xmlResponseObj.toString(), Map.class);
responseVal = configUtil.parseMap(responseMap, successField);
if(!successVal.equals(responseVal)){
throw new CustomerException("successVal not equals responseVal! current responseVal is : "
+ responseVal + ", the successVal is " + successVal + ", responseMsg is " + configUtil.parseMap(responseMap, messageField));
}
return responseVal;
} }
@Override @Override
public void logToOA(String modelId, String url, String requestId, public void logToOA(String modelId, String url, String requestId,
String requestXml, String response) { String requestXml, String response, String error) {
HashMap<String, Object> params = new HashMap<>(); HashMap<String, Object> params = new HashMap<>();
params.put("requestUrlAndFunName", url); params.put("requestUrl", url);
params.put("reqId", requestId); params.put("reqId", requestId);
params.put("requestXml", requestXml); params.put("requestXml", requestXml);
params.put("responseCode",""); params.put("responseCode","");
params.put("erpResponse", response); params.put("sapResponse", response);
CusInfoToOAUtil.getDataId(Util.getIntValue(modelId, -1), params, "select id from #{tableName} where reqId = ?", Collections.singletonList(requestId)); params.put("error", error);
log.info("写入日志参数 : " + com.alibaba.fastjson.JSONObject.toJSONString(params));
CusData2OA.writeToModel(modelId, "select id from #{tableName} where reqId = " + requestId, params);
} }
} }

View File

@ -1,5 +1,6 @@
package weaver.xuanran.wang.eighty_five_degreec.sap.util; package weaver.xuanran.wang.eighty_five_degreec.sap.util;
import aiyh.utils.excention.CustomerException;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -12,11 +13,10 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.DetailRequestCo
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
import weaver.zwl.common.ToolUtil; import weaver.zwl.common.ToolUtil;
import java.io.BufferedReader; import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.text.ParseException; import java.text.ParseException;
@ -55,7 +55,7 @@ public class ReadConfigUtil extends ToolUtil {
} }
int mainId = Util.getIntValue(res.getId()); int mainId = Util.getIntValue(res.getId());
// 配置明细表 // 配置明细表
sql = "select paramName,paramType,parentName,getValueType,workflowField,valueContext,fv.tableName," + sql = "select nodeType,paramName,paramType,parentName,getValueType,workflowField,valueContext,fv.tableName," +
" fv.id fieldId,fv.fieldname,fv.indexdesc " + " fv.id fieldId,fv.fieldname,fv.indexdesc " +
" from uf_memsic_createXml_dt1 config " + " from uf_memsic_createXml_dt1 config " +
" left join workflow_field_table_view fv on config.workflowField = fv.id " + " left join workflow_field_table_view fv on config.workflowField = fv.id " +
@ -88,7 +88,7 @@ public class ReadConfigUtil extends ToolUtil {
* @return * @return
**/ **/
public static <T> T getInstance(RecordSet queryRs, Class<T> clazz) { public static <T> T getInstance(RecordSet queryRs, Class<T> clazz) {
T res = null; T res;
try { try {
res = clazz.newInstance(); res = clazz.newInstance();
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
@ -443,15 +443,35 @@ public class ReadConfigUtil extends ToolUtil {
// 明细 // 明细
String[] detailIdArr = detailIndex.split(","); String[] detailIdArr = detailIndex.split(",");
StringBuilder detailSb = new StringBuilder(); StringBuilder detailSb = new StringBuilder();
for (String detailId : detailIdArr) { for (String detailId : detailIdArr) {
String nodeName;
List<DetailRequestConfig> nodeList = requestConfigList.stream()
.filter(item -> "0".equals(item.getNodeType())).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(nodeList)){
nodeName = nodeList.get(0).getParamName();
} else {
nodeName = "";
}
List<DetailRequestConfig> detailCollect = requestConfigList.stream() List<DetailRequestConfig> detailCollect = requestConfigList.stream()
.filter(item -> "detailRecord".equals(item.getParentName()) .filter(item -> {
).collect(Collectors.toList()); if(StringUtils.isNotBlank(nodeName)){
return nodeName.equals(item.getParentName());
}else {
return "detailRecord".equals(item.getParentName());
}
}).collect(Collectors.toList());
String detailSql = "select * from " + tableName + "_dt" + detailId + " where mainid = ?"; String detailSql = "select * from " + tableName + "_dt" + detailId + " where mainid = ?";
if (detailRs.executeQuery(detailSql, mainId)) { if (detailRs.executeQuery(detailSql, mainId)) {
int count = 1; int count = 1;
while (detailRs.next()) { while (detailRs.next()) {
if(StringUtils.isNotBlank(nodeName)){
detailSb.append("<").append(nodeName).append(">\n");
}
appendXml(detailSb, detailCollect, mainRs, detailRs, count++); appendXml(detailSb, detailCollect, mainRs, detailRs, count++);
if(StringUtils.isNotBlank(nodeName)){
detailSb.append("</").append(nodeName).append(">\n");
}
} }
} }
} }
@ -474,7 +494,7 @@ public class ReadConfigUtil extends ToolUtil {
.append(paramName) .append(paramName)
.append(">") .append(">")
.append(getParamValue(requestConfig, mainRs, detailRs,count)) .append(getParamValue(requestConfig, mainRs, detailRs,count))
.append("<") .append("</")
.append(paramName) .append(paramName)
.append(">") .append(">")
.append("\n"); .append("\n");
@ -544,22 +564,80 @@ public class ReadConfigUtil extends ToolUtil {
* @return * @return
*/ */
public String parseMap(Map<String, Object> responseMap, String responseField){ public String parseMap(Map<String, Object> responseMap, String responseField){
String[] strArr = responseField.split("\\."); try {
int i = 0; String[] strArr = responseField.split("\\.");
while (i < strArr.length - 1){ int i = 0;
Object o = responseMap.get(strArr[i]); while (i < strArr.length - 1){
if(o instanceof Map){ Object o = responseMap.get(strArr[i]);
responseMap = (Map<String, Object>) o; if(o instanceof Map){
}else if(o instanceof List){ responseMap = (Map<String, Object>) o;
List<Map<String, Object>> list = (List<Map<String, Object>>) o; }else if(o instanceof List){
if(CollectionUtils.isEmpty(list)){ List<Map<String, Object>> list = (List<Map<String, Object>>) o;
return ""; if(CollectionUtils.isEmpty(list)){
} return "";
responseMap = list.get(0); }
} responseMap = list.get(0);
i++; }
} i++;
return Util.null2String(responseMap.get(strArr[strArr.length - 1])); }
return Util.null2String(responseMap.get(strArr[strArr.length - 1]));
}catch (Exception e){
throw new CustomerException("parseMap error : " + e.getMessage());
}
} }
/**
* <h1>sap</h1>
* @author xuanran.wang
* @dateTime 2023/5/15 14:05
* @param url
* @param xml xml
* @return
**/
public String callSap(String url, String xml){
OutputStreamWriter writer = null;
BufferedReader reader = null;
try {
String userName = aiyh.utils.Util.null2DefaultStr(getSystemParamValue("sapUserName"),"");
String password = aiyh.utils.Util.null2DefaultStr(getSystemParamValue("sapPassword"),"");
log.info("callSap userName : [ " + userName + " ], password : [ " + password + " ]");
String authString = userName + ":" + password;
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
String authStringEnc = new String(authEncBytes);
URL serviceUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
connection.setDoOutput(true);
writer = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
writer.write(xml);
writer.close();
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
String line;
StringBuilder responseBuilder = new StringBuilder();
while ((line = reader.readLine()) != null) {
responseBuilder.append(line);
}
reader.close();
String response = responseBuilder.toString();
if(StringUtils.isBlank(response)){
throw new CustomerException("sap response is empty!");
}
return response;
}catch (Exception e){
throw new CustomerException("callSap error : " + e.getMessage());
}finally {
try {
if(writer != null){
writer.close();
}
if(reader != null){
reader.close();
}
}catch (Exception e){
log.error("关流异常 : " + e.getMessage());
}
}
}
} }

View File

@ -35,6 +35,8 @@ public class ShBigDataUtil {
WHILTE_LIST.add("loginErrorSendRedirectUrl"); WHILTE_LIST.add("loginErrorSendRedirectUrl");
WHILTE_LIST.add("getUserIdDebug"); WHILTE_LIST.add("getUserIdDebug");
WHILTE_LIST.add("getUserIdDebugOutKey"); WHILTE_LIST.add("getUserIdDebugOutKey");
WHILTE_LIST.add("ssoInterfaceCompareField");
WHILTE_LIST.add("ssoOaCompareField");
} }
/** /**

View File

@ -4,3 +4,5 @@ aiyh.htmllabel.porsche.faddcontractcontroller.pushsuccess.labelindex=-1
aiyh.htmllabel.porsche.faddcontractcontroller.pushsuccess.defaultstr=签署邮件发送成功! aiyh.htmllabel.porsche.faddcontractcontroller.pushsuccess.defaultstr=签署邮件发送成功!
attachment_sort.annexsortaction.sorterr.labelindex=-1 attachment_sort.annexsortaction.sorterr.labelindex=-1
attachment_sort.annexsortaction.sorterr.defaultstr=文件排序失败,请联系系统管理员! attachment_sort.annexsortaction.sorterr.defaultstr=文件排序失败,请联系系统管理员!
xbk.contractRepush.errorMsg.labelindex=-83377
xbk.contractRepush.errorMsg.defaultstr=我是傻狗

View File

@ -0,0 +1,500 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/systeminfo/init_wev8.jsp"%>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%>
<%@ page import="weaver.file.Prop" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.systeminfo.SystemEnv" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="RecordSet_count" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page" />
<jsp:useBean id="DepartmentComInfo" class="weaver.hrm.company.DepartmentComInfo" scope="page" />
<jsp:useBean id="CrmSupplierComInfo" class="weaver.crm.supplierinfo.CrmSupplierComInfo" scope="page" />
<jsp:useBean id="RecordSet_Dep" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="SubCompanyComInfo" class="weaver.hrm.company.SubCompanyComInfo" scope="page" /><!--zl-->
<HTML>
<HEAD>
<LINK href="/css/Weaver_wev8.css" type=text/css rel=STYLESHEET>
<SCRIPT language="javascript" src="/js/weaver_wev8.js"></script>
<style>
td * {font-size:9px !important;}
</style>
</head>
<%
String sqlwhere = " where 1=1 ";
String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID()));
//是否采购部
boolean isDep = false;
//是否是流程接收人
boolean isShow = false;
//采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片
RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment());
if(RecordSet_Dep.next()) isDep = true;
//是否合同流程接收人
String sqlwhere_workflow = "";
RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID());
if(RecordSet_Dep.next()) isShow = true;
if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){
response.sendRedirect("/notice/noright.jsp");
}
//如果是合同管理权限则直接1=1
if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){
sqlwhere += " and 1=1";
}else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){
//如果是流程接收人,并且有合同查看权限
sqlwhere += " and (requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"')";
}else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){
//如果只有合同查看权限
sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'";
}else if(isShow){
//如果只是流程接收人
sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+")";
}
//如果没有查看全部的权限,加分部条件
if(!HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){
if (!subcompanyid1.equals("0")) {sqlwhere += " and CrmContractInfo.subcompanyid1 = '"+subcompanyid1+"' ";}
}
String imagefilename = "/images/hdReport.gif";
String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage());
String needfav = "1";
String needhelp = "";
%>
<BODY>
<%@ include file="/systeminfo/TopTitle_wev8.jsp"%>
<%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%>
<%
RCMenu += "{" + SystemEnv.getHtmlLabelName(197, user.getLanguage()) + ",javascript:OnSearch(),_top} ";
RCMenuHeight += RCMenuHeightStep;
RCMenu += "{" + "Excel,javascript:ContractExport(),_top} ";
RCMenuHeight += RCMenuHeightStep;
RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}";
RCMenuHeight += RCMenuHeightStep;
RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}";
RCMenuHeight += RCMenuHeightStep;
RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}";
RCMenuHeight += RCMenuHeightStep;
RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}";
RCMenuHeight += RCMenuHeightStep;
%>
<%
int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1);
int perpage = Util.getPerpageLog();
if (perpage <= 1) perpage = 10;
String creator = Util.fromScreen(request.getParameter("creator"), user.getLanguage());
String fromdate = Util.fromScreen(request.getParameter("fromdate"), user.getLanguage());
String fromdate2 = Util.fromScreen(request.getParameter("fromdate2"), user.getLanguage());
String enddate = Util.fromScreen(request.getParameter("enddate"), user.getLanguage());
String enddate2 = Util.fromScreen(request.getParameter("enddate2"), user.getLanguage());
String status_temp = Util.null2String(request.getParameter("status_temp"));
String conNo = Util.fromScreen(request.getParameter("conNo"), user.getLanguage());
String prNo = Util.fromScreen(request.getParameter("prNo"), user.getLanguage());
String jpcNo = Util.fromScreen(request.getParameter("jpcNo"), user.getLanguage());
String suppliersId = Util.fromScreen(request.getParameter("suppliersId"), user.getLanguage());
String isOneSuppliers = Util.fromScreen(request.getParameter("isOneSuppliers"), user.getLanguage());
// String reqDeptId = String.valueOf(user.getUserDepartment());
String reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());;
//管理员组或采购部才能查询所有部门下合同,合同接收人查看接收的合同
// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user) || isShow) reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());
String isOverdue = Util.fromScreen(request.getParameter("isOverdue"), user.getLanguage());
String status = Util.fromScreen(request.getParameter("status"), user.getLanguage());
String isOverdueNext = Util.fromScreen(request.getParameter("isOverdueNext"), user.getLanguage());
String conType = Util.fromScreen(request.getParameter("conType"), user.getLanguage());
String name = Util.fromScreen(request.getParameter("name"), user.getLanguage());
String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage());
String reNewStatus = Util.fromScreen(request.getParameter("reNewStatus"), user.getLanguage());
String conStatus = Util.fromScreen(request.getParameter("conStatus"), user.getLanguage());
String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage());
String csstatus = Util.fromScreen(request.getParameter("csstatus"), user.getLanguage());
int opentype = Util.getIntValue(request.getParameter("opentype"),-1);
//String sqlwhere = " where status = '' ";
//if(!"".equals(status_temp)) sqlwhere += " and status in ("+status_temp+") ";
if (!fromdate.equals("")) sqlwhere += " and startDate>='" + fromdate + "'";
if (!fromdate2.equals("")) sqlwhere += " and startDate<='" + fromdate2 + "'";
if (!enddate.equals("")) sqlwhere += " and enddate>='" + enddate + "'";
if (!enddate2.equals("")) sqlwhere += " and enddate<='" + enddate2 + "'";
if (!conNo.equals("")) sqlwhere += " and conNo like '%" + conNo + "%'";
if (!prNo.equals("")) sqlwhere += " and prNo='" + prNo + "'";
if (!jpcNo.equals("")) sqlwhere += " and jpcNo='" + jpcNo + "'";
if(!"".equals(suppliersId)) sqlwhere += " and suppliersId=" + suppliersId;
if (!isOneSuppliers.equals("")) sqlwhere += " and isOneSuppliers='" + isOneSuppliers + "'";
if (!"".equals(creator) && !"0".equals(creator)) sqlwhere += " and CrmContractInfo.creator=" + creator;
if (!reqDeptId.equals("")) sqlwhere += " and reqDeptId=" + reqDeptId;
if (!isOverdue.equals("")) sqlwhere += " and isOverdue='" + isOverdue + "'";
if (!status.equals("")) sqlwhere += " and CrmContractInfo.status='" + status + "'";
if (!isOverdueNext.equals("")) sqlwhere += " and isOverdueNext='" + isOverdueNext + "'";
if (!conType.equals("")) sqlwhere += " and conType='" + conType + "'";
if (!csstatus.equals("")) sqlwhere += " and CrmSalesContractInfo.status='" + csstatus + "'";
if (!name.equals("")) sqlwhere += " and name like '%" + name + "%'";
if (!subCompanyId.equals("")) sqlwhere += " and CrmContractInfo.subcompanyid1 = '" + subCompanyId + "'";
if (!reNewStatus.equals("")) sqlwhere += " and conStatus = '" + reNewStatus + "'";
if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'";
//if (reNewStatus2.equals("待续签")) sqlwhere += " and dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0";
//else if (reNewStatus2.equals("已续签")) sqlwhere += " and dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0";
//else if (reNewStatus2.equals("无需续签")) sqlwhere += " and dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0";
//System.out.println("sqlwhere:"+sqlwhere);
if(opentype > -1){
sqlwhere += " and isnull(CrmContractInfo.opentype,0) = " + opentype;
}
String orderStr = " order by startDate desc, CrmContractInfo.id desc ";
// out.println("sqlwhere:" + sqlwhere);
// out.println("orderStr:" + orderStr);
// session.setAttribute("sqlwhere", sqlwhere);
// session.setAttribute("orderStr", orderStr);
%>
<form id=frmmain name=frmmain method=post action="ContractList.jsp">
<input type=hidden id=pagenum name=pagenum value="<%=pagenum%>">
<input type=hidden id=status_temp name=status_temp value="">
<table class=ViewForm>
<tbody>
<COLGROUP>
<COL width="13%">
<COL width="20%">
<COL width="14%">
<COL width="20%">
<COL width="13%">
<COL width="20%">
<TR class=Title>
<TH colSpan=6><%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%></TH>
</TR>
<tr style="height: 1px">
<td class=Line1 colspan=6></td>
</tr>
<tr style="height: 1px">
<td class=Line colspan=6></td>
</tr>
<tr>
<TD>合同状态</TD>
<TD class=Field>
<select id="reNewStatus" name="reNewStatus">
<option value="" <%="".equals(reNewStatus)?"selected":""%>></option>
<option value="0" <%="0".equals(reNewStatus)?"selected":""%>>执行</option>
<option value="1" <%="1".equals(reNewStatus)?"selected":""%>>待续签</option>
<option value="2" <%="2".equals(reNewStatus)?"selected":""%>>已续签</option>
<option value="3" <%="3".equals(reNewStatus)?"selected":""%>>关闭</option>
</select>
</TD>
<td><%=SystemEnv.getHtmlLabelName(1970, user.getLanguage())%></td>
<td class=field>
<BUTTON type="button" class=calendar id=SelectDate onclick=getDate('fromdatespan','fromdate')></BUTTON>&nbsp;
<SPAN id=fromdatespan><%=Util.toScreen(fromdate, user.getLanguage())%></SPAN>&nbsp;-&nbsp;
<BUTTON type="button" class=calendar id=SelectDate onclick=getDate('fromdate2span','fromdate2')></BUTTON>&nbsp;
<SPAN id=fromdate2span><%=Util.toScreen(fromdate2, user.getLanguage())%></SPAN>
<input type="hidden" name="fromdate" value=<%=fromdate%>>
<input type="hidden" name="fromdate2" value=<%=fromdate2%>>
</td>
<td><%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%></td>
<td class=field>
<BUTTON type="button" class=calendar id=SelectDate onclick=getDate('enddatespan','enddate')></BUTTON>&nbsp;
<SPAN id=enddatespan><%=Util.toScreen(enddate, user.getLanguage())%></SPAN>&nbsp;-&nbsp;
<BUTTON type="button" class=calendar id=SelectDate onclick=getDate('enddate2span','enddate2')></BUTTON>&nbsp;
<SPAN id=enddate2span><%=Util.toScreen(enddate2, user.getLanguage())%></SPAN>
<input type="hidden" name="enddate" value=<%=enddate%>>
<input type="hidden" name="enddate2" value=<%=enddate2%>>
</td>
</TR>
<tr style="height: 1px">
<td class=Line colspan=6></td>
</tr>
<TR>
<TD><%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%></TD>
<TD class=Field>
<INPUT class=InputStyle maxLength=100 id="conNo" name="conNo" STYLE="width:150" value="<%=conNo%>">
</TD>
<TD>PR<%=SystemEnv.getHtmlLabelName(403,user.getLanguage())%></TD>
<TD class=Field>
<INPUT class=InputStyle maxLength=100 id="prNo" name="prNo" STYLE="width:150" value="<%=prNo%>">
</TD>
<TD>JPC<%=SystemEnv.getHtmlLabelName(2171,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(16992,user.getLanguage())%></TD>
<TD class=Field>
<INPUT class=InputStyle maxLength=100 id="jpcNo" name="jpcNo" STYLE="width:150" value="<%=jpcNo%>">
</TD>
</TR>
<tr style="height: 1px">
<td class=Line colspan=6></td>
</tr>
<TR>
<TD><%=SystemEnv.getHtmlLabelName(613002, user.getLanguage())%></TD>
<TD class=Field>
<brow:browser viewType="0"
id="suppliersId"
name="suppliersId"
browserValue="<%=suppliersId %>"
browserUrl="/systeminfo/BrowserMain.jsp?url=/interface/CommonBrowser.jsp?type=browser.gys"
hasInput="true"
isSingle="true"
hasBrowser = "true"
isMustInput='1'
width="165px"
browserSpanValue="<%=CrmSupplierComInfo.getSuppliername(suppliersId) %>">
</brow:browser>
</TD>
<TD></TD>
<TD class=Field>
</TD>
<TD><%=SystemEnv.getHtmlLabelName(913, user.getLanguage())%></TD>
<TD class=Field>
<brow:browser viewType="0"
id="creator"
name="creator"
browserValue="<%=creator %>"
browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/resource/ResourceBrowser.jsp"
hasInput="true"
isSingle="true"
hasBrowser = "true"
isMustInput='1'
width="165px"
browserSpanValue="<%=ResourceComInfo.getResourcename(creator) %>">
</brow:browser>
</TD>
</TR>
<tr style="height: 1px">
<td class=Line colspan=6></td>
</tr>
<TR>
<TD><%=SystemEnv.getHtmlLabelName(620002, user.getLanguage())%></TD>
<TD class=Field>
<brow:browser viewType="0"
id="reqDeptId"
name="reqDeptId"
browserValue="<%=reqDeptId %>"
browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"
hasInput="true"
isSingle="true"
hasBrowser = "true"
isMustInput='1'
width="165px"
browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">
</brow:browser>
<%-- <%--%>
<%-- //管理员组才能查询所有部门下合同--%>
<%-- if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){--%>
<%-- %>--%>
<%-- <brow:browser viewType="0"--%>
<%-- id="reqDeptId"--%>
<%-- name="reqDeptId"--%>
<%-- browserValue="<%=reqDeptId %>"--%>
<%-- browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"--%>
<%-- hasInput="true"--%>
<%-- isSingle="true"--%>
<%-- hasBrowser = "true"--%>
<%-- isMustInput='1'--%>
<%-- width="165px"--%>
<%-- browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">--%>
<%-- </brow:browser>--%>
<%-- &lt;%&ndash;<INPUT type=hidden class="wuiBrowser" _required="no" _displayTemplate="#b{name}" _displayText="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>" _url="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp" name="reqDeptId" value="<%=reqDeptId%>">&ndash;%&gt;--%>
<%-- <%}else{ %>--%>
<%-- <%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>--%>
<%-- <%} %>--%>
</TD>
<TD>付款状态</TD>
<TD class=Field>
<select id="status" name="status">
<option value="" <%="".equals(status)?"selected":""%>></option>
<option value="0" <%="0".equals(status)?"selected":""%>>执行中</option>
<option value="1" <%="1".equals(status)?"selected":""%>>已结清</option>
</select>
</TD>
<TD><%=SystemEnv.getHtmlLabelName(620017, user.getLanguage())%></TD>
<TD class=Field>
<select id="isOverdueNext" name="isOverdueNext">
<option value="" <%="".equals(isOverdueNext)?"selected":""%>></option>
<option value="Y" <%="Y".equals(isOverdueNext)?"selected":""%>><%=SystemEnv.getHtmlLabelName(163,user.getLanguage())%></option>
<option value="N" <%="N".equals(isOverdueNext)?"selected":""%>><%=SystemEnv.getHtmlLabelName(161,user.getLanguage())%></option>
</select>
</TD>
</TR>
<tr style="height: 1px">
<td class=Line colspan=6></td>
</tr>
<TR>
<TD><%=SystemEnv.getHtmlLabelName(15775, user.getLanguage())%></TD>
<TD class=Field>
<select id="conType" name="conType">
<option value="" <%="".equals(conType)?"selected":""%>></option>
<option value="0" <%="0".equals(conType)?"selected":""%>>业务型</option>
<option value="1" <%="1".equals(conType)?"selected":""%>>资本型</option>
<option value="2" <%="2".equals(conType)?"selected":""%>>费用型</option>
</select>
</TD>
<TD><%=SystemEnv.getHtmlLabelName(15142, user.getLanguage())%></TD>
<TD class=Field>
<INPUT class=InputStyle maxLength=200 id="name" name="name" STYLE="width:150" value="<%=name%>">
</TD>
<%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%>
<TD><%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%></TD>
<TD class=Field>
<brow:browser viewType="0"
id="subCompanyId"
name="subCompanyId"
browserValue="<%=subCompanyId %>"
browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"
hasInput="true"
isSingle="true"
hasBrowser = "true"
isMustInput='1'
width="165px"
browserSpanValue="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>">
</brow:browser>
<%--<input class=wuiBrowser class=inputStyle id=subCompanyId type=hidden name=subCompanyId value="<%=subCompanyId%>"--%>
<%--_url="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"--%>
<%--_displayText="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>"--%>
<%-->--%>
</TD>
<%}%>
</TR>
<tr style="height: 1px">
<td class=Line colspan=6></td>
</tr>
<TR>
<TD><%=SystemEnv.getHtmlLabelName(16404, user.getLanguage())%><%=SystemEnv.getHtmlLabelName(195, user.getLanguage())%></TD>
<TD class=Field>
<INPUT class=InputStyle maxLength=200 id="contractName" name="contractName" STYLE="width:150" value="<%=contractName%>">
</TD>
<TD>销售合同状态</TD>
<TD class=Field>
<select id="csstatus" name="csstatus">
<option value="" <%="".equals(csstatus)?"selected":""%>></option>
<option value="0" <%="0".equals(csstatus)?"selected":""%>>已签署</option>
<option value="1" <%="1".equals(csstatus)?"selected":""%>>未签署</option>
<option value="2" <%="2".equals(csstatus)?"selected":""%>>已续签</option>
<option value="3" <%="3".equals(csstatus)?"selected":""%>>关闭</option>
</select>
</TD>
<td>开闭口类型</td>
<td class="Field">
<select name="opentype">
<option value="-1" <%=(opentype == -1) ?"selected":"" %>>--请选择--</option>
<option value="0" <%=(opentype == 0) ?"selected":"" %>>闭口</option>
<option value="1" <%=(opentype == 1) ?"selected":"" %>>开口</option>
<option value="2" <%=(opentype == 2) ?"selected":"" %>>周期性</option>
</select>
</td>
</TR>
<tr style="height: 1px">
<td class=Line colspan=6></td>
</tr>
</tbody>
</table>
</form>
<div id="" style="overflow-x:scroll;width:100%;">
<table width="2500px" style="table-Layout:fixed">
<tr>
<td>
<%
String tableString = "";
String backfields = " CrmContractInfo.id,case CrmContractInfo.opentype when '0' then '闭口' when '1' then '开口' when '2' then '周期性' end opentype, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, ',' as str_temp, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, CrmContractInfo.creator, CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus, contractName, saleContract, case when dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0 then '已续签' when dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0 then '待续签' when dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0 then '无需续签' end as reNewStatus2,case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as csstatus ";
String fromSql = " CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract ";
//out.print("select"+backfields+"from"+fromSql +sqlwhere);
String str_content = "content"+"str_temp";
tableString = " <table instanceid=\"crmContractInfoTable\" tabletype=\"none\" pageId=\"perpage\" pagesize=\"" +PageIdConst.getPageSize("perpage",user.getUID())+"\" >" + "<sql backfields=\"" + backfields + "\" sqlform=\"" + fromSql + "\" sqlwhere=\"" + Util.toHtmlForSplitPage(sqlwhere) + "\" sqlprimarykey=\"CrmContractInfo.id\" sqlsortway=\"Desc\" sqlisdistinct=\"false\" />" + "<head>";
tableString += "<col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(15142, user.getLanguage()) + "\" column=\"name\" orderkey=\"name\" linkkey=\"id\" linkvaluecolumn=\"id\" href=\"/CRM/contractinfo/ContractEdit.jsp\" target=\"_fullwindow\" />";
tableString += "<col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(21282, user.getLanguage()) + "\" column=\"conNo\" orderkey=\"conNo\" />";
tableString += "<col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(620002, user.getLanguage()) + "\" column=\"reqDeptId\" orderkey=\"reqDeptId\" transmethod=\"weaver.hrm.company.DepartmentComInfo.getDepartmentname\" linkkey=\"id\" href=\"/hrm/company/HrmDepartmentDsp.jsp\" target=\"_fullwindow\" />";
tableString += "<col width=\"10%\" text=\""+ SystemEnv.getHtmlLabelName(613002, user.getLanguage()) + "\" column=\"suppliersId\" orderkey=\"suppliersId\" linkkey=\"id\" transmethod=\"weaver.crm.supplierinfo.CrmSupplierComInfo.getSuppliername\" href=\"/CRM/supplierinfo/SuppliersEdit.jsp?1=1\" target=\"_fullwindow\" />";
tableString += "<col width=\"6%\" text=\"" + SystemEnv.getHtmlLabelName(1970, user.getLanguage()) + "\" column=\"startDate\" orderkey=\"startDate\" />";
tableString += "<col width=\"6%\" text=\"" + SystemEnv.getHtmlLabelName(15236, user.getLanguage()) + "\" column=\"endDate\" orderkey=\"endDate\" />";
//tableString += "<col width=\"3%\" text=\"" + SystemEnv.getHtmlLabelName(620016, user.getLanguage()) + "\" column=\"isOverdue\" orderkey=\"isOverdue\" />";
tableString += "<col width=\"6%\" text=\"" + SystemEnv.getHtmlLabelName(6146, user.getLanguage()) + "\" column=\"conAmount\" orderkey=\"conAmount\" />";
tableString += "<col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(620015, user.getLanguage()) + "\" column=\"content\" orderkey=\""+str_content+"\" transmethod=\"weaver.splitepage.transform.SptmForDoc.getDocNames\" />";
tableString += "<col width=\"4%\" text=\"" + SystemEnv.getHtmlLabelName(620017, user.getLanguage()) + "\" column=\"isOverdueNext\" orderkey=\"isOverdueNext\" />";
tableString += "<col width=\"4%\" text=\"付款状态\" column=\"status\" orderkey=\"status\" />";
tableString += "<col width=\"4%\" text=\"" + SystemEnv.getHtmlLabelName(913, user.getLanguage()) + "\" column=\"creator\" orderkey=\"creator\" linkkey=\"id\" transmethod=\"weaver.hrm.resource.ResourceComInfo.getResourcename\" href=\"/hrm/resource/HrmResource.jsp?1=1\" target=\"_fullwindow\" />";
//tableString += "<col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(104, user.getLanguage()) + "\" column=\"id\" orderkey=\"id\" transmethod=\"weaver.crm.contractinfo.CrmContractTool.getLinkButtons\" />";
tableString += "<col width=\"4%\" text=\"合同状态\" column=\"reNewStatus\" orderkey=\"reNewStatus\" />";
tableString += "<col width=\"4%\" text=\"销售合同\" column=\"contractName\" orderkey=\"contractName\" linkkey=\"id\" linkvaluecolumn=\"saleContract\" href=\"/CRM/salecontractinfo/SaleContractEdits.jsp?metherid=search\" target=\"_fullwindow\" />";
tableString += "<col width=\"4%\" text=\"销售合同状态\" column=\"csstatus\" orderkey=\"csstatus\" />";
tableString += "<col width=\"4%\" text=\"开闭口类型\" column=\"opentype\" orderkey=\"opentype\" />";
tableString += "<col width=\"4%\" text=\"" + SystemEnv.getHtmlLabelName(141,user.getLanguage()) + "\" column=\"subcompanyid1\" orderkey=\"subcompanyid1\" transmethod=\"weaver.hrm.company.SubCompanyComInfo.getSubCompanyname\" />";
tableString += "</head>";
tableString += "</table>";
%>
<input type="hidden" name="pageId" id="pageId" value="crmContractInfoTable" />
<wea:SplitPageTag tableString="<%=tableString%>" mode="run" />
</td>
</tr>
</table>
</div>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%>
</body>
<iframe id="searchexport" style="display: none"></iframe>
<script language=javascript>
function ContractExport() {
console.log("contract export =====>sqlwhere:"+encodeURI("<%=sqlwhere%>")+" orderStr:"+encodeURI("<%=orderStr%>"));
var sqlwhere = encodeURI("<%=sqlwhere%>");
var orderStr = encodeURI("<%=orderStr%>");
jQuery("#searchexport").attr("src", "ContractReportExport.jsp?sqlwhere="+sqlwhere+"&orderStr=" + orderStr);
}
function OnSubmit(pagenum) {
document.frmmain.pagenum.value = pagenum;
document.frmmain.submit();
}
function OnSearch(){
var chkInTableTags = document.getElementsByName("status");
var status_temp = "";
for(var i=0;i<chkInTableTags.length;i++){
if(chkInTableTags[i].checked && chkInTableTags[i].value != ''){
if(status_temp == "") status_temp = "'" + chkInTableTags[i].value + "'";
else status_temp = status_temp + ",'" + chkInTableTags[i].value + "'";
}
}
jQuery("#status_temp").val(status_temp);
document.frmmain.submit();
}
//续签
function newWorkflowByContract4(key){
location.href = "ContractNewWorkflow.jsp?status=4&id="+key;
}
//试运作
function newWorkflowByContract3(key){
location.href = "ContractNewWorkflow.jsp?status=3&id="+key;
}
</script>
<SCRIPT language="javascript" src="/js/datetime_wev8.js"></script>
<SCRIPT language="javascript" src="/js/JSDateTime/WdatePicker_wev8.js"></script>
</html>

View File

@ -0,0 +1,130 @@
<%@ page language="java" contentType="text/html; charset=GBK" %>
<%@ include file="/systeminfo/init.jsp" %>
<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow" %>
<%@ page import="lombok.val" %>
<%@ page import="weaver.zwl.common.logging.Logger" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
<jsp:useBean id="SptmForDoc" class="weaver.splitepage.transform.SptmForDoc" scope="page"/>
<jsp:useBean id="SubCompanyComInfo" class="weaver.hrm.company.SubCompanyComInfo" scope="page"/>
<jsp:useBean id="DepartmentComInfo" class="weaver.hrm.company.DepartmentComInfo" scope="page"/>
<jsp:useBean id="CrmSupplierComInfo" class="weaver.crm.supplierinfo.CrmSupplierComInfo" scope="page"/>
<jsp:useBean id="RequestComInfo" class="weaver.workflow.request.RequestComInfo" scope="page"/>
<jsp:useBean id="DocComInfo" class="weaver.docs.docs.DocComInfo" scope="page"/>
<jsp:useBean id="ExcelFile" class="weaver.file.ExcelFile" scope="session"/>
<%!
public static String ToDBC(String input) {
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == 12288) {
//全角空格为12288半角空格为32
c[i] = (char) 32;
continue;
}
if (c[i] > 65280 && c[i] < 65375)
//其他字符半角(33-126)与全角(65281-65374)的对应关系是均相差65248
c[i] = (char) (c[i] - 65248);
}
return new String(c);
}
%>
<%
// String sqlwhere=(String)session.getAttribute("sqlwhere");
// String orderStr=(String)session.getAttribute("orderStr");
val logger = aiyh.utils.Util.getLogger();
String sqlwhere = request.getParameter("sqlwhere");
sqlwhere = ToDBC(sqlwhere);
String orderStr = request.getParameter("orderStr");
orderStr = ToDBC(orderStr);
String sqlstr = "";
if (RecordSet.getDBType().equals("oracle")) {
sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, case isOneSuppliers when 'Y' then '是' when 'N' then '否' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr;
} else {
sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, case isOneSuppliers when 'Y' then '是' when 'N' then '否' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr;
}
new BaseBean().writeLog(">>>>>>>>"+sqlstr);
RecordSet.executeQuery(sqlstr);
ExcelSheet es = new ExcelSheet();
ExcelRow er = es.newExcelRow();
er.addStringValue(SystemEnv.getHtmlLabelName(141,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620002,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(613002,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(21282,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(15142,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(1970,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(15236,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620016,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(6146,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620017,user.getLanguage()));
er.addStringValue("付款状态");
er.addStringValue(SystemEnv.getHtmlLabelName(913,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620009,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620003,user.getLanguage()));
er.addStringValue("JPC"+SystemEnv.getHtmlLabelName(16992,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620004,user.getLanguage()));
er.addStringValue("PR"+SystemEnv.getHtmlLabelName(403,user.getLanguage()));
er.addStringValue("PR"+SystemEnv.getHtmlLabelName(856,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620010,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620011,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620006,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620012,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620013,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620014,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage()));
er.addStringValue(SystemEnv.getHtmlLabelName(614,user.getLanguage())+SystemEnv.getHtmlLabelName(722,user.getLanguage()));
er.addStringValue("合同状态");
er.addStringValue("销售合同");
er.addStringValue("销售合同状态");
while (RecordSet.next()) {
ExcelRow erdetail = es.newExcelRow();
erdetail.addStringValue(SubCompanyComInfo.getSubCompanyname(RecordSet.getString("subcompanyid1")));
erdetail.addStringValue(DepartmentComInfo.getDepartmentname(RecordSet.getString("reqDeptId")));
erdetail.addStringValue(CrmSupplierComInfo.getSuppliername(RecordSet.getString("suppliersId")));
erdetail.addStringValue(RecordSet.getString("conNo"));
erdetail.addStringValue(RecordSet.getString("name"));
erdetail.addStringValue(RecordSet.getString("startDate"));
erdetail.addStringValue(RecordSet.getString("endDate"));
erdetail.addStringValue(RecordSet.getString("isOverdue"));
erdetail.addStringValue(RecordSet.getString("conAmount"));
erdetail.addStringValue(Util.toScreen(SptmForDoc.getDocName(RecordSet.getString("content")), user.getLanguage()));
erdetail.addStringValue(RecordSet.getString("isOverdueNext"));
erdetail.addStringValue(RecordSet.getString("status"));
erdetail.addStringValue(Util.toScreen(ResourceComInfo.getResourcename(RecordSet.getString("creator")), user.getLanguage()));
erdetail.addStringValue(RecordSet.getString("isOneSuppliers"));
erdetail.addStringValue(RequestComInfo.getRequestname(RecordSet.getString("prRequestId")));
erdetail.addStringValue(RecordSet.getString("jpcNo"));
erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("jpcFile")));
erdetail.addStringValue(RecordSet.getString("prNo"));
erdetail.addStringValue(RecordSet.getString("prAmount"));
erdetail.addStringValue(RecordSet.getString("prAmountSum"));
erdetail.addStringValue(ResourceComInfo.getResourcename(RecordSet.getString("managerId")));
erdetail.addStringValue(RecordSet.getString("subject"));
erdetail.addStringValue(RecordSet.getString("giveDate"));
erdetail.addStringValue(RecordSet.getString("giveRemark"));
erdetail.addStringValue(RecordSet.getString("payRemark"));
erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("content")));
erdetail.addStringValue(RecordSet.getString("createDate"));
erdetail.addStringValue(RecordSet.getString("reNewStatus"));
erdetail.addStringValue(RecordSet.getString("contractName"));
erdetail.addStringValue(RecordSet.getString("reNewStatus2"));
}
ExcelFile.init();
ExcelFile.setFilename("合同报表");
ExcelFile.addSheet("合同", es);
%>
<%--<iframe name="ExcelOut" id="ExcelOut" src="/weaver/weaver.file.ExcelOut" style="display:none" ></iframe>--%>
<script language="javascript">
window.location = "/weaver/weaver.file.ExcelOut";
</script>

View File

@ -120,6 +120,31 @@ public class FaRequestUtils {
return responeVo; return responeVo;
} }
/**
*
*
* @param data
* @param url
* @return
*/
public static ResponeVo companyAuthentication(Map<String, Object> data, String url) {
log.info("公司认证状态同步");
try {
HEADER.put("sign", builderSign(data));
} catch (Exception e) {
throw new CustomerException("签名失败!", e);
}
HEADER.put("Content-Type", "application/json");
ResponeVo responeVo = null;
try {
responeVo = HTTP_UTILS.apiPost(url,
data, null);
} catch (IOException e) {
e.printStackTrace();
}
return responeVo;
}
public static ResponeVo RevocationContract(Map<String, Object> data, String url) { public static ResponeVo RevocationContract(Map<String, Object> data, String url) {
log.info("撤销合同方法"); log.info("撤销合同方法");
try { try {

View File

@ -130,6 +130,7 @@ public class BaseTest {
@Test @Test
public void with() { public void with() {
Logger logger = Util.getLogger(); Logger logger = Util.getLogger();
logger.info("aafasdf"); logger.info("aafasdf");
String sql = "select COMPANYNAME,LICENSE,EXPIREDATE,CVERSION from license "; String sql = "select COMPANYNAME,LICENSE,EXPIREDATE,CVERSION from license ";

View File

@ -8,8 +8,10 @@ import basetest.BaseTest;
import bokang.xiao.entity.CourseEntity; import bokang.xiao.entity.CourseEntity;
import bokang.xiao.entity.StudentEntity; import bokang.xiao.entity.StudentEntity;
import bokang.xiao.entity.TeacherEntity; import bokang.xiao.entity.TeacherEntity;
import bokang.xiao.util.XmlParser;
import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.alibaba.fastjson.JSON;
import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper;
import com.api.bokang.xiao.wx_report.mapper.ReportMapper; import com.api.bokang.xiao.wx_report.mapper.ReportMapper;
@ -20,8 +22,14 @@ import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test; import org.junit.Test;
import weaver.bokang.xiao.common.CommonUtil;
import weaver.bokang.xiao.common.mapper.ModeMapper; import weaver.bokang.xiao.common.mapper.ModeMapper;
import weaver.bokang.xiao.common.mapper.WorkflowMapper;
import weaver.bokang.xiao.deg_repeat_check.action.RepeatCheckAction; import weaver.bokang.xiao.deg_repeat_check.action.RepeatCheckAction;
import weaver.bokang.xiao.porsche.action.DateFieldUpdateAction;
import weaver.bokang.xiao.porsche.schedule.CompanyWriteBackSchedule;
import weaver.bokang.xiao.porsche.schedule.SalaryUpdateSchedule;
import weaver.bokang.xiao.sh_bigdata.action.DataPushAction;
import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart; import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule; import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule;
@ -30,6 +38,7 @@ import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern;
import weaver.bokang.xiao.zscq.action.OneNetComAction; import weaver.bokang.xiao.zscq.action.OneNetComAction;
import weaver.bokang.xiao.zscq.action.StatusChangeAction; import weaver.bokang.xiao.zscq.action.StatusChangeAction;
import weaver.bokang.xiao.zscq.config.service.ModeChangeService; import weaver.bokang.xiao.zscq.config.service.ModeChangeService;
import weaver.bokang.xiao.zscq.store.TableNameStore;
import weaver.bokang.xiao.zxyh.RepeatSubmitAction; import weaver.bokang.xiao.zxyh.RepeatSubmitAction;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.StaticObj; import weaver.general.StaticObj;
@ -44,6 +53,7 @@ import java.io.*;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.sql.*; import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.Date; import java.util.Date;
@ -57,16 +67,16 @@ public class NormalTest extends BaseTest {
@Test @Test
public void testWord(){ public void testWord(){
//GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class); GenerateFileUtil.createCronJobDocument(SalaryUpdateSchedule.class);
//GenerateFileUtil.createActionDocument(OneNetComAction.class); //GenerateFileUtil.createActionDocument(DataPushAction.class);
GenerateFileUtil.createActionDocument(RepeatSubmitAction.class); //GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class);
} }
@Test @Test
public void testChain(){ public void testChain(){
GenerateReportSchedule generateReportSchedule = new GenerateReportSchedule(); GenerateReportSchedule generateReportSchedule = new GenerateReportSchedule();
generateReportSchedule.setReportModelId("-2915"); //generateReportSchedule.setReportModelId("-2915");
generateReportSchedule.setDataSource("NCC"); //generateReportSchedule.setDataSource("NCC");
generateReportSchedule.runCode(); generateReportSchedule.runCode();
} }
@ -343,9 +353,52 @@ public class NormalTest extends BaseTest {
@Test @Test
public void testSub(){ public void testSub(){
String sourceStr = ",0,1,2,"; WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class);
String value = ",0,"; List<Map<String, Object>> maps = workflowMapper.queryCommonSelect("付款银行");
System.out.println(sourceStr.contains(value)); System.out.println(maps);
}
@Test
public void testDate(){
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MMMM d','yyyy",Locale.US);
String formattedDate = sdf.format(date);
System.out.println("Formatted date: " + formattedDate);
}
@Test
public void testXml() throws Exception {
//Map<String, Object> stringObjectMap = XmlParser.parseXml("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
// "<bocb2e version=\"120\" security=\"true\" locale=\"zh_CN\"><head><termid>E192168000104</termid><trnid>220630083401</trnid><custid>387679060</custid><cusopr>******</cusopr><trncod>b2e0009</trncod><token/></head><trans><trn-b2e0009-rq><transtype/><b2e0009-rq><insid>2206300834010001</insid><obssid/><trnamt>7220.02</trnamt><trncur>CNY</trncur><priolv>0</priolv><furinfo></furinfo><trfdate>20220630</trfdate><trftime></trftime><comacn/><fractn><fribkn/><actacn>455959225352</actacn><actnam/></fractn><toactn><toibkn>313290030097</toibkn><actacn>3101040160001226585</actacn><toname>上海昱锐科技有限公司</toname><toaddr/><tobknm>杭州银行股份有限公司上海青浦支行</tobknm></toactn></b2e0009-rq></trn-b2e0009-rq></trans></bocb2e>");
//System.out.println(JSON.toJSONString(stringObjectMap));
String insid = XmlParser.getNodeValue("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<bocb2e version=\"120\" security=\"true\" locale=\"zh_CN\"><head><termid>E192168000104</termid><trnid>220630083401</trnid><custid>387679060</custid><cusopr>******</cusopr><trncod>b2e0009</trncod><token/></head><trans><trn-b2e0009-rq><transtype/><b2e0009-rq><insid>2206300834010001</insid><obssid/><trnamt>7220.02</trnamt><trncur>CNY</trncur><priolv>0</priolv><furinfo></furinfo><trfdate>20220630</trfdate><trftime></trftime><comacn/><fractn><fribkn/><actacn>455959225352</actacn><actnam/></fractn><toactn><toibkn>313290030097</toibkn><actacn>3101040160001226585</actacn><toname>上海昱锐科技有限公司</toname><toaddr/><tobknm>杭州银行股份有限公司上海青浦支行</tobknm></toactn></b2e0009-rq></trn-b2e0009-rq></trans></bocb2e>","insid");
System.out.println(insid);
}
@Test
public void testDiffrentce() throws Exception {
Map<String, Object> map1 = new HashMap<>();
map1.put("id", 1);
map1.put("name", "A");
Map<String, Object> map2 = new HashMap<>();
map2.put("id", 1);
map2.put("name", "B");
Map<String, Object> map3 = new HashMap<>();
map3.put("id", 2);
map3.put("name", "B");
List<Map<String, Object>> list1 = Arrays.asList(map1, map2);
List<Map<String, Object>> list2 = Arrays.asList(map2, map3);
List<Map<String, Object>> difference = CommonUtil.difference(list1, list2, map -> map.get("id"));
List<Map<String, Object>> difference1 = CommonUtil.difference(list2, list1, map -> map.get("id"));
System.out.println(difference); // 输出 [{id=1, name=A}]
System.out.println(difference1); // 输出 [{id=1, name=A}]
}
@Test
public void testQuery1(){
TableNameStore.getInstance().refresh();
} }
} }

View File

@ -0,0 +1,94 @@
package bokang.xiao.util;
import java.io.StringReader;
import java.util.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
public class XmlParser {
/**
* XML Map
*
* @param xml XML
* @return Map
* @throws Exception
*/
public static Map<String, Object> parseXml(String xml) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
// 创建 SAXBuilder 对象
SAXBuilder builder = new SAXBuilder();
// 解析 XML 字符串成 Document 对象
Document document = builder.build(new StringReader(xml));
// 获取根元素
Element root = document.getRootElement();
// 解析根元素
parseElement(root, map);
return map;
}
/**
* Element Map
*
* @param element Element
* @param map Map
*/
private static void parseElement(Element element, Map<String, Object> map) {
// 获取子元素列表
List<Element> childElements = element.getChildren();
if (childElements.isEmpty()) {
// 如果没有子元素,则将当前元素的名称和值存入 Map 对象中
map.put(element.getName(), element.getValue());
} else {
Map<String, Object> childMap = new HashMap<String, Object>();
for (Element childElement : childElements) {
// 如果有多个同名元素,则将这些元素解析成一个 List 对象,并将该 List 对象存入当前节点的 Map 对象中
//if (childElement.getName().equals(childElements.get(0).getName())) {
// List<Map<String, Object>> childList = new ArrayList<Map<String, Object>>();
// parseElement(childElement, childMap);
// childList.add(childMap);
// map.put(childElement.getName(), childList);
//} else {
// parseElement(childElement, childMap);
// map.put(childElement.getName(), childMap);
//}
parseElement(childElement, childMap);
map.put(childElement.getName(), childMap);
}
}
}
public static String getNodeValue(String xml, String nodeName) throws Exception {
try {
SAXBuilder builder = new SAXBuilder();
StringReader reader = new StringReader(xml);
Document doc = builder.build(reader);
Element root = doc.getRootElement();
String nodeValue = getNodeValue(root, nodeName);
return nodeValue == null ? "" : nodeValue;
}catch (Exception e){
return "";
}
}
private static String getNodeValue(Element element, String nodeName) {
Element node = element.getChild(nodeName);
if (node != null) {
return node.getValue();
} else {
List<Element> children = element.getChildren();
if(Objects.nonNull(children) && children.size() > 0){
for (Element child : children) {
String value = getNodeValue(child, nodeName);
if (value != null) {
return value;
}
}
}
return null;
}
}
}

View File

@ -0,0 +1,21 @@
package xuanran.wang;
import aiyh.utils.GenerateFileUtil;
import basetest.BaseTest;
import org.junit.Test;
import weaver.xuanran.wang.eighty_five_degreec.sap.action.WorkflowToSap;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/5/19 16:48
*/
public class NormalTest extends BaseTest {
@Test
public void testWord(){
GenerateFileUtil.createActionDocument(WorkflowToSap.class);
}
}

View File

@ -3,6 +3,7 @@ package xuanran.wang.big_data;
import aiyh.utils.Util; import aiyh.utils.Util;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.sh_bigdata.sso.mapper.OtherSystemToOAMapper;
import com.icbc.api.internal.apache.http.impl.cookie.S; import com.icbc.api.internal.apache.http.impl.cookie.S;
import com.weaver.esb.server.cache.ResourceComInfo; import com.weaver.esb.server.cache.ResourceComInfo;
import emo.macro.ob.OB; import emo.macro.ob.OB;
@ -13,6 +14,7 @@ import weaver.email.EmailWorkRunnable;
import weaver.general.TimeUtil; import weaver.general.TimeUtil;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil; import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess;
import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil;
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys;
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain;
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment;
@ -32,369 +34,366 @@ import java.util.stream.Collectors;
* @date 2023/4/10 10:49 * @date 2023/4/10 10:49
*/ */
public class BigDataTest extends BaseTest { public class BigDataTest extends BaseTest {
private final OrgHrmAsyncServiceImpl orgHrmAsyncService = new OrgHrmAsyncServiceImpl(); // private final OrgHrmAsyncServiceImpl orgHrmAsyncService = new OrgHrmAsyncServiceImpl();
private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl(); // private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl();
private final List<String> departmentWhiteList; // private final List<String> departmentWhiteList;
private final List<String> subCompanyWhiteList; // private final List<String> subCompanyWhiteList;
private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class); // private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class);
//
{ // {
departmentWhiteList = orgHrmAsyncMapper.selectCusDepart(); // departmentWhiteList = orgHrmAsyncMapper.selectCusDepart();
subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany(); // subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany();
} // }
//
@Test // @Test
public void testA() throws IOException { // public void testA() throws IOException {
// List<OtherSysDepartment> rootDepList = departmentInfo //// List<OtherSysDepartment> rootDepList = departmentInfo
// .stream() //// .stream()
// .filter(item -> 1 == item.getHasChild()) //// .filter(item -> 1 == item.getHasChild())
// .sorted(Comparator.comparing(OtherSysDepartment::getId)) //// .sorted(Comparator.comparing(OtherSysDepartment::getId))
// .collect(Collectors.toList()); //// .collect(Collectors.toList());
// for (OtherSysDepartment department : rootDepList) { //// for (OtherSysDepartment department : rootDepList) {
// setChildList(department, departmentInfo); //// setChildList(department, departmentInfo);
//// }
//// List<OtherSysDepartment> departmentInfo = orgHrmAsyncApiService.getDepartmentInfo();
//// List<OtherSysDepartment> convert = Util.listToTree(departmentInfo,
//// OtherSysDepartment::getId, OtherSysDepartment::getParentid,
//// OtherSysDepartment::getChildList, OtherSysDepartment::setChildList,
//// parentid -> parentid == -1);
//// System.out.println("convert => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect));
//// List<OtherSysDepartment> hrmSubCompany = new ArrayList<>();
//// List<OtherSysDepartment> hrmDepartment = new ArrayList<>();
//// int maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3);
//// System.out.println(countNodes(convert.get(0)));
//// parseSubCompanyAndDepartment(convert, 0,maxLevel, hrmSubCompany, hrmDepartment);
//// parseSubCompanyAndDepartment(convert, hrmSubCompany);
//// System.out.println("hrmSubCompany => " + hrmSubCompany.size());
//// System.out.println("convertLevel => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect));
//// System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany));
//// System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment));
//// orgHrmAsyncService.asyncDepartment();
// Map res = JSONObject.parseObject("{\n" +
// "\t\t\"code\":0,\n" +
// "\t\t\"msg\":\"ok\",\n" +
// "\t\t\"data\":{\n" +
// "\t\t\t\"UserId\":\"13800000000\",\n" +
// "\t\t\t\"errcode\":0,\n" +
// "\t\t\t\"errmsg\":\"ok\",\n" +
// "\t\t\t\"id\":109,\n" +
// "\t\t\t\"userid\":\"13800000000\",\n" +
// "\t\t\t\"name\":\"祝芳\",\n" +
// "\t\t\t\"mobile\":\"13800000000\",\n" +
// "\t\t\t\"gender\":1,\n" +
// "\t\t\t\"department\":[\n" +
// "\t\t\t\t539\n" +
// "\t\t\t],\n" +
// "\t\t\t\"order\":[\n" +
// "\t\t\t\t6\n" +
// "\t\t\t]\n" +
// "\t\t}\n" +
// "\t}", Map.class);
// System.out.println(getRes(res));
// }
//
// public String getRes(Map res){
// return (String) parseRes(res, cusSuccess);
// }
//
// private final CusSuccess cusSuccess = CusSuccess.builder()
// .successField("code")
// .successValue(0)
// .errorMsg("msg")
// .dataKey("data.id")
// .build();
//
// public <T> T parseRes(Map<String, Object> response, CusSuccess cusSuccess){
// String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\.");
// int len = split.length;
// if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){
// return (T)response;
// } // }
// List<OtherSysDepartment> departmentInfo = orgHrmAsyncApiService.getDepartmentInfo(); // for (int i = 0; i < len - 1; i++) {
// List<OtherSysDepartment> convert = Util.listToTree(departmentInfo, // response = (Map) response.get(split[i]);
// OtherSysDepartment::getId, OtherSysDepartment::getParentid, // }
// OtherSysDepartment::getChildList, OtherSysDepartment::setChildList, // return (T) response.get(split[len - 1]);
// parentid -> parentid == -1); // }
// System.out.println("convert => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); //
// List<OtherSysDepartment> hrmSubCompany = new ArrayList<>(); // @Test
// List<OtherSysDepartment> hrmDepartment = new ArrayList<>(); // public void testMap(){
// int maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3); // List<Map<String, Object>> list = orgHrmAsyncApiService.getDepartmentInfoMap();
// System.out.println(countNodes(convert.get(0))); // // 将列表转换为以id为键的Map
// parseSubCompanyAndDepartment(convert, 0,maxLevel, hrmSubCompany, hrmDepartment); // List<Map<String, Object>> tree = convertListToTree(list);
// parseSubCompanyAndDepartment(convert, hrmSubCompany); // List<Map<String, Object>> department = new ArrayList<>();
// System.out.println("hrmSubCompany => " + hrmSubCompany.size()); // List<Map<String, Object>> subCompany = new ArrayList<>();
// System.out.println("convertLevel => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); // orgHrmAsyncService.parseSubCompanyAndDepartmentMap(tree, 0, 3, department, subCompany);
// System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany)); // System.out.println(JSONObject.toJSONString(department));
// System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment)); // System.out.println(JSONObject.toJSONString(subCompany));
// orgHrmAsyncService.asyncDepartment(); // }
Map res = JSONObject.parseObject("{\n" + //
"\t\t\"code\":0,\n" + // @Test
"\t\t\"msg\":\"ok\",\n" + // public void testMapper(){
"\t\t\"data\":{\n" + //// System.setProperty("_isDebug", "false");
"\t\t\t\"UserId\":\"13800000000\",\n" + //// System.out.println("分部执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(0)));
"\t\t\t\"errcode\":0,\n" + //// System.out.println("部门执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(1)));
"\t\t\t\"errmsg\":\"ok\",\n" + //// List<OrgHrmAsyncConfigMain> orgHrmAsyncConfigMains = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2);
"\t\t\t\"id\":109,\n" + //// System.out.println(JSONObject.toJSONString(orgHrmAsyncConfigMains));
"\t\t\t\"userid\":\"13800000000\",\n" + // ArrayList<String> ids = new ArrayList<>();
"\t\t\t\"name\":\"祝芳\",\n" + // for (int i = 0; i < 100; i++) {
"\t\t\t\"mobile\":\"13800000000\",\n" + // ids.add("'" + UUID.randomUUID().toString().replace("-","") + "'");
"\t\t\t\"gender\":1,\n" + // }
"\t\t\t\"department\":[\n" + // String updateDelStatus = "update cus_fielddata set field0 = 1 where " +
"\t\t\t\t539\n" + // weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"field2","not in");
"\t\t\t],\n" + // System.out.println(updateDelStatus);
"\t\t\t\"order\":[\n" + // }
"\t\t\t\t6\n" + //
"\t\t\t]\n" + // @Test
"\t\t}\n" + // public void testAsync(){
"\t}", Map.class); // System.out.println(TimeUtil.getCurrentTimeString());
System.out.println(getRes(res)); // OrganizationHrmSyncFromOtherSys async = new OrganizationHrmSyncFromOtherSys();
} // async.SynTimingToOASubCompany();
// async.SynTimingToOADepartment();
public String getRes(Map res){ // HashMap synResult = async.getSynResult();
return (String) parseRes(res, cusSuccess); // System.out.println("res => \n" + JSONObject.toJSONString(synResult));
} // System.out.println(TimeUtil.getCurrentTimeString());
// }
private final CusSuccess cusSuccess = CusSuccess.builder() //
.successField("code") // @Test
.successValue(0) // public void testExtra(){
.errorMsg("msg") // orgHrmAsyncService.asyncHrm();
.dataKey("data.id") // }
.build(); //
// public List<Map<String, Object>> convertListToTree(List<Map<String, Object>> list){
public <T> T parseRes(Map<String, Object> response, CusSuccess cusSuccess){ // Map<Integer, Map<String, Object>> map = new HashMap<>();
String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); // for (Map<String, Object> item : list) {
int len = split.length; // map.put((Integer) item.get("id"), item);
if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){ // }
return (T)response; //
} // // 构建树形结构
for (int i = 0; i < len - 1; i++) { // List<Map<String, Object>> tree = new ArrayList<>();
response = (Map) response.get(split[i]); // for (Map<String, Object> item : list) {
} // int parentId = (Integer) item.get("parentid");
return (T) response.get(split[len - 1]); // if (parentId == -1) {
} // // 添加根节点
// tree.add(item);
@Test // } else {
public void testMap(){ // // 添加子节点
List<Map<String, Object>> list = orgHrmAsyncApiService.getDepartmentInfoMap(); // Map<String, Object> parent = map.get(parentId);
// 将列表转换为以id为键的Map // if (parent != null) {
List<Map<String, Object>> tree = convertListToTree(list); // List<Map<String, Object>> childList = (List<Map<String, Object>>) parent.get("childList");
List<Map<String, Object>> department = new ArrayList<>(); // if (childList == null) {
List<Map<String, Object>> subCompany = new ArrayList<>(); // childList = new ArrayList<>();
orgHrmAsyncService.parseSubCompanyAndDepartmentMap(tree, 0, 3, department, subCompany); // parent.put("childList", childList);
System.out.println(JSONObject.toJSONString(department)); // }
System.out.println(JSONObject.toJSONString(subCompany)); // childList.add(item);
} // }
// }
@Test // }
public void testMapper(){ // return tree;
// System.setProperty("_isDebug", "false"); // }
// System.out.println("分部执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(0))); // public int countNodes(OtherSysDepartment node) {
// System.out.println("部门执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(1))); // int count = 1; // 当前节点也算一条数据
// List<OrgHrmAsyncConfigMain> orgHrmAsyncConfigMains = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2); // List<OtherSysDepartment> childList = node.getChildList();
// System.out.println(JSONObject.toJSONString(orgHrmAsyncConfigMains)); // if (CollectionUtils.isNotEmpty(childList)) {
ArrayList<String> ids = new ArrayList<>(); // for (OtherSysDepartment otherSysDepartment : childList) {
for (int i = 0; i < 100; i++) { // count += countNodes(otherSysDepartment);
ids.add("'" + UUID.randomUUID().toString().replace("-","") + "'"); // }
} // }
String updateDelStatus = "update cus_fielddata set field0 = 1 where " + // return count;
weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"field2","not in"); // }
System.out.println(updateDelStatus); //
} // public int countNodes(Map<String, Object> node) {
// int count = 1; // 当前节点也算一条数据
@Test // List<Map<String, Object>> childList = (List<Map<String, Object>>) node.get("childList");
public void testAsync(){ // if (CollectionUtils.isNotEmpty(childList)) {
System.out.println(TimeUtil.getCurrentTimeString()); // for (Map<String, Object> map : childList) {
OrganizationHrmSyncFromOtherSys async = new OrganizationHrmSyncFromOtherSys(); // count += countNodes(map);
async.SynTimingToOASubCompany(); // }
async.SynTimingToOADepartment(); // }
HashMap synResult = async.getSynResult(); // return count;
System.out.println("res => \n" + JSONObject.toJSONString(synResult)); // }
System.out.println(TimeUtil.getCurrentTimeString()); //
} //
// /**
@Test // * <h1>解析部门or分部</h1>
public void testExtra(){ // * @author xuanran.wang
orgHrmAsyncService.asyncHrm(); // * @dateTime 2023/4/10 12:13
} // * @param list 树形集合
// * @param hrmDepartment 部门
public List<Map<String, Object>> convertListToTree(List<Map<String, Object>> list){ // **/
Map<Integer, Map<String, Object>> map = new HashMap<>(); // public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, List<OtherSysDepartment> hrmDepartment){
for (Map<String, Object> item : list) { // for (OtherSysDepartment department : list) {
map.put((Integer) item.get("id"), item); // List<OtherSysDepartment> childList = department.getChildList();
} // if(CollectionUtils.isNotEmpty(childList)){
// parseSubCompanyAndDepartment(childList,hrmDepartment);
// 构建树形结构 // department.setChildList(null);
List<Map<String, Object>> tree = new ArrayList<>(); // }
for (Map<String, Object> item : list) { // hrmDepartment.add(department);
int parentId = (Integer) item.get("parentid"); // }
if (parentId == -1) { // }
// 添加根节点 //
tree.add(item); //
} else { // /**
// 添加子节点 // * <h1>解析部门or分部</h1>
Map<String, Object> parent = map.get(parentId); // * @author xuanran.wang
if (parent != null) { // * @dateTime 2023/4/10 12:13
List<Map<String, Object>> childList = (List<Map<String, Object>>) parent.get("childList"); // * @param list 树形集合
if (childList == null) { // * @param n 层级
childList = new ArrayList<>(); // * @param hrmSubCompany 分部
parent.put("childList", childList); // * @param hrmDepartment 部门
} // **/
childList.add(item); // public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, int n, int maxLevel,List<OtherSysDepartment> hrmSubCompany, List<OtherSysDepartment> hrmDepartment){
} // n++;
} // for (OtherSysDepartment department : list) {
} // department.setLevel(n);
return tree; // List<OtherSysDepartment> childList = department.getChildList();
} // String departmentId = department.getId() + "";
public int countNodes(OtherSysDepartment node) { // if(CollectionUtils.isNotEmpty(childList)){
int count = 1; // 当前节点也算一条数据 // List<String> collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList());
List<OtherSysDepartment> childList = node.getChildList(); // if(departmentWhiteList.contains(departmentId)){
if (CollectionUtils.isNotEmpty(childList)) { // departmentWhiteList.addAll(collect);
for (OtherSysDepartment otherSysDepartment : childList) { // }else if(subCompanyWhiteList.contains(departmentId)){
count += countNodes(otherSysDepartment); // subCompanyWhiteList.addAll(collect);
} // }
} // parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment);
return count; // department.setChildList(null);
} // }
// if(n > maxLevel || departmentWhiteList.contains(departmentId)){
public int countNodes(Map<String, Object> node) { // hrmDepartment.add(department);
int count = 1; // 当前节点也算一条数据 // }else {
List<Map<String, Object>> childList = (List<Map<String, Object>>) node.get("childList"); // hrmSubCompany.add(department);
if (CollectionUtils.isNotEmpty(childList)) { // }
for (Map<String, Object> map : childList) { //
count += countNodes(map); // }
} // }
} //
return count; // @Test
} // public void testParseObj(){
// String json = "{\n" +
// " \"code\":0,\n" +
/** // " \"msg\":\"ok\",\n" +
* <h1>or</h1> // " \"data\":\n" +
* @author xuanran.wang // " {\n" +
* @dateTime 2023/4/10 12:13 // " \"errcode\": 0,\n" +
* @param list // " \"errmsg\": \"ok\",\n" +
* @param hrmDepartment // " \"id\": \"1\",\n" +
**/ // " \"userid\": \"superAdmin\",\n" +
public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, List<OtherSysDepartment> hrmDepartment){ // " \"name\": \"超级管理员\",\n" +
for (OtherSysDepartment department : list) { // " \"mobile\":\"12345678911\",\n" +
List<OtherSysDepartment> childList = department.getChildList(); // " \"email\":\"123@321.com\",\n" +
if(CollectionUtils.isNotEmpty(childList)){ // " \"gender\":0,\n" +
parseSubCompanyAndDepartment(childList,hrmDepartment); // " \"position\":\"position\",\n" +
department.setChildList(null); // " \"avatarImg\":\"avatarImg\",\n" +
} // " \"workPhone\":\"workPhone\",\n" +
hrmDepartment.add(department); // " \"fixedTelephone\":\"fixedTelephone\",\n" +
} // " \"extName\":\"extName\",\n" +
} // " \"userType\":0,\n" +
// " \"department\": [\n" +
// " 1\n" +
/** // " ],\n" +
* <h1>or</h1> // " \"order\": [\n" +
* @author xuanran.wang // " 0\n" +
* @dateTime 2023/4/10 12:13 // " ],\n" +
* @param list // " \"rank\":\"rank\"\n" +
* @param n // " }\n" +
* @param hrmSubCompany // "}";
* @param hrmDepartment // Map response = JSONObject.parseObject(json, Map.class);
**/ // String obj = Util.null2DefaultStr(getObj("data.id", response),"");
public void parseSubCompanyAndDepartment(List<OtherSysDepartment> list, int n, int maxLevel,List<OtherSysDepartment> hrmSubCompany, List<OtherSysDepartment> hrmDepartment){ // System.out.println("obj => " + obj);
n++; // }
for (OtherSysDepartment department : list) { //
department.setLevel(n); // public <T> T getObj(String dataKey, Map<String, Object> response){
List<OtherSysDepartment> childList = department.getChildList(); // String[] split = Util.null2DefaultStr(dataKey,"").split("\\.");
String departmentId = department.getId() + ""; // int len = split.length;
if(CollectionUtils.isNotEmpty(childList)){ // if(len == 0 || StringUtils.isBlank(dataKey)){
List<String> collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList()); // return (T)response;
if(departmentWhiteList.contains(departmentId)){ // }
departmentWhiteList.addAll(collect); // for (int i = 0; i < len - 1; i++) {
}else if(subCompanyWhiteList.contains(departmentId)){ // response = (Map) response.get(split[i]);
subCompanyWhiteList.addAll(collect); // }
} // return (T) response.get(split[len - 1]);
parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment); // }
department.setChildList(null); //
} // @Test
if(n > maxLevel || departmentWhiteList.contains(departmentId)){ // public void testMsg(){
hrmDepartment.add(department); // String html = "<!DOCTYPE html>\n" +
}else { // "<html>\n" +
hrmSubCompany.add(department); // "<head>\n" +
} // "\t<title>Investment Calculator</title>\n" +
// "\t<style>\n" +
} // "\t\ttable {\n" +
} // "\t\t\tborder-collapse: collapse;\n" +
// "\t\t\twidth: 80%;\n" +
@Test // "\t\t\tmargin: 0 auto;\n" +
public void testParseObj(){ // "\t\t\tmargin-top: 50px;\n" +
String json = "{\n" + // "\t\t\tmargin-bottom: 50px;\n" +
" \"code\":0,\n" + // "\t\t}\n" +
" \"msg\":\"ok\",\n" + // "\t\tth, td {\n" +
" \"data\":\n" + // "\t\t\tborder: 1px solid black;\n" +
" {\n" + // "\t\t\tpadding: 10px;\n" +
" \"errcode\": 0,\n" + // "\t\t\ttext-align: center;\n" +
" \"errmsg\": \"ok\",\n" + // "\t\t}\n" +
" \"id\": \"1\",\n" + // "\t\tth {\n" +
" \"userid\": \"superAdmin\",\n" + // "\t\t\tbackground-color: #f2f2f2;\n" +
" \"name\": \"超级管理员\",\n" + // "\t\t}\n" +
" \"mobile\":\"12345678911\",\n" + // "\t\t.first-row {\n" +
" \"email\":\"123@321.com\",\n" + // "\t\t\ttext-align: center;\n" +
" \"gender\":0,\n" + // "\t\t\tfont-size: 24px;\n" +
" \"position\":\"position\",\n" + // "\t\t\tfont-weight: bold;\n" +
" \"avatarImg\":\"avatarImg\",\n" + // "\t\t\theight: 50px;\n" +
" \"workPhone\":\"workPhone\",\n" + // "\t\t\tline-height: 50px;\n" +
" \"fixedTelephone\":\"fixedTelephone\",\n" + // "\t\t}\n" +
" \"extName\":\"extName\",\n" + // "\t</style>\n" +
" \"userType\":0,\n" + // "</head>\n" +
" \"department\": [\n" + // "<body>\n" +
" 1\n" + // "\t<table>\n" +
" ],\n" + // "\t\t<tr class=\"first-row\">\n" +
" \"order\": [\n" + // "\t\t\t<td colspan=\"26\">投资试算(场外基金)</td>\n" +
" 0\n" + // "\t\t</tr>\n" +
" ],\n" + // "\t\t<tr>\n" +
" \"rank\":\"rank\"\n" + // "\t\t\t<td>A</td>\n" +
" }\n" + // "\t\t\t<td>B</td>\n" +
"}"; // "\t\t\t<td>C</td>\n" +
Map response = JSONObject.parseObject(json, Map.class); // "\t\t\t<td>D</td>\n" +
String obj = Util.null2DefaultStr(getObj("data.id", response),""); // "\t\t\t<td>E</td>\n" +
System.out.println("obj => " + obj); // "\t\t\t<td>F</td>\n" +
} // "\t\t\t<td>G</td>\n" +
// "\t\t\t<td>H</td>\n" +
public <T> T getObj(String dataKey, Map<String, Object> response){ // "\t\t\t<td>I</td>\n" +
String[] split = Util.null2DefaultStr(dataKey,"").split("\\."); // "\t\t\t<td>J</td>\n" +
int len = split.length; // "\t\t\t<td>K</td>\n" +
if(len == 0 || StringUtils.isBlank(dataKey)){ // "\t\t\t<td>L</td>\n" +
return (T)response; // "\t\t\t<td>M</td>\n" +
} // "\t\t\t\n" +
for (int i = 0; i < len - 1; i++) { // "\t\t</tr>\n" +
response = (Map) response.get(split[i]); // "\t\t<tr>\n" +
} // "\t\t\t<td>Cell A1</td>\n" +
return (T) response.get(split[len - 1]); // "\t\t\t<td>Cell B1</td>\n" +
} // "\t\t\t<td>Cell C1</td>\n" +
// "\t\t\t<td>Cell D1</td>\n" +
@Test // "\t\t\t<td>Cell E1</td>\n" +
public void testMsg(){ // "\t\t\t<td>Cell F1</td>\n" +
String html = "<!DOCTYPE html>\n" + // "\t\t\t<td>Cell G1</td>\n" +
"<html>\n" + // "\t\t\t<td>Cell H1</td>\n" +
"<head>\n" + // "\t\t\t<td>Cell I1</td>\n" +
"\t<title>Investment Calculator</title>\n" + // "\t\t\t<td>Cell J1</td>\n" +
"\t<style>\n" + // "\t\t\t<td>Cell K1</td>\n" +
"\t\ttable {\n" + // "\t\t\t<td>Cell L1</td>\n" +
"\t\t\tborder-collapse: collapse;\n" + // "\t\t\t<td>Cell M1</td>\n" +
"\t\t\twidth: 80%;\n" + // "\t\t\n" +
"\t\t\tmargin: 0 auto;\n" + // "\t\t</tr>\n" +
"\t\t\tmargin-top: 50px;\n" + // " \t</table>\n" +
"\t\t\tmargin-bottom: 50px;\n" + // " </body>\n" +
"\t\t}\n" + // "\n";
"\t\tth, td {\n" + // EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html);
"\t\t\tborder: 1px solid black;\n" + //
"\t\t\tpadding: 10px;\n" + // }
"\t\t\ttext-align: center;\n" + private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class);
"\t\t}\n" +
"\t\tth {\n" +
"\t\t\tbackground-color: #f2f2f2;\n" +
"\t\t}\n" +
"\t\t.first-row {\n" +
"\t\t\ttext-align: center;\n" +
"\t\t\tfont-size: 24px;\n" +
"\t\t\tfont-weight: bold;\n" +
"\t\t\theight: 50px;\n" +
"\t\t\tline-height: 50px;\n" +
"\t\t}\n" +
"\t</style>\n" +
"</head>\n" +
"<body>\n" +
"\t<table>\n" +
"\t\t<tr class=\"first-row\">\n" +
"\t\t\t<td colspan=\"26\">投资试算(场外基金)</td>\n" +
"\t\t</tr>\n" +
"\t\t<tr>\n" +
"\t\t\t<td>A</td>\n" +
"\t\t\t<td>B</td>\n" +
"\t\t\t<td>C</td>\n" +
"\t\t\t<td>D</td>\n" +
"\t\t\t<td>E</td>\n" +
"\t\t\t<td>F</td>\n" +
"\t\t\t<td>G</td>\n" +
"\t\t\t<td>H</td>\n" +
"\t\t\t<td>I</td>\n" +
"\t\t\t<td>J</td>\n" +
"\t\t\t<td>K</td>\n" +
"\t\t\t<td>L</td>\n" +
"\t\t\t<td>M</td>\n" +
"\t\t\t\n" +
"\t\t</tr>\n" +
"\t\t<tr>\n" +
"\t\t\t<td>Cell A1</td>\n" +
"\t\t\t<td>Cell B1</td>\n" +
"\t\t\t<td>Cell C1</td>\n" +
"\t\t\t<td>Cell D1</td>\n" +
"\t\t\t<td>Cell E1</td>\n" +
"\t\t\t<td>Cell F1</td>\n" +
"\t\t\t<td>Cell G1</td>\n" +
"\t\t\t<td>Cell H1</td>\n" +
"\t\t\t<td>Cell I1</td>\n" +
"\t\t\t<td>Cell J1</td>\n" +
"\t\t\t<td>Cell K1</td>\n" +
"\t\t\t<td>Cell L1</td>\n" +
"\t\t\t<td>Cell M1</td>\n" +
"\t\t\n" +
"\t\t</tr>\n" +
" \t</table>\n" +
" </body>\n" +
"\n";
EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html);
}
@Test @Test
public void testG(){ public void testG(){
// String sql =" select case '$t{test1}' when '03' then '场外基金' when '04' then '基金赎回' else '测试下' end"; String oaOutKey = "111";
// HashMap<String, Object> param = new HashMap<>(); String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}";
// param.put("test1","04"); int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey);
// String s = orgHrmAsyncMapper.selectCustomerSql(sql, param); log.info("id => " + id);
// System.out.println("s => " + s);
HashMap<String, Object> map = new HashMap<>();
map.put("tiem", new Date());
System.out.println("map => " + JSONObject.toJSONString(map));
} }
} }

View File

@ -1,6 +1,7 @@
package xuanran.wang.cssc; package xuanran.wang.cssc;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.util.HttpUtils;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
@ -201,4 +202,9 @@ public class FileTest extends BaseTest {
} }
} }
@Test
public void testB(){
HttpUtils httpUtils = new HttpUtils();
}
} }

View File

@ -1,12 +1,24 @@
package xuanran.wang.eighty_five_degreec; package xuanran.wang.eighty_five_degreec;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.tool.cn.hutool.core.lang.UUID; import aiyh.utils.tool.cn.hutool.core.lang.UUID;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.excel.util.CollectionUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;
import org.junit.Test; import org.junit.Test;
import weaver.general.GCONST;
import weaver.general.Util;
import weaver.xuanran.wang.common.util.CusData2OA; import weaver.xuanran.wang.common.util.CusData2OA;
import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig;
import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService;
import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl;
import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil; import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -20,15 +32,116 @@ import java.util.Map;
*/ */
public class SAPTest extends BaseTest { public class SAPTest extends BaseTest {
private final WorkflowToSapService service = new WorkflowToSapServiceImpl();
@Test @Test
public void testXml(){ public void testXml(){
ReadConfigUtil configUtil = new ReadConfigUtil();
String uniqueCode = "test1"; String uniqueCode = "test1";
String tableName = "formtable_main_161"; String billTable = "formtable_main_161";
String requestId = "419420"; String requestId = "419420";
MainRequestConfig config = configUtil.getConfigByUniqueCode(uniqueCode, tableName);
String xml = configUtil.getXml(config, requestId, tableName); String response = "";
System.out.println("xml => \n " + xml); String url = "";
String error = "";
String xml = "";
boolean success = true;
String modelId = "119";
String successField = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.TYPE";
String successVal = "N";
String messageField = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.MESSAGE";
try {
MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable);
url = config.getRequestUrl();
xml = service.convertXml(config, requestId, billTable);
// response = service.sendToSap(config.getRequestUrl(), xml);
response = "<soap-env:Envelope\n" +
" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap-env:Header/>\n" +
" <soap-env:Body>\n" +
" <n0:ZFI_OA_DOC_POSTINGResponse\n" +
" xmlns:n0=\"urn:sap-com:document:sap:rfc:functions\">\n" +
" <ES_OA_OUTPUT>\n" +
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
" <BELNR/>\n" +
" <BUKRS>1200</BUKRS>\n" +
" <BUDAT>2023-05-01</BUDAT>\n" +
" <BKTXT>t?·???????é??è????¨</BKTXT>\n" +
" <TYPE>E</TYPE>\n" +
" <MESSAGE> 1000 上不存在成本中心 1200180001/2023/05/01 。</MESSAGE>\n" +
" <ERDAT>2023-05-15</ERDAT>\n" +
" <ERZET>13:46:11</ERZET>\n" +
" </ES_OA_OUTPUT>\n" +
" <IT_OA_ITEMS>\n" +
" <item>\n" +
" <ZOAPZ>clbx000002</ZOAPZ>\n" +
" <ZOAXM>1</ZOAXM>\n" +
" <SGTXT>item1</SGTXT>\n" +
" <LIFNR>CN07010001</LIFNR>\n" +
" <HKONT/>\n" +
" <KOSTL/>\n" +
" <PSWBT>123.23</PSWBT>\n" +
" <PSWSL>CNY</PSWSL>\n" +
" <SHKZG>H</SHKZG>\n" +
" <BOAPZ>string..............</BOAPZ>\n" +
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
" </item>\n" +
" <item>\n" +
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
" <ZOAXM>2</ZOAXM>\n" +
" <SGTXT>item2</SGTXT>\n" +
" <LIFNR/>\n" +
" <HKONT>90010601</HKONT>\n" +
" <KOSTL>1200180001</KOSTL>\n" +
" <PSWBT>100.23</PSWBT>\n" +
" <PSWSL>CNY</PSWSL>\n" +
" <SHKZG>S</SHKZG>\n" +
" <BOAPZ>string..............</BOAPZ>\n" +
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
" </item>\n" +
" <item>\n" +
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
" <ZOAXM>3</ZOAXM>\n" +
" <SGTXT>item3</SGTXT>\n" +
" <LIFNR/>\n" +
" <HKONT>90010602</HKONT>\n" +
" <KOSTL>1200180001</KOSTL>\n" +
" <PSWBT>23.0</PSWBT>\n" +
" <PSWSL>CNY</PSWSL>\n" +
" <SHKZG>S</SHKZG>\n" +
" <BOAPZ>string..............</BOAPZ>\n" +
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
" </item>\n" +
" </IT_OA_ITEMS>\n" +
" </n0:ZFI_OA_DOC_POSTINGResponse>\n" +
" </soap-env:Body>\n" +
"</soap-env:Envelope>";
response = service.parseResponse(response, successField, successVal, messageField);
}catch (Exception e){
log.error("流程数据推送SAP error : " + e.getMessage());
error = e.getMessage();
success = false;
}
try {
service.logToOA(modelId, url, requestId, xml, response, error);
}catch (Exception e){
log.error("日志数据写入建模失败! " + e.getMessage());
}
if(!success){
throw new CustomerException("WorkflowToSap Action execute error : " + error);
}
} }
@Test @Test
@ -49,4 +162,149 @@ public class SAPTest extends BaseTest {
List<String> strings = CusData2OA.batchWriteToModel(modelId, sql, list); List<String> strings = CusData2OA.batchWriteToModel(modelId, sql, list);
System.out.println("data => " + strings); System.out.println("data => " + strings);
} }
@Test
public void testResponse() throws JSONException {
String response = "<soap-env:Envelope\n" +
" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap-env:Header/>\n" +
" <soap-env:Body>\n" +
" <n0:ZFI_OA_DOC_POSTINGResponse\n" +
" xmlns:n0=\"urn:sap-com:document:sap:rfc:functions\">\n" +
" <ES_OA_OUTPUT>\n" +
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
" <BELNR/>\n" +
" <BUKRS>1200</BUKRS>\n" +
" <BUDAT>2023-05-01</BUDAT>\n" +
" <BKTXT>t?·???????é??è????¨</BKTXT>\n" +
" <TYPE>E</TYPE>\n" +
" <MESSAGE> 1000 上不存在成本中心 1200180001/2023/05/01 。</MESSAGE>\n" +
" <ERDAT>2023-05-15</ERDAT>\n" +
" <ERZET>13:46:11</ERZET>\n" +
" </ES_OA_OUTPUT>\n" +
" <IT_OA_ITEMS>\n" +
" <item>\n" +
" <ZOAPZ>clbx000002</ZOAPZ>\n" +
" <ZOAXM>1</ZOAXM>\n" +
" <SGTXT>item1</SGTXT>\n" +
" <LIFNR>CN07010001</LIFNR>\n" +
" <HKONT/>\n" +
" <KOSTL/>\n" +
" <PSWBT>123.23</PSWBT>\n" +
" <PSWSL>CNY</PSWSL>\n" +
" <SHKZG>H</SHKZG>\n" +
" <BOAPZ>string..............</BOAPZ>\n" +
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
" </item>\n" +
" <item>\n" +
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
" <ZOAXM>2</ZOAXM>\n" +
" <SGTXT>item2</SGTXT>\n" +
" <LIFNR/>\n" +
" <HKONT>90010601</HKONT>\n" +
" <KOSTL>1200180001</KOSTL>\n" +
" <PSWBT>100.23</PSWBT>\n" +
" <PSWSL>CNY</PSWSL>\n" +
" <SHKZG>S</SHKZG>\n" +
" <BOAPZ>string..............</BOAPZ>\n" +
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
" </item>\n" +
" <item>\n" +
" <ZOAPZ>clbx000003</ZOAPZ>\n" +
" <ZOAXM>3</ZOAXM>\n" +
" <SGTXT>item3</SGTXT>\n" +
" <LIFNR/>\n" +
" <HKONT>90010602</HKONT>\n" +
" <KOSTL>1200180001</KOSTL>\n" +
" <PSWBT>23.0</PSWBT>\n" +
" <PSWSL>CNY</PSWSL>\n" +
" <SHKZG>S</SHKZG>\n" +
" <BOAPZ>string..............</BOAPZ>\n" +
" <RESE_FIELD_1>string..............</RESE_FIELD_1>\n" +
" <RESE_FIELD_2>string..............</RESE_FIELD_2>\n" +
" <RESE_FIELD_3>string..............</RESE_FIELD_3>\n" +
" <RESE_FIELD_4>string..............</RESE_FIELD_4>\n" +
" <RESE_FIELD_5>string..............</RESE_FIELD_5>\n" +
" </item>\n" +
" </IT_OA_ITEMS>\n" +
" </n0:ZFI_OA_DOC_POSTINGResponse>\n" +
" </soap-env:Body>\n" +
"</soap-env:Envelope>";
JSONObject xmlResponseObj = XML.toJSONObject(response);
log.info("接口响应 : \n" + xmlResponseObj);
Map<String, Object> responseMap = com.alibaba.fastjson.JSONObject.parseObject(xmlResponseObj.toString(), Map.class);
System.out.println("responseMap : " + com.alibaba.fastjson.JSONObject.toJSONString(responseMap));
// code = Util.null2String(parseMap(responseMap, RESPONSE_CODE));
// if(!successCode.equals(code)){
// throw new RuntimeException("推送erp接口失败! " + Util.null2String(readConfigUtil.parseMap(responseMap, RESPONSE_DESCRIPTION)));
// }
}
/**
* <h1></h1>
* @param responseMap map
* @param responseField map Response.Execution
* @return
*/
public String parseMap(Map<String, Object> responseMap, String responseField){
String[] strArr = responseField.split("\\.");
int i = 0;
while (i < strArr.length - 1){
Object o = responseMap.get(strArr[i]);
if(o instanceof Map){
responseMap = (Map<String, Object>) o;
}else if(o instanceof List){
List<Map<String, Object>> list = (List<Map<String, Object>>) o;
if(CollectionUtils.isEmpty(list)){
return "";
}
responseMap = list.get(0);
}
i++;
}
return Util.null2String(responseMap.get(strArr[strArr.length - 1]));
}
@Test
public void testB(){
String path = "sap.sap.xml";
System.out.println(parseConfigPath(path));
}
/**
* <h1>xml</h1>
* wxr.memsic.test.xml = /wxr/memsic/test.xml
* @param configFilePath
* @return
*/
public String parseConfigPath(String configFilePath){
StringBuilder filePath = new StringBuilder(GCONST.getSysFilePath());
int beginIndex = configFilePath.indexOf(".");
int endIndex = configFilePath.lastIndexOf(".");
if(beginIndex == endIndex){
filePath.append(configFilePath);
}else {
String[] pathArr = configFilePath.split("\\.");
for (int i = 0; i < pathArr.length - 2; i++) {
if(i != 0){
filePath.append(File.separator);
}
filePath.append(pathArr[i]);
}
filePath.append(File.separator)
.append(pathArr[pathArr.length - 2])
.append(".")
.append(pathArr[pathArr.length - 1]);
}
return filePath.toString();
}
} }

View File

@ -0,0 +1,19 @@
package xuanran.wang.http_test.annotations;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/5/25 14:42
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface CusJsonMappingConfig {
String configCode() default "";
String tableName() default "";
}

View File

@ -15,5 +15,5 @@ import java.lang.annotation.*;
@Target({ElementType.METHOD, ElementType.TYPE}) @Target({ElementType.METHOD, ElementType.TYPE})
@Documented @Documented
public @interface CusReqAfterHandleRegister { public @interface CusReqAfterHandleRegister {
Class<?> afterHandle(); Class<?>[] afterHandle();
} }

View File

@ -23,4 +23,6 @@ public @interface CusRequestPost {
@AliasFor(annotation = CusRequestType.class, attribute = "requestType") @AliasFor(annotation = CusRequestType.class, attribute = "requestType")
int requestType() default CusRequestClientConstant.POST; int requestType() default CusRequestClientConstant.POST;
String configCode() default "";
} }

View File

@ -7,7 +7,9 @@ import lombok.Setter;
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle; import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
import xuanran.wang.http_test.handle.CusRequestAfterHandle; import xuanran.wang.http_test.handle.CusRequestAfterHandle;
import java.lang.reflect.Type;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -31,8 +33,8 @@ public class CusRequestEntity{
private boolean async = false; private boolean async = false;
private String host = ""; private String host = "";
private int port; private int port;
private Class<?> returnType; private Type returnType;
private CusRequestAfterHandle cusRequestAfter; private List<CusRequestAfterHandle> cusRequestAfter;
private CusResponseSuccessHandle responseSuccessHandle; private CusResponseSuccessHandle responseSuccessHandle;
private Map<String, Object> responseMap; private Map<String, Object> responseMap;
} }

View File

@ -7,6 +7,7 @@ import aiyh.utils.tool.cn.hutool.core.annotation.AnnotationUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister; import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister;
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle; import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
@ -85,16 +86,17 @@ public class CusHandleCenter{
} }
public Object requestAfterHandle(Method method, CusRequestEntity cusRequest, ResponeVo responseVo){ public Object requestAfterHandle(Method method, CusRequestEntity cusRequest, ResponeVo responseVo){
if(cusRequest.getCusRequestAfter() == null){ CusReqAfterHandleRegister cusReqAfterHandleRegister = method.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
CusReqAfterHandleRegister cusReqAfterHandleRegister = method.getDeclaredAnnotation(CusReqAfterHandleRegister.class); if(cusReqAfterHandleRegister != null){
if(cusReqAfterHandleRegister != null){ RequestUtil.setCusRequestAfter(cusReqAfterHandleRegister, cusRequest);
RequestUtil.setCusRequestAfter(cusReqAfterHandleRegister, cusRequest); }else {
} List<CusRequestAfterHandle> tempList = new ArrayList<>();
tempList.add(new CusDefaultRequestAfterHandle());
cusRequest.setCusRequestAfter(tempList);
} }
// Type genericReturnType = method.getGenericReturnType(); cusRequest.setReturnType(method.getGenericReturnType());
cusRequest.setReturnType(method.getReturnType());
CusResponseSuccessHandle cusResponseSuccessHandle = method.getDeclaredAnnotation(CusResponseSuccessHandle.class); CusResponseSuccessHandle cusResponseSuccessHandle = method.getDeclaredAnnotation(CusResponseSuccessHandle.class);
if(cusResponseSuccessHandle != null && cusRequest.getResponseSuccessHandle() == null){ if(cusResponseSuccessHandle != null && cusRequest.getResponseSuccessHandle() != null){
cusRequest.setResponseSuccessHandle(cusResponseSuccessHandle); cusRequest.setResponseSuccessHandle(cusResponseSuccessHandle);
} }
return requestAfterHandle(cusRequest, responseVo); return requestAfterHandle(cusRequest, responseVo);
@ -113,11 +115,19 @@ public class CusHandleCenter{
responseVo.getEntityString())); responseVo.getEntityString()));
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // throw new CustomerException(Util.logStr("can not fetch [{}]", url)); //
} }
CusRequestAfterHandle handle = cusRequest.getCusRequestAfter() == null ? new CusDefaultRequestAfterHandle() : cusRequest.getCusRequestAfter(); cusRequest.setResponseMap(responseVo.getResponseMap());
cusRequest.setCusRequestAfter(handle); List<CusRequestAfterHandle> cusRequestAfter = cusRequest.getCusRequestAfter();
Object res = null;
log.info(Util.logStr("cusRequest: {}", JSONObject.toJSONString(cusRequest))); log.info(Util.logStr("cusRequest: {}", JSONObject.toJSONString(cusRequest)));
Object res = handle.parseResponse(cusRequest, responseVo); for (CusRequestAfterHandle handle : cusRequestAfter) {
handle.service(cusRequest, responseVo); if(RequestUtil.isMethodOverridden(handle.getClass(), CusDefaultRequestAfterHandle.class, "parseResponse")){
res = handle.parseResponse(cusRequest, responseVo);
}else {
CusDefaultRequestAfterHandle defaultRequestAfterHandle = new CusDefaultRequestAfterHandle();
res = defaultRequestAfterHandle.parseResponse(cusRequest, responseVo);
}
handle.service(cusRequest, responseVo);
}
return res; return res;
} }

View File

@ -25,11 +25,10 @@ public abstract class CusRequestHandle {
realRequestUrl.append(url); realRequestUrl.append(url);
}else { }else {
realRequestUrl.append(host); realRequestUrl.append(host);
if(!host.endsWith(":")){ if(port > 0 && !host.endsWith(":")){
realRequestUrl.append(":"); realRequestUrl.append(":").append(port);
} }
realRequestUrl.append(port); if(!host.endsWith("/") && !url.startsWith("/")){
if(!url.endsWith("/")){
realRequestUrl.append("/"); realRequestUrl.append("/");
} }
realRequestUrl.append(url); realRequestUrl.append(url);

View File

@ -72,10 +72,14 @@ public class RequestHeaderHandle implements CusRequestBeforeHandle {
Parameter parameter = parameters[i]; Parameter parameter = parameters[i];
CusRequestHeader requestHeader = parameter.getAnnotation(CusRequestHeader.class); CusRequestHeader requestHeader = parameter.getAnnotation(CusRequestHeader.class);
if(requestHeader != null){ if(requestHeader != null){
String val = Util.null2DefaultStr(args[i], "").trim(); if(Map.class.isAssignableFrom(parameter.getType())){
String key = requestHeader.value().trim(); headers.putAll((Map<? extends String, ? extends String>) args[i]);
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){ }else {
headers.put(key, val); String val = Util.null2DefaultStr(args[i], "").trim();
String key = requestHeader.value().trim();
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){
headers.put(key, val);
}
} }
} }
} }

View File

@ -10,6 +10,7 @@ import xuanran.wang.http_test.constant.CusRequestClientConstant;
import xuanran.wang.http_test.entity.CusRequestEntity; import xuanran.wang.http_test.entity.CusRequestEntity;
import xuanran.wang.http_test.handle.CusRequestAfterHandle; import xuanran.wang.http_test.handle.CusRequestAfterHandle;
import java.lang.reflect.Type;
import java.util.Map; import java.util.Map;
/** /**
@ -22,12 +23,11 @@ public class CusDefaultRequestAfterHandle implements CusRequestAfterHandle {
@Override @Override
public Object parseResponse(CusRequestEntity cusRequest, ResponeVo responseVo) { public Object parseResponse(CusRequestEntity cusRequest, ResponeVo responseVo) {
Class<?> returnType = cusRequest.getReturnType(); Type returnType = cusRequest.getReturnType();
if(ResponeVo.class.isAssignableFrom(returnType)) { if(ResponeVo.class.isAssignableFrom(returnType.getClass())) {
return responseVo; return responseVo;
} }
String json = responseVo.getEntityString(); String json = responseVo.getEntityString();
cusRequest.setResponseMap(responseVo.getResponseMap());
CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle(); CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle();
if(responseSuccessHandle != null){ if(responseSuccessHandle != null){
String successCondition = responseSuccessHandle.successCondition(); String successCondition = responseSuccessHandle.successCondition();

View File

@ -8,6 +8,8 @@ import xuanran.wang.http_test.entity.CusRequestEntity;
import xuanran.wang.http_test.handle.CusRequestBeforeHandle; import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/** /**
* <h1></h1> * <h1></h1>
@ -23,7 +25,6 @@ public class CusUrlHandle implements CusRequestBeforeHandle {
throw new CustomerException("method not found CusRequestUrl!"); throw new CustomerException("method not found CusRequestUrl!");
} }
cusRequest.setUrl(requestUrl.url()); cusRequest.setUrl(requestUrl.url());
Class<?> returnType = method.getReturnType(); cusRequest.setReturnType(method.getGenericReturnType());
cusRequest.setReturnType(returnType);
} }
} }

View File

@ -17,6 +17,8 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
/** /**
@ -29,12 +31,13 @@ public class RequestUtil implements InvocationHandler {
private CusRequestAddress cusRequestAddress = null; private CusRequestAddress cusRequestAddress = null;
private final Logger log = Util.getLogger(); private final Logger log = Util.getLogger();
private final CusHandleCenter handleCenter = new CusHandleCenter(); private final CusHandleCenter handleCenter = new CusHandleCenter();
private final CusRequestEntity cusRequest = new CusRequestEntity(); private CusRequestEntity cusRequest;
public <T> T getRequestClient(Class<?> clazz){ public <T> T getRequestClient(Class<?> clazz){
Annotation annotation = clazz.getDeclaredAnnotation(CusRequestClient.class); Annotation annotation = clazz.getDeclaredAnnotation(CusRequestClient.class);
if(annotation == null){ if(annotation == null){
throw new CustomerException(Util.logStr(clazz.getName() + " not found CusRequestClient annotation!")); throw new CustomerException(Util.logStr(clazz.getName() + " not found CusRequestClient annotation!"));
} }
cusRequest = new CusRequestEntity();
// 请求后处理 // 请求后处理
CusReqAfterHandleRegister cusReqAfterHandleRegister = clazz.getDeclaredAnnotation(CusReqAfterHandleRegister.class); CusReqAfterHandleRegister cusReqAfterHandleRegister = clazz.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
if(cusReqAfterHandleRegister != null){ if(cusReqAfterHandleRegister != null){
@ -62,7 +65,6 @@ public class RequestUtil implements InvocationHandler {
cusRequest.setPort(port); cusRequest.setPort(port);
} }
handleCenter.requestBeforeHandle(cusRequest, method, args); handleCenter.requestBeforeHandle(cusRequest, method, args);
log.info("requestHandle : \n" + JSONObject.toJSONString(cusRequest));
ResponeVo responeVo = handleCenter.requestHandle(cusRequest, method); ResponeVo responeVo = handleCenter.requestHandle(cusRequest, method);
return handleCenter.requestAfterHandle(method, cusRequest, responeVo); return handleCenter.requestAfterHandle(method, cusRequest, responeVo);
} }
@ -70,16 +72,33 @@ public class RequestUtil implements InvocationHandler {
public static void setCusRequestAfter(CusReqAfterHandleRegister cusReqAfterHandleRegister, public static void setCusRequestAfter(CusReqAfterHandleRegister cusReqAfterHandleRegister,
CusRequestEntity cusRequest){ CusRequestEntity cusRequest){
if(cusReqAfterHandleRegister != null){ if(cusReqAfterHandleRegister != null){
Class<?> clazz = cusReqAfterHandleRegister.afterHandle(); Class<?>[] clazz = cusReqAfterHandleRegister.afterHandle();
if (CusRequestAfterHandle.class.isAssignableFrom(clazz)) { List<CusRequestAfterHandle> requestAfter = cusRequest.getCusRequestAfter();
try { if(requestAfter == null){
Object cusRequestAfter = clazz.newInstance(); requestAfter = new ArrayList<>();
cusRequest.setCusRequestAfter((CusRequestAfterHandle) cusRequestAfter); }
}catch (Exception e){ cusRequest.setCusRequestAfter(requestAfter);
throw new CustomerException(Util.logStr("class : {}, newInstance error!", e.getMessage())); for (Class<?> aClass : clazz) {
if (CusRequestAfterHandle.class.isAssignableFrom(aClass)) {
try {
CusRequestAfterHandle cusRequestAfter = (CusRequestAfterHandle) aClass.newInstance();
requestAfter.add(cusRequestAfter);
}catch (Exception e){
throw new CustomerException(Util.logStr("class : {}, newInstance error!", e.getMessage()));
}
} }
} }
} }
} }
public static boolean isMethodOverridden(Class<?> subclass, Class<?> superclass, String methodName) {
try {
Method method = subclass.getDeclaredMethod(methodName);
Method superMethod = superclass.getDeclaredMethod(methodName);
return !method.equals(superMethod);
} catch (NoSuchMethodException e) {
return false;
}
}
} }

View File

@ -0,0 +1,27 @@
package xuanran.wang.http_test.service;
import xuanran.wang.http_test.annotations.CusRequestClient;
import xuanran.wang.http_test.annotations.header.CusRequestHeader;
import xuanran.wang.http_test.annotations.request_type.CusRequestPost;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/5/24 14:53
*/
@CusRequestClient(host = "https://ecology.yeyaguitu.cn")
public interface EcTestService {
@CusRequestPost(url = "/api/ec/dev/auth/regist")
@CusRequestHeader(cusHeaders = {"appid:JYZ", "loginid:sysadmin","Content-type:"+ MediaType.APPLICATION_JSON})
Map<String, Object> register();
@CusRequestPost(url = "/api/ec/dev/auth/regist")
@CusRequestHeader(cusHeaders = {"Content-type:"+ MediaType.APPLICATION_JSON})
Map<String, Object> register(@CusRequestHeader("appid") String appId,
@CusRequestHeader Map<String, String> headers);
}

View File

@ -2,12 +2,15 @@ package xuanran.wang.http_test.service;
import xuanran.wang.http_test.annotations.*; import xuanran.wang.http_test.annotations.*;
import xuanran.wang.http_test.annotations.body.CusRequestBody; import xuanran.wang.http_test.annotations.body.CusRequestBody;
import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister;
import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle; import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
import xuanran.wang.http_test.annotations.header.CusRequestHeader; import xuanran.wang.http_test.annotations.header.CusRequestHeader;
import xuanran.wang.http_test.annotations.request_path.CusPathQuery; import xuanran.wang.http_test.annotations.request_path.CusPathQuery;
import xuanran.wang.http_test.annotations.request_type.CusRequestGet; import xuanran.wang.http_test.annotations.request_type.CusRequestGet;
import xuanran.wang.http_test.annotations.request_type.CusRequestPost; import xuanran.wang.http_test.annotations.request_type.CusRequestPost;
import xuanran.wang.http_test.constant.CusRequestClientConstant; import xuanran.wang.http_test.constant.CusRequestClientConstant;
import xuanran.wang.http_test.test.Student;
import xuanran.wang.http_test.test.TestRequestAfterHandle;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -19,7 +22,6 @@ import java.util.Map;
* @date 2023/3/10 12:39 * @date 2023/3/10 12:39
*/ */
@CusRequestClient(host = "http://114.115.168.220", port = 8191) @CusRequestClient(host = "http://114.115.168.220", port = 8191)
//@CusReqAfterHandleRegister(afterHandle = TestRequestAfterHandle.class)
public interface TestService { public interface TestService {
@CusRequestGet(url = "educate-plat/api/v1/class/getClassList") @CusRequestGet(url = "educate-plat/api/v1/class/getClassList")
@ -30,8 +32,9 @@ public interface TestService {
errorMsg = "msg", errorMsg = "msg",
data = "data" data = "data"
) )
Map<String, Object> getStu(Map<String, Object> path, @CusReqAfterHandleRegister(afterHandle = {TestRequestAfterHandle.class})
@CusRequestBody Map<String, Object> body, List<Student> getStu(Map<String, Object> path,
@CusRequestHeader("hsjhdsad") String test, @CusRequestBody Map<String, Object> body,
@CusPathQuery("test") String test1); @CusRequestHeader("hsjhdsad") String test,
@CusPathQuery("test") String test1);
} }

View File

@ -2,6 +2,7 @@ package xuanran.wang.http_test.test;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.api.doc.migrate.util.FtpUtil; import com.api.doc.migrate.util.FtpUtil;
import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.ChannelSftp;
import org.junit.Test; import org.junit.Test;
@ -9,6 +10,7 @@ import weaver.backup.utils.ZipUtil;
import xuanran.wang.http_test.entity.CusHandleEntity; import xuanran.wang.http_test.entity.CusHandleEntity;
import xuanran.wang.http_test.handle.util.HandleUtil; import xuanran.wang.http_test.handle.util.HandleUtil;
import xuanran.wang.http_test.proxy.CusUtil; import xuanran.wang.http_test.proxy.CusUtil;
import xuanran.wang.http_test.service.EcTestService;
import xuanran.wang.http_test.service.TestService; import xuanran.wang.http_test.service.TestService;
import java.util.*; import java.util.*;
@ -23,6 +25,7 @@ import java.util.stream.Collectors;
public class RequestTest extends BaseTest { public class RequestTest extends BaseTest {
private TestService requestClient = CusUtil.getRequestClient(TestService.class); private TestService requestClient = CusUtil.getRequestClient(TestService.class);
private EcTestService ecTestService = CusUtil.getRequestClient(EcTestService.class);
@Test @Test
public void test(){ public void test(){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
@ -36,9 +39,11 @@ public class RequestTest extends BaseTest {
path.put("e","5"); path.put("e","5");
path.put("f","6"); path.put("f","6");
Map<String, Object> stu = requestClient.getStu(map, body, "a", "test1111"); // List<Student> stu = requestClient.getStu(map, body, "a", "test1111");
log.info("stu : \n" + JSONObject.toJSONString(stu)); List<Student> stu = requestClient.getStu(map, body, "a", "test1111");
for (Student student : stu) {
System.out.println("stu => " + student);
}
// String json = "{\"xuanran.wang.http_test.requestBeforeHandle.path_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.CusPathParseHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"},{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.TestHandle\",\"order\":99,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"}],\"xuanran.wang.http_test.requestBeforeHandle.header_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle.RequestHeaderHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle\"}]}"; // String json = "{\"xuanran.wang.http_test.requestBeforeHandle.path_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.CusPathParseHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"},{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.TestHandle\",\"order\":99,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"}],\"xuanran.wang.http_test.requestBeforeHandle.header_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle.RequestHeaderHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle\"}]}";
// System.out.println(JSONObject.parseObject(JSONObject.toJSONString(json), Map.class)); // System.out.println(JSONObject.parseObject(JSONObject.toJSONString(json), Map.class));
// String stu1 = requestClient.getStu(body); // String stu1 = requestClient.getStu(body);
@ -61,4 +66,16 @@ public class RequestTest extends BaseTest {
} }
} }
@Test
public void testB(){
Map<String, Object> register = ecTestService.register();
System.out.printf("register : " + JSONObject.toJSONString(register));
HashMap<String, String> header = new HashMap<>();
header.put("loginid","123");
header.put("dadsada","sasas");
Map<String, Object> register1 = ecTestService.register("JYZ1", header);
System.out.printf("register1 : " + JSONObject.toJSONString(register1));
}
} }

View File

@ -0,0 +1,49 @@
package xuanran.wang.http_test.test;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/5/23 11:40
*/
public class Student {
private String teacherId;
private int belongYear;
private String classNo;
private String className;
private String id;
public void setTeacherId(String teacherId) {
this.teacherId = teacherId;
}
public String getTeacherId() {
return teacherId;
}
public void setBelongYear(int belongYear) {
this.belongYear = belongYear;
}
public int getBelongYear() {
return belongYear;
}
public void setClassNo(String classNo) {
this.classNo = classNo;
}
public String getClassNo() {
return classNo;
}
public void setClassName(String className) {
this.className = className;
}
public String getClassName() {
return className;
}
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
}