diff --git a/javascript/xuanran.wang/bme/js/BuildContractApply.js b/javascript/xuanran.wang/bme/js/BuildContractApply.js
index c8df318..f328f1b 100644
--- a/javascript/xuanran.wang/bme/js/BuildContractApply.js
+++ b/javascript/xuanran.wang/bme/js/BuildContractApply.js
@@ -22,6 +22,7 @@ const detail2TempDateField = WfForm.convertFieldNameToId("dyrq", detailTable);
// 需要计算的款项类型集合
const computeDatePayType = ['0'];
const DETAIL_MAX_SIZE = 5;
+const readOnlyArr = ['0'];
// 款项类型预计对应日期取值
const paymentTypeGetValue = {
0: (index)=>{
@@ -36,7 +37,8 @@ jQuery().ready(function(){
'detailComPayDateId': detail2ComPayDateId,
'dayId': detail2DayId,
'computeDatePayType': computeDatePayType,
- 'paymentTypeGetValue': paymentTypeGetValue
+ 'paymentTypeGetValue': paymentTypeGetValue,
+ 'readOnlyArr': readOnlyArr
}
let rowArr = WfForm.getDetailAllRowIndexStr(detailTable).split(",");
@@ -49,7 +51,7 @@ jQuery().ready(function(){
addRowBack(2, configObj);
- changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, computeDatePayType)
+ changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, readOnlyArr)
// 主表字段发生变化
mainFieldChangeDetailCom(contractSignDateId, detailTable, configObj);
diff --git a/javascript/xuanran.wang/bme/js/Common.js b/javascript/xuanran.wang/bme/js/Common.js
index 5c432b3..583099e 100644
--- a/javascript/xuanran.wang/bme/js/Common.js
+++ b/javascript/xuanran.wang/bme/js/Common.js
@@ -60,6 +60,7 @@ function submitCallback(detailTable, detail2PayProportionId){
sum += parseFloat(WfForm.getFieldValue(field));//遍历明细行字段
}
}
+ console.log('sum => ', sum)
sum === 100.00 ? callback() : WfForm.showMessage("明细付款比例总和不等于100,请修改后提交!");
});
}
@@ -118,11 +119,18 @@ function changeDetailPayDate(obj){
let computeDatePayType = obj['computeDatePayType'];
// 获取主表的字符值转换函数
let paymentTypeGetValue = obj['paymentTypeGetValue'];
+ // 只读
+ let readOnlyArr = obj['readOnlyArr'];
// 款项类型
let paymentType = WfForm.getFieldValue(`${detailPaymentTypeId}_${index}`);
+ if(readOnlyArr.includes(paymentType)){
+ WfForm.changeFieldAttr(`${detailComPayDateId}_${index}`, READ_ONLY);
+ }else{
+ // 如果款项类型不需要计算就把预计付款日期属性改成可编辑
+ WfForm.changeFieldAttr(`${detailComPayDateId}_${index}`, EDIT);
+ }
// 先进行赋值
if(computeDatePayType.includes(paymentType)){
- WfForm.changeFieldAttr(`${detailComPayDateId}_${index}`, READ_ONLY);
// 存在字段联动延时处理
setTimeout(()=>{
if(paymentTypeGetValue){
@@ -142,16 +150,14 @@ function changeDetailPayDate(obj){
value: comDate
});
}
- }else {
- // 如果对应日期为空就给预计付款赋空值
- WfForm.changeFieldValue(`${detailComPayDateId}_${index}`,{
- value: ''
- });
}
+ // else {
+ // // 如果对应日期为空就给预计付款赋空值
+ // WfForm.changeFieldValue(`${detailComPayDateId}_${index}`,{
+ // value: ''
+ // });
+ // }
},100);
- }else{
- // 如果款项类型不需要计算就把预计付款日期属性改成可编辑
- WfForm.changeFieldAttr(`${detailComPayDateId}_${index}`, EDIT);
}
}
diff --git a/javascript/xuanran.wang/bme/js/DiaoBo.js b/javascript/xuanran.wang/bme/js/DiaoBo.js
new file mode 100644
index 0000000..a742e50
--- /dev/null
+++ b/javascript/xuanran.wang/bme/js/DiaoBo.js
@@ -0,0 +1,26 @@
+const zrckField = WfForm.convertFieldNameToId('zrck');
+const zcckField = WfForm.convertFieldNameToId('zcck');
+// 主表存货编码
+const mainStockSetField = WfForm.convertFieldNameToId('chbmjh');
+// 明细1存货编码字段
+const deail1StockSetField = WfForm.convertFieldNameToId('chbm','detail_1');
+jQuery(document).ready(function(){
+ WfForm.triggerFieldAllLinkage(zrckField);
+ WfForm.triggerFieldAllLinkage(zcckField);
+ initStockNo();
+});
+function initStockNo(){
+ var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
+ let arr = [];
+ for(var i=0; i{
+ WfForm.triggerFieldAllLinkage(mainStockSetField);
+ },500);
+}
\ No newline at end of file
diff --git a/javascript/xuanran.wang/bme/js/PayApply.js b/javascript/xuanran.wang/bme/js/PayApply.js
index fbe6238..3923e3f 100644
--- a/javascript/xuanran.wang/bme/js/PayApply.js
+++ b/javascript/xuanran.wang/bme/js/PayApply.js
@@ -3,30 +3,157 @@ const yjfksj = WfForm.convertFieldNameToId('yjfksj');
// 主表比例
const bl = WfForm.convertFieldNameToId('bcfkbl');
// 明细要求付款日期
-const detail3Yqfkrq = WfForm.convertFieldNameToId('yqfkrq',"detail_3");
+const detail3Yqfkrq = WfForm.convertFieldNameToId('yqfkrq', "detail_3");
// 明细本次付款比例
-const detailBl = WfForm.convertFieldNameToId('bcfkbl',"detail_3");
+const detailBl = WfForm.convertFieldNameToId('bcfkbl', "detail_3");
+// 关联订单
+const relationOrder = WfForm.convertFieldNameToId("gldd");
+// 明细4施工合同字段
+const detail4SgField = WfForm.convertFieldNameToId("sght", "detail_4");
+// 明细4采购合同字段
+const detail4CgField = WfForm.convertFieldNameToId("cght", "detail_4");
+// 明细4发票字段
+const detail4FpField = WfForm.convertFieldNameToId("fpje", "detail_4");
+// 明细4合同发票金额和
+let detail4Map = new Map();
+// 明细3施工合同字段
+const detail3SgField = WfForm.convertFieldNameToId("sght", "detail_3");
+// 明细3采购合同字段
+const detail3CgField = WfForm.convertFieldNameToId("cght", "detail_3");
+// 明细3 含税金额
+const detail3TaxField = WfForm.convertFieldNameToId("ddhsje", "detail_3");
+// 明细3以收票金额
+const detail3YspField = WfForm.convertFieldNameToId("yspje", "detail_3");
WfForm.registerCheckEvent(WfForm.OPER_ADDROW + "3", function (callback) {
callback();
+ setTimeout(() => {
+ initDeatail3Date();
+ }, 5)
+});
+// 关联订单变化时将明细四的合同-金额map进行初始化
+WfForm.bindFieldChangeEvent(relationOrder, function (obj, id, value) {
+ setTimeout(() => {
+ initDetail4Map();
+ changeDetail3SpMoney();
+ }, 2000);
+});
+
+
+WfForm.bindFieldChangeEvent(`${yjfksj},${bl}`, function (obj, id, value) {
initDeatail3Date();
});
-WfForm.bindFieldChangeEvent(`${yjfksj},${bl}`, function(obj,id,value){
- initDeatail3Date();
-});
-
-function initDeatail3Date(){
- let dateVal = WfForm.getFieldValue(yjfksj);
- let blVal = WfForm.getFieldValue(bl);
- console.log('dateVal ', dateVal);
- console.log('blVal ', blVal);
+// 计算明细三开票金额
+function changeDetail3SpMoney() {
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
for (let i = 0; i < detail3RowArr.length; i++) {
let rowIndex = detail3RowArr[i];
if (rowIndex !== "") {
- WfForm.changeFieldValue(`${detail3Yqfkrq}_${rowIndex}`,{value: dateVal});
- WfForm.changeFieldValue(`${detailBl}_${rowIndex}`,{value: blVal});
+ let detail3SgFieldVal = WfForm.getFieldValue(`${detail3SgField}_${rowIndex}`);
+ let detail3CgFieldVal = WfForm.getFieldValue(`${detail3CgField}_${rowIndex}`);
+ let fpje = detail4Map.get(detail3SgFieldVal) ?? detail4Map.get(detail3CgFieldVal);
+ let mapVal = detail4Map.get(detail3SgFieldVal);
+ let key = detail3SgFieldVal;
+ if (!mapVal) {
+ key = detail3CgFieldVal;
+ }
+ console.log('key ', key);
+ if (fpje) {
+ console.log('fpje => ', fpje);
+// 0.1 0.3
+ let detail3TaxVal = WfForm.getFieldValue(`${detail3TaxField}_${rowIndex}`);
+ console.log('detail3TaxVal => ', detail3TaxVal);
+ let tempJe = fpje - detail3TaxVal;
+ console.log('tempJe => ', tempJe);
+ if (fpje > detail3TaxVal) {
+ WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`, {value: detail3TaxVal});
+ } else if (tempJe <= 0 && fpje == 0) {
+ WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`, {value: 0});
+ } else if (tempJe < 0) {
+ WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`, {value: fpje});
+ tempJe = 0;
+ }
+ detail4Map.set(key, tempJe);
+ console.log('detail4Map ', detail4Map)
+ } else {
+ WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`, {value: 0});
+ }
}
}
-}
\ No newline at end of file
+}
+
+
+function initDeatail3Date() {
+ let dateVal = WfForm.getFieldValue(yjfksj);
+ let blVal = WfForm.getFieldValue(bl);
+ let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
+ for (let i = 0; i < detail3RowArr.length; i++) {
+ let rowIndex = detail3RowArr[i];
+ if (rowIndex !== "") {
+ WfForm.changeFieldValue(`${detail3Yqfkrq}_${rowIndex}`, {value: dateVal});
+ WfForm.changeFieldValue(`${detailBl}_${rowIndex}`, {value: blVal});
+ }
+ }
+}
+
+function initDetail4Map() {
+ let detail4RowArr = WfForm.getDetailAllRowIndexStr('detail_4').split(",");
+ console.log('detail4RowArr ', detail4RowArr);
+ for (let i = 0; i < detail4RowArr.length; i++) {
+ let rowIndex = detail4RowArr[i];
+ if (rowIndex !== "") {
+ let detail4SgFieldVal = WfForm.getFieldValue(`${detail4SgField}_${rowIndex}`);
+ let detail4CgFieldVal = WfForm.getFieldValue(`${detail4CgField}_${rowIndex}`);
+ let detail4FpFieldVal = WfForm.getFieldValue(`${detail4FpField}_${rowIndex}`);
+ let key = -1;
+ console.log('detail4SgFieldVal ', detail4SgFieldVal);
+ console.log('detail4CgFieldVal ', detail4CgFieldVal);
+ console.log('detail4FpFieldVal ', detail4FpFieldVal);
+ if (!detail4FpFieldVal) {
+ continue;
+ }
+ key = detail4CgFieldVal ?? detail4SgFieldVal;
+ console.log('key ', key);
+ let tempVal = parseFloat(detail4Map.get(key) ?? 0);
+ tempVal += parseFloat(detail4FpFieldVal);
+ detail4Map.set(key, tempVal);
+ }
+ }
+ console.log('detail4Map ', detail4Map)
+}
+
+const detail3ApplyMoneyField = WfForm.convertFieldNameToId("bcfkje", "detail_3");
+const detail3CgId = WfForm.convertFieldNameToId("cgddzbid", "detail_3");
+const detail3Bl = WfForm.convertFieldNameToId('bcfkbl', "detail_3");
+let detailBlMap = new Map();
+const detail1Bl = WfForm.convertFieldNameToId('fkbl', "detail_1");
+const detail1CgId = WfForm.convertFieldNameToId("cgddzbid", "detail_1");
+WfForm.bindDetailFieldChangeEvent(detail3ApplyMoneyField, (id, rowIndex, value) => {
+ let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
+ detailBlMap = new Map();
+ for (let i = 0; i < detail3RowArr.length; i++) {
+ let rowIndex = detail3RowArr[i];
+ if (rowIndex !== "") {
+ let bl = parseFloat(WfForm.getFieldValue(`${detail3Bl}_${rowIndex}`));
+ let cg = WfForm.getFieldValue(`${detail3CgId}_${rowIndex}`);
+ let mapVal = parseFloat(detailBlMap.get(cg) ?? 0) + bl;
+ detailBlMap.set(cg, mapVal);
+ }
+ }
+ console.log('detailBlMap ', detailBlMap)
+ let detail1RowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
+ for (let i = 0; i < detail1RowArr.length; i++) {
+ let rowIndex = detail1RowArr[i];
+ if (rowIndex !== "") {
+ let cg = WfForm.getFieldValue(`${detail1CgId}_${rowIndex}`);
+ let val = detailBlMap.get(cg) === '' ? 0 : detailBlMap.get(cg);
+ WfForm.changeFieldValue(`${detail1Bl}_${rowIndex}`, {value: val})
+ }
+ }
+});
+
+
+
+
+
diff --git a/javascript/xuanran.wang/bme/js/PurchaseContractApply.js b/javascript/xuanran.wang/bme/js/PurchaseContractApply.js
index 705e114..1e2722f 100644
--- a/javascript/xuanran.wang/bme/js/PurchaseContractApply.js
+++ b/javascript/xuanran.wang/bme/js/PurchaseContractApply.js
@@ -23,6 +23,7 @@ const detailComPayDateId = WfForm.convertFieldNameToId("yjfkrq",detailTable);
// 对应日期
const detailTempDateField = WfForm.convertFieldNameToId("dyrq", detailTable);
// 需要计算的款项类型集合
+const readOnlyArr = ['0'];
const computeDatePayType = ['0','2','4'];
// 款项类型预计对应日期取值
const paymentTypeGetValue = {
@@ -49,12 +50,13 @@ function init(){
'detailComPayDateId': detailComPayDateId,
'dayId': detailDayId,
'computeDatePayType': computeDatePayType,
- 'paymentTypeGetValue': paymentTypeGetValue
+ 'paymentTypeGetValue': paymentTypeGetValue,
+ 'readOnlyArr': readOnlyArr
}
addRowBack(3, obj);
- changeDetailFieldReadOnly(detailTable, detailComPayDateId, detailPaymentTypeId, computeDatePayType)
+ changeDetailFieldReadOnly(detailTable, detailComPayDateId, detailPaymentTypeId, readOnlyArr)
// 主表字段发生变化
mainFieldChangeDetailCom(`${mainProjectId},${contractSignDateId}`, detailTable, obj);
// 明细的款项类型字段变化绑定
diff --git a/javascript/xuanran.wang/bme/js/SaleContractApply.js b/javascript/xuanran.wang/bme/js/SaleContractApply.js
index eff8107..6fb1ba7 100644
--- a/javascript/xuanran.wang/bme/js/SaleContractApply.js
+++ b/javascript/xuanran.wang/bme/js/SaleContractApply.js
@@ -11,7 +11,7 @@ const mainWorkFlowEndId = WfForm.convertFieldNameToId("fhdgdrq");
// 主表实际验收
const mainActualCheckId = WfForm.convertFieldNameToId("sjysrq");
// 明细2付款比例字段
-const detail2PayProportionId = WfForm.convertFieldNameToId("fkbl",detailTable);
+const detail2PayProportionId = WfForm.convertFieldNameToId("skbl",detailTable);
// 明细2款项类型
const detail2PaymentTypeId = WfForm.convertFieldNameToId("kxlx",detailTable);
// 明细2前后字段
@@ -24,6 +24,8 @@ const detail2ComPayDateId = WfForm.convertFieldNameToId("yjfkrq",detailTable);
const detail2TempDateField = WfForm.convertFieldNameToId("dyrq", detailTable);
// 需要计算的款项类型集合
const computeDatePayType = ['2', '4', '5'];
+// 只读 明细款项类型
+const readOnlyArr = [];
// 款项类型预计对应日期取值
const paymentTypeGetValue = {
2: (index)=>{
@@ -50,10 +52,11 @@ function init(){
'detailComPayDateId': detail2ComPayDateId,
'dayId': detail2DayId,
'computeDatePayType': computeDatePayType,
- 'paymentTypeGetValue': paymentTypeGetValue
+ 'paymentTypeGetValue': paymentTypeGetValue,
+ 'readOnlyArr': readOnlyArr
}
addRowBack(2, obj);
- changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, computeDatePayType)
+ changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, readOnlyArr);
// 主表字段发生变化
mainFieldChangeDetailCom(mainProjectId, detailTable, obj);
// 明细的款项类型字段变化绑定
diff --git a/javascript/xuanran.wang/shyl/MealOrder.js b/javascript/xuanran.wang/shyl/MealOrder.js
new file mode 100644
index 0000000..aca382b
--- /dev/null
+++ b/javascript/xuanran.wang/shyl/MealOrder.js
@@ -0,0 +1,45 @@
+const enable = 0;
+// 班级浏览按钮表单字段id
+const classFieldId = WfForm.convertFieldNameToId("bjmc");
+// 明细1学员id
+const detail1StuId = WfForm.convertFieldNameToId("studentId","detail_1");;
+// 明细1学员编号
+const detail1StuNo = WfForm.convertFieldNameToId("studentNo","detail_1");;
+// 明细1学员姓名
+const detail1StuName = WfForm.convertFieldNameToId("studentName","detail_1");;
+// 明细1班级id
+const detail1ClassId = WfForm.convertFieldNameToId("classId","detail_1");
+// 主表学员汇总字段
+const stuAllField = WfForm.convertFieldNameToId("mxxybhhzfz");
+WfForm.bindFieldChangeEvent(classFieldId, function(obj,id,value){
+ let classId = WfForm.getBrowserShowName(classFieldId);
+ WfForm.delDetailRow("detail_1", "all");
+ $.get('/api/wxr/students/getStudentsByClassId',{id:classId},(res)=>{
+ let obj = JSON.parse(res);
+ if(obj.code != 200){
+ WfForm.showMessage(obj.msg);
+ return;
+ }
+ console.log('obj ', obj);
+ let objData = obj.data;
+ let responseObj = JSON.parse(objData);
+ if(!responseObj || !responseObj.data){
+ WfForm.showMessage(responseObj.msg);
+ return;
+ }
+ objData = responseObj.data;
+ WfForm.changeFieldValue(stuAllField, {value: ''});
+ let stuArr = [];
+ objData.forEach((item)=>{
+ let detailObj = {};
+ detailObj[detail1StuId] = { value: item.id };
+ detailObj[detail1StuNo] = { value: item.studentNo };
+ detailObj[detail1StuName] = { value: item.studentName };
+ detailObj[detail1ClassId] = { value: item.classId };
+ // console.log('detailObj ', detailObj)
+ WfForm.addDetailRow("detail_1",detailObj);
+ stuArr.push(item.studentNo);
+ })
+ WfForm.changeFieldValue(stuAllField, {value: stuArr.join(',')});
+ })
+});
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5b8411e..7267c9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,6 +103,12 @@
4.4.0
+
+ org.apache.kafka
+ kafka-clients
+ 2.3.1
+
+
cn.afterturn
easypoi-base
diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java b/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java
index 3c0791d..94abd03 100644
--- a/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java
+++ b/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java
@@ -6,8 +6,6 @@ import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.shyl.service.BatchCreateWorkflowService;
-import com.api.xuanran.wang.shyl.service.MeetingService;
-import com.api.xuanran.wang.shyl.vo.CreateWfVO;
import com.engine.common.util.ServiceUtil;
import com.engine.workflow.publicApi.WorkflowRequestOperatePA;
import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl;
@@ -16,7 +14,6 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.hrm.User;
-import weaver.xuanran.wang.common.mapper.CommonMapper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -26,7 +23,6 @@ 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;
/**
* 上海团校-批量创建流程接口
diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/UserUpdateToMQController.java b/src/main/java/com/api/xuanran/wang/shyl/controller/UserUpdateToMQController.java
new file mode 100644
index 0000000..a0b5f89
--- /dev/null
+++ b/src/main/java/com/api/xuanran/wang/shyl/controller/UserUpdateToMQController.java
@@ -0,0 +1,54 @@
+package com.api.xuanran.wang.shyl.controller;
+
+import aiyh.utils.ApiResult;
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.api.xuanran.wang.shyl.service.UserUpdateToMQService;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * 用户信息更新将数据发送到队列中
+ *
+ * @author xuanran.wang
+ * @date 2023/3/20 17:15
+ */
+@Path("/wxr/user_mq")
+public class UserUpdateToMQController {
+ private final Logger log = Util.getLogger();
+ private final UserUpdateToMQService userUpdateToMQService = new UserUpdateToMQService();
+ /**
+ * 用户信息更新
+ * @author xuanran.wang
+ * @dateTime 2023/3/1 15:24
+ **/
+ @Path("/update")
+ @POST
+ @Produces(MediaType.TEXT_PLAIN)
+ public String updateUserInfoToMQ(@Context HttpServletRequest request,
+ @Context HttpServletResponse response){
+ try {
+ String id = Util.null2DefaultStr(request.getParameter("id"),"");
+ String onlyMark = Util.null2DefaultStr(request.getParameter("onlyMark"),"");
+ String configName = Util.null2DefaultStr(request.getParameter("configName"),"");
+ String debug = Util.null2DefaultStr(request.getParameter("debug"),"");
+ if(StringUtils.isBlank(id) || StringUtils.isBlank(onlyMark) || StringUtils.isBlank(configName)){
+ throw new CustomerException("update user to mq id or onlyMark or configName can not null!");
+ }
+ userUpdateToMQService.toMQ(id, onlyMark, configName, debug);
+ return ApiResult.success(null);
+ }catch (Exception e){
+ log.error(Util.logStr("MeetingController error ! {}", e.getMessage()));
+ return ApiResult.error(500,"会议取消接口发生异常! 异常信息 :[ " + e.getMessage() + " ]");
+ }
+
+ }
+}
diff --git a/src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java b/src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java
index 3b7da0c..7d0715b 100644
--- a/src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java
+++ b/src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java
@@ -5,7 +5,7 @@ import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import com.api.xuanran.wang.shyl.entity.ProducerCarInfo;
-import java.util.HashMap;
+import java.util.Map;
/**
* 生产者mapper
@@ -15,6 +15,13 @@ import java.util.HashMap;
*/
@SqlMapper
public interface ProducerMapper {
+ /**
+ * 通过车辆ID查信息
+ * @author xuanran.wang
+ * @dateTime 2023/3/20 17:26
+ * @param id 车辆id
+ * @return 车辆实体
+ **/
@Select("select a.id carCode, Deposit status,b.outkey driver, b.lastname userName, " +
"b.telephone userPhone, carNo plateList, remark " +
"from carinfo a " +
@@ -23,6 +30,13 @@ public interface ProducerMapper {
"where a.id = #{id}")
ProducerCarInfo queryCarInfo(@ParamMapper("id") String id);
+ /**
+ * 通过车排号查信息
+ * @author xuanran.wang
+ * @dateTime 2023/3/20 17:27
+ * @param carNo 车牌号
+ * @return 车辆实体
+ **/
@Select("select a.id carCode, Deposit status,b.outkey driver, b.lastname userName, " +
"b.telephone userPhone, carNo plateList, remark " +
"from carinfo a " +
@@ -30,4 +44,14 @@ public interface ProducerMapper {
"on a.driver = b.id " +
"where a.carNo = #{carNo}")
ProducerCarInfo queryCarNo(@ParamMapper("carNo") String carNo);
+
+ /**
+ * 根据人员ID查询信息
+ * @author xuanran.wang
+ * @dateTime 2023/3/20 17:27
+ * @param id 人员ID
+ * @return 人员信息
+ **/
+ @Select("select * from hrmresource where id = #{id}")
+ Map queryUserInfo(@ParamMapper("id") String id);
}
diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/CarService.java b/src/main/java/com/api/xuanran/wang/shyl/service/CarService.java
index c4205ec..fd73005 100644
--- a/src/main/java/com/api/xuanran/wang/shyl/service/CarService.java
+++ b/src/main/java/com/api/xuanran/wang/shyl/service/CarService.java
@@ -81,6 +81,10 @@ public class CarService {
carNo = Util.null2DefaultStr(request.getParameter("carNo"),"");
info = producerMapper.queryCarNo(carNo);
}
+
+ //add by taojw
+// String plateList = info.getPlateList();
+
// 如果能找到就说明是更新或者新增
if("del".equals(operation)){ //删除状态下
info = new ProducerCarInfo();
@@ -88,6 +92,7 @@ public class CarService {
info.setStatus("1");
info.setRemark("");
info.setDriver("");
+ //edit by taojw
info.setPlateList("");
info.setUserName("");
info.setUserPhone("");
diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/UserUpdateToMQService.java b/src/main/java/com/api/xuanran/wang/shyl/service/UserUpdateToMQService.java
new file mode 100644
index 0000000..c19c2dc
--- /dev/null
+++ b/src/main/java/com/api/xuanran/wang/shyl/service/UserUpdateToMQService.java
@@ -0,0 +1,57 @@
+package com.api.xuanran.wang.shyl.service;
+
+import aiyh.utils.Util;
+import com.alibaba.fastjson.JSONObject;
+import com.api.xuanran.wang.shyl.mapper.ProducerMapper;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import weaver.conn.RecordSet;
+import weaver.xiao.commons.config.entity.RequestMappingConfig;
+import weaver.xiao.commons.config.service.DealWithMapping;
+import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 用户信息更新将数据发送到队列业务方法
+ *
+ * @author xuanran.wang
+ * @date 2023/3/20 17:18
+ */
+public class UserUpdateToMQService {
+
+ private final Logger logger = Util.getLogger();
+
+ private final DealWithMapping dealWithMapping = new DealWithMapping();
+
+ private final ProducerMapper producerMapper = Util.getMapper(ProducerMapper.class);
+
+ private static final String HRM_TABLE = "hrmresource";
+
+
+ public void toMQ(String id,
+ String onlyMark,
+ String configName,
+ String debug){
+ Map userMap = producerMapper.queryUserInfo(id);
+ if(MapUtils.isEmpty(userMap)){
+ logger.error(Util.logStr("userId: {}, userInfo is empty!"));
+ return;
+ }
+ RequestMappingConfig config = dealWithMapping.treeDealWithUniqueCode(onlyMark);
+ dealWithMapping.setMainTable(HRM_TABLE);
+ Map param = dealWithMapping.getRequestParam(userMap, config);
+ if(MapUtils.isEmpty(param)){
+ logger.error(Util.logStr("userId:{}, 生成json为空!",id));
+ return;
+ }
+ if(StringUtils.isNotBlank(debug)){
+ logger.info("update user json : \n" + JSONObject.toJSONString(param));
+ return;
+ }
+ RocketConsumerUtil.producerSendMsg(configName, JSONObject.toJSONString(param), id);
+ }
+}
diff --git a/src/main/java/weaver/shyl/workflow/action/FileTypeFieldConvert.java b/src/main/java/weaver/shyl/workflow/action/FileTypeFieldConvert.java
new file mode 100644
index 0000000..5e3a293
--- /dev/null
+++ b/src/main/java/weaver/shyl/workflow/action/FileTypeFieldConvert.java
@@ -0,0 +1,70 @@
+package weaver.shyl.workflow.action;
+
+import aiyh.utils.Util;
+import aiyh.utils.entity.DocImageInfo;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import weaver.file.ImageFileManager;
+import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Base64;
+import java.util.Map;
+/**
+ * 团校-流程中字段图片附件转成base64
+ *
+ * @author xuanran.wang
+ * @date 2023/3/27 22:41
+ */
+public class FileTypeFieldConvert implements CusInterfaceGetValue {
+
+ private final Logger log = Util.getLogger();
+
+ /**
+ * 获取参数值
+ *
+ * @param mainMap 主表数据
+ * @param detailMap 明细表数据
+ * @param currentValue 当前字段值
+ * @param pathParam 路径参数
+ * @return 最终返回参数
+ */
+ @Override
+ public Object execute(Map mainMap, Map detailMap, String currentValue, Map pathParam) {
+ try {
+ log.info("原文件图片ID:[" + currentValue + "]");
+ log.info("pathParam : " + JSONObject.toJSONString(pathParam));
+ int tempId = Util.getIntValue(currentValue, -1);
+ if(!"".equals(currentValue) && tempId > 0 && !currentValue.contains(",")) {
+ String imageFileId = Util.null2DefaultStr(pathParam.get("imageFileId"),"");
+ InputStream inputStream;
+ if (StringUtils.isBlank(imageFileId)) {
+ DocImageInfo docImageInfo = Util.selectImageInfoByDocId(currentValue);
+ inputStream = ImageFileManager.getInputStreamById(docImageInfo.getImageFileId());
+ }else {
+ int fileId = Util.getIntValue(currentValue, -1);
+ if(fileId < 0){
+ throw new CustomerException("image file id < 0");
+ }
+ inputStream = ImageFileManager.getInputStreamById(fileId);
+ }
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ }
+ byte[] bytes = outputStream.toByteArray();
+ return Base64.getEncoder().encodeToString(bytes);
+ }
+ } catch (Exception e) {
+ log.error("convert file to base64 fail!" + e.getMessage() + "\n" + Util.getErrString(e));
+ throw new CustomerException("convert file to base64 fail!");
+ }
+ return null;
+ }
+}
+
diff --git a/src/main/java/weaver/xuanran/wang/bme/action/CheckConsumerNameAction.java b/src/main/java/weaver/xuanran/wang/bme/action/CheckConsumerNameAction.java
new file mode 100644
index 0000000..9adc14c
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/bme/action/CheckConsumerNameAction.java
@@ -0,0 +1,49 @@
+package weaver.xuanran.wang.bme.action;
+
+import aiyh.utils.Util;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import weaver.conn.RecordSet;
+import weaver.interfaces.workflow.action.Action;
+import weaver.soa.workflow.request.RequestInfo;
+import weaver.workflow.request.RequestManager;
+
+/**
+ * 校验客户名称
+ *
+ * @author xuanran.wang
+ * @date 2023/4/6 09:51
+ */
+public class CheckConsumerNameAction implements Action {
+ private final Logger log = Util.getLogger();
+ private String wfConsumerField;
+ private String modelConsumerField;
+ private String modelName;
+
+ @Override
+ public String execute(RequestInfo request) {
+ String requestId = request.getRequestid();
+ String tableName = request.getRequestManager().getBillTableName();
+ RecordSet rs = new RecordSet();
+
+ wfConsumerField = Util.null2DefaultStr(wfConsumerField, "khmc");
+ modelConsumerField = Util.null2DefaultStr(modelConsumerField, "khmc");
+ modelName = Util.null2DefaultStr(modelName, "uf_kh");
+
+ RequestManager requestManager = request.getRequestManager();
+ rs.executeQuery("select * from " + tableName + " where requestid = ?", requestId);
+ rs.next();
+ String wfConsumer = rs.getString(wfConsumerField);
+ log.info("wfConsumer : [ " + wfConsumer + " ]");
+ if(StringUtils.isNotBlank(wfConsumer)){
+ String sql = "select id from " + modelName + " where " + modelConsumerField + " = ?";
+ log.info("sql : " + sql + " ,参数: " + wfConsumer);
+ if (rs.executeQuery(sql, wfConsumer) && rs.next()) {
+ requestManager.setMessageid(System.currentTimeMillis() + "");
+ requestManager.setMessagecontent("当前客户名称: " + wfConsumer + " ,在客户表中已经存在请修改后提交!");
+ return Action.FAILURE_AND_CONTINUE;
+ }
+ }
+ return Action.SUCCESS;
+ }
+}
diff --git a/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java b/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java
index 55478d3..a58c672 100644
--- a/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java
+++ b/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java
@@ -68,6 +68,7 @@ public class ContractApplyComDateAction implements Action {
* 明细前后字段
**/
@RequiredMark
+ @PrintParamMark
private String beforeBackField;
/**
@@ -124,6 +125,7 @@ public class ContractApplyComDateAction implements Action {
log.error(Util.logStr("checkDate:{}, project:{}", checkDate, project));
throw new CustomerException("实际验收日期或项目字段字段为空!");
}
+ // select a.id,a.requestid from formtable_main_58 a right join uf_cgdd b on a.htbh = b.lcbh where b.id =
String selectSql = "select id,requestid from " + buildContractTable + " where " + buildContractProjectField + " = ?";
if(StringUtils.isNotBlank(relationSql)){
selectSql = relationSql;
@@ -159,16 +161,15 @@ public class ContractApplyComDateAction implements Action {
params.add(param);
log.info(Util.logStr("关联流程requestId: {}, 流程明细前后字段: {}, 天数: {}, 计算后的日期: {}",tempRequestId, beforeBack, day, computeDate));
}
- }
- if(CollectionUtils.isNotEmpty(params)){
- if(!rs.executeBatchSql(updateSql,params)){
- log.error(Util.logStr("更新sql : {}, 参数 : {}", updateSql, params));
- throw new CustomerException("更新合同sql错误!");
+ if(CollectionUtils.isNotEmpty(params)){
+ if(!rs.executeBatchSql(updateSql,params)){
+ log.error(Util.logStr("更新sql : {}, 参数 : {}", updateSql, params));
+ throw new CustomerException("更新合同sql错误!");
+ }
+ }else {
+ log.error(Util.logStr("明细表: {}不存在数据!", detailContractTable));
}
- }else {
- log.error(Util.logStr("明细表: {}不存在数据!", detailContractTable));
}
-
}else{
log.error(Util.logStr("查询关联项目sql暂未查到数据! sql {} ,{}", selectSql, requestId));
}
diff --git a/src/main/java/weaver/xuanran/wang/common/util/CusInfoToOAUtil.java b/src/main/java/weaver/xuanran/wang/common/util/CusInfoToOAUtil.java
index 0496f10..53df958 100644
--- a/src/main/java/weaver/xuanran/wang/common/util/CusInfoToOAUtil.java
+++ b/src/main/java/weaver/xuanran/wang/common/util/CusInfoToOAUtil.java
@@ -150,13 +150,15 @@ public class CusInfoToOAUtil {
* @dateTime 2023/2/9 11:51
* @param modelId 模块id
* @param list 插入参数集合
- * @param whereSql 更新条件
+ * @param whereSql 更新条件sql
* @return 建模数据id
**/
public static List executeBatchByEntity(int modelId, List> list, String whereSql){
String tableName = checkModelId(modelId);
List> params = new ArrayList<>();
List> whereParams = new ArrayList<>();
+ StringBuilder whereSqlSb;
+ LinkedHashSet whereFields = new LinkedHashSet<>();
for (Object o : list) {
if(Objects.isNull(o)){
continue;
@@ -165,7 +167,14 @@ public class CusInfoToOAUtil {
Field[] fields = clazz.getDeclaredFields();
LinkedHashMap linkedHashMap = new LinkedHashMap<>();
ArrayList whereParam = new ArrayList<>();
- for (Field field : fields) {
+ List fieldArr = Arrays.stream(fields).collect(Collectors.toList());
+ Class> superclass = clazz.getSuperclass();
+ // 找出父类所有的字段
+ while (superclass != null){
+ fieldArr.addAll(Arrays.stream(superclass.getDeclaredFields()).collect(Collectors.toList()));
+ superclass = superclass.getSuperclass();
+ }
+ for (Field field : fieldArr) {
field.setAccessible(true);
String fieldName = field.getName();
Object fieldValue;
@@ -194,14 +203,25 @@ public class CusInfoToOAUtil {
if(null == sqlUpdateWhereField || !sqlUpdateWhereField.value()){
continue;
}
+ if(StringUtils.isBlank(whereSql)){
+ whereFields.add(fieldName + " = ?");
+ }
whereParam.add(fieldValue.toString());
}
params.add(linkedHashMap);
whereParams.add(whereParam);
}
+ if(!whereFields.isEmpty()){
+ whereSqlSb = new StringBuilder("select id from #{tableName} where ");
+ for (String field : whereFields) {
+ whereSqlSb.append(field).append(" and ");
+ }
+ whereSql = whereSqlSb.substring(0, whereSqlSb.length() - 4);
+ }
return executeBatch(modelId, tableName, params, whereSql, whereParams, true, new ArrayList<>());
}
+
/**
* 将自定义信息写入建模
* @author xuanran.wang
diff --git a/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java b/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java
new file mode 100644
index 0000000..0246fb8
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java
@@ -0,0 +1,64 @@
+package weaver.xuanran.wang.immc;
+
+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 weaver.hrm.User;
+import weaver.soa.workflow.request.RequestInfo;
+import weaver.xuanran.wang.immc.entity.VmsResponseVoField;
+import weaver.xuanran.wang.immc.service.WorkFlowToVmsAndMQService;
+
+/**
+ * 智己 将流程数据推送到接口/kafka队列中
+ *
+ * @author xuanran.wang
+ * @date 2023/3/30 11:21
+ */
+@ActionDesc(value = "智己 将流程数据推送到接口/kafka队列中", author = "xuanran.wang")
+public class WorkFlowToVmsAndMQ extends SafeCusBaseAction {
+
+ private final WorkFlowToVmsAndMQService workFlowToVmsAndMQService = new WorkFlowToVmsAndMQService();
+ /**
+ *
+ * OA-uat
+ * 用户密码
+ * oa_uat_user/los0cp6aiV1iO1e2
+ * Topic
+ * oa_service_immc_topic_uat
+ * 接入点
+ * 10.184.42.41:9094,10.184.42.42:9094,10.184.42.40:9094
+ *
+ **/
+ @PrintParamMark
+ @ActionOptionalParam(value = "", desc = "kafka配置文件名称")
+ private String kafkaConfig;
+
+ @PrintParamMark
+ @RequiredMark("建模配置文件唯一标识")
+ private String onlyMark;
+
+ @PrintParamMark
+ @ActionOptionalParam(value = "code", desc = "接口成功标识字段")
+ private String successField;
+ @PrintParamMark
+ @ActionOptionalParam(value = "200", desc = "接口成功标识默认200")
+ private String successVal;
+ @PrintParamMark
+ @ActionOptionalParam(value = "message", desc = "报错返回信息字段")
+ private String msg;
+
+ @Override
+ public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
+ log.info("-------------- " + requestId + " begin --------------");
+ VmsResponseVoField vmsResponseVoField = VmsResponseVoField
+ .builder()
+ .successField(Util.null2DefaultStr(successField, "code"))
+ .successVal(Util.null2DefaultStr(successVal, "200"))
+ .message(Util.null2DefaultStr(msg, "message"))
+ .build();
+ workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig);
+ }
+}
diff --git a/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java b/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java
new file mode 100644
index 0000000..44faeeb
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java
@@ -0,0 +1,50 @@
+package weaver.xuanran.wang.immc.cusfieldvalue;
+
+import aiyh.utils.Util;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
+import weaver.xiao.commons.config.interfacies.CusInterfaceListValue;
+import weaver.xuanran.wang.immc.mapper.ImMcMapper;
+
+import java.util.*;
+
+/**
+ * 附件集合
+ *
+ * @author xuanran.wang
+ * @date 2023/3/30 15:11
+ */
+public class CusListValue implements CusInterfaceGetValue {
+
+ private final Logger log = Util.getLogger();
+ private final ImMcMapper mapper = Util.getMapper(ImMcMapper.class);
+
+ @Override
+ public Object execute(Map mainMap, Map detailMap, String currentValue, Map pathParam) {
+ List
**/
- @SqlFieldMapping()
+ @SqlFieldMapping
private String topic;
/**
* 消息内容操作类型
@@ -35,19 +35,19 @@ public class MQMessage {
* PASSWORD_ACTION: 修改密码
*
**/
- @SqlFieldMapping()
+ @SqlFieldMapping
private String actionType;
/**
* 消息发送时间
**/
- @SqlFieldMapping()
+ @SqlFieldMapping
private String sendTime;
/**
* 消息业务内容,json 格式,分业务(用户、机构、密码修改)
**/
- @SqlFieldMapping()
+ @SqlFieldMapping
private String content;
- @SqlFieldMapping()
+ @SqlFieldMapping
private String error;
}
diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java
index 1d6bab2..e1ec671 100644
--- a/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java
+++ b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java
@@ -100,7 +100,7 @@ public interface ConsumerMapper {
* @param id id
* @return true/false
**/
- @Delete("delete from hrmresource where id = #{id}")
+ @Delete("update hrmresource set status = 7 where id = #{id}")
boolean deleteHrmById(@ParamMapper("id") String id);
/**
@@ -115,4 +115,8 @@ public interface ConsumerMapper {
@Select("select count(1) from uf_mqLog where messageId = #{messageId}")
int getMainIdFromMQLogByMessageId(@ParamMapper("messageId") String messageId);
+
+ @Update("update hrmresource set loginId = #{loginId} where id = #{id}")
+ boolean updateHrmLoginIdById(@ParamMapper("id") String id,
+ @ParamMapper("loginId") String loginId);
}
diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java
index 75c5bbc..e6ad383 100644
--- a/src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java
+++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java
@@ -29,7 +29,7 @@ public class ProducerService {
private final Logger logger = Util.getLogger();
private final DealWithMapping dealWithMapping = new DealWithMapping();
- private final ToolUtil toolUtil = new ToolUtil();
+
private final HttpUtils httpUtils = new HttpUtils();
{
@@ -54,7 +54,7 @@ public class ProducerService {
ChangeRequestParam changeRequestParam){
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, tableName);
- logger.info("查询主表sql : " + selectMainSql);
+// logger.info("查询主表sql : " + selectMainSql);
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(selectMainSql, requestId);
Map requestParam = new HashMap<>();
@@ -69,10 +69,6 @@ public class ProducerService {
if(!Objects.isNull(changeRequestParam)){
changeRequestParam.changeRequestParam(requestParam);
}
-// logger.info(Util.logStr("requestId : {}, msg:{}", requestId, JSONObject.toJSONString(requestParam)));
- String sendMQ = Util.null2DefaultStr(toolUtil.getSystemParamValue("sendMQ"),"");
- if("1".equals(sendMQ)){
- RocketConsumerUtil.producerSendMsg(configName,JSONObject.toJSONString(requestParam), requestId);
- }
+ RocketConsumerUtil.producerSendMsg(configName, JSONObject.toJSONString(requestParam), requestId);
}
}
diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java
index b9cf11a..4a5198c 100644
--- a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java
+++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java
@@ -42,14 +42,14 @@ public class PassWordServiceImpl extends CusInfoActionService {
String content = message.getContent();
ModifyPassWord passWord = JSONObject.parseObject(content, ModifyPassWord.class);
logger.info(Util.logStr("cusPassWordAction messageId: {},UserInfo : {} ",message.getId(),JSONObject.toJSONString(passWord)));
- String outKey = passWord.getId();
- String hrmId = consumerMapper.getHrmIdByOutKey(outKey);
- if(StringUtils.isBlank(hrmId)){
- throw new CustomerException(Util.logStr("the userId is {} , no personnel information found in oa!", outKey));
- }
- if (!consumerMapper.updatePasswordById(hrmId, Util.getEncrypt(passWord.getPassword()))) {
- throw new CustomerException("update user password error!");
- }
+// String outKey = passWord.getId();
+// String hrmId = consumerMapper.getHrmIdByOutKey(outKey);
+// if(StringUtils.isBlank(hrmId)){
+// throw new CustomerException(Util.logStr("the userId is {} , no personnel information found in oa!", outKey));
+// }
+// if (!consumerMapper.updatePasswordById(hrmId, Util.getEncrypt(passWord.getPassword()))) {
+// throw new CustomerException("update user password error!");
+// }
writeInOA(message.getId());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} catch (Exception e) {
diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..8a126d0
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java
@@ -0,0 +1,124 @@
+package weaver.xuanran.wang.shyl_mq.service.impl;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.hrm.resource.ResourceComInfo;
+import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
+import weaver.xuanran.wang.shyl_mq.entity.UserInfo;
+import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
+
+
+/**
+ * 用户业务方法
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:04
+ */
+public class UserServiceImpl extends CusInfoActionService {
+ private Logger logger = Util.getLogger("mq-consumer-user");
+
+ {
+ if(null == logger){
+ logger = Util.getLogger("mq-consumer-user");
+ }
+ }
+
+ /**
+ * 用户新增
+ * @author xuanran.wang
+ * @dateTime 2023/1/3 13:37
+ * @param message mq消息
+ * @return 成功/重试
+ **/
+ @Override
+ public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) {
+ try {
+ String content = message.getContent();
+ UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
+ logger.info(Util.logStr("userCusCreateAction messageId: {}, UserInfo : {} ",message.getId(), JSONObject.toJSONString(userInfo)));
+ updateLoginId(userInfo);
+ writeInOA(message.getId());
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("hrmCreateAction error : {}", e.getMessage()));
+ }
+ }
+
+ /**
+ * 用户删除
+ * @author xuanran.wang
+ * @dateTime 2023/1/3 13:38
+ * @param message mq消息
+ * @return 成功/重试
+ **/
+ @Override
+ public ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message) {
+ try {
+ String content = message.getContent();
+ UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
+ logger.info(Util.logStr("userCusDeleteAction messageId: {},UserInfo : {} ", message.getId(),JSONObject.toJSONString(userInfo)));
+ String id = Util.null2DefaultStr(userInfo.getId(),"");
+ if(StringUtils.isBlank(id)){
+ throw new CustomerException("del user id not null!");
+ }
+ if (!consumerMapper.deleteHrmById(id)) {
+ throw new CustomerException("del user sql execute error!");
+ }
+ ResourceComInfo resourceComInfo = new ResourceComInfo();
+ resourceComInfo.updateResourceInfoCache(id);
+ writeInOA(message.getId());
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ } catch (Exception e) {
+ throw new CustomerException(Util.logStr("hrmDeleteAction execute error : [{}]!", e.getMessage()));
+ }
+ }
+
+ /**
+ * 用户更新
+ * @author xuanran.wang
+ * @dateTime 2023/1/3 13:39
+ * @param message mq消息
+ * @return 成功/重试
+ **/
+ @Override
+ public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
+ try {
+ String content = message.getContent();
+ UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
+ logger.info(Util.logStr("userCusUpdateAction messageId: {},UserInfo : {} ", message.getId(), JSONObject.toJSONString(userInfo)));
+ updateLoginId(userInfo);
+ writeInOA(message.getId());
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("userCusUpdateAction execute error : [{}]!", e.getMessage()));
+ }
+ }
+ /**
+ * <更新登陆名/h1>
+ * @author xuanran.wang
+ * @dateTime 2023/3/28 13:07
+ * @param userInfo 用户实体
+ **/
+ public void updateLoginId(UserInfo userInfo) throws Exception {
+ String id = Util.null2DefaultStr(userInfo.getId(),"");
+ String userName = Util.null2DefaultStr(userInfo.getUserName(),"");
+ if(StringUtils.isBlank(id) || StringUtils.isBlank(userName)){
+ throw new CustomerException("create user id or userName can not null!");
+ }
+ if (!consumerMapper.updateHrmLoginIdById(id, userName)) {
+ throw new CustomerException("update loginId sql execute error!");
+ }
+ ResourceComInfo resourceComInfo = new ResourceComInfo();
+ // 清空缓存
+ resourceComInfo.updateResourceInfoCache(id);
+ }
+
+ @Override
+ public ConsumeConcurrentlyStatus cusPassWordAction(MQMessage message) {
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImplBack.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImplBack.java
index 759e1e2..3f97c57 100644
--- a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImplBack.java
+++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImplBack.java
@@ -22,12 +22,12 @@ import java.util.List;
import java.util.Map;
/**
- * 用户业务方法
+ * 用户业务方法-废弃
*
* @Author xuanran.wang
* @Date 2022/12/30 13:04
*/
-public class UserServiceImpl extends CusInfoActionService {
+public class UserServiceImplBack extends CusInfoActionService {
private Logger logger = Util.getLogger("mq-consumer-user");
{
diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java b/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java
index a27c413..c6b564d 100644
--- a/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java
+++ b/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java
@@ -1,4 +1,4 @@
-package weaver.xuanran.wang.shyl_mq.util;//package weaver.xuanran.wang.shyl.mq.util;
+package weaver.xuanran.wang.shyl_mq.util;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
@@ -37,15 +37,21 @@ import java.util.*;
*/
public class RocketConsumerUtil {
private static Logger log = Util.getLogger("mq-util");
+
+ private static Logger producerLog = Util.getLogger("mq-producer");
private static final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class);
private static final ToolUtil tool = new ToolUtil();
private static final int ERROR_LOG_ID;
+ private static final ToolUtil toolUtil = new ToolUtil();
static {
ERROR_LOG_ID = Util.getIntValue(tool.getSystemParamValue("mqErrorLogModelId"), -1);
if(log == null){
log = Util.getLogger("mq-util");
}
+ if(producerLog == null){
+ producerLog = Util.getLogger("mq-producer");
+ }
}
/**
@@ -83,7 +89,7 @@ public class RocketConsumerUtil {
CusInfoActionService cusInfoActionService, String configName){
Map configMap = RocketMQFactory.CONFIG_MAPS.get(configName);
int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("MaxReconsumeTimes")), RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
- MessageExt messageExt = null;
+ MessageExt messageExt;
String msgBody = "";
String mqMessageId = "";
MQMessage mqMessage = null;
@@ -143,7 +149,7 @@ public class RocketConsumerUtil {
mqMessage.setError(e.getMessage());
List ids = CusInfoToOAUtil.executeBatchByEntity(ERROR_LOG_ID, Collections.singletonList(mqMessage), "");
if(CollectionUtils.isEmpty(ids)){
- log.error("insert into mq_error_log failed!");
+ log.error(Util.logStr("messageId : {}, insert into mq_error_log failed!", mqMessageId));
}
}
log.error(Util.logStr("MQ producer error already bigger maxReconsumeTimes! messageId : {}",mqMessageId));
@@ -164,6 +170,10 @@ public class RocketConsumerUtil {
* @param requestId 请求id
**/
public static void producerSendMsg(String configName, String msg, String requestId) {
+ String sendMQ = Util.null2DefaultStr(toolUtil.getSystemParamValue("sendMQ"),"");
+ if(!"1".equals(sendMQ)){
+ return;
+ }
// 先从本地缓存中获取生产者对象
DefaultMQProducer producer = RocketMQFactory.getMQProducer(configName);
// 获取配置信息
@@ -171,9 +181,10 @@ public class RocketConsumerUtil {
// 队列名
String topic = Util.null2DefaultStr(configMap.get("Topic"), "");
// tag
- String tag = Util.null2DefaultStr(configMap.get("Tag"), "");
+// String tag = Util.null2DefaultStr(configMap.get("Tag"), "");
Message message;
try {
+ producerLog.info(Util.logStr("requestId: {}, msg: {}", requestId, msg));
message = new Message(topic, msg.getBytes(RemotingHelper.DEFAULT_CHARSET));
} catch (Exception e) {
throw new CustomerException(Util.logStr("init message error : {} !", e.getMessage()));
@@ -190,12 +201,12 @@ public class RocketConsumerUtil {
} catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) {
throw new CustomerException(Util.logStr("producer send message error!: {}", e.getMessage()));
}
- log.info(Util.logStr("requestId: {}, result : {}",requestId, JSONObject.toJSONString(result)));
+ producerLog.info(Util.logStr("requestId: {}, result : {}",requestId, JSONObject.toJSONString(result)));
SendStatus sendStatus = result.getSendStatus();
// 如果失败
if (!SendStatus.SEND_OK.equals(sendStatus)) {
String error = Util.logStr("producer send message call back status is not ok! the message is {}, the status is {}.", msg, sendStatus);
- log.error(error);
+ producerLog.error(error);
// 如果重试超过最大次数
if(count >= RocketMQConstant.SEND_MAX_COUNT){
throw new CustomerException(error + " and retry > max");
diff --git a/src/main/resources/WEB-INF/prop/prop2map/OACarTest.properties b/src/main/resources/WEB-INF/prop/prop2map/OACarTest.properties
new file mode 100644
index 0000000..516ecc6
--- /dev/null
+++ b/src/main/resources/WEB-INF/prop/prop2map/OACarTest.properties
@@ -0,0 +1,5 @@
+producerGroup=weaver-car
+serverAddr=114.115.168.220:9876
+topic=AUTH_CONSOLE_ORG_TOPIC
+tag=*
+consumerGroup=weaver-car-consumer
diff --git a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties
new file mode 100644
index 0000000..448dd3f
--- /dev/null
+++ b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties
@@ -0,0 +1,24 @@
+# ???????
+corpSecret=5eab6957b4944d75acfa9cfcc8feff5a
+agentId=10000060
+corpId=wwdbb6b075752cc1b9
+# ??token???
+tokenUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/gettoken
+# ??????
+userInfoUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/user/get
+# ??????
+departmentInfoUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/department/list
+# ??????
+addTodoTaskUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/task/create
+# ??????
+updateTodoTaskUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/task/update
+# ?????????appId
+appId=wwdbb6b075752cc1b9
+# ????????????ID
+modelId=112
+# ???????????sql ????????outkey ??sql?? select outkey from hrmresource where id in (${ids}) ??
+hrmSenderConvertRuleSql=select lastname from hrmresource where id in (${ids})
+# ?????
+hrmReceiveConvertRuleSql=select lastname from hrmresource where id in (${ids})
+# oa token??????????
+expiryBeforeTime=5
\ No newline at end of file
diff --git a/src/main/resources/WEB-INF/prop/prop2map/VmsKafka.properties b/src/main/resources/WEB-INF/prop/prop2map/VmsKafka.properties
new file mode 100644
index 0000000..33eb23e
--- /dev/null
+++ b/src/main/resources/WEB-INF/prop/prop2map/VmsKafka.properties
@@ -0,0 +1,5 @@
+bootstrap.servers=10.184.42.41:9094,10.184.42.42:9094,10.184.42.40:9094
+acks=all
+retries=1
+key.serializer=org.apache.kafka.common.serialization.StringSerializer
+value.serializer=org.apache.kafka.common.serialization.StringSerializer
\ No newline at end of file
diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusRequestClient.java b/src/test/java/xuanran/wang/http_test/annotations/CusRequestClient.java
index c1ea590..cadd360 100644
--- a/src/test/java/xuanran/wang/http_test/annotations/CusRequestClient.java
+++ b/src/test/java/xuanran/wang/http_test/annotations/CusRequestClient.java
@@ -1,5 +1,9 @@
package xuanran.wang.http_test.annotations;
+import aiyh.utils.tool.cn.hutool.core.annotation.AliasFor;
+import xuanran.wang.http_test.annotations.request_type.CusRequestType;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+
import java.lang.annotation.*;
/**
@@ -11,5 +15,10 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
+@CusRequestAddress()
public @interface CusRequestClient {
+ @AliasFor(annotation = CusRequestAddress.class, attribute = "host")
+ String host() default "";
+ @AliasFor(annotation = CusRequestAddress.class, attribute = "port")
+ int port() default 0;
}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusRequestUrl.java b/src/test/java/xuanran/wang/http_test/annotations/CusRequestUrl.java
new file mode 100644
index 0000000..299db5e
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/annotations/CusRequestUrl.java
@@ -0,0 +1,16 @@
+package xuanran.wang.http_test.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * 请求地址
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 19:59
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Documented
+public @interface CusRequestUrl {
+ String url();
+}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/body/CusRequestBody.java b/src/test/java/xuanran/wang/http_test/annotations/body/CusRequestBody.java
new file mode 100644
index 0000000..0b72ed0
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/annotations/body/CusRequestBody.java
@@ -0,0 +1,16 @@
+package xuanran.wang.http_test.annotations.body;
+
+import java.lang.annotation.*;
+
+/**
+ * 请求体
+ *
+ * @author xuanran.wang
+ * @date 2023/3/20 21:27
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+@Documented
+public @interface CusRequestBody {
+
+}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/handle/CusHandle.java b/src/test/java/xuanran/wang/http_test/annotations/handle/CusHandle.java
new file mode 100644
index 0000000..ee01d9c
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/annotations/handle/CusHandle.java
@@ -0,0 +1,16 @@
+package xuanran.wang.http_test.annotations.handle;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义handle注解
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 15:37
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+public @interface CusHandle {
+ int order() default 0;
+}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/handle/CusPreLoadHandle.java b/src/test/java/xuanran/wang/http_test/annotations/handle/CusPreLoadHandle.java
new file mode 100644
index 0000000..54e9634
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/annotations/handle/CusPreLoadHandle.java
@@ -0,0 +1,23 @@
+package xuanran.wang.http_test.annotations.handle;
+
+import aiyh.utils.tool.cn.hutool.core.annotation.AliasFor;
+import xuanran.wang.http_test.annotations.CusRequestUrl;
+import xuanran.wang.http_test.annotations.request_type.CusRequestType;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+
+import java.lang.annotation.*;
+
+/**
+ * 请求前置加载
+ *
+ * @author xuanran.wang
+ * @date 2023/3/20 21:14
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@CusHandle(order = 0)
+public @interface CusPreLoadHandle {
+ @AliasFor(annotation = CusHandle.class, attribute = "order")
+ int order() default 0;
+}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/handle/CusReqAfterHandleRegister.java b/src/test/java/xuanran/wang/http_test/annotations/handle/CusReqAfterHandleRegister.java
new file mode 100644
index 0000000..172c5af
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/annotations/handle/CusReqAfterHandleRegister.java
@@ -0,0 +1,19 @@
+package xuanran.wang.http_test.annotations.handle;
+
+import xuanran.wang.http_test.handle.CusRequestAfterHandle;
+import xuanran.wang.http_test.test.TestRequestAfterHandle;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/24 14:44
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Documented
+public @interface CusReqAfterHandleRegister {
+ Class> afterHandle();
+}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/handle/CusResponseSuccessHandle.java b/src/test/java/xuanran/wang/http_test/annotations/handle/CusResponseSuccessHandle.java
new file mode 100644
index 0000000..5f2755d
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/annotations/handle/CusResponseSuccessHandle.java
@@ -0,0 +1,19 @@
+package xuanran.wang.http_test.annotations.handle;
+
+import java.lang.annotation.*;
+
+/**
+ * 响应体成功失败标识
+ *
+ * @author xuanran.wang
+ * @date 2023/3/22 11:29
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Documented
+public @interface CusResponseSuccessHandle {
+ String successKey();
+ String successCondition();
+ String errorMsg();
+ String data();
+}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java b/src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java
index c6c3706..3fc2936 100644
--- a/src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java
+++ b/src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java
@@ -14,7 +14,7 @@ import java.lang.annotation.*;
* @date 2023/3/14 22:50
*/
@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
+@Target({ElementType.METHOD,ElementType.PARAMETER})
@Documented
public @interface CusPathQuery {
/**
diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java
index a20a87a..427f25f 100644
--- a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java
+++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java
@@ -1,5 +1,9 @@
package xuanran.wang.http_test.annotations.request_type;
+import aiyh.utils.tool.cn.hutool.core.annotation.AliasFor;
+import xuanran.wang.http_test.annotations.CusRequestUrl;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+
import java.lang.annotation.*;
/**
@@ -11,6 +15,12 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
+@CusRequestUrl(url = "")
+@CusRequestType(requestType = CusRequestClientConstant.DELETE)
public @interface CusRequestDelete {
- String url() default "";
+ @AliasFor(annotation = CusRequestUrl.class, attribute = "url")
+ String url();
+
+ @AliasFor(annotation = CusRequestType.class, attribute = "requestType")
+ int requestType() default CusRequestClientConstant.DELETE;
}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java
index 14a7ec2..ad1fe1d 100644
--- a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java
+++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java
@@ -1,5 +1,9 @@
package xuanran.wang.http_test.annotations.request_type;
+import aiyh.utils.tool.cn.hutool.core.annotation.AliasFor;
+import xuanran.wang.http_test.annotations.CusRequestUrl;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+
import java.lang.annotation.*;
/**
@@ -9,8 +13,14 @@ import java.lang.annotation.*;
* @date 2023/3/10 10:15
*/
@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
+@Target({ElementType.METHOD, ElementType.TYPE})
@Documented
+@CusRequestUrl(url = "")
+@CusRequestType(requestType = CusRequestClientConstant.GET)
public @interface CusRequestGet{
- String url() default "";
+ @AliasFor(annotation = CusRequestUrl.class, attribute = "url")
+ String url();
+
+ @AliasFor(annotation = CusRequestType.class, attribute = "requestType")
+ int requestType() default CusRequestClientConstant.GET;
}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java
index 4871a05..57f6806 100644
--- a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java
+++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java
@@ -1,5 +1,9 @@
package xuanran.wang.http_test.annotations.request_type;
+import aiyh.utils.tool.cn.hutool.core.annotation.AliasFor;
+import xuanran.wang.http_test.annotations.CusRequestUrl;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+
import java.lang.annotation.*;
/**
@@ -11,6 +15,12 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
+@CusRequestUrl(url = "")
+@CusRequestType(requestType = CusRequestClientConstant.POST)
public @interface CusRequestPost {
- String url() default "";
+ @AliasFor(annotation = CusRequestUrl.class, attribute = "url")
+ String url();
+
+ @AliasFor(annotation = CusRequestType.class, attribute = "requestType")
+ int requestType() default CusRequestClientConstant.POST;
}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java
index 0fd5c5d..9a06cb2 100644
--- a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java
+++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java
@@ -1,5 +1,9 @@
package xuanran.wang.http_test.annotations.request_type;
+import aiyh.utils.tool.cn.hutool.core.annotation.AliasFor;
+import xuanran.wang.http_test.annotations.CusRequestUrl;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+
import java.lang.annotation.*;
/**
@@ -11,6 +15,12 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
+@CusRequestUrl(url = "")
+@CusRequestType(requestType = CusRequestClientConstant.PUT)
public @interface CusRequestPut {
- String url() default "";
+ @AliasFor(annotation = CusRequestUrl.class, attribute = "url")
+ String url();
+
+ @AliasFor(annotation = CusRequestType.class, attribute = "requestType")
+ int requestType() default CusRequestClientConstant.PUT;
}
diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestType.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestType.java
new file mode 100644
index 0000000..53b12a9
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestType.java
@@ -0,0 +1,16 @@
+package xuanran.wang.http_test.annotations.request_type;
+
+import java.lang.annotation.*;
+
+/**
+ * 请求类型
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 23:07
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Documented
+public @interface CusRequestType {
+ int requestType() default 0;
+}
diff --git a/src/test/java/xuanran/wang/http_test/constant/CusRequestClientConstant.java b/src/test/java/xuanran/wang/http_test/constant/CusRequestClientConstant.java
index d368610..0d83b8d 100644
--- a/src/test/java/xuanran/wang/http_test/constant/CusRequestClientConstant.java
+++ b/src/test/java/xuanran/wang/http_test/constant/CusRequestClientConstant.java
@@ -1,5 +1,16 @@
package xuanran.wang.http_test.constant;
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Function;
+
/**
* 请求工具常量
*
@@ -11,5 +22,51 @@ public class CusRequestClientConstant {
public static final int POST = 1;
public static final int DELETE = 2;
public static final int PUT = 3;
- public static final int HEADER = -1;
+ public static final int HTTP_SUCCESS_CODE = 200;
+ public static final Map> CONVERT = new HashMap<>();
+ public static final String IS_NOT_NULL = "{ is not null }";
+ public static final String EQUALS = "{ equals }";
+ public static final String EQUALS_IGNORE_CASE = "{ equalsIgnoreCase }";
+
+ static {
+ CONVERT.put(IS_NOT_NULL, cusRequest ->{
+ Map responseMap = cusRequest.getResponseMap();
+ CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle();
+ String key = responseSuccessHandle.successKey();
+ String errorMsg = responseSuccessHandle.errorMsg();
+ String successValue = Util.null2DefaultStr(Util.getValueByKeyStr(key, responseMap),"");
+ if (successValue == null) {
+ throw new CustomerException(Util.logStr("is not null check response error! the error is {}", responseMap.get(errorMsg)));
+ }
+ return JSONObject.toJSONString(responseMap.get(responseSuccessHandle.data()));
+ });
+
+ CONVERT.put(EQUALS, cusRequest ->{
+ Map responseMap = cusRequest.getResponseMap();
+ CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle();
+ String key = responseSuccessHandle.successKey();
+ String successCondition = responseSuccessHandle.successCondition();
+ String errorMsg = responseSuccessHandle.errorMsg();
+ String successValue = Util.null2DefaultStr(Util.getValueByKeyStr(key, responseMap),"");
+ String successConditionValue = successCondition.trim().replace(EQUALS, "").trim();
+ if(!successConditionValue.equals(successValue)){
+ throw new CustomerException(Util.logStr("equals check response error! the error is {}", responseMap.get(errorMsg)));
+ }
+ return JSONObject.toJSONString(responseMap.get(responseSuccessHandle.data()));
+ });
+
+ CONVERT.put(EQUALS_IGNORE_CASE, cusRequest ->{
+ Map responseMap = cusRequest.getResponseMap();
+ CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle();
+ String key = responseSuccessHandle.successKey();
+ String successCondition = responseSuccessHandle.successCondition();
+ String errorMsg = responseSuccessHandle.errorMsg();
+ String successValue = Util.null2DefaultStr(Util.getValueByKeyStr(key, responseMap),"");
+ String successConditionValue = successCondition.trim().replace(EQUALS_IGNORE_CASE, "").trim();
+ if(!successConditionValue.equalsIgnoreCase(Util.null2DefaultStr(successValue,""))){
+ throw new CustomerException(Util.logStr("equalsIgnoreCase check response error! the error is {}", responseMap.get(errorMsg)));
+ }
+ return JSONObject.toJSONString(responseMap.get(responseSuccessHandle.data()));
+ });
+ }
}
diff --git a/src/test/java/xuanran/wang/http_test/entity/CusHandleEntity.java b/src/test/java/xuanran/wang/http_test/entity/CusHandleEntity.java
new file mode 100644
index 0000000..9fe49f0
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/entity/CusHandleEntity.java
@@ -0,0 +1,16 @@
+package xuanran.wang.http_test.entity;
+
+import lombok.Data;
+
+/**
+ * 自定义handle
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 16:07
+ */
+@Data
+public class CusHandleEntity {
+ private Class> handleClass;
+ private int order;
+ private String packageName;
+}
diff --git a/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java b/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java
index 143ac83..67c06e9 100644
--- a/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java
+++ b/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java
@@ -4,7 +4,10 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
+import xuanran.wang.http_test.handle.CusRequestAfterHandle;
+import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
@@ -19,11 +22,17 @@ import java.util.function.Consumer;
@Setter
@Getter
public class CusRequestEntity{
- private String url;
- private Map headers;
- private Map pathParams;
- private Object bodyParams;
- private int requestType;
+ private String url = "";
+ private Map headers = new HashMap<>();
+ private Map pathParams = new HashMap<>();
+ private Object bodyParams = new Object();
+ private int requestType = -1;
private Consumer consumer;
- private boolean async;
+ private boolean async = false;
+ private String host = "";
+ private int port;
+ private Class> returnType;
+ private CusRequestAfterHandle cusRequestAfter;
+ private CusResponseSuccessHandle responseSuccessHandle;
+ private Map responseMap;
}
diff --git a/src/test/java/xuanran/wang/http_test/entity/CusResponseSuccess.java b/src/test/java/xuanran/wang/http_test/entity/CusResponseSuccess.java
new file mode 100644
index 0000000..3bed5a1
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/entity/CusResponseSuccess.java
@@ -0,0 +1,21 @@
+package xuanran.wang.http_test.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 接口响应成功标识对象
+ *
+ * @author xuanran.wang
+ * @date 2023/3/29 16:58
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CusResponseSuccess {
+ private String successKey;
+ private String successCondition;
+ private String errorMsg;
+ private String data;
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/CusHandleCenter.java b/src/test/java/xuanran/wang/http_test/handle/CusHandleCenter.java
new file mode 100644
index 0000000..4bcafaa
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/CusHandleCenter.java
@@ -0,0 +1,129 @@
+package xuanran.wang.http_test.handle;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import aiyh.utils.httpUtil.ResponeVo;
+import aiyh.utils.tool.cn.hutool.core.annotation.AnnotationUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+
+import org.apache.log4j.Logger;
+import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister;
+import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
+import xuanran.wang.http_test.annotations.request_type.CusRequestType;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+import xuanran.wang.http_test.entity.CusHandleEntity;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.path_handle.CusBodyParseHandle;
+import xuanran.wang.http_test.handle.request_handle.CusRequestGetHandle;
+import xuanran.wang.http_test.handle.request_handle.CusRequestPostHandle;
+import xuanran.wang.http_test.handle.request_handle.CusUrlHandle;
+import xuanran.wang.http_test.handle.request_handle.CusDefaultRequestAfterHandle;
+import xuanran.wang.http_test.handle.util.HandleUtil;
+import xuanran.wang.http_test.proxy.RequestUtil;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 处理器中心对象
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 22:38
+ */
+public class CusHandleCenter{
+
+ private final Logger log = Util.getLogger();
+
+ private final Queue preloadQueue = new LinkedList<>();
+ private final Map requestHandle = new HashMap<>();
+ private final CusRequestAfterHandle cusRequestAfterHandle = new CusDefaultRequestAfterHandle();
+
+ {
+ requestHandle.put(CusRequestClientConstant.GET, new CusRequestGetHandle());
+ requestHandle.put(CusRequestClientConstant.POST, new CusRequestPostHandle());
+ preloadQueue.add(new CusUrlHandle());
+ preloadQueue.add(new CusBodyParseHandle());
+ }
+
+ public void requestBeforeHandle(CusRequestEntity cusRequest, Method method, Object[] args){
+ try {
+ log.info("preloadQueue => " + JSONObject.toJSONString(preloadQueue));
+ // 前置加载处理
+ for (CusRequestBeforeHandle handle : preloadQueue) {
+ handle.handle(cusRequest, method, args);
+ }
+ // 扫描执行handle包下面的所有加了CusHandle注解的实现方法并按order进行排序 包的顺序随机
+ HashMap> scan = HandleUtil.scanHandle();
+ log.info("scan => " + JSONObject.toJSONString(scan));
+ for (Map.Entry> entry : scan.entrySet()) {
+ List value = entry.getValue();
+ List collect = value.stream().sorted(Comparator.comparingInt(CusHandleEntity::getOrder)).collect(Collectors.toList());
+ log.info("扫描到的handle : " + JSONObject.toJSONString(collect));
+ for (CusHandleEntity handle : collect) {
+ Class> handleClass = handle.getHandleClass();
+ if (CusRequestBeforeHandle.class.isAssignableFrom(handleClass)) {
+ CusRequestBeforeHandle o = (CusRequestBeforeHandle) handleClass.newInstance();
+ o.handle(cusRequest, method, args);
+ }
+ }
+ }
+ }catch (Exception e){
+ throw new CustomerException("execute requestBeforeHandle error! " + e.getMessage());
+ }
+ }
+
+ public ResponeVo requestHandle(CusRequestEntity cusRequest, Method method){
+ try {
+ CusRequestType requestType = AnnotationUtil.getSynthesizedAnnotation(method, CusRequestType.class);
+ return requestHandle.get(requestType.requestType()).execute(cusRequest);
+ }catch (Exception e){
+ throw new CustomerException("request error! " + e.getMessage());
+ }
+ }
+
+ public Object requestAfterHandle(Method method, CusRequestEntity cusRequest, ResponeVo responseVo){
+ if(cusRequest.getCusRequestAfter() == null){
+ CusReqAfterHandleRegister cusReqAfterHandleRegister = method.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
+ if(cusReqAfterHandleRegister != null){
+ RequestUtil.setCusRequestAfter(cusReqAfterHandleRegister, cusRequest);
+ }
+ }
+// Type genericReturnType = method.getGenericReturnType();
+ cusRequest.setReturnType(method.getReturnType());
+ CusResponseSuccessHandle cusResponseSuccessHandle = method.getDeclaredAnnotation(CusResponseSuccessHandle.class);
+ if(cusResponseSuccessHandle != null && cusRequest.getResponseSuccessHandle() == null){
+ cusRequest.setResponseSuccessHandle(cusResponseSuccessHandle);
+ }
+ return requestAfterHandle(cusRequest, responseVo);
+ }
+
+ private Object requestAfterHandle(CusRequestEntity cusRequest, ResponeVo responseVo){
+ if(responseVo == null){
+ throw new CustomerException("CusRequestAfterHandle responseVo is null!");
+ }
+ int code = responseVo.getCode();
+ if(CusRequestClientConstant.HTTP_SUCCESS_CODE != code){
+ String url = cusRequest.getUrl();
+ log.error(Util.logStr("can not fetch [{}],this request params is [{}]," + // 构建日志字符串
+ "this request heard is [{}],but response status code is [{}]," +
+ "this response is [{}]", cusRequest.getUrl(), JSON.toJSON(cusRequest.getBodyParams()), JSON.toJSONString(cusRequest.getHeaders()), responseVo.getCode(), // 相应状态码
+ responseVo.getEntityString()));
+ throw new CustomerException(Util.logStr("can not fetch [{}]", url)); //
+ }
+ CusRequestAfterHandle handle = cusRequest.getCusRequestAfter() == null ? new CusDefaultRequestAfterHandle() : cusRequest.getCusRequestAfter();
+ cusRequest.setCusRequestAfter(handle);
+ log.info(Util.logStr("cusRequest: {}", JSONObject.toJSONString(cusRequest)));
+ Object res = handle.parseResponse(cusRequest, responseVo);
+ handle.service(cusRequest, responseVo);
+ return res;
+ }
+
+
+ public void registerPreHandle(CusRequestBeforeHandle handle){
+ preloadQueue.add(handle);
+ }
+
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/CusRequestAfterHandle.java b/src/test/java/xuanran/wang/http_test/handle/CusRequestAfterHandle.java
new file mode 100644
index 0000000..543f6b0
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/CusRequestAfterHandle.java
@@ -0,0 +1,31 @@
+package xuanran.wang.http_test.handle;
+
+import aiyh.utils.httpUtil.ResponeVo;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+
+
+/**
+ * 请求后处理器
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 23:57
+ */
+public interface CusRequestAfterHandle{
+ /**
+ * 解析响应方法
+ * @author xuanran.wang
+ * @dateTime 2023/3/24 15:32
+ * @param cusRequest 请求对象
+ * @param responseVo 响应对象
+ **/
+ Object parseResponse(CusRequestEntity cusRequest, ResponeVo responseVo);
+
+ /**
+ * do something
+ * @author xuanran.wang
+ * @dateTime 2023/3/24 15:32
+ * @param cusRequest 请求对象
+ * @param responseVo 响应对象
+ **/
+ void service(CusRequestEntity cusRequest, ResponeVo responseVo);
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/CusRequestBeforeHandle.java b/src/test/java/xuanran/wang/http_test/handle/CusRequestBeforeHandle.java
index 48faa20..4e0e80b 100644
--- a/src/test/java/xuanran/wang/http_test/handle/CusRequestBeforeHandle.java
+++ b/src/test/java/xuanran/wang/http_test/handle/CusRequestBeforeHandle.java
@@ -10,6 +10,6 @@ import java.lang.reflect.Method;
* @author xuanran.wang
* @date 2023/3/10 11:38
*/
-public interface RequestBeforeHandle {
- void handle(CusRequestEntity requestEntity, Method method, Object[] args);
+public interface CusRequestBeforeHandle {
+ void handle(CusRequestEntity cusRequest, Method method, Object[] args);
}
diff --git a/src/test/java/xuanran/wang/http_test/handle/CusRequestHandle.java b/src/test/java/xuanran/wang/http_test/handle/CusRequestHandle.java
new file mode 100644
index 0000000..06901f6
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/CusRequestHandle.java
@@ -0,0 +1,42 @@
+package xuanran.wang.http_test.handle;
+
+import aiyh.utils.httpUtil.ResponeVo;
+import aiyh.utils.httpUtil.util.HttpUtils;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+/**
+ * 请求参数初始化之后请求之前handle
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 23:21
+ */
+public abstract class CusRequestHandle {
+ protected HttpUtils httpUtils = new HttpUtils();
+
+ protected final ResponeVo execute(CusRequestEntity cusRequest) throws IOException{
+ String host = cusRequest.getHost();
+ int port = cusRequest.getPort();
+ String url = cusRequest.getUrl();
+ StringBuilder realRequestUrl = new StringBuilder();
+ if(url.startsWith("http:") || url.startsWith("https:")){
+ realRequestUrl.append(url);
+ }else {
+ realRequestUrl.append(host);
+ if(!host.endsWith(":")){
+ realRequestUrl.append(":");
+ }
+ realRequestUrl.append(port);
+ if(!url.endsWith("/")){
+ realRequestUrl.append("/");
+ }
+ realRequestUrl.append(url);
+ }
+ cusRequest.setUrl(realRequestUrl.toString());
+ return request(cusRequest);
+ }
+ // 执行具体的请求方法
+ protected abstract ResponeVo request(CusRequestEntity cusRequest) throws IOException;
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/header_handle/RequestHeaderHandle.java b/src/test/java/xuanran/wang/http_test/handle/header_handle/RequestHeaderHandle.java
new file mode 100644
index 0000000..7baeadb
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/header_handle/RequestHeaderHandle.java
@@ -0,0 +1,84 @@
+package xuanran.wang.http_test.handle.header_handle;
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import xuanran.wang.http_test.annotations.handle.CusHandle;
+import xuanran.wang.http_test.annotations.header.CusRequestHeader;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
+import xuanran.wang.http_test.interfaces.CusCreateRequestHeader;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 请求头处理
+ *
+ * @author xuanran.wang
+ * @date 2023/3/10 14:42
+ */
+@CusHandle
+public class RequestHeaderHandle implements CusRequestBeforeHandle {
+
+ @Override
+ public void handle(CusRequestEntity cusRequest, Method method, Object[] args) {
+ CusRequestHeader methodCusRequestHeader = method.getDeclaredAnnotation(CusRequestHeader.class);
+ if(methodCusRequestHeader == null){
+ return;
+ }
+ // 数组形式
+ String[] headersArr = methodCusRequestHeader.cusHeaders();
+ HashMap headers = new HashMap<>();
+ if(headersArr != null){
+ for (String headerStr : headersArr) {
+ String[] split = headerStr.split(":");
+ String key = Util.null2DefaultStr(split[0],"").trim();
+ String val = Util.null2DefaultStr(split[1],"").trim();
+ if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){
+ headers.put(key, val);
+ }
+ }
+ }
+
+ // java代码自定义
+ String path = Util.null2DefaultStr(methodCusRequestHeader.cusHeadersClassPath(),"");
+ if(StringUtils.isNotBlank(path)){
+ Class> clazz;
+ try {
+ clazz = Class.forName(path);
+ } catch (ClassNotFoundException e) {
+ throw new CustomerException(Util.logStr("自定义请求头java类文件没找到!: {}", path));
+ }
+ if(!CusCreateRequestHeader.class.isAssignableFrom(clazz)){
+ throw new CustomerException(Util.logStr("当前类路径:[{}] ,未实现CusCreateRequestHeader接口!", path));
+ }
+ CusCreateRequestHeader o;
+ try {
+ o = (CusCreateRequestHeader) clazz.newInstance();
+ }catch (InstantiationException | IllegalAccessException e) {
+ throw new CustomerException(Util.logStr("实例化 [{}] 对象失败! error:{}", path, e.getMessage()));
+ }
+ Map cusCreateHeader = o.createHeader();
+ if(MapUtils.isNotEmpty(cusCreateHeader)){
+ headers.putAll(cusCreateHeader);
+ }
+ }
+ // 参数中
+ Parameter[] parameters = method.getParameters();
+ for (int i = 0; i < parameters.length; i++) {
+ Parameter parameter = parameters[i];
+ CusRequestHeader requestHeader = parameter.getAnnotation(CusRequestHeader.class);
+ if(requestHeader != null){
+ String val = Util.null2DefaultStr(args[i], "").trim();
+ String key = requestHeader.value().trim();
+ if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){
+ headers.put(key, val);
+ }
+ }
+ }
+ cusRequest.getHeaders().putAll(headers);
+ }
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/path_handle/CusBodyParseHandle.java b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusBodyParseHandle.java
new file mode 100644
index 0000000..03735dd
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusBodyParseHandle.java
@@ -0,0 +1,39 @@
+package xuanran.wang.http_test.handle.path_handle;
+
+import aiyh.utils.excention.CustomerException;
+import aiyh.utils.tool.cn.hutool.core.annotation.AnnotationUtil;
+import org.springframework.web.bind.annotation.RequestBody;
+import xuanran.wang.http_test.annotations.CusRequestUrl;
+import xuanran.wang.http_test.annotations.body.CusRequestBody;
+import xuanran.wang.http_test.annotations.request_type.CusRequestType;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.util.Map;
+
+/**
+ * 请求体处理
+ *
+ * @author xuanran.wang
+ * @date 2023/3/20 21:21
+ */
+public class CusBodyParseHandle implements CusRequestBeforeHandle {
+ @Override
+ public void handle(CusRequestEntity cusRequest, Method method, Object[] args) {
+ Parameter[] parameters = method.getParameters();
+ for (int i = 0; i < parameters.length; i++) {
+ Parameter parameter = parameters[i];
+ CusRequestBody requestBody = parameter.getDeclaredAnnotation(CusRequestBody.class);
+ CusRequestType requestType = AnnotationUtil.getSynthesizedAnnotation(method, CusRequestType.class);
+ if(null != requestBody &&
+ null != requestType &&
+ requestType.requestType() != CusRequestClientConstant.GET){
+ cusRequest.setBodyParams(args[i]);
+ }
+ }
+ }
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/path_handle/CusPathParseHandle.java b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusPathParseHandle.java
index d9cf5b8..dc874d8 100644
--- a/src/test/java/xuanran/wang/http_test/handle/path_handle/CusPathParseHandle.java
+++ b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusPathParseHandle.java
@@ -2,9 +2,10 @@ package xuanran.wang.http_test.handle.path_handle;
import aiyh.utils.Util;
import org.apache.commons.lang3.StringUtils;
+import xuanran.wang.http_test.annotations.handle.CusHandle;
import xuanran.wang.http_test.annotations.request_path.CusPathQuery;
import xuanran.wang.http_test.entity.CusRequestEntity;
-import xuanran.wang.http_test.handle.RequestBeforeHandle;
+import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
@@ -16,11 +17,12 @@ import java.util.Map;
* @author xuanran.wang
* @date 2023/3/14 23:11
*/
-public class CusFieldKeyParseHandle implements RequestBeforeHandle {
+@CusHandle
+public class CusPathParseHandle implements CusRequestBeforeHandle {
@Override
- public void handle(CusRequestEntity requestEntity, Method method, Object[] args) {
+ public void handle(CusRequestEntity cusRequest, Method method, Object[] args) {
Parameter[] parameters = method.getParameters();
- String url = requestEntity.getUrl();
+ String url = cusRequest.getUrl();
for (int i = 0; i < parameters.length; i++) {
Parameter parameter = parameters[i];
CusPathQuery cusPathQuery = parameter.getDeclaredAnnotation(CusPathQuery.class);
@@ -33,11 +35,11 @@ public class CusFieldKeyParseHandle implements RequestBeforeHandle {
}else {
Class> clazz = parameter.getType();
if(clazz.isAssignableFrom(Map.class)){
- requestEntity.getPathParams().putAll((Map extends String, ? extends String>) arg);
+ cusRequest.getPathParams().putAll((Map) arg);
}
}
}
}
- requestEntity.setUrl(url);
+ cusRequest.setUrl(url);
}
}
diff --git a/src/test/java/xuanran/wang/http_test/handle/path_handle/TestHandle.java b/src/test/java/xuanran/wang/http_test/handle/path_handle/TestHandle.java
new file mode 100644
index 0000000..3133ded
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/path_handle/TestHandle.java
@@ -0,0 +1,22 @@
+package xuanran.wang.http_test.handle.path_handle;
+
+import xuanran.wang.http_test.annotations.handle.CusHandle;
+import xuanran.wang.http_test.annotations.handle.CusPreLoadHandle;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
+
+import java.lang.reflect.Method;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 16:22
+ */
+@CusHandle
+public class TestHandle implements CusRequestBeforeHandle {
+ @Override
+ public void handle(CusRequestEntity cusRequest, Method method, Object[] args) {
+ System.out.println("TestHandle 111");
+ }
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusDefaultRequestAfterHandle.java b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusDefaultRequestAfterHandle.java
new file mode 100644
index 0000000..500e3c0
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusDefaultRequestAfterHandle.java
@@ -0,0 +1,47 @@
+package xuanran.wang.http_test.handle.request_handle;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import aiyh.utils.httpUtil.ResponeVo;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.CusRequestAfterHandle;
+
+import java.util.Map;
+
+/**
+ * 默认的请求后处理响应类
+ *
+ * @author xuanran.wang
+ * @date 2023/3/17 11:03
+ */
+public class CusDefaultRequestAfterHandle implements CusRequestAfterHandle {
+
+ @Override
+ public Object parseResponse(CusRequestEntity cusRequest, ResponeVo responseVo) {
+ Class> returnType = cusRequest.getReturnType();
+ if(ResponeVo.class.isAssignableFrom(returnType)) {
+ return responseVo;
+ }
+ String json = responseVo.getEntityString();
+ cusRequest.setResponseMap(responseVo.getResponseMap());
+ CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle();
+ if(responseSuccessHandle != null){
+ String successCondition = responseSuccessHandle.successCondition();
+ String str = successCondition.substring(0, successCondition.lastIndexOf("}") + 1);
+ json = Util.null2DefaultStr(CusRequestClientConstant.CONVERT
+ .get(str)
+ .apply(cusRequest),"");
+ }
+ return JSONObject.parseObject(json, returnType);
+ }
+
+ @Override
+ public void service(CusRequestEntity cusRequest, ResponeVo responeVo){
+
+ }
+
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusRequestGetHandle.java b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusRequestGetHandle.java
new file mode 100644
index 0000000..6d8b84c
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusRequestGetHandle.java
@@ -0,0 +1,21 @@
+package xuanran.wang.http_test.handle.request_handle;
+
+import aiyh.utils.httpUtil.ResponeVo;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.CusRequestHandle;
+
+import java.io.IOException;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 23:20
+ */
+public class CusRequestGetHandle extends CusRequestHandle {
+
+ @Override
+ protected ResponeVo request(CusRequestEntity cusRequest) throws IOException {
+ return httpUtils.apiGet(cusRequest.getUrl(), cusRequest.getPathParams(), cusRequest.getHeaders());
+ }
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusRequestPostHandle.java b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusRequestPostHandle.java
new file mode 100644
index 0000000..56719ea
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusRequestPostHandle.java
@@ -0,0 +1,21 @@
+package xuanran.wang.http_test.handle.request_handle;
+
+import aiyh.utils.httpUtil.ResponeVo;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.CusRequestHandle;
+
+import java.io.IOException;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 23:20
+ */
+public class CusRequestPostHandle extends CusRequestHandle {
+
+ @Override
+ protected ResponeVo request(CusRequestEntity cusRequest) throws IOException {
+ return httpUtils.apiPostObject(cusRequest.getUrl(), cusRequest.getBodyParams(), cusRequest.getHeaders());
+ }
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusUrlHandle.java b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusUrlHandle.java
new file mode 100644
index 0000000..d5c9edb
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusUrlHandle.java
@@ -0,0 +1,29 @@
+package xuanran.wang.http_test.handle.request_handle;
+
+import aiyh.utils.excention.CustomerException;
+import aiyh.utils.tool.cn.hutool.core.annotation.AnnotationUtil;
+import xuanran.wang.http_test.annotations.CusRequestUrl;
+import xuanran.wang.http_test.annotations.request_type.CusRequestType;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.CusRequestBeforeHandle;
+
+import java.lang.reflect.Method;
+
+/**
+ * 方法路径拼接处理
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 19:51
+ */
+public class CusUrlHandle implements CusRequestBeforeHandle {
+ @Override
+ public void handle(CusRequestEntity cusRequest, Method method, Object[] args) {
+ CusRequestUrl requestUrl = AnnotationUtil.getSynthesizedAnnotation(method, CusRequestUrl.class);
+ if(requestUrl == null){
+ throw new CustomerException("method not found CusRequestUrl!");
+ }
+ cusRequest.setUrl(requestUrl.url());
+ Class> returnType = method.getReturnType();
+ cusRequest.setReturnType(returnType);
+ }
+}
diff --git a/src/test/java/xuanran/wang/http_test/handle/util/HandleUtil.java b/src/test/java/xuanran/wang/http_test/handle/util/HandleUtil.java
new file mode 100644
index 0000000..1590e99
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/handle/util/HandleUtil.java
@@ -0,0 +1,179 @@
+package xuanran.wang.http_test.handle.util;
+
+import aiyh.utils.excention.CustomerException;
+import ebu7common.youhong.ai.bean.Builder;
+import xuanran.wang.http_test.annotations.handle.CusHandle;
+import xuanran.wang.http_test.entity.CusHandleEntity;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/16 15:42
+ */
+public class HandleUtil {
+ /**
+ * 扫描指定路径下对class文件
+ * @author xuanran.wang
+ * @dateTime 2023/3/16 16:02
+ * @return class
+ **/
+ public static HashMap> scanHandle() throws ClassNotFoundException{
+ String packageName = HandleUtil.class.getPackage().getName();
+ return scan(packageName.substring(0, packageName.lastIndexOf(".")));
+ }
+
+ /**
+ * 扫描指定路径下的类文件
+ *
+ * @param packagePath 包路径
+ */
+ private static HashMap> scan(String packagePath) throws ClassNotFoundException {
+ // 转化包路径为文件路径
+ String scanPath = packagePath.replace(".", "/");
+ // 扫描
+ ClassLoader classLoader = HandleUtil.class.getClassLoader();
+ URL resource = classLoader.getResource(scanPath);
+ Set fileNameSet = new LinkedHashSet<>();
+ if (resource == null) {
+ throw new CustomerException("package is not found! :" + packagePath);
+ }
+ String rootPath = getRootPath(resource);
+ if (isJarFile(resource.getFile())) {
+ try {
+ // 是jar包使用JarInputStream
+ JarInputStream jarInputStream = new JarInputStream(Files.newInputStream(Paths.get(rootPath)));
+ JarEntry nextJarEntry = jarInputStream.getNextJarEntry();
+ // 遍历
+ while (null != nextJarEntry) {
+ String name = nextJarEntry.getName();
+ // 如果是指定包名下的文件并且是.class结尾,那就保存它
+ if (name.startsWith(scanPath) && isClassFile(name)) {
+ fileNameSet.add(name.replace(".class", ""));
+ }
+ nextJarEntry = jarInputStream.getNextJarEntry();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ // 是文件夹,获取该文件夹下所有文件
+ Set allFilePath = getAllFilePath(rootPath);
+ for (String filePath : allFilePath) {
+ fileNameSet.add(transFilePathToPackagePath(filePath, scanPath));
+ }
+ }
+ HashMap> maps = new HashMap<>();
+ for (String fileName : fileNameSet) {
+ String packageName = fileName.substring(0, fileName.lastIndexOf("."));
+ Class> scanClass = Class.forName(fileName, false, HandleUtil.class.getClassLoader());
+ CusHandle annotation = scanClass.getAnnotation(CusHandle.class);
+ if(null != annotation){
+ CusHandleEntity cusHandleEntity = Builder.builder(CusHandleEntity::new)
+ .with(CusHandleEntity::setHandleClass, scanClass)
+ .with(CusHandleEntity::setOrder, annotation.order())
+ .with(CusHandleEntity::setPackageName, packageName)
+ .build();
+ List cusHandleEntities = new ArrayList<>();
+ if(maps.containsKey(packageName)){
+ cusHandleEntities = maps.get(packageName);
+ }
+ cusHandleEntities.add(cusHandleEntity);
+ maps.put(packageName, cusHandleEntities);
+ }
+ }
+ return maps;
+ }
+
+ /**
+ * 遍历获取某个文件下所有文件名称
+ *
+ * @param path path
+ * @return Set
+ */
+ private static Set getAllFilePath(String path) {
+ Set fileSet = new LinkedHashSet<>();
+ File file = new File(path);
+ return getAllFilePath(fileSet, file);
+ }
+
+ /**
+ * 递归遍历获取某个文件下所有文件名称
+ *
+ * @param fileSet fileSet
+ * @param file 源文件
+ * @return Set
+ */
+ private static Set getAllFilePath(Set fileSet, File file) {
+ if (file.isDirectory()) {
+ File[] files = file.listFiles();
+ if (files != null) {
+ for (File file1 : files) {
+ getAllFilePath(fileSet, file1);
+ }
+ }
+ } else {
+ if (isClassFile(file.getAbsolutePath())) {
+ fileSet.add(file.getAbsolutePath());
+ }
+ return fileSet;
+ }
+ return fileSet;
+ }
+
+ /**
+ * 把文件路径转为包路径
+ *
+ * @param filePath filePath
+ * @param scanPath 扫描路径
+ * @return String
+ */
+ private static String transFilePathToPackagePath(String filePath, String scanPath) {
+ filePath = filePath.replace("\\", "/");
+ String substring = filePath.substring(filePath.indexOf(scanPath), filePath.indexOf(".class"));
+ return substring.replace("\\", ".").replace("/", ".");
+ }
+
+ /**
+ * 判断一个文件是不是jar包
+ *
+ * @param fileName fileName
+ * @return true-是,false-否
+ */
+ private static boolean isJarFile(String fileName) {
+ return fileName.contains(".jar!");
+ }
+
+ /**
+ * 判断一个文件class文件
+ *
+ * @param fileName fileName
+ * @return true-是,false-否
+ */
+ private static boolean isClassFile(String fileName) {
+ return fileName.endsWith(".class");
+ }
+
+ /**
+ * 获取文件路径
+ *
+ * @param url url
+ * @return String
+ */
+ private static String getRootPath(URL url) {
+ String path = url.getFile();
+ if (path.contains("!")) {
+ return path.substring(5, path.indexOf("!"));
+ }
+ return path;
+ }
+
+}
diff --git a/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java b/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java
index f0c7cc2..169237b 100644
--- a/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java
+++ b/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java
@@ -3,30 +3,21 @@ package xuanran.wang.http_test.proxy;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.ResponeVo;
-import aiyh.utils.httpUtil.util.HttpUtils;
-import com.alibaba.fastjson.JSON;
+import aiyh.utils.tool.cn.hutool.core.annotation.AnnotationUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.log4j.Logger;
import xuanran.wang.http_test.annotations.*;
-import xuanran.wang.http_test.annotations.async.CusAsync;
-import xuanran.wang.http_test.annotations.request_type.CusRequestDelete;
-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.CusRequestPut;
-import xuanran.wang.http_test.constant.RequestUtilConstant;
+import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister;
+import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
import xuanran.wang.http_test.entity.CusRequestEntity;
-import xuanran.wang.http_test.handle.*;
-import xuanran.wang.http_test.handle.path_handle.CusFieldKeyParseHandle;
+import xuanran.wang.http_test.handle.CusHandleCenter;
+import xuanran.wang.http_test.handle.CusRequestAfterHandle;
-import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import java.lang.reflect.Parameter;
import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Function;
+
/**
* 声明式发送http请求
@@ -36,57 +27,59 @@ import java.util.function.Function;
*/
public class RequestUtil implements InvocationHandler {
private CusRequestAddress cusRequestAddress = null;
- private final HttpUtils httpUtils = new HttpUtils();
private final Logger log = Util.getLogger();
- private boolean async = false;
+ private final CusHandleCenter handleCenter = new CusHandleCenter();
+ private final CusRequestEntity cusRequest = new CusRequestEntity();
public T getRequestClient(Class> clazz){
- Annotation annotation = clazz.getDeclaredAnnotation(CusRequest.class);
+ Annotation annotation = clazz.getDeclaredAnnotation(CusRequestClient.class);
if(annotation == null){
- throw new CustomerException("该类未添加CusRequest注解!");
+ throw new CustomerException(Util.logStr(clazz.getName() + " not found CusRequestClient annotation!"));
+ }
+ // 请求后处理
+ CusReqAfterHandleRegister cusReqAfterHandleRegister = clazz.getDeclaredAnnotation(CusReqAfterHandleRegister.class);
+ if(cusReqAfterHandleRegister != null){
+ setCusRequestAfter(cusReqAfterHandleRegister, cusRequest);
+ }
+ // 响应处理
+ CusResponseSuccessHandle cusResponseSuccessHandle = clazz.getDeclaredAnnotation(CusResponseSuccessHandle.class);
+ if(cusResponseSuccessHandle != null){
+ cusRequest.setResponseSuccessHandle(cusResponseSuccessHandle);
}
cusRequestAddress = clazz.getDeclaredAnnotation(CusRequestAddress.class);
- if(null != clazz.getDeclaredAnnotation(CusAsync.class)){
- async = true;
- }
+ cusRequestAddress = AnnotationUtil.getSynthesizedAnnotation(clazz, CusRequestAddress.class);
+// if(null != clazz.getDeclaredAnnotation(CusAsync.class)){
+// async = true;
+// }
return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, this);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
- StringBuilder url = new StringBuilder();
- CusRequestEntity cusRequest = new CusRequestEntity();
if(cusRequestAddress != null){
String host = Util.null2DefaultStr(cusRequestAddress.host(),"");
int port = Util.getIntValue( Util.null2DefaultStr(cusRequestAddress.port(),""),0);
- url.append(host)
- .append(":")
- .append(port);
- cusRequest.setUrl(url.toString());
+ cusRequest.setHost(host);
+ cusRequest.setPort(port);
}
- CusFieldKeyParseHandle keyParseHandle = new CusFieldKeyParseHandle();
- keyParseHandle.handle(cusRequest, method, args);
- log.info("cusRequest : \n" + JSONObject.toJSONString(cusRequest));
- return "";
+ handleCenter.requestBeforeHandle(cusRequest, method, args);
+ log.info("requestHandle : \n" + JSONObject.toJSONString(cusRequest));
+ ResponeVo responeVo = handleCenter.requestHandle(cusRequest, method);
+ return handleCenter.requestAfterHandle(method, cusRequest, responeVo);
}
- private String appendPath(StringBuilder url, String path){
- if(!path.endsWith("/")){
- url.append("/");
- }
- url.append(path);
- return url.toString();
- }
-
- public Object get(String url, Map params, Map headers) throws IOException {
- return httpUtils.apiGet(url, params, headers);
- }
-
- public static boolean isJSON(String str) {
- try {
- JSON.parse(str);
- return true;
- } catch (Exception e) {
- return false;
+ public static void setCusRequestAfter(CusReqAfterHandleRegister cusReqAfterHandleRegister,
+ CusRequestEntity cusRequest){
+ if(cusReqAfterHandleRegister != null){
+ Class> clazz = cusReqAfterHandleRegister.afterHandle();
+ if (CusRequestAfterHandle.class.isAssignableFrom(clazz)) {
+ try {
+ Object cusRequestAfter = clazz.newInstance();
+ cusRequest.setCusRequestAfter((CusRequestAfterHandle) cusRequestAfter);
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("class : {}, newInstance error!", e.getMessage()));
+ }
+ }
}
}
+
}
diff --git a/src/test/java/xuanran/wang/http_test/service/TestService.java b/src/test/java/xuanran/wang/http_test/service/TestService.java
index 00e770b..e74ea59 100644
--- a/src/test/java/xuanran/wang/http_test/service/TestService.java
+++ b/src/test/java/xuanran/wang/http_test/service/TestService.java
@@ -1,11 +1,15 @@
package xuanran.wang.http_test.service;
-import aiyh.utils.httpUtil.ResponeVo;
import xuanran.wang.http_test.annotations.*;
+import xuanran.wang.http_test.annotations.body.CusRequestBody;
+import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle;
import xuanran.wang.http_test.annotations.header.CusRequestHeader;
+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.CusRequestPost;
+import xuanran.wang.http_test.constant.CusRequestClientConstant;
+import java.util.List;
import java.util.Map;
/**
@@ -14,19 +18,20 @@ import java.util.Map;
* @author xuanran.wang
* @date 2023/3/10 12:39
*/
-@CusRequest
-@CusRequestAddress(host = "http://114.115.168.220/educate-plat/api/v1/class/getClassList/{test}", port = 8191)
+@CusRequestClient(host = "http://114.115.168.220", port = 8191)
+//@CusReqAfterHandleRegister(afterHandle = TestRequestAfterHandle.class)
public interface TestService {
-
- @CusRequestGet(url = "educate-plat/api/v1/class/getClassList/{test}")
- @CusRequestHeader(cusHeaders = {"sa: sasa", "sas:11212"})
- String getStu(Map path,
- @PostBody Map body,
- @CusRequestHeader("hsjhdsad") String test,
- @CusPathQuery("test") String test1);
-
- @CusRequestPost(url = "test/post/sas")
- @CusRequestHeader(cusHeaders = {"content-Type: application/json"}, cusHeadersClassPath = "java.fsdfds")
- String getStu(@PostBody Map body);
+ @CusRequestGet(url = "educate-plat/api/v1/class/getClassList")
+ @CusRequestHeader(cusHeaders = {"sa: sasa", "sas:11212","content-Type:application/json"})
+ @CusResponseSuccessHandle(
+ successKey = "code",
+ successCondition = CusRequestClientConstant.EQUALS + " 0 ",
+ errorMsg = "msg",
+ data = "data"
+ )
+ Map getStu(Map path,
+ @CusRequestBody Map body,
+ @CusRequestHeader("hsjhdsad") String test,
+ @CusPathQuery("test") String test1);
}
diff --git a/src/test/java/xuanran/wang/http_test/test/RequestTest.java b/src/test/java/xuanran/wang/http_test/test/RequestTest.java
index ca18084..7b3dccf 100644
--- a/src/test/java/xuanran/wang/http_test/test/RequestTest.java
+++ b/src/test/java/xuanran/wang/http_test/test/RequestTest.java
@@ -1,13 +1,18 @@
package xuanran.wang.http_test.test;
-import aiyh.utils.httpUtil.ResponeVo;
import basetest.BaseTest;
+import com.alibaba.fastjson.JSONObject;
+import com.api.doc.migrate.util.FtpUtil;
+import com.jcraft.jsch.ChannelSftp;
import org.junit.Test;
+import weaver.backup.utils.ZipUtil;
+import xuanran.wang.http_test.entity.CusHandleEntity;
+import xuanran.wang.http_test.handle.util.HandleUtil;
import xuanran.wang.http_test.proxy.CusUtil;
-import xuanran.wang.http_test.proxy.RequestUtil;
import xuanran.wang.http_test.service.TestService;
-import java.util.HashMap;
+import java.util.*;
+import java.util.stream.Collectors;
/**
*
@@ -24,7 +29,6 @@ public class RequestTest extends BaseTest {
map.put("a","1");
map.put("b","2");
HashMap body = new HashMap<>();
-
body.put("a","3");
body.put("b","4");
@@ -32,10 +36,29 @@ public class RequestTest extends BaseTest {
path.put("e","5");
path.put("f","6");
- requestClient.getStu(map, body, "a", "test1111");
+ Map stu = requestClient.getStu(map, body, "a", "test1111");
+ log.info("stu : \n" + JSONObject.toJSONString(stu));
+// 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));
// String stu1 = requestClient.getStu(body);
+ }
+
+ @Test
+ public void testA(){
+ try {
+ HashMap> scan = HandleUtil.scanHandle();
+ for (Map.Entry> entry : scan.entrySet()) {
+ List value = entry.getValue();
+ List collect = value.stream().sorted(Comparator.comparingInt(CusHandleEntity::getOrder)).collect(Collectors.toList());
+ log.info("collect : " + JSONObject.toJSONString(collect));
+ }
+ log.info("scan => " + JSONObject.toJSONString(scan));
+ }catch (Exception e){
+ log.info("erro => " + e.getMessage());
+ }
+
}
}
diff --git a/src/test/java/xuanran/wang/http_test/test/TestRequestAfterHandle.java b/src/test/java/xuanran/wang/http_test/test/TestRequestAfterHandle.java
new file mode 100644
index 0000000..a55804d
--- /dev/null
+++ b/src/test/java/xuanran/wang/http_test/test/TestRequestAfterHandle.java
@@ -0,0 +1,20 @@
+package xuanran.wang.http_test.test;
+
+import aiyh.utils.httpUtil.ResponeVo;
+import xuanran.wang.http_test.entity.CusRequestEntity;
+import xuanran.wang.http_test.handle.request_handle.CusDefaultRequestAfterHandle;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/20 14:48
+ */
+public class TestRequestAfterHandle extends CusDefaultRequestAfterHandle {
+
+ @Override
+ public void service(CusRequestEntity cusRequest, ResponeVo responseVo) {
+ System.out.println("============== ceshi xia ===============");
+ }
+
+}
diff --git a/src/test/java/xuanran/wang/immc/Kafka/MQTest.java b/src/test/java/xuanran/wang/immc/Kafka/MQTest.java
new file mode 100644
index 0000000..d2d69fe
--- /dev/null
+++ b/src/test/java/xuanran/wang/immc/Kafka/MQTest.java
@@ -0,0 +1,363 @@
+package xuanran.wang.immc.Kafka;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import basetest.BaseTest;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.kafka.clients.producer.RecordMetadata;
+import org.junit.Test;
+
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.Future;
+import java.util.stream.Collectors;
+
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.springframework.beans.BeanUtils;
+import weaver.conn.RecordSet;
+import weaver.workflow.request.todo.RequestStatusObj;
+import weaver.xuanran.wang.common.annocation.SqlFieldMapping;
+import weaver.xuanran.wang.common.annocation.SqlUpdateWhereField;
+import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
+import weaver.xuanran.wang.sh_bigdata.common.util.SendTodoTaskUtil;
+import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil;
+import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment;
+import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncApiService;
+import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncApiServiceImpl;
+import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusDoneTask;
+import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusDoneTaskOA;
+import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask;
+import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTaskToOADetail;
+import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/30 11:06
+ */
+public class MQTest extends BaseTest {
+
+ @Test
+ public void testProducer(){
+ // 设置Kafka生产者的配置属性
+ Properties props = new Properties();
+ props.put("bootstrap.servers", "10.184.42.41:9094,10.184.42.42:9094,10.184.42.40:9094");
+// props.put("acks", "all");
+// props.put("retries", 0);
+// props.put("batch.size", 16384);
+// props.put("linger.ms", 1);
+// props.put("buffer.memory", 33554432);
+ props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
+ props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
+ Map configMap = Util.getProperties2Map("VmsKafka");
+ if(MapUtils.isEmpty(configMap)){
+ throw new CustomerException("please check /web-inf/prop2map has VmsKafka.properties");
+ }
+ // 创建Kafka生产者实例
+ KafkaProducer producer =new KafkaProducer(configMap);
+
+ // 发送消息到指定主题
+ String topic = "oa_service_immc_topic_uat";
+ String message = "Hello, Kafka!";
+ ProducerRecord record = new ProducerRecord<>(topic, message);
+ Future send = producer.send(record);
+
+ // 关闭Kafka生产者实例
+ producer.close();
+
+
+
+ }
+
+ @Test
+ public void testA(){
+ RecordSet rs = new RecordSet();
+ rs.executeQuery("select je from formtable_main_20 where requestid = ?", 353354);
+ rs.next();
+ Map mapMapping = getMapMapping(rs);
+ System.out.println("mapMapping => " + JSONObject.toJSONString(mapMapping));
+ }
+
+ @Test
+ public void testB(){
+ String json = "{\n" +
+ " \"errcode\":0,\n" +
+ " \"errmsg\":\"ok\",\n" +
+ " \"access_token\": \"accesstoken000001\",\n" +
+ " \"expires_in\": 7200\n" +
+ "}";
+ Map map = JSONObject.parseObject(json, Map.class);
+ String dataKey = "access_token";
+ String parse = parse(map, dataKey).toString();
+ System.out.println("parse => " +JSONObject.toJSONString(parse));
+ }
+
+ public T parse(Map response, String dataKey){
+ dataKey = Util.null2DefaultStr(dataKey, "");
+ String[] split = dataKey.split("\\.");
+ int len = split.length;
+ if(len == 0 || StringUtils.isBlank(dataKey)){
+ return (T)response;
+ }
+ for (int i = 0; i < len - 1; i++) {
+ response = (Map) response.get(split[i]);
+ }
+ return (T) response.get(split[len - 1]);
+ }
+
+ private static Map getMapMapping(RecordSet rs) {
+ Map map = new HashMap<>();
+ String[] columnType = rs.getColumnTypeName();
+ int colCounts;
+ colCounts = rs.getColCounts() == 0 ? columnType.length : rs.getColCounts();
+ for (int i = 1; i <= colCounts; i++) {
+ String key;
+ String type = "varchar";
+ if (columnType != null) {
+ if (columnType.length != colCounts) {
+ type = "varchar";
+ } else {
+ type = columnType[i - 1];
+ }
+ }
+ key = rs.getColumnName(i).toLowerCase();
+ if ("int".equalsIgnoreCase(type) || "Integer".equalsIgnoreCase(type)
+ || "Long".equalsIgnoreCase(type) || "BIGINT".equalsIgnoreCase(type)
+ || "NUMBER".equalsIgnoreCase(type) || "INTEGER".equalsIgnoreCase(type)
+ || "TINYINT".equalsIgnoreCase(type) || "SMALLINT".equalsIgnoreCase(type)) {
+ map.put(key, rs.getInt(i) == -1 ? rs.getString(i) : rs.getInt(i));
+ continue;
+ }
+ if ("FLOAT".equalsIgnoreCase(type)) {
+ map.put(key, rs.getFloat(i));
+ continue;
+ }
+ if ("DATE".equalsIgnoreCase(type) || "TIMESTAMP".equalsIgnoreCase(type)
+ || "DATETIME".equalsIgnoreCase(type)) {
+ map.put(key, rs.getString(i));
+ continue;
+ }
+ if ("DOUBLE".equalsIgnoreCase(type)) {
+ map.put(key, rs.getDouble(i));
+ continue;
+ }
+ if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) {
+ String val = weaver.general.Util.null2String(rs.getString(i));
+ BigDecimal decimal;
+ if(StringUtils.isBlank(val)){
+ decimal = new BigDecimal("0");
+ }else {
+ decimal = new BigDecimal(val);
+ }
+ map.put(key, decimal);
+ continue;
+ }
+ map.put(key, rs.getString(i));
+ }
+ return map;
+ }
+
+ private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl();
+ @Test
+ public void testC(){
+ String json = "[{\"id\":1,\"name\":\"上海市\",\"parentid\":-1,\"order\":100000000,\"hasChild\":1},{\"id\":2,\"name\":\"市委\",\"parentid\":1,\"order\":100000000,\"hasChild\":0},{\"id\":14,\"name\":\"市人大\",\"parentid\":1,\"order\":99999500,\"hasChild\":1},{\"id\":15,\"name\":\"市人大常委会办公厅\",\"parentid\":14,\"order\":100000000,\"hasChild\":0},{\"id\":16,\"name\":\"市政府\",\"parentid\":1,\"order\":99999000,\"hasChild\":1},{\"id\":18,\"name\":\"市政府办公厅\",\"parentid\":16,\"order\":99999500,\"hasChild\":1},{\"id\":19,\"name\":\"秘书处\",\"parentid\":18,\"order\":100000000,\"hasChild\":0},{\"id\":20,\"name\":\"督查室\",\"parentid\":18,\"order\":99999500,\"hasChild\":0},{\"id\":21,\"name\":\"建议提案处\",\"parentid\":18,\"order\":99999000,\"hasChild\":0},{\"id\":22,\"name\":\"综合处\",\"parentid\":18,\"order\":99998500,\"hasChild\":0},{\"id\":23,\"name\":\"区政处\",\"parentid\":18,\"order\":99998000,\"hasChild\":0},{\"id\":24,\"name\":\"联络处\",\"parentid\":18,\"order\":99997500,\"hasChild\":0},{\"id\":25,\"name\":\"总值班室\",\"parentid\":18,\"order\":99997000,\"hasChild\":0},{\"id\":26,\"name\":\"政务公开办公室\",\"parentid\":18,\"order\":99996500,\"hasChild\":0},{\"id\":27,\"name\":\"数据发展管理办\",\"parentid\":18,\"order\":99996000,\"hasChild\":0},{\"id\":28,\"name\":\"法律事务办\",\"parentid\":18,\"order\":99995500,\"hasChild\":0},{\"id\":29,\"name\":\"政府职能转变协调处\",\"parentid\":18,\"order\":99995000,\"hasChild\":0},{\"id\":30,\"name\":\"政务服务处\",\"parentid\":18,\"order\":99994500,\"hasChild\":0},{\"id\":31,\"name\":\"上海发布办公室\",\"parentid\":18,\"order\":99994000,\"hasChild\":0},{\"id\":32,\"name\":\"打击走私综合治理处\",\"parentid\":18,\"order\":99993500,\"hasChild\":0},{\"id\":33,\"name\":\"城运规划处\",\"parentid\":18,\"order\":99993000,\"hasChild\":0},{\"id\":34,\"name\":\"指挥协调处\",\"parentid\":18,\"order\":99992500,\"hasChild\":0},{\"id\":35,\"name\":\"党政办公室\",\"parentid\":18,\"order\":99992000,\"hasChild\":0},{\"id\":36,\"name\":\"人事处\",\"parentid\":18,\"order\":99991500,\"hasChild\":0},{\"id\":37,\"name\":\"行政处\",\"parentid\":18,\"order\":99991000,\"hasChild\":0},{\"id\":38,\"name\":\"驻办公厅纪检组\",\"parentid\":18,\"order\":99990500,\"hasChild\":0},{\"id\":39,\"name\":\"市大数据中心\",\"parentid\":18,\"order\":99990000,\"hasChild\":0},{\"id\":40,\"name\":\"文印中心\",\"parentid\":18,\"order\":99989500,\"hasChild\":0},{\"id\":41,\"name\":\"离退休干部管理服务中心\",\"parentid\":18,\"order\":99989000,\"hasChild\":0},{\"id\":42,\"name\":\"市发展改革委\",\"parentid\":16,\"order\":99999000,\"hasChild\":1},{\"id\":43,\"name\":\"委领导\",\"parentid\":42,\"order\":100000000,\"hasChild\":0},{\"id\":44,\"name\":\"内设机构\",\"parentid\":42,\"order\":99999500,\"hasChild\":0},{\"id\":45,\"name\":\"直属单位\",\"parentid\":42,\"order\":99999000,\"hasChild\":0},{\"id\":46,\"name\":\"市经济信息化委\",\"parentid\":16,\"order\":99998500,\"hasChild\":1},{\"id\":47,\"name\":\"委领导\",\"parentid\":46,\"order\":100000000,\"hasChild\":0},{\"id\":48,\"name\":\"内设机构\",\"parentid\":46,\"order\":99999500,\"hasChild\":0},{\"id\":49,\"name\":\"直属单位\",\"parentid\":46,\"order\":99999000,\"hasChild\":0},{\"id\":50,\"name\":\"市商务委\",\"parentid\":16,\"order\":99998000,\"hasChild\":1},{\"id\":51,\"name\":\"委领导\",\"parentid\":50,\"order\":100000000,\"hasChild\":0},{\"id\":52,\"name\":\"内设机构\",\"parentid\":50,\"order\":99999500,\"hasChild\":0},{\"id\":53,\"name\":\"直属单位\",\"parentid\":50,\"order\":99999000,\"hasChild\":0},{\"id\":54,\"name\":\"市教委\",\"parentid\":16,\"order\":99997500,\"hasChild\":1},{\"id\":55,\"name\":\"委领导\",\"parentid\":54,\"order\":100000000,\"hasChild\":0},{\"id\":56,\"name\":\"内设机构\",\"parentid\":54,\"order\":99999500,\"hasChild\":0},{\"id\":57,\"name\":\"直属单位\",\"parentid\":54,\"order\":99999000,\"hasChild\":0},{\"id\":58,\"name\":\"市科委\",\"parentid\":16,\"order\":99997000,\"hasChild\":1},{\"id\":59,\"name\":\"委领导\",\"parentid\":58,\"order\":100000000,\"hasChild\":0},{\"id\":60,\"name\":\"内设机构\",\"parentid\":58,\"order\":99999500,\"hasChild\":0},{\"id\":61,\"name\":\"直属单位\",\"parentid\":58,\"order\":99999000,\"hasChild\":0},{\"id\":62,\"name\":\"市民族宗教局\",\"parentid\":16,\"order\":99996500,\"hasChild\":1},{\"id\":63,\"name\":\"委领导\",\"parentid\":62,\"order\":100000000,\"hasChild\":0},{\"id\":64,\"name\":\"内设机构\",\"parentid\":62,\"order\":99999500,\"hasChild\":0},{\"id\":65,\"name\":\"直属单位\",\"parentid\":62,\"order\":99999000,\"hasChild\":0},{\"id\":66,\"name\":\"市公安局\",\"parentid\":16,\"order\":99996000,\"hasChild\":1},{\"id\":67,\"name\":\"委领导\",\"parentid\":66,\"order\":100000000,\"hasChild\":0},{\"id\":68,\"name\":\"内设机构\",\"parentid\":66,\"order\":99999500,\"hasChild\":0},{\"id\":69,\"name\":\"直属单位\",\"parentid\":66,\"order\":99999000,\"hasChild\":0},{\"id\":70,\"name\":\"市民政局\",\"parentid\":16,\"order\":99995500,\"hasChild\":1},{\"id\":71,\"name\":\"局领导\",\"parentid\":70,\"order\":100000000,\"hasChild\":0},{\"id\":72,\"name\":\"内设机构\",\"parentid\":70,\"order\":99999500,\"hasChild\":0},{\"id\":73,\"name\":\"直属单位\",\"parentid\":70,\"order\":99999000,\"hasChild\":0},{\"id\":74,\"name\":\"市司法局\",\"parentid\":16,\"order\":99995000,\"hasChild\":1},{\"id\":75,\"name\":\"局领导\",\"parentid\":74,\"order\":100000000,\"hasChild\":0},{\"id\":76,\"name\":\"内设机构\",\"parentid\":74,\"order\":99999500,\"hasChild\":0},{\"id\":77,\"name\":\"直属单位\",\"parentid\":74,\"order\":99999000,\"hasChild\":0},{\"id\":78,\"name\":\"市财政局\",\"parentid\":16,\"order\":99994500,\"hasChild\":1},{\"id\":79,\"name\":\"局领导\",\"parentid\":78,\"order\":100000000,\"hasChild\":0},{\"id\":80,\"name\":\"内设机构\",\"parentid\":78,\"order\":99999500,\"hasChild\":0},{\"id\":81,\"name\":\"直属单位\",\"parentid\":78,\"order\":99999000,\"hasChild\":0},{\"id\":82,\"name\":\"市人力资源社会保障局\",\"parentid\":16,\"order\":99994000,\"hasChild\":1},{\"id\":83,\"name\":\"局领导\",\"parentid\":82,\"order\":100000000,\"hasChild\":0},{\"id\":84,\"name\":\"内设机构\",\"parentid\":82,\"order\":99999500,\"hasChild\":0},{\"id\":85,\"name\":\"直属单位\",\"parentid\":82,\"order\":99999000,\"hasChild\":0},{\"id\":86,\"name\":\"市规划资源局\",\"parentid\":16,\"order\":99993500,\"hasChild\":1},{\"id\":87,\"name\":\"内设机构\",\"parentid\":86,\"order\":100000000,\"hasChild\":0},{\"id\":88,\"name\":\"直属单位\",\"parentid\":86,\"order\":99999500,\"hasChild\":0},{\"id\":89,\"name\":\"市生态环境局\",\"parentid\":16,\"order\":99993000,\"hasChild\":1},{\"id\":93,\"name\":\"市住房城乡建设管理委\",\"parentid\":16,\"order\":99992500,\"hasChild\":1},{\"id\":94,\"name\":\"委领导\",\"parentid\":93,\"order\":100000000,\"hasChild\":0},{\"id\":95,\"name\":\"内设机构\",\"parentid\":93,\"order\":99999500,\"hasChild\":0},{\"id\":96,\"name\":\"直属单位\",\"parentid\":93,\"order\":99999000,\"hasChild\":0},{\"id\":97,\"name\":\"市交通委\",\"parentid\":16,\"order\":99992000,\"hasChild\":1},{\"id\":98,\"name\":\"委领导\",\"parentid\":97,\"order\":100000000,\"hasChild\":0},{\"id\":99,\"name\":\"内设机构\",\"parentid\":97,\"order\":99999500,\"hasChild\":0},{\"id\":100,\"name\":\"直属单位\",\"parentid\":97,\"order\":99999000,\"hasChild\":0},{\"id\":101,\"name\":\"市农业农村委\",\"parentid\":16,\"order\":99991500,\"hasChild\":1},{\"id\":102,\"name\":\"委领导\",\"parentid\":101,\"order\":100000000,\"hasChild\":0},{\"id\":103,\"name\":\"内设机构\",\"parentid\":101,\"order\":99999500,\"hasChild\":0},{\"id\":104,\"name\":\"直属单位\",\"parentid\":101,\"order\":99999000,\"hasChild\":0},{\"id\":105,\"name\":\"市水务局\",\"parentid\":16,\"order\":99991000,\"hasChild\":1},{\"id\":107,\"name\":\"局机关\",\"parentid\":105,\"order\":100000000,\"hasChild\":1},{\"id\":108,\"name\":\"局属单位\",\"parentid\":105,\"order\":99999500,\"hasChild\":1},{\"id\":109,\"name\":\"市文化旅游局\",\"parentid\":16,\"order\":99990500,\"hasChild\":1},{\"id\":110,\"name\":\"局领导\",\"parentid\":109,\"order\":100000000,\"hasChild\":0},{\"id\":111,\"name\":\"内设机构\",\"parentid\":109,\"order\":99999500,\"hasChild\":0},{\"id\":112,\"name\":\"直属单位\",\"parentid\":109,\"order\":99999000,\"hasChild\":0},{\"id\":113,\"name\":\"市卫生健康委\",\"parentid\":16,\"order\":99990000,\"hasChild\":1},{\"id\":114,\"name\":\"委领导\",\"parentid\":113,\"order\":100000000,\"hasChild\":0},{\"id\":115,\"name\":\"内设机构\",\"parentid\":113,\"order\":99999500,\"hasChild\":0},{\"id\":116,\"name\":\"直属单位\",\"parentid\":113,\"order\":99999000,\"hasChild\":0},{\"id\":117,\"name\":\"市退役军人局\",\"parentid\":16,\"order\":99989500,\"hasChild\":1},{\"id\":119,\"name\":\"局机关\",\"parentid\":117,\"order\":100000000,\"hasChild\":1},{\"id\":120,\"name\":\"局属单位\",\"parentid\":117,\"order\":99999500,\"hasChild\":1},{\"id\":121,\"name\":\"市应急局\",\"parentid\":16,\"order\":99989000,\"hasChild\":1},{\"id\":122,\"name\":\"局领导\",\"parentid\":121,\"order\":100000000,\"hasChild\":0},{\"id\":123,\"name\":\"内设机构\",\"parentid\":121,\"order\":99999500,\"hasChild\":0},{\"id\":124,\"name\":\"直属单位\",\"parentid\":121,\"order\":99999000,\"hasChild\":0},{\"id\":125,\"name\":\"市消防救援总队\",\"parentid\":121,\"order\":99998500,\"hasChild\":0},{\"id\":126,\"name\":\"市审计局\",\"parentid\":16,\"order\":99988500,\"hasChild\":1},{\"id\":127,\"name\":\"局领导\",\"parentid\":126,\"order\":100000000,\"hasChild\":0},{\"id\":128,\"name\":\"内设机构\",\"parentid\":126,\"order\":99999500,\"hasChild\":0},{\"id\":129,\"name\":\"直属单位\",\"parentid\":126,\"order\":99999000,\"hasChild\":0},{\"id\":130,\"name\":\"市市场监管局\",\"parentid\":16,\"order\":99988000,\"hasChild\":1},{\"id\":131,\"name\":\"局领导\",\"parentid\":130,\"order\":100000000,\"hasChild\":0},{\"id\":132,\"name\":\"内设机构\",\"parentid\":130,\"order\":99999500,\"hasChild\":0},{\"id\":133,\"name\":\"直属单位\",\"parentid\":130,\"order\":99999000,\"hasChild\":0},{\"id\":134,\"name\":\"市地方金融监管局\",\"parentid\":16,\"order\":99987500,\"hasChild\":1},{\"id\":135,\"name\":\"局领导\",\"parentid\":134,\"order\":100000000,\"hasChild\":0},{\"id\":136,\"name\":\"内设机构\",\"parentid\":134,\"order\":99999500,\"hasChild\":0},{\"id\":137,\"name\":\"直属单位\",\"parentid\":134,\"order\":99999000,\"hasChild\":0},{\"id\":138,\"name\":\"市政府外办\",\"parentid\":16,\"order\":99987000,\"hasChild\":1},{\"id\":139,\"name\":\"办领导\",\"parentid\":138,\"order\":100000000,\"hasChild\":0},{\"id\":140,\"name\":\"内设机构\",\"parentid\":138,\"order\":99999500,\"hasChild\":0},{\"id\":141,\"name\":\"直属单位\",\"parentid\":138,\"order\":99999000,\"hasChild\":0},{\"id\":142,\"name\":\"市国资委\",\"parentid\":16,\"order\":99986500,\"hasChild\":1},{\"id\":144,\"name\":\"委机关\",\"parentid\":142,\"order\":100000000,\"hasChild\":1},{\"id\":145,\"name\":\"委属单位\",\"parentid\":142,\"order\":99999500,\"hasChild\":1},{\"id\":146,\"name\":\"市体育局\",\"parentid\":16,\"order\":99986000,\"hasChild\":1},{\"id\":150,\"name\":\"市统计局\",\"parentid\":16,\"order\":99985500,\"hasChild\":1},{\"id\":151,\"name\":\"局领导\",\"parentid\":150,\"order\":100000000,\"hasChild\":0},{\"id\":152,\"name\":\"内设机构\",\"parentid\":150,\"order\":99999500,\"hasChild\":0},{\"id\":153,\"name\":\"直属单位\",\"parentid\":150,\"order\":99999000,\"hasChild\":0},{\"id\":154,\"name\":\"市医保局\",\"parentid\":16,\"order\":99985000,\"hasChild\":1},{\"id\":155,\"name\":\"局领导\",\"parentid\":154,\"order\":100000000,\"hasChild\":0},{\"id\":156,\"name\":\"内设机构\",\"parentid\":154,\"order\":99999500,\"hasChild\":0},{\"id\":157,\"name\":\"直属单位\",\"parentid\":154,\"order\":99999000,\"hasChild\":0},{\"id\":158,\"name\":\"市绿化市容局\",\"parentid\":16,\"order\":99984500,\"hasChild\":1},{\"id\":159,\"name\":\"局领导\",\"parentid\":158,\"order\":100000000,\"hasChild\":0},{\"id\":160,\"name\":\"内设机构\",\"parentid\":158,\"order\":99999500,\"hasChild\":0},{\"id\":161,\"name\":\"直属单位\",\"parentid\":158,\"order\":99999000,\"hasChild\":0},{\"id\":162,\"name\":\"市机管局\",\"parentid\":16,\"order\":99984000,\"hasChild\":1},{\"id\":166,\"name\":\"市民防办\",\"parentid\":16,\"order\":99983500,\"hasChild\":1},{\"id\":170,\"name\":\"市政府合作交流办\",\"parentid\":16,\"order\":99983000,\"hasChild\":1},{\"id\":171,\"name\":\"办领导\",\"parentid\":170,\"order\":100000000,\"hasChild\":0},{\"id\":172,\"name\":\"内设机构\",\"parentid\":170,\"order\":99999500,\"hasChild\":0},{\"id\":173,\"name\":\"直属单位\",\"parentid\":170,\"order\":99999000,\"hasChild\":0},{\"id\":174,\"name\":\"市政府研究室\",\"parentid\":16,\"order\":99982500,\"hasChild\":1},{\"id\":175,\"name\":\"室领导\",\"parentid\":174,\"order\":100000000,\"hasChild\":0},{\"id\":177,\"name\":\"直属单位\",\"parentid\":174,\"order\":99999000,\"hasChild\":0},{\"id\":178,\"name\":\"市政府参事室\",\"parentid\":16,\"order\":99982000,\"hasChild\":1},{\"id\":182,\"name\":\"市知识产权局\",\"parentid\":16,\"order\":99981500,\"hasChild\":1},{\"id\":183,\"name\":\"局领导\",\"parentid\":182,\"order\":100000000,\"hasChild\":0},{\"id\":184,\"name\":\"内设机构\",\"parentid\":182,\"order\":99999500,\"hasChild\":0},{\"id\":185,\"name\":\"直属单位\",\"parentid\":182,\"order\":99999000,\"hasChild\":0},{\"id\":186,\"name\":\"市粮食物资储备局\",\"parentid\":16,\"order\":99981000,\"hasChild\":1},{\"id\":187,\"name\":\"局领导\",\"parentid\":186,\"order\":100000000,\"hasChild\":0},{\"id\":188,\"name\":\"内设机构\",\"parentid\":186,\"order\":99999500,\"hasChild\":0},{\"id\":189,\"name\":\"直属单位\",\"parentid\":186,\"order\":99999000,\"hasChild\":0},{\"id\":190,\"name\":\"市监狱管理局\",\"parentid\":16,\"order\":99980500,\"hasChild\":1},{\"id\":191,\"name\":\"局领导\",\"parentid\":190,\"order\":100000000,\"hasChild\":0},{\"id\":192,\"name\":\"内设机构\",\"parentid\":190,\"order\":99999500,\"hasChild\":0},{\"id\":193,\"name\":\"直属单位\",\"parentid\":190,\"order\":99999000,\"hasChild\":0},{\"id\":194,\"name\":\"市城管执法局\",\"parentid\":16,\"order\":99980000,\"hasChild\":1},{\"id\":195,\"name\":\"局领导\",\"parentid\":194,\"order\":100000000,\"hasChild\":0},{\"id\":196,\"name\":\"内设机构\",\"parentid\":194,\"order\":99999500,\"hasChild\":0},{\"id\":197,\"name\":\"直属单位\",\"parentid\":194,\"order\":99999000,\"hasChild\":0},{\"id\":198,\"name\":\"市房屋管理局\",\"parentid\":16,\"order\":99979500,\"hasChild\":1},{\"id\":199,\"name\":\"局领导\",\"parentid\":198,\"order\":100000000,\"hasChild\":0},{\"id\":200,\"name\":\"内设机构\",\"parentid\":198,\"order\":99999500,\"hasChild\":0},{\"id\":201,\"name\":\"直属单位\",\"parentid\":198,\"order\":99999000,\"hasChild\":0},{\"id\":202,\"name\":\"市药品监督管理局\",\"parentid\":16,\"order\":99979000,\"hasChild\":1},{\"id\":203,\"name\":\"局领导\",\"parentid\":202,\"order\":100000000,\"hasChild\":0},{\"id\":204,\"name\":\"内设机构\",\"parentid\":202,\"order\":99999500,\"hasChild\":0},{\"id\":205,\"name\":\"直属单位\",\"parentid\":202,\"order\":99999000,\"hasChild\":0},{\"id\":206,\"name\":\"市道路运输管理局\",\"parentid\":16,\"order\":99978500,\"hasChild\":1},{\"id\":207,\"name\":\"局领导\",\"parentid\":206,\"order\":100000000,\"hasChild\":0},{\"id\":208,\"name\":\"内设机构\",\"parentid\":206,\"order\":99999500,\"hasChild\":0},{\"id\":209,\"name\":\"直属单位\",\"parentid\":206,\"order\":99999000,\"hasChild\":0},{\"id\":210,\"name\":\"国家税务总局上海市税务局\",\"parentid\":16,\"order\":99978000,\"hasChild\":1},{\"id\":211,\"name\":\"局领导\",\"parentid\":210,\"order\":100000000,\"hasChild\":0},{\"id\":212,\"name\":\"内设机构\",\"parentid\":210,\"order\":99999500,\"hasChild\":0},{\"id\":213,\"name\":\"直属单位\",\"parentid\":210,\"order\":99999000,\"hasChild\":0},{\"id\":214,\"name\":\"市政府发展研究中心\",\"parentid\":16,\"order\":99977500,\"hasChild\":1},{\"id\":215,\"name\":\"中心领导\",\"parentid\":214,\"order\":100000000,\"hasChild\":0},{\"id\":216,\"name\":\"内设机构\",\"parentid\":214,\"order\":99999500,\"hasChild\":0},{\"id\":217,\"name\":\"直属单位\",\"parentid\":214,\"order\":99999000,\"hasChild\":0},{\"id\":218,\"name\":\"市政协\",\"parentid\":1,\"order\":99997500,\"hasChild\":1},{\"id\":219,\"name\":\"市政协办公厅\",\"parentid\":218,\"order\":100000000,\"hasChild\":0},{\"id\":220,\"name\":\"市法院\",\"parentid\":1,\"order\":99998500,\"hasChild\":0},{\"id\":221,\"name\":\"市检察院\",\"parentid\":1,\"order\":99998000,\"hasChild\":0},{\"id\":222,\"name\":\"各区\",\"parentid\":1,\"order\":99997000,\"hasChild\":1},{\"id\":223,\"name\":\"浦东新区\",\"parentid\":222,\"order\":100000000,\"hasChild\":1},{\"id\":224,\"name\":\"区委\",\"parentid\":223,\"order\":100000000,\"hasChild\":0},{\"id\":225,\"name\":\"区人大\",\"parentid\":223,\"order\":99999500,\"hasChild\":0},{\"id\":226,\"name\":\"区政府\",\"parentid\":223,\"order\":99999000,\"hasChild\":0},{\"id\":227,\"name\":\"区政协\",\"parentid\":223,\"order\":99998500,\"hasChild\":0},{\"id\":228,\"name\":\"区法院\",\"parentid\":223,\"order\":99998000,\"hasChild\":0},{\"id\":229,\"name\":\"区检察院\",\"parentid\":223,\"order\":99997500,\"hasChild\":0},{\"id\":230,\"name\":\"街镇\",\"parentid\":223,\"order\":99997000,\"hasChild\":0},{\"id\":231,\"name\":\"黄浦区\",\"parentid\":222,\"order\":99999500,\"hasChild\":1},{\"id\":232,\"name\":\"区委\",\"parentid\":231,\"order\":100000000,\"hasChild\":0},{\"id\":233,\"name\":\"区人大\",\"parentid\":231,\"order\":99999500,\"hasChild\":0},{\"id\":234,\"name\":\"区政府\",\"parentid\":231,\"order\":99999000,\"hasChild\":0},{\"id\":235,\"name\":\"区政协\",\"parentid\":231,\"order\":99998500,\"hasChild\":0},{\"id\":236,\"name\":\"区法院\",\"parentid\":231,\"order\":99998000,\"hasChild\":0},{\"id\":237,\"name\":\"区检察院\",\"parentid\":231,\"order\":99997500,\"hasChild\":0},{\"id\":238,\"name\":\"街道\",\"parentid\":231,\"order\":99997000,\"hasChild\":0},{\"id\":239,\"name\":\"静安区\",\"parentid\":222,\"order\":99999000,\"hasChild\":1},{\"id\":240,\"name\":\"区委\",\"parentid\":239,\"order\":100000000,\"hasChild\":0},{\"id\":241,\"name\":\"区人大\",\"parentid\":239,\"order\":99999500,\"hasChild\":0},{\"id\":242,\"name\":\"区政府\",\"parentid\":239,\"order\":99999000,\"hasChild\":0},{\"id\":243,\"name\":\"区政协\",\"parentid\":239,\"order\":99998500,\"hasChild\":0},{\"id\":244,\"name\":\"区法院\",\"parentid\":239,\"order\":99998000,\"hasChild\":0},{\"id\":245,\"name\":\"区检察院\",\"parentid\":239,\"order\":99997500,\"hasChild\":0},{\"id\":246,\"name\":\"街镇\",\"parentid\":239,\"order\":99997000,\"hasChild\":0},{\"id\":247,\"name\":\"徐汇区\",\"parentid\":222,\"order\":99998500,\"hasChild\":1},{\"id\":248,\"name\":\"区委\",\"parentid\":247,\"order\":100000000,\"hasChild\":0},{\"id\":249,\"name\":\"区人大\",\"parentid\":247,\"order\":99999500,\"hasChild\":0},{\"id\":250,\"name\":\"区政府\",\"parentid\":247,\"order\":99999000,\"hasChild\":1},{\"id\":251,\"name\":\"区政协\",\"parentid\":247,\"order\":99998500,\"hasChild\":0},{\"id\":252,\"name\":\"区法院\",\"parentid\":247,\"order\":99998000,\"hasChild\":0},{\"id\":253,\"name\":\"区检察院\",\"parentid\":247,\"order\":99997500,\"hasChild\":0},{\"id\":254,\"name\":\"街镇\",\"parentid\":247,\"order\":99997000,\"hasChild\":0},{\"id\":255,\"name\":\"长宁区\",\"parentid\":222,\"order\":99998000,\"hasChild\":1},{\"id\":256,\"name\":\"区委\",\"parentid\":255,\"order\":100000000,\"hasChild\":0},{\"id\":257,\"name\":\"区人大\",\"parentid\":255,\"order\":99999500,\"hasChild\":0},{\"id\":258,\"name\":\"区政府\",\"parentid\":255,\"order\":99999000,\"hasChild\":0},{\"id\":259,\"name\":\"区政协\",\"parentid\":255,\"order\":99998500,\"hasChild\":0},{\"id\":260,\"name\":\"区法院\",\"parentid\":255,\"order\":99998000,\"hasChild\":0},{\"id\":261,\"name\":\"区检察院\",\"parentid\":255,\"order\":99997500,\"hasChild\":0},{\"id\":262,\"name\":\"街镇\",\"parentid\":255,\"order\":99997000,\"hasChild\":0},{\"id\":263,\"name\":\"普陀区\",\"parentid\":222,\"order\":99997500,\"hasChild\":1},{\"id\":264,\"name\":\"区委\",\"parentid\":263,\"order\":100000000,\"hasChild\":0},{\"id\":265,\"name\":\"区人大\",\"parentid\":263,\"order\":99999500,\"hasChild\":0},{\"id\":266,\"name\":\"区政府\",\"parentid\":263,\"order\":99999000,\"hasChild\":0},{\"id\":267,\"name\":\"区政协\",\"parentid\":263,\"order\":99998500,\"hasChild\":0},{\"id\":268,\"name\":\"区法院\",\"parentid\":263,\"order\":99998000,\"hasChild\":0},{\"id\":269,\"name\":\"区检察院\",\"parentid\":263,\"order\":99997500,\"hasChild\":0},{\"id\":270,\"name\":\"街镇\",\"parentid\":263,\"order\":99997000,\"hasChild\":0},{\"id\":271,\"name\":\"虹口区\",\"parentid\":222,\"order\":99997000,\"hasChild\":1},{\"id\":272,\"name\":\"区委\",\"parentid\":271,\"order\":100000000,\"hasChild\":0},{\"id\":273,\"name\":\"区人大\",\"parentid\":271,\"order\":99999500,\"hasChild\":0},{\"id\":274,\"name\":\"区政府\",\"parentid\":271,\"order\":99999000,\"hasChild\":0},{\"id\":275,\"name\":\"区政协\",\"parentid\":271,\"order\":99998500,\"hasChild\":0},{\"id\":276,\"name\":\"区法院\",\"parentid\":271,\"order\":99998000,\"hasChild\":0},{\"id\":277,\"name\":\"区检察院\",\"parentid\":271,\"order\":99997500,\"hasChild\":0},{\"id\":278,\"name\":\"街镇\",\"parentid\":271,\"order\":99997000,\"hasChild\":0},{\"id\":279,\"name\":\"杨浦区\",\"parentid\":222,\"order\":99996500,\"hasChild\":1},{\"id\":280,\"name\":\"区委\",\"parentid\":279,\"order\":100000000,\"hasChild\":0},{\"id\":281,\"name\":\"区人大\",\"parentid\":279,\"order\":99999500,\"hasChild\":0},{\"id\":282,\"name\":\"区政府\",\"parentid\":279,\"order\":99999000,\"hasChild\":0},{\"id\":283,\"name\":\"区政协\",\"parentid\":279,\"order\":99998500,\"hasChild\":0},{\"id\":284,\"name\":\"区法院\",\"parentid\":279,\"order\":99998000,\"hasChild\":0},{\"id\":285,\"name\":\"区检察院\",\"parentid\":279,\"order\":99997500,\"hasChild\":0},{\"id\":286,\"name\":\"街镇\",\"parentid\":279,\"order\":99997000,\"hasChild\":0},{\"id\":287,\"name\":\"宝山区\",\"parentid\":222,\"order\":99996000,\"hasChild\":1},{\"id\":288,\"name\":\"区委\",\"parentid\":287,\"order\":100000000,\"hasChild\":0},{\"id\":289,\"name\":\"区人大\",\"parentid\":287,\"order\":99999500,\"hasChild\":0},{\"id\":290,\"name\":\"区政府\",\"parentid\":287,\"order\":99999000,\"hasChild\":0},{\"id\":291,\"name\":\"区政协\",\"parentid\":287,\"order\":99998500,\"hasChild\":0},{\"id\":292,\"name\":\"区法院\",\"parentid\":287,\"order\":99998000,\"hasChild\":0},{\"id\":293,\"name\":\"区检察院\",\"parentid\":287,\"order\":99997500,\"hasChild\":0},{\"id\":294,\"name\":\"街镇\",\"parentid\":287,\"order\":99997000,\"hasChild\":0},{\"id\":295,\"name\":\"闵行区\",\"parentid\":222,\"order\":99995500,\"hasChild\":1},{\"id\":296,\"name\":\"区委\",\"parentid\":295,\"order\":100000000,\"hasChild\":0},{\"id\":297,\"name\":\"区人大\",\"parentid\":295,\"order\":99999500,\"hasChild\":0},{\"id\":298,\"name\":\"区政府\",\"parentid\":295,\"order\":99999000,\"hasChild\":0},{\"id\":299,\"name\":\"区政协\",\"parentid\":295,\"order\":99998500,\"hasChild\":0},{\"id\":300,\"name\":\"区法院\",\"parentid\":295,\"order\":99998000,\"hasChild\":0},{\"id\":301,\"name\":\"区检察院\",\"parentid\":295,\"order\":99997500,\"hasChild\":0},{\"id\":302,\"name\":\"街镇\",\"parentid\":295,\"order\":99997000,\"hasChild\":0},{\"id\":303,\"name\":\"嘉定区\",\"parentid\":222,\"order\":99995000,\"hasChild\":1},{\"id\":304,\"name\":\"区委\",\"parentid\":303,\"order\":100000000,\"hasChild\":0},{\"id\":305,\"name\":\"区人大\",\"parentid\":303,\"order\":99999500,\"hasChild\":0},{\"id\":306,\"name\":\"区政府\",\"parentid\":303,\"order\":99999000,\"hasChild\":0},{\"id\":307,\"name\":\"区政协\",\"parentid\":303,\"order\":99998500,\"hasChild\":0},{\"id\":308,\"name\":\"区法院\",\"parentid\":303,\"order\":99998000,\"hasChild\":0},{\"id\":309,\"name\":\"区检察院\",\"parentid\":303,\"order\":99997500,\"hasChild\":0},{\"id\":310,\"name\":\"街镇\",\"parentid\":303,\"order\":99997000,\"hasChild\":0},{\"id\":311,\"name\":\"金山区\",\"parentid\":222,\"order\":99994500,\"hasChild\":1},{\"id\":312,\"name\":\"区委\",\"parentid\":311,\"order\":100000000,\"hasChild\":0},{\"id\":313,\"name\":\"区人大\",\"parentid\":311,\"order\":99999500,\"hasChild\":0},{\"id\":314,\"name\":\"区政府\",\"parentid\":311,\"order\":99999000,\"hasChild\":0},{\"id\":315,\"name\":\"区政协\",\"parentid\":311,\"order\":99998500,\"hasChild\":0},{\"id\":316,\"name\":\"区法院\",\"parentid\":311,\"order\":99998000,\"hasChild\":0},{\"id\":317,\"name\":\"区检察院\",\"parentid\":311,\"order\":99997500,\"hasChild\":0},{\"id\":318,\"name\":\"街镇\",\"parentid\":311,\"order\":99997000,\"hasChild\":0},{\"id\":319,\"name\":\"松江区\",\"parentid\":222,\"order\":99994000,\"hasChild\":1},{\"id\":320,\"name\":\"区委\",\"parentid\":319,\"order\":100000000,\"hasChild\":0},{\"id\":321,\"name\":\"区人大\",\"parentid\":319,\"order\":99999500,\"hasChild\":0},{\"id\":322,\"name\":\"区政府\",\"parentid\":319,\"order\":99999000,\"hasChild\":0},{\"id\":323,\"name\":\"区政协\",\"parentid\":319,\"order\":99998500,\"hasChild\":0},{\"id\":324,\"name\":\"区法院\",\"parentid\":319,\"order\":99998000,\"hasChild\":0},{\"id\":325,\"name\":\"区检察院\",\"parentid\":319,\"order\":99997500,\"hasChild\":0},{\"id\":326,\"name\":\"街镇\",\"parentid\":319,\"order\":99997000,\"hasChild\":0},{\"id\":327,\"name\":\"青浦区\",\"parentid\":222,\"order\":99993500,\"hasChild\":1},{\"id\":328,\"name\":\"区委\",\"parentid\":327,\"order\":100000000,\"hasChild\":0},{\"id\":329,\"name\":\"区人大\",\"parentid\":327,\"order\":99999500,\"hasChild\":0},{\"id\":330,\"name\":\"区政府\",\"parentid\":327,\"order\":99999000,\"hasChild\":0},{\"id\":331,\"name\":\"区政协\",\"parentid\":327,\"order\":99998500,\"hasChild\":0},{\"id\":332,\"name\":\"区法院\",\"parentid\":327,\"order\":99998000,\"hasChild\":0},{\"id\":333,\"name\":\"区检察院\",\"parentid\":327,\"order\":99997500,\"hasChild\":0},{\"id\":334,\"name\":\"街镇\",\"parentid\":327,\"order\":99997000,\"hasChild\":0},{\"id\":335,\"name\":\"奉贤区\",\"parentid\":222,\"order\":99993000,\"hasChild\":1},{\"id\":336,\"name\":\"区委\",\"parentid\":335,\"order\":100000000,\"hasChild\":0},{\"id\":337,\"name\":\"区人大\",\"parentid\":335,\"order\":99999500,\"hasChild\":0},{\"id\":338,\"name\":\"区政府\",\"parentid\":335,\"order\":99999000,\"hasChild\":0},{\"id\":339,\"name\":\"区政协\",\"parentid\":335,\"order\":99998500,\"hasChild\":0},{\"id\":340,\"name\":\"区法院\",\"parentid\":335,\"order\":99998000,\"hasChild\":0},{\"id\":341,\"name\":\"区检察院\",\"parentid\":335,\"order\":99997500,\"hasChild\":0},{\"id\":342,\"name\":\"街镇\",\"parentid\":335,\"order\":99997000,\"hasChild\":0},{\"id\":343,\"name\":\"崇明区\",\"parentid\":222,\"order\":99992500,\"hasChild\":1},{\"id\":344,\"name\":\"区委\",\"parentid\":343,\"order\":100000000,\"hasChild\":0},{\"id\":345,\"name\":\"区人大\",\"parentid\":343,\"order\":99999500,\"hasChild\":0},{\"id\":346,\"name\":\"区政府\",\"parentid\":343,\"order\":99999000,\"hasChild\":0},{\"id\":347,\"name\":\"区政协\",\"parentid\":343,\"order\":99998500,\"hasChild\":0},{\"id\":348,\"name\":\"区法院\",\"parentid\":343,\"order\":99998000,\"hasChild\":0},{\"id\":349,\"name\":\"区检察院\",\"parentid\":343,\"order\":99997500,\"hasChild\":0},{\"id\":350,\"name\":\"街道乡镇\",\"parentid\":343,\"order\":99997000,\"hasChild\":0},{\"id\":351,\"name\":\"业务条线\",\"parentid\":1,\"order\":99996500,\"hasChild\":1},{\"id\":352,\"name\":\"办公室和值班室系统\",\"parentid\":351,\"order\":99999500,\"hasChild\":0},{\"id\":353,\"name\":\"城运系统\",\"parentid\":351,\"order\":99999000,\"hasChild\":0},{\"id\":354,\"name\":\"网格系统\",\"parentid\":351,\"order\":99998500,\"hasChild\":0},{\"id\":355,\"name\":\"防汛防台系统\",\"parentid\":351,\"order\":99998000,\"hasChild\":0},{\"id\":356,\"name\":\"统一综合执法系统\",\"parentid\":351,\"order\":99997000,\"hasChild\":0},{\"id\":357,\"name\":\"重要会议保障\",\"parentid\":351,\"order\":99997500,\"hasChild\":0},{\"id\":358,\"name\":\"TEST-ZONE\",\"parentid\":667,\"order\":100000000,\"hasChild\":1},{\"id\":360,\"name\":\"正通过管理通讯录同时可手动编辑正\",\"parentid\":404,\"order\":100000000,\"hasChild\":1},{\"id\":362,\"name\":\"测试数据\",\"parentid\":358,\"order\":99999500,\"hasChild\":0},{\"id\":363,\"name\":\"测试数据1\",\"parentid\":358,\"order\":99993500,\"hasChild\":1},{\"id\":364,\"name\":\"测试数据2\",\"parentid\":358,\"order\":99994500,\"hasChild\":0},{\"id\":365,\"name\":\"超长部门名称测试超长部门名称测试\",\"parentid\":363,\"order\":100000000,\"hasChild\":0},{\"id\":366,\"name\":\"测试子部门\",\"parentid\":450,\"order\":99999500,\"hasChild\":0},{\"id\":368,\"name\":\"新建子部门\",\"parentid\":408,\"order\":99999000,\"hasChild\":0},{\"id\":369,\"name\":\"测试\",\"parentid\":358,\"order\":99998000,\"hasChild\":1},{\"id\":376,\"name\":\"1\",\"parentid\":450,\"order\":100000000,\"hasChild\":0},{\"id\":377,\"name\":\"23333\",\"parentid\":450,\"order\":99998500,\"hasChild\":0},{\"id\":378,\"name\":\"3\",\"parentid\":405,\"order\":100000000,\"hasChild\":1},{\"id\":380,\"name\":\"2\",\"parentid\":358,\"order\":99996000,\"hasChild\":1},{\"id\":399,\"name\":\"正在通过管理员权限\",\"parentid\":360,\"order\":100000000,\"hasChild\":0},{\"id\":400,\"name\":\"正在通过\",\"parentid\":405,\"order\":99999500,\"hasChild\":0},{\"id\":403,\"name\":\"1\",\"parentid\":358,\"order\":99996500,\"hasChild\":0},{\"id\":404,\"name\":\"21\",\"parentid\":450,\"order\":99999000,\"hasChild\":1},{\"id\":405,\"name\":\"dy测试\",\"parentid\":358,\"order\":99998500,\"hasChild\":1},{\"id\":406,\"name\":\"asdfa\",\"parentid\":408,\"order\":100000000,\"hasChild\":0},{\"id\":407,\"name\":\"asdfasdf'\",\"parentid\":408,\"order\":99998500,\"hasChild\":0},{\"id\":408,\"name\":\"dy测试22\",\"parentid\":405,\"order\":99999000,\"hasChild\":1},{\"id\":410,\"name\":\"局领导班子\",\"parentid\":107,\"order\":100000000,\"hasChild\":0},{\"id\":411,\"name\":\"二级巡视员\",\"parentid\":107,\"order\":99999500,\"hasChild\":0},{\"id\":412,\"name\":\"办公室\",\"parentid\":107,\"order\":99999000,\"hasChild\":0},{\"id\":413,\"name\":\"政策研究室\",\"parentid\":107,\"order\":99998500,\"hasChild\":0},{\"id\":414,\"name\":\"法规处\",\"parentid\":107,\"order\":99998000,\"hasChild\":0},{\"id\":415,\"name\":\"组织人事处(老干部处)\",\"parentid\":107,\"order\":99997500,\"hasChild\":0},{\"id\":416,\"name\":\"综合规划处\",\"parentid\":107,\"order\":99997000,\"hasChild\":0},{\"id\":417,\"name\":\"计划财务处\",\"parentid\":107,\"order\":99996500,\"hasChild\":0},{\"id\":418,\"name\":\"科技信息处(社会宣传处)\",\"parentid\":107,\"order\":99996000,\"hasChild\":0},{\"id\":419,\"name\":\"河长制工作处(综合督导处)\",\"parentid\":107,\"order\":99995500,\"hasChild\":0},{\"id\":420,\"name\":\"水资源管理处(上海市节约用水办公室)\",\"parentid\":107,\"order\":99995000,\"hasChild\":0},{\"id\":421,\"name\":\"建设管理处\",\"parentid\":107,\"order\":99994500,\"hasChild\":0},{\"id\":422,\"name\":\"水利管理处(水土保持处)\",\"parentid\":107,\"order\":99994000,\"hasChild\":0},{\"id\":423,\"name\":\"海域海岛管理处(海洋经济协调处)\",\"parentid\":107,\"order\":99993500,\"hasChild\":0},{\"id\":424,\"name\":\"水旱和海洋灾害防御处\",\"parentid\":107,\"order\":99993000,\"hasChild\":0},{\"id\":425,\"name\":\"设施运行管理处(安全监督处)\",\"parentid\":107,\"order\":99992500,\"hasChild\":0},{\"id\":426,\"name\":\"审计室\",\"parentid\":107,\"order\":99992000,\"hasChild\":0},{\"id\":427,\"name\":\"工会\",\"parentid\":107,\"order\":99991500,\"hasChild\":0},{\"id\":428,\"name\":\"机关党委\",\"parentid\":107,\"order\":99991000,\"hasChild\":0},{\"id\":429,\"name\":\"团委\",\"parentid\":107,\"order\":99990500,\"hasChild\":0},{\"id\":430,\"name\":\"纪检监察组\",\"parentid\":107,\"order\":99990000,\"hasChild\":0},{\"id\":431,\"name\":\"文印室\",\"parentid\":107,\"order\":99989500,\"hasChild\":0},{\"id\":432,\"name\":\"局网站编辑部\",\"parentid\":107,\"order\":99989000,\"hasChild\":0},{\"id\":433,\"name\":\"水务志编辑室\",\"parentid\":107,\"order\":99988500,\"hasChild\":0},{\"id\":434,\"name\":\"老干部活动中心\",\"parentid\":107,\"order\":99988000,\"hasChild\":0},{\"id\":435,\"name\":\"上海市水务局执法总队(中国海监上海市总队)\",\"parentid\":108,\"order\":100000000,\"hasChild\":0},{\"id\":436,\"name\":\"上海市水务局行政服务中心(上海市海洋局行政服务中心)\",\"parentid\":108,\"order\":99999500,\"hasChild\":0},{\"id\":437,\"name\":\"上海市水利管理事务中心(上海市河湖管理事务中心)\",\"parentid\":108,\"order\":99999000,\"hasChild\":0},{\"id\":438,\"name\":\"上海市供水管理事务中心(上海市节约用水促进中心)\",\"parentid\":108,\"order\":99998500,\"hasChild\":0},{\"id\":439,\"name\":\"上海市排水管理事务中心\",\"parentid\":108,\"order\":99998000,\"hasChild\":0},{\"id\":440,\"name\":\"上海市堤防泵闸建设运行中心\",\"parentid\":108,\"order\":99997500,\"hasChild\":0},{\"id\":441,\"name\":\"上海市水文总站\",\"parentid\":108,\"order\":99997000,\"hasChild\":0},{\"id\":442,\"name\":\"上海市水务规划设计研究院(上海市海洋规划设计研究院)\",\"parentid\":108,\"order\":99996500,\"hasChild\":0},{\"id\":443,\"name\":\"上海市供水调度监测中心\",\"parentid\":108,\"order\":99996000,\"hasChild\":0},{\"id\":444,\"name\":\"上海市水务建设工程安全质量监督中心站(上海市水务工程定额管理站)\",\"parentid\":108,\"order\":99995500,\"hasChild\":0},{\"id\":445,\"name\":\"上海市水旱灾害防御技术中心\",\"parentid\":108,\"order\":99995000,\"hasChild\":0},{\"id\":446,\"name\":\"上海市海洋管理事务中心\",\"parentid\":108,\"order\":99994500,\"hasChild\":0},{\"id\":447,\"name\":\"上海市海洋监测预报中心\",\"parentid\":108,\"order\":99994000,\"hasChild\":0},{\"id\":449,\"name\":\"一个部门\",\"parentid\":378,\"order\":99999000,\"hasChild\":0},{\"id\":450,\"name\":\"test\",\"parentid\":380,\"order\":99999500,\"hasChild\":1},{\"id\":453,\"name\":\"委领导\",\"parentid\":144,\"order\":100000000,\"hasChild\":0},{\"id\":454,\"name\":\"党委办公室\",\"parentid\":144,\"order\":99999500,\"hasChild\":0},{\"id\":455,\"name\":\"组织处\",\"parentid\":144,\"order\":99999000,\"hasChild\":0},{\"id\":456,\"name\":\"宣传处\",\"parentid\":144,\"order\":99998500,\"hasChild\":0},{\"id\":457,\"name\":\"企业领导人员管理处\",\"parentid\":144,\"order\":99998000,\"hasChild\":0},{\"id\":458,\"name\":\"老干部处\",\"parentid\":144,\"order\":99997500,\"hasChild\":0},{\"id\":459,\"name\":\"办公室\",\"parentid\":144,\"order\":99997000,\"hasChild\":0},{\"id\":460,\"name\":\"人事处\",\"parentid\":144,\"order\":99996500,\"hasChild\":0},{\"id\":461,\"name\":\"研究室\",\"parentid\":144,\"order\":99996000,\"hasChild\":0},{\"id\":462,\"name\":\"政策法规处\",\"parentid\":144,\"order\":99995500,\"hasChild\":0},{\"id\":463,\"name\":\"规划发展处\",\"parentid\":144,\"order\":99995000,\"hasChild\":0},{\"id\":464,\"name\":\"创新发展处\",\"parentid\":144,\"order\":99994500,\"hasChild\":0},{\"id\":465,\"name\":\"企业改革处(城镇集体资产管理处)\",\"parentid\":144,\"order\":99994000,\"hasChild\":0},{\"id\":466,\"name\":\"金融企业发展处\",\"parentid\":144,\"order\":99993500,\"hasChild\":0},{\"id\":467,\"name\":\"产权管理处(资本运营管理处)\",\"parentid\":144,\"order\":99993000,\"hasChild\":0},{\"id\":468,\"name\":\"评估管理处\",\"parentid\":144,\"order\":99992500,\"hasChild\":0},{\"id\":469,\"name\":\"审计监督处(稽查办公室)\",\"parentid\":144,\"order\":99992000,\"hasChild\":0},{\"id\":470,\"name\":\"财务评价处\",\"parentid\":144,\"order\":99991500,\"hasChild\":0},{\"id\":471,\"name\":\"业绩考核处\",\"parentid\":144,\"order\":99991000,\"hasChild\":0},{\"id\":472,\"name\":\"分配保障处\",\"parentid\":144,\"order\":99990500,\"hasChild\":0},{\"id\":473,\"name\":\"综合协调处\",\"parentid\":144,\"order\":99990000,\"hasChild\":0},{\"id\":474,\"name\":\"公司治理处\",\"parentid\":144,\"order\":99989500,\"hasChild\":0},{\"id\":475,\"name\":\"信息化管理处\",\"parentid\":144,\"order\":99989000,\"hasChild\":0},{\"id\":476,\"name\":\"信访办公室\",\"parentid\":144,\"order\":99988500,\"hasChild\":0},{\"id\":477,\"name\":\"直属机关党委\",\"parentid\":144,\"order\":99988000,\"hasChild\":0},{\"id\":478,\"name\":\"上海市国有资产监督管理委员会企业发展服务中心\",\"parentid\":145,\"order\":100000000,\"hasChild\":0},{\"id\":479,\"name\":\"上海市国资国企改革发展研究中心\",\"parentid\":145,\"order\":99999500,\"hasChild\":0},{\"id\":480,\"name\":\"上海市国有企业绩效评价中心(上海市国有资产监督管理委员会稽查事务中心)\",\"parentid\":145,\"order\":99999000,\"hasChild\":0},{\"id\":481,\"name\":\"局领导\",\"parentid\":119,\"order\":100000000,\"hasChild\":0},{\"id\":482,\"name\":\"办公室\",\"parentid\":119,\"order\":99999500,\"hasChild\":0},{\"id\":483,\"name\":\"组织人事处\",\"parentid\":119,\"order\":99999000,\"hasChild\":0},{\"id\":484,\"name\":\"政策法规处\",\"parentid\":119,\"order\":99998500,\"hasChild\":0},{\"id\":485,\"name\":\"规划财务处\",\"parentid\":119,\"order\":99998000,\"hasChild\":0},{\"id\":486,\"name\":\"思想政治和权益维护处\",\"parentid\":119,\"order\":99997500,\"hasChild\":0},{\"id\":487,\"name\":\"移交安置处(就业创业处)\",\"parentid\":119,\"order\":99997000,\"hasChild\":0},{\"id\":488,\"name\":\"军休服务管理处\",\"parentid\":119,\"order\":99996500,\"hasChild\":0},{\"id\":489,\"name\":\"拥军优抚处(褒扬纪念处)\",\"parentid\":119,\"order\":99996000,\"hasChild\":0},{\"id\":490,\"name\":\"直属机关党委\",\"parentid\":119,\"order\":99995500,\"hasChild\":0},{\"id\":491,\"name\":\"上海市双拥服务中心\",\"parentid\":120,\"order\":100000000,\"hasChild\":0},{\"id\":492,\"name\":\"上海市军队离休退休干部活动中心\",\"parentid\":120,\"order\":99999500,\"hasChild\":0},{\"id\":493,\"name\":\"上海市荣誉军人疗养院\",\"parentid\":120,\"order\":99999000,\"hasChild\":0},{\"id\":494,\"name\":\"上海市龙华烈士陵园(龙华烈士纪念馆)\",\"parentid\":120,\"order\":99998500,\"hasChild\":0},{\"id\":495,\"name\":\"上海市军队离退休干部古美休养所\",\"parentid\":120,\"order\":99998000,\"hasChild\":0},{\"id\":496,\"name\":\"上海市军供站\",\"parentid\":120,\"order\":99997500,\"hasChild\":0},{\"id\":497,\"name\":\"上海市退役军人服务中心\",\"parentid\":120,\"order\":99997000,\"hasChild\":0},{\"id\":498,\"name\":\"参事室领导\",\"parentid\":178,\"order\":100000000,\"hasChild\":0},{\"id\":499,\"name\":\"秘书处\",\"parentid\":503,\"order\":100000000,\"hasChild\":0},{\"id\":500,\"name\":\"宣传交流处\",\"parentid\":503,\"order\":99999500,\"hasChild\":0},{\"id\":501,\"name\":\"参事业务处\",\"parentid\":503,\"order\":99999000,\"hasChild\":0},{\"id\":502,\"name\":\"组织人事处\",\"parentid\":503,\"order\":99998500,\"hasChild\":0},{\"id\":503,\"name\":\"内设机构\",\"parentid\":178,\"order\":99999500,\"hasChild\":1},{\"id\":504,\"name\":\"局机关\",\"parentid\":162,\"order\":100000000,\"hasChild\":1},{\"id\":505,\"name\":\"办公室\",\"parentid\":504,\"order\":100000000,\"hasChild\":0},{\"id\":506,\"name\":\"政策法规处(研究室)\",\"parentid\":504,\"order\":99999500,\"hasChild\":0},{\"id\":507,\"name\":\"人事处(老干部处)\",\"parentid\":504,\"order\":99999000,\"hasChild\":0},{\"id\":508,\"name\":\"财务处(审计室)\",\"parentid\":504,\"order\":99998500,\"hasChild\":0},{\"id\":509,\"name\":\"国有资产管理处\",\"parentid\":504,\"order\":99998000,\"hasChild\":0},{\"id\":510,\"name\":\"办公用房与人防设施处\",\"parentid\":504,\"order\":99997500,\"hasChild\":0},{\"id\":511,\"name\":\"车辆管理处\",\"parentid\":504,\"order\":99997000,\"hasChild\":0},{\"id\":512,\"name\":\"公共机构节能管理处\",\"parentid\":504,\"order\":99996500,\"hasChild\":0},{\"id\":513,\"name\":\"服务监管处(后勤改革指导处)\",\"parentid\":504,\"order\":99996000,\"hasChild\":0},{\"id\":514,\"name\":\"住房管理处\",\"parentid\":504,\"order\":99995500,\"hasChild\":0},{\"id\":515,\"name\":\"局管单位\",\"parentid\":162,\"order\":99999000,\"hasChild\":1},{\"id\":516,\"name\":\"上海市孙中山宋庆龄文物管理委员会\",\"parentid\":515,\"order\":100000000,\"hasChild\":0},{\"id\":517,\"name\":\"上海上勤(集团)有限公司\",\"parentid\":515,\"order\":99999500,\"hasChild\":0},{\"id\":518,\"name\":\"上海展览中心(集团)有限公司\",\"parentid\":515,\"order\":99999000,\"hasChild\":0},{\"id\":519,\"name\":\"上海孙中山故居纪念馆\",\"parentid\":515,\"order\":99998500,\"hasChild\":0},{\"id\":520,\"name\":\"上海宋庆龄故居纪念馆\",\"parentid\":515,\"order\":99998000,\"hasChild\":0},{\"id\":521,\"name\":\"中华人民共和国名誉主席宋庆龄陵园管理处(上海市万国公墓管理处)\",\"parentid\":515,\"order\":99997500,\"hasChild\":0},{\"id\":522,\"name\":\"局机关\",\"parentid\":146,\"order\":100000000,\"hasChild\":1},{\"id\":523,\"name\":\"局领导\",\"parentid\":522,\"order\":100000000,\"hasChild\":0},{\"id\":524,\"name\":\"办公室\",\"parentid\":522,\"order\":99999500,\"hasChild\":0},{\"id\":525,\"name\":\"规划产业处(法规处)\",\"parentid\":522,\"order\":99999000,\"hasChild\":0},{\"id\":526,\"name\":\"人事处(外事处)\",\"parentid\":522,\"order\":99998500,\"hasChild\":0},{\"id\":527,\"name\":\"财务处(设施建设处)\",\"parentid\":522,\"order\":99998000,\"hasChild\":0},{\"id\":528,\"name\":\"群众体育处\",\"parentid\":522,\"order\":99997500,\"hasChild\":0},{\"id\":529,\"name\":\"竞技体育处\",\"parentid\":522,\"order\":99997000,\"hasChild\":0},{\"id\":530,\"name\":\"青少年体育处(科教处)\",\"parentid\":522,\"order\":99996500,\"hasChild\":0},{\"id\":531,\"name\":\"竞赛处\",\"parentid\":522,\"order\":99996000,\"hasChild\":0},{\"id\":532,\"name\":\"局属单位\",\"parentid\":146,\"order\":99999500,\"hasChild\":1},{\"id\":533,\"name\":\"上海棋院(上海市棋牌运动管理中心)\",\"parentid\":532,\"order\":100000000,\"hasChild\":0},{\"id\":534,\"name\":\"上海市第二体育运动学校(上海市体育中学)\",\"parentid\":532,\"order\":99999500,\"hasChild\":0},{\"id\":535,\"name\":\"上海市划船俱乐部\",\"parentid\":532,\"order\":99999000,\"hasChild\":0},{\"id\":536,\"name\":\"上海市竞技体育训练管理中心\",\"parentid\":532,\"order\":99998500,\"hasChild\":0},{\"id\":537,\"name\":\"上海市科技体育运动管理中心\",\"parentid\":532,\"order\":99998000,\"hasChild\":0},{\"id\":538,\"name\":\"上海市马术运动管理中心\",\"parentid\":532,\"order\":99997500,\"hasChild\":0},{\"id\":539,\"name\":\"上海市青少年训练管理中心\",\"parentid\":532,\"order\":99997000,\"hasChild\":0},{\"id\":540,\"name\":\"上海市社会体育管理中心\",\"parentid\":532,\"order\":99996500,\"hasChild\":0},{\"id\":541,\"name\":\"上海市体育彩票管理中心\",\"parentid\":532,\"order\":99996000,\"hasChild\":0},{\"id\":542,\"name\":\"上海市体育场馆设施管理中心\",\"parentid\":532,\"order\":99995500,\"hasChild\":0},{\"id\":543,\"name\":\"上海市体育发展服务中心\",\"parentid\":532,\"order\":99995000,\"hasChild\":0},{\"id\":544,\"name\":\"上海市体育宣传教育中心\",\"parentid\":532,\"order\":99994500,\"hasChild\":0},{\"id\":545,\"name\":\"上海市体育训练基地管理中心\",\"parentid\":532,\"order\":99994000,\"hasChild\":0},{\"id\":546,\"name\":\"上海市体育运动学校\",\"parentid\":532,\"order\":99993500,\"hasChild\":0},{\"id\":547,\"name\":\"上海体育科学研究所(上海市反兴奋剂中心)\",\"parentid\":532,\"order\":99993000,\"hasChild\":0},{\"id\":548,\"name\":\"上海武术院(上海市健身气功管理中心)\",\"parentid\":532,\"order\":99992500,\"hasChild\":0},{\"id\":549,\"name\":\"上海市体育发展基金会\",\"parentid\":532,\"order\":99992000,\"hasChild\":0},{\"id\":550,\"name\":\"办机关\",\"parentid\":166,\"order\":100000000,\"hasChild\":1},{\"id\":551,\"name\":\"办领导\",\"parentid\":550,\"order\":100000000,\"hasChild\":0},{\"id\":552,\"name\":\"秘书处\",\"parentid\":550,\"order\":99999500,\"hasChild\":0},{\"id\":553,\"name\":\"政策法规处(审计监督室)\",\"parentid\":550,\"order\":99999000,\"hasChild\":0},{\"id\":554,\"name\":\"指挥通信处\",\"parentid\":550,\"order\":99998500,\"hasChild\":0},{\"id\":555,\"name\":\"工程处\",\"parentid\":550,\"order\":99998000,\"hasChild\":0},{\"id\":556,\"name\":\"科技宣教处\",\"parentid\":550,\"order\":99997500,\"hasChild\":0},{\"id\":557,\"name\":\"计划财务处\",\"parentid\":550,\"order\":99997000,\"hasChild\":0},{\"id\":558,\"name\":\"组织人事处\",\"parentid\":550,\"order\":99996500,\"hasChild\":0},{\"id\":559,\"name\":\"直属单位\",\"parentid\":166,\"order\":99999500,\"hasChild\":1},{\"id\":560,\"name\":\"上海市民防监督管理事务中心\",\"parentid\":559,\"order\":100000000,\"hasChild\":0},{\"id\":561,\"name\":\"上海市民防科学研究所\",\"parentid\":559,\"order\":99999500,\"hasChild\":0},{\"id\":562,\"name\":\"上海市民防指挥信息保障中心\",\"parentid\":559,\"order\":99999000,\"hasChild\":0},{\"id\":563,\"name\":\"上海市民防特种救援中心\",\"parentid\":559,\"order\":99998500,\"hasChild\":0},{\"id\":564,\"name\":\"上海市民防教育培训中心\",\"parentid\":559,\"order\":99998000,\"hasChild\":0},{\"id\":565,\"name\":\"局机关\",\"parentid\":89,\"order\":100000000,\"hasChild\":1},{\"id\":566,\"name\":\"局领导\",\"parentid\":565,\"order\":100000000,\"hasChild\":0},{\"id\":567,\"name\":\"办公室(宣传教育处、信访办公室)\",\"parentid\":565,\"order\":99999500,\"hasChild\":0},{\"id\":568,\"name\":\"生态环境保护督察办公室 \",\"parentid\":565,\"order\":99999000,\"hasChild\":0},{\"id\":569,\"name\":\"综合规划处(区域协作处)\",\"parentid\":565,\"order\":99998500,\"hasChild\":0},{\"id\":570,\"name\":\"法规与标准处\",\"parentid\":565,\"order\":99998000,\"hasChild\":0},{\"id\":571,\"name\":\"干部人事处\",\"parentid\":565,\"order\":99997500,\"hasChild\":0},{\"id\":572,\"name\":\"科技与国际合作处\",\"parentid\":565,\"order\":99997000,\"hasChild\":0},{\"id\":573,\"name\":\"自然生态保护处 \",\"parentid\":565,\"order\":99996500,\"hasChild\":0},{\"id\":574,\"name\":\"水生态环境处\",\"parentid\":565,\"order\":99996000,\"hasChild\":0},{\"id\":575,\"name\":\"海洋生态环境处\",\"parentid\":565,\"order\":99995500,\"hasChild\":0},{\"id\":576,\"name\":\"大气生态环境处\",\"parentid\":565,\"order\":99995000,\"hasChild\":0},{\"id\":577,\"name\":\"应对气候变化处\",\"parentid\":565,\"order\":99994500,\"hasChild\":0},{\"id\":578,\"name\":\"土壤生态环境处(固体废物与化学品处)\",\"parentid\":565,\"order\":99994000,\"hasChild\":0},{\"id\":579,\"name\":\"辐射安全管理处\",\"parentid\":565,\"order\":99993500,\"hasChild\":0},{\"id\":580,\"name\":\"环境影响评价与排放管理处\",\"parentid\":565,\"order\":99993000,\"hasChild\":0},{\"id\":581,\"name\":\"生态环境监测处\",\"parentid\":565,\"order\":99992500,\"hasChild\":0},{\"id\":582,\"name\":\"生态环境执法与应急处\",\"parentid\":565,\"order\":99992000,\"hasChild\":0},{\"id\":583,\"name\":\"局属单位\",\"parentid\":89,\"order\":99999500,\"hasChild\":1},{\"id\":584,\"name\":\"上海市环境科学研究院\",\"parentid\":583,\"order\":100000000,\"hasChild\":0},{\"id\":585,\"name\":\"上海市环境监测中心\",\"parentid\":583,\"order\":99999500,\"hasChild\":0},{\"id\":586,\"name\":\"上海市生态环境局执法总队\",\"parentid\":583,\"order\":99999000,\"hasChild\":0},{\"id\":587,\"name\":\"上海市辐射环境安全技术中心\",\"parentid\":583,\"order\":99998500,\"hasChild\":0},{\"id\":588,\"name\":\"上海市固体废物与化学品管理技术中心\",\"parentid\":583,\"order\":99998000,\"hasChild\":0},{\"id\":589,\"name\":\"上海市环境保护宣传教育中心\",\"parentid\":583,\"order\":99997500,\"hasChild\":0},{\"id\":590,\"name\":\"测试部门\",\"parentid\":358,\"order\":99997500,\"hasChild\":1},{\"id\":591,\"name\":\"测试子部门\",\"parentid\":590,\"order\":99999500,\"hasChild\":0},{\"id\":592,\"name\":\"测试子部门1\",\"parentid\":590,\"order\":100000000,\"hasChild\":0},{\"id\":593,\"name\":\"测试子部门2\",\"parentid\":590,\"order\":99999000,\"hasChild\":0},{\"id\":599,\"name\":\"推送简单\",\"parentid\":358,\"order\":99997000,\"hasChild\":1},{\"id\":602,\"name\":\"推送主节点变更测试\",\"parentid\":599,\"order\":99999500,\"hasChild\":0},{\"id\":603,\"name\":\"推送子部门\",\"parentid\":675,\"order\":100000000,\"hasChild\":1},{\"id\":606,\"name\":\"导出\",\"parentid\":358,\"order\":99995500,\"hasChild\":0},{\"id\":607,\"name\":\"ces\",\"parentid\":358,\"order\":99995000,\"hasChild\":0},{\"id\":610,\"name\":\"测试10-12\",\"parentid\":380,\"order\":100000000,\"hasChild\":0},{\"id\":611,\"name\":\"上海市大数据股份有限公司\",\"parentid\":351,\"order\":100000000,\"hasChild\":1},{\"id\":612,\"name\":\"人力资源管理部门\",\"parentid\":611,\"order\":99998500,\"hasChild\":0},{\"id\":613,\"name\":\"其他一些股份制有限公司\",\"parentid\":358,\"order\":99999000,\"hasChild\":1},{\"id\":614,\"name\":\"技术研发部门\",\"parentid\":611,\"order\":99998000,\"hasChild\":1},{\"id\":615,\"name\":\"行政执行部门\",\"parentid\":611,\"order\":99999500,\"hasChild\":0},{\"id\":616,\"name\":\"总裁办公室\",\"parentid\":611,\"order\":100000000,\"hasChild\":0},{\"id\":618,\"name\":\"行业集成组\",\"parentid\":614,\"order\":99999000,\"hasChild\":0},{\"id\":619,\"name\":\"云资源管理组\",\"parentid\":614,\"order\":100000000,\"hasChild\":0},{\"id\":620,\"name\":\"网络安全与运营维护组\",\"parentid\":614,\"order\":99998000,\"hasChild\":1},{\"id\":621,\"name\":\"大数据组\",\"parentid\":614,\"order\":99997500,\"hasChild\":0},{\"id\":622,\"name\":\"局属单位\",\"parentid\":162,\"order\":99999500,\"hasChild\":1},{\"id\":623,\"name\":\"离职人员\",\"parentid\":613,\"order\":100000000,\"hasChild\":0},{\"id\":624,\"name\":\"上海市市级机关建设管理事务中心\",\"parentid\":622,\"order\":100000000,\"hasChild\":0},{\"id\":625,\"name\":\"上海市市级机关国有资产事务中心(上海市机关事务行政服务中心)\",\"parentid\":622,\"order\":99999500,\"hasChild\":0},{\"id\":626,\"name\":\"上海市机关事务管理局人防工程管理中心(上海市机关事务管理局老干部活动室)\",\"parentid\":622,\"order\":99999000,\"hasChild\":0},{\"id\":627,\"name\":\"上海市市级机关第二幼儿园\",\"parentid\":622,\"order\":99998500,\"hasChild\":0},{\"id\":628,\"name\":\"上海市政府采购中心\",\"parentid\":622,\"order\":99998000,\"hasChild\":0},{\"id\":629,\"name\":\"财务会计部门\",\"parentid\":611,\"order\":99999000,\"hasChild\":0},{\"id\":647,\"name\":\"推送23\",\"parentid\":408,\"order\":99999500,\"hasChild\":0},{\"id\":648,\"name\":\"项目管理部门\",\"parentid\":614,\"order\":99998500,\"hasChild\":0},{\"id\":649,\"name\":\"SHDATA办公平台测试部门\",\"parentid\":358,\"order\":100000000,\"hasChild\":0},{\"id\":651,\"name\":\"0313测试部门全程\",\"parentid\":653,\"order\":100000000,\"hasChild\":1},{\"id\":653,\"name\":\"0313测试子部门全称\",\"parentid\":651,\"order\":100000000,\"hasChild\":1},{\"id\":665,\"name\":\"真的有很多人\",\"parentid\":668,\"order\":100000000,\"hasChild\":1},{\"id\":666,\"name\":\"泛微网络\",\"parentid\":351,\"order\":99996500,\"hasChild\":0},{\"id\":667,\"name\":\"测试组\",\"parentid\":614,\"order\":99999500,\"hasChild\":1},{\"id\":668,\"name\":\"可能有一个人\",\"parentid\":665,\"order\":100000000,\"hasChild\":1},{\"id\":670,\"name\":\"测试推全子部门\",\"parentid\":674,\"order\":100000000,\"hasChild\":1},{\"id\":674,\"name\":\"22\",\"parentid\":670,\"order\":100000000,\"hasChild\":1},{\"id\":675,\"name\":\"推送子子部门\",\"parentid\":603,\"order\":100000000,\"hasChild\":1},{\"id\":676,\"name\":\"区政府办公厅\",\"parentid\":250,\"order\":100000000,\"hasChild\":1},{\"id\":677,\"name\":\"区大数据中心\",\"parentid\":676,\"order\":100000000,\"hasChild\":0},{\"id\":678,\"name\":\"测试组\",\"parentid\":247,\"order\":99996500,\"hasChild\":0},{\"id\":679,\"name\":\"测试部门3\",\"parentid\":620,\"order\":100000001,\"hasChild\":0},{\"id\":680,\"name\":\"测试部门2\",\"parentid\":620,\"order\":99999500,\"hasChild\":0},{\"id\":681,\"name\":\"测试部门2_1\",\"parentid\":620,\"order\":100000001,\"hasChild\":0},{\"id\":682,\"name\":\"测试部门4\",\"parentid\":620,\"order\":100000001,\"hasChild\":0},{\"id\":683,\"name\":\"测试部门5\",\"parentid\":620,\"order\":100000000,\"hasChild\":0},{\"id\":688,\"name\":\"k测试5\",\"parentid\":369,\"order\":100000000,\"hasChild\":0},{\"id\":689,\"name\":\"k测试6\",\"parentid\":369,\"order\":99999500,\"hasChild\":0},{\"id\":690,\"name\":\"d测试1\",\"parentid\":667,\"order\":99999500,\"hasChild\":0},{\"id\":691,\"name\":\"d测试2\",\"parentid\":667,\"order\":99999000,\"hasChild\":0},{\"id\":692,\"name\":\"d测试3\",\"parentid\":667,\"order\":99998500,\"hasChild\":1},{\"id\":693,\"name\":\"d测试4\",\"parentid\":692,\"order\":100000000,\"hasChild\":1},{\"id\":694,\"name\":\"d测试5\",\"parentid\":693,\"order\":100000000,\"hasChild\":1},{\"id\":695,\"name\":\"d测试6\",\"parentid\":694,\"order\":100000000,\"hasChild\":1},{\"id\":696,\"name\":\"d测试7\",\"parentid\":695,\"order\":100000000,\"hasChild\":1},{\"id\":697,\"name\":\"d测试8\",\"parentid\":696,\"order\":100000000,\"hasChild\":1},{\"id\":698,\"name\":\"d测试9\",\"parentid\":697,\"order\":100000000,\"hasChild\":1},{\"id\":699,\"name\":\"d测试10\",\"parentid\":698,\"order\":100000000,\"hasChild\":0},{\"id\":700,\"name\":\"技术支持厂商\",\"parentid\":1,\"order\":99996000,\"hasChild\":1},{\"id\":701,\"name\":\"公务之家测试单位\",\"parentid\":700,\"order\":100000000,\"hasChild\":1},{\"id\":705,\"name\":\"局领导\",\"parentid\":701,\"order\":100000000,\"hasChild\":0},{\"id\":706,\"name\":\"财务处\",\"parentid\":701,\"order\":99999500,\"hasChild\":1},{\"id\":707,\"name\":\"开发部\",\"parentid\":701,\"order\":99999000,\"hasChild\":0},{\"id\":708,\"name\":\"测试部\",\"parentid\":701,\"order\":99998500,\"hasChild\":1},{\"id\":709,\"name\":\"财务一处\",\"parentid\":706,\"order\":100000000,\"hasChild\":1},{\"id\":710,\"name\":\"会计\",\"parentid\":709,\"order\":100000000,\"hasChild\":0},{\"id\":711,\"name\":\"一部\",\"parentid\":708,\"order\":100000000,\"hasChild\":0},{\"id\":712,\"name\":\"二部\",\"parentid\":708,\"order\":99999500,\"hasChild\":0}]";
+// List list = JSONObject.parseObject(json, List.class);
+ List departmentInfo = orgHrmAsyncApiService.getDepartmentInfo();
+ System.out.println("departmentInfoList => " + departmentInfo);
+ // 过滤出父节点并根据id进行升序排序
+ List rootDepList = departmentInfo
+ .stream()
+ .filter(item -> 1 == item.getHasChild() && -1 != item.getParentid())
+ .sorted(Comparator.comparing(OtherSysDepartment::getId))
+ .collect(Collectors.toList());
+ System.out.println("rootDepList => "+ JSONObject.toJSONString(rootDepList));
+ for (OtherSysDepartment sysDepartment : rootDepList) {
+ setChildList(sysDepartment, departmentInfo);
+ }
+ // 过滤出父节点并根据id进行升序排序
+
+ System.out.println("departmentInfo => " + JSONObject.toJSONString(departmentInfo, SerializerFeature.DisableCircularReferenceDetect));
+ }
+
+ public void setChildList(OtherSysDepartment department, List departmentList){
+ if(department.getHasChild() == 0){
+ return;
+ }
+ List childList = departmentList
+ .stream()
+ .filter(item -> department.getId() == item.getParentid())
+ .collect(Collectors.toList());
+ System.out.println("childList => " + JSONObject.toJSONString(childList));
+ department.setChildList(childList);
+ for (OtherSysDepartment sysDepartment : childList) {
+ setChildList(sysDepartment, departmentList);
+ }
+ }
+ private final SendTodoTaskMapper mapper = Util.getMapper(SendTodoTaskMapper.class);
+ @Test
+ public void testD(){
+ ArrayList details = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail();
+ detail.setTaskNum("14672332" + (System.currentTimeMillis() / 1000));
+ detail.setRequestUrl("11111");
+ detail.setTaskName("taskName" + i);
+ detail.setTaskType(0);
+ detail.setStatus(0);
+ detail.setSuccess(0);
+ detail.setResponse("{\n" +
+ " \"code\": 200,\n" +
+ " \"msg\": \"操作成功\", //返回文字描述\n" +
+ " \"data\": null,\n" +
+ " \"total\": null,\n" +
+ " \"totalPage\": null,\n" +
+ " \"takeTime\": null\n" +
+ "}");
+ detail.setRequestJson(JSONObject.toJSONString(detail));
+ String sourceTaskId = detail.getTaskNum().substring(0, detail.getTaskNum().length() - 10);
+ detail.setSourceTaskId(sourceTaskId);
+ details.add(detail);
+ }
+// CusInfoToOAUtil.executeBatchByEntity(111, details,"");
+ ArrayList list = new ArrayList<>();
+ ArrayList successTaskIds = new ArrayList<>();
+ List lists = mapper.queryUnSendTodoTaskList("14672332");
+ for (String num : lists) {
+ int success = 0;
+ CusDoneTaskOA taskOA = new CusDoneTaskOA();
+ taskOA.setTaskNum(num);
+ taskOA.setTaskType(1);
+ String sourceTaskId =num.substring(0, num.length() - 10);
+ taskOA.setSourceTaskId(sourceTaskId);
+ taskOA.setResponse("{\n" +
+ " \"code\": 200,\n" +
+ " \"msg\": \"操作成功\", //返回文字描述\n" +
+ " \"data\": null,\n" +
+ " \"total\": null,\n" +
+ " \"totalPage\": null,\n" +
+ " \"takeTime\": null\n" +
+ "}");
+ taskOA.setRequestUrl("22222222");
+ taskOA.setRequestJson(JSONObject.toJSONString(num));
+ taskOA.setSuccess(success);
+ list.add(taskOA);
+ successTaskIds.add(num);
+ }
+ CusInfoToOAUtil.executeBatchByEntity(111, list,"");
+ mapper.updateStatusByTaskNum(successTaskIds);
+ }
+
+ public void sqlTest(int modelId, List> list, String whereSql){
+ List> params = new ArrayList<>();
+ List> whereParams = new ArrayList<>();
+ StringBuilder whereSqlSb = new StringBuilder();
+ LinkedHashSet whereFields = new LinkedHashSet<>();
+ for (Object o : list) {
+ if(Objects.isNull(o)){
+ continue;
+ }
+ Class> clazz = o.getClass();
+ Field[] fields = clazz.getDeclaredFields();
+ LinkedHashMap linkedHashMap = new LinkedHashMap<>();
+ ArrayList whereParam = new ArrayList<>();
+ List fieldArr = Arrays.stream(fields).collect(Collectors.toList());
+ Class> superclass = clazz.getSuperclass();
+ // 找出父类所有的字段
+ while (superclass != null){
+ fieldArr.addAll(Arrays.stream(superclass.getDeclaredFields()).collect(Collectors.toList()));
+ superclass = superclass.getSuperclass();
+ }
+ for (Field field : fieldArr) {
+ field.setAccessible(true);
+ String fieldName = field.getName();
+ Object fieldValue;
+ try {
+ fieldValue = field.get(o);
+ } catch (IllegalAccessException e) {
+ throw new CustomerException(Util.logStr("field get error! the error is :[{}]," +
+ "current field is: [{}], current obj is: [{}]", e.getMessage(), fieldName, JSONObject.toJSONString(o)));
+ }
+ if(Objects.isNull(fieldValue)){
+ continue;
+ }
+ // 数据库字段映射 如果注解中没有值那么写入数据库就是实体类字段名
+ SqlFieldMapping sqlFieldMapping = field.getAnnotation(SqlFieldMapping.class);
+ if(null == sqlFieldMapping){
+ continue;
+ }
+ String sqlFieldMappingValue = sqlFieldMapping.value();
+ if(StringUtils.isNotBlank(sqlFieldMappingValue)){
+ fieldName = sqlFieldMappingValue;
+ }
+ linkedHashMap.put(fieldName, fieldValue);
+
+ // 更新条件字段注解
+ SqlUpdateWhereField sqlUpdateWhereField = field.getAnnotation(SqlUpdateWhereField.class);
+ if(null == sqlUpdateWhereField || !sqlUpdateWhereField.value()){
+ continue;
+ }
+ if(StringUtils.isBlank(whereSql)){
+ whereFields.add(fieldName + " = ? ");
+ }
+ whereParam.add(fieldValue.toString());
+ }
+ params.add(linkedHashMap);
+ whereParams.add(whereParam);
+ }
+ if(!whereFields.isEmpty()){
+ whereSqlSb = new StringBuilder("select id from #{tableName} where ");
+ for (String field : whereFields) {
+ whereSqlSb.append(field).append(" and ");
+ }
+ whereSql = whereSqlSb.substring(0, whereSqlSb.length() - 4);
+ }
+ System.out.println("params => " +JSONObject.toJSONString(params));
+ System.out.println("whereParams => " +JSONObject.toJSONString(whereParams));
+ System.out.println("whereSql => " +JSONObject.toJSONString(whereSql));
+
+ }
+
+
+ SendTodoTaskUtil sendTodoTaskUtil = new SendTodoTaskUtil();
+ @Test
+ public void testToken(){
+ String hrmConvertRuleSql = ShBigDataUtil.getPropertiesValByKey("hrmSenderConvertRuleSql");
+ System.out.println("hrm =>" + hrmConvertRuleSql);
+ RequestStatusObj obj = new RequestStatusObj();
+ obj.setRequestid(121323);
+ obj.setNodeid(12);
+ System.out.println("convert => " + sendTodoTaskUtil.getConvertHrm(0, obj, 22 + "," + 23));
+// String requestid = "8288283";
+// String detail = requestid + "" + (System.currentTimeMillis() / 1000);
+// System.out.println(detail.substring(0, detail.length() - 10));
+// for (int i = 0; i < 10; i++) {
+// int finalI = i;
+// new Thread(()->{
+// try {
+// if(finalI > 5){
+// Thread.sleep(1000 * 5 * finalI);
+// }
+// System.out.println("多线程校验token => " + ShBigDataUtil.getToken());
+// }catch (Exception e){
+//
+// }
+//
+// }).start();
+// }
+//
+// try {
+// Thread.sleep(1000 * 60 * 3);
+// String token1 = ShBigDataUtil.getToken();
+// System.out.println("模拟过期 => " + token1);
+// }catch (Exception e){
+//
+// }
+ }
+}
diff --git a/src/test/java/xuanran/wang/mq/CusMQType.java b/src/test/java/xuanran/wang/mq/CusMQType.java
new file mode 100644
index 0000000..37aebdb
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/CusMQType.java
@@ -0,0 +1,17 @@
+package xuanran.wang.mq;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/4/3 15:13
+ */
+public enum CusMQType {
+ ROCKET_MQ("RocketMQ",0),
+ KAFKA("Kafka",1),
+ RABBIT_MQ("RabbitMQ",2),
+ ACTIVE_MQ("ActiveMQ",3);
+
+ CusMQType(String type, int code) {
+ }
+}
diff --git a/src/test/java/xuanran/wang/mq/consumer/DefaultConsumer.java b/src/test/java/xuanran/wang/mq/consumer/DefaultConsumer.java
new file mode 100644
index 0000000..2c4e646
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/consumer/DefaultConsumer.java
@@ -0,0 +1,21 @@
+package xuanran.wang.mq.consumer;
+
+import com.weaverboot.frame.ioc.anno.classAnno.WeaSysInitComponent;
+import xuanran.wang.mq.infaces.CusMQClient;
+import xuanran.wang.mq.infaces.callback.CusMQCallBack;
+import xuanran.wang.mq.mq.CusMQFactory;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/4/3 15:04
+ */
+@WeaSysInitComponent("MQ-消费者")
+public class DefaultConsumer {
+
+ public static void registerConsumer(String configName, String type, CusMQCallBack callBack){
+ CusMQClient cusMQ = CusMQFactory.createCusMQ(configName, type);
+ cusMQ.consumer(callBack);
+ }
+}
diff --git a/src/test/java/xuanran/wang/mq/infaces/CusBaseMQ.java b/src/test/java/xuanran/wang/mq/infaces/CusBaseMQ.java
new file mode 100644
index 0000000..734b7f7
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/infaces/CusBaseMQ.java
@@ -0,0 +1,27 @@
+package xuanran.wang.mq.infaces;
+
+import aiyh.utils.Util;
+import org.apache.log4j.Logger;
+import xuanran.wang.mq.infaces.aop.CusMQAop;
+
+/**
+ * mq基础类
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 11:47
+ */
+public interface CusBaseMQ {
+ Logger log = Util.getLogger();
+ /**
+ * 初始化生产者
+ **/
+ void initProducer(String configName);
+ /**
+ * 初始化消费者
+ **/
+ void initConsumer(String configName);
+ /**
+ * 销毁
+ **/
+ void destroy();
+}
diff --git a/src/test/java/xuanran/wang/mq/infaces/CusConsumer.java b/src/test/java/xuanran/wang/mq/infaces/CusConsumer.java
new file mode 100644
index 0000000..fbdcc67
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/infaces/CusConsumer.java
@@ -0,0 +1,16 @@
+package xuanran.wang.mq.infaces;
+
+import xuanran.wang.mq.infaces.callback.CusMQCallBack;
+
+/**
+ * 消费者
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 11:56
+ */
+public interface CusConsumer extends CusBaseMQ{
+ /**
+ * 消费
+ **/
+ void consumer(CusMQCallBack callBack);
+}
diff --git a/src/test/java/xuanran/wang/mq/infaces/CusMQClient.java b/src/test/java/xuanran/wang/mq/infaces/CusMQClient.java
new file mode 100644
index 0000000..6c0d88f
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/infaces/CusMQClient.java
@@ -0,0 +1,11 @@
+package xuanran.wang.mq.infaces;
+
+/**
+ * 客户端
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 13:09
+ */
+public interface CusMQClient extends CusProducer, CusConsumer {
+}
+
diff --git a/src/test/java/xuanran/wang/mq/infaces/CusProducer.java b/src/test/java/xuanran/wang/mq/infaces/CusProducer.java
new file mode 100644
index 0000000..84cc44a
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/infaces/CusProducer.java
@@ -0,0 +1,16 @@
+package xuanran.wang.mq.infaces;
+
+import java.util.Map;
+
+/**
+ * 生产者方法
+ *
+ * @author xuanran.wang
+ * @date 2023/3/30 11:37
+ */
+public interface CusProducer extends CusBaseMQ{
+ /**
+ * 生产者
+ **/
+ void send(Object message);
+}
diff --git a/src/test/java/xuanran/wang/mq/infaces/aop/CusMQAop.java b/src/test/java/xuanran/wang/mq/infaces/aop/CusMQAop.java
new file mode 100644
index 0000000..a5184af
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/infaces/aop/CusMQAop.java
@@ -0,0 +1,18 @@
+package xuanran.wang.mq.infaces.aop;
+
+import aiyh.utils.tool.cn.hutool.core.collection.CollUtil;
+
+/**
+ * 切面
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 12:52
+ */
+public interface CusMQAop {
+ void sendBefore();
+ void sendAfter();
+ void consumerBefore();
+ void consumerAfter();
+ void destroyBefore();
+ void destroyAfter();
+}
diff --git a/src/test/java/xuanran/wang/mq/infaces/callback/CusMQCallBack.java b/src/test/java/xuanran/wang/mq/infaces/callback/CusMQCallBack.java
new file mode 100644
index 0000000..81a19a6
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/infaces/callback/CusMQCallBack.java
@@ -0,0 +1,35 @@
+package xuanran.wang.mq.infaces.callback;
+
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+/**
+ * 回调
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 13:13
+ */
+public interface CusMQCallBack {
+ /**
+ * kafka 回调
+ * @author xuanran.wang
+ * @dateTime 2023/4/3 14:55
+ * @param records 消息对象
+ **/
+ void kafkaCallBack(ConsumerRecords records);
+ /**
+ * rocket-MQ 回调
+ * @author xuanran.wang
+ * @dateTime 2023/4/3 14:55
+ * @param msgList 消息列表
+ * @param context 上下文
+ * @return 状态
+ **/
+ ConsumeConcurrentlyStatus rocketCallBack(List msgList, ConsumeConcurrentlyContext context);
+}
diff --git a/src/test/java/xuanran/wang/mq/mq/CusKafkaMQ.java b/src/test/java/xuanran/wang/mq/mq/CusKafkaMQ.java
new file mode 100644
index 0000000..b17dc4d
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/mq/CusKafkaMQ.java
@@ -0,0 +1,86 @@
+package xuanran.wang.mq.mq;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import lombok.NoArgsConstructor;
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import xuanran.wang.mq.infaces.*;
+import xuanran.wang.mq.infaces.aop.CusMQAop;
+import xuanran.wang.mq.infaces.callback.CusMQCallBack;
+import xuanran.wang.mq.util.CusMQUtil;
+
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+import java.util.Map;
+
+/**
+ * kafka
+ *
+ * @author xuanran.wang
+ * @date 2023/3/30 11:44
+ */
+@NoArgsConstructor
+public class CusKafkaMQ implements CusMQClient {
+ private KafkaProducer producer = null;
+ private KafkaConsumer consumer = null;
+ private Map config = null;
+ private CusMQAop cusMQAop = new DefaultCusMQAop();
+ public CusKafkaMQ(CusMQAop cusMQAop){
+ this.cusMQAop = cusMQAop;
+ }
+
+ @Override
+ public void initProducer(String configName) {
+ config = CusMQUtil.getConfigMapByName(configName);
+ producer = new KafkaProducer<>(config);
+ }
+
+ @Override
+ public void initConsumer(String configName) {
+ config = CusMQUtil.getConfigMapByName(configName);
+ consumer = new KafkaConsumer<>(config);
+ }
+
+ @Override
+ public void send(Object message) {
+ String topic = Util.null2DefaultStr(config.get("topic"),"");
+ try {
+ producer.send(new ProducerRecord<>(topic, JSONObject.toJSONString(message))).get();
+ }catch (Exception e){
+ log.error(Util.logStr("kafka producer topic: {}, message: {}, error: {}", topic, JSONObject.toJSONString(message), e.getMessage()));
+ throw new CustomerException("kafka producer send message error!");
+ }finally {
+ this.destroy();
+ }
+ }
+
+ @Override
+ public void consumer(CusMQCallBack callBack) {
+ new Thread(() -> {
+ try {
+ while (true) {
+ /*轮询获取数据*/
+ ConsumerRecords records = consumer.poll(Duration.of(100, ChronoUnit.MILLIS));
+ callBack.kafkaCallBack(records);
+ }
+ } finally {
+ consumer.close();
+ }
+ }).start();
+ }
+
+ @Override
+ public void destroy() {
+ if(producer != null){
+ producer.close();
+ }
+ if(consumer != null){
+ consumer.close();
+ }
+ }
+
+}
diff --git a/src/test/java/xuanran/wang/mq/mq/CusMQFactory.java b/src/test/java/xuanran/wang/mq/mq/CusMQFactory.java
new file mode 100644
index 0000000..e2b9352
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/mq/CusMQFactory.java
@@ -0,0 +1,45 @@
+package xuanran.wang.mq.mq;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import xuanran.wang.mq.infaces.CusMQClient;
+import xuanran.wang.mq.infaces.aop.CusMQAop;
+
+/**
+ * 工厂
+ *
+ * @author xuanran.wang
+ * @date 2023/3/30 11:38
+ */
+public class CusMQFactory {
+
+ public static final String ROCKET_MQ = "0";
+
+ public static final String KAFKA = "1";
+
+ public static final String RABBIT_MQ = "2";
+
+ public static final String ACTIVE_MQ = "3";
+
+ public static CusMQClient createCusMQ(String configName, String type) {
+ return createCusMQ(configName, type, null);
+ }
+
+ public static CusMQClient createCusMQ(String configName, String type, CusMQAop cusMQAop){
+ CusMQClient cusAbstractMQ;
+ switch (type){
+ case ROCKET_MQ: {
+ cusAbstractMQ = new CusRocketMQ();
+ break;
+ }
+ case KAFKA: {
+ cusAbstractMQ = new CusKafkaMQ();
+ break;
+ }
+ default: throw new CustomerException(Util.logStr("create CusMQClient error! type: {}, not support!", type));
+ }
+ cusAbstractMQ.initConsumer(configName);
+ cusAbstractMQ.initProducer(configName);
+ return cusAbstractMQ;
+ }
+}
diff --git a/src/test/java/xuanran/wang/mq/mq/CusRocketMQ.java b/src/test/java/xuanran/wang/mq/mq/CusRocketMQ.java
new file mode 100644
index 0000000..83f8497
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/mq/CusRocketMQ.java
@@ -0,0 +1,146 @@
+package xuanran.wang.mq.mq;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import lombok.NoArgsConstructor;
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.client.producer.SendStatus;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import weaver.xuanran.wang.shyl_mq.constant.RocketMQConstant;
+import xuanran.wang.mq.infaces.CusMQClient;
+import xuanran.wang.mq.infaces.aop.CusMQAop;
+import xuanran.wang.mq.infaces.callback.CusMQCallBack;
+import xuanran.wang.mq.util.CusMQUtil;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 自定义rocket-mq
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 13:02
+ */
+@NoArgsConstructor
+public class CusRocketMQ implements CusMQClient {
+ private DefaultMQProducer producer = null;
+
+ private DefaultMQPushConsumer consumer = null;
+
+ private Map config = null;
+ private CusMQAop cusMQAop = new DefaultCusMQAop();
+
+ public CusRocketMQ(CusMQAop cusMQAop){
+ this.cusMQAop = cusMQAop;
+ }
+
+ @Override
+ public void initProducer(String configName) {
+ Map configMap = CusMQUtil.getConfigMapByName(configName);
+ this.config = configMap;
+ producer = new DefaultMQProducer(Util.null2DefaultStr(configMap.get("producerGroup"),""));
+ // 发送消息最大超时时间 默认60000
+ int sendMsgTimeOut = Util.getIntValue(Util.null2String(configMap.get("sendMsgTimeOut")), RocketMQConstant.PRODUCER_SEND_MSG_TIME_OUT);
+ producer.setSendMsgTimeout(sendMsgTimeOut);
+ producer.setVipChannelEnabled(false);
+ producer.setNamesrvAddr(Util.null2String(configMap.get("serverAddr")));
+ try {
+ producer.start();
+ }catch (MQClientException e){
+ throw new CustomerException(Util.logStr("producer start error!:{}",e.getMessage()));
+ }
+ }
+
+ @Override
+ public void initConsumer(String configName) {
+ Map configMap = CusMQUtil.getConfigMapByName(configName);
+ this.config = configMap;
+ try {
+ int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("maxReconsumeTimes")), RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
+ // 声明一个消费者consumer,需要传入一个组 weaver-consumer
+ consumer = new DefaultMQPushConsumer(Util.null2String(configMap.get("consumerGroup")));
+ // 设置集群的NameServer地址,多个地址之间以分号分隔 183.192.65.118:9876
+ consumer.setNamesrvAddr(Util.null2String(configMap.get("serverAddr")));
+ // 设置consumer的消费策略
+ consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
+ // 集群模式消费,广播消费不会重试
+ consumer.setMessageModel(MessageModel.CLUSTERING);
+ // 设置最大重试次数,默认是16次
+ consumer.setMaxReconsumeTimes(maxReconsumeTimes);
+ // 设置consumer所订阅的Topic和Tag,*代表全部的Tag AUTH_CONSOLE_USERINFO_TOPIC
+ consumer.subscribe(Util.null2String(configMap.get("topic")),"*");
+ // 是否开启vip
+ consumer.setVipChannelEnabled(false);
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("init rocket MQ consumer error: {}!",e.getMessage()));
+ }
+ }
+
+ @Override
+ public void destroy() {
+ if(producer != null){
+ producer.shutdown();
+ }
+ if(consumer != null){
+ consumer.shutdown();
+ }
+ }
+
+ @Override
+ public void send(Object message) {
+ cusMQAop.sendBefore();
+ // 队列名
+ String topic = Util.null2DefaultStr(config.get("topic"), "");
+ Message msg;
+ try {
+ msg = new Message(topic, JSONObject.toJSONString(message).getBytes(RemotingHelper.DEFAULT_CHARSET));
+ } catch (Exception e) {
+ throw new CustomerException(Util.logStr("init message error : {} !", e.getMessage()));
+ }
+ // 发送成功标识
+ boolean sendOk = false;
+ // 发送次数
+ int count = 0;
+ do {
+ SendResult result;
+ count++;
+ try {
+ result = producer.send(msg);
+ } catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) {
+ throw new CustomerException(Util.logStr("producer send message error!: {}", e.getMessage()));
+ }
+ SendStatus sendStatus = result.getSendStatus();
+ // 如果失败
+ if (!SendStatus.SEND_OK.equals(sendStatus)) {
+ String error = Util.logStr("producer send message call back status is not ok! the message is {}, the status is {}.", msg, sendStatus);
+ // 如果重试超过最大次数
+ if(count >= RocketMQConstant.SEND_MAX_COUNT){
+ throw new CustomerException(error + " and retry > max");
+ }
+ }else {
+ sendOk = true;
+ }
+ } while (!sendOk);
+ cusMQAop.sendAfter();
+ }
+
+
+ @Override
+ public void consumer(CusMQCallBack callBack) {
+ consumer.registerMessageListener(callBack::rocketCallBack);
+ try {
+ consumer.start();
+ }catch (Exception e){
+ throw new CustomerException("consumer start error : " + e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/xuanran/wang/mq/mq/DefaultCusMQAop.java b/src/test/java/xuanran/wang/mq/mq/DefaultCusMQAop.java
new file mode 100644
index 0000000..483264a
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/mq/DefaultCusMQAop.java
@@ -0,0 +1,41 @@
+package xuanran.wang.mq.mq;
+
+import xuanran.wang.mq.infaces.aop.CusMQAop;
+
+/**
+ * 默认的aop
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 12:56
+ */
+public class DefaultCusMQAop implements CusMQAop {
+ @Override
+ public void sendBefore() {
+
+ }
+
+ @Override
+ public void sendAfter() {
+
+ }
+
+ @Override
+ public void consumerBefore() {
+
+ }
+
+ @Override
+ public void consumerAfter() {
+
+ }
+
+ @Override
+ public void destroyBefore() {
+
+ }
+
+ @Override
+ public void destroyAfter() {
+
+ }
+}
diff --git a/src/test/java/xuanran/wang/mq/test/MQTest.java b/src/test/java/xuanran/wang/mq/test/MQTest.java
new file mode 100644
index 0000000..a9a99df
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/test/MQTest.java
@@ -0,0 +1,58 @@
+package xuanran.wang.mq.test;
+
+import basetest.BaseTest;
+import org.junit.Test;
+import weaver.general.Util;
+import xuanran.wang.mq.infaces.CusMQClient;
+import xuanran.wang.mq.infaces.aop.CusMQAop;
+import xuanran.wang.mq.mq.CusMQFactory;
+
+/**
+ *
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 12:34
+ */
+public class MQTest extends BaseTest {
+
+ @Test
+ public void testKafka(){
+ CusMQAop cusMQAop = new CusMQAop() {
+ @Override
+ public void sendBefore() {
+ System.out.println("发送前!");
+ }
+
+ @Override
+ public void sendAfter() {
+ System.out.println("发送后!");
+ }
+
+ @Override
+ public void consumerBefore() {
+ System.out.println("消费前!");
+ }
+
+ @Override
+ public void consumerAfter() {
+ System.out.println("消费后!");
+ }
+
+ @Override
+ public void destroyBefore() {
+ System.out.println("销毁前!");
+ }
+
+ @Override
+ public void destroyAfter() {
+ System.out.println("销毁前!");
+ }
+ };
+
+ CusMQClient cusMQ = CusMQFactory.createCusMQ("OACarTest", CusMQFactory.ROCKET_MQ);
+
+ cusMQ.send("11212121212");
+
+ }
+
+}
diff --git a/src/test/java/xuanran/wang/mq/util/CusMQUtil.java b/src/test/java/xuanran/wang/mq/util/CusMQUtil.java
new file mode 100644
index 0000000..29d318b
--- /dev/null
+++ b/src/test/java/xuanran/wang/mq/util/CusMQUtil.java
@@ -0,0 +1,53 @@
+package xuanran.wang.mq.util;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * mq工具类
+ *
+ * @author xuanran.wang
+ * @date 2023/3/31 11:52
+ */
+public class CusMQUtil {
+ private static final Logger log = Util.getLogger();
+ private static final String[] checkField = new String[]{"serverAddr", "topic"};
+ /**
+ * 配置文件本地存储对象
+ **/
+ public static Map> CONFIG_MAPS = new HashMap<>(16);
+
+ /**
+ * 通过配置文件名称获取配置map
+ * @author xuanran.wang
+ * @dateTime 2023/1/4 13:18
+ * @param configName 配置文件名称
+ * @return 配置文件map
+ **/
+ public synchronized static Map getConfigMapByName(String configName){
+ Map configMap = new HashMap<>();
+ if(!CONFIG_MAPS.containsKey(configName)){
+ configMap = Util.getProperties2Map(configName);
+ checkConfig(configMap);
+ CONFIG_MAPS.put(configName, configMap);
+ }else {
+ configMap = CONFIG_MAPS.get(configName);
+ }
+ return configMap;
+ }
+
+ public static void checkConfig(Map configMap){
+ for (String field : checkField) {
+ if(!configMap.containsKey(field) && StringUtils.isBlank(Util.null2DefaultStr(configMap.get(field),""))){
+ log.error("MQ config : " + JSONObject.toJSONString(configMap));
+ throw new CustomerException("MQ config map not contains " + field + " or " + field + " is empty!");
+ }
+ }
+ }
+}
diff --git a/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java b/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java
index 563e1dc..057a32b 100644
--- a/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java
+++ b/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java
@@ -174,25 +174,9 @@ public class AsyncTest extends BaseTest {
consumer.registerMessageListener(new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List list, ConsumeConcurrentlyContext consumeConcurrentlyContext) {
- MessageExt messageExt = list.get(0);
- String msgBody;
- MQMessage mqMessage;
- try {
- msgBody = new String(messageExt.getBody(), StandardCharsets.UTF_8);
- if (StringUtils.isBlank(msgBody)) {
- throw new CustomerException("MQ msgBody is empty!");
- }
- mqMessage = JSONObject.parseObject(msgBody, MQMessage.class);
- // 业务主体
- String content = Util.null2DefaultStr(mqMessage.getContent(), "");
- if (StringUtils.isBlank(content)) {
- throw new CustomerException(Util.logStr("the messageId : {}, content is empty!", Util.null2DefaultStr(mqMessage.getId(), "")));
- }
- log.info(Util.logStr("MQMessage : {} ", mqMessage));
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- } catch (Exception e) {
- throw new CustomerException("consumeMessage => " + e.getMessage());
- }
+ System.out.println("msgs : " + JSONObject.toJSONString(list));
+ System.out.println("context : " + JSONObject.toJSONString(consumeConcurrentlyContext));
+ return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
});
consumer.start();
diff --git a/src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java b/src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java
index 98a6fa5..1c548b6 100644
--- a/src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java
+++ b/src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java
@@ -6,14 +6,16 @@ import com.api.meeting.util.FieldUtil;
import com.api.xuanran.wang.shyl.entity.meeting.MeetingCusFieldConfigMain;
import com.api.xuanran.wang.shyl.service.MeetingService;
import org.junit.Test;
+import weaver.file.ImageFileManager;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.systeminfo.SystemEnv;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
/**
*
@@ -42,8 +44,32 @@ public class MapperTest extends BaseTest {
}
@Test
- public void testC(){
- String s = TimeUtil.dateAdd("2023-03-02", -3);
- log.info("time => " + s);
+ public void testC() throws IOException {
+ InputStream inputStream = new FileInputStream("/Users/wangxuanran/Downloads/chrome/1589665325711042c4c7c0e4ff4c6868.png");
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ }
+ byte[] bytes = outputStream.toByteArray();
+ String str = Base64.getEncoder().encodeToString(bytes);
+ System.out.println("str => " + str);
+
+ }
+
+ @Test
+ public void testD(){
+ String cusSql = "select a.docsubject fileName, concat('http://10.184.45.196/zjdownload?filed=', a.id)\n" +
+ " fullPath, RIGHT(c.imagefilename, INSTR(REVERSE(c.imagefilename),'.')) downloadType\n" +
+ "from docdetail a\n" +
+ "left join docimagefile b\n" +
+ "on a.id = b.docid\n" +
+ "left join docimagefile c\n" +
+ "on b.imagefileid = c.imagefileid\n" +
+ "where a.id in ${docIds}";
+ String docIds = "1,2,3";
+ cusSql = cusSql.replace("${docIds}", "( " + docIds + " )");
+ System.out.println("cus => " + cusSql);
}
}