From c6a845528d45bfb44591a69dadb44539432d06d0 Mon Sep 17 00:00:00 2001 From: yuxc <653031404@qq.com> Date: 星期五, 12 五月 2023 11:55:06 +0800 Subject: [PATCH] 枚举相关改动 --- Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumitemWrapper.java | 62 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumItemService.java | 50 Source/UBCS-WEB/src/const/code/plCodeKeyattrrepeat.js | 24 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumItemMapper.java | 44 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumController.java | 163 + Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstempattrService.java | 79 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java | 7 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeManagerOid.java | 36 Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumMapper.xml | 52 Source/UBCS-WEB/src/views/omd/omd.vue | 445 ++++ Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/EnumItem.java | 99 + Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/INodeOid.java | 16 Source/UBCS-WEB/src/const/code/codebutton.js | 18 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstemplateServiceImpl.java | 146 Source/UBCS-WEB/src/api/omd/enum.js | 131 + Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/enums/EnumEnum.java | 95 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeMergerOid.java | 26 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumMapper.java | 44 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/constant/VciSystemVarConstants.java | 70 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumItemClient.java | 55 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumFallback.java | 23 Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumItemMapper.xml | 26 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java | 9 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumClient.java | 91 Source/UBCS/ubcs-service-api/ubcs-omd-api/pom.xml | 8 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemClient.java | 51 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumItemVO.java | 35 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java | 806 ++++++++ Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstemplateService.java | 9 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/cache/EnumCache.java | 132 + Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumClient.java | 97 + Source/UBCS-WEB/src/views/code/codebutton.vue | 8 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemFallback.java | 27 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeButtonController.java | 83 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmProductCodeService.java | 1 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/PatternUtil.java | 50 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyTemplateAttrController.java | 135 + Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumService.java | 65 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumVO.java | 63 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/FormulaServiceImpl.java | 1165 ++++++++++++ Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumWrapper.java | 50 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/Md5.java | 82 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClstemplateController.java | 71 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java | 2 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumItemServiceImpl.java | 58 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/Enum.java | 90 Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeButtonMapper.xml | 40 Source/UBCS-WEB/src/const/omd/enum.js | 119 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumItemController.java | 149 + Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumServiceImpl.java | 101 + Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java | 40 /dev/null | 50 Source/UBCS-WEB/src/views/modeling/original.vue | 2 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 389 ++- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java | 5 Source/UBCS-WEB/src/views/code/plCodeKeyattrrepeat.vue | 8 Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeClstemplateMapper.xml | 2 57 files changed, 5,258 insertions(+), 546 deletions(-) diff --git a/Source/UBCS-WEB/src/api/omd/dict.js b/Source/UBCS-WEB/src/api/omd/dict.js deleted file mode 100644 index 957bc5e..0000000 --- a/Source/UBCS-WEB/src/api/omd/dict.js +++ /dev/null @@ -1,89 +0,0 @@ -import request from '@/router/axios'; - -export const getList = (current, size, params) => { - return request({ - url: '/api/ubcs-omd/dict/list', - method: 'get', - params: { - ...params, - current, - size, - } - }) -} - -export const getParentList = (current, size, params) => { - return request({ - url: '/api/ubcs-omd/dict/parent-list', - method: 'get', - params: { - ...params, - current, - size, - } - }) -} - -export const getChildList = (current, size, parentId, params) => { - return request({ - url: '/api/ubcs-omd/dict/child-list', - method: 'get', - params: { - ...params, - current, - size, - parentId: parentId, - } - }) -} - -export const remove = (ids) => { - return request({ - url: '/api/ubcs-omd/dict/remove', - method: 'post', - params: { - ids, - } - }) -} - -export const add = (row) => { - return request({ - url: '/api/ubcs-omd/dict/submit', - method: 'post', - data: row - }) -} - -export const update = (row) => { - return request({ - url: '/api/ubcs-omd/dict/submit', - method: 'post', - data: row - }) -} - - -export const getDict = (id) => { - return request({ - url: '/api/ubcs-omd/dict/detail', - method: 'get', - params: { - id, - } - }) -} -export const getDictTree = () => { - return request({ - url: '/api/ubcs-omd/dict/tree?code=DICT', - method: 'get' - }) -} - -export const getDictionary = (params) => { - return request({ - url: '/api/ubcs-omd/dict/dictionary', - method: 'get', - params, - }) -} diff --git a/Source/UBCS-WEB/src/api/omd/enum.js b/Source/UBCS-WEB/src/api/omd/enum.js new file mode 100644 index 0000000..0427f19 --- /dev/null +++ b/Source/UBCS-WEB/src/api/omd/enum.js @@ -0,0 +1,131 @@ +import request from '@/router/axios'; + +export const getList = (current, size, params) => { + return request({ + url: '/api/ubcs-omd/enum/list', + method: 'get', + params: { + ...params, + current, + size, + } + }) +} + +export const getParentList = (current, size, params) => { + return request({ + url: '/api/ubcs-omd/enum/parent-list', + method: 'get', + params: { + ...params, + current, + size, + } + }) +} + +export const getChildList = (current, size, parentoid, params) => { + debugger; + return request({ + url: '/api/ubcs-omd/enumItem/listAll', + method: 'get', + params: { + ...params, + current, + size, + parentoid: parentoid, + } + }) +} + +export const remove = (ids) => { + return request({ + url: '/api/ubcs-omd/enum/remove', + method: 'post', + params: { + ids, + } + }) +} + +export const removeChild = (ids) => { + return request({ + url: '/api/ubcs-omd/enumItem/remove', + method: 'post', + params: { + ids, + } + }) +} + +export const add = (row) => { + return request({ + url: '/api/ubcs-omd/enum/submit', + method: 'post', + data: row + }) +} + +export const addChild = (row) => { + return request({ + url: '/api/ubcs-omd/enumItem/submit', + method: 'post', + data: row + }) +} + +export const update = (row) => { + debugger; + return request({ + url: '/api/ubcs-omd/enum/submit', + method: 'post', + data: row + }) +} + +export const updateChild = (row) => { + return request({ + url: '/api/ubcs-omd/enumItem/submit', + method: 'post', + data: row + }) +} + + +export const getDict = (oid) => { + return request({ + url: '/api/ubcs-omd/enum/detail', + method: 'get', + params: { + oid, + } + }) +} +export const getDictChild = (oid) => { + return request({ + url: '/api/ubcs-omd/enumItem/detail', + method: 'get', + params: { + oid, + } + }) +} +export const getDictTree = (current, size, params) => { + return request({ + url: '/api/ubcs-omd/enum/tree', + method: 'get', + params: { + ...params, + current, + size, + } + }) +} + +export const getDictionary = (params) => { + return request({ + url: '/api/ubcs-omd/enum/dictionary', + method: 'get', + params, + }) +} diff --git a/Source/UBCS-WEB/src/const/code/codebutton.js b/Source/UBCS-WEB/src/const/code/codebutton.js index 75d3028..f509090 100644 --- a/Source/UBCS-WEB/src/const/code/codebutton.js +++ b/Source/UBCS-WEB/src/const/code/codebutton.js @@ -236,23 +236,23 @@ // }, { label: "鐘舵��", - prop: "lcstatusName", + prop: "lcStatusText", slot: true, display: false }, { label: "鐘舵��", type: "select", - dicUrl: "/api/ubcs-omd/dict/dictionary?code=codeLcstatus", + dicUrl: "/api/ubcs-omd/enum/dictionary?code=codeLcstatus", props: { - label: "dictValue", - value: "dictKey" + label: "itemName", + value: "itemValue" }, dataType: "String", search: true, hide: true, display: true, - prop: "lcstatus", + prop: "lcStatus", rules: [{ required: true, message: "鐘舵��", @@ -288,7 +288,7 @@ // }, { label: "鎸夐挳鐨勪綅缃�", - prop: "usedpositiontypeName", + prop: "usedpositiontypeText", slot: true, display: false }, @@ -296,10 +296,10 @@ label: "鎸夐挳鐨勪綅缃�", type: "select", weight :'140px', - dicUrl: "/api/ubcs-omd/dict/dictionary?code=codeButtonPosition", + dicUrl: "/api/ubcs-omd/enum/dictionary?code=codeButtonPosition", props: { - label: "dictValue", - value: "dictKey" + label: "itemName", + value: "itemValue" }, dataType: "String", search: true, diff --git a/Source/UBCS-WEB/src/const/code/plCodeKeyattrrepeat.js b/Source/UBCS-WEB/src/const/code/plCodeKeyattrrepeat.js index 819f401..146b664 100644 --- a/Source/UBCS-WEB/src/const/code/plCodeKeyattrrepeat.js +++ b/Source/UBCS-WEB/src/const/code/plCodeKeyattrrepeat.js @@ -256,12 +256,12 @@ label: "蹇界暐澶у皬鍐�", prop: "ignorecaseflag", type: "select", - dicUrl: "/api/ubcs-system/dict/dictionary?code=codeKeyFlag", + dicUrl: "/api/ubcs-omd/enum/dictionary?code=codeKeyFlag", dataType: "String", search: true, props: { - label: "dictValue", - value: "dictKey" + label: "itemName", + value: "itemValue" }, rules: [{ required: true, @@ -273,12 +273,12 @@ label: "蹇界暐绌烘牸", prop: "ignorespaceflag", type: "select", - dicUrl: "/api/ubcs-system/dict/dictionary?code=codeKeyFlag", + dicUrl: "/api/ubcs-omd/enum/dictionary?code=codeKeyFlag", dataType: "String", search: true, props: { - label: "dictValue", - value: "dictKey" + label: "itemName", + value: "itemValue" }, rules: [{ required: true, @@ -290,12 +290,12 @@ label: "蹇界暐鍏ㄩ儴绌烘牸", prop: "ignoreallspaceflag", type: "select", - dicUrl: "/api/ubcs-system/dict/dictionary?code=codeKeyFlag", + dicUrl: "/api/ubcs-omd/enum/dictionary?code=codeKeyFlag", dataType: "String", search: true, props: { - label: "dictValue", - value: "dictKey" + label: "itemName", + value: "itemValue" }, rules: [{ required: true, @@ -308,11 +308,11 @@ prop: "ignorewidthflag", type: "select", search: true, - dicUrl: "/api/ubcs-system/dict/dictionary?code=codeKeyFlag", + dicUrl: "/api/ubcs-omd/enum/dictionary?code=codeKeyFlag", dataType: "String", props: { - label: "dictValue", - value: "dictKey" + label: "itemName", + value: "itemValue" }, rules: [{ required: true, diff --git a/Source/UBCS-WEB/src/const/omd/dict.js b/Source/UBCS-WEB/src/const/omd/enum.js similarity index 70% rename from Source/UBCS-WEB/src/const/omd/dict.js rename to Source/UBCS-WEB/src/const/omd/enum.js index d6c8c32..43d3b69 100644 --- a/Source/UBCS-WEB/src/const/omd/dict.js +++ b/Source/UBCS-WEB/src/const/omd/enum.js @@ -14,7 +14,7 @@ column: [ { label: "浠e彿", - prop: "code", + prop: "name", search: true, slot: true, span: 24, @@ -28,7 +28,7 @@ }, { label: "鍚嶇О", - prop: "dictValue", + prop: "label", search: true, align: "center", rules: [ @@ -39,21 +39,21 @@ } ] }, - { - label: "鏋氫妇鎺掑簭", - prop: "sort", - type: "number", - align: "right", - width: 100, - hide: true, - rules: [ - { - required: true, - message: "璇疯緭鍏ユ灇涓炬帓搴�", - trigger: "blur" - } - ] - }, + // { + // label: "鏋氫妇鎺掑簭", + // prop: "sort", + // type: "number", + // align: "right", + // width: 100, + // hide: true, + // rules: [ + // { + // required: true, + // message: "璇疯緭鍏ユ灇涓炬帓搴�", + // trigger: "blur" + // } + // ] + // }, // { // label: "灏佸瓨", // prop: "isSealed", @@ -105,25 +105,25 @@ dialogWidth: 880, dialogClickModal: false, column: [ - { - label: "浠e彿", - prop: "code", - addDisabled: true, - editDisabled: true, - search: true, - span: 24, - hide: true, - rules: [ - { - required: true, - message: "璇疯緭鍏ヤ唬鍙�", - trigger: "blur" - } - ] - }, + // { + // label: "浠e彿", + // prop: "value", + // addDisabled: true, + // editDisabled: true, + // search: true, + // span: 24, + // hide: true, + // rules: [ + // { + // required: true, + // message: "璇疯緭鍏ヤ唬鍙�", + // trigger: "blur" + // } + // ] + // }, { label: "鍚嶇О", - prop: "dictValue", + prop: "name", search: true, align: "center", rules: [ @@ -134,29 +134,30 @@ } ] }, - { - label: "涓婄骇", - prop: "parentId", - type: "tree", - dicData: [], - hide: true, - props: { - label: "title" - }, - addDisabled: true, - editDisabled: true, - rules: [ - { - required: false, - message: "璇烽�夋嫨涓婄骇", - trigger: "click" - } - ] - }, + // { + // label: "涓婄骇", + // prop: "parentoid", + // type: "tree", + // dicData: [], + // hide: true, + // props: { + // label: "title" + // }, + // addDisabled: true, + // editDisabled: true, + // rules: [ + // { + // required: false, + // message: "璇烽�夋嫨涓婄骇", + // trigger: "click" + // } + // ] + // }, { label: "鍊�", - prop: "dictKey", + prop: "value", width: 80, + search: true, rules: [ { required: true, @@ -164,6 +165,10 @@ trigger: "blur" } ] + },{ + label: "鎻忚堪", + prop: "description", + // hide: true }, { label: "鏋氫妇鎺掑簭", @@ -205,10 +210,6 @@ // } // ] // }, - { - label: "鎻忚堪", - prop: "remark", - // hide: true - } + ] }; diff --git a/Source/UBCS-WEB/src/views/code/codebutton.vue b/Source/UBCS-WEB/src/views/code/codebutton.vue index 4dd6593..5f0db1d 100644 --- a/Source/UBCS-WEB/src/views/code/codebutton.vue +++ b/Source/UBCS-WEB/src/views/code/codebutton.vue @@ -68,10 +68,10 @@ ...mapGetters(["permission"]), permissionList() { return { - addBtn: this.vaildData(this.permission.codebutton_add, false), - viewBtn: this.vaildData(this.permission.codebutton_view, false), - delBtn: this.vaildData(this.permission.codebutton_delete, false), - editBtn: this.vaildData(this.permission.codebutton_edit, false) + // addBtn: this.vaildData(this.permission.codebutton_add, false), + // viewBtn: this.vaildData(this.permission.codebutton_view, false), + // delBtn: this.vaildData(this.permission.codebutton_delete, false), + // editBtn: this.vaildData(this.permission.codebutton_edit, false) }; }, ids() { diff --git a/Source/UBCS-WEB/src/views/code/plCodeKeyattrrepeat.vue b/Source/UBCS-WEB/src/views/code/plCodeKeyattrrepeat.vue index 3c36a25..0b48b51 100644 --- a/Source/UBCS-WEB/src/views/code/plCodeKeyattrrepeat.vue +++ b/Source/UBCS-WEB/src/views/code/plCodeKeyattrrepeat.vue @@ -56,10 +56,10 @@ ...mapGetters(["permission"]), permissionList() { return { - addBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_add, false), - viewBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_view, false), - delBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_delete, false), - editBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_edit, false) + // addBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_add, false), + // viewBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_view, false), + // delBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_delete, false), + // editBtn: this.vaildData(this.permission.plCodeKeyattrrepeat_edit, false) }; }, ids() { diff --git a/Source/UBCS-WEB/src/views/modeling/original.vue b/Source/UBCS-WEB/src/views/modeling/original.vue index 8597d3e..910206a 100644 --- a/Source/UBCS-WEB/src/views/modeling/original.vue +++ b/Source/UBCS-WEB/src/views/modeling/original.vue @@ -94,7 +94,7 @@ update, getPage } from "@/api/omd/OmdAttribute"; -import { getDictionary } from "@/api/omd/dict"; +import { getDictionary } from "@/api/omd/enum"; export default { name: "original", diff --git a/Source/UBCS-WEB/src/views/omd/dict.vue b/Source/UBCS-WEB/src/views/omd/dict.vue deleted file mode 100644 index 9476deb..0000000 --- a/Source/UBCS-WEB/src/views/omd/dict.vue +++ /dev/null @@ -1,442 +0,0 @@ -<template> - <basic-container> - <avue-crud - :option="optionParent" - :table-loading="loading" - :data="dataParent" - :page="pageParent" - ref="crud" - v-model="formParent" - :permission="permissionList" - :before-open="beforeOpen" - @row-del="rowDel" - @row-update="rowUpdate" - @row-save="rowSave" - @row-click="handleRowClick" - @search-change="searchChange" - @search-reset="searchReset" - @selection-change="selectionChange" - @current-change="currentChange" - @size-change="sizeChange" - @refresh-change="refreshChange" - @on-load="onLoadParent" - > - <template slot="menuLeft"> - <el-button - type="danger" - size="small" - icon="el-icon-delete" - v-if="permission.dict_delete" - plain - @click="handleDelete" - >鍒� 闄� - </el-button> - </template> - <template slot-scope="scope" slot="menu"> - <el-button - type="text" - icon="el-icon-setting" - size="small" - @click.stop="handleRowClick(scope.row)" - v-if="userInfo.role_name.includes('admin')" - >鏋氫妇閰嶇疆 - </el-button> - </template> - <template slot-scope="{row}" slot="code"> - <el-tag @click="handleRowClick(row)" style="cursor:pointer">{{ row.code }}</el-tag> - </template> - <template slot-scope="{row}" slot="isSealed"> - <el-tag>{{ row.isSealed === 0 ? '鍚�' : '鏄�' }}</el-tag> - </template> - </avue-crud> - <el-dialog :title="`[${dictValue}]鏋氫妇椤归厤缃甡" - append-to-body - :visible.sync="box" - width="1000px"> - <avue-crud - :option="optionChild" - :table-loading="loadingChild" - :data="dataChild" - ref="crudChild" - v-model="formChild" - :permission="permissionList" - :before-open="beforeOpenChild" - :before-close="beforeCloseChild" - @row-del="rowDelChild" - @row-update="rowUpdateChild" - @row-save="rowSaveChild" - @search-change="searchChangeChild" - @search-reset="searchResetChild" - @selection-change="selectionChangeChild" - @current-change="currentChangeChild" - @size-change="sizeChangeChild" - @refresh-change="refreshChangeChild" - @on-load="onLoadChild" - > - <template slot="menuLeft"> - <el-button - type="danger" - size="small" - icon="el-icon-delete" - v-if="permission.dict_delete" - plain - @click="handleDelete" - >鍒� 闄� - </el-button> - </template> -<!-- <template slot-scope="scope" slot="menu">--> -<!-- <el-button--> -<!-- type="text"--> -<!-- icon="el-icon-circle-plus-outline"--> -<!-- size="small"--> -<!-- @click.stop="handleAdd(scope.row,scope.index)"--> -<!-- v-if="userInfo.role_name.includes('admin')"--> -<!-- >鏂板瀛愰」--> -<!-- </el-button>--> -<!-- </template>--> - <template slot-scope="{row}" slot="isSealed"> - <el-tag>{{ row.isSealed === 0 ? '鍚�' : '鏄�' }}</el-tag> - </template> - </avue-crud> - </el-dialog> - </basic-container> -</template> - -<script> - import { - getParentList, - getChildList, - remove, - update, - add, - getDict, - getDictTree - } from "@/api/omd/dict"; - import {optionParent, optionChild} from "@/const/omd/dict"; - import {mapGetters} from "vuex"; - - export default { - data() { - return { - dictValue: '鏆傛棤', - parentId: -1, - formParent: {}, - formChild: {}, - selectionList: [], - query: {}, - box: false, - loading: true, - loadingChild: true, - pageParent: { - pageSize: 10, - pageSizes: [10, 30, 50, 100, 200], - currentPage: 1, - total: 0 - }, - pageChild: { - pageSize: 10, - pageSizes: [10, 30, 50, 100, 200], - currentPage: 1, - total: 0 - }, - dataParent: [], - dataChild: [], - optionParent: optionParent, - optionChild: optionChild, - }; - }, - computed: { - ...mapGetters(["userInfo", "permission"]), - permissionList() { - return { - addBtn: this.vaildData(this.permission.dict_add, false), - delBtn: this.vaildData(this.permission.dict_delete, false), - editBtn: this.vaildData(this.permission.dict_edit, false), - viewBtn: false, - }; - }, - ids() { - let ids = []; - this.selectionList.forEach(ele => { - ids.push(ele.id); - }); - return ids.join(","); - } - }, - mounted() { - this.initData(); - }, - methods: { - initData() { - getDictTree().then(res => { - const column = this.findObject(this.optionChild.column, "parentId"); - column.dicData = res.data.data; - }); - }, - handleAdd(row) { - this.formChild.dictValue = ""; - this.formChild.dictKey = ""; - this.formChild.sort = 0; - this.formChild.isSealed = 0; - this.formChild.remark = ""; - this.formChild.parentId = row.id; - this.$refs.crudChild.rowAdd(); - }, - rowSave(row, done, loading) { - const form = { - ...row, - dictKey: -1, - }; - add(form).then(() => { - this.onLoadParent(this.pageParent); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - done(); - }, error => { - window.console.log(error); - loading(); - }); - }, - rowUpdate(row, index, done, loading) { - update(row).then(() => { - this.onLoadParent(this.pageParent); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - this.onLoadChild(this.pageChild); - done(); - }, error => { - window.console.log(error); - loading(); - }); - }, - rowDel(row) { - this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning" - }) - .then(() => { - return remove(row.id); - }) - .then(() => { - this.onLoadParent(this.pageParent); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - }); - }, - handleRowClick(row) { - this.query = {}; - this.parentId = row.id; - this.dictValue = row.dictValue; - - const code = this.findObject(this.optionChild.column, "code"); - code.value = row.code; - const parentId = this.findObject(this.optionChild.column, "parentId"); - parentId.value = row.id; - - this.box = true; - this.onLoadChild(this.pageChild); - }, - searchReset() { - this.query = {}; - this.onLoadParent(this.pageParent); - }, - searchChange(params, done) { - this.query = params; - this.pageParent.currentPage = 1; - this.onLoadParent(this.pageParent, params); - done(); - }, - selectionChange(list) { - this.selectionList = list; - }, - selectionClear() { - this.selectionList = []; - this.$refs.crud.toggleSelection(); - }, - handleDelete() { - if (this.selectionList.length === 0) { - this.$message.warning("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�"); - return; - } - this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning" - }) - .then(() => { - return remove(this.ids); - }) - .then(() => { - this.onLoadParent(this.pageParent); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - this.$refs.crud.toggleSelection(); - }); - }, - beforeOpen(done, type) { - if (["edit", "view"].includes(type)) { - getDict(this.formParent.id).then(res => { - this.formParent = res.data.data; - }); - } - done(); - }, - currentChange(currentPage) { - this.pageParent.currentPage = currentPage; - }, - sizeChange(pageSize) { - this.pageParent.pageSize = pageSize; - }, - refreshChange() { - this.onLoadParent(this.pageParent, this.query); - }, - rowSaveChild(row, done, loading) { - add(row).then(() => { - this.onLoadChild(this.pageChild); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - done(); - }, error => { - window.console.log(error); - loading(); - }); - }, - rowUpdateChild(row, index, done, loading) { - update(row).then(() => { - this.onLoadChild(this.pageChild); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - done(); - }, error => { - window.console.log(error); - loading(); - }); - }, - rowDelChild(row) { - this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning" - }) - .then(() => { - return remove(row.id); - }) - .then(() => { - this.onLoadChild(this.pageChild); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - }); - }, - searchResetChild() { - this.query = {}; - this.onLoadChild(this.pageChild); - }, - searchChangeChild(params, done) { - this.query = params; - this.pageChild.currentPage = 1; - this.onLoadChild(this.pageChild, params); - done(); - }, - selectionChangeChild(list) { - this.selectionList = list; - }, - selectionClearChild() { - this.selectionList = []; - this.$refs.crudChild.toggleSelection(); - }, - handleDeleteChild() { - if (this.selectionList.length === 0) { - this.$message.warning("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�"); - return; - } - this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning" - }) - .then(() => { - return remove(this.ids); - }) - .then(() => { - this.onLoadChild(this.pageChild); - this.$message({ - type: "success", - message: "鎿嶄綔鎴愬姛!" - }); - this.$refs.crudChild.toggleSelection(); - }); - }, - beforeOpenChild(done, type) { - if (["add", "edit"].includes(type)) { - this.initData(); - } - if (["edit", "view"].includes(type)) { - getDict(this.formChild.id).then(res => { - this.formChild = res.data.data; - }); - } - done(); - }, - beforeCloseChild(done) { - this.$refs.crudChild.value.parentId = this.parentId; - this.$refs.crudChild.option.column.filter(item => { - if (item.prop === "parentId") { - item.value = this.parentId; - } - }); - done(); - }, - currentChangeChild(currentPage) { - this.pageChild.currentPage = currentPage; - }, - sizeChangeChild(pageSize) { - this.pageChild.pageSize = pageSize; - }, - refreshChangeChild() { - this.onLoadChild(this.pageChild, this.query); - }, - onLoadParent(page, params = {}) { - this.loading = true; - getParentList( - page.currentPage, - page.pageSize, - Object.assign(params, this.query) - ).then(res => { - const data = res.data.data; - this.pageParent.total = data.total; - this.dataParent = data.records; - this.loading = false; - this.selectionClear(); - }); - }, - onLoadChild(page, params = {}) { - this.loadingChild = true; - getChildList( - page.currentPage, - page.pageSize, - this.parentId, - Object.assign(params, this.query) - ).then(res => { - this.dataChild = res.data.data; - this.loadingChild = false; - this.selectionClear(); - }); - } - } - }; -</script> diff --git a/Source/UBCS-WEB/src/views/omd/omd.vue b/Source/UBCS-WEB/src/views/omd/omd.vue new file mode 100644 index 0000000..9808f1d --- /dev/null +++ b/Source/UBCS-WEB/src/views/omd/omd.vue @@ -0,0 +1,445 @@ +<template> + <basic-container> + <avue-crud + :option="optionParent" + :table-loading="loading" + :data="dataParent" + :page="pageParent" + ref="crud" + v-model="formParent" + :permission="permissionList" + :before-open="beforeOpen" + @row-del="rowDel" + @row-update="rowUpdate" + @row-save="rowSave" + @row-click="handleRowClick" + @search-change="searchChange" + @search-reset="searchReset" + @selection-change="selectionChange" + @current-change="currentChange" + @size-change="sizeChange" + @refresh-change="refreshChange" + @on-load="onLoadParent" + > + <template slot="menuLeft"> + <el-button + type="danger" + size="small" + icon="el-icon-delete" + v-if="permission.dict_delete" + plain + @click="handleDelete" + >鍒� 闄� + </el-button> + </template> + <template slot-scope="scope" slot="menu"> + <el-button + type="text" + icon="el-icon-setting" + size="small" + @click.stop="handleRowClick(scope.row)" + v-if="userInfo.role_name.includes('admin')" + >鏋氫妇閰嶇疆 + </el-button> + </template> + <template slot-scope="{row}" slot="code"> + <el-tag @click="handleRowClick(row)" style="cursor:pointer">{{ row.code }}</el-tag> + </template> + <template slot-scope="{row}" slot="isSealed"> + <el-tag>{{ row.isSealed === 0 ? '鍚�' : '鏄�' }}</el-tag> + </template> + </avue-crud> + <el-dialog :title="`[${name}]鏋氫妇椤归厤缃甡" + append-to-body + :visible.sync="box" + width="1000px"> + <avue-crud + :option="optionChild" + :table-loading="loadingChild" + :data="dataChild" + ref="crudChild" + v-model="formChild" + :permission="permissionList" + :before-open="beforeOpenChild" + :before-close="beforeCloseChild" + @row-del="rowDelChild" + @row-update="rowUpdateChild" + @row-save="rowSaveChild" + @search-change="searchChangeChild" + @search-reset="searchResetChild" + @selection-change="selectionChangeChild" + @current-change="currentChangeChild" + @size-change="sizeChangeChild" + @refresh-change="refreshChangeChild" + @on-load="onLoadChild" + > + <template slot="menuLeft"> + <el-button + type="danger" + size="small" + icon="el-icon-delete" + v-if="permission.dict_delete" + plain + @click="handleDeleteChild" + >鍒� 闄� + </el-button> + </template> + <!-- <template slot-scope="scope" slot="menu">--> + <!-- <el-button--> + <!-- type="text"--> + <!-- icon="el-icon-circle-plus-outline"--> + <!-- size="small"--> + <!-- @click.stop="handleAdd(scope.row,scope.index)"--> + <!-- v-if="userInfo.role_name.includes('admin')"--> + <!-- >鏂板瀛愰」--> + <!-- </el-button>--> + <!-- </template>--> + <template slot-scope="{row}" slot="isSealed"> + <el-tag>{{ row.isSealed === 0 ? '鍚�' : '鏄�' }}</el-tag> + </template> + </avue-crud> + </el-dialog> + </basic-container> +</template> + +<script> +import { + getParentList, + getChildList, + remove, + update, + add, + getDict, + getDictTree, addChild, updateChild, getDictChild, removeChild +} from "@/api/omd/enum"; +import {optionParent, optionChild} from "@/const/omd/enum"; +import {mapGetters} from "vuex"; + +export default { + data() { + return { + dictValue: '鏆傛棤', + parentoid: -1, + formParent: {}, + formChild: {}, + selectionList: [], + query: {}, + box: false, + loading: true, + loadingChild: true, + pageParent: { + pageSize: 10, + pageSizes: [10, 30, 50, 100, 200], + currentPage: 1, + total: 0 + }, + pageChild: { + pageSize: 10, + pageSizes: [10, 30, 50, 100, 200], + currentPage: 1, + total: 0 + }, + dataParent: [], + dataChild: [], + optionParent: optionParent, + optionChild: optionChild, + }; + }, + computed: { + ...mapGetters(["userInfo", "permission"]), + permissionList() { + return { + addBtn: this.vaildData(this.permission.dict_add, false), + delBtn: this.vaildData(this.permission.dict_delete, false), + editBtn: this.vaildData(this.permission.dict_edit, false), + viewBtn: false, + }; + }, + ids() { + let ids = []; + this.selectionList.forEach(ele => { + ids.push(ele.oid); + }); + return ids.join(","); + } + }, + mounted() { + this.initData(); + }, + methods: { + initData() { + getDictTree(this.pageParent.currentPage, + this.pageParent.pageSize, + this.query).then(res => { + const column = this.findObject(this.optionChild.column, "parentoid"); + column.dicData = res.data.data; + }); + }, + handleAdd(row) { + this.formChild.value = ""; + this.formChild.name = ""; + this.formChild.sort = 0; + this.formChild.isSealed = 0; + this.formChild.remark = ""; + this.formChild.parentoid = row.oid; + this.$refs.crudChild.rowAdd(); + }, + rowSave(row, done, loading) { + const form = { + ...row, + dictKey: -1, + }; + add(form).then(() => { + this.onLoadParent(this.pageParent); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + done(); + }, error => { + window.console.log(error); + loading(); + }); + }, + rowUpdate(row, index, done, loading) { + update(row).then(() => { + this.onLoadParent(this.pageParent); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + this.onLoadChild(this.pageChild); + done(); + }, error => { + window.console.log(error); + loading(); + }); + }, + rowDel(row) { + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return remove(row.oid); + }) + .then(() => { + this.onLoadParent(this.pageParent); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + }); + }, + handleRowClick(row) { + this.query = {}; + this.parentId = row.oid; + this.name = row.name; + + const code = this.findObject(this.optionChild.column, "value"); + code.value = row.code; + // const parentoid = this.findObject(this.optionChild.column, "parentoid"); + this.parentoid = row.oid; + + this.box = true; + this.onLoadChild(this.pageChild); + }, + searchReset() { + this.query = {}; + this.onLoadParent(this.pageParent); + }, + searchChange(params, done) { + this.query = params; + this.pageParent.currentPage = 1; + this.onLoadParent(this.pageParent, params); + done(); + }, + selectionChange(list) { + this.selectionList = list; + }, + selectionClear() { + this.selectionList = []; + this.$refs.crud.toggleSelection(); + }, + handleDelete() { + if (this.selectionList.length === 0) { + this.$message.warning("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�"); + return; + } + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return remove(this.ids); + }) + .then(() => { + this.onLoadParent(this.pageParent); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + this.$refs.crud.toggleSelection(); + }); + }, + beforeOpen(done, type) { + if (["edit", "view"].includes(type)) { + getDict(this.formParent.oid).then(res => { + this.formParent = res.data.data; + }); + } + done(); + }, + currentChange(currentPage) { + this.pageParent.currentPage = currentPage; + }, + sizeChange(pageSize) { + this.pageParent.pageSize = pageSize; + }, + refreshChange() { + this.onLoadParent(this.pageParent, this.query); + }, + rowSaveChild(row, done, loading) { + row.parentoid = this.parentoid; + addChild(row).then(() => { + this.onLoadChild(this.pageChild); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + done(); + }, error => { + window.console.log(error); + loading(); + }); + }, + rowUpdateChild(row, index, done, loading) { + updateChild(row).then(() => { + this.onLoadChild(this.pageChild); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + done(); + }, error => { + window.console.log(error); + loading(); + }); + }, + rowDelChild(row) { + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return removeChild(row.oid); + }) + .then(() => { + this.onLoadChild(this.pageChild); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + }); + }, + searchResetChild() { + this.query = {}; + this.onLoadChild(this.pageChild); + }, + searchChangeChild(params, done) { + this.query = params; + this.pageChild.currentPage = 1; + this.onLoadChild(this.pageChild, params); + done(); + }, + selectionChangeChild(list) { + this.selectionList = list; + }, + selectionClearChild() { + this.selectionList = []; + this.$refs.crudChild.toggleSelection(); + }, + handleDeleteChild() { + if (this.selectionList.length === 0) { + this.$message.warning("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�"); + return; + } + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return removeChild(this.ids); + }) + .then(() => { + this.onLoadChild(this.pageChild); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + this.$refs.crudChild.toggleSelection(); + }); + }, + beforeOpenChild(done, type) { + if (["add", "edit"].includes(type)) { + this.initData(); + } + if (["edit", "view"].includes(type)) { + getDictChild(this.formChild.oid).then(res => { + this.formChild = res.data.data; + }); + } + done(); + }, + beforeCloseChild(done) { + this.$refs.crudChild.value.parentId = this.parentId; + this.$refs.crudChild.option.column.filter(item => { + if (item.prop === "parentId") { + item.value = this.parentId; + } + }); + done(); + }, + currentChangeChild(currentPage) { + this.pageChild.currentPage = currentPage; + }, + sizeChangeChild(pageSize) { + this.pageChild.pageSize = pageSize; + }, + refreshChangeChild() { + this.onLoadChild(this.pageChild, this.query); + }, + onLoadParent(page, params = {}) { + this.loading = true; + getParentList( + page.currentPage, + page.pageSize, + Object.assign(params, this.query) + ).then(res => { + const data = res.data.data; + this.pageParent.total = data.total; + this.dataParent = data.records; + this.loading = false; + this.selectionClear(); + }); + }, + onLoadChild(page, params = {}) { + this.loadingChild = true; + getChildList( + page.currentPage, + page.pageSize, + this.parentoid, + Object.assign(params, this.query) + ).then(res => { + this.dataChild = res.data.data; + this.loadingChild = false; + this.selectionClear(); + }); + } + } +}; +</script> diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/pom.xml b/Source/UBCS/ubcs-service-api/ubcs-omd-api/pom.xml index c17ea62..69dc113 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/pom.xml +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/pom.xml @@ -14,4 +14,12 @@ <version>${bladex.project.version}</version> <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>com.vci.ubcs</groupId> + <artifactId>ubcs-util-api</artifactId> + <version>3.0.1.RELEASE</version> + </dependency> + </dependencies> + </project> diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/cache/DictCache.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/cache/DictCache.java deleted file mode 100644 index 12ff05b..0000000 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/cache/DictCache.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 搴勯獮 (smallchill@163.com) - */ -package com.vci.ubcs.omd.cache; - -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.enums.DictEnum; -import com.vci.ubcs.omd.feign.IDictClient; -import org.springblade.core.cache.utils.CacheUtil; -import org.springblade.core.secure.utils.AuthUtil; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.SpringUtil; -import org.springblade.core.tool.utils.StringPool; - -import java.util.List; - -import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; - -/** - * 涓氬姟瀛楀吀缂撳瓨宸ュ叿绫� - * - * @author Chill - */ -public class DictCache { - - private static final String DICT_ID = "dict:id"; - private static final String DICT_VALUE = "dict:value"; - private static final String DICT_LIST = "dict:list"; - - private static IDictClient dictClient; - - private static IDictClient getDictClient() { - if (dictClient == null) { - dictClient = SpringUtil.getBean(IDictClient.class); - } - return dictClient; - } - - /** - * 鑾峰彇瀛楀吀瀹炰綋 - * - * @param id 涓婚敭 - * @return DictBiz - */ - public static Dict getById(Long id) { - String keyPrefix = DICT_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); - return CacheUtil.get(DICT_CACHE, keyPrefix, id, () -> { - R<Dict> result = getDictClient().getById(id); - return result.getData(); - }); - } - - /** - * 鑾峰彇瀛楀吀鍊� - * - * @param code 瀛楀吀缂栧彿鏋氫妇 - * @param dictKey Integer鍨嬪瓧鍏搁敭 - * @return String - */ - public static String getValue(DictEnum code, Integer dictKey) { - return getValue(code.getName(), dictKey); - } - - - /** - * 鑾峰彇瀛楀吀鍊� - * - * @param code 瀛楀吀缂栧彿 - * @param dictKey Integer鍨嬪瓧鍏搁敭 - * @return String - */ - public static String getValue(String code, Integer dictKey) { - String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); - return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, String.valueOf(dictKey), () -> { - R<String> result = getDictClient().getValue(code, String.valueOf(dictKey)); - return result.getData(); - }); - } - - /** - * 鑾峰彇瀛楀吀鍊� - * - * @param code 瀛楀吀缂栧彿鏋氫妇 - * @param dictKey String鍨嬪瓧鍏搁敭 - * @return String - */ - public static String getValue(DictEnum code, String dictKey) { - return getValue(code.getName(), dictKey); - } - - /** - * 鑾峰彇瀛楀吀鍊� - * - * @param code 瀛楀吀缂栧彿 - * @param dictKey String鍨嬪瓧鍏搁敭 - * @return String - */ - public static String getValue(String code, String dictKey) { - String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); - return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> { - R<String> result = getDictClient().getValue(code, dictKey); - return result.getData(); - }); - } - - /** - * 鑾峰彇瀛楀吀闆嗗悎 - * - * @param code 瀛楀吀缂栧彿 - * @return List<DictBiz> - */ - public static List<Dict> getList(String code) { - String keyPrefix = DICT_LIST.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); - return CacheUtil.get(DICT_CACHE, keyPrefix, code, () -> { - R<List<Dict>> result = getDictClient().getList(code); - return result.getData(); - }); - } - -} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/cache/EnumCache.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/cache/EnumCache.java new file mode 100644 index 0000000..ba9f2ac --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/cache/EnumCache.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.cache; + +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.enums.EnumEnum; +import com.vci.ubcs.omd.feign.IEnumClient; +import com.vci.ubcs.omd.vo.EnumVO; +import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.SpringUtil; +import org.springblade.core.tool.utils.StringPool; + +import java.util.List; +/** + * 涓氬姟瀛楀吀缂撳瓨宸ュ叿绫� + * + * @author Chill + */ +public class EnumCache { + + private static final String ENUM_ID = "enum:id"; + private static final String ENUM_VALUE = "enum:value"; + private static final String ENUM_LIST = "enum:list"; + private static final String ENUM_CACHE = "blade:enum"; + + private static IEnumClient iEnumClient; + + private static IEnumClient getIOmdEnumClient() { + if (iEnumClient == null) { + iEnumClient = SpringUtil.getBean(IEnumClient.class); + } + return iEnumClient; + } + + /** + * 鑾峰彇瀛楀吀瀹炰綋 + * + * @param oid 涓婚敭 + * @return Enum + */ + public static Enum getById(String oid) { + String keyPrefix = ENUM_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); + return CacheUtil.get(ENUM_CACHE, keyPrefix, oid, () -> { + R<Enum> result = getIOmdEnumClient().getById(oid); + return result.getData(); + }); + } + + /** + * 鑾峰彇瀛楀吀鍊� + * + * @param name 瀛楀吀缂栧彿鏋氫妇 + * @param nameChild Integer鍨嬪瓧鍏搁敭 + * @return String + */ + public static String getValue(EnumEnum name, Integer nameChild) { + return getValue(name.getName(), nameChild); + } + + + /** + * 鑾峰彇瀛楀吀鍊� + * + * @param name 鐖跺瓧鍏哥紪鍙� + * @param nameChild 瀛愬瓧鍏哥紪鍙� + * @return String + */ + public static String getValue(String name, Integer nameChild) { + String keyPrefix = ENUM_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); + return CacheUtil.get(ENUM_CACHE, keyPrefix + name + StringPool.COLON, String.valueOf(nameChild), () -> { + R<String> result = getIOmdEnumClient().getValue(name, String.valueOf(nameChild)); + return result.getData(); + }); + } + + /** + * 鑾峰彇瀛楀吀鍊� + * + * @param name 瀛楀吀缂栧彿鏋氫妇 + * @param nameChild String鍨嬪瓧鍏搁敭 + * @return String + */ + public static String getValue(EnumEnum name, String nameChild) { + return getValue(name.getName(), nameChild); + } + + /** + * 鑾峰彇瀛楀吀鍊� + * + * @param code 瀛楀吀缂栧彿 + * @param dictKey String鍨嬪瓧鍏搁敭 + * @return String + */ + public static String getValue(String code, String dictKey) { + String keyPrefix = ENUM_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); + return CacheUtil.get(ENUM_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> { + R<String> result = getIOmdEnumClient().getValue(code, dictKey); + return result.getData(); + }); + } + + /** + * 鑾峰彇瀛楀吀闆嗗悎 + * + * @param name 瀛楀吀缂栧彿 + * @return List<EnumVO> + */ + public static List<EnumVO> getList(String name) { + String keyPrefix = ENUM_LIST.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); + return CacheUtil.get(ENUM_CACHE, keyPrefix, name, () -> { + R<List<EnumVO>> result = getIOmdEnumClient().getList(name); + return result.getData(); + }); + } + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/Dict.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/Dict.java deleted file mode 100644 index 29ee3e6..0000000 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/Dict.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 搴勯獮 (smallchill@163.com) - */ -package com.vci.ubcs.omd.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.apache.ibatis.type.Alias; - -import java.io.Serializable; - -/** - * 瀹炰綋绫� - * - * @author Chill - */ -@Data -@TableName("pl_sys_dict") -@Alias("pl_sys_dict_omd") -@ApiModel(value = "Dict瀵硅薄", description = "Dict瀵硅薄") -public class Dict implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * 涓婚敭 - */ - @JsonSerialize(using = ToStringSerializer.class) - @ApiModelProperty(value = "涓婚敭") - @TableId(value = "id", type = IdType.ASSIGN_ID) - private Long id; - - /** - * 鐖朵富閿� - */ - @JsonSerialize(using = ToStringSerializer.class) - @ApiModelProperty(value = "鐖朵富閿�") - private Long parentId; - - /** - * 瀛楀吀鐮� - */ - @ApiModelProperty(value = "鏋氫妇鐮�") - private String code; - - /** - * 瀛楀吀鍊� - */ - @ApiModelProperty(value = "鏋氫妇鍊�") - private String dictKey; - - /** - * 瀛楀吀鍚嶇О - */ - @ApiModelProperty(value = "鏋氫妇鍚嶇О") - private String dictValue; - - /** - * 鎺掑簭 - */ - @ApiModelProperty(value = "鎺掑簭") - private Integer sort; - - /** - * 瀛楀吀澶囨敞 - */ - @ApiModelProperty(value = "鏋氫妇澶囨敞") - private String remark; - - /** - * 鏄惁宸插皝瀛� - */ - @ApiModelProperty(value = "鏄惁宸插皝瀛�") - private Integer isSealed; - - /** - * 鏄惁宸插垹闄� - */ - @TableLogic - @ApiModelProperty(value = "鏄惁宸插垹闄�") - private Integer isDeleted; - - -} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/Enum.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/Enum.java new file mode 100644 index 0000000..6f48438 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/Enum.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.Date; + +/** + * 鏋氫妇瀹氫箟 瀹炰綋绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@Data +@TableName("PL_OMD_ENUM") +@ApiModel(value = "OmdEnum瀵硅薄", description = "鏋氫妇瀹氫箟") +//@EqualsAndHashCode(callSuper = true) +public class Enum implements Serializable { + private static final long serialVersionUID = 1L; + /** + * + */ + @TableId(value = "oid", type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "") + private String oid; + /** + * + */ + @ApiModelProperty(value = "") + private String name; + /** + * + */ + @ApiModelProperty(value = "") + private String label; + /** + * + */ + @ApiModelProperty(value = "") + private Date ts; + /** + * + */ + @ApiModelProperty(value = "") + private String creator; + /** + * + */ + @ApiModelProperty(value = "") + private Date createtime; + /** + * + */ + @ApiModelProperty(value = "") + private String modifier; + /** + * + */ + @ApiModelProperty(value = "") + private Date modifytime; + /** + * + */ + @ApiModelProperty(value = "") + private String remark; + + + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/EnumItem.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/EnumItem.java new file mode 100644 index 0000000..4ab81a4 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/entity/EnumItem.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.Date; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 瀹炰綋绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@Data +@TableName("PL_OMD_ENUMITEM") +@ApiModel(value = "OmdEnumitem瀵硅薄", description = "鏋氫妇瀹氫箟瀛愯〃") +//@EqualsAndHashCode(callSuper = true) +public class EnumItem implements Serializable { + private static final long serialVersionUID = 1L; + /** + * + */ + @ApiModelProperty(value = "") + @TableId(value = "oid", type = IdType.ASSIGN_ID) + private String oid; + /** + * + */ + @ApiModelProperty(value = "") + private String name; + /** + * + */ + @ApiModelProperty(value = "") + private String value; + /** + * + */ + @ApiModelProperty(value = "") + private String description; + /** + * + */ + @ApiModelProperty(value = "") + private Date ts; + /** + * + */ + @ApiModelProperty(value = "") + private String creator; + /** + * + */ + @ApiModelProperty(value = "") + private Date createtime; + /** + * + */ + @ApiModelProperty(value = "") + private String modifier; + /** + * + */ + @ApiModelProperty(value = "") + private Date modifytime; + /** + * + */ + @ApiModelProperty(value = "") + private String parentoid; + + /** + * + */ + @ApiModelProperty(value = "") + private Integer sort; + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/enums/EnumEnum.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/enums/EnumEnum.java new file mode 100644 index 0000000..bfa9ab6 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/enums/EnumEnum.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 绯荤粺瀛楀吀鏋氫妇绫� + * + * @author Chill + */ +@Getter +@AllArgsConstructor +public enum EnumEnum { + + /** + * 鎬у埆 + */ + SEX("sex"), + /** + * 閫氱煡绫诲瀷 + */ + NOTICE("notice"), + /** + * 鑿滃崟绫诲瀷 + */ + MENU_CATEGORY("menu_category"), + /** + * 鎸夐挳鍔熻兘 + */ + BUTTON_FUNC("button_func"), + /** + * 鏄惁 + */ + YES_NO("yes_no"), + /** + * 娴佺▼绫诲瀷 + */ + FLOW("flow"), + /** + * 鏈烘瀯绫诲瀷 + */ + ORG_CATEGORY("org_category"), + /** + * 鏁版嵁鏉冮檺 + */ + DATA_SCOPE_TYPE("data_scope_type"), + /** + * 鎺ュ彛鏉冮檺 + */ + API_SCOPE_TYPE("api_scope_type"), + /** + * 鏉冮檺绫诲瀷 + */ + SCOPE_CATEGORY("scope_category"), + /** + * 瀵硅薄瀛樺偍绫诲瀷 + */ + OSS("oss"), + /** + * 鐭俊鏈嶅姟绫诲瀷 + */ + SMS("sms"), + /** + * 宀椾綅绫诲瀷 + */ + POST_CATEGORY("post_category"), + /** + * 琛屾斂鍖哄垝 + */ + REGION("region"), + /** + * 鐢ㄦ埛骞冲彴 + */ + USER_TYPE("user_type"), + ; + + final String name; + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClient.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClient.java deleted file mode 100644 index bd14e19..0000000 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClient.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 搴勯獮 (smallchill@163.com) - */ -package com.vci.ubcs.omd.feign; - - -import com.vci.ubcs.omd.entity.Dict; -import org.springblade.core.launch.constant.AppConstant; -import org.springblade.core.tool.api.R; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; -import java.util.List; - -/** - * Feign鎺ュ彛绫� - * - * @author Chill - */ -@FeignClient( - value = AppConstant.APPLICATION_NAME_OMD, - fallback = IDictClientFallback.class -) -public interface IDictClient { - - String API_PREFIX = "/client"; - String GET_BY_ID = API_PREFIX + "/dict/get-by-id"; - String GET_VALUE = API_PREFIX + "/dict/get-value"; - String GET_LIST = API_PREFIX + "/dict/get-list"; - String CHECK_VALUE = API_PREFIX + "/dict/check-value"; - - /** - * 鑾峰彇瀛楀吀瀹炰綋 - * - * @param id 涓婚敭 - * @return - */ - @GetMapping(GET_BY_ID) - R<Dict> getById(@RequestParam("id") Long id); - - /** - * 鑾峰彇瀛楀吀琛ㄥ搴斿�� - * - * @param code 瀛楀吀缂栧彿 - * @param dictKey 瀛楀吀搴忓彿 - * @return - */ - @GetMapping(GET_VALUE) - R<String> getValue(@RequestParam("code") String code, @RequestParam("dictKey") String dictKey); - - /** - * 鑾峰彇瀛楀吀琛� - * - * @param code 瀛楀吀缂栧彿 - * @return - */ - @GetMapping(GET_LIST) - R<List<Dict>> getList(@RequestParam("code") String code); - - /** - * 妫�鏌ュ瓧鍏告槸鍚﹀瓨鍦紝瀛樺湪鍗宠繑鍥烇紝涓嶅瓨鍦ㄦ柊澧� - * - * @param dict 瀛楀吀鏁版嵁 - * @return - */ - @GetMapping(CHECK_VALUE) - R getCheck(@Valid @RequestBody Dict dict); - -} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumClient.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumClient.java new file mode 100644 index 0000000..3fe4fd4 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumClient.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.feign; + +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumVO; +import org.springblade.core.launch.constant.AppConstant; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * 鏋氫妇瀹氫箟 Feign鎺ュ彛绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@FeignClient( + value = AppConstant.APPLICATION_NAME_OMD, + fallback = IEnumFallback.class +) +public interface IEnumClient { + + String API_PREFIX = "/client"; + String TOP = API_PREFIX + "/enum/top"; + String GET_BY_ID = API_PREFIX + "/enum/get-by-oid"; + String GET_BYCHILD_ID = API_PREFIX + "/enum/get-byChild-oid"; + String GET_VALUE = API_PREFIX + "/enum/get-value"; + String GET_LIST = API_PREFIX + "/enum/get-list"; + + /** + * 鑾峰彇鏋氫妇瀹氫箟鍒楄〃 + * + * @param current 椤靛彿 + * @param size 椤垫暟 + * @return BladePage + */ + @GetMapping(TOP) + BladePage<Enum> top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); + + /** + * 鑾峰彇鏋氫妇瀹氫箟鍒楄〃 + * + * @param name 鐖惰妭鐐筺ame + * @param nameChild 瀛愯妭鐐筺ame + * @return BladePage + */ + @GetMapping(GET_VALUE) + R<String> getValue(@RequestParam("name") String name,@RequestParam("nameChild") String nameChild); + + /** + * 鑾峰彇瀛楀吀瀹炰綋 + * + * @param oid 涓婚敭 + * @return + */ + @GetMapping(GET_BY_ID) + R<Enum> getById(@RequestParam("oid") String oid); + + /** + * 鑾峰彇瀛楀吀瀹炰綋 + * + * @param oid 涓婚敭 + * @return + */ + @GetMapping(GET_BYCHILD_ID) + R<EnumItem> getByChildId(@RequestParam("oid") String oid); + + /** + * 鑾峰彇瀛楀吀琛� + * + * @param name 鏋氫妇缂栧彿 + * @return + */ + @GetMapping(GET_LIST) + R<List<EnumVO>> getList(@RequestParam("name") String name); + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClientFallback.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumFallback.java similarity index 70% rename from Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClientFallback.java rename to Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumFallback.java index 36e1569..32a8581 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClientFallback.java +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumFallback.java @@ -16,8 +16,11 @@ */ package com.vci.ubcs.omd.feign; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumVO; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.tool.api.R; -import com.vci.ubcs.omd.entity.Dict; import org.springframework.stereotype.Component; import java.util.List; @@ -27,25 +30,31 @@ * * @author Chill */ -@Component("Dictclient2") -public class IDictClientFallback implements IDictClient { +@Component +public class IEnumFallback implements IEnumClient { @Override - public R<Dict> getById(Long id) { + public BladePage<Enum> top(Integer current, Integer size) { + return null; + } + + @Override + public R<String> getValue(String name, String nameChild) { return R.fail("鑾峰彇鏁版嵁澶辫触"); } @Override - public R<String> getValue(String code, String dictKey) { + public R<Enum> getById(String oid) { return R.fail("鑾峰彇鏁版嵁澶辫触"); } @Override - public R<List<Dict>> getList(String code) { + public R<EnumItem> getByChildId(String oid) { return R.fail("鑾峰彇鏁版嵁澶辫触"); } @Override - public R getCheck(Dict dict) { + public R<List<EnumVO>> getList(String name) { return R.fail("鑾峰彇鏁版嵁澶辫触"); } + } diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemClient.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemClient.java new file mode 100644 index 0000000..7168efc --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemClient.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.feign; + +import com.vci.ubcs.omd.entity.EnumItem; +import org.springblade.core.launch.constant.AppConstant; +import org.springblade.core.mp.support.BladePage; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 Feign鎺ュ彛绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@FeignClient( + value = AppConstant.APPLICATION_NAME_OMD, + fallback = IEnumItemFallback.class +) +public interface IEnumItemClient { + + String API_PREFIX = "/clientEnumItem"; + String TOP = API_PREFIX + "/top"; + + /** + * 鑾峰彇鏋氫妇瀹氫箟瀛愯〃鍒楄〃 + * + * @param current 椤靛彿 + * @param size 椤垫暟 + * @return BladePage + */ + @GetMapping(TOP) + BladePage<EnumItem> top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClientFallback.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemFallback.java similarity index 68% copy from Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClientFallback.java copy to Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemFallback.java index 36e1569..ef93754 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IDictClientFallback.java +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IEnumItemFallback.java @@ -16,8 +16,11 @@ */ package com.vci.ubcs.omd.feign; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumVO; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.tool.api.R; -import com.vci.ubcs.omd.entity.Dict; import org.springframework.stereotype.Component; import java.util.List; @@ -27,25 +30,11 @@ * * @author Chill */ -@Component("Dictclient2") -public class IDictClientFallback implements IDictClient { +@Component +public class IEnumItemFallback implements IEnumItemClient { @Override - public R<Dict> getById(Long id) { - return R.fail("鑾峰彇鏁版嵁澶辫触"); + public BladePage<EnumItem> top(Integer current, Integer size) { + return null; } - @Override - public R<String> getValue(String code, String dictKey) { - return R.fail("鑾峰彇鏁版嵁澶辫触"); - } - - @Override - public R<List<Dict>> getList(String code) { - return R.fail("鑾峰彇鏁版嵁澶辫触"); - } - - @Override - public R getCheck(Dict dict) { - return R.fail("鑾峰彇鏁版嵁澶辫触"); - } } diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumItemVO.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumItemVO.java new file mode 100644 index 0000000..ddcebab --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumItemVO.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.vo; + +import com.vci.ubcs.omd.entity.EnumItem; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 瑙嗗浘瀹炰綋绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class EnumItemVO extends EnumItem { + private static final long serialVersionUID = 1L; + + String parentName; +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/DictVO.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumVO.java similarity index 62% rename from Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/DictVO.java rename to Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumVO.java index 54a85fd..9fc7e40 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/DictVO.java +++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/vo/EnumVO.java @@ -17,55 +17,60 @@ package com.vci.ubcs.omd.vo; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.vci.ubcs.omd.entity.Dict; -import io.swagger.annotations.ApiModel; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.starter.util.node.INodeOid; import lombok.Data; import lombok.EqualsAndHashCode; -import org.springblade.core.tool.node.INode; import java.util.ArrayList; import java.util.List; /** - * 瑙嗗浘瀹炰綋绫� + * 鏋氫妇瀹氫箟 瑙嗗浘瀹炰綋绫� * - * @author Chill + * @author yuxc + * @since 2023-05-08 */ @Data @EqualsAndHashCode(callSuper = true) -@ApiModel(value = "DictVO瀵硅薄", description = "DictVO瀵硅薄") -public class DictVO extends Dict implements INode<Dict> { +public class EnumVO extends Enum implements INodeOid<EnumItem> { private static final long serialVersionUID = 1L; - /** - * 涓婚敭ID - */ - @JsonSerialize(using = ToStringSerializer.class) - private Long id; - - /** - * 鐖惰妭鐐笽D - */ - @JsonSerialize(using = ToStringSerializer.class) - private Long parentId; /** * 瀛愬瓩鑺傜偣 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List<Dict> children; + private List<EnumItem> children = new ArrayList<>(); + /** + * 鏄惁鏈夊瓙瀛欒妭鐐� + */ + private Boolean hasChildren = false; + /** + * 瀛愯妭鐐筄ID + */ + private String itemOid; + /** + * 瀛愯妭鐐规灇涓剧紪鐮� + */ + private String itemName; + /** + * 瀛愯妭鐐规灇涓惧�� + */ + private String itemValue; + /** + * 瀛愯妭鐐规灇鎻忚堪 + */ + private String itemDescription; @Override - public List<Dict> getChildren() { - if (this.children == null) { - this.children = new ArrayList<>(); - } + public String getParentOid() { + return null; + } + + @Override + public List<EnumItem> getChildren() { return this.children; } - /** - * 涓婄骇瀛楀吀 - */ - private String parentName; } diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/PatternUtil.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/PatternUtil.java new file mode 100644 index 0000000..b40a46a --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/PatternUtil.java @@ -0,0 +1,50 @@ +package com.vci.ubcs.starter.util; + + +import com.baomidou.mybatisplus.core.toolkit.StringUtils; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PatternUtil { + + //*${xxx}* + public static Pattern dynamic = Pattern.compile(".*\\$\\{([a-z]+)\\}.*"); + public static Pattern dynamicLimitCount = Pattern.compile("\\$\\{([a-z]+)\\}"); + /** + * 鍒ゆ柇鍐呭涓槸鍚﹀寘鍚姩鎬佸弬鏁�(${key}褰㈠紡鐨�) + * + * @param content 瑕佸垽鏂殑鍐呭 + * @return + */ + public static boolean isContainsDynamicParameter(String content) { + if(StringUtils.isBlank(content)){ + return false; + } + return dynamic.matcher(content).matches(); + } + + /** + * 鎸夌収鍔ㄦ�佸唴瀹圭殑鍙傛暟鍑虹幇椤哄簭,灏嗗弬鏁版斁鍒癓ist涓� + * + * @param content + * @return + */ + public static List<String> getKeyListByContent(String content) { + if(StringUtils.isBlank(content)){ + return new ArrayList<>(); + } + Set<String> paramSet = new LinkedHashSet<>(); + Matcher m = dynamicLimitCount.matcher(content); + while (m.find()) { + paramSet.add(m.group(1)); + } + return new ArrayList<>(paramSet); + } + + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeManagerOid.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeManagerOid.java new file mode 100644 index 0000000..a60a37e --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeManagerOid.java @@ -0,0 +1,36 @@ +package com.vci.ubcs.starter.util.node; + + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ForestNodeManagerOid<T extends INodeOid<T>> { + private final ImmutableMap<String, T> nodeMap; + private final Map<String, Object> parentIdMap = Maps.newHashMap(); + + public ForestNodeManagerOid(List<T> nodes) { + this.nodeMap = Maps.uniqueIndex(nodes, INodeOid::getOid); + } + + public INodeOid<T> getTreeNodeAt(String id) { + return this.nodeMap.containsKey(id) ? (INodeOid)this.nodeMap.get(id) : null; + } + + public void addParentId(String parentId) { + this.parentIdMap.put(parentId, ""); + } + + public List<T> getRoot() { + List<T> roots = new ArrayList(); + this.nodeMap.forEach((key, node) -> { + if (node.getParentOid() == null || this.parentIdMap.containsKey(node.getOid())) { + roots.add(node); + } + + }); + return roots; + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeMergerOid.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeMergerOid.java new file mode 100644 index 0000000..95b93d9 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/ForestNodeMergerOid.java @@ -0,0 +1,26 @@ +package com.vci.ubcs.starter.util.node; + + + +import java.util.List; + +public class ForestNodeMergerOid { + public ForestNodeMergerOid() { + } + + public static <T extends INodeOid<T>> List<T> merge(List<T> items) { + ForestNodeManagerOid forestNodeManager = new ForestNodeManagerOid(items); + items.forEach((forestNode) -> { + if (forestNode.getParentOid() != null) { + INodeOid<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentOid()); + if (node != null) { + node.getChildren().add(forestNode); + } else { + forestNodeManager.addParentId(forestNode.getOid()); + } + } + + }); + return forestNodeManager.getRoot(); + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/INodeOid.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/INodeOid.java new file mode 100644 index 0000000..14742f1 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/util/node/INodeOid.java @@ -0,0 +1,16 @@ +package com.vci.ubcs.starter.util.node; + +import java.io.Serializable; +import java.util.List; + +public interface INodeOid<T> extends Serializable { + String getOid(); + + String getParentOid(); + + List<T> getChildren(); + + default Boolean getHasChildren() { + return false; + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/constant/VciSystemVarConstants.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/constant/VciSystemVarConstants.java new file mode 100644 index 0000000..0c049d8 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/constant/VciSystemVarConstants.java @@ -0,0 +1,70 @@ +package com.vci.ubcs.starter.web.constant; + + +import com.vci.ubcs.starter.web.pagemodel.SessionInfo; +import com.vci.ubcs.starter.web.util.VciBaseUtil; +import com.vci.ubcs.starter.web.util.VciDateUtil; + +import java.util.*; +import java.util.stream.Collectors; + +public class VciSystemVarConstants { + public static final String CURRENTUSER_OID = "#CURRENTUSER.OID#"; + public static final String CURRENTUSER_ID = "#CURRENTUSER.ID#"; + public static final String CURRENTTIME = "#CURRENTTIME#"; + public static final String CURRENTDATE = "#CURRENTDATE#"; + public static final String CURRENTDATETIME = "#CURRENTDATETIME#"; + public static final String CURRENTUSER_NAME = "#CURRENTUSER_NAME#"; + public static final String CURRENTUSER_SECRETGRADE = "#CURRENTUSER.SECRETGRADE#"; + public static final String CURRENTUSER_IP_SECRET = "#CURRENTUSER.IPSECRET#"; + public static final String CURRENTUSER_BUSINESS_UNIT = "#CURRENTUSER.BUSINESSUNIT#"; + public static final String CURRENTUSER_BUSINESS_UNIT_NAME = "#CURRENTUSER.BUSINESSUNITNAME#"; + public static final String CURRENTUSER_GROUPOID = "#CURRENTUSER.GROUPOID#"; + public static final String CURRENTUSER_GROUPNAME = "#CURRENTUSER.GROUPNAME#"; + public static final String CURRENTUSER_EMAIL = "#CURRENTUSER.EMAIL#"; + public static final String CURRENTUSER_ROLENAME = "#CURRENTUSER.ROLENAME#"; + public static final String[] SYSTEM_VAR_KEYS = new String[]{"#CURRENTUSER.OID#", "#CURRENTUSER.ID#", "#CURRENTDATE#", "#CURRENTTIME#", "#CURRENTDATETIME#", "#CURRENTUSER.GROUPOID#", "#CURRENTUSER_NAME#", "#CURRENTUSER.SECRETGRADE#", "#CURRENTUSER.GROUPNAME#", "#CURRENTUSER.EMAIL#", "#CURRENTUSER.ROLENAME#", "#CURRENTUSER.IPSECRET#", "#CURRENTUSER.BUSINESSUNIT#", "#CURRENTUSER.BUSINESSUNITNAME#"}; + public static final Map<String, String> SYSTEM_VAR_KEYNAMEMAP = new HashMap(); + + public VciSystemVarConstants() { + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTTIME#", "褰撳墠鏃堕棿"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTDATE#", "褰撳墠鏃ユ湡"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTDATETIME#", "褰撳墠鏃ユ湡鏃堕棿"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.OID#", "褰撳墠鐢ㄦ埛涓婚敭"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.ID#", "褰撳墠鐢ㄦ埛璐︽埛"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER_NAME#", "褰撳墠鐢ㄦ埛濮撳悕"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.SECRETGRADE#", "褰撳墠鐢ㄦ埛瀵嗙骇"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.IPSECRET#", "褰撳墠鐢ㄦ埛鐨勬満鍣ㄥ瘑绾�"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.GROUPOID#", "褰撳墠鐢ㄦ埛鐨勯儴闂ㄧ殑涓婚敭"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.GROUPNAME#", "褰撳墠鐢ㄦ埛鎵�灞為儴闂ㄥ悕绉�"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.EMAIL#", "褰撳墠鐢ㄦ埛閭欢鍦板潃"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.ROLENAME#", "褰撳墠鐢ㄦ埛鎵�灞炶鑹插悕绉�"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.BUSINESSUNIT#", "褰撳墠鐢ㄦ埛鎵�灞炰笟鍔″崟鍏冧富閿�"); + SYSTEM_VAR_KEYNAMEMAP.put("#CURRENTUSER.BUSINESSUNITNAME#", "褰撳墠鐢ㄦ埛鎵�灞炰笟鍔″崟鍏�"); + } + + public static Map<String, String> getSystemVarValueMap() { + Map<String, String> systemVarMap = new HashMap(); + SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); + if (sessionInfo != null) { + systemVarMap.put("#CURRENTUSER.OID#", sessionInfo.getUserOid()); + systemVarMap.put("#CURRENTUSER.ID#", sessionInfo.getUserId()); + systemVarMap.put("#CURRENTUSER_NAME#", sessionInfo.getUserName()); + systemVarMap.put("#CURRENTDATETIME#", VciDateUtil.getNowString()); + systemVarMap.put("#CURRENTDATE#", VciDateUtil.getNowString("yyyy-MM-dd")); + systemVarMap.put("#CURRENTTIME#", VciDateUtil.getNowString("HH:mm:ss")); + systemVarMap.put("#CURRENTUSER.SECRETGRADE#", sessionInfo.getUserSecret()); + systemVarMap.put("#CURRENTUSER.GROUPNAME#", sessionInfo.getDeptName()); + systemVarMap.put("#CURRENTUSER.GROUPOID#", sessionInfo.getDeptOid()); + systemVarMap.put("#CURRENTUSER.EMAIL#", sessionInfo.getEmail()); + systemVarMap.put("#CURRENTUSER.ROLENAME#", (String) ((Collection) Optional.ofNullable(sessionInfo.getRolesName().values()).orElseGet(() -> { + return new ArrayList(); + })).stream().collect(Collectors.joining(","))); + systemVarMap.put("#CURRENTUSER.IPSECRET#", sessionInfo.getIpSecret()); + systemVarMap.put("#CURRENTUSER.BUSINESSUNIT#", sessionInfo.getOrgsOid()); + systemVarMap.put("#CURRENTUSER.BUSINESSUNITNAME#", sessionInfo.getOrgsName()); + } + + return systemVarMap; + } +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/Md5.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/Md5.java new file mode 100644 index 0000000..de2a60d --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/Md5.java @@ -0,0 +1,82 @@ +package com.vci.ubcs.starter.web.util; + +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + + +import java.security.MessageDigest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Md5 { + private static Logger logger = LoggerFactory.getLogger(Md5.class); + + public Md5() { + } + + public static String md5(String v) { + if (v == null) { + return null; + } else { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + return toHex(md.digest(v.getBytes())); + } catch (Exception var2) { + return null; + } + } + } + + public static String twoTimesMd5(String sourceString) throws Exception { + return sourceString == null ? null : md5(md5(sourceString)); + } + + public static boolean equalMd5(String md5String, String sourceString) { + if (md5String != null && sourceString != null) { + try { + return md5String.equals(twoTimesMd5(sourceString)); + } catch (Exception var3) { + var3.printStackTrace(); + return false; + } + } else { + return false; + } + } + + public static boolean equalOneMd5(String md5String, String sourceString) { + if (md5String != null && sourceString != null) { + try { + String ms = md5(sourceString); + return md5String.equals(ms); + } catch (Exception var3) { + if (logger.isErrorEnabled()) { + logger.error("瀵规瘮md5鐨勬椂鍊欏嚭鐜颁簡閿欒", var3); + } + + return false; + } + } else { + return false; + } + } + + private static String toHex(byte[] buffer) { + StringBuffer sb = new StringBuffer(32); + String s = null; + + for(int i = 0; i < buffer.length; ++i) { + s = Integer.toHexString(buffer[i] & 255); + if (s.length() < 2) { + sb.append('0'); + } + + sb.append(s); + } + + return sb.toString(); + } +} + diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java index 4cb289a..bf83190 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java +++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java @@ -79,7 +79,14 @@ return 0; } } - + public static SessionInfo getCurrentUserSessionInfo() throws VciBaseException { + SessionInfo si = getCurrentUserSessionInfoNotException(); + if (si == null) { + throw new VciBaseException("noLogin", new String[]{"娌℃湁褰撳墠鐢ㄦ埛淇℃伅"}); + } else { + return si; + } + } public static long getLong(String s) { long l = 0L; if (s == null) { diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeButtonController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeButtonController.java index ddf9b95..69fb80a 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeButtonController.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeButtonController.java @@ -26,7 +26,6 @@ import com.vci.ubcs.code.vo.pagemodel.CodeButtonVO; import com.vci.ubcs.code.wrapper.CodeButtonWrapper; import com.vci.ubcs.starter.web.pagemodel.BaseQueryObject; -import com.vci.ubcs.starter.web.pagemodel.DataGrid; import com.vci.ubcs.starter.web.util.VciBaseUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -52,11 +51,14 @@ */ @RestController @AllArgsConstructor -@RequestMapping("/codeButtonController") +@RequestMapping("/codebutton") @Api(value = "妯℃澘鎵╁睍姹�", tags = "妯℃澘鎵╁睍姹犳帴鍙�") public class CodeButtonController extends BladeController { private final ICodeButtonService codeButtonService; + + CodeButtonMapper codeButtonMapper; + /** * 涓绘暟鎹腑鐨勬寜閽墿灞曞垪琛� @@ -136,6 +138,82 @@ } return R.data(codeButtonService.refDataGridCodeButton(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper())); } + /** + * 妯℃澘鎵╁睍姹� 璇︽儏 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "璇︽儏", notes = "浼犲叆codebutton") + public R<CodeButtonVO> detail(CodeButton codebutton) { + CodeButton detail = codeButtonMapper.selectOne(Condition.getQueryWrapper(codebutton)); + return R.data(CodeButtonWrapper.build().entityVO(detail)); + } + /** + * 妯℃澘鎵╁睍姹� 鍒嗛〉 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆codebutton") + public R<IPage<CodeButtonVO>> list(CodeButton codebutton, Query query) { + IPage<CodeButton> pages = codeButtonMapper.selectPage(Condition.getPage(query), Condition.getQueryWrapper(codebutton)); + return R.data(CodeButtonWrapper.build().pageVO(pages)); + } + + /** + * 妯℃澘鎵╁睍姹� 鑷畾涔夊垎椤� + */ + @GetMapping("/page") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆codebutton") + public R<IPage<CodeButtonVO>> page(CodeButtonVO codebutton, Query query) { + IPage<CodeButtonVO> pages = codeButtonService.selectcodebuttonPage(Condition.getPage(query), codebutton); + return R.data(pages); + } + + /** + * 妯℃澘鎵╁睍姹� 鏂板 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "鏂板", notes = "浼犲叆codebutton") + public R save(@Valid @RequestBody CodeButton codebutton) { + return R.status(SqlHelper.retBool(codeButtonMapper.insert(codebutton))); + } + + /** + * 妯℃澘鎵╁睍姹� 淇敼 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "淇敼", notes = "浼犲叆codebutton") + public R update(@Valid @RequestBody CodeButton codebutton) { + return R.status(SqlHelper.retBool(codeButtonMapper.updateById(codebutton))); + } + + /** + * 妯℃澘鎵╁睍姹� 鏂板鎴栦慨鏀� + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆codebutton") + public R submit(@Valid @RequestBody CodeButton codebutton) { + if(codebutton.getOid() != null){ + return R.status(SqlHelper.retBool(codeButtonMapper.updateById(codebutton))); + } + return R.status(SqlHelper.retBool(codeButtonMapper.insert(codebutton))); + } + + /** + * 妯℃澘鎵╁睍姹� 鍒犻櫎 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "閫昏緫鍒犻櫎", notes = "浼犲叆ids") + public R remove(@ApiParam(value = "涓婚敭闆嗗悎", required = true) @RequestParam String ids) { +// return codebuttonService.deleteCodeButton(ids); + return R.status(SqlHelper.retBool(codeButtonMapper.deleteBatchIds(Func.toStrList(ids)))); + } + /** * 鍚敤 @@ -157,4 +235,5 @@ return codeButtonService.disableOrgDuty(oid); } + } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyTemplateAttrController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyTemplateAttrController.java index 92fabc6..746140e 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyTemplateAttrController.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClassifyTemplateAttrController.java @@ -18,10 +18,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.vci.ubcs.code.dto.CodeClstempattrDTO; import com.vci.ubcs.code.entity.CodeClassifyTemplateAttr; import com.vci.ubcs.code.service.ICodeClassifyTemplateAttrService; +import com.vci.ubcs.code.service.ICodeClstempattrService; +import com.vci.ubcs.code.vo.CodeClstempattrVO; +import com.vci.ubcs.code.vo.CodeOsbtmtypeattributeVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; import com.vci.ubcs.code.wrapper.CodeClstempattrWrapper; +import com.vci.ubcs.starter.web.pagemodel.BaseQueryObject; +import com.vci.ubcs.starter.web.pagemodel.DataGrid; +import com.vci.ubcs.starter.web.util.VciBaseUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -31,9 +38,12 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.Collection; +import java.util.List; /** * 缂栫爜搴撳畾涔�-妯℃澘灞炴�� 鎺у埗鍣� @@ -48,6 +58,7 @@ public class CodeClassifyTemplateAttrController extends BladeController { private final ICodeClassifyTemplateAttrService CodeClstempattrService; + private final ICodeClstempattrService iCodeClstempattrService; /** * 缂栫爜搴撳畾涔�-妯℃澘灞炴�� 璇︽儏 @@ -120,6 +131,130 @@ public R remove(@ApiParam(value = "涓婚敭闆嗗悎", required = true) @RequestParam String ids) { return R.status(CodeClstempattrService.removeBatchByIds(Func.toLongList(ids))); } + /** + * 涓婚搴撳垎绫荤殑妯℃澘灞炴�у垪琛� + * @param baseQueryObject 鍩虹鏌ヨ瀵硅薄锛屽寘鍚煡璇㈡潯浠讹紝鍒嗛〉锛屾帓搴忕瓑 + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞″垪琛� + */ + @GetMapping("/gridCodeClassifyTemplateAttr") + public DataGrid<CodeClstempattrVO> gridCodeClassifyTemplateAttr(BaseQueryObject baseQueryObject){ + if(baseQueryObject == null){ + baseQueryObject = new BaseQueryObject(); + } + return iCodeClstempattrService.gridCodeClassifyTemplateAttr(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); + } + /** + * 澧炲姞 涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� + * @return 鎵ц缁撴灉锛宻uccess涓簍rue琛ㄧず鎴愬姛锛宮sg鏄け璐ョ殑鎻愮ず淇℃伅锛宱bj鏄坊鍔犲畬鎴愬悗鐨勬樉绀哄璞� + */ + @PostMapping( "/addSave") + public R<CodeClstempattrVO> addSave(@RequestBody CodeClstempattrDTO codeClassifyTemplateAttrDTO){ + CodeClstempattrVO codeClassifyTemplateAttrVO = iCodeClstempattrService.addSave(codeClassifyTemplateAttrDTO); + return R.data(codeClassifyTemplateAttrVO); + } + + /** + * 鎵归噺淇濆瓨鍒楄〃鏁版嵁 + * @param list + * @return + */ + @PostMapping( "/batchAddSave") + public R<List<CodeClstempattrVO>> batchAddSaves(@RequestBody List<CodeClstempattrDTO> list){ + if(CollectionUtils.isEmpty(list)){ + return R.fail("鍒楄〃涓嶈兘涓虹┖!"); + } + List<CodeClstempattrVO> codeClassifyTemplateAttrVOs = iCodeClstempattrService.batchAddSave(list); + return R.data(codeClassifyTemplateAttrVOs); + } + + /** + * 淇敼 涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� + * @return 鎵ц缁撴灉锛宻uccess涓簍rue琛ㄧず鎴愬姛锛宮sg鏄け璐ョ殑鎻愮ず淇℃伅锛宱bj鏄坊鍔犲畬鎴愬悗鐨勬樉绀哄璞� + */ + @PutMapping("/editSave") + public R<CodeClstempattrVO> editSave(@RequestBody CodeClstempattrDTO codeClassifyTemplateAttrDTO){ + return iCodeClstempattrService.editSave(codeClassifyTemplateAttrDTO); + } + + /** + * 鍒犻櫎涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈� + * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐� + */ + @DeleteMapping( "/deleteData") + public R delCodeClassifyTemplateAttr(@RequestBody CodeClstempattrDTO codeClassifyTemplateAttrDTO) { + return iCodeClstempattrService.deleteCodeClassifyTemplateAttr(codeClassifyTemplateAttrDTO); + } + + /** + * 涓婚敭鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param oid 涓婚敭 + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� + */ + @GetMapping("/getObjectByOid") + public R<CodeClstempattrVO> getObjectByOid(String oid){ + CodeClstempattrVO codeClassifyTemplateAttrVO = iCodeClstempattrService.getObjectByOid(oid); + return R.data(codeClassifyTemplateAttrVO); + } + + + /** + * 涓婚敭鎵归噺鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param oids 涓婚敭锛屽涓互閫楀彿鍒嗛殧锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓� + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� + */ + @GetMapping("/listDataByOids") + public R listCodeClassifyTemplateAttrByOids(String oids){ + Collection<CodeClstempattrVO> voCollection = iCodeClstempattrService.listCodeClassifyTemplateAttrByOids(VciBaseUtil.str2List(oids)); +// BaseResult baseResult = BaseResult.success(); +// baseResult.setData(voCollection); + return R.data(voCollection); + } + + /** + * 鍙傜収涓婚搴撳垎绫荤殑妯℃澘灞炴�у垪琛� + * @param baseQueryObject 鍩虹鏌ヨ瀵硅薄锛屽寘鍚煡璇㈡潯浠讹紝鍒嗛〉锛屾帓搴忕瓑 + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹� + */ + @GetMapping("/refDataGrid") + public DataGrid<CodeClstempattrVO> refDataGridCodeClassifyTemplateAttr(BaseQueryObject baseQueryObject){ + if(baseQueryObject == null){ + baseQueryObject = new BaseQueryObject(); + } + return iCodeClstempattrService.refDataGridCodeClassifyTemplateAttr(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); + } + + /** + * 鏌ヨ杩欎釜涓氬姟绫诲瀷涓嬬殑鎵�鏈夊睘鎬�,鎺掗櫎鎺夎繖涓ā鏉垮凡缁忓瓨鍦ㄧ殑灞炴�� + * @param baseQueryObject + * @return + */ + @GetMapping("/codeClassifyTemplateAttrByBtm") + public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject){ + return iCodeClstempattrService.codeClassifyTemplateAttrByBtm(baseQueryObject); + } + + /** + * 鏌ヨ杩欎釜涓氬姟绫诲瀷涓嬨�佽繖涓ā鏉垮凡缁忓瓨鍦ㄧ殑灞炴�� + * @param baseQueryObject + * @return + */ + @GetMapping("/codeClassifyTemplateAttrByBtmHave") + public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject){ + return iCodeClstempattrService.codeClassifyTemplateAttrByBtmHave(baseQueryObject); + } + + /** + * 鍚屾鍒板叾浠栨ā鏉� + * @param codeClassifyAttrDTO id 鑻辨枃鍚嶇О + * @return 鎵ц缁撴灉 + */ + @PostMapping( "/copyto") + public R copyto(@RequestBody CodeClstempattrDTO codeClassifyAttrDTO) { + return iCodeClstempattrService.copyto(codeClassifyAttrDTO); + } } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClstemplateController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClstemplateController.java index 53c4684..4e763ae 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClstemplateController.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeClstemplateController.java @@ -25,8 +25,10 @@ import com.vci.ubcs.code.mapper.CodeClstemplateMapper; import com.vci.ubcs.code.service.ICodeClstemplateService; import com.vci.ubcs.code.vo.CodeClstemplateVO; -import com.vci.ubcs.starter.revision.model.TreeQueryObject; import com.vci.ubcs.code.wrapper.PlCodeClstemplateWrapper; +import com.vci.ubcs.starter.revision.model.TreeQueryObject; +import com.vci.ubcs.starter.web.pagemodel.BaseQueryObject; +import com.vci.ubcs.starter.web.pagemodel.DataGrid; import com.vci.ubcs.starter.web.pagemodel.Tree; import com.vci.ubcs.starter.web.util.VciBaseUtil; import io.swagger.annotations.Api; @@ -52,7 +54,7 @@ */ @RestController @AllArgsConstructor -@RequestMapping("/codeClstemplate") +@RequestMapping("/codeClassifyTemplateController") @Api(value = "缂栫爜搴撳畾涔�-妯℃澘绠$悊", tags = "缂栫爜搴撳畾涔�-妯℃澘绠$悊鎺ュ彛") public class CodeClstemplateController extends BladeController { @@ -142,16 +144,37 @@ return plCodeClstemplateService.treeCodeClassifyTemplate(treeQueryObject); } -// /** -// * 鍒嗙被妯℃澘鍒楄〃 -// * @param baseQueryObject 鍩虹鏌ヨ瀵硅薄 -// * @return 鏄剧ず瀵硅薄 -// */ -// @GetMapping("/gridCodeClassifyTemplate") -// public DataGrid<CodeClstemplateVO> gridCodeClassifyTemplate(BaseQueryObject baseQueryObject){ -// -// return plCodeClstemplateService.gridCodeClassifyTemplate(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); -// } + /** + * 鍒嗙被妯℃澘鍒楄〃 + * @param baseQueryObject 鍩虹鏌ヨ瀵硅薄 + * @return 鏄剧ず瀵硅薄 + */ + @GetMapping("/gridCodeClassifyTemplate") + public DataGrid<CodeClstemplateVO> gridCodeClassifyTemplate(BaseQueryObject baseQueryObject){ + + return plCodeClstemplateService.gridCodeClassifyTemplate(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); + + } + + /** + * 澧炲姞 鍒嗙被妯℃澘瀵硅薄 + * @param codeClassifyTemplateDTO 鍒嗙被妯℃澘瀵硅薄鏁版嵁浼犺緭瀵硅薄 + * @return 鎵ц缁撴灉锛宻uccess涓簍rue琛ㄧず鎴愬姛锛宮sg鏄け璐ョ殑鎻愮ず淇℃伅锛宱bj鏄坊鍔犲畬鎴愬悗鐨勬樉绀哄璞� + */ + @PostMapping( "/addSave") + public R<CodeClstemplateVO> addSave(@RequestBody CodeClstemplateDTO codeClassifyTemplateDTO){ + return plCodeClstemplateService.addSave(codeClassifyTemplateDTO); + } + + /** + * 淇敼 鍒嗙被妯℃澘瀵硅薄 + * @param codeClassifyTemplateDTO 鍒嗙被妯℃澘瀵硅薄鏁版嵁浼犺緭瀵硅薄 + * @return 鎵ц缁撴灉锛宻uccess涓簍rue琛ㄧず鎴愬姛锛宮sg鏄け璐ョ殑鎻愮ず淇℃伅锛宱bj鏄坊鍔犲畬鎴愬悗鐨勬樉绀哄璞� + */ + @PutMapping("/editSave") + public R<CodeClstemplateVO> editSave(@RequestBody CodeClstemplateDTO codeClassifyTemplateDTO){ + return plCodeClstemplateService.editSave(codeClassifyTemplateDTO); + } /** @@ -234,7 +257,7 @@ * @return */ @PostMapping( "/editDate") - public R editDate( CodeClstemplateDTO codeClassifyDTO) { + public R editDate(@RequestBody CodeClstemplateDTO codeClassifyDTO) { return plCodeClstemplateService.updateLcStatus(codeClassifyDTO.getOid(),CodeClassifyTemplateLC.EDITING.getValue()); } @@ -248,4 +271,26 @@ return plCodeClstemplateService.Upgrade(codeClassifyDTO); } + + @GetMapping( "/upgrade1") + public R upgrade1(@RequestBody CodeClstemplateDTO codeClassifyDTO) { + return Upgrade(codeClassifyDTO); + } + + /** + * 鍏嬮殕 + * @param codeClassifyDTO + * @return oid妯℃澘oid + */ + @PostMapping( "/copy") + public R copyTemplate(@RequestBody CodeClstemplateDTO codeClassifyDTO) { + + return plCodeClstemplateService.copyTemplate(codeClassifyDTO); + } + + @GetMapping( "/copyTemplate1") + public R copyTemplate1(@RequestBody CodeClstemplateDTO codeClassifyDTO) { + + return copyTemplate(codeClassifyDTO); + } } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstempattrService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstempattrService.java index 27c01d0..c3093da 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstempattrService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstempattrService.java @@ -18,11 +18,18 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.vci.ubcs.code.dto.CodeClstempattrDTO; import com.vci.ubcs.code.entity.CodeClstempattrEntity; import com.vci.ubcs.code.vo.CodeClstempattrVO; +import com.vci.ubcs.code.vo.CodeOsbtmtypeattributeVO; +import com.vci.ubcs.starter.web.pagemodel.BaseQueryObject; +import com.vci.ubcs.starter.web.pagemodel.DataGrid; +import com.vci.ubcs.starter.web.pagemodel.PageHelper; +import org.springblade.core.tool.api.R; import java.util.Collection; import java.util.List; +import java.util.Map; /** * 缂栫爜搴撳畾涔�-妯℃澘灞炴�� 鏈嶅姟绫� @@ -61,5 +68,77 @@ * @return 鏄剧ず瀵硅薄 */ CodeClstempattrVO codeClassifyTemplateAttrDO2VO(CodeClstempattrEntity codeClassifyTemplateAttrDO); + /** + * 鏌ヨ鎵�鏈夌殑涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param conditionMap 鏌ヨ鏉′欢 + * @param pageHelper 鍒嗛〉鍜屾帓搴� + * @return 鎵ц缁撴灉 + */ + DataGrid<CodeClstempattrVO> gridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper); + + /** + * 澧炲姞涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� + * @return 鎵ц缁撴灉 + */ + CodeClstempattrVO addSave(CodeClstempattrDTO codeClassifyTemplateAttrDTO); + + List<CodeClstempattrVO> batchAddSave(List<CodeClstempattrDTO> list); + + /** + * 淇敼涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� + * @return 鎵ц缁撴灉 + */ + R<CodeClstempattrVO> editSave(CodeClstempattrDTO codeClassifyTemplateAttrDTO); + + /** + * 鍒犻櫎涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈� + * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐� + */ + R deleteCodeClassifyTemplateAttr(CodeClstempattrDTO codeClassifyTemplateAttrDTO); + + /** + * 涓婚敭鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param oid 涓婚敭 + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� + */ + CodeClstempattrVO getObjectByOid(String oid); + + /** + * 涓婚敭鎵归噺鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓� + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� + */ + Collection<CodeClstempattrVO> listCodeClassifyTemplateAttrByOids(Collection<String> oidCollections); + + /** + * 鍙傜収涓婚搴撳垎绫荤殑妯℃澘灞炴�у垪琛� + * @param conditionMap 鏌ヨ鏉′欢 + * @param pageHelper 鍒嗛〉鍜屾帓搴� + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹� + */ + DataGrid<CodeClstempattrVO> refDataGridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper); + + /** + * 鏌ヨ杩欎釜妯℃澘锛屼笟鍔$被鍨嬩笅鐨勬墍鏈夋湭閫夋嫨鐨勫睘鎬� + * @param baseQueryObject + * @return + */ + DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject); + /** + * 鏌ヨ杩欎釜妯℃澘锛屼笟鍔$被鍨嬩笅宸查�夋嫨鐨勫睘鎬� + * @param baseQueryObject + * @return + */ + DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject); + + /** + * 鍚屾鍒板叾浠栨ā鏉� + * @param codeClassifyAttrDTO oid + * @return + */ + R copyto(CodeClstempattrDTO codeClassifyAttrDTO); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstemplateService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstemplateService.java index 5e287d1..6ee51bf 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstemplateService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeClstemplateService.java @@ -23,6 +23,7 @@ import com.vci.ubcs.code.vo.CodeClstemplateVO; import com.vci.ubcs.starter.revision.model.TreeQueryObject; import com.vci.ubcs.starter.web.pagemodel.DataGrid; +import com.vci.ubcs.starter.web.pagemodel.PageHelper; import com.vci.ubcs.starter.web.pagemodel.Tree; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -164,11 +165,11 @@ /** * 鍒嗙被妯℃澘鍒楄〃 - * @param plCodeClstemplate 鏌ヨ鏉′欢 - * @param query 鍒嗛〉瀵硅薄 + * @param conditionMap 鏌ヨ鏉′欢 + * @param pageHelper 鍒嗛〉瀵硅薄 * @return 鏄剧ず瀵硅薄 */ - DataGrid<CodeClstemplateVO> gridCodeClassifyTemplate(CodeClstemplateVO plCodeClstemplate, Query query); + DataGrid<CodeClstemplateVO> gridCodeClassifyTemplate(Map<String, String> conditionMap, PageHelper pageHelper); /** * 澧炲姞鍒嗙被妯℃澘瀵硅薄 @@ -212,7 +213,7 @@ * @param templateOid 涓婚敭 * @return 鍒嗙被妯℃澘瀵硅薄鏄剧ず瀵硅薄 */ - CodeClstemplateVO getObjectHasAttrByOid(String templateOid); + CodeClstemplateVO getObjectHasAttrByOid(String templateOid); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java index 2c7f399..92334b9 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java @@ -5,12 +5,18 @@ import com.vci.ubcs.code.dto.CodeOrderDTO; import com.vci.ubcs.code.dto.datapush.BaseModelDTO; import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeRule; +import com.vci.ubcs.code.entity.CodeWupinEntity; +import com.vci.ubcs.code.vo.CodeClstempattrVO; import com.vci.ubcs.code.vo.CodeClstemplateVO; +import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; +import com.vci.ubcs.starter.exception.VciBaseException; import com.vci.ubcs.starter.web.pagemodel.KeyValue; import java.util.List; +import java.util.Map; /** * 涓绘暟鎹紩鎿庢湇鍔� @@ -18,7 +24,6 @@ * @date 2022-2-21 */ public interface MdmEngineService extends IService<CodeAllCode> { - /** * 浣跨敤鍒嗙被鐨勪富閿幏鍙栧彲浠ヤ娇鐢ㄧ殑妯℃澘瀵硅薄 * @param codeClassifyOid 鍒嗙被鐨勪富閿� @@ -60,4 +65,37 @@ * @param orderDTO 缂栫爜鐢宠鐨勫唴瀹� */ void checkSecValueOnOrder(CodeRuleVO ruleVO, CodeOrderDTO orderDTO); + + /** + * 灏佽鍏抽敭灞炴�х殑鏌ヨ璇彞 + * + * @param value 褰撳墠鐨勫�� + * @param keyRuleVO 鍏抽敭灞炴�х殑鎺у埗瑙勫垯锛屽彲浠ヤ负绌� + * @param attrId 灞炴�х殑缂栧彿 + * @param trim 鏄惁鍘婚櫎绌烘牸 + * @param ignoreCase 鏄惁涓嶅尯鍒嗗ぇ灏忓啓 + * @param ignoreWidth 鏄惁蹇界暐鍏ㄥ崐瑙� + * @param trimAll 鏄惁蹇界暐鍏ㄩ儴绌烘牸 + * @param conditionMap 鏌ヨ鏉′欢 + */ + void wrapperKeyAttrConditionMap(String value, CodeKeyattrrepeatVO keyRuleVO, String attrId, + boolean trim, boolean ignoreCase, boolean ignoreWidth, + boolean trimAll, Map<String, String> conditionMap); + /** + * 鍒濆鍖栦笟鍔$被鍨� + * --鍒涘缓浜洪粯璁や负褰撳墠鐢ㄦ埛锛屽鏋滈渶瑕佷慨鏀癸紝鍙互鍦ㄨ幏鍙栧悗鑷澶勭悊 + * @param btmName 涓氬姟绫诲瀷鐨勫悕绉帮紝浼氳嚜鍔ㄥ彉鎴愬皬鍐� + * @return CodeWupinEntity + * @throws VciBaseException 鍒濆鍖栧嚭閿欑殑鏄細鎶涘嚭寮傚父 + */ + CodeWupinEntity createCBOByBtmName(String btmName); + + /** + * 淇濆瓨鍙緭鍙�夌殑淇℃伅 + * + * @param templateVO 妯℃澘鐨勫璞� + * @param cboList 鏁版嵁鐨勫唴瀹� + */ + void batchSaveSelectChar(CodeClstemplateVO templateVO, /*List<ClientBusinessObject> cboList*/ + List<String> cboList); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmProductCodeService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmProductCodeService.java index 4136658..a1244c8 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmProductCodeService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmProductCodeService.java @@ -8,6 +8,7 @@ import java.util.List; + public interface MdmProductCodeService { /** * 鐢熸垚缂栫爜--骞朵笖淇濆瓨鏁版嵁-鏂规硶鍔犻攣锛屽洜姝や笉鑳借繑鍥瀊atchCBO diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java index 338c9f6..3a43b7d 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java @@ -263,7 +263,7 @@ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - public List<CodeButtonVO> codeButtonDO2VOs(Collection<CodeButton> codeButtonDOs) throws VciBaseException{ + public List<CodeButtonVO> codeButtonDO2VOs(Collection<CodeButton> codeButtonDOs) throws VciBaseException{ List<CodeButtonVO> voList = new ArrayList<CodeButtonVO>(); if(!CollectionUtils.isEmpty(codeButtonDOs)){ for(CodeButton s: codeButtonDOs){ @@ -289,7 +289,7 @@ BeanUtilForVCI.copyPropertiesIgnoreCase(codeButtonDO,vo); //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽 vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())); - vo.setUsedpositiontypeText(CodeUseButtonPositionTypeEnum.getTextByValue(codeButtonDO.getUsedPositionType())); + } return vo; } @@ -319,6 +319,7 @@ return codeButtonDOList; } + @Override public R enableCodeButton(String id) { CodeButton codebutton = codeButtonMapper.selectById(id); @@ -344,7 +345,7 @@ * @return 鎵ц鐨勭粨鏋� */ private R changeLcStatus(CodeButton buttonDTO, boolean disable){ - // VciBaseUtil.alertNotNull(buttonDTO,"鏁版嵁瀵硅薄",buttonDTO.getOid(),"涓婚敭"); +// VciBaseUtil.alertNotNull(buttonDTO,"鏁版嵁瀵硅薄",buttonDTO.getOid(),"涓婚敭"); if(disable){ buttonDTO.setLcStatus(FrameworkDataLCStatus.ENABLED.getValue()); }else{ diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java new file mode 100644 index 0000000..aaf3f76 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java @@ -0,0 +1,806 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.code.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.common.utils.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.vci.ubcs.code.constant.MdmBtmTypeConstant; +import com.vci.ubcs.code.dto.CodeClstempattrDTO; +import com.vci.ubcs.code.entity.CodeClassifyTemplateAttr; +import com.vci.ubcs.code.entity.CodeClstempattrEntity; +import com.vci.ubcs.code.entity.CodeClstemplateEntity; +import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; +import com.vci.ubcs.code.mapper.CodeClstempattrMapper; +import com.vci.ubcs.code.mapper.CodeClstemplateMapper; +import com.vci.ubcs.code.mapper.CodeOsbtmtypeattributeMapper; +import com.vci.ubcs.code.service.ICodeClstempattrService; +import com.vci.ubcs.code.service.ICodeTempphaseService; +import com.vci.ubcs.code.vo.CodeClstempattrVO; +import com.vci.ubcs.code.vo.CodeOsbtmtypeattributeVO; +import com.vci.ubcs.starter.exception.VciBaseException; +import com.vci.ubcs.starter.revision.service.RevisionModelUtil; +import com.vci.ubcs.starter.util.PatternUtil; +import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; +import com.vci.ubcs.starter.web.pagemodel.*; +import com.vci.ubcs.starter.web.util.BeanUtilForVCI; +import com.vci.ubcs.starter.web.util.VciBaseUtil; +import com.vci.ubcs.starter.web.util.VciDateUtil; +import com.vci.ubcs.system.entity.DictBiz; +import com.vci.ubcs.system.feign.IDictBizClient; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cglib.beans.BeanMap; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; + +/** + * 缂栫爜搴撳畾涔�-妯℃澘灞炴�� 鏈嶅姟瀹炵幇绫� + * + * @author yuxc + * @since 2023-04-19 + */ +@Service +public class CodeClstempattrServiceImpl extends ServiceImpl<CodeClstempattrMapper, CodeClstempattrEntity> implements ICodeClstempattrService { + + @Resource + CodeClstempattrMapper codeClstempattrMapper; + // @Resource +// ICodeTempphaseService codeTempphaseService; + @Resource + IDictBizClient iDictBizClient; + @Resource + CodeClstemplateMapper codeClstemplateMapper; + @Resource + CodeOsbtmtypeattributeMapper codeOsbtmtypeattributeMapper; + @Resource + ICodeTempphaseService codeTempphaseService; + + /** + * 瀵硅薄鐨勬搷浣� + */ + @Autowired(required = false) + private RevisionModelUtil revisionModelUtil; + + @Override + public IPage<CodeClstempattrVO> selectCodeClstempattrPage(IPage<CodeClstempattrVO> page, CodeClstempattrVO CodeClstempattr) { + return page.setRecords(baseMapper.selectCodeClstempattrPage(page, CodeClstempattr)); + } + + + /** + * 浣跨敤妯℃澘鐨勪富閿幏鍙栨ā鏉跨殑灞炴��--鎵归噺 + * + * @param templateOidCollection 妯℃澘鐨勪富閿� + * @return 灞炴�х殑淇℃伅 + */ + @Override + public List<CodeClstempattrVO> listCodeClassifyTemplateAttrByTemplateOids(Collection<String> templateOidCollection) { + if(CollectionUtils.isEmpty(templateOidCollection)){ + return new ArrayList<>(); + } + List<CodeClstempattrEntity> attrDOList = new ArrayList<>(); + VciBaseUtil.switchCollectionForOracleIn(templateOidCollection).stream().forEach(templateOids->{ +// Map<String,String> conditionMap = new HashMap<>(); +// conditionMap.put("classifytemplateoid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(templateOids.toArray(new String[0])) + ")"); +// PageHelper pageHelper = new PageHelper(-1); +// pageHelper.addDefaultAsc("orderNum"); + List<CodeClstempattrEntity> attrDOS = baseMapper.selectByClassifytemplateoid(VciBaseUtil.toInSql(templateOids.toArray(new String[0]))); + + if(!CollectionUtils.isEmpty(attrDOS)){ + attrDOList.addAll(attrDOS); + } + }); + return codeClassifyTemplateAttrDO2VOs(attrDOList); + } + + /** + * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� + * @param codeClassifyTemplateAttrDOs 鏁版嵁瀵硅薄鍒楄〃 + * @return 鏄剧ず瀵硅薄 + */ + @Override + public List<CodeClstempattrVO> codeClassifyTemplateAttrDO2VOs(Collection<CodeClstempattrEntity> codeClassifyTemplateAttrDOs){ + List<CodeClstempattrVO> voList = new ArrayList<CodeClstempattrVO>(); + if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOs)){ + for(CodeClstempattrEntity s: codeClassifyTemplateAttrDOs){ + CodeClstempattrVO vo = codeClassifyTemplateAttrDO2VO(s); + if(vo != null){ + voList.add(vo); + } + } + } + return voList; + } + + /** + * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� + * @param codeClassifyTemplateAttrDO 鏁版嵁瀵硅薄 + * @return 鏄剧ず瀵硅薄 + */ + @Override + public CodeClstempattrVO codeClassifyTemplateAttrDO2VO(CodeClstempattrEntity codeClassifyTemplateAttrDO){ + CodeClstempattrVO vo = new CodeClstempattrVO(); + if(codeClassifyTemplateAttrDO != null){ + BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,vo); + //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽 + vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributedatatype())); + } + return vo; + } + + /** + * 鏌ヨ鎵�鏈夌殑涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param conditionMap 鏌ヨ鏉′欢 + * @param pageHelper 鍒嗛〉鍜屾帓搴� + * @return 鎵ц缁撴灉 + */ + @Override + public DataGrid<CodeClstempattrVO> gridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) { + DataGrid<CodeClstempattrVO> dataGrid=new DataGrid<CodeClstempattrVO>(); + //娌℃湁浼犻�掑弬鏁帮紝灏变笉鎵ц鏌ヨ閫昏緫 + if(conditionMap.size()==0){ + dataGrid.setData(new ArrayList<>()); + dataGrid.setTotal(0); + return dataGrid; + } + + if (pageHelper == null) { + pageHelper = new PageHelper(-1); + } + pageHelper.addDefaultAsc("ordernum"); +// IPage iPage = new IPage(); + Query query = new Query(); + query.setAscs("ordernum"); +// query.setSize(100); + if(pageHelper.getLimit() != -1){ + query.setSize(pageHelper.getLimit()); + query.setCurrent(pageHelper.getPage()); + } +// Condition.getPage(query) + CodeClstempattrVO codeClstempattrVO = new CodeClstempattrVO(); +// BeanUtil.toBean(map,codeClstempattrVO); +// BeanUtil + BeanMap beanMap = BeanMap.create(codeClstempattrVO); + + beanMap.putAll(conditionMap); +// Condition.getQueryWrapper( + IPage<CodeClstempattrEntity> doList = baseMapper. + selectPage(Condition.getPage(query), Condition.getQueryWrapper(codeClstempattrVO)); + + + if (!CollectionUtils.isEmpty(doList.getRecords())) { +// CodeClstempattrEntity codeClstempattrEntity = new CodeClstempattrEntity(); +// BeanUtils.copyProperties(conditionMap, codeClstempattrEntity); +// List<CodeClstempattrEntity> codeClstempattrEntities = new ArrayList<>(); +// BeanUtils.copyProperties(doList,codeClstempattrEntities); +// codeClstempattrEntities.addAll(doList); + dataGrid.setData(codeClassifyTemplateAttrDO2VOs(doList.getRecords())); + dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(baseMapper.selectCount(Condition.getQueryWrapper(codeClstempattrVO))))); + } + return dataGrid; + } + + /** + * 澧炲姞涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� + * @return 鎵ц缁撴灉 + */ + @Override + public CodeClstempattrVO addSave(CodeClstempattrDTO codeClassifyTemplateAttrDTO){ + VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄"); + //灏咲TO杞崲涓篋O + CodeClstempattrEntity codeClassifyTemplateAttrDO = new CodeClstempattrEntity(); + BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); + baseMapper.insert(codeClassifyTemplateAttrDO); + return codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO); + } + + + /** + * 鎵归噺娣诲姞 + * @param codeClassifyTemplateAttrDTOs 鏁版嵁浼犺緭瀵硅薄 + * @return 淇濆瓨鍚庣殑鏄剧ず瀵硅薄 + */ + @Override + @Transactional + public List<CodeClstempattrVO> batchAddSave(List<CodeClstempattrDTO> codeClassifyTemplateAttrDTOs) { + if(CollectionUtils.isEmpty(codeClassifyTemplateAttrDTOs)){ + return new ArrayList<>(); + } + + //鍙栨墍鏈夊睘鎬х殑鑻辨枃鍚嶇О锛岀涓変釜楠岃瘉闇�瑕佺敤鍒� + Map<String,CodeClstempattrDTO> attrDTOMap =codeClassifyTemplateAttrDTOs.stream().collect(Collectors.toMap(s->s.getId().toLowerCase(Locale.ROOT), t->t)); + + //鎵惧睘鎬т腑鏂囧悕瀛楅噸澶� + Map<String, Long> nameCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getName(), Collectors.counting())); + List<String> repeatNameList = nameCountMap.keySet().stream().filter(s -> nameCountMap.get(s) > 1).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(repeatNameList)){ + throw new VciBaseException("妯℃澘灞炴�т腑鏂囧悕绉般�恵0}銆戦噸澶�",new String[]{ repeatNameList.stream().collect(Collectors.joining(","))}); + } + //鎵惧睘鎬ц嫳鏂囧悕瀛楅噸澶� + Map<String, Long> idCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getId().toLowerCase(Locale.ROOT), Collectors.counting())); + List<String> repeatIdList = idCountMap.keySet().stream().filter(s -> idCountMap.get(s) > 1).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(repeatIdList)){ + throw new VciBaseException("妯℃澘灞炴�ц嫳鏂囧悕绉般�恵0}銆戦噸澶�",new String[]{ repeatIdList.stream().collect(Collectors.joining(","))}); + } + + //妯℃澘oid + String CLASSIFYTEMPLATEOID = null; + //杞崲 + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOInsert = new ArrayList<CodeClstempattrEntity>(); + List<String> prefix = new ArrayList<>(); + List<String> suffix = new ArrayList<>(); + List<String> dateFormates = new ArrayList<>(); + for (CodeClstempattrEntity codeClassifyTemplateAttrDTO:codeClassifyTemplateAttrDTOs){ + VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄"); + //灏咲TO杞崲涓篋O + CodeClstempattrEntity codeClassifyTemplateAttrDO = new CodeClstempattrEntity(); + BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); + codeClassifyTemplateAttrDOInsert.add(codeClassifyTemplateAttrDO); + + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getPrefixvalue())){ + prefix.add(codeClassifyTemplateAttrDO.getPrefixvalue()); + } + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getSuffixvalue())){ + suffix.add(codeClassifyTemplateAttrDO.getSuffixvalue()); + } + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodedateformat())){ + dateFormates.add(codeClassifyTemplateAttrDO.getCodedateformat()); + } + //鍒ゆ柇浼犺繃鏉ョ殑鏋氫妇娉ㄥ叆鏄惁鏄痡sonArr鏍煎紡 + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getEnumstring())&&!checkKVArr(codeClassifyTemplateAttrDO.getEnumstring())){ + throw new VciBaseException("{0}{1}灞炴�х殑鏋氫妇娉ㄥ叆鏁版嵁鏍煎紡閿欒!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); + } + //鍒嗙被娉ㄥ叆 + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getClassifyinvokeattr()) + && !CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(codeClassifyTemplateAttrDO.getClassifyinvokelevel()) + && VciBaseUtil.getInt(codeClassifyTemplateAttrDO.getClassifyinvokelevel()) < 0){ + throw new VciBaseException("{0}{1}灞炴�х殑鏄垎绫绘敞鍏ワ紝浣嗘槸娉ㄥ叆灞傜骇涓嶈兘灏忎簬0!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); + } + + //鍒ゆ柇浼犺繃鏉ョ殑鍙傜収閰嶇疆鏄惁鏄痡son鏍煎紡 + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getReferconfig())&&!checkKVObj(codeClassifyTemplateAttrDO.getReferconfig())){ + throw new VciBaseException("{0}{1}灞炴�х殑鍙傜収閰嶇疆鏁版嵁鏍煎紡閿欒!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); + } + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodedateformat()) && !checkDateFormat(codeClassifyTemplateAttrDO.getCodedateformat())){ + throw new VciBaseException("{0}{1}灞炴�х殑鏃堕棿鏍煎紡涓嶇鍚堣姹�",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); + } + //濡傛灉鏄粍鍚堣鍒欙紝閲岄潰浣跨敤鐨勫睘鎬т笉鑳界己澶憋紝涔熼兘寰楁樉绀� + String componentrule = codeClassifyTemplateAttrDTO.getComponentrule(); + boolean isContainsDynamicParameter = PatternUtil.isContainsDynamicParameter(componentrule); + if(isContainsDynamicParameter){ + List<String> userdAttrList = PatternUtil.getKeyListByContent(componentrule);//鍖呭惈鐨勬墍鏈�${xxx}涓殑xxx + if(!CollectionUtils.isEmpty(userdAttrList)){ + String unExistAttr = userdAttrList.stream().filter(s -> !attrDTOMap.containsKey(s.toLowerCase(Locale.ROOT))).collect(Collectors.joining(",")); + if(StringUtils.isNotBlank(unExistAttr)){ + throw new VciBaseException("{0}灞炴�ф槸缁勫悎瑙勫垯锛屼絾鏄鍒欓噷鍖呭惈鐨勫睘鎬{1}]鍦ㄥ綋鍓嶆ā鏉夸腑涓嶅瓨鍦�!",new String[]{codeClassifyTemplateAttrDO.getName(), unExistAttr}); + } + //瑕佺湅鐪嬭〃鍗曟槸鍚︽樉绀� + String unFormDisplayAttr = userdAttrList.stream().filter(s -> !VciBaseUtil.getBoolean(attrDTOMap.getOrDefault(s.toLowerCase(Locale.ROOT), + new CodeClstempattrDTO()).getFormdisplayflag())).collect(Collectors.joining(",")); + if(StringUtils.isNotBlank(unFormDisplayAttr)){ + throw new VciBaseException("{0}灞炴�ф槸缁勫悎瑙勫垯锛屼絾鏄鍒欓噷鍖呭惈鐨勫睘鎬{1}]鍦ㄥ綋鍓嶆ā鏉夸腑娌℃湁璁剧疆 琛ㄥ崟鏄剧ず ",new String[]{codeClassifyTemplateAttrDO.getName(),unFormDisplayAttr}); + } + } + } + + if(CLASSIFYTEMPLATEOID==null){ + CLASSIFYTEMPLATEOID = codeClassifyTemplateAttrDTO.getClassifytemplateoid(); + } + + } + + //鎵ц鏁版嵁淇濆瓨鎿嶄綔 +// WebUtil.setPersistence(false);//涓嶆墽琛屼繚瀛� + + //鍏堥兘鍒犱簡 +// VciQueryWrapperForDO deleteAttrWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); +// deleteAttrWrapper.addQueryMap("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID); + Map<String,Object> condition = new HashMap<>(); + condition.put("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID); + List<CodeClstempattrEntity> codeClassifyTemplateAttrDODelete = baseMapper.selectByMap(condition); + + //oids + List<String> oids = new ArrayList<String>(); + for (CodeClstempattrEntity codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDODelete){ + oids.add(codeClassifyTemplateAttrDO.getOid()); + } +// BatchCBO batchCBOTemplateDelete = new BatchCBO(); + if(!CollectionUtils.isEmpty(oids)){ + baseMapper.deleteBatchIds(oids); + } + + //鍐嶆柊澧� + if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ + this.saveBatch(codeClassifyTemplateAttrDOInsert); + } + + //璋冪敤闃舵 + if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ + List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrs = new ArrayList<>(); + for (CodeClstempattrEntity codeClstempattrEntity : codeClassifyTemplateAttrDOInsert) { + CodeClassifyTemplateAttr codeClassifyTemplateAttr = new CodeClassifyTemplateAttr(); + BeanUtils.copyProperties(codeClstempattrEntity,codeClassifyTemplateAttr);; + codeClassifyTemplateAttrs.add(codeClassifyTemplateAttr); + } + codeTempphaseService.codeTemplateAttrModifyTrigger(codeClassifyTemplateAttrs); + + } + + +// SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); + //澶勭悊鍙緭鍙�夌殑瀛楃 + if(!CollectionUtils.isEmpty(prefix)){ + for (String s : prefix) { + DictBiz dictBiz = new DictBiz(); + dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); + dictBiz.setDictKey(s); + dictBiz.setDictValue("prefix"); + iDictBizClient.getCheck(dictBiz) ; + } +// .saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"prefix",prefix,sessionInfo); + } + if(!CollectionUtils.isEmpty(suffix)){ + for (String s : suffix) { + DictBiz dictBiz = new DictBiz(); + dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); + dictBiz.setDictKey(s); + dictBiz.setDictValue("suffix"); + iDictBizClient.getCheck(dictBiz) ; + } +// charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"suffix",suffix,sessionInfo); + } + if(!CollectionUtils.isEmpty(dateFormates)){ + for (String s : dateFormates) { + DictBiz dictBiz = new DictBiz(); + dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); + dictBiz.setDictKey(s); + dictBiz.setDictValue("dateFormates"); + iDictBizClient.getCheck(dictBiz) ; + } +// charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"dateFormates",dateFormates,sessionInfo); + } + +// WebUtil.setPersistence(true);//鎵ц淇濆瓨 +// boService.persistenceBatch(batchCBOTemplateDelete);//涓�璧锋墽琛屼繚瀛� + return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOInsert); + } + + public boolean checkKVArr(String kvString){ + boolean isKV = true; + try { + JSONObject.parseArray(kvString, KeyValue.class); + }catch (Exception e){ + isKV=false; + } + return isKV; + } + public boolean checkKVObj(String kvString){ + boolean isKV = true; + try { + JSONObject.parseObject(kvString, UIFormReferVO.class); + }catch (Exception e){ + isKV=false; + } + return isKV; + } + + /** + * 鏍¢獙鏃堕棿鏍煎紡 + * @param dateFormat 鏃堕棿鏍煎紡 + * @return true琛ㄧず鏍¢獙閫氳繃 + */ + public boolean checkDateFormat(String dateFormat){ + try{ + VciDateUtil.date2Str(new Date(),dateFormat); + return true; + }catch (Throwable e){ + return false; + } + } + + + /** + * 淇敼涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� + * @return 鎵ц缁撴灉 + * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父 + */ + @Override + public R editSave(CodeClstempattrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ + VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"鏁版嵁瀵硅薄",codeClassifyTemplateAttrDTO.getOid(),"涓婚搴撳垎绫荤殑妯℃澘灞炴�т富閿�"); + + //鍒ゆ柇浼犺繃鏉ョ殑鏋氫妇娉ㄥ叆鏄惁鏄痡sonArr鏍煎紡 + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getEnumstring())&&!checkKVArr(codeClassifyTemplateAttrDTO.getEnumstring())){ + throw new VciBaseException("鏋氫妇娉ㄥ叆鏁版嵁鏍煎紡閿欒!"); + } + + //鍒ゆ柇浼犺繃鏉ョ殑鍙傜収閰嶇疆鏄惁鏄痡son鏍煎紡 + if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getReferbtmid())&&!checkKVObj(codeClassifyTemplateAttrDTO.getReferbtmid())){ + throw new VciBaseException("鏋氫妇娉ㄥ叆鏁版嵁鏍煎紡閿欒!"); + } + + + //妫�鏌s + CodeClstempattrEntity codeClassifyTemplateAttrDOCopyFromDTO = new CodeClstempattrEntity(); +// BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDOCopyFromDTO); +// boolean tsBoolean = boService.checkTs(codeClassifyTemplateAttrDOCopyFromDTO); + + //妫�鏌s +// Map<String,Object> condition = new HashMap<>(2); +// condition.put("oid",codeClassifyTemplateAttrDTO.getOid()); +// condition.put("ts",codeClassifyTemplateAttrDTO.getTs()); + CodeClstempattrEntity detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); + if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//涓嶆槸鏈�鏂扮殑涓嶈鏀� + return R.fail("褰撳墠鏁版嵁涓嶆槸鏈�鏂帮紝璇峰埛鏂板悗鍐嶄慨鏀癸紒"); + } + + //灏咲TO杞崲涓篋O + CodeClstempattrEntity codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); + revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); + baseMapper.updateById(codeClassifyTemplateAttrDO); + return R.data(codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO)); + } + + /** + * 鍒犻櫎涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈� + * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐� + * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯� + */ + @Override + public R deleteCodeClassifyTemplateAttr(CodeClstempattrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ + VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹璞�",codeClassifyTemplateAttrDTO.getOid(),"涓婚搴撳垎绫荤殑妯℃澘灞炴�х殑涓婚敭"); + CodeClstempattrEntity codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); + R baseResult = checkIsCanDeleteForDO(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); + if(baseResult.isSuccess()) { + }else{ + return baseResult; + } + //鎵ц鍒犻櫎鎿嶄綔 + int deleteNum = baseMapper.deleteById(codeClassifyTemplateAttrDO.getOid()); + return deleteNum>0?R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL); + } + + /** + * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎 + * @param codeClassifyTemplateAttrDTO 鏁版嵁浼犺緭瀵硅薄 + * @param codeClassifyTemplateAttrDO 鏁版嵁搴撲腑鐨勬暟鎹璞� + * @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾� + */ + private R checkIsCanDeleteForDO(CodeClstempattrDTO codeClassifyTemplateAttrDTO, CodeClstempattrEntity codeClassifyTemplateAttrDO) { +// boService.checkTs(codeClassifyTemplateAttrDO); +// Map<String,Object> condition = new HashMap<>(2); +// condition.put("oid",codeClassifyTemplateAttrDTO.getOid()); +// condition.put("ts",codeClassifyTemplateAttrDTO.getTs()); + CodeClstempattrEntity detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); +// .selectOne(Condition.getQueryWrapper(condition,CodeClstempattrEntity.class)); + + if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//涓嶆槸鏈�鏂扮殑涓嶈鏀� + return R.fail("褰撳墠鏁版嵁涓嶆槸鏈�鏂帮紝璇峰埛鏂板悗鍐嶄慨鏀癸紒"); + } + if(!checkIsLinked(codeClassifyTemplateAttrDO.getOid())) { + return R.success("鍙互鍒犻櫎锛�"); + }else{ + return R.fail(DATA_LINKED_NOT_DELETE); + } + } + + /** + * 鏍¢獙鏄惁琚紩鐢� + * @param oid 涓婚敭 + * @throws VciBaseException 琚紩鐢ㄧ殑鏃跺�欎細鎶涘嚭寮傚父 + */ + private boolean checkIsLinked(String oid) throws VciBaseException{ + //TODO 娣诲姞闇�瑕佹牎楠屽紩鐢ㄧ殑鍦版柟 + return false; + } + + /** + * 涓婚敭鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param oid 涓婚敭 + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� + * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父 + */ + @Override + public CodeClstempattrVO getObjectByOid(String oid) throws VciBaseException{ + return codeClassifyTemplateAttrDO2VO(selectByOid(oid)); + } + /** + * 涓婚敭鏌ヨ鏁版嵁瀵硅薄 + * @param oid 涓婚敭 + * @return 鏁版嵁瀵硅薄 + * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父 + */ + private CodeClstempattrEntity selectByOid(String oid) throws VciBaseException{ + VciBaseUtil.alertNotNull(oid,"涓婚敭"); + CodeClstempattrEntity codeClassifyTemplateAttrDO = baseMapper.selectById(oid.trim()); + if(codeClassifyTemplateAttrDO == null || StringUtils.isBlank(codeClassifyTemplateAttrDO.getOid())){ + throw new VciBaseException(DATA_OID_NOT_EXIST); + } + return codeClassifyTemplateAttrDO; + } + + /** + * 涓婚敭鎵归噺鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� + * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓� + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� + * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭 + */ + @Override + public Collection<CodeClstempattrVO> listCodeClassifyTemplateAttrByOids(Collection<String> oidCollections) { + VciBaseUtil.alertNotNull(oidCollections,"鏁版嵁瀵硅薄涓婚敭闆嗗悎"); + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = listCodeClassifyTemplateAttrDOByOidCollections(oidCollections); + return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOList); + } + + /** + * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄 + * @param oidCollections 涓婚敭鐨勯泦鍚� + * @return 鏁版嵁瀵硅薄鍒楄〃 + */ + private List<CodeClstempattrEntity> listCodeClassifyTemplateAttrDOByOidCollections(Collection<String> oidCollections){ + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = new ArrayList<CodeClstempattrEntity>(); + if(!CollectionUtils.isEmpty(oidCollections)){ + Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); + for(Collection<String> oids: oidCollectionsList){ + List<CodeClstempattrEntity> tempDOList = baseMapper.selectBatchIds(oids); + if(!CollectionUtils.isEmpty(tempDOList)){ + codeClassifyTemplateAttrDOList.addAll(tempDOList); + } + } + } + return codeClassifyTemplateAttrDOList; + } + + /** + * 鍙傜収涓婚搴撳垎绫荤殑妯℃澘灞炴�у垪琛� + * @param conditionMap 鏌ヨ鏉′欢 + * @param pageHelper 鍒嗛〉鍜屾帓搴� + * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹� + * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父 + */ + @Override + public DataGrid<CodeClstempattrVO> refDataGridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ + if(conditionMap == null){ + conditionMap = new HashMap<String, String>(); + } + return gridCodeClassifyTemplateAttr(conditionMap,pageHelper); + } + + /** + * 鏌ヨ杩欎釜妯℃澘锛屼笟鍔$被鍨嬩笅鐨勬墍鏈夋湭閫夋嫨鐨勫睘鎬� + * @param baseQueryObject + * @return + */ + @Override + public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject){ + if(baseQueryObject.getConditionMap() == null){ + baseQueryObject.setConditionMap(new HashMap<>()); + } + DataGrid<CodeOsbtmtypeattributeVO> dataGrid=new DataGrid<CodeOsbtmtypeattributeVO>(); + //妯℃澘oid + String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); + String name = baseQueryObject.getConditionMap().getOrDefault("name",""); + String id = baseQueryObject.getConditionMap().getOrDefault("id",""); + + //娌℃湁oid涓嶆墽琛岄�昏緫 + if(StringUtils.isBlank(templateAttrOid)){ + dataGrid.setData(new ArrayList<>()); + dataGrid.setTotal(0); + return dataGrid; + } + + //鏌ヨ妯℃澘瀵硅薄 + CodeClstemplateEntity codeClassifyTemplateDO = codeClstemplateMapper.selectById(templateAttrOid); + + //杩欎釜涓氬姟绫诲瀷涓嬬殑鎵�鏈夊睘鎬� + List<CodeOsbtmtypeattributeVO> boAttrs = (List<CodeOsbtmtypeattributeVO>) codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId());// this.btmService.listAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); +// codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()); +// BeanUtils.copyProperties(codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()),boAttrs); + //鎶婇粯璁ょ殑灞炴�т篃娣诲姞鍒癰oAttrs + if(boAttrs == null){ + boAttrs = new ArrayList<>(); + } + if(!false){ +// List<CodeOsbtmtypeattributeVO> finalBoAttrs = boAttrs; +// attributeService.getDefaultAttributeVOs().stream().forEach(attr-> { +// CodeOsbtmtypeattributeVO attributeVO = new CodeOsbtmtypeattributeVO(); +// BeanUtil.convert(attr, attributeVO); +// if ("id".equalsIgnoreCase(attributeVO.getId())) { +// attributeVO.setName("浼佷笟缂栫爜"); +// } +// if ("name".equalsIgnoreCase(attributeVO.getId())) { +// attributeVO.setName("闆嗗洟鐮�"); +// } +// attributeVO.setAttrDataType(attr.getAttributeDataType()); +// attributeVO.setAttributeLength(attr.getAttrLength()); +// attributeVO.setReferBtmTypeId(attr.getBtmTypeId()); +// attributeVO.setReferBtmTypeName(attr.getBtmTypeName()); +// finalBoAttrs.add(attributeVO); +// }); +// boAttrs = finalBoAttrs; + Object o = null; + } + + //杩欎釜妯℃澘涓嬪凡缁忔湁鐨勫睘鎬� +// VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); +// queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); + Map<String,Object> condition = new HashMap<>(1); + condition.put("CLASSIFYTEMPLATEOID",templateAttrOid); + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = codeClstempattrMapper.selectByMap(condition); + + List<String> btmOids = new ArrayList<String>(); + for (CodeClstempattrEntity codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ + btmOids.add(codeClassifyTemplateAttrDO.getId()); + } + + //杩囨护鎺夊凡缁忓瓨鍦ㄧ殑灞炴�� + List<CodeOsbtmtypeattributeVO> boAttrss = new ArrayList<CodeOsbtmtypeattributeVO>(); + + for (CodeOsbtmtypeattributeVO osBtmTypeAttributeVO:boAttrs){ + if(!btmOids.contains(osBtmTypeAttributeVO.getId())){ + //鐪嬬湅鏄笉鏄湁妯$硦鏌ヨ + boolean inSearch = true; + if(StringUtils.isNotBlank(name) && !osBtmTypeAttributeVO.getName().contains(name.replace("*",""))){ + inSearch = false; + } + if(StringUtils.isNotBlank(id) && !osBtmTypeAttributeVO.getId().contains(id.replace("*",""))){ + inSearch = false; + } + if(inSearch) { + boAttrss.add(osBtmTypeAttributeVO); + } + } + } + dataGrid.setData(boAttrss); + dataGrid.setTotal(boAttrss.size()); + return dataGrid; + } + + + + /** + * 鏌ヨ杩欎釜妯℃澘锛屼笟鍔$被鍨嬩笅宸查�夋嫨鐨勫睘鎬� + * @param baseQueryObject + * @return + */ + @Override + public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject){ + DataGrid<CodeOsbtmtypeattributeVO> dataGrid=new DataGrid<CodeOsbtmtypeattributeVO>(); + //妯℃澘oid + String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); + + //娌℃湁oid涓嶆墽琛岄�昏緫 + if(StringUtils.isBlank(templateAttrOid)){ + dataGrid.setData(new ArrayList<>()); + dataGrid.setTotal(0); + return dataGrid; + } + + //鏌ヨ妯℃澘瀵硅薄 + CodeClstemplateEntity codeClassifyTemplateDO = codeClstemplateMapper.selectById(templateAttrOid); + + //杩欎釜涓氬姟绫诲瀷涓嬬殑鎵�鏈夊睘鎬� + List<CodeOsbtmtypeattributeVO> boAttrs = (List<CodeOsbtmtypeattributeVO>) codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId());//this.btmService.listAttributeByBtmIdHasDefault(codeClassifyTemplateDO.getBtmTypeId()); +// codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()); +// BeanUtils.copyProperties(codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()),boAttrs); + //杩欎釜妯℃澘涓嬪凡缁忔湁鐨勫睘鎬� + //鎶婇粯璁ょ殑灞炴�т篃娣诲姞鍒癰oAttrs + if(boAttrs == null){ + boAttrs = new ArrayList<>(); + } +// VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); +// queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); + +// Map<String,Object> condition = new HashMap<>(1); +// condition.put("CLASSIFYTEMPLATEOID",templateAttrOid); + + QueryWrapper<CodeClstempattrEntity> wrapper=new QueryWrapper<>(); + wrapper.eq("CLASSIFYTEMPLATEOID",templateAttrOid); + + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = codeClstempattrMapper.selectList(wrapper); + List<String> btmOids = new ArrayList<String>(); + for (CodeClstempattrEntity codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ + btmOids.add(codeClassifyTemplateAttrDO.getId()); + } + + //杩囨护鎺夐櫎浜嗚嚜韬殑鍒殑灞炴�� + List<CodeOsbtmtypeattributeVO> boAttrss = new ArrayList<CodeOsbtmtypeattributeVO>(); + + for (CodeOsbtmtypeattributeVO osBtmTypeAttributeVO:boAttrs){ + if(btmOids.contains(osBtmTypeAttributeVO.getId())){ + boAttrss.add(osBtmTypeAttributeVO); + } + } + dataGrid.setData(boAttrss); + dataGrid.setTotal(boAttrss.size()); + return dataGrid; + } + + + /** + * 鍚屾鍒板叾浠栨ā鏉� + * @param codeClassifyTemplateAttrDTO oid + * @return + */ + @Override + public R copyto(CodeClstempattrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ + + String templateAttrOid = codeClassifyTemplateAttrDTO.getOid(); + + //鏌ヨ鍑烘潵瑕佸鍒剁殑瀵硅薄 + CodeClstempattrEntity codeClassifyTemplateAttrDO = selectByOid(templateAttrOid); + String id = codeClassifyTemplateAttrDO.getId();//鑻辨枃鍚嶇О + String classfyTemplateOid = codeClassifyTemplateAttrDO.getClassifytemplateoid(); + + //鏌ヨ鍏朵粬id=id鐨勬ā鏉垮睘鎬� +// VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); +// queryWrapper.addQueryMap("id",id); +// Map<String,Object> condition = new HashMap<>(1); +// condition.put("id",id); + QueryWrapper<CodeClstempattrEntity> wrapper=new QueryWrapper<>(); + wrapper.eq("id",id); + //鎵�鏈塱d=id鐨勬ā鏉垮睘鎬� + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList =codeClstempattrMapper.selectList(wrapper); + + //瑕佸垹闄ょ殑妯℃澘灞炴�х殑oids + List<String> deleteOids = new ArrayList<String>(); + //瑕佷慨鏀圭殑妯℃澘灞炴�у璞� + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOListInsert = new ArrayList<CodeClstempattrEntity>(); + for (CodeClstempattrEntity codeClassifyTemplateAttrDOi:codeClassifyTemplateAttrDOList){ + String oid = codeClassifyTemplateAttrDOi.getOid(); + String templateOldOid = codeClassifyTemplateAttrDOi.getClassifytemplateoid(); + + CodeClstempattrEntity codeClassifyTemplateAttrDOInsert = new CodeClstempattrEntity(); + BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,codeClassifyTemplateAttrDOInsert); + codeClassifyTemplateAttrDOInsert.setOid(oid); + codeClassifyTemplateAttrDOInsert.setClassifytemplateoid(templateOldOid); + codeClassifyTemplateAttrDOListInsert.add(codeClassifyTemplateAttrDOInsert); + + deleteOids.add(codeClassifyTemplateAttrDOi.getOid()); + } + +// WebUtil.setPersistence(false);//涓嶆墽琛屼繚瀛� + + //鍒犻櫎 +// BatchCBO batchCBOTemplateAttrDelete = codeClassifyTemplateAttrDOissifyTemplateAttrMapper.batchDeleteByOids(deleteOids); + codeClstempattrMapper.deleteBatchIds(deleteOids); + //鍐嶆柊澧� +// BatchCBO batchCBOTemplateAttrInsert = codeClassifyTemplateAttrMapper.batchInsert(codeClassifyTemplateAttrDOListInsert); +// batchCBOTemplateAttrDelete.copyFromOther(batchCBOTemplateAttrInsert); + this.saveBatch(codeClassifyTemplateAttrDOListInsert); + +// WebUtil.setPersistence(true);//鎵ц淇濆瓨 +// boService.persistenceBatch(batchCBOTemplateAttrDelete);//涓�璧锋墽琛屼繚瀛� + + return R.success("鎿嶄綔鎴愬姛锛�"); + } +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstemplateServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstemplateServiceImpl.java index dfba31d..f684d88 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstemplateServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstemplateServiceImpl.java @@ -27,8 +27,8 @@ import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; import com.vci.ubcs.code.mapper.*; import com.vci.ubcs.code.service.ICodeClassifyService; -import com.vci.ubcs.code.service.ICodeClassifyTemplateAttrService; import com.vci.ubcs.code.service.ICodeClstemplateService; +import com.vci.ubcs.code.vo.CodeClstempattrVO; import com.vci.ubcs.code.vo.CodeClstemplateVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; import com.vci.ubcs.starter.exception.VciBaseException; @@ -36,6 +36,7 @@ import com.vci.ubcs.starter.revision.model.TreeWrapperOptions; import com.vci.ubcs.starter.revision.service.RevisionModelUtil; import com.vci.ubcs.starter.web.pagemodel.DataGrid; +import com.vci.ubcs.starter.web.pagemodel.PageHelper; import com.vci.ubcs.starter.web.pagemodel.Tree; import com.vci.ubcs.starter.web.util.BeanUtilForVCI; import com.vci.ubcs.starter.web.util.VciBaseUtil; @@ -45,6 +46,7 @@ import org.springblade.core.tool.api.R; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cglib.beans.BeanMap; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -71,7 +73,7 @@ */ @Lazy @Autowired(required = false) - ICodeClassifyTemplateAttrService codeClstempattrService; + CodeClstempattrServiceImpl codeClstempattrService; /** * 瀵硅薄鐨勬搷浣� @@ -80,7 +82,7 @@ private RevisionModelUtil revisionModelUtil; @Autowired(required = false) - private CodeClassifyTemplateAttrMapper codeClstempattrMapper; + private CodeClstempattrMapper codeClstempattrMapper; @Autowired(required = false) private CodeTempphaseServiceImpl codeTempphaseServiceImpl; @Autowired(required = false) @@ -179,14 +181,20 @@ if(hasAttr){ //涓�涓垎绫婚噷闈㈡�讳笉鑳借秴杩�1000涓敓鏁堢殑鐗堟湰鍚э紒锛侊紒 VciBaseUtil.switchCollectionForOracleIn(voList.stream().map(CodeClstemplateVO::getOid).collect(Collectors.toList())).forEach(tempOids->{ - List<CodeClassifyTemplateAttrVO> attrVOList = codeClstempattrService.listCodeClassifyTemplateAttrByTemplateOids(tempOids); + List<CodeClstempattrVO> attrVOList = codeClstempattrService.listCodeClassifyTemplateAttrByTemplateOids(tempOids); if(!CollectionUtils.isEmpty(attrVOList)){ - Map<String, List<CodeClassifyTemplateAttrVO>> attrVOMap = attrVOList.stream().collect(Collectors.groupingBy(s -> s.getClassifyTemplateOid())); - + Map<String, List<CodeClstempattrVO>> attrVOMap = attrVOList.stream().collect(Collectors.groupingBy(s -> s.getClassifytemplateoid())); voList.stream().forEach(templateVO->{ if(attrVOMap.containsKey(templateVO.getOid())){ - templateVO.setAttributes(attrVOMap.get(templateVO.getOid())); + List<CodeClstempattrVO> codeClstempattrVOS = attrVOMap.get(templateVO.getOid()); + List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOS = new ArrayList<>(); + for (CodeClstempattrVO codeClstempattrVO : codeClstempattrVOS) { + CodeClassifyTemplateAttrVO codeClassifyTemplateAttrVO = new CodeClassifyTemplateAttrVO(); + BeanUtils.copyProperties(codeClstempattrVO,codeClassifyTemplateAttrVO); + codeClassifyTemplateAttrVOS.add(codeClassifyTemplateAttrVO); + } + templateVO.setAttributes(codeClassifyTemplateAttrVOS); } }); } @@ -343,11 +351,11 @@ //鍒犻櫎妯℃澘灞炴�� // VciQueryWrapperForDO templateQueryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); // templateQueryWrapper.addQueryMap("classifyTemplateOid",templateOid); - List<CodeClassifyTemplateAttr> codeClstempattrEntityList = codeClstempattrMapper.selectRefByOid(templateOid); + List<CodeClstempattrEntity> codeClstempattrEntityList = codeClstempattrMapper.selectRefByOid(templateOid); if(!CollectionUtils.isEmpty(codeClstempattrEntityList)) { List<String> templateAttrOids = new ArrayList<String>(); - for (CodeClassifyTemplateAttr codeClstempattrEntity:codeClstempattrEntityList){ + for (CodeClstempattrEntity codeClstempattrEntity:codeClstempattrEntityList){ templateAttrOids.add(codeClstempattrEntity.getOid()); } @@ -487,34 +495,34 @@ // ClientBusinessObject clientBusinessObject_template_insert = null; // try { // clientBusinessObject_template_insert = clientBusinessObjectOperation.reviseBusinessObject(clientBusinessObject_template, ""); - codeCls_template_insert.setOid(VciBaseUtil.getPk()); - codeCls_template_insert.setRevisionOid(VciBaseUtil.getPk()); - codeCls_template_insert.setNameOid(codeCls_template.getNameOid()); - codeCls_template_insert.setBtmname(codeCls_template.getBtmname()); - codeCls_template_insert.setLastR(String.valueOf(1)); - codeCls_template_insert.setFirstR(String.valueOf(0)); - codeCls_template_insert.setFirstV(String.valueOf(1)); - codeCls_template_insert.setLastV(String.valueOf(1)); - codeCls_template_insert.setCreator(AuthUtil.getUser().getUserName()); - codeCls_template_insert.setCreateTime(new Date()); - codeCls_template_insert.setLastModifier(AuthUtil.getUser().getUserName()); - codeCls_template_insert.setLastModifyTime(new Date()); - codeCls_template_insert.setRevisionRule(codeCls_template.getRevisionRule()); - codeCls_template_insert.setVersionRule(codeCls_template.getVersionRule()); - Map rvObj = baseMapper.getNextRevision(codeCls_template.getNameOid()); - codeCls_template_insert.setRevisionSeq(Integer.parseInt(rvObj.get("REVISIONSEQ").toString())); - codeCls_template_insert.setRevisionValue(rvObj.get("REVISIONVAL").toString()); + codeCls_template_insert.setOid(VciBaseUtil.getPk()); + codeCls_template_insert.setRevisionOid(VciBaseUtil.getPk()); + codeCls_template_insert.setNameOid(codeCls_template.getNameOid()); + codeCls_template_insert.setBtmname(codeCls_template.getBtmname()); + codeCls_template_insert.setLastR(String.valueOf(1)); + codeCls_template_insert.setFirstR(String.valueOf(0)); + codeCls_template_insert.setFirstV(String.valueOf(1)); + codeCls_template_insert.setLastV(String.valueOf(1)); + codeCls_template_insert.setCreator(AuthUtil.getUser().getUserName()); + codeCls_template_insert.setCreateTime(new Date()); + codeCls_template_insert.setLastModifier(AuthUtil.getUser().getUserName()); + codeCls_template_insert.setLastModifyTime(new Date()); + codeCls_template_insert.setRevisionRule(codeCls_template.getRevisionRule()); + codeCls_template_insert.setVersionRule(codeCls_template.getVersionRule()); + Map rvObj = baseMapper.getNextRevision(codeCls_template.getNameOid()); + codeCls_template_insert.setRevisionSeq(Integer.parseInt(rvObj.get("REVISIONSEQ").toString())); + codeCls_template_insert.setRevisionValue(rvObj.get("REVISIONVAL").toString()); // VersionValueObject versionObj = this.getVersionValue(item.verRuleName); - codeCls_template_insert.setVersionSeq(Integer.parseInt(rvObj.get("VERSIONSEQ").toString())); - codeCls_template_insert.setVersionValue(rvObj.get("VERSIONVAL").toString()); - codeCls_template_insert.setLctid(codeCls_template.getLctid()); - codeCls_template_insert.setLcStatus("Editing"); - codeCls_template_insert.setId(codeCls_template.getId()); - codeCls_template_insert.setName(codeCls_template.getName()); - codeCls_template_insert.setDescription(codeCls_template.getDescription()); - codeCls_template_insert.setOwner(AuthUtil.getUser().getUserName()); + codeCls_template_insert.setVersionSeq(Integer.parseInt(rvObj.get("VERSIONSEQ").toString())); + codeCls_template_insert.setVersionValue(rvObj.get("VERSIONVAL").toString()); + codeCls_template_insert.setLctid(codeCls_template.getLctid()); + codeCls_template_insert.setLcStatus("Editing"); + codeCls_template_insert.setId(codeCls_template.getId()); + codeCls_template_insert.setName(codeCls_template.getName()); + codeCls_template_insert.setDescription(codeCls_template.getDescription()); + codeCls_template_insert.setOwner(AuthUtil.getUser().getUserName()); // codeCls_template_insert.setCheckinBy(userName); - codeCls_template_insert.setCopyFromVersion(codeCls_template.getOid()); + codeCls_template_insert.setCopyFromVersion(codeCls_template.getOid()); // }catch (VCIError e){ // e.printStackTrace(); // logger.error("===============>鍒嗙被妯℃澘-鍗囩増澶嶅埗鍑洪敊oid锛� "+templateOldOid+",mes"+e.error_message); @@ -537,12 +545,12 @@ // codeClassifyTemplateAttrQuery.addQueryMap("classifyTemplateOid",templateOldOid); Map<String,Object> condition = new HashMap<>(1); condition.put("classifyTemplateOid",templateOldOid); - List<CodeClassifyTemplateAttr> codeClstempattrEntities = codeClstempattrMapper.selectByMap(condition); + List<CodeClstempattrEntity> codeClstempattrEntities = codeClstempattrMapper.selectByMap(condition); // List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOList = codeClassifyTemplateAttrDaoI.selectByWrapper(codeClassifyTemplateAttrQuery); - for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO :codeClstempattrEntities){ + for (CodeClstempattrEntity codeClassifyTemplateAttrDO :codeClstempattrEntities){ // String attrOid = VciBaseUtil.getPk(); codeClassifyTemplateAttrDO.setOid(null); - codeClassifyTemplateAttrDO.setClassifyTemplateOid(templateNewOid); + codeClassifyTemplateAttrDO.setClassifytemplateoid(templateNewOid); codeClstempattrMapper.insert(codeClassifyTemplateAttrDO); } @@ -559,7 +567,7 @@ //涓�璧蜂繚瀛樻暟鎹� // WebUtil.setPersistence(false);//涓嶆墽琛屼繚瀛� - //淇濆瓨妯℃澘鈥斺�� + //淇濆瓨妯℃澘 // BatchCBO batchCBOTemplate = new BatchCBO(); //batchCBO淇濆瓨鐨勬椂鍊欐病鏈夎兘澶熻嚜鍔╱pdate婧愭暟鎹殑isLastR //batchCBOTemplate.getCreateCbos().add(clientBusinessObject_template_insert); @@ -646,7 +654,7 @@ codeClassifyTemplateDOList.add(codeClassifyTemplateDO_old); //澶嶅埗妯℃澘灞炴�� - List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = copyTemplateAttr(oldOid,newOid); + List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = copyTemplateAttr(oldOid,newOid); //澶嶅埗妯℃澘娴佺▼ List<CodeClsflowtempEntity> codeClassifyProcessTempDOList = copyTemplateProcess(oldOid,newOid); @@ -815,23 +823,23 @@ /** * 澶嶅埗妯℃澘灞炴�� */ - public List<CodeClassifyTemplateAttr> copyTemplateAttr(String templateOldOid,String templateNewOid){ + public List<CodeClstempattrEntity> copyTemplateAttr(String templateOldOid,String templateNewOid){ // VciQueryWrapperForDO codeClassifyTemplateAttrQuery = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); // codeClassifyTemplateAttrQuery.addQueryMap("classifyTemplateOid",templateOldOid); // Map<String,Object> condition = new HashMap<>(1); // condition.put("classifyTemplateOid",templateOldOid); - QueryWrapper<CodeClassifyTemplateAttr> wrapper=new QueryWrapper<>(); + QueryWrapper<CodeClstempattrEntity> wrapper=new QueryWrapper<>(); wrapper.eq("classifyTemplateOid",templateOldOid); -// List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = codeClassifyTemplateAttrDaoI.selectByWrapper(codeClassifyTemplateAttrQuery); - List<CodeClassifyTemplateAttr> codeClstempattrEntities = codeClstempattrMapper.selectList(wrapper); +// List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = codeClassifyTemplateAttrDaoI.selectByWrapper(codeClassifyTemplateAttrQuery); + List<CodeClstempattrEntity> codeClstempattrEntities = codeClstempattrMapper.selectList(wrapper); - for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO :codeClstempattrEntities){ + for (CodeClstempattrEntity codeClassifyTemplateAttrDO :codeClstempattrEntities){ // String attrOid = VciBaseUtil.getPk(); codeClassifyTemplateAttrDO.setOid(null); - codeClassifyTemplateAttrDO.setClassifyTemplateOid(templateNewOid); + codeClassifyTemplateAttrDO.setClassifytemplateoid(templateNewOid); // codeClstempattrMapper.insert(codeClassifyTemplateAttrDO); } return codeClstempattrEntities; @@ -841,13 +849,13 @@ /** * 鍒嗙被妯℃澘鍒楄〃 * - * @param plCodeClstemplate 鏌ヨ鏉′欢 - * @param query 鍒嗛〉瀵硅薄 + * @param conditionMap 鏌ヨ鏉′欢 + * @param pageHelper 鍒嗛〉瀵硅薄 * @return 鏄剧ず瀵硅薄 * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - public DataGrid<CodeClstemplateVO> gridCodeClassifyTemplate(CodeClstemplateVO plCodeClstemplate, Query query) throws VciBaseException { + public DataGrid<CodeClstemplateVO> gridCodeClassifyTemplate(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException { DataGrid<CodeClstemplateVO> dataGrid=new DataGrid<CodeClstemplateVO>(); //娌℃湁浼犲垎绫籭d锛屼笉鎵ц鏌ヨ閫昏緫锛岀洿鎺ヨ繑鍥� // if(conditionMap.size()==0){ @@ -860,14 +868,36 @@ // } // pageHelper.addDefaultDesc("revisionSeq"); - List<CodeClstemplateVO> doList = codeClstemplateMapper.selectPlCodeClstemplatePage(Condition.getPage(query), plCodeClstemplate); - if (!CollectionUtils.isEmpty(doList)) { - // QueryWrapper<CodeClstemplateVO> codeClstemplateVOQueryWrapper = new QueryWrapper<>(); - // codeClstemplateVOQueryWrapper.allEq(plCodeClstemplate); - List<CodeClstemplateEntity> codeClstemplateEntity = new ArrayList<>(); - BeanUtils.copyProperties(doList,codeClstemplateEntity); - dataGrid.setData(codeClassifyTemplateDO2VOs(codeClstemplateEntity)); - dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeClstemplateMapper.selectCount(Condition.getQueryWrapper(plCodeClstemplate))))); + CodeClstemplateVO codeClstemplateVO = new CodeClstemplateVO(); + CodeClstemplateEntity codeClstemplateQuery = new CodeClstemplateEntity(); +// BeanUtil.toBean(map,codeClstempattrVO); +// BeanUtil + BeanMap beanMap = BeanMap.create(codeClstemplateVO); + beanMap.putAll(conditionMap); + BeanUtils.copyProperties(codeClstemplateVO,codeClstemplateQuery); + if (pageHelper == null) { + pageHelper = new PageHelper(-1); + } +// IPage iPage = new IPage(); + Query query = new Query(); +// query.setSize(100); + if(pageHelper.getLimit() != -1){ + query.setSize(pageHelper.getLimit()); + query.setCurrent(pageHelper.getPage()); + } + +// List<CodeClstemplateVO> doList = codeClstemplateMapper.selectPlCodeClstemplatePage(Condition.getPage(query), codeClstemplateVO); + + IPage<CodeClstemplateEntity> doList = baseMapper. + selectPage(Condition.getPage(query), Condition.getQueryWrapper(codeClstemplateVO)); + if (!CollectionUtils.isEmpty(doList.getRecords())) { +// QueryWrapper<CodeClstemplateVO> codeClstemplateVOQueryWrapper = new QueryWrapper<>(); +// codeClstemplateVOQueryWrapper.allEq(plCodeClstemplate); +// List<CodeClstemplateEntity> codeClstemplateEntity = new ArrayList<>(); +// BeanUtils.copyProperties(doList,codeClstemplateEntity); + + dataGrid.setData(codeClassifyTemplateDO2VOs(doList.getRecords())); + dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeClstemplateMapper.selectCount(Condition.getQueryWrapper(codeClstemplateQuery))))); } return dataGrid; } @@ -1006,7 +1036,7 @@ // condition.put("ts",codeClassifyTemplateDOCopyFromDTO.getTs()); CodeClstemplateEntity detail = baseMapper .selectById(codeClassifyTemplateDOCopyFromDTO.getOid()); - // boolean tsBoolean = boService.checkTs(codeClassifyTemplateAttrDOListemplateDOCopyFromDTO); + // boolean tsBoolean = boService.checkTs(codeClassifyTemplateAttrDOListemplateDOCopyFromDTO); if(detail.getTs().compareTo(codeClassifyTemplateDOCopyFromDTO.getTs()) != 0){//涓嶆槸鏈�鏂扮殑涓嶈鏀� return R.fail("褰撳墠鏁版嵁涓嶆槸鏈�鏂帮紝璇峰埛鏂板悗鍐嶄慨鏀癸紒"); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/FormulaServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/FormulaServiceImpl.java new file mode 100644 index 0000000..dccbe4d --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/FormulaServiceImpl.java @@ -0,0 +1,1165 @@ +package com.vci.ubcs.code.service.impl; + + +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.vci.ubcs.code.mapper.CommonsMapper; +import com.vci.ubcs.starter.web.constant.VciSystemVarConstants; +import com.vci.ubcs.starter.web.toolmodel.DateConverter; +import com.vci.ubcs.starter.web.util.Md5; +import com.vci.ubcs.starter.web.util.VciDateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.Period; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * 鍏紡澶勭悊 + * @author weidy + * @date 2022-02-11 + * + */ +@Service +public class FormulaServiceImpl { + + /** + * 鏃ュ織鏂囦欢 + */ + private Logger logger = LoggerFactory.getLogger(getClass()); + /** + * 閫氱敤鏌ヨ + */ + @Resource + CommonsMapper commonsMapper; + +// /** +// * 涓氬姟鏁版嵁鏈嶅姟 +// */ +// @Autowired +// private WebBoServiceI boService; + + /** + * 鏄惁杩愯瀹屾垚 + */ + private Boolean formulaBlag = true; + /** + * 杩愮畻绗� + */ + public static List<String> lc = new ArrayList<String>(); + + static { + lc.add("+"); + lc.add("-"); + lc.add("*"); + lc.add("/"); + } + + /** + * 閫昏緫杩愮畻绗� + */ + public static List<String> lj = new ArrayList<String>(); + static { + lj.add(">"); + lj.add("<"); + lj.add("="); + lj.add("!"); + } + + /** + * 鍑芥暟锛宨nt鏁扮粍娉ㄩ噴,绗竴涓爣璇�:0鑷甫鍑芥暟 1鑷畾涔夊嚱鏁�;绗簩涓爣璇�:鍙傛暟涓暟 + */ + public static Map<String, int[]> funMap = new HashMap<String, int[]>(); + // int鏁扮粍娉ㄩ噴,绗竴涓爣璇�:0鑷甫鍑芥暟 1鑷畾涔夊嚱鏁�;绗簩涓爣璇�:鍙傛暟涓暟 + static { + // 鑷甫鍑芥暟,鍙埄鐢ㄥ弽灏勬満鍒� + funMap.put("abs", new int[] { 0, 1 }); + funMap.put("acos", new int[] { 0, 1 }); + funMap.put("asin", new int[] { 0, 1 }); + funMap.put("atan", new int[] { 0, 1 }); + funMap.put("cbrt", new int[] { 0, 1 }); + funMap.put("ceil", new int[] { 0, 1 }); + funMap.put("cos", new int[] { 0, 1 }); + funMap.put("cosh", new int[] { 0, 1 }); + funMap.put("exp", new int[] { 0, 1 }); + funMap.put("expm1", new int[] { 0, 1 }); + funMap.put("floor", new int[] { 0, 1 }); + funMap.put("log", new int[] { 0, 1 }); + funMap.put("log10", new int[] { 0, 1 }); + funMap.put("log1p", new int[] { 0, 1 }); + funMap.put("random", new int[] { 0, 0 }); + funMap.put("rint", new int[] { 0, 1 }); + funMap.put("round", new int[] { 0, 1 }); + funMap.put("signum", new int[] { 0, 1 }); + funMap.put("sin", new int[] { 0, 1 }); + funMap.put("sinh", new int[] { 0, 1 }); + funMap.put("sqrt", new int[] { 0, 1 }); + funMap.put("tan", new int[] { 0, 1 }); + funMap.put("tanh", new int[] { 0, 1 }); + funMap.put("max", new int[] { 0, 2 }); + funMap.put("min", new int[] { 0, 2 }); + + // 鑷畾涔夊嚱鏁� + funMap.put("if", new int[] { 1, 3 }); + funMap.put("sum", new int[] { 1, 2 }); + funMap.put("sub", new int[] { 1, 2 }); + funMap.put("mul", new int[] { 1, 2 }); + funMap.put("div", new int[] { 1, 2 }); + funMap.put("mod", new int[] { 1, 2 }); + funMap.put("toInt", new int[] { 1, 1 }); + funMap.put("toDouble", new int[] { 1, 1 }); + funMap.put("doubleRound", new int[] { 1, 2 }); + funMap.put("zeroIfNull", new int[] { 1, 1 }); + funMap.put("endsWith", new int[] { 1, 2 }); + funMap.put("startsWith", new int[] { 1, 2 }); + funMap.put("charAt", new int[] { 1, 2 }); + funMap.put("equalsIgnoreCase", new int[] { 1, 2 }); + funMap.put("indexOf", new int[] { 1, 2 }); + funMap.put("isEmpty", new int[] { 1, 1 }); + funMap.put("lastIndexOf", new int[] { 1, 2 }); + funMap.put("leftStr", new int[] { 1, 2 }); + funMap.put("length", new int[] { 1, 1 }); + funMap.put("mid", new int[] { 1, 3 }); + funMap.put("right", new int[] { 1, 2 }); + funMap.put("rightStr", new int[] { 1, 2 }); + funMap.put("tolowercase", new int[] { 1, 1 }); + funMap.put("touppercase", new int[] { 1, 1 }); + funMap.put("trimzero", new int[] { 1, 1 }); + funMap.put("compareDate", new int[] { 1, 2 }); + funMap.put("nowDate", new int[] { 1, 0 }); + funMap.put("chinaDate", new int[] { 1, 1 }); + funMap.put("dateDdd", new int[] { 1, 2 }); + funMap.put("dateBalanceYear",new int[] {1,3}); + funMap.put("dateBalanceDay",new int[] {1,2}); + funMap.put("dateformat", new int[] { 1, 2 }); + funMap.put("nowDatetime", new int[] { 1, 0 }); + funMap.put("dayOf", new int[] { 1, 1 }); + funMap.put("nowMon", new int[] { 1, 1 }); + funMap.put("monOf", new int[] { 1, 1 }); + funMap.put("nowTime", new int[] { 1, 0 }); + funMap.put("nowYear", new int[] { 1, 0 }); + funMap.put("yearOf", new int[] { 1, 1 }); + funMap.put("getChineseCurrency", new int[] { 1, 1 }); + funMap.put("setThmark", new int[] { 1, 1 }); + funMap.put("toChinese", new int[] { 1, 1 }); + funMap.put("getcolvalue", new int[] { 1, 5 }); + funMap.put("MD5", new int[]{1,1}); + funMap.put("getValueByMethod", new int[]{1,3}); + } + + /** + * 鍏紡鍒濆鍖栬浆鎹� + * + * @param str 鍏紡鐨勫唴瀹� + * @return 杞崲鍚庣殑鍐呭 + */ + private String strCast(String str) { + // str = str.toLowerCase();// 鍘婚櫎绌烘牸锛屽彉灏忓啓 + if (str == null ? true : str.length() == 0) { + return "0"; + } + str = str.trim(); + if (!checkFormula(str)) { + formulaError(); + return str; + } + str = str.replaceAll("锛�", ","); + str = str.replaceAll("\\+-", "-"); + str = str.replaceAll("-\\+", "-"); + //str = str.replaceAll(" ", ""); + return str; + } + + /** + * 妫�鏌ュ叕寮忎腑鎷彿鍑虹幇娆℃暟鏄惁姝g‘ + * + * @param formulaStr 鍏紡鐨勫唴瀹� + * @return true 琛ㄧず鏍¢獙鎴愬姛 + */ + private boolean checkFormula(String formulaStr) { + formulaBlag = true; + int count = 0; + for (int i = 0; i < formulaStr.length(); i++) { + String s = String.valueOf(formulaStr.charAt(i)); + if ("(".equals(s)) { + count++; + } else if (")".equals(s)) { + count--; + } + if (count < 0) { + formulaBlag = false; + break; + } + } + formulaBlag = count == 0; + return formulaBlag; + } + + /** + * 鍒嗗壊鍑芥暟 + * + * @param str 瀛楃涓� + * @param bs 鍒嗗壊绗� + * @return 杞崲鍚庣殑鍐呭 + */ + private String[] spliteFun(String str, String bs) { + List<String> list = new ArrayList<String>(); + String bds = ""; + int bracket = 0; + int len = str.length(); + for (int i = 0; i < len; i++) { + String s = String.valueOf(str.charAt(i)); + if ("(".equals(s)) { + bracket++; + } else if (")".equals(s)) { + bracket--; + } + + if (bracket == 0 && bs.equals(s)) { + list.add(bds); + bds = ""; + continue; + } + + bds += s; + } + + list.add(bds); + + String[] ss = new String[list.size()]; + for (int i = 0; i < list.size(); i++) { + ss[i] = list.get(i); + } + + return ss; + } + + /** + * 鐢ㄦ埛鑷畾涔夊嚱鏁� + * + * @param str 瀛楃涓� + * @param funStr 鍑芥暟鐨勫唴瀹� + * @return + */ + private String customFun(String str, String funStr) { + String reval = "false"; + String[] gss = spliteFun(str, ","); + //姣忎竴涓弬鏁帮紝鎴戦兘搴旇鍘荤湅鐪嬫槸鍚﹁繕鏈�()銆傝繖璇存槑閲岄潰鏄柟娉� + for (int i = 0; i < gss.length; i++) { + String record = gss[i]; + if(StringUtils.isNotBlank(record) && record.contains("(") && record.contains(")")){ + gss[i] = calculate(gss[i]); + } + } + if ("if".equals(funStr)) { + //logger.debug("绗竴涓弬鏁帮細" + gss[0]); + if (compare(gss[0])) { + reval = calculate(gss[1]); + } else { + reval = calculate(gss[2]); + } + } else if ("sum".equals(funStr)) { + BigDecimal ln = new BigDecimal(gss[0]); + BigDecimal rn = new BigDecimal(gss[1]); + reval = ln.add(rn).doubleValue() + ""; + } else if ("sub".equals(funStr)) { + BigDecimal ln = new BigDecimal(gss[0]); + BigDecimal rn = new BigDecimal(gss[1]); + reval = ln.subtract(rn).doubleValue() + ""; + } else if ("mul".equals(funStr)) { + BigDecimal ln = new BigDecimal(gss[0]); + BigDecimal rn = new BigDecimal(gss[1]); + reval = ln.multiply(rn).doubleValue() + ""; + } else if ("div".equals(funStr)) { + BigDecimal ln = new BigDecimal(gss[0]); + BigDecimal rn = new BigDecimal(gss[1]); + if (rn.doubleValue() == 0) { + formulaError(); + //reval = "0"; + return reval; + } else { + reval = ln.divide(rn, 10, BigDecimal.ROUND_HALF_UP) + ""; + } + + } else if ("mod".equals(funStr)) { + int rn = Integer.parseInt(gss[1]); + if (rn == 0) { + formulaError(); + + return reval; + } + int ln = Integer.parseInt(gss[0]); + reval = (ln % rn) + ""; + } else if ("toInt".equals(funStr)) { + reval = (int) Math.floor(new Double(calculate(gss[0]))) + ""; + } else if("toDouble".equals(funStr)){ + reval = new Double(calculate(gss[0])) + ""; + }else if("MD5".equals(funStr)){ + reval = Md5.md5(calculate(gss[0])); + }else if ("doubleRound".equals(funStr)) { + try { + BigDecimal b = new BigDecimal(calculate(gss[0])); + reval = b.setScale(Integer.parseInt(gss[1]), + BigDecimal.ROUND_HALF_UP).doubleValue() + + ""; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + + } else if ("zeroIfNull".equals(funStr)) { + logger.debug(gss[0]); + if ("null".equals(gss[0]) || gss[0].trim().length() == 0) { + reval = "0"; + return reval; + } + reval = gss[0]; + } else if ("endsWith".equals(funStr)) { + reval = "false"; + if (gss[0].endsWith(gss[1])) { + reval = "true"; + } + + } else if ("startsWith".equals(funStr)) { + reval = "false"; + if (gss[0].startsWith(gss[1])) { + reval = "true"; + } + } else if ("charAt".equals(funStr)) { + try { + reval = String.valueOf(gss[0].charAt(Integer.parseInt(gss[1]))); + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + reval = ""; + } + + } else if ("equalsignoreCase".equals(funStr)) { + if (gss[0].equalsIgnoreCase(gss[1])) { + reval = "true"; + } + } else if ("indexOf".equals(funStr)) { + reval = gss[0].indexOf(gss[1]) + ""; + } else if ("isEmpty".equals(funStr)) { + if (gss[0].trim().length() == 0 || "".equals(gss[0]) + || "null".equals(gss[0])) { + reval = "true"; + } + } else if ("lastIndexOf".equals(funStr)) { + reval = gss[0].lastIndexOf(gss[1]) + ""; + } else if ("leftStr".equals(funStr)) { + reval = gss[0].substring(0, Integer.parseInt(gss[1])); + } else if ("length".equals(funStr)) { + reval = gss[0].length() + ""; + } else if ("right".equals(funStr)) { + reval = String.valueOf(gss[0].charAt(gss[0].length() + - Integer.parseInt(gss[1]))); + + } else if ("rightStr".equals(funStr)) { + reval = gss[0] + .substring(gss[0].length() - Integer.parseInt(gss[1])); + } else if ("mid".equals(funStr)) { + try { + reval = gss[0].substring(Integer.parseInt(gss[1]), + Integer.parseInt(gss[2])); + }catch (Exception e) { + e.printStackTrace(); + formulaError(); + reval = ""; + } + + } else if ("tolowercase".equals(funStr)) { + reval = gss[0].toLowerCase(); + } else if ("touppercase".equals(funStr)) { + reval = gss[0].toUpperCase(); + } else if ("trimZero".equals(funStr)) { + int len = gss[0].length() - 1; + for (int i = len; i >= 0; i--) { + if (gss[0].charAt(i) == '0') { + gss[0] = gss[0].substring(0, gss[0].length() - 1); + } else { + reval = gss[0]; + break; + } + } + } else if ("compareDate".equals(funStr)) { + if (gss[0].indexOf("date") != -1) { + gss[0] = calculate(gss[0]); + } + if (gss[1].indexOf("date") != -1) { + gss[1] = calculate(gss[1]); + } + gss[0] = gss[0].replaceAll("`", "-"); + gss[1] = gss[1].replaceAll("`", "-"); + String result; + try { + result = VciDateUtil.compareDate(gss[0], gss[1]); + if ("=".equals(result)) { + reval = "true"; + } + ; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + + } else if ("nowDate".equals(funStr)) { + reval = VciDateUtil.getNowString("yyyy-MM-dd"); + } else if ("chinaDate".equals(funStr)) { + try { + if (gss[0].indexOf("date") != -1) { + gss[0] = calculate(gss[0]); + } + gss[0] = gss[0].replaceAll("`", "-"); + reval = VciDateUtil.getChinaDate(gss[0]); + return reval; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + } else if ("dateAdd".equals(funStr)) { + try { + if (gss[0].indexOf("date") != -1) { + gss[0] = calculate(gss[0]); + } + gss[0] = gss[0].replaceAll("`", "-"); + DateConverter dateConverter = new DateConverter(); + dateConverter.setAsText(gss[0]); + Date date = VciDateUtil.getDateAddDay(dateConverter.getValue(), + Integer.parseInt(gss[1])); + reval = VciDateUtil.date2Str(date, VciDateUtil.DateTimeFormat); + return reval; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + } else if("dateBalanceYear".equals(funStr)) { + //姹傛椂闂寸殑宸 + //3涓弬鏁帮紝瀵规瘮鐨勬簮鍊硷紝瀵规瘮鐨勭洰鏍囧��,鏄惁杩涗竴 + String sourceDate = gss[0]; + String targetDate = gss[1]; + boolean remainderType = "true".equalsIgnoreCase(gss[2]) ? true : false; + DateConverter dateConverter = new DateConverter(); + dateConverter.setAsText(sourceDate); + Date sDate = dateConverter.getValue(); + Date tDate = new Date(); + if (StringUtils.isBlank(targetDate)) { + dateConverter.setAsText(targetDate); + tDate = dateConverter.getValue(); + } + + Period p = Period.between(LocalDate.parse(VciDateUtil.date2Str(sDate, VciDateUtil.DateTimeMillFormat), DateTimeFormatter.ofPattern(VciDateUtil.DateTimeMillFormat)), + LocalDate.parse(VciDateUtil.date2Str(tDate, VciDateUtil.DateTimeMillFormat), DateTimeFormatter.ofPattern(VciDateUtil.DateTimeMillFormat))); + reval = String.valueOf((remainderType && (p.getMonths() > 0 || p.getDays() > 0)) ? (p.getYears() + 1) : p.getYears()); + //鏈堜唤鐩稿樊鏄病鍔炴硶璁$畻 + }else if("dateBalanceDay".equals(funStr)){ + String sourceDate = gss[0]; + String targetDate = gss[1]; + DateConverter dateConverter = new DateConverter(); + dateConverter.setAsText(sourceDate); + Date sDate = dateConverter.getValue(); + Date tDate = new Date(); + if (StringUtils.isNotBlank(targetDate)) { + dateConverter.setAsText(targetDate); + tDate = dateConverter.getValue(); + } + reval = String.valueOf(TimeUnit.DAYS.convert(Math.abs(sDate.getTime()-tDate.getTime()),TimeUnit.MILLISECONDS)); + }else if ("dateformat".equals(funStr)) { + if (gss[0].indexOf("date") != -1) { + gss[0] = calculate(gss[0]); + } + gss[0] = gss[0].replaceAll("`", "-"); + gss[1] = gss[1].replaceAll("`", "-"); + Date date; + try { + if("''".equalsIgnoreCase(gss[0])) { + gss[0] = VciDateUtil.getNowString(); + } + DateConverter dateConverter =new DateConverter(); + dateConverter.setAsText(gss[0]); + date = dateConverter.getValue(); + reval = VciDateUtil.date2Str(date, gss[1].replace("&"," ")); + return reval; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + + } else if ("nowDatetime".equals(funStr)) { + reval = VciDateUtil.getNowString(); + } else if ("dayOf".equals(funStr)) { + if (gss[0].indexOf("date") != -1) { + gss[0] = calculate(gss[0]); + } + gss[0] = gss[0].replaceAll("`", "-"); + try { + Date date = VciDateUtil.str2Date(gss[0], "yyyy-MM-dd"); + reval = date.getDate() + ""; + return reval; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + } else if ("nowNon".equals(funStr)) { + try { + reval = VciDateUtil.getNowString("MM"); + return reval; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + } else if ("monOf".equals(funStr)) { + if (gss[0].indexOf("date") != -1) { + gss[0] = calculate(gss[0]); + } + gss[0] = gss[0].replaceAll("`", "-"); + try { + Date date = VciDateUtil.str2Date(gss[0], "yyyy-MM-dd"); + reval = date.getMonth() + ""; + return reval; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + } else if ("nowTime".equals(funStr)) { + reval = VciDateUtil.getNowString("HH:mm:ss"); + return reval; + } else if ("nowYear".equals(funStr)) { + reval = VciDateUtil.getNowString("yyyy"); + return reval; + } else if ("yearOf".equals(funStr)) { + if (gss[0].indexOf("date") != -1) { + gss[0] = calculate(gss[0]); + } + gss[0] = gss[0].replaceAll("`", "-"); + try { + Date date = VciDateUtil.str2Date(gss[0], "yyyy-MM-dd"); + reval = date.getYear() + 1900 + ""; + return reval; + } catch (Exception e) { + e.printStackTrace(); + formulaError(); + } + } else if ("getChineseCurrency".equals(funStr)) { + gss[0] = calculate(gss[0]); + reval = toChineseCurrency(gss[0]); + } else if ("setThmark".equals(funStr)) { + String numstr = ""; + + String[] number = gss[0].split("\\."); + //logger.debug(number[0]); + for (int i = number[0].length() - 1; i >= 0; i--) { + if (i % 3 == 2 && i < number[0].length() - 1) { + numstr += ","; + } + numstr += number[0].charAt(i); + } + reval = ""; + for (int i = numstr.toCharArray().length - 1; i >= 0; i--) { + reval += numstr.toCharArray()[i]; + } + if (gss[0].indexOf(".") != -1) { + reval += "." + number[1]; + } + + } else if ("toChinese".equals(funStr)) { + gss[0] = calculate(gss[0]); + //logger.debug(gss[0]); + reval = toChinese(gss[0]); + } else if ("getcolvalue".equals(funStr)) { + if (gss[0].trim().length() == 0 || gss[1].trim().length() == 0 + || gss[2].trim().length() == 0 + || gss[3].trim().length() == 0 + || gss[4].trim().length() == 0) { + formulaError(); + return reval; + } + reval = getColValue(gss[0], gss[1], gss[2], gss[3], gss[4]); + }else if("getValueByMethod".equalsIgnoreCase(funStr)){ + if (gss[0].trim().length() == 0 || gss[1].trim().length() == 0 + || gss[2].trim().length() == 0) { + formulaError(); + return reval; + } + reval = getValueByMethod(gss[0], gss[1], gss[2]); + } + + return reval; + } + + // 閫昏緫琛ㄨ揪寮忓垽鏂� + private boolean compare(String str) { + if ("true".equals(calculate(str))) { + return true; + } else if ("false".equals(calculate(str))) { + return false; + } + boolean flag = false; + boolean bs = false; + int len = str.length(); + int bracket = 0; + String ljbds = ""; + double d_left = 0; + double d_right = 0; + for (int i = 0; i < len; i++) { + String s = String.valueOf(str.charAt(i)); + if ("(".equals(s)) { + bracket++; + } else if (")".equals(s)) { + bracket--; + } + + if (bracket == 0 && lj.contains(s)) { + for (int j = i; j < len; j++) { + String ts = String.valueOf(str.charAt(j)); + if (lj.contains(ts)) { + ljbds += ts; + } else { + bs = true; + break; + } + } + } + if (bs) { + break; + } + } + //logger.debug("閫昏緫琛ㄨ揪寮忥細" + ljbds); + String[] s = str.split(ljbds); + //logger.debug("宸﹁竟锛�" + (s[0])); + //logger.debug("鍙宠竟锛�" + (s[1])); + if (isNumber(calculate(s[0])) && isNumber(calculate(s[1]))) { + d_left = new Double(calculate(s[0])); + d_right = new Double(calculate(s[1])); + } else { + formulaError(); + return false; + } + + if ("<".equals(ljbds)) { + if (d_left < d_right) { + return true; + } + } else if (">".equals(ljbds)) { + if (d_left > d_right) { + return true; + } + } else if ("=".equals(ljbds)) { + if (d_left == d_right) { + return true; + } + } else if (">=".equals(ljbds)) { + if (d_left >= d_right) { + return true; + } + } else if ("<=".equals(ljbds)) { + if (d_left <= d_right) { + return true; + } + } else if ("<>".equals(ljbds) || "!=".equals(ljbds)) { + if (d_left != d_right) { + return true; + } + } else { + formulaError(); + } + return flag; + } + + /** + * 浣跨敤鍏紡璁$畻缁撴灉 + * @param dataMap 鏈満鏅彉閲忕殑鍊� + * @param calculateString 鍏紡鐨勫唴瀹� + * @return 鎵ц鍚庣殑鍊� + */ + public String getValueByFormula(Map<String,String> dataMap,String calculateString){ + final String[] finalRule = new String[]{calculateString}; + if(!CollectionUtils.isEmpty(dataMap)){ + dataMap.forEach((key,value)->{ + if(value == null){ + value = ""; + } + finalRule[0] = finalRule[0].replace("${" + key + "}",value); + }); + } + return calculate(finalRule[0]); + } + + /** + * 閫掑綊璋冪敤杩愮畻锛屾敞鎰忓彉閲忛渶瑕佽嚜琛屾浛鎹� + * + * @param str + * @return + */ + public String calculate(String str) { + str = this.strCast(str); + if (!formulaBlag) { + //logger.debug("鍏紡涓嶆纭�"); + return str; + } + boolean onlyFunction = str.length()>2 && str.startsWith("->"); + if(onlyFunction){ + str = str.substring(2); + } + //闇�瑕佹浛鎹㈢郴缁熷彉閲� + Map<String, String> systemVarValueMap = VciSystemVarConstants.getSystemVarValueMap(); + if(!CollectionUtils.isEmpty(systemVarValueMap)){ + final String[] finalStr = new String[]{str}; + systemVarValueMap.forEach((key,value)->{ + if(value == null){ + value = ""; + } + finalStr[0] = finalStr[0].replace( key,value); + }); + str = finalStr[0]; + } + String reval = ""; + String bds = ""; + int bracket = 0;// 瀵瑰簲鎷彿涓暟 + int pos = 0; + boolean title = false; + // 濡傛灉浠ヨ礋鏁板紑澶达紝鍏堝幓鎺夎礋鍙� + if (str.substring(0, 1).equals("-")) { + str = str.substring(1); + title = true; + } + + int len = str.length(); + for (int i = 0; i < len; i++) { + String s = String.valueOf(str.charAt(i)); + pos = i; + bracket = 0; + if (!lc.contains(s)) {// 濡傛灉娌¢亣鍒拌繍绠楃 + if ("(".equals(s)) {// 濡傛灉閬囧埌宸︽嫭鍙� + if (funMap.containsKey(bds)) {// 濡傛灉宸︽嫭鍙峰墠鏄嚱鏁� + for (int j = i + 1; j < len; j++) {// 浠庡乏鎷彿鍚庡紑濮嬪惊鐜� + pos++;// 绱绉诲姩瀛楃浣嶆暟 + String ts = String.valueOf(str.charAt(j));// 鍗曚釜瀛楃 + // reval+=ts; + if ("(".equals(ts))// 濡傛灉鏄乏鎷彿绱 + { + bracket++; + } else if (")".equals(ts)) {// 濡傛灉鏄彸鎷彿杩涜鍑忓皯 + bracket--; + if (bracket == -1) {// 濡傛灉鏄�-1,鏍囪瘑鎷彿缁撴潫 + reval = reval.substring(0, reval.length() + - bds.length());// 閲嶆柊鑾峰緱鍘绘帀鍑芥暟澶寸殑琛ㄨ揪寮� + reval += this.funCalculate( + str.substring(i + 1, j), bds);// 琛ㄨ揪寮忓姞涓婂嚱鏁扮粨鏋�,褰㈡垚鏂拌〃杈惧紡 + i = pos;// 璁℃暟鍣ㄥ鍔� + bds = "";// 鍑芥暟澶存竻绌� + break;// 閫�鍑烘湰娆″惊鐜� + } + } + } + } else if ("".equals(bds) || lc.contains(bds)) {// 濡傛灉鏄櫘閫氳繍绠� + //logger.debug("鏅�氳繍绠�"); + for (int j = i + 1; j < len; j++) { + pos++; + String ts = String.valueOf(str.charAt(j)); + if ("(".equals(ts)) { + bracket++; + } else if (")".equals(ts)) { + bracket--; + if (bracket == -1) { + logger.debug("褰撳墠璁$畻鐨勫瓧绗︿覆涓猴細" + + str.substring(i + 1, pos)); + reval += calculate(str + .substring(i + 1, pos)); + i = pos; + bds = ""; + break; + } + } + } + } else { + logger.debug("娌℃湁姝ゅ嚱鏁�"); + formulaError(); + } + } else {// 绱姞鎬昏〃杈惧紡鍜屾渶鍚庝竴涓繍绠楁暟(鎴栧嚱鏁�) + bds += s; + reval += s; + } + } else {// 閬囧埌杩愮畻绗︽渶鍚庝竴涓繍绠楁暟(鎴栧嚱鏁�)娓呯┖ + bds = ""; + reval += s; + } + } + // 濡傛灉涓鸿礋鏁� 鍦ㄥ墠闈㈠姞璐熷彿 + if (title) { + reval = "0-" + reval; + } + if(onlyFunction){ + + return reval; + } + String result = basicOperation(reval); + logger.debug("璁$畻缁撴灉" + result); + return result; + } + + /** + * 鍑芥暟杩愮畻 + * + * @param gs + * @param funStr + * @return + */ + private String funCalculate(String gs, String funStr) { + String rval = "0"; + logger.debug("鍑芥暟鍚嶏細" + funStr); + if (funMap.containsKey(funStr)) { + int[] csi = funMap.get(funStr); + try { + if (csi[0] == 0) {// java鍐呴儴鍑芥暟,閫氳繃鍙嶅皠璋冪敤 + Class[] cs = new Class[csi[1]]; + Object[] objs = new Object[csi[1]]; + String[] gss = splitParameter(gs); + for (int i = 0; i < csi[1]; i++) { + cs[i] = double.class; + objs[i] = new Double(calculate(gss[i])); + } + Class cls = Class.forName("java.lang.Math"); + Method m = cls.getMethod(funStr, cs); + logger.debug("鏂规硶鍚嶏細" + m); + rval = String.valueOf(m.invoke(cls, objs)); + } else if (csi[0] == 1) {// 鑷畾涔夊嚱鏁� + rval = customFun(gs, funStr); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + return rval; + } + + // 鍏紡閲岀殑鍙傛暟鍒嗗壊 + public static String[] splitParameter(String str) { + int len = str.length(); + boolean flag = true; + String tstr = ""; + + for (int i = 0; i < len; i++) { + String s = String.valueOf(str.charAt(i)); + if ("(".equals(s)) { + flag = false; + } else if (")".equals(s)) { + flag = true; + } + if (flag && ",".equals(s)) { + tstr += "@"; + } else { + tstr += s; + } + } + return tstr.split("@"); + + } + + /** + * 鍥涘垯杩愮畻琛ㄨ揪寮忓鐞� + * + * @param gs + * @return + */ + private String basicOperation(String gs) { + gs = gs + "+0"; // 鍥犱负涓嬮潰鐨勮绠楁槸閬囧埌绗﹀彿鎵嶈繘琛�,鎵�浠ュ鍔犲叆涓�涓绠楃鍙�,涓嶅奖鍝嶅��. + if(gs.indexOf("-")>-1){//鍖呭惈鏈�-鍙锋垨鑰呮槸璐熸暟 + if(gs.startsWith("-")) { + gs = "0" + gs; + } +// if(gs.indexOf("-")>0&&lc.contains(gs.substring(gs.indexOf("-")-1,gs.indexOf("-")))){//绱ф尐鐫�鏃佽竟灏辨槸杩愮畻绗�,鎬庝箞鍔炲晩 +// //gs = gs.substring(0,gs.indexOf("-")-1) + "(0" + gs.substring(gs.indexOf("-")) +// } + } + String c1 = "";// 绗竴涓繍绠楃鍙� + String c2 = "";// 绗簩涓繍绠楃鍙� + String s1 = "";// 绗竴涓繍绠楁暟 + String s2 = "";// 绗簩涓繍绠楁暟 + String s3 = "";// 绗笁涓繍绠楁暟 + + int len = gs.length(); + for (int i = 0; i < len; i++) { + String s = String.valueOf(gs.charAt(i));// 鑾峰緱璇ヤ綅缃瓧绗﹀苟杞崲鎴愬瓧绗︿覆鍋氭瘮杈� + if (lc.contains(s)) { // 濡傛灉鏄繍绠楃鍙� + if (c1.length() == 0)// 濡傛灉绗竴涓繍绠楃鍙蜂负绌�,鍔犲叆 + { + c1 = s; + } else if (c2.length() == 0) {// 鍚﹀垯,濡傛灉绗簩涓繍绠楃鍙蜂负绌�,鍔犲叆 + c2 = s;// 绗簩涓繍绠楃鍙� + if ("+".equals(c2) || "-".equals(c2)) {// 濡傛灉绗簩涓繍绠楃鍙风骇鍒綆,閭d箞杩涜璁$畻 + if(s2.trim().length()>0){ + s1 = this.operation(s1, c1, s2);// 绗竴涓拰绗簩涓暟璁$畻 + c1 = c2;// 淇濆瓨绗簩涓繍绠楃,鍏朵粬涓虹┖ + c2 = ""; + s2 = ""; + }else{//s2杩樻病鍑虹幇 + s2=this.calculate(gs.substring(i)); + s1 = this.operation(s1, c1, s2); + break; + } + } + } else {// 涓婅堪閮戒繚瀛樿繃 + if ("+".equals(s) || "-".equals(s)) {// 濡傛灉绗笁涓繍绠楃绾у埆浣�,杩涜杩愮畻 + s2 = this.operation(s2, c2, s3);// 鍏堢畻绗簩涓変釜鏁�,淇濆瓨鑷崇浜屼釜 + s1 = this.operation(s1, c1, s2);// 鍐嶇畻绗竴浜屼釜,淇濆瓨鑷崇涓�涓� + c1 = s;// 淇濆瓨褰撳墠杩愮畻绗�,鍏朵粬涓虹┖ + s2 = ""; + c2 = ""; + s3 = ""; + } else {// 濡傛灉绗笁涓繍绠楃绾у埆楂� + s2 = this.operation(s2, c2, s3);// 鍏堢畻绗簩涓変釜鏁�,淇濆瓨鑷崇浜屼釜 + c2 = s;// 鍓嶉潰涓嶅姩,淇濆瓨杩愮畻绗� + s3 = ""; + } + } + } else if (s1.length() > 0 && c1.length() > 0 && c2.length() == 0) {// 濡傛灉绗竴涓暟,绗竴涓繍绠楃宸蹭繚瀛�,绗簩涓繍绠楃鏈繚瀛�,淇濆瓨绗簩鍝ユ暟 + s2 += s; + } else if (c1.length() == 0) {// 濡傛灉娌℃湁杩愮畻绗�,淇濆瓨绗竴涓暟 + s1 += s; + } else if (s1.length() > 0 && s2.length() > 0 && c1.length() > 0 + && c2.length() > 0) {// 濡傛灉绗竴浜屼釜鏁板拰杩愮畻绗﹂兘鏈�,淇濆瓨绗笁涓暟 + s3 += s; + } + } + return s1; + } + + /** + * 鍩烘湰鍥涘垯杩愮畻 + * + * @param c1 + * 杩愮畻鏁�1 + * @param s1 + * 杩愮畻绗�(鍔犲噺涔橀櫎) + * @param c2 + * 杩愮畻鏁�2 + * @return + */ + private String operation(String c1, String s1, String c2) { + String reval = "0"; + String c22 = ""; + try { + for (int i = 0; i < c2.length(); i++) { + String s = String.valueOf(c2.charAt(i)); + if (lj.contains(s)) { + break; + } + c22 += s; + } + if (isNumber(c1) && isNumber(c22)) { + BigDecimal ln = new BigDecimal(c1.trim()); + BigDecimal rn = new BigDecimal(c2.trim()); + if ("+".equals(s1)) { + return ln.add(rn).doubleValue() + ""; + } else if ("-".equals(s1)) { + return ln.subtract(rn).doubleValue() + ""; + } else if ("*".equals(s1)) { + return ln.multiply(rn).doubleValue() + ""; + } else if ("/".equals(s1)) { + if (rn.doubleValue() == 0) { + return reval; + } + else { + return ln.divide(rn, 10, BigDecimal.ROUND_HALF_UP) + ""; + } + } + } else { + this.formulaError(); + return c1+s1+c2; + } + + } catch (Exception e) { + this.formulaError(); + e.printStackTrace(); + } finally { + } + + return reval; + } + + private Boolean isNumber(String str) { + return StringUtils.isNotBlank(str) && str.matches("(-)?([1-9]+[0-9]*|0)(\\.[\\d]+)?"); + } + + private String formulaError() { + formulaBlag = false; + //logger.debug("鍏紡楠岃瘉澶辫触锛岃閲嶆柊杈撳叆"); + return "fail"; + } + + public String toChineseCurrency(String value) { + String doubleValue = this.calculate("doubleround(" + value + ",2)"); + String fushu = ""; + if (doubleValue.indexOf("-") == 0) { + fushu = "璐�"; + doubleValue = doubleValue.substring(1); +// formulaError(); +// return ""; + } + char[] hunit = { '鎷�', '浣�', '浠�' }; // 娈靛唴浣嶇疆琛ㄧず + char[] vunit = { '涓�', '浜�' }; // 娈靛悕琛ㄧず + char[] digit = { '闆�', '澹�', '璐�', '鍙�', '鑲�', '浼�', '闄�', '鏌�', '鎹�', '鐜�' }; // 鏁板瓧琛ㄧず + //double midVal = (Double.parseDouble(doubleValue) * 100); // 杞寲鎴愭暣褰� + //String valStr = String.valueOf(midVal); // 杞寲鎴愬瓧绗︿覆 + //String head = valStr.substring(0, valStr.length() - 2); // 鍙栨暣鏁伴儴鍒� + //String rail = valStr.substring(valStr.length() - 2); // 鍙栧皬鏁伴儴鍒� + String head = ""; + String rail = "00"; + if(doubleValue.indexOf(".")>-1){ + head = doubleValue.substring(0,doubleValue.indexOf(".")); + rail = doubleValue.substring(doubleValue.indexOf(".")+1); + if(rail.trim().length() == 1) { + rail += "0";//蹇呴』瑕佷繚璇佹湁鍒� + } + } + else { + head = doubleValue; + } + String prefix = ""; // 鏁存暟閮ㄥ垎杞寲鐨勭粨鏋� + String suffix = ""; // 灏忔暟閮ㄥ垎杞寲鐨勭粨鏋� + // 澶勭悊灏忔暟鐐瑰悗闈㈢殑鏁� + if (rail.equals("00")) { // 濡傛灉灏忔暟閮ㄥ垎涓�0 + suffix = "鏁�"; + } else { + suffix = digit[rail.charAt(0) - '0'] + "瑙�" + + digit[rail.charAt(1) - '0'] + "鍒�"; // 鍚﹀垯鎶婅鍒嗚浆鍖栧嚭鏉� + } + // 澶勭悊灏忔暟鐐瑰墠闈㈢殑鏁� + char[] chDig = head.toCharArray(); // 鎶婃暣鏁伴儴鍒嗚浆鍖栨垚瀛楃鏁扮粍 + char zero = '0'; // 鏍囧織'0'琛ㄧず鍑虹幇杩�0 + byte zeroSerNum = 0; // 杩炵画鍑虹幇0鐨勬鏁� + for (int i = 0; i < chDig.length; i++) { // 寰幆澶勭悊姣忎釜鏁板瓧 + int idx = (chDig.length - i - 1) % 4; // 鍙栨鍐呬綅缃� + int vidx = (chDig.length - i - 1) / 4; // 鍙栨浣嶇疆 + if (chDig[i] == '0') { // 濡傛灉褰撳墠瀛楃鏄�0 + zeroSerNum++; // 杩炵画0娆℃暟閫掑 + if (zero == '0') { // 鏍囧織 + zero = digit[0]; + } else if (idx == 0 && vidx > 0 && zeroSerNum < 4) { + prefix += vunit[vidx - 1]; + zero = '0'; + } + continue; + } + zeroSerNum = 0; // 杩炵画0娆℃暟娓呴浂 + if (zero != '0') { // 濡傛灉鏍囧織涓嶄负0,鍒欏姞涓�,渚嬪涓�,浜夸粈涔堢殑 + prefix += zero; + zero = '0'; + } + prefix += digit[chDig[i] - '0']; // 杞寲璇ユ暟瀛楄〃绀� + if (idx > 0) { + prefix += hunit[idx - 1]; + } + if (idx == 0 && vidx > 0) { + prefix += vunit[vidx - 1]; // 娈电粨鏉熶綅缃簲璇ュ姞涓婃鍚嶅涓�,浜� + } + } + + if (prefix.length() > 0) { + prefix += '鍦�'; // 濡傛灉鏁存暟閮ㄥ垎瀛樺湪,鍒欐湁鍦嗙殑瀛楁牱 + } + return fushu + prefix + suffix; // 杩斿洖姝g‘琛ㄧず + } + + private String toChinese(String value) { + if (!isNumber(value)) { + this.formulaError(); + return ""; + } + String fu = ""; + // 濡傛灉鏄礋鏁板墠闈㈠姞璐� + if (value.indexOf("-") == 0) { + value = value.substring(1); + fu += "璐�"; + } + char[] hunit = { '鎷�', '浣�', '浠�' }; // 娈靛唴浣嶇疆琛ㄧず + char[] vunit = { '涓�', '浜�' }; // 娈靛悕琛ㄧず + char[] digit = { '闆�', '涓�', '浜�', '涓�', '鍥�', '浜�', '鍏�', '涓�', '鍏�', '涔�' }; // 鏁板瓧琛ㄧず + String head = ""; + String rail = ""; + String prefix = ""; // 鏁存暟閮ㄥ垎杞寲鐨勭粨鏋� + String suffix = ""; // 灏忔暟閮ㄥ垎杞寲鐨勭粨鏋� + if (value.indexOf(".") != -1 && value.indexOf(".") < value.length() - 1) { + String[] number = value.split("\\."); + head = number[0]; // 鍙栨暣鏁伴儴鍒� + rail = number[1]; + suffix += "鐐�"; + } else { + head = value; + } + // 澶勭悊灏忔暟鐐瑰悗闈㈢殑鏁� + for (int i = 0; i < rail.length(); i++) { + suffix += digit[rail.charAt(i) - '0']; + } + + // 澶勭悊灏忔暟鐐瑰墠闈㈢殑鏁� + char[] chDig = head.toCharArray(); // 鎶婃暣鏁伴儴鍒嗚浆鍖栨垚瀛楃鏁扮粍 + char zero = '0'; // 鏍囧織'0'琛ㄧず鍑虹幇杩�0 + byte zeroSerNum = 0; // 杩炵画鍑虹幇0鐨勬鏁� + for (int i = 0; i < chDig.length; i++) { // 寰幆澶勭悊姣忎釜鏁板瓧 + int idx = (chDig.length - i - 1) % 4; // 鍙栨鍐呬綅缃� + int vidx = (chDig.length - i - 1) / 4; // 鍙栨浣嶇疆 + if (chDig[i] == '0') { // 濡傛灉褰撳墠瀛楃鏄�0 + zeroSerNum++; // 杩炵画0娆℃暟閫掑 + if (zero == '0') { // 鏍囧織 + zero = digit[0]; + } else if (idx == 0 && vidx > 0 && zeroSerNum < 4) { + prefix += vunit[vidx - 1]; + zero = '0'; + } + continue; + } + zeroSerNum = 0; // 杩炵画0娆℃暟娓呴浂 + if (zero != '0') { // 濡傛灉鏍囧織涓嶄负0,鍒欏姞涓�,渚嬪涓�,浜夸粈涔堢殑 + prefix += zero; + zero = '0'; + } + prefix += digit[chDig[i] - '0']; // 杞寲璇ユ暟瀛楄〃绀� + if (idx > 0) { + prefix += hunit[idx - 1]; + } + if (idx == 0 && vidx > 0) { + prefix += vunit[vidx - 1]; // 娈电粨鏉熶綅缃簲璇ュ姞涓婃鍚嶅涓�,浜� + } + } + return fu + prefix + suffix; // 杩斿洖姝g‘琛ㄧず + } + + private String getColValue(String servername, String tableName, + String fieldname, String pkfield, String pkvalue) { + //鏆傛椂涓嶆敮鎸乻erver鐨勬柟寮� + String sql = "select " + fieldname.trim() + " from " + tableName.trim() + " where " + pkfield + " = '" + pkvalue+"'"; +// Map<String,String> param = new HashMap<String, String>(); +// param.put(pkfield, pkvalue); + String str = ""; + try{ + List data = commonsMapper.selectById(sql); + if(data != null || data.size() > 0) { + str = (String) ((HashMap) data.get(0)).get(fieldname.trim()); + } + }catch(Exception e){ + + } + return str; + + } + + private String getValueByMethod(String serviceName,String methods,String paramsString){ + //鏆傛椂涓嶆敮鎸侀�氳繃鏂规硶鏉ヨ幏鍙栧�� + return paramsString; + } + + public static void main(String[] args) { + + } + +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java index d99f7e4..d5dbbc5 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java @@ -3,32 +3,28 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.common.utils.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.sun.corba.se.impl.orbutil.ObjectUtility; import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; import com.vci.ubcs.code.dto.CodeOrderDTO; import com.vci.ubcs.code.dto.datapush.BaseModelDTO; import com.vci.ubcs.code.entity.CodeAllCode; import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; -import com.vci.ubcs.code.entity.CodeRule; import com.vci.ubcs.code.entity.CodeWupinEntity; import com.vci.ubcs.code.enumpack.CodeDefaultLC; import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; import com.vci.ubcs.code.enumpack.CodeSecTypeEnum; import com.vci.ubcs.code.mapper.CodeAllCodeMapper; import com.vci.ubcs.code.mapper.CodeOsbtmtypeMapper; -import com.vci.ubcs.code.mapper.CodeRuleMapper; +import com.vci.ubcs.code.mapper.CommonsMapper; import com.vci.ubcs.code.service.*; +import com.vci.ubcs.code.vo.CodeClstempattrVO; import com.vci.ubcs.code.vo.CodeClstemplateVO; import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO; import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; -import com.vci.ubcs.omd.entity.Dict; import com.vci.ubcs.starter.exception.VciBaseException; -import com.vci.ubcs.starter.revision.model.BaseModel; import com.vci.ubcs.starter.web.enumpck.UserSecretEnum; import com.vci.ubcs.starter.web.pagemodel.KeyValue; import com.vci.ubcs.starter.web.toolmodel.DateConverter; @@ -40,7 +36,6 @@ import com.vci.ubcs.system.feign.IDictBizClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springframework.beans.BeanUtils; @@ -50,7 +45,6 @@ import javax.annotation.Resource; import java.util.*; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; /** @@ -61,6 +55,7 @@ */ @Service public class MdmEngineServiceImpl extends ServiceImpl<CodeAllCodeMapper, CodeAllCode> implements MdmEngineService { + /** * 妯℃澘鐨勬湇鍔� @@ -96,6 +91,17 @@ private ICodeClassifyService classifyService; /** + * 鍏紡鐨勬湇鍔� + */ + @Autowired + private FormulaServiceImpl formulaService; + + /** + * 閫氱敤鏌ヨ + */ + @Resource + CommonsMapper commonsMapper; + /** * 鍏抽敭灞炴�х殑閰嶇疆 */ @Autowired @@ -105,8 +111,10 @@ */ private Logger logger = LoggerFactory.getLogger(getClass()); - // @Autowired - // private CodeOsbtmtypeMapper codeOsbtmtypeMapper; +// @Autowired +// private CodeOsbtmtypeMapper codeOsbtmtypeMapper; + + /** * 浣跨敤鍒嗙被鐨勪富閿幏鍙栧彲浠ヤ娇鐢ㄧ殑妯℃澘瀵硅薄 @@ -184,14 +192,14 @@ List<CodeAllCode> codeCbos = baseMapper.selectList(allCodeWrapper); // List<ClientBusinessObject> codeCbos = boService.queryCBO(MdmBtmTypeConstant.CODE_ALL_CODE, conditionMap); // 鍥炴敹闇�瑕佷笟鍔℃暟鎹垹闄� -// if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) { -//// BatchCBO batchCBO = new BatchCBO(); -//// batchCBO.getDeleteCbos().addAll(cboList); -// codeOsbtmtypeMapper.deleteBatchIds(cboList); -//// boService.persistenceBatch(batchCBO); -// } else { + if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) { +// BatchCBO batchCBO = new BatchCBO(); +// batchCBO.getDeleteCbos().addAll(cboList); + codeOsbtmtypeMapper.deleteBatchIds(cboList); +// boService.persistenceBatch(batchCBO); + } else { // lifeCycleService.transCboStatus(cboList, baseModelDTO.getLcStatus()); -// } + } // lifeCycleService.transCboStatus(codeCbos, baseModelDTO.getLcStatus()); } @@ -227,23 +235,30 @@ switchDateAttrOnOrder(templateVO, orderDTO); //9.鐢熸垚缂栫爜鐨勪俊鎭� // ClientBusinessObject cbo = boService.createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()); -// CodeWupinEntity cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()); + CodeWupinEntity cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()); // //榛樿鐨勫睘鎬ч兘涓嶇敤浠庡墠绔嫹璐� // //璁剧疆缂栫爜闇�瑕佺殑榛樿灞炴�х殑鍐呭 -// copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, false); + copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, false); // //TODO:鍥犱负榛樿鐨勫睘鎬ч兘涓嶆嫹璐濓紝鐩墠闆嗗洟鐮佸彨name锛屽苟娌℃湁浠嶥TO鎷疯礉鍒癱bo閲屻�傚鍔犱竴涓崟鐙鐞嗭紝浠ュ悗鍐嶇湅瑕佷笉瑕佽皟鏁� -// cbo.setName(orderDTO.getName() == null ? "" : orderDTO.getName()); + cbo.setName(orderDTO.getName() == null ? "" : orderDTO.getName()); // //end -- modify by lihang @20220407 -// List<CodeWupinEntity> cboList = new ArrayList<>(); -// -// //澶囨敞 -// cbo.setDescription(orderDTO.getDescription()); + List<CodeWupinEntity> cboList = new ArrayList<>(); + + //澶囨敞 + cbo.setDescription(orderDTO.getDescription()); + cboList.add(cbo); // // cboList.add(cbo); -// List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(),cboList); -//// batchSaveSelectChar(templateVO, cboList); -// return codeList.size() > 0 ? codeList.get(0) : ""; - return null; + List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(),cboList); + + + List<String> charList = new ArrayList<>(); + for (CodeWupinEntity wupinEntity : cboList) { + charList.add(wupinEntity.getId()); + } + batchSaveSelectChar(templateVO, charList); + return codeList.size() > 0 ? codeList.get(0) : ""; +// return null; } /** @@ -378,7 +393,7 @@ } dataLowMap.putAll(orderDTO.getData()); compAttrVOMap.forEach((attrId, attrVO) -> { -// dataLowMap.put(attrId, formulaService.getValueByFormula(dataLowMap, attrVO.getComponentrule())); + dataLowMap.put(attrId, formulaService.getValueByFormula(dataLowMap, attrVO.getComponentRule())); }); dataLowMap.forEach((key, value) -> { setValueToOrderDTO(orderDTO, key, value); @@ -446,29 +461,30 @@ if (value == null) { value = ""; } -// wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); + wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); }); //娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙� -// if (!CollectionUtils.isEmpty(conditionMap)) { -// final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "}; -// conditionMap.forEach((key, value) -> { -// sql[0] += " and " + key + " = " + value; -// }); -// if (StringUtils.isNotBlank(orderDTO.getOid())) { -// //淇敼鐨勬椂鍊欙紝闇�瑕佹帓闄よ嚜宸� -// sql[0] += " and oid != '" + orderDTO.getOid() + "'"; -// } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) { -// sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'"; -// } -// sql[0] += " and islastR = '1' and islastV = '1' "; + if (!CollectionUtils.isEmpty(conditionMap)) { + final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "}; + conditionMap.forEach((key, value) -> { + sql[0] += " and " + key + " = " + value; + }); + if (StringUtils.isNotBlank(orderDTO.getOid())) { + //淇敼鐨勬椂鍊欙紝闇�瑕佹帓闄よ嚜宸� + sql[0] += " and oid != '" + orderDTO.getOid() + "'"; + } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) { + sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'"; + } + sql[0] += " and islastR = '1' and islastV = '1' "; // if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) { -// String ruleInfoMsg = keyRuleVO == null ? "" : "鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}"; -// String[] objs = new String[]{trim ? "鏄�" : "鍚�", ignoreCase ? "鏄�" : "鍚�", ignoreWidth ? "鏄�" : "鍚�", trimAll ? "鏄�" : "鍚�"}; -// throw new VciBaseException("鏍规嵁鎮ㄥ~鍐欑殑鍏抽敭灞炴�х殑鍐呭锛岀粨鍚堝叧閿睘鎬ф煡璇㈣鍒欙紝鍙戠幇杩欎釜鏁版嵁宸茬粡鍦ㄧ郴缁熶腑瀛樺湪浜嗐�傝淇!銆�" + ruleInfoMsg, objs); -// } -// } + if (Integer.parseInt(commonsMapper.selectById(sql[0]).get(0)) > 0) { + String ruleInfoMsg = keyRuleVO == null ? "" : "鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}"; + String[] objs = new String[]{trim ? "鏄�" : "鍚�", ignoreCase ? "鏄�" : "鍚�", ignoreWidth ? "鏄�" : "鍚�", trimAll ? "鏄�" : "鍚�"}; + throw new VciBaseException("鏍规嵁鎮ㄥ~鍐欑殑鍏抽敭灞炴�х殑鍐呭锛岀粨鍚堝叧閿睘鎬ф煡璇㈣鍒欙紝鍙戠幇杩欎釜鏁版嵁宸茬粡鍦ㄧ郴缁熶腑瀛樺湪浜嗐�傝淇!銆�" + ruleInfoMsg, objs); + } + } } /** @@ -483,54 +499,54 @@ * @param trimAll 鏄惁蹇界暐鍏ㄩ儴绌烘牸 * @param conditionMap 鏌ヨ鏉′欢 */ -// @Override -// public void wrapperKeyAttrConditionMap(String value, CodeKeyattrrepeatVO keyRuleVO, String attrId, -// boolean trim, boolean ignoreCase, boolean ignoreWidth, -// boolean trimAll, Map<String, String> conditionMap) { -// boolean ignoreSpace = trim || trimAll; -// if (StringUtils.isBlank(value)) { -// //涓虹┖鐨勬椂鍊欙紝涓嶈兘鐢≦ueryOperation.ISNULL锛屽钩鍙颁笉鐭ラ亾鍟ユ椂鍊欎笉澶勭悊杩欑浜� -// conditionMap.put("t."+attrId, "null"); -// } else { -// if (keyRuleVO != null) { -// String queryKey = ""; -// String queryValue = ""; -// -// String temp = ""; -// if (ignoreCase && ignoreSpace && ignoreWidth) { -// //蹇界暐澶у皬鍐欙紝涓斿幓绌猴紝蹇界暐鍏ㄥ崐瑙� -// temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(to_single_byte(%s)) " + (trimAll ? ",' ','')" : ")"); -// } else if (ignoreCase && ignoreSpace && !ignoreWidth) { -// //蹇界暐澶у皬鍐欍�佸幓绌恒�佷笉蹇界暐鍏ㄥ崐瑙� -// temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(%s) " + (trimAll ? ",' ','')" : ")"); -// } else if (ignoreCase && !ignoreSpace && ignoreWidth) { -// //蹇界暐澶у皬鍐欍�佷笉鍘荤┖銆佸拷鐣ュ叏鍗婅 -// temp = "UPPER(to_single_byte(%s))"; -// } else if (!ignoreCase && ignoreSpace && ignoreWidth) { -// //涓嶅拷鐣ュぇ灏忓啓銆佸幓绌恒�佸拷鐣ュ叏鍗婅 -// temp = (trimAll ? "REPLACE" : "TRIM") + "(to_single_byte(%s) " + (trimAll ? ",' ','')" : ")"); -// } else if (ignoreCase && !ignoreSpace && !ignoreWidth) { -// //蹇界暐澶у皬鍐欍�佷笉鍘荤┖銆佷笉蹇界暐鍏ㄥ崐瑙� -// temp = "UPPER(%s)"; -// } else if (!ignoreCase && !ignoreCase && ignoreWidth) { -// //涓嶅拷鐣ュぇ灏忓啓銆佷笉鍘荤┖銆佸拷鐣ュ叏鍗婅 -// temp = "to_single_byte(%s)"; -// } else if (!ignoreCase && ignoreSpace && !ignoreWidth) { -// //涓嶅拷鐣ュぇ灏忓啓銆佸幓绌恒�佷笉蹇界暐鍏ㄥ崐瑙� -// temp = (trimAll ? "REPLACE" : "TRIM") + "(%s " + (trimAll ? ",' ','')" : ")"); -// } else if (!ignoreCase && !ignoreSpace && !ignoreWidth) { -// //涓嶅拷鐣ュぇ灏忓啓銆佷笉鍘荤┖銆佷笉蹇界暐鍏ㄥ崐瑙� -// temp = "%s"; -// } -// queryKey = String.format(temp, "t."+attrId); -// queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'"); -// conditionMap.put(queryKey, queryValue); -// } else { -// //涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅 -// conditionMap.put("t."+attrId, value); -// } -// } -// } + @Override + public void wrapperKeyAttrConditionMap(String value, CodeKeyattrrepeatVO keyRuleVO, String attrId, + boolean trim, boolean ignoreCase, boolean ignoreWidth, + boolean trimAll, Map<String, String> conditionMap) { + boolean ignoreSpace = trim || trimAll; + if (StringUtils.isBlank(value)) { + //涓虹┖鐨勬椂鍊欙紝涓嶈兘鐢≦ueryOperation.ISNULL锛屽钩鍙颁笉鐭ラ亾鍟ユ椂鍊欎笉澶勭悊杩欑浜� + conditionMap.put("t."+attrId, "null"); + } else { + if (keyRuleVO != null) { + String queryKey = ""; + String queryValue = ""; + + String temp = ""; + if (ignoreCase && ignoreSpace && ignoreWidth) { + //蹇界暐澶у皬鍐欙紝涓斿幓绌猴紝蹇界暐鍏ㄥ崐瑙� + temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(to_single_byte(%s)) " + (trimAll ? ",' ','')" : ")"); + } else if (ignoreCase && ignoreSpace && !ignoreWidth) { + //蹇界暐澶у皬鍐欍�佸幓绌恒�佷笉蹇界暐鍏ㄥ崐瑙� + temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(%s) " + (trimAll ? ",' ','')" : ")"); + } else if (ignoreCase && !ignoreSpace && ignoreWidth) { + //蹇界暐澶у皬鍐欍�佷笉鍘荤┖銆佸拷鐣ュ叏鍗婅 + temp = "UPPER(to_single_byte(%s))"; + } else if (!ignoreCase && ignoreSpace && ignoreWidth) { + //涓嶅拷鐣ュぇ灏忓啓銆佸幓绌恒�佸拷鐣ュ叏鍗婅 + temp = (trimAll ? "REPLACE" : "TRIM") + "(to_single_byte(%s) " + (trimAll ? ",' ','')" : ")"); + } else if (ignoreCase && !ignoreSpace && !ignoreWidth) { + //蹇界暐澶у皬鍐欍�佷笉鍘荤┖銆佷笉蹇界暐鍏ㄥ崐瑙� + temp = "UPPER(%s)"; + } else if (!ignoreCase && !ignoreCase && ignoreWidth) { + //涓嶅拷鐣ュぇ灏忓啓銆佷笉鍘荤┖銆佸拷鐣ュ叏鍗婅 + temp = "to_single_byte(%s)"; + } else if (!ignoreCase && ignoreSpace && !ignoreWidth) { + //涓嶅拷鐣ュぇ灏忓啓銆佸幓绌恒�佷笉蹇界暐鍏ㄥ崐瑙� + temp = (trimAll ? "REPLACE" : "TRIM") + "(%s " + (trimAll ? ",' ','')" : ")"); + } else if (!ignoreCase && !ignoreSpace && !ignoreWidth) { + //涓嶅拷鐣ュぇ灏忓啓銆佷笉鍘荤┖銆佷笉蹇界暐鍏ㄥ崐瑙� + temp = "%s"; + } + queryKey = String.format(temp, "t."+attrId); + queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'"); + conditionMap.put(queryKey, queryValue); + } else { + //涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅 + conditionMap.put("t."+attrId, value); + } + } + } /** * 鏍¢獙鏋氫妇鐨勫唴瀹� @@ -657,77 +673,77 @@ * @return CodeWupinEntity * @throws VciBaseException 鍒濆鍖栧嚭閿欑殑鏄細鎶涘嚭寮傚父 */ -// @Override -// public CodeWupinEntity createCBOByBtmName(String btmName) -// throws VciBaseException { -// if(btmName!=null){ -// btmName = btmName.trim().toLowerCase(); + @Override + public CodeWupinEntity createCBOByBtmName(String btmName) + throws VciBaseException { + if(btmName!=null){ + btmName = btmName.trim().toLowerCase(); + } + String userid = AuthUtil.getUser().getUserName(); +// if(!hasCreatedCbos.containsKey(btmName)){ +// if(StringUtils.isEmpty(userid)){ +// throw new VciBaseException(msgCodePrefix +"noHasUserid"); +// } +// try { +// hasCreatedCbos.put(btmName, createBusinessObject(btmName)); +// } catch (Exception e) { +// logger.error("鍒涘缓涓氬姟绫诲瀷瀵硅薄",e); +// throw new VciBaseException(msgCodePrefix + "initBoError",new String[]{btmName}); +// } // } -// String userid = AuthUtil.getUser().getUserName(); -//// if(!hasCreatedCbos.containsKey(btmName)){ -//// if(StringUtils.isEmpty(userid)){ -//// throw new VciBaseException(msgCodePrefix +"noHasUserid"); -//// } -//// try { -//// hasCreatedCbos.put(btmName, createBusinessObject(btmName)); -//// } catch (Exception e) { -//// logger.error("鍒涘缓涓氬姟绫诲瀷瀵硅薄",e); -//// throw new VciBaseException(msgCodePrefix + "initBoError",new String[]{btmName}); -//// } -//// } -//// ClientBusinessObject cbo = cloneClientBusinessObject(hasCreatedCbos.get(btmName)); -// -// QueryWrapper<CodeOsbtmtypeEntity> btmWrapper = new QueryWrapper<>(); -// btmWrapper.eq("ID",btmName); -// CodeOsbtmtypeEntity btmTypeVO = codeOsbtmtypeMapper.selectOne(btmWrapper); -//// OsBtmTypeVO btmTypeVO = btmService.getBtmById(boName); -// String userName = AuthUtil.getUser().getUserName(); -// CodeWupinEntity wupinEntity = new CodeWupinEntity(); -// wupinEntity.setOid(null); -//// bo.setRevisionid((new ObjectUtility()).getNewObjectID36()); -//// bo.setNameoid((new ObjectUtility()).getNewObjectID36()); -// wupinEntity.setBtmname(btmName); -// wupinEntity.setLastR(String.valueOf(1)); -// wupinEntity.setFirstR(String.valueOf(1)); -// wupinEntity.setFirstV(String.valueOf(1)); -// wupinEntity.setLastV(String.valueOf(1)); -// wupinEntity.setCreator(userName); -// wupinEntity.setCreateTime(new Date()); -// wupinEntity.setLastModifier(userName); -// wupinEntity.setLastModifyTime(new Date()); -// wupinEntity.setRevisionRule(btmTypeVO.getRevisionruleid()); -// wupinEntity.setVersionRule(String.valueOf(btmTypeVO.getVersionRule())); -// if(StringUtils.isNotBlank(btmTypeVO.getRevisionruleid())){ -// //鎻掍釜鐐癸紝闇�瑕侀棶鍕囧摜鐗堟湰闂锛屽睍绀洪粯璁や负1 -//// OsRevisionRuleVO revisionRuleVO = revisionRuleService.getRevisionRuleById(btmTypeVO.getRevisionruleid()); -// wupinEntity.setRevisionValue("1"); -// } -// -// wupinEntity.setRevisionSeq(1); -// wupinEntity.setVersionSeq(1); -// //鎻掍釜鐐癸紝闇�瑕侀棶鍕囧摜鐗堟湰闂锛屽睍绀洪粯璁や负1 -// wupinEntity.setVersionValue("1"); -// wupinEntity.setLctid("wupinLC"); -// wupinEntity.setLcStatus("Editing"); -// wupinEntity.setId(""); -// wupinEntity.setName(""); -// wupinEntity.setDescription(""); -// wupinEntity.setOwner(userName); -// wupinEntity.setCheckinby(userName); -// wupinEntity.setCopyFromVersion(""); -// wupinEntity.setMaterialtype((short) 1001); -// wupinEntity.setCaigouwl("true"); -// wupinEntity.setShifoupihaoguanli("true"); -// wupinEntity.setKucunwl("true"); -// wupinEntity.setXiaoshouwl("false"); -// wupinEntity.setPassing("true"); -// -//// this.initTypeAttributeValue(wupinEntity,btmTypeVO); -// return wupinEntity; -// -// -//// return cbo; -// } +// ClientBusinessObject cbo = cloneClientBusinessObject(hasCreatedCbos.get(btmName)); + + QueryWrapper<CodeOsbtmtypeEntity> btmWrapper = new QueryWrapper<>(); + btmWrapper.eq("ID",btmName); + CodeOsbtmtypeEntity btmTypeVO = codeOsbtmtypeMapper.selectOne(btmWrapper); +// OsBtmTypeVO btmTypeVO = btmService.getBtmById(boName); + String userName = AuthUtil.getUser().getUserName(); + CodeWupinEntity wupinEntity = new CodeWupinEntity(); + wupinEntity.setOid(null); +// bo.setRevisionid((new ObjectUtility()).getNewObjectID36()); +// bo.setNameoid((new ObjectUtility()).getNewObjectID36()); + wupinEntity.setBtmname(btmName); + wupinEntity.setLastR(String.valueOf(1)); + wupinEntity.setFirstR(String.valueOf(1)); + wupinEntity.setFirstV(String.valueOf(1)); + wupinEntity.setLastV(String.valueOf(1)); + wupinEntity.setCreator(userName); + wupinEntity.setCreateTime(new Date()); + wupinEntity.setLastModifier(userName); + wupinEntity.setLastModifyTime(new Date()); + wupinEntity.setRevisionRule(btmTypeVO.getRevisionruleid()); + wupinEntity.setVersionRule(String.valueOf(btmTypeVO.getVersionRule())); + if(StringUtils.isNotBlank(btmTypeVO.getRevisionruleid())){ + //鎻掍釜鐐癸紝闇�瑕侀棶鍕囧摜鐗堟湰闂锛屽睍绀洪粯璁や负1 +// OsRevisionRuleVO revisionRuleVO = revisionRuleService.getRevisionRuleById(btmTypeVO.getRevisionruleid()); + wupinEntity.setRevisionValue("1"); + } + + wupinEntity.setRevisionSeq(1); + wupinEntity.setVersionSeq(1); + //鎻掍釜鐐癸紝闇�瑕侀棶鍕囧摜鐗堟湰闂锛屽睍绀洪粯璁や负1 + wupinEntity.setVersionValue("1"); + wupinEntity.setLctid("wupinLC"); + wupinEntity.setLcStatus("Editing"); + wupinEntity.setId(""); + wupinEntity.setName(""); + wupinEntity.setDescription(""); + wupinEntity.setOwner(userName); + wupinEntity.setCheckinby(userName); + wupinEntity.setCopyFromVersion(""); + wupinEntity.setMaterialtype((short) 1001); + wupinEntity.setCaigouwl("true"); + wupinEntity.setShifoupihaoguanli("true"); + wupinEntity.setKucunwl("true"); + wupinEntity.setXiaoshouwl("false"); + wupinEntity.setPassing("true"); + +// this.initTypeAttributeValue(wupinEntity,btmTypeVO); + return wupinEntity; + + +// return cbo; + } /** * 鏄惁涓轰慨鏀瑰拷鐣ョ殑灞炴�� @@ -750,27 +766,36 @@ * @param templateVO 妯℃澘鐨勫璞� * @param cboList 鏁版嵁鐨勫唴瀹� */ -// @Override -// public void batchSaveSelectChar(CodeClstemplateVO templateVO, List<ClientBusinessObject> cboList) { -// if (templateVO != null && !CollectionUtils.isEmpty(cboList)) { -// //鏄紓姝ョ殑锛屾墍浠ョ洿鎺ュ惊鐜� -// List<CodeClassifyTemplateAttrVO> selectAttrVOs = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getLibraryidentification())).collect(Collectors.toList()); -// -// if (!CollectionUtils.isEmpty(selectAttrVOs)) { -//// SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); -// selectAttrVOs.parallelStream().forEach(attrVO -> { -// List<String> valuesList = new CopyOnWriteArrayList<>(); + @Override + public void batchSaveSelectChar(CodeClstemplateVO templateVO, /*List<ClientBusinessObject> cboList*/ + List<String> cboList) { + if (templateVO != null && !CollectionUtils.isEmpty(cboList)) { + //鏄紓姝ョ殑锛屾墍浠ョ洿鎺ュ惊鐜� + List<CodeClassifyTemplateAttrVO> selectAttrVOs = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getLibraryIdentification())).collect(Collectors.toList()); + + if (!CollectionUtils.isEmpty(selectAttrVOs)) { +// SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); + selectAttrVOs.parallelStream().forEach(attrVO -> { + List<String> valuesList = cboList; // cboList.parallelStream().forEach(cbo -> { -// String value = cbo.getAttributeValue(attrVO.getId()); +// String value = cbo.get.getAttributeValue(attrVO.getId()); // if (StringUtils.isNotBlank(value)) { // valuesList.add(value); // } // }); -// if (!CollectionUtils.isEmpty(valuesList)) { + if (!CollectionUtils.isEmpty(valuesList)) { + for (String s : valuesList) { + DictBiz dictBiz = new DictBiz(); + dictBiz.setCode(templateVO.getBtmTypeId()); + dictBiz.setDictKey(s); + dictBiz.setDictValue(s); + //浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜� + iDictBizClient.getCheck(dictBiz); + } // charService.saveBySameNamespaceAndFlag(templateVO.getBtmTypeId(), attrVO.getLibraryIdentification(), valuesList, sessionInfo); -// } -// }); -// } -// } -// } + } + }); + } + } + } } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java index 6e6559a..47d5777 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java @@ -35,6 +35,7 @@ import java.util.stream.Collectors; import static com.vci.ubcs.code.constant.MdmEngineConstant.*; + @Service public class MdmProductCodeServiceImpl implements MdmProductCodeService { @@ -303,7 +304,6 @@ Map<String, String> statusMap = allCodeDOList.stream().collect(Collectors.toMap(s -> s.getOid(), s -> s.getLcStatus())); allCodeDOList.stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmname())).forEach(s -> { s.setLcStatus(statusMap.get(s.getOid())); - }); codeAllCodeService.saveBatch(allCodeDOList); iCodeWupinService.saveBatch(dataCBOList); diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java index 43e0fb2..deec5ff 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/wrapper/CodeButtonWrapper.java @@ -16,6 +16,7 @@ */ package com.vci.ubcs.code.wrapper; +import com.vci.ubcs.omd.cache.EnumCache; import com.vci.ubcs.system.cache.DictCache; import com.vci.ubcs.code.entity.CodeButton; import com.vci.ubcs.code.vo.pagemodel.CodeButtonVO; @@ -43,8 +44,8 @@ @Override public CodeButtonVO entityVO(CodeButton codebutton) { CodeButtonVO codebuttonVO = Objects.requireNonNull(BeanUtil.copy(codebutton, CodeButtonVO.class)); - codebuttonVO.setUsedpositiontypeText(DictCache.getValue("codeButtonPosition", codebutton.getUsedPositionType())); - codebuttonVO.setLcStatusText(DictCache.getValue("codeLcstatus", codebutton.getLcStatus())); + codebuttonVO.setUsedpositiontypeText(EnumCache.getValue("codeButtonPosition", codebutton.getUsedPositionType())); + codebuttonVO.setLcStatusText(EnumCache.getValue("codeLcstatus", codebutton.getLcStatus())); return codebuttonVO; } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeButtonMapper.xml b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeButtonMapper.xml index 94cafa2..bdcb7b1 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeButtonMapper.xml +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeButtonMapper.xml @@ -5,34 +5,34 @@ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> <resultMap id="codebuttonResultMap" type="com.vci.ubcs.code.entity.CodeButton"> <result column="OID" property="oid"/> - <result column="REVISIONOID" property="revisionoid"/> - <result column="NAMEOID" property="nameoid"/> + <result column="REVISIONOID" property="revisionOid"/> + <result column="NAMEOID" property="nameOid"/> <result column="BTMNAME" property="btmname"/> - <result column="LASTR" property="lastr"/> - <result column="FIRSTR" property="firstr"/> - <result column="LASTV" property="lastv"/> - <result column="FIRSTV" property="firstv"/> + <result column="LASTR" property="lastR"/> + <result column="FIRSTR" property="firstR"/> + <result column="LASTV" property="lastV"/> + <result column="FIRSTV" property="firstV"/> <result column="CREATOR" property="creator"/> - <result column="CREATETIME" property="createtime"/> - <result column="LASTMODIFIER" property="lastmodifier"/> - <result column="LASTMODIFYTIME" property="lastmodifytime"/> - <result column="REVISIONRULE" property="revisionrule"/> - <result column="VERSIONRULE" property="versionrule"/> - <result column="REVISIONSEQ" property="revisionseq"/> - <result column="REVISIONVALUE" property="revisionvalue"/> - <result column="VERSIONSEQ" property="versionseq"/> - <result column="VERSIONVALUE" property="versionvalue"/> + <result column="CREATETIME" property="createTime"/> + <result column="LASTMODIFIER" property="lastModifier"/> + <result column="LASTMODIFYTIME" property="lastModifyTime"/> + <result column="REVISIONRULE" property="revisionRule"/> + <result column="VERSIONRULE" property="versionRule"/> + <result column="REVISIONSEQ" property="revisionSeq"/> + <result column="REVISIONVALUE" property="revisionValue"/> + <result column="VERSIONSEQ" property="versionSeq"/> + <result column="VERSIONVALUE" property="versionValue"/> <result column="LCTID" property="lctid"/> - <result column="LCSTATUS" property="lcstatus"/> + <result column="LCSTATUS" property="lcStatus"/> <result column="TS" property="ts"/> <result column="ID" property="id"/> <result column="NAME" property="name"/> <result column="DESCRIPTION" property="description"/> <result column="OWNER" property="owner"/> - <result column="COPYFROMVERSION" property="copyfromversion"/> - <result column="ICONCLS" property="iconcls"/> - <result column="EXECUTEJS" property="executejs"/> - <result column="USEDPOSITIONTYPE" property="usedpositiontype"/> + <result column="COPYFROMVERSION" property="copyFromVersion"/> + <result column="ICONCLS" property="iconCls"/> + <result column="EXECUTEJS" property="executeJs"/> + <result column="USEDPOSITIONTYPE" property="usedPositionType"/> </resultMap> diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeClstemplateMapper.xml b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeClstemplateMapper.xml index f3c03fa..7730a6a 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeClstemplateMapper.xml +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeClstemplateMapper.xml @@ -37,7 +37,7 @@ <select id="selectPlCodeClstemplatePage" resultMap="plCodeClstemplateResultMap"> - select * from PL_CODE_CLSTEMPLATE where is_deleted = 0 order by revisionSeq + select * from PL_CODE_CLSTEMPLATE where 0 = 0 order by revisionSeq </select> <select id="selectAllLevelChildOid" resultType="java.lang.String" > diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/DictController.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/DictController.java deleted file mode 100644 index 7b65fa2..0000000 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/DictController.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 搴勯獮 (smallchill@163.com) - */ -package com.vci.ubcs.omd.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.vci.ubcs.common.constant.CommonConstant; -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.service.IDictService; -import com.vci.ubcs.omd.vo.DictVO; -import com.vci.ubcs.omd.wrapper.DictWrapper; -import io.swagger.annotations.*; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.cache.utils.CacheUtil; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tenant.annotation.NonDS; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.StringPool; -import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; - -/** - * 鎺у埗鍣� - * - * @author Chill - */ -@NonDS -@RestController -@AllArgsConstructor -@RequestMapping("/dict") -@Api(value = "鏋氫妇瀹氫箟", tags = "鏋氫妇瀹氫箟") -public class DictController extends BladeController { - - private final IDictService dictService; - - /** - * 璇︽儏 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "璇︽儏", notes = "浼犲叆dict") - public R<DictVO> detail(Dict dict) { - Dict detail = dictService.getOne(Condition.getQueryWrapper(dict)); - return R.data(DictWrapper.build().entityVO(detail)); - } - - /** - * 鍒楄〃 - */ - @GetMapping("/list") - @ApiImplicitParams({ - @ApiImplicitParam(name = "code", value = "鏋氫妇缂栧彿", paramType = "query", dataType = "string"), - @ApiImplicitParam(name = "dictValue", value = "鏋氫妇鍚嶇О", paramType = "query", dataType = "string") - }) - @ApiOperationSupport(order = 2) - @ApiOperation(value = "鍒楄〃", notes = "浼犲叆dict") - public R<List<DictVO>> list(@ApiIgnore @RequestParam Map<String, Object> dict) { - List<Dict> list = dictService.list(Condition.getQueryWrapper(dict, Dict.class).lambda().orderByAsc(Dict::getSort)); - return R.data(DictWrapper.build().listNodeVO(list)); - } - - /** - * 椤剁骇鍒楄〃 - */ - @GetMapping("/parent-list") - @ApiImplicitParams({ - @ApiImplicitParam(name = "code", value = "鏋氫妇缂栧彿", paramType = "query", dataType = "string"), - @ApiImplicitParam(name = "dictValue", value = "鏋氫妇鍚嶇О", paramType = "query", dataType = "string") - }) - @ApiOperationSupport(order = 3) - @ApiOperation(value = "鍒楄〃", notes = "浼犲叆dict") - public R<IPage<DictVO>> parentList(@ApiIgnore @RequestParam Map<String, Object> dict, Query query) { - return R.data(dictService.parentList(dict, query)); - } - - /** - * 瀛愬垪琛� - */ - @GetMapping("/child-list") - @ApiImplicitParams({ - @ApiImplicitParam(name = "code", value = "瀛楀吀缂栧彿", paramType = "query", dataType = "string"), - @ApiImplicitParam(name = "dictValue", value = "瀛楀吀鍚嶇О", paramType = "query", dataType = "string"), - @ApiImplicitParam(name = "parentId", value = "瀛楀吀鍚嶇О", paramType = "query", dataType = "string") - }) - @ApiOperationSupport(order = 4) - @ApiOperation(value = "鍒楄〃", notes = "浼犲叆dict") - public R<List<DictVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) { - return R.data(dictService.childList(dict, parentId)); - } - - /** - * 鑾峰彇瀛楀吀鏍戝舰缁撴瀯 - */ - @GetMapping("/tree") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "鏍戝舰缁撴瀯", notes = "鏍戝舰缁撴瀯") - public R<List<DictVO>> tree() { - List<DictVO> tree = dictService.tree(); - return R.data(tree); - } - - /** - * 鑾峰彇瀛楀吀鏍戝舰缁撴瀯 - */ - @GetMapping("/parent-tree") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "鏍戝舰缁撴瀯", notes = "鏍戝舰缁撴瀯") - public R<List<DictVO>> parentTree() { - List<DictVO> tree = dictService.parentTree(); - return R.data(tree); - } - - /** - * 鏂板鎴栦慨鏀� - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆dict") - public R submit(@Valid @RequestBody Dict dict) { - CacheUtil.clear(DICT_CACHE); - return R.status(dictService.submit(dict)); - } - - - /** - * 鍒犻櫎 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 7) - @ApiOperation(value = "鍒犻櫎", notes = "浼犲叆ids") - public R remove(@ApiParam(value = "涓婚敭闆嗗悎", required = true) @RequestParam String ids) { - CacheUtil.clear(DICT_CACHE); - return R.status(dictService.removeDict(ids)); - } - - /** - * 鑾峰彇瀛楀吀 - */ - @GetMapping("/dictionary") - @ApiOperationSupport(order = 8) - @ApiOperation(value = "鑾峰彇瀛楀吀", notes = "鑾峰彇瀛楀吀") - public R<List<Dict>> dictionary(String code) { - List<Dict> tree = dictService.getList(code); - return R.data(tree); - } - - /** - * 鑾峰彇瀛楀吀鏍� - */ - @GetMapping("/dictionary-tree") - @ApiOperationSupport(order = 9) - @ApiOperation(value = "鑾峰彇瀛楀吀鏍�", notes = "鑾峰彇瀛楀吀鏍�") - public R<List<DictVO>> dictionaryTree(String code) { - List<Dict> tree = dictService.getList(code); - return R.data(DictWrapper.build().listNodeVO(tree)); - } - - /** - * 妫�鏌ュ瓧鍏告槸鍚﹀瓨鍦紝瀛樺湪鍗宠繑鍥烇紝涓嶅瓨鍦ㄦ柊澧� - */ - @PostMapping("/check") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆dict") - public R checkOrInsert(@Valid @RequestBody Dict dict) { - CacheUtil.clear(DICT_CACHE); - return dictService.checkOrInsert(dict); - } - - /** - * 瀛楀吀閿�煎垪琛� - */ - @GetMapping("/select") - @ApiOperationSupport(order = 10) - @ApiOperation(value = "瀛楀吀閿�煎垪琛�", notes = "瀛楀吀閿�煎垪琛�") - public R<List<Dict>> select() { - List<Dict> list = dictService.list(Wrappers.<Dict>query().lambda().eq(Dict::getParentId, CommonConstant.TOP_PARENT_ID)); - list.forEach(dict -> dict.setDictValue(dict.getCode() + StringPool.COLON + StringPool.SPACE + dict.getDictValue())); - return R.data(list); - } - -} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumController.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumController.java new file mode 100644 index 0000000..cba83cd --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumController.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.controller; + +import com.vci.ubcs.omd.wrapper.EnumWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import lombok.AllArgsConstructor; +import javax.validation.Valid; + +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.vo.EnumVO; +import com.vci.ubcs.omd.service.IEnumService; +import org.springblade.core.boot.ctrl.BladeController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; +import java.util.Map; + +/** + * 鏋氫妇瀹氫箟 鎺у埗鍣� + * + * @author yuxc + * @since 2023-05-08 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/enum") +@Api(value = "鏋氫妇瀹氫箟", tags = "鏋氫妇瀹氫箟鎺ュ彛") +public class EnumController extends BladeController { + + private final IEnumService omdEnumService; + + /** + * 鏋氫妇瀹氫箟 璇︽儏 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "璇︽儏", notes = "浼犲叆omdEnum") + public R<EnumVO> detail(Enum omdEnum) { + Enum detail = omdEnumService.getOne(Condition.getQueryWrapper(omdEnum)); + return R.data(EnumWrapper.build().entityVO(detail)); + } + /** + * 鏋氫妇瀹氫箟 鍒嗛〉 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆omdEnum") + public R<IPage<EnumVO>> list(Enum omdEnum, Query query) { + IPage<Enum> pages = omdEnumService.page(Condition.getPage(query), Condition.getQueryWrapper(omdEnum)); + return R.data(EnumWrapper.build().pageVO(pages)); + } + + /** + * 鏋氫妇瀹氫箟 鑷畾涔夊垎椤� + */ + @GetMapping("/page") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆omdEnum") + public R<IPage<EnumVO>> page(EnumVO omdEnum, Query query) { + IPage<EnumVO> pages = omdEnumService.selectOmdEnumPage(Condition.getPage(query), omdEnum); + return R.data(pages); + } + + /** + * 鏋氫妇瀹氫箟 鏂板 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "鏂板", notes = "浼犲叆omdEnum") + public R save(@Valid @RequestBody Enum omdEnum) { + return R.status(omdEnumService.save(omdEnum)); + } + + /** + * 鏋氫妇瀹氫箟 淇敼 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "淇敼", notes = "浼犲叆omdEnum") + public R update(@Valid @RequestBody Enum omdEnum) { + return R.status(omdEnumService.updateById(omdEnum)); + } + + /** + * 鏋氫妇瀹氫箟 鏂板鎴栦慨鏀� + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆omdEnum") + public R submit(@Valid @RequestBody Enum omdEnum) { + return R.status(omdEnumService.saveOrUpdate(omdEnum)); + } + + /** + * 鏋氫妇瀹氫箟 鍒犻櫎 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "閫昏緫鍒犻櫎", notes = "浼犲叆ids") + public R remove(@ApiParam(value = "涓婚敭闆嗗悎", required = true) @RequestParam String ids) { + return R.status(omdEnumService.deleteLogic(Func.toStrList(ids))); + } + + + /** + * 鏋氫妇瀹氫箟 鍒嗛〉 + */ + @GetMapping("/parent-list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆omdEnum") + public R<IPage<EnumVO>> parentList(@ApiIgnore @RequestParam Map<String, Object> dict , Query query) { + return R.data(omdEnumService.parentList(dict, query)); + } + + + /** + * 鑾峰彇瀛楀吀鏍戝舰缁撴瀯 + */ + @GetMapping("/tree") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "鏍戝舰缁撴瀯", notes = "鏍戝舰缁撴瀯") + public R<List<EnumVO>> tree(@ApiIgnore @RequestParam Map<String, Object> dict , Query query) { + List<EnumVO> tree = omdEnumService.tree(dict, query); + return R.data(tree); + } + + /** + * 鑾峰彇鏋氫妇 + */ + @GetMapping("/dictionary") + @ApiOperationSupport(order = 8) + @ApiOperation(value = "鑾峰彇鏋氫妇", notes = "鑾峰彇鏋氫妇") + public R<List<EnumVO>> dictionary(String code) { + List<EnumVO> tree = omdEnumService.getList(code); + return R.data(tree); + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumItemController.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumItemController.java new file mode 100644 index 0000000..ce482c0 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/controller/EnumItemController.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.controller; + +import com.vci.ubcs.omd.wrapper.EnumitemWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import lombok.AllArgsConstructor; +import javax.validation.Valid; + +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumItemVO; +import com.vci.ubcs.omd.service.IEnumItemService; +import org.springblade.core.boot.ctrl.BladeController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 鎺у埗鍣� + * + * @author yuxc + * @since 2023-05-08 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/enumItem") +@Api(value = "鏋氫妇瀹氫箟瀛愯〃", tags = "鏋氫妇瀹氫箟瀛愯〃鎺ュ彛") +public class EnumItemController extends BladeController { + + private final IEnumItemService omdEnumitemService; + + /** + * 鏋氫妇瀹氫箟瀛愯〃 璇︽儏 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "璇︽儏", notes = "浼犲叆omdEnumitem") + public R<EnumItemVO> detail(EnumItem enumitem) { + EnumItem detail = omdEnumitemService.getOne(Condition.getQueryWrapper(enumitem)); + return R.data(EnumitemWrapper.build().entityVO(detail)); + } + /** + * 鏋氫妇瀹氫箟瀛愯〃 鍒嗛〉 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆omdEnumitem") + public R<IPage<EnumItemVO>> list(EnumItem enumitem, Query query) { + IPage<EnumItem> pages = omdEnumitemService.page(Condition.getPage(query), Condition.getQueryWrapper(enumitem).orderByAsc("sort")); + return R.data(EnumitemWrapper.build().pageVO(pages)); + } + + /** + * 鏋氫妇瀹氫箟瀛愯〃 鍒嗛〉 + */ + @GetMapping("/listAll") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆omdEnumitem") + public R<List<EnumItemVO>> listAll(@ApiIgnore @RequestParam Map<String, Object> omdEnumitem, Query query) { + return R.data(omdEnumitemService.childList(Condition.getQueryWrapper(omdEnumitem, EnumItem.class).orderByAsc("sort"))); + } + + /** + * 鏋氫妇瀹氫箟瀛愯〃 鑷畾涔夊垎椤� + */ + @GetMapping("/page") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "鍒嗛〉", notes = "浼犲叆omdEnumitem") + public R<IPage<EnumItemVO>> page(EnumItemVO omdEnumitem, Query query) { + IPage<EnumItemVO> pages = omdEnumitemService.selectOmdEnumitemPage(Condition.getPage(query), omdEnumitem); + return R.data(pages); + } + + /** + * 鏋氫妇瀹氫箟瀛愯〃 鏂板 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "鏂板", notes = "浼犲叆omdEnumitem") + public R save(@Valid @RequestBody EnumItem enumitem) { + return R.status(omdEnumitemService.save(enumitem)); + } + + /** + * 鏋氫妇瀹氫箟瀛愯〃 淇敼 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "淇敼", notes = "浼犲叆omdEnumitem") + public R update(@Valid @RequestBody EnumItem enumitem) { + return R.status(omdEnumitemService.updateById(enumitem)); + } + + /** + * 鏋氫妇瀹氫箟瀛愯〃 鏂板鎴栦慨鏀� + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆omdEnumitem") + public R submit(@Valid @RequestBody EnumItem enumitem) { + + if(enumitem.getOid() == null){ + enumitem.setCreatetime(new Date()); + enumitem.setCreator(AuthUtil.getUser().getUserName()); + } + enumitem.setModifier(AuthUtil.getUser().getUserName()); + enumitem.setModifytime(new Date()); + enumitem.setTs(new Date()); + return R.status(omdEnumitemService.saveOrUpdate(enumitem)); + } + + /** + * 鏋氫妇瀹氫箟瀛愯〃 鍒犻櫎 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "閫昏緫鍒犻櫎", notes = "浼犲叆ids") + public R remove(@ApiParam(value = "涓婚敭闆嗗悎", required = true) @RequestParam String ids) { + return R.status(omdEnumitemService.deleteLogic(Func.toStrList(ids))); + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/DictClient.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/DictClient.java deleted file mode 100644 index 1b0d863..0000000 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/DictClient.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 搴勯獮 (smallchill@163.com) - */ -package com.vci.ubcs.omd.feign; - - -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.service.IDictService; -import lombok.AllArgsConstructor; -import org.springblade.core.tenant.annotation.NonDS; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import springfox.documentation.annotations.ApiIgnore; - -import java.util.List; - - -/** - * 瀛楀吀鏈嶅姟Feign瀹炵幇绫� - * - * @author Chill - */ -@NonDS -@ApiIgnore -@RestController -@AllArgsConstructor -public class DictClient implements IDictClient { - - private final IDictService service; - - @Override - @GetMapping(GET_BY_ID) - public R<Dict> getById(Long id) { - return R.data(service.getById(id)); - } - - @Override - @GetMapping(GET_VALUE) - public R<String> getValue(String code, String dictKey) { - return R.data(service.getValue(code, dictKey)); - } - - @Override - @GetMapping(GET_LIST) - public R<List<Dict>> getList(String code) { - return R.data(service.getList(code)); - } - - @Override - @GetMapping(CHECK_VALUE) - public R getCheck(Dict dict) { - return service.checkOrInsert(dict); - } - -} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumClient.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumClient.java new file mode 100644 index 0000000..5798a75 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumClient.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.feign; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.mapper.EnumMapper; +import com.vci.ubcs.omd.service.IEnumItemService; +import com.vci.ubcs.omd.service.IEnumService; +import com.vci.ubcs.omd.vo.EnumVO; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; + +/** + * 鏋氫妇瀹氫箟 Feign瀹炵幇绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@ApiIgnore() +@RestController +@AllArgsConstructor +public class EnumClient implements IEnumClient { + private final EnumMapper enumMapper; + + private IEnumService iEnumService; + private IEnumItemService iEnumItemService; + @Override + @GetMapping(TOP) + public BladePage<Enum> top(Integer current, Integer size) { + Query query = new Query(); + query.setCurrent(current); + query.setSize(size); + IPage<Enum> page = enumMapper.selectPage(Condition.getPage(query), + Wrappers.emptyWrapper()); +// service.page(Condition.getPage(query)); + return BladePage.of(page); + } + /** + * 鑾峰彇鏋氫妇瀹氫箟鍒楄〃 + * + * @param name 鐖惰妭鐐筺ame + * @param nameChild 瀛愯妭鐐筺ame + * @return BladePage + */ + @Override + public R<String> getValue(String name,String nameChild) { + return R.data(iEnumService.getValue(name, nameChild)); + } + + @Override + public R<Enum> getById(String oid) { + return R.data(iEnumService.getById(oid)); + } + + @Override + public R<EnumItem> getByChildId(String oid) { + return R.data(iEnumItemService.getById(oid)); + } + + @Override + public R<List<EnumVO>> getList(String name) { + return R.data(iEnumService.getList(name)); + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumItemClient.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumItemClient.java new file mode 100644 index 0000000..2519e3d --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/EnumItemClient.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.feign; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.mapper.EnumItemMapper; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 Feign瀹炵幇绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@ApiIgnore() +@RestController +@AllArgsConstructor +public class EnumItemClient implements IEnumItemClient { + + private final EnumItemMapper enumItemMapper; + @Override + @GetMapping(TOP) + public BladePage<EnumItem> top(Integer current, Integer size) { + Query query = new Query(); + query.setCurrent(current); + query.setSize(size); + IPage<EnumItem> page = enumItemMapper.selectPage(Condition.getPage(query), + Wrappers.emptyWrapper()); +// service.page(Condition.getPage(query)); + return BladePage.of(page); + } + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/DictMapper.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumItemMapper.java similarity index 63% copy from Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/DictMapper.java copy to Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumItemMapper.java index 3308e43..afe70d3 100644 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/DictMapper.java +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumItemMapper.java @@ -16,49 +16,27 @@ */ package com.vci.ubcs.omd.mapper; - +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumItemVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.vo.DictVO; - +import com.baomidou.mybatisplus.core.metadata.IPage; import java.util.List; /** - * Mapper 鎺ュ彛 + * 鏋氫妇瀹氫箟瀛愯〃 Mapper 鎺ュ彛 * - * @author Chill + * @author yuxc + * @since 2023-05-08 */ -public interface DictMapper extends BaseMapper<Dict> { +public interface EnumItemMapper extends BaseMapper<EnumItem> { /** - * 鑾峰彇瀛楀吀琛ㄥ搴斾腑鏂� + * 鑷畾涔夊垎椤� * - * @param code 瀛楀吀缂栧彿 - * @param dictKey 瀛楀吀搴忓彿 + * @param page + * @param omdEnumitem * @return */ - String getValue(String code, String dictKey); - - /** - * 鑾峰彇瀛楀吀琛� - * - * @param code 瀛楀吀缂栧彿 - * @return - */ - List<Dict> getList(String code); - - /** - * 鑾峰彇鏍戝舰鑺傜偣 - * - * @return - */ - List<DictVO> tree(); - - /** - * 鑾峰彇鏍戝舰鑺傜偣 - * - * @return - */ - List<DictVO> parentTree(); + List<EnumItemVO> selectOmdEnumitemPage(IPage page, EnumItemVO omdEnumitem); } diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/DictMapper.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumMapper.java similarity index 63% rename from Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/DictMapper.java rename to Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumMapper.java index 3308e43..315e969 100644 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/DictMapper.java +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/mapper/EnumMapper.java @@ -16,49 +16,31 @@ */ package com.vci.ubcs.omd.mapper; - +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.vo.EnumVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.vo.DictVO; - +import com.baomidou.mybatisplus.core.metadata.IPage; import java.util.List; /** - * Mapper 鎺ュ彛 + * 鏋氫妇瀹氫箟 Mapper 鎺ュ彛 * - * @author Chill + * @author yuxc + * @since 2023-05-08 */ -public interface DictMapper extends BaseMapper<Dict> { +public interface EnumMapper extends BaseMapper<Enum> { /** - * 鑾峰彇瀛楀吀琛ㄥ搴斾腑鏂� + * 鑷畾涔夊垎椤� * - * @param code 瀛楀吀缂栧彿 - * @param dictKey 瀛楀吀搴忓彿 + * @param page + * @param omdEnum * @return */ - String getValue(String code, String dictKey); + List<EnumVO> selectOmdEnumPage(IPage page, EnumVO omdEnum); - /** - * 鑾峰彇瀛楀吀琛� - * - * @param code 瀛楀吀缂栧彿 - * @return - */ - List<Dict> getList(String code); - /** - * 鑾峰彇鏍戝舰鑺傜偣 - * - * @return - */ - List<DictVO> tree(); + String getValue(String name, String nameChild); - /** - * 鑾峰彇鏍戝舰鑺傜偣 - * - * @return - */ - List<DictVO> parentTree(); - + List<EnumVO> getList(String name); } diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IDictService.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IDictService.java deleted file mode 100644 index f9ece50..0000000 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IDictService.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 搴勯獮 (smallchill@163.com) - */ -package com.vci.ubcs.omd.service; - - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.vo.DictVO; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; - -import java.util.List; -import java.util.Map; - -/** - * 鏈嶅姟绫� - * - * @author Chill - */ -public interface IDictService extends IService<Dict> { - - /** - * 鏍戝舰缁撴瀯 - * - * @return - */ - List<DictVO> tree(); - - /** - * 鏍戝舰缁撴瀯 - * - * @return - */ - List<DictVO> parentTree(); - - /** - * 鑾峰彇鏋氫妇琛ㄥ搴斾腑鏂� - * - * @param code 鏋氫妇缂栧彿 - * @param dictKey 鏋氫妇搴忓彿 - * @return - */ - String getValue(String code, String dictKey); - - /** - * 鑾峰彇鏋氫妇琛� - * - * @param code 鏋氫妇缂栧彿 - * @return - */ - List<Dict> getList(String code); - - /** - * 鏂板鎴栦慨鏀� - * - * @param dict - * @return - */ - boolean submit(Dict dict); - - /** - * 鍒犻櫎瀛楀吀 - * - * @param ids - * @return - */ - boolean removeDict(String ids); - - /** - * 椤剁骇鍒楄〃 - * - * @param dict - * @param query - * @return - */ - IPage<DictVO> parentList(Map<String, Object> dict, Query query); - - /** - * 瀛愬垪琛� - * - * @param dict - * @param parentId - * @return - */ - List<DictVO> childList(Map<String, Object> dict, Long parentId); - - /** - * 鏂板鎴栦慨鏀� - * - * @param dict - * @return - */ - R checkOrInsert(Dict dict); -} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumItemService.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumItemService.java new file mode 100644 index 0000000..8b9044c --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumItemService.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumItemVO; +import com.baomidou.mybatisplus.core.metadata.IPage; + +import java.util.List; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 鏈嶅姟绫� + * + * @author yuxc + * @since 2023-05-08 + */ +public interface IEnumItemService extends IService<EnumItem> { + + /** + * 鑷畾涔夊垎椤� + * + * @param page + * @param omdEnumitem + * @return + */ + IPage<EnumItemVO> selectOmdEnumitemPage(IPage<EnumItemVO> page, EnumItemVO omdEnumitem); + + + boolean deleteLogic(List<String> toStringList); + + List<EnumItemVO> childList(QueryWrapper<EnumItem> queryWrapper); + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumService.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumService.java new file mode 100644 index 0000000..d9232d4 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IEnumService.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.vo.EnumVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springblade.core.mp.support.Query; + +import java.util.List; +import java.util.Map; + +/** + * 鏋氫妇瀹氫箟 鏈嶅姟绫� + * + * @author yuxc + * @since 2023-05-08 + */ +public interface IEnumService extends IService<Enum> { + + /** + * 鑷畾涔夊垎椤� + * + * @param page + * @param omdEnum + * @return + */ + IPage<EnumVO> selectOmdEnumPage(IPage<EnumVO> page, EnumVO omdEnum); + + + boolean deleteLogic(List<String> toStringList); + + IPage<EnumVO> parentList(Map<String, Object> dict, Query query); + /** + * 鏍戝舰缁撴瀯 + * + * @return + */ + List<EnumVO> tree(Map<String, Object> dict , Query query); + /** + * 鑾峰彇鏋氫妇瀹氫箟鍒楄〃 + * + * @param name 鐖惰妭鐐筺ame + * @param nameChild 瀛愯妭鐐筺ame + * @return BladePage + */ + String getValue(String name, String nameChild); + + List<EnumVO> getList(String name); +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictServiceImpl.java deleted file mode 100644 index 0a412b4..0000000 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/DictServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.vci.ubcs.omd.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springblade.core.log.exception.ServiceException; -import com.vci.ubcs.omd.mapper.DictMapper; -import com.vci.ubcs.omd.service.IDictService; -import com.vci.ubcs.omd.wrapper.DictWrapper; -import com.vci.ubcs.common.constant.CommonConstant; -import org.springblade.core.cache.utils.CacheUtil; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.constant.BladeConstant; -import org.springblade.core.tool.node.ForestNodeMerger; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringPool; -import com.vci.ubcs.omd.cache.DictCache; -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.vo.DictVO; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; - -/** - * 鏈嶅姟瀹炵幇绫� - * - * @author Chill - */ -@Service -public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements IDictService { - - @Override - public List tree() { - return ForestNodeMerger.merge((List)baseMapper.tree()); - } - - @Override - public List<DictVO> parentTree() { - return ForestNodeMerger.merge((List)baseMapper.parentTree()); - } - - @Override - public String getValue(String code, String dictKey) { - return Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY); - } - - @Override - public List<Dict> getList(String code) { - return baseMapper.getList(code); - } - - @Override - public boolean submit(Dict dict) { - LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey()); - Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId())); - if (cnt > 0L) { - throw new ServiceException("褰撳墠鏋氫妇閿�煎凡瀛樺湪!"); - } - // 淇敼椤剁骇瀛楀吀鍚庡悓姝ユ洿鏂颁笅灞炲瓧鍏哥殑缂栧彿 - if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) { - Dict parent = DictCache.getById(dict.getId()); - this.update(Wrappers.<Dict>update().lambda().set(Dict::getCode, dict.getCode()).eq(Dict::getCode, parent.getCode()).ne(Dict::getParentId, BladeConstant.TOP_PARENT_ID)); - } - if (Func.isEmpty(dict.getParentId())) { - dict.setParentId(BladeConstant.TOP_PARENT_ID); - } - dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); - CacheUtil.clear(DICT_CACHE); - return saveOrUpdate(dict); - } - - @Override - public boolean removeDict(String ids) { - Long cnt = baseMapper.selectCount(Wrappers.<Dict>query().lambda().in(Dict::getParentId, Func.toLongList(ids))); - if (cnt > 0L) { - throw new ServiceException("璇峰厛鍒犻櫎瀛愯妭鐐�!"); - } - return removeByIds(Func.toLongList(ids)); - } - - @Override - public IPage<DictVO> parentList(Map<String, Object> dict, Query query) { - IPage<Dict> page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, Dict.class).lambda().eq(Dict::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(Dict::getSort)); - return DictWrapper.build().pageVO(page); - } - - @Override - public List<DictVO> childList(Map<String, Object> dict, Long parentId) { - if (parentId < 0) { - return new ArrayList<>(); - } - dict.remove("parentId"); - Dict parentDict = DictCache.getById(parentId); - List<Dict> list = this.list(Condition.getQueryWrapper(dict, Dict.class).lambda().ne(Dict::getId, parentId).eq(Dict::getCode, parentDict.getCode()).orderByAsc(Dict::getSort)); - return DictWrapper.build().listNodeVO(list); - } - - @Override - public R checkOrInsert(Dict dict) { - - LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey()); - Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId())); - if (cnt > 0L) { - return R.fail("鏋氫妇宸茬粡瀛樺湪锛�"); - } - - if (Func.isEmpty(dict.getParentId())) { - dict.setParentId(BladeConstant.TOP_PARENT_ID); - } - dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); - CacheUtil.clear(DICT_CACHE); - - if(saveOrUpdate(dict) == true){ - return R.success("鎿嶄綔鎴愬姛!"); - } - return R.fail("鎿嶄綔澶辫触锛�"); - - } -} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumItemServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumItemServiceImpl.java new file mode 100644 index 0000000..eb0a7df --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumItemServiceImpl.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumItemVO; +import com.vci.ubcs.omd.mapper.EnumItemMapper; +import com.vci.ubcs.omd.service.IEnumItemService; +import com.vci.ubcs.omd.wrapper.EnumitemWrapper; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.metadata.IPage; + +import java.util.List; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 鏈嶅姟瀹炵幇绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@Service +public class EnumItemServiceImpl extends ServiceImpl<EnumItemMapper, EnumItem> implements IEnumItemService { + + @Override + public IPage<EnumItemVO> selectOmdEnumitemPage(IPage<EnumItemVO> page, EnumItemVO omdEnumitem) { + return page.setRecords(baseMapper.selectOmdEnumitemPage(page, omdEnumitem)); + } + + @Override + public boolean deleteLogic(List<String> toStringList) { + return SqlHelper.retBool(baseMapper.deleteBatchIds(toStringList)); + } + + @Override + public List<EnumItemVO> childList(QueryWrapper<EnumItem> queryWrapper) { + + return EnumitemWrapper.build().listVO(baseMapper.selectList(queryWrapper)); + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumServiceImpl.java new file mode 100644 index 0000000..56c6a1a --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/EnumServiceImpl.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.mapper.EnumItemMapper; +import com.vci.ubcs.omd.vo.EnumVO; +import com.vci.ubcs.omd.mapper.EnumMapper; +import com.vci.ubcs.omd.service.IEnumService; +import com.vci.ubcs.omd.wrapper.EnumWrapper; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringPool; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.metadata.IPage; + +import javax.annotation.Resource; +import java.util.*; + +/** + * 鏋氫妇瀹氫箟 鏈嶅姟瀹炵幇绫� + * + * @author yuxc + * @since 2023-05-08 + */ +@Service +public class EnumServiceImpl extends ServiceImpl<EnumMapper, Enum> implements IEnumService { + + @Resource + EnumItemMapper enumItemMapper; + @Override + public IPage<EnumVO> selectOmdEnumPage(IPage<EnumVO> page, EnumVO omdEnum) { + return page.setRecords(baseMapper.selectOmdEnumPage(page, omdEnum)); + } + + @Override + public boolean deleteLogic(List<String> toStringList) { + return SqlHelper.retBool(baseMapper.deleteBatchIds(toStringList)); + } + + @Override + public IPage<EnumVO> parentList(Map<String, Object> dict, Query query) { + IPage<Enum> page = this.page(Condition.getPage(query), + Condition.getQueryWrapper(dict, Enum.class).lambda() + .orderByDesc(Enum::getCreatetime)); + return EnumWrapper.build().pageVO(page); + } + + @Override + public List<EnumVO> tree(Map<String, Object> dict, Query query) { + List<Enum> pages = this.page(Condition.getPage(query),Condition.getQueryWrapper(dict, Enum.class).lambda() + .orderByDesc(Enum::getCreatetime)).getRecords(); + List<EnumVO> listVo = new ArrayList<>(); + pages.stream().forEach(page->{ + EnumVO enumVO = new EnumVO(); + QueryWrapper<EnumItem> wrapper = new QueryWrapper<>(); + wrapper.eq("parentOid",page.getOid()); + List<EnumItem> enumItems = enumItemMapper.selectList(wrapper); + BeanUtils.copyProperties(page, enumVO); + if(enumItems.size()>0){ + enumVO.setChildren(enumItems); + enumVO.setHasChildren(true); + } + listVo.add(enumVO); + }); + + return listVo; + } + + @Override + public String getValue(String name, String nameChild) { + return Func.toStr(baseMapper.getValue(name, nameChild), StringPool.EMPTY); + } + + @Override + public List<EnumVO> getList(String name) { + return baseMapper.getList(name); + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/DictWrapper.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/DictWrapper.java deleted file mode 100644 index a36faab..0000000 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/DictWrapper.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 搴勯獮 (smallchill@163.com) - */ -package com.vci.ubcs.omd.wrapper; - -import com.vci.ubcs.omd.cache.DictCache; -import com.vci.ubcs.omd.entity.Dict; -import com.vci.ubcs.omd.vo.DictVO; -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.constant.BladeConstant; -import org.springblade.core.tool.node.ForestNodeMerger; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - - -/** - * 鍖呰绫�,杩斿洖瑙嗗浘灞傛墍闇�鐨勫瓧娈� - * - * @author Chill - */ -public class DictWrapper extends BaseEntityWrapper<Dict, DictVO> { - - public static DictWrapper build() { - return new DictWrapper(); - } - - @Override - public DictVO entityVO(Dict dict) { - DictVO dictVO = Objects.requireNonNull(BeanUtil.copy(dict, DictVO.class)); - if (Func.equals(dict.getParentId(), BladeConstant.TOP_PARENT_ID)) { - dictVO.setParentName(BladeConstant.TOP_PARENT_NAME); - } else { - Dict parent = DictCache.getById(dict.getParentId()); - dictVO.setParentName(parent.getDictValue()); - } - return dictVO; - } - - public List<DictVO> listNodeVO(List<Dict> list) { - List<DictVO> collect = list.stream().map(dict -> BeanUtil.copy(dict, DictVO.class)).collect(Collectors.toList()); - return ForestNodeMerger.merge((List)collect); - } - -} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumWrapper.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumWrapper.java new file mode 100644 index 0000000..4869526 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumWrapper.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.wrapper; + +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.utils.BeanUtil; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.vo.EnumVO; +import java.util.Objects; + +/** + * 鏋氫妇瀹氫箟 鍖呰绫�,杩斿洖瑙嗗浘灞傛墍闇�鐨勫瓧娈� + * + * @author yuxc + * @since 2023-05-08 + */ +public class EnumWrapper extends BaseEntityWrapper<Enum, EnumVO> { + + public static EnumWrapper build() { + return new EnumWrapper(); + } + + @Override + public EnumVO entityVO(Enum omdEnum) { + EnumVO enumVO = Objects.requireNonNull(BeanUtil.copy(omdEnum, EnumVO.class)); + + //User createUser = UserCache.getUser(omdEnum.getCreateUser()); + //User updateUser = UserCache.getUser(omdEnum.getUpdateUser()); + //omdEnumVO.setCreateUserName(createUser.getName()); + //omdEnumVO.setUpdateUserName(updateUser.getName()); + + return enumVO; + } + + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumitemWrapper.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumitemWrapper.java new file mode 100644 index 0000000..885903d --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/wrapper/EnumitemWrapper.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package com.vci.ubcs.omd.wrapper; + +import com.vci.ubcs.omd.cache.EnumCache; +import com.vci.ubcs.omd.entity.Enum; +import com.vci.ubcs.omd.vo.EnumVO; +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.node.ForestNodeMerger; +import org.springblade.core.tool.utils.BeanUtil; +import com.vci.ubcs.omd.entity.EnumItem; +import com.vci.ubcs.omd.vo.EnumItemVO; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * 鏋氫妇瀹氫箟瀛愯〃 鍖呰绫�,杩斿洖瑙嗗浘灞傛墍闇�鐨勫瓧娈� + * + * @author yuxc + * @since 2023-05-08 + */ +public class EnumitemWrapper extends BaseEntityWrapper<EnumItem, EnumItemVO> { + + public static EnumitemWrapper build() { + return new EnumitemWrapper(); + } + + @Override + public EnumItemVO entityVO(EnumItem enumitem) { + + EnumItemVO enumItemVO = Objects.requireNonNull(BeanUtil.copy(enumitem, EnumItemVO.class)); + if (enumitem.getParentoid() == null ) { + enumItemVO.setParentName(BladeConstant.TOP_PARENT_NAME); + } else { + Enum parent = EnumCache.getById(enumitem.getParentoid()); + enumItemVO.setParentName(parent.getLabel()); + } + return enumItemVO; + } + public List<EnumVO> listNodeVO(List<EnumItem> list) { + List<EnumItem> collect = list.stream().map(omdEnumItem -> BeanUtil.copy(omdEnumItem, EnumItem.class)).collect(Collectors.toList()); + return ForestNodeMerger.merge((List)collect); + } + +} diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/DictMapper.xml b/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/DictMapper.xml deleted file mode 100644 index 6ab5794..0000000 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/DictMapper.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="com.vci.ubcs.omd.mapper.DictMapper"> - - <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> - <resultMap id="dictResultMap" type="com.vci.ubcs.omd.entity.Dict"> - <id column="id" property="id"/> - <result column="parent_id" property="parentId"/> - <result column="code" property="code"/> - <result column="dict_key" property="dictKey"/> - <result column="dict_value" property="dictValue"/> - <result column="sort" property="sort"/> - <result column="remark" property="remark"/> - <result column="is_deleted" property="isDeleted"/> - </resultMap> - - <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> - <id column="id" property="id"/> - <result column="parent_id" property="parentId"/> - <result column="title" property="title"/> - <result column="value" property="value"/> - <result column="key" property="key"/> - </resultMap> - - <select id="getValue" resultType="java.lang.String"> - select - dict_value - from pl_sys_dict where code = #{param1} and dict_key = #{param2} and is_deleted = 0 - </select> - - <!-- oracle 鐗堟湰 --> - <!--<select id="getValue" resultType="java.lang.String"> - select - dict_value - from pl_sys_dict_biz where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} and dict_key >= 0 rownum 1 - </select>--> - - <select id="getList" resultMap="dictResultMap"> - select id, parent_id, code, dict_key, dict_value, sort, remark from pl_sys_dict where code = #{param1} and parent_id > 0 and is_sealed = 0 and is_deleted = 0 - </select> - - <select id="tree" resultMap="treeNodeResultMap"> - select id, parent_id, dict_value as title, id as "value", id as "key" from pl_sys_dict where is_deleted = 0 - </select> - - <select id="parentTree" resultMap="treeNodeResultMap"> - select id, parent_id, dict_value as title, id as "value", id as "key" from pl_sys_dict where is_deleted = 0 and parent_id = 0 - </select> - -</mapper> diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumItemMapper.xml b/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumItemMapper.xml new file mode 100644 index 0000000..5305b6a --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumItemMapper.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.vci.ubcs.omd.mapper.EnumItemMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="enumitemResultMap" type="com.vci.ubcs.omd.entity.EnumItem"> + <result column="OID" property="oid"/> + <result column="NAME" property="name"/> + <result column="VALUE" property="value"/> + <result column="DESCRIPTION" property="description"/> + <result column="TS" property="ts"/> + <result column="CREATOR" property="creator"/> + <result column="CREATETIME" property="createtime"/> + <result column="MODIFIER" property="modifier"/> + <result column="MODIFYTIME" property="modifytime"/> + <result column="PARENTOID" property="parentoid"/> + <result column="SORT" property="sort"/> + </resultMap> + + + <select id="selectOmdEnumitemPage" resultMap="enumitemResultMap"> + select * from PL_OMD_ENUMITEM where 1 = 1 + </select> + + +</mapper> diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumMapper.xml b/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumMapper.xml new file mode 100644 index 0000000..d37dd63 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/resources/mapper/EnumMapper.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.vci.ubcs.omd.mapper.EnumMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="enumResultMap" type="com.vci.ubcs.omd.entity.Enum"> + <result column="OID" property="oid"/> + <result column="NAME" property="name"/> + <result column="LABEL" property="label"/> + <result column="TS" property="ts"/> + <result column="CREATOR" property="creator"/> + <result column="CREATETIME" property="createtime"/> + <result column="MODIFIER" property="modifier"/> + <result column="MODIFYTIME" property="modifytime"/> + <result column="REMARK" property="remark"/> + </resultMap> + + + <select id="selectOmdEnumPage" resultMap="enumResultMap"> + select * from PL_OMD_ENUM where 1 = 0 + </select> + + <select id="getValue" resultType="java.lang.String"> + select POE.NAME + from PL_OMD_ENUM PO, PL_OMD_ENUMITEM POE + WHERE PO.OID = POE.PARENTOID + AND PO.NAME = #{param1} + AND POE.VALUE = #{param2} + </select> + + <select id="getList" resultType="com.vci.ubcs.omd.vo.EnumVO"> + select PO.OID, + PO.NAME, + PO.LABEL, + PO.TS, + PO.CREATOR, + PO.CREATOR, + PO.CREATETIME, + PO.MODIFIER, + PO.MODIFYTIME, + PO.REMARK, + POE.OID ITEM_OID, + POE.NAME ITEM_NAME, + POE.VALUE ITEM_VALUE, + POE.DESCRIPTION ITEM_DESCRIPTION + from PL_OMD_ENUM PO, PL_OMD_ENUMITEM POE + WHERE PO.OID = POE.PARENTOID + AND PO.NAME = #{param1} + </select> + + +</mapper> -- Gitblit v1.9.3