From 70aa9b5ca249a84e5867912d551cdafbec76e54e Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期五, 05 十二月 2025 09:45:17 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/InterfaceLog.cs | 65 +
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_CheckService/ReCheckOrderService.cs | 20
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs | 37
项目代码/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js | 2
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITask_HtyService.cs | 1
项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue | 6
项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm | 0
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs | 60 +
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs | 269 ++++
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundBatchPickingService.cs | 34
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs | 3
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/NoStockOutModel.cs | 6
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 73
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ESSController.cs | 15
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/WIDESEA_OutboundService.csproj | 1
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs | 459 +++++--
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 128 +
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs | 19
项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm | 0
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs | 143 ++
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskStatusEnum.cs | 2
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CustomProfile.cs | 5
项目代码/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue | 1143 +++++++++++++++-----
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_PickingRecord.cs | 18
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs | 1
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs | 3
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs | 773 ++++++++-----
27 files changed, 2,356 insertions(+), 930 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue"
index 3cc1b7d..da423a5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue"
@@ -201,6 +201,12 @@
width: 90,
},
{
+ prop: "overOutQuantity",
+ title: "鎸枡鏁伴噺",
+ type: "string",
+ width: 90,
+ },
+ {
prop: "unit",
title: "鍗曚綅",
type: "string",
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
index 02fafb3..39c1469 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
@@ -386,7 +386,7 @@
let wheres = [{
'name': 'orderType',
- 'value': '0',
+ 'value': ['0','116'],
'displayType': 'text'
}];
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue"
index b73d987..48d960a 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue"
@@ -92,7 +92,7 @@
</div>
<!-- 鎷嗗寘寮圭獥 -->
- <div v-if="showCustomSplitDialog" class="custom-dialog-overlay">
+ <div v-if="showCustomSplitDialog" class="custom-dialog-overlay" style="z-index: 2000;">
<div class="custom-dialog-wrapper">
<div class="custom-dialog">
<div class="custom-dialog-header">
@@ -154,7 +154,7 @@
</div>
<!-- 鎾ら攢鎷嗗寘寮圭獥 -->
- <div v-if="showRevertSplitDialog" class="custom-dialog-overlay">
+ <div v-if="showRevertSplitDialog" class="custom-dialog-overlay" style="z-index: 2001;">
<div class="custom-dialog-wrapper">
<div class="custom-dialog">
<div class="custom-dialog-header">
@@ -214,7 +214,7 @@
</div>
<!-- 鎷嗗寘閾句俊鎭脊绐� -->
-<div v-if="showSplitChainDialog" class="custom-dialog-overlay">
+<div v-if="showSplitChainDialog" class="custom-dialog-overlay" style="z-index: 2002;">
<div class="custom-dialog-wrapper">
<div class="custom-dialog" style="width: 750px;">
<div class="custom-dialog-header">
@@ -338,7 +338,7 @@
</div>
<!-- 鎵归噺鍥炲簱寮圭獥 -->
- <div v-if="showBatchReturnDialog" class="custom-dialog-overlay">
+ <div v-if="showBatchReturnDialog" class="custom-dialog-overlay" style="z-index: 2003;">
<div class="custom-dialog-wrapper">
<div class="custom-dialog">
<div class="custom-dialog-header">
@@ -370,7 +370,7 @@
</div>
<!-- 鍙栬蛋绌虹寮圭獥 -->
- <div v-if="showEmptyPalletDialog" class="custom-dialog-overlay">
+ <div v-if="showEmptyPalletDialog" class="custom-dialog-overlay" style="z-index: 2004;">
<div class="custom-dialog-wrapper">
<div class="custom-dialog">
<div class="custom-dialog-header">
@@ -405,11 +405,12 @@
</div>
</template>
+
+
<script>
import http from '@/api/http.js'
-import { ref, defineComponent } from "vue";
+import { defineComponent } from "vue";
import { ElMessage } from 'element-plus'
-import { useRoute } from 'vue-router'
import printView from "@/extension/outbound/extend/printView.vue"
export default defineComponent({
@@ -417,6 +418,7 @@
components: {printView},
data() {
return {
+ // 淇濇寔鎵�鏈夊師濮嬫暟鎹粨鏋勪笉鍙�...
scanData: {
orderNo: '',
palletCode: '',
@@ -432,21 +434,24 @@
},
palletStatus: '鏈煡',
- // 寮圭獥鐘舵��
+ // 寮圭獥鐘舵�� - 鍏抽敭淇锛氬彧鍏佽涓�涓脊绐楁墦寮�
+ activeDialog: null, // 'split', 'revert', 'batchReturn', 'emptyPallet', 'splitChain'
showCustomSplitDialog: false,
showRevertSplitDialog: false,
showBatchReturnDialog: false,
showEmptyPalletDialog: false,
- showSplitChainDialog: false, // 鏂板锛氭媶鍖呴摼淇℃伅寮圭獥
+ showSplitChainDialog: false,
+ // 娣诲姞闃查噸澶嶇偣鍑绘爣蹇�
+ isOpeningDialog: false,
// 鍔犺浇鐘舵��
splitLoading: false,
revertSplitLoading: false,
batchReturnLoading: false,
emptypalletOutLoading: false,
- splitChainLoading: false, // 鏂板锛氭媶鍖呴摼鍔犺浇鐘舵��
+ splitChainLoading: false,
- // 琛ㄥ崟鏁版嵁
+ // 琛ㄥ崟鏁版嵁...
splitForm: {
orderNo: '',
palletCode: '',
@@ -472,14 +477,13 @@
palletCode: ''
},
- // 鏂板锛氭媶鍖呴摼鐩稿叧鏁版嵁
splitChainInfo: {
originalBarcode: '',
totalSplitTimes: 0,
splitChain: []
},
- // 楠岃瘉瑙勫垯
+ // 楠岃瘉瑙勫垯...
splitFormRules: {
originalBarcode: [
{ required: true, message: '璇疯緭鍏ュ師鏉$爜', trigger: 'blur' }
@@ -505,8 +509,17 @@
isProcessing: false
}
},
+ watch: {
+ // 鍏抽敭淇锛氱‘淇濆悓涓�鏃堕棿鍙湁涓�涓脊绐楁墦寮�
+ activeDialog(newVal, oldVal) {
+ this.showCustomSplitDialog = newVal === 'split'
+ this.showRevertSplitDialog = newVal === 'revert'
+ this.showBatchReturnDialog = newVal === 'batchReturn'
+ this.showEmptyPalletDialog = newVal === 'emptyPallet'
+ this.showSplitChainDialog = newVal === 'splitChain'
+ }
+ },
computed: {
- // 鏄惁鍙互鍙栨秷鏁翠釜鎷嗗寘閾�
canCancelWholeChain() {
return this.splitChainInfo.splitChain &&
this.splitChainInfo.splitChain.some(item => !item.isReverted);
@@ -519,9 +532,13 @@
this.batchReturnForm.orderNo = this.$route.query.orderNo;
this.emptypalletOutForm.orderNo = this.$route.query.orderNo;
}
- this.$nextTick(() => {
- this.$refs.palletInput.focus();
+ // 浣跨敤 requestAnimationFrame 纭繚椤甸潰瀹屽叏鍔犺浇
+ requestAnimationFrame(() => {
+ if (this.$refs.palletInput) {
+ this.$refs.palletInput.focus();
+ }
});
+
},
methods: {
goBack(){
@@ -568,16 +585,445 @@
}
},
- // 鎷嗗寘鐩稿叧鏂规硶
- openSplitDialog() {
+ openSplitDialog() {
+ console.log('绱ф�ヤ慨澶嶇増锛氭墦寮�鎷嗗寘寮圭獥');
+
if (!this.scanData.palletCode) {
this.$message.warning('璇峰厛鎵弿鎵樼洏鐮�');
return;
}
- this.showCustomSplitDialog = true;
- this.resetSplitForm();
- this.splitForm.orderNo = this.scanData.orderNo;
- this.splitForm.palletCode = this.scanData.palletCode;
+
+ // 1. 鍏抽棴鎵�鏈塚ue寮圭獥
+ this.closeAllDialogs();
+
+ // 2. 寮哄埗浠嶥OM涓Щ闄ゆ墍鏈夊脊绐�
+ setTimeout(() => {
+ const dialogs = document.querySelectorAll('.custom-dialog-overlay');
+ dialogs.forEach(dialog => {
+ if (dialog.parentNode) {
+ dialog.parentNode.removeChild(dialog);
+ }
+ });
+
+ // 濡傛灉宸茬粡瀛樺湪鎵嬪姩寮圭獥锛屽厛绉婚櫎
+ if (this.manualDialog && this.manualDialog.parentNode) {
+ this.manualDialog.parentNode.removeChild(this.manualDialog);
+ }
+
+ // 3. 绛夊緟涓�甯�
+ requestAnimationFrame(() => {
+ // 4. 鐩存帴鍒涘缓鏂板脊绐楋紝涓嶄緷璧朧ue鐨勫搷搴斿紡绯荤粺
+ this.createManualSplitDialog();
+ });
+ }, 10);
+ },
+
+ // 鍒涘缓鎵嬪姩鎷嗗寘寮圭獥
+ createManualSplitDialog() {
+ const newDialog = document.createElement('div');
+ newDialog.className = 'custom-dialog-overlay emergency-fix';
+
+ // 鐢熸垚闅忔満ID鐢ㄤ簬浜嬩欢缁戝畾
+ const dialogId = 'manual-dialog-' + Date.now();
+ newDialog.id = dialogId;
+
+ // 瀛樺偍寮曠敤
+ this.manualDialog = newDialog;
+
+ // 寮圭獥鍐呭
+ newDialog.innerHTML = `
+ <div class="custom-dialog-wrapper">
+ <div class="custom-dialog" style="width: 500px;">
+ <div class="custom-dialog-header">
+ <h3 style="margin: 0; color: #303133;">鎷嗗寘鎿嶄綔</h3>
+ <button class="close-button" onclick="document.getElementById('${dialogId}').remove()" style="
+ font-size: 18px;
+ color: #909399;
+ padding: 0;
+ width: 24px;
+ height: 24px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: none;
+ border: none;
+ cursor: pointer;
+ ">脳</button>
+ </div>
+ <div class="custom-dialog-body" style="padding: 20px;">
+ <div style="margin-bottom: 15px;">
+ <div style="display: flex; align-items: center; margin-bottom: 5px;">
+ <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">璁㈠崟缂栧彿:</span>
+ <input type="text" value="${this.scanData.orderNo}" disabled style="
+ flex: 1;
+ padding: 8px 12px;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ background-color: #f5f7fa;
+ color: #909399;
+ ">
+ </div>
+ </div>
+
+ <div style="margin-bottom: 15px;">
+ <div style="display: flex; align-items: center; margin-bottom: 5px;">
+ <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">鎵樼洏缂栧彿:</span>
+ <input type="text" value="${this.scanData.palletCode}" disabled style="
+ flex: 1;
+ padding: 8px 12px;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ background-color: #f5f7fa;
+ color: #909399;
+ ">
+ </div>
+ </div>
+
+ <div style="margin-bottom: 15px;">
+ <div style="display: flex; align-items: center; margin-bottom: 5px;">
+ <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">鍘熸潯鐮�:</span>
+ <div style="flex: 1; display: flex; align-items: center; gap: 10px;">
+ <input type="text" id="${dialogId}-barcode" placeholder="鎵弿鍘熸潯鐮�" style="
+ flex: 1;
+ padding: 8px 12px;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ ">
+ <button id="${dialogId}-viewChain" style="
+ padding: 8px 16px;
+ background: #409eff;
+ color: white;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ white-space: nowrap;
+ ">鏌ョ湅鎷嗗寘閾�</button>
+ </div>
+ </div>
+ </div>
+
+ <div style="margin-bottom: 15px;">
+ <div style="display: flex; align-items: center; margin-bottom: 5px;">
+ <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">鐗╂枡缂栫爜:</span>
+ <input type="text" id="${dialogId}-materiel" disabled style="
+ flex: 1;
+ padding: 8px 12px;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ background-color: #f5f7fa;
+ color: #909399;
+ ">
+ </div>
+ </div>
+
+ <div style="margin-bottom: 15px;">
+ <div style="display: flex; align-items: center; margin-bottom: 5px;">
+ <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">鍓╀綑鏁伴噺:</span>
+ <input type="text" id="${dialogId}-remain" disabled style="
+ flex: 1;
+ padding: 8px 12px;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ background-color: #f5f7fa;
+ color: #909399;
+ ">
+ </div>
+ </div>
+
+ <div style="margin-bottom: 15px;">
+ <div style="display: flex; align-items: center; margin-bottom: 5px;">
+ <span style="width: 100px; text-align: right; padding-right: 12px; color: #606266;">鎷嗗寘鏁伴噺:</span>
+ <div style="flex: 1;">
+ <input type="number" id="${dialogId}-splitQty" value="1" min="0.01" step="0.01" style="
+ width: 100%;
+ padding: 8px 12px;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ ">
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="custom-dialog-footer" style="
+ padding: 10px 20px 20px;
+ text-align: right;
+ border-top: 1px solid #ebeef5;
+ ">
+ <button id="${dialogId}-cancel" style="
+ padding: 9px 15px;
+ background: white;
+ color: #606266;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ cursor: pointer;
+ margin-right: 10px;
+ ">鍙栨秷</button>
+ <button id="${dialogId}-confirm" style="
+ padding: 9px 15px;
+ background: #409eff;
+ color: white;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ ">纭鎷嗗寘</button>
+ </div>
+ </div>
+ </div>
+ `;
+
+ // 娣诲姞鏍峰紡
+ newDialog.style.cssText = `
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0,0,0,0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 999999;
+ `;
+
+ // 寮圭獥瀹瑰櫒鏍峰紡
+ const wrapper = newDialog.querySelector('.custom-dialog-wrapper');
+ if (wrapper) {
+ wrapper.style.position = 'relative';
+ wrapper.style.zIndex = '1000000';
+ }
+
+ // 寮圭獥鍐呭鏍峰紡
+ const dialog = newDialog.querySelector('.custom-dialog');
+ if (dialog) {
+ dialog.style.background = 'white';
+ dialog.style.borderRadius = '4px';
+ dialog.style.maxWidth = '90vw';
+ dialog.style.maxHeight = '90vh';
+ dialog.style.boxShadow = '0 2px 12px 0 rgba(0, 0, 0, 0.1)';
+ dialog.style.overflow = 'auto';
+ }
+
+ // 寮圭獥澶撮儴鏍峰紡
+ const header = newDialog.querySelector('.custom-dialog-header');
+ if (header) {
+ header.style.display = 'flex';
+ header.style.justifyContent = 'space-between';
+ header.style.alignItems = 'center';
+ header.style.padding = '20px 20px 10px';
+ header.style.borderBottom = '1px solid #ebeef5';
+ }
+
+ document.body.appendChild(newDialog);
+ console.log('绱ф�ュ脊绐楀凡鍒涘缓');
+
+ // 缁戝畾浜嬩欢
+ this.bindManualDialogEvents(dialogId);
+
+ // 鑷姩鑱氱劍鍒版潯鐮佽緭鍏ユ
+ setTimeout(() => {
+ const barcodeInput = document.getElementById(`${dialogId}-barcode`);
+ if (barcodeInput) {
+ barcodeInput.focus();
+ // 娣诲姞鍥炶溅閿洃鍚�
+ barcodeInput.addEventListener('keyup', (event) => {
+ if (event.key === 'Enter') {
+ this.onManualSplitBarcodeScan(dialogId);
+ }
+ });
+ }
+ }, 100);
+ },
+
+ // 缁戝畾鎵嬪姩寮圭獥浜嬩欢
+ bindManualDialogEvents(dialogId) {
+ const vm = this; // 淇濆瓨Vue瀹炰緥寮曠敤
+
+ // 鏌ョ湅鎷嗗寘閾炬寜閽�
+ const viewChainBtn = document.getElementById(`${dialogId}-viewChain`);
+ if (viewChainBtn) {
+ viewChainBtn.onclick = () => {
+ const barcodeInput = document.getElementById(`${dialogId}-barcode`);
+ if (barcodeInput && barcodeInput.value.trim()) {
+ vm.viewSplitChainFromManualDialog(barcodeInput.value.trim(), dialogId);
+ } else {
+ ElMessage.warning('璇峰厛杈撳叆鏉$爜');
+ }
+ };
+ }
+
+ // 鍙栨秷鎸夐挳
+ const cancelBtn = document.getElementById(`${dialogId}-cancel`);
+ if (cancelBtn) {
+ cancelBtn.onclick = () => {
+ const dialog = document.getElementById(dialogId);
+ if (dialog && dialog.parentNode) {
+ dialog.parentNode.removeChild(dialog);
+ }
+ };
+ }
+
+ // 纭鎷嗗寘鎸夐挳
+ const confirmBtn = document.getElementById(`${dialogId}-confirm`);
+ if (confirmBtn) {
+ confirmBtn.onclick = () => {
+ vm.handleManualSplitPackage(dialogId);
+ };
+ }
+
+ // 鏉$爜杈撳叆妗嗗彉鍖栦簨浠�
+ const barcodeInput = document.getElementById(`${dialogId}-barcode`);
+ if (barcodeInput) {
+ // 闃叉姈澶勭悊
+ let timeout;
+ barcodeInput.addEventListener('input', () => {
+ clearTimeout(timeout);
+ timeout = setTimeout(() => {
+ if (barcodeInput.value.trim()) {
+ vm.onManualSplitBarcodeScan(dialogId);
+ }
+ }, 500);
+ });
+ }
+ },
+
+ // 鎵嬪姩寮圭獥鐨勬潯鐮佹壂鎻忓鐞�
+ async onManualSplitBarcodeScan(dialogId) {
+ const barcodeInput = document.getElementById(`${dialogId}-barcode`);
+ if (!barcodeInput || !barcodeInput.value.trim()) return;
+
+ const barcode = barcodeInput.value.trim();
+
+ try {
+ const res = await http.post('/api/OutboundBatchPicking/split-package-info', {
+ orderNo: this.scanData.orderNo,
+ palletCode: this.scanData.palletCode,
+ barcode: barcode
+ });
+
+ if (res.status) {
+ // 鏇存柊鐗╂枡缂栫爜
+ const materielInput = document.getElementById(`${dialogId}-materiel`);
+ if (materielInput) {
+ materielInput.value = res.data.materielCode || '';
+ }
+
+ // 鏇存柊鍓╀綑鏁伴噺
+ const remainInput = document.getElementById(`${dialogId}-remain`);
+ if (remainInput) {
+ remainInput.value = res.data.remainQuantity || 0;
+ }
+
+ // 鏇存柊鎷嗗寘鏁伴噺锛堥粯璁や负1锛屼笉瓒呰繃鍓╀綑鏁伴噺锛�
+ const splitQtyInput = document.getElementById(`${dialogId}-splitQty`);
+ if (splitQtyInput) {
+ const maxQty = res.data.remainQuantity || 0;
+ splitQtyInput.max = maxQty;
+ const currentVal = parseFloat(splitQtyInput.value) || 1;
+ if (currentVal > maxQty) {
+ splitQtyInput.value = Math.min(1, maxQty);
+ }
+ }
+ } else {
+ ElMessage.error(res.message || '鑾峰彇鎷嗗寘淇℃伅澶辫触');
+ }
+ } catch (error) {
+ console.error('鑾峰彇鎷嗗寘淇℃伅澶辫触:', error);
+ ElMessage.error('鑾峰彇鎷嗗寘淇℃伅澶辫触');
+ }
+ },
+
+ // 浠庢墜鍔ㄥ脊绐楁煡鐪嬫媶鍖呴摼
+ viewSplitChainFromManualDialog(barcode, dialogId) {
+ // 鍏堝叧闂墜鍔ㄥ脊绐�
+ const dialog = document.getElementById(dialogId);
+ if (dialog && dialog.parentNode) {
+ dialog.parentNode.removeChild(dialog);
+ }
+
+ // 寤惰繜涓�涓嬶紝鐒跺悗鎵撳紑Vue鐨勬媶鍖呴摼寮圭獥
+ setTimeout(() => {
+ this.viewSplitChain(barcode);
+ }, 50);
+ },
+
+ // 澶勭悊鎵嬪姩寮圭獥鐨勬媶鍖呮搷浣�
+ async handleManualSplitPackage(dialogId) {
+ const barcodeInput = document.getElementById(`${dialogId}-barcode`);
+ const splitQtyInput = document.getElementById(`${dialogId}-splitQty`);
+
+ if (!barcodeInput || !barcodeInput.value.trim()) {
+ ElMessage.warning('璇疯緭鍏ュ師鏉$爜');
+ return;
+ }
+
+ if (!splitQtyInput || !splitQtyInput.value || parseFloat(splitQtyInput.value) <= 0) {
+ ElMessage.warning('璇疯緭鍏ユ湁鏁堢殑鎷嗗寘鏁伴噺');
+ return;
+ }
+
+ const originalBarcode = barcodeInput.value.trim();
+ const splitQuantity = parseFloat(splitQtyInput.value);
+
+ try {
+ // 鏄剧ず鍔犺浇鐘舵��
+ const confirmBtn = document.getElementById(`${dialogId}-confirm`);
+ if (confirmBtn) {
+ confirmBtn.disabled = true;
+ confirmBtn.textContent = '澶勭悊涓�...';
+ }
+
+ const res = await http.post('/api/OutboundBatchPicking/split-package', {
+ orderNo: this.scanData.orderNo,
+ palletCode: this.scanData.palletCode,
+ originalBarcode: originalBarcode,
+ splitQuantity: splitQuantity
+ });
+
+ if (res.status) {
+ ElMessage.success('鎷嗗寘鎴愬姛');
+
+ // 鍏抽棴鎵嬪姩寮圭獥
+ const dialog = document.getElementById(dialogId);
+ if (dialog && dialog.parentNode) {
+ dialog.parentNode.removeChild(dialog);
+ }
+
+ // 閲嶆柊鍔犺浇鏁版嵁
+ await this.loadPalletData();
+ } else {
+ ElMessage.error(res.message || '鎷嗗寘澶辫触');
+
+ // 鎭㈠鎸夐挳鐘舵��
+ if (confirmBtn) {
+ confirmBtn.disabled = false;
+ confirmBtn.textContent = '纭鎷嗗寘';
+ }
+ }
+ } catch (error) {
+ console.error('鎷嗗寘澶辫触:', error);
+ ElMessage.error('鎷嗗寘澶辫触');
+
+ // 鎭㈠鎸夐挳鐘舵��
+ const confirmBtn = document.getElementById(`${dialogId}-confirm`);
+ if (confirmBtn) {
+ confirmBtn.disabled = false;
+ confirmBtn.textContent = '纭鎷嗗寘';
+ }
+ }
+ },
+ closeAllDialogsImmediately() {
+ console.log('绔嬪嵆鍏抽棴鎵�鏈夊脊绐�');
+
+ // 鐩存帴璁剧疆涓� false锛屼笉绛夊緟浠讳綍寮傛鎿嶄綔
+ this.showCustomSplitDialog = false;
+ this.showRevertSplitDialog = false;
+ this.showBatchReturnDialog = false;
+ this.showEmptyPalletDialog = false;
+ this.showSplitChainDialog = false;
+
+ // 寮哄埗DOM鏇存柊
+ this.$forceUpdate();
},
async onSplitBarcodeScan() {
@@ -620,7 +1066,7 @@
});
if (res.status) {
this.$message.success('鎷嗗寘鎴愬姛');
- this.showCustomSplitDialog = false;
+ this.closeAllDialogs();
await this.loadPalletData();
} else {
this.$message.error(res.message || '鎷嗗寘澶辫触');
@@ -634,28 +1080,24 @@
});
}
},
-// 鍦ㄦ媶鍖呭脊绐椾腑鏌ョ湅鎷嗗寘閾�
-async viewSplitChainFromSplit(barcode) {
- if (!barcode) {
- this.$message.warning('璇峰厛杈撳叆鏉$爜');
- return;
- }
-
- // 鍏堝叧闂媶鍖呭脊绐�
- this.closeCustomSplitDialog();
-
- await this.$nextTick();
-
- // 鐒跺悗鎵撳紑鎷嗗寘閾句俊鎭脊绐�
- await this.viewSplitChain(barcode);
-},
+
+ async viewSplitChainFromSplit(barcode) {
+ if (!barcode) {
+ this.$message.warning('璇峰厛杈撳叆鏉$爜');
+ return;
+ }
+
+ this.closeAllDialogs();
+
+ setTimeout(() => {
+ this.viewSplitChain(barcode);
+ }, 50);
+ },
+
// 鎾ら攢鎷嗗寘
async onRevertSplitBarcodeScan() {
if (!this.revertSplitForm.newBarcode) return;
this.revertSplitForm.newBarcode = this.revertSplitForm.newBarcode.replace(/\n/g, '').trim();
-
- // 鏂板锛氭壂鎻忓悗鑷姩鏄剧ず鎷嗗寘閾句俊鎭�
- await this.viewSplitChain(this.revertSplitForm.newBarcode);
},
async handleRevertSplit() {
@@ -671,7 +1113,7 @@
});
if (res.status) {
this.$message.success('鎾ら攢鎷嗗寘鎴愬姛');
- this.showRevertSplitDialog = false;
+ this.closeAllDialogs();
await this.loadPalletData();
} else {
this.$message.error(res.message || '鎾ら攢鎷嗗寘澶辫触');
@@ -685,216 +1127,140 @@
});
}
},
-// 鏌ユ壘瀹屾暣鎷嗗寘閾撅紙浠庢牴鏉$爜寮�濮嬶級
-async findRootChain(currentBarcode) {
- this.splitChainLoading = true;
- try {
- const res = await http.post('/api/OutboundBatchPicking/find-root-split-chain', {
- orderNo: this.scanData.orderNo,
- barcode: currentBarcode
- });
-
- if (res.status) {
- this.splitChainInfo = res.data;
- this.$message.success('宸插姞杞藉畬鏁存媶鍖呴摼');
- } else {
- this.$message.error(res.message || '鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
- }
- } catch (error) {
- this.$message.error('鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
- } finally {
- this.splitChainLoading = false;
- }
-},
- // 鎷嗗寘閾剧浉鍏虫柟娉�
- // 鏌ョ湅鎷嗗寘閾句俊鎭�
-async viewSplitChain(barcode) {
- if (!barcode) {
- this.$message.warning('璇峰厛杈撳叆鏉$爜');
- return;
- }
-
- this.splitChainLoading = true;
- try {
- const res = await http.post('/api/OutboundBatchPicking/split-package-chain-info', {
- orderNo: this.scanData.orderNo,
- barcode: barcode
- });
-
- if (res.status) {
- this.splitChainInfo = res.data;
-
- // 鏄剧ず鎻愮ず淇℃伅锛屽憡璇夌敤鎴疯繖鏄粈涔堢被鍨嬬殑鎷嗗寘閾�
- let chainType = "褰撳墠鏉$爜鐨勬媶鍖呴摼";
- if (this.splitChainInfo.chainType === 'root') {
- chainType = "瀹屾暣鎷嗗寘閾撅紙浠庡師濮嬫潯鐮佸紑濮嬶級";
- } else if (this.splitChainInfo.chainType === 'branch') {
- chainType = "鍒嗘敮鎷嗗寘閾�";
+
+ async findRootChain(currentBarcode) {
+ this.splitChainLoading = true;
+ try {
+ const res = await http.post('/api/OutboundBatchPicking/find-root-split-chain', {
+ orderNo: this.scanData.orderNo,
+ barcode: currentBarcode
+ });
+
+ if (res.status) {
+ this.splitChainInfo = res.data;
+ this.$message.success('宸插姞杞藉畬鏁存媶鍖呴摼');
+ } else {
+ this.$message.error(res.message || '鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
+ }
+ } catch (error) {
+ this.$message.error('鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
+ } finally {
+ this.splitChainLoading = false;
+ }
+ },
+
+ // 鏌ョ湅鎷嗗寘閾句俊鎭�
+ async viewSplitChain(barcode) {
+ if (!barcode) {
+ this.$message.warning('璇峰厛杈撳叆鏉$爜');
+ return;
}
- this.$message.info(`宸插姞杞�${chainType}锛屽叡${this.splitChainInfo.totalSplitTimes}娆℃媶鍖卄);
- this.showSplitChainDialog = true;
- } else {
- this.$message.error(res.message || '鑾峰彇鎷嗗寘閾句俊鎭け璐�');
- }
- } catch (error) {
- this.$message.error('鑾峰彇鎷嗗寘閾句俊鎭け璐�');
- } finally {
- this.splitChainLoading = false;
- }
-},
+ this.splitChainLoading = true;
+ try {
+ const res = await http.post('/api/OutboundBatchPicking/split-package-chain-info', {
+ orderNo: this.scanData.orderNo,
+ barcode: barcode
+ });
+
+ if (res.status) {
+ this.splitChainInfo = res.data;
+ this.activeDialog = 'splitChain';
+ } else {
+ this.$message.error(res.message || '鑾峰彇鎷嗗寘閾句俊鎭け璐�');
+ }
+ } catch (error) {
+ this.$message.error('鑾峰彇鎷嗗寘閾句俊鎭け璐�');
+ } finally {
+ this.splitChainLoading = false;
+ }
+ },
// 鍏抽棴鎷嗗寘閾句俊鎭脊绐�
- closeSplitChainDialog() {
+ closeSplitChainDialog() {
this.showSplitChainDialog = false;
-
},
- // 鍦ㄦ挙閿�鎷嗗寘寮圭獥涓煡鐪嬫媶鍖呴摼
-async viewSplitChainFromRevert(barcode) {
- if (!barcode) {
- this.$message.warning('璇峰厛杈撳叆鏉$爜');
- return;
- }
-
- // 鍏堝叧闂挙閿�鎷嗗寘寮圭獥
- this.closeRevertSplitDialog();
-
- await this.$nextTick();
-
- // 鐒跺悗鎵撳紑鎷嗗寘閾句俊鎭脊绐�
- await this.viewSplitChain(barcode);
-},
-// 蹇�熼噸鏂版墦寮�鎷嗗寘閾惧脊绐�
-async quickReopenSplitChainDialog(barcode) {
- if (!barcode) return;
-
- this.showSplitChainDialog = true;
- this.splitChainLoading = true;
-
- try {
- const res = await http.post('/api/OutboundBatchPicking/split-package-chain-info', {
- orderNo: this.scanData.orderNo,
- barcode: barcode
- });
-
- if (res.status) {
- this.splitChainInfo = res.data;
- }
- } catch (error) {
- console.error('閲嶆柊鍔犺浇鎷嗗寘閾句俊鎭け璐�:', error);
- } finally {
- this.splitChainLoading = false;
- }
-},
- // 鍙栨秷鍗曚釜鎷嗗寘璁板綍
-async cancelSingleSplit(newBarcode) {
- // 鍏堣褰曞綋鍓嶄俊鎭紝鐒跺悗鍏抽棴寮圭獥
- const originalBarcode = this.splitChainInfo.originalBarcode;
- this.closeSplitChainDialog();
-
- await this.$nextTick();
-
- try {
- await this.$confirm(
- `纭畾瑕佸彇娑堟潯鐮� ${newBarcode} 鐨勬媶鍖呮搷浣滃悧锛焋,
- '鍙栨秷鍗曚釜鎷嗗寘',
- {
- confirmButtonText: '纭畾鍙栨秷',
- cancelButtonText: '鍐嶆兂鎯�',
- type: 'warning'
- }
- );
-
- this.revertSplitLoading = true;
-
- const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
- orderNo: this.scanData.orderNo,
- palletCode: this.scanData.palletCode,
- newBarcode: newBarcode
- });
-
- if (res.status) {
- this.$message.success('鍙栨秷鎷嗗寘鎴愬姛');
- await this.loadPalletData();
- // 閲嶆柊鎵撳紑寮圭獥鏄剧ず鏇存柊鍚庣殑鐘舵��
- await this.viewSplitChain(originalBarcode);
- } else {
- this.$message.error(res.message || '鍙栨秷鎷嗗寘澶辫触');
- await this.viewSplitChain(originalBarcode);
- }
- } catch (error) {
- if (error === 'cancel') {
- // 鐢ㄦ埛鍙栨秷鍚庨噸鏂版墦寮�寮圭獥
- await this.viewSplitChain(originalBarcode);
- } else {
- this.$message.error('鍙栨秷鎷嗗寘澶辫触');
- await this.viewSplitChain(originalBarcode);
- }
- } finally {
- this.revertSplitLoading = false;
- }
-},
-// 鍙栨秷鏁翠釜鎷嗗寘閾�
-async cancelWholeSplitChain() {
- // 鍏堣褰曞綋鍓嶆媶鍖呴摼淇℃伅锛岀劧鍚庡叧闂脊绐�
- const originalBarcode = this.splitChainInfo.originalBarcode;
- this.closeSplitChainDialog();
-
- // 缁欎竴鐐规椂闂磋寮圭獥瀹屽叏鍏抽棴
- await this.$nextTick();
-
- try {
- // 鐜板湪鏄剧ず纭瀵硅瘽妗嗭紝纭繚瀹冨湪鏈�鍓嶉潰
- await this.$confirm(
- `纭畾瑕佸彇娑堟暣涓媶鍖呴摼鍚楋紵\n杩欏皢鍙栨秷浠庢潯鐮� ${originalBarcode} 寮�濮嬬殑鎵�鏈夋媶鍖呮搷浣溿�俙,
- '鍙栨秷鎷嗗寘閾剧‘璁�',
- {
- confirmButtonText: '纭畾鍙栨秷',
- cancelButtonText: '鍐嶆兂鎯�',
- type: 'warning',
- center: true,
- closeOnClickModal: false
+ // 鍙栨秷鍗曚釜鎷嗗寘璁板綍
+ async cancelSingleSplit(newBarcode) {
+ const originalBarcode = this.splitChainInfo.originalBarcode;
+
+ try {
+ await this.$confirm(
+ `纭畾瑕佸彇娑堟潯鐮� ${newBarcode} 鐨勬媶鍖呮搷浣滃悧锛焋,
+ '鍙栨秷鍗曚釜鎷嗗寘',
+ {
+ confirmButtonText: '纭畾鍙栨秷',
+ cancelButtonText: '鍐嶆兂鎯�',
+ type: 'warning'
+ }
+ );
+
+ this.revertSplitLoading = true;
+
+ const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
+ orderNo: this.scanData.orderNo,
+ palletCode: this.scanData.palletCode,
+ newBarcode: newBarcode
+ });
+
+ if (res.status) {
+ this.$message.success('鍙栨秷鎷嗗寘鎴愬姛');
+ await this.loadPalletData();
+ this.closeAllDialogs();
+ setTimeout(() => {
+ this.viewSplitChain(originalBarcode);
+ }, 50);
+ } else {
+ this.$message.error(res.message || '鍙栨秷鎷嗗寘澶辫触');
+ }
+ } catch (error) {
+ if (error !== 'cancel') {
+ this.$message.error('鍙栨秷鎷嗗寘澶辫触');
+ }
+ } finally {
+ this.revertSplitLoading = false;
}
- );
-
- // 鐢ㄦ埛纭鍚庢墽琛屽彇娑堟搷浣�
- this.revertSplitLoading = true;
-
- const res = await http.post('/api/OutboundBatchPicking/cancel-split-chain', {
- orderNo: this.scanData.orderNo,
- palletCode: this.scanData.palletCode,
- startBarcode: originalBarcode
- });
-
- console.log('鍙栨秷鎷嗗寘閾惧搷搴�:', res);
-
- if (res.status) {
- this.$message.success('鍙栨秷鎷嗗寘閾炬垚鍔�');
- await this.loadPalletData();
- // 鍙�夛細閲嶆柊鎵撳紑鎷嗗寘閾句俊鎭脊绐楁樉绀烘洿鏂板悗鐨勭姸鎬�
- // await this.viewSplitChain(originalBarcode);
- } else {
- this.$message.error(res.message || '鍙栨秷鎷嗗寘閾惧け璐�');
- // 澶辫触鍚庨噸鏂版墦寮�寮圭獥
- await this.viewSplitChain(originalBarcode);
- }
- } catch (error) {
- // 鐢ㄦ埛鍙栨秷鎿嶄綔
- if (error === 'cancel') {
- console.log('鐢ㄦ埛鍙栨秷浜嗘媶鍖呴摼鎿嶄綔');
- // 鐢ㄦ埛鍙栨秷鍚庨噸鏂版墦寮�寮圭獥
- await this.viewSplitChain(originalBarcode);
- } else {
- console.error('鍙栨秷鎷嗗寘閾鹃敊璇�:', error);
- this.$message.error('鍙栨秷鎷嗗寘閾惧け璐�: ' + error.message);
- // 鍑洪敊鍚庨噸鏂版墦寮�寮圭獥
- await this.viewSplitChain(originalBarcode);
- }
- } finally {
- this.revertSplitLoading = false;
- }
-},
+ },
+
+ // 鍙栨秷鏁翠釜鎷嗗寘閾�
+ async cancelWholeSplitChain() {
+ try {
+ await this.$confirm(
+ `纭畾瑕佸彇娑堟暣涓媶鍖呴摼鍚楋紵\n杩欏皢鍙栨秷浠庢潯鐮� ${this.splitChainInfo.originalBarcode} 寮�濮嬬殑鎵�鏈夋媶鍖呮搷浣溿�俙,
+ '鍙栨秷鎷嗗寘閾剧‘璁�',
+ {
+ confirmButtonText: '纭畾鍙栨秷',
+ cancelButtonText: '鍐嶆兂鎯�',
+ type: 'warning',
+ center: true,
+ closeOnClickModal: false
+ }
+ );
+
+ this.revertSplitLoading = true;
+
+ const res = await http.post('/api/OutboundBatchPicking/cancel-split-chain', {
+ orderNo: this.scanData.orderNo,
+ palletCode: this.scanData.palletCode,
+ startBarcode: this.splitChainInfo.originalBarcode
+ });
+
+ if (res.status) {
+ this.$message.success('鍙栨秷鎷嗗寘閾炬垚鍔�');
+ this.closeAllDialogs();
+ await this.loadPalletData();
+ } else {
+ this.$message.error(res.message || '鍙栨秷鎷嗗寘閾惧け璐�');
+ }
+ } catch (error) {
+ if (error !== 'cancel') {
+ this.$message.error('鍙栨秷鎷嗗寘閾惧け璐�: ' + error.message);
+ }
+ } finally {
+ this.revertSplitLoading = false;
+ }
+ },
// 妫�鏌ユ潯鐮佹槸鍚﹀凡琚垎鎷�
hasPicked(barcode) {
@@ -908,17 +1274,58 @@
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`;
},
+ // 鍏抽敭淇锛氭柊澧炲叧闂墍鏈夊脊绐楃殑鏂规硶
+ closeAllDialogs() {
+ this.activeDialog = null;
+ // 纭繚鎵�鏈夊脊绐楃姸鎬侀兘琚噸缃�
+// 鍏抽棴Vue寮圭獥
+ this.showCustomSplitDialog = false;
+ this.showRevertSplitDialog = false;
+ this.showBatchReturnDialog = false;
+ this.showEmptyPalletDialog = false;
+ this.showSplitChainDialog = false;
+
+ // 鍏抽棴鎵嬪姩寮圭獥
+ if (this.manualDialog && this.manualDialog.parentNode) {
+ this.manualDialog.parentNode.removeChild(this.manualDialog);
+ this.manualDialog = null;
+ }
+
+ // 绉婚櫎鎵�鏈夌揣鎬ュ脊绐�
+ const emergencyDialogs = document.querySelectorAll('.emergency-fix');
+ emergencyDialogs.forEach(dialog => {
+ if (dialog.parentNode) {
+ dialog.parentNode.removeChild(dialog);
+ }
+ });
+ },
+
// 鍥炲簱鐩稿叧鏂规硶
openBatchReturnDialog() {
if (!this.scanData.palletCode) {
this.$message.warning('璇峰厛鎵弿鎵樼洏鐮�');
return;
}
- this.showBatchReturnDialog = true;
- this.batchReturnForm.orderNo = this.scanData.orderNo;
- this.batchReturnForm.palletCode = this.scanData.palletCode;
- this.batchReturnForm.unpickedCount = this.summary.unpickedCount;
- this.batchReturnForm.unpickedQuantity = this.summary.unpickedQuantity;
+
+ if (this.isOpeningDialog) return;
+
+ this.isOpeningDialog = true;
+
+ setTimeout(() => {
+ this.closeAllDialogsImmediately();
+
+ requestAnimationFrame(() => {
+ this.showBatchReturnDialog = true;
+ this.batchReturnForm.orderNo = this.scanData.orderNo;
+ this.batchReturnForm.palletCode = this.scanData.palletCode;
+ this.batchReturnForm.unpickedCount = this.summary.unpickedCount;
+ this.batchReturnForm.unpickedQuantity = this.summary.unpickedQuantity;
+
+ this.$nextTick(() => {
+ this.isOpeningDialog = false;
+ });
+ });
+ }, 0);
},
async handleBatchReturnConfirm() {
@@ -930,7 +1337,7 @@
});
if (res.status) {
this.$message.success('鍥炲簱鎴愬姛');
- this.showBatchReturnDialog = false;
+ this.closeAllDialogs();
await this.loadPalletData();
} else {
this.$message.error(res.message || '鍥炲簱澶辫触');
@@ -943,10 +1350,24 @@
},
// 鍙栫┖绠辨柟娉�
- handleEmptyPallet() {
- this.showEmptyPalletDialog = true;
- this.emptypalletOutForm.orderNo = this.scanData.orderNo;
- this.emptypalletOutForm.palletCode = '';
+handleEmptyPallet() {
+ if (this.isOpeningDialog) return;
+
+ this.isOpeningDialog = true;
+
+ setTimeout(() => {
+ this.closeAllDialogsImmediately();
+
+ requestAnimationFrame(() => {
+ this.showEmptyPalletDialog = true;
+ this.emptypalletOutForm.orderNo = this.scanData.orderNo;
+ this.emptypalletOutForm.palletCode = '';
+
+ this.$nextTick(() => {
+ this.isOpeningDialog = false;
+ });
+ });
+ }, 0);
},
async handleEmptyPalletConfirm() {
@@ -958,7 +1379,7 @@
});
if (res.status) {
this.$message.success('鍙栬蛋绌虹鎴愬姛');
- this.showEmptyPalletDialog = false;
+ this.closeAllDialogs();
await this.loadPalletData();
} else {
this.$message.error(res.message || '鍙栬蛋绌虹澶辫触');
@@ -974,9 +1395,13 @@
async loadPalletData() {
if (!this.scanData.orderNo || !this.scanData.palletCode) return;
- await this.loadUnpickedList();
- await this.loadPickedList();
- await this.loadPalletStatus();
+ try {
+ await this.loadUnpickedList();
+ await this.loadPickedList();
+ await this.loadPalletStatus();
+ } catch (error) {
+ console.error('鍔犺浇鎵樼洏鏁版嵁澶辫触:', error);
+ }
},
async loadUnpickedList() {
@@ -986,7 +1411,6 @@
palletCode: this.scanData.palletCode
});
if (res.status) {
- //this.unpickedList = res.data || [];
this.unpickedList = (res.data || []).filter(item => item.canPick === true);
this.summary.unpickedCount = this.unpickedList.length;
this.summary.unpickedQuantity = this.unpickedList.reduce((sum, item) => sum + (item.remainQuantity || 0), 0);
@@ -1003,16 +1427,10 @@
palletCode: this.scanData.palletCode
});
if (res.status) {
- this.pickedList = res.data || [];
-
- this.pickedList = res.data.map(item => {
- // 鏂瑰紡1锛氫繚鐣欏師barcode瀛楁锛屾柊澧瀋urrentBarcode
- return {
- ...item,
- currentBarcode: item.barcode
- };
-});
-
+ this.pickedList = res.data.map(item => ({
+ ...item,
+ currentBarcode: item.barcode
+ }));
this.summary.pickedCount = this.pickedList.length;
}
} catch (error) {
@@ -1116,17 +1534,31 @@
this.resetSplitForm();
},
- openRevertSplitDialog() {
- this.showRevertSplitDialog = true;
- this.revertSplitForm.newBarcode = '';
+openRevertSplitDialog() {
+ if (this.isOpeningDialog) return;
+
+ this.isOpeningDialog = true;
+
+ setTimeout(() => {
+ this.closeAllDialogsImmediately();
+
+ requestAnimationFrame(() => {
+ this.showRevertSplitDialog = true;
+ this.revertSplitForm.newBarcode = '';
+
+ this.$nextTick(() => {
+ this.isOpeningDialog = false;
+ });
+ });
+ }, 0);
},
- closeRevertSplitDialog() {
+ closeRevertSplitDialog() {
this.showRevertSplitDialog = false;
this.revertSplitForm.newBarcode = '';
},
- closeBatchReturnDialog() {
+ closeBatchReturnDialog() {
this.showBatchReturnDialog = false;
},
@@ -1135,7 +1567,7 @@
this.emptypalletOutForm.palletCode = this.emptypalletOutForm.palletCode.replace(/\n/g, '').trim();
},
- closeEmptyPalletDialog() {
+ closeEmptyPalletDialog() {
this.showEmptyPalletDialog = false;
this.emptypalletOutForm.palletCode = '';
},
@@ -1182,19 +1614,7 @@
color: #909399;
}
-/* 鑷畾涔夊脊绐楁牱寮� */
-:deep(.el-message-box) {
- z-index: 10010 !important;
-}
-
-:deep(.el-overlay) {
- z-index: 10009 !important;
-}
-
-:deep(.el-message) {
- z-index: 10011 !important;
-}
-
+/* 鑷畾涔夊脊绐楁牱寮� - 鍏抽敭淇 */
.custom-dialog-overlay {
position: fixed;
top: 0;
@@ -1205,7 +1625,130 @@
display: flex;
align-items: center;
justify-content: center;
- z-index: 2000; /* 淇濇寔涓�涓悎鐞嗙殑 z-index */
+ z-index: 9999; /* 鎻愰珮z-index纭繚鍦ㄦ渶涓婂眰 */
+}
+
+.custom-dialog-wrapper {
+ position: relative;
+ z-index: 10000;
+}
+
+.custom-dialog {
+ background: white;
+ border-radius: 4px;
+ width: 500px;
+ max-width: 90vw;
+ max-height: 90vh;
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+ overflow: auto;
+}
+
+.custom-dialog-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 20px 20px 10px;
+ border-bottom: 1px solid #ebeef5;
+}
+
+.custom-dialog-header h3 {
+ margin: 0;
+ color: #303133;
+}
+
+.close-button {
+ font-size: 18px;
+ color: #909399;
+ padding: 0;
+ width: 24px;
+ height: 24px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.close-button:hover {
+ color: #409EFF;
+ background-color: transparent;
+}
+
+.custom-dialog-body {
+ padding: 20px;
+}
+
+.custom-dialog-footer {
+ padding: 10px 20px 20px;
+ text-align: right;
+ border-top: 1px solid #ebeef5;
+}
+
+.custom-dialog-footer .el-button {
+ margin-left: 10px;
+}
+
+@media (max-width: 768px) {
+ .custom-dialog {
+ width: 95vw;
+ margin: 10px;
+ }
+
+ .scanner-form {
+ flex-direction: column;
+ align-items: stretch;
+ }
+
+ .scanner-form .el-input {
+ width: 100%;
+ }
+}
+
+/* 鍘熸湁鐨勬牱寮忎繚鎸佷笉鍙� */
+.OutboundPicking-container {
+ padding: 20px;
+}
+
+.scanner-form {
+ display: flex;
+ gap: 10px;
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+.scanner-form .el-input {
+ width: 200px;
+}
+
+.summary-info {
+ display: flex;
+ gap: 20px;
+ flex-wrap: wrap;
+}
+
+.table-actions {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 10px;
+ padding: 0 10px;
+}
+
+.selection-count {
+ font-size: 12px;
+ color: #909399;
+}
+
+/* 鍘熸湁鐨勮嚜瀹氫箟寮圭獥鏍峰紡 */
+.custom-dialog-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 2000;
}
.custom-dialog-wrapper {
@@ -1276,16 +1819,22 @@
flex-direction: column;
align-items: stretch;
}
- /* 纭繚纭瀵硅瘽妗嗗湪鏈�鍓嶉潰 */
-.el-message-box__wrapper {
- z-index: 10001 !important;
-}
-
-.el-message {
- z-index: 10002 !important;
-}
+
.scanner-form .el-input {
width: 100%;
}
}
+
+/* 鏂板锛氭墜鍔ㄥ脊绐楃殑鎸夐挳鎮仠鏁堟灉 */
+:deep(button) {
+ transition: all 0.3s;
+}
+
+:deep(button:hover) {
+ opacity: 0.8;
+}
+
+:deep(button:active) {
+ opacity: 0.6;
+}
</style>
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
index fae3bf5..97ece0b 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
index 332c120..81243ca 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs"
index 83277ed..b1304d5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs"
@@ -41,7 +41,10 @@
{
try
{
+ //erp 娴嬭瘯鐜
var request = new TokenRequest { appId = "BG_SYSTEM", secretKey = "7e9239c1e132462a9cf03bfa342a044aMTcxODE5MzgxODI4Mw" };
+ ////erp 姝e紡鐜
+ //var request = new TokenRequest { appId = "BG_SYSTEM", secretKey = "9a3d0b5a37Bfc6dAM4b34ODb8ebDOSb937106d1b19DS29098" };
var response = await PostAsync<TokenRequest, TokenResponse>("auth/getAccessToken", request, includeToken: false);
var _token = response?.data?.access_token;
return _token ?? "";
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs"
index 3848d23..03077e3 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs"
@@ -5,6 +5,7 @@
using Org.BouncyCastle.Asn1.Ocsp;
using SqlSugar;
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -25,9 +26,10 @@
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Outbound;
namespace WIDESEA_BasicService
-{
+{
public class InvokeMESService : IInvokeMESService
{
private readonly IHttpClientFactory _httpClientFactory;
@@ -44,7 +46,14 @@
private readonly IOutboundOrderService _outboundOrderService;
private readonly IOutboundOrderDetailService _outboundOrderDetailService;
private readonly IOutStockLockInfoService _outStockLockInfoService;
- public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService, IMaterialUnitService materialUnitService, IRepository<Dt_PickingRecord> pickingRecoreRepository)
+ private readonly IRepository<Dt_InterfaceLog> _interfacelogRepository;
+
+ // 瀛樺偍璧勬簮ID鍙婂叾瀵瑰簲鐨勯攣瀵硅薄銆備娇鐢� ConcurrentDictionary 纭繚瀵瑰瓧鍏告搷浣滄湰韬殑绾跨▼瀹夊叏銆�
+ private static readonly ConcurrentDictionary<string, object> _resourceLocks = new ConcurrentDictionary<string, object>();
+
+ // 鍏ㄥ眬闈欐�侀攣锛氱敤浜庝繚鎶� _resourceLocks 瀛楀吀涓� GetOrAdd 鎴� TryRemove 鏃剁殑绔炰簤
+ private static readonly object _globalLocker = new object();
+ public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService, IMaterialUnitService materialUnitService, IRepository<Dt_PickingRecord> pickingRecoreRepository, IRepository<Dt_InterfaceLog> interfacelogRepository)
{
_httpClientFactory = httpClientFactory;
_logger = logger;
@@ -57,6 +66,7 @@
_outStockLockInfoService = outStockLockInfoService;
_materialUnitService = materialUnitService;
_pickingRecoreRepository = pickingRecoreRepository;
+ _interfacelogRepository = interfacelogRepository;
}
/// <summary>
@@ -105,7 +115,7 @@
_client.DefaultRequestHeaders.Clear();
_client.DefaultRequestHeaders.Add("Accept", "application/json");
- _logger.LogInformation("InvokeMESService FeedbackOutbound : "+ model.orderNo +" , " + json);
+ _logger.LogInformation("InvokeMESService FeedbackOutbound : " + model.orderNo + " , " + json);
var response = await _client.PostAsync("AldMaterialOutbound/MaterialOutbound", content);
string body = await response.Content.ReadAsStringAsync();
@@ -224,7 +234,8 @@
}
}
-
+
+
/// <summary>
///
/// </summary>
@@ -233,141 +244,159 @@
/// <returns></returns>
public async Task<WebResponseContent> BatchOrderFeedbackToMes(List<string> orderNos, int inout)
{
- if (inout == 1)
+ // 1. 銆愬唴瀛橀攣鎶㈠崰銆�
+ if (MemoryLockManager.TryAcquireLock(orderNos[0]))
{
- foreach (var orderNo in orderNos)
+ try
{
- try
+ if (inout == 1)
{
- var stockinfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>("info").Where(info => info.StockStatus == 6)
- .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == orderNo).Any())
- .ToList();
- var feeds = _feedbacktomesRepository.Db.Queryable<Dt_FeedbackToMes>().Where(x => x.OrderNo == orderNo && x.ReportStatus == 1).Select(o => o.PalletCode).ToList();
- var unreports = stockinfos.Where(x => !feeds.Contains(x.PalletCode)).ToList();
- if (unreports != null && !unreports.Any())
+ foreach (var orderNo in orderNos)
{
- return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖浼犵殑鏁版嵁");
- }
- foreach (var item in unreports)
- {
- var lists = _stockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.StockId == item.Id).ToList();
- if (lists.Any())
+ try
{
- var inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().First(x => x.InboundOrderNo == lists.FirstOrDefault().OrderNo);
- if (inboundOrder != null)
+ var stockinfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>("info").Where(info => info.StockStatus == 6)
+ .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == orderNo).Any())
+ .ToList();
+ var feeds = _feedbacktomesRepository.Db.Queryable<Dt_FeedbackToMes>().Where(x => x.OrderNo == orderNo && x.ReportStatus == 1).Select(o => o.PalletCode).ToList();
+ var unreports = stockinfos.Where(x => !feeds.Contains(x.PalletCode)).ToList();
+ if (unreports != null && !unreports.Any())
{
- if (inboundOrder.OrderType == (int)InOrderTypeEnum.AllocatInbound)//璋冩嫧鍏ュ簱
+ return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖浼犵殑鏁版嵁");
+ }
+ foreach (var item in unreports)
+ {
+ var lists = _stockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.StockId == item.Id).ToList();
+ if (lists.Any())
{
- var allocate = SqlSugarHelper.DbWMS.Queryable<Dt_AllocateOrder>().Where(x => x.OrderNo == inboundOrder.InboundOrderNo).First();
- var allocatefeedmodel = new AllocateDto
+ var inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().First(x => x.InboundOrderNo == lists.FirstOrDefault().OrderNo);
+ if (inboundOrder != null)
{
- ReqCode = Guid.NewGuid().ToString(),
- ReqTime = DateTime.Now.ToString(),
- BusinessType = "2",
- FactoryArea = inboundOrder.FactoryArea,
- OperationType = 1,
- Operator = inboundOrder.Operator,
- OrderNo = inboundOrder.UpperOrderNo,
- fromWarehouse = allocate?.FromWarehouse ?? "",
- toWarehouse = allocate?.ToWarehouse ?? "",
- Details = new List<AllocateDtoDetail>()
+ if (inboundOrder.OrderType == (int)InOrderTypeEnum.AllocatInbound)//璋冩嫧鍏ュ簱
+ {
+ var allocate = SqlSugarHelper.DbWMS.Queryable<Dt_AllocateOrder>().Where(x => x.OrderNo == inboundOrder.InboundOrderNo).First();
+ var allocatefeedmodel = new AllocateDto
+ {
+ ReqCode = Guid.NewGuid().ToString(),
+ ReqTime = DateTime.Now.ToString(),
+ BusinessType = "2",
+ FactoryArea = inboundOrder.FactoryArea,
+ OperationType = 1,
+ Operator = inboundOrder.Operator,
+ OrderNo = inboundOrder.UpperOrderNo,
+ fromWarehouse = allocate?.FromWarehouse ?? "",
+ toWarehouse = allocate?.ToWarehouse ?? "",
+ Details = new List<AllocateDtoDetail>()
- };
+ };
- var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
- .Select(group => new AllocateDtoDetail
- {
- MaterialCode = group.Key.MaterielCode,
- LineNo = group.Key.InboundOrderRowNo,
- WarehouseCode = group.Key.WarehouseCode,
- Qty = group.Sum(x => x.BarcodeQty),
- Unit = group.Key.BarcodeUnit,
- Barcodes = group.Select(row => new BarcodeInfo
- {
- Barcode = row.Barcode,
- Qty = row.BarcodeQty,
- BatchNo = row.BatchNo,
- SupplyCode = row.SupplyCode,
- Unit = row.BarcodeUnit
- }).ToList()
- }).ToList();
- allocatefeedmodel.Details = groupedData;
+ var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new AllocateDtoDetail
+ {
+ MaterialCode = group.Key.MaterielCode,
+ LineNo = group.Key.InboundOrderRowNo,
+ WarehouseCode = group.Key.WarehouseCode,
+ Qty = group.Sum(x => x.BarcodeQty),
+ Unit = group.Key.BarcodeUnit,
+ Barcodes = group.Select(row => new BarcodeInfo
+ {
+ Barcode = row.Barcode,
+ Qty = row.BarcodeQty,
+ BatchNo = row.BatchNo,
+ SupplyCode = row.SupplyCode,
+ Unit = row.BarcodeUnit
+ }).ToList()
+ }).ToList();
+ allocatefeedmodel.Details = groupedData;
- var result = await FeedbackAllocate(allocatefeedmodel);
- if (result != null && result.code == 200)
- {
- _feedbacktomesRepository.Db.Insertable(new Dt_FeedbackToMes { OrderNo = orderNo, PalletCode = item.PalletCode, ReportStatus = 1 }).ExecuteCommand();
- }
- }
- else
- {
- var feedmodel = new FeedbackInboundRequestModel
- {
- reqCode = Guid.NewGuid().ToString(),
- reqTime = DateTime.Now.ToString(),
- business_type = inboundOrder.BusinessType,
- factoryArea = inboundOrder.FactoryArea,
- operationType = 1,
- Operator = inboundOrder.Operator,
- orderNo = inboundOrder.UpperOrderNo,
- status = inboundOrder.OrderStatus,
- details = new List<FeedbackInboundDetailsModel>()
+ var result = await FeedbackAllocate(allocatefeedmodel);
+ if (result != null && result.code == 200)
+ {
+ _feedbacktomesRepository.Db.Insertable(new Dt_FeedbackToMes { OrderNo = orderNo, PalletCode = item.PalletCode, ReportStatus = 1 }).ExecuteCommand();
+ }
+ }
+ else
+ {
+ var feedmodel = new FeedbackInboundRequestModel
+ {
+ reqCode = Guid.NewGuid().ToString(),
+ reqTime = DateTime.Now.ToString(),
+ business_type = inboundOrder.BusinessType,
+ factoryArea = inboundOrder.FactoryArea,
+ operationType = 1,
+ Operator = inboundOrder.Operator,
+ orderNo = inboundOrder.UpperOrderNo,
+ status = inboundOrder.OrderStatus,
+ details = new List<FeedbackInboundDetailsModel>()
- };
+ };
- var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
- .Select(group => new FeedbackInboundDetailsModel
- {
- materialCode = group.Key.MaterielCode,
- supplyCode = group.Key.SupplyCode,
- batchNo = group.Key.BatchNo,
- lineNo = group.Key.InboundOrderRowNo,
- qty = group.Sum(x => x.BarcodeQty),
- // warehouseCode = group.Key.WarehouseCode=="0"?"1072": group.Key.WarehouseCode,
- warehouseCode = group.Key.WarehouseCode,
- unit = group.Key.BarcodeUnit,
- barcodes = group.Select(row => new FeedbackBarcodesModel
- {
- barcode = row.Barcode,
- qty = row.BarcodeQty
- }).ToList()
- }).ToList();
- feedmodel.details = groupedData;
- var result = await FeedbackInbound(feedmodel);
- if (result != null && result.code == 200)
- {
- _feedbacktomesRepository.Db.Insertable(new Dt_FeedbackToMes { OrderNo = orderNo, PalletCode = item.PalletCode, ReportStatus = 1 }).ExecuteCommand();
+ var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new FeedbackInboundDetailsModel
+ {
+ materialCode = group.Key.MaterielCode,
+ supplyCode = group.Key.SupplyCode,
+ batchNo = group.Key.BatchNo,
+ lineNo = group.Key.InboundOrderRowNo,
+ qty = group.Sum(x => x.BarcodeQty),
+ // warehouseCode = group.Key.WarehouseCode=="0"?"1072": group.Key.WarehouseCode,
+ warehouseCode = group.Key.WarehouseCode,
+ unit = group.Key.BarcodeUnit,
+ barcodes = group.Select(row => new FeedbackBarcodesModel
+ {
+ barcode = row.Barcode,
+ qty = row.BarcodeQty
+ }).ToList()
+ }).ToList();
+ feedmodel.details = groupedData;
+ var result = await FeedbackInbound(feedmodel);
+ if (result != null && result.code == 200)
+ {
+ _feedbacktomesRepository.Db.Insertable(new Dt_FeedbackToMes { OrderNo = orderNo, PalletCode = item.PalletCode, ReportStatus = 1 }).ExecuteCommand();
+ }
+ }
}
}
}
}
+ catch (Exception ex)
+ {
+ _logger.LogInformation("InvokeMESService BatchOrderFeedbackToMes 鍥炲啓MES澶辫触: " + ex.Message);
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+
}
}
- catch (Exception ex)
+ else if (inout == 2)
{
- _logger.LogInformation("InvokeMESService BatchOrderFeedbackToMes 鍥炲啓MES澶辫触: " + ex.Message);
- return WebResponseContent.Instance.Error(ex.Message);
- }
+ foreach (var orderNo in orderNos)
+ {
+ var outboundOrder = await _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().FirstAsync(x => x.OrderNo == orderNo);
+ if (outboundOrder != null && outboundOrder.IsBatch == 0)
+ {
+ var result = await HandleOutboundOrderToMESCompletion(outboundOrder, orderNo);
+ return result;
+ }
+ else if (outboundOrder != null && outboundOrder.IsBatch == 1)
+ {
+ var result = await HandleOutboundOrderBatchToMESCompletion(outboundOrder, orderNo);
+ return result;
+ }
+ }
+ }
+ }
+ finally
+ {
+ // 2. 銆愰噴鏀惧唴瀛橀攣銆戞棤璁烘垚鍔熷け璐ワ紝蹇呴』閲婃斁
+ MemoryLockManager.ReleaseLock(orderNos[0]);
}
}
- else if (inout == 2)
+ else
{
- foreach (var orderNo in orderNos)
- {
- var outboundOrder = await _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().FirstAsync(x => x.OrderNo == orderNo);
- if (outboundOrder != null && outboundOrder.IsBatch == 0)
- {
- var result = await HandleOutboundOrderToMESCompletion(outboundOrder, orderNo);
- return result;
- }
- else if (outboundOrder != null && outboundOrder.IsBatch == 1)
- {
- var result = await HandleOutboundOrderBatchToMESCompletion(outboundOrder, orderNo);
- return result;
- }
- }
+ // 鎶㈤攣澶辫触锛氳鏄庢湁鍙︿竴涓嚎绋嬶紙WCS鍥炶皟鎴栦汉宸ユ搷浣滐級姝e湪澶勭悊
+ return WebResponseContent.Instance.Error("WMS姝e湪澶勭悊姝ゅ洖浼犱换鍔★紝璇峰嬁閲嶅鎿嶄綔銆�");
}
return WebResponseContent.Instance.OK();
}
@@ -404,218 +433,66 @@
return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖浼犵殑鍒嗘嫞璁板綍");
- var documentNo = UniqueValueGenerator.Generate();
-
-
- var feedModel = new FeedbackOutboundRequestModel
+ var groups = pickingRecords.GroupBy(x => x.FeedBackMesDocumentNo).ToList();
+ foreach (var group in groups)
{
- reqCode = Guid.NewGuid().ToString(),
- reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- business_type = outboundOrder.BusinessType,
- factoryArea = outboundOrder.FactoryArea,
- operationType = 1,
- Operator = outboundOrder.Operator!=""? outboundOrder.Operator:App.User.UserName,
- orderNo = outboundOrder.UpperOrderNo,
- documentsNO = documentNo,
- status = outboundOrder.OrderStatus,
- details = new List<FeedbackOutboundDetailsModel>()
- };
- var detailIds = new List<int>();
- // 濉厖鏄庣粏鍜屾潯鐮佷俊鎭�
- foreach (var detail in orderDetails)
- {
- // 鏌ヨ璇ユ槑缁嗗搴旂殑閿佸畾鏉$爜璁板綍
- var detailPicks = pickingRecords.Where(x => x.OrderNo == orderNo
- && detail.Id == x.OrderDetailId).ToList();
- if (!detailPicks.Any())
- {
- continue;
- }
- var detailModel = new FeedbackOutboundDetailsModel
- {
- materialCode = detail.MaterielCode,
- lineNo = detail.lineNo,
- warehouseCode = detail.WarehouseCode,
- qty = detail.BarcodeQty,
- currentDeliveryQty = 0,
- unit = detail.BarcodeUnit,
- barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
- };
- // 濉厖鏉$爜淇℃伅锛堝惈鍗曚綅杞崲锛�
- foreach (var item in detailPicks)
+ List<Dt_PickingRecord> records = group.ToList(); // 璇ュ垎缁勪笅鐨勬墍鏈夎褰�
+ if (string.IsNullOrEmpty(group.Key))
{
- if (item.PickQuantity <= 0)
+ var emptydocumentNo = UniqueValueGenerator.Generate();
+ records.ForEach(x => { x.FeedBackMesDocumentNo = emptydocumentNo; });
+ var result = await _pickingRecoreRepository.Db.Updateable(records).ExecuteCommandAsync();
+
+ var interfacelog = new Dt_InterfaceLog
{
- continue;
- }
- var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
- {
- barcode = item.Barcode,
- supplyCode = item.SupplyCode,
- batchNo = item.BatchNo,
- unit = item.BarcodeUnit,
- qty = item.PickQuantity
+ Content = JsonConvert.SerializeObject(records),
+ DocumentNo = emptydocumentNo,
+ OrderNo = orderNo,
+ OrderType = "2",
};
+ _interfacelogRepository.AddData(interfacelog);
- // 鍗曚綅涓嶄竴鑷存椂杞崲
- if (detail.BarcodeUnit != detail.Unit)
+ if (result > 0)
{
- var convertResult = await _materialUnitService.ConvertAsync(
- item.MaterielCode, item.PickQuantity, detail.Unit, detail.BarcodeUnit);
- barModel.unit = convertResult.Unit;
- barModel.qty = convertResult.Quantity;
- }
- else
- {
- barModel.qty = item.PickQuantity;
- }
- detailModel.currentDeliveryQty += barModel.qty;
- detailModel.barcodes.Add(barModel);
- }
- detailIds.Add(detail.Id);
- feedModel.details.Add(detailModel);
- }
+ (bool _flowControl, WebResponseContent _value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, emptydocumentNo);
- feedModel.details = feedModel.details.GroupBy(item => new { item.materialCode, item.lineNo, item.warehouseCode, item.unit,item.qty }).Select(group => new FeedbackOutboundDetailsModel
- {
- materialCode = group.Key.materialCode,
- lineNo = group.Key.lineNo,
- warehouseCode = group.Key.warehouseCode,
- qty = group.Key.qty,
- currentDeliveryQty = group.Sum(x => x.currentDeliveryQty),
- unit = group.Key.unit,
- barcodes = group.SelectMany(x => x.barcodes.GroupBy(o => new { o.barcode, o.supplyCode, o.batchNo, o.unit }).Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
- {
- barcode = row.Key.barcode,
- supplyCode = row.Key.supplyCode,
- batchNo = row.Key.batchNo,
- unit = row.Key.unit,
- qty = row.Sum(y => y.qty)
- })).ToList()
- }).ToList();
+ return _value;
- var allCompleted = true;
-
- // 绛涢�夊緟鍥炰紶鐨勬槑缁嗭紙ReturnToMESStatus=0锛�
- var pendingDetails = orderDetails.Where(x => x.ReturnToMESStatus == 0).ToList();
- foreach (var detail in pendingDetails)
- {
- if (detail.OverOutQuantity < detail.NeedOutQuantity)
- {
- allCompleted = false;
- }
- }
-
- // 瀛樺湪鍥炰紶澶辫触鐨勬槑缁嗭紙ReturnToMESStatus=2锛夛紝鏍囪鏈畬鎴�
- if (orderDetails.Any(x => x.ReturnToMESStatus == 2))
- {
- allCompleted = false;
- }
-
- // 鏇存柊璁㈠崟鐘舵��
- int newStatus = allCompleted ? (int)OutOrderStatusEnum.鍑哄簱瀹屾垚 : (int)OutOrderStatusEnum.鍑哄簱涓�;
- if (outboundOrder.OrderStatus != newStatus)
- {
-
- int updateCount = await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
- .SetColumns(x => x.OrderStatus == newStatus)
- .Where(x => x.OrderNo == orderNo)
- .ExecuteCommandAsync();
-
- if (updateCount <= 0)
- {
- _logger.LogWarning($"鏇存柊鍑哄簱鍗曠姸鎬佸け璐� - OrderNo: {orderNo}, 鐩爣鐘舵��: {newStatus}");
-
- }
- }
-
-
- // 璋冪敤MES鍥炰紶鎺ュ彛
- var mesResult = await FeedbackOutbound(feedModel);
- if (mesResult == null || mesResult.code != 200)
- {
-
- // 鏇存柊鏄庣粏涓哄洖浼犲け璐ワ紙ReturnToMESStatus=2锛�
- await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
- .SetColumns(it => new Dt_OutboundOrderDetail
- {
- ReturnToMESStatus = 2,
- documentsNO = documentNo,
- })
- .Where(x => detailIds.Contains(x.Id))
- .ExecuteCommandAsync();
-
- return WebResponseContent.Instance.Error($"鍥炰紶MES澶辫触");
- }
- foreach (var record in pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList())
- {
- record.ReturnToMESStatus = 1;
- }
- var updates = pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList();
- updates.ForEach(x =>
- {
- x.ReturnToMESStatus = 1;
- });
- await _pickingRecoreRepository.Db.Updateable(updates).ExecuteCommandAsync();
- if (allCompleted)
- {
- //MES鍥炰紶鎴愬姛锛氭洿鏂版槑缁嗕负鍥炰紶鎴愬姛鐘舵��
- await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
- .SetColumns(it => new Dt_OutboundOrderDetail
- {
- ReturnToMESStatus = 1,
- documentsNO = documentNo,
- })
- .Where(x => detailIds.Contains(x.Id))
- .ExecuteCommandAsync();
- }
- // 鏍¢獙鏄惁鎵�鏈夋槑缁嗛兘瀹屾垚锛屾洿鏂拌鍗曟渶缁堢姸鎬�
- if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
- {
- await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
- .SetColumns(x => new Dt_OutboundOrder
- {
- ReturnToMESStatus = 1,
- OrderStatus = newStatus
- })
- .Where(x => x.OrderNo == orderNo)
- .ExecuteCommandAsync();
- }
- else
- {
- // 浜屾鏍¢獙鏄惁鎵�鏈夋湭鍥炰紶鏄庣粏閮藉凡瀹屾垚
- var dbOrderDetails = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
- .LeftJoin<Dt_OutboundOrder>((o, item) => o.OrderId == item.Id)
- .Where((o, item) => item.OrderNo == orderNo && item.ReturnToMESStatus != 1)
- .Select((o, item) => o)
- .ToListAsync();
-
- var secAllCompleted = true;
- foreach (var detail in dbOrderDetails.Where(x => x.ReturnToMESStatus == 0).ToList())
- {
- if (detail.OverOutQuantity < detail.NeedOutQuantity)
- {
- secAllCompleted = false;
- break;
}
}
-
- if (secAllCompleted)
+ else
{
- await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
- .SetColumns(it => new Dt_OutboundOrder
+ var ilog = _interfacelogRepository.QueryFirst(x => x.DocumentNo == group.Key);
+ if (ilog == null)
+ {
+ var interfacelog = new Dt_InterfaceLog
{
- ReturnToMESStatus = 1,
- OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt(),
- })
- .Where(x => x.OrderNo == orderNo)
- .ExecuteCommandAsync();
+ Content = JsonConvert.SerializeObject(records),
+ DocumentNo = group.Key,
+ OrderNo = orderNo,
+ OrderType = "2",
+ };
+ _interfacelogRepository.AddData(interfacelog);
+ }
+ (bool _flowControl, WebResponseContent _value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, group.Key);
+
+ return _value;
+
}
}
+
+
+ //var documentNo = UniqueValueGenerator.Generate();
+
+ //(bool flowControl, WebResponseContent value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, documentNo);
+ //if (!flowControl)
+ //{
+ // return value;
+ //}
// 鍥炰紶鎴愬姛鐨勬渶缁堣繑鍥�
- response = WebResponseContent.Instance.OK($"鍥炰紶MES鎴愬姛锛屽崟鎹彿锛歿documentNo}");
+ response = WebResponseContent.Instance.OK($"鍥炰紶MES鎴愬姛锛屽崟鎹彿锛歿orderNo}");
}
catch (Exception ex)
{
@@ -628,6 +505,223 @@
}
return response;
+ }
+
+ private async Task<(bool flowControl, WebResponseContent value)> FeedBackBatchToMes(Dt_OutboundOrder outboundOrder, string orderNo, List<Dt_OutboundOrderDetail> orderDetails, List<Dt_PickingRecord> pickingRecords, string documentNo)
+ {
+ var feedModel = new FeedbackOutboundRequestModel
+ {
+ reqCode = Guid.NewGuid().ToString(),
+ reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ business_type = outboundOrder.BusinessType,
+ factoryArea = outboundOrder.FactoryArea,
+ operationType = 1,
+ Operator = outboundOrder.Operator != "" ? outboundOrder.Operator : App.User.UserName,
+ orderNo = outboundOrder.UpperOrderNo,
+ documentsNO = documentNo,
+ status = outboundOrder.OrderStatus,
+ details = new List<FeedbackOutboundDetailsModel>()
+ };
+ var detailIds = new List<int>();
+ // 濉厖鏄庣粏鍜屾潯鐮佷俊鎭�
+ foreach (var detail in orderDetails)
+ {
+ // 鏌ヨ璇ユ槑缁嗗搴旂殑閿佸畾鏉$爜璁板綍
+ var detailPicks = pickingRecords.Where(x => x.OrderNo == orderNo
+ && detail.Id == x.OrderDetailId).ToList();
+ if (!detailPicks.Any())
+ {
+ continue;
+ }
+ var detailModel = new FeedbackOutboundDetailsModel
+ {
+ materialCode = detail.MaterielCode,
+ lineNo = detail.lineNo,
+ warehouseCode = detail.WarehouseCode,
+ qty = detail.BarcodeQty,
+ currentDeliveryQty = 0,
+ unit = detail.BarcodeUnit,
+ barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
+ };
+
+ // 濉厖鏉$爜淇℃伅锛堝惈鍗曚綅杞崲锛�
+ foreach (var item in detailPicks)
+ {
+ if (item.PickQuantity <= 0)
+ {
+ continue;
+ }
+ var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = item.Barcode,
+ supplyCode = item.SupplyCode,
+ batchNo = item.BatchNo,
+ unit = item.BarcodeUnit,
+ qty = item.PickQuantity
+ };
+
+ // 鍗曚綅涓嶄竴鑷存椂杞崲
+ if (detail.BarcodeUnit != detail.Unit)
+ {
+ var convertResult = await _materialUnitService.ConvertAsync(
+ item.MaterielCode, item.PickQuantity, detail.Unit, detail.BarcodeUnit);
+ barModel.unit = convertResult.Unit;
+ barModel.qty = convertResult.Quantity;
+ }
+ else
+ {
+ barModel.qty = item.PickQuantity;
+ }
+ detailModel.currentDeliveryQty += barModel.qty;
+ detailModel.barcodes.Add(barModel);
+ }
+ detailIds.Add(detail.Id);
+ feedModel.details.Add(detailModel);
+ }
+
+ feedModel.details = feedModel.details.GroupBy(item => new { item.materialCode, item.lineNo, item.warehouseCode, item.unit, item.qty }).Select(group => new FeedbackOutboundDetailsModel
+ {
+ materialCode = group.Key.materialCode,
+ lineNo = group.Key.lineNo,
+ warehouseCode = group.Key.warehouseCode,
+ qty = group.Key.qty,
+ currentDeliveryQty = group.Sum(x => x.currentDeliveryQty),
+ unit = group.Key.unit,
+ barcodes = group.SelectMany(x => x.barcodes.GroupBy(o => new { o.barcode, o.supplyCode, o.batchNo, o.unit }).Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = row.Key.barcode,
+ supplyCode = row.Key.supplyCode,
+ batchNo = row.Key.batchNo,
+ unit = row.Key.unit,
+ qty = row.Sum(y => y.qty)
+ })).ToList()
+ }).ToList();
+
+ var allCompleted = true;
+
+ // 绛涢�夊緟鍥炰紶鐨勬槑缁嗭紙ReturnToMESStatus=0锛�
+ var pendingDetails = orderDetails.Where(x => x.ReturnToMESStatus == 0).ToList();
+ foreach (var detail in pendingDetails)
+ {
+ if (detail.OverOutQuantity < detail.NeedOutQuantity)
+ {
+ allCompleted = false;
+ }
+ }
+
+ // 瀛樺湪鍥炰紶澶辫触鐨勬槑缁嗭紙ReturnToMESStatus=2锛夛紝鏍囪鏈畬鎴�
+ if (orderDetails.Any(x => x.ReturnToMESStatus == 2))
+ {
+ allCompleted = false;
+ }
+
+ // 鏇存柊璁㈠崟鐘舵��
+ int newStatus = allCompleted ? (int)OutOrderStatusEnum.鍑哄簱瀹屾垚 : (int)OutOrderStatusEnum.鍑哄簱涓�;
+ if (outboundOrder.OrderStatus != newStatus)
+ {
+
+ int updateCount = await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(x => x.OrderStatus == newStatus)
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+
+ if (updateCount <= 0)
+ {
+ _logger.LogWarning($"鏇存柊鍑哄簱鍗曠姸鎬佸け璐� - OrderNo: {orderNo}, 鐩爣鐘舵��: {newStatus}");
+
+ }
+ }
+
+
+ // 璋冪敤MES鍥炰紶鎺ュ彛
+ var mesResult = await FeedbackOutbound(feedModel);
+ if (mesResult == null || mesResult.code != 200)
+ {
+
+ // 鏇存柊鏄庣粏涓哄洖浼犲け璐ワ紙ReturnToMESStatus=2锛�
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(it => new Dt_OutboundOrderDetail
+ {
+ ReturnToMESStatus = 2,
+ documentsNO = documentNo,
+ })
+ .Where(x => detailIds.Contains(x.Id))
+ .ExecuteCommandAsync();
+
+ return (flowControl: false, value: WebResponseContent.Instance.Error($"鍥炰紶MES澶辫触"));
+ }
+ foreach (var record in pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList())
+ {
+ record.ReturnToMESStatus = 1;
+ }
+ var updates = pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList();
+ updates.ForEach(x =>
+ {
+ x.ReturnToMESStatus = 1;
+ });
+ await _pickingRecoreRepository.Db.Updateable(updates).ExecuteCommandAsync();
+ await _interfacelogRepository.Db.Updateable<Dt_InterfaceLog>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+
+ if (allCompleted)
+ {
+ //MES鍥炰紶鎴愬姛锛氭洿鏂版槑缁嗕负鍥炰紶鎴愬姛鐘舵��
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(it => new Dt_OutboundOrderDetail
+ {
+ ReturnToMESStatus = 1,
+ documentsNO = documentNo,
+ })
+ .Where(x => detailIds.Contains(x.Id))
+ .ExecuteCommandAsync();
+ }
+ // 鏍¢獙鏄惁鎵�鏈夋槑缁嗛兘瀹屾垚锛屾洿鏂拌鍗曟渶缁堢姸鎬�
+ if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
+ {
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(x => new Dt_OutboundOrder
+ {
+ ReturnToMESStatus = 1,
+ OrderStatus = newStatus
+ })
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
+ else
+ {
+ // 浜屾鏍¢獙鏄惁鎵�鏈夋湭鍥炰紶鏄庣粏閮藉凡瀹屾垚
+ var dbOrderDetails = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+ .LeftJoin<Dt_OutboundOrder>((o, item) => o.OrderId == item.Id)
+ .Where((o, item) => item.OrderNo == orderNo && item.ReturnToMESStatus != 1)
+ .Select((o, item) => o)
+ .ToListAsync();
+
+ var secAllCompleted = true;
+ foreach (var detail in dbOrderDetails.Where(x => x.ReturnToMESStatus == 0).ToList())
+ {
+ if (detail.OverOutQuantity < detail.NeedOutQuantity)
+ {
+ secAllCompleted = false;
+ break;
+ }
+ }
+
+ if (secAllCompleted)
+ {
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(it => new Dt_OutboundOrder
+ {
+ ReturnToMESStatus = 1,
+ OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt(),
+ })
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
+ }
+
+ return (flowControl: true, value: null);
}
private async Task<WebResponseContent> HandleOutboundOrderToMESCompletion(Dt_OutboundOrder outboundOrder, string orderNo)
@@ -777,7 +871,7 @@
return WebResponseContent.Instance.Error("澶勭悊鍥炰紶MES鏃跺彂鐢熷紓甯革紝璇疯仈绯荤鐞嗗憳");
}
}
- }
+ }
public static class UniqueValueGenerator
{
@@ -796,10 +890,10 @@
// 鎷兼帴锛氳鏁板櫒琛�0涓�3浣嶏紙閬垮厤浣嶆暟涓嶄竴鑷达級
return $"{datePart}{ticksPart}";
}
-
+
public static string GenerateCount()
{
- var now = DateTime.Now;
+ var now = DateTime.Now;
string datePart = now.ToString("yyyyMMddHHmmss");
@@ -810,4 +904,59 @@
return $"{datePart}{counterPart:D3}";
}
}
+
+
+ public static class MemoryLockManager
+ {
+ // 瀛樺偍璧勬簮ID鍙婂叾瀵瑰簲鐨勯攣瀵硅薄銆備娇鐢� ConcurrentDictionary 纭繚瀵瑰瓧鍏告搷浣滄湰韬殑绾跨▼瀹夊叏銆�
+ private static readonly ConcurrentDictionary<string, object> _resourceLocks = new ConcurrentDictionary<string, object>();
+
+ // 鍏ㄥ眬闈欐�侀攣锛氱敤浜庝繚鎶� _resourceLocks 瀛楀吀涓� GetOrAdd 鎴� TryRemove 鏃剁殑绔炰簤
+ private static readonly object _globalLocker = new object();
+
+ /// <summary>
+ /// 灏濊瘯閿佸畾涓�涓祫婧怚D銆�
+ /// </summary>
+ /// <param name="resourceId">瑕侀攣瀹氱殑璧勬簮ID锛堜緥濡� InboundRecord ID锛�</param>
+ /// <returns>鏄惁鎴愬姛鑾峰彇閿�</returns>
+ public static bool TryAcquireLock(string resourceId)
+ {
+ object lockObject = null;
+
+ // 鏍稿績鎬濊矾锛氫负姣忎釜璧勬簮鍒涘缓涓�涓敮涓�鐨勯攣瀵硅薄
+ lock (_globalLocker)
+ {
+ // 濡傛灉璧勬簮ID涓嶅湪瀛楀吀涓紝鍒欐坊鍔犱竴涓柊鐨勯攣瀵硅薄
+ // 鍚﹀垯锛屼娇鐢ㄥ凡瀛樺湪鐨勯攣瀵硅薄
+ lockObject = _resourceLocks.GetOrAdd(resourceId, new object());
+ }
+
+ // 灏濊瘯鑾峰彇璧勬簮鐗瑰畾鐨勯攣
+ // 浣跨敤 Monitor.TryEnter 閬垮厤闃诲锛屽苟瀹炵幇闈為樆濉炵殑鎶㈤攣
+ return Monitor.TryEnter(lockObject);
+ }
+
+ /// <summary>
+ /// 閲婃斁璧勬簮ID鐨勯攣瀹氥��
+ /// </summary>
+ /// <param name="resourceId">瑕侀噴鏀剧殑璧勬簮ID</param>
+ public static void ReleaseLock(string resourceId)
+ {
+ if (_resourceLocks.TryGetValue(resourceId, out object lockObject))
+ {
+ // 纭繚閲婃斁鐨勬槸褰撳墠绾跨▼鎸佹湁鐨勯攣
+ if (Monitor.IsEntered(lockObject))
+ {
+ Monitor.Exit(lockObject);
+
+ // 閲婃斁閿佸悗锛屽皾璇曚粠瀛楀吀涓Щ闄よ繖涓攣瀵硅薄锛屾竻鐞嗗唴瀛樸��
+ // 蹇呴』鍦� Monitor.Exit 涔嬪悗鎵ц銆�
+ lock (_globalLocker)
+ {
+ _resourceLocks.TryRemove(resourceId, out _);
+ }
+ }
+ }
+ }
+ }
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs"
index edb4c46..bb8786c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs"
@@ -139,15 +139,26 @@
}
List<string> lockLocationCodes = locationCaches.Select(x => x.LocationCode).ToList();
+
+ //Dictionary<string, SqlSugar.OrderByType> orderBy = new Dictionary<string, OrderByType>()
+ //{
+ // { nameof(Dt_LocationInfo.RoadwayNo),OrderByType.Asc },
+ // { nameof(Dt_LocationInfo.Layer),OrderByType.Asc },
+ // { nameof(Dt_LocationInfo.Column),OrderByType.Asc },
+ // { nameof(Dt_LocationInfo.Depth),OrderByType.Desc },
+ // { nameof(Dt_LocationInfo.Row),OrderByType.Asc }
+ //};
Dictionary<string, SqlSugar.OrderByType> orderBy = new Dictionary<string, OrderByType>()
{
- { nameof(Dt_LocationInfo.RoadwayNo),OrderByType.Asc },
+ //{ nameof(Dt_LocationInfo.RoadwayNo),OrderByType.Asc },
{ nameof(Dt_LocationInfo.Layer),OrderByType.Asc },
+ { nameof(Dt_LocationInfo.Row),OrderByType.Asc },
{ nameof(Dt_LocationInfo.Column),OrderByType.Asc },
{ nameof(Dt_LocationInfo.Depth),OrderByType.Desc },
- { nameof(Dt_LocationInfo.Row),OrderByType.Asc }
+
};
+
var first = BaseDal.QueryFirst(x => x.LocationType == locationType && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt() && !lockLocationCodes.Contains(x.LocationCode), orderBy);//鏌ヨ绌鸿揣浣嶄俊鎭苟鎺掗櫎5鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
if (first != null)
@@ -157,7 +168,7 @@
{
LocationStatus = (int)LocationStatusEnum.InStockLock,
}).Where(x => x.Id == first.Id).ExecuteCommand();
- }
+ }
return first;
}
@@ -217,7 +228,7 @@
{
return Repository.QueryData(x => locationCodes.Contains(x.LocationCode));
}
-
+
public List<LocationTypeDto> GetLocationTypes()
{
return _locationTypeRepository.Db.Queryable<Dt_LocationType>().Select(x =>
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_CheckService/ReCheckOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_CheckService/ReCheckOrderService.cs"
index 2177e5a..3822dee 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_CheckService/ReCheckOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_CheckService/ReCheckOrderService.cs"
@@ -92,6 +92,11 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒板崟淇℃伅");
}
+ var isupdate = false;
+ if (recheckOrder.SignSeq == model.SignSeq)
+ {
+ isupdate = true;
+ }
recheckOrder.OrderNo = model.OrderNo;
recheckOrder.MaterielCode = model.MaterielCode;
recheckOrder.BatchNo = model.BatchNo;
@@ -107,14 +112,15 @@
BaseDal.UpdateData(recheckOrder);
- _outboundService.OutboundOrderService.Db.Deleteable<Dt_OutboundOrder>().Where(x => x.OrderNo == model.OrderNo).ExecuteCommand();
- _outboundService.OutboundOrderDetailService.Db.Deleteable<Dt_OutboundOrderDetail>()
- .Where(p => SqlFunc.Subqueryable<Dt_OutboundOrder>().Where(s => s.Id == p.OrderId && s.OrderNo == model.OrderNo).Any()).ExecuteCommand();
+ if (isupdate)
+ {
+ _outboundService.OutboundOrderService.Db.Deleteable<Dt_OutboundOrder>().Where(x => x.OrderNo == model.OrderNo).ExecuteCommand();
+ _outboundService.OutboundOrderDetailService.Db.Deleteable<Dt_OutboundOrderDetail>()
+ .Where(p => SqlFunc.Subqueryable<Dt_OutboundOrder>().Where(s => s.Id == p.OrderId && s.OrderNo == model.OrderNo).Any()).ExecuteCommand();
- var outboundOrders = ConvertToOutboundOrders(model);
-
- await _outboundService.OutboundOrderService.ReceiveOutboundOrder(outboundOrders, 1);
-
+ var outboundOrders = ConvertToOutboundOrders(model);
+ await _outboundService.OutboundOrderService.ReceiveOutboundOrder(outboundOrders, 1);
+ }
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskStatusEnum.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskStatusEnum.cs"
index fdea881..38a980e 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskStatusEnum.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskStatusEnum.cs"
@@ -66,6 +66,8 @@
[Description("AGV鎵ц涓�")]
AGV_Executing = 310,
+ [Description("AGV鍙栬揣涓�")]
+ AGV_Pull = 315,
/// <summary>
/// AGV寰呯户缁墽琛�
/// </summary>
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
index 171d380..2d08e68 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
@@ -901,7 +901,7 @@
else if (propertyInfo.Name == nameof(BaseEntity.ModifyDate))
{
propertyInfo.SetValue(obj, DateTime.Now);
- }
+ }
else
{
propertyInfo.SetValue(obj, property.GetValue(entity));
@@ -913,62 +913,245 @@
}
}
return DeleteData(entity);
-
+
}
+
+ //public bool DeleteAndMoveIntoHty(TEntity entity, OperateTypeEnum operateType)
+ //{
+ // // 鏍稿績閫昏緫锛氱敤浜嬪姟淇濊瘉鍘熷瓙鎬э紝寮傚父鎹曡幏閬垮厤娴佺▼涓柇锛屾棩蹇楄緟鍔╂帓鏌�
+ // bool isSuccess = false;
+ // string entityTypeName = entity?.GetType().Name ?? "鏈煡瀹炰綋";
+
+ // try
+ // {
+ // // 鍓嶇疆鏍¢獙锛氬疄浣撲笉鑳戒负绌�
+ // if (entity == null)
+ // {
+ // return false;
+ // }
+
+ // Type entityType = entity.GetType();
+ // Assembly assembly = entityType.Assembly;
+ // string htyTypeName = $"{entityType.FullName}_Hty";
+ // Type? htyType = assembly.GetType(htyTypeName);
+
+ // // 1. 妫�鏌ュ巻鍙茶〃绫诲瀷鏄惁瀛樺湪
+ // if (htyType == null)
+ // {
+
+ // return false;
+ // }
+
+ // // 2. 鍒涘缓鍘嗗彶琛ㄥ疄渚嬶紙澶勭悊鏃犲弬鏋勯�犲嚱鏁颁笉瀛樺湪鐨勬儏鍐碉級
+ // object? htyObj;
+ // try
+ // {
+ // htyObj = Activator.CreateInstance(htyType);
+ // }
+ // catch (Exception ex)
+ // {
+ // // _logger.LogError(ex, "DeleteAndMoveIntoHty锛氬垱寤哄巻鍙茶〃瀹炰緥 {HtyTypeName} 澶辫触", htyTypeName);
+ // return false;
+ // }
+ // if (htyObj == null)
+ // {
+ // // _logger.LogWarning("DeleteAndMoveIntoHty锛氬巻鍙茶〃瀹炰緥 {HtyTypeName} 鍒涘缓缁撴灉涓簄ull", htyTypeName);
+ // return false;
+ // }
+
+ // // 3. 鑾峰彇鏍稿績灞炴�э紙鎸囧畾BindingFlags纭繚鑾峰彇鍏叡瀹炰緥灞炴�э級
+ // BindingFlags propFlags = BindingFlags.Public | BindingFlags.Instance;
+ // PropertyInfo? keyPro = typeof(TEntity).GetKeyProperty(); // 鑷畾涔夋柟娉曢渶纭繚杩斿洖闈炵┖锛屾澶勫鍔犲垽绌�
+ // PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType), propFlags);
+ // PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId), propFlags);
+
+ // // 鏍¢獙鏍稿績灞炴�ф槸鍚﹀瓨鍦�
+ // if (keyPro == null)
+ // {
+ // //_logger.LogError("DeleteAndMoveIntoHty锛氬疄浣� {EntityType} 鏈壘鍒颁富閿睘鎬�", entityType.FullName);
+ // return false;
+ // }
+ // if (operateTypePro == null)
+ // {
+ // //_logger.LogError("DeleteAndMoveIntoHty锛氬巻鍙茶〃 {HtyTypeName} 鏈壘鍒癘perateType灞炴��", htyTypeName);
+ // return false;
+ // }
+ // if (sourceIdPro == null)
+ // {
+ // // _logger.LogError("DeleteAndMoveIntoHty锛氬巻鍙茶〃 {HtyTypeName} 鏈壘鍒癝ourceId灞炴��", htyTypeName);
+ // return false;
+ // }
+
+ // // 4. 璧嬪�兼牳蹇冨睘鎬э紙鏍¢獙绫诲瀷鍖归厤锛岄伩鍏峉etValue鎶涘紓甯革級
+ // try
+ // {
+ // // 澶勭悊OperateType绫诲瀷鍖归厤锛氳嫢鍘嗗彶琛ㄥ睘鎬ф槸鏋氫妇绫诲瀷锛岀洿鎺ヤ紶鏋氫妇鑰岄潪瀛楃涓�
+ // if (operateTypePro.PropertyType == typeof(OperateTypeEnum))
+ // {
+ // operateTypePro.SetValue(htyObj, operateType);
+ // }
+ // else if (operateTypePro.PropertyType == typeof(string))
+ // {
+ // operateTypePro.SetValue(htyObj, operateType.ToString());
+ // }
+ // else
+ // {
+ // //_logger.LogError("DeleteAndMoveIntoHty锛氬巻鍙茶〃 {HtyTypeName} 鐨凮perateType灞炴�х被鍨� {PropType} 涓嶅尮閰嶏紙浠呮敮鎸佹灇涓�/瀛楃涓诧級", htyTypeName, operateTypePro.PropertyType.FullName);
+ // return false;
+ // }
+
+ // // 璧嬪�糞ourceId锛堟牎楠岀被鍨嬪尮閰嶏級
+ // object sourceIdValue = keyPro.GetValue(entity)!;
+ // if (sourceIdPro.PropertyType != sourceIdValue.GetType())
+ // {
+ // sourceIdValue = Convert.ChangeType(sourceIdValue, sourceIdPro.PropertyType); // 绫诲瀷杞崲
+ // }
+ // sourceIdPro.SetValue(htyObj, sourceIdValue);
+ // }
+ // catch (Exception ex)
+ // {
+ // // _logger.LogError(ex, "DeleteAndMoveIntoHty锛氬巻鍙茶〃 {HtyTypeName} 鏍稿績灞炴�ц祴鍊煎け璐�", htyTypeName);
+ // return false;
+ // }
+
+ // // 5. 璧嬪�煎叾浠栧睘鎬э紙鎺掗櫎鏍稿績灞炴�э級
+ // List<PropertyInfo> htyProperties = htyType.GetProperties(propFlags)
+ // .Where(x => x.Name != operateTypePro.Name
+ // && x.Name != sourceIdPro.Name
+ // && x.Name != keyPro.Name)
+ // .ToList();
+
+ // foreach (PropertyInfo htyProp in htyProperties)
+ // {
+ // PropertyInfo? entityProp = entityType.GetProperty(htyProp.Name, propFlags);
+ // if (entityProp == null) continue; // 瀹炰綋鏃犺灞炴�у垯璺宠繃
+
+ // try
+ // {
+ // object propValue;
+ // // 澶勭悊淇敼浜猴細閬垮厤App.User绌哄紩鐢�
+ // if (htyProp.Name == nameof(BaseEntity.Modifier))
+ // {
+ // propValue = App.User?.UserId > 0 ? App.User?.UserName : "System";
+ // }
+ // // 澶勭悊淇敼鏃堕棿
+ // else if (htyProp.Name == nameof(BaseEntity.ModifyDate))
+ // {
+ // propValue = DateTime.Now;
+ // }
+ // // 鍏朵粬灞炴�т粠鍘熷疄浣撳彇鍊�
+ // else
+ // {
+ // propValue = entityProp.GetValue(entity) ?? DBNull.Value; // 澶勭悊null鍊�
+ // }
+
+ // // 绫诲瀷杞崲鍚庤祴鍊硷紙閬垮厤绫诲瀷涓嶅尮閰嶏級
+ // if (propValue != DBNull.Value && propValue != null)
+ // {
+ // propValue = Convert.ChangeType(propValue, htyProp.PropertyType);
+ // }
+ // htyProp.SetValue(htyObj, propValue);
+ // }
+ // catch (Exception ex)
+ // {
+ // // _logger.LogWarning(ex, "DeleteAndMoveIntoHty锛氬巻鍙茶〃 {HtyTypeName} 灞炴�� {PropName} 璧嬪�煎け璐ワ紝璺宠繃璇ュ睘鎬�", htyTypeName, htyProp.Name);
+ // }
+ // }
+ // try
+ // {
+ // // 鎵ц鎻掑叆鍘嗗彶琛�
+ // int insertRows = _db.InsertableByObject(htyObj).AS(entityType.Name + "_Hty").ExecuteCommand();
+
+ // if (insertRows <= 0)
+ // {
+ // // _logger.LogError("DeleteAndMoveIntoHty锛氬巻鍙茶〃 {HtyTypeName} 鎻掑叆澶辫触锛堝奖鍝嶈鏁�0锛�", htyTypeName);
+ // _db.InsertableByObject(htyObj).AS(entityType.Name + "_Hty").ExecuteCommand();
+ // return false;
+ // }
+ // // 鎻掑叆鎴愬姛鍚庢墽琛屽垹闄�
+ // bool deleteSuccess = DeleteData(entity);
+ // if (!deleteSuccess)
+ // {
+ // //_logger.LogError("DeleteAndMoveIntoHty锛氬疄浣� {EntityType} 鍒犻櫎澶辫触", entityType.FullName);
+ // DeleteData(entity);
+ // return false;
+ // }
+ // // 鎻愪氦浜嬪姟
+
+ // isSuccess = true;
+ // //_logger.LogInformation("DeleteAndMoveIntoHty锛氬疄浣� {EntityType} 宸叉垚鍔熺Щ鍏ュ巻鍙茶〃骞跺垹闄ゅ師鏁版嵁", entityType.FullName);
+ // }
+ // catch (Exception ex)
+ // {
+
+ // // _logger.LogError(ex, "DeleteAndMoveIntoHty锛氫簨鍔℃墽琛屽け璐ワ紙鎻掑叆鍘嗗彶琛�/鍒犻櫎鍘熸暟鎹級", entityType.FullName);
+ // return false;
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // // _logger.LogError(ex, "DeleteAndMoveIntoHty锛氬鐞嗗疄浣� {EntityTypeName} 鏃跺彂鐢熸湭鎹曡幏寮傚父", entityTypeName);
+ // return false;
+ // }
+
+ // return isSuccess;
+ //}
+
+
public bool DeleteAndMoveIntoHty(List<TEntity> entities, OperateTypeEnum operateType)
+{
+ Type type = typeof(TEntity);
+ Assembly assembly = type.Assembly;
+ Type? htyType = assembly.GetType(type.FullName + "_Hty");
+ if (htyType != null)
+ {
+ object? obj2 = Activator.CreateInstance(htyType);
+ PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
+ PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType));
+ PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId));
+ if (obj2 != null && keyPro != null && operateTypePro != null && sourceIdPro != null)
{
- Type type = typeof(TEntity);
- Assembly assembly = type.Assembly;
- Type? htyType = assembly.GetType(type.FullName + "_Hty");
- if (htyType != null)
+ List<PropertyInfo> propertyInfos = htyType.GetProperties().Where(x => x.Name != operateTypePro.Name && x.Name != sourceIdPro.Name && x.Name != keyPro.Name).ToList();
+ List<object> list = new List<object>();
+ foreach (var item in entities)
{
- object? obj2 = Activator.CreateInstance(htyType);
- PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
- PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType));
- PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId));
- if (obj2 != null && keyPro != null && operateTypePro != null && sourceIdPro != null)
+ object? obj = Activator.CreateInstance(htyType);
+ if (obj != null)
{
- List<PropertyInfo> propertyInfos = htyType.GetProperties().Where(x => x.Name != operateTypePro.Name && x.Name != sourceIdPro.Name && x.Name != keyPro.Name).ToList();
- List<object> list = new List<object>();
- foreach (var item in entities)
+ operateTypePro.SetValue(obj, operateType.ToString());
+ sourceIdPro.SetValue(obj, keyPro.GetValue(item));
+ for (int i = 0; i < propertyInfos.Count; i++)
{
- object? obj = Activator.CreateInstance(htyType);
- if (obj != null)
- {
- operateTypePro.SetValue(obj, operateType.ToString());
- sourceIdPro.SetValue(obj, keyPro.GetValue(item));
- for (int i = 0; i < propertyInfos.Count; i++)
- {
- PropertyInfo propertyInfo = propertyInfos[i];
- PropertyInfo? property = type.GetProperty(propertyInfo.Name);
+ PropertyInfo propertyInfo = propertyInfos[i];
+ PropertyInfo? property = type.GetProperty(propertyInfo.Name);
- if (property != null)
- {
- if (propertyInfo.Name == nameof(BaseEntity.Modifier))
- {
- propertyInfo.SetValue(obj, App.User.UserId > 0 ? App.User.UserName : "System");
- }
- else if (propertyInfo.Name == nameof(BaseEntity.ModifyDate))
- {
- propertyInfo.SetValue(obj, DateTime.Now);
- }
- else
- {
- propertyInfo.SetValue(obj, property.GetValue(item));
- }
- }
+ if (property != null)
+ {
+ if (propertyInfo.Name == nameof(BaseEntity.Modifier))
+ {
+ propertyInfo.SetValue(obj, App.User.UserId > 0 ? App.User.UserName : "System");
}
- list.Add(obj);
+ else if (propertyInfo.Name == nameof(BaseEntity.ModifyDate))
+ {
+ propertyInfo.SetValue(obj, DateTime.Now);
+ }
+ else
+ {
+ propertyInfo.SetValue(obj, property.GetValue(item));
+ }
}
}
- if (list.Count > 0)
- _db.InsertableByObject(list).AS(type.Name + "_Hty").ExecuteCommand();
-
+ list.Add(obj);
}
}
- return DeleteData(entities);
+ if (list.Count > 0)
+ _db.InsertableByObject(list).AS(type.Name + "_Hty").ExecuteCommand();
+
}
+ }
+ return DeleteData(entities);
+}
//List<TResult> QueryMuch<T, T2, T3, TResult>(
// Expression<Func<T, T2, T3, object[]>> joinExpression,
// Expression<Func<T, T2, T3, TResult>> selectExpression,
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs"
index 7f01bf2..9c630cb 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs"
@@ -23,6 +23,7 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.CommonEnum;
+using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
@@ -44,6 +45,8 @@
Task<WebResponseContent> TaskCompleted(string taskNum);
+ Task TaskStatusChange(string taskNum, TaskStatusEnum taskStatusEnum);
+
Task<WebResponseContent> GenerateOutboundTasksAsync(int[] keys, string outStation);
Task<WebResponseContent> GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews,string station=null);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITask_HtyService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITask_HtyService.cs"
index 8bd7243..0cbb6a1 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITask_HtyService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITask_HtyService.cs"
@@ -15,4 +15,5 @@
public interface ITask_HtyService : IService<Dt_Task_Hty>
{
+ bool DeleteAndMoveIntoHty(Dt_Task task, OperateTypeEnum operateType);
}
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_PickingRecord.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_PickingRecord.cs"
index d642e34..02f07e6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_PickingRecord.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_PickingRecord.cs"
@@ -8,11 +8,11 @@
namespace WIDESEA_Model.Models
{
-
+
/// <summary>
/// 鎷i�夎褰曡〃
/// </summary>
-
+
[SugarTable(nameof(Dt_PickingRecord), "鎷i�夎褰曡〃")]
public class Dt_PickingRecord : BaseEntity
@@ -20,7 +20,7 @@
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
- public int TaskNo { get; set; }
+ public int TaskNo { get; set; }
public string OrderNo { get; set; }
public int OrderDetailId { get; set; }
@@ -93,6 +93,8 @@
public decimal BarcodeMoveQty { get; set; }
public int ReturnToMESStatus { get; set; }
+
+ public string FeedBackMesDocumentNo { get; set; }
}
@@ -114,7 +116,7 @@
/// 鍥炲簱鏁伴噺
/// </summary>
public decimal ReturnQty { get; set; }
-
+
public DateTime ReturnTime { get; set; }
/// <summary>
/// 0-寰呭洖搴� 1-宸插洖搴�
@@ -126,7 +128,7 @@
/// 鎷嗗寘璁板綍琛�
/// </summary>
[SugarTable("Dt_SplitPackageRecord")]
- public class Dt_SplitPackageRecord: BaseEntity
+ public class Dt_SplitPackageRecord : BaseEntity
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
@@ -140,8 +142,8 @@
public int OutStockLockInfoId { get; set; } // 鍏宠仈鐨勫嚭搴撻攣瀹氫俊鎭�
public string OriginalBarcode { get; set; } // 鍘熸潯鐮�
public string NewBarcode { get; set; } // 鏂版潯鐮�
-
- public string FactoryArea { get; set; }
+
+ public string FactoryArea { get; set; }
/// <summary>
/// 鎷嗗垎鏁伴噺锛堟柊鏉$爜鏁伴噺锛�
/// </summary>
@@ -162,7 +164,7 @@
[SugarColumn(IsNullable = true)]
public decimal? OriginalStockQuantity { get; set; }
- public decimal StockBeforeSplit { get; set; }
+ public decimal StockBeforeSplit { get; set; }
public decimal AssignBeforeSplit { get; set; }
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/InterfaceLog.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/InterfaceLog.cs"
new file mode 100644
index 0000000..015828a
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/InterfaceLog.cs"
@@ -0,0 +1,65 @@
+锘縰sing Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.DB.Models;
+
+namespace WIDESEA_Model.Models.Outbound
+{
+
+ /// <summary>
+ /// 鎺ュ彛鏃ュ織璁板綍琛�
+ /// </summary>
+ [SugarTable("Dt_InterfaceLog")]
+ public class Dt_InterfaceLog : BaseEntity
+ {
+ /// <summary>
+ /// 涓婚敭ID锛堣嚜澧烇級
+ /// </summary>
+ [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
+ public long Id { get; set; }
+
+ /// <summary>
+ /// 璁㈠崟鍙�
+ /// </summary>
+ [SugarColumn(ColumnName = "OrderNo", Length = 100, IsNullable = false)]
+ [Required(ErrorMessage = "璁㈠崟鍙蜂笉鑳戒负绌�")]
+ public string OrderNo { get; set; }
+
+ /// <summary>
+ /// 鏂囨。鍙�
+ /// </summary>
+ [SugarColumn(ColumnName = "DocumentNo", Length = 100, IsNullable = true)]
+ public string? DocumentNo { get; set; }
+
+ /// <summary>
+ /// 璁㈠崟绫诲瀷
+ /// </summary>
+ [SugarColumn(ColumnName = "OrderType", Length = 50, IsNullable = true)]
+ [Required(ErrorMessage = "璁㈠崟绫诲瀷涓嶈兘涓虹┖")]
+ public string OrderType { get; set; }
+
+ /// <summary>
+ /// JSON鍐呭
+ /// </summary>
+ [SugarColumn(ColumnName = "Content", IsNullable = true, ColumnDataType = "nvarchar(max)")]
+ [Required(ErrorMessage = "鍐呭涓嶈兘涓虹┖")]
+ public string Content { get; set; }
+
+
+
+ public int ReturnToMESStatus { get; set; }
+ /// <summary>
+ /// 杞垹闄ゆ爣蹇�
+ /// </summary>
+ [SugarColumn(ColumnName = "IsDeleted", IsNullable = false)]
+ public bool IsDeleted { get; set; } = false;
+
+
+ }
+
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/NoStockOutModel.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/NoStockOutModel.cs"
index 6ebc3ff..ec524fe 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/NoStockOutModel.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/NoStockOutModel.cs"
@@ -1,5 +1,8 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json;
+using SqlSugar;
+using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -43,4 +46,5 @@
public List<string> BarCodeSubmit { get; set; }
}
+
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundBatchPickingService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundBatchPickingService.cs"
index de06d72..e988272 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundBatchPickingService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundBatchPickingService.cs"
@@ -21,6 +21,7 @@
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
using WIDESEA_IStockService;
+using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Outbound;
@@ -49,6 +50,7 @@
private readonly IDailySequenceService _dailySequenceService;
private readonly IAllocateService _allocateService;
private readonly IRepository<Dt_OutboundBatch> _outboundBatchRepository;
+ private readonly ITask_HtyService _task_HtyService;
private readonly ILogger<OutboundPickingService> _logger;
private Dictionary<string, string> stations = new Dictionary<string, string>
@@ -68,7 +70,7 @@
public OutboundBatchPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService,
IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService,
IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService,
- IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository) : base(BaseDal)
+ IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, ITask_HtyService task_HtyService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -86,6 +88,7 @@
_dailySequenceService = dailySequenceService;
_allocateService = allocateService;
_outboundBatchRepository = outboundBatchRepository;
+ _task_HtyService = task_HtyService;
}
// <summary>
@@ -1798,7 +1801,7 @@
// 鏇存柊閿佸畾璁板綍鐘舵�佷负宸插洖搴�
lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
- lockInfo.Operator = App.User.UserName;
+ lockInfo.Operator = App.User.UserName;
await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
@@ -1854,7 +1857,7 @@
// 鏇存柊閿佸畾璁板綍鐘舵�佷负宸插洖搴�
lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
- lockInfo.Operator = App.User.UserName;
+ lockInfo.Operator = App.User.UserName;
await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
@@ -1945,9 +1948,17 @@
PalletType = stockInfo.PalletType,
WarehouseId = currentTask.WarehouseId
};
+ try
+ {
+ await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
- await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
-
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"鍒涘缓鍥炲簱浠诲姟澶辫触 - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+ throw new Exception($"鍒涘缓鍥炲簱浠诲姟澶辫触 - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+
+ }
// 鍙戦�丒SS鍛戒护
await SendESSCommands(palletCode, currentTask.TargetAddress, returnTask);
@@ -2223,7 +2234,7 @@
// 鍒嗛厤鏁伴噺鍦ㄨ鍗曟槑缁嗗眰闈㈢粺涓�澶勭悊
var originalStatus = lockInfo.Status;
lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
- lockInfo.Operator = App.User.UserName;
+ lockInfo.Operator = App.User.UserName;
await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
@@ -2550,7 +2561,7 @@
/// <summary>
/// 澶勭悊鏈垎鎷g殑閿佸畾璁板綍鍥炲簱
/// </summary>
-
+
/// <summary>
/// 澶勭悊鎵樼洏涓婄殑搴撳瓨璐х墿鍥炲簱
@@ -3478,11 +3489,16 @@
};
// 淇濆瓨鍥炲簱浠诲姟
- await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
+ var insertcount = await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
+ if (insertcount <= 0)
+ {
+ throw new Exception("鍒涘缓浠诲姟澶辫触锛�");
+ }
var targetAddress = originalTask.TargetAddress;
// 鍒犻櫎鍘熷鍑哄簱浠诲姟
- _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
+ //_taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
+ _task_HtyService.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.浜哄伐鍒犻櫎);
await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs"
index a47f0c3..bf49e91 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs"
@@ -1,4 +1,5 @@
-锘縰sing Microsoft.Extensions.Logging;
+锘縰sing Autofac.Core;
+using Microsoft.Extensions.Logging;
using SqlSugar;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
@@ -123,6 +124,10 @@
// 鏇存柊鍑哄簱鍗曟槑缁嗙姸鎬�
UpdateOrderDetailStatus(item.Details, allocatedQuantity, needQuantity);
+
+
+ // 鏇存柊搴撳瓨鍜屾墭鐩樼姸鎬�
+ UpdateNormalStocksAndPalletsStatus(autoAssignStocks, stockAllocations);
}
if (outStocks.Any())
@@ -133,7 +138,27 @@
return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
}
+ /// <summary>
+ /// 鏇存柊搴撳瓨鍜屾墭鐩樼姸鎬�
+ /// </summary>
+ private void UpdateNormalStocksAndPalletsStatus(List<Dt_StockInfo> stocks, Dictionary<int, decimal> stockAllocations)
+ {
+ foreach (var stock in stocks)
+ {
+ var stockDetail = stock.Details.First();
+ if (stockAllocations.TryGetValue(stockDetail.Id, out decimal allocatedQty) && allocatedQty > 0)
+ {
+ _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>()
+ .SetColumns(x => new Dt_StockInfo
+ {
+ StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾,
+ })
+ .Where(x => x.Id == stock.Id)
+ .ExecuteCommand();
+ }
+ }
+ }
/// <summary>
/// 妫�鏌ヨ鍗曟槸鍚﹀厑璁搁噸鏂板垎閰�
/// </summary>
@@ -331,6 +356,9 @@
// 鏇存柊鍑哄簱鍗曟槑缁嗙姸鎬�
UpdateOrderDetailStatus(item.Details, allocatedQuantity, needQuantity);
+
+ // 鏇存柊搴撳瓨鍜屾墭鐩樼姸鎬佷负鍑哄簱閿佸畾
+ await UpdateStocksAndPalletsStatus(autoAssignStocks, stockAllocations);
}
if (outStocks.Any())
@@ -343,7 +371,27 @@
return (outStocks, groupDetails.SelectMany(x => x.Details).ToList(), outStockLockInfos, locationInfos);
}
-
+ /// <summary>
+ /// 鏇存柊搴撳瓨鍜屾墭鐩樼姸鎬�
+ /// </summary>
+ private async Task UpdateStocksAndPalletsStatus(List<Dt_StockInfo> stocks, Dictionary<int, decimal> stockAllocations)
+ {
+ foreach (var stock in stocks)
+ {
+ var stockDetail = stock.Details.First();
+ if (stockAllocations.TryGetValue(stockDetail.Id, out decimal allocatedQty) && allocatedQty > 0)
+ {
+
+ await _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>()
+ .SetColumns(x => new Dt_StockInfo
+ {
+ StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾,
+ })
+ .Where(x => x.Id == stock.Id)
+ .ExecuteCommandAsync();
+ }
+ }
+ }
/// <summary>
/// 鎸夊厛杩涘厛鍑哄師鍒欏垎閰嶉攣瀹氭暟閲�
/// </summary>
@@ -588,24 +636,25 @@
if (userSelection == null) continue;
// 璁$畻璇ユ墭鐩樺疄闄呭彲鐢ㄦ暟閲�
- var availableQuantity = CalculateAvailableQuantity(stock, outboundOrderDetail.MaterielCode,
- outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode);
+ var availableQuantity = CalculateAvailableQuantityByBarcode(stock, outboundOrderDetail.MaterielCode,
+ outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode, userSelection.Barcode);
// 纭畾鍒嗛厤鏁伴噺锛氬彇鐢ㄦ埛閫夋嫨鏁伴噺銆佸彲鐢ㄦ暟閲忓拰鍓╀綑闇�姹傜殑鏈�灏忓��
- var assignQuantity = Math.Min(Math.Min(userSelection.UseableQuantity, availableQuantity),remainingNeedQuantity);
+ var assignQuantity = Math.Min(Math.Min(userSelection.UseableQuantity, availableQuantity), remainingNeedQuantity);
if (assignQuantity <= 0) continue;
- // 鎵ц鍒嗛厤
- var actualAssigned = AssignStockQuantity(stock, outboundOrderDetail, assignQuantity);
+ // 鎵ц鍒嗛厤锛屼娇鐢ㄧ敤鎴烽�夋嫨鐨勬潯鐮�
+ var actualAssigned = AssignStockQuantity(stock, outboundOrderDetail, assignQuantity, userSelection.Barcode);
+
if (actualAssigned > 0)
{
outStocks.Add(stock);
totalAssignedFromUserSelection += actualAssigned;
remainingNeedQuantity -= actualAssigned;
- // 鍒涘缓閿佸畾璁板綍
- var lockInfo = CreateOutStockLockInfo(outboundOrder, outboundOrderDetail, stock, actualAssigned);
+ // 鍒涘缓閿佸畾璁板綍锛屼娇鐢ㄧ敤鎴烽�夋嫨鐨勬潯鐮�
+ var lockInfo = CreateOutStockLockInfo(outboundOrder, outboundOrderDetail, stock, actualAssigned, userSelection.Barcode);
outStockLockInfos.Add(lockInfo);
}
}
@@ -664,7 +713,7 @@
}
// 鏇存柊閿佸畾鏁伴噺
- outboundOrderDetail.LockQuantity += totalAssignedFromUserSelection + totalAssignedFromUserSelection;
+ outboundOrderDetail.LockQuantity += totalAssignedFromUserSelection;
// 鏇存柊鐘舵��
UpdateOrderDetailStatus(outboundOrderDetail, remainingNeedQuantity);
@@ -673,7 +722,25 @@
return (outStocks, outboundOrderDetail, outStockLockInfos, locationInfos);
}
+ private decimal CalculateAvailableQuantityByBarcode(Dt_StockInfo stock, string materielCode, string batchNo, string supplyCode, string barcode)
+ {
+ var query = stock.Details.AsQueryable()
+ .Where(d => d.MaterielCode == materielCode &&
+ (d.StockQuantity - d.OutboundQuantity) > 0 &&
+ d.Barcode == barcode);
+ if (!string.IsNullOrEmpty(batchNo))
+ {
+ query = query.Where(x => x.BatchNo == batchNo);
+ }
+
+ if (!string.IsNullOrEmpty(supplyCode))
+ {
+ query = query.Where(d => d.SupplyCode == supplyCode);
+ }
+
+ return query.Sum(d => d.StockQuantity - d.OutboundQuantity);
+ }
// 杈呭姪鏂规硶
private decimal CalculateAvailableQuantity(Dt_StockInfo stock, string materielCode, string batchNo, string supplyCode)
{
@@ -686,9 +753,45 @@
return relevantDetails.Sum(d => d.StockQuantity - d.OutboundQuantity);
}
- private decimal AssignStockQuantity(Dt_StockInfo stock, Dt_OutboundOrderDetail detail, decimal assignQuantity)
+ private decimal AssignStockQuantity(Dt_StockInfo stock, Dt_OutboundOrderDetail detail, decimal assignQuantity, string barcode)
{
decimal remainingAssign = assignQuantity;
+
+ // 鎸夊厛杩涘厛鍑哄垎閰嶆寚瀹氭潯鐮佺殑搴撳瓨鏄庣粏
+ var query = stock.Details.AsQueryable()
+ .Where(d => d.MaterielCode == detail.MaterielCode &&
+ (d.StockQuantity - d.OutboundQuantity) > 0 &&
+ d.Barcode == barcode); // 鍙垎閰嶆寚瀹氭潯鐮�
+
+ if (!string.IsNullOrEmpty(detail.BatchNo))
+ {
+ query = query.Where(x => x.BatchNo == detail.BatchNo);
+ }
+ // 濡傛灉鍑哄簱鍗曟湁渚涘簲鍟嗚姹傦紝鎸変緵搴斿晢杩囨护
+ if (!string.IsNullOrEmpty(detail.SupplyCode))
+ {
+ query = query.Where(d => d.SupplyCode == detail.SupplyCode);
+ }
+ var sortedDetails = query.ToList().OrderBy(d => d.CreateDate);
+
+ foreach (var stockDetail in sortedDetails)
+ {
+ if (remainingAssign <= 0) break;
+
+ var available = stockDetail.StockQuantity - stockDetail.OutboundQuantity;
+ var assign = Math.Min(available, remainingAssign);
+
+ stockDetail.OutboundQuantity += assign;
+ remainingAssign -= assign;
+ }
+
+ return assignQuantity - remainingAssign; // 杩斿洖瀹為檯鍒嗛厤鏁伴噺
+ }
+
+ private (decimal assignedQuantity, string barcode) AssignStockQuantity(Dt_StockInfo stock, Dt_OutboundOrderDetail detail, decimal assignQuantity)
+ {
+ decimal remainingAssign = assignQuantity;
+ string assignedBarcode = string.Empty;
// 鎸夊厛杩涘厛鍑哄垎閰嶅簱瀛樻槑缁�
var query = stock.Details.AsQueryable()
@@ -717,18 +820,20 @@
stockDetail.OutboundQuantity += assign;
remainingAssign -= assign;
+ if (string.IsNullOrEmpty(assignedBarcode) && assign > 0)
+ {
+ assignedBarcode = stockDetail.Barcode;
+ }
}
- return assignQuantity - remainingAssign; // 杩斿洖瀹為檯鍒嗛厤鏁伴噺
+
+ return (assignQuantity - remainingAssign, assignedBarcode);
}
private Dt_OutStockLockInfo CreateOutStockLockInfo(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail detail,
- Dt_StockInfo stock, decimal quantity)
+ Dt_StockInfo stock, decimal quantity,string barcode="")
{
- var barcode = stock.Details
- .Where(d => !string.IsNullOrEmpty(d.Barcode))
- .Select(d => d.Barcode)
- .FirstOrDefault();
+
return _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, detail, stock, quantity, barcode);
}
@@ -792,8 +897,8 @@
return (false, $"鎵樼洏[{selection.PalletCode}]涓嶅瓨鍦�");
}
- var available = CalculateAvailableQuantity(stock, outboundOrderDetail.MaterielCode,
- outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode);
+ var available = CalculateAvailableQuantityByBarcode(stock, outboundOrderDetail.MaterielCode,
+ outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode,selection.Barcode);
if (available <= 0)
{
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
index 3d01ccb..f8db1b6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
@@ -334,6 +334,7 @@
}
var data = BaseDal.Db.Queryable<Dt_OutboundOrder>()
.WhereIF(!wheres.IsNullOrEmpty(), wheres)
+ .Where(x => x.OrderType == 0 || x.OrderType == 116)
.OrderBy(orderByModels)
.ToPageList(options.Page, options.Rows, ref totalCount);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs"
index e8415a6..5345170 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs"
@@ -32,6 +32,7 @@
using WIDESEA_IInboundService;
using WIDESEA_IOutboundService;
using WIDESEA_IStockService;
+using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Check;
@@ -63,6 +64,7 @@
private readonly IInboundOrderDetailService _inboundOrderDetailService;
private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
private readonly IReCheckOrderService _reCheckOrderService;
+ private readonly ITask_HtyService _task_HtyService;
private readonly ILogger<OutboundPickingService> _logger;
private Dictionary<string, string> stations = new Dictionary<string, string>
@@ -82,7 +84,7 @@
public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService,
IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService,
IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService,
- IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService) : base(BaseDal)
+ IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService, ITask_HtyService task_HtyService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -103,6 +105,7 @@
_inboundOrderDetailService = inboundOrderDetailService;
_warehouseAreaRepository = warehouseAreaRepository;
_reCheckOrderService = reCheckOrderService;
+ _task_HtyService = task_HtyService;
}
@@ -1124,7 +1127,7 @@
{
// 鑾峰彇鏈�鏂扮殑璁㈠崟鏄庣粏鏁版嵁锛堝甫閿侊級
var currentOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
- .With(SqlWith.RowLock)
+ //.With(SqlWith.RowLock)
.FirstAsync(x => x.Id == orderDetailId);
decimal newOverOutQuantity = currentOrderDetail.OverOutQuantity - cancelQty;
@@ -1684,14 +1687,29 @@
WarehouseId = originalTask.WarehouseId
};
- // 淇濆瓨鍥炲簱浠诲姟
- await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
+ try
+ {
+ // 淇濆瓨鍥炲簱浠诲姟
+ var insertcount = await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
+ if (insertcount <= 0)
+ {
+ throw new Exception("鍒涘缓浠诲姟澶辫触锛�");
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"CreateReturnTaskAndHandleESS 鍒涘缓浠诲姟澶辫触: {orderNo} 锛� {palletCode}");
+ throw new Exception("鍒涘缓浠诲姟澶辫触锛�");
+ }
var targetAddress = originalTask.TargetAddress;
// 鍒犻櫎鍘熷鍑哄簱浠诲姟
- _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
- await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
-
+ // _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
+ var result = _task_HtyService.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.浜哄伐鍒犻櫎);
+ if (!result)
+ {
+ await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
+ }
// 缁� ESS 鍙戦�佹祦鍔ㄤ俊鍙峰拰鍒涘缓浠诲姟
@@ -2093,8 +2111,7 @@
{
// 1. 鍒犻櫎搴撳瓨鏁伴噺涓�0鐨勬槑缁嗚褰�
var deleteDetailCount = await _stockInfoDetailService.Db.Deleteable<Dt_StockInfoDetail>()
- .Where(x => x.StockId == stockId && x.StockQuantity == 0 && (x.Status == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() || x.Status ==
- StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()))
+ .Where(x => x.StockId == stockId && x.StockQuantity == 0)
.ExecuteCommandAsync();
await _stockInfoService.Db.Deleteable<Dt_StockInfo>()
@@ -2753,15 +2770,15 @@
TaskNum = 0,
Status = (int)OutLockStockStatusEnum.鎷i�夊畬鎴�,
Unit = outboundOrderDetail.Unit,
- SupplyCode = outboundOrderDetail.SupplyCode?? "鏃�",
+ SupplyCode = outboundOrderDetail.SupplyCode ?? "鏃�",
OrderType = outboundOrder.OrderType,
CurrentBarcode = inboundOrderDetail.Barcode,
IsSplitted = 1,
Operator = App.User.UserName,
- lineNo= outboundOrderDetail.lineNo,
+ lineNo = outboundOrderDetail.lineNo,
WarehouseCode = outboundOrderDetail.WarehouseCode ?? "鏃�",
- BarcodeQty=outboundOrderDetail.NoStockOutQty,
- BarcodeUnit =outboundOrderDetail.BarcodeUnit,
+ BarcodeQty = outboundOrderDetail.NoStockOutQty,
+ BarcodeUnit = outboundOrderDetail.BarcodeUnit,
BatchNo = outboundOrderDetail.BatchNo
};
_outStockLockInfoService.AddData(newLockInfo);
@@ -2843,18 +2860,18 @@
var documentNo = UniqueValueGenerator.Generate();
var outfeedmodel = new FeedbackOutboundRequestModel
- {
- reqCode = Guid.NewGuid().ToString(),
- reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- business_type = outboundOrder.BusinessType,
- factoryArea = outboundOrder.FactoryArea,
- operationType = 1,
- Operator = App.User.UserName,
- orderNo = outboundOrder.UpperOrderNo,
- documentsNO = documentNo,
- status = outboundOrder.OrderStatus,
- details = new List<FeedbackOutboundDetailsModel>()
- };
+ {
+ reqCode = Guid.NewGuid().ToString(),
+ reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ business_type = outboundOrder.BusinessType,
+ factoryArea = outboundOrder.FactoryArea,
+ operationType = 1,
+ Operator = App.User.UserName,
+ orderNo = outboundOrder.UpperOrderNo,
+ documentsNO = documentNo,
+ status = outboundOrder.OrderStatus,
+ details = new List<FeedbackOutboundDetailsModel>()
+ };
foreach (var detail in outboundOrder.Details)
{
// 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
@@ -2864,34 +2881,34 @@
(x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴� || x.Status == (int)OutLockStockStatusEnum.宸插洖搴�))
.ToListAsync();
- var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
- .Select(group => new FeedbackOutboundDetailsModel
- {
+ var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new FeedbackOutboundDetailsModel
+ {
- materialCode = group.Key.MaterielCode,
- lineNo = group.Key.lineNo,
- warehouseCode = group.Key.WarehouseCode,
- qty = group.Sum(x => x.PickedQty),
- currentDeliveryQty = group.Sum(x => x.PickedQty),
- unit = group.Key.BarcodeUnit,
- barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
- {
- barcode = lockInfo.CurrentBarcode,
- supplyCode = lockInfo.SupplyCode,
- batchNo = lockInfo.BatchNo,
- unit = lockInfo.BarcodeUnit,
- qty = lockInfo.PickedQty
- }).ToList()
- }).ToList();
- outfeedmodel.details.AddRange(groupdata);
- }
- var result = await _invokeMESService.FeedbackOutbound(outfeedmodel);
- if (result != null && result.code == 200)
- {
- await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
- .SetColumns(x => x.ReturnToMESStatus == 1)
- .Where(x => x.OrderId == outboundOrder.Id)
- .ExecuteCommandAsync();
+ materialCode = group.Key.MaterielCode,
+ lineNo = group.Key.lineNo,
+ warehouseCode = group.Key.WarehouseCode,
+ qty = group.Sum(x => x.PickedQty),
+ currentDeliveryQty = group.Sum(x => x.PickedQty),
+ unit = group.Key.BarcodeUnit,
+ barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = lockInfo.CurrentBarcode,
+ supplyCode = lockInfo.SupplyCode,
+ batchNo = lockInfo.BatchNo,
+ unit = lockInfo.BarcodeUnit,
+ qty = lockInfo.PickedQty
+ }).ToList()
+ }).ToList();
+ outfeedmodel.details.AddRange(groupdata);
+ }
+ var result = await _invokeMESService.FeedbackOutbound(outfeedmodel);
+ if (result != null && result.code == 200)
+ {
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.OrderId == outboundOrder.Id)
+ .ExecuteCommandAsync();
await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
.SetColumns(x => x.ReturnToMESStatus == 1)
@@ -2978,6 +2995,8 @@
{
return content.Error("鍙湁鎷垮埌閲嶆缁撴灉鎵嶈兘鍏ュ簱锛�");
}
+
+
}
// Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo);
@@ -3003,7 +3022,8 @@
stockInfo.Details = new List<Dt_StockInfoDetail>();
}
var inboindId = 0; Dt_InboundOrder dt_InboundOrder = null;
- var dbinbound = _inboundOrderRepository.QueryData(x => x.InboundOrderNo == dbinboundOrderDetails.First().OrderNo).First();
+ var orderno = dbinboundOrderDetails.First().OrderNo;
+ var dbinbound = _inboundOrderRepository.QueryData(x => x.InboundOrderNo == orderno).FirstOrDefault();
if (dbinbound == null)
{
dt_InboundOrder = new Dt_InboundOrder
@@ -3046,7 +3066,7 @@
FactoryArea = item.FactoryArea,
Status = 0,
OrderNo = item.OrderNo,
- BusinessType = InOrderTypeEnum.InternalAllocat.ObjToInt().ToString()
+ BusinessType = materielGroupDTO.orderTypes.ToString()
});
item.WarehouseCode = item.WarehouseCode;
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/WIDESEA_OutboundService.csproj" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/WIDESEA_OutboundService.csproj"
index 17401e0..99ef843 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/WIDESEA_OutboundService.csproj"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/WIDESEA_OutboundService.csproj"
@@ -15,6 +15,7 @@
<ProjectReference Include="..\WIDESEA_IOutboundService\WIDESEA_IOutboundService.csproj" />
<ProjectReference Include="..\WIDESEA_IRecordService\WIDESEA_IRecordService.csproj" />
<ProjectReference Include="..\WIDESEA_IStockService\WIDESEA_IStockService.csproj" />
+ <ProjectReference Include="..\WIDESEA_ITaskInfoService\WIDESEA_ITaskInfoService.csproj" />
</ItemGroup>
</Project>
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 956fcca..c72a941 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -84,6 +84,7 @@
private readonly IRecordService _recordService;
private readonly IAllocateService _allocateService;
private readonly IInvokeMESService _invokeMESService;
+ private readonly ITask_HtyService _task_HtyService;
public IRepository<Dt_Task> Repository => BaseDal;
private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new()
@@ -103,7 +104,7 @@
public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
- public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService) : base(BaseDal)
+ public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService) : base(BaseDal)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -126,8 +127,21 @@
_allocateOrderDetailRepository = allocateOrderDetailRepository;
_allocateOrderRepository = allocateOrderRepository;
_materialUnitService = materialUnitService;
+ _task_HtyService = task_HtyService;
}
+ public async Task TaskStatusChange(string taskNum,TaskStatusEnum taskStatusEnum)
+ {
+ if (int.TryParse(taskNum, out var newTaskNum))
+ {
+ await Db.Updateable<Dt_Task>().SetColumns(it => new Dt_Task {
+ TaskStatus = taskStatusEnum.ObjToInt()
+ })
+ .Where(it => it.TaskNum == newTaskNum)
+ .ExecuteCommandAsync();
+ }
+
+ }
/// <summary>
///
@@ -276,8 +290,12 @@
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
- BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-
+ // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+ if (!result)
+ {
+ await Db.Deleteable(task).ExecuteCommandAsync();
+ }
_locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
_recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
@@ -325,8 +343,8 @@
}).ToList();
allocatefeedmodel.Details = groupedData;
- var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
- if (result != null && result.code == 200)
+ var feedbackresult = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
+ if (feedbackresult != null && feedbackresult.code == 200)
{
_inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
.Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
@@ -381,8 +399,8 @@
}).ToList();
allocatefeedmodel.Details = groupedData;
- var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
- if (result != null && result.code == 200)
+ var feedbackresult = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
+ if (feedbackresult != null && feedbackresult.code == 200)
{
_inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
.Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
@@ -429,8 +447,8 @@
}).ToList();
feedmodel.details = groupedData;
- var result = await _invokeMESService.FeedbackInbound(feedmodel);
- if (result != null && result.code == 200)
+ var feedbackresult = await _invokeMESService.FeedbackInbound(feedmodel);
+ if (feedbackresult != null && feedbackresult.code == 200)
{
_inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
.Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
@@ -536,8 +554,12 @@
var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().First(x => x.OrderNo == task.OrderNo);
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
- BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-
+ // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+ if (!result)
+ {
+ await Db.Deleteable(task).ExecuteCommandAsync();
+ }
_locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
@@ -650,9 +672,13 @@
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
// 鍒犻櫎浠诲姟璁板綍
- BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
- BaseDal.DeleteData(task);
-
+ //BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ //BaseDal.DeleteData(task);
+ var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+ if (!result)
+ {
+ await Db.Deleteable(task).ExecuteCommandAsync();
+ }
// 璁板綍璐т綅鐘舵�佸彉鏇�
_locationStatusChangeRecordService.AddLocationStatusChangeRecord(
locationInfo,
@@ -1105,7 +1131,7 @@
//涓嶇敤鍥炰紶
}
else
- {
+ {
if (outboundOrder != null && outboundOrder.IsBatch == 0)
{
var feedmodel = new FeedbackOutboundRequestModel
@@ -1187,7 +1213,7 @@
}
else if (outboundOrder != null && outboundOrder.IsBatch == 1)
{
- await _invokeMESService.BatchOrderFeedbackToMes(new List<string>(){outboundOrder.OrderNo },2);
+ await _invokeMESService.BatchOrderFeedbackToMes(new List<string>() { outboundOrder.OrderNo }, 2);
}
}
@@ -1227,9 +1253,18 @@
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
- BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
- _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
- //_stockRepository.Db.Deleteable(stockInfo).ExecuteCommand();
+ // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+ if (!result)
+ {
+ await Db.Deleteable(task).ExecuteCommandAsync();
+ }
+
+ var stockresult = _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ if (!stockresult)
+ {
+ _stockRepository.Db.Deleteable(stockInfo).ExecuteCommand();
+ }
_stockService.StockInfoService.DeleteData(stockInfo);
_locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index db099ac..29100af 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -2,6 +2,7 @@
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -148,42 +149,73 @@
List<Dt_LocationInfo>? locationInfos = null;
CleanupPreviousInvalidLocks(outboundOrderDetails);
-
- (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
- if (result.Item1 != null && result.Item1.Count > 0)
+ // 寮�鍚簨鍔★紝浣跨敤鏁版嵁搴撹绾ч攣
+ using (var transaction = _outboundOrderDetailService.Db.Ado.UseTran())
{
- Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
- TaskTypeEnum typeEnum = outboundOrder.OrderType switch
+ try
{
- (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound,
- (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate,
- (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality,
- _ => TaskTypeEnum.Outbound
- };
- tasks = GetTasks(result.Item1, typeEnum, outStation);
- tasks.ForEach(x =>
- {
- x.OrderNo = outboundOrder.OrderNo;
- });
- result.Item2.ForEach(x =>
- {
- x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
- });
- result.Item3.ForEach(x =>
- {
- x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
- });
+ // 浣跨敤鎮茶閿侀攣瀹氳鍗曟槑缁�
+ var lockedOrderDetails = new List<Dt_OutboundOrderDetail>();
+ foreach (var key in keys)
+ {
+ var detail = _outboundOrderDetailService.Db.Ado.SqlQuerySingle<Dt_OutboundOrderDetail>(
+ "SELECT * FROM Dt_OutboundOrderDetail WITH (UPDLOCK) WHERE Id = @Id",
+ new { Id = key });
- stockInfos = result.Item1;
- orderDetails = result.Item2;
- outStockLockInfos = result.Item3;
- locationInfos = result.Item4;
+ if (detail != null)
+ {
+ lockedOrderDetails.Add(detail);
+ }
+ }
+
+ if (!lockedOrderDetails.Any())
+ {
+ throw new Exception("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+ }
+ (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
+ if (result.Item1 != null && result.Item1.Count > 0)
+ {
+ Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+ TaskTypeEnum typeEnum = outboundOrder.OrderType switch
+ {
+ (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound,
+ (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate,
+ (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality,
+ _ => TaskTypeEnum.Outbound
+ };
+ tasks = GetTasks(result.Item1, typeEnum, outStation);
+ tasks.ForEach(x =>
+ {
+ x.OrderNo = outboundOrder.OrderNo;
+ });
+ result.Item2.ForEach(x =>
+ {
+ x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+ });
+ result.Item3.ForEach(x =>
+ {
+ x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
+ });
+
+ stockInfos = result.Item1;
+ orderDetails = result.Item2;
+ outStockLockInfos = result.Item3;
+ locationInfos = result.Item4;
+ transaction.CommitTran();
+ }
+ else
+ {
+ transaction.RollbackTran();
+ throw new Exception("鏃犲簱瀛�");
+ }
+ }
+ catch (Exception)
+ {
+ transaction.RollbackTran();
+ throw;
+ }
+ return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos);
}
- else
- {
- throw new Exception("鏃犲簱瀛�");
- }
- return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos);
}
/// <summary>
/// 娓呯悊涔嬪墠鐨勬棤鏁堥攣瀹氳褰�
@@ -355,7 +387,6 @@
// TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
PalletType = stockInfo.PalletType,
WarehouseId = stockInfo.WarehouseId,
-
};
//if (taskType != TaskTypeEnum.OutEmpty)
//{
@@ -371,52 +402,67 @@
return tasks;
}
- public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType)
+
+
+ #region 鍐呭瓨閿佺鐞嗗櫒
+ private static readonly ConcurrentDictionary<string, SemaphoreSlim> _normalmaterialLocks =
+ new ConcurrentDictionary<string, SemaphoreSlim>();
+ private static readonly ConcurrentDictionary<string, DateTime> _normallockLastUsed =
+ new ConcurrentDictionary<string, DateTime>();
+ private static readonly object _normalcleanupLock = new object();
+ private static DateTime _normallastCleanupTime = DateTime.MinValue;
+
+ /// <summary>
+ /// 鑾峰彇鐗╂枡绾у唴瀛橀攣
+ /// </summary>
+ private SemaphoreSlim GetNormalMaterialSemaphore(string materialCode, string batchNo, string supplyCode)
{
- List<Dt_Task> tasks = new List<Dt_Task>();
- List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.QueryData(x => stockInfos.Select(x => x.LocationCode).Contains(x.LocationCode));
- for (int i = 0; i < stockInfos.Count; i++)
+ // 鍒涘缓閿侀敭锛氱墿鏂�+鎵规+渚涘簲鍟�
+ string lockKey = $"MaterialLock_{materialCode}_{batchNo}_{supplyCode}";
+
+ // 娓呯悊闀挎椂闂翠笉鐢ㄧ殑閿侊紙姣忓皬鏃舵竻鐞嗕竴娆★級
+ var now = DateTime.Now;
+ if ((now - _normallastCleanupTime).TotalHours >= 1)
{
- Dt_StockInfo stockInfo = stockInfos[i];
-
- if (stockInfo != null)
+ lock (_normalcleanupLock)
{
- Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode);
- if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode))
+ if ((now - _normallastCleanupTime).TotalHours >= 1)
{
- Dt_Task task = new()
- {
- CurrentAddress = stockInfo.LocationCode,
- Grade = 0,
- PalletCode = stockInfo.PalletCode,
- NextAddress = "",
- Roadway = locationInfo.RoadwayNo,
- SourceAddress = stockInfo.LocationCode,
- TargetAddress = "",
- TaskStatus = TaskStatusEnum.New.ObjToInt(),
- TaskType = taskType.ObjToInt(),
- //TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
- PalletType = stockInfo.PalletType,
- WarehouseId = stockInfo.WarehouseId,
+ var keysToRemove = _normallockLastUsed
+ .Where(kvp => (now - kvp.Value).TotalHours > 2)
+ .Select(kvp => kvp.Key)
+ .ToList();
- };
- //if (taskType != TaskTypeEnum.OutEmpty)
- //{
- // task.MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
- // task.Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
- // task.BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
- //}
- //if (stockInfo.StockLength > 0)
- //{
- // task.TaskLength = stockInfo.StockLength;
- //}
- tasks.Add(task);
+ foreach (var key in keysToRemove)
+ {
+ if (_normalmaterialLocks.TryRemove(key, out var _semaphore))
+ {
+ _semaphore.Dispose();
+ }
+ _normallockLastUsed.TryRemove(key, out _);
+ }
+
+ _normallastCleanupTime = now;
}
}
}
- return tasks;
+
+ // 鑾峰彇鎴栧垱寤轰俊鍙烽噺
+ var semaphore = _normalmaterialLocks.GetOrAdd(lockKey, _ => new SemaphoreSlim(1, 1));
+ _normallockLastUsed[lockKey] = now;
+
+ return semaphore;
}
+ /// <summary>
+ /// 鏇存柊鍐呭瓨閿佹渶鍚庝娇鐢ㄦ椂闂�
+ /// </summary>
+ private void UpdateNormalMaterialLockUsedTime(string materialCode, string batchNo, string supplyCode)
+ {
+ string lockKey = $"MaterialLock_{materialCode}_{batchNo}_{supplyCode}";
+ _normallockLastUsed[lockKey] = DateTime.Now;
+ }
+ #endregion
/// <summary>
/// 鐢熸垚鍑哄簱浠诲姟
/// </summary>
@@ -432,31 +478,90 @@
List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
-
- (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys, outStation);
- if (result.Item2 != null && result.Item2.Count > 0)
+ // 鍏堣幏鍙栨墍鏈夎鍗曟槑缁嗭紝纭畾闇�瑕侀攣瀹氱殑鐗╂枡
+ var orderDetails = _outboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id));
+ if (orderDetails == null || orderDetails.Count == 0)
{
- stockInfos.AddRange(result.Item2);
- }
- if (result.Item3 != null && result.Item3.Count > 0)
- {
- outboundOrderDetails.AddRange(result.Item3);
- }
- if (result.Item4 != null && result.Item4.Count > 0)
- {
- outStockLockInfos.AddRange(result.Item4);
- }
- if (result.Item5 != null && result.Item5.Count > 0)
- {
- locationInfos.AddRange(result.Item5);
- }
- if (result.Item1 != null && result.Item1.Count > 0)
- {
- tasks.AddRange(result.Item1);
+ return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
}
- WebResponseContent content = await GenerateOutboundTaskDataUpdateAsync(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos);
- return content;
+ // 鑾峰彇鎵�鏈夐渶瑕侀攣瀹氱殑鐗╂枡鍒嗙粍
+ var materialGroups = orderDetails
+ .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode })
+ .Select(g => new
+ {
+ g.Key.MaterielCode,
+ g.Key.BatchNo,
+ g.Key.SupplyCode,
+ Count = g.Count()
+ })
+ .ToList();
+
+ // 鎸夐『搴忚幏鍙栨墍鏈夌墿鏂欑殑鍐呭瓨閿侊紙鎸夌墿鏂欎唬鐮佹帓搴忎互閬垮厤姝婚攣锛�
+ var semaphores = new List<SemaphoreSlim>();
+ var acquiredLocks = new List<(string MaterialCode, string BatchNo, string SupplyCode)>();
+
+ try
+ {
+ foreach (var group in materialGroups.OrderBy(g => g.MaterielCode).ThenBy(g => g.BatchNo))
+ {
+ var semaphore = GetMaterialSemaphore(group.MaterielCode, group.BatchNo, group.SupplyCode);
+
+ // 绛夊緟鑾峰彇閿侊紝鏈�澶氱瓑寰�30绉�
+ bool lockAcquired = await semaphore.WaitAsync(TimeSpan.FromSeconds(30));
+
+ if (!lockAcquired)
+ {
+ // 濡傛灉鑾峰彇閿佸け璐ワ紝閲婃斁宸茶幏鍙栫殑鎵�鏈夐攣
+ foreach (var acquiredSemaphore in semaphores)
+ {
+ acquiredSemaphore.Release();
+ }
+ return WebResponseContent.Instance.Error($"鐗╂枡[{group.MaterielCode}]鎵规[{group.BatchNo}]鍒嗛厤绻佸繖锛岃绋嶅悗閲嶈瘯");
+ }
+
+ semaphores.Add(semaphore);
+ acquiredLocks.Add((group.MaterielCode, group.BatchNo, group.SupplyCode));
+ }
+
+ (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys, outStation);
+ if (result.Item2 != null && result.Item2.Count > 0)
+ {
+ stockInfos.AddRange(result.Item2);
+ }
+ if (result.Item3 != null && result.Item3.Count > 0)
+ {
+ outboundOrderDetails.AddRange(result.Item3);
+ }
+ if (result.Item4 != null && result.Item4.Count > 0)
+ {
+ outStockLockInfos.AddRange(result.Item4);
+ }
+ if (result.Item5 != null && result.Item5.Count > 0)
+ {
+ locationInfos.AddRange(result.Item5);
+ }
+ if (result.Item1 != null && result.Item1.Count > 0)
+ {
+ tasks.AddRange(result.Item1);
+ }
+
+ WebResponseContent content = await GenerateOutboundTaskDataUpdateAsync(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos);
+ return content;
+ }
+ finally
+ {
+ // 閲婃斁鎵�鏈夊唴瀛橀攣骞舵洿鏂颁娇鐢ㄦ椂闂�
+ foreach (var semaphore in semaphores)
+ {
+ semaphore.Release();
+ }
+
+ foreach (var lockInfo in acquiredLocks)
+ {
+ UpdateMaterialLockUsedTime(lockInfo.MaterialCode, lockInfo.BatchNo, lockInfo.SupplyCode);
+ }
+ }
}
catch (Exception ex)
{
@@ -491,17 +596,17 @@
{
return WebResponseContent.Instance.Error("鎵句笉鍒板嚭搴撳崟鎹�");
}
-
- var orderdetail = outboundOrder.Details.Where(outItem => allocorder.Details .Any(allocItem => allocItem.MaterielCode == outItem.MaterielCode && allocItem.LineNo == outItem.lineNo
- && allocItem.BarcodeQty==outItem.BarcodeQty && allocItem.WarehouseCode==outItem.WarehouseCode && allocItem.BarcodeUnit==outItem.BarcodeUnit) ) .First();
+
+ var orderdetail = outboundOrder.Details.Where(outItem => allocorder.Details.Any(allocItem => allocItem.MaterielCode == outItem.MaterielCode && allocItem.LineNo == outItem.lineNo
+ && allocItem.BarcodeQty == outItem.BarcodeQty && allocItem.WarehouseCode == outItem.WarehouseCode && allocItem.BarcodeUnit == outItem.BarcodeUnit)).First();
if (orderdetail == null)
{
return WebResponseContent.Instance.Error("鎵句笉鍒板嚭搴撴槑缁嗗崟鎹�");
}
- (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(outboundOrder.Details.First().Id, stockSelectViews,station);
+ (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(outboundOrder.Details.First().Id, stockSelectViews, station);
- WebResponseContent content =await GenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5);
+ WebResponseContent content = await GenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5);
return content;
}
@@ -516,7 +621,7 @@
/// <param name="orderDetailId"></param>
/// <param name="stockSelectViews"></param>
/// <returns></returns>
- public async Task<WebResponseContent> GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews,string station=null)
+ public async Task<WebResponseContent> GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews, string station = null)
{
try
{
@@ -526,9 +631,9 @@
{
return WebResponseContent.Instance.Error("鎵句笉鍒板崟鎹�");
}
- (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(outboundOrder.Details.First().Id, stockSelectViews,station);
+ (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(outboundOrder.Details.First().Id, stockSelectViews, station);
- WebResponseContent content =await GenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5);
+ WebResponseContent content = await GenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5);
return content;
}
@@ -545,7 +650,7 @@
/// <param name="stockSelectViews"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
- public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int orderDetailId, List<StockSelectViewDTO> stockSelectViews,string station=null)
+ public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int orderDetailId, List<StockSelectViewDTO> stockSelectViews, string station = null)
{
List<Dt_Task> tasks = new List<Dt_Task>();
Dt_OutboundOrderDetail outboundOrderDetail = _outboundOrderDetailService.Repository.QueryFirst(x => x.Id == orderDetailId);
@@ -563,12 +668,13 @@
Dt_OutboundOrderDetail? orderDetail = null;
List<Dt_OutStockLockInfo>? outStockLockInfos = null;
List<Dt_LocationInfo>? locationInfos = null;
- if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
+ if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt() ||
+ outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Outbound.ObjToInt())
{
(List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundOrderDetailService.AssignStockOutbound(outboundOrderDetail, stockSelectViews);
if (result.Item1 != null && result.Item1.Count > 0)
{
- Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
+ Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
TaskTypeEnum typeEnum = outboundOrder.OrderType switch
{
(int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound,
@@ -576,7 +682,7 @@
(int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality,
_ => TaskTypeEnum.Outbound
};
- tasks = GetTasks(result.Item1, typeEnum,station);
+ tasks = GetTasks(result.Item1, typeEnum, station);
result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
result.Item3.ForEach(x =>
{
@@ -599,7 +705,7 @@
if (stockLockInfos != null && stockLockInfos.Count > 0)
{
List<Dt_StockInfo> stocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList());
- tasks = GetTasks(stocks, TaskTypeEnum.Outbound);
+ tasks = GetTasks(stocks, TaskTypeEnum.Outbound,station);
}
}
@@ -615,7 +721,7 @@
/// <param name="outStockLockInfos"></param>
/// <param name="locationInfos"></param>
/// <returns></returns>
- public async Task< WebResponseContent> GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null)
+ public async Task<WebResponseContent> GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null)
{
try
{
@@ -699,7 +805,7 @@
{
return WebResponseContent.Instance.Error("涓嬪彂鏈哄櫒浜轰换鍔″け璐ワ紒");
}
-
+
}
catch (Exception ex)
{
@@ -711,7 +817,65 @@
#region 鍒嗘壒鍒嗛厤搴撳瓨
+ #region 鍐呭瓨閿佺鐞嗗櫒
+ private static readonly ConcurrentDictionary<string, SemaphoreSlim> _materialLocks =
+ new ConcurrentDictionary<string, SemaphoreSlim>();
+ private static readonly ConcurrentDictionary<string, DateTime> _lockLastUsed =
+ new ConcurrentDictionary<string, DateTime>();
+ private static readonly object _cleanupLock = new object();
+ private static DateTime _lastCleanupTime = DateTime.MinValue;
+ /// <summary>
+ /// 鑾峰彇鐗╂枡绾у唴瀛橀攣
+ /// </summary>
+ private SemaphoreSlim GetMaterialSemaphore(string materialCode, string batchNo, string supplyCode)
+ {
+ // 鍒涘缓閿侀敭锛氱墿鏂�+鎵规+渚涘簲鍟�
+ string lockKey = $"MaterialLock_{materialCode}_{batchNo}_{supplyCode}";
+
+ // 娓呯悊闀挎椂闂翠笉鐢ㄧ殑閿侊紙姣忓皬鏃舵竻鐞嗕竴娆★級
+ var now = DateTime.Now;
+ if ((now - _lastCleanupTime).TotalHours >= 1)
+ {
+ lock (_cleanupLock)
+ {
+ if ((now - _lastCleanupTime).TotalHours >= 1)
+ {
+ var keysToRemove = _lockLastUsed
+ .Where(kvp => (now - kvp.Value).TotalHours > 2)
+ .Select(kvp => kvp.Key)
+ .ToList();
+
+ foreach (var key in keysToRemove)
+ {
+ if (_materialLocks.TryRemove(key, out var _semaphore))
+ {
+ _semaphore.Dispose();
+ }
+ _lockLastUsed.TryRemove(key, out _);
+ }
+
+ _lastCleanupTime = now;
+ }
+ }
+ }
+
+ // 鑾峰彇鎴栧垱寤轰俊鍙烽噺
+ var semaphore = _materialLocks.GetOrAdd(lockKey, _ => new SemaphoreSlim(1, 1));
+ _lockLastUsed[lockKey] = now;
+
+ return semaphore;
+ }
+
+ /// <summary>
+ /// 閲婃斁鍐呭瓨閿佸苟鏇存柊鏈�鍚庝娇鐢ㄦ椂闂�
+ /// </summary>
+ private void UpdateMaterialLockUsedTime(string materialCode, string batchNo, string supplyCode)
+ {
+ string lockKey = $"MaterialLock_{materialCode}_{batchNo}_{supplyCode}";
+ _lockLastUsed[lockKey] = DateTime.Now;
+ }
+ #endregion
/// <summary>
/// 鍒嗘壒鍒嗛厤搴撳瓨
/// </summary>
@@ -719,37 +883,62 @@
{
try
{
- List<Dt_Task> tasks = new List<Dt_Task>();
- List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
- List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
- List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
- List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
+ // 鍏堣幏鍙栬鍗曟槑缁嗕俊鎭紝纭畾鐗╂枡
+ var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+ .FirstAsync(x => x.Id == orderDetailId);
- (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = await BatchAllocateStockDataHandle(orderDetailId, batchQuantity, outStation);
+ if (orderDetail == null)
+ return WebResponseContent.Instance.Error("鏈壘鍒拌鍗曟槑缁嗕俊鎭�");
- if (result.Item2 != null && result.Item2.Count > 0)
- {
- stockInfos.AddRange(result.Item2);
- }
- if (result.Item3 != null && result.Item3.Count > 0)
- {
- outboundOrderDetails.AddRange(result.Item3);
- }
- if (result.Item4 != null && result.Item4.Count > 0)
- {
- outStockLockInfos.AddRange(result.Item4);
- }
- if (result.Item5 != null && result.Item5.Count > 0)
- {
- locationInfos.AddRange(result.Item5);
- }
- if (result.Item1 != null && result.Item1.Count > 0)
- {
- tasks.AddRange(result.Item1);
- }
+ // 鑾峰彇鐗╂枡绾у唴瀛橀攣
+ var semaphore = GetMaterialSemaphore(orderDetailId + orderDetail.MaterielCode, orderDetail.BatchNo, orderDetail.SupplyCode);
- WebResponseContent content = await GenerateOutboundTaskDataUpdateAsync(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos);
- return content;
+ // 绛夊緟鑾峰彇鍐呭瓨閿侊紝鏈�澶氱瓑寰�30绉�
+ bool memoryLockAcquired = await semaphore.WaitAsync(TimeSpan.FromSeconds(30));
+
+ if (!memoryLockAcquired)
+ return WebResponseContent.Instance.Error("绯荤粺绻佸繖锛岃绋嶅悗閲嶈瘯");
+
+ try
+ {
+ List<Dt_Task> tasks = new List<Dt_Task>();
+ List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
+ List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
+ List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
+ List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
+
+ (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = await BatchAllocateStockDataHandle(orderDetailId, batchQuantity, outStation);
+
+ if (result.Item2 != null && result.Item2.Count > 0)
+ {
+ stockInfos.AddRange(result.Item2);
+ }
+ if (result.Item3 != null && result.Item3.Count > 0)
+ {
+ outboundOrderDetails.AddRange(result.Item3);
+ }
+ if (result.Item4 != null && result.Item4.Count > 0)
+ {
+ outStockLockInfos.AddRange(result.Item4);
+ }
+ if (result.Item5 != null && result.Item5.Count > 0)
+ {
+ locationInfos.AddRange(result.Item5);
+ }
+ if (result.Item1 != null && result.Item1.Count > 0)
+ {
+ tasks.AddRange(result.Item1);
+ }
+
+ WebResponseContent content = await GenerateOutboundTaskDataUpdateAsync(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos);
+ return content;
+ }
+ finally
+ {
+ // 閲婃斁鍐呭瓨閿�
+ semaphore.Release();
+ UpdateMaterialLockUsedTime(orderDetail.MaterielCode, orderDetail.BatchNo, orderDetail.SupplyCode);
+ }
}
catch (Exception ex)
{
@@ -768,7 +957,7 @@
List<Dt_Task> tasks = new List<Dt_Task>();
// 鑾峰彇璁㈠崟鏄庣粏
- var outboundOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+ var outboundOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().With("UPDLOCK")
.FirstAsync(x => x.Id == orderDetailId);
if (outboundOrderDetail == null)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs"
index 73bd716..0a6bc41 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs"
@@ -1,5 +1,10 @@
-锘縰sing WIDESEA_Core.BaseRepository;
+锘縰sing AutoMapper;
+using Microsoft.Extensions.Logging;
+using System.Transactions;
+using WIDESEA_Core;
+using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
+using WIDESEA_Core.Enums;
using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
@@ -7,7 +12,58 @@
public class Task_HtyService : ServiceBase<Dt_Task_Hty, IRepository<Dt_Task_Hty>>, ITask_HtyService
{
- public Task_HtyService(IRepository<Dt_Task_Hty> BaseDal) : base(BaseDal)
+ private readonly ILogger<Task_HtyService> _logger;
+
+ private readonly IMapper _mapper; // AutoMapper瀹炰緥
+ public Task_HtyService(IRepository<Dt_Task_Hty> BaseDal, IMapper mapper, ILogger<Task_HtyService> logger) : base(BaseDal)
{
+ _mapper = mapper;
+ _logger = logger;
+ }
+ public bool DeleteAndMoveIntoHty(Dt_Task task, OperateTypeEnum operateType)
+ {
+ // using var transaction = Db.Ado.UseTran();
+ try
+ {
+ var historyEntity = _mapper.Map<Dt_Task_Hty>(task);
+
+ // 2. 濉厖鍘嗗彶瀹炰綋鏍稿績瀛楁
+ historyEntity.SourceId = task.TaskId;
+ historyEntity.OperateType = App.User?.UserName != null ? OperateTypeEnum.鑷姩瀹屾垚.ToString() : OperateTypeEnum.浜哄伐瀹屾垚.ToString();
+ historyEntity.Creater = App.User?.UserName != null ? App.User.UserName : "System";
+
+ // 瑕嗙洊淇敼浜�/淇敼鏃堕棿锛堜紭鍏堢骇楂樹簬鏄犲皠锛�
+ // historyEntity.Modifier = App.User?.UserId > 0 ? App.User?.UserName : "System";
+ // historyEntity.ModifyDate = DateTime.Now;
+
+ // 3. 鎻掑叆鍘嗗彶琛紙绫诲瀷瀹夊叏锛屾棤鍙嶅皠鎷兼帴琛ㄥ悕锛�
+
+ int insertCount = Db.Insertable(historyEntity).ExecuteCommand();
+
+ if (insertCount <= 0)
+ {
+ _logger.LogError($"浠诲姟鍘嗗彶琛―t_Task_Hty [{task.TaskNum}]鎻掑叆澶辫触锛屽奖鍝嶈鏁颁负0");
+ // transaction.RollbackTran();
+ return false;
+ }
+
+ // 4. 鍒犻櫎鍘熷疄浣擄紙绫诲瀷瀹夊叏锛�
+ int deleteCount = Db.Deleteable(task).ExecuteCommand();
+ if (deleteCount <= 0)
+ {
+ _logger.LogError("浠诲姟涓氬姟瀹炰綋[{0}]鍒犻櫎澶辫触锛屽奖鍝嶈鏁颁负0", task.TaskNum);
+ // transaction.RollbackTran();
+ return false;
+ }
+ //transaction.CommitTran();
+ _logger.LogInformation("浠诲姟瀹炰綋[{0}]宸叉垚鍔熺Щ鍏ュ巻鍙茶〃[{1}]骞跺垹闄ゅ師鏁版嵁", task.TaskNum);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ // transaction.RollbackTran();
+ _logger.LogError(ex, "浠诲姟鍒犻櫎瀹炰綋[{0}]骞剁Щ鍏ュ巻鍙茶〃澶辫触", task.TaskNum);
+ return false;
+ }
}
}
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ESSController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ESSController.cs"
index 6cfedd4..ba22c1c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ESSController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ESSController.cs"
@@ -287,8 +287,7 @@
/// </summary>
private async Task HandleTaskSuspended(StatusCallbackRequest request)
{
- _logger.LogWarning("浠诲姟鎸傝捣: TaskCode={TaskCode}, 绯荤粺浠诲姟鐮�={SysTaskCode}, 鍘熷洜={Message}",
- request.TaskCode, request.SysTaskCode, request.Message);
+ _logger.LogWarning("浠诲姟鎸傝捣: TaskCode={TaskCode}, 绯荤粺浠诲姟鐮�={SysTaskCode}, 鍘熷洜={Message}",request.TaskCode, request.SysTaskCode, request.Message);
// 杩欓噷娣诲姞鎮ㄧ殑鎸傝捣澶勭悊閫昏緫
await Task.CompletedTask;
@@ -299,8 +298,7 @@
/// </summary>
private async Task HandleTaskAllocated(StatusCallbackRequest request)
{
- _logger.LogInformation("浠诲姟鍒嗛厤: TaskCode={TaskCode}, Robot={Robot}",
- request.TaskCode, request.RobotCode);
+ _logger.LogInformation("浠诲姟鍒嗛厤: TaskCode={TaskCode}, Robot={Robot}",request.TaskCode, request.RobotCode);
// 杩欓噷娣诲姞鎮ㄧ殑浠诲姟鍒嗛厤澶勭悊閫昏緫
await Task.CompletedTask;
@@ -313,8 +311,9 @@
{
if (request.Status == WIDESEA_DTO.Basic.TaskStatus.success)
{
- _logger.LogInformation("鍙栫瀹屾垚: Container={Container}, Location={Location}",
- request.ContainerCode, request.LocationCode);
+ _logger.LogInformation("鍙栫瀹屾垚: Container={Container}, Location={Location}", request.ContainerCode, request.LocationCode);
+
+ await _taskService.TaskStatusChange(request.TaskCode, WIDESEA_Common.TaskEnum.TaskStatusEnum.AGV_Pull);
}
else
{
@@ -333,8 +332,8 @@
{
if (request.Status == WIDESEA_DTO.Basic.TaskStatus.success)
{
- _logger.LogInformation("鏀剧瀹屾垚: Container={Container}, Location={Location}",
- request.ContainerCode, request.LocationCode);
+ _logger.LogInformation("鏀剧瀹屾垚: Container={Container}, Location={Location}", request.ContainerCode, request.LocationCode);
+ await _taskService.TaskStatusChange(request.TaskCode, WIDESEA_Common.TaskEnum.TaskStatusEnum.AGV_Puting);
}
else
{
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs"
index 69bc686..201f0f2 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs"
@@ -13,6 +13,8 @@
using WIDESEA_Core;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.BaseController;
+using WIDESEA_Core.BaseRepository;
+using WIDESEA_Core.Enums;
using WIDESEA_DTO.Allocate;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Mes;
@@ -20,6 +22,7 @@
using WIDESEA_IInboundService;
using WIDESEA_InboundService;
using WIDESEA_IOutboundService;
+using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using WIDESEA_OutboundService;
@@ -42,8 +45,10 @@
private readonly IMaterialUnitService _materialUnitService;
private readonly IOutStockLockInfoService _outStockLockInfoService;
private readonly IOutboundOrderDetailService _outboundOrderDetailService;
+ private readonly IRepository<Dt_Task> _taskRepository;
+ private readonly ITask_HtyService _task_HtyService;
private readonly ILogger<InboundOrderController> _logger;
- public InboundOrderController(IInboundOrderService service, WIDESEA_IBasicService.IErpApiService erpApiService, WIDESEA_IBasicService.IInvokeMESService invokeMESService, IESSApiService eSSApiService, IDailySequenceService dailySequenceService, ILocationInfoService locationInfoService, ILogger<InboundOrderController> logger, IMaterialUnitService materialUnitService, IInboundService inboundService, IOutStockLockInfoService outStockLockInfoService, IOutboundOrderDetailService outboundOrderDetailService) : base(service)
+ public InboundOrderController(IInboundOrderService service, WIDESEA_IBasicService.IErpApiService erpApiService, WIDESEA_IBasicService.IInvokeMESService invokeMESService, IESSApiService eSSApiService, IDailySequenceService dailySequenceService, ILocationInfoService locationInfoService, ILogger<InboundOrderController> logger, IMaterialUnitService materialUnitService, IInboundService inboundService, IOutStockLockInfoService outStockLockInfoService, IOutboundOrderDetailService outboundOrderDetailService, IRepository<Dt_Task> taskRepository, ITask_HtyService task_HtyService) : base(service)
{
this.erpApiService = erpApiService;
_invokeMESService = invokeMESService;
@@ -55,22 +60,32 @@
_inboundService = inboundService;
_outStockLockInfoService = outStockLockInfoService;
_outboundOrderDetailService = outboundOrderDetailService;
+ _taskRepository = taskRepository;
+ _task_HtyService = task_HtyService;
}
[HttpPost, Route("Test"), AllowAnonymous, MethodParamsValidate]
public async Task<WebResponseContent> Test()
{
-
+ var originalTask = _taskRepository.Db.Queryable<Dt_Task>().First();
+
+ var result = _task_HtyService.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.浜哄伐鍒犻櫎);
+ if (result)
+ {
+ var sddd = "trueee";
+ }
+ //var originalTask = _taskRepository.Db.Queryable<Dt_Task>().First();
+ //_taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
// Service.Db.Deleteable<Dt_InboundOrder>().Where(x=>x.UpperOrderNo== "12020251100040").ExecuteCommand();
//_inboundService.InboundOrderDetailService.Db.Deleteable<Dt_InboundOrderDetail>()
// .Where(p => SqlFunc.Subqueryable<Dt_InboundOrder>().Where(s => s.Id == p.OrderId && s.UpperOrderNo == "12020251100040").Any()).ExecuteCommand();
- var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync("100513-00303", 1);
+ //var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync("100513-00303", 1);
- var pdddurchaseToStockResult = await _materialUnitService.ConvertFromToStockAsync("100513-00303", "W013", 1);
+ //var pdddurchaseToStockResult = await _materialUnitService.ConvertFromToStockAsync("100513-00303", "W013", 1);
- //var sddd = _locationInfoService.AssignLocation();
+ //var sddd = _locationInfoService.AssignLocation(1);
//var code = sddd.LocationCode;
//var ssss=await _dailySequenceService.GetNextSequenceAsync();
//var ddddssss = "WSLOT" + DateTime.Now.ToString("yyyyMMddHHmmss") + ssss.ToString().PadLeft(5, '0');
@@ -104,7 +119,7 @@
//await erpApiService.GetMaterialInfoAsync(new WIDESEA_DTO.Basic.MaterialRequest());
- return WebResponseContent.Instance.OK();
+ return WebResponseContent.Instance.OK(result?1:0 );
}
/// <summary>
@@ -115,12 +130,12 @@
[HttpPost, Route("ReceiveInboundOrder"), AllowAnonymous, MethodParamsValidate]
public async Task<WebResponseContent> ReceiveInboundOrder([FromBody] InboundRequestModel model)
{
- if(model.inBounds == null || !model.inBounds.Any())
+ if (model.inBounds == null || !model.inBounds.Any())
{
return WebResponseContent.Instance.Error("鍏ュ簱鍗曚笉鑳戒负绌�");
}
- _logger.LogInformation("InboundOrderController ReceiveInboundOrder: " + JsonConvert.SerializeObject(model));
+ _logger.LogInformation("InboundOrderController ReceiveInboundOrder: " + JsonConvert.SerializeObject(model));
List<Dt_InboundOrder> inboundOrders = new List<Dt_InboundOrder>();
foreach (var item in model.inBounds)
@@ -178,7 +193,7 @@
inboundOrders.Add(dt_InboundOrder);
}
- var content =await Service.ReceiveInboundOrder(inboundOrders, model.operationType);
+ var content = await Service.ReceiveInboundOrder(inboundOrders, model.operationType);
if (content.Status) return WebResponseContent.Instance.OK(200);
else return WebResponseContent.Instance.Error(content.Message);
@@ -224,9 +239,9 @@
}
[HttpPost, Route("BatchOrderFeedbackToMes"), AllowAnonymous]
- public async Task<WebResponseContent> BatchOrderFeedbackToMes([FromBody] BatchOrderFeedbackToMesDto request)
+ public async Task<WebResponseContent> BatchOrderFeedbackToMes([FromBody] BatchOrderFeedbackToMesDto request)
{
- return await _invokeMESService.BatchOrderFeedbackToMes(request.orderNos, request.inout);
+ return await _invokeMESService.BatchOrderFeedbackToMes(request.orderNos, request.inout);
}
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CustomProfile.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CustomProfile.cs"
index 8636c46..565c922 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CustomProfile.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Filter/CustomProfile.cs"
@@ -7,6 +7,7 @@
using System.Threading.Tasks;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Core.Helper;
+using WIDESEA_Core.HttpContextUser;
using WIDESEA_DTO;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Outbound;
@@ -33,6 +34,10 @@
CreateMap<Dt_ReceiveOrderDetail, Dt_CheckOrder>().ForMember(a => a.ReceivedQuantity, b => b.MapFrom(x => x.ReceivedQuantity)).ForMember(a => a.MaterielCode, b => b.MapFrom(x => x.MaterielCode)).ForMember(a => a.CheckOrderStatus, b => b.MapFrom(x => CheckOrderStatusEnum.NotCheck.ObjToInt()));
CreateMap<Dt_Task, WMSTaskDTO>();
+
+ CreateMap<Dt_Task, Dt_Task_Hty>()
+ .ForMember(dest => dest.SourceId, opt => opt.Ignore()) // 鎵嬪姩濉厖锛屽拷鐣ユ槧灏�
+ .ForMember(dest => dest.OperateType, opt => opt.Ignore()); // 鎵嬪姩濉厖锛屽拷鐣ユ槧灏�
}
}
}
--
Gitblit v1.9.3