2023-03-15 团校mq代码

main
王宣然 2023-03-15 13:50:48 +08:00
parent 8b16f9ca57
commit af939631b4
101 changed files with 3914 additions and 417 deletions

View File

@ -47,6 +47,8 @@ jQuery().ready(function(){
}
}
addRowBack(2, configObj);
changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, computeDatePayType)
// 主表字段发生变化

View File

@ -42,6 +42,8 @@ function getDate(time) {
return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
}
/**
* 校验比例是否等于100
* @param detailTable 明细表
@ -153,6 +155,18 @@ function changeDetailPayDate(obj){
}
}
/**
* 字段联动后添加明细行后执行的逻辑
* @param detail
* @param configObj
*/
function addRowBack(detail, configObj){
WfForm.registerAction(WfForm.ACTION_ADDROW + detail, function(index){
configObj.index = index;
changeDetailPayDate(configObj);
});
}
/**
* 改变明细表字段只读
* @param detailTable
@ -173,3 +187,5 @@ function changeDetailFieldReadOnly(detailTable, detailComDateField, detailPaymen
}
}
}

View File

@ -0,0 +1,31 @@
// 存货分类编码
const chflbmId = WfForm.convertFieldNameToId("chflbm");
// 流程类型
const workflowType = WfForm.convertFieldNameToId("lcxz");
// 唯一编码
const unqieCode = WfForm.convertFieldNameToId("wybm");
// 帐套查询
const zt = WfForm.convertFieldNameToId("ztcx");
// 存货编码
const chbm = WfForm.convertFieldNameToId("chbm2");
changeVal();
WfForm.bindFieldChangeEvent(chflbmId, function(obj,id,value){
changeVal();
});
function changeVal(){
let value = WfForm.getFieldValue(chflbmId)
console.log('value: ', value);
if(!value){
return;
}
let firstVal = value.charAt(0);
if(firstVal == 0){
value = value.substring(1, value.length);
console.log('修改后的val ', value);
setTimeout(()=>{
$(`#${chflbmId}span`)[0].innerHTML = value;
},5);
}
}

View File

@ -0,0 +1,32 @@
// 主表预计付款日期
const yjfksj = WfForm.convertFieldNameToId('yjfksj');
// 主表比例
const bl = WfForm.convertFieldNameToId('bcfkbl');
// 明细要求付款日期
const detail3Yqfkrq = WfForm.convertFieldNameToId('yqfkrq',"detail_3");
// 明细本次付款比例
const detailBl = WfForm.convertFieldNameToId('bcfkbl',"detail_3");
WfForm.registerCheckEvent(WfForm.OPER_ADDROW + "3", function (callback) {
callback();
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);
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});
}
}
}

View File

@ -0,0 +1,217 @@
var m_xmmc = WfForm.convertFieldNameToId("xmmc");//项目名称
var m_bmwyz = WfForm.convertFieldNameToId("glkcjlb");//关联勘察
var m_bmwyz1 = WfForm.convertFieldNameToId("glxsxqd");//关联销售
var m_bmwyz2 = WfForm.convertFieldNameToId("chdadx");//唯一值多选
var dt2_tyrq = WfForm.convertFieldNameToId("tyrq", "detail_2");//明细2停用日期
jQuery(document).ready(function () {
setTimeout("bindFieldChange()", "500");
});
function bindFieldChange() {
WfForm.bindFieldChangeEvent(m_xmmc, function (obj, id, value) {
WfForm.changeFieldValue(m_bmwyz, {value: ''});
WfForm.changeFieldValue(m_bmwyz1, {value: ''});
WfForm.changeFieldValue(m_bmwyz2, {value: ''});
});
//提交检验
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, function (callback) {
var flag = true;
var rowArr = WfForm.getDetailAllRowIndexStr("detail_2").split(",");
for (var i = 0; i < rowArr.length; i++) {
var rowid = rowArr[i];
var dt2_tyrq_v = WfForm.getFieldValue(dt2_tyrq + "_" + rowid);
if (dt2_tyrq_v != "") {
WfForm.showMessage("明细2第" + (i + 1) + "行设备已在" + dt2_tyrq_v + "停用!", 2, 5);
flag = flase;
break;
}
}
if (flag) {
callback(); //继续提交需调用callback不调用代表阻断
}
});
}
var rowArr = WfForm.getDetailAllRowIndexStr("detail_3").split(",");
// WfForm.delDetailRow("detail_2", "all");
for (var i = 0; i < rowArr.length; i++) {
var rowIndex = rowArr[i];
if (rowIndex !== "") {
var fieldMark = "field12566" + rowIndex;
if (fieldMark === "0") {
var count = WfForm.getFieldValue("field12562" + rowIndex);
var field7108_ = WfForm.getFieldValue("field6117_" + rowIndex);
WfForm.addDetailRow("detail_2", {field8567: {value: count}, field7583: {value: field7108_},});
}
}
}
/*
dev-1 王宣然 限制明细表选择的bom不能重复
*/
const detailBomField = WfForm.convertFieldNameToId('bombm', 'detail_1');
/**
* 主表辅助字段
*/
const mainAttrField = WfForm.convertFieldNameToId('ycbmpzx');
/**
* 明细1数量
*/
const detail1NumFieldId = WfForm.convertFieldNameToId('sl1', "detail_1");
/**
* 明细3 明细2数量
*/
const detail3NumFieldId = WfForm.convertFieldNameToId('mx2sl', "detail_3");
/**
* 明细3数量
*/
const detail3NumFieldId2 = WfForm.convertFieldNameToId('sl1', "detail_3");
/**
* 明细3需求数量
*/
const detail3NumFieldId3 = WfForm.convertFieldNameToId('sl', "detail_3");
/**
* 明细3bom编码
*/
const detail3BomFieldId = WfForm.convertFieldNameToId('bombm', "detail_3");
/**
* 明细1bom编码
*/
const detail1BomFieldId = WfForm.convertFieldNameToId('bombm', "detail_1");
/*
*已经选择的bom
*/
let choiceArr = new Set();
let updateNum = {};
const yjdhrq = WfForm.convertFieldNameToId('yjdhrq');
console.log('id ', yjdhrq)
// 明细到货日期
const detail1yjdhsj = WfForm.convertFieldNameToId('yjdhsj', "detail_2");
WfForm.bindFieldChangeEvent(yjdhrq, function (obj, id, value) {
initDeatail2Date(value);
});
WfForm.registerCheckEvent(WfForm.OPER_ADDROW + "2", function (callback) {
callback();
let value = WfForm.getFieldValue(yjdhrq);
initDeatail2Date(value);
});
WfForm.bindDetailFieldChangeEvent(detailBomField, function (id, rowIndex, value) {
if (!value) {
return;
}
if (choiceArr.has(value)) {
WfForm.showMessage('不能选择重复的bom请重新选择!');
setTimeout(() => {
WfForm.changeFieldValue(`${detailBomField}_${rowIndex}`, {value: '', specialobj: []});
}, 5);
}
initChoiceArr();
getBomArr();
});
// 数量变化自动计算
WfForm.bindDetailFieldChangeEvent(`${detail1NumFieldId},${detailBomField}`, function (id, rowIndex, value) {
let detail1RowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
console.log(detail1RowArr);
for (let i = 0; i < detail1RowArr.length; i++) {
let rowIndex = detail1RowArr[i];
if (rowIndex !== "") {
let num = WfForm.getFieldValue(`${detail1NumFieldId}_${rowIndex}`);
// bom编码
let bom = WfForm.getFieldValue(`${detail1BomFieldId}_${rowIndex}`);
setTimeout(() => {
computeNum(bom, num);
}, 500);
}
}
});
function initDeatail2Date(value) {
let detail2RowArr = WfForm.getDetailAllRowIndexStr('detail_2').split(",");
for (let i = 0; i < detail2RowArr.length; i++) {
let rowIndex = detail2RowArr[i];
if (rowIndex !== "") {
WfForm.changeFieldValue(`${detail1yjdhsj}_${rowIndex}`, {value: value});
}
}
}
/**
* 计算明细3数量
*/
function computeNum(detail1Bom, detail1Num) {
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
console.log(detail3RowArr);
for (let i = 0; i < detail3RowArr.length; i++) {
let rowIndex = detail3RowArr[i];
if (rowIndex !== "") {
// bom编码
let bom = WfForm.getFieldValue(`${detail3BomFieldId}_${rowIndex}`);
if (bom != detail1Bom) {
continue;
}
console.log('需要改变的index ', rowIndex)
WfForm.changeFieldValue(`${detail3NumFieldId}_${rowIndex}`, {value: detail1Num});
}
}
}
/**
* 初始化已经选择的数组
*/
function initChoiceArr() {
choiceArr = new Set();
let rowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
for (let i = 0; i < rowArr.length; i++) {
let rowIndex = rowArr[i];
if (rowIndex !== "") {
let bom = WfForm.getFieldValue(`${detailBomField}_${rowIndex}`);
// console.log('bom ', bom);
if (!bom) {
continue;
}
choiceArr.add(bom);
}
}
console.log('choiceArr ', choiceArr)
}
WfForm.registerCheckEvent(WfForm.OPER_DELROW + "1", function (callback) {
callback();
getBomArr();
initChoiceArr();
});
function getBomArr() {
let arr = [];
let rowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
for (let i = 0; i < rowArr.length; i++) {
let rowIndex = rowArr[i];
if (rowIndex !== "") {
arr.push(WfForm.getFieldValue(`${detailBomField}_${rowIndex}`));
}
}
let bom = new Set(arr);
let arr2 = [...bom];
let obj = {};
obj.value = arr2.join(',');
let specialobjArr = [];
for (let i = 0; i < arr2.length; i++) {
let obj = {};
obj.id = arr2[i];
obj.name = arr2[i];
specialobjArr.push(obj);
}
obj.specialobj = specialobjArr;
let val = WfForm.changeFieldValue(mainAttrField, obj);
if (!val) {
WfForm.delDetailRow("detail_3", "all");
}
console.log('主表辅助字段值 : ', WfForm.getFieldValue(mainAttrField));
}

View File

@ -51,6 +51,9 @@ function init(){
'computeDatePayType': computeDatePayType,
'paymentTypeGetValue': paymentTypeGetValue
}
addRowBack(3, obj);
changeDetailFieldReadOnly(detailTable, detailComPayDateId, detailPaymentTypeId, computeDatePayType)
// 主表字段发生变化
mainFieldChangeDetailCom(`${mainProjectId},${contractSignDateId}`, detailTable, obj);

View File

@ -52,6 +52,7 @@ function init(){
'computeDatePayType': computeDatePayType,
'paymentTypeGetValue': paymentTypeGetValue
}
addRowBack(2, obj);
changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, computeDatePayType)
// 主表字段发生变化
mainFieldChangeDetailCom(mainProjectId, detailTable, obj);

View File

