From af939631b4dceebc9e0dd539a1ac825967077db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=A3=E7=84=B6?= Date: Wed, 15 Mar 2023 13:50:48 +0800 Subject: [PATCH] =?UTF-8?q?2023-03-15=20=E5=9B=A2=E6=A0=A1mq=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xuanran.wang/bme/js/BuildContractApply.js | 2 + javascript/xuanran.wang/bme/js/Common.js | 16 + .../xuanran.wang/bme/js/InventFileFirst.js | 31 ++ javascript/xuanran.wang/bme/js/PayApply.js | 32 ++ .../xuanran.wang/bme/js/ProDataConfirm.js | 217 ++++++++++++ .../bme/js/PurchaseContractApply.js | 3 + .../xuanran.wang/bme/js/SaleContractApply.js | 1 + .../BatchCreateWorkFlowController.java | 91 +++++ .../shyl/controller/CarToMQController.java | 37 ++ .../shyl/controller/GetStudentsClass.java | 48 +++ .../shyl/controller/MeetingController.java | 63 ++++ .../wang/shyl/entity/CusCreateWfInfo.java | 17 + .../xuanran/wang/shyl}/entity/MQMessage.java | 4 +- .../wang/shyl/entity/ProducerCarInfo.java | 111 ++++++ .../meeting/MeetingCusFieldConfigDetail.java | 18 + .../meeting/MeetingCusFieldConfigMain.java | 23 ++ .../wang/shyl/mapper/MeetingMapper.java | 61 ++++ .../wang/shyl/mapper/ProducerMapper.java | 33 ++ .../service/BatchCreateWorkflowService.java | 195 +++++++++++ .../xuanran/wang/shyl/service/CarService.java | 111 ++++++ .../wang/shyl/service/MeetingService.java | 78 +++++ .../wang/shyl/service/StudentsService.java | 59 ++++ .../api/xuanran/wang/shyl/vo/CreateWfVO.java | 15 + .../impl/MeetingRoomAddCusAopService.java | 88 +++++ .../impl/MeetingRoomEditCusAopService.java | 41 +++ .../impl/MeetingRoomLookCusAopService.java | 123 +++++++ .../action/ContractApplyComDateAction.java | 148 ++++++-- .../bme/action/CusCreateWaterNoAction.java | 7 + .../wang/bme/action/TransOrderApproval.java | 36 ++ .../wang/bme/action/UpdateModelInfo.java | 190 +++++++++++ .../wang/bme/service/PushDataService.java | 95 ++++++ .../common/annocation/Map2JSONConvert.java | 25 ++ .../wang/common/mapper/CommonMapper.java | 55 +++ .../xuanran/wang/common/util/CommonUtil.java | 37 ++ .../shyl/dataasync/job/CusDataAsyncJob.java | 69 +--- .../service/CusDataAsyncService.java | 29 +- .../wang/shyl/mq/action/ProducerAction.java | 44 --- .../shyl/mq/service/CusInfoActionService.java | 49 --- .../wang/shyl/mq/service/ProducerService.java | 49 --- .../mq/service/interfaces/CreateAction.java | 14 - .../mq/service/interfaces/DeleteAction.java | 14 - .../mq/service/interfaces/PassWordAction.java | 14 - .../mq/service/interfaces/UpdateAction.java | 14 - .../RocketMQConsumerListener.java | 3 +- .../{shyl/mq => shyl_mq}/RocketMQFactory.java | 17 +- .../wang/shyl_mq/action/ProducerAction.java | 47 +++ .../constant/RocketMQConstant.java | 4 +- .../mq => shyl_mq}/consumer/OrgConsumer.java | 10 +- .../consumer/PassWordConsumer.java | 11 +- .../consumer/UserInfoConsumer.java | 10 +- .../wang/shyl_mq/entity/MQMessage.java | 53 +++ .../mq => shyl_mq}/entity/ModifyPassWord.java | 2 +- .../wang/{shyl/mq => shyl_mq}/entity/Org.java | 2 +- .../{shyl/mq => shyl_mq}/entity/UserInfo.java | 2 +- .../mq => shyl_mq}/mapper/ConsumerMapper.java | 49 ++- .../shyl_mq/service/ChangeRequestParam.java | 17 + .../shyl_mq/service/CusInfoActionService.java | 74 ++++ .../wang/shyl_mq/service/ProducerService.java | 78 +++++ .../service/impl/OrgServiceImpl.java | 48 ++- .../service/impl/PassWordServiceImpl.java | 28 +- .../service/impl/UserServiceImpl.java | 63 +++- .../service/interfaces/CRUDAction.java | 17 + .../util/RocketConsumerUtil.java} | 123 ++++--- .../WEB-INF/prop/prop2map/OACar.properties | 2 +- .../WEB-INF/prop/prop2map/OAMeal.properties | 2 +- .../prop/prop2map/OAMeeting.properties | 3 +- .../prop/prop2map/OAVisitor.properties | 2 +- .../prop/prop2map/OrgConsumer.properties | 2 +- .../prop/prop2map/PassWordConsumer.properties | 2 +- .../prop/prop2map/UserInfoConsumer.properties | 2 +- .../WEB-INF/prop/prop2map/test.properties | 3 + .../xuanran/wang/bme/PushDataActionTest.java | 45 +++ .../http_test/annotations/CusPathQuery.java | 16 + .../http_test/annotations/CusRequest.java | 15 + .../annotations/CusRequestAddress.java | 19 ++ .../http_test/annotations/GetPathValue.java | 15 + .../wang/http_test/annotations/PostBody.java | 15 + .../http_test/annotations/async/AsyncFun.java | 15 + .../http_test/annotations/async/CusAsync.java | 17 + .../annotations/header/CusRequestHeader.java | 21 ++ .../request_path/CusPathQuery.java | 24 ++ .../request_type/CusRequestDelete.java | 16 + .../request_type/CusRequestGet.java | 16 + .../request_type/CusRequestPost.java | 16 + .../request_type/CusRequestPut.java | 16 + .../constant/RequestUtilConstant.java | 15 + .../http_test/entity/CusRequestEntity.java | 29 ++ .../wang/http_test/handle/PostTypeHandle.java | 35 ++ .../http_test/handle/RequestBeforeHandle.java | 15 + .../http_test/handle/RequestHeaderHandle.java | 81 +++++ .../path_handle/CusFieldKeyParseHandle.java | 43 +++ .../interfaces/CusCreateRequestHeader.java | 13 + .../xuanran/wang/http_test/proxy/CusUtil.java | 17 + .../wang/http_test/proxy/RequestUtil.java | 92 +++++ .../wang/http_test/service/TestService.java | 32 ++ .../wang/http_test/test/RequestTest.java | 41 +++ .../wang/shyl/dataasync/AsyncTest.java | 321 +++++++++++++++++- .../shyl/dataasync/CreateWorkflowTest.java | 192 +++++++++++ .../wang/shyl/dataasync/MapperTest.java | 49 +++ .../waco_first/WacoFirstTest.java | 1 + 常用命令.md | 6 + 101 files changed, 3914 insertions(+), 417 deletions(-) create mode 100644 javascript/xuanran.wang/bme/js/InventFileFirst.js create mode 100644 javascript/xuanran.wang/bme/js/PayApply.js create mode 100644 javascript/xuanran.wang/bme/js/ProDataConfirm.js create mode 100644 src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/controller/CarToMQController.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/controller/MeetingController.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/entity/CusCreateWfInfo.java rename src/main/java/{weaver/xuanran/wang/shyl/mq => com/api/xuanran/wang/shyl}/entity/MQMessage.java (92%) create mode 100644 src/main/java/com/api/xuanran/wang/shyl/entity/ProducerCarInfo.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigDetail.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigMain.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/mapper/MeetingMapper.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/service/CarService.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/service/MeetingService.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/service/StudentsService.java create mode 100644 src/main/java/com/api/xuanran/wang/shyl/vo/CreateWfVO.java create mode 100644 src/main/java/com/customization/shyl/service/impl/MeetingRoomAddCusAopService.java create mode 100644 src/main/java/com/customization/shyl/service/impl/MeetingRoomEditCusAopService.java create mode 100644 src/main/java/com/customization/shyl/service/impl/MeetingRoomLookCusAopService.java create mode 100644 src/main/java/weaver/xuanran/wang/bme/action/TransOrderApproval.java create mode 100644 src/main/java/weaver/xuanran/wang/bme/action/UpdateModelInfo.java create mode 100644 src/main/java/weaver/xuanran/wang/bme/service/PushDataService.java create mode 100644 src/main/java/weaver/xuanran/wang/common/annocation/Map2JSONConvert.java delete mode 100644 src/main/java/weaver/xuanran/wang/shyl/mq/action/ProducerAction.java delete mode 100644 src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java delete mode 100644 src/main/java/weaver/xuanran/wang/shyl/mq/service/ProducerService.java delete mode 100644 src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/CreateAction.java delete mode 100644 src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/DeleteAction.java delete mode 100644 src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/PassWordAction.java delete mode 100644 src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/UpdateAction.java rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/RocketMQConsumerListener.java (94%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/RocketMQFactory.java (88%) create mode 100644 src/main/java/weaver/xuanran/wang/shyl_mq/action/ProducerAction.java rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/constant/RocketMQConstant.java (91%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/consumer/OrgConsumer.java (67%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/consumer/PassWordConsumer.java (68%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/consumer/UserInfoConsumer.java (68%) create mode 100644 src/main/java/weaver/xuanran/wang/shyl_mq/entity/MQMessage.java rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/entity/ModifyPassWord.java (94%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/entity/Org.java (92%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/entity/UserInfo.java (95%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/mapper/ConsumerMapper.java (60%) create mode 100644 src/main/java/weaver/xuanran/wang/shyl_mq/service/ChangeRequestParam.java create mode 100644 src/main/java/weaver/xuanran/wang/shyl_mq/service/CusInfoActionService.java create mode 100644 src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/service/impl/OrgServiceImpl.java (78%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/service/impl/PassWordServiceImpl.java (64%) rename src/main/java/weaver/xuanran/wang/{shyl/mq => shyl_mq}/service/impl/UserServiceImpl.java (79%) create mode 100644 src/main/java/weaver/xuanran/wang/shyl_mq/service/interfaces/CRUDAction.java rename src/main/java/weaver/xuanran/wang/{shyl/mq/util/RocketUtil.java => shyl_mq/util/RocketConsumerUtil.java} (57%) create mode 100644 src/main/resources/WEB-INF/prop/prop2map/test.properties create mode 100644 src/test/java/xuanran/wang/bme/PushDataActionTest.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/CusRequest.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/CusRequestAddress.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/PostBody.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/async/AsyncFun.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/async/CusAsync.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/header/CusRequestHeader.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java create mode 100644 src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java create mode 100644 src/test/java/xuanran/wang/http_test/constant/RequestUtilConstant.java create mode 100644 src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java create mode 100644 src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java create mode 100644 src/test/java/xuanran/wang/http_test/handle/RequestBeforeHandle.java create mode 100644 src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java create mode 100644 src/test/java/xuanran/wang/http_test/handle/path_handle/CusFieldKeyParseHandle.java create mode 100644 src/test/java/xuanran/wang/http_test/interfaces/CusCreateRequestHeader.java create mode 100644 src/test/java/xuanran/wang/http_test/proxy/CusUtil.java create mode 100644 src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java create mode 100644 src/test/java/xuanran/wang/http_test/service/TestService.java create mode 100644 src/test/java/xuanran/wang/http_test/test/RequestTest.java create mode 100644 src/test/java/xuanran/wang/shyl/dataasync/CreateWorkflowTest.java create mode 100644 src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java create mode 100644 常用命令.md diff --git a/javascript/xuanran.wang/bme/js/BuildContractApply.js b/javascript/xuanran.wang/bme/js/BuildContractApply.js index 723ec25..c8df318 100644 --- a/javascript/xuanran.wang/bme/js/BuildContractApply.js +++ b/javascript/xuanran.wang/bme/js/BuildContractApply.js @@ -47,6 +47,8 @@ jQuery().ready(function(){ } } + addRowBack(2, configObj); + changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, computeDatePayType) // 主表字段发生变化 diff --git a/javascript/xuanran.wang/bme/js/Common.js b/javascript/xuanran.wang/bme/js/Common.js index 4aae9d3..5c432b3 100644 --- a/javascript/xuanran.wang/bme/js/Common.js +++ b/javascript/xuanran.wang/bme/js/Common.js @@ -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 } } } + + diff --git a/javascript/xuanran.wang/bme/js/InventFileFirst.js b/javascript/xuanran.wang/bme/js/InventFileFirst.js new file mode 100644 index 0000000..032724b --- /dev/null +++ b/javascript/xuanran.wang/bme/js/InventFileFirst.js @@ -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); + } + } \ No newline at end of file diff --git a/javascript/xuanran.wang/bme/js/PayApply.js b/javascript/xuanran.wang/bme/js/PayApply.js new file mode 100644 index 0000000..fbe6238 --- /dev/null +++ b/javascript/xuanran.wang/bme/js/PayApply.js @@ -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}); + } + } +} \ No newline at end of file diff --git a/javascript/xuanran.wang/bme/js/ProDataConfirm.js b/javascript/xuanran.wang/bme/js/ProDataConfirm.js new file mode 100644 index 0000000..6994422 --- /dev/null +++ b/javascript/xuanran.wang/bme/js/ProDataConfirm.js @@ -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)); +} + diff --git a/javascript/xuanran.wang/bme/js/PurchaseContractApply.js b/javascript/xuanran.wang/bme/js/PurchaseContractApply.js index 4303665..705e114 100644 --- a/javascript/xuanran.wang/bme/js/PurchaseContractApply.js +++ b/javascript/xuanran.wang/bme/js/PurchaseContractApply.js @@ -51,6 +51,9 @@ function init(){ 'computeDatePayType': computeDatePayType, 'paymentTypeGetValue': paymentTypeGetValue } + + addRowBack(3, obj); + changeDetailFieldReadOnly(detailTable, detailComPayDateId, detailPaymentTypeId, computeDatePayType) // 主表字段发生变化 mainFieldChangeDetailCom(`${mainProjectId},${contractSignDateId}`, detailTable, obj); diff --git a/javascript/xuanran.wang/bme/js/SaleContractApply.js b/javascript/xuanran.wang/bme/js/SaleContractApply.js index 2836a58..eff8107 100644 --- a/javascript/xuanran.wang/bme/js/SaleContractApply.js +++ b/javascript/xuanran.wang/bme/js/SaleContractApply.js @@ -52,6 +52,7 @@ function init(){ 'computeDatePayType': computeDatePayType, 'paymentTypeGetValue': paymentTypeGetValue } + addRowBack(2, obj); changeDetailFieldReadOnly(detailTable, detail2ComPayDateId, detail2PaymentTypeId, computeDatePayType) // 主表字段发生变化 mainFieldChangeDetailCom(mainProjectId, detailTable, obj); diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java b/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java new file mode 100644 index 0000000..3c0791d --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java @@ -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; + +/** + *

上海团校-批量创建流程接口

+ * + * @author xuanran.wang + * @date 2023/2/22 13:51 + */ +@Path("/wxr/shyl/workflow") +public class BatchCreateWorkFlowController { + + private final Logger log = Util.getLogger(); + + /** + *

创建流程对象

+ **/ + 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() + " ]"); + } + } + + /** + *

获取创建流程对象(系统标准方法)

+ * @author xuanran.wang + * @dateTime 2023/2/22 16:53 + * @return 创建流程对象 + **/ + private static WorkflowRequestOperatePA getRequestOperatePA() { + return (WorkflowRequestOperatePAImpl) ServiceUtil.getService(WorkflowRequestOperatePAImpl.class); + } +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/CarToMQController.java b/src/main/java/com/api/xuanran/wang/shyl/controller/CarToMQController.java new file mode 100644 index 0000000..83032a0 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/controller/CarToMQController.java @@ -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; + +/** + *

车辆信息发送到mq中

+ * + * @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()); + } + + } + +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java b/src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java new file mode 100644 index 0000000..10b720f --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java @@ -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; + +/** + *

+ * + * @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() + " ]"); + } + } +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/MeetingController.java b/src/main/java/com/api/xuanran/wang/shyl/controller/MeetingController.java new file mode 100644 index 0000000..3074b74 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/controller/MeetingController.java @@ -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; + +/** + *

批量取消

+ * + * @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(); + + /** + *

会议取消

+ * @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()); + } +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/entity/CusCreateWfInfo.java b/src/main/java/com/api/xuanran/wang/shyl/entity/CusCreateWfInfo.java new file mode 100644 index 0000000..6fc120f --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/entity/CusCreateWfInfo.java @@ -0,0 +1,17 @@ +package com.api.xuanran.wang.shyl.entity; +import com.engine.workflow.entity.publicApi.PAResponseEntity; +import lombok.Data; + +/** + *

创建流程对象

+ * + * @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; +} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/MQMessage.java b/src/main/java/com/api/xuanran/wang/shyl/entity/MQMessage.java similarity index 92% rename from src/main/java/weaver/xuanran/wang/shyl/mq/entity/MQMessage.java rename to src/main/java/com/api/xuanran/wang/shyl/entity/MQMessage.java index 1c005ab..6c14570 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/MQMessage.java +++ b/src/main/java/com/api/xuanran/wang/shyl/entity/MQMessage.java @@ -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 { /** *

消息业务内容,json 格式,分业务(用户、机构、密码修改)

**/ - private String content; + private Object content; } diff --git a/src/main/java/com/api/xuanran/wang/shyl/entity/ProducerCarInfo.java b/src/main/java/com/api/xuanran/wang/shyl/entity/ProducerCarInfo.java new file mode 100644 index 0000000..2614726 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/entity/ProducerCarInfo.java @@ -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; + +/** + *

mq生产者车辆信息

+ * + * @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 + '\'' + + '}'; + } +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigDetail.java b/src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigDetail.java new file mode 100644 index 0000000..495f5b0 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigDetail.java @@ -0,0 +1,18 @@ +package com.api.xuanran.wang.shyl.entity.meeting; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + *

会议新增字段配置表主表对象

+ * + * @author xuanran.wang + * @date 2023/3/1 15:43 + */ +@Data +public class MeetingCusFieldConfigDetail { + @SqlOracleDbFieldAnn("SELECTKEY") + private String selectKey; + @SqlOracleDbFieldAnn("SELECTSHOWNAME") + private String selectShowName; +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigMain.java b/src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigMain.java new file mode 100644 index 0000000..b8c7ce1 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/entity/meeting/MeetingCusFieldConfigMain.java @@ -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; + +/** + *

会议新增字段配置表主表对象

+ * + * @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 options; +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/mapper/MeetingMapper.java b/src/main/java/com/api/xuanran/wang/shyl/mapper/MeetingMapper.java new file mode 100644 index 0000000..42eb115 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/mapper/MeetingMapper.java @@ -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; + +/** + *

会议模块相关

+ * + * @author xuanran.wang + * @date 2023/2/24 19:09 + */ +@SqlMapper +public interface MeetingMapper { + /** + *

查询配置表主表信息

+ * @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 queryMeetingCusConfigMain(); + + /** + *

查询配置表明细表信息

+ * @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 queryMeetingCusConfigDetail(@ParamMapper("mainId") int mainId); + + /** + *

更新会议室信息

+ * @param sql 自定义sql + * @param conditionData 条件值 + * @return 是否更新成功 + */ + @Update(custom = true) + boolean updateMeetingRoom(@SqlString String sql, HashMap conditionData); + + /** + *

查询会议室信息

+ * @author xuanran.wang + * @dateTime 2023/3/1 16:44 + * @param id 会议室id + **/ + @Select("select * from meetingroom where id = #{id}") + Map queryMeetingRoom(@ParamMapper("id") String id); +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java b/src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java new file mode 100644 index 0000000..3b7da0c --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/mapper/ProducerMapper.java @@ -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; + +/** + *

生产者mapper

+ * + * @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); +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java b/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java new file mode 100644 index 0000000..7621447 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java @@ -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; + + +/** + *

批量创建流程业务方法

+ * + * @author xuanran.wang + * @date 2023/2/22 13:58 + */ +public class BatchCreateWorkflowService { + + // 表名 : requestId 本次需要删除的数据 + private final ConcurrentHashMap> delWorkflowTableRequestId = new ConcurrentHashMap<>(); + // workflowId : tableName + private static final HashMap 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(); + /** + *

取消会议 支持多个

+ * @author xuanran.wang + * @dateTime 2023/2/24 10:21 + * @param ids 会议id + **/ + public void cancelMeeting(String ids){ + meetingService.cancelMeeting(ids); + } + + /** + *

批量创建流程

+ * @author xuanran.wang + * @dateTime 2023/2/22 17:10 + * @param array 流程数据数组 + * @return 创建流程结果 + **/ + public List batchCreateWorkflow(User user, JSONArray array) { + List> list = new ArrayList<>(); + List errors = new ArrayList<>(); + ArrayList res = new ArrayList<>(); + try { + List reqOperateRequestEntities = checkParams(array); + // 结果集 + for (int i = 0; i < reqOperateRequestEntities.size(); i++) { + int temp = i; + // 创建流程 + Callable callable = () -> this.createWorkflow(user,reqOperateRequestEntities.get(temp), temp); + list.add(Util.threadPool.submit(callable)); + } + for (Future 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 data = (Map) 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 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> entry : delWorkflowTableRequestId.entrySet()) { + String tableName = entry.getKey(); + List 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()); + } + } + + /** + *

创建流程

+ * @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 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; + } + + /** + *

参数校验并将json转成ReqOperateRequestEntity

+ * @author xuanran.wang + * @dateTime 2023/2/24 13:36 + * @param array json数组 + * @return 解析后的集合 + **/ + public List checkParams(JSONArray array){ + ArrayList 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 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; + } +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/CarService.java b/src/main/java/com/api/xuanran/wang/shyl/service/CarService.java new file mode 100644 index 0000000..c4205ec --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/service/CarService.java @@ -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; + +/** + *

车辆业务方法

+ * + * @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); + + /** + *

将信息发送到mq中

+ * @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()); + } + } +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/MeetingService.java b/src/main/java/com/api/xuanran/wang/shyl/service/MeetingService.java new file mode 100644 index 0000000..acec27d --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/service/MeetingService.java @@ -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; + +/** + *

会议相关业务

+ * + * @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); + /** + *

取消会议 支持多个

+ * @author xuanran.wang + * @dateTime 2023/2/24 10:21 + * @param ids 会议id + **/ + public void cancelMeeting(String ids){ + String[] idArr = ids.split(","); + List 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()); + } + } + + /** + *

将取消的会议发送到mq中

+ * @author xuanran.wang + * @dateTime 2023/2/28 14:40 + * @param requestIds 请求ids + **/ + private void sendToMQ(List requestIds){ + for (String requestId : requestIds) { + producerService.pushWorkFlowToMQ(CONFIG_NAME,ONLY_MARK, requestId, TABLE_NAME, (map)->{ + map.put("actionType", "DELETE_ACTION"); + }); + } + } + + /** + *

获取会议新增字段配置

+ * @author xuanran.wang + * @dateTime 2023/3/1 15:45 + * @return 建模配置对象 + **/ + public List getMeetingFieldCusConfig(){ + return meetingMapper.queryMeetingCusConfigMain(); + } + + +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/StudentsService.java b/src/main/java/com/api/xuanran/wang/shyl/service/StudentsService.java new file mode 100644 index 0000000..2d6d657 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/service/StudentsService.java @@ -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; + +/** + *

学员业务方法

+ * + * @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); // 全局请求头 + } + + /** + *

根据班级id获取学员信息

+ * @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 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 ""; + } +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/vo/CreateWfVO.java b/src/main/java/com/api/xuanran/wang/shyl/vo/CreateWfVO.java new file mode 100644 index 0000000..61b0841 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/shyl/vo/CreateWfVO.java @@ -0,0 +1,15 @@ +package com.api.xuanran.wang.shyl.vo; + +import lombok.Data; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/2/24 13:19 + */ +@Data +public class CreateWfVO { + private String customId; + private String requestId; +} diff --git a/src/main/java/com/customization/shyl/service/impl/MeetingRoomAddCusAopService.java b/src/main/java/com/customization/shyl/service/impl/MeetingRoomAddCusAopService.java new file mode 100644 index 0000000..031edfb --- /dev/null +++ b/src/main/java/com/customization/shyl/service/impl/MeetingRoomAddCusAopService.java @@ -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; + +/** + *

会议室新增时将自定义字段写入后端数据库

+ * + * @author xuanran.wang + * @date 2023/3/1 16:18 + */ +//@WeaIocReplaceComponent("MeetingRoomAddCusAopService") +@CommandDynamicProxy(target = DoAddRoomCmd.class, desc="会议室新增时将自定义字段写入后端数据库") +public class MeetingRoomAddCusAopService extends AbstractCommandProxy> { + private final Logger logger = Util.getLogger(); + private final MeetingMapper meetingMapper = Util.getMapper(MeetingMapper.class); + + @Override + public Map execute(Command> command) { + DoAddRoomCmd doAddRoomCmd = (DoAddRoomCmd) command; + Map request = doAddRoomCmd.getParams(); + Map 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; + } + + /** + *

修改会议表参数

+ * @author xuanran.wang + * @dateTime 2023/3/2 14:49 + * @param roomId 会议室id + * @param request 请求参数 + **/ + public void changeMeetingInfo(String roomId, Map request){ + if(StringUtils.isNotBlank(roomId)){ + List config = meetingMapper.queryMeetingCusConfigMain(); + Assert.notNull(config, "查询会议室新增字段配置为空!"); + HashMap 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 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("更新会议室表失败!"); + } + } + } + +} diff --git a/src/main/java/com/customization/shyl/service/impl/MeetingRoomEditCusAopService.java b/src/main/java/com/customization/shyl/service/impl/MeetingRoomEditCusAopService.java new file mode 100644 index 0000000..66921c8 --- /dev/null +++ b/src/main/java/com/customization/shyl/service/impl/MeetingRoomEditCusAopService.java @@ -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; + +/** + *

会议室编辑时将自定义字段写入后端数据库

+ * + * @author xuanran.wang + * @date 2023/3/2 14:45 + */ +@CommandDynamicProxy(target = DoEditRoomCmd.class, desc="会议室编辑时将自定义字段返回") +public class MeetingRoomEditCusAopService extends AbstractCommandProxy> { + private final Logger logger = Util.getLogger(); + + private final MeetingRoomAddCusAopService roomAddCusAopService = new MeetingRoomAddCusAopService(); + @Override + public Map execute(Command> command) { + DoEditRoomCmd doEditRoomCmd = (DoEditRoomCmd) command; + Map request = doEditRoomCmd.getParams(); + Map 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; + } +} diff --git a/src/main/java/com/customization/shyl/service/impl/MeetingRoomLookCusAopService.java b/src/main/java/com/customization/shyl/service/impl/MeetingRoomLookCusAopService.java new file mode 100644 index 0000000..38eda7c --- /dev/null +++ b/src/main/java/com/customization/shyl/service/impl/MeetingRoomLookCusAopService.java @@ -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; + +/** + *

会议室查看时将自定义字段返回

+ * + * @author xuanran.wang + * @date 2023/3/1 17:04 + */ +@CommandDynamicProxy(target = GetRoomFieldsCmd.class, desc="会议室查看时将自定义字段返回") +public class MeetingRoomLookCusAopService extends AbstractCommandProxy> { + private final MeetingMapper meetingMapper = Util.getMapper(MeetingMapper.class); + private final Logger log = Util.getLogger(); + /** + *

可编辑

+ **/ + private static final int EDIT = 2; + /** + *

数字

+ **/ + private static final int NUMBER = 0; + /** + *

下拉框

+ **/ + private static final int SELECT_TYPE = 1; + /** + *

文本

+ **/ + private static final int TEXT = 2; + + @Override + public Map execute(Command> command) { + GetRoomFieldsCmd getRoomFieldsCmd = (GetRoomFieldsCmd) command; + Map params = getRoomFieldsCmd.getParams(); + Map res = nextExecute(command); + String roomId = Util.null2DefaultStr(params.get("roomid"), ""); + try { + log.info("------------ lookRoomAfterCmd ------------"); + Map map = new HashMap<>(); + if(StringUtils.isNotBlank(roomId)){ + map = meetingMapper.queryMeetingRoom(roomId); + Assert.notNull(map, "根据会议室id查询会议室信息为空!"); + } + + List config = meetingMapper.queryMeetingCusConfigMain(); + Assert.notNull(config, "查询会议室新增字段配置为空!"); + + List> fields = (List>) res.get("fields"); + Assert.notNull(fields, "接口返回fields为空!"); + + Map roomAddress = fields.get(1); + Assert.notNull(roomAddress, "fields.get(1)为空!"); + + List> roomAddressFields = (List>) roomAddress.get("items"); + Assert.notNull(roomAddressFields, "roomAddressFields为空!"); + + for (MeetingCusFieldConfigMain configMain : config) { + Map 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 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 getOptions(String currentValue, + List details) { + List options = new ArrayList<>(); + for (MeetingCusFieldConfigDetail option : details) { + String key = option.getSelectKey(); + options.add(new SearchConditionOption(key, option.getSelectShowName(), key.equals(currentValue))); + } + return options; + } + + +} diff --git a/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java b/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java index 2739c08..55478d3 100644 --- a/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java +++ b/src/main/java/weaver/xuanran/wang/bme/action/ContractApplyComDateAction.java @@ -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; /** *

柏美施工合同修改日期action

@@ -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 { /** *

施工合同项目字段

**/ @RequiredMark + @PrintParamMark private String buildContractProjectField; /** *

施工合同主表名

**/ @RequiredMark + @PrintParamMark private String buildContractTable; /** *

施工合同明细表表名

**/ @RequiredMark + @PrintParamMark private String detailContractTable; /** *

施工合同明细表更新日期字段

**/ @RequiredMark + @PrintParamMark private String detailContractDateFiled; /** *

验收流程项目字段

**/ @RequiredMark + @PrintParamMark private String projectField; /** *

验收流程日期字段

**/ @RequiredMark + @PrintParamMark private String checkDateField; + /** - *

明细表更新验收日期的条件

+ *

明细前后字段

**/ - private String updateWhere; + @RequiredMark + private String beforeBackField; + + /** + *

明细表天数

+ **/ + @RequiredMark + @PrintParamMark + private String dayField; + + /** + *

更新条件字段

+ **/ + @RequiredMark + @PrintParamMark + private String whereField; + + /** + *

更新条件值

+ **/ + @RequiredMark + @PrintParamMark + private String whereValues; + + /** + *

嵌套条件自定义sql

+ *

+ * select a.id,a.requestid + * from + * formtable_main_58 a + * right join uf_cgdd b + * on a.id = b.cght + * where b.id = 874; + *

+ **/ + @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 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 params = new ArrayList<>(); + if (rs.executeQuery(selectSql, mainId)) { + while (rs.next()) { + ArrayList 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 getMainTableValue(RequestInfo requestInfo) { + // 获取主表数据 + Property[] propertyArr = requestInfo.getMainTableInfo().getProperty(); + return getStringMap(propertyArr); + } + + private Map getStringMap(Property[] propertyArr) { + if (null == propertyArr) { + return Collections.emptyMap(); + } + Map 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; + } + } diff --git a/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java b/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java index e129c0b..45ff7cc 100644 --- a/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java +++ b/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java @@ -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 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); diff --git a/src/main/java/weaver/xuanran/wang/bme/action/TransOrderApproval.java b/src/main/java/weaver/xuanran/wang/bme/action/TransOrderApproval.java new file mode 100644 index 0000000..ac4174a --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/bme/action/TransOrderApproval.java @@ -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; + +/** + *

调拨单审核action 将流程数据推送到u8

+ * + * @author xuanran.wang + * @date 2023/2/21 13:19 + */ +public class TransOrderApproval extends SafeCusBaseAction { + /** + *

配置唯一标识

+ **/ + @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())); + } + } +} diff --git a/src/main/java/weaver/xuanran/wang/bme/action/UpdateModelInfo.java b/src/main/java/weaver/xuanran/wang/bme/action/UpdateModelInfo.java new file mode 100644 index 0000000..2b44e2f --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/bme/action/UpdateModelInfo.java @@ -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; + +/** + *

更新采购/施工合同建模数据

+ *

沙雕代码

+ * @author xuanran.wang + * @date 2022/12/13 11:13 + */ +public class UpdateModelInfo implements Action { + + private final Logger log = Util.getLogger(); + + /** + *

订单类型 glddxx

+ **/ + @PrintParamMark + @RequiredMark + private String orderType; + + /** + *

施工合同表名

+ * select * from formtable_main_62 where htbh = 'D520230209001' + **/ + @PrintParamMark + @RequiredMark + private String sgTable; + + /** + *

施工合同明细表名

+ * select * from formtable_main_62 where htbh = 'D520230209001' + **/ + @PrintParamMark + @RequiredMark + private String sgDetailTable; + /** + *

采购合同表名

+ **/ + @PrintParamMark + @RequiredMark + private String cgTable; + /** + *

采购合同明细表名

+ **/ + @PrintParamMark + @RequiredMark + private String cgDetailTable; + + /** + *

更新字段映射关系

+ *

bcfkje:sjfkje,sjfkrq:sjfkrq

+ **/ + @PrintParamMark + @RequiredMark + private String sgFieldMapping; + /** + *

更新字段映射关系

+ *

bcfkje:fkje,sjfkrq:sjfkrq

+ **/ + @PrintParamMark + @RequiredMark + private String cgFieldMapping; + /** + *

采购合同流程关联字段

+ **/ + @PrintParamMark + @RequiredMark + private String cgModelRelationField; + /** + *

施工合同流程关联字段

+ * htbh + **/ + @PrintParamMark + @RequiredMark + private String sgModelRelationField; + /** + *

订单号

+ **/ + private static final String DDH = "ddh"; + /** + *

款项类型

+ **/ + 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 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 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; + } + } +} diff --git a/src/main/java/weaver/xuanran/wang/bme/service/PushDataService.java b/src/main/java/weaver/xuanran/wang/bme/service/PushDataService.java new file mode 100644 index 0000000..1b4143c --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/bme/service/PushDataService.java @@ -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; + +/** + *

数据推送方法

+ * + * @author xuanran.wang + * @date 2023/2/21 13:21 + */ +public class PushDataService { + + private static final int SUCCESS_CODE = 200; + /** + *

接口响应信息

+ **/ + private static final String MESSAGE_FIELD = "Message"; + /** + *

业务处理成功/失败标识

+ */ + private static final String SUCCESS_FIELD = "Success"; + /** + *

requestId记录表名

+ **/ + 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); // 全局请求头 + } + + /** + *

数据推送

+ * @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 listParam = dealWithMapping.getRequestListParam(recordSet, requestMappingConfig); + Assert.isNull(listParam,"流程生成JSON失败!"); + ResponeVo responseVo = httpUtils.apiPost(url, listParam,new HashMap<>()); + Map 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 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 构建日志字符串 + } + } + } + +} diff --git a/src/main/java/weaver/xuanran/wang/common/annocation/Map2JSONConvert.java b/src/main/java/weaver/xuanran/wang/common/annocation/Map2JSONConvert.java new file mode 100644 index 0000000..80d5611 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/common/annocation/Map2JSONConvert.java @@ -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; + +/** + *

map转json注解

+ * + * @author xuanran.wang + * @date 2023/2/25 15:22 + */ +@Target({ElementType.FIELD,ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Map2JSONConvert { + /** + *

map字段名

+ **/ + String mapField() default ""; + /** + *

json字段名

+ **/ + String jsonField() default ""; +} diff --git a/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java b/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java index b932268..ec35493 100644 --- a/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java +++ b/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java @@ -42,6 +42,25 @@ public interface CommonMapper { boolean deleteModelDataByIds(@ParamMapper("tableName") String tableName, @ParamMapper("ids") List ids); + /** + *

通过requestId删除流程表数据

+ * @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 requestIds); + + /** + *

根据模块id查询数据审批配置

+ * @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 getExpendConfigByModeId(@ParamMapper("modelId") int modelId); + /** + *

TODO

+ * @author xuanran.wang + * @dateTime 2023/2/22 15:37 + * @param triggerId 数据审批id + * @return + **/ @Select("select * from mode_triggerworkflowset where id = #{triggerId}") Map getConfigByTriggerId(@ParamMapper("triggerId") String triggerId); + /** + *

TODO

+ * @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); + /** + *

根据流程id获取流程表名

+ * @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); + + /** + *

根据请求id获取会议id

+ * @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 requestIds); } diff --git a/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java b/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java index 2ddb52d..818b3f0 100644 --- a/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java +++ b/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java @@ -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()); } + /** *

通过自定义日期注解转换参数值

* @author xuanran.wang @@ -618,6 +621,40 @@ public class CommonUtil { return "select * from " + tableName + " where requestid = ? " + cusWhere; } + /** + *

根据路径ID获取流程表名

+ * @author xuanran.wang + * @dateTime 2023/2/22 16:25 + * @param workflowId 流程id + * @return 表名 + **/ + public static String getTableNameByWorkflowId(int workflowId){ + return commonMapper.queryTableNameByWorkflowId(workflowId); + } + + /** + *

通过requestId删除流程表数据

+ * @author xuanran.wang + * @dateTime 2022/11/17 10:41 + * @param tableName 流程表名 + * @param requestIds 请求id集合 + * @return 删除是否成功 + **/ + public static boolean deleteWorkflowDataByRequestIds(String tableName, List requestIds){ + return commonMapper.deleteWorkflowDataByRequestIds(tableName, requestIds); + } + + /** + *

根据请求id获取会议id

+ * @author xuanran.wang + * @dateTime 2023/2/22 17:37 + * @param requestId 请求id + * @return 会议id + **/ + public static String getMeetingIdByRequestId(String requestId){ + return commonMapper.queryMeetingIdByRequestId(requestId); + } + } diff --git a/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java b/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java index e649494..4778f42 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java +++ b/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java @@ -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; - /** - *

教研资系统动态码地址

- **/ - @ParamPrint - @ParamNotNull - private String dynamicCodeUrl; - /** - *

教研资系统登陆地址

- **/ - @ParamPrint - @ParamNotNull - private String loginUrl; /** *

查询班级列表url

**/ @ParamPrint @ParamNotNull private String queryClassUrl; - /** - *

查询学员列表Url

- **/ - @ParamPrint - @ParamNotNull - private String queryStuUrl; +// /** +// *

查询学员列表Url

+// **/ +// @ParamPrint +// @ParamNotNull +// private String queryStuUrl; /** *

班级模块id

**/ @ParamPrint @ParamNotNull private String classModelId; - /** - *

学员模块id

- **/ - @ParamPrint - @ParamNotNull - private String studentModelId; - /** - *

教研资系统用户名

- **/ - @ParamPrint - @ParamNotNull - private String userName; - /** - *

教研资系统密码

- **/ - @ParamPrint - @ParamNotNull - private String userPwd; +// /** +// *

学员模块id

+// **/ +// @ParamPrint +// @ParamNotNull +// private String studentModelId; /** *

更新班级建模条件sql

**/ @@ -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 loginParams = new HashMap<>(); - loginParams.put("username", userName); - loginParams.put("password", userPwd); - loginParams.put("authType", "normal"); - - Object token = dataAsyncService.getToken(dynamicCodeUrl, loginUrl, loginParams); - HashMap 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))); } } } diff --git a/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java b/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java index 04377ac..91be9a6 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java +++ b/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java @@ -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.*; /** *

班级列表/学员数据同步业务方法

@@ -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 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 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 params, Map 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())); diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/action/ProducerAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/action/ProducerAction.java deleted file mode 100644 index d12b20f..0000000 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/action/ProducerAction.java +++ /dev/null @@ -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; - -/** - *

生产者action 将流程数据发送到mq中

- * - * @author xuanran.wang - * @date 2023/1/4 14:47 - */ -public class ProducerAction extends SafeCusBaseAction { - - /** - *

mq配置文件名称

- **/ - @RequiredMark - @PrintParamMark - private String MQConfigName; - /** - *

配置文件唯一标识

- **/ - @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); - } - } -} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java deleted file mode 100644 index 4dd8f42..0000000 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java +++ /dev/null @@ -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; - -/** - *

抽象类

- * - * @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(); - /** - *

consumer-mapper

- **/ - protected final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class); - /** - *

分部id

- **/ - protected String subId; - // 默认初始化分部ID - { - subId = consumerMapper.getDefaultSubId(); - } - - - /** - *

