From ffe8ac13ba8bc9426f8b5f5b88f094a05b31b7ff Mon Sep 17 00:00:00 2001 From: xxyy <cathay_xy@163.com> Date: 星期一, 10 三月 2025 10:15:29 +0800 Subject: [PATCH] 增强功能与修复错误,更新缓存服务 --- Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/stock/DtBoxingInfo.js | 18 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Options/CacheSettingsOptions.cs | 46 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheService.cs | 219 ++ Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_DictionaryList.js | 22 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs | 31 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/WIDESEA_WMSServer.MvcApplicationPartsAssemblyInfo.cs | 1 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/WIDESEA_StoragIntegrationServices.csproj | 1 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs | 12 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/GlobalUsing.cs | 7 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs | 148 Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Dictionary.js | 65 Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceInfo.js | 87 + Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/dispatchInfo.js | 58 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/ObjectExtension.cs | 45 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/WIDESEA_Cache.csproj | 17 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json | 28 Code Management/WMS/WIDESEA_WMSClient/public/index.html | 135 + Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs | 10 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj | 1 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Const/CacheConst.cs | 52 Code Management/WMS/WIDESEA_WMSServer/LogLibrary/Log/Log.cs | 18 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/LinqExtension.cs | 19 Code Management/WMS/WIDESEA_WMSClient/src/views/widesea_wms/MOM/ErrorMessage/Message.vue | 65 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer.sln | 14 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/DB/Models/BaseEntity.cs | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheService.cs | 180 ++ Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/MCSService.cs | 6 Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_User.js | 86 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CheckingStockOutMiddleware.cs | 27 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs | 20 Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Log.js | 26 .gitignore | 7 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 665 ++----- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs | 4 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs | 5 Code Management/WMS/WIDESEA_WMSClient/config/buttons.js | 143 + Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheHashService.cs | 45 Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role1.js | 61 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheHashService.cs | 88 + Code Management/WMS/WIDESEA_WMSClient/src/router/index.js | 5 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheHashService.cs | 60 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs | 2 Code Management/WMS/WIDESEA_WMSClient/src/extension/basicinfo/router.js | 72 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs | 4 Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/methods.js | 1684 +++++++++++++++++++ Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js | 86 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs | 61 Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/MOM/MOMMessage.js | 76 Code Management/WMS/WIDESEA_WMSClient/src/extension/taskinfo/task.js | 82 Code Management/WMS/WIDESEA_WMSClient/src/router/viewGird.js | 71 Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocol.js | 58 Code Management/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue | 21 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheService.cs | 187 ++ Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocolDetail.js | 58 Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role.js | 49 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Services/Sys_CompanyRegistrationService.cs | 2 Code Management/WMS/WIDESEA_WMSClient/vue.config.js | 53 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/ThrottleFilter.cs | 74 Code Management/WMS/WIDESEA_WMSClient/tests/unit/example.spec.js | 13 60 files changed, 4,495 insertions(+), 709 deletions(-) diff --git a/.gitignore b/.gitignore index 3e0c958..dbac3ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1687,6 +1687,13 @@ /Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/SemanticSymbols.db /Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/SemanticSymbols.db-shm /Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/SemanticSymbols.db-wal +/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/copilot-chat/bef6627e/sessions/4a99214b-9f9f-4ab7-8ce9-83d07cd22a77 +/Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/CodeChunks.db +/Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/CodeChunks.db-shm +/Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/CodeChunks.db-wal +/Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/SemanticSymbols.db +/Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/SemanticSymbols.db-shm +/Code Management/.vs/Code Management/CopilotIndices/17.13.433.20974/SemanticSymbols.db-wal /3F/Code Management/WCS/WIDESEAWCS_Server/.vs/ProjectEvaluation/wideseawcs_server.metadata.v7.bin /3F/Code Management/WCS/WIDESEAWCS_Server/.vs/ProjectEvaluation/wideseawcs_server.projects.v7.bin /3F/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/DesignTimeBuild/.dtbcache.v2 diff --git a/Code Management/WMS/WIDESEA_WMSClient/config/buttons.js b/Code Management/WMS/WIDESEA_WMSClient/config/buttons.js new file mode 100644 index 0000000..50c4dfd --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/config/buttons.js @@ -0,0 +1,143 @@ + +let buttons = [{ + name: "鏌� 璇�", + value: 'Search', + icon: 'el-icon-search', + class: '', + type: 'primary', + onClick: function () { + this.search(); + } +}, +{ + name: "鏂� 寤�", + icon: 'el-icon-plus', + value: 'Add', + class: '', + // plain:true, + type: 'success', + // plain:true, + onClick: function () { + this.add(); + } +}, +{ + name: "缂� 杈�", + icon: 'el-icon-edit', + value: 'Update', + // plain:true, + class: '', + type: 'primary', + onClick: function () { + this.edit(); + } +}, +{ + name: "浠诲姟瀹屾垚", + icon: '', + class: '', + value: 'TaskCompleted', + type: 'primary', + onClick: function () { + } +}, +{ + name: "浠诲姟鍙栨秷", + icon: '', + class: '', + value: 'TaskCancel', + type: 'danger', + onClick: function () { + } +}, +{ + name: "浠诲姟鎭㈠", + icon: '', + class: '', + value: 'TaskRecovery', + type: 'danger', + onClick: function () { + } +}, +{ + name: "鏌ョ湅瀹屾暣璺敱", + icon: '', + class: '', + value: 'ViewAllRouter', + type: 'info', + onClick: function () { + } +}, +{ + name: "璺敱閰嶇疆", + icon: '', + class: '', + value: 'AddRouters', + type: 'success', + onClick: function () { + } +}, +{ + name: "鍥炴粴鍒颁笂涓�姝�", + icon: '', + class: '', + value: 'Previous', + type: 'danger', + onClick: function () { + } +}, +{ + name: "璺宠浆鍒颁笅涓�姝�", + icon: '', + class: '', + value: 'Next', + type: 'warning', + onClick: function () { + } +}, +{ + name: "鍒� 闄�", + icon: 'el-icon-delete', + class: '', + value: 'Delete', + type: 'danger', + onClick: function () { + this.del(); + } +}, +{ + name: "瀹� 鏍�", + icon: 'el-icon-check', + class: '', + value: 'Audit', + plain: true, + type: 'primary', + onClick: function () { + this.audit(); + } +}, +{ + name: "瀵� 鍏�", + icon: 'el-icon-top', + class: '', + type: 'success', + plain: true, + value: 'Import', + onClick: function () { + this.import(); + } +}, +{ + name: "瀵� 鍑�", + icon: 'el-icon-bottom', + type: 'success', + plain: true, + value: 'Export', + onClick: function () { + this.export(); + } +} + +] + +export default buttons \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/public/index.html b/Code Management/WMS/WIDESEA_WMSClient/public/index.html new file mode 100644 index 0000000..548664e --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/public/index.html @@ -0,0 +1,135 @@ +<!DOCTYPE html> +<html lang=""> + +<head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width,initial-scale=1.0"> + <meta name="keywords" content=".netccore,dotnet core,vue,element,element plus,vue3" /> + <meta name="description" content="" /> + <link rel="icon" href="<%= BASE_URL %>wcslogo.png"> + <title><%= htmlWebpackPlugin.options.title %></title> +</head> + +<body> + <noscript> + <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. + Please enable it to continue.</strong> + </noscript> + <div id="app"></div> + <!-- built files will be auto injected --> +</body> + +</html> +<style> + html, + body { + margin: 0; + padding: 0; + height: 100%; + width: 100%; + } + + * { + box-sizing: border-box; + } + + .el-loading { + z-index: 999999; + } + + .el-table th { + display: table-cell !important; + } + + .el-loading .el-loading-spinner { + padding: 7px; + background: #ececec; + width: 200px; + color: red; + left: 0; + right: 0; + margin: 0 auto; + border-radius: 5px; + border: 1px solid #a0a0a0; + + } + + h1, + h2, + h3, + h4 { + margin: 0; + } + + .v-dialog { + border-radius: 5px; + top: 50%; + /* margin-top: -220px !important; */ + } + + .v-dialog .el-dialog__header { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + padding: 0px 13px; + line-height: 53px; + border-bottom: 1px solid #e2e2e2; + height: 50px; + color: white; + font-weight: bold; + font-size: 14px; + background-image: linear-gradient(135deg, #0cd7bd 10%, #50c3f7); + } + + .v-dialog .el-dialog__header .el-dialog__headerbtn { + top: 3px; + right: 0px; + } + + .v-dialog .el-dialog__header .el-dialog__headerbtn .el-dialog__close { + font-size: 19px; + color: white; + } + + .v-dialog .el-dialog__body { + padding: 0; + } + + .el-message { + z-index: 3500 !important; + } + + .v-date-range .el-input__inner { + padding: 0 15px 0 8px + } + + .v-date-range .el-input__suffix .el-input__icon { + display: table-caption; + background: white; + margin: 1px; + height: auto; + margin-right: -4px; + height: 33px; + width: 19px; + font-size: 13px; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + } + + .v-date-range .el-icon-circle-check { + display: none !important; + } + + .v-dialog .el-dialog__header { + margin-right: 0; + } + + .el-button { + font-size: 12px !important; + } + + .el-button--small { + padding: 0px 15px !important; + height: 32px; + } +</style> \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/methods.js b/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/methods.js new file mode 100644 index 0000000..fa02eca --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/methods.js @@ -0,0 +1,1684 @@ +import detailMethods from './detailMethods.js'; +//涓氬姟澶勭悊鏂规硶,鍏ㄩ儴鍙互鐢卞紑鍙戣鐩� +import serviceFilter from './serviceFilter.js'; +let methods = { + //褰撴坊鍔犳墿灞曠粍浠秅ridHeader/gridBody/gridFooter鍙婃槑缁唌odelHeader/modelBody/modelFooter鏃讹紝 + //濡傛灉瑕佽幏鍙栫埗绾ue瀵硅薄,璇蜂娇鐢ㄦ鏂规硶杩涜鍥炶皟 + parentCall(fun) { + if (typeof fun != 'function') { + return console.log('鎵╁睍缁勪欢闇�瑕佷紶鍏ヤ竴涓洖璋冩柟娉曟墠鑳借幏鍙栫埗绾ue瀵硅薄'); + } + fun(this); + }, + getCurrentAction() { + if (this.currentReadonly) { + return ''; + } + return '--' + (this.currentAction == this.const.ADD ? '鏂板' : '缂栬緫'); + }, + quickSearchKeyPress($event) { + //鏌ヨ瀛楁涓篿nput鏃讹紝鎸夊洖杞︽煡璇� + if ($event.keyCode == 13) { + if (this.searchFormFields[this.singleSearch.field] != '') { + this.search(); + } + } + }, + getButtons() { + //鐢熸垚ViewGrid鐣岄潰鐨勬搷浣滄寜閽強鏇村閫夐」 + let searchIndex = this.buttons.findIndex((x) => { + return x.value == 'Search'; + }); + //娣诲姞楂樼骇鏌ヨ + let hasOneFormItem = + this.searchFormOptions.length == 1 && + this.searchFormOptions[0].length == 1; + if (searchIndex != -1 && !hasOneFormItem) { + this.buttons.splice(searchIndex + 1, 0, { + icon: this.fiexdSearchForm ? 'el-icon-refresh-left' : 'el-icon-search', + name: this.fiexdSearchForm ? '閲嶇疆' : '楂樼骇鏌ヨ', + plain: true, + type: this.buttons[searchIndex].type, + onClick: () => { + if (this.fiexdSearchForm) { + return this.resetSearch(); + } + this.searchBoxShow = !this.searchBoxShow; + } + }); + } + if (hasOneFormItem) { + this.fiexdSearchForm = false; + } + this.maxBtnLength += searchIndex == -1 ? 0 : 1; + // if (this.buttons.length <= this.maxBtnLength) { + // return this.buttons; + // } + // let btns = this.buttons.slice(0, this.maxBtnLength); + // btns[this.maxBtnLength - 1].last = true; + // return btns; + }, + extendBtn(btns, source) { + //btns鏉冮檺鎸夐挳锛宻ource涓烘墿灞曟寜閽� + if (!btns || !(source && source instanceof Array)) { + return; + } + //source閫氳繃鍦ㄨ〃鐨勬墿灞昷s鏂囦欢涓璪uttons瀵瑰簲鎸夐挳鐨勫睘鎬ndex鍐冲畾鎸夐挳鎵�鏀句綅缃� + source.forEach((x) => { + //閫氳繃鎸夐挳鐨処ndex灞炴�э紝鏀惧埌鎸囧畾鐨勪綅缃� + btns.splice(x.index == undefined ? btns.length : x.index, 0, x); + }); + // if (this.extend.buttons.view) { + // this.extend.buttons.view.forEach((x) => { + // //閫氳繃鎸夐挳鐨処ndex灞炴�э紝鏀惧埌鎸囧畾鐨勪綅缃� + // this.buttons.splice(x.index == undefined ? this.buttons.length : x.index, 0, x); + // }) + // } + }, + initBoxButtons() { + //鍒濆鍖朧iewGird涓庡脊鍑烘/鏄庣粏琛ㄦ寜閽� + let path = this.$route.path; + //閫氳繃鑿滃崟鑾峰彇鐢ㄦ埛鎵�瀵瑰簲鑿滃崟闇�瑕佹樉绀虹殑鎸夐挳 + let permissionButtons = this.permission.getButtons( + path, + null, + this.extend.tableAction, + this.table.name + ); + if (permissionButtons) { + //2020.03.31娣诲姞娣辨嫹璐濇寜閽粍 + permissionButtons.forEach((p) => { + let _obj = {}; + for (const key in p) { + _obj[key] = p[key]; + } + this.buttons.push(_obj); + }); + // this.buttons.push(...permissionButtons); + } + if (!this.extend) { + this.extend = {}; + } + if (!this.extend.buttons) { + this.extend.buttons = {}; + } + //鏌ヨ鐣岄潰鎵╁睍鎸夐挳(鎵╁睍鎸夐挳鍙嚜琛岄�氳繃璁剧疆鎸夐挳鐨処ndex灞炴�ф樉绀哄埌鍏蜂綋浣嶇疆) + if (this.extend.buttons.view) { + this.extendBtn(this.buttons, this.extend.buttons.view); + } + + //寮瑰嚭妗嗘寜閽� + let boxButtons = []; + + let saveBtn = this.buttons.some((x) => { + if ( + x.value && + (x.value.toLowerCase() == this.const.ADD.toLowerCase() || + x.value.toLowerCase() == this.const.EDIT.toLowerCase()) + ) + return true; + }); + this.currentReadonly = !saveBtn; + //浠庤〃琛ㄦ牸鎿嶄綔鎸夐挳 + let detailGridButtons = { + name: '鍒锋柊', + type: 'info', + icon: 'el-icon-refresh', + onClick() { + //濡傛灉鏄庣粏琛ㄥ綋鍓嶇殑鐘舵�佷负鏂板缓鏃讹紝绂佹鍒锋柊 + if (this.currentAction == this.const.ADD) { + return; + } + this.refreshRow(); + } + }; + + let importExcel = this.buttons.some((x) => { + if (x.value == this.const.IMPORT) return true; + }); + //濡傛灉鏈夊鍏ユ潈闄�,鍒欓渶瑕佸垵濮嬪寲瀵煎叆缁勪欢 + if (importExcel) { + this.upload.url = this.getUrl(this.const.IMPORT); + //瀹氫箟涓嬭浇妯℃澘鐨勬枃浠跺悕 + this.upload.template.fileName = this.table.cnName; + //瀹氫箟涓嬭浇妯℃澘鐨刄rl璺緞 + this.upload.template.url = + this.http.ipAddress + this.getUrl(this.const.DOWNLOADTEMPLATE, true); + } + + // disabled + //濡傛灉褰撳墠瑙掕壊娌℃湁缂栬緫鎴栨柊寤哄姛鑳斤紝鏌ョ湅鏄庣粏鏃跺瓧娈佃缃叏閮ㄥ彧璇� + //鍙湁鏄庣粏琛紝灏嗘槑缁嗚〃涔熻缃负涓嶅彲鑳界紪杈戯紝骞朵笖涓嶆樉绀烘坊鍔犺銆佸垹闄よ + if (!saveBtn) { + this.editFormOptions.forEach((row) => { + row.forEach((x) => { + x.disabled = true; + }); + }); + //娌℃湁鏂板缂栬緫鏉冮檺鐨勶紝寮瑰嚭妗嗛兘璁剧疆涓哄彧璇� + this.detail.columns.forEach((column) => { + if (column.hasOwnProperty('edit')) { + column.readonly = true; + // row['edit'] = false; + } + }); + //寮瑰嚭妗嗘墿灞曟寜閽� + this.extendBtn(boxButtons, this.extend.buttons.box); + //寮瑰嚭寮规鎸夐挳(2020.04.21),娌℃湁缂栬緫鎴栨柊寤烘潈闄愭椂锛屼篃鍙互閫氳繃buttons灞炴�ф坊鍔犺嚜瀹氫箟寮瑰嚭妗嗘寜閽� + this.boxButtons.push(...boxButtons); + this.detailOptions.buttons.push(detailGridButtons); + this.detailOptions.buttons.forEach((button) => { + if (!button.hasOwnProperty('hidden')) { + button.hidden = false; + } + }); + //寮瑰嚭妗嗘墿灞曟槑缁嗚〃鎸夐挳 + this.extendBtn(this.detailOptions.buttons, this.extend.buttons.detail); + + return boxButtons; + } + + this.detailOptions.edit = true; + boxButtons.push( + ...[ + { + name: '淇� 瀛�', + icon: 'el-icon-check', + type: 'danger', + disabled: false, + value: 'save', + onClick() { + this.save(); + } + } + // { + // name: '閲� 缃�', + // icon: 'el-icon-refresh-right', + // type: 'primary', + // disabled: false, + // onClick() { + // this.resetEdit(); + // } + // } + ] + ); + //浠庤〃琛ㄦ牸鎿嶄綔鎸夐挳 + this.detailOptions.buttons.push( + ...[ + { + name: '娣诲姞琛�', + icon: 'el-icon-plus', + type: 'primary', + hidden: false, + plain: true, + onClick() { + this.addRow(); + } + }, + { + type: 'danger', + plain: true, + name: '鍒犻櫎琛�', + hidden: false, + icon: 'el-icon-delete', + onClick() { + this.delRow(); + } + }, + //2022.01.08澧炲姞鏄庣粏琛ㄥ鍏ュ鍑哄姛鑳� + //娉ㄦ剰闇�瑕侀噸鍐欏悗鍙版槑缁嗚〃鎺ュ彛鐨勫鍏ヤ笌涓嬭浇妯℃澘銆佸鍑虹殑鏉冮檺,Sys_DictionaryListController.cs/SellOrderListController.cs + { + type: 'danger', + plain: true, + name: '瀵煎叆', + value: 'import', + hidden: false, + icon: 'el-icon-upload2', + onClick() { + this.upload.url = `${this.http.ipAddress}api/${this.detail.table}/${this.const.IMPORT}?table=1`; + this.upload.template.url = `${this.http.ipAddress}api/${this.detail.table}/${this.const.DOWNLOADTEMPLATE}`; + //瀹氫箟涓嬭浇妯℃澘鐨勬枃浠跺悕 + this.upload.template.fileName = this.detail.cnName; + this.upload.excel = true; + } + }, + { + type: 'danger', + plain: true, + name: '瀵煎嚭', + value: 'export', + icon: 'el-icon-download', + hidden: false, + onClick() { + this.export(true); + } + } + ] + ); + this.detailOptions.buttons.forEach((button) => { + if (button.hasOwnProperty('hidden')) { + button.hidden = false; + } + }); + //寮瑰嚭妗嗘墿灞曟寜閽� + this.extendBtn(boxButtons, this.extend.buttons.box); + + //寮瑰嚭妗嗘墿灞曟槑缁嗚〃鎸夐挳 + this.detailOptions.buttons.push(detailGridButtons); + this.extendBtn(this.detailOptions.buttons, this.extend.buttons.detail); + + //寮瑰嚭寮规鎸夐挳 + this.boxButtons.push(...boxButtons); + }, + onClick(click) { + click.apply(this); + }, + changeDropdown(btnName, v1) { + let button = this.buttons.filter((x) => { + return x.name == btnName; + }); + if (button && button.length > 0) { + button[0].onClick.apply(this); + } + }, + emptyValue(value) { + if (typeof value == 'string' && value.trim() === '') { + return true; + } + if (value instanceof Array && !value.length) { + return true; + } + return value === null || value === undefined || value === ''; + }, + getSearchParameters() { + //鑾峰彇鏌ヨ鍙傛暟 + // 2020.09.11澧炲姞鍥哄畾鏌ヨ琛ㄥ崟,濡傛灉璁剧疆鍥哄畾浜嗘煡璇㈣〃鍗曪紝鐐瑰嚮鏌ヨ鏃讹紝涓嶅啀鍏抽棴 + if (!this.fiexdSearchForm) { + this.searchBoxShow = false; + } + + let query = { wheres: [] }; + for (const key in this.searchFormFields) { + let value = this.searchFormFields[key]; + if (this.emptyValue(value)) continue; + + if (typeof value == 'number') { + value = value + ''; + } + let displayType = this.getSearchItem(key); + + //鑱旂骇鍙繚鐣欓�変腑鑺傜偣鐨勬渶鍚庝竴涓�� + if (displayType == 'cascader') { + //鏌ヨ涓嬮潰鎵�鏈夌殑瀛愯妭鐐癸紝濡傦細閫変腑鐨勬槸鐖惰妭鐐癸紝搴旇鏌ヨ涓嬮潰鎵�鏈夌殑鑺傜偣鏁版嵁--寰呭畬 + value = value.length ? value[value.length - 1] + '' : ''; + } + //2021.05.02澧炲姞鍖洪棿鏌ヨ + if ( + typeof value == 'string' || + ['date', 'datetime', 'range'].indexOf(displayType) == -1 + ) { + query.wheres.push({ + name: key, + value: + typeof value == 'string' ? (value + '').trim() : value.join(','), + displayType: displayType + }); + continue; + } + for (let index = 0; index < value.length; index++) { + if (!this.emptyValue(value[index])) { + query.wheres.push({ + name: key, + value: (value[index] + '').trim(), + displayType: (() => { + if (['date', 'datetime', 'range'].indexOf(displayType) != -1) { + return index ? 'lessorequal' : 'thanorequal'; + } + return displayType; + })() + }); + } + } + } + return query; + }, + search() { + //鏌ヨ + // let query = this.getSearchParameters(); + // this.$refs.table.load(query, true); + this.$refs.table.load(null, true); + }, + loadTableBefore(param, callBack) { + //鏌ヨ鍓嶈缃煡璇㈡潯浠跺強鍒嗛〉淇℃伅 + let query = this.getSearchParameters(); + if (query) { + param = Object.assign(param, query); + } + + if (this.$route.query.viewflow && this.$route.query.id) { + param.wheres.push({ + name: this.table.key, + value: this.$route.query.id + }); + } + // if (this.isViewFlow() && data && data.length) { + // let query = JSON.parse(JSON.stringify(this.$route.query)); + // query.viewflow = 0; + // this.$router.replace({ path: this.$route.path, query: query }); + // this.$nextTick(() => { + // this.getWorkFlowSteps(data[0]); + // }); + // } + let status = this.searchBefore(param); + callBack(status); + }, + + loadTableAfter(data, callBack, result) { + //鏌ヨ鍚� + //2020.10.30澧炲姞鏌ヨ鍚庤繑鍥炴墍鏈夌殑鏌ヨ淇℃伅 + let status = this.searchAfter(data, result); + callBack(status); + //鑷姩寮瑰嚭妗嗗鎵硅鎯� + }, + loadDetailTableBefore(param, callBack) { + //鏄庣粏鏌ヨ鍓� + //鏂板缓鏃剁姝㈠姞杞芥槑缁� + if (this.currentAction == this.const.ADD) { + callBack(false); + return false; + } + let status = this.searchDetailBefore(param); + callBack(status); + }, + loadDetailTableAfter(data, callBack) { + //鏄庣粏鏌ヨ鍚� + let status = this.searchDetailAfter(data); + callBack(status); + }, + getSearchItem(field) { + //鑾峰彇鏌ヨ鐨勫弬鏁� + let data; + for (let index = 0; index < this.searchFormOptions.length; index++) { + if (data) return data.type; + const item = this.searchFormOptions[index]; + data = item.find((x) => { + return x.field == field; + }); + } + + return (data || {}).type; + }, + resetSearch() { + //閲嶇疆鏌ヨ瀵硅薄 + this.resetSearchForm(); + //2020.10.17澧炲姞閲嶇疆鍚庢柟娉� + this.resetSearchFormAfter && this.resetSearchFormAfter(); + }, + resetEdit() { + //閲嶇疆缂栬緫鐨勬暟鎹� + let isEdit = this.currentAction != this.const.ADD; + //閲嶇疆涔嬪墠 + if (!this[isEdit ? 'resetUpdateFormBefore' : 'resetAddFormBefore']()) { + return; + } + let objKey = {}; + //缂栬緫鐘舵�佷笅,涓嶉渶瑕侀噸缃富閿�,鍒涘缓鏃堕棿鍒涘缓浜� + if (isEdit) { + objKey[this.table.key] = this.editFormFields[this.table.key]; + } + this.resetEditForm(objKey); + //閲嶇疆涔嬪悗 + + if (!this[isEdit ? 'resetUpdateFormAfter' : 'resetAddFormAfter']()) { + return; + } + }, + resetSearchForm(sourceObj) { + //閲嶇疆鏌ヨ琛� + this.resetForm('searchForm', sourceObj); + }, + resetEditForm(sourceObj) { + if (this.hasDetail && this.$refs.detail) { + // this.$refs.detail.rowData.splice(0); + this.$refs.detail.reset(); + } + this.resetForm('form', sourceObj); + if (this.$refs.form && this.$refs.form.$refs.volform) { + setTimeout(() => { + this.$refs.form.$refs.volform.clearValidate(); + }, 100); + } + }, + getKeyValueType(formData, isEditForm) { + try { + let keyLeft = (isEditForm ? 'e' : 's') + '_b_'; + formData.forEach((item) => { + item.forEach((x) => { + if (this.keyValueType.hasOwnProperty(keyLeft + x.field)) { + return true; + } + let data; + if (x.type == 'switch') { + this.keyValueType[x.field] = 1; + } else if (x.bind && x.bind.data) { + data = x.bind.data; + } else if (x.data) { + if (x.data instanceof Array) { + data = x.data; + } else if (x.data.data && x.data.data instanceof Array) { + data = x.data.data; + } + } + if ( + data && + data.length > 0 && + !this.keyValueType.hasOwnProperty(x.field) + ) { + this.keyValueType[x.field] = data[0].key; + this.keyValueType[keyLeft + x.field] = x.type; + } + }); + }); + } catch (error) { + console.log(error.message); + } + }, + resetForm(formName, sourceObj) { + // return; + //閲嶇疆琛ㄥ崟鏁版嵁 + if (this.$refs[formName]) { + this.$refs[formName].reset(); + } + + if (!sourceObj) return; + let form, keyLeft; + if (formName == 'searchForm') { + form = this.searchFormFields; + keyLeft = 's' + '_b_'; + } else { + form = this.editFormFields; + keyLeft = 'e' + '_b_'; + } + //鑾峰彇鏁版嵁婧愮殑data绫诲瀷锛屽惁鍒欏鏋滄暟鎹簮data鐨刱ey鏄暟瀛楋紝閲嶇疆鐨勫�兼槸瀛楃涓插氨鏃犳硶缁戝畾鍊� + if (!this.keyValueType._dinit) { + this.getKeyValueType(this.editFormOptions, true); + this.getKeyValueType(this.searchFormOptions, false); + this.keyValueType._dinit = true; + } + var _cascaderParentTree; + for (const key in form) { + if (sourceObj.hasOwnProperty(key)) { + let newVal = sourceObj[key]; + let kv_type = this.keyValueType[keyLeft + key]; + + if ( + kv_type == 'selectList' || + kv_type == 'checkbox' || + kv_type == 'cascader' || + kv_type == 'treeSelect' + ) { + // 2020.05.31澧炲姞iview缁勪欢Cascader + // 2020.11.01澧炲姞iview缁勪欢Cascader琛ㄥ崟閲嶇疆鏃舵煡璇㈡墍鏈夌殑鐖惰妭鐐� + if (kv_type == 'cascader' || kv_type == 'treeSelect') { + var treeDic = this.dicKeys.find((dic) => { + return dic.fileds && dic.fileds.indexOf(key) != -1; + }); + + if (treeDic && treeDic.orginData && treeDic.orginData.length) { + let keyIsNum = typeof treeDic.orginData[0].id == 'number'; + + if (kv_type == 'cascader') { + newVal = keyIsNum ? newVal * 1 || 0 : newVal + ''; + if (kv_type == 'cascader') { + _cascaderParentTree = this.base.getTreeAllParent( + newVal, + treeDic.orginData + ); + if (_cascaderParentTree) { + newVal = _cascaderParentTree.map((x) => { + return x.id; + }); + } + } + } else { + if (newVal === null || newVal === undefined) { + newVal = []; + } else if (typeof newVal == 'string') { + newVal = newVal.split(','); + } + if (keyIsNum) { + if (Array.isArray(newVal)) { + newVal = newVal.map((x) => { + return x * 1 || 0; + }); + } + } else if (typeof newVal == 'number') { + newVal = [newVal + '']; + } + } + } else { + newVal = [newVal]; + } + } else if ( + newVal != '' && + newVal != undefined && + typeof newVal == 'string' + ) { + newVal = newVal.split(','); + } else if (kv_type == 'checkbox') { + newVal = []; + } + } else if ( + this.keyValueType.hasOwnProperty(key) && + typeof this.keyValueType[key] == 'number' && + newVal * 1 == newVal + ) { + newVal = newVal * 1; + } else { + if (newVal == null || newVal == undefined) { + newVal = ''; + } else if (this.numberFields.indexOf(key) != -1) { + newVal = newVal * 1 || 0; + } else { + newVal += ''; + } + } + if (newVal instanceof Array) { + if (form[key]) { + form[key] = []; + } + form[key] = newVal; + } else { + form[key] = newVal; + } + } else { + form[key] = form[key] instanceof Array ? [] : ''; + } + } + }, + onBtnClick(param) { + this[param.method](param.data); + }, + refresh() { + //鍒锋柊 + this.search(); + // this.$refs.table.load(); + }, + saveBefore(formData) { + return true; + }, + saveAfter(formData, result) { + return true; + }, + save() { + //鏂板鎴栫紪杈戞椂淇濆瓨 + // if (!this.$refs.form.validate()) return; + this.$refs.form.validate((result) => { + if (result) { + this.saveExecute(); + } + }); + }, + async saveExecute() { + let editFormFields = {}; + //涓婁紶鏂囦欢浠ラ�楀彿闅斿紑 + for (const key in this.editFormFields) { + if ( + this.uploadfiled && + this.uploadfiled.length > 0 && + this.uploadfiled.indexOf(key) != -1 && + this.editFormFields[key] instanceof Array + ) { + let allPath = this.editFormFields[key].map((x) => { + return x.path; + }); + editFormFields[key] = allPath.join(','); + } else if (typeof this.editFormFields[key] == 'function') { + try { + editFormFields[key] = this.editFormFields[key](); + } catch (error) { } + } else { + //2021.05.30淇涓嬫媺妗嗘竻闄ゆ暟鎹悗鍚庡彴涓嶈兘淇濆瓨鐨勯棶棰� + if ( + this.editFormFields[key] === undefined && + this.dicKeys.some((x) => { + return x.fileds && x.fileds.indexOf(key) != -1; + }) + ) { + editFormFields[key] = null; + } else { + editFormFields[key] = this.editFormFields[key]; + } + } + } + //灏嗘暟缁勮浆鎹㈡垚string + //2020.11.01澧炲姞绾ц仈澶勭悊 + for (const key in editFormFields) { + if (editFormFields[key] instanceof Array) { + var iscascader = this.dicKeys.some((x) => { + return ( + x.type == 'cascader' && x.fileds && x.fileds.indexOf(key) != -1 + ); + }); + if (iscascader && editFormFields[key].length) { + editFormFields[key] = + editFormFields[key][editFormFields[key].length - 1]; + } else { + editFormFields[key] = editFormFields[key].join(','); + } + } + } + + let formData = { + mainData: editFormFields, + detailData: null, + delKeys: null + }; + + //鑾峰彇鏄庣粏鏁版嵁(鍓嶅彴鏁版嵁鏄庣粏鏈仛鏍¢獙锛屽緟瀹�.鍚庡彴宸茬粡鏍¢獙) + if (this.hasDetail) { + formData.detailData = this.$refs.detail.rowData; + let _fields = this.detail.columns + .filter((c) => { + return ( + c.type == 'selectList' || (c.edit && c.edit.type == 'selectList') + ); + }) + .map((c) => { + return c.field; + }); + //2022.06.20澧炲姞淇濆瓨鏃跺鏄庣粏琛ㄤ笅鎷夋澶氶�夌殑鍒ゆ柇 + if (_fields.length) { + formData.detailData = JSON.parse(JSON.stringify(formData.detailData)); + formData.detailData.forEach((row) => { + for (let index = 0; index < _fields.length; index++) { + const _field = _fields[index]; + if (Array.isArray(row[_field])) { + row[_field] = row[_field].join(','); + } + } + }); + } + } + if (this.detailOptions.delKeys.length > 0) { + formData.delKeys = this.detailOptions.delKeys; + } + //淇濆瓨鍓嶆嫤鎴� + let _currentIsAdd = this.currentAction == this.const.ADD; + if (_currentIsAdd) { + //2020.12.06澧炲姞鏂板缓鍓嶅紓姝ュ鐞嗘柟娉� + //2021.08.16淇寮傛璇硶鍐欓敊鐨勯棶棰� + if (!this.addBefore(formData) || !(await this.addBeforeAsync(formData))) + return; + } else { + //2020.12.06澧炲姞淇敼鍓嶅紓姝ュ鐞嗘柟娉� + if ( + !this.updateBefore(formData) || + !(await this.updateBeforeAsync(formData)) + ) + return; + } + let url = this.getUrl(this.currentAction); + this.http.post(url, formData, true).then((x) => { + //淇濆瓨鍚� + if (_currentIsAdd) { + if (!this.addAfter(x)) return; + //杩炵画娣诲姞 + if (this.continueAdd && x.status) { + this.$success(x.message); + //鏂板缓 + this.currentAction = this.const.ADD; + this.currentRow = {}; + this.resetAdd(); + this.refresh(); + return; + } + } else { + if (!this.updateAfter(x)) return; + } + if (!x.status) return this.$error(x.message); + this.$success(x.message || '鎿嶄綔鎴愬姛'); + //濡傛灉淇濆瓨鎴愬姛鍚庨渶瑕佸叧闂紪杈戞锛岀洿鎺ヨ繑鍥炰笉澶勭悊鍚庨潰 + if (this.boxOptions.saveClose) { + this.boxModel = false; + //2020.12.27濡傛灉鏄紪杈戜繚瀛樺悗涓嶉噸缃垎椤甸〉鏁帮紝鍒锋柊椤甸潰鏃惰繕鏄樉绀哄綋鍓嶉〉鐨勬暟鎹� + this.$refs.table.load(null, _currentIsAdd); + //this.refresh(); + return; + } + let resultRow; + if (typeof x.data == 'string' && x.data != '') { + resultRow = JSON.parse(x.data); + } else { + resultRow = x.data; + } + + if (this.currentAction == this.const.ADD) { + // this.currentRow=x.data; + this.editFormFields[this.table.key] = ''; + this.currentAction = this.const.EDIT; + this.currentRow = resultRow.data; + } + this.resetEditForm(resultRow.data); + // console.log(resultRow); + if (this.hasDetail) { + this.detailOptions.delKeys = []; + if (resultRow.list) { + this.$refs.detail.rowData.push(...resultRow.list); + } + } + this.$refs.table.load(null, _currentIsAdd); + // this.refresh(); + }); + }, + del(rows) { + if (rows) { + if (!(rows instanceof Array)) { + rows = [rows]; + } + } else { + rows = this.$refs.table.getSelected(); + } + //鍒犻櫎鏁版嵁 + + if (!rows || rows.length == 0) return this.$error('璇烽�夋嫨瑕佸垹闄ょ殑琛�!'); + let delKeys = rows.map((x) => { + return x[this.table.key]; + }); + if (!delKeys || delKeys.length == 0) + return this.$error('娌℃湁鑾峰彇瑕佸垹闄ょ殑琛屾暟鎹�!'); + //鍒犻櫎鍓� + if (!this.delBefore(delKeys, rows)) { + return; + } + let tigger = false; + this.$confirm('纭瑕佸垹闄ら�夋嫨鐨勬暟鎹悧?', '璀﹀憡', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning', + center: true + }).then(() => { + if (tigger) return; + tigger = true; + let url = this.getUrl(this.const.DEL); + this.http.post(url, delKeys, '姝e湪鍒犻櫎鏁版嵁....').then((x) => { + if (!x.status) return this.$error(x.message); + this.$success("鍒犻櫎鎴愬姛"); + //鍒犻櫎鍚� + if (!this.delAfter(x)) { + return; + } + this.refresh(); + }); + }); + }, + async modelOpenBeforeAsync(row) { + return true; + }, + async initBox() { + //2022.01.08澧炲姞鏂板缓鏃堕殣钘忔槑缁嗚〃瀵煎嚭鍔熻兘 + this.detailOptions.buttons.forEach((x) => { + if (x.value == 'export') { + x.hidden = this.currentAction == 'Add'; + } + }); + //鍒濆鍖栨柊寤恒�佺紪杈戠殑寮瑰嚭妗� + if (!(await this.modelOpenBeforeAsync(this.currentRow))) return false; + this.modelOpenBefore(this.currentRow); + if (!this.boxInit) { + this.boxInit = true; + this.boxModel = true; + // this.detailUrl = this.url; + } + return true; + }, + setEditForm(row) { + // if (this.remoteColumns.length == 0 || !rows || rows.length == 0) return; + let remoteColumns = this.$refs.table.remoteColumns; + remoteColumns.forEach((column) => { + this.editFormOptions.forEach((option) => { + option.forEach((x) => { + if (x.field == column.field) { + x.data.data = Object.assign([], x.data, column.bind.data); + } + }); + }); + }); + this.editFormFields; + //閲嶇疆缂栬緫琛ㄥ崟鏁版嵁 + this.editFormFields[this.table.key] = row[this.table.key]; + + this.resetEditForm(row); + this.currentAction = this.const.EDIT; + this.boxModel = true; + }, + async linkData(row, column) { + this.boxOptions.title = this.table.cnName + '(缂栬緫)'; + //鐐瑰嚮table鍗曞厓鏍煎揩鎹烽摼鎺ユ樉绀虹紪杈戞暟鎹� + this.currentAction = this.const.EDIT; + this.currentRow = row; + if (!(await this.initBox())) return; + this.resetDetailTable(row); + this.setEditForm(row); + this.setContinueAdd(false); + //璁剧疆杩滅▼鏌ヨ琛ㄥ崟鐨勯粯璁ey/value + this.getRemoteFormDefaultKeyValue(); + //鐐瑰嚮缂栬緫鎸夐挳寮瑰嚭妗嗗悗锛屽彲浠ュ湪姝ゅ鍐欓�昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + this.modelOpenProcess(row); + }, + setContinueAdd(isAdd) { + if (!this.continueAdd) return; + var _button = this.boxButtons.find((x) => { + return x.value == 'save'; + }); + if (_button) { + _button.name = isAdd ? this.continueAddName : '淇� 瀛�'; + } + }, + resetAdd() { + if (this.hasDetail) { + this.$refs.detail && + // this.$refs.detail.rowData && + this.$refs.detail.reset(); + } + let obj = {}; + //濡傛灉鏈塻witch鏍囩锛岄粯璁ら兘璁剧疆涓哄惁 + this.editFormOptions.forEach((x) => { + x.forEach((item) => { + if (item.type == 'switch') { + obj[item.field] = 0; + } + }); + }); + this.resetEditForm(obj); + }, + async add() { + this.boxOptions.title = this.table.cnName + '(鏂板缓)'; + //鏂板缓 + this.currentAction = this.const.ADD; + this.currentRow = {}; + if (!(await this.initBox())) return; + + this.resetAdd(); + this.setContinueAdd(true); + // this.resetEditForm(); + this.boxModel = true; + //鐐瑰嚮鏂板缓鎸夐挳寮瑰嚭妗嗗悗锛屽彲浠ュ湪姝ゅ鍐欓�昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + this.modelOpenProcess(); + // this.modelOpenAfter(); + }, + async edit(rows) { + this.boxOptions.title = '缂栬緫'; + //缂栬緫 + this.currentAction = this.const.EDIT; + if (rows) { + if (!(rows instanceof Array)) { + rows = [rows]; + } + } else { + rows = this.$refs.table.getSelected(); + } + if (rows.length == 0) { + return this.$error('璇烽�夋嫨瑕佺紪杈戠殑琛�!'); + } + if (rows.length != 1) { + return this.$error('鍙兘閫夋嫨涓�琛屾暟鎹繘琛岀紪杈�!'); + } + //璁板綍褰撳墠缂栬緫鐨勮 + this.currentRow = rows[0]; + //鍒濆鍖栧脊鍑烘 + if (!(await this.initBox())) return; + this.setContinueAdd(false); + //閲嶇疆琛ㄥ崟 + this.resetDetailTable(); + + //璁剧疆褰撳墠鐨勬暟鎹埌琛ㄥ崟涓� + this.setEditForm(rows[0]); + //璁剧疆杩滅▼鏌ヨ琛ㄥ崟鐨勯粯璁ey/value + this.getRemoteFormDefaultKeyValue(); + //鐐瑰嚮缂栬緫鎸夐挳寮瑰嚭妗嗗悗锛屽彲浠ュ湪姝ゅ鍐欓�昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + this.modelOpenProcess(rows[0]); + // this.modelOpenAfter(rows[0]); + }, + getRemoteFormDefaultKeyValue() { + //璁剧疆琛ㄥ崟杩滅▼鏁版嵁婧愮殑榛樿key.value + if (this.currentAction != this.const.EDIT || this.remoteKeys.length == 0) + return; + this.editFormOptions.forEach((x, xIndex) => { + x.forEach((item, yIndex) => { + if (item.remote) { + let column = this.columns.find((x) => { + return x.bind && x.bind.key == item.dataKey; + }); + if (!column) return; + let key = this.currentRow[item.field]; + let obj = column.bind.data.find((x) => { + return x.key == key; + }); + // obj ? obj.value : key濡傛灉娌℃湁鏌ュ埌鏁版嵁婧愶紝鐩存帴浣跨敤鍘熸暟鎹� + item.data = [{ key: key, value: obj ? obj.value : key }]; + this.editFormOptions[xIndex].splice(yIndex, 1, item); + // this.$set(item, 'data', [{ key: key + '', value: obj.value }]) + // item.data = [{ key: key + '', value: obj.value }]; + } + }); + }); + }, + modelOpenProcess(row) { + this.$nextTick(() => { + this.modelOpenAfter(row); + }); + return; + // if (!this.$refs.form) { + // let timeOut = setTimeout(x => { + // this.modelOpenAfter(row); + // }, 500) + // return; + // } + // this.modelOpenAfter(row); + }, + import() { + //瀵煎叆(涓婁紶excel),寮瑰嚭瀵煎叆缁勪欢UploadExcel.vue + this.upload.excel = true; + this.$refs.upload_excel && this.$refs.upload_excel.reset(); + }, + download(url, fileName) { + //涓嬭浇瀵煎嚭鐨勬枃浠� + let xmlResquest = new XMLHttpRequest(); + xmlResquest.open('GET', url, true); + xmlResquest.setRequestHeader('Content-type', 'application/json'); + xmlResquest.setRequestHeader( + 'Authorization', + this.$store.getters.getToken() + ); + let elink = this.$refs.export; + xmlResquest.responseType = 'blob'; + xmlResquest.onload = function (oEvent) { + if (xmlResquest.status != 200) { + this.$error('涓嬭浇鏂囦欢鍑洪敊浜�..'); + return; + } + let content = xmlResquest.response; + // let elink = this.$refs.export;//document.createElement("a"); + elink.download = fileName; //+".xlsx"; + // elink.style.display = "none"; + let blob = new Blob([content]); + elink.href = URL.createObjectURL(blob); + // document.body.appendChild(elink); + elink.click(); + // document.body.removeChild(elink); + }; + xmlResquest.send(); + }, + getFileName(isDetail) { + //2021.01.08澧炲姞瀵煎嚭excel鏃惰嚜瀹氫箟鏂囦欢鍚� + if (isDetail) { + return this.detail.cnName + '.xlsx'; + } + return this.table.cnName + '.xlsx'; + }, + export(isDetail) { + //瀵煎嚭 + let url, query, param; + if (isDetail) { + //鏄庣粏琛ㄥ鍑烘椂濡傛灉鏄柊寤虹姸鎬侊紝绂佹瀵煎嚭 + if (this.currentAction == 'Add') { + return; + } + url = `api/${this.detail.table}/${this.const.EXPORT}`; + param = { + wheres: [ + { name: this.table.key, value: this.editFormFields[this.table.key] } + ] + }; + } else { + //涓昏〃瀵煎嚭 + url = this.getUrl(this.const.EXPORT); + query = this.getSearchParameters(); + param = { order: this.pagination.order, wheres: query.wheres || [] }; + } + //2020.06.25澧炲姞瀵煎嚭鍓嶅鐞� + if (!isDetail && !this.exportBefore(param)) { + return; + } + + if (param.wheres && typeof param.wheres == 'object') { + param.wheres = JSON.stringify(param.wheres); + } + let $http = this.http; + //2022.09.26澧炲姞鑷畾涔夊鍑烘枃浠跺悕 + let fileName = this.downloadFileName || this.getFileName(isDetail); + //2021.01.08浼樺寲瀵煎嚭鍔熻兘 + $http + .post(url, param, '姝e湪瀵煎嚭鏁版嵁....', { responseType: 'blob' }) + .then((content) => { + const blob = new Blob([content]); + if ('download' in document.createElement('a')) { + // 闈濱E涓嬭浇 + const elink = document.createElement('a'); + elink.download = fileName; + elink.style.display = 'none'; + elink.href = URL.createObjectURL(blob); + document.body.appendChild(elink); + elink.click(); + URL.revokeObjectURL(elink.href); + document.body.removeChild(elink); + } else { + // IE10+涓嬭浇 + navigator.msSaveBlob(blob, fileName); + } + }); + //.then(result => { + // if (!result.status) { + // return this.$error(result.message); + // } + // let path = this.getUrl(this.const.DOWNLOAD); + // path = path[0] == "/" ? path.substring(1) : path; + // this.download( + // $http.ipAddress + path + "?path=" + result.data, + // this.table.cnName + ".xlsx" // filePath + // ); + /// window.open($http.ipAddress + path + "?fileName=" + filePath, "_self"); + // }); + }, + getSelectRows() { + //鑾峰彇閫変腑鐨勮 + return this.$refs.table.getSelected(); + }, + getDetailSelectRows() { + //鎴栬幏鍙栨槑缁嗛�変腑鐨勮 + if (!this.$refs.detail) { + return []; + } + return this.$refs.detail.getSelected(); + }, + audit() { + //瀹℃牳寮瑰嚭妗� + let rows = this.$refs.table.getSelected(); + if (rows.length == 0) return this.$error('璇烽�夋嫨瑕佸鏍哥殑琛�!'); + let auditStatus = Object.keys(rows[0]).find(x => { return x.toLowerCase() === 'auditstatus' }); + if (!auditStatus) { + return this.$message.error(`琛ㄥ繀椤诲寘鎷鏍稿瓧娈点�怉uditStatus銆�,骞朵笖鏄痠nt绫诲瀷`) + } + // let checkStatus = rows.every((x) => { + // return this.$global.audit.status.some(c => { return c === x[auditStatus] || !x[auditStatus] }) + // }); + // if (!checkStatus) return this.$error('鍙兘閫夋嫨寰呭鎵规垨瀹℃牳涓殑鏁版嵁!'); + this.$refs.audit.open(rows); + }, + saveAudit(params, rows, callback) { + + //淇濆瓨瀹℃牳 + let keys = rows.map(x => { return x[this.table.key] }); + if (!this.auditBefore(keys, rows)) { + return; + } + let url = `${this.getUrl(this.const.AUDIT)}?auditReason=${params.reason}&auditStatus=${params.value}` + this.http.post(url, keys, '瀹℃牳涓�....').then((x) => { + if (!this.auditAfter(x, keys)) { + return; + } + if (!x.status) return this.$error(x.message); + + callback && callback(x); + this.$success(x.message); + this.refresh(); + }); + }, + viewModelCancel() { + //鏌ョ湅琛ㄧ粨鏋� + this.viewModel = false; + }, + initFormOptions(formOptions, keys, formFields, isEdit) { + //鍒濆鍖栨煡璇€�佺紪杈戝璞$殑涓嬫媺妗嗘暟鎹簮銆佸浘鐗囦笂浼犻摼鎺ュ湴鍧� + //let defaultOption = { key: "", value: "璇烽�夋嫨" }; + //鏈変笂浼犵殑瀛楁 + //2020.05.03鏂板 + //缂栬緫鏁版嵁婧愮殑绫诲瀷 + formOptions.forEach((item) => { + item.forEach((d) => { + if (d.type == 'number') { + //2022.08.22浼樺寲琛ㄥ崟绫诲瀷涓簄umber鏃剁殑榛樿鍊� + if (formFields[d.field] === '') { + formFields[d.field] = undefined; + } + this.numberFields.push(d.field); + } + if ( + d.type == 'img' || + d.type == 'excel' || + d.type == 'file' || + d.columnType == 'img' + ) { + d.url = this.http.ipAddress + 'api' + this.table.url + 'Upload'; + this.uploadfiled.push(d.field); + } + if (!d.dataKey) return true; + //2022.02.20寮哄埗寮�鍚仈绾у彲浠ラ�夋嫨鏌愪釜鑺傜偣 + if (d.type == 'cascader' && !d.hasOwnProperty('changeOnSelect')) { + //寮哄埗寮�鍚仈绾у彲浠ラ�夋嫨鏌愪釜鑺傜偣 + d.changeOnSelect = true; + } + //寮�鍚繙绋嬫悳绱� + if (d.remote) { + this.remoteKeys.push(d.dataKey); + d.data = []; //{ dicNo: d.dataKey, data: [] }; + return true; + } + //2020.05.03澧炲姞缂栬緫琛ㄥ崟瀵筩heckbox鐨勬敮鎸� + if (d.type == 'checkbox' && !(formFields[d.field] instanceof Array)) { + formFields[d.field] = []; + } + if (keys.indexOf(d.dataKey) == -1) { + //2020.05.03澧炲姞璁板綍缂栬緫瀛楁鐨勬暟鎹簮绫诲瀷 + + keys.push(d.dataKey); + //2020.05.03淇鏌ヨ琛ㄥ崟涓庣紪杈戣〃鍗晅ype绫诲瀷鍙樻垚寮轰竴鑷存�х殑闂 + //this.dicKeys.push({ dicNo: d.dataKey, data: [], type: d.type }); + // 2020.11.01澧炲姞iview缁勪欢Cascader鏁版嵁婧愬瓨鍌� + let _dic = { + dicNo: d.dataKey, + data: [], + fileds: [d.field], + orginData: [] + }; + if (d.type == 'cascader') { + _dic.type = 'cascader'; + } + if (isEdit) { + _dic['e_type'] = d.type; + } + this.dicKeys.push(_dic); + } else if (d.type == 'cascader') { + this.dicKeys.forEach((x) => { + if (x.dicNo == d.dataKey) { + x.type = 'cascader'; + x.fileds.push(d.field); + } + }); + } + if (d.type != 'cascader') { + //2020.01.30绉婚櫎鍐呴儴琛ㄥ崟formOptions鏁版嵁婧愰厤缃牸寮廳ata.data锛屾墍鏈夊弬鏁版敼涓轰笌缁勪欢api鏍煎紡鐩稿悓 + Object.assign( + d, + this.dicKeys.filter((f) => { + return f.dicNo == d.dataKey; + })[0], + { type: d.type } + ); + } + }); + }); + }, + //鍒濆table涓庢槑缁嗚〃鐨勬暟鎹簮鎸囧悜dicKeys瀵硅薄锛屽啀鍘诲悗鍙板姞杞芥暟鎹簮 + initColumns(scoure, dicKeys, keys) { + if (!scoure || !(scoure instanceof Array)) return; + scoure.forEach((item) => { + if (!item.bind || (item.bind.data && item.bind.data.length > 0)) + return true; + let key = item.bind.key || item.bind.dicNo; + if (this.remoteKeys.indexOf(key) != -1) { + item.bind.remote = true; + return true; + } + if (this.hasKeyField.indexOf(item.field) == -1) { + this.hasKeyField.push(item.field); + } + var dic = dicKeys.filter((x) => { + return x.dicNo == key; + }); + if (!dic || dic.length == 0) { + dicKeys.push({ dicNo: key, data: [] }); + dic = [dicKeys[dicKeys.length - 1]]; + keys.push(key); + } + //2020.11.01澧炲姞绾ц仈澶勭悊 + if (dic[0].type == 'cascader' || dic[0].type == 'treeSelect') { + item.bind = { data: dic[0].orginData, type: 'select', key: key }; + } else { + item.bind = dic[0]; + } + //2020.05.03浼樺寲table鏁版嵁婧恈heckbox涓巗elect绫诲瀷浠庣紪杈戝垪涓�夊彇 + item.bind.type = item.bind.e_type || 'string'; + }); + }, + bindOptions(dic) { + //缁戝畾涓嬫媺妗嗙殑鏁版嵁婧� + //缁戝畾鍚庡彴鐨勫瓧鍏告暟鎹� + dic.forEach((d) => { + if (d.data.length >= (this.select2Count || 500)) { + if ( + !this.dicKeys.some((x) => { + return ( + x.dicNo == d.dicNo && + (x.type == 'cascader' || x.type == 'treeSelect') + ); + }) + ) { + d.data.forEach((item) => { + item.label = item.value; + item.value = item.key; + }); + } + } + this.dicKeys.forEach((x) => { + if (x.dicNo != d.dicNo) return true; + //2020.10.26澧炲姞绾ц仈鏁版嵁婧愮粦瀹氬鐞� + if (x.type == 'cascader' || x.type == 'treeSelect') { + // x.data=d.data; + //鐢熸垚tree缁撴瀯 + let _data = JSON.parse(JSON.stringify(d.data)); + //2022.04.04澧炲姞绾ц仈瀛楀吀鏁版嵁婧愬埛鏂板悗table娌℃湁鍙樺寲鐨勯棶棰� + this.columns.forEach((column) => { + if (column.bind && column.bind.key == d.dicNo) { + column.bind.data = d.data; + } + }); + let arr = this.base.convertTree(_data, (node, data, isRoot) => { + if (!node.inited) { + node.inited = true; + node.label = node.value; + node.value = node.key; + } + }); + x.data.push(...arr); + x.orginData.push(...d.data); + //2021.10.17淇鏌ヨ绾ц仈涓嶈兘缁戝畾鏁版嵁婧愮殑闂 + this.searchFormOptions.forEach((searhcOption) => { + searhcOption.forEach((_option) => { + if (_option.type == 'cascader' && _option.dataKey == x.dicNo) { + _option.data = arr; + _option.orginData = d.data; + } + }); + }); + //2021.10.17淇绾ц仈涓嶈兘浜岀骇鍒锋柊鐨勯棶棰� + this.editFormOptions.forEach((editOption) => { + editOption.forEach((_option) => { + if ( + (_option.type == 'cascader' || _option.type == 'treeSelect') && + _option.dataKey == x.dicNo + ) { + _option.data = arr; + _option.orginData = d.data; + } + }); + }); + } else if (d.data.length > 0 && !d.data[0].hasOwnProperty('key')) { + let source = d.data, + newSource = new Array(source.length); + for (let index = 0; index < source.length; index++) { + newSource[index] = { + //榛樿浠庡瓧鍏告暟鎹鍑烘潵鐨刱ey閮芥槸string绫诲瀷,浣嗗鏋滄暟鎹粠sql涓煡璇㈢殑鍙兘涓洪潪string,鍚︽槸async-validator闇�瑕侀噸缃缃牸寮� + key: source['key'] + '', //source[index][x.config.valueField] + "", + value: source['value'] //source[index][x.config.textField] + }; + } + + x.data.push(...newSource); + } else { + //2020.06.06锛屽鏋滄槸selectList鏁版嵁婧愪娇鐢ㄧ殑鑷畾涔塻ql骞朵笖key鏄暟瀛楋紝寮哄埗杞崲鎴愬瓧绗︿覆 + if ( + x.e_type == 'selectList' && + d.data.length > 0 && + typeof d.data[0].key == 'number' + ) { + d.data.forEach((c) => { + c.key = c.key + ''; + }); + } + x.data.push(...d.data); + } + if ( + this.singleSearch && + this.singleSearch.dataKey && + this.singleSearch.dataKey == x.dicNo + ) { + this.singleSearch.data.splice(0, 1, ...x.data); + } + }); + }); + }, + getUrl(action, ingorPrefix) { + //鏄惁蹇界暐鍓嶇紑/ 鑾峰彇鎿嶄綔鐨剈rl + return (!ingorPrefix ? '/' : '') + 'api' + this.table.url + action; + }, + + initDicKeys() { + //鍒濆鍖栧瓧鍏告暟鎹� + let keys = []; + //2022.04.17浼樺寲閲嶆柊鍔犺浇鏁版嵁婧� + this.dicKeys.forEach((item) => { + item.data.splice(0); + item.orginData && item.orginData.splice(0); + }); + //this.dicKeys.splice(0); + //鍒濆鍖栫紪杈戞暟鎹簮,榛樿涓轰竴涓┖鏁扮粍锛屽鏋滆姹傚繀濉缃畉ype=number/decimal鐨勬渶灏忓�� + this.initFormOptions(this.editFormOptions, keys, this.editFormFields, true); + //鍒濆鍖栨煡璇㈡暟鎹簮,榛樿涓轰竴涓┖鏁扮粍 + this.initFormOptions( + this.searchFormOptions, + keys, + this.searchFormFields, + false + ); + //鏌ヨ鏃ユ湡璁剧疆涓哄彲閫夊紑濮嬩笌缁撴灉鏃ユ湡 + this.searchFormOptions.forEach((item) => { + item.forEach((x) => { + if (x.type == 'date' || x.type == 'datetime') x.range = true; + }); + }); + //鍒濆鍖杁atatable琛ㄦ暟鎹簮,榛樿涓轰竴涓┖鏁扮粍,dicKeys涓虹晫闈㈡墍鏈夌殑鏁版嵁瀛楀吀缂栧彿 + this.initColumns(this.columns, this.dicKeys, keys); + //2021.05.23榛樿寮�鍚煡璇㈤〉闈㈡墍鏈夊瓧娈垫帓搴�,濡傛灉涓嶉渶瑕佹帓搴忥紝鍦╫nInited閬嶅巻columns璁剧疆sort=false + //2021.09.25绉婚櫎寮哄埗鎺掑簭鍔熻兘 + // this.columns.forEach(x => { + // x.sort = x.render ? false : true; + // }) + if (this.detailOptions && this.detailOptions.columns) { + this.initColumns(this.detailOptions.columns, this.dicKeys, keys); + } + //鍒濆鍖栧揩閫熸煡璇㈠瓧娈�,榛樿浣跨敤浠g爜鐢熸垚鍣ㄩ厤缃殑绗竴涓煡璇㈠瓧娈� + if (this.searchFormOptions.length > 0) { + this.singleSearch = { + dataKey: this.searchFormOptions[0][0].dataKey, + dicNo: this.searchFormOptions[0][0].dicNo, + field: this.searchFormOptions[0][0].field, + title: this.searchFormOptions[0][0].title, + type: this.searchFormOptions[0][0].type, + data: [] + }; + // this.singleSearch = this.searchFormOptions[0][0]; + } + if (keys.length == 0) return; + let $this = this; + this.http.post('/api/Sys_Dictionary/GetVueDictionary', keys).then((dic) => { + + $this.bindOptions(dic); + //2022.04.04澧炲姞瀛楀吀鍔犺浇瀹屾垚鏂规硶 + $this.dicInited && $this.dicInited(dic); + }); + }, + setFiexdColumn(columns, containerWidth) { + //璁$畻鏁翠釜table鐨勫搴︼紝鏍规嵁瀹藉害鍐冲畾鏄惁鍚敤绗竴琛屾樉绀虹殑鍒椾负鍥哄畾鍒� + //2021.09.21绉婚櫎寮哄埗鍥哄畾绗竴鍒� + // let columnsWidth = 0; + // columns.forEach(x => { + // if (!x.hidden && x.width) { + // columnsWidth += x.width; + // } + // }); + // //鍚敤绗竴鍒椾负鍥哄畾鍒� + // if (columnsWidth > containerWidth) { + // let firstColumn = columns.find(x => !x.hidden); + // if (firstColumn) { + // firstColumn.fixed = true; + // } + // } + }, + initBoxHeightWidth() { + //鍒濆鍖栧脊鍑烘鐨勯珮搴︿笌瀹藉害 + let clientHeight = document.documentElement.clientHeight; + //寮瑰嚭妗嗛珮搴﹁嚦灏�250px + clientHeight = clientHeight < 250 ? 250 : clientHeight; + let clientWidth = document.documentElement.clientWidth; + if ( + this.editFormOptions.some((x) => { + return x.some((item) => { + return item.type == 'editor'; + }); + }) + ) { + this.editor.uploadImgUrl = this.getUrl('upload'); + this.boxOptions.height = clientHeight * 0.8; + this.boxOptions.width = clientWidth * 0.8; + } else { + if (this.boxOptions.height) { + //濡傛灉楂樺害涓庡搴﹁秴杩囦簡鑾峰彇鍒扮殑鍙楂樺搴︼紝鍒欒涓洪粯璁ょ殑90%楂樺 + if (this.boxOptions.height > clientHeight * 0.8) { + this.boxOptions.height = clientHeight * 0.8; + } + } + if (this.boxOptions.width) { + //濡傛灉楂樺害涓庡搴﹁秴杩囦簡鑾峰彇鍒扮殑鍙楂樺搴︼紝鍒欒涓洪粯璁ょ殑90%楂樺 + if (this.boxOptions.width > clientWidth * 0.8) { + this.boxOptions.width = clientWidth * 0.8; + } + } + } + //璁$畻鏁翠釜table鐨勫搴︼紝鏍规嵁瀹藉害鍐冲畾鏄惁鍚敤绗竴琛屾樉绀虹殑鍒椾负鍥哄畾鍒� + let maxTableWidth = clientWidth - 270; + this.setFiexdColumn(this.columns, maxTableWidth); + + this.height = this.tableHeight || clientHeight - 206; + this.url = this.getUrl(this.const.PAGE); + //璁$畻寮瑰嚭妗嗙殑楂樹笌瀹藉害 + //濡傛灉鏈夋槑缁嗚〃锛岄珮搴︿笌瀹藉甫璁剧疆涓�0.9/0.82 + if (this.detail.columns && this.detail.columns.length > 0) { + this.hasDetail = true; + clientWidth = clientWidth * 0.8; + clientHeight = clientHeight * 0.85; + if (!this.detailOptions.height) { + this.detailOptions.height = + clientHeight - this.editFormOptions.length * 36 - 234; + this.detailOptions.height = + this.detailOptions.height < 240 ? 240 : this.detailOptions.height; + } + + this.detailOptions.columns = this.detail.columns; + this.detailOptions.pagination.sortName = this.detail.sortName; + this.detailOptions.cnName = this.detail.cnName; + this.detailOptions.key = this.detail.key; + this.detailOptions.url = this.getUrl('getDetailPage'); + //璁$畻寮瑰嚭妗嗘暣涓猼able鐨勫搴︼紝鏍规嵁瀹藉害鍐冲畾鏄惁鍚敤绗竴琛屾樉绀虹殑鍒椾负鍥哄畾鍒� + this.setFiexdColumn(this.detail.columns, clientWidth); + } else { + let maxColumns = 1; //鏈�澶у垪鏁帮紝鏍规嵁鍒楄绠楀脊妗嗙殑瀹藉害 + this.editFormOptions.forEach((x) => { + if (x.length > maxColumns) maxColumns = x.length; + }); + let maxHeightRate = 0.7, + maxWidthRate = 0.5; + maxWidthRate = maxColumns / 10 + 0.3; + maxHeightRate = (this.editFormOptions.length || 1) * 0.1 + 0.03; + maxHeightRate = maxHeightRate > 0.9 ? 0.9 : maxHeightRate; + clientWidth = clientWidth * maxWidthRate; + clientHeight = clientHeight * maxHeightRate; + // this.boxOptions.width = clientWidth * maxWidthRate; + // this.boxOptions.height = clientHeight * maxHeightRate; + } + if (!this.boxOptions.height) { + this.boxOptions.height = clientHeight + 10; + } + if (!this.boxOptions.width) { + this.boxOptions.width = clientWidth + 30; + } + }, + rowOnChange(row) { + this.rowChange(row); + }, + rowChange(row) { + //閫変腑琛宑heckbox琛屼簨浠� + }, + rowOnClick({ row, column, event }) { + this.rowClick({ row, column, event }); + }, + rowClick({ row, column, event }) { + // 鐐瑰嚮琛屼簨浠�(2020.11.07) + }, + rowOnDbClick({ row, column, event }) { + this.rowDbClick({ row, column, event }); + }, + rowDbClick({ row, column, event }) { + // 鍙屽嚮鍑昏浜嬩欢(2021.05.23) + }, + $error(message) { + this.$message.error(message); + // this.$message({ + // type: 'error', + // content: message, + // duration: 5 + // }); + }, + $success(message) { + this.$message.success(message); + }, + setFiexdSearchForm(visiable) { + //2020.09.011澧炲姞鍥哄畾鏌ヨ琛ㄥ崟鍔熻兘,visiable=true榛樿灏嗘煡璇㈣〃鍗曞睍寮� + this.fiexdSearchForm = true; + let refreshBtn = this.buttons.find((x) => x.name == '鍒� 鏂�'); + if (visiable) { + this.searchBoxShow = true; + } + if (refreshBtn) { + refreshBtn.name = '閲� 缃�'; + refreshBtn.onClick = function () { + this.resetSearch(); + }; + } + }, + tableBeginEdit(row, column, index) { + //2021.03.19鏄惁寮�鍚煡璇㈢晫闈㈣〃鏍煎弻鍑荤紪杈戠粨鏉熸柟娉�,杩斿洖false涓嶄細缁撴潫缂栬緫 + return this.beginEdit(row, column, index); + }, + beginEdit(row, column, index) { + //2021.03.19鏄惁寮�鍚煡璇㈢晫闈㈣〃鏍煎弻鍑荤紪杈戠粨鏉熸柟娉�,杩斿洖false涓嶄細缁撴潫缂栬緫 + return true; + }, + tableEndEditBefore(row, column, index) { + return this.endEditBefore(row, column, index); + }, + endEditBefore(row, column, index) { + //2021.03.19鏄惁寮�鍚煡璇㈢晫闈㈣〃鏍煎弻鍑荤紪杈戠粨鏉熸柟娉�,杩斿洖false涓嶄細缁撴潫缂栬緫 + return true; + }, + filterPermission(tableName, permission) { + //2021.03.19鍒ゆ柇鏄惁鏈夋煇涓〃鐨勬寜閽潈闄� + //:["Search","Add","Delete","Update","Import","Export","Upload","Audit"] + const _result = (this.$store.state.permission || []).find((x) => { + return x.url == '/' + tableName; + }); + return _result && _result.permission.some((x) => x == permission); + }, + destroyed() { + //2021.04.11澧炲姞vue椤甸潰閿�姣佹柟娉�,璺敱蹇呴』璁剧疆keepLive:false锛岃缃柟娉曡锛氬墠绔紑鍙戞枃妗�-銆媅绂佺敤椤甸潰缂撳瓨keepAlive] + }, + loadTreeTableChildren(tree, treeNode, resolve) { + this.loadTreeChildren.call(this, tree, treeNode, resolve); + }, + loadTreeChildren(tree, treeNode, resolve) { + //鏍戝舰缁撴瀯鍔犺浇瀛愯妭鐐�(2021.05.02),鍦╫nInit涓缃簡rowKey涓婚敭瀛楁鍚庢墠浼氱敓鏁� + return resolve([]); + }, + importDetailAfter(data) { + //2022.01.08澧炲姞鏄庣粏琛ㄥ鍏ュ悗澶勭悊 + }, + importExcelAfter(data) { + //2022.01.08澧炲姞鏄庣粏琛ㄥ鍏ュ悗鏂规硶鍒ゆ柇 + + if (!data.status) { + return; // this.$message.error(data.message); + } + //鏄庣粏琛ㄥ鍏� + if (this.boxModel) { + if (data.data) { + data.data = JSON.parse(data.data); + } else { + data.data = []; + } + data.data.forEach((x) => { + x[this.detail.key] = undefined; + x[this.table.key] = undefined; + }); + this.importDetailAfter(data); //澧炲姞鏄庣粏琛ㄥ鍏ュ悗澶勭悊 + this.$refs.detail.rowData.unshift(...data.data); + this.upload.excel = false; + return; + } + this.importAfter(data); + }, + onGridModelClose(iconClick) { + if (this.isBoxAudit) { + this.initFormOptionType(false); + } + this.isBoxAudit = false; + this.onModelClose(iconClick); + }, + initAuditColumn() { + + }, + getWorkFlowSteps(row) { + let table = this.table.url.replaceAll('/', ''); + let url = `api/Sys_WorkFlow/getSteps?tableName=${table}&id=${row[this.table.key] + }`; + this.http.get(url, {}, true).then((result) => { + this.workFlowSteps.splice(0); + //鏈夊彲鑳芥病鏈夐厤缃鎵规祦绋� + if (!result.list || !result.list.length) { + result.list = []; + this.auditParam.showAction = true; + this.auditParam.height = 240; + this.auditParam.showViewButton = row.AuditStatus == 0; + } else { + this.auditParam.showAction = result.list.some((c) => { + return c.isCurrentUser; + }); + this.auditParam.height = 511; + this.auditParam.showViewButton = true; + } + this.auditParam.reason = ''; + this.auditParam.status = -1; + this.auditParam.value = -1; + if (result.his) { + result.his.forEach((item) => { + item.auditStatus = this.getAuditStatus(item.auditStatus); + }); + } + + this.auditParam.auditHis = result.his; + this.workFlowSteps.push(...result.list); + this.isBoxAudit = true; + this.initFormOptionType(true); + this.edit(row); + this.boxOptions.title = '瀹℃牳'; + }); + }, + initFormOptionType(isReadonly) { + this.editFormOptions.forEach((options) => { + options.forEach((option) => { + if (isReadonly) { + if (!option.readonly) { + this.formFieldsType.push(option.field); + option.readonly = true; + } + } else { + if (this.formFieldsType.indexOf(option.field) != -1) { + option.readonly = false; + } + } + }); + }); + }, + getAuditStatus(status) { + let data = this.auditParam.data.find((x) => { + return x.value == status; + }); + if (!data) { + return '-'; + // return `瀹℃牳鍊间笉姝g‘:${status}` + } + return data.text; + }, + initFlowQuery() { + if (this.$route.query.viewflow) { + this.$refs.table && this.search(); + } + }, + fullscreen(full) { //寮瑰嚭妗嗗叏灞忔柟娉� + + } +}; +import customColumns from './ViewGridCustomColumn.js'; +//鍚堝苟鎵╁睍鏂规硶 +methods = Object.assign(methods, detailMethods, serviceFilter, customColumns); +export default methods; diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue b/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue index 3279d39..ec01ee7 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue +++ b/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue @@ -22,8 +22,7 @@ <!-- 2020.10.10绉婚櫎table绗竴琛屽己鍒舵帓搴� --> <el-table-column v-for="(column, cindex) in filterColumns" :prop="column.field" :label="column.title" :min-width="column.width" :formatter="formatter" :fixed="column.fixed" :key="column.field + cindex" - :align="column.align" :sortable="column.sort ? 'custom' : false" - :show-overflow-tooltip="column.showOverflowTooltip"> + :align="column.align" :sortable="column.sort ? 'custom' : false" :show-overflow-tooltip=true> <template #header> <span v-if="(column.require || column.required) && column.edit" class="column-required">*</span>{{ column.title }} @@ -103,7 +102,7 @@ column.onChange && column.onChange(scope.row, column, val); } - " :type="column.edit.type" :placeholder="column.placeholder || column.title" + " :type="column.edit.type" :placeholder="column.placeholder || column.title" :disabledDate="(val) => getDateOptions(val, column)" :value-format="getDateFormat(column)" :disabled="initColumnDisabled(scope.row, column)"> </el-date-picker> @@ -112,7 +111,7 @@ column.onChange && column.onChange(scope.row, column, val); } - " :placeholder="column.placeholder || column.title" :value-format="column.format || 'HH:mm:ss'" + " :placeholder="column.placeholder || column.title" :value-format="column.format || 'HH:mm:ss'" :disabled="initColumnDisabled(scope.row, column)"> </el-time-picker> <el-switch v-else-if="column.edit.type == 'switch'" v-model="scope.row[column.field]" @@ -120,17 +119,17 @@ inline-prompt @change="(val) => { switchChange(val, scope.row, column); } - " :active-value="typeof scope.row[column.field] == 'boolean' + " :active-value="typeof scope.row[column.field] == 'boolean' ? true : typeof scope.row[column.field] == 'string' ? '1' : 1 " :inactive-value="typeof scope.row[column.field] == 'boolean' - ? false - : typeof scope.row[column.field] == 'string' - ? '0' - : 0 - " :disabled="initColumnDisabled(scope.row, column)"> + ? false + : typeof scope.row[column.field] == 'string' + ? '0' + : 0 + " :disabled="initColumnDisabled(scope.row, column)"> </el-switch> <template v-else-if=" ['select', 'selectList'].indexOf(column.edit.type) != -1 @@ -234,7 +233,7 @@ <div @click="() => { column.click && formatterClick(scope.row, column); } - " v-else-if="column.bind"> + " v-else-if="column.bind"> <el-tag v-if="useTag" class="cell-tag" :class="[isEmptyTag(scope.row, column)]" :type="getColor(scope.row, column)" :effect="column.effect">{{ formatter(scope.row, column, true) }}</el-tag> diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/basicinfo/router.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/basicinfo/router.js new file mode 100644 index 0000000..d907544 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/basicinfo/router.js @@ -0,0 +1,72 @@ + +//姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜 +import gridBody from './extend/routerview.vue'; +import gridHeader from './extend/addrouters.vue'; +let extension = { + components: { + //鏌ヨ鐣岄潰鎵╁睍缁勪欢 + gridHeader: gridHeader, + gridBody: gridBody, + gridFooter: '', + //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢 + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + tableAction: '', //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓) + buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� + methods: { + //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� + onInit() { + var viewButton = this.buttons.find((x) => x.value == "ViewAllRouter"); + if (viewButton) { + viewButton.onClick = ()=>{ + this.$refs.gridBody.open(); + } + } + + var addRoutersButton = this.buttons.find((x) => x.value == "AddRouters"); + if (addRoutersButton) { + addRoutersButton.onClick = ()=>{ + this.$refs.gridHeader.open(); + } + } + }, + onInited() { + //妗嗘灦鍒濆鍖栭厤缃悗 + //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔 + //this.detailOptions.columns.forEach(column=>{ }); + }, + searchBefore(param) { + //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟 + //杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ + return true; + }, + searchAfter(result) { + //鏌ヨ鍚庯紝result杩斿洖鐨勬煡璇㈡暟鎹�,鍙互鍦ㄦ樉绀哄埌琛ㄦ牸鍓嶅鐞嗚〃鏍肩殑鍊� + return true; + }, + addBefore(formData) { + //鏂板缓淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛紝鍙互缁欑粰琛ㄥ崟璁剧疆鍊硷紝鑷繁杈撳嚭鐪媐ormData鐨勫�� + return true; + }, + updateBefore(formData) { + //缂栬緫淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛ㄣ�佸垹闄よ鐨処d + return true; + }, + rowClick({ row, column, event }) { + //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + }, + modelOpenAfter(row) { + //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + //(1)鍒ゆ柇鏄紪杈戣繕鏄柊寤烘搷浣滐細 this.currentAction=='Add'; + //(2)缁欏脊鍑烘璁剧疆榛樿鍊� + //(3)this.editFormFields.瀛楁='xxx'; + //濡傛灉闇�瑕佺粰涓嬫媺妗嗚缃粯璁ゅ�硷紝璇烽亶鍘唗his.editFormOptions鎵惧埌瀛楁閰嶇疆瀵瑰簲data灞炴�х殑key鍊� + //鐪嬩笉鎳傚氨鎶婅緭鍑虹湅锛歝onsole.log(this.editFormOptions) + } + } + }; + export default extension; + \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceInfo.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceInfo.js new file mode 100644 index 0000000..d882861 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceInfo.js @@ -0,0 +1,87 @@ +import gridBody from "./extend/importDevicePro.vue"; +let extension = { + components: { + //鏌ヨ鐣岄潰鎵╁睍缁勪欢 + gridHeader: "", + gridBody: gridBody, + gridFooter: "", + //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢 + modelHeader: "", + modelBody: "", + modelFooter: "", + }, + tableAction: "", //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓) + buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� + methods: { + //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� + onInit() { + // console.log(this.detailOptions.buttons); + // console.log(this.$refs.detail) + var detailImport = this.detailOptions.buttons.find( + (item) => item.value == "import" + ); + if (detailImport) { + detailImport.onClick = function () { + this.$refs.gridBody.open(); + }; + } + this.buttons.unshift({ + //涔熷彲浠ョ敤push鎴栬�卻plice鏂规硶鏉ヤ慨鏀筨uttons鏁扮粍 + name: "寮�鍚湇鍔�", //鎸夐挳鍚嶇О + icon: "el-icon-document", //鎸夐挳鍥炬爣vue2鐗堟湰瑙乮view鏂囨。icon锛寁ue3鐗堟湰瑙乪lement ui鏂囨。icon(娉ㄦ剰涓嶆槸element puls鏂囨。) + type: "primary", //鎸夐挳鏍峰紡vue2鐗堟湰瑙乮view鏂囨。button锛寁ue3鐗堟湰瑙乪lement ui鏂囨。button + onClick: function () { + this.$Message.success("寮�鍚湇鍔�"); + }, + }); + }, + onInited() { + //妗嗘灦鍒濆鍖栭厤缃悗 + //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔 + // this.detailOptions.columns.forEach(column=>{ }); + // console.log(this) + }, + searchBefore(param) { + //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟 + //杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ + return true; + }, + searchAfter(result) { + //鏌ヨ鍚庯紝result杩斿洖鐨勬煡璇㈡暟鎹�,鍙互鍦ㄦ樉绀哄埌琛ㄦ牸鍓嶅鐞嗚〃鏍肩殑鍊� + return true; + }, + addBefore(formData) { + //鏂板缓淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛紝鍙互缁欑粰琛ㄥ崟璁剧疆鍊硷紝鑷繁杈撳嚭鐪媐ormData鐨勫�� + return true; + }, + updateBefore(formData) { + //缂栬緫淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛ㄣ�佸垹闄よ鐨処d + return true; + }, + rowClick({ row, column, event }) { + //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + }, + modelOpenAfter(row) { + //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + //(1)鍒ゆ柇鏄紪杈戣繕鏄柊寤烘搷浣滐細 this.currentAction=='Add'; + //(2)缁欏脊鍑烘璁剧疆榛樿鍊� + //(3)this.editFormFields.瀛楁='xxx'; + //濡傛灉闇�瑕佺粰涓嬫媺妗嗚缃粯璁ゅ�硷紝璇烽亶鍘唗his.editFormOptions鎵惧埌瀛楁閰嶇疆瀵瑰簲data灞炴�х殑key鍊� + //鐪嬩笉鎳傚氨鎶婅緭鍑虹湅锛歝onsole.log(this.editFormOptions) + }, + updated() { + //console.log(this.$refs) + this.$nextTick(() => { + if (this.$refs.upload_excel) { + alert("鐐瑰嚮浜嗕笂浼犳寜閽�"); + this.$refs.upload_excel.upload = function () { + console.log("鐐瑰嚮浜嗕笂浼犳寜閽�"); + }; + } + // alert(1) + }); + }, + }, +}; +export default extension; diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocol.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocol.js new file mode 100644 index 0000000..a39e193 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocol.js @@ -0,0 +1,58 @@ + +//姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜 + +let extension = { + components: { + //鏌ヨ鐣岄潰鎵╁睍缁勪欢 + gridHeader: '', + gridBody: '', + gridFooter: '', + //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢 + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + tableAction: '', //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓) + buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� + methods: { + //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� + onInit() { + }, + onInited() { + //妗嗘灦鍒濆鍖栭厤缃悗 + //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔 + //this.detailOptions.columns.forEach(column=>{ }); + }, + searchBefore(param) { + //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟 + //杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ + return true; + }, + searchAfter(result) { + //鏌ヨ鍚庯紝result杩斿洖鐨勬煡璇㈡暟鎹�,鍙互鍦ㄦ樉绀哄埌琛ㄦ牸鍓嶅鐞嗚〃鏍肩殑鍊� + return true; + }, + addBefore(formData) { + //鏂板缓淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛紝鍙互缁欑粰琛ㄥ崟璁剧疆鍊硷紝鑷繁杈撳嚭鐪媐ormData鐨勫�� + return true; + }, + updateBefore(formData) { + //缂栬緫淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛ㄣ�佸垹闄よ鐨処d + return true; + }, + rowClick({ row, column, event }) { + //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + }, + modelOpenAfter(row) { + //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + //(1)鍒ゆ柇鏄紪杈戣繕鏄柊寤烘搷浣滐細 this.currentAction=='Add'; + //(2)缁欏脊鍑烘璁剧疆榛樿鍊� + //(3)this.editFormFields.瀛楁='xxx'; + //濡傛灉闇�瑕佺粰涓嬫媺妗嗚缃粯璁ゅ�硷紝璇烽亶鍘唗his.editFormOptions鎵惧埌瀛楁閰嶇疆瀵瑰簲data灞炴�х殑key鍊� + //鐪嬩笉鎳傚氨鎶婅緭鍑虹湅锛歝onsole.log(this.editFormOptions) + } + } + }; + export default extension; + \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocolDetail.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocolDetail.js new file mode 100644 index 0000000..a39e193 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/deviceProtocolDetail.js @@ -0,0 +1,58 @@ + +//姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜 + +let extension = { + components: { + //鏌ヨ鐣岄潰鎵╁睍缁勪欢 + gridHeader: '', + gridBody: '', + gridFooter: '', + //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢 + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + tableAction: '', //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓) + buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� + methods: { + //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� + onInit() { + }, + onInited() { + //妗嗘灦鍒濆鍖栭厤缃悗 + //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔 + //this.detailOptions.columns.forEach(column=>{ }); + }, + searchBefore(param) { + //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟 + //杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ + return true; + }, + searchAfter(result) { + //鏌ヨ鍚庯紝result杩斿洖鐨勬煡璇㈡暟鎹�,鍙互鍦ㄦ樉绀哄埌琛ㄦ牸鍓嶅鐞嗚〃鏍肩殑鍊� + return true; + }, + addBefore(formData) { + //鏂板缓淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛紝鍙互缁欑粰琛ㄥ崟璁剧疆鍊硷紝鑷繁杈撳嚭鐪媐ormData鐨勫�� + return true; + }, + updateBefore(formData) { + //缂栬緫淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛ㄣ�佸垹闄よ鐨処d + return true; + }, + rowClick({ row, column, event }) { + //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + }, + modelOpenAfter(row) { + //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + //(1)鍒ゆ柇鏄紪杈戣繕鏄柊寤烘搷浣滐細 this.currentAction=='Add'; + //(2)缁欏脊鍑烘璁剧疆榛樿鍊� + //(3)this.editFormFields.瀛楁='xxx'; + //濡傛灉闇�瑕佺粰涓嬫媺妗嗚缃粯璁ゅ�硷紝璇烽亶鍘唗his.editFormOptions鎵惧埌瀛楁閰嶇疆瀵瑰簲data灞炴�х殑key鍊� + //鐪嬩笉鎳傚氨鎶婅緭鍑虹湅锛歝onsole.log(this.editFormOptions) + } + } + }; + export default extension; + \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/dispatchInfo.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/dispatchInfo.js new file mode 100644 index 0000000..a39e193 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/quartzJob/dispatchInfo.js @@ -0,0 +1,58 @@ + +//姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜 + +let extension = { + components: { + //鏌ヨ鐣岄潰鎵╁睍缁勪欢 + gridHeader: '', + gridBody: '', + gridFooter: '', + //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢 + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + tableAction: '', //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓) + buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� + methods: { + //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� + onInit() { + }, + onInited() { + //妗嗘灦鍒濆鍖栭厤缃悗 + //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔 + //this.detailOptions.columns.forEach(column=>{ }); + }, + searchBefore(param) { + //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟 + //杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ + return true; + }, + searchAfter(result) { + //鏌ヨ鍚庯紝result杩斿洖鐨勬煡璇㈡暟鎹�,鍙互鍦ㄦ樉绀哄埌琛ㄦ牸鍓嶅鐞嗚〃鏍肩殑鍊� + return true; + }, + addBefore(formData) { + //鏂板缓淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛紝鍙互缁欑粰琛ㄥ崟璁剧疆鍊硷紝鑷繁杈撳嚭鐪媐ormData鐨勫�� + return true; + }, + updateBefore(formData) { + //缂栬緫淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛ㄣ�佸垹闄よ鐨処d + return true; + }, + rowClick({ row, column, event }) { + //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + }, + modelOpenAfter(row) { + //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + //(1)鍒ゆ柇鏄紪杈戣繕鏄柊寤烘搷浣滐細 this.currentAction=='Add'; + //(2)缁欏脊鍑烘璁剧疆榛樿鍊� + //(3)this.editFormFields.瀛楁='xxx'; + //濡傛灉闇�瑕佺粰涓嬫媺妗嗚缃粯璁ゅ�硷紝璇烽亶鍘唗his.editFormOptions鎵惧埌瀛楁閰嶇疆瀵瑰簲data灞炴�х殑key鍊� + //鐪嬩笉鎳傚氨鎶婅緭鍑虹湅锛歝onsole.log(this.editFormOptions) + } + } + }; + export default extension; + \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Dictionary.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Dictionary.js new file mode 100644 index 0000000..e37ecf6 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Dictionary.js @@ -0,0 +1,65 @@ +import { h, resolveComponent } from 'vue'; +let extension = { + components: { //鍔ㄦ�佹墿鍏呯粍浠舵垨缁勪欢璺緞 + //琛ㄥ崟header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + //鎵╁睍缁勪欢寮曞叆鏂瑰紡 + gridHeader: '', + gridBody: '', + gridFooter: '', + //寮瑰嚭妗�(淇敼銆佺紪杈戙�佹煡鐪�)header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + buttons: [], //鎵╁睍鐨勬寜閽� + methods: { //浜嬩欢鎵╁睍 + onInit() { + //鐐瑰嚮鍗曞厓鏍肩紪杈戜笌缁撴潫缂栬緫(榛樿鏄偣鍑诲崟鍏冩牸缂栬緫锛岄紶鏍囩寮�缁撴潫缂栬緫) + this.detailOptions.clickEdit = true; + this.editFormOptions.forEach(x => { + x.forEach(item => { + if (item.field == 'ParentId') { + item.min = 0; + } + if (item.field == "DbSql") { + item.placeholder = "濡傛灉浠庢暟鎹簱鍔犺浇鏁版嵁婧愶紝璇锋寜姝ゆ牸寮忛厤缃畇ql璇彞锛歴elect orderType as key,orderName as value from order 濡傛灉闇�瑕佹牴鎹敤鎴蜂俊鎭姞杞芥暟鎹簮锛岃閰嶇疆濂芥sql,鍐嶄慨鏀瑰悗鍙癉ictionaryHandler.GetCustomDBSql鏂规硶"; + } + }) + }) + this.detailOptions.columns.forEach(x => { + if (x.field == 'OrderNo') { + x.summary = true; + } + }) + //淇濆瓨鍚庝笉鍏抽棴缂栬緫妗� + this.boxOptions.saveClose = false; + }, + onInited() { + this.boxOptions.height = document.body.clientHeight * 0.87 + this.height = this.height - 45; + }, + addBefore(formData) { + return this.saveBefore(formData); + }, + updateBefore(formData) { + return this.saveBefore(formData); + }, + saveBefore(formData) { + if (this.editFormFields.DbSql && + (this.editFormFields.DbSql.indexOf('value') == -1 || + this.editFormFields.DbSql.indexOf('key') == -1) + ) { + this.$message.error("sql璇彞蹇呴』鍖呮嫭key/value瀛楁,濡�:select orderType as key,orderName as value from order"); + return false; + } + return true; + }, + searchBefore(param) { + return true; + }, + searchAfter(result) { + return true; + } + } +}; +export default extension; \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_DictionaryList.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_DictionaryList.js new file mode 100644 index 0000000..da94487 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_DictionaryList.js @@ -0,0 +1,22 @@ + + +let extension = { + components: {//鍔ㄦ�佹墿鍏呯粍浠舵垨缁勪欢璺緞 + //琛ㄥ崟header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + gridHeader:'', + gridbody:'', + gridFooter: '', + //寮瑰嚭妗�(淇敼銆佺紪杈戙�佹煡鐪�)header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + buttons: [],//鎵╁睍鐨勬寜閽� + methods: {//浜嬩欢鎵╁睍 + onInit() { + }, + onInited() { + } + } +}; +export default extension; \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Log.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Log.js new file mode 100644 index 0000000..5b05c40 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Log.js @@ -0,0 +1,26 @@ +import { h, resolveComponent } from 'vue'; +let extension = { + components: { + //鍔ㄦ�佹墿鍏呯粍浠舵垨缁勪欢璺緞 + //琛ㄥ崟header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + gridHeader: "", //{ template: "<div>鎵╁睍缁剎x浠�</div>" }, + gridBody: '', + gridFooter: "", + //寮瑰嚭妗�(淇敼銆佺紪杈戙�佹煡鐪�)header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + modelHeader: "", + modelBody: "", + modelFooter: "" + }, + buttons: [], //鎵╁睍鐨勬寜閽� + methods: { + //浜嬩欢鎵╁睍 + onInit() { + console.log("sys_log") + this.setFiexdSearchForm(true); + }, + onInited() { + this.height = this.height - 170; + } + } +}; +export default extension; diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role.js new file mode 100644 index 0000000..5ba4845 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role.js @@ -0,0 +1,49 @@ + +let extension = { + components: {//鍔ㄦ�佹墿鍏呯粍浠舵垨缁勪欢璺緞 + //琛ㄥ崟header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + gridHeader: '', + gridBody: '', + gridFooter: '', + //寮瑰嚭妗�(淇敼銆佺紪杈戙�佹煡鐪�)header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + buttons: [],//鎵╁睍鐨勬寜閽� + tableAction:"Sys_Role", + methods: {//浜嬩欢鎵╁睍 + onInited () { + this.height = this.height - 80; + this.editFormOptions.forEach(x => { + x.forEach(item => { + if (item.field == 'ParentId') { + item.title = "涓婄骇瑙掕壊"; + //璁剧疆浠绘剰鑺傜偣閮借兘閫変腑(榛樿鍙兘閫変腑鏈�鍚庝竴涓妭鐐�) + item.changeOnSelect = true; + } + }) + }) + }, + onInit() { + //璁剧疆treetable鐨勫敮涓�鍊煎瓧娈�(杩欎釜瀛楁鐨勫�煎湪琛ㄩ噷闈㈠繀椤绘槸鍞竴鐨�) + this.rowKey="Role_Id"; + }, + /***鍔犺浇鍚庡彴鏁版嵁瑙丼ys_RoleController.cs鏂囦欢***/ + loadTreeChildren(tree, treeNode, resolve) { //鍔犺浇瀛愯妭鐐� + let url=`api/role/getTreeTableChildrenData?roleId=${tree.Role_Id}`; + this.http.post(url,{}).then(result=>{ + resolve(result.rows) + }) + }, + /***鍔犺浇鍚庡彴鏁版嵁瑙丼ys_RoleController.cs鏂囦欢***/ + searchBefore(params){//鍒ゆ柇鍔犺浇鏍硅妭鐐规垨瀛愯妭鐐� + //娌℃湁鏌ヨ鏉′欢锛岄粯璁ゆ煡璇㈣繑鍥炴墍鏈夋牴鑺傜偣鏁版嵁 + if (!params.wheres.length) { + params.value=1; + } + return true; + } + } +}; +export default extension; diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role1.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role1.js new file mode 100644 index 0000000..d6715be --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_Role1.js @@ -0,0 +1,61 @@ + +import { h, resolveComponent } from 'vue'; +let extension = { + components: {//鍔ㄦ�佹墿鍏呯粍浠舵垨缁勪欢璺緞 + //琛ㄥ崟header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + gridHeader: '', + gridBody: { + render () { + return [ + h(resolveComponent('el-alert'), { + style: { 'margin-bottom': '12px' }, + 'show-icon': true, type: 'error', + closable: false, title: '鍏充簬TreeTable浣跨敤' + }, ' treetable鍚屾牱鍏ㄩ儴浠g爜鑷姩鐢熸垚锛岄〉闈㈢敓鎴愬悗璁剧疆this.rowKe="xxx" tree涓婚敭瀛楁,鍗冲彲瀹屾垚鏍戝舰table閰嶇疆,鍏蜂綋璇存槑瑙丼ys_Role1.js'), + ] + } + }, + + gridFooter: '', + //寮瑰嚭妗�(淇敼銆佺紪杈戙�佹煡鐪�)header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + buttons: [],//鎵╁睍鐨勬寜閽� + tableAction:"Sys_Role", + methods: {//浜嬩欢鎵╁睍 + onInited () { + this.height = this.height - 80; + this.editFormOptions.forEach(x => { + x.forEach(item => { + if (item.field == 'ParentId') { + item.title = "涓婄骇瑙掕壊"; + //璁剧疆浠绘剰鑺傜偣閮借兘閫変腑(榛樿鍙兘閫変腑鏈�鍚庝竴涓妭鐐�) + item.changeOnSelect = true; + } + }) + }) + }, + onInit() { + //璁剧疆treetable鐨勫敮涓�鍊煎瓧娈�(杩欎釜瀛楁鐨勫�煎湪琛ㄩ噷闈㈠繀椤绘槸鍞竴鐨�) + this.rowKey="Role_Id"; + }, + /***鍔犺浇鍚庡彴鏁版嵁瑙丼ys_RoleController.cs鏂囦欢***/ + loadTreeChildren(tree, treeNode, resolve) { //鍔犺浇瀛愯妭鐐� + let url=`api/role/getTreeTableChildrenData?roleId=${tree.Role_Id}`; + this.http.post(url,{}).then(result=>{ + resolve(result.rows) + }) + }, + /***鍔犺浇鍚庡彴鏁版嵁瑙丼ys_RoleController.cs鏂囦欢***/ + searchBefore(params){//鍒ゆ柇鍔犺浇鏍硅妭鐐规垨瀛愯妭鐐� + //娌℃湁鏌ヨ鏉′欢锛岄粯璁ゆ煡璇㈣繑鍥炴墍鏈夋牴鑺傜偣鏁版嵁 + if (!params.wheres.length) { + params.value=1; + } + return true; + } + } +}; +export default extension; diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_User.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_User.js new file mode 100644 index 0000000..4be7155 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/system/Sys_User.js @@ -0,0 +1,86 @@ +import { defineAsyncComponent } from "vue"; +let extension = { + components: { //鍔ㄦ�佹墿鍏呯粍浠舵垨缁勪欢璺緞 + //琛ㄥ崟header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + gridHeader: defineAsyncComponent(() => + import("./Sys_User/Sys_UserGridHeader.vue")), + gridBody: '', + gridFooter: '', + //寮瑰嚭妗�(淇敼銆佺紪杈戙�佹煡鐪�)header銆乧ontent銆乫ooter瀵瑰簲浣嶇疆鎵╁厖鐨勭粍浠� + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + text: "鍙兘鐪嬪埌褰撳墠瑙掕壊涓嬬殑鎵�鏈夊笎鍙�", + buttons: [], //鎵╁睍鐨勬寜閽� + methods: { //浜嬩欢鎵╁睍 + onInit() { + this.boxOptions.height = 530; + this.columns.push({ + title: '鎿嶄綔', + hidden: false, + align: "center", + fixed: 'right', + width: 120, + render: (h, { row, column, index }) => { + return h( + "div", { style: { 'font-size': '13px', 'cursor': 'pointer', 'color': '#409eff' } }, [ + h( + "a", { + style: { 'margin-right': '15px' }, + onClick: (e) => { + e.stopPropagation() + this.$refs.gridHeader.open(row); + } + }, "淇敼瀵嗙爜" + ), + h( + "a", { + style: {}, + onClick: (e) => { + e.stopPropagation() + this.edit(row); + } + }, + "缂栬緫" + ), + ]) + } + }) + }, + onInited() { }, + addAfter(result) { //鐢ㄦ埛鏂板缓鍚庯紝鏄剧ず闅忔満鐢熸垚鐨勫瘑鐮� + if (!result.status) { + return true; + } + //鏄剧ず鏂板缓鐢ㄦ埛鐨勫瘑鐮� + //2020.08.28浼樺寲鏂板缓鎴愬悗鎻愮ず鏂瑰紡 + this.$confirm(result.message, '鏂板缓鐢ㄦ埛鎴愬姛', { + confirmButtonText: '纭畾', + type: 'success', + center: true + }).then(() => { }) + + this.boxModel = false; + this.refresh(); + return false; + }, + modelOpenAfter() { + //鐐瑰嚮寮瑰嚭妗嗗悗锛屽鏋滄槸缂栬緫鐘舵�侊紝绂佹缂栬緫鐢ㄦ埛鍚嶏紝濡傛灉鏂板缓鐘舵�侊紝灏嗙敤鎴峰悕瀛楁璁剧疆涓哄彲缂栬緫 + let isEDIT = this.currentAction == this.const.EDIT; + this.editFormOptions.forEach(item => { + item.forEach(x => { + if (x.field == "UserName") { + x.disabled=isEDIT; + } + }) + //涓嶆槸鏂板缓锛屾�у埆榛樿鍊艰缃负鐢� + if (!isEDIT) { + this.editFormFields.Gender = "0"; + } + }) + } + + } +}; +export default extension; \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/taskinfo/task.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/taskinfo/task.js new file mode 100644 index 0000000..8a02afb --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/taskinfo/task.js @@ -0,0 +1,82 @@ + +//姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜 +import gridBody from './extend/taskExecuteDetail.vue' +let extension = { + components: { + //鏌ヨ鐣岄潰鎵╁睍缁勪欢 + gridHeader: '', + gridBody: gridBody, + gridFooter: '', + //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢 + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + tableAction: '', //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓) + buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� + methods: { + //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� + onInit() { + // this.$Notice.success({ title: this.detailOptions.cnName + ',鏌ヨ缁撴灉', desc: '杩斿洖鐨勫璞★細' + JSON.stringify(data) }); + + var previousButton = this.buttons.find((x) => x.value == "Previous"); + if (previousButton) previousButton.hidden = true; + var nextButton = this.buttons.find((x) => x.value == "Next"); + if (nextButton) nextButton.hidden = true; + var recoveryButton = this.buttons.find((x) => x.value == "TaskRecovery"); + if (recoveryButton) recoveryButton.hidden = true; + + //鎵╁睍椤甸潰鍒濆鍖栨搷浣� + this.columns.push({ + field: '鎿嶄綔', + title: '鎿嶄綔', + width: 70, + fixed: 'right', + align: 'center', + formatter: (row) => { + return ( + '<i style="cursor: pointer;color: #2d8cf0;"class="el-icon-view">鏌ョ湅</i>' + ); + }, + click: (row) => { + this.$refs.gridBody.open(row); + } + }); + }, + onInited() { + //妗嗘灦鍒濆鍖栭厤缃悗 + //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔 + //this.detailOptions.columns.forEach(column=>{ }); + }, + searchBefore(param) { + //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟 + //杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ + return true; + }, + searchAfter(result) { + //鏌ヨ鍚庯紝result杩斿洖鐨勬煡璇㈡暟鎹�,鍙互鍦ㄦ樉绀哄埌琛ㄦ牸鍓嶅鐞嗚〃鏍肩殑鍊� + return true; + }, + addBefore(formData) { + //鏂板缓淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛紝鍙互缁欑粰琛ㄥ崟璁剧疆鍊硷紝鑷繁杈撳嚭鐪媐ormData鐨勫�� + return true; + }, + updateBefore(formData) { + //缂栬緫淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛ㄣ�佸垹闄よ鐨処d + return true; + }, + rowClick({ row, column, event }) { + //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + }, + modelOpenAfter(row) { + //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + //(1)鍒ゆ柇鏄紪杈戣繕鏄柊寤烘搷浣滐細 this.currentAction=='Add'; + //(2)缁欏脊鍑烘璁剧疆榛樿鍊� + //(3)this.editFormFields.瀛楁='xxx'; + //濡傛灉闇�瑕佺粰涓嬫媺妗嗚缃粯璁ゅ�硷紝璇烽亶鍘唗his.editFormOptions鎵惧埌瀛楁閰嶇疆瀵瑰簲data灞炴�х殑key鍊� + //鐪嬩笉鎳傚氨鎶婅緭鍑虹湅锛歝onsole.log(this.editFormOptions) + } + } +}; +export default extension; diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/MOM/MOMMessage.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/MOM/MOMMessage.js new file mode 100644 index 0000000..520ac40 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/MOM/MOMMessage.js @@ -0,0 +1,76 @@ +/***************************************************************************************** +** Author:jxx 2022 +** QQ:283591387 +**瀹屾暣鏂囨。瑙侊細http://v2.volcore.xyz/document/api 銆愪唬鐮佺敓鎴愰〉闈iewGrid銆� +**甯哥敤绀轰緥瑙侊細http://v2.volcore.xyz/document/vueDev +**鍚庡彴鎿嶄綔瑙侊細http://v2.volcore.xyz/document/netCoreDev +*****************************************************************************************/ +//姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜 + +let extension = { + components: { + //鏌ヨ鐣岄潰鎵╁睍缁勪欢 + gridHeader: '', + gridBody: '', + gridFooter: '', + //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢 + modelHeader: '', + modelBody: '', + modelFooter: '' + }, + tableAction: '', //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓) + buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� + methods: { + //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� + onInit() { //妗嗘灦鍒濆鍖栭厤缃墠锛� + //绀轰緥锛氬湪鎸夐挳鐨勬渶鍓嶉潰娣诲姞涓�涓寜閽� + // this.buttons.unshift({ //涔熷彲浠ョ敤push鎴栬�卻plice鏂规硶鏉ヤ慨鏀筨uttons鏁扮粍 + // name: '鎸夐挳', //鎸夐挳鍚嶇О + // icon: 'el-icon-document', //鎸夐挳鍥炬爣vue2鐗堟湰瑙乮view鏂囨。icon锛寁ue3鐗堟湰瑙乪lement ui鏂囨。icon(娉ㄦ剰涓嶆槸element puls鏂囨。) + // type: 'primary', //鎸夐挳鏍峰紡vue2鐗堟湰瑙乮view鏂囨。button锛寁ue3鐗堟湰瑙乪lement ui鏂囨。button + // onClick: function () { + // this.$Message.success('鐐瑰嚮浜嗘寜閽�'); + // } + // }); + + //绀轰緥锛氳缃慨鏀规柊寤恒�佺紪杈戝脊鍑烘瀛楁鏍囩鐨勯暱搴� + this.boxOptions.labelWidth = 150; + }, + onInited() { + //妗嗘灦鍒濆鍖栭厤缃悗 + //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔 + //this.detailOptions.columns.forEach(column=>{ }); + }, + searchBefore(param) { + //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟 + //杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ + return true; + }, + searchAfter(result) { + //鏌ヨ鍚庯紝result杩斿洖鐨勬煡璇㈡暟鎹�,鍙互鍦ㄦ樉绀哄埌琛ㄦ牸鍓嶅鐞嗚〃鏍肩殑鍊� + return true; + }, + addBefore(formData) { + //鏂板缓淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛紝鍙互缁欑粰琛ㄥ崟璁剧疆鍊硷紝鑷繁杈撳嚭鐪媐ormData鐨勫�� + return true; + }, + updateBefore(formData) { + //缂栬緫淇濆瓨鍓峟ormData涓哄璞★紝鍖呮嫭鏄庣粏琛ㄣ�佸垹闄よ鐨処d + return true; + }, + rowClick({ row, column, event }) { + //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + }, + modelOpenAfter(row) { + //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 + //(1)鍒ゆ柇鏄紪杈戣繕鏄柊寤烘搷浣滐細 this.currentAction=='Add'; + //(2)缁欏脊鍑烘璁剧疆榛樿鍊� + //(3)this.editFormFields.瀛楁='xxx'; + //濡傛灉闇�瑕佺粰涓嬫媺妗嗚缃粯璁ゅ�硷紝璇烽亶鍘唗his.editFormOptions鎵惧埌瀛楁閰嶇疆瀵瑰簲data灞炴�х殑key鍊� + //鐪嬩笉鎳傚氨鎶婅緭鍑虹湅锛歝onsole.log(this.editFormOptions) + } + } + }; + export default extension; + \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/stock/DtBoxingInfo.js b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/stock/DtBoxingInfo.js index b04bca5..01efd28 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/stock/DtBoxingInfo.js +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/stock/DtBoxingInfo.js @@ -6,6 +6,7 @@ **鍚庡彴鎿嶄綔瑙侊細http://v2.volcore.xyz/document/netCoreDev *****************************************************************************************/ //姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜 + let extension = { components: { //鏌ヨ鐣岄潰鎵╁睍缁勪欢 @@ -21,9 +22,18 @@ buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽� methods: { //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄� - onInit() { - //妗嗘灦鍒濆鍖栭厤缃墠锛� - //璁剧疆鏌ヨ鐣岄潰寮瑰嚭妗嗙殑label瀹藉害 + onInit() { //妗嗘灦鍒濆鍖栭厤缃墠锛� + //绀轰緥锛氬湪鎸夐挳鐨勬渶鍓嶉潰娣诲姞涓�涓寜閽� + // this.buttons.unshift({ //涔熷彲浠ョ敤push鎴栬�卻plice鏂规硶鏉ヤ慨鏀筨uttons鏁扮粍 + // name: '鎸夐挳', //鎸夐挳鍚嶇О + // icon: 'el-icon-document', //鎸夐挳鍥炬爣vue2鐗堟湰瑙乮view鏂囨。icon锛寁ue3鐗堟湰瑙乪lement ui鏂囨。icon(娉ㄦ剰涓嶆槸element puls鏂囨。) + // type: 'primary', //鎸夐挳鏍峰紡vue2鐗堟湰瑙乮view鏂囨。button锛寁ue3鐗堟湰瑙乪lement ui鏂囨。button + // onClick: function () { + // this.$Message.success('鐐瑰嚮浜嗘寜閽�'); + // } + // }); + + //绀轰緥锛氳缃慨鏀规柊寤恒�佺紪杈戝脊鍑烘瀛楁鏍囩鐨勯暱搴� this.boxOptions.labelWidth = 150; }, onInited() { @@ -53,7 +63,7 @@ }, rowClick({ row, column, event }) { //鏌ヨ鐣岄潰鐐瑰嚮琛屼簨浠� - //this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; + // this.$refs.table.$refs.table.toggleRowSelection(row); //鍗曞嚮琛屾椂閫変腑褰撳墠琛�; }, modelOpenAfter(row) { //鐐瑰嚮缂栬緫銆佹柊寤烘寜閽脊鍑烘鍚庯紝鍙互鍦ㄦ澶勫啓閫昏緫锛屽锛屼粠鍚庡彴鑾峰彇鏁版嵁 diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/router/index.js b/Code Management/WMS/WIDESEA_WMSClient/src/router/index.js index c355370..47eb415 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/router/index.js +++ b/Code Management/WMS/WIDESEA_WMSClient/src/router/index.js @@ -22,7 +22,7 @@ name: 'UserInfo', component: () => import('@/views/system/UserInfo.vue'), meta: { - keepAlive: false + } }, { @@ -30,7 +30,7 @@ name: 'sysMenu', component: () => import('@/views/system/Sys_Menu.vue'), meta: { - keepAlive: false + } }, { @@ -38,7 +38,6 @@ name: 'signalR', component: () => import('@/views/signalR/Index.vue'), meta:{ - keepAlive:false } }, ] diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js b/Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js index 239b566..bec3af3 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js +++ b/Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js @@ -3,24 +3,21 @@ path: '/Dt_AreaInfo', name: 'Dt_AreaInfo', component: () => import('@/views/widesea_wms/basicinfo/Dt_AreaInfo.vue'), - // meta: { - // keepAlive: true - // } + meta: { + + } }, { path: '/Dt_BillGroupStock', name: 'Dt_BillGroupStock', component: () => import('@/views/widesea_wms/stock/Dt_BillGroupStock.vue'), - // meta: { - // keepAlive: true - // } }, // { // path: '/Dt_BillGroupStockDetail', // name: 'Dt_BillGroupStockDetail', // component: () => import('@/views/widesea_wms/stock/Dt_BillGroupStockDetail.vue'), // meta: { - // keepAlive: true + // // } // }, { @@ -28,7 +25,7 @@ name: 'Dt_InboundOrder', component: () => import('@/views/widesea_wms/invoices/Dt_InboundOrder.vue'), meta: { - keepAlive: false + } }, { @@ -36,7 +33,7 @@ name: 'Dt_InboundOrderDetail', component: () => import('@/views/widesea_wms/invoices/Dt_InboundOrderDetail.vue'), meta: { - keepAlive: false + } }, { @@ -44,7 +41,7 @@ name: 'Dt_LocationInfo', component: () => import('@/views/widesea_wms/basicinfo/Dt_LocationInfo.vue'), meta: { - keepAlive: true + } }, { @@ -52,7 +49,7 @@ name: 'Dt_MaterielAttribute', component: () => import('@/views/widesea_wms/material/Dt_MaterielAttribute.vue'), meta: { - keepAlive: false + } }, { @@ -60,7 +57,7 @@ name: 'Dt_MaterielInfo', component: () => import('@/views/widesea_wms/material/Dt_MaterielInfo.vue'), meta: { - keepAlive: false + } }, { @@ -68,7 +65,7 @@ name: 'Dt_OutOrder', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrder.vue'), meta: { - keepAlive: false + } }, { @@ -76,7 +73,7 @@ name: 'Dt_OutOrderAndStock', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrderAndStock.vue'), meta: { - keepAlive: false + } }, { @@ -84,7 +81,7 @@ name: 'Dt_OutOrderDetail', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrderDetail.vue'), meta: { - keepAlive: false + } }, { @@ -92,7 +89,7 @@ name: 'Dt_OutOrderProduction', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrderProduction.vue'), meta: { - keepAlive: false + } }, { @@ -100,7 +97,7 @@ name: 'Dt_OutOrderProductionDetail', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrderProductionDetail.vue'), meta: { - keepAlive: false + } }, { @@ -108,7 +105,7 @@ name: 'Dt_OutOrderTransfer', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrderTransfer.vue'), meta: { - keepAlive: false + } }, { @@ -116,7 +113,7 @@ name: 'Dt_OutOrderTransferDetail', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrderTransferDetail.vue'), meta: { - keepAlive: false + } }, { @@ -124,38 +121,38 @@ name: 'Dt_RoadWayInfo', component: () => import('@/views/widesea_wms/basicinfo/Dt_RoadWayInfo.vue'), meta: { - keepAlive: false + } }, { path: '/Dt_Strategy', name: 'Dt_Strategy', component: () => import('@/views/widesea_wms/basicinfo/Dt_Strategy.vue'), - // meta: { - // keepAlive: false - // } + meta: { + + } }, { path: '/Dt_Task', name: 'Dt_Task', component: () => import('@/views/widesea_wms/taskinfo/Dt_Task.vue'), - // meta: { - // keepAlive: true - // } + meta: { + + } },{ path: '/Dt_Task_Hty', name: 'Dt_Task_Hty', component: () => import('@/views/widesea_wms/taskinfo/Dt_Task_Hty.vue'), - // meta: { - // keepAlive: true - // } + meta: { + + } }, // { // path: '/Dt_TaskOut', // name: 'Dt_TaskOut', // component: () => import('@/views/widesea_wms/taskinfo/Dt_TaskOut.vue'), // meta: { - // keepAlive: false + // // } // }, // { @@ -163,7 +160,7 @@ // name: 'Dt_TaskExecuteDetail', // component: () => import('@/views/widesea_wms/taskinfo/Dt_TaskExecuteDetail.vue'), // meta: { - // keepAlive: false + // // } // }, { @@ -171,7 +168,7 @@ name: 'Dt_UnitInfo', component: () => import('@/views/widesea_wms/basicinfo/Dt_UnitInfo.vue'), meta: { - keepAlive: false + } }, { @@ -179,7 +176,7 @@ name: 'Dt_WareAreaInfo', component: () => import('@/views/widesea_wms/basicinfo/Dt_WareAreaInfo.vue'), meta: { - keepAlive: false + } }, { @@ -187,7 +184,7 @@ name: 'Dt_OutOrderSorting', component: () => import('@/views/widesea_wms/invoices/Dt_OutOrderSorting.vue'), meta: { - keepAlive: false + } }, // { @@ -200,7 +197,7 @@ name: 'PointStackerRelation', component: () => import('@/views/widesea_wms/basicinfo/PointStackerRelation.vue'), meta: { - keepAlive: false + } }, { @@ -208,7 +205,7 @@ name: 'LocationStatusChange', component: () => import('@/views/widesea_wms/basicinfo/LocationStatusChange.vue'), meta: { - keepAlive: false + } }, { @@ -216,7 +213,7 @@ name: 'DtBoxing', component: () => import('@/views/widesea_wms/stock/DtBoxingInfo.vue'), meta: { - keepAlive: false + } }, { @@ -224,7 +221,7 @@ name: 'momTest', component: () => import('@/views/widesea_wms/MOM/momTest.vue'), meta: { - keepAlive: false + } }, { @@ -232,7 +229,7 @@ name: 'ProductionModel', component: () => import('@/views/widesea_wms/MOM/ProductionModel.vue'), meta: { - keepAlive: false + } }, { @@ -240,14 +237,21 @@ name: 'Dt_StationManager', component: () => import('@/views/widesea_wms/basicinfo/Dt_StationManager.vue'), meta: { - keepAlive: false + } },{ path: '/Dt_needBarcode', name: 'Dt_needBarcode', component: () => import('@/views/widesea_wms/basicinfo/Dt_needBarcode.vue'), meta: { - keepAlive: false + + } + },{ + path: '/Message', + name: 'Message', + component: () => import('@/views/widesea_wms/MOM/ErrorMessage/Message.vue'), + meta: { + } }, ] diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/router/viewGird.js b/Code Management/WMS/WIDESEA_WMSClient/src/router/viewGird.js index c598d33..db68844 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/router/viewGird.js +++ b/Code Management/WMS/WIDESEA_WMSClient/src/router/viewGird.js @@ -4,7 +4,7 @@ name: 'sys_Log', component: () => import('@/views/system/Sys_Log.vue'), meta: { - keepAlive: false + } }, { @@ -12,7 +12,7 @@ name: 'Sys_User', component: () => import('@/views/system/Sys_User.vue'), meta: { - keepAlive: false + } }, { @@ -20,7 +20,7 @@ name: 'permission', component: () => import('@/views/system/Permission.vue'), meta: { - keepAlive: false + } }, @@ -29,7 +29,7 @@ name: 'Sys_Dictionary', component: () => import('@/views/system/Sys_Dictionary.vue'), meta: { - keepAlive: false + } }, { @@ -37,77 +37,22 @@ name: 'Sys_Role', component: () => import('@/views/system/Sys_Role.vue'), meta: { - keepAlive: false + } }, - // { - // path: '/Sys_Role1', - // name: 'Sys_Role1', - // component: () => import('@/views/system/Sys_Role1.vue') - // } - // , { path: '/Sys_DictionaryList', name: 'Sys_DictionaryList', component: () => import('@/views/system/Sys_DictionaryList.vue'), meta: { - keepAlive: false + } - }, - // { - // path: '/FormDesignOptions', - // name: 'FormDesignOptions', - // component: () => import('@/views/system/form/FormDesignOptions.vue'), - // meta: { - // keepAlive: false - // } - // }, - // { - // path: '/FormCollectionObject', - // name: 'FormCollectionObject', - // component: () => import('@/views/system/form/FormCollectionObject.vue'), - // meta: { - // keepAlive: false - // } - // }, - // { - // path: '/Sys_WorkFlow', - // name: 'Sys_WorkFlow', - // component: () => import('@/views/system/flow/Sys_WorkFlow.vue'), - // meta: { - // keepAlive: false - // } - // }, - // { - // path: '/Sys_WorkFlowTable', - // name: 'Sys_WorkFlowTable', - // component: () => import('@/views/system/flow/Sys_WorkFlowTable.vue'), - // meta: { - // keepAlive: false - // } - // }, - // { - // path: '/Sys_QuartzOptions', - // name: 'Sys_QuartzOptions', - // component: () => import('@/views/system/quartz/Sys_QuartzOptions.vue'), - // meta: { - // keepAlive: false - // } - // }, - // { - // path: '/Sys_QuartzLog', - // name: 'Sys_QuartzLog', - // component: () => import('@/views/system/quartz/Sys_QuartzLog.vue'), - // meta: { - // keepAlive: false - // } - // }, - { + },{ path: '/Sys_Department', name: 'Sys_Department', component: () => import('@/views/system/system/Sys_Department.vue'), meta: { - keepAlive: false + } } ] diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/views/widesea_wms/MOM/ErrorMessage/Message.vue b/Code Management/WMS/WIDESEA_WMSClient/src/views/widesea_wms/MOM/ErrorMessage/Message.vue new file mode 100644 index 0000000..58ed4ed --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/src/views/widesea_wms/MOM/ErrorMessage/Message.vue @@ -0,0 +1,65 @@ +<!-- +*Author锛歫xx + *Contact锛�283591387@qq.com + *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩� + *涓氬姟璇峰湪@/extension/widesea_wms/basicinfo/Dt_AreaInfo.js姝ゅ缂栧啓 + --> + <template> + <view-grid ref="grid" :columns="columns" :detail="detail" :editFormFields="editFormFields" + :editFormOptions="editFormOptions" :searchFormFields="searchFormFields" :searchFormOptions="searchFormOptions" + :table="table" :extend="extend"> + </view-grid> +</template> +<script> +import extend from "@/extension/widesea_wms/MOM/MOMMessage.js"; +import { ref, defineComponent } from "vue"; +export default defineComponent({ + setup() { + const table = ref({ + key: 'id', + footer: "Foots", + cnName: 'MOM娑堟伅', + name: 'MOM/MOMErrorMessage', + url: "/MOMErrorMessage/", + sortName: "CreateTime" + }); + const editFormFields = ref({}); + const editFormOptions = ref([]); + const searchFormFields = ref({}); + const searchFormOptions = ref([ + [ + { "title": "鎵樼洏鍙�", "field": "palletCode", type: "text" }, + { "title": "浠诲姟鍙�", "field": "taskNum", type: "text" , hidden: true}, + { "title": "寮傚父娑堟伅", "field": "errorMessage", type: "text" }, + ], + [ + { "title": "api鍚嶇О", "field": "apiName", type: "text" }, + { "title": "鍒涘缓鏃堕棿", "field": "createTime", type: "text" }, + ] + ]); + const columns = ref([{ field: 'id', title: '涓婚敭', type: 'int', sort: true, hidden: true, width: 110, readonly: true, require: true, align: 'left' }, + { field: 'taskNum', title: '浠诲姟鍙�', type: 'string', sort: true, width: 110, require: true, align: 'left', sort: true , hidden: true}, + { field: 'palletCode', title: '鎵樼洏鍙�', type: 'string', sort: true, width: 110, align: 'left' }, + { field: 'errorMessage', title: '寮傚父娑堟伅', type: 'string', sort: true, width: 200, align: 'left' }, + { field: 'apiName', title: 'api鍚嶇О', type: 'string', sort: true, width: 110, align: 'left' }, + { field: 'createTime', title: '鍒涘缓鏃堕棿', type: 'string', sort: true, width: 110, align: 'left' },]); + const detail = ref({ + cnName: "#detailCnName", + table: "#detailTable", + columns: [], + sortName: "", + key: "" + }); + return { + table, + extend, + editFormFields, + editFormOptions, + searchFormFields, + searchFormOptions, + columns, + detail, + }; + }, +}); +</script> diff --git a/Code Management/WMS/WIDESEA_WMSClient/tests/unit/example.spec.js b/Code Management/WMS/WIDESEA_WMSClient/tests/unit/example.spec.js new file mode 100644 index 0000000..bc9939b --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/tests/unit/example.spec.js @@ -0,0 +1,13 @@ +import { expect } from 'chai' +import { shallowMount } from '@vue/test-utils' +import HelloWorld from '@/components/HelloWorld.vue' + +describe('HelloWorld.vue', () => { + it('renders props.msg when passed', () => { + const msg = 'new message' + const wrapper = shallowMount(HelloWorld, { + props: { msg } + }) + expect(wrapper.text()).to.include(msg) + }) +}) diff --git a/Code Management/WMS/WIDESEA_WMSClient/vue.config.js b/Code Management/WMS/WIDESEA_WMSClient/vue.config.js new file mode 100644 index 0000000..2428b79 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSClient/vue.config.js @@ -0,0 +1,53 @@ +// const webpack = require("webpack"); + +module.exports = { + productionSourceMap: false, + lintOnSave: false, + devServer: { + port: 8080, + overlay: { + warning: false, + errors: false + } + }, + css: { + //鏌ョ湅CSS灞炰簬鍝釜css鏂囦欢 + sourceMap: true + }, + configureWebpack: { + module: { + rules: [ + { + test: /\.mjs$/, + include: /node_modules/, + type: "javascript/auto" + }, + ] + } + }, + //https://cli.vuejs.org/zh/guide/html-and-static-assets.html#html + chainWebpack: (config) => { + // 绉婚櫎 prefetch 鎻掍欢 + config.plugins.delete('prefetch'); + //鑷笅瀹氫箟title + config.plugin('html').tap((args) => { + args[0].title = 'WCS'; + return args; + }); + + // 鎴栬�� + // 淇敼瀹冪殑閫夐」锛� + // config.plugin('prefetch').tap(options => { + // options[0].fileBlacklist = options[0].fileBlacklist || [] + // options[0].fileBlacklist.push(/myasyncRoute(.)+?\.js$/) + // return options + // }) + } + // configureWebpack: { + // plugins: [ + // new webpack.optimize.MinChunkSizePlugin({ + // minChunkSize: 100000 // 閫氳繃鍚堝苟灏忎簬 minChunkSize 澶у皬鐨� chunk锛屽皢 chunk 浣撶Н淇濇寔鍦ㄦ寚瀹氬ぇ灏忛檺鍒朵互涓� + // }) + // ] + // } +}; diff --git a/Code Management/WMS/WIDESEA_WMSServer/LogLibrary/Log/Log.cs b/Code Management/WMS/WIDESEA_WMSServer/LogLibrary/Log/Log.cs index 7c81819..6022c2a 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/LogLibrary/Log/Log.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/LogLibrary/Log/Log.cs @@ -398,7 +398,7 @@ public void FatalFormat(bool isWriteFile, IFormatProvider provider, string format, params object[] args) { string log = GetDataTimeLog(string.Format(provider, format, args)); - Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Fatal, log); @@ -415,7 +415,7 @@ public void FatalFormat(bool isWriteFile, string format, object arg0, object arg1) { string log = GetDataTimeLog(string.Format(format, arg0, arg1)); - Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Fatal, log); @@ -433,7 +433,7 @@ public void FatalFormat(bool isWriteFile, string format, object arg0, object arg1, object arg2) { string log = GetDataTimeLog(string.Format(format, arg0, arg1, arg2)); - Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Fatal, log); @@ -448,7 +448,7 @@ public void Info(bool isWriteFile, object message) { string log = GetDataTimeLog(message.ToString()); - Console.WriteLine(m_MessageTemplate, m_Name, m_Info, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Info, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Info, log); @@ -464,7 +464,7 @@ public void Info(bool isWriteFile, object message, Exception exception) { string log = GetDataTimeLog(message + Environment.NewLine + exception.Message + exception.StackTrace); - Console.WriteLine(m_MessageTemplate, m_Name, m_Info, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Info, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Info, log); @@ -480,7 +480,7 @@ public void InfoFormat(bool isWriteFile, string format, object arg0) { string log = GetDataTimeLog(string.Format("\n{0}\n{1}\n-----------------------------------------------------------\n\n", format, arg0)); - Console.WriteLine(m_MessageTemplate, m_Name, m_Info, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Info, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Info, log); @@ -570,7 +570,7 @@ public void Warn(bool isWriteFile, object message) { string log = GetDataTimeLog(message.ToString()); - Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Warn, log); @@ -586,7 +586,7 @@ public void Warn(bool isWriteFile, object message, Exception exception) { string log = GetDataTimeLog(message + Environment.NewLine + exception.Message + exception.StackTrace); - Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Warn, log); @@ -602,7 +602,7 @@ public void WarnFormat(bool isWriteFile, string format, object arg0) { string log = GetDataTimeLog(string.Format(format, arg0)); - Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, log); + //Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, log); if (isWriteFile) { LogUtil.WriteLogFile(m_Name, m_Warn, log); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Const/CacheConst.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Const/CacheConst.cs new file mode 100644 index 0000000..47445a2 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Const/CacheConst.cs @@ -0,0 +1,52 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// Redis甯搁噺 +/// </summary> +public class CacheConst +{ + /// <summary> + /// Redis Key鍓嶇紑(鍙垹闄�) + /// </summary> + public const string Cache_Prefix_Web = "WIDESEA_WMSServerWeb:"; + + /// <summary> + /// Redis Key鍓嶇紑(闇�瑕佹寔涔呭寲锛屼笉闅忕郴缁熼噸鍚垹闄�) + /// </summary> + public const string Cache_Prefix = "WIDESEA_WMSServer:"; + + /// <summary> + /// Redis Hash绫诲瀷 + /// </summary> + public const string Cache_Hash = "Hash"; + + /// <summary> + /// 绯荤粺閰嶇疆琛ㄧ紦瀛楰ey + /// </summary> + public const string Cache_DevConfig = Cache_Prefix_Web + "DevConfig:"; + + /// <summary> + /// 鐧诲綍楠岃瘉鐮佺紦瀛楰ey + /// </summary> + public const string Cache_Captcha = Cache_Prefix_Web + "Captcha:"; + + /// <summary> + /// 鐢ㄦ埛琛ㄧ紦瀛楰ey + /// </summary> + public const string Cache_SysUser = Cache_Prefix_Web + "SysUser"; + + /// <summary> + /// 鐢ㄦ埛鎵嬫満鍙峰叧绯荤紦瀛楰ey + /// </summary> + public const string Cache_SysUserPhone = Cache_Prefix_Web + "SysUserPhone"; + + /// <summary> + /// 鐢ㄦ埛Token缂撳瓨Key + /// </summary> + public const string Cache_UserToken = Cache_Prefix + "UserToken"; + + /// <summary> + /// WMS搴撳瓨缂撳瓨Key + /// </summary>Cache_AutoModel + public const string Cache_DtStockInfo = Cache_Prefix + "DtStockInfo"; +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/LinqExtension.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/LinqExtension.cs new file mode 100644 index 0000000..b733b7d --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/LinqExtension.cs @@ -0,0 +1,19 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// Linq鎵╁睍 +/// </summary> +public static class LinqExtension +{ + /// <summary> + /// 鏄惁閮藉寘鍚� + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="first">绗竴涓垪琛�</param> + /// <param name="secend">绗簩涓垪琛�</param> + /// <returns></returns> + public static bool ContainsAll<T>(this List<T> first, List<T> secend) + { + return secend.All(s => first.Any(f => f.Equals(s))); + } +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/ObjectExtension.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/ObjectExtension.cs new file mode 100644 index 0000000..cf2b20e --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Extension/ObjectExtension.cs @@ -0,0 +1,45 @@ +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace WIDESEA_Cache; +/// <summary> +/// object鎷撳睍 +/// </summary> +public static class ObjectExtension +{ + /// <summary> + /// json瀛楃涓插簭鍒楀寲 + /// </summary> + /// <param name="json"></param> + /// <returns></returns> + public static object ToObject(this string json) + { + return string.IsNullOrEmpty(json) ? null : JsonConvert.DeserializeObject(json); + } + + /// <summary> + /// json瀛楃涓插簭鍒楀寲 + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="json"></param> + /// <returns></returns> + public static T ToObject<T>(this string json) + { + if (json != null) + { + json = json.Replace(" ", ""); + return JsonConvert.DeserializeObject<T>(json); + } + else return default; + } + + /// <summary> + /// json瀛楃涓插簭鍒楀寲 + /// </summary> + /// <param name="json"></param> + /// <returns></returns> + public static JObject ToJObject(this string json) + { + return json == null ? JObject.Parse("{}") : JObject.Parse(json.Replace(" ", "")); + } +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/GlobalUsing.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/GlobalUsing.cs new file mode 100644 index 0000000..45ad6b4 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/GlobalUsing.cs @@ -0,0 +1,7 @@ +锘縢lobal using Masuit.Tools; +global using Microsoft.AspNetCore.Builder; +global using Microsoft.AspNetCore.Hosting; +global using Microsoft.Extensions.DependencyInjection; +global using NewLife.Caching; +global using NewLife.Serialization; +global using SimpleRedis; diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheHashService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheHashService.cs new file mode 100644 index 0000000..a15f099 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheHashService.cs @@ -0,0 +1,60 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// 缂撳瓨鏈嶅姟 +/// </summary> +public partial interface ISimpleCacheService +{ + /// <summary> + /// 娣诲姞涓�鏉℃暟鎹埌HashMap + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="key">閿�</param> + /// <param name="hashKey">hash鍒楄〃閲岀殑Key</param> + /// <param name="value">鍊�</param> + void HashAdd<T>(string key, string hashKey, T value); + + /// <summary> + /// 娣诲姞澶氭潯鏁版嵁鍒癏ashMap + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="key">閿�</param> + /// <param name="dic">閿�煎瀛楀吀</param> + /// <returns></returns> + bool HashSet<T>(string key, Dictionary<string, T> dic); + + /// <summary> + /// 浠嶩ashMap涓垹闄ゆ暟鎹� + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="key">閿�</param> + /// <param name="fields">hash閿垪琛�</param> + /// <returns>鎵ц缁撴灉</returns> + int HashDel<T>(string key, params string[] fields); + + /// <summary> + /// 鏍规嵁閿幏鍙杊ash鍒楄〃涓殑鍊� + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="key">閿�</param> + /// <param name="fields">hash閿垪琛�</param> + /// <returns>鏁版嵁鍒楄〃</returns> + List<T> HashGet<T>(string key, params string[] fields); + + /// <summary> + /// 鏍规嵁閿幏鍙杊ash鍒楄〃涓殑鍊� + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="key">閿�</param> + /// <param name="field">hash閿�</param> + /// <returns></returns> + T HashGetOne<T>(string key, string field); + + /// <summary> + /// 鑾峰彇鎵�鏈夐敭鍊煎 + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="key">閿�</param> + /// <returns>鏁版嵁瀛楀吀</returns> + IDictionary<string, T> HashGetAll<T>(string key); +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheService.cs new file mode 100644 index 0000000..fc55623 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Interface/ISimpleCacheService.cs @@ -0,0 +1,180 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// 缂撳瓨鏈嶅姟 +/// </summary> +public partial interface ISimpleCacheService +{ + #region 鍩虹鎿嶄綔 + + /// <summary>鏄惁鍖呭惈缂撳瓨椤�</summary> + /// <param name="key"></param> + /// <returns></returns> + bool ContainsKey(string key); + + /// <summary>璁剧疆缂撳瓨椤�</summary> + /// <param name="key">閿�</param> + /// <param name="value">鍊�</param> + /// <param name="expire">杩囨湡鏃堕棿锛岀銆傚皬浜�0鏃堕噰鐢ㄩ粯璁ょ紦瀛樻椂闂�</param> + /// <returns></returns> + bool Set<T>(string key, T value, int expire = -1); + + /// <summary>璁剧疆缂撳瓨椤�</summary> + /// <param name="key">閿�</param> + /// <param name="value">鍊�</param> + /// <param name="expire">杩囨湡鏃堕棿</param> + /// <returns></returns> + bool Set<T>(string key, T value, TimeSpan expire); + + /// <summary>鑾峰彇缂撳瓨椤�</summary> + /// <param name="key">閿�</param> + /// <returns></returns> + T Get<T>(string key); + + /// <summary>鎵归噺绉婚櫎缂撳瓨椤�</summary> + /// <param name="keys">閿泦鍚�</param> + /// <returns></returns> + int Remove(params string[] keys); + + /// <summary>娓呯┖鎵�鏈夌紦瀛橀」</summary> + void Clear(); + + /// <summary>璁剧疆缂撳瓨椤规湁鏁堟湡</summary> + /// <param name="key">閿�</param> + /// <param name="expire">杩囨湡鏃堕棿</param> + bool SetExpire(string key, TimeSpan expire); + + /// <summary>鑾峰彇缂撳瓨椤规湁鏁堟湡</summary> + /// <param name="key">閿�</param> + /// <returns></returns> + TimeSpan GetExpire(string key); + + /// <summary> + /// 妯$硦鍒犻櫎 + /// </summary> + /// <param name="pattern">鍖归厤鍏抽敭瀛�</param> + void DelByPattern(string pattern); + + #endregion 鍩虹鎿嶄綔 + + #region 闆嗗悎鎿嶄綔 + + /// <summary>鎵归噺鑾峰彇缂撳瓨椤�</summary> + /// <typeparam name="T"></typeparam> + /// <param name="keys"></param> + /// <returns></returns> + IDictionary<string, T> GetAll<T>(IEnumerable<string> keys); + + /// <summary>鎵归噺璁剧疆缂撳瓨椤�</summary> + /// <typeparam name="T"></typeparam> + /// <param name="values"></param> + /// <param name="expire">杩囨湡鏃堕棿锛岀銆傚皬浜�0鏃堕噰鐢ㄩ粯璁ょ紦瀛樻椂闂�</param> + void SetAll<T>(IDictionary<string, T> values, int expire = -1); + + /// <summary>鑾峰彇鍒楄〃</summary> + /// <typeparam name="T">鍏冪礌绫诲瀷</typeparam> + /// <param name="key">閿�</param> + /// <returns></returns> + IList<T> GetList<T>(string key); + + /// <summary>鑾峰彇鍝堝笇</summary> + /// <typeparam name="T">鍏冪礌绫诲瀷</typeparam> + /// <param name="key">閿�</param> + /// <returns></returns> + IDictionary<string, T> GetDictionary<T>(string key); + + /// <summary>鑾峰彇闃熷垪</summary> + /// <typeparam name="T">鍏冪礌绫诲瀷</typeparam> + /// <param name="key">閿�</param> + /// <returns></returns> + IProducerConsumer<T> GetQueue<T>(string key); + + /// <summary>鑾峰彇鏍�</summary> + /// <typeparam name="T">鍏冪礌绫诲瀷</typeparam> + /// <param name="key">閿�</param> + /// <returns></returns> + IProducerConsumer<T> GetStack<T>(string key); + + /// <summary>鑾峰彇Set</summary> + /// <typeparam name="T"></typeparam> + /// <param name="key"></param> + /// <returns></returns> + ICollection<T> GetSet<T>(string key); + + #endregion 闆嗗悎鎿嶄綔 + + #region 楂樼骇鎿嶄綔 + + /// <summary>娣诲姞锛屽凡瀛樺湪鏃朵笉鏇存柊</summary> + /// <typeparam name="T">鍊肩被鍨�</typeparam> + /// <param name="key">閿�</param> + /// <param name="value">鍊�</param> + /// <param name="expire">杩囨湡鏃堕棿锛岀銆傚皬浜�0鏃堕噰鐢ㄩ粯璁ょ紦瀛樻椂闂�</param> + /// <returns></returns> + bool Add<T>(string key, T value, int expire = -1); + + /// <summary>璁剧疆鏂板�煎苟鑾峰彇鏃у�硷紝鍘熷瓙鎿嶄綔</summary> + /// <remarks> + /// 甯稿父閰嶅悎Increment浣跨敤锛岀敤浜庣疮鍔犲埌涓�瀹氭暟鍚庨噸缃綊闆讹紝鍙堥伩鍏嶅绾跨▼鍐茬獊銆� + /// </remarks> + /// <typeparam name="T">鍊肩被鍨�</typeparam> + /// <param name="key">閿�</param> + /// <param name="value">鍊�</param> + /// <returns></returns> + T Replace<T>(string key, T value); + + /// <summary>灏濊瘯鑾峰彇鎸囧畾閿紝杩斿洖鏄惁鍖呭惈鍊笺�傛湁鍙兘缂撳瓨椤瑰垰濂芥槸榛樿鍊硷紝鎴栬�呭彧鏄弽搴忓垪鍖栧け璐ワ紝瑙e喅缂撳瓨绌块�忛棶棰�</summary> + /// <typeparam name="T">鍊肩被鍨�</typeparam> + /// <param name="key">閿�</param> + /// <param name="value">鍊笺�傚嵆浣挎湁鍊间篃涓嶄竴瀹氳兘澶熻繑鍥烇紝鍙兘缂撳瓨椤瑰垰濂芥槸榛樿鍊硷紝鎴栬�呭彧鏄弽搴忓垪鍖栧け璐�</param> + /// <returns>杩斿洖鏄惁鍖呭惈鍊硷紝鍗充娇鍙嶅簭鍒楀寲澶辫触</returns> + bool TryGetValue<T>(string key, out T value); + + /// <summary>绱姞锛屽師瀛愭搷浣�</summary> + /// <param name="key">閿�</param> + /// <param name="value">鍙樺寲閲�</param> + /// <returns></returns> + long Increment(string key, long value); + + /// <summary>绱姞锛屽師瀛愭搷浣�</summary> + /// <param name="key">閿�</param> + /// <param name="value">鍙樺寲閲�</param> + /// <returns></returns> + double Increment(string key, double value); + + /// <summary>閫掑噺锛屽師瀛愭搷浣�</summary> + /// <param name="key">閿�</param> + /// <param name="value">鍙樺寲閲�</param> + /// <returns></returns> + long Decrement(string key, long value); + + /// <summary>閫掑噺锛屽師瀛愭搷浣�</summary> + /// <param name="key">閿�</param> + /// <param name="value">鍙樺寲閲�</param> + /// <returns></returns> + double Decrement(string key, double value); + + #endregion 楂樼骇鎿嶄綔 + + #region 浜嬪姟 + + /// <summary>鎻愪氦鍙樻洿銆傞儴鍒嗘彁渚涜�呴渶瑕佸埛鐩�</summary> + /// <returns></returns> + int Commit(); + + /// <summary>鐢宠鍒嗗竷寮忛攣</summary> + /// <param name="key">瑕侀攣瀹氱殑key</param> + /// <param name="msTimeout">閿佺瓑寰呮椂闂达紝鍗曚綅姣</param> + /// <returns></returns> + IDisposable AcquireLock(string key, int msTimeout); + + /// <summary>鐢宠鍒嗗竷寮忛攣</summary> + /// <param name="key">瑕侀攣瀹氱殑key</param> + /// <param name="msTimeout">閿佺瓑寰呮椂闂达紝鐢宠鍔犻攣鏃跺鏋滈亣鍒板啿绐佸垯绛夊緟鐨勬渶澶ф椂闂达紝鍗曚綅姣</param> + /// <param name="msExpire">閿佽繃鏈熸椂闂达紝瓒呰繃璇ユ椂闂村鏋滄病鏈変富鍔ㄩ噴鏀惧垯鑷姩閲婃斁閿侊紝蹇呴』鏁存暟绉掞紝鍗曚綅姣</param> + /// <param name="throwOnFailure">澶辫触鏃舵槸鍚︽姏鍑哄紓甯革紝濡傛灉涓嶆姏鍑哄紓甯革紝鍙�氳繃杩斿洖null寰楃煡鐢宠閿佸け璐�</param> + /// <returns></returns> + IDisposable AcquireLock(string key, int msTimeout, int msExpire, bool throwOnFailure); + + #endregion 浜嬪姟 +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Options/CacheSettingsOptions.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Options/CacheSettingsOptions.cs new file mode 100644 index 0000000..f1b2e25 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Options/CacheSettingsOptions.cs @@ -0,0 +1,46 @@ +锘�//using Furion.ConfigurableOptions; +using WIDESEA_Core.Core; + +namespace WIDESEA_Cache; + +/// <summary> +/// 缂撳瓨璁剧疆 +/// </summary> +public class CacheSettingsOptions : IConfigurableOptions +{ + /// <summary> + /// 浣跨敤Redis + /// </summary> + public bool UseRedis { get; set; } + + /// <summary> + /// 鏄惁姣忔鍚姩閮芥竻绌� + /// </summary> + public RedisSettings RedisSettings { get; set; } +} + +/// <summary> +/// Redis璁剧疆 +/// </summary> +public class RedisSettings +{ + /// <summary> + /// 杩炴帴鍦板潃 + /// </summary> + public string Address { get; set; } + + /// <summary> + /// 瀵嗙爜 + /// </summary> + public string Password { get; set; } + + /// <summary> + /// 鏁版嵁搴� + /// </summary> + public int Db { get; set; } = 0; + + /// <summary> + /// 鏄惁姣忔鍚姩閮芥竻绌� + /// </summary> + public bool ClearRedis { get; set; } = false; +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheHashService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheHashService.cs new file mode 100644 index 0000000..4d96f71 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheHashService.cs @@ -0,0 +1,88 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// <inheritdoc cref="ISimpleCacheService"/> +/// 鍐呭瓨缂撳瓨 +/// </summary> +public partial class MemoryCacheService : ISimpleCacheService +{ + /// <inheritdoc/> + public void HashAdd<T>(string key, string hashKey, T value) + { + //鑾峰彇瀛楀吀 + var exist = _memoryCache.GetDictionary<T>(key); + if (exist.ContainsKey(hashKey))//濡傛灉鍖呭惈Key + exist[hashKey] = value;//閲嶆柊璧嬪�� + else exist.Add(hashKey, value);//鍔犱笂鏂扮殑鍊� + _memoryCache.Set(key, exist); + } + + //private IDictionary<string,T> GetDictionary(string key,string) + + /// <inheritdoc/> + public bool HashSet<T>(string key, Dictionary<string, T> dic) + { + //鑾峰彇瀛楀吀 + var exist = _memoryCache.GetDictionary<T>(key); + dic.ForEach(it => + { + if (exist.ContainsKey(it.Key))//濡傛灉鍖呭惈Key + exist[it.Key] = it.Value;//閲嶆柊璧嬪�� + else exist.Add(it.Key, it.Value);//鍔犱笂鏂扮殑鍊� + }); + + return true; + } + + /// <inheritdoc/> + public int HashDel<T>(string key, params string[] fields) + { + int result = 0; + //鑾峰彇瀛楀吀 + var exist = _memoryCache.GetDictionary<T>(key); + foreach (var field in fields) + { + if (field != null && exist.ContainsKey(field))//濡傛灉鍖呭惈Key + { + exist.Remove(field);//鍒犻櫎 + result++; + } + } + return result; + } + + /// <inheritdoc/> + public List<T> HashGet<T>(string key, params string[] fields) + { + List<T> list = new List<T>(); + //鑾峰彇瀛楀吀 + var exist = _memoryCache.GetDictionary<T>(key); + foreach (var field in fields) + { + if (exist.ContainsKey(field))//濡傛灉鍖呭惈Key + { + list.Add(exist[field]); + } + else { list.Add(default); } + } + return list; + } + + /// <inheritdoc/> + public T HashGetOne<T>(string key, string field) + { + //鑾峰彇瀛楀吀 + var exist = _memoryCache.GetDictionary<T>(key); + + exist.TryGetValue(field, out T result); + var data = result.DeepClone(); + return data; + } + + /// <inheritdoc/> + public IDictionary<string, T> HashGetAll<T>(string key) + { + var data = _memoryCache.GetDictionary<T>(key); + return data; + } +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheService.cs new file mode 100644 index 0000000..78a2b6d --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/MemoryCacheService.cs @@ -0,0 +1,219 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// <inheritdoc cref="ISimpleCacheService"/> +/// 鍐呭瓨缂撳瓨 +/// </summary> +public partial class MemoryCacheService : ISimpleCacheService +{ + public readonly MemoryCache _memoryCache; + + public MemoryCacheService() + { + _memoryCache = new MemoryCache(); + } + + #region 鏅�氭搷浣� + + /// <inheritdoc/> + public T Get<T>(string key) + { + var data = _memoryCache.Get<string>(key); + return data.ToObject<T>(); + } + + /// <inheritdoc/> + public int Remove(params string[] keys) + { + return _memoryCache.Remove(keys); + } + + /// <inheritdoc/> + public bool Set<T>(string key, T value, int expire = -1) + { + return _memoryCache.Set(key, value.ToJson(), expire); + } + + /// <inheritdoc/> + public bool Set<T>(string key, T value, TimeSpan expire) + { + return _memoryCache.Set(key, value.ToJson(), expire); + } + + /// <inheritdoc/> + public bool SetExpire(string key, TimeSpan expire) + { + return _memoryCache.SetExpire(key, expire); + } + + /// <inheritdoc/> + public TimeSpan GetExpire(string key) + { + return _memoryCache.GetExpire(key); + } + + /// <inheritdoc/> + public bool ContainsKey(string key) + { + return _memoryCache.ContainsKey(key); + } + + /// <inheritdoc/> + public void Clear() + { + _memoryCache.Clear(); + } + + /// <inheritdoc/> + public void DelByPattern(string pattern) + { + var keys = _memoryCache.Keys.ToList();//鑾峰彇鎵�鏈塳ey + keys.ForEach(it => + { + if (it.Contains(pattern))//濡傛灉鍖归厤 + _memoryCache.Remove(pattern); + }); + } + + #endregion 鏅�氭搷浣� + + #region 闆嗗悎鎿嶄綔 + + /// <inheritdoc/> + public IDictionary<string, T> GetAll<T>(IEnumerable<string> keys) + { + IDictionary<string, T>? result = default;//瀹氫箟闆嗗悎 + IDictionary<string, string>? data = _memoryCache.GetAll<string>(keys);//鑾峰彇鏁版嵁 + data.ForEach(it => + { + result.Add(it.Key, it.Value.ToObject<T>());//閬嶅巻鏁版嵁,鏍煎紡鍖栧苟鍔犲埌鏂扮殑鏁版嵁闆嗗悎 + }); + return result; + } + + /// <inheritdoc/> + public void SetAll<T>(IDictionary<string, T> values, int expire = -1) + { + IDictionary<string, string>? result = default;//瀹氫箟闆嗗悎 + values.ForEach(it => + { + result.Add(it.Key, it.Value.ToJson());//閬嶅巻鏁版嵁,鏍煎紡鍖栧苟鍔犲埌鏂扮殑鏁版嵁闆嗗悎 + }); + _memoryCache.SetAll(values, expire); + } + + /// <inheritdoc/> + public IDictionary<string, T> GetDictionary<T>(string key) + { + IDictionary<string, T>? result = default;//瀹氫箟闆嗗悎 + var data = _memoryCache.GetDictionary<string>(key); + data.ForEach(it => + { + result.Add(it.Key, it.Value.ToObject<T>());//閬嶅巻鏁版嵁,鏍煎紡鍖栧苟鍔犲埌鏂扮殑鏁版嵁闆嗗悎 + }); + return result; + } + + /// <inheritdoc/> + public IProducerConsumer<T> GetQueue<T>(string key) + { + return _memoryCache.GetQueue<T>(key); + } + + /// <inheritdoc/> + public IProducerConsumer<T> GetStack<T>(string key) + { + return _memoryCache.GetStack<T>(key); + } + + /// <inheritdoc/> + public ICollection<T> GetSet<T>(string key) + { + return _memoryCache.GetSet<T>(key); + } + + #endregion 闆嗗悎鎿嶄綔 + + #region 楂樼骇鎿嶄綔 + + /// <inheritdoc/> + public bool Add<T>(string key, T value, int expire = -1) + { + return _memoryCache.Add(key, value.ToJson(), expire); + } + + /// <inheritdoc/> + public IList<T> GetList<T>(string key) + { + IList<T> result = default;//瀹氫箟闆嗗悎 + var data = _memoryCache.GetList<string>(key); + data.ForEach(it => + { + result.Add(it.ToObject<T>());//閬嶅巻鏁版嵁,鏍煎紡鍖栧苟鍔犲埌鏂扮殑鏁版嵁闆嗗悎 + }); + return result; + } + + /// <inheritdoc/> + public T Replace<T>(string key, T value) + { + return _memoryCache.Replace(key, value); + } + + /// <inheritdoc/> + public bool TryGetValue<T>(string key, out T value) + { + var result = string.Empty; + _ = _memoryCache.TryGetValue<string>(key, out result); + value = result.ToObject<T>(); + return value == null; + } + + /// <inheritdoc/> + public long Decrement(string key, long value) + { + return _memoryCache.Decrement(key, value); + } + + /// <inheritdoc/> + public double Decrement(string key, double value) + { + return _memoryCache.Decrement(key, value); + } + + /// <inheritdoc/> + public long Increment(string key, long value) + { + return _memoryCache.Increment(key, value); + } + + /// <inheritdoc/> + public double Increment(string key, double value) + { + return _memoryCache.Increment(key, value); + } + + #endregion 楂樼骇鎿嶄綔 + + #region 浜嬪姟 + + /// <inheritdoc/> + public int Commit() + { + return _memoryCache.Commit(); + } + + /// <inheritdoc/> + public IDisposable AcquireLock(string key, int msTimeout) + { + return _memoryCache.AcquireLock(key, msTimeout); + } + + /// <inheritdoc/> + public IDisposable AcquireLock(string key, int msTimeout, int msExpire, bool throwOnFailure) + { + return _memoryCache.AcquireLock(key, msTimeout, msExpire, throwOnFailure); + } + + #endregion 浜嬪姟 +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheHashService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheHashService.cs new file mode 100644 index 0000000..93e9b10 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheHashService.cs @@ -0,0 +1,45 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// <inheritdoc cref="ISimpleCacheService"/> +/// Redis缂撳瓨 +/// </summary> + +public partial class RedisCacheService : ISimpleCacheService +{ + /// <inheritdoc/> + public void HashAdd<T>(string key, string hashKey, T value) + { + _simpleRedis.HashAdd<T>(key, hashKey, value); + } + + /// <inheritdoc/> + public bool HashSet<T>(string key, Dictionary<string, T> dic) + { + return _simpleRedis.HashSet<T>(key, dic); + } + + /// <inheritdoc/> + public int HashDel<T>(string key, params string[] fields) + { + return _simpleRedis.HashDel<T>(key, fields); + } + + /// <inheritdoc/> + public List<T> HashGet<T>(string key, params string[] fields) + { + return _simpleRedis.HashGet<T>(key, fields); + } + + /// <inheritdoc/> + public T HashGetOne<T>(string key, string field) + { + return _simpleRedis.HashGetOne<T>(key, field); + } + + /// <inheritdoc/> + public IDictionary<string, T> HashGetAll<T>(string key) + { + return _simpleRedis.HashGetAll<T>(key); + } +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheService.cs new file mode 100644 index 0000000..bfb225c --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/Service/RedisCacheService.cs @@ -0,0 +1,187 @@ +锘縩amespace WIDESEA_Cache; + +/// <summary> +/// <inheritdoc cref="ISimpleCacheService"/> +/// Redis缂撳瓨 +/// </summary> +public partial class RedisCacheService : ISimpleCacheService +{ + private readonly ISimpleRedis _simpleRedis; + + public RedisCacheService(ISimpleRedis simpleRedis) + { + this._simpleRedis = simpleRedis; + } + + #region 鏅�氭搷浣� + + /// <inheritdoc/> + public T Get<T>(string key) + { + return _simpleRedis.Get<T>(key); + } + + /// <inheritdoc/> + public int Remove(params string[] keys) + { + return _simpleRedis.GetFullRedis().Remove(keys); + } + + /// <inheritdoc/> + public bool Set<T>(string key, T value, int expire = -1) + { + return _simpleRedis.Set(key, value, expire); + } + + /// <inheritdoc/> + public bool Set<T>(string key, T value, TimeSpan expire) + { + return _simpleRedis.Set(key, value, expire); + } + + /// <inheritdoc/> + public bool SetExpire(string key, TimeSpan expire) + { + return _simpleRedis.GetFullRedis().SetExpire(key, expire); + } + + /// <inheritdoc/> + public TimeSpan GetExpire(string key) + { + return _simpleRedis.GetFullRedis().GetExpire(key); + } + + /// <inheritdoc/> + public bool ContainsKey(string key) + { + return _simpleRedis.ContainsKey(key); + } + + /// <inheritdoc/> + public void Clear() + { + _simpleRedis.Clear(); + } + + /// <inheritdoc/> + public void DelByPattern(string pattern) + { + _simpleRedis.DelByPattern(pattern); + } + + #endregion 鏅�氭搷浣� + + #region 闆嗗悎鎿嶄綔 + + /// <inheritdoc/> + public IDictionary<string, T> GetAll<T>(IEnumerable<string> keys) + { + return _simpleRedis.GetFullRedis().GetAll<T>(keys); + } + + /// <inheritdoc/> + public void SetAll<T>(IDictionary<string, T> values, int expire = -1) + { + _simpleRedis.GetFullRedis().SetAll(values, expire); + } + + /// <inheritdoc/> + public IDictionary<string, T> GetDictionary<T>(string key) + { + return _simpleRedis.GetFullRedis().GetDictionary<T>(key); + } + + /// <inheritdoc/> + public IProducerConsumer<T> GetQueue<T>(string key) + { + return _simpleRedis.GetFullRedis().GetQueue<T>(key); + } + + /// <inheritdoc/> + public IProducerConsumer<T> GetStack<T>(string key) + { + return _simpleRedis.GetFullRedis().GetStack<T>(key); + } + + /// <inheritdoc/> + public ICollection<T> GetSet<T>(string key) + { + return _simpleRedis.GetFullRedis().GetSet<T>(key); + } + + #endregion 闆嗗悎鎿嶄綔 + + #region 楂樼骇鎿嶄綔 + + /// <inheritdoc/> + public bool Add<T>(string key, T value, int expire = -1) + { + return _simpleRedis.GetFullRedis().Add(key, value, expire); + } + + /// <inheritdoc/> + public IList<T> GetList<T>(string key) + { + return _simpleRedis.GetFullRedis().GetList<T>(key); + } + + /// <inheritdoc/> + public T Replace<T>(string key, T value) + { + return _simpleRedis.GetFullRedis().Replace(key, value); + } + + /// <inheritdoc/> + public bool TryGetValue<T>(string key, out T value) + { + return _simpleRedis.GetFullRedis().TryGetValue(key, out value); + } + + /// <inheritdoc/> + public long Decrement(string key, long value) + { + return _simpleRedis.GetFullRedis().Decrement(key, value); + } + + /// <inheritdoc/> + public double Decrement(string key, double value) + { + return _simpleRedis.GetFullRedis().Decrement(key, value); + } + + /// <inheritdoc/> + public long Increment(string key, long value) + { + return _simpleRedis.GetFullRedis().Increment(key, value); + } + + /// <inheritdoc/> + public double Increment(string key, double value) + { + return _simpleRedis.GetFullRedis().Increment(key, value); + } + + #endregion 楂樼骇鎿嶄綔 + + #region 浜嬪姟 + + /// <inheritdoc/> + public int Commit() + { + return _simpleRedis.GetFullRedis().Commit(); + } + + /// <inheritdoc/> + public IDisposable AcquireLock(string key, int msTimeout) + { + return _simpleRedis.GetFullRedis().AcquireLock(key, msTimeout); + } + + /// <inheritdoc/> + public IDisposable AcquireLock(string key, int msTimeout, int msExpire, bool throwOnFailure) + { + return _simpleRedis.GetFullRedis().AcquireLock(key, msTimeout, msExpire, throwOnFailure); + } + + #endregion 浜嬪姟 +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/WIDESEA_Cache.csproj b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/WIDESEA_Cache.csproj new file mode 100644 index 0000000..1cde5b8 --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Cache/WIDESEA_Cache.csproj @@ -0,0 +1,17 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="SimpleRedis" Version="1.1.9" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\WIDESEA_Core\WIDESEA_Core.csproj" /> + </ItemGroup> + +</Project> diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/DB/Models/BaseEntity.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/DB/Models/BaseEntity.cs index 81bb1a4..802ade4 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/DB/Models/BaseEntity.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/DB/Models/BaseEntity.cs @@ -50,7 +50,7 @@ [ImporterHeader(Name = "鍒涘缓鑰�")] [ExporterHeader(DisplayName = "鍒涘缓鑰�")] [SugarColumn(IsNullable = false, IsOnlyIgnoreUpdate = true, ColumnDescription = "鍒涘缓鑰�")] - public string Creater { get; set; } = "Systeam"; + public string Creater { get; set; } = "System"; /// <summary> /// 鍒涘缓鏃堕棿 diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Services/Sys_CompanyRegistrationService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Services/Sys_CompanyRegistrationService.cs index ba6272e..961ba29 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Services/Sys_CompanyRegistrationService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Services/Sys_CompanyRegistrationService.cs @@ -74,7 +74,7 @@ // 璁剧疆榛樿鍊� registration.RegistrationStatus = "寰呭鏍�"; - registration.Creater = "Systeam"; + registration.Creater = "System"; // 鍒涘缓 HTML 鏍煎紡鐨勯偖浠跺唴瀹� var bodyBuilder = new BodyBuilder(); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/MCSService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/MCSService.cs index d224489..33a5904 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/MCSService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/MCSService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using WIDESEA_Cache; using WIDESEA_IBusinessesRepository; using WIDESEA_IServices; using WIDESEA_IStorageBasicRepository; @@ -22,9 +23,11 @@ private readonly ISys_ConfigService _configService; private readonly IDt_StationManagerRepository _stationManagerRepository; private readonly IDt_AreaInfoRepository _areaInfoRepository; + + private readonly ISimpleCacheService _simpleCacheService; private readonly LogFactory LogFactory = new LogFactory(); - public MCSService(ILocationInfoRepository locationRepository,IDt_TaskRepository taskRepository,IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository,IDt_AreaInfoRepository dt_AreaInfoRepository) + public MCSService(ILocationInfoRepository locationRepository,IDt_TaskRepository taskRepository,IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository,IDt_AreaInfoRepository dt_AreaInfoRepository, ISimpleCacheService simpleCacheService) { _locationRepository = locationRepository; _taskRepository = taskRepository; @@ -32,6 +35,7 @@ _configService = configService; _stationManagerRepository = stationManagerRepository; _areaInfoRepository = dt_AreaInfoRepository; + _simpleCacheService = simpleCacheService; } } } diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs index 3029cce..a38f83b 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs @@ -105,6 +105,10 @@ if (respone.Status) { var taskId = _taskRepository.AddData(task); + location.LocationStatus = (int) LocationEnum.InStockDisable; + _locationRepository.UpdateData(location); + + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); } else @@ -116,6 +120,7 @@ { throw new Exception("WCS澶勭悊澶辫触"); } + //WMSTaskDTO taskDTO = new WMSTaskDTO //{ // Id = 0, diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs index 67b5f60..7c0c7c2 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs @@ -35,7 +35,7 @@ input.SessionId = Guid.NewGuid().ToString(); input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputJson = input.ToDictionary(); + var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); // Specify the namespace explicitly var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.AgingInput)?.ConfigValue; @@ -64,8 +64,8 @@ } catch (Exception err) { - MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.AgingInput); - Console.WriteLine(err.Message.ToString()); + //MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.AgingInput); + //Console.WriteLine(err.Message.ToString()); LogFactory.GetLog("闈欑疆闄堝寲鍏ュ簱锛堟暣鎵樼洏锛�").Error(true, $"\r\r--------------------------------------"); LogFactory.GetLog("闈欑疆闄堝寲鍏ュ簱锛堟暣鎵樼洏锛�").Error(true, err.StackTrace); } @@ -85,7 +85,7 @@ input.SessionId = Guid.NewGuid().ToString(); input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputJson = input.ToDictionary(); + var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); // Specify the namespace explicitly var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.AgingOutput)?.ConfigValue; @@ -114,8 +114,8 @@ } catch (Exception err) { - MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.AgingOutput); - Console.WriteLine(err.Message.ToString()); + //MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.AgingOutput); + //Console.WriteLine(err.Message.ToString()); LogFactory.GetLog("闈欑疆闄堝寲鍑哄簱锛堟暣鎵樼洏锛�").Error(true, $"\r\r--------------------------------------"); LogFactory.GetLog("闈欑疆闄堝寲鍑哄簱锛堟暣鎵樼洏锛�").Error(true, err.StackTrace); content.Error(err.Message); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs index 7c2baf4..e61bb34 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs @@ -42,7 +42,7 @@ input.SessionId = Guid.NewGuid().ToString(); input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputJson = input.ToDictionary(); + var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.CellState)?.ConfigValue; @@ -60,7 +60,7 @@ } catch (Exception err) { - Console.WriteLine(err.Message.ToString()); + //Console.WriteLine(err.Message.ToString()); LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Error(true, $"\r\r--------------------------------------"); LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Error(true, $"璇锋眰鍙傛暟: {JsonConvert.SerializeObject(input)}"); LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Error(true, err.Message); @@ -82,7 +82,7 @@ input.SessionId = Guid.NewGuid().ToString(); input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputJson = input.ToDictionary(); + var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.TrayCellsStatus)?.ConfigValue; @@ -111,9 +111,9 @@ } catch (Exception err) { - MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.TrayCellsStatus); + //MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.TrayCellsStatus); - Console.WriteLine(err.Message.ToString()); + //Console.WriteLine(err.Message.ToString()); LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, $"\r\r--------------------------------------"); LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, $"璇锋眰鍙傛暟: {JsonConvert.SerializeObject(input)}"); LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, err.Message); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs index 0725b0b..78df137 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs @@ -47,7 +47,7 @@ input.SessionId = Guid.NewGuid().ToString(); input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputJson = input.ToDictionary(); + var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ProcessApply)?.ConfigValue; @@ -78,7 +78,7 @@ } catch (Exception ex) { - Console.WriteLine(ex.Message); + //Console.WriteLine(ex.Message); LogFactory.GetLog("宸ヨ壓璺嚎鐢宠").Error(true, $"\r\r--------------------------------------"); LogFactory.GetLog("宸ヨ壓璺嚎鐢宠").Error(true, ex.StackTrace); } diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs index 4225e41..b84189a 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Unbind/UnbindService.cs @@ -38,7 +38,7 @@ input.EquipmentCode = "24MEJQ08-1091"; input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputJson = input.ToDictionary(); + var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); LogFactory.GetLog("鎵樼洏鍗曠數鑺В缁�1").Info(true, JsonConvert.SerializeObject(inputJson)); var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; @@ -77,7 +77,7 @@ input.EquipmentCode = "24MEJQ08-1091"; input.EmployeeNo = "MITest"; input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); - var inputJson = input.ToDictionary(); + var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); Console.WriteLine(inputJson); var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress); var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue; diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/WIDESEA_StoragIntegrationServices.csproj b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/WIDESEA_StoragIntegrationServices.csproj index 0c382c9..aa0d93c 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/WIDESEA_StoragIntegrationServices.csproj +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/WIDESEA_StoragIntegrationServices.csproj @@ -8,6 +8,7 @@ <ItemGroup> <ProjectReference Include="..\LogLibrary\LogLibrary.csproj" /> + <ProjectReference Include="..\WIDESEA_Cache\WIDESEA_Cache.csproj" /> <ProjectReference Include="..\WIDESEA_Common\WIDESEA_Common.csproj" /> <ProjectReference Include="..\WIDESEA_IStoragIntegrationServices\WIDESEA_IStoragIntegrationServices.csproj" /> <ProjectReference Include="..\WIDESEA_Services\WIDESEA_Services.csproj" /> diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs index dd91382..1e19635 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs @@ -201,7 +201,7 @@ RoadwayNo = locType > 1 ? $"GWSC{((line - 1) / 4) + 1}" : $"GWSC{((line - 1) / 2) + 1}", LocationStatus = LocationEnum.Free.ObjToInt(), AreaId = areaId, - Creater = "systeam", + Creater = "System", EnalbeStatus = 2, }); } diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs index 2146ea2..271e0af 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs @@ -1,6 +1,7 @@ 锘縰sing Masuit.Tools; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using WIDESEA_Cache; using WIDESEA_Core.Const; using WIDESEA_DTO.WMS; using WIDESEA_IServices; @@ -17,10 +18,11 @@ private readonly IDt_StationManagerRepository _stationManagerRepository; private readonly ISys_ConfigService _configService; private readonly ILocationInfoRepository _locationRepository; + private readonly ISimpleCacheService _simpleCacheService; private Timer _timer; - public MyBackgroundService(ILogger<MyBackgroundService> logger, ILocationInfoRepository locationRepository, IStockInfoRepository stockInfoRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService) + public MyBackgroundService(ILogger<MyBackgroundService> logger, ILocationInfoRepository locationRepository, IStockInfoRepository stockInfoRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService, ISimpleCacheService simpleCacheService) { _logger = logger; _locationRepository = locationRepository; @@ -29,11 +31,12 @@ _taskRepository = taskRepository; _stationManagerRepository = stationManagerRepository; _configService = configService; + _simpleCacheService = simpleCacheService; } public Task StartAsync(CancellationToken cancellationToken) { - _timer = new Timer(DoWork, null, 0, 10000); + _timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(5)); return Task.CompletedTask; } @@ -44,11 +47,12 @@ var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == "GWSC1"); if (area == null) { return; } - var stockInfo = _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo - .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails - .Where(x => x.AreaCode == area.AreaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 杩囨护鏉′欢 - .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 杩囨护鏉′欢 + + IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); + List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); + + var stockInfo = stockInfoList.Where(x => x.AreaCode == area.AreaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 杩囨护鏉′欢 + .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 杩囨护鏉′欢 .OrderBy(x => x.OutboundTime) // 鎺掑簭 .ToList(); // 鑾峰彇绗竴涓厓绱� @@ -135,7 +139,7 @@ Creater = "System", // 淇鎷煎啓閿欒 CreateDate = DateTime.Now, TaskId = 0, - ProductionLine= stockInfo.ProductionLine, + ProductionLine = stockInfo.ProductionLine, ProcessCode = stockInfo.ProcessCode, }; } diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs index cad83fa..eda759d 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -1,7 +1,8 @@ -锘縰sing Autofac.Core; -using Mapster; +锘縰sing Mapster; using Masuit.Tools; +using SqlSugar; using System.Text.RegularExpressions; +using WIDESEA_Cache; using WIDESEA_Core.Const; using WIDESEA_DTO.MOM; using WIDESEA_DTO.WMS; @@ -9,7 +10,6 @@ using WIDESEA_IStoragIntegrationServices; using WIDESEAWCS_BasicInfoRepository; using WIDESEAWCS_QuartzJob.Models; - namespace WIDESEA_StorageTaskServices; @@ -31,6 +31,7 @@ private readonly IAgingInOrOutInputService _agingInOrOutInputService; //闈欑疆\闄堝寲 private readonly IDt_StationManagerRepository _stationManagerRepository; private readonly ISys_ConfigService _configService; + private readonly ISimpleCacheService _simpleCacheService; public Dt_TaskService(IDt_TaskRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, @@ -48,7 +49,8 @@ IAgingInOrOutInputService agingInOrOutInputService, IStockInfoDetailRepository stockInfoDetailRepository, IDt_StationManagerRepository stationManagerRepository, - ISys_ConfigService configService) : base(BaseDal) + ISys_ConfigService configService, + ISimpleCacheService simpleCacheService) : base(BaseDal) { _unitOfWorkManage = unitOfWorkManage; _stockInfoRepository = stockInfoRepository; @@ -65,6 +67,7 @@ _stockInfoDetailRepository = stockInfoDetailRepository; _stationManagerRepository = stationManagerRepository; _configService = configService; + _simpleCacheService = simpleCacheService; } #region 澶栭儴鎺ュ彛鏂规硶 @@ -78,86 +81,6 @@ { if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) { - #region 鑰佺増鏈� - //var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>() - // .FirstAsync(x => x.EquipmentName == task.Roadway); - //var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue); - //if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB") //闈炲垎瀹瑰簱鍖轰笌褰撳墠宸ュ簭鏄疧CVB鍧囦笂鎶OM鍑哄叆绔� - //{ - // var agingOutputDto = MapToAgingOutputDto(stock); - // content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); - // //ValidateResponse(content); - // var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); - // if (!result.Success || !agingOutputDto.SerialNos[0].SerialNoResult) - // { - // if (result.MessageCode == "E10001") - // { - // var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode); - // if (area == null) - // { - // throw new Exception("鏈壘鍒板搴旂殑搴撳尯淇℃伅"); - // } - // var trayCells = new TrayCellsStatusDto() - // { - // Software = area.Spare3, - // TrayBarcode = task.PalletCode, - // EquipmentCode = area.Spare2, - // SceneType = area.Spare4 - // }; - // content = await _cellStateService.GetTrayCellStatusAsync(trayCells); - // if (!content.Status) return content; - - // var ResultTray = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); - // if (ResultTray.SerialNos.Count > 0) - // { - // var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stock.ParameterInfos).FirstOrDefault(y => y.Description.Contains("鏃堕棿")); - // if (parameterInfo == null) throw new Exception(""); - - // var outHours = (DateTime.Now - (stock.LinedProcessFeedbackTime == null ? stock.CreateDate : stock.LinedProcessFeedbackTime.ToDateTime())).TotalHours; - - // var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble(); - - // var defectCode = string.Empty; - // if (!isNG) defectCode = "TQCK"; - // var outputDto = new AgingOutputDto - // { - // OpFlag = 1, - // Software = area.Spare3, - // EquipmentCode = area.Spare2, - // TrayBarcode = stock.PalletCode, - // SerialNos = ResultTray.SerialNos.Select(x => new SerialNoOutDto - // { - // SlotNo = x.PositionNo, - // SerialNo = x.SerialNo, - // SerialNoResult = true, //isNG, - // ParameterInfo = new List<ParameterInfoOutput> { - // new ParameterInfoOutput() { - // Value = outHours.ToString(), - // ParameterCode =parameterInfo.ParameterCode, - // ParameterDesc = parameterInfo.Description, - // ParameterResult = "OK", //isNG.ToString(), - // TargetValue = parameterInfo.TargetValue, - // LowerLomit = parameterInfo.LowerSpecificationsLimit, - // UpperLimit = parameterInfo.UpperSpecificationsLimit, - // DefectCode = defectCode, - // UOMCode = parameterInfo.UOMCode, - // } - // } - // }).ToList() - // }; - - // content = await _agingInOrOutInputService.GetOCVOutputAsync(outputDto); - // result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); - // if (!result.Success) - // task.Remark = "NG"; - // } - // } - // else - // task.Remark = "NG"; - // } - //} - #endregion 鑰佺増鏈� - if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) { if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB") @@ -189,12 +112,12 @@ ConsoleHelper.WriteErrorLine("MOM閫氭姤鐐硅姱NG"); return content.Error("MOM閫氭姤鐐硅姱NG"); } - // 鏇存柊搴撳瓨鐘舵�佸拰浠诲姟鐘舵�� (var loc, var tas) = UpdateStockAndTaskStatus(stock, task); var taskHty = task.Adapt<Dt_Task_Hty>(); taskHty.FinishTime = DateTime.Now; - taskHty.OperateType = (int)OperateTypeEnum.鑷姩瀹屾垚; + taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.浜哄伐瀹屾垚 : (int)OperateTypeEnum.鑷姩瀹屾垚; + taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System"; DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); stockInfo_Hty.ModifyDate = DateTime.Now; @@ -212,6 +135,20 @@ await DeleteTaskAsync(task.TaskId); await AddTaskHtyAsync(taskHty); }); + try + { + //using (_simpleCacheService.AcquireLock(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, 2000)) + //{ + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { stock.PalletCode }); + //} + } + catch (Exception ex) + { + LogFactory.GetLog("鍒犻櫎缂撳瓨澶辫触").Error(true, $"{stock.PalletCode}_鍒犻櫎缂撳瓨澶辫触锛屽紓甯镐俊鎭細{ex.Message}"); + //using (_simpleCacheService.AcquireLock(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, 2000)) + //{ + //} + } return content.OK("浠诲姟瀹屾垚鎴愬姛", task.Remark); } @@ -222,7 +159,7 @@ } } - private AgingOutputDto MapToAgingOutputDto(DtStockInfo stock, ResponseEqptRunDto info = null) + private AgingOutputDto MapToAgingOutputDto(DtStockInfo stock, ResponseEqptRunDto? info = null) { // TODO Value鍊兼牴鎹甅OM涓嬪彂鐨勯潤缃椂闂村埌褰撳墠鏃堕棿鐨勫垎閽熸暟 var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode); @@ -446,6 +383,20 @@ if (isResult) { _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInf, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum); + + stock.StockInfoDetails = new List<DtStockInfoDetail>() { { stock.StockInfoDetails[0] } }; + stock.LocationInfo = locationInf; + //using(_simpleCacheService.AcquireLock(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, 2000)) + //{ + try + { + _simpleCacheService.HashAdd(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, stock.PalletCode, stock); + } + catch (Exception ex) + { + LogFactory.GetLog("娣诲姞缂撳瓨澶辫触").Error(true, $"{stock.PalletCode}_娣诲姞缂撳瓨澶辫触锛屽紓甯镐俊鎭細{ex.Message}"); + } + content.OK("鍏ュ簱浠诲姟瀹屾垚鎴愬姛"); } else @@ -594,9 +545,9 @@ { isFull = respone.SpecialParameterDuration.IsNullOrEmpty(); } - if (respone.ProductionLine == null || respone.ParameterInfos == null) + if (respone.ProductionLine == null || respone.ParameterInfos == null || respone.ParameterInfos.IsNullOrEmpty()) { - throw new Exception("MOM鏁版嵁杩斿洖閿欒"); + throw new Exception($"MOM鏁版嵁杩斿洖閿欒,浜х嚎{respone.ProductionLine},ParameterInfos{respone.ParameterInfos}"); } stock.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime; stock.SpecialParameterDuration = respone.SpecialParameterDuration; @@ -678,244 +629,6 @@ #endregion 浠诲姟瀹屾垚 #region 璇锋眰浠诲姟鍏ュ簱 - - #region - - /// <summary> - /// 璇锋眰浠诲姟宸烽亾 - /// </summary> - /// <param name="input">璇锋眰妯″瀷</param> - /// <returns>鍖呭惈浠诲姟淇℃伅鐨勫搷搴斿唴瀹�</returns> - public async Task<WebResponseContent> RequestTaskAsync2(RequestTaskDto input) - { - // 鍒涘缓涓�涓猈ebResponseContent瀵硅薄 - WebResponseContent content = new WebResponseContent(); - - try - { - // 璋冪敤BaseDal.QueryFirstAsync鏂规硶锛屾煡璇换鍔� - var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == input.PalletCode); - if (task != null) - { - //if (task.TaskState == (int)TaskInStatusEnum.InNew) - { - // 鍒涘缓WMS浠诲姟 - WMSTaskDTO taskDTO = new WMSTaskDTO() - { - TaskNum = task.TaskNum.Value, - Grade = 1, - PalletCode = task.PalletCode, - RoadWay = task.Roadway, - SourceAddress = task.SourceAddress, - TargetAddress = task.Roadway, - TaskState = task.TaskState.Value, - Id = 0, - TaskType = task.TaskType, - }; - return content.OK(data: taskDTO); - } - } - - var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == input.PalletCode && x.IsFull); - if (stock != null) - { - // TODO璐ㄦ鍥炲簱 - } - - var area = await _areaInfoRepository.QueryFirstAsync(x => x.Spare1.Contains(input.Position)); - if (area == null) - return content.Error("鏀圭偣浣嶄笉鍦ㄥ尯鍩熷垪琛ㄤ腑瀛樺湪"); - - // 鍒涘缓涓�涓猅rayCellsStatusDto瀵硅薄锛屽苟璧嬪�� - TrayCellsStatusDto trayCells = new TrayCellsStatusDto() - { - Software = area.Spare3, - TrayBarcode = input.PalletCode, - EquipmentCode = area.Spare2, - SceneType = area.Spare4, - }; - - // 璋冪敤GetTrayCellStatusAsync鏂规硶锛岃幏鍙栨暣鐩樼數鑺� - content = await GetTrayCellStatusAsync(trayCells); - // 濡傛灉鐘舵�佷负false锛屽垯杩斿洖content - if (!content.Status) return content; - - // 娣诲姞缁勭洏淇℃伅 - // 灏哻ontent.Data杞崲涓篟esultTrayCellsStatus瀵硅薄 - var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); - if (!result.Success) - return content.Error(result.MOMMessage); - - // 鑾峰彇寮傚父鐢佃姱 - List<SerialNoDto>? serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList(); - if (serialNosError.Count > 0) - { - // TODO 鍒涘缓浠诲姟閫佽嚦NG鎺掑嚭鍙� - var efg = _stationManagerRepository.QueryData(x => x.stationType == 1 && x.stationChildCode == input.Position && x.stationArea == area.AreaCode).ToList(); - //List<string> NGStation = input.Position == "1088" ? new List<string>() { "1020" } : new List<string>() { "JZSC01" }; - if (efg.Count <= 0) - { - throw new Exception("鏈壘鍒癗G鍏ュ簱绔欏彴閰嶇疆"); - } - List<string> NGStation = efg.Select(x => x.stationNGLocation).ToList(); - if (NGStation.Count <= 0) - { - NGStation = efg.Select(x => x.stationNGChildCode).ToList(); - } - content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, NGStation, 2); - return content.Error("瀛樺湪寮傚父鐢佃姱"); - } - - if (result.SerialNos.Count <= 0) - { - // Todo 绌烘墭鐩樺叆搴撻�昏緫 - content = await RequestTrayInTaskAsync(input); - return content; - } - - var boxing = CreateBoxingInfo(result, input.PalletCode); - //Console.WriteLine(boxing.ToJsonString()); - if (boxing == null) return content.Error("缁勭洏澶辫触"); - - if (result.ProcessCode == "OCVB") - { - //TODO 鍒ゆ柇闇�涓嶉渶瑕佸幓鍖呰锛屼笉闇�瑕佸氨鍘诲父娓╀笁 - var stationManagers = _stationManagerRepository.QueryData(x => x.stationPLC == "1018" && x.stationArea == "Cache"); - var station = stationManagers.Select(x => x.stationChildCode).ToList(); - - // 鑾峰彇WCSip鍦板潃 - var configz = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); - var wcsBasez = configz.Where(x => x.ConfigKey == SysConfigConst.WCSIPAddress).FirstOrDefault()?.ConfigValue; - var address = configz.Where(x => x.ConfigKey == SysConfigConst.GetStation).FirstOrDefault()?.ConfigValue; - if (wcsBasez == null || address == null) - { - throw new InvalidOperationException("WCS IP 鏈厤缃�"); - } - var wcsIpAddrss = wcsBasez + address; - - var abc = HttpHelper.PostAsync(wcsIpAddrss, station.ToJsonString()).Result; - content = JsonConvert.DeserializeObject<WebResponseContent>(abc); - if (content.Data.ObjToInt() > 0) - { - // TODO 閫佽嚦鍖呰 - List<string> strings = stationManagers.Where(x => x.stationType == 0).Select(x => x.Roadway).ToList(); - content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings, 3); - return content; - } - else - { - var config = _configService.GetByConfigKey("SYS_InStacker", "CW3InStacker"); - var strings = config.ConfigValue.Split(',').ToList(); - // TODO 鍏ュ簱 - content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings); - if (content.Status) - await _boxingInfoRepository.AddDataNavAsync(boxing); - } - } - else - { - // TODO 鑾峰彇鏈湴鏂欐灞炴�т笌鏁寸洏鐢佃姱灞炴�ц幏鍙栫殑鍊艰繘琛屽姣旓紝濡傛灉涓�鑷村垯缁х画锛屽惁鍒欒繑鍥為敊璇俊鎭� - //var productions = await _productionRepository.QueryDataAsync(x => result.TrayBarcodePropertys.Select(x => x.TrayBarcodeProperty).ToList().Contains(x.TrayBarcodeProperty)); - //if (productions.Count <= 0) - // return content.Error("鏂欐灞炴�т笉瀛樺湪"); - - // 璋冪敤CreateBoxingInfo鏂规硶锛屽垱寤虹粍鐩樹俊鎭� - - //var boxing = CreateBoxingInfo(result, input.PalletCode); - ////Console.WriteLine(boxing.ToJsonString()); - //if (boxing == null) return content.Error("缁勭洏澶辫触"); - - // 璋冪敤GetProcessApplyAsync鏂规硶锛岃幏鍙栧伐鑹鸿矾绾� - ProcessApplyDto process = await GetProcessApplyAsync(result); - - // 濡傛灉process涓簄ull锛屽垯杩斿洖content - if (process == null) return content; - - // 骞惰祴鍊间笂浣嶈蒋浠跺悕绉板拰璁惧缂栫爜 - process.Software = area.Spare3; - process.EquipmentCode = area.Spare2; - - // 璋冪敤GetProcessApplyAsync鏂规硶锛岃幏鍙栧伐鑹虹敵璇� - - // 璋冪敤_processApplyService.GetProcessApplyAsync鏂规硶锛岃幏鍙栧伐鑹虹敵璇� - content = await _processApplyService.GetProcessApplyAsync(process); - - // 濡傛灉鐘舵�佷负false锛屽垯杩斿洖null - if (!content.Status) return content.Error("宸ヨ壓鐢宠澶辫触"); - - var resultProcessApply = JsonConvert.DeserializeObject<ResultProcessApply>(content.Data.ToString()); - if (!resultProcessApply.Success) return content.Error("宸ヨ壓鐢宠澶辫触"); - - var number = resultProcessApply.ProcessInfo.Where(x => x.ProcessCode == boxing.ProcessCode).FirstOrDefault().Number.ToInt32(); - foreach (var item in resultProcessApply.ProcessInfo) - { - if (item.Number.ToInt32() == number + 1) - { - boxing.NextProcessCode = item.ProcessCode; - } - } - Console.WriteLine(); - Console.WriteLine($"褰撳墠宸ュ簭锛歿boxing.ProcessCode}"); - Console.WriteLine($"涓嬩竴宸ュ簭锛歿boxing.NextProcessCode}"); - - Console.WriteLine(area.AreaCode + "-----------------------"); - Console.WriteLine(input.Position + "-----------------------"); - - var areaIn = string.Empty; - switch (boxing.NextProcessCode) - { - case "CH01": - areaIn = "CH001"; - break; - - case "JZ01": - areaIn = "JZ001"; - break; - - case "GW01": - areaIn = "GWSC1"; - break; - - case "CW01": - areaIn = "CWSC1"; - break; - - case "CW02": - areaIn = "CWSC2"; - break; - - default: - break; - } - - var stationManagers = _stationManagerRepository.QueryData(x => x.stationType == 1 && x.stationChildCode == input.Position && x.stationArea.Contains(areaIn)).FirstOrDefault(); - if (stationManagers == null) - { - throw new Exception("鏈壘鍒板叆搴撶珯鍙伴厤缃�"); - } - List<string> strings = stationManagers.Roadway.Split(',').ToList(); - Console.WriteLine(strings.ToJsonString() + "b-----------------------"); - //// 璋冪敤CreateNewTask鏂规硶锛屽垱寤烘柊浠诲姟 - content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings); - if (content.Status) - { - var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing); - } - //} - } - } - catch (Exception err) - { - // 濡傛灉鍙戠敓寮傚父锛屽垯璋冪敤content.Error鏂规硶锛岃褰曢敊璇俊鎭紝骞惰緭鍑洪敊璇俊鎭� - content.Error(err.Message); - Console.WriteLine(err.Message); - } - - // 杩斿洖content - return content; - } - - #endregion 璇锋眰浠诲姟鍏ュ簱 public async Task<WebResponseContent> RequestTaskAsync(RequestTaskDto input) { @@ -1001,7 +714,6 @@ return content.Error(result.MOMMessage); } - if (result.SerialNos.Count <= 0) { var config = _configService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStacker, SysConfigConst.InboundIsEmpty); @@ -1079,18 +791,6 @@ { // 鍒涘缓WMS浠诲姟 WMSTaskDTO taskDTO = CreateTaskDTO(task); - //WMSTaskDTO taskDTO = new WMSTaskDTO() - //{ - // TaskNum = task.TaskNum.Value, - // Grade = 1, - // PalletCode = task.PalletCode, - // RoadWay = task.Roadway, - // SourceAddress = task.SourceAddress, - // TargetAddress = task.Roadway, - // TaskState = task.TaskState.Value, - // Id = 0, - // TaskType = task.TaskType, - //}; return content.OK(data: task); } @@ -1117,7 +817,6 @@ ConsoleHelper.WriteErrorLine($"褰撳墠鎵樼洏鏃犱骇绾�,鑱旂郴MOM娣诲姞浜х嚎"); return content.Error("褰撳墠鎵樼洏鏃犱骇绾�,鑱旂郴MOM娣诲姞浜х嚎"); } - var stationManagers = _stationManagerRepository.QueryData(x => x.stationType == 6 && x.stationChildCode == input.Position).FirstOrDefault(); if (stationManagers == null) @@ -1177,7 +876,7 @@ }; } - #endregion 澶栭儴鎺ュ彛鏂规硶 + #endregion 璇锋眰浠诲姟鍏ュ簱 #region 璇锋眰鍑哄簱锛堝疄鐩�&绌虹洏锛� @@ -1205,7 +904,6 @@ } //ConsoleHelper.WriteColorLine(JsonConvert.SerializeObject(stockInfo), ConsoleColor.DarkMagenta); - // 鏂板閲嶅浠诲姟鏍¢獙 var hasTask = BaseDal.QueryFirst(x => x.PalletCode == stockInfo.PalletCode); @@ -1240,7 +938,7 @@ { // 璁板綍寮傚父淇℃伅骞舵姏鍑� LogFactory.GetLog("璇锋眰鎵樼洏浠诲姟").Error(true, ex); - ConsoleHelper.WriteErrorLine("璇锋眰绌�/瀹炴墭鐩樹换鍔�" + ex.Message); + ConsoleHelper.WriteErrorLine("璇锋眰绌�/瀹炴墭鐩樹换鍔�" + ex.Message + "\r\n" + ex.StackTrace); return content.Error(ex.Message); } } @@ -1250,35 +948,52 @@ /// </summary> private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, List<string> devices, string productionLine) { - var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); - if (area == null) + try { - ConsoleHelper.WriteErrorLine($"鏌ヨ瀹炵洏搴撳瓨淇℃伅鏃�,鏈壘鍒板尯鍩熶唬鐮佷负{areaCode}鐨勬暟鎹�"); + var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); + if (area == null) + { + ConsoleHelper.WriteErrorLine($"鏌ヨ瀹炵洏搴撳瓨淇℃伅鏃�,鏈壘鍒板尯鍩熶唬鐮佷负{areaCode}鐨勬暟鎹�"); + return null; + } + + var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); + List<string>? materielCodes = outBoundMateriel.Count != 0 + ? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == area.AreaCode) + .Select(x => x.MaterielCode) + .ToList() + : null; + + IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); + List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); + var result = new DtStockInfo(); + + //if (stockInfoList.IsNullOrEmpty()) + //{ + // stockInfoList = await _stockInfoRepository.Db.Queryable<DtStockInfo>() + // .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock).IncludesAllFirstLayer().ToListAsync(); + //} + + result = stockInfoList.Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull) + .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) + .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) + .WhereIF(!devices.IsNullOrEmpty(), x => devices.Contains(x.LocationInfo.RoadwayNo)) + .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) + .OrderBy(x => x.OutboundTime) + .FirstOrDefault(); + + if (result != null) + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); + else + ConsoleHelper.WriteErrorLine("QueryStockInfoForRealTrayAsync鏌ヨ瀹炵洏搴撳瓨淇℃伅澶辫触:鏈壘鍒扮鍚堟潯浠剁殑鏁版嵁"); + + return result; + } + catch (Exception ex) + { + ConsoleHelper.WriteErrorLine("QueryStockInfoForRealTrayAsync鏌ヨ瀹炵洏搴撳瓨淇℃伅澶辫触:" + ex.Message + "\r\n" + ex.StackTrace); return null; } - - var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); - List<string> materielCodes = null; - if (outBoundMateriel.Count != 0) - { - materielCodes = outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == area.AreaCode).Select(x => x.MaterielCode).ToList(); - } - - var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo - .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails - .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 杩囨护鏉′欢 - .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) - .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 - .WhereIF(!devices.IsNullOrEmpty(), x => devices.Contains(x.LocationInfo.RoadwayNo)) - .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) - .OrderBy(x => x.OutboundTime) // 鎺掑簭 - .FirstAsync(); // 鑾峰彇绗竴涓厓绱� - - //var firstOrDefault = result.FirstOrDefault(x => roadways.Contains(x.LocationInfo.RoadwayNo)); // 鏌ユ壘绗竴涓尮閰嶇殑鍏冪礌 - //var firstOrDefault = result[0]; // 鏌ユ壘绗竴涓尮閰嶇殑鍏冪礌 - //return firstOrDefault; - return result; } /// <summary> @@ -1286,42 +1001,62 @@ /// </summary> private async Task<DtStockInfo> QueryStockInfoForRealTrayCWAsync(List<string> areaCodes, string productionLine) { - var areaId = (await _areaInfoRepository.QueryDataAsync(x => areaCodes.Contains(x.AreaCode))).Select(x => x.AreaID).ToList(); - if (areaId.Count == 0) + try { - ConsoleHelper.WriteErrorLine($"鏌ヨ甯告俯瀹炵洏搴撳瓨淇℃伅鏃�,鏈壘鍒板尯鍩熶唬鐮佷负{JsonConvert.SerializeObject(areaCodes)}鐨勬暟鎹�"); + var areaId = (await _areaInfoRepository.QueryDataAsync(x => areaCodes.Contains(x.AreaCode))).Select(x => x.AreaID).ToList(); + if (areaId.Count == 0) + { + ConsoleHelper.WriteErrorLine($"鏌ヨ甯告俯瀹炵洏搴撳瓨淇℃伅鏃�,鏈壘鍒板尯鍩熶唬鐮佷负{JsonConvert.SerializeObject(areaCodes)}鐨勬暟鎹�"); + return null; + } + + //var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); + //List<string> materielCodes = null; + //if (outBoundMateriel.Count != 0) + //{ + // materielCodes = outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0]).Select(x => x.MaterielCode).ToList(); + //} + + var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); + List<string>? materielCodes = outBoundMateriel.Count != 0 + ? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0]) + .Select(x => x.MaterielCode) + .ToList() + : null; + + var deviceCode = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() + .Where(x => x.DeviceStatus == "1") + .Where(x => x.DeviceCode.Contains("CWSC")) + .ToList().Select(x => x.DeviceCode).ToList(); + //var deviceCode = devices.Select(x => x.DeviceCode).ToList(); + + IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); + List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); + + var result = stockInfoList.Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 杩囨护鏉′欢 + .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) + .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 + .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) + .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) + .OrderBy(x => x.OutboundTime) // 鎺掑簭 + .FirstOrDefault(); // 鑾峰彇绗竴涓厓绱� + + if (result != null) + { + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); + } + else + { + ConsoleHelper.WriteErrorLine("QueryStockInfoForRealTrayCWAsync鏌ヨ甯告俯瀹炵洏搴撳瓨淇℃伅澶辫触:鏈壘鍒扮鍚堟潯浠剁殑鏁版嵁"); + } + + return result; + } + catch (Exception ex) + { + ConsoleHelper.WriteErrorLine("QueryStockInfoForRealTrayCWAsync鏌ヨ瀹炵洏搴撳瓨淇℃伅澶辫触:" + ex.Message + "\r\n" + ex.StackTrace); return null; } - - - var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); - List<string> materielCodes = null; - if (outBoundMateriel.Count != 0) - { - materielCodes = outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0]).Select(x => x.MaterielCode).ToList(); - } - - var devices = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() - .Where(x => x.DeviceStatus == "1") - .Where(x => x.DeviceCode.Contains("CWSC")) - .ToList(); - var deviceCode = devices.Select(x => x.DeviceCode).ToList(); - - var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo - .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails - .Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 杩囨护鏉′欢 - .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) - .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 - .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) - .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) - .OrderBy(x => x.OutboundTime) // 鎺掑簭 - .FirstAsync(); // 鑾峰彇绗竴涓厓绱� - - //var firstOrDefault = result.FirstOrDefault(x => roadways.Contains(x.LocationInfo.RoadwayNo)); // 鏌ユ壘绗竴涓尮閰嶇殑鍏冪礌 - //var firstOrDefault = result[0]; // 鏌ユ壘绗竴涓尮閰嶇殑鍏冪礌 - //return firstOrDefault; - return result; } /// <summary> @@ -1329,36 +1064,44 @@ /// </summary> private async Task<DtStockInfo> QueryStockInfoForEmptyTrayAsync(string areaCode, string position) { - var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); + try + { + var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); - ConsoleHelper.WriteColorLine(position + "..." + areaCode, ConsoleColor.Magenta); - var station = await _stationManagerRepository.QueryFirstAsync(x => x.stationChildCode == position && x.stationType == 17); + ConsoleHelper.WriteColorLine(position + "..." + areaCode, ConsoleColor.Magenta); + var station = await _stationManagerRepository.QueryFirstAsync(x => x.stationChildCode == position && x.stationType == 17); - ConsoleHelper.WriteColorLine(station.Roadway, ConsoleColor.Magenta); - var stackers = station.Roadway.Split(',').ToList(); + ConsoleHelper.WriteColorLine(station.Roadway, ConsoleColor.Magenta); + var stackers = station.Roadway.Split(',').ToList(); + var deviceCode = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() + .Where(x => x.DeviceStatus == "1") + .Where(x => stackers.Contains(x.DeviceCode)) + .ToList().Select(x => x.DeviceCode).ToList(); - var devices = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() - .Where(x => x.DeviceStatus == "1") - .Where(x => stackers.Contains(x.DeviceCode)) - .ToList(); + IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); + List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); - var deviceCode = devices.Select(x => x.DeviceCode).ToList(); + var result = stockInfoList.Where(x => x.ProductionLine == station.productLine) + .Where(x => x.AreaCode == areaCode && x.IsFull == false) + .Where(x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => y.MaterielCode == "绌烘墭鐩�")) + .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 + .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) + .OrderBy(x => x.CreateDate) // 鎺掑簭 + .FirstOrDefault(); // 杞崲涓哄垪琛� - var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo - .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails - .Where(x => x.ProductionLine == station.productLine) - .Where(x => x.AreaCode == areaCode && x.IsFull == false) - .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "绌烘墭鐩�")) - .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 - .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) - .OrderBy(x => x.CreateDate) // 鎺掑簭 - .FirstAsync(); // 杞崲涓哄垪琛� + if (result != null) + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); + else + ConsoleHelper.WriteErrorLine("QueryStockInfoForEmptyTrayAsync鏌ヨ绌虹洏搴撳瓨淇℃伅澶辫触:鏈壘鍒扮鍚堟潯浠剁殑鏁版嵁"); - //var firstOrDefault = result[0]; // 鏌ユ壘绗竴涓尮閰嶇殑鍏冪礌 - //return firstOrDefault; - return result; + return result; + } + catch (Exception ex) + { + ConsoleHelper.WriteErrorLine("QueryStockInfoForEmptyTrayAsync鏌ヨ瀹炵洏搴撳瓨淇℃伅澶辫触:" + ex.Message + "\r\n" + ex.StackTrace); + return null; + } } /// <summary> @@ -1684,7 +1427,7 @@ // content.Error(ex.Message); //} //return content; - #endregion + #endregion 闈欑疆寮傚父鍙e叆搴� WebResponseContent content = new WebResponseContent(); try { @@ -1754,7 +1497,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskInboundTypeEnum.Inbound, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -1792,7 +1535,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskInboundTypeEnum.InTray, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -1825,7 +1568,6 @@ } return content; } - private WMSTaskDTO CreateWMSTaskDTO(object source) { @@ -1867,11 +1609,9 @@ } } - #endregion 闈欑疆寮傚父鍙e叆搴� - #endregion 澶栭儴鎺ュ彛鏂规硶 - + #endregion 澶栭儴鎺ュ彛鏂规硶 #region 鍐呴儴璋冪敤鏂规硶 @@ -2063,7 +1803,7 @@ var taskHty = _mapper.Map<Dt_Task_Hty>(task); taskHty.FinishTime = DateTime.Now; taskHty.TaskId = 0; - taskHty.OperateType = isHand ? (int)OperateTypeEnum.浜哄伐鍒犻櫎 : (int)OperateTypeEnum.鑷姩瀹屾垚; + taskHty.OperateType = isHand ? (int)OperateTypeEnum.浜哄伐鍒犻櫎 : App.User.UserName != null ? (int)OperateTypeEnum.浜哄伐瀹屾垚 : (int)OperateTypeEnum.鑷姩瀹屾垚; taskHty.SourceId = task.TaskId; if (isHand) { @@ -2125,33 +1865,34 @@ } } - if (stock.IsFull) - { - // 鏌ヨ绗﹀悎鏉′欢鐨勫簱瀛樹俊鎭� - var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration); + #region 鏇存柊搴撳瓨淇℃伅锛堟殏鏃朵笉闇�瑕侊級 + //if (stock.IsFull) + //{ + // // 鏌ヨ绗﹀悎鏉′欢鐨勫簱瀛樹俊鎭� + // var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration); - // 鏌ヨ浠诲姟淇℃伅 - var tasks = BaseDal.QueryData(x => x.PalletCode != stock.PalletCode && x.ProductionLine == stock.ProductionLine).Select(x => x.PalletCode).ToList(); + // // 鏌ヨ浠诲姟淇℃伅 + // var tasks = BaseDal.QueryData(x => x.PalletCode != stock.PalletCode && x.ProductionLine == stock.ProductionLine).Select(x => x.PalletCode).ToList(); - if (stocks != null && stocks.Count > 0) - { - // 杩囨护鍑洪渶瑕佹洿鏂扮殑搴撳瓨淇℃伅 - var stocksToUpdate = stocks.Where(item => !tasks.Contains(item.PalletCode)).ToList(); - foreach (var item in stocksToUpdate) - { - // 鏇存柊搴撳瓨淇℃伅鐨勭壒瀹氬弬鏁� - item.SpecialParameterDuration = stock.SpecialParameterDuration; - item.ParameterInfos = stock.ParameterInfos; - item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration)); - } - if (stocksToUpdate.Count > 0) - { - // 寮傛鏇存柊搴撳瓨淇℃伅 - var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocksToUpdate); - } - } - } - + // if (stocks != null && stocks.Count > 0) + // { + // // 杩囨护鍑洪渶瑕佹洿鏂扮殑搴撳瓨淇℃伅 + // var stocksToUpdate = stocks.Where(item => !tasks.Contains(item.PalletCode)).ToList(); + // foreach (var item in stocksToUpdate) + // { + // // 鏇存柊搴撳瓨淇℃伅鐨勭壒瀹氬弬鏁� + // item.SpecialParameterDuration = stock.SpecialParameterDuration; + // item.ParameterInfos = stock.ParameterInfos; + // item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration)); + // } + // if (stocksToUpdate.Count > 0) + // { + // // 寮傛鏇存柊搴撳瓨淇℃伅 + // var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocksToUpdate); + // } + // } + //} + #endregion // 娣诲姞鍘嗗彶浠诲姟 var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0; @@ -2185,7 +1926,6 @@ } #region 浠诲姟璇锋眰鏂规硶 - private static readonly SemaphoreSlim _semaphoreUpdate = new SemaphoreSlim(1, 1); // 鏇存柊浠诲姟璐т綅 @@ -2273,7 +2013,6 @@ } catch (Exception) { - throw; } finally { _semaphoreUpdate.Release(); } @@ -2344,7 +2083,7 @@ TaskState = flag == 3 ? (int)TaskOutStatusEnum.OutNew : (int)TaskInStatusEnum.InNew, TaskType = flag == 0 ? (int)TaskInboundTypeEnum.Inbound : flag == 1 ? (int)TaskInboundTypeEnum.InTray : flag == 2 ? (int)TaskInboundTypeEnum.InNG : (int)TaskOutboundTypeEnum.Outbound, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = productionLine, ProcessCode = processCode }; @@ -2387,8 +2126,8 @@ return content; } - private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); + /// <summary> /// 鏌ユ壘璐т綅 /// </summary> diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs index 514860b..528d7af 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs @@ -1,7 +1,6 @@ 锘縰sing Masuit.Tools; +using SqlSugar; using WIDESEA_Common.CustomModels; - -//using WIDESEA_Common.CustomModels; using WIDESEA_Core.Const; using WIDESEA_DTO.MOM; using WIDESEA_DTO.WMS; @@ -199,7 +198,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskOutboundTypeEnum.InToOut, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -226,7 +225,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskOutboundTypeEnum.InToOut, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam" + Creater = "System" }; return taskNG; } @@ -258,7 +257,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskOutboundTypeEnum.InToOut, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -292,7 +291,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskOutboundTypeEnum.InToOut, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -370,7 +369,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskOutboundTypeEnum.InToOut, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -420,7 +419,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = stationManager.stationType == 1 ? (int)TaskInboundTypeEnum.Inbound : (int)TaskInboundTypeEnum.InTray, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -541,12 +540,14 @@ { if (stationManager.stationType != 7) throw new Exception("閿欒鐨勮皟鍙�"); - var stockinfo = await _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Includes(x => x.LocationInfo) - //.Includes(x=>x.StockInfoDetails) - .Where(x => !x.IsFull && x.LocationInfo.RoadwayNo == stationManager.Roadway) - .OrderBy(x => x.CreateDate) - .FirstAsync(); + // 浠庣紦瀛樹腑鑾峰彇搴撳瓨淇℃伅 + IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); + List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); + + var stockinfo1 = stockInfoList.OrderBy(x => x.CreateDate) + .ToList(); + var stockinfo = stockinfo1.Where(x => x.LocationInfo != null && !x.IsFull && x.LocationInfo.RoadwayNo == stationManager.Roadway) + .FirstOrDefault(); if (stockinfo == null) return null; @@ -565,10 +566,10 @@ TaskState = (int)TaskOutStatusEnum.OutNew, TaskType = (int)TaskOutboundTypeEnum.OutTray, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = stockinfo.ProductionLine, }; - + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { task.PalletCode }); return task; } catch (Exception ex) @@ -660,7 +661,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskInboundTypeEnum.InTray, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -722,7 +723,7 @@ TaskState = (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskInboundTypeEnum.Inbound, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = result.ProductionLine, ProcessCode = result.ProcessCode, }; @@ -885,11 +886,34 @@ #region 甯告俯琛ョ┖鎵樼洏鑷冲垎瀹� + private static readonly Dictionary<string, (int Count, DateTime LastRequestTime)> requestTrackerToCW = new(); + public async Task<WebResponseContent> GetFROutTrayToCW(RequestTaskDto taskDTO) { WebResponseContent content = new WebResponseContent(); try { + //string requestKey = JsonConvert.SerializeObject(taskDTO); + //// 妫�鏌ヨ姹傛鏁板拰鏃堕棿闄愬埗 + //if (requestTrackerToCW.TryGetValue(requestKey, out var requestInfo)) + //{ + // if (requestInfo.Count > 5 && DateTime.Now < requestInfo.LastRequestTime.AddMinutes(2)) + // { + // // 濡傛灉璇锋眰娆℃暟瓒呰繃闄愬埗涓旀湭瓒呰繃10鍒嗛挓锛屾姏鍑哄紓甯� + // throw new InvalidOperationException("璇锋眰娆℃暟宸茶揪鍒伴檺鍒讹紝璇风◢鍚庡啀璇曘��"); + // } + //} + + //// 鏇存柊璇锋眰璺熻釜淇℃伅 + //if (requestTrackerToCW.ContainsKey(requestKey)) + //{ + // requestTrackerToCW[requestKey] = (requestInfo.Count + 1, DateTime.Now); + //} + //else + //{ + // requestTrackerToCW[requestKey] = (1, DateTime.Now); + //} + var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == taskDTO.Position && x.stationStatus == "1"); var locations = _locationRepository.QueryData(x => x.RoadwayNo == station.Roadway && x.LocationStatus == (int)LocationEnum.Free && x.LocationType == 1); @@ -922,6 +946,8 @@ _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum); // 杩斿洖鎴愬姛鍝嶅簲 + //requestTrackerToCW.Remove(requestKey); + return content.OK(data: wmsTask); } else @@ -948,26 +974,30 @@ ConsoleHelper.WriteColorLine(station.Roadway, ConsoleColor.Magenta); var stackers = station.Roadway.Split(',').ToList(); - var devices = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() + var deviceCode = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() .Where(x => x.DeviceStatus == "1") .Where(x => stackers.Contains(x.DeviceCode)) - .ToList(); + .ToList().Select(x => x.DeviceCode).ToList(); - var deviceCode = devices.Select(x => x.DeviceCode).ToList(); + // 浠庣紦瀛樹腑鑾峰彇搴撳瓨淇℃伅 + IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); + List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); - var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo - .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails - .Where(x => x.ProductionLine == productLine) + var result1 = stockInfoList.Where(x => x.ProductionLine == productLine) .Where(x => x.AreaCode == areaCode && x.IsFull == false) - .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "绌烘墭鐩�")) - .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 - .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) + .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo)) .OrderBy(x => x.CreateDate) // 鎺掑簭 - .FirstAsync(); // 杞崲涓哄垪琛� + .ToList(); // 杞崲涓哄垪琛� - //var firstOrDefault = result[0]; // 鏌ユ壘绗竴涓尮閰嶇殑鍏冪礌 - //return firstOrDefault; + var result = result1.Where(x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => y.MaterielCode == "绌烘墭鐩�")) + .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 + .FirstOrDefault(); // 鑾峰彇绗竴涓厓绱� + + if (result != null) + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); + else + ConsoleHelper.WriteColorLine($"甯告俯{productLine}绌烘墭鐩樺簱瀛樹笉瓒�", ConsoleColor.Red); + return result; } @@ -988,48 +1018,32 @@ WebResponseContent content = new WebResponseContent(); try { - //string requestKey = JsonConvert.SerializeObject(json); - //// 妫�鏌ヨ姹傛鏁板拰鏃堕棿闄愬埗 - //if (requestTracker.TryGetValue(requestKey, out var requestInfo)) - //{ - // if (requestInfo.Count >= 9 && DateTime.Now < requestInfo.LastRequestTime.AddMinutes(5)) - // { - // // 濡傛灉璇锋眰娆℃暟瓒呰繃闄愬埗涓旀湭瓒呰繃10鍒嗛挓锛屾姏鍑哄紓甯� - // throw new InvalidOperationException("璇锋眰娆℃暟宸茶揪鍒伴檺鍒讹紝璇风◢鍚庡啀璇曘��"); - // } - //} - - //// 鏇存柊璇锋眰璺熻釜淇℃伅 - //if (requestTracker.ContainsKey(requestKey)) - //{ - // requestTracker[requestKey] = (requestInfo.Count + 1, DateTime.Now); - //} - //else - //{ - // requestTracker[requestKey] = (1, DateTime.Now); - //} - //LogFactory.GetLog("甯告俯3鍑哄簱鑷冲寘瑁�").Info(true, $"甯告俯3鍑哄簱鑷冲寘瑁呬紶鍏ュ弬鏁帮細" + JsonConvert.SerializeObject(json, Formatting.Indented)); - Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position && x.stationType == 12 && x.stationArea == "Call"); if (station == null) { throw new Exception($"鏈壘鍒板寘瑁呯珯鍙颁俊鎭紝璇锋鏌ヤ紶鍏ュ弬鏁皗json.Position}"); } - var devices = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() + var deviceCode = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() .Where(x => x.DeviceStatus == "1") .Where(x => x.DeviceCode.Contains("CWSC")) // 杩囨护鏉′欢 + .ToList().Select(x => x.DeviceCode).ToList(); + + // 浠庣紦瀛樹腑鑾峰彇搴撳瓨淇℃伅 + IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); + List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); + + // 淇敼鍚庣殑鏌ヨ浠g爜 + var stockInfo1 = stockInfoList + .Where(x => x.ProductionLine == station.productLine) + .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true) + .OrderBy(x => x.OutboundTime) .ToList(); - var deviceCode = devices.Select(x => x.DeviceCode).ToList(); - //LogFactory.GetLog("甯告俯3鍑哄簱鑷冲寘瑁�").Info(true, $"甯告俯3鍑哄簱鑷冲寘瑁呬紶鍏ュ弬鏁帮細" + JsonConvert.SerializeObject(json, Formatting.Indented)); - var stockInfo = _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Where(x => x.ProductionLine == station.productLine) - .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo - .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true) // 杩囨护鏉′欢 - .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock) // 杩囨护鏉′欢 - .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) - .OrderBy(x => x.OutboundTime) // 鎺掑簭 - .First(); // 鑾峰彇绗竴涓厓绱� + var stockInfo = stockInfo1 + // 澧炲姞瀵� LocationInfo 鐨勭┖鍊兼鏌� + .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock) + // 澧炲姞瀵� LocationInfo 鐨勭┖鍊兼鏌� + .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo)) + .FirstOrDefault(); - //DtStockInfo stockInfo = _stockInfoRepository.QueryFirst(X => X.IsFull && X.AreaCode == "CWSC3" && X.ProductionLine == station.productLine); if (stockInfo == null) throw new Exception($"搴撳唴{station.productLine}鏃犳弧瓒虫潯浠剁殑搴撳瓨鍙嚭搴�"); DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.AreaId == 5 && x.LocationCode == stockInfo.LocationCode); @@ -1052,7 +1066,7 @@ TaskState = (int)TaskOutStatusEnum.OutNew, TaskType = (int)TaskOutboundTypeEnum.Outbound, TaskNum = await BaseDal.GetTaskNo(), - Creater = "Systeam", + Creater = "System", ProductionLine = stockInfo.ProductionLine, ProcessCode = stockInfo.ProcessCode, }; @@ -1065,6 +1079,8 @@ stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; _locationRepository.UpdateData(stockInfo.LocationInfo); + _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); + _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum); return content.OK(data: taskDTO); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj index 8b2f84d..1c51ae2 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj @@ -16,6 +16,7 @@ <ItemGroup> <ProjectReference Include="..\LogLibrary\LogLibrary.csproj" /> + <ProjectReference Include="..\WIDESEA_Cache\WIDESEA_Cache.csproj" /> <ProjectReference Include="..\WIDESEA_IBusinessServices\WIDESEA_IBusinessServices.csproj" /> <ProjectReference Include="..\WIDESEA_IStorageBasicService\WIDESEA_IStorageBasicServices.csproj" /> <ProjectReference Include="..\WIDESEA_IStorageOutOrderService\WIDESEA_IStorageOutOrderServices.csproj" /> diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer.sln b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer.sln index bb25daf..ddc6e1e 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer.sln +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer.sln @@ -78,6 +78,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WIDESEA_IStoragIntegrationServices", "WIDESEA_IStoragIntegrationServices\WIDESEA_IStoragIntegrationServices.csproj", "{94D572FA-810E-4897-B673-AF988FD4019E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WIDESEA_Cache", "WIDESEA_Cache\WIDESEA_Cache.csproj", "{461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -436,6 +438,18 @@ {94D572FA-810E-4897-B673-AF988FD4019E}.Release|Any CPU.Build.0 = Release|Any CPU {94D572FA-810E-4897-B673-AF988FD4019E}.Release|x86.ActiveCfg = Release|Any CPU {94D572FA-810E-4897-B673-AF988FD4019E}.Release|x86.Build.0 = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Debug|x86.ActiveCfg = Debug|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Debug|x86.Build.0 = Debug|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Dev|Any CPU.ActiveCfg = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Dev|Any CPU.Build.0 = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Dev|x86.ActiveCfg = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Dev|x86.Build.0 = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Release|Any CPU.Build.0 = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Release|x86.ActiveCfg = Release|Any CPU + {461A73BF-9FC7-4BFE-9BEB-2AE686CBFEEC}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs index 69acae2..cd1bff6 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs @@ -1,5 +1,4 @@ 锘縰sing WIDESEA_DTO; -using static WIDESEA_DTO.RequestTaskDto; namespace WIDESEA_WMSServer.Controllers; @@ -29,21 +28,11 @@ /// <param name="saveModel">浠诲姟鍙�</param> /// <returns>鎴愬姛鎴栧け璐�</returns> [HttpGet, Route("CompleteTaskAsync"), AllowAnonymous] + //[TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> CompleteTaskAsync(int taskNum) { return await _taskService.CompleteAsync(taskNum); } - - /// <summary> - /// 浠诲姟瀹屾垚 - /// </summary> - /// <param name="saveModel">浠诲姟鍙�</param> - /// <returns>鎴愬姛鎴栧け璐�</returns> - //[HttpGet, Route("CompleteTaskByStation"), AllowAnonymous] - //public async Task<WebResponseContent> CompleteTaskByStation(int taskNum) - //{ - // return await _taskService.CompleteTaskByStation(taskNum); - //} /// <summary> /// 妫�鏌ユ槸鍚﹂渶瑕佽繘琛岀Щ搴� @@ -51,6 +40,7 @@ /// <param name="taskNum">浠诲姟鍙�</param> /// <returns>浠诲姟</returns> [HttpGet, Route("TransferCheckAsync"), AllowAnonymous] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> TransferCheckAsync(int taskNum) { return new WebResponseContent().OK(data: await _locationService.TransferCheckAsync(taskNum)); @@ -62,6 +52,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("RequestTaskAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> RequestTaskAsync([FromBody] RequestTaskDto input) { return await Service.RequestTaskAsync(input); @@ -73,6 +64,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("RequestInTask")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> RequestInTask([FromBody] RequestTaskDto input) { return await Service.RequestInTask(input); @@ -84,6 +76,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("RequestLocationTaskAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> UpdateExistingTask([FromBody] RequestTaskDto input) { return await Service.UpdateExistingTask(input); @@ -95,17 +88,19 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("RequestTrayInTaskAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> RequestTrayInTaskAsync([FromBody] RequestTaskDto input) { return await Service.RequestTrayInTaskAsync(input); } /// <summary> - /// 绌烘墭鐩�&婊$洏鍑哄簱璇锋眰 + /// 绌烘墭鐩樻弧鐩樺嚭搴撹姹� /// </summary> /// <param name="request">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("RequestTrayOutTaskAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> RequestTrayOutTaskAsync([FromBody] RequestOutTaskDto request) { return await Service.RequestTrayOutTaskAsync(request.Position, request.Tag, request.AreaCdoe, request.AreaCdoes, request.ProductionLine); @@ -117,6 +112,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("UpdateTaskStatus")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> UpdateTaskStatus([FromBody] UpdateStatusDto input) { return await Service.UpdateTaskStatus(input.TaskNum, input.TaskState); @@ -128,6 +124,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpGet, AllowAnonymous, Route("StockCheckingAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public WebResponseContent StockCheckingAsync() { return Service.StockCheckingAsync(); @@ -140,6 +137,7 @@ /// <param name="palletCode">鎵樼洏鍙�</param> /// <returns></returns> [HttpGet, AllowAnonymous, Route("CreateAndSendOutboundTask")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> CreateAndSendOutboundTask(string locationCode, string palletCode) { return await Service.CreateAndSendOutboundTask(locationCode, palletCode); @@ -152,6 +150,7 @@ /// <param name="palletCode">鎵樼洏鍙�</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("RequestInBoundTaskNG")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> RequestInBoundTaskNG([FromBody] RequestTaskDto input) { return await Service.CreateAndSendInboundTask(input.PalletCode, input.Position); @@ -163,6 +162,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("GetFROutTrayToCW")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 15 })] // 5绉掕妭娴� public async Task<WebResponseContent> GetFROutTrayToCW([FromBody] RequestTaskDto input) { return await Service.GetFROutTrayToCW(input); @@ -174,11 +174,11 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("EmergencyTask")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public WebResponseContent EmergencyTask([FromBody] object input) { return Service.EmergencyTask(input); } - /// <summary> /// CW3 鍑哄簱鑷冲寘瑁� @@ -186,6 +186,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("RequestOutTaskToBZAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> RequestOutTaskToBZAsync([FromBody] RequestTaskDto input) { return await Service.RequestOutTaskToBZAsync(input); @@ -197,6 +198,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("SetEmptyOutbyInToOutAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> SetEmptyOutbyInToOutAsync([FromBody] RequestTaskDto input) { return await Service.SetEmptyOutbyInToOutAsync(input); @@ -208,6 +210,7 @@ /// <param name="input">璇锋眰鏁版嵁</param> /// <returns></returns> [HttpPost, AllowAnonymous, Route("SetEmptyOutbyInToOutOneAsync")] + [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴� public async Task<WebResponseContent> SetEmptyOutbyInToOutOneAsync([FromBody] RequestTaskDto input) { return await Service.SetEmptyOutbyInToOutOneAsync(input); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CheckingStockOutMiddleware.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CheckingStockOutMiddleware.cs new file mode 100644 index 0000000..7f8fb9e --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CheckingStockOutMiddleware.cs @@ -0,0 +1,27 @@ +锘� +using WIDESEA_Core.Middlewares; +using WIDESEA_IStorageTaskServices; +using WIDESEA_StorageOutTaskServices; + +namespace WIDESEA_WMSServer.Filter +{ + public static class StockOutMiddleware + { + public static Task InvokeAsync() + { + Task.Run(() => + { + while (true) + { + var _taskService = WIDESEA_Core.App.GetService<IDt_TaskService>(); + if (_taskService != null) + { + _taskService.StockCheckingAsync(); + } + Thread.Sleep(10000); + } + }); + return Task.CompletedTask; + } + } +} diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/ThrottleFilter.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/ThrottleFilter.cs new file mode 100644 index 0000000..9d1ab3b --- /dev/null +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/ThrottleFilter.cs @@ -0,0 +1,74 @@ +锘縰sing Microsoft.AspNetCore.Mvc.Filters; +using System.Collections.Concurrent; +using System.Text.Json; + +public class ThrottleFilter : IAsyncActionFilter +{ + private static readonly ConcurrentDictionary<string, DateTime> _lastExecutionTimes = new ConcurrentDictionary<string, DateTime>(); + private readonly int _intervalInSeconds; + + public ThrottleFilter(int intervalInSeconds) + { + _intervalInSeconds = intervalInSeconds; + } + + public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) + { + var actionName = context.ActionDescriptor.DisplayName; + + var parameterString = GenerateParameterString(context.ActionArguments); + var key = $"{actionName}_{parameterString}"; + + if (_lastExecutionTimes.TryGetValue(key, out var lastExecutionTime)) + { + var elapsedTime = DateTime.Now - lastExecutionTime; + if (elapsedTime.TotalSeconds < _intervalInSeconds) + { + context.Result = new OkObjectResult(new WebResponseContent().Error("璇锋眰杩囦簬棰戠箒锛岃绋嶅悗鍐嶈瘯")); + return; + } + } + + _lastExecutionTimes[key] = DateTime.Now; + await next(); + } + + private string GenerateParameterString(IDictionary<string, object> arguments) + { + if (arguments == null || arguments.Count == 0) + { + return ""; + } + + var paramStrings = new List<string>(); + foreach (var argument in arguments) + { + var key = argument.Key; + var value = argument.Value; + string valueString; + + if (value == null) + { + valueString = "null"; + } + else if (IsSimpleType(value.GetType())) + { + valueString = value.ToString(); + } + else + { + valueString = JsonSerializer.Serialize(value); + } + + paramStrings.Add($"{key}={valueString}"); + } + + return string.Join("&", paramStrings); + } + + // 鍒ゆ柇绫诲瀷鏄惁涓虹畝鍗曠被鍨� + private bool IsSimpleType(Type type) + { + return type.IsPrimitive || type == typeof(string) || type == typeof(decimal); + } +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs index c7403ba..4bcf385 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs @@ -20,6 +20,13 @@ using Swashbuckle.AspNetCore.SwaggerGen; using Microsoft.OpenApi.Models; using WIDESEA_StorageTaskServices; +using Autofac.Core; +using WIDESEA_Cache; +using SimpleRedis; +using WIDESEA_DTO.WMS; +using static NewLife.Remoting.ApiHttpClient; +using NewLife.Windows; +using WIDESEA_Core.Enums; var builder = WebApplication.CreateBuilder(args); @@ -112,8 +119,41 @@ builder.Services.AddHostedService<MyBackgroundService>(); +//缓存设置配置转实体 +builder.Services.AddConfigurableOptions<CacheSettingsOptions>(); +//禁止在主机启动时通过 App.GetOptions<TOptions> 获取选项,如需获取配置选项理应通过 App.GetConfig<TOptions>("配置节点", true)。 +var cacheSettings = AppSettings.Configuration.GetSection("CacheSettings").Get<CacheSettingsOptions>(); +//如果有redis连接字符串 +if (cacheSettings.UseRedis) +{ + var connectionString = + $"server={cacheSettings.RedisSettings.Address};db={cacheSettings.RedisSettings.Db}"; + //注入redis + builder.Services.AddSimpleRedis(connectionString); + builder.Services.AddScoped<ISimpleCacheService, RedisCacheService>(); +} +else +{ + builder.Services.AddScoped<ISimpleCacheService, MemoryCacheService>(); +} + var app = builder.Build(); + +// 验证 Redis 服务是否成功注册 +using (var scope = app.Services.CreateScope()) +{ + var services = scope.ServiceProvider; + var redisService = services.GetService<ISimpleCacheService>(); + if (redisService == null) + { + WIDESEA_Core.Helper.ConsoleHelper.WriteErrorLine("Redis 服务未成功注册"); + } + else + { + WIDESEA_Core.Helper.ConsoleHelper.WriteSuccessLine("Redis 服务已成功注册"); + } +} // 3、配置中间件 app.UseMiniProfiler();//性能分析器 @@ -151,5 +191,26 @@ app.MapControllers(); +//通过 App.GetOptions<TOptions> 获取选项 +var cacheSettingsb = App.GetOptions<CacheSettingsOptions>(); +//如果需要清除缓存 +if (cacheSettingsb.UseRedis && cacheSettingsb.RedisSettings.ClearRedis) +{ + var redis = app.Services.CreateScope().ServiceProvider.GetService<ISimpleCacheService>(); //获取redis服务 + // 删除redis的key + redis.DelByPattern(CacheConst.Cache_Prefix); + + WIDESEA_Core.Helper.ConsoleHelper.WriteInfoLine("正在缓存库存信息"); + var stockInfoList = await SqlSugarHelper.DbWMS.Queryable<DtStockInfo>() + .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock).IncludesAllFirstLayer().ToListAsync(); + // 缓存库存信息 + foreach (var item in stockInfoList) + { + item.StockInfoDetails = new List<DtStockInfoDetail>() { { item.StockInfoDetails[0] } }; + redis.HashAdd(CacheConst.Cache_DtStockInfo, item.PalletCode, item); + } + WIDESEA_Core.Helper.ConsoleHelper.WriteInfoLine("缓存库存信息完成"); +} + app.Run(); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj index 6091c76..f91f8ef 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj @@ -20,6 +20,7 @@ </ItemGroup> <ItemGroup> + <None Include="Controllers\Basic\MOMErrorMessageController.cs" /> <None Include="wwwroot\WIDESEA_DB.DBSeed.Json\Sys_Tenant.tsv" /> <None Include="wwwroot\WIDESEA_DB.DBSeed.Json\Sys_User.tsv" /> </ItemGroup> @@ -34,6 +35,7 @@ <ItemGroup> <ProjectReference Include="..\WIDESEA_BusinessServices\WIDESEA_BusinessServices.csproj" /> + <ProjectReference Include="..\WIDESEA_Cache\WIDESEA_Cache.csproj" /> <ProjectReference Include="..\WIDESEA_Services\WIDESEA_Services.csproj" /> <ProjectReference Include="..\WIDESEA_IServices\WIDESEA_IServices.csproj" /> <ProjectReference Include="..\WIDESEA_StorageBasicServices\WIDESEA_StorageBasicServices.csproj" /> diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json index 5731809..e794714 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json @@ -11,11 +11,11 @@ //杩炴帴瀛楃涓� //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=", //"ConnectionString": "Data Source=192.168.5.251;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - "ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WMS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WMS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", //"ConnectionString": "Data Source=.\\LIULEI;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WMSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WMSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", //"ConnectionStringWCS": "Data Source=192.168.5.251;Initial Catalog=WIDESEAWCS_TEST;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - "ConnectionStringWCS": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=sa123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "ConnectionStringWCS": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCS2F09;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", //璺ㄥ煙 "Cors": { "PolicyName": "CorsIpAccess", //绛栫暐鍚嶇О @@ -24,6 +24,18 @@ // 娉ㄦ剰锛宧ttp://127.0.0.1:1818 鍜� http://localhost:1818 鏄笉涓�鏍风殑 "IPs": "http://127.0.0.1:8080,http://localhost:8080,http://127.0.0.1:8081,http://localhost:8081" }, + + //缂撳瓨璁剧疆 + "CacheSettings": { + "UseRedis": true, //鍚敤redis + "RedisSettings": { + "Address": "127.0.0.1:6379", //鍦板潃 + "Password": "123456", //Redis鏈嶅姟瀵嗙爜 + "Db": 9, //榛樿搴� + "ClearRedis": true //鏄惁姣忔鍚姩閮芥竻闄edis缂撳瓨 + } + }, + "ApiName": "WIDESEA", "ExpMinutes": 120, @@ -32,10 +44,10 @@ // 鍏佽鍑哄簱鐨勭紪鐮� "OutBoundMateriel": [ - { - "MaterielCode": "CC01050001348", - "ProductionLine": "ZJ-8", - "ProcessCode": "CH001" - } + //{ + // "MaterielCode": "CC01050001348", + // "ProductionLine": "ZJ-8", + // "ProcessCode": "CH001" + //} ] } diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/WIDESEA_WMSServer.MvcApplicationPartsAssemblyInfo.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/WIDESEA_WMSServer.MvcApplicationPartsAssemblyInfo.cs index c85e30c..cd44a9d 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/WIDESEA_WMSServer.MvcApplicationPartsAssemblyInfo.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/WIDESEA_WMSServer.MvcApplicationPartsAssemblyInfo.cs @@ -17,6 +17,7 @@ [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("Swashbuckle.AspNetCore.SwaggerGen")] [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEA_BusinessesRepository")] [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEA_BusinessServices")] +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEA_Cache")] [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEA_Core")] [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEA_DTO")] [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEA_IBusinessesRepository")] -- Gitblit v1.9.3