@ -0,0 +1,91 @@
package com.api.xuanran.wang.shyl.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
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;
import com.engine.workflow.util.CommonUtil;
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;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* <h1>-</h1>
*
* @author xuanran.wang
* @date 2023/2/22 13:51
*/
@Path("/wxr/shyl/workflow")
public class BatchCreateWorkFlowController {
private final Logger log = Util.getLogger();
/**
* <h2></h2>
**/
public static WorkflowRequestOperatePA WRO = null;
static {
WRO = getRequestOperatePA();
}
private final BatchCreateWorkflowService service = new BatchCreateWorkflowService();
@Path("/batchCreate")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String batchCreate(@Context HttpServletRequest request,
@Context HttpServletResponse response,
@RequestBody JSONObject obj) {
User user = CommonUtil.getUserByRequest(request, response);
if(null == user){
return ApiResult.error(500,"请先登陆!");
}
try {
log.info("批量预约&取消接口接收参数: \n" + obj.toString());
if(obj.isEmpty()){
throw new CustomerException("请求体对象不能为空!");
}
String cancelIds = Util.null2DefaultStr(obj.get("cancelIds"),"");
if(StringUtils.isNotBlank(cancelIds)){
service.cancelMeeting(cancelIds);
}
JSONArray workflows = obj.getJSONArray("workflows");
return ApiResult.success(service.batchCreateWorkflow(user, workflows));
}catch (Exception e){
log.error(Util.logStr("batchCreate error : {}", e.getMessage()));
return ApiResult.error(500,"批量创建流程接口发生异常! 异常信息 :[ " + e.getMessage() + " ]");
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/2/22 16:53
* @return
**/
private static WorkflowRequestOperatePA getRequestOperatePA() {
return (WorkflowRequestOperatePAImpl) ServiceUtil.getService(WorkflowRequestOperatePAImpl.class);
}
}

View File

@ -0,0 +1,37 @@
package com.api.xuanran.wang.shyl.controller;
import aiyh.utils.ApiResult;
import com.api.xuanran.wang.shyl.service.CarService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* <h1>mq</h1>
*
* @author xuanran.wang
* @date 2023/2/27 13:25
*/
@Path("/wxr/shyl/car")
public class CarToMQController {
private final CarService carService = new CarService();
@Path("/toMq")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String batchCreate(@Context HttpServletRequest request,
@Context HttpServletResponse response) {
try {
carService.sendCarToMQ(request);
return ApiResult.success(null);
}catch (Exception e){
return ApiResult.error("车辆信息发送MQ异常 : " + e.getMessage());
}
}
}

View File

@ -0,0 +1,48 @@
package com.api.xuanran.wang.shyl.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.xuanran.wang.shyl.service.StudentsService;
import com.engine.workflow.util.CommonUtil;
import org.apache.log4j.Logger;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/1 10:56
*/
@Path("/wxr/students")
public class GetStudentsClass {
private final Logger log = Util.getLogger();
private final StudentsService studentsService = new StudentsService();
@Path("/getStudentsByClassId")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getStudentsByClassId(@Context HttpServletRequest request,
@Context HttpServletResponse response){
User user = CommonUtil.getUserByRequest(request, response);
if(null == user){
return ApiResult.error(500,"请先登陆!");
}
String id = Util.null2DefaultStr(request.getParameter("id"),"");
log.info(Util.logStr("class id : {}", id));
try {
return ApiResult.success(studentsService.getStudentsByClassId(id));
}catch (Exception e){
log.error(Util.logStr("getStudentsByClassId error ! {}", e.getMessage()));
return ApiResult.error(500,"获取学员信息接口发生异常! 异常信息 :[ " + e.getMessage() + " ]");
}
}
}

View File

@ -0,0 +1,63 @@
package com.api.xuanran.wang.shyl.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.xuanran.wang.shyl.service.MeetingService;
import com.engine.workflow.util.CommonUtil;
import org.apache.log4j.Logger;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/23 18:56
*/
@Path("/wxr/meeting")
public class MeetingController {
private final Logger log = Util.getLogger();
private final MeetingService meetingService = new MeetingService();
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/3/1 15:24
**/
@Path("/cancel")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String meetingCancel(@Context HttpServletRequest request,
@Context HttpServletResponse response){
User user = CommonUtil.getUserByRequest(request, response);
if(null == user){
return ApiResult.error(500,"请先登陆!");
}
String id = Util.null2DefaultStr(request.getParameter("id"),"");
log.info(Util.logStr("cancel interface id : {}", id));
try {
meetingService.cancelMeeting(id);
return ApiResult.success(null);
}catch (Exception e){
log.error(Util.logStr("MeetingController error ! {}", e.getMessage()));
return ApiResult.error(500,"会议取消接口发生异常! 异常信息 :[ " + e.getMessage() + " ]");
}
}
@Path("/cusFormConfig")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getMeetingFormConfig(@Context HttpServletRequest request,
@Context HttpServletResponse response){
User user = CommonUtil.getUserByRequest(request, response);
if(null == user){
return ApiResult.error(500,"请先登陆!");
}
return ApiResult.success(meetingService.getMeetingFieldCusConfig());
}
}

View File

@ -0,0 +1,17 @@
package com.api.xuanran.wang.shyl.entity;
import com.engine.workflow.entity.publicApi.PAResponseEntity;
import lombok.Data;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/24 12:02
*/
@Data
public class CusCreateWfInfo {
private PAResponseEntity paResponseEntity;
private int index;
private int workflowId;
private String customId;
}

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.shyl.mq.entity;
package com.api.xuanran.wang.shyl.entity;
import lombok.Data;
@ -40,5 +40,5 @@ public class MQMessage {
/**
* <h2>,json ,()</h2>
**/
private String content;
private Object content;
}

View File

@ -0,0 +1,111 @@
package com.api.xuanran.wang.shyl.entity;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import com.weaverboot.frame.dao.anno.WeaSqlFrom;
import lombok.Data;
import weaver.xuanran.wang.common.annocation.Map2JSONConvert;
import java.lang.annotation.Annotation;
/**
* <h1>mq</h1>
*
* @author xuanran.wang
* @date 2023/2/25 15:04
*/
public class ProducerCarInfo {
@SqlDbFieldAnn("ID")
private String carCode;
@SqlOracleDbFieldAnn("DEPOSIT")
private String status;
@SqlOracleDbFieldAnn("DRIVER")
private String driver;
@SqlOracleDbFieldAnn("USERNAME")
private String userName;
@SqlOracleDbFieldAnn("USERPHONE")
private String userPhone;
@SqlOracleDbFieldAnn("CARNO")
private String plateList;
@SqlOracleDbFieldAnn("REMARK")
private String remark;
private String identification;
public String getCarCode() {
return carCode;
}
public void setCarCode(String carCode) {
this.carCode = carCode;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDriver() {
return driver;
}
public void setDriver(String driver) {
this.driver = driver;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
public String getPlateList() {
return plateList;
}
public void setPlateList(String plateList) {
this.plateList = plateList;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getIdentification() {
return identification;
}
public void setIdentification(String identification) {
this.identification = identification;
}
@Override
public String toString() {
return "ProducerCarInfo{" +
"carCode='" + carCode + '\'' +
", status='" + status + '\'' +
", driver='" + driver + '\'' +
", userName='" + userName + '\'' +
", userPhone='" + userPhone + '\'' +
", plateList='" + plateList + '\'' +
", remark='" + remark + '\'' +
", identification='" + identification + '\'' +
'}';
}
}

View File

@ -0,0 +1,18 @@
package com.api.xuanran.wang.shyl.entity.meeting;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import lombok.Data;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/1 15:43
*/
@Data
public class MeetingCusFieldConfigDetail {
@SqlOracleDbFieldAnn("SELECTKEY")
private String selectKey;
@SqlOracleDbFieldAnn("SELECTSHOWNAME")
private String selectShowName;
}

View File

@ -0,0 +1,23 @@
package com.api.xuanran.wang.shyl.entity.meeting;
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
import lombok.Data;
import java.util.List;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/1 15:41
*/
@Data
public class MeetingCusFieldConfigMain {
@SqlOracleDbFieldAnn("FIELDNAME")
private String fieldName;
@SqlOracleDbFieldAnn("FIELDTYPE")
private int fieldType;
@SqlOracleDbFieldAnn("FIELDONLYMARK")
private String fieldOnlyMark;
private List<MeetingCusFieldConfigDetail> options;
}

View File

@ -0,0 +1,61 @@
package com.api.xuanran.wang.shyl.mapper;
import aiyh.utils.annotation.recordset.*;
import com.api.xuanran.wang.shyl.entity.meeting.MeetingCusFieldConfigDetail;
import com.api.xuanran.wang.shyl.entity.meeting.MeetingCusFieldConfigMain;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/24 19:09
*/
@SqlMapper
public interface MeetingMapper {
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/3/1 16:39
* @return
**/
@Select("select * from uf_meetFieldConfig where enable = 0")
@CollectionMappings({
@CollectionMapping(property = "options",
column = "id",
id = @Id(value = Integer.class, methodId = 1))
})
List<MeetingCusFieldConfigMain> queryMeetingCusConfigMain();
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/3/1 16:39
* @param mainId id
* @return
**/
@Select("select * from uf_meetFieldConfig_dt1 where mainid = #{mainId}")
@CollectionMethod(1)
List<MeetingCusFieldConfigDetail> queryMeetingCusConfigDetail(@ParamMapper("mainId") int mainId);
/**
* <h2></h2>
* @param sql sql
* @param conditionData
* @return
*/
@Update(custom = true)
boolean updateMeetingRoom(@SqlString String sql, HashMap<String, Object> conditionData);
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/3/1 16:44
* @param id id
**/
@Select("select * from meetingroom where id = #{id}")
Map<String, String> queryMeetingRoom(@ParamMapper("id") String id);
}

View File

@ -0,0 +1,33 @@
package com.api.xuanran.wang.shyl.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import com.api.xuanran.wang.shyl.entity.ProducerCarInfo;
import java.util.HashMap;
/**
* <h1>mapper</h1>
*
* @author xuanran.wang
* @date 2023/2/25 15:50
*/
@SqlMapper
public interface ProducerMapper {
@Select("select a.id carCode, Deposit status,b.outkey driver, b.lastname userName, " +
"b.telephone userPhone, carNo plateList, remark " +
"from carinfo a " +
"left join hrmresource b " +
"on a.driver = b.id " +
"where a.id = #{id}")
ProducerCarInfo queryCarInfo(@ParamMapper("id") String id);
@Select("select a.id carCode, Deposit status,b.outkey driver, b.lastname userName, " +
"b.telephone userPhone, carNo plateList, remark " +
"from carinfo a " +
"left join hrmresource b " +
"on a.driver = b.id " +
"where a.carNo = #{carNo}")
ProducerCarInfo queryCarNo(@ParamMapper("carNo") String carNo);
}

View File

@ -0,0 +1,195 @@
package com.api.xuanran.wang.shyl.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.shyl.controller.BatchCreateWorkFlowController;
import com.api.xuanran.wang.shyl.entity.CusCreateWfInfo;
import com.api.xuanran.wang.shyl.vo.CreateWfVO;
import com.engine.workflow.constant.PAResponseCode;
import com.engine.workflow.entity.publicApi.PAResponseEntity;
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.hrm.User;
import weaver.workflow.webservices.WorkflowRequestTableField;
import weaver.xuanran.wang.common.util.CommonUtil;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/22 13:58
*/
public class BatchCreateWorkflowService {
// 表名 : requestId 本次需要删除的数据
private final ConcurrentHashMap<String, List<String>> delWorkflowTableRequestId = new ConcurrentHashMap<>();
// workflowId : tableName
private static final HashMap<Integer, String> workflowTable = new HashMap<>();
private final Logger log = Util.getLogger();
private static final String CUSTOM_ID = "customId";
// private final MeetingMapper meetingTransMapper = Util.getTransMapper(MeetingMapper.class);
private final MeetingService meetingService = new MeetingService();
/**
* <h1> </h1>
* @author xuanran.wang
* @dateTime 2023/2/24 10:21
* @param ids id
**/
public void cancelMeeting(String ids){
meetingService.cancelMeeting(ids);
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/2/22 17:10
* @param array
* @return
**/
public List<CreateWfVO> batchCreateWorkflow(User user, JSONArray array) {
List<Future<CusCreateWfInfo>> list = new ArrayList<>();
List<CusCreateWfInfo> errors = new ArrayList<>();
ArrayList<CreateWfVO> res = new ArrayList<>();
try {
List<ReqOperateRequestEntity> reqOperateRequestEntities = checkParams(array);
// 结果集
for (int i = 0; i < reqOperateRequestEntities.size(); i++) {
int temp = i;
// 创建流程
Callable<CusCreateWfInfo> callable = () -> this.createWorkflow(user,reqOperateRequestEntities.get(temp), temp);
list.add(Util.threadPool.submit(callable));
}
for (Future<CusCreateWfInfo> future : list) {
CusCreateWfInfo cusCreateWfInfo = future.get();
PAResponseEntity entity = cusCreateWfInfo.getPaResponseEntity();
String tableName = workflowTable.get(cusCreateWfInfo.getWorkflowId());
if(PAResponseCode.SUCCESS != entity.getCode()){
errors.add(cusCreateWfInfo);
continue;
}
// 将生成的requestId存到vo中返回
Map<String, Object> data = (Map<String, Object>) entity.getData();
String requestId = Util.null2DefaultStr(data.get("requestid"),"");
CreateWfVO vo = new CreateWfVO();
vo.setRequestId(requestId);
vo.setCustomId(cusCreateWfInfo.getCustomId());
res.add(vo);
// 将表名 requestId 存到成员变量中
if (!delWorkflowTableRequestId.containsKey(tableName)) {
ArrayList<String> requestIds = new ArrayList<>();
requestIds.add(requestId);
delWorkflowTableRequestId.put(tableName, requestIds);
}else {
delWorkflowTableRequestId.get(tableName).add(requestId);
}
}
if(errors.size() > 0){
throw new CustomerException("创建流程失败!错误参数流程 : \n" + JSONObject.toJSONString(errors));
}
return res;
}catch (Exception e){
if(MapUtils.isNotEmpty(delWorkflowTableRequestId)){
log.info("删除流程数据map : " + JSONObject.toJSONString(delWorkflowTableRequestId));
for (Map.Entry<String, List<String>> entry : delWorkflowTableRequestId.entrySet()) {
String tableName = entry.getKey();
List<String> requestIds = entry.getValue();
if (!CommonUtil.deleteWorkflowDataByRequestIds(tableName, requestIds)) {
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", tableName,JSONObject.toJSONString(requestIds)));
}
if (!CommonUtil.deleteWorkflowDataByRequestIds("workflow_requestbase", requestIds)) {
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "workflow_requestbase", JSONObject.toJSONString(requestIds)));
}
if (!CommonUtil.deleteWorkflowDataByRequestIds("Bill_Meeting", requestIds)) {
log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "Bill_Meeting", JSONObject.toJSONString(requestIds)));
}
}
}
throw new CustomerException(e.getMessage());
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/2/24 14:33
* @param user
* @param requestEntity
* @param index
* @return
**/
public CusCreateWfInfo createWorkflow(User user,
ReqOperateRequestEntity requestEntity,
int index){
// 创建流程
PAResponseEntity responseEntity = BatchCreateWorkFlowController.WRO.doCreateRequest(user, requestEntity);
CusCreateWfInfo cusCreateWfInfo = new CusCreateWfInfo();
cusCreateWfInfo.setIndex(index);
cusCreateWfInfo.setPaResponseEntity(responseEntity);
int workflowId = requestEntity.getWorkflowId();
String tableName = workflowTable.get(workflowId);
if(StringUtils.isBlank(tableName)){
tableName = CommonUtil.getTableNameByWorkflowId(workflowId);
workflowTable.put(workflowId, tableName);
}
// 获取主表的customId
List<WorkflowRequestTableField> collect = requestEntity.getMainData()
.stream()
.filter(item -> CUSTOM_ID.equals(item.getFieldName()))
.collect(Collectors.toList());
String customIdVal = collect.get(0).getFieldValue();
cusCreateWfInfo.setCustomId(customIdVal);
cusCreateWfInfo.setWorkflowId(workflowId);
return cusCreateWfInfo;
}
/**
* <h1>jsonReqOperateRequestEntity</h1>
* @author xuanran.wang
* @dateTime 2023/2/24 13:36
* @param array json
* @return
**/
public List<ReqOperateRequestEntity> checkParams(JSONArray array){
ArrayList<ReqOperateRequestEntity> res = new ArrayList<>();
try {
for (Object obj : array) {
ReqOperateRequestEntity entity;
JSONObject jsonObject;
// 将json转成内部流程对象
try {
jsonObject = JSONObject.parseObject(obj.toString());
entity = JSONObject.parseObject(jsonObject.toString(), ReqOperateRequestEntity.class);
}catch (Exception e){
throw new CustomerException(Util.logStr("json反序列化失败!当前对象:{}, 错误信息: {}" ,obj,e.getMessage()));
}
if(Util.getIntValue(String.valueOf(entity.getWorkflowId()),-1) < 0){
throw new CustomerException(Util.logStr("该对象workflowId为空!", obj));
}
List<WorkflowRequestTableField> collect = entity.getMainData()
.stream()
.filter(item -> CUSTOM_ID.equals(item.getFieldName()))
.collect(Collectors.toList());
if(collect.size() == 0){
throw new CustomerException(Util.logStr("该对象mainData中未找到customId!:{}", obj));
}
res.add(entity);
}
}catch (Exception e){
throw new CustomerException(Util.logStr("JSON参数校验失败!请检查json是否正确!错误信息: {}",e.getMessage()));
}
return res;
}
}

View File

@ -0,0 +1,111 @@
package com.api.xuanran.wang.shyl.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.shyl.entity.MQMessage;
import com.api.xuanran.wang.shyl.entity.ProducerCarInfo;
import com.api.xuanran.wang.shyl.mapper.ProducerMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.general.TimeUtil;
import weaver.xuanran.wang.shyl_mq.constant.RocketMQConstant;
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
import weaver.zwl.common.ToolUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
import java.util.UUID;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/27 13:28
*/
public class CarService {
private final Logger log = Util.getLogger();
private final ToolUtil toolUtil = new ToolUtil();
private final ProducerMapper producerMapper = Util.getMapper(ProducerMapper.class);
/**
* <h1>mq</h1>
* @author xuanran.wang
* @dateTime 2023/2/27 13:29
* @param request
**/
public void sendCarToMQ(HttpServletRequest request){
try {
// 操作类型 edit 编辑 add 新增 deposit 封存
String operation = Util.null2String(request.getParameter("operation"));
// 车辆id
String id = Util.null2String(request.getParameter("id"));
log.info(Util.logStr("operation : {}. id : {}", operation, id));
String actionType = "";
// 标识 新增 0 修改 1 删除 2
String identification = "";
switch (operation){
case "add":{
identification = "0";
actionType = RocketMQConstant.CREATE_ACTION;
}break;
case "deposit":
case "edit":{
identification = "1";
actionType = RocketMQConstant.UPDATE_ACTION;
}break;
case "del":{
identification = "2";
actionType = RocketMQConstant.DELETE_ACTION;
}
break;
}
if(StringUtils.isBlank(operation)){
identification = "2";
actionType = RocketMQConstant.DELETE_ACTION;
}
String sendMQ = Util.null2DefaultStr(toolUtil.getSystemParamValue("sendMQ"),"");
log.info(Util.logStr("carId : {}, sendMQ : {}",id, sendMQ));
String msg = "";
MQMessage mqMessage = new MQMessage();
mqMessage.setId(UUID.randomUUID().toString());
mqMessage.setTopic("OA_CAR_TOPIC");
mqMessage.setSendTime(TimeUtil.getCurrentTimeString());
mqMessage.setActionType(actionType);
ProducerCarInfo info = null;
String carNo = "";
if(StringUtils.isNotBlank(id)){
info = producerMapper.queryCarInfo(id);
}else {
// 车牌号
carNo = Util.null2DefaultStr(request.getParameter("carNo"),"");
info = producerMapper.queryCarNo(carNo);
}
// 如果能找到就说明是更新或者新增
if("del".equals(operation)){ //删除状态下
info = new ProducerCarInfo();
info.setCarCode(id);
info.setStatus("1");
info.setRemark("");
info.setDriver("");
info.setPlateList("");
info.setUserName("");
info.setUserPhone("");
log.info("删除状态下!");
}
log.info("ProducerCarInfo : " + JSONObject.toJSONString(info));
if(!Objects.isNull(info)){
carNo = Util.null2DefaultStr(info.getPlateList(),"");
info.setIdentification(identification);
mqMessage.setContent(info);
msg = JSONObject.toJSONString(mqMessage);
log.info(Util.logStr("car msg : {}", msg));
if("1".equals(sendMQ) && StringUtils.isNotBlank(msg)){
RocketConsumerUtil.producerSendMsg("OACar", msg, carNo);
}
}
}catch (Exception e){
throw new CustomerException("sendCarToMQ error : " + e.getMessage());
}
}
}

View File

@ -0,0 +1,78 @@
package com.api.xuanran.wang.shyl.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.api.xuanran.wang.shyl.entity.meeting.MeetingCusFieldConfigMain;
import com.api.xuanran.wang.shyl.mapper.MeetingMapper;
import org.apache.commons.lang3.StringUtils;
import weaver.xuanran.wang.common.mapper.CommonMapper;
import weaver.xuanran.wang.shyl_mq.service.ProducerService;
import weaver.zwl.common.ToolUtil;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/24 10:20
*/
public class MeetingService {
private final ToolUtil toolUtil = new ToolUtil();
private final CommonMapper commonMapper = Util.getMapper(CommonMapper.class);
private final ProducerService producerService = new ProducerService();
private final String TABLE_NAME = Util.null2DefaultStr(toolUtil.getSystemParamValue("meetingTableName"),"");
private final String CONFIG_NAME = Util.null2DefaultStr(toolUtil.getSystemParamValue("OAMeetingConfig"),"OAMeeting");
private final String ONLY_MARK = Util.null2DefaultStr(toolUtil.getSystemParamValue("meetingOnlyMark"),"meeting");
private final MeetingMapper meetingMapper = Util.getMapper(MeetingMapper.class);
/**
* <h1> </h1>
* @author xuanran.wang
* @dateTime 2023/2/24 10:21
* @param ids id
**/
public void cancelMeeting(String ids){
String[] idArr = ids.split(",");
List<String> requestIds = Arrays.stream(idArr).collect(Collectors.toList());
if (!commonMapper.cancelMeeting(requestIds)){
throw new CustomerException("更新会议状态失败!");
}
try {
if(StringUtils.isNotBlank(TABLE_NAME)){
sendToMQ(requestIds);
}
}catch (Exception e){
throw new CustomerException("更新会议状态下发MQ失败! " + e.getMessage());
}
}
/**
* <h1>mq</h1>
* @author xuanran.wang
* @dateTime 2023/2/28 14:40
* @param requestIds ids
**/
private void sendToMQ(List<String> requestIds){
for (String requestId : requestIds) {
producerService.pushWorkFlowToMQ(CONFIG_NAME,ONLY_MARK, requestId, TABLE_NAME, (map)->{
map.put("actionType", "DELETE_ACTION");
});
}
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/3/1 15:45
* @return
**/
public List<MeetingCusFieldConfigMain> getMeetingFieldCusConfig(){
return meetingMapper.queryMeetingCusConfigMain();
}
}

View File

@ -0,0 +1,59 @@
package com.api.xuanran.wang.shyl.service;
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 org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.zwl.common.ToolUtil;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/1 11:01
*/
public class StudentsService {
private final HttpUtils httpUtils = new HttpUtils();
private final Logger log = Util.getLogger();
private final ToolUtil toolUtil = new ToolUtil();
{
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
}
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2023/3/1 11:17
* @param classId id
* @return json
**/
public String getStudentsByClassId(String classId){
String url = Util.null2DefaultStr(toolUtil.getSystemParamValue("studentsUrl"),"");
if(StringUtils.isBlank(url)){
throw new CustomerException("在系统配置表中没有配置教研资studentsUrl!");
}
HashMap<String, Object> params = new HashMap<>();
params.put("classId", classId);
try {
ResponeVo responeVo = httpUtils.apiGet(url, params, new HashMap<>());
if(responeVo.getCode() != 200){
log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串
"this request heard is [{}]but response status code is [{}]" +
"this response is [{}]", url, JSON.toJSON(params), "", responeVo.getCode(), // 相应状态码
responeVo.getEntityString())); // 相应内容
}
return responeVo.getEntityString();
}catch (Exception e){
log.error(Util.logStr("查询班级列表人员数据接口失败!错误信息:{}",e.getMessage()));
}
return "";
}
}

View File

@ -0,0 +1,15 @@
package com.api.xuanran.wang.shyl.vo;
import lombok.Data;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/24 13:19
*/
@Data
public class CreateWfVO {
private String customId;
private String requestId;
}

View File

@ -0,0 +1,88 @@
package com.customization.shyl.service.impl;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.shyl.entity.meeting.MeetingCusFieldConfigMain;
import com.api.xuanran.wang.shyl.mapper.MeetingMapper;
import com.engine.core.cfg.annotation.CommandDynamicProxy;
import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.meeting.cmd.meetingroom.DoAddRoomCmd;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/1 16:18
*/
//@WeaIocReplaceComponent("MeetingRoomAddCusAopService")
@CommandDynamicProxy(target = DoAddRoomCmd.class, desc="会议室新增时将自定义字段写入后端数据库")
public class MeetingRoomAddCusAopService extends AbstractCommandProxy<Map<String,Object>> {
private final Logger logger = Util.getLogger();
private final MeetingMapper meetingMapper = Util.getMapper(MeetingMapper.class);
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
DoAddRoomCmd doAddRoomCmd = (DoAddRoomCmd) command;
Map<String, Object> request = doAddRoomCmd.getParams();
Map<String, Object> result = nextExecute(command);
try {
String id = Util.null2DefaultStr(result.get("id"),"");
logger.info("------------ addRoomAfterCmd start------------");
logger.info("roomId : " + id);
changeMeetingInfo(id,request);
logger.info("------------ addRoomAfterCmd end------------");
}catch (Exception e){
logger.error(Util.logStr("addRoomAfter error: {}", e.getMessage()));
}
return result;
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/3/2 14:49
* @param roomId id
* @param request
**/
public void changeMeetingInfo(String roomId, Map<String, Object> request){
if(StringUtils.isNotBlank(roomId)){
List<MeetingCusFieldConfigMain> config = meetingMapper.queryMeetingCusConfigMain();
Assert.notNull(config, "查询会议室新增字段配置为空!");
HashMap<String, Object> params = new HashMap<>();
for (MeetingCusFieldConfigMain main : config) {
// 数据库字段
String fieldOnlyMark = main.getFieldOnlyMark();
// 接口字段值
String requestValue = Util.null2DefaultStr(request.get(fieldOnlyMark),"");
params.put(fieldOnlyMark, requestValue);
}
StringBuilder sb = new StringBuilder("update ");
sb.append("meetingroom").append(" set ");
for (Map.Entry<String, Object> entry : params.entrySet()) {
sb.append(entry.getKey())
.append(" = #{")
.append(entry.getKey())
.append("},");
}
sb.deleteCharAt(sb.length() - 1);
sb.append(" where id = ").append(roomId);
String sql = sb.toString();
boolean success = meetingMapper.updateMeetingRoom(sql, params);
if(!success){
logger.info("更新会议室表失败!");
}
}
}
}

View File

@ -0,0 +1,41 @@
package com.customization.shyl.service.impl;
import aiyh.utils.Util;
import com.engine.core.cfg.annotation.CommandDynamicProxy;
import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.meeting.cmd.meetingroom.DoAddRoomCmd;
import com.engine.meeting.cmd.meetingroom.DoEditRoomCmd;
import com.engine.meeting.cmd.meetingroom.GetRoomFieldsCmd;
import org.apache.log4j.Logger;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/2 14:45
*/
@CommandDynamicProxy(target = DoEditRoomCmd.class, desc="会议室编辑时将自定义字段返回")
public class MeetingRoomEditCusAopService extends AbstractCommandProxy<Map<String,Object>> {
private final Logger logger = Util.getLogger();
private final MeetingRoomAddCusAopService roomAddCusAopService = new MeetingRoomAddCusAopService();
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
DoEditRoomCmd doEditRoomCmd = (DoEditRoomCmd) command;
Map<String, Object> request = doEditRoomCmd.getParams();
Map<String, Object> result = nextExecute(command);
try {
String id = Util.null2DefaultStr(request.get("roomid"),"");
logger.info("------------ editRoomAfterCmd start ------------");
logger.info("roomId : " + id);
roomAddCusAopService.changeMeetingInfo(id, request);
logger.info("------------ editRoomAfterCmd end ------------");
}catch (Exception e){
logger.error(Util.logStr("editRoomAfter error: {}", e.getMessage()));
}
return result;
}
}

View File

@ -0,0 +1,123 @@
package com.customization.shyl.service.impl;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSONObject;
import com.api.browser.bean.SearchConditionOption;
import com.api.meeting.util.FieldUtil;
import com.api.xuanran.wang.shyl.entity.meeting.MeetingCusFieldConfigDetail;
import com.api.xuanran.wang.shyl.entity.meeting.MeetingCusFieldConfigMain;
import com.api.xuanran.wang.shyl.mapper.MeetingMapper;
import com.engine.core.cfg.annotation.CommandDynamicProxy;
import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.meeting.cmd.meetingroom.DoAddRoomCmd;
import com.engine.meeting.cmd.meetingroom.GetRoomFieldsCmd;
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/1 17:04
*/
@CommandDynamicProxy(target = GetRoomFieldsCmd.class, desc="会议室查看时将自定义字段返回")
public class MeetingRoomLookCusAopService extends AbstractCommandProxy<Map<String,Object>> {
private final MeetingMapper meetingMapper = Util.getMapper(MeetingMapper.class);
private final Logger log = Util.getLogger();
/**
* <h2></h2>
**/
private static final int EDIT = 2;
/**
* <h2></h2>
**/
private static final int NUMBER = 0;
/**
* <h2></h2>
**/
private static final int SELECT_TYPE = 1;
/**
* <h2></h2>
**/
private static final int TEXT = 2;
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
GetRoomFieldsCmd getRoomFieldsCmd = (GetRoomFieldsCmd) command;
Map<String, Object> params = getRoomFieldsCmd.getParams();
Map<String, Object> res = nextExecute(command);
String roomId = Util.null2DefaultStr(params.get("roomid"), "");
try {
log.info("------------ lookRoomAfterCmd ------------");
Map<String, String> map = new HashMap<>();
if(StringUtils.isNotBlank(roomId)){
map = meetingMapper.queryMeetingRoom(roomId);
Assert.notNull(map, "根据会议室id查询会议室信息为空!");
}
List<MeetingCusFieldConfigMain> config = meetingMapper.queryMeetingCusConfigMain();
Assert.notNull(config, "查询会议室新增字段配置为空!");
List<Map<String, Object>> fields = (List<Map<String, Object>>) res.get("fields");
Assert.notNull(fields, "接口返回fields为空!");
Map<String, Object> roomAddress = fields.get(1);
Assert.notNull(roomAddress, "fields.get(1)为空!");
List<Map<String, Object>> roomAddressFields = (List<Map<String, Object>>) roomAddress.get("items");
Assert.notNull(roomAddressFields, "roomAddressFields为空!");
for (MeetingCusFieldConfigMain configMain : config) {
Map<String, Object> item = null;
// 数据库字段
String dbField = configMain.getFieldOnlyMark();
// 当前值
String currentValue = Util.null2DefaultStr(map.get(dbField), "");
// 前端显示名称
String fieldName = configMain.getFieldName();
int fieldType = configMain.getFieldType();
// 下拉框
if (fieldType == SELECT_TYPE) {
List<SearchConditionOption> options = getOptions(currentValue, configMain.getOptions());
item = FieldUtil.getFormItemForSelect(dbField, fieldName, currentValue, EDIT, options);
} else if(fieldType == NUMBER) {
item = FieldUtil.getFormItemForInputNumber(dbField, fieldName, currentValue, -999, 999, EDIT);
}else if(fieldType == TEXT){
item = FieldUtil.getFormItemForInput(dbField, fieldName, currentValue, EDIT);
}
roomAddressFields.add(item);
}
fields.remove(1);
roomAddress.put("items", roomAddressFields);
fields.add(roomAddress);
res.put("fields", fields);
} catch (Exception e) {
log.error(Util.logStr("lookRoomAfter error : {}", e.getMessage()));
}
return res;
}
public List<SearchConditionOption> getOptions(String currentValue,
List<MeetingCusFieldConfigDetail> details) {
List<SearchConditionOption> options = new ArrayList<>();
for (MeetingCusFieldConfigDetail option : details) {
String key = option.getSelectKey();
options.add(new SearchConditionOption(key, option.getSelectShowName(), key.equals(currentValue)));
}
return options;
}
}

View File

@ -2,14 +2,22 @@ package weaver.xuanran.wang.bme.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSetTrans;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;
import java.util.*;
import java.util.Map;
/**
* <h1>action</h1>
@ -17,49 +25,97 @@ import java.util.Map;
* @Author xuanran.wang
* @Date 2022/12/20 11:33
*/
public class ContractApplyComDateAction extends SafeCusBaseAction {
public class ContractApplyComDateAction implements Action {
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String buildContractProjectField;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String buildContractTable;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String detailContractTable;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String detailContractDateFiled;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String projectField;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String checkDateField;
/**
* <h2></h2>
* <h2></h2>
**/
private String updateWhere;
@RequiredMark
private String beforeBackField;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String dayField;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String whereField;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String whereValues;
/**
* <h2>sql</h2>
* <p>
* select a.id,a.requestid
* from
* formtable_main_58 a
* right join uf_cgdd b
* on a.id = b.cght
* where b.id = 874;
* </p>
**/
@PrintParamMark
private String relationSql;
private static final String BEFORE = "0";
private final Logger log = Util.getLogger();
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
public String execute(RequestInfo requestInfo) {
String requestId = requestInfo.getRequestid();
log.info(Util.logStr("--------------- requestId : {} Begin ---------------", requestId));
RecordSetTrans rs = new RecordSetTrans();
rs.setAutoCommit(false);
RecordSet rs = new RecordSet();
RequestManager requestManager = requestInfo.getRequestManager();
try {
Util.verifyRequiredField(this);
Map<String, String> mainTableValue = getMainTableValue(requestInfo);
// 验收流程的实际验收日期
String checkDate = mainTableValue.get(checkDateField);
@ -68,25 +124,79 @@ public class ContractApplyComDateAction extends SafeCusBaseAction {
log.error(Util.logStr("checkDate:{}, project:{}", checkDate, project));
throw new CustomerException("实际验收日期或项目字段字段为空!");
}
String selectSql = "select id from " + buildContractTable + " where " + buildContractProjectField + " = ?";
String selectSql = "select id,requestid from " + buildContractTable + " where " + buildContractProjectField + " = ?";
if(StringUtils.isNotBlank(relationSql)){
selectSql = relationSql;
}
log.info(Util.logStr("查询主表数据sql: {}, 参数: {}", selectSql, project));
if(rs.executeQuery(selectSql, project) && rs.next()){
String mainId = rs.getString("id");
String updateSql = "update " + detailContractTable + " set " + detailContractDateFiled + " = ? where mainid = ?";
if(StringUtils.isNotBlank(updateWhere)){
updateSql += " and " + updateWhere;
String tempRequestId = rs.getString("requestid");
// 查明细表数据
selectSql = "select * from " + detailContractTable + " where " + whereField + " in ( " + whereValues + " ) and mainid = ?";
log.info(Util.logStr("查明细表数据sql: {}, 参数: {}", selectSql, mainId));
String updateSql = "update " + detailContractTable + " set " + detailContractDateFiled + " = ? where id = ?";
log.info(Util.logStr("更新表单数据sql : {}", updateSql));
List<List> params = new ArrayList<>();
if (rs.executeQuery(selectSql, mainId)) {
while (rs.next()) {
ArrayList<Object> param = new ArrayList<>();
int temp = 1;
// 前还是后
String beforeBack = rs.getString(beforeBackField);
// 天数
String dayStr = rs.getString(dayField);
if(StringUtils.isBlank(beforeBack) || StringUtils.isBlank(dayStr)){
continue;
}
if(BEFORE.equals(beforeBack)){
temp = -1;
}
int day = Util.getIntValue(dayStr,1);
String computeDate = TimeUtil.dateAdd(checkDate, temp * day);
param.add(computeDate);
param.add(rs.getString("id"));
params.add(param);
log.info(Util.logStr("关联流程requestId: {}, 流程明细前后字段: {}, 天数: {}, 计算后的日期: {}",tempRequestId, beforeBack, day, computeDate));
}
}
log.info(Util.logStr("更新合同明细表sql:{}, 参数:{}, {}", updateSql, checkDate, mainId));
if(!rs.executeUpdate(updateSql, checkDate, mainId)){
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));
}
rs.commit();
}else{
log.error(Util.logStr("查询施工合同关联项目sql暂未查到数据! sql {} ,{}", selectSql, requestId));
log.error(Util.logStr("查询关联项目sql暂未查到数据! sql {} ,{}", selectSql, requestId));
}
return Action.SUCCESS;
}catch (Exception e){
rs.rollback();
throw new CustomerException(Util.logStr("更新施工合同实际验收日期发生异常: {} ", e.getMessage()));
log.error(Util.logStr("execute action fail, exception message is [{}], error stack trace msg is: \n{}",
e.getMessage(), Util.getErrString(e)));
return Util.actionFail(requestManager,Util.logStr("更新日期发生异常: {} ", e.getMessage()));
}
}
protected Map<String, String> getMainTableValue(RequestInfo requestInfo) {
// 获取主表数据
Property[] propertyArr = requestInfo.getMainTableInfo().getProperty();
return getStringMap(propertyArr);
}
private Map<String, String> getStringMap(Property[] propertyArr) {
if (null == propertyArr) {
return Collections.emptyMap();
}
Map<String, String> mainTable = new HashMap<>((int) Math.ceil(propertyArr.length * 1.4));
for (Property property : propertyArr) {
String fieldName = property.getName();
String value = property.getValue();
mainTable.put(fieldName, value);
}
return mainTable;
}
}

View File

@ -152,9 +152,13 @@ public class CusCreateWaterNoAction extends SafeCusBaseAction {
}
if(endInt < 10){
endStr = "0" + endInt;
}else {
endStr = "" + endInt;
}
if(frontInt < 10){
frontStr = "0" + frontInt;
}else {
frontStr = "" + frontInt;
}
res = frontStr + "." + endStr;
}
@ -162,6 +166,9 @@ public class CusCreateWaterNoAction extends SafeCusBaseAction {
}
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
String serialCode = inventoryCode + "." + res;
if(serialCode.charAt(0) == '0'){
serialCode = serialCode.substring(1);
}
map.put("invClassificationCode", inventoryCode);
map.put("serialNumber", res);
map.put("serialCode", serialCode);