获取下一个人员id

- * @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)); - } - -} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/ProducerService.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/ProducerService.java deleted file mode 100644 index e028dae..0000000 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/ProducerService.java +++ /dev/null @@ -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; - -/** - *

生产者业务方法

- * - * @author xuanran.wang - * @date 2023/1/4 14:54 - */ -public class ProducerService { - - private final DealWithMapping dealWithMapping = new DealWithMapping(); - - /** - *

作为生产者将流程数据推送至mq中

- * @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 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)); - } -} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/CreateAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/CreateAction.java deleted file mode 100644 index 018e37a..0000000 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/CreateAction.java +++ /dev/null @@ -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; - -/** - *

新增接口

- * - * @Author xuanran.wang - * @Date 2022/12/30 13:00 - */ -public interface CreateAction { - ConsumeConcurrentlyStatus cusCreateAction(MQMessage message); -} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/DeleteAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/DeleteAction.java deleted file mode 100644 index ff2bc9e..0000000 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/DeleteAction.java +++ /dev/null @@ -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; - -/** - *

删除接口

- * - * @Author xuanran.wang - * @Date 2022/12/30 13:02 - */ -public interface DeleteAction { - ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message); -} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/PassWordAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/PassWordAction.java deleted file mode 100644 index 956e1cb..0000000 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/PassWordAction.java +++ /dev/null @@ -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; - -/** - *

密码修改接口

- * - * @Author xuanran.wang - * @Date 2022/12/30 13:03 - */ -public interface PassWordAction { - ConsumeConcurrentlyStatus cusPassWordAction(MQMessage message); -} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/UpdateAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/UpdateAction.java deleted file mode 100644 index 0ad59b4..0000000 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/UpdateAction.java +++ /dev/null @@ -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; - -/** - *

更新接口

- * - * @Author xuanran.wang - * @Date 2022/12/30 13:01 - */ -public interface UpdateAction { - ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message); -} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQConsumerListener.java b/src/main/java/weaver/xuanran/wang/shyl_mq/RocketMQConsumerListener.java similarity index 94% rename from src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQConsumerListener.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/RocketMQConsumerListener.java index 366a1b1..0ef2ef6 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQConsumerListener.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/RocketMQConsumerListener.java @@ -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)); diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQFactory.java b/src/main/java/weaver/xuanran/wang/shyl_mq/RocketMQFactory.java similarity index 88% rename from src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQFactory.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/RocketMQFactory.java index 2df840a..45b0aaf 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQFactory.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/RocketMQFactory.java @@ -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 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 getConfigMapByName(String configName){ Map configMap = new HashMap<>(); if(!CONFIG_MAPS.containsKey(configName)){ - configMap = RocketUtil.initMQConfigMap(configName); + configMap = RocketConsumerUtil.initMQConfigMap(configName); CONFIG_MAPS.put(configName, configMap); } return configMap; diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/action/ProducerAction.java b/src/main/java/weaver/xuanran/wang/shyl_mq/action/ProducerAction.java new file mode 100644 index 0000000..ba7f09a --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/action/ProducerAction.java @@ -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; + +/** + *

生产者action 将流程数据发送到mq中

+ * + * @author xuanran.wang + * @date 2023/1/4 14:47 + */ +public class ProducerAction implements Action { + + /** + *

建模配置标识

+ **/ + private String onlyMark; + + /** + *

配置文件名称

+ **/ + 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; + } + } +} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/constant/RocketMQConstant.java b/src/main/java/weaver/xuanran/wang/shyl_mq/constant/RocketMQConstant.java similarity index 91% rename from src/main/java/weaver/xuanran/wang/shyl/mq/constant/RocketMQConstant.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/constant/RocketMQConstant.java index 9af0e6a..7bd6915 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/constant/RocketMQConstant.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/constant/RocketMQConstant.java @@ -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"; diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/OrgConsumer.java b/src/main/java/weaver/xuanran/wang/shyl_mq/consumer/OrgConsumer.java similarity index 67% rename from src/main/java/weaver/xuanran/wang/shyl/mq/consumer/OrgConsumer.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/consumer/OrgConsumer.java index b5c11a1..2a6a978 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/OrgConsumer.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/consumer/OrgConsumer.java @@ -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 msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, orgService, CONFIG_NAME); + return (List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketConsumerUtil.execute(msg, consumeConcurrentlyContext, orgService, CONFIG_NAME); } } diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/PassWordConsumer.java b/src/main/java/weaver/xuanran/wang/shyl_mq/consumer/PassWordConsumer.java similarity index 68% rename from src/main/java/weaver/xuanran/wang/shyl/mq/consumer/PassWordConsumer.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/consumer/PassWordConsumer.java index f400e56..fadf164 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/PassWordConsumer.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/consumer/PassWordConsumer.java @@ -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 msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, passWordService, CONFIG_NAME); + return (List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketConsumerUtil.execute(msg, consumeConcurrentlyContext, passWordService, CONFIG_NAME); } } diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/UserInfoConsumer.java b/src/main/java/weaver/xuanran/wang/shyl_mq/consumer/UserInfoConsumer.java similarity index 68% rename from src/main/java/weaver/xuanran/wang/shyl/mq/consumer/UserInfoConsumer.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/consumer/UserInfoConsumer.java index f87a276..7d1e44b 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/UserInfoConsumer.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/consumer/UserInfoConsumer.java @@ -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 msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, userInfoService, CONFIG_NAME); + return (List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketConsumerUtil.execute(msg, consumeConcurrentlyContext, userInfoService, CONFIG_NAME); } } diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/entity/MQMessage.java b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/MQMessage.java new file mode 100644 index 0000000..ae01080 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/MQMessage.java @@ -0,0 +1,53 @@ +package weaver.xuanran.wang.shyl_mq.entity; + +import lombok.Data; +import weaver.xuanran.wang.common.annocation.SqlFieldMapping; + +/** + *