View File

@ -0,0 +1,36 @@
package weaver.xuanran.wang.bme.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.soa.workflow.request.RequestService;
import weaver.xuanran.wang.bme.service.PushDataService;
/**
* <h1>action u8</h1>
*
* @author xuanran.wang
* @date 2023/2/21 13:19
*/
public class TransOrderApproval extends SafeCusBaseAction {
/**
* <h2></h2>
**/
@PrintParamMark
@RequiredMark
private String onlyMark;
private final PushDataService pushDataService = new PushDataService();
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
try {
pushDataService.pushData(onlyMark, requestId, billTable);
}catch (Exception e){
throw new CustomerException(Util.logStr("TransOrderApproval error : {}", e.getMessage()));
}
}
}

View File

@ -0,0 +1,190 @@
package weaver.xuanran.wang.bme.action;
import aiyh.utils.Util;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import aiyh.utils.sqlUtil.whereUtil.Where;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;
import java.util.HashMap;
import java.util.List;
/**
* <h1>/</h1>
* <h2></h2>
* @author xuanran.wang
* @date 2022/12/13 11:13
*/
public class UpdateModelInfo implements Action {
private final Logger log = Util.getLogger();
/**
* <h2> glddxx</h2>
**/
@PrintParamMark
@RequiredMark
private String orderType;
/**
* <h2></h2>
* select * from formtable_main_62 where htbh = 'D520230209001'
**/
@PrintParamMark
@RequiredMark
private String sgTable;
/**
* <h2></h2>
* select * from formtable_main_62 where htbh = 'D520230209001'
**/
@PrintParamMark
@RequiredMark
private String sgDetailTable;
/**
* <h2></h2>
**/
@PrintParamMark
@RequiredMark
private String cgTable;
/**
* <h2></h2>
**/
@PrintParamMark
@RequiredMark
private String cgDetailTable;
/**
* <h2></h2>
* <h2>bcfkje:sjfkje,sjfkrq:sjfkrq</h2>
**/
@PrintParamMark
@RequiredMark
private String sgFieldMapping;
/**
* <h2></h2>
* <h2>bcfkje:fkje,sjfkrq:sjfkrq</h2>
**/
@PrintParamMark
@RequiredMark
private String cgFieldMapping;
/**
* <h2></h2>
**/
@PrintParamMark
@RequiredMark
private String cgModelRelationField;
/**
* <h2></h2>
* htbh
**/
@PrintParamMark
@RequiredMark
private String sgModelRelationField;
/**
* <h2></h2>
**/
private static final String DDH = "ddh";
/**
* <h2></h2>
**/
private static final String KXLX = "kxlx";
@Override
public String execute(RequestInfo requestInfo) {
RecordSetTrans rsts = new RecordSetTrans();
RequestManager requestManager = requestInfo.getRequestManager();
String requestId = requestInfo.getRequestid();
String billTable = requestManager.getBillTableName();
rsts.setAutoCommit(false);
log.info("UpdateModelInfo begin ===== " + requestId);
try {
Util.verifyRequiredField(this);
String sql = "select * from " + billTable + " where requestid = ?";
// 查询的建模表单名称
String modelTableName = "";
RecordSet mainRs = new RecordSet();
// 建模表关联流程sql
String relationField = "";
// 建模更新表名
String updateTable = "";
String fieldMapping = "";
if (mainRs.executeQuery(sql, requestId) && mainRs.next()) {
String orderTypeVal = mainRs.getString(orderType);
switch (orderTypeVal){
case "0":{
modelTableName = cgTable;
relationField += cgModelRelationField;
updateTable = cgDetailTable;
fieldMapping = cgFieldMapping;
}break;
case "1":{
modelTableName = sgTable;
relationField += sgModelRelationField;
updateTable = sgDetailTable;
fieldMapping = sgFieldMapping;
break;
}
}
String modelMainRsSql = "select id from " + modelTableName + " where " + relationField + " = ?";
log.info("查询关联建模主表数据id sql " + modelMainRsSql);
// 建模明细表
RecordSet detailRs = new RecordSet();
String mainId = mainRs.getString("id");
RecordSet modelMainRs = new RecordSet();
String detail3Sql = "select * from " + billTable + "_dt3 where mainid = ?";
detailRs.executeQuery(detail3Sql, mainId);
while (detailRs.next()) {
// 订单号
String orderIdVal = detailRs.getString(DDH);
if(StringUtils.isBlank(orderIdVal)) {
continue;
}
String modelMainId = "";
if (modelMainRs.executeQuery(modelMainRsSql, orderIdVal) && modelMainRs.next()) {
modelMainId = modelMainRs.getString("id");
}
log.info("orderIdVal : " + orderIdVal);
String[] split = fieldMapping.split(",");
HashMap<String, Object> params = new HashMap<>();
Where where = Util.createPrepWhereImpl()
.whereAnd("mainid")
.whereEqual(modelMainId)
.whereAnd(KXLX)
.whereEqual(Util.null2DefaultStr(detailRs.getString(KXLX),""));
for (String field : split) {
String[] fields = field.split(":");
params.put(fields[1], Util.null2DefaultStr(detailRs.getString(fields[0]),""));
}
PrepSqlResultImpl updateSql = Util.createSqlBuilder().updateSql(updateTable, params, where);
String sqlStr = updateSql.getSqlStr();
List<Object> args = updateSql.getArgs();
log.info("更新表单sql : " + sqlStr);
log.info("参数 : " + JSONObject.toJSONString(args));
if(!rsts.executeUpdate(sqlStr, args)){
throw new CustomerException("执行更新sql失败! 当前sql : " + sqlStr + " 参数 : " + JSONObject.toJSONString(args));
}
}
rsts.commit();
}
return Action.SUCCESS;
}catch (Exception e){
rsts.rollback();
String error = Util.logStr("UpdateModelInfo error : {}", e.getMessage());
log.error(error);
requestManager.setMessageid(System.currentTimeMillis() + "");
requestManager.setMessagecontent(error);
return Action.FAILURE_AND_CONTINUE;
}
}
}