mq消息实体类

+ * + * @Author xuanran.wang + * @Date 2022/12/30 13:09 + */ +@Data +public class MQMessage { + /** + *

消息ID

+ **/ + @SqlFieldMapping("messageId") + private String id; + /** + *

消息队列名

+ *

+ * AUTH_CONSOLE_USERINFO_TOPIC: 用户队列; + * AUTH_CONSOLE_ORG_TOPIC: 机构队列; + * AUTH_CONSOLE_USERINFO_PASSWORD_TOPIC: 密码修改队列 + *

+ **/ + @SqlFieldMapping() + private String topic; + /** + *

消息内容操作类型

+ *

+ * CREATE_ACTION:新增; + * UPDATE_ACTION: 修改; + * DELETE_ACTION: 删除; + * PASSWORD_ACTION: 修改密码 + *

+ **/ + @SqlFieldMapping() + private String actionType; + /** + *

消息发送时间

+ **/ + @SqlFieldMapping() + private String sendTime; + /** + *

消息业务内容,json 格式,分业务(用户、机构、密码修改)

+ **/ + @SqlFieldMapping() + private String content; + + @SqlFieldMapping() + private String error; +} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/ModifyPassWord.java similarity index 94% rename from src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/entity/ModifyPassWord.java index f147608..2884b93 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/ModifyPassWord.java @@ -1,4 +1,4 @@ -package weaver.xuanran.wang.shyl.mq.entity; +package weaver.xuanran.wang.shyl_mq.entity; import lombok.Data; diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/Org.java b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/Org.java similarity index 92% rename from src/main/java/weaver/xuanran/wang/shyl/mq/entity/Org.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/entity/Org.java index 10c9ad8..5ff754f 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/Org.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/Org.java @@ -1,5 +1,5 @@ -package weaver.xuanran.wang.shyl.mq.entity; +package weaver.xuanran.wang.shyl_mq.entity; import lombok.Data; diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/UserInfo.java b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/UserInfo.java similarity index 95% rename from src/main/java/weaver/xuanran/wang/shyl/mq/entity/UserInfo.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/entity/UserInfo.java index 2849a15..4b5a39a 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/UserInfo.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/entity/UserInfo.java @@ -1,4 +1,4 @@ -package weaver.xuanran.wang.shyl.mq.entity; +package weaver.xuanran.wang.shyl_mq.entity; import lombok.Data; diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java similarity index 60% rename from src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java index 7a74f64..1d6bab2 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java @@ -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); + /** + *

通过id删除部门

+ * @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); + /** *

通过outKey封存部门

* @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 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(); + + /** + *

通过id删除人员

+ * @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); + + /** + *

通过outKey删除人员

+ * @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); } diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/ChangeRequestParam.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/ChangeRequestParam.java new file mode 100644 index 0000000..be103ed --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/ChangeRequestParam.java @@ -0,0 +1,17 @@ +package weaver.xuanran.wang.shyl_mq.service; + +import java.util.Map; + +/** + *

修改请求配置参数

+ * + * @author xuanran.wang + * @date 2023/2/28 14:35 + */ +public interface ChangeRequestParam { + /** + * 修改请求配置参数 + * @param requestParam 请求 + */ + void changeRequestParam(Map requestParam); +} diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/CusInfoActionService.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/CusInfoActionService.java new file mode 100644 index 0000000..5d39072 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/CusInfoActionService.java @@ -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; + +/** + *

抽象类

+ * + * @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(); + /** + *

consumer-mapper

+ **/ + protected final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class); + protected ToolUtil toolUtil = new ToolUtil(); + /** + *

分部id

+ **/ + protected String subId; + /** + *

成功消费日志模块id

+ **/ + private final int modelId; + + // 默认初始化分部ID + { + subId = consumerMapper.getDefaultSubId(); + modelId = Util.getIntValue(toolUtil.getSystemParamValue("mqLogModelId"),-1); + log.info(Util.logStr("subId : {}, modelId : {}", subId, modelId)); + } + + + /** + *