View File

@ -0,0 +1,95 @@
package weaver.xuanran.wang.bme.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import aiyh.utils.tool.Assert;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.collections.CollectionUtils;
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.schroeder.mapper.SchroederMapper;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/21 13:21
*/
public class PushDataService {
private static final int SUCCESS_CODE = 200;
/**
* <h2></h2>
**/
private static final String MESSAGE_FIELD = "Message";
/**
* <h2>/</h2>
*/
private static final String SUCCESS_FIELD = "Success";
/**
* <h2>requestId</h2>
**/
private final DealWithMapping dealWithMapping = new DealWithMapping();
private final Logger log = Util.getLogger(); // 获取日志对象
private final HttpUtils httpUtils = new HttpUtils();
{
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
}
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2023/2/21 13:34
* @param onlyMark
* @param requestId id
* @param tableName
**/
public void pushData(String onlyMark,
String requestId,
String tableName) throws IOException {
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
dealWithMapping.setMainTable(tableName);
String cusWhere = Util.null2DefaultStr(requestMappingConfig.getCusWhereSql(), "");
if (StringUtils.isNotBlank(cusWhere)) {
cusWhere = DealWithMapping.sbc2dbcCase(cusWhere); // 全角转半角
}
String url = requestMappingConfig.getRequestUrl();
String selectMainSql = "select * from " + tableName + " where requestid = ? " + cusWhere;
log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId));
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(selectMainSql, requestId);
if (recordSet.next()) {
dealWithMapping.setMainTable(tableName);
List<Object> listParam = dealWithMapping.getRequestListParam(recordSet, requestMappingConfig);
Assert.isNull(listParam,"流程生成JSON失败!");
ResponeVo responseVo = httpUtils.apiPost(url, listParam,new HashMap<>());
Map<String, String> headers = httpUtils.getGlobalCache().header;// 全局请求头
if (responseVo.getCode() != SUCCESS_CODE) { // 相应状态码
log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串
"this request heard is [{}]but response status code is [{}]" +
"this response is [{}]", url, JSON.toJSON(listParam), JSON.toJSONString(headers), responseVo.getCode(), // 相应状态码
responseVo.getEntityString())); // 相应内容
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
Map<String, Object> response = responseVo.getResponseMap(); // 根据相应结果转化为map集合
Boolean success = (Boolean) response.get(SUCCESS_FIELD);
if (!success) {
throw new CustomerException(Util.logStr("接口响应码不为 : [{}],接口响应信息: {}", success, Util.null2DefaultStr(response.get(MESSAGE_FIELD), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
}
}
}
}

View File

@ -0,0 +1,25 @@
package weaver.xuanran.wang.common.annocation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <h1>mapjson</h1>
*
* @author xuanran.wang
* @date 2023/2/25 15:22
*/
@Target({ElementType.FIELD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Map2JSONConvert {
/**
* <h2>map</h2>
**/
String mapField() default "";
/**
* <h2>json</h2>
**/
String jsonField() default "";
}

View File

@ -42,6 +42,25 @@ public interface CommonMapper {
boolean deleteModelDataByIds(@ParamMapper("tableName") String tableName,
@ParamMapper("ids") List<String> ids);
/**
* <h1>requestId</h1>
* @author xuanran.wang
* @dateTime 2022/11/17 10:41
* @param tableName
* @param requestIds id
* @return
**/
@Delete("delete from $t{tableName} where requestid in (${requestIds})")
boolean deleteWorkflowDataByRequestIds(@ParamMapper("tableName") String tableName,
@ParamMapper("requestIds") List<String> requestIds);
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2023/2/22 15:17
* @param modelId id
* @return
**/
@Select("SELECT mp.id,m.formId,mpd.triggerWorkflowSetId " +
"FROM MODE_PageExpand mp " +
"INNER JOIN modeInfo m " +
@ -51,10 +70,46 @@ public interface CommonMapper {
"WHERE mp.modeid = #{modelId} AND mp.isSystem = 1 AND mp.iSSystemFlag = 1")
Map<String, Integer> getExpendConfigByModeId(@ParamMapper("modelId") int modelId);
/**
* <h1>TODO</h1>
* @author xuanran.wang
* @dateTime 2023/2/22 15:37
* @param triggerId id
* @return
**/
@Select("select * from mode_triggerworkflowset where id = #{triggerId}")
Map<String, String> getConfigByTriggerId(@ParamMapper("triggerId") String triggerId);
/**
* <h1>TODO</h1>
* @author xuanran.wang
* @dateTime 2023/2/22 15:38
* @param triggerId
* @return
**/
@Select("select showcondition from mode_triggerworkflowset where id = #{triggerId}")
String getConditionByTriggerId(@ParamMapper("triggerId") String triggerId);
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2023/2/22 15:38
* @param workflowId id
* @return id
**/
@Select("select tablename from workflow_bill a right join workflow_base b on a.id = b.FORMID where b.id = #{workflowId}")
String queryTableNameByWorkflowId(@ParamMapper("workflowId") int workflowId);
/**
* <h1>idid</h1>
* @author xuanran.wang
* @dateTime 2023/2/22 15:38
* @param requestId id
* @return id
**/
@Select("select id from meeting where requestid = #{requestId}")
String queryMeetingIdByRequestId(@ParamMapper("requestId") String requestId);
@Update("update meeting set meetingstatus = 4 where requestid in (${requestIds})")
boolean cancelMeeting(@ParamMapper("requestIds") List<String> requestIds);
}

View File

@ -18,6 +18,8 @@ import weaver.xuanran.wang.common.annocation.ParamNotNull;
import weaver.xuanran.wang.common.annocation.ParamPrint;
import weaver.xuanran.wang.common.mapper.CommonMapper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
@ -274,6 +276,7 @@ public class CommonUtil {
).filter(b -> !b.isEmpty())
.collect(Collectors.toList());
}
/**
* <h1></h1>
* @author xuanran.wang
@ -618,6 +621,40 @@ public class CommonUtil {
return "select * from " + tableName + " where requestid = ? " + cusWhere;
}
/**
* <h1>ID</h1>
* @author xuanran.wang
* @dateTime 2023/2/22 16:25
* @param workflowId id
* @return
**/
public static String getTableNameByWorkflowId(int workflowId){
return commonMapper.queryTableNameByWorkflowId(workflowId);
}
/**
* <h1>requestId</h1>
* @author xuanran.wang
* @dateTime 2022/11/17 10:41
* @param tableName
* @param requestIds id
* @return
**/
public static boolean deleteWorkflowDataByRequestIds(String tableName, List<String> requestIds){
return commonMapper.deleteWorkflowDataByRequestIds(tableName, requestIds);
}
/**
* <h1>idid</h1>
* @author xuanran.wang
* @dateTime 2023/2/22 17:37
* @param requestId id
* @return id
**/
public static String getMeetingIdByRequestId(String requestId){
return commonMapper.queryMeetingIdByRequestId(requestId);
}
}

View File

@ -1,6 +1,7 @@
package weaver.xuanran.wang.shyl.dataasync.job;
import aiyh.utils.Util;
import lombok.Data;
import org.apache.log4j.Logger;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.xuanran.wang.common.annocation.ParamNotNull;
@ -18,6 +19,7 @@ import java.util.HashMap;
* @author xuanran.wang
* @date 2023/2/9 10:02
*/
@Data
public class CusDataAsyncJob extends BaseCronJob {
/**
@ -26,54 +28,30 @@ public class CusDataAsyncJob extends BaseCronJob {
@ParamPrint
@ParamNotNull
private String baseAddr;
/**
* <h2></h2>
**/
@ParamPrint
@ParamNotNull
private String dynamicCodeUrl;
/**
* <h2></h2>
**/
@ParamPrint
@ParamNotNull
private String loginUrl;
/**
* <h2>url</h2>
**/
@ParamPrint
@ParamNotNull
private String queryClassUrl;
/**
* <h2>Url</h2>
**/
@ParamPrint
@ParamNotNull
private String queryStuUrl;
// /**
// * <h2>查询学员列表Url</h2>
// **/
// @ParamPrint
// @ParamNotNull
// private String queryStuUrl;
/**
* <h2>id</h2>
**/
@ParamPrint
@ParamNotNull
private String classModelId;
/**
* <h2>id</h2>
**/
@ParamPrint
@ParamNotNull
private String studentModelId;
/**
* <h2></h2>
**/
@ParamPrint
@ParamNotNull
private String userName;
/**
* <h2></h2>
**/
@ParamPrint
@ParamNotNull
private String userPwd;
// /**
// * <h2>学员模块id</h2>
// **/
// @ParamPrint
// @ParamNotNull
// private String studentModelId;
/**
* <h2>sql</h2>
**/
@ -85,28 +63,17 @@ public class CusDataAsyncJob extends BaseCronJob {
private final CusDataAsyncService dataAsyncService = new CusDataAsyncService();
private final Logger log = Util.getLogger();
// private final Logger logger = Util.getLogger();
@Override
public void execute() {
try {
CommonUtil.checkParamNotNull(this);
// 获取token参数
HashMap<String, Object> loginParams = new HashMap<>();
loginParams.put("username", userName);
loginParams.put("password", userPwd);
loginParams.put("authType", "normal");
Object token = dataAsyncService.getToken(dynamicCodeUrl, loginUrl, loginParams);
HashMap<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + token);
// 数据同步
dataAsyncService.asyncData(baseAddr + queryClassUrl, classModelId, StudentClass.class, updateClassSql,headers);
dataAsyncService.asyncData(baseAddr + queryStuUrl, studentModelId, Student.class, updateStudentSql, headers);
dataAsyncService.asyncData(baseAddr + queryClassUrl, classModelId, StudentClass.class, updateClassSql,"data");
}catch (Exception e){
log.error(Util.logStr("CusDataAsyncJob execute error! the error is :{}, " +
"error stack trace msg is: \n{}", e.getMessage(), Util.getErrString(e)));
// logger.error(Util.logStr("CusDataAsyncJob execute error! the error is :{}, " +
// "error stack trace msg is: \n{}", e.getMessage(), Util.getErrString(e)));
}
}
}

View File

@ -5,7 +5,9 @@ import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
@ -13,10 +15,7 @@ import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
/**
* <h1>/</h1>
@ -49,14 +48,22 @@ public class CusDataAsyncService {
* @param modelId id
* @param clazz class
* @param updateSql sql
* @param headers
**/
public void asyncData(String url, String modelId,
Class<?> clazz,String updateSql,
HashMap<String, String> headers){
Object data = getResponseDataByPost(url, new HashMap<>(), headers,"");
List<?> list = JSONObject.parseArray(data.toString(), clazz);
CusInfoToOAUtil.executeBatchByEntity(Util.getIntValue(modelId, -1), list, updateSql);
Class<?> clazz,String updateSql, String key){
Object data = getResponseDataByGet(url, new HashMap<>(), new HashMap<>(), key);
JSONArray array = JSONObject.parseArray(JSONObject.toJSONString(data));
log.info("data : " + array);
if(CollectionUtils.isEmpty(array)){
log.error("array is empty!");
return;
}
ArrayList<Object> dataList = new ArrayList<>();
for (Object o : array) {
Object temp = JSONObject.parseObject(o.toString(), clazz);
dataList.add(temp);
}
CusInfoToOAUtil.executeBatchByEntity(Util.getIntValue(modelId, -1), dataList, updateSql);
}
/**
@ -90,7 +97,7 @@ public class CusDataAsyncService {
private Object getResponseDataByPost(String url, Map<String, Object> params,
Map<String, String> headers, String key){
try {
ResponeVo responseVo = httpUtils.apiPost(url, params, headers);
ResponeVo responseVo = httpUtils.apiGet(url, params, headers);
return getResponseData(url, responseVo, key);
}catch (IOException e) {
throw new CustomerException(Util.logStr("api get error! current url is : {}, error is :{}",url, e.getMessage()));

View File

@ -1,44 +0,0 @@
package weaver.xuanran.wang.shyl.mq.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xuanran.wang.shyl.mq.service.ProducerService;
/**
* <h1>action mq</h1>
*
* @author xuanran.wang
* @date 2023/1/4 14:47
*/
public class ProducerAction extends SafeCusBaseAction {
/**
* <h2>mq</h2>
**/
@RequiredMark
@PrintParamMark
private String MQConfigName;
/**
* <h2></h2>
**/
@RequiredMark
@PrintParamMark
private String onlyMark;
private final ProducerService producerService = new ProducerService();
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
try {
producerService.pushWorkFlowToMQ(MQConfigName, onlyMark, billTable, requestId);
}catch (Exception e){
String error = Util.logStr("push workFlow to MQ error! the error is :[{}]", e.getMessage());
throw new CustomerException(error);
}
}
}