获取下一个人员id

+ * @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)); + } + + /** + *

将处理过的mq消息存入oa

+ * @author xuanran.wang + * @dateTime 2023/2/21 18:27 + * @param messageId 消息id + **/ + protected void writeInOA(String messageId){ + HashMap params = new HashMap<>(); + params.put("messageId",messageId); + params.put("dealTime", TimeUtil.getCurrentTimeString()); + log.info(Util.logStr("messageId : {}, consumer success!",messageId)); + CusInfoToOAUtil.getDataId(modelId,params); + } + +} diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java new file mode 100644 index 0000000..75c5bbc --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/ProducerService.java @@ -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; + + +/** + *

生产者业务方法

+ * + * @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); // 全局请求头 + } + + + + /** + *

作为生产者将流程数据推送至mq中

+ * @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 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); + } + } +} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/OrgServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/OrgServiceImpl.java similarity index 78% rename from src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/OrgServiceImpl.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/OrgServiceImpl.java index a569617..ddbf9e1 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/OrgServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/OrgServiceImpl.java @@ -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; /** - *

+ *

组织结构

* * @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"); + } + } /** *

部门创建

@@ -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 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; } } diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/PassWordServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java similarity index 64% rename from src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/PassWordServiceImpl.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java index 6130288..b9cf11a 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/PassWordServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java @@ -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; /** *

密码修改业务方法

@@ -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; } } diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/UserServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java similarity index 79% rename from src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/UserServiceImpl.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java index c95c7b0..01d336e 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/UserServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java @@ -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; - /** *

用户业务方法

* @@ -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"); + } + } /** *

用户新增

* @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 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 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; } } diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/interfaces/CRUDAction.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/interfaces/CRUDAction.java new file mode 100644 index 0000000..5d78e47 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/interfaces/CRUDAction.java @@ -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; + +/** + *

组织/用户 新增、删除、更新action

+ * + * @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); +} diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/util/RocketUtil.java b/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java similarity index 57% rename from src/main/java/weaver/xuanran/wang/shyl/mq/util/RocketUtil.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java index c5ef4d6..a27c413 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/mq/util/RocketUtil.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java @@ -1,4 +1,4 @@ -package weaver.xuanran.wang.shyl.mq.util; +package weaver.xuanran.wang.shyl_mq.util;//package weaver.xuanran.wang.shyl.mq.util; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; @@ -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.*; /** *

rocketMQ集成工具类

@@ -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"); + } + } /** *

初始化配置文件对象

@@ -70,52 +82,71 @@ public class RocketUtil { public static ConsumeConcurrentlyStatus execute(List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext, CusInfoActionService cusInfoActionService, String configName){ Map 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 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); } + + } diff --git a/src/main/resources/WEB-INF/prop/prop2map/OACar.properties b/src/main/resources/WEB-INF/prop/prop2map/OACar.properties index 0606409..e59d985 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/OACar.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/OACar.properties @@ -1,4 +1,4 @@ ConsumerGroup=weaver-car -NameServer=183.192.65.118:9876 +NameServer=114.115.168.220:9876 Topic=OA_CAR_TOPIC Tag=* \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/OAMeal.properties b/src/main/resources/WEB-INF/prop/prop2map/OAMeal.properties index 4bbdaf5..4df76a1 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/OAMeal.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/OAMeal.properties @@ -1,4 +1,4 @@ ConsumerGroup=weaver-meal -NameServer=183.192.65.118:9876 +NameServer=114.115.168.220:9876 Topic=OA_MEAL_TOPIC Tag=* \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/OAMeeting.properties b/src/main/resources/WEB-INF/prop/prop2map/OAMeeting.properties index a693a32..ca730e1 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/OAMeeting.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/OAMeeting.properties @@ -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=* \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/OAVisitor.properties b/src/main/resources/WEB-INF/prop/prop2map/OAVisitor.properties index 9d47d17..e4bf6d0 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/OAVisitor.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/OAVisitor.properties @@ -1,4 +1,4 @@ ConsumerGroup=weaver-visitor -NameServer=183.192.65.118:9876 +NameServer=114.115.168.220:9876 Topic=OA_VISITOR_TOPIC Tag=* \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/OrgConsumer.properties b/src/main/resources/WEB-INF/prop/prop2map/OrgConsumer.properties index 024092c..2b07de5 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/OrgConsumer.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/OrgConsumer.properties @@ -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=* \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/PassWordConsumer.properties b/src/main/resources/WEB-INF/prop/prop2map/PassWordConsumer.properties index 04f8b6b..b87f068 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/PassWordConsumer.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/PassWordConsumer.properties @@ -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=* \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/UserInfoConsumer.properties b/src/main/resources/WEB-INF/prop/prop2map/UserInfoConsumer.properties index b285ae1..33e22d9 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/UserInfoConsumer.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/UserInfoConsumer.properties @@ -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=* \ No newline at end of file diff --git a/src/main/resources/WEB-INF/prop/prop2map/test.properties b/src/main/resources/WEB-INF/prop/prop2map/test.properties new file mode 100644 index 0000000..1a82ab3 --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/test.properties @@ -0,0 +1,3 @@ +1=1212 +2=212 +#2=21 \ No newline at end of file diff --git a/src/test/java/xuanran/wang/bme/PushDataActionTest.java b/src/test/java/xuanran/wang/bme/PushDataActionTest.java new file mode 100644 index 0000000..45dd960 --- /dev/null +++ b/src/test/java/xuanran/wang/bme/PushDataActionTest.java @@ -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; + +/** + *

柏美测试类

+ * + * @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 requestListParam = dealWithMapping.getRequestListParam(recordSet, requestMappingConfig); + log.info("list : " + requestListParam); + } +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java b/src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java new file mode 100644 index 0000000..3d43003 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java @@ -0,0 +1,16 @@ +package xuanran.wang.http_test.annotations; + +import java.lang.annotation.*; + +/** + *

请求路径参数替换

+ * + * @author xuanran.wang + * @date 2023/3/10 17:00 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.PARAMETER}) +@Documented +public @interface CusPathQuery { + String value(); +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusRequest.java b/src/test/java/xuanran/wang/http_test/annotations/CusRequest.java new file mode 100644 index 0000000..ef05213 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/CusRequest.java @@ -0,0 +1,15 @@ +package xuanran.wang.http_test.annotations; + +import java.lang.annotation.*; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/3/10 10:46 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +@Documented +public @interface CusRequest { +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusRequestAddress.java b/src/test/java/xuanran/wang/http_test/annotations/CusRequestAddress.java new file mode 100644 index 0000000..460b59c --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/CusRequestAddress.java @@ -0,0 +1,19 @@ +package xuanran.wang.http_test.annotations; + +import java.lang.annotation.*; + +/** + *

请求地址

+ * + * @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; +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java b/src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java new file mode 100644 index 0000000..65dd302 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java @@ -0,0 +1,15 @@ +package xuanran.wang.http_test.annotations; + +import java.lang.annotation.*; + +/** + *

路径参数 可以修饰map,字段 如果是字段那就会将

+ * + * @author xuanran.wang + * @date 2023/3/10 13:06 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +@Documented +public @interface GetPathValue { +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/PostBody.java b/src/test/java/xuanran/wang/http_test/annotations/PostBody.java new file mode 100644 index 0000000..2f704c8 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/PostBody.java @@ -0,0 +1,15 @@ +package xuanran.wang.http_test.annotations; + +import java.lang.annotation.*; + +/** + *

post请求体

+ * + * @author xuanran.wang + * @date 2023/3/10 13:48 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +@Documented +public @interface PostBody { +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/async/AsyncFun.java b/src/test/java/xuanran/wang/http_test/annotations/async/AsyncFun.java new file mode 100644 index 0000000..c23be52 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/async/AsyncFun.java @@ -0,0 +1,15 @@ +package xuanran.wang.http_test.annotations.async; + +import java.lang.annotation.*; + +/** + *

异步

+ * + * @author xuanran.wang + * @date 2023/3/10 14:17 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +@Documented +public @interface AsyncFun { +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/async/CusAsync.java b/src/test/java/xuanran/wang/http_test/annotations/async/CusAsync.java new file mode 100644 index 0000000..73ceae1 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/async/CusAsync.java @@ -0,0 +1,17 @@ +package xuanran.wang.http_test.annotations.async; + +import java.lang.annotation.*; + +/** + *

是否开启异步

+ * + * @author xuanran.wang + * @date 2023/3/10 10:13 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@Documented +public @interface CusAsync { + //

是否开启异步 默认为false

+ boolean enable() default false; +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/header/CusRequestHeader.java b/src/test/java/xuanran/wang/http_test/annotations/header/CusRequestHeader.java new file mode 100644 index 0000000..4f41825 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/header/CusRequestHeader.java @@ -0,0 +1,21 @@ +package xuanran.wang.http_test.annotations.header; + +import java.lang.annotation.*; + +/** + *

自定义请求头

+ * + * @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 ""; +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java b/src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java new file mode 100644 index 0000000..c6c3706 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/request_path/CusPathQuery.java @@ -0,0 +1,24 @@ +package xuanran.wang.http_test.annotations.request_path; + +import java.lang.annotation.*; + +/** + *

+ * 路径参数注解 + * 可以作用于参数中如果想要替换路径中的/api/test/{job} {job} 需要在参数指明替换占位符的key + * 如果不指明会判断参数类型 如果是map则直接拼接在路径中 + * 如果是/api/test/${job} 以$开头的则将参数 通过&进行分割解析成map + *

+ * + * @author xuanran.wang + * @date 2023/3/14 22:50 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +@Documented +public @interface CusPathQuery { + /** + *

路径中需要替换的key

+ **/ + String value() default ""; +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java new file mode 100644 index 0000000..a20a87a --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestDelete.java @@ -0,0 +1,16 @@ +package xuanran.wang.http_test.annotations.request_type; + +import java.lang.annotation.*; + +/** + *

delete 请求

+ * + * @author xuanran.wang + * @date 2023/3/10 10:17 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@Documented +public @interface CusRequestDelete { + String url() default ""; +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java new file mode 100644 index 0000000..14a7ec2 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestGet.java @@ -0,0 +1,16 @@ +package xuanran.wang.http_test.annotations.request_type; + +import java.lang.annotation.*; + +/** + *

get 请求

+ * + * @author xuanran.wang + * @date 2023/3/10 10:15 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +@Documented +public @interface CusRequestGet{ + String url() default ""; +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java new file mode 100644 index 0000000..4871a05 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java @@ -0,0 +1,16 @@ +package xuanran.wang.http_test.annotations.request_type; + +import java.lang.annotation.*; + +/** + *

post 请求

+ * + * @author xuanran.wang + * @date 2023/3/10 10:17 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +@Documented +public @interface CusRequestPost { + String url() default ""; +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java new file mode 100644 index 0000000..0fd5c5d --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPut.java @@ -0,0 +1,16 @@ +package xuanran.wang.http_test.annotations.request_type; + +import java.lang.annotation.*; + +/** + *

put 请求

+ * + * @author xuanran.wang + * @date 2023/3/10 10:18 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +@Documented +public @interface CusRequestPut { + String url() default ""; +} diff --git a/src/test/java/xuanran/wang/http_test/constant/RequestUtilConstant.java b/src/test/java/xuanran/wang/http_test/constant/RequestUtilConstant.java new file mode 100644 index 0000000..d8f6c83 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/constant/RequestUtilConstant.java @@ -0,0 +1,15 @@ +package xuanran.wang.http_test.constant; + +/** + *

请求工具常量

+ * + * @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; +} diff --git a/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java b/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java new file mode 100644 index 0000000..143ac83 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java @@ -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; + +/** + *

真实请求对象

+ * + * @author xuanran.wang + * @date 2023/3/14 23:28 + */ +@AllArgsConstructor +@NoArgsConstructor +@Setter +@Getter +public class CusRequestEntity{ + private String url; + private Map headers; + private Map pathParams; + private Object bodyParams; + private int requestType; + private Consumer consumer; + private boolean async; +} diff --git a/src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java b/src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java new file mode 100644 index 0000000..7b75eeb --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java @@ -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; +// +///** +// *