View File

@ -1,49 +0,0 @@
package weaver.xuanran.wang.shyl.mq.service;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.xuanran.wang.shyl.mq.mapper.ConsumerMapper;
import weaver.xuanran.wang.shyl.mq.service.interfaces.CreateAction;
import weaver.xuanran.wang.shyl.mq.service.interfaces.DeleteAction;
import weaver.xuanran.wang.shyl.mq.service.interfaces.PassWordAction;
import weaver.xuanran.wang.shyl.mq.service.interfaces.UpdateAction;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 13:04
*/
public abstract class CusInfoActionService implements CreateAction, DeleteAction, UpdateAction, PassWordAction {
protected final RecordSet recordSet = new RecordSet();
protected final Logger logger = Util.getLogger();
/**
* <h2>consumer-mapper</h2>
**/
protected final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class);
/**
* <h2>id</h2>
**/
protected String subId;
// 默认初始化分部ID
{
subId = consumerMapper.getDefaultSubId();
}
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2023/01/03 10:50
* @return next id
**/
protected synchronized String getNextHrmId(){
recordSet.executeProc("HrmResourceMaxId_Get", "");
recordSet.next();
//新增的部门id
return Util.null2String(recordSet.getInt(1));
}
}

View File

@ -1,49 +0,0 @@
package weaver.xuanran.wang.shyl.mq.service;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.MapUtils;
import weaver.conn.RecordSet;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping;
import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
import java.util.HashMap;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/1/4 14:54
*/
public class ProducerService {
private final DealWithMapping dealWithMapping = new DealWithMapping();
/**
* <h1>mq</h1>
* @author xuanran.wang
* @dateTime 2023/1/18 10:22
* @param configName mq
* @param onlyMark
* @param requestId id
* @param tableName
**/
public void pushWorkFlowToMQ(String configName, String onlyMark, String requestId, String tableName){
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, tableName);
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(selectMainSql, requestId);
Map<String, Object> requestParam = new HashMap<>();
if (recordSet.next()) {
dealWithMapping.setMainTable(tableName);
requestParam = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
}
if(MapUtils.isEmpty(requestParam)){
throw new CustomerException("convert workflow information to json error!");
}
RocketUtil.producerSendMsg(configName, JSONObject.toJSONString(requestParam));
}
}

View File

@ -1,14 +0,0 @@
package weaver.xuanran.wang.shyl.mq.service.interfaces;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 13:00
*/
public interface CreateAction {
ConsumeConcurrentlyStatus cusCreateAction(MQMessage message);
}

View File

@ -1,14 +0,0 @@
package weaver.xuanran.wang.shyl.mq.service.interfaces;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 13:02
*/
public interface DeleteAction {
ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message);
}

View File

@ -1,14 +0,0 @@
package weaver.xuanran.wang.shyl.mq.service.interfaces;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 13:03
*/
public interface PassWordAction {
ConsumeConcurrentlyStatus cusPassWordAction(MQMessage message);
}

View File

@ -1,14 +0,0 @@
package weaver.xuanran.wang.shyl.mq.service.interfaces;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 13:01
*/
public interface UpdateAction {
ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message);
}

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.shyl.mq;
package weaver.xuanran.wang.shyl_mq;//package weaver.xuanran.wang.shyl.mq;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
@ -50,7 +50,6 @@ public abstract class RocketMQConsumerListener extends HttpServlet {
}catch (Exception e){
throw new CustomerException(Util.logStr("the consumer start exception : {}", e.getMessage()));
}
log.info(Util.logStr("---- consumer : {} initialized end ----", configName));
}catch (Exception e){
log.info(Util.logStr("---- consumer : {} initialized error ----", configName));
log.error(Util.getErrString(e));

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.shyl.mq;
package weaver.xuanran.wang.shyl_mq;//package weaver.xuanran.wang.shyl.mq;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
@ -8,8 +8,8 @@ import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
import weaver.xuanran.wang.shyl_mq.constant.RocketMQConstant;
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
import java.util.HashMap;
import java.util.Map;
@ -60,6 +60,8 @@ public class RocketMQFactory {
consumer.subscribe(Util.null2String(configMap.get("Topic")), Util.null2String(configMap.get("Tag")));
// Listener主要进行消息的逻辑处理,监听topic如果有消息就会立即去消费
consumer.registerMessageListener(messageListenerConcurrently);
// 是否开启vip
consumer.setVipChannelEnabled(false);
return consumer;
}catch (Exception e){
throw new CustomerException(Util.logStr("consumer init error, now config name is : {} error : {}",configName, e.getMessage()), e);
@ -82,17 +84,18 @@ public class RocketMQFactory {
return PRODUCER_MAP.get(configName);
}else {
Map<String, Object> configMap = getConfigMapByName(configName);
defaultMQProducer = new DefaultMQProducer();
defaultMQProducer = new DefaultMQProducer(Util.null2DefaultStr(configMap.get("ConsumerGroup"),""));
// 发送消息最大超时时间 默认60000
int sendMsgTimeOut = Util.getIntValue(Util.null2String(configMap.get("sendMsgTimeOut")), RocketMQConstant.PRODUCER_SEND_MSG_TIME_OUT);
defaultMQProducer.setSendMsgTimeout(sendMsgTimeOut);
defaultMQProducer.setVipChannelEnabled(false);
defaultMQProducer.setNamesrvAddr(Util.null2String(configMap.get("NameServer")));
try {
defaultMQProducer.start();
}catch (MQClientException e){
throw new CustomerException("producer start error!",e);
throw new CustomerException(Util.logStr("producer start error!:{}",e.getMessage()));
}
// mq地址
defaultMQProducer.setNamesrvAddr(Util.null2String(configMap.get("NameServer")));
PRODUCER_MAP.put(configName, defaultMQProducer);
}
}
@ -109,7 +112,7 @@ public class RocketMQFactory {
private synchronized static Map<String, Object> getConfigMapByName(String configName){
Map<String, Object> configMap = new HashMap<>();
if(!CONFIG_MAPS.containsKey(configName)){
configMap = RocketUtil.initMQConfigMap(configName);
configMap = RocketConsumerUtil.initMQConfigMap(configName);
CONFIG_MAPS.put(configName, configMap);
}
return configMap;

View File

@ -0,0 +1,47 @@
package weaver.xuanran.wang.shyl_mq.action;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;
import weaver.xuanran.wang.shyl_mq.service.ProducerService;
/**
* <h1>action mq</h1>
*
* @author xuanran.wang
* @date 2023/1/4 14:47
*/
public class ProducerAction implements Action {
/**
* <h2></h2>
**/
private String onlyMark;
/**
* <h2></h2>
**/
private String configName;
private final Logger logger = Util.getLogger();
private final ProducerService producerService = new ProducerService();
@Override
public String execute(RequestInfo requestInfo) {
RequestManager requestManager = requestInfo.getRequestManager();
String billTable = requestManager.getBillTableName();
String requestId = requestInfo.getRequestid();
try {
producerService.pushWorkFlowToMQ(configName,onlyMark, requestId, billTable, null);
return Action.SUCCESS;
}catch (Exception e){
String error = Util.logStr("push workFlow to MQ error! the error is :[{}]", e.getMessage());
logger.error(error);
requestManager.setMessageid(System.currentTimeMillis() + "");
requestManager.setMessagecontent(error);
return Action.FAILURE_AND_CONTINUE;
}
}
}

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.shyl.mq.constant;
package weaver.xuanran.wang.shyl_mq.constant;
import java.util.HashMap;
import java.util.Map;
@ -14,7 +14,7 @@ public class RocketMQConstant {
public static final String UPDATE_ACTION = "UPDATE_ACTION";
public static final String DELETE_ACTION = "DELETE_ACTION";
public static final String PASSWORD_ACTION = "PASSWORD_ACTION";
public static final int DEFAULT_MAX_RECONSUME_TIMES = 5;
public static final int DEFAULT_MAX_RECONSUME_TIMES = 2;
public static final String SEX_GIRL = "1";
public static final String SEX_BOY = "2";
public static final String STATUS_ENABLE = "1";

View File

@ -1,13 +1,13 @@
package weaver.xuanran.wang.shyl.mq.consumer;
package weaver.xuanran.wang.shyl_mq.consumer;//package weaver.xuanran.wang.shyl.mq.consumer;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;
import weaver.xuanran.wang.shyl.mq.RocketMQConsumerListener;
import weaver.xuanran.wang.shyl.mq.service.impl.OrgServiceImpl;
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
import weaver.xuanran.wang.shyl_mq.RocketMQConsumerListener;
import weaver.xuanran.wang.shyl_mq.service.impl.OrgServiceImpl;
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
import java.util.List;
@ -29,7 +29,7 @@ public class OrgConsumer extends RocketMQConsumerListener {
@Override
public MessageListenerConcurrently service() {
return (List<MessageExt> msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, orgService, CONFIG_NAME);
return (List<MessageExt> msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketConsumerUtil.execute(msg, consumeConcurrentlyContext, orgService, CONFIG_NAME);
}
}

View File

@ -1,13 +1,12 @@
package weaver.xuanran.wang.shyl.mq.consumer;
package weaver.xuanran.wang.shyl_mq.consumer;//package weaver.xuanran.wang.shyl.mq.consumer;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;
import weaver.xuanran.wang.shyl.mq.RocketMQConsumerListener;
import weaver.xuanran.wang.shyl.mq.service.impl.PassWordServiceImpl;
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
import weaver.xuanran.wang.shyl_mq.RocketMQConsumerListener;
import weaver.xuanran.wang.shyl_mq.service.impl.PassWordServiceImpl;
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
import java.util.List;
@ -30,7 +29,7 @@ public class PassWordConsumer extends RocketMQConsumerListener {
@Override
public MessageListenerConcurrently service() {
return (List<MessageExt> msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, passWordService, CONFIG_NAME);
return (List<MessageExt> msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketConsumerUtil.execute(msg, consumeConcurrentlyContext, passWordService, CONFIG_NAME);
}
}

View File

@ -1,13 +1,13 @@
package weaver.xuanran.wang.shyl.mq.consumer;
package weaver.xuanran.wang.shyl_mq.consumer;//package weaver.xuanran.wang.shyl.mq.consumer;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;
import weaver.xuanran.wang.shyl.mq.RocketMQConsumerListener;
import weaver.xuanran.wang.shyl.mq.service.impl.UserServiceImpl;
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
import weaver.xuanran.wang.shyl_mq.RocketMQConsumerListener;
import weaver.xuanran.wang.shyl_mq.service.impl.UserServiceImpl;
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
import java.util.List;
@ -29,7 +29,7 @@ public class UserInfoConsumer extends RocketMQConsumerListener {
@Override
public MessageListenerConcurrently service() {
return (List<MessageExt> msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, userInfoService, CONFIG_NAME);
return (List<MessageExt> msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketConsumerUtil.execute(msg, consumeConcurrentlyContext, userInfoService, CONFIG_NAME);
}
}

View File

@ -0,0 +1,53 @@
package weaver.xuanran.wang.shyl_mq.entity;
import lombok.Data;
import weaver.xuanran.wang.common.annocation.SqlFieldMapping;
/**
* <h1>mq</h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 13:09
*/
@Data
public class MQMessage {
/**
* <h2>ID</h2>
**/
@SqlFieldMapping("messageId")
private String id;
/**
* <h2></h2>
* <p>
* AUTH_CONSOLE_USERINFO_TOPIC: ;
* AUTH_CONSOLE_ORG_TOPIC: ;
* AUTH_CONSOLE_USERINFO_PASSWORD_TOPIC:
* </p>
**/
@SqlFieldMapping()
private String topic;
/**
* <h2></h2>
* <p>
* CREATE_ACTION;
* UPDATE_ACTION: ;
* DELETE_ACTION: ;
* PASSWORD_ACTION:
* </p>
**/
@SqlFieldMapping()
private String actionType;
/**
* <h2></h2>
**/
@SqlFieldMapping()
private String sendTime;
/**
* <h2>,json ,()</h2>
**/
@SqlFieldMapping()
private String content;
@SqlFieldMapping()
private String error;
}

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.shyl.mq.entity;
package weaver.xuanran.wang.shyl_mq.entity;
import lombok.Data;

View File

@ -1,5 +1,5 @@
package weaver.xuanran.wang.shyl.mq.entity;
package weaver.xuanran.wang.shyl_mq.entity;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.shyl.mq.entity;
package weaver.xuanran.wang.shyl_mq.entity;
import lombok.Data;

View File

@ -1,8 +1,6 @@
package weaver.xuanran.wang.shyl.mq.mapper;
package weaver.xuanran.wang.shyl_mq.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.Update;
import aiyh.utils.annotation.recordset.*;
import java.util.Map;
@ -12,6 +10,7 @@ import java.util.Map;
* @Author xuanran.wang
* @Date 2022/12/30 14:19
*/
@SqlMapper
public interface ConsumerMapper {
/**
@ -23,14 +22,25 @@ public interface ConsumerMapper {
@Update("update hrmresource set status = 5 where outkey = #{outKey}")
boolean updateUserStatusByOutKey(@ParamMapper("outKey") String outKey);
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2022/12/30 14:33
* @param id id
* @return
**/
@Delete("delete from hrmdepartment where id = #{id}")
boolean deleteDepartmentById(@ParamMapper("id") String id);
/**
* <h1>outKey</h1>
* @author xuanran.wang
* @dateTime 2022/12/30 14:33
* @param outKey id
* @return
* set canceled = 1 where outkey = #{outKey}
**/
@Update("update hrmdepartment set canceled = 1 where outkey = #{outKey}")
@Delete("delete from hrmdepartment where outkey = #{outKey}")
boolean deleteDepartmentByOutKey(@ParamMapper("outKey") String outKey);
/**
@ -40,7 +50,7 @@ public interface ConsumerMapper {
* @param outKey id
* @return map key : id, val : id
**/
@Update("select id departmentId, subcompanyid1 subCompanyId from hrmdepartment where outkey = #{outKey} and canceled != 1")
@Select("select id departmentId, subcompanyid1 subCompanyId from hrmdepartment where outkey = #{outKey} and canceled != 1")
Map<String, Integer> getDepInfoByOutKey(@ParamMapper("outKey") String outKey);
/**
@ -50,7 +60,7 @@ public interface ConsumerMapper {
* @param outKey id
* @return id
**/
@Update("select id from hrmresource where outkey = #{outKey}")
@Select("select id from hrmresource where outkey = #{outKey}")
String getHrmIdByOutKey(@ParamMapper("outKey") String outKey);
/**
@ -60,7 +70,7 @@ public interface ConsumerMapper {
* @param outKey id
* @return id
**/
@Update("select id from hrmdepartment where outkey = #{outKey} and canceled != 1")
@Select("select id from hrmdepartment where outkey = #{outKey} and canceled != 1")
String getDepIdByOutKey(@ParamMapper("outKey") String outKey);
/**
@ -82,4 +92,27 @@ public interface ConsumerMapper {
**/
@Select("select id from hrmsubcompany")
String getDefaultSubId();
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2022/12/30 14:33
* @param id id
* @return true/false
**/
@Delete("delete from hrmresource where id = #{id}")
boolean deleteHrmById(@ParamMapper("id") String id);
/**
* <h1>outKey</h1>
* @author xuanran.wang
* @dateTime 2022/12/30 14:33
* @param outKey outKey
* @return true/false
**/
@Delete("delete from hrmresource where outkey = #{outKey}")
boolean deleteHrmByOutKey(@ParamMapper("outKey") String outKey);
@Select("select count(1) from uf_mqLog where messageId = #{messageId}")
int getMainIdFromMQLogByMessageId(@ParamMapper("messageId") String messageId);
}

View File

@ -0,0 +1,17 @@
package weaver.xuanran.wang.shyl_mq.service;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/28 14:35
*/
public interface ChangeRequestParam {
/**
*
* @param requestParam
*/
void changeRequestParam(Map<String, Object> requestParam);
}

View File

@ -0,0 +1,74 @@
package weaver.xuanran.wang.shyl_mq.service;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.shyl_mq.mapper.ConsumerMapper;
import weaver.xuanran.wang.shyl_mq.service.interfaces.CRUDAction;
import weaver.zwl.common.ToolUtil;
import java.util.HashMap;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 13:04
*/
public abstract class CusInfoActionService implements CRUDAction {
protected final RecordSet recordSet = new RecordSet();
protected final Logger log = Util.getLogger();
/**
* <h2>consumer-mapper</h2>
**/
protected final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class);
protected ToolUtil toolUtil = new ToolUtil();
/**
* <h2>id</h2>
**/
protected String subId;
/**
* <h2>id</h2>
**/
private final int modelId;
// 默认初始化分部ID
{
subId = consumerMapper.getDefaultSubId();
modelId = Util.getIntValue(toolUtil.getSystemParamValue("mqLogModelId"),-1);
log.info(Util.logStr("subId : {}, modelId : {}", subId, modelId));
}
/**
* <h1>id</h1>
* @author xuanran.wang
* @dateTime 2023/01/03 10:50
* @return next id
**/
protected synchronized String getNextHrmId(){
recordSet.executeProc("HrmResourceMaxId_Get", "");
recordSet.next();
//新增的部门id
return Util.null2String(recordSet.getInt(1));
}
/**
* <h1>mqoa</h1>
* @author xuanran.wang
* @dateTime 2023/2/21 18:27
* @param messageId id
**/
protected void writeInOA(String messageId){
HashMap<String, Object> params = new HashMap<>();
params.put("messageId",messageId);
params.put("dealTime", TimeUtil.getCurrentTimeString());
log.info(Util.logStr("messageId : {}, consumer success!",messageId));
CusInfoToOAUtil.getDataId(modelId,params);
}
}

View File

@ -0,0 +1,78 @@
package weaver.xuanran.wang.shyl_mq.service;
import aiyh.utils.Util;
import aiyh.utils.httpUtil.util.HttpUtils;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.MapUtils;
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.common.util.CommonUtil;
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
import weaver.zwl.common.ToolUtil;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/1/4 14:54
*/
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();
{
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
}
/**
* <h1>mq</h1>
* @author xuanran.wang
* @dateTime 2023/1/18 10:22
* @param configName
* @param onlyMark
* @param requestId id
* @param tableName
**/
public void pushWorkFlowToMQ(String configName,
String onlyMark,
String requestId,
String tableName,
ChangeRequestParam changeRequestParam){
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, tableName);
logger.info("查询主表sql : " + selectMainSql);
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(selectMainSql, requestId);
Map<String, Object> requestParam = new HashMap<>();
if (recordSet.next()) {
dealWithMapping.setMainTable(tableName);
requestParam = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
}
if(MapUtils.isEmpty(requestParam)){
logger.error(Util.logStr("requestId: {}, 生成json为空!",requestId));
return;
}
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);
}
}
}

View File

@ -1,29 +1,37 @@
package weaver.xuanran.wang.shyl.mq.service.impl;
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.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.hrm.company.DepartmentComInfo;
import weaver.interfaces.hrm.HrmServiceManager;
import weaver.matrix.MatrixUtil;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
import weaver.xuanran.wang.shyl.mq.entity.Org;
import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
import weaver.xuanran.wang.shyl_mq.entity.Org;
import java.util.ArrayList;
import java.util.List;
/**
* <h1></h1>
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/12/30 15:05
*/
public class OrgServiceImpl extends CusInfoActionService {
private Logger logger = Util.getLogger("mq-consumer-org");
{
if(null == logger){
logger = Util.getLogger("mq-consumer-org");
}
}
/**
* <h1></h1>
@ -34,9 +42,11 @@ public class OrgServiceImpl extends CusInfoActionService {
**/
@Override
public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) {
int depId = 0;
try {
String content = message.getContent();
Org org = JSONObject.parseObject(content, Org.class);
logger.info(Util.logStr("orgCusCreateAction messageId: {},org : {} ",message.getId(), JSONObject.toJSONString(org)));
char separator = weaver.general.Util.getSeparator();
// 分部id
RecordSet insertRs = new RecordSet();
@ -48,11 +58,13 @@ public class OrgServiceImpl extends CusInfoActionService {
"" + separator + "" + separator + subId + separator + org.getSortIndex() + separator + "";
insertRs.executeProc("HrmDepartment_Insert", para);
if (insertRs.next()) {
int depId = insertRs.getInt(1);
depId = insertRs.getInt(1);
updateDepartmentInfo(String.valueOf(depId), subId, org);
}
writeInOA(message.getId());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}catch (Exception e){
consumerMapper.deleteDepartmentById(subId + "");
throw new CustomerException(Util.logStr("orgCreateAction error : {}", e.getMessage()), e);
}
}
@ -69,6 +81,7 @@ public class OrgServiceImpl extends CusInfoActionService {
try {
String content = message.getContent();
Org org = JSONObject.parseObject(content, Org.class);
logger.info(Util.logStr("orgCusDeleteAction messageId: {}, org : {} ",message.getId(),JSONObject.toJSONString(org)));
String id = org.getId();
if(StringUtils.isBlank(id)){
throw new CustomerException("userInfo id can not be empty!");
@ -77,6 +90,7 @@ public class OrgServiceImpl extends CusInfoActionService {
if (!success) {
throw new CustomerException(Util.logStr("update user status error!"));
}
writeInOA(message.getId());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}catch (Exception e){
throw new CustomerException(Util.logStr("orgDeleteAction execute error : [{}]!", e.getMessage()), e);
@ -95,13 +109,19 @@ public class OrgServiceImpl extends CusInfoActionService {
try {
String content = message.getContent();
Org org = JSONObject.parseObject(content, Org.class);
String outKey = org.getId();
logger.info(Util.logStr("orgCusUpdateAction messageId: {}, org : {} ",message.getId(), JSONObject.toJSONString(org)));
String outKey = Util.null2DefaultStr(org.getId(),"");
if(StringUtils.isBlank(outKey)){
throw new CustomerException("orgId can not null!");
}
// 分部待明确
String depId = consumerMapper.getDepIdByOutKey(outKey);
if(StringUtils.isBlank(depId)){
throw new CustomerException(Util.logStr("The department information data obtained by foreign key is empty!"));
logger.error(Util.logStr("The department information data obtained by foreign key is empty!"));
return cusCreateAction(message);
}
updateDepartmentInfo(depId, subId, org);
writeInOA(message.getId());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}catch (Exception e){
throw new CustomerException(Util.logStr("orgUpdateAction error : {}", e.getMessage()), e);
@ -123,7 +143,7 @@ public class OrgServiceImpl extends CusInfoActionService {
RecordSet updateRs = new RecordSet();
List<Object> params = initDepartParam(String.valueOf(depId), subId, org);
if (!updateRs.executeUpdate(insertSQL, params)) {
throw new CustomerException(Util.logStr("insert HrmDepartment error sql : {}, params : {}", insertSQL, JSONObject.toJSONString(params)));
throw new CustomerException(Util.logStr("insert HrmDepartment error sql : {}, params : {}", insertSQL, params));
}
DepartmentComInfo dci = new DepartmentComInfo();
//清除全部部门缓存
@ -161,16 +181,16 @@ public class OrgServiceImpl extends CusInfoActionService {
// 显示顺序
params.add(org.getSortIndex());
// 是否封存
params.add("0");
params.add(0);
// 部门标识
params.add(org.getOrgName());
// 部门名称
params.add(org.getOrgName());
String parentId = org.getParentId();
// 父级部门id
String supDepId = "";
if(StringUtils.isNotBlank(parentId)){
supDepId = consumerMapper.getDepIdByOutKey(parentId);
String supDepId = consumerMapper.getDepIdByOutKey(parentId);
if(StringUtils.isBlank(supDepId)){
supDepId = "1";
}
params.add(supDepId);
// 分部
@ -183,6 +203,6 @@ public class OrgServiceImpl extends CusInfoActionService {
@Override
public ConsumeConcurrentlyStatus cusPassWordAction(MQMessage message) {
return null;
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}

View File

@ -1,13 +1,14 @@
package weaver.xuanran.wang.shyl.mq.service.impl;
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.xuanran.wang.shyl.mq.entity.MQMessage;
import weaver.xuanran.wang.shyl.mq.entity.ModifyPassWord;
import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
import weaver.xuanran.wang.shyl_mq.entity.ModifyPassWord;
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
/**
* <h1></h1>
@ -16,14 +17,23 @@ import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
* @date 2023/1/3 16:07
*/
public class PassWordServiceImpl extends CusInfoActionService {
private Logger logger = Util.getLogger("mq-consumer-password");
{
if(null == logger){
logger = Util.getLogger("mq-consumer-password");
}
}
@Override
public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) {
return null;
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
@Override
public ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message) {
return null;
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
@Override
@ -31,14 +41,16 @@ public class PassWordServiceImpl extends CusInfoActionService {
try {
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!", 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) {
throw new CustomerException(Util.logStr("passWordAction execute error : [{}]!", e.getMessage()));
@ -47,6 +59,6 @@ public class PassWordServiceImpl extends CusInfoActionService {
@Override
public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
return null;
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.shyl.mq.service.impl;
package weaver.xuanran.wang.shyl_mq.service.impl;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
@ -6,24 +6,21 @@ import com.alibaba.fastjson.JSONObject;
import com.weaver.general.TimeUtil;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import weaver.conn.RecordSet;
import weaver.hrm.finance.SalaryManager;
import weaver.hrm.resource.ResourceComInfo;
import weaver.xiao.commons.utils.JsonResult;
import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
import weaver.xuanran.wang.shyl.mq.entity.UserInfo;
import weaver.xuanran.wang.shyl.mq.mapper.ConsumerMapper;
import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
import weaver.xuanran.wang.shyl_mq.constant.RocketMQConstant;
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
import weaver.xuanran.wang.shyl_mq.entity.UserInfo;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import static com.api.ecme.excel.HtmlLayoutOperate.user;
/**
* <h1></h1>
*
@ -31,7 +28,13 @@ import static com.api.ecme.excel.HtmlLayoutOperate.user;
* @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");
}
}
/**
* <h1></h1>
* @author xuanran.wang
@ -41,10 +44,15 @@ public class UserServiceImpl extends CusInfoActionService {
**/
@Override
public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) {
String nextHrmId = "";
try {
String content = message.getContent();
UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
String outKey = userInfo.getId();
logger.info(Util.logStr("userCusCreateAction messageId: {}, UserInfo : {} ",message.getId(), JSONObject.toJSONString(userInfo)));
String outKey = Util.null2DefaultStr(userInfo.getId(),"");
if(StringUtils.isBlank(outKey)){
throw new CustomerException("create user id can not null!");
}
String userId = consumerMapper.getHrmIdByOutKey(outKey);
// 如果存在就走更新
if(StringUtils.isNotBlank(userId)){
@ -60,10 +68,16 @@ public class UserServiceImpl extends CusInfoActionService {
// 通过外键获取部门信息数据为空
throw new CustomerException("The department information data obtained by foreign key is empty!");
}
String nextHrmId = getNextHrmId();
nextHrmId = getNextHrmId();
List<Object> params = initHrmParam(nextHrmId, userInfo, depInfoByOutKey);
String departmentId = Util.null2DefaultStr(depInfoByOutKey.get("departmentId"), "");
if(StringUtils.isBlank(departmentId)){
departmentId = Util.null2DefaultStr(depInfoByOutKey.get("DEPARTMENTID"), "");
}
String subCompanyId = Util.null2DefaultStr(depInfoByOutKey.get("subCompanyId"), "");
if(StringUtils.isBlank(subCompanyId)){
departmentId = Util.null2DefaultStr(depInfoByOutKey.get("SUBCOMPANYID"), "");
}
RecordSet insertRs = new RecordSet();
//使用sql新增人员
String insertSql = "insert into HrmResource(systemlanguage,workcode,departmentid,subcompanyid1," +
@ -93,11 +107,15 @@ public class UserServiceImpl extends CusInfoActionService {
String sql_10 = ("insert into HrmInfoStatus (itemid,hrmid) values(10," + nextHrmId + ")");
insertRs.execute(sql_10);
resourceComInfo.updateResourceInfoCache(nextHrmId);
writeInOA(message.getId());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}else {
throw new CustomerException(Util.logStr("insert HrmResource error sql : {}, params : {}", insertSql, JSONObject.toJSONString(params)));
}
}catch (Exception e){
if(StringUtils.isNotBlank(nextHrmId)){
consumerMapper.deleteHrmById(nextHrmId);
}
throw new CustomerException(Util.logStr("hrmCreateAction error : {}", e.getMessage()));
}
}
@ -114,14 +132,16 @@ public class UserServiceImpl extends CusInfoActionService {
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 = userInfo.getId();
if(StringUtils.isBlank(id)){
throw new CustomerException("userInfo id can not be empty!");
}
boolean success = consumerMapper.updateUserStatusByOutKey(id);
boolean success = consumerMapper.deleteHrmByOutKey(id);
if (!success) {
throw new CustomerException(Util.logStr("update user status error!"));
}
writeInOA(message.getId());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} catch (Exception e) {
throw new CustomerException(Util.logStr("hrmDeleteAction execute error : [{}]!", e.getMessage()));
@ -140,8 +160,9 @@ public class UserServiceImpl extends CusInfoActionService {
try {
String content = message.getContent();
UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
String userInfoId = userInfo.getId();
String userInfoDepartmentId = userInfo.getDepartmentId();
logger.info(Util.logStr("userCusUpdateAction messageId: {},UserInfo : {} ", message.getId(), JSONObject.toJSONString(userInfo)));
String userInfoId = Util.null2DefaultStr(userInfo.getId(),"");
String userInfoDepartmentId = Util.null2DefaultStr(userInfo.getDepartmentId(),"");
// 接口人员id
if(StringUtils.isBlank(userInfoId)){
throw new CustomerException("userInfo id can not be empty!");
@ -159,7 +180,8 @@ public class UserServiceImpl extends CusInfoActionService {
// oa人员id
String hrmId = consumerMapper.getHrmIdByOutKey(userInfoId);
if(StringUtils.isBlank(hrmId)){
throw new CustomerException(Util.logStr("userInfoId = [{}], No personnel information found in oa!", userInfoId));
logger.error(Util.logStr("userInfoId = [{}], No personnel information found in oa!", userInfoId));
return cusCreateAction(message);
}
//使用sql新增人员
String updateSql = "update HrmResource set systemlanguage = ?, workcode = ?, departmentid = ?, subcompanyid1 = ?," +
@ -173,9 +195,10 @@ public class UserServiceImpl extends CusInfoActionService {
ResourceComInfo resourceComInfo = new ResourceComInfo();
// 清空缓存
resourceComInfo.updateResourceInfoCache(hrmId);
writeInOA(message.getId());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}catch (Exception e){
throw new CustomerException(Util.logStr("hrmUpdateAction execute error : [{}]!", e.getMessage()));
throw new CustomerException(Util.logStr("userCusUpdateAction execute error : [{}]!", e.getMessage()));
}
}
@ -194,7 +217,13 @@ public class UserServiceImpl extends CusInfoActionService {
ArrayList<Object> params = new ArrayList<>();
String userName = Util.null2DefaultStr(userInfo.getUserName(), "");
String departmentId = Util.null2DefaultStr(depInfoByOutKey.get("departmentId"), "");
if(StringUtils.isBlank(departmentId)){
departmentId = Util.null2DefaultStr(depInfoByOutKey.get("DEPARTMENTID"), "");
}
String subCompanyId = Util.null2DefaultStr(depInfoByOutKey.get("subCompanyId"), "");
if(StringUtils.isBlank(subCompanyId)){
subCompanyId = Util.null2DefaultStr(depInfoByOutKey.get("SUBCOMPANYID"), "");
}
// 语言
params.add(7);
// 工号
@ -238,6 +267,6 @@ public class UserServiceImpl extends CusInfoActionService {
@Override
public ConsumeConcurrentlyStatus cusPassWordAction(MQMessage message) {
return null;
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}

View File

@ -0,0 +1,17 @@
package weaver.xuanran.wang.shyl_mq.service.interfaces;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
/**
* <h1>/ action</h1>
*
* @author xuanran.wang
* @date 2023/2/22 09:43
*/
public interface CRUDAction {
ConsumeConcurrentlyStatus cusCreateAction(MQMessage message);
ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message);
ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message);
ConsumeConcurrentlyStatus cusPassWordAction(MQMessage message);
}

View File

@ -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;
@ -18,14 +18,16 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingException;
import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.shyl_mq.RocketMQFactory;
import weaver.xuanran.wang.shyl_mq.constant.RocketMQConstant;
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
import weaver.xuanran.wang.shyl_mq.mapper.ConsumerMapper;
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
import weaver.zwl.common.ToolUtil;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* <h1>rocketMQ</h1>
@ -33,8 +35,18 @@ import java.util.Map;
* @Author xuanran.wang
* @Date 2022/12/29 21:03
*/
public class RocketUtil {
private static final Logger log = Util.getLogger();
public class RocketConsumerUtil {
private static Logger log = Util.getLogger("mq-util");
private static final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class);
private static final ToolUtil tool = new ToolUtil();
private static final int ERROR_LOG_ID;
static {
ERROR_LOG_ID = Util.getIntValue(tool.getSystemParamValue("mqErrorLogModelId"), -1);
if(log == null){
log = Util.getLogger("mq-util");
}
}
/**
* <h1></h1>
@ -70,52 +82,71 @@ public class RocketUtil {
public static ConsumeConcurrentlyStatus execute(List<MessageExt> msg, ConsumeConcurrentlyContext consumeConcurrentlyContext,
CusInfoActionService cusInfoActionService, String configName){
Map<String, Object> configMap = RocketMQFactory.CONFIG_MAPS.get(configName);
log.info(Util.logStr("{} service config is {}", configName, JSONObject.toJSONString(configMap)));
int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("MaxReconsumeTimes")),RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("MaxReconsumeTimes")), RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
MessageExt messageExt = null;
String msgBody = "";
String mqMessageId = "";
MQMessage mqMessage = null;
try {
if (CollectionUtils.isNotEmpty(msg)) {
MessageExt messageExt = msg.get(0);
String msgBody;
MQMessage mqMessage;
messageExt = msg.get(0);
if(Objects.isNull(messageExt)){
throw new CustomerException("messageExt is null!");
}
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));
// 业务类型
String actionType = mqMessage.getActionType();
switch (actionType){
case RocketMQConstant.CREATE_ACTION:{
return cusInfoActionService.cusCreateAction(mqMessage);
}
case RocketMQConstant.UPDATE_ACTION:{
return cusInfoActionService.cusUpdateAction(mqMessage);
}
case RocketMQConstant.DELETE_ACTION:{
return cusInfoActionService.cusDeleteAction(mqMessage);
}
case RocketMQConstant.PASSWORD_ACTION:{
return cusInfoActionService.cusPassWordAction(mqMessage);
}
default: throw new CustomerException(Util.logStr("current actionType : [{}] is not supported!", actionType));
if(Objects.isNull(mqMessage)){
throw new CustomerException("parseObject error!");
}
}catch (Exception e){
throw new CustomerException(Util.logStr("parse msgBody to Message error current msgBody is {}, the error is {}", msg, e.getMessage()));
throw new CustomerException(Util.logStr("parse msgBody to Message error current msgBody is {}, the error is {}", msgBody, e.getMessage()));
}
// 业务主体
String content = Util.null2DefaultStr(mqMessage.getContent(),"");
if(StringUtils.isBlank(content)){
throw new CustomerException(Util.logStr("the messageId : {}, content is empty! msgBody : {}", Util.null2DefaultStr(mqMessage.getId(), ""), msgBody));
}
mqMessageId = mqMessage.getId();
int mqLogByMessageId = consumerMapper.getMainIdFromMQLogByMessageId(mqMessageId);
if(mqLogByMessageId > 0){
log.error(Util.logStr("MQMessageId: {}, Already consumed!",mqMessageId));
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
// 业务类型
String actionType = mqMessage.getActionType();
switch (actionType){
case RocketMQConstant.CREATE_ACTION:{
return cusInfoActionService.cusCreateAction(mqMessage);
}
case RocketMQConstant.UPDATE_ACTION:{
return cusInfoActionService.cusUpdateAction(mqMessage);
}
case RocketMQConstant.DELETE_ACTION:{
return cusInfoActionService.cusDeleteAction(mqMessage);
}
case RocketMQConstant.PASSWORD_ACTION:{
return cusInfoActionService.cusPassWordAction(mqMessage);
}
default: throw new CustomerException(Util.logStr("current actionType : [{}] is not supported!", actionType));
}
}else {
log.error("the msgList is empty!");
}
} catch (Exception e) {
// 如果重试达到最大还是异常那么先返回成功 oa将错误日志记录到日志中
log.error(Util.logStr("msgId: {}, RocketUtil error: {}",mqMessageId, e.getMessage() ));
if (msg.get(0).getReconsumeTimes() == maxReconsumeTimes) {
//TODO
if(!Objects.isNull(mqMessage)){
mqMessage.setError(e.getMessage());
List<String> 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("MQ producer error already bigger maxReconsumeTimes! messageId : {}",mqMessageId));
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} else {
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
@ -130,8 +161,9 @@ public class RocketUtil {
* @dateTime 2023/1/4 14:30
* @param configName
* @param msg
* @param requestId id
**/
public static void producerSendMsg(String configName, String msg) {
public static void producerSendMsg(String configName, String msg, String requestId) {
// 先从本地缓存中获取生产者对象
DefaultMQProducer producer = RocketMQFactory.getMQProducer(configName);
// 获取配置信息
@ -142,7 +174,7 @@ public class RocketUtil {
String tag = Util.null2DefaultStr(configMap.get("Tag"), "");
Message message;
try {
message = new Message(topic, tag, msg.getBytes(RemotingHelper.DEFAULT_CHARSET));
message = new Message(topic, msg.getBytes(RemotingHelper.DEFAULT_CHARSET));
} catch (Exception e) {
throw new CustomerException(Util.logStr("init message error : {} !", e.getMessage()));
}
@ -156,8 +188,9 @@ public class RocketUtil {
try {
result = producer.send(message);
} catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) {
throw new CustomerException(Util.logStr("producer send message error!", e.getMessage()));
throw new CustomerException(Util.logStr("producer send message error!: {}", e.getMessage()));
}
log.info(Util.logStr("requestId: {}, result : {}",requestId, JSONObject.toJSONString(result)));
SendStatus sendStatus = result.getSendStatus();
// 如果失败
if (!SendStatus.SEND_OK.equals(sendStatus)) {
@ -165,11 +198,13 @@ public class RocketUtil {
log.error(error);
// 如果重试超过最大次数
if(count >= RocketMQConstant.SEND_MAX_COUNT){
throw new CustomerException(error);
throw new CustomerException(error + " and retry > max");
}
}else {
sendOk = true;
}
} while (!sendOk || count < RocketMQConstant.SEND_MAX_COUNT);
} while (!sendOk);
}
}

View File

@ -1,4 +1,4 @@
ConsumerGroup=weaver-car
NameServer=183.192.65.118:9876
NameServer=114.115.168.220:9876
Topic=OA_CAR_TOPIC
Tag=*

View File

@ -1,4 +1,4 @@
ConsumerGroup=weaver-meal
NameServer=183.192.65.118:9876
NameServer=114.115.168.220:9876
Topic=OA_MEAL_TOPIC
Tag=*

View File

@ -1,4 +1,5 @@
ConsumerGroup=weaver-meeting
NameServer=183.192.65.118:9876
NameServer=114.115.168.220:9876
#114.115.168.220:9876
Topic=OA_MEETING_TOPIC
Tag=*

View File

@ -1,4 +1,4 @@
ConsumerGroup=weaver-visitor
NameServer=183.192.65.118:9876
NameServer=114.115.168.220:9876
Topic=OA_VISITOR_TOPIC
Tag=*

View File

@ -1,4 +1,4 @@
ConsumerGroup=weaver-org
NameServer=183.192.65.118:9876
NameServer=114.115.168.220:9876
Topic=AUTH_CONSOLE_ORG_TOPIC
Tag=*

View File

@ -1,4 +1,4 @@
ConsumerGroup=weaver-password
NameServer=183.192.65.118:9876
NameServer=114.115.168.220:9876
Topic=AUTH_CONSOLE_USERINFO_PASSWORD_TOPIC
Tag=*

View File

@ -1,4 +1,4 @@
ConsumerGroup=weaver-userinfo
NameServer=183.192.65.118:9876
NameServer=114.115.168.220:9876
Topic=AUTH_CONSOLE_USERINFO_TOPIC
Tag=*

View File

@ -0,0 +1,3 @@
1=1212
2=212
#2=21

View File

@ -0,0 +1,45 @@
package xuanran.wang.bme;
import aiyh.utils.Util;
import basetest.BaseTest;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import weaver.conn.RecordSet;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/2/21 14:04
*/
public class PushDataActionTest extends BaseTest {
private final DealWithMapping dealWithMapping = new DealWithMapping();
@Test
public void testA(){
String onlyMark = "listTest";
String tableName = "formtable_main_22";
String requestId = "55065";
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
dealWithMapping.setMainTable(tableName);
String cusWhere = Util.null2DefaultStr(requestMappingConfig.getCusWhereSql(), "");
if (StringUtils.isNotBlank(cusWhere)) {
cusWhere = DealWithMapping.sbc2dbcCase(cusWhere); // 全角转半角
}
String url = requestMappingConfig.getRequestUrl();
String selectMainSql = "select * from " + tableName + " where requestid = ? " + cusWhere;
log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId));
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(selectMainSql, requestId);
recordSet.next();
List<Object> requestListParam = dealWithMapping.getRequestListParam(recordSet, requestMappingConfig);
log.info("list : " + requestListParam);
}
}

View File

@ -0,0 +1,16 @@
package xuanran.wang.http_test.annotations;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 17:00
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
@Documented
public @interface CusPathQuery {
String value();
}

View File

@ -0,0 +1,15 @@
package xuanran.wang.http_test.annotations;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:46
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
public @interface CusRequest {
}

View File

@ -0,0 +1,19 @@
package xuanran.wang.http_test.annotations;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:18
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
public @interface CusRequestAddress {
// ip地址
String host() default "";
// 端口号
int port() default 0;
}

View File

@ -0,0 +1,15 @@
package xuanran.wang.http_test.annotations;
import java.lang.annotation.*;
/**
* <h1> map, </h1>
*
* @author xuanran.wang
* @date 2023/3/10 13:06
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@Documented
public @interface GetPathValue {
}

View File

@ -0,0 +1,15 @@
package xuanran.wang.http_test.annotations;
import java.lang.annotation.*;
/**
* <h1>post</h1>
*
* @author xuanran.wang
* @date 2023/3/10 13:48
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@Documented
public @interface PostBody {
}

View File

@ -0,0 +1,15 @@
package xuanran.wang.http_test.annotations.async;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 14:17
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@Documented
public @interface AsyncFun {
}

View File

@ -0,0 +1,17 @@
package xuanran.wang.http_test.annotations.async;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:13
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface CusAsync {
// <h2>是否开启异步 默认为false</h2>
boolean enable() default false;
}

View File

@ -0,0 +1,21 @@
package xuanran.wang.http_test.annotations.header;
import java.lang.annotation.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 14:20
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD,ElementType.TYPE})
@Documented
public @interface CusRequestHeader {
// 自定义请求头java文件全路径
String cusHeadersClassPath() default "";
// 自定义请求头
String[] cusHeaders() default {};
// 自定义请求头标识
String value() default "";
}

View File

@ -0,0 +1,24 @@
package xuanran.wang.http_test.annotations.request_path;
import java.lang.annotation.*;
/**
* <h1>
*
* /api/test/{job} {job} key
* map
* /api/test/${job} $ &map
* </h1>
*
* @author xuanran.wang
* @date 2023/3/14 22:50
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface CusPathQuery {
/**
* <h2>key</h2>
**/
String value() default "";
}

View File

@ -0,0 +1,16 @@
package xuanran.wang.http_test.annotations.request_type;
import java.lang.annotation.*;
/**
* <h1>delete </h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:17
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface CusRequestDelete {
String url() default "";
}

View File

@ -0,0 +1,16 @@
package xuanran.wang.http_test.annotations.request_type;
import java.lang.annotation.*;
/**
* <h1>get </h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:15
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface CusRequestGet{
String url() default "";
}

View File

@ -0,0 +1,16 @@
package xuanran.wang.http_test.annotations.request_type;
import java.lang.annotation.*;
/**
* <h1>post </h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:17
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface CusRequestPost {
String url() default "";
}

View File

@ -0,0 +1,16 @@
package xuanran.wang.http_test.annotations.request_type;
import java.lang.annotation.*;
/**
* <h1>put </h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:18
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface CusRequestPut {
String url() default "";
}

View File

@ -0,0 +1,15 @@
package xuanran.wang.http_test.constant;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 14:01
*/
public class RequestUtilConstant {
public static final int GET = 0;
public static final int POST = 1;
public static final int DELETE = 2;
public static final int PUT = 3;
public static final int HEADER = -1;
}

View File

@ -0,0 +1,29 @@
package xuanran.wang.http_test.entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Map;
import java.util.function.Consumer;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/14 23:28
*/
@AllArgsConstructor
@NoArgsConstructor
@Setter
@Getter
public class CusRequestEntity{
private String url;
private Map<String, String> headers;
private Map<String, String> pathParams;
private Object bodyParams;
private int requestType;
private Consumer<Object> consumer;
private boolean async;
}

View File

@ -0,0 +1,35 @@
//package xuanran.wang.http_test.handle;
//
//import com.alibaba.fastjson.JSONObject;
//import xuanran.wang.http_test.annotations.PostBody;
//
//import java.lang.reflect.Method;
//import java.lang.reflect.Parameter;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * <h1>post方法解析</h1>
// *
// * @author xuanran.wang
// * @date 2023/3/10 13:54
// */
//public class PostTypeHandle implements RequestBeforeHandle {
// @Override
// public Map handle(String url, Method method, Object[] args) {
// Parameter[] parameters = method.getParameters();
// for (int i = 0; i < parameters.length; i++) {
// PostBody postBody = parameters[i].getDeclaredAnnotation(PostBody.class);
// if(postBody != null){
// Object arg = args[i];
// if(arg instanceof Map){
// return (Map<String, String>) arg;
// }else if(arg instanceof String){
// String json = JSONObject.toJSONString(arg);
// return JSONObject.parseObject(json, Map.class);
// }
// }
// }
// return new HashMap();
// }
//}

View File

@ -0,0 +1,15 @@
package xuanran.wang.http_test.handle;
import xuanran.wang.http_test.entity.CusRequestEntity;
import java.lang.reflect.Method;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 11:38
*/
public interface RequestBeforeHandle {
void handle(CusRequestEntity requestEntity, Method method, Object[] args);
}

View File

@ -0,0 +1,81 @@
//package xuanran.wang.http_test.handle;
//
//import aiyh.utils.Util;
//import aiyh.utils.excention.CustomerException;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.commons.collections.MapUtils;
//import org.apache.commons.lang3.StringUtils;
//import xuanran.wang.http_test.annotations.header.CusRequestHeader;
//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;
//
///**
// * <h1>请求头处理</h1>
// *
// * @author xuanran.wang
// * @date 2023/3/10 14:42
// */
//public class RequestHeaderHandle implements RequestBeforeHandle {
// @Override
// public Object handle(String url, Method method, Object[] args) {
// CusRequestHeader methodCusRequestHeader = method.getDeclaredAnnotation(CusRequestHeader.class);
// if(methodCusRequestHeader == null){
// return new HashMap<>();
// }
// // 数组形式
// String[] headersArr = methodCusRequestHeader.cusHeaders();
// HashMap<String, String> 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(!clazz.isAssignableFrom(CusCreateRequestHeader.class)){
// 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<String, String> 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);
// }
// }
// }
// return headers;
// }
//}

View File

@ -0,0 +1,43 @@
package xuanran.wang.http_test.handle.path_handle;
import aiyh.utils.Util;
import org.apache.commons.lang3.StringUtils;
import xuanran.wang.http_test.annotations.CusPathQuery;
import xuanran.wang.http_test.entity.CusRequestEntity;
import xuanran.wang.http_test.handle.RequestBeforeHandle;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Map;
/**
* <h1> key</h1>
*
* @author xuanran.wang
* @date 2023/3/14 23:11
*/
public class CusFieldKeyParseHandle implements RequestBeforeHandle {
@Override
public void handle(CusRequestEntity requestEntity, Method method, Object[] args) {
Parameter[] parameters = method.getParameters();
String url = requestEntity.getUrl();
for (int i = 0; i < parameters.length; i++) {
Parameter parameter = parameters[i];
CusPathQuery cusPathQuery = parameter.getDeclaredAnnotation(CusPathQuery.class);
if(cusPathQuery != null){
String pathQuery = cusPathQuery.value();
Object arg = args[i];
if (StringUtils.isNotBlank(pathQuery)) {
String key = "\\{" + pathQuery + "}";
url = url.replaceAll(key, Util.null2DefaultStr(arg,""));
}else {
Class<?> clazz = parameter.getType();
if(clazz.isAssignableFrom(Map.class)){
requestEntity.setPathParams((Map<String, String>) arg);
}
}
}
}
requestEntity.setUrl(url);
}
}

View File

@ -0,0 +1,13 @@
package xuanran.wang.http_test.interfaces;
import java.util.Map;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 16:33
*/
public interface CusCreateRequestHeader {
Map<String, String> createHeader();
}

View File

@ -0,0 +1,17 @@
package xuanran.wang.http_test.proxy;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 12:44
*/
public class CusUtil {
private static final RequestUtil requestUtil = new RequestUtil();
public static <T> T getRequestClient(Class<T> t) {
return requestUtil.getRequestClient(t);
}
}

View File

@ -0,0 +1,92 @@
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 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.entity.CusRequestEntity;
import xuanran.wang.http_test.handle.*;
import xuanran.wang.http_test.handle.path_handle.CusFieldKeyParseHandle;
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;
/**
* <h1>http</h1>
*
* @author xuanran.wang
* @date 2023/3/10 10:35
*/
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;
public <T> T getRequestClient(Class<?> clazz){
Annotation annotation = clazz.getDeclaredAnnotation(CusRequest.class);
if(annotation == null){
throw new CustomerException("该类未添加CusRequest注解!");
}
cusRequestAddress = clazz.getDeclaredAnnotation(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());
}
CusFieldKeyParseHandle keyParseHandle = new CusFieldKeyParseHandle();
keyParseHandle.handle(cusRequest, method, args);
log.info("cusRequest : \n" + JSONObject.toJSONString(cusRequest));
return "";
}
private String appendPath(StringBuilder url, String path){
if(!path.endsWith("/")){
url.append("/");
}
url.append(path);
return url.toString();
}
public Object get(String url, Map<String, Object> params, Map<String , String> 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;
}
}
}

View File

@ -0,0 +1,32 @@
package xuanran.wang.http_test.service;
import aiyh.utils.httpUtil.ResponeVo;
import xuanran.wang.http_test.annotations.*;
import xuanran.wang.http_test.annotations.header.CusRequestHeader;
import xuanran.wang.http_test.annotations.request_type.CusRequestGet;
import xuanran.wang.http_test.annotations.request_type.CusRequestPost;
import java.util.Map;
/**
* <h1></h1>
*
* @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)
public interface TestService {
@CusRequestGet(url = "educate-plat/api/v1/class/getClassList/{test}")
@CusRequestHeader(cusHeaders = {"sa: sasa", "sas:11212"})
String getStu(Map<String, Object> path,
@PostBody Map<String, Object> 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<String, Object> body);
}

View File

@ -0,0 +1,41 @@
package xuanran.wang.http_test.test;
import aiyh.utils.httpUtil.ResponeVo;
import basetest.BaseTest;
import org.junit.Test;
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;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/10 12:42
*/
public class RequestTest extends BaseTest {
private TestService requestClient = CusUtil.getRequestClient(TestService.class);
@Test
public void test(){
HashMap<String, Object> map = new HashMap<>();
map.put("a","1");
map.put("b","2");
HashMap<String, Object> body = new HashMap<>();
body.put("a","3");
body.put("b","4");
HashMap<String, String> path = new HashMap<>();
path.put("e","5");
path.put("f","6");
requestClient.getStu(map, body, "a", "test1111");
// String stu1 = requestClient.getStu(body);
}
}

View File

@ -2,19 +2,46 @@ package xuanran.wang.shyl.dataasync;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.util.HttpUtils;
import basetest.BaseTest;
import cfca.sadk.org.bouncycastle.jcajce.provider.digest.SHA1;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.shyl.entity.MQMessage;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.junit.Test;
import weaver.xuanran.wang.common.annocation.SqlFieldMapping;
import weaver.xuanran.wang.common.annocation.SqlUpdateWhereField;
import weaver.xuanran.wang.shyl.dataasync.entity.StudentClass;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.security.acl.LastOwnerException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import weaver.xuanran.wang.shyl_mq.RocketMQFactory;
import weaver.xuanran.wang.shyl_mq.consumer.OrgConsumer;
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* <h1></h1>
*
@ -24,7 +51,8 @@ import java.util.*;
public class AsyncTest extends BaseTest {
@Test
public void testExecuteBatchByEntity(){
public void testExecuteBatchByEntity() {
HttpUtils httpUtils = new HttpUtils();
String json = "{\n" +
"\t\"msg\": \"success\",\n" +
"\t\"code\": 0,\n" +
@ -47,7 +75,7 @@ public class AsyncTest extends BaseTest {
List<LinkedHashMap<String, Object>> params = new ArrayList<>();
List<List<String>> whereParams = new ArrayList<>();
for (Object o : list) {
if(Objects.isNull(o)){
if (Objects.isNull(o)) {
continue;
}
Class<?> clazz = o.getClass();
@ -64,23 +92,23 @@ public class AsyncTest extends BaseTest {
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)){
if (Objects.isNull(fieldValue)) {
continue;
}
// 数据库字段映射 如果注解中没有值那么写入数据库就是实体类字段名
SqlFieldMapping sqlFieldMapping = field.getAnnotation(SqlFieldMapping.class);
if(null == sqlFieldMapping){
if (null == sqlFieldMapping) {
continue;
}
String sqlFieldMappingValue = sqlFieldMapping.value();
if(StringUtils.isNotBlank(sqlFieldMappingValue)){
if (StringUtils.isNotBlank(sqlFieldMappingValue)) {
fieldName = sqlFieldMappingValue;
}
linkedHashMap.put(fieldName, fieldValue);
// 更新条件字段注解
SqlUpdateWhereField sqlUpdateWhereField = field.getAnnotation(SqlUpdateWhereField.class);
if(null == sqlUpdateWhereField || !sqlUpdateWhereField.value()){
if (null == sqlUpdateWhereField || !sqlUpdateWhereField.value()) {
continue;
}
whereParam.add(fieldValue.toString());
@ -91,4 +119,281 @@ public class AsyncTest extends BaseTest {
log.info("params : " + JSONObject.toJSONString(params));
log.info("wheres : " + whereParams);
}
@Test
public void testSql() {
String json = "[{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"}],\"workflowId\":\"451\"}]";
JSONArray temp = new JSONArray();
JSONArray arr = JSONObject.parseObject(json, JSONArray.class);
for (int i = 0; i < arr.size() - 1; i++) {
for (int j = 0; j < 25; j++) {
Object o = arr.get(i);
JSONObject object = JSONObject.parseObject(o.toString());
temp.add(object);
}
}
JSONArray arrr = new JSONArray();
for (Object o : temp) {
JSONObject object = JSONObject.parseObject(o.toString());
List mainData = (List)object.get("mainData");
JSONObject jsonObject = new JSONObject();
jsonObject.put("fieldName","customId");
jsonObject.put("fieldValue",UUID.randomUUID().toString());
mainData.add(jsonObject);
object.put("mainData", mainData);
arrr.add(object);
}
arr.addAll(arrr);
log.info("json arr size " + arr.size());
log.info("arr : \n" + JSONObject.toJSONString(arr));
// try {
// List<String> s = batchCreateWorkflowService.batchCreateWorkflow2(arr);
// log.info("创建流程接口返回 " + s);
// } catch (Exception e) {
// log.error("创建流程失败 ! " + e.getMessage());
// }
}
@Test
public void testC() {
try {
// 声明一个消费者consumer需要传入一个组 weaver-consumer
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("weaver-consumer");
// 设置集群的NameServer地址多个地址之间以分号分隔 183.192.65.118:9876
consumer.setNamesrvAddr("114.115.168.220:9876");
// 设置consumer的消费策略
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
// 集群模式消费,广播消费不会重试
consumer.setMessageModel(MessageModel.CLUSTERING);
// 设置最大重试次数默认是16次
consumer.setMaxReconsumeTimes(1);
// 设置consumer所订阅的Topic和Tag*代表全部的Tag AUTH_CONSOLE_USERINFO_TOPIC
consumer.subscribe("AUTH_CONSOLE_ORG_TOPIC", "*");
consumer.setVipChannelEnabled(false);
// Listener主要进行消息的逻辑处理,监听topic如果有消息就会立即去消费
consumer.registerMessageListener(new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> 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());
}
}
});
consumer.start();
} catch (Exception e) {
log.error(" e => " + e.getMessage());
}
}
@Test
public void testD() throws UnsupportedEncodingException, MQBrokerException, RemotingException, InterruptedException, MQClientException {
String msg = "{\n" +
"\t\"actionType\": \"CREATE_ACTION\",\n" +
"\t\"topic\": \"OA_MEETING_TOPIC\",\n" +
"\t\"id\": \"29039\",\n" +
"\t\"content\": {\n" +
"\t\t\"sourceId\": \"29050\",\n" +
"\t\t\"mrtype\": \"2\",\n" +
"\t\t\"EndTime\": \"17:10\",\n" +
"\t\t\"meetingStatus\": \"1\",\n" +
"\t\t\"BeginTime\": \"17:36\",\n" +
"\t\t\"meetingTitle\": \"MQ测试20230223\",\n" +
"\t\t\"roomCode\": \"青年会堂会议室\",\n" +
"\t\t\"signCode\": \"\",\n" +
"\t\t\"EndDate\": \"2023-02-24\",\n" +
"\t\t\"BeginDate\": \"2023-02-23\",\n" +
"\t\t\"meetingHost\": \"96\",\n" +
"\t\t\"userList\": \"96\",\n" +
"\t\t\"meetingContent\": \"测试MQ20230223\"\n" +
"\t},\n" +
"\t\"sendTime\": \"2023-02-23 17:49:11\"\n" +
"}";
RocketConsumerUtil.producerSendMsg("OAMeeting", msg,"");
// 先从本地缓存中获取生产者对象
}
@Test
public void testE() {
DefaultMQPushConsumer consumer = null;
log.info(Util.logStr("---- consumer : {} initialized start ----", "OrgConsumer"));
try {
try {
// 根据配置文件初始化一个consumer对象
consumer = RocketMQFactory.getMQPushConsumer("OrgConsumer", new OrgConsumer().service());
} catch (Exception e) {
throw new CustomerException(Util.logStr("the consumer init exception : {}", e.getMessage()));
}
try {
// 调用start()方法启动consumer
consumer.start();
} catch (Exception e) {
throw new CustomerException(Util.logStr("the consumer start exception : {}", e.getMessage()));
}
log.info(Util.logStr("---- consumer : {} initialized end ----", "OrgConsumer"));
} catch (Exception e) {
log.info(Util.logStr("---- consumer : {} initialized error ----", "OrgConsumer"));
log.error(Util.getErrString(e));
}
}
private static final Map<String, String> SYSTEM_CACHE = new HashMap<>();
/**
* ecology(appid)
*/
private static final String APPID = "JYZ";
@Test
public void testB() {
String json = "[{\n" +
"\t\"requestName\": \"你个沙雕32323\",\n" +
"\t\"workflowId\": \"45\",\n" +
"\t\"mainData\": [{\n" +
"\t\t\"fieldName\": \"yysy\",\n" +
"\t\t\"fieldValue\": \"测试20230309\"\n" +
"\t}]\n" +
"}, {\n" +
"\t\"requestName\": \"沙雕2号\",\n" +
"\t\"workflowId\": \"45\",\n" +
"\t\"mainData\": [{\n" +
"\t\t\"fieldName\": \"yysy\",\n" +
"\t\t\"fieldValue\": \"沙雕沙雕沙雕沙雕沙雕\"\n" +
"\t}]\n" +
"}, {\n" +
"\t\"requestName\": \"沙雕2号\",\n" +
"\t\"workflowId\": \"451\",\n" +
"\t\"mainData\": [{\n" +
"\t\t\"fieldName\": \"yysy\",\n" +
"\t\t\"fieldValue\": \"沙雕沙雕沙雕沙雕沙雕\"\n" +
"\t}]\n" +
"}]";
testRestful("http://183.192.65.115:8080", "/api/wxr/shyl/workflow/batchCreate233", json);
}
/**
*
* <p>
* ecology,appid,Secret
*/
public static Map<String, Object> testRegist(String address) {
//获取当前系统RSA加密的公钥
RSA rsa = new RSA();
String publicKey = rsa.getPublicKeyBase64();
String privateKey = rsa.getPrivateKeyBase64();
// 客户端RSA私钥
SYSTEM_CACHE.put("LOCAL_PRIVATE_KEY", privateKey);
// 客户端RSA公钥
SYSTEM_CACHE.put("LOCAL_PUBLIC_KEY", publicKey);
//调用ECOLOGY系统接口进行注册
String data = HttpRequest.post(address + "/api/ec/dev/auth/regist")
.header("appid", APPID)
.header("cpk", publicKey)
.timeout(2000)
.execute().body();
// 打印ECOLOGY响应信息
System.out.println("testRegist()" + data);
Map<String, Object> datas = JSONUtil.parseObj(data);
//ECOLOGY返回的系统公钥
SYSTEM_CACHE.put("SERVER_PUBLIC_KEY", StrUtil.nullToEmpty((String) datas.get("spk")));
//ECOLOGY返回的系统密钥
SYSTEM_CACHE.put("SERVER_SECRET", StrUtil.nullToEmpty((String) datas.get("secrit")));
return datas;
}
/**
*
* <p>
* token
*/
public static Map<String, Object> testGetoken(String address) {
// 从系统缓存或者数据库中获取ECOLOGY系统公钥和Secret信息
String secret = SYSTEM_CACHE.get("SERVER_SECRET");
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
// 如果为空,说明还未进行注册,调用注册接口进行注册认证与数据更新
if (Objects.isNull(secret) || Objects.isNull(spk)) {
testRegist(address);
// 重新获取最新ECOLOGY系统公钥和Secret信息
secret = SYSTEM_CACHE.get("SERVER_SECRET");
spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
}
// 公钥加密,所以RSA对象私钥为null
RSA rsa = new RSA(null, spk);
//对秘钥进行加密传输,防止篡改数据
String encryptSecret = rsa.encryptBase64(secret, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
//调用ECOLOGY系统接口进行注册
String data = HttpRequest.post(address + "/api/ec/dev/auth/applytoken")
.header("appid", APPID)
.header("secret", encryptSecret)
.header("time", "3600")
.execute().body();
System.out.println("testGetoken()" + data);
Map<String, Object> datas = JSONUtil.parseObj(data);
//ECOLOGY返回的token
// TODO 为Token缓存设置过期时间
SYSTEM_CACHE.put("SERVER_TOKEN", StrUtil.nullToEmpty((String) datas.get("token")));
return datas;
}
/**
*
* <p>
* ecologyresttoken
*
* @param address ecology
* @param api rest api (GET)
* @param jsonParams json
* <p>
* ECOLOGYPOST "Content-Type","application/x-www-form-urlencoded; charset=utf-8"
*/
public String testRestful(String address, String api, String jsonParams) {
//ECOLOGY返回的token
String token = SYSTEM_CACHE.get("SERVER_TOKEN");
if (StrUtil.isEmpty(token)) {
token = (String) testGetoken(address).get("token");
}
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
//封装请求头参数
RSA rsa = new RSA(null, spk);
//对用户信息进行加密传输,暂仅支持传输OA用户ID
String encryptUserid = rsa.encryptBase64("1", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
List list = JSONObject.parseObject(jsonParams, List.class);
HttpUtils httpUtils = new HttpUtils();
HashMap<String, String> headers = new HashMap<>();
headers.put("appid", APPID);
headers.put("token", token);
headers.put("userid", encryptUserid);
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
log.info("请求头 = > " + headers);
// try {
// ResponeVo responeVo = httpUtils.apiPostObject(address + api, list, headers);
// log.info("reslut => " + JSONObject.toJSON(responeVo));
// } catch (Exception e) {
// log.error("e => " + e.getMessage());
// }
return "";
}
@Test
public void testF() {
Map<String, Object> test = Util.getProperties2Map("test");
log.info("test => " + JSONObject.toJSONString(test));
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,49 @@
package xuanran.wang.shyl.dataasync;
import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject;
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.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;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/3/1 15:58
*/
public class MapperTest extends BaseTest {
private final MeetingService meetingService = new MeetingService();
@Test
public void testA(){
List<MeetingCusFieldConfigMain> meetingFieldCusConfig = meetingService.getMeetingFieldCusConfig();
log.info("config : " + JSONObject.toJSONString(meetingFieldCusConfig));
}
@Test
public void testB(){
Map<String, Object> dalou = FieldUtil.getFormItemForSelect("dalou", "大楼", "1213", 2, new ArrayList<>());
log.info("大楼 : " + dalou);
Map var70 = FieldUtil.getFormItemForInputNumber("shuliang", "数量", String.valueOf(131), -999, 999, 2);
log.info("数量 : " + var70);
Map<String, Object> formItemForInput = FieldUtil.getFormItemForInput("shuliang", "数量", String.valueOf(131), 2);
log.info("formItemForInput : " + formItemForInput);
}
@Test
public void testC(){
String s = TimeUtil.dateAdd("2023-03-02", -3);
log.info("time => " + s);
}
}

View File

@ -100,4 +100,5 @@ public class WacoFirstTest extends BaseTest {
}
}

Some files were not shown because too many files have changed in this diff Show More