post方法解析

+// * +// * @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) arg; +// }else if(arg instanceof String){ +// String json = JSONObject.toJSONString(arg); +// return JSONObject.parseObject(json, Map.class); +// } +// } +// } +// return new HashMap(); +// } +//} diff --git a/src/test/java/xuanran/wang/http_test/handle/RequestBeforeHandle.java b/src/test/java/xuanran/wang/http_test/handle/RequestBeforeHandle.java new file mode 100644 index 0000000..48faa20 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/handle/RequestBeforeHandle.java @@ -0,0 +1,15 @@ +package xuanran.wang.http_test.handle; + +import xuanran.wang.http_test.entity.CusRequestEntity; + +import java.lang.reflect.Method; + +/** + *

请求前处理

+ * + * @author xuanran.wang + * @date 2023/3/10 11:38 + */ +public interface RequestBeforeHandle { + void handle(CusRequestEntity requestEntity, Method method, Object[] args); +} diff --git a/src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java b/src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java new file mode 100644 index 0000000..6d2d99b --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java @@ -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; +// +///** +// *

请求头处理

+// * +// * @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 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 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; +// } +//} diff --git a/src/test/java/xuanran/wang/http_test/handle/path_handle/CusFieldKeyParseHandle.java b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusFieldKeyParseHandle.java new file mode 100644 index 0000000..19ab94e --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusFieldKeyParseHandle.java @@ -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; + +/** + *

解析方法路径中是否包含占位符 并将参数匹配的key进行替换

+ * + * @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) arg); + } + } + } + } + requestEntity.setUrl(url); + } +} diff --git a/src/test/java/xuanran/wang/http_test/interfaces/CusCreateRequestHeader.java b/src/test/java/xuanran/wang/http_test/interfaces/CusCreateRequestHeader.java new file mode 100644 index 0000000..045d6fd --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/interfaces/CusCreateRequestHeader.java @@ -0,0 +1,13 @@ +package xuanran.wang.http_test.interfaces; + +import java.util.Map; + +/** + *

自定义请求头

+ * + * @author xuanran.wang + * @date 2023/3/10 16:33 + */ +public interface CusCreateRequestHeader { + Map createHeader(); +} diff --git a/src/test/java/xuanran/wang/http_test/proxy/CusUtil.java b/src/test/java/xuanran/wang/http_test/proxy/CusUtil.java new file mode 100644 index 0000000..13f83e5 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/proxy/CusUtil.java @@ -0,0 +1,17 @@ +package xuanran.wang.http_test.proxy; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/3/10 12:44 + */ +public class CusUtil { + + private static final RequestUtil requestUtil = new RequestUtil(); + + public static T getRequestClient(Class t) { + return requestUtil.getRequestClient(t); + } + +} diff --git a/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java b/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java new file mode 100644 index 0000000..f0c7cc2 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java @@ -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; + +/** + *

声明式发送http请求

+ * + * @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 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 params, Map headers) throws IOException { + return httpUtils.apiGet(url, params, headers); + } + + public static boolean isJSON(String str) { + try { + JSON.parse(str); + return true; + } catch (Exception e) { + return false; + } + } +} diff --git a/src/test/java/xuanran/wang/http_test/service/TestService.java b/src/test/java/xuanran/wang/http_test/service/TestService.java new file mode 100644 index 0000000..00e770b --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/service/TestService.java @@ -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; + +/** + *

+ * + * @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 path, + @PostBody Map body, + @CusRequestHeader("hsjhdsad") String test, + @CusPathQuery("test") String test1); + + @CusRequestPost(url = "test/post/sas") + @CusRequestHeader(cusHeaders = {"content-Type: application/json"}, cusHeadersClassPath = "java.fsdfds") + String getStu(@PostBody Map body); +} diff --git a/src/test/java/xuanran/wang/http_test/test/RequestTest.java b/src/test/java/xuanran/wang/http_test/test/RequestTest.java new file mode 100644 index 0000000..ca18084 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/test/RequestTest.java @@ -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; + +/** + *

+ * + * @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 map = new HashMap<>(); + map.put("a","1"); + map.put("b","2"); + HashMap body = new HashMap<>(); + + body.put("a","3"); + body.put("b","4"); + + HashMap path = new HashMap<>(); + + path.put("e","5"); + path.put("f","6"); + requestClient.getStu(map, body, "a", "test1111"); + +// String stu1 = requestClient.getStu(body); + + + } +} diff --git a/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java b/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java index 8257758..563e1dc 100644 --- a/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java +++ b/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java @@ -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; + /** *

上海团校测试类

* @@ -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> params = new ArrayList<>(); List> 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 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 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 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); + } + + /** + * 第一步: + *

+ * 调用ecology注册接口,根据appid进行注册,将返回服务端公钥和Secret信息 + */ + public static Map 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 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; + } + + /** + * 第二步: + *

+ * 通过第一步中注册系统返回信息进行获取token信息 + */ + public static Map 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 datas = JSONUtil.parseObj(data); + //ECOLOGY返回的token + // TODO 为Token缓存设置过期时间 + SYSTEM_CACHE.put("SERVER_TOKEN", StrUtil.nullToEmpty((String) datas.get("token"))); + return datas; + } + + /** + * 第三步: + *

+ * 调用ecology系统的rest接口,请求头部带上token和用户标识认证信息 + * + * @param address ecology系统地址 + * @param api rest api 接口地址(该测试代码仅支持GET请求) + * @param jsonParams 请求参数json串 + *

+ * 注意:ECOLOGY系统所有POST接口调用请求头请设置 "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 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 test = Util.getProperties2Map("test"); + log.info("test => " + JSONObject.toJSONString(test)); + } + + } diff --git a/src/test/java/xuanran/wang/shyl/dataasync/CreateWorkflowTest.java b/src/test/java/xuanran/wang/shyl/dataasync/CreateWorkflowTest.java new file mode 100644 index 0000000..8aedbb5 --- /dev/null +++ b/src/test/java/xuanran/wang/shyl/dataasync/CreateWorkflowTest.java @@ -0,0 +1,192 @@ +package xuanran.wang.shyl.dataasync; + +import aiyh.utils.Util; +import basetest.BaseTest; +import com.alibaba.fastjson.JSONArray; +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 com.api.xuanran.wang.shyl.service.BatchCreateWorkflowService; +import com.api.xuanran.wang.shyl.vo.CreateWfVO; +import ebu7common.youhong.ai.bean.Builder; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.xuanran.wang.shyl.dataasync.entity.StudentClass; +import weaver.xuanran.wang.shyl.dataasync.service.CusDataAsyncService; +import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil; + +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/2/24 13:09 + */ +public class CreateWorkflowTest extends BaseTest { + + private final BatchCreateWorkflowService batchCreateWorkflowService = new BatchCreateWorkflowService(); + private final ProducerMapper producerMapper = Util.getMapper(ProducerMapper.class); + + @Test + public void testA(){ + String json = "[{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"212121\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"cbc7bc14-01ef-4fbc-9a64-07d68ece640d\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"81fdff79-361e-4377-9094-1d4f88b8a258\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"cddc29b7-0fd6-4624-a98f-52e88b466bfb\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"e50787ba-547a-42f2-b0f8-e0e220f22704\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"1d24eef1-ee6e-4d66-9a63-aef642801920\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"3219d315-3bcf-406f-8932-33e9cdf6f443\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"f1789302-835d-4cb3-b24b-fdd5860865f6\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"04977392-1fdb-42f0-a3ef-d1a181c41a07\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"ce09860e-3f31-4790-95fe-5c06700e6262\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"7ce49160-3e66-40cb-9bb2-fb692a17f7b7\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"c5eee9d8-9605-419c-85d1-07eb36cc8bcd\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"3f16559d-e2a9-4f01-a089-4556c4d44554\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"e5f0a91b-be45-4908-9965-1d97a2290717\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"fbb60256-7972-45e2-802a-edc42f20ed64\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"97f8551e-df0b-4559-9219-ffa6d02f049a\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"1a34307b-74fc-4b08-98fb-3433a6276d3e\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"edf54ba8-a29d-4aea-90c6-711d8f045125\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"593fb831-8c0f-4c51-b919-ef9b27643483\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"eb20f0a1-9ee7-44d3-a9e4-fb470af0444e\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"2d5c3eac-0f41-4da7-97b5-8dded1dd1583\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"95fa2685-85db-4f4d-b526-9ea3bac05787\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"ef1e3243-fc3f-439d-a293-0b95fd25234a\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"7dc79466-3fab-4b12-af04-88b9b07493bd\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"43d16081-7a95-47d9-be96-a891ad9ea589\"}],\"workflowId\":\"45\"},{\"requestName\":\"放松放松\",\"mainData\":[{\"fieldName\":\"yysy\",\"fieldValue\":\"测试20230309\"},{\"fieldName\":\"customId\",\"fieldValue\":\"122323\"},{\"fieldName\":\"customId\",\"fieldValue\":\"8b1092b5-604f-4fbe-a73f-b1ab87b937e1\"}],\"workflowId\":\"45\"}] \n"; + JSONArray temp = new JSONArray(); + JSONArray arr = JSONObject.parseObject(json, JSONArray.class); +// for (int i = 0; i < arr.size() - 1; i++) { +// Object o = arr.get(i); +// for (int j = 0; j < 25; j++) { +// temp.add(o); +// } +// } +// arr.addAll(temp); + log.info("jsonarr : \n" + JSONObject.toJSONString(arr)); + log.info("json arr size " + arr.size()); + try { + List res = batchCreateWorkflowService.batchCreateWorkflow(new User(1), arr); + log.info("res => " + res); + }catch (Exception e){ + log.error("批量创建流程异常 : " + e.getMessage()); + } + } + + @Test + public void testB(){ + String url = "https://ecology.yeyaguitu.cn/api/wxr/meeting/cancel"; + String id = "111,112"; + url += "?id="+id; + try { + String encode= java.net.URLEncoder.encode(url, "UTF-8"); + log.info("encode => " + encode); + }catch (Exception e){ + log.error("e => " + e.getMessage()); + } + } + + @Test + public void testC(){ + String json = "{\n" + + "\t\"id\": \"43489ef6-4f48-4c00-b9fd-258bd943434\",\n" + + "\t\"topic\": \"AUTH_CONSOLE_ORG_TOPIC\",\n" + + "\t\"actionType\": \"CREATE_ACTION\",\n" + + "\t\"sendTime\": \"2023-02-18 19:26:25\",\n" + + "\t\"content\": {\n" + + "\t\t\"id\": \"780053000679849931313\",\n" + + "\t\t\"orgCode\": \"ZJJF\",\n" + + "\t\t\"orgName\": \"展馆教学管理部1\",\n" + + "\t\t\"fullName\": \"展馆教学管理部1\",\n" + + "\t\t\"parentId\": \"1\",\n" + + "\t\t\"parentName\": \"\",\n" + + "\t\t\"type\": \"1\",\n" + + "\t\t\"codePath\": \"1/780053000679849984\",\n" + + "\t\t\"namePath\": \"上海青年管理干部学院/展馆教学管理部\",\n" + + "\t\t\"level\": 0,\n" + + "\t\t\"division\": \"\",\n" + + "\t\t\"country\": \"\",\n" + + "\t\t\"region\": \"\",\n" + + "\t\t\"locality\": \"\",\n" + + "\t\t\"street\": \"\",\n" + + "\t\t\"address\": \"\",\n" + + "\t\t\"contact\": \"\",\n" + + "\t\t\"postalCode\": \"\",\n" + + "\t\t\"phone\": \"\",\n" + + "\t\t\"fax\": \"\",\n" + + "\t\t\"email\": \"\",\n" + + "\t\t\"sortIndex\": 1,\n" + + "\t\t\"status\": 1,\n" + + "\t\t\"instId\": \"1\",\n" + + "\t\t\"isPrimary\": 0,\n" + + "\t\t\"reorgNamePath\": false,\n" + + "\t\t\"rows\": 0,\n" + + "\t\t\"pageSize\": 20,\n" + + "\t\t\"pageNumber\": 1,\n" + + "\t\t\"startRow\": 0,\n" + + "\t\t\"endRow\": 0,\n" + + "\t\t\"pageable\": false\n" + + "\t}\n" + + "}"; + RocketConsumerUtil.producerSendMsg("OrgConsumer",json,""); + } + + @Test + public void testD(){ + ProducerCarInfo dsdasds = Builder.builder(ProducerCarInfo::new) + .with(ProducerCarInfo::setStatus, "1") + .with(ProducerCarInfo::setPlateList,"ggsahdsah") + .with(ProducerCarInfo::setCarCode, "2") + .build(); + MQMessage mqMessage = new MQMessage(); + mqMessage.setId(UUID.randomUUID().toString()); + mqMessage.setTopic("OACar"); + mqMessage.setSendTime(TimeUtil.getCurrentTimeString()); + mqMessage.setActionType("create"); + mqMessage.setContent(dsdasds); + String msg = JSONObject.toJSONString(mqMessage); + log.info(Util.logStr("car msg : {}", msg)); + } + + @Test + public void testE(){ + ProducerCarInfo info = null; + String id = "1"; + String carNo = "21212"; + MQMessage mqMessage = new MQMessage(); + mqMessage.setId(UUID.randomUUID().toString()); + mqMessage.setTopic("OA_CAR_TOPIC"); + mqMessage.setSendTime(TimeUtil.getCurrentTimeString()); + mqMessage.setActionType("1"); + if(StringUtils.isNotBlank(id)){ + info = producerMapper.queryCarInfo(id); + }else { + // 车牌号 + info = producerMapper.queryCarNo(carNo); + } + + // 如果能找到就说明是更新或者新增 + if(Objects.isNull(info) && StringUtils.isNotBlank(id)){ //删除状态下 + 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)){ + log.error("查找车辆信息失败!"); + return; + } + carNo = info.getPlateList(); + info.setIdentification("1"); + mqMessage.setContent(info); + String msg = JSONObject.toJSONString(mqMessage); + log.info(Util.logStr("car msg : {}", msg)); + } + + private final CusDataAsyncService dataAsyncService = new CusDataAsyncService(); + + /** + *

更新班级建模条件sql

+ **/ + private static final String updateClassSql = "select id from #{tableName} where classId = ?"; + /** + *

更新学员建模条件sql

+ **/ + private static final String updateStudentSql = "select id from #{tableName} where studentId = ?"; + + @Test + public void testAsync(){ + String baseAddr = "http://114.115.168.220:8191"; + String queryClassUrl = "/educate-plat/api/v1/class/getClassList"; + String classModelId = "97"; + dataAsyncService.asyncData(baseAddr + queryClassUrl, classModelId, StudentClass.class, updateClassSql,"data"); + } +} diff --git a/src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java b/src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java new file mode 100644 index 0000000..98a6fa5 --- /dev/null +++ b/src/test/java/xuanran/wang/shyl/dataasync/MapperTest.java @@ -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; + +/** + *

+ * + * @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 meetingFieldCusConfig = meetingService.getMeetingFieldCusConfig(); + log.info("config : " + JSONObject.toJSONString(meetingFieldCusConfig)); + } + + @Test + public void testB(){ + Map 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 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); + } +} diff --git a/src/test/java/xuanran/wang/traffic_bank/waco_first/WacoFirstTest.java b/src/test/java/xuanran/wang/traffic_bank/waco_first/WacoFirstTest.java index 3699a15..44d1118 100644 --- a/src/test/java/xuanran/wang/traffic_bank/waco_first/WacoFirstTest.java +++ b/src/test/java/xuanran/wang/traffic_bank/waco_first/WacoFirstTest.java @@ -100,4 +100,5 @@ public class WacoFirstTest extends BaseTest { } + } diff --git a/常用命令.md b/常用命令.md new file mode 100644 index 0000000..30107e9 --- /dev/null +++ b/常用命令.md @@ -0,0 +1,6 @@ +# 常用的命令 +### 1.打有宏utils jar包 +```text +cd target/classes/ +jar -cvf aiyh_utils.jar aiyh +``` \ No newline at end of file