From 74ab8260224fd69add7b0b7c98ad139b28136334 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期一, 01 十二月 2025 08:38:52 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Stock/Dt_StockInfoDetail.cs | 1
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/InventoryLockJob.cs | 23
项目代码/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js | 9
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundPickingController.cs | 5
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 351 +++++
项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue | 7
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundPickingService.cs | 6
项目代码/WIDESEA_WMSClient/src/extension/check/recheckOrder.js | 31
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs | 18
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundBatchPickingService.cs | 1305 +++++++++++++++++++-----
项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/PickingRetuenPallet.vue | 1282 ++++++++++++++++++++++++
项目代码/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue | 4
项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/AllocatedPallet.vue | 4
项目代码/WIDESEA_WMSClient/src/views/check/ReCheckOrder.vue | 37
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/PickingReturnController.cs | 44
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Common/StockEnum/StockStatusEmun.cs | 5
16 files changed, 2,797 insertions(+), 335 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/recheckOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/recheckOrder.js"
index 5637829..c79a67f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/recheckOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/recheckOrder.js"
@@ -7,7 +7,9 @@
*****************************************************************************************/
//姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜
import gridBody from './extend/StockSelect.vue'
-
+import http from '@/api/http.js'
+import { h,createVNode, render,reactive,ref } from 'vue';
+import { ElDialog , ElForm, ElFormItem, ElInput, ElButton, ElMessage ,ElSelect ,ElOption } from 'element-plus'; // 寮曞叆ElMessage锛岃В鍐虫彁绀烘棤鍙嶅簲
let extension = {
components: {
//鏌ヨ鐣岄潰鎵╁睍缁勪欢
@@ -20,7 +22,32 @@
modelFooter: ''
},
tableAction: '', //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓)
- buttons: { view: [], box: [], detail: [] }, //鎵╁睍鐨勬寜閽�
+ buttons: { view: [ {
+ name: '缁勭洏',
+ type: 'primary',
+ value: '缁勭洏',
+ onClick: function () { // 淇1锛氱Щ闄ゆ棤鐢╮ow鍙傛暟锛屽姞鏃ュ織璋冭瘯
+ console.log('缁勭洏鎸夐挳琚偣鍑伙紝寮�濮嬫牎楠�');
+ const selectedRows = this.$refs.table.getSelected();
+
+ // 鏍¢獙1锛氭槸鍚﹂�変腑琛�
+ if (selectedRows.length === 0) {
+ console.log('鏍¢獙涓嶉�氳繃锛氭湭閫変腑浠讳綍鍗曟嵁');
+ ElMessage.warning('璇烽�夋嫨涓�鏉″崟鎹�');
+ return;
+ }
+ // 鏍¢獙2锛氭槸鍚﹂�変腑鍗曡
+ if (selectedRows.length > 1) {
+ console.log('鏍¢獙涓嶉�氳繃锛氶�変腑澶氳鍗曟嵁');
+ ElMessage.warning('鍙兘閫夋嫨涓�鏉″崟鎹�');
+ return;
+ }
+
+ const targetRow = selectedRows[0];
+
+ this.$emit('openPalletDialog', targetRow.orderNo);
+ }
+ },], box: [], detail: [] }, //鎵╁睍鐨勬寜閽�
methods: {
//涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄�
onInit() { //妗嗘灦鍒濆鍖栭厤缃墠锛�
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js"
index 061bb6b..afd3d2e 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js"
@@ -431,6 +431,15 @@
searchBefore(param) {
//鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟
//杩斿洖false锛屽垯涓嶄細鎵ц鏌ヨ
+
+ let wheres = [{
+ 'name': 'orderType',
+ 'value': '117',
+ 'displayType': 'text'}];
+
+
+ param.wheres.push(...wheres);
+ return true;
return true;
},
searchAfter(result) {
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocatedPallet.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocatedPallet.vue"
index b976153..cfe8cc1 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocatedPallet.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocatedPallet.vue"
@@ -510,7 +510,7 @@
this.sumError = '';
try {
// 璋冪敤鍚庣缁熻鎺ュ彛锛堟浛鎹负浣犵殑瀹為檯鎺ュ彛璺緞锛�
- const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo='+this.docNo, {
+ const response = await http.post('/api/PickingReturn/UnPalletQuantity?orderNo='+this.docNo, {
});
@@ -885,7 +885,7 @@
// API璇锋眰 - 鏇挎崲涓哄疄闄呯殑API璋冪敤
async fetchMaterialData(barcode) {
try {
- const response = await http.post('/api/InboundOrder/BarcodeMaterielGroup',
+ const response = await http.post('/api/PickingReturn/BarcodeMaterielGroup',
{
palletCode: this.trayBarcode,
orderNo: this.docNo,
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/PickingRetuenPallet.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/PickingRetuenPallet.vue"
new file mode 100644
index 0000000..7cf5a0d
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/PickingRetuenPallet.vue"
@@ -0,0 +1,1282 @@
+<template>
+ <vol-box v-model="groupPalletVisible" :title="'缁勭洏鎿嶄綔 - 鍗曟嵁鍙凤細' + currentDocNo" :height="1000" :width="1100" :padding="20"
+ :modal="true" @open="handleDialogOpen" @close="handleDialogClose">
+ <div class="barcode-scanner-container">
+
+ <!-- 浠撳簱閫夋嫨 - 绱у噾甯冨眬 -->
+ <div class="location-section compact">
+ <el-form :model="form" :rules="rules" ref="locationForm" class="compact-form">
+ <el-form-item label="浠撳簱" prop="warehouseType" class="location-select compact-item">
+ <el-select v-model="form.warehouseType" placeholder="璇烽�夋嫨浠撳簱" clearable filterable
+ @change="handleWarehouseChange" style="width: 100%" :loading="warehouseLoading" size="medium">
+ <el-option v-for="item in warehouseTypes" :key="item.warehouseType" :label="item.warehouseTypeDesc"
+ :value="item.warehouseType" />
+ </el-select>
+ </el-form-item>
+ </el-form>
+ </div>
+
+ <!-- 浠撳簱鍖哄煙閫夋嫨 - 绱у噾甯冨眬 -->
+ <div class="location-section compact">
+ <el-form :model="form" :rules="rules" ref="locationForm" class="compact-form">
+ <el-form-item label="浠撳簱鍖哄煙" prop="locationType" class="location-select compact-item">
+ <el-select v-model="form.locationType" placeholder="璇峰厛閫夋嫨浠撳簱" clearable filterable
+ @change="handleLocationChange" style="width: 100%" :loading="locationLoading" size="medium">
+ <el-option v-for="item in locationTypes" :key="item.locationType" :label="item.locationTypeDesc"
+ :value="item.locationType" />
+ </el-select>
+ </el-form-item>
+ </el-form>
+ </div>
+
+ <!-- 鎵樼洏淇℃伅鏄剧ず - 绱у噾甯冨眬 -->
+ <div class="tray-info compact" v-if="trayBarcode">
+ <i class="el-icon-s-management"></i> 褰撳墠鏂欑: {{ trayBarcode }}
+ <span class="location-info" v-if="form.warehouseType">
+ | 浠撳簱: {{ currentWarehouseName }}
+ </span>
+ <span class="location-info" v-if="form.locationType">
+ | 浠撳簱鍖哄煙: {{ currentLocationDesc }}
+ </span>
+ </div>
+
+ <!-- 鎵爜鍖哄煙 - 绱у噾甯冨眬 -->
+ <div class="input-section compact">
+ <el-card shadow="hover" class="compact-card">
+ <div slot="header" class="compact-header">
+ <span><i class="el-icon-scanner"></i> 鎵爜鍖哄煙</span>
+ <span class="scan-status">
+ <span class="scan-indicator"></span>
+ {{ form.locationType && form.warehouseType ? '鎵爜灏辩华' : '璇峰厛閫夋嫨浠撳簱鍜屼粨搴撳尯鍩�' }}
+ </span>
+ </div>
+
+ <!-- 鎵樼洏鏉$爜杈撳叆 -->
+ <div class="input-wrapper custom-input-group compact-input">
+ <div class="input-label">鏂欑鐮�</div>
+ <el-input ref="trayInput" v-model="trayBarcode" placeholder="璇锋壂鎻忔垨杈撳叆鏂欑鐮佸悗鎸夊洖杞﹂敭" clearable
+ :disabled="!form.locationType || !form.warehouseType" @keyup.enter.native="handleTraySubmit"
+ @clear="handleTrayClear" @input="handleTrayInput" class="custom-input" size="medium">
+ <template slot="append">
+ <el-button @click="handleTraySubmit" type="primary" icon="el-icon-position"
+ :disabled="!form.locationType || !trayBarcode || !form.warehouseType" size="medium">
+ 纭
+ </el-button>
+ </template>
+ </el-input>
+ </div>
+
+ <!-- 鐗╂枡鏉$爜杈撳叆 -->
+ <div class="input-wrapper custom-input-group compact-input">
+ <div class="input-label">鐗╂枡鏉$爜</div>
+ <el-input ref="barcodeInput" v-model="barcode" placeholder="璇锋壂鎻忔垨杈撳叆鐗╂枡鏉$爜鍚庢寜鍥炶溅閿�" clearable
+ :disabled="!form.locationType || !trayBarcode || !form.warehouseType"
+ @keyup.enter.native="handleBarcodeSubmit" @clear="handleClear" @input="handleBarcodeInput"
+ class="custom-input" size="medium">
+ <template slot="append">
+ <el-button :loading="loading" @click="handleBarcodeSubmit" type="primary" icon="el-icon-search"
+ :disabled="!form.locationType || !trayBarcode || !barcode || !from.warehouseType" size="medium">
+ {{ loading ? '鏌ヨ涓�...' : '鏌ヨ' }}
+ </el-button>
+ </template>
+ </el-input>
+ </div>
+
+ <div class="input-tips compact-tips">
+ <p>鎻愮ず锛氳鍏堥�夋嫨浠撳簱 鈫� 閫夋嫨浠撳簱鍖哄煙 鈫� 杈撳叆鏂欑鐮� 鈫� 杈撳叆鐗╂枡鏉$爜</p>
+ <p v-if="!form.warehouseType" class="warning-text">鈿狅笍 璇峰厛閫夋嫨浠撳簱</p>
+ <p v-if="!form.locationType && !form.warehouseType" class="warning-text">鈿狅笍 璇峰厛閫夋嫨浠撳簱鍖哄煙</p>
+ <p v-if="form.warehouseType && form.locationType && !trayBarcode" class="warning-text">鈿狅笍 璇峰厛杈撳叆鏂欑鐮�</p>
+ </div>
+
+ </el-card>
+ </div>
+
+ <!-- 鍔犺浇鐘舵�� -->
+ <div v-if="loading" class="loading compact">
+ <el-progress :percentage="100" status="success" :show-text="false" />
+ <p>姝e湪鏌ヨ鐗╂枡淇℃伅...</p>
+ </div>
+
+ <!-- 閿欒鎻愮ず -->
+ <div v-if="error" class="error-message compact">
+ <el-alert :title="error" type="error" show-icon closable @close="error = ''" />
+ </div>
+
+ <!-- 鐗╂枡鍒楄〃 - 鍥哄畾楂樺害甯︽粴鍔ㄦ潯 -->
+ <div class="material-list compact">
+ <el-card shadow="hover" class="compact-card">
+ <div slot="header" class="compact-header">
+ <span><i class="el-icon-tickets"></i> 缁勭洏鏁版嵁</span>
+ <span class="list-actions">
+ <el-tag type="primary" size="small">鍏� {{ materials.length }} 鏉�</el-tag>
+ <el-tag type="primary" size="small">鏈粍鐩� {{ totalStockCount }}</el-tag>
+ <el-tag type="primary" size="small">鏈叆搴撴暟閲� {{ totalStockSum }}{{ uniqueUnit }}</el-tag>
+ <el-tag v-if="trayBarcode" type="success" size="small">鎵樼洏: {{ trayBarcode }}</el-tag>
+ <el-tag v-if="form.warehouseType" type="info" size="small">浠撳簱: {{ currentWarehouseName }}</el-tag>
+ <el-tag v-if="form.locationType" type="info" size="small">鍖哄煙: {{ currentLocationDesc }}</el-tag>
+ </span>
+ </div>
+
+ <div v-if="materials.length === 0" class="empty-state compact">
+ <i class="el-icon-document"></i>
+ <p v-if="!form.warehouseType">璇峰厛閫夋嫨浠撳簱</p>
+ <p v-if="!form.locationType">璇峰厛閫夋嫨浠撳簱鍖哄煙</p>
+ <p v-else-if="!trayBarcode">璇峰厛杈撳叆鏂欑鏉$爜</p>
+ <p v-else>鏆傛棤鐗╂枡鏁版嵁锛岃鎵弿鎴栬緭鍏ョ墿鏂欐潯鐮�</p>
+ </div>
+
+ <div class="table-container" v-else>
+ <el-table :data="materials" stripe style="width: 100%" height="100%" size="small">
+ <el-table-column type="index" label="搴忓彿" width="60" align="center"></el-table-column>
+ <el-table-column prop="barcode" label="鏉$爜" min-width="140" show-overflow-tooltip></el-table-column>
+ <el-table-column prop="materielCode" label="鐗╂枡缂栫爜" min-width="150" show-overflow-tooltip></el-table-column>
+ <el-table-column prop="batchNo" label="鎵规" min-width="150" show-overflow-tooltip></el-table-column>
+ <el-table-column prop="stockQuantity" label="鏁伴噺" min-width="130" align="right"></el-table-column>
+ <el-table-column prop="unit" label="鍗曚綅" width="80" align="center"></el-table-column>
+ <el-table-column prop="supplyCode" label="渚涘簲鍟�" min-width="130" show-overflow-tooltip></el-table-column>
+ <el-table-column prop="warehouseType" label="浠撳簱" min-width="120" show-overflow-tooltip></el-table-column>
+ </el-table>
+ </div>
+ </el-card>
+ </div>
+ </div>
+
+ <!-- <div slot="footer" class="dialog-footer">
+ <el-button @click="handleCancel">鍙栨秷</el-button>
+ <el-button type="primary" @click="handleConfirm">纭</el-button>
+ </div> -->
+ </vol-box>
+</template>
+<script>
+import http from '@/api/http.js';
+import VolBox from '@/components/basic/VolBox.vue';
+import VolForm from '@/components/basic/VolForm.vue';
+import VolTable from '@/components/basic/VolTable.vue';
+import { ElLoading, ElMessage, ElMessageBox } from 'element-plus';
+import { ref, onMounted, onUnmounted } from 'vue'
+import InboundOrder from '../../../views/inbound/inboundOrder.vue';
+import { th } from 'element-plus/es/locales.mjs';
+
+export default {
+ name: 'BarcodeScanner',
+ components: { VolBox, VolForm, VolTable },
+ props: {
+ docNo: { type: String, required: true, default: '' },
+ visible: { type: Boolean, required: true, default: false }
+ },
+
+ data() {
+ return {
+ palletVisible: this.visible,
+ trayBarcode: '',
+ barcode: '',
+ materials: [],
+ loading: false,
+ error: '',
+ debugMode: false,
+ currentFocus: 'warehouse',
+
+ // 鎵爜鏋浉鍏冲彉閲�
+ scanCode: '',
+ lastKeyTime: null,
+ isManualInput: false,
+ isScanning: false,
+ scanTimer: null,
+ manualInputTimer: null,
+ scanTarget: 'tray', // 褰撳墠鎵爜鐩爣: tray 鎴� material
+
+ // 搴撳瓨缁熻鐩稿叧鍙橀噺
+ totalStockSum: 0,
+ totalStockCount: 0,
+ uniqueUnit: '',
+ sumLoading: false,
+ sumError: '',
+ // 浠撳簱鐩稿叧鍙橀噺
+ warehouseTypes: [],
+ warehouseLoading: false,
+ // 浠撳簱鍖哄煙鐩稿叧鍙橀噺
+ locationTypes: [],
+ locationLoading: false,
+ form: {
+ warehouseType: null,
+ locationType: null
+ },
+ rules: {
+ locationType: [
+ {
+ validator: this.validateLocationType,
+ trigger: 'change'
+ }
+ ],
+ warehouseType: [
+ {
+ massage: '璇烽�夋嫨浠撳簱',
+ trigger: 'change'
+ }
+ ]
+ }
+ }
+ },
+ computed: {
+ groupPalletVisible: {
+ get() { return this.visible; },
+ set(newVal) { this.$emit('update:visible', newVal); }
+ },
+ currentDocNo() { return this.docNo; },
+ // 褰撳墠閫夋嫨鐨勪粨搴撳悕绉�
+ currentWarehouseName() {
+ const warehouse = this.warehouseTypes.find(item => item.warehouseType === this.form.warehouseType);
+ return warehouse ? warehouse.warehouseTypeDesc : '';
+ },
+ // 褰撳墠閫夋嫨鐨勪粨搴撳尯鍩熸弿杩�
+ currentLocationDesc() {
+ const location = this.locationTypes.find(item => item.locationType === this.form.locationType)
+ return location ? location.locationTypeDesc : ''
+ }
+ },
+ watch: {
+ visible(newVal, oldVal) {
+ this.palletVisible = newVal;
+
+ // 褰撲粠 false 鍙樹负 true 鏃讹紝琛ㄧず寮规鎵撳紑
+ if (newVal === true && oldVal === false) {
+ console.log('寮规鎵撳紑锛岄噸缃暟鎹�');
+ this.resetData();
+ this.$nextTick(() => {
+ setTimeout(() => {
+ // this.focusTrayInput();
+ this.initwarehouseTypes(); // 鍒濆鍖栦粨搴�
+ this.initLocationTypes(); // 鍒濆鍖栦粨搴撳尯鍩�
+ this.fetchStockStatistics(); // 鍔犺浇缁熻鏁版嵁
+ }, 300);
+ });
+ }
+
+ // 褰撲粠 true 鍙樹负 false 鏃讹紝琛ㄧず寮规鍏抽棴
+ if (newVal === false && oldVal === true) {
+ console.log('寮规鍏抽棴锛岄噸缃暟鎹�');
+ this.resetData();
+ }
+ },
+ palletVisible(newVal) {
+ this.$emit('update:visible', newVal);
+ },
+ docNo(newVal) {
+ if (newVal) {
+ this.palletForm = { palletCode: '', barcode: '' };
+ this.backData = [];
+ this.$refs.palletForm?.reset();
+ this.fetchStockStatistics(); // 鍗曟嵁鍙峰彉浜嗭紝鍒锋柊缁熻
+ }
+ }
+ },
+ 'form.warehouseType'(newVal) {
+ if (newVal) {
+ this.form.locationType = null;
+ } else {
+ this.locationTypes = [];
+ }
+ },
+
+ mounted() {
+
+ // 娣诲姞鍏ㄥ眬閿洏鐩戝惉
+ document.addEventListener('keypress', this.handleKeyPress);
+
+ // 浣跨敤setTimeout纭繚DOM瀹屽叏娓叉煋鍚庡啀鑱氱劍
+ setTimeout(() => {
+ // this.focusTrayInput();
+ this.focusLocationSelect();
+ }, 300);
+ },
+ beforeDestroy() {
+ // 娓呯悊浜嬩欢鐩戝惉
+ document.removeEventListener('keypress', this.handleKeyPress);
+ this.clearAllTimers();
+ },
+ methods: {
+ /**
+* 鑷畾涔変粨搴撳尯鍩熼獙璇�
+* 鍏佽鍊间负0锛屽洜涓�0鏄悎娉曠殑locationType
+*/
+ validateLocationType(rule, value, callback) {
+ // 妫�鏌ュ�兼槸鍚︿负null銆乽ndefined鎴栫┖瀛楃涓诧紝浣嗗厑璁告暟瀛�0
+ if (!this.form.warehouseType) {
+ callback(new Error('璇峰厛閫夋嫨浠撳簱'));
+ } else if (value === null || value === undefined || value === '') {
+ callback(new Error('璇烽�夋嫨浠撳簱鍖哄煙'));
+ } else {
+ callback();
+ }
+ },
+ /**
+ * 鍒濆鍖栦粨搴撳尯鍩熸暟鎹�
+ */
+ async initLocationTypes() {
+ this.locationLoading = true;
+ this.error = '';
+
+ try {
+ const response = await http.post('/api/LocationInfo/GetLocationTypes');
+
+ if (response.status && Array.isArray(response.data)) {
+ this.locationTypes = response.data;
+ if (this.locationTypes.length === 0) {
+ this.error = '鏈幏鍙栧埌浠撳簱鍖哄煙鏁版嵁';
+ } else {
+ // 濡傛灉鏈夐粯璁ゅ尯鍩燂紝鍙互鍦ㄨ繖閲岃缃�
+ // this.form.locationType = this.locationTypes[0].locationType;
+ }
+ } else {
+ this.error = '鑾峰彇浠撳簱鍖哄煙鏁版嵁澶辫触';
+ }
+ } catch (error) {
+ console.error('鑾峰彇浠撳簱鍖哄煙澶辫触:', error);
+ this.error = `鑾峰彇浠撳簱鍖哄煙澶辫触: ${error.message || '缃戠粶閿欒'}`;
+ } finally {
+ this.locationLoading = false;
+ }
+ },
+
+ /**
+ * 鍒濆鍖栦粨搴撴暟鎹�
+ */
+ async initwarehouseTypes() {
+ this.warehouseLoading = true;
+ this.error = '';
+
+ try {
+ const response = await http.post('/api/Warehouse/GetwarehouseTypes');
+
+ if (response.status && Array.isArray(response.data)) {
+ this.warehouseTypes = response.data;
+ if (this.warehouseTypes.length === 0) {
+ this.error = '鏈幏鍙栧埌浠撳簱鏁版嵁';
+ } else {
+ // 濡傛灉鏈夐粯璁ゅ尯鍩燂紝鍙互鍦ㄨ繖閲岃缃�
+ // this.form.locationType = this.locationTypes[0].locationType;
+ }
+ } else {
+ this.error = '鑾峰彇浠撳簱鏁版嵁澶辫触';
+ }
+ } catch (error) {
+ console.error('鑾峰彇浠撳簱澶辫触:', error);
+ this.error = `鑾峰彇浠撳簱澶辫触: ${error.message || '缃戠粶閿欒'}`;
+ } finally {
+ this.warehouseLoading = false;
+ }
+ },
+
+
+ /**
+ * 浠撳簱鍖哄煙鍙樻洿澶勭悊
+ */
+ handleLocationChange(value) {
+ console.log('閫夋嫨浠撳簱鍖哄煙:', value, '绫诲瀷:', typeof value, this.currentLocationDesc);
+
+ // 绔嬪嵆娓呴櫎閿欒淇℃伅
+ this.error = '';
+
+ // 鎵嬪姩瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
+ this.$nextTick(() => {
+ if (this.$refs.locationForm) {
+ // 娓呴櫎璇ュ瓧娈电殑楠岃瘉鐘舵�侊紝鐒跺悗閲嶆柊楠岃瘉
+ this.$refs.locationForm.clearValidate('locationType');
+
+ // 鐭殏寤惰繜鍚庨噸鏂伴獙璇侊紝纭繚DOM宸叉洿鏂�
+ setTimeout(() => {
+ this.$refs.locationForm.validateField('locationType', (errorMsg) => {
+ if (!errorMsg && (value === 0 || value)) {
+ console.log('浠撳簱鍖哄煙楠岃瘉閫氳繃:', value);
+ // 鍖哄煙閫夋嫨鍚庯紝鑷姩鑱氱劍鍒版墭鐩樿緭鍏ユ
+ this.focusLocationSelect();
+ }
+ });
+ }, 100);
+ }
+ });
+ },
+
+ /**
+ * 浠撳簱鍙樻洿澶勭悊
+ */
+ handleWarehouseChange(value) {
+ console.log('閫夋嫨浠撳簱:', value, '绫诲瀷:', typeof value, this.currentWarehouseName);
+
+ // 绔嬪嵆娓呴櫎閿欒淇℃伅
+ this.error = '';
+
+ // 鎵嬪姩瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
+ this.$nextTick(() => {
+ if (this.$refs.locationForm) {
+ // 娓呴櫎璇ュ瓧娈电殑楠岃瘉鐘舵�侊紝鐒跺悗閲嶆柊楠岃瘉
+ this.$refs.locationForm.clearValidate('warehouseType');
+
+ // 鐭殏寤惰繜鍚庨噸鏂伴獙璇侊紝纭繚DOM宸叉洿鏂�
+ setTimeout(() => {
+ this.$refs.locationForm.validateField('warehouseType', (errorMsg) => {
+ if (!errorMsg && (value === 0 || value)) {
+ console.log('浠撳簱楠岃瘉閫氳繃:', value);
+ this.focusLocationSelect();
+ }
+ });
+ }, 100);
+ }
+ });
+ },
+
+ async fetchStockStatistics() {
+ // 鍗曟嵁鍙蜂负绌烘椂涓嶆煡璇�
+ if (!this.docNo) {
+ this.sumError = '鍗曟嵁鍙蜂负绌猴紝鏃犳硶缁熻';
+ return;
+ }
+
+ this.sumLoading = true;
+ this.sumError = '';
+ try {
+ // 璋冪敤鍚庣缁熻鎺ュ彛锛堟浛鎹负浣犵殑瀹為檯鎺ュ彛璺緞锛�
+ const response = await http.post('/api/PickingReturn/UnPalletQuantity?orderNo=' + this.docNo, {
+
+ });
+
+ // 缁戝畾鏁版嵁锛堝尮閰� PalletSumQuantityDTO 缁撴瀯锛�
+ if (response.data) {
+ this.totalStockSum = response.data.stockSumQuantity || 0; // 鎬诲簱瀛樻暟閲�
+ this.totalStockCount = response.data.stockCount || 0; // 鎬诲簱瀛樿褰曟暟
+ this.uniqueUnit = response.data.uniqueUnit || ''; // 璁¢噺鍗曚綅
+ }
+ } catch (err) {
+ this.sumError = '缁熻鍔犺浇澶辫触';
+ this.totalStockSum = 0;
+ this.totalStockCount = 0;
+ console.error('搴撳瓨缁熻鏌ヨ寮傚父锛�', err);
+ } finally {
+ this.sumLoading = false;
+ }
+ },
+ /**
+ * 琛ㄥ崟楠岃瘉
+ */
+ async validateForm() {
+ return new Promise((resolve) => {
+ if (!this.$refs.locationForm) {
+ this.error = '琛ㄥ崟鏈垵濮嬪寲';
+ this.$message.warning('璇峰厛閫夋嫨浠撳簱鍖哄煙');
+ resolve(false);
+ return;
+ }
+
+ this.$refs.locationForm.validate((valid) => {
+ if (valid) {
+ this.error = '';
+ resolve(true);
+ } else {
+ // 鎵嬪姩妫�鏌ocationType锛屾纭鐞嗗�间负0鐨勬儏鍐�
+ if (!this.from.warehouseType) {
+ this.error = '璇峰厛閫夋嫨浠撳簱';
+ }
+ else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') {
+ this.error = '璇峰厛閫夋嫨浠撳簱鍖哄煙';
+ //this.$message.warning('璇峰厛閫夋嫨浠撳簱鍖哄煙');
+ } else {
+ // 濡傛灉鍊煎瓨鍦紙鍖呮嫭0锛夛紝浣嗛獙璇佷笉閫氳繃锛屽彲鑳芥槸鍏朵粬楠岃瘉閿欒
+ this.error = '璇锋鏌ヨ〃鍗曞~鍐欐槸鍚︽纭�';
+ }
+ resolve(false);
+ }
+ });
+ });
+ },
+ focusWarehouseSelect() {
+ if (this.$refs.locationForm) {
+ const selectEl = this.$el.querySelector('.location-select:first-child .el-input__inner');
+ if (selectEl) {
+ selectEl.focus();
+ this.currentFocus = 'warehouse';
+ }
+ }
+ },
+ // 鑱氱劍鍒颁粨搴撳尯鍩熼�夋嫨
+ focusLocationSelect() {
+ if (this.$refs.locationForm) {
+ const selectEl = this.$el.querySelector('.location-select:nth-child(2) .el-input__inner');
+ if (selectEl) {
+ selectEl.focus();
+ this.currentFocus = 'location';
+ }
+ }
+ },
+ // 鑱氱劍鍒版墭鐩樿緭鍏ユ
+ focusTrayInput() {
+ if (this.$refs.trayInput && this.$refs.trayInput.$el) {
+ const inputEl = this.$refs.trayInput.$el.querySelector('input');
+ if (inputEl) {
+ inputEl.focus();
+ this.currentFocus = 'tray';
+ this.scanTarget = 'tray';
+ }
+ }
+ },
+
+ // 鑱氱劍鍒扮墿鏂欒緭鍏ユ
+ focusBarcodeInput() {
+ if (this.$refs.barcodeInput && this.$refs.barcodeInput.$el) {
+ const inputEl = this.$refs.barcodeInput.$el.querySelector('input');
+ if (inputEl) {
+ inputEl.focus();
+ this.currentFocus = 'material';
+ this.scanTarget = 'material';
+
+
+ inputEl.select();
+ console.log('鐗╂枡杈撳叆妗嗗唴瀹瑰凡閫変腑');
+
+ }
+ }
+ },
+
+
+
+
+ // 閲嶇疆鎵�鏈夋暟鎹�
+ resetData() {
+ console.log('閲嶇疆寮规鏁版嵁');
+ this.trayBarcode = '';
+ this.barcode = '';
+ this.materials = [];
+ this.loading = false;
+ this.error = '';
+ this.scanCode = '';
+ this.lastKeyTime = null;
+ this.isManualInput = false;
+ this.isScanning = false;
+ this.currentFocus = 'warehouse';
+ this.scanTarget = 'tray';
+ this.clearAllTimers();
+ this.totalStockSum = 0;
+ this.totalStockCount = 0;
+ this.sumLoading = false;
+ this.sumError = '';
+ this.form = {
+ warehouseType: null,
+ locationType: null
+ }
+ this.warehouseTypes = [];
+ this.locationTypes = [];
+ // 娓呴櫎琛ㄥ崟楠岃瘉鐘舵��
+ this.$nextTick(() => {
+ if (this.$refs.locationForm) {
+ this.$refs.locationForm.clearValidate();
+ }
+ });
+ },
+
+ // 娓呴櫎鎵�鏈夎鏃跺櫒
+ clearAllTimers() {
+ if (this.manualInputTimer) {
+ clearTimeout(this.manualInputTimer);
+ this.manualInputTimer = null;
+ }
+ if (this.scanTimer) {
+ clearTimeout(this.scanTimer);
+ this.scanTimer = null;
+ }
+ },
+
+ // 寮规鎵撳紑鏃堕噸缃暟鎹�
+ handleDialogOpen() {
+ console.log('寮规鎵撳紑锛岄噸缃暟鎹�');
+ this.resetData();
+ // 浣跨敤setTimeout纭繚DOM瀹屽叏娓叉煋鍚庡啀鑱氱劍
+ this.$nextTick(() => {
+ setTimeout(() => {
+ this.initwarehouseTypes();
+ this.initLocationTypes(); // 鍒濆鍖栦粨搴撳尯鍩�
+ // 纭繚琛ㄥ崟寮曠敤瀛樺湪鍚庡啀鑱氱劍
+ if (this.$refs.locationForm) {
+ this.focusWarehouseSelect();
+ } else {
+ // 濡傛灉琛ㄥ崟寮曠敤杩樹笉瀛樺湪锛岀◢鍚庨噸璇�
+ setTimeout(() => {
+ this.focusWarehouseSelect();
+ }, 500);
+ }
+ }, 300);
+ });
+ },
+
+ // 寮规鍏抽棴鏃堕噸缃暟鎹�
+ handleDialogClose() {
+ console.log('寮规鍏抽棴锛岄噸缃暟鎹�');
+ this.resetData();
+ },
+
+ // 鍙栨秷鎸夐挳
+ handleCancel() {
+ this.palletVisible = false;
+ },
+
+ // 纭鎸夐挳
+ async handleConfirm() {
+ if (!await this.validateForm()) return;
+
+ if (this.materials.length === 0) {
+ this.$message.warning('璇疯嚦灏戞坊鍔犱竴涓墿鏂�');
+ return;
+ }
+
+ if (!this.trayBarcode) {
+ this.$message.warning('璇疯緭鍏ユ墭鐩樻潯鐮�');
+ return;
+ }
+
+ const result = {
+ warehouseType: this.form.warehouseType,
+ warehouseName: this.currentWarehouseName,
+ locationType: this.form.locationType,
+ locationDesc: this.currentLocationDesc,
+ trayBarcode: this.trayBarcode,
+ materials: this.materials,
+ docNo: this.docNo
+ };
+
+ // 瑙﹀彂鐖剁粍浠剁殑 back-success 浜嬩欢
+ this.$emit('back-success', result);
+ this.palletVisible = false;
+ },
+ // 澶勭悊鎵樼洏杈撳叆
+ handleTrayInput() {
+ // 鏍囪涓烘墜鍔ㄨ緭鍏ユā寮�
+ this.isManualInput = true;
+ this.isScanning = false;
+
+ // 娓呴櫎涔嬪墠鐨勮鏃跺櫒
+ if (this.manualInputTimer) {
+ clearTimeout(this.manualInputTimer);
+ }
+
+ // 璁剧疆璁℃椂鍣紝濡傛灉涓�娈垫椂闂村唴娌℃湁杈撳叆锛屽垯閲嶇疆涓烘壂鐮佹ā寮�
+ this.manualInputTimer = setTimeout(() => {
+ this.isManualInput = false;
+ }, 1000);
+ },
+
+ // 澶勭悊鐗╂枡杈撳叆
+ handleBarcodeInput() {
+ // 鏍囪涓烘墜鍔ㄨ緭鍏ユā寮�
+ this.isManualInput = true;
+ this.isScanning = false;
+
+ // 娓呴櫎涔嬪墠鐨勮鏃跺櫒
+ if (this.manualInputTimer) {
+ clearTimeout(this.manualInputTimer);
+ }
+
+ // 璁剧疆璁℃椂鍣紝濡傛灉涓�娈垫椂闂村唴娌℃湁杈撳叆锛屽垯閲嶇疆涓烘壂鐮佹ā寮�
+ this.manualInputTimer = setTimeout(() => {
+ this.isManualInput = false;
+ }, 1000);
+ },
+
+ // 澶勭悊鎵樼洏鏉$爜鎻愪氦
+ async handleTraySubmit() {
+ // 鍏堢洿鎺ユ鏌ocationType锛岄伩鍏嶈〃鍗曢獙璇佺殑寮傛闂
+ if (!this.form.warehouseType) {
+ this.error = '璇峰厛閫夋嫨浠撳簱';
+ return;
+ }
+ if (!this.form.locationType) {
+ this.error = '璇峰厛閫夋嫨浠撳簱鍖哄煙';
+ //this.$message.warning('璇峰厛閫夋嫨浠撳簱鍖哄煙');
+ return;
+ }
+
+ // 鐒跺悗鍐嶈繘琛屽畬鏁寸殑琛ㄥ崟楠岃瘉
+ if (!await this.validateForm()) return;
+
+ const currentTrayBarcode = this.trayBarcode.trim();
+
+ if (!currentTrayBarcode) {
+ this.error = '璇疯緭鍏ユ垨鎵弿鎵樼洏鏉$爜';
+ return;
+ }
+
+ this.error = '';
+
+ // 璁剧疆鎵樼洏鏉$爜鍚庯紝鑷姩鑱氱劍鍒扮墿鏂欒緭鍏ユ
+ this.focusBarcodeInput();
+
+ this.$message({
+ message: `鎵樼洏鏉$爜宸茶缃�: ${currentTrayBarcode}`,
+ type: 'success',
+ duration: 2000
+ });
+ },
+
+ // 娓呴櫎鎵樼洏
+ clearTray() {
+ this.trayBarcode = '';
+ this.materials = [];
+ this.focusTrayInput();
+ this.$message({
+ message: '鎵樼洏鏉$爜宸叉竻闄�',
+ type: 'info',
+ duration: 2000
+ });
+ },
+
+ // 娓呯┖鎵樼洏杈撳叆
+ handleTrayClear() {
+ this.error = '';
+ },
+
+ // 娓呯┖杈撳叆
+ handleClear() {
+ this.error = '';
+ this.scanCode = '';
+ this.isManualInput = false;
+ this.isScanning = false;
+ },
+
+
+ // 澶勭悊鐗╂枡鏉$爜鎻愪氦
+ async handleBarcodeSubmit() {
+ if (!await this.validateForm()) return;
+ const currentBarcode = this.barcode.trim();
+
+ if (!this.trayBarcode) {
+ this.error = '璇峰厛杈撳叆鎵樼洏鏉$爜';
+ this.focusTrayInput();
+ return;
+ }
+
+ if (!currentBarcode) {
+ this.error = '璇疯緭鍏ユ垨鎵弿鐗╂枡鏉$爜';
+ return;
+ }
+
+ this.focusBarcodeInput();
+ this.error = '';
+ this.loading = true;
+
+ try {
+ // 璋冪敤API鏌ヨ鐗╂枡淇℃伅
+ const materialData = await this.fetchMaterialData(currentBarcode);
+ if (!materialData || materialData.length === 0) {
+
+
+ return;
+ }
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鐗╂枡缂栫爜鐨勮褰�
+ const exists = this.materials.some(item =>
+ item.barcode === this.trayBarcode
+ );
+ console.log('API:', materialData)
+ if (exists) {
+ this.$message({
+ message: '璇ユ潯鐮佸凡瀛樺湪褰撳墠鎵樼洏鐨勫垪琛ㄤ腑',
+ type: 'warning',
+ duration: 2000
+ });
+
+ } else {
+
+ materialData.forEach(item => {
+
+ // 濡傛灉涓嶅瓨鍦紝娣诲姞鏂扮墿鏂�
+ this.materials.push({
+ ...item,
+ trayCode: this.trayBarcode,
+ locationType: this.form.locationType,
+ locationDesc: this.currentLocationDesc,
+ scanTime: this.formatTime(new Date())
+ });
+ });
+
+ this.$message({
+ message: `鎴愬姛娣诲姞鏉$爜: ${currentBarcode}`,
+ type: 'success',
+ duration: 2000
+ });
+
+ this.fetchStockStatistics();
+ // 娓呯┖鐗╂枡杈撳叆妗嗗苟淇濇寔鑱氱劍
+ this.barcode = '';
+ this.scanCode = ''; // 娓呯┖鎵爜缂撳瓨
+ this.isScanning = false;
+
+ setTimeout(() => {
+ this.focusBarcodeInput();
+ }, 100);
+ }
+ } catch (err) {
+ this.error = err.message || '鏌ヨ鏉$爜淇℃伅澶辫触锛岃閲嶈瘯';
+ this.focusBarcodeInput();
+ setTimeout(() => {
+ // 閫変腑杈撳叆妗嗗唴鐨勯敊璇唴瀹癸紙纭繚focus瀹屾垚鍚庢墽琛岋級
+ const inputEl = this.$refs.barcodeInput?.$el?.querySelector('input');
+ if (inputEl) inputEl.select();
+ }, 100);
+ } finally {
+ this.loading = false;
+ }
+ },
+
+ // API璇锋眰 - 鏇挎崲涓哄疄闄呯殑API璋冪敤
+ async fetchMaterialData(barcode) {
+ try {
+ const response = await http.post('/api/PickingReturn/BarcodeMaterielGroup',
+ {
+ palletCode: this.trayBarcode,
+ orderNo: this.docNo,
+ barcodes: barcode,
+ locationTypeDesc: this.currentLocationDesc,
+ locationType: this.form.locationType, // 娣诲姞浠撳簱鍖哄煙淇℃伅
+ warehouseType: this.form.warehouseType
+ }
+ );
+
+
+ let materialData;
+
+ if (typeof response.data === 'string') {
+
+ try {
+ materialData = JSON.parse(response.data);
+ } catch (e) {
+
+ }
+ } else {
+ // 濡傛灉杩斿洖鐨勬槸JSON瀵硅薄锛岀洿鎺ヤ娇鐢�
+ materialData = response.data;
+ }
+ if (!response.status) {
+ this.error = response.message || '鏌ヨ鏉$爜淇℃伅澶辫触锛岃閲嶈瘯';
+ }
+
+ return materialData;
+
+ } catch (error) {
+ console.error('API璋冪敤澶辫触:', error);
+
+
+ }
+ },
+
+ // 澶勭悊鎵爜鏋緭鍏�
+ handleKeyPress(event) {
+ // 濡傛灉鏄墜鍔ㄨ緭鍏ユā寮忥紝涓嶅鐞嗘壂鐮佹灙閫昏緫
+ if (this.isManualInput) {
+ return;
+ }
+
+ const key = event.key;
+ const currentTime = new Date().getTime();
+
+ // 蹇界暐鐩存帴鎸変笅鐨勫洖杞﹂敭锛堢敱handleBarcodeSubmit澶勭悊锛�
+ if (key === 'Enter') {
+ if (this.scanCode.length > 0) {
+ // 闃绘榛樿鍥炶溅琛屼负锛岄伩鍏嶈〃鍗曟彁浜�
+ event.preventDefault();
+
+ // 鎵爜瀹屾垚锛岃嚜鍔ㄨЕ鍙戞煡璇�
+ this.isScanning = false;
+
+ // 鏍规嵁褰撳墠鎵爜鐩爣璁剧疆鐩稿簲鐨勮緭鍏ユ鍊�
+ if (this.scanTarget === 'tray') {
+ this.trayBarcode = this.scanCode;
+ this.handleTraySubmit();
+ } else if (this.scanTarget === 'material') {
+ this.barcode = this.scanCode;
+ this.handleBarcodeSubmit();
+ }
+ }
+ this.scanCode = '';
+ this.lastKeyTime = null;
+ return;
+ }
+
+ // 鏋勫缓鎵爜鍐呭锛堝揩閫熻繛缁緭鍏ヨ涓烘壂鐮侊級
+ if (this.lastKeyTime && currentTime - this.lastKeyTime < 50) {
+ this.scanCode += key;
+ this.isScanning = true;
+ } else {
+ this.scanCode = key;
+ this.isScanning = true;
+ }
+
+ // 璁剧疆璁℃椂鍣紝濡傛灉涓�娈垫椂闂村唴娌℃湁杈撳叆锛屽垯閲嶇疆鎵弿鐘舵��
+ if (this.scanTimer) {
+ clearTimeout(this.scanTimer);
+ }
+ this.scanTimer = setTimeout(() => {
+ this.isScanning = false;
+ }, 100);
+
+ this.lastKeyTime = currentTime;
+ },
+
+ // 鍒犻櫎鐗╂枡
+ removeMaterial(index) {
+ this.$confirm('纭畾瑕佸垹闄よ繖鏉$墿鏂欒褰曞悧?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ this.materials.splice(index, 1);
+ this.$message({
+ type: 'success',
+ message: '鍒犻櫎鎴愬姛!'
+ });
+ this.fetchStockStatistics();
+
+ }).catch(() => {
+ // 鍙栨秷鍒犻櫎
+ });
+ },
+
+ // 娓呯┖鎵�鏈夌墿鏂�
+ clearAllMaterials() {
+ if (this.materials.length === 0) return;
+
+ this.$confirm('纭畾瑕佹竻绌烘墍鏈夌墿鏂欒褰曞悧?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ this.materials = [];
+ this.$message({
+ type: 'success',
+ message: '宸叉竻绌烘墍鏈夎褰�!'
+ });
+ }).catch(() => {
+ // 鍙栨秷娓呯┖
+ });
+ },
+
+ // 鏍煎紡鍖栨椂闂�
+ formatTime(date) {
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ const seconds = String(date.getSeconds()).padStart(2, '0');
+
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+ }
+ }
+}
+</script>
+
+<style scoped>
+.barcode-scanner-container {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 10px;
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ gap: 8px;
+}
+
+/* 绱у噾甯冨眬鏍峰紡 */
+.compact {
+ margin-bottom: 0;
+}
+
+.compact-form {
+ margin-bottom: 0;
+}
+
+.compact-item {
+ margin-bottom: 0;
+}
+
+.compact-card {
+ margin-bottom: 0;
+}
+
+.compact-card>>>.el-card__body {
+ padding: 12px;
+}
+
+.compact-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 0 !important;
+}
+
+.compact-header>>>.el-card__header {
+ padding: 8px 12px;
+}
+
+.compact-input {
+ margin: 8px 0;
+}
+
+.compact-tips {
+ margin-top: 8px;
+ font-size: 11px;
+}
+
+/* 浠撳簱鍖哄煙閫夋嫨 - 绱у噾 */
+.location-section.compact {
+ margin-bottom: 8px;
+}
+
+.location-section.compact>>>.el-form-item {
+ margin-bottom: 0;
+}
+
+/* 鎵樼洏淇℃伅 - 绱у噾 */
+.tray-info.compact {
+ padding: 6px 10px;
+ margin-bottom: 8px;
+ font-size: 13px;
+}
+
+/* 鎵爜鍖哄煙 - 绱у噾 */
+.input-section.compact {
+ margin-bottom: 8px;
+ flex-shrink: 0;
+}
+
+/* 鐗╂枡鍒楄〃 - 鍥哄畾楂樺害甯︽粴鍔� */
+.material-list.compact {
+ flex: 1;
+ min-height: 0;
+ /* 閲嶈锛氬厑璁竑lex瀛愰」鏀剁缉 */
+ display: flex;
+ flex-direction: column;
+}
+
+.material-list.compact>>>.el-card {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+}
+
+.material-list.compact>>>.el-card__body {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ padding: 0;
+ min-height: 0;
+}
+
+.table-container {
+ flex: 1;
+ min-height: 0;
+ overflow: hidden;
+}
+
+.material-list.compact>>>.el-table {
+ flex: 1;
+}
+
+.material-list.compact>>>.el-table__body-wrapper {
+ overflow-y: auto;
+}
+
+/* 绱у噾鐨勭┖鐘舵�� */
+.empty-state.compact {
+ padding: 20px 0;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.empty-state.compact i {
+ font-size: 36px;
+ margin-bottom: 8px;
+}
+
+.empty-state.compact p {
+ font-size: 13px;
+}
+
+/* 鍏朵粬鍘熸湁鏍峰紡璋冩暣 */
+.page-title {
+ text-align: center;
+ margin-bottom: 15px;
+}
+
+.scan-status {
+ font-size: 12px;
+ color: #67C23A;
+}
+
+.scan-indicator {
+ display: inline-block;
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background-color: #67C23A;
+ margin-right: 5px;
+ animation: pulse 1.5s infinite;
+}
+
+@keyframes pulse {
+ 0% {
+ opacity: 1;
+ }
+
+ 50% {
+ opacity: 0.4;
+ }
+
+ 100% {
+ opacity: 1;
+ }
+}
+
+.input-wrapper {
+ position: relative;
+}
+
+.input-tips {
+ margin-top: 6px;
+ color: #909399;
+}
+
+.warning-text {
+ color: #E6A23C;
+ font-weight: bold;
+}
+
+.loading.compact {
+ text-align: center;
+ margin: 10px 0;
+ padding: 5px;
+}
+
+.loading.compact p {
+ margin-top: 5px;
+ color: #409EFF;
+ font-size: 12px;
+}
+
+.error-message.compact {
+ margin: 5px 0;
+}
+
+.error-message.compact>>>.el-alert {
+ padding: 6px 12px;
+}
+
+.list-actions {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+}
+
+.list-actions>>>.el-tag {
+ height: 24px;
+ line-height: 22px;
+ padding: 0 6px;
+}
+
+.clear-all-btn {
+ margin-left: 8px;
+}
+
+.material-code {
+ font-family: 'Courier New', monospace;
+ font-weight: bold;
+ color: #409EFF;
+}
+
+.location-info {
+ color: #606266;
+ font-weight: normal;
+}
+
+.debug-info {
+ background: #f5f7fa;
+ padding: 8px;
+ border-radius: 4px;
+ margin-top: 8px;
+ font-size: 11px;
+ color: #909399;
+}
+
+.small-button {
+ padding: 6px 8px;
+ font-size: 11px;
+}
+
+/* 杈撳叆妗嗙粍鏍峰紡璋冩暣 */
+.custom-input-group {
+ display: flex;
+ align-items: center;
+ width: 100%;
+ margin: 8px 0;
+ border: 1px solid #DCDFE6;
+ border-radius: 4px;
+ overflow: hidden;
+ background: #fff;
+}
+
+.input-label {
+ padding: 0 12px;
+ background: #F5F7FA;
+ border-right: 1px solid #DCDFE6;
+ color: #606266;
+ font-size: 13px;
+ white-space: nowrap;
+ height: 36px;
+ line-height: 36px;
+ flex-shrink: 0;
+ min-width: 70px;
+ text-align: center;
+}
+
+.input-container {
+ display: flex;
+ flex: 1;
+ align-items: center;
+}
+
+.custom-input {
+ flex: 1;
+}
+
+.custom-input>>>.el-input__inner {
+ border: none;
+ border-radius: 0;
+ height: 36px;
+ line-height: 36px;
+ font-size: 13px;
+}
+
+/* 鍝嶅簲寮忚皟鏁� */
+@media (max-width: 768px) {
+ .barcode-scanner-container {
+ padding: 5px;
+ }
+
+ .custom-input-group {
+ flex-direction: column;
+ border: none;
+ }
+
+ .input-label {
+ width: 100%;
+ border-right: none;
+ border-bottom: 1px solid #DCDFE6;
+ margin-bottom: 5px;
+ }
+
+ .input-container {
+ width: 100%;
+ border: 1px solid #DCDFE6;
+ border-radius: 4px;
+ }
+}
+</style>
\ No newline at end of file
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 ab7d308..3cc1b7d 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"
@@ -24,6 +24,7 @@
<el-link
type="primary"
size="small"
+ v-if="isBatch === 0"
style="float: right; height: 20px"
@click="handleOpenPicking"
>鎷i��</el-link>
@@ -31,11 +32,13 @@
type="primary"
size="small"
style="float: right; height: 20px; margin-right: 10px"
+ v-if="isBatch === 1"
@click="handleOpenBatchPicking"
>鍒嗘壒鎷i��</el-link>
<el-link
type="primary"
size="small"
+ v-if="isBatch === 0"
style="float: right; height: 20px; margin-right: 10px"
@click="outbound"
>鐩存帴鍑哄簱</el-link
@@ -43,6 +46,7 @@
<el-link
type="primary"
size="small"
+ v-if="isBatch === 1"
style="float: right; height: 20px; margin-right: 10px"
@click="outboundbatch"
>鍒嗘壒鍑哄簱</el-link
@@ -133,6 +137,7 @@
data() {
return {
row: null,
+ isBatch :0,
showDetialBox: false,
flag: false,
currentRow: null,
@@ -300,6 +305,8 @@
open(row) {
this.row = row;
this.showDetialBox = true;
+ console.log(this.row);
+ this.isBatch = row.isBatch;
this.getDictionaryData();
this.getData();
},
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/check/ReCheckOrder.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/check/ReCheckOrder.vue"
index 62a8a5c..d6ba787 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/check/ReCheckOrder.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/check/ReCheckOrder.vue"
@@ -5,15 +5,30 @@
*涓氬姟璇峰湪@/extension/widesea_wcs/order/Dt_CheckOrder.js姝ゅ缂栧啓
-->
<template>
- <view-grid ref="grid" :columns="columns" :editFormFields="editFormFields"
+ <view-grid ref="grid" @openPalletDialog="handleOpenPalletDialog" :columns="columns" :editFormFields="editFormFields"
:editFormOptions="editFormOptions" :searchFormFields="searchFormFields" :searchFormOptions="searchFormOptions"
:table="table" :extend="extend">
</view-grid>
+
+ <!-- 2. 缁勭洏寮圭獥锛氱‘淇漰rops鍜屼簨浠剁粦瀹氭纭� -->
+ <PalletDialog
+ v-model:visible="palletVisible"
+ :docNo="currentPalletDocNo"
+ @back-success="handlePalletBackSuccess"
+ ></PalletDialog>
+
</template>
<script>
import extend from "@/extension/check/recheckOrder.js";
+import ViewGrid from '@/components/basic/ViewGrid/ViewGrid.vue';
import { ref, defineComponent } from "vue";
+import PalletDialog from "@/extension/inbound/extend/PickingRetuenPallet.vue";
export default defineComponent({
+ components: {
+ viewGrid: ViewGrid,
+ PalletDialog // 娉ㄥ唽缁勭洏寮圭獥
+
+ },
setup() {
const table = ref({
key: 'id',
@@ -100,7 +115,20 @@
{ field: 'modifier', title: '淇敼浜�', type: 'string', width: 100, align: 'left' },
{ field: 'modifyDate', title: '淇敼鏃ユ湡', type: 'datetime', width: 150, align: 'left', sort: true },
]);
+ // 6. 缁勭洏寮圭獥鑱斿姩锛堟墍鏈夊彉閲忓繀椤昏繑鍥烇級
+ const palletVisible = ref(false);
+ const currentPalletDocNo = ref("");
+ const handleOpenPalletDialog = (docNo) => {
+ console.log('涓荤粍浠舵敹鍒扮粍鐩樹簨浠讹紝鍗曟嵁鍙凤細', docNo);
+ currentPalletDocNo.value = docNo;
+ palletVisible.value = true;
+ };
+
+ const handlePalletBackSuccess = () => {
+ console.log('缁勭洏鍥炰紶鎴愬姛锛屽埛鏂拌〃鏍�');
+ grid.value?.refresh(); // 姝ゆ椂gridRef宸叉寕杞斤紝鍙皟鐢ㄦ柟娉�
+ };
return {
table,
extend,
@@ -108,7 +136,12 @@
editFormOptions,
searchFormFields,
searchFormOptions,
- columns
+ columns,
+ PalletDialog, // 寮圭獥缁勪欢锛堟棤闇�杩斿洖锛屾敞鍐屽嵆鍙紝浣嗗彉閲忛渶杩斿洖锛�
+ palletVisible,
+ currentPalletDocNo,
+ handleOpenPalletDialog,
+ handlePalletBackSuccess
};
},
});
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 e4918ee..8649eec 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"
@@ -550,8 +550,8 @@
this.$message.success('鎷i�夌‘璁ゆ垚鍔�');
this.scanData.barcode = '';
await this.loadPalletData();
- if(res.data && res.data.splitResults && res.data.splitResults.length>0){
- this.$refs.childs.open(res.data.splitResults);
+ if(res.data && res.data && res.data.length>0){
+ this.$refs.childs.open(res.data);
}
this.$nextTick(() => {
this.$refs.barcodeInput.focus();
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/StockEnum/StockStatusEmun.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/StockEnum/StockStatusEmun.cs"
index 65e71f1..804117d 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/StockEnum/StockStatusEmun.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/StockEnum/StockStatusEmun.cs"
@@ -104,10 +104,15 @@
[Description("宸叉竻鐞�")]
宸叉竻鐞� = 33,
+ [Description("杩囨湡")]
+ 杩囨湡 =98,
+
[Description("缁勭洏鎾ら攢")]
缁勭洏鎾ら攢 = 99,
[Description("鍏ュ簱鎾ら攢")]
鍏ュ簱鎾ら攢 = 199,
+
+
}
}
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_IOutboundService/IOutboundPickingService.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_IOutboundService/IOutboundPickingService.cs"
index 56b1b45..dda5c65 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_IOutboundService/IOutboundPickingService.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_IOutboundService/IOutboundPickingService.cs"
@@ -6,6 +6,7 @@
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
+using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Outbound;
using WIDESEA_Model.Models;
@@ -43,9 +44,12 @@
/// <returns></returns>
WebResponseContent DeleteBarcode(NoStockOutModel noStockOut);
- WebResponseContent NoStockOutSubmit(NoStockOutSubmit noStockOutSubmit);
+ Task<WebResponseContent> NoStockOutSubmit(NoStockOutSubmit noStockOutSubmit);
Task<WebResponseContent> RemoveEmptyPallet(string orderNo, string palletCode);
+
+ WebResponseContent UnPalletQuantity(string orderNo);
+ WebResponseContent BarcodeMaterielGroup(BarcodeMaterielGroupDTO materielGroupDTO);
}
}
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/Stock/Dt_StockInfoDetail.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/Stock/Dt_StockInfoDetail.cs"
index cc19acf..25d54e5 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/Stock/Dt_StockInfoDetail.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/Stock/Dt_StockInfoDetail.cs"
@@ -132,6 +132,7 @@
public string BarcodeUnit { get; set; }
+ public DateTime? ValidDate { get; set; }
/// <summary>
/// 澶囨敞
/// </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_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 54eab6d..d2b6954 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"
@@ -10,9 +10,12 @@
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
+using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
+using WIDESEA_Core.Enums;
+using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Outbound;
using WIDESEA_IAllocateService;
using WIDESEA_IBasicService;
@@ -217,7 +220,7 @@
.Where(x => x.OrderNo == orderNo &&
x.PalletCode == palletCode &&
x.CurrentBarcode == barcode
- //&& x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�
+ //&& x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�
)
.FirstAsync();
@@ -241,166 +244,6 @@
#endregion
- #region 鍙栬蛋绌虹閫昏緫
-
-
-
- /// <summary>
- /// 鍙栬蛋绌虹 - 娓呯悊宸插畬鎴愭嫞閫夌殑鎵樼洏鏁版嵁
- /// </summary>
- public async Task<WebResponseContent> RemoveEmptyPallet(string orderNo, string palletCode)
- {
- try
- {
- _unitOfWorkManage.BeginTran();
-
- // 楠岃瘉鎵樼洏鏄惁鍙互鍙栬蛋锛堝繀椤诲叏閮ㄥ畬鎴愭嫞閫夛級
- var validationResult = await ValidateEmptyPalletRemoval(orderNo, palletCode);
- if (!validationResult.IsValid)
- return WebResponseContent.Instance.Error(validationResult.ErrorMessage);
-
- var completedLocks = validationResult.Data;
-
- // 娓呯悊閿佸畾璁板綍锛堟爣璁颁负宸插畬鎴愶級
- await CleanupCompletedLocks(completedLocks);
-
- // 鏇存柊鐩稿叧璁㈠崟鐘舵��
- await UpdateOrderStatusAfterPalletRemoval(orderNo);
-
- // 璁板綍鎿嶄綔鍘嗗彶
- // await RecordEmptyPalletRemoval(orderNo, palletCode, completedLocks);
-
- _unitOfWorkManage.CommitTran();
-
- return WebResponseContent.Instance.OK("鍙栬蛋绌虹鎴愬姛");
- }
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- _logger.LogError($"鍙栬蛋绌虹澶辫触 - OrderNo: {orderNo}, PalletCode: {palletCode}, Error: {ex.Message}");
- return WebResponseContent.Instance.Error($"鍙栬蛋绌虹澶辫触锛歿ex.Message}");
- }
- }
-
- /// <summary>
- /// 楠岃瘉绌虹鍙栬蛋鏉′欢
- /// </summary>
- private async Task<ValidationResult<List<Dt_OutStockLockInfo>>> ValidateEmptyPalletRemoval(string orderNo, string palletCode)
- {
- // 鑾峰彇鎵樼洏鐨勬墍鏈夐攣瀹氳褰�
- var lockInfos = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
- .Where(x => x.OrderNo == orderNo && x.PalletCode == palletCode)
- .ToListAsync();
-
- if (!lockInfos.Any())
- return ValidationResult<List<Dt_OutStockLockInfo>>.Error("璇ユ墭鐩樻病鏈夐攣瀹氳褰�");
-
- // 妫�鏌ユ槸鍚︽湁鏈畬鎴愮殑閿佸畾璁板綍
- var unfinishedLocks = lockInfos.Where(x =>
- x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓� ||
- x.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�).ToList();
-
- if (unfinishedLocks.Any())
- {
- var unfinishedCount = unfinishedLocks.Count;
- var unfinishedQty = unfinishedLocks.Sum(x => x.AssignQuantity - x.PickedQty);
- return ValidationResult<List<Dt_OutStockLockInfo>>.Error(
- $"鎵樼洏杩樻湁{unfinishedCount}鏉℃湭瀹屾垚璁板綍锛屽墿浣欐暟閲弡unfinishedQty}锛屼笉鑳藉彇璧扮┖绠�");
- }
-
- // 鑾峰彇宸插畬鎴愮殑閿佸畾璁板綍
- var completedLocks = lockInfos.Where(x =>
- x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�).ToList();
-
- if (!completedLocks.Any())
- return ValidationResult<List<Dt_OutStockLockInfo>>.Error("璇ユ墭鐩樻病鏈夊凡瀹屾垚鎷i�夌殑璁板綍");
-
- return ValidationResult<List<Dt_OutStockLockInfo>>.Success(completedLocks);
- }
-
- /// <summary>
- /// 娓呯悊宸插畬鎴愮殑閿佸畾璁板綍
- /// </summary>
- private async Task CleanupCompletedLocks(List<Dt_OutStockLockInfo> completedLocks)
- {
- foreach (var lockInfo in completedLocks)
- {
- // 鏍囪閿佸畾璁板綍涓哄凡鍙栬蛋
- lockInfo.Status = (int)OutLockStockStatusEnum.宸插彇璧�;
- lockInfo.Operator = App.User.UserName;
- await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
-
- // 娓呯悊瀵瑰簲鐨勫簱瀛樿褰曠姸鎬�
- await CleanupStockInfo(lockInfo);
- }
- }
-
- /// <summary>
- /// 娓呯悊搴撳瓨淇℃伅
- /// </summary>
- private async Task CleanupStockInfo(Dt_OutStockLockInfo lockInfo)
- {
- var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
- .FirstAsync(x => x.Barcode == lockInfo.CurrentBarcode && x.StockId == lockInfo.StockId);
-
- if (stockDetail != null && stockDetail.Status == (int)StockStatusEmun.鍑哄簱瀹屾垚)
- {
- stockDetail.Status = (int)StockStatusEmun.宸叉竻鐞�;
- await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
- }
- }
-
-
- /// <summary>
- /// 鏇存柊璁㈠崟鐘舵��
- /// </summary>
- private async Task UpdateOrderStatusAfterPalletRemoval(string orderNo)
- {
- // 妫�鏌ヨ鍗曟槸鍚︽墍鏈夋墭鐩橀兘宸插畬鎴�
- var allLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
- .Where(x => x.OrderNo == orderNo)
- .ToListAsync();
-
- var unfinishedPallets = allLocks
- .GroupBy(x => x.PalletCode)
- .Where(g => g.Any(x => x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓� ||
- x.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�))
- .ToList();
-
- // 濡傛灉娌℃湁鏈畬鎴愮殑鎵樼洏锛屾洿鏂拌鍗曠姸鎬佷负鍑哄簱瀹屾垚
- if (!unfinishedPallets.Any())
- {
- await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
- .SetColumns(x => new Dt_OutboundOrder
- {
- OrderStatus = (int)OutOrderStatusEnum.鍑哄簱瀹屾垚,
- })
- .Where(x => x.OrderNo == orderNo)
- .ExecuteCommandAsync();
- }
- }
-
- /// <summary>
- /// 璁板綍绌虹鍙栬蛋鍘嗗彶
- /// </summary>
- private async Task RecordEmptyPalletRemoval(string orderNo, string palletCode, List<Dt_OutStockLockInfo> completedLocks)
- {
- var removalRecord = new Dt_EmptyPalletRemoval
- {
- OrderNo = orderNo,
- PalletCode = palletCode,
- RemovalTime = DateTime.Now,
- Operator = App.User.UserName,
- CompletedItemsCount = completedLocks.Count,
- TotalPickedQuantity = completedLocks.Sum(x => x.PickedQty)
- };
-
- await Db.Insertable(removalRecord).ExecuteCommandAsync();
- }
-
- #endregion
-
-
#region 鍒嗘壒鍒嗘嫞
/// <summary>
@@ -433,7 +276,7 @@
(lockInfo, orderDetail, stockDetail, batch) = refreshedValidation.Data;
- // 閲嶈淇锛氳嚜鍔ㄦ媶鍖呭悗锛岀珛鍗虫墽琛屽師鏉$爜鐨勫垎鎷�
+
var actualPickedQty = lockInfo.AssignQuantity;
var pickingResult = await ExecutePickingLogic(lockInfo, orderDetail, stockDetail, actualPickedQty);
@@ -445,15 +288,7 @@
_unitOfWorkManage.CommitTran();
- return WebResponseContent.Instance.OK("鑷姩鎷嗗寘骞跺垎鎷f垚鍔�", new
- {
- AutoSplitted = true,
- NewBarcode = autoSplitResult.NewBarcode,
- OriginalBarcode = barcode,
- SplitQuantity = autoSplitResult.SplitQuantity,
- PickedQuantity = actualPickedQty,
- MaterialCode = lockInfo.MaterielCode
- });
+ return WebResponseContent.Instance.OK("鑷姩鎷嗗寘骞跺垎鎷f垚鍔�", autoSplitResult);
}
// 姝e父鍒嗘嫞娴佺▼锛堜笉闇�瑕佽嚜鍔ㄦ媶鍖咃級
@@ -529,9 +364,159 @@
}
#endregion
- #region 鎵嬪姩鎷嗗寘
- #region 鎵嬪姩鎷嗗寘鐩稿叧鏂规硶
+ #region 鍙栬蛋绌虹閫昏緫
+
+
+
+ /// <summary>
+ /// 楠岃瘉绌虹鍙栬蛋鏉′欢
+ /// </summary>
+ private async Task<ValidationResult<List<Dt_OutStockLockInfo>>> ValidateEmptyPalletRemoval(string orderNo, string palletCode)
+ {
+ // 鑾峰彇鎵樼洏鐨勬墍鏈夐攣瀹氳褰�
+ var lockInfos = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == orderNo && x.PalletCode == palletCode)
+ .ToListAsync();
+
+ if (!lockInfos.Any())
+ return ValidationResult<List<Dt_OutStockLockInfo>>.Error("璇ユ墭鐩樻病鏈夐攣瀹氳褰�");
+
+ // 妫�鏌ユ槸鍚︽湁鏈畬鎴愮殑閿佸畾璁板綍
+ var unfinishedLocks = lockInfos.Where(x =>
+ x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓� ||
+ x.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�).ToList();
+
+ if (unfinishedLocks.Any())
+ {
+ var unfinishedCount = unfinishedLocks.Count;
+ var unfinishedQty = unfinishedLocks.Sum(x => x.AssignQuantity - x.PickedQty);
+ return ValidationResult<List<Dt_OutStockLockInfo>>.Error(
+ $"鎵樼洏杩樻湁{unfinishedCount}鏉℃湭瀹屾垚璁板綍锛屽墿浣欐暟閲弡unfinishedQty}锛屼笉鑳藉彇璧扮┖绠�");
+ }
+
+ // 鑾峰彇宸插畬鎴愮殑閿佸畾璁板綍
+ var completedLocks = lockInfos.Where(x =>
+ x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�).ToList();
+
+ if (!completedLocks.Any())
+ return ValidationResult<List<Dt_OutStockLockInfo>>.Error("璇ユ墭鐩樻病鏈夊凡瀹屾垚鎷i�夌殑璁板綍");
+
+ return ValidationResult<List<Dt_OutStockLockInfo>>.Success(completedLocks);
+ }
+
+ /// <summary>
+ /// 娓呯悊宸插畬鎴愮殑閿佸畾璁板綍
+ /// </summary>
+ private async Task CleanupCompletedLocks(List<Dt_OutStockLockInfo> completedLocks)
+ {
+ foreach (var lockInfo in completedLocks)
+ {
+ // 鏍囪閿佸畾璁板綍涓哄凡鍙栬蛋
+ lockInfo.Status = (int)OutLockStockStatusEnum.宸插彇璧�;
+ lockInfo.Operator = App.User.UserName;
+ await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
+
+ // 娓呯悊瀵瑰簲鐨勫簱瀛樿褰曠姸鎬�
+ await CleanupStockInfo(lockInfo);
+ }
+ }
+
+ /// <summary>
+ /// 娓呯悊搴撳瓨淇℃伅
+ /// </summary>
+ private async Task CleanupStockInfo(Dt_OutStockLockInfo lockInfo)
+ {
+ var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .FirstAsync(x => x.Barcode == lockInfo.CurrentBarcode && x.StockId == lockInfo.StockId);
+
+ if (stockDetail != null && stockDetail.Status == (int)StockStatusEmun.鍑哄簱瀹屾垚)
+ {
+ stockDetail.Status = (int)StockStatusEmun.宸叉竻鐞�;
+ await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
+ }
+ }
+
+
+ /// <summary>
+ /// 鏇存柊璁㈠崟鐘舵��
+ /// </summary>
+ private async Task UpdateOrderStatusAfterPalletRemoval(string orderNo)
+ {
+ // 妫�鏌ヨ鍗曟槸鍚︽墍鏈夋墭鐩橀兘宸插畬鎴�
+ var allLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == orderNo)
+ .ToListAsync();
+
+ var unfinishedPallets = allLocks
+ .GroupBy(x => x.PalletCode)
+ .Where(g => g.Any(x => x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓� ||
+ x.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�))
+ .ToList();
+
+ // 濡傛灉娌℃湁鏈畬鎴愮殑鎵樼洏锛屾洿鏂拌鍗曠姸鎬佷负鍑哄簱瀹屾垚
+ if (!unfinishedPallets.Any())
+ {
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(x => new Dt_OutboundOrder
+ {
+ OrderStatus = (int)OutOrderStatusEnum.鍑哄簱瀹屾垚,
+ })
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
+ }
+
+ /// <summary>
+ /// 璁板綍绌虹鍙栬蛋鍘嗗彶
+ /// </summary>
+ private async Task RecordEmptyPalletRemoval(string orderNo, string palletCode, List<Dt_OutStockLockInfo> completedLocks)
+ {
+ var removalRecord = new Dt_EmptyPalletRemoval
+ {
+ OrderNo = orderNo,
+ PalletCode = palletCode,
+ RemovalTime = DateTime.Now,
+ Operator = App.User.UserName,
+ CompletedItemsCount = completedLocks.Count,
+ TotalPickedQuantity = completedLocks.Sum(x => x.PickedQty)
+ };
+
+ await Db.Insertable(removalRecord).ExecuteCommandAsync();
+ }
+
+ #endregion
+
+ private List<SplitResult> CreateSplitResults(Dt_OutStockLockInfo lockInfo, decimal splitQty, decimal remainQty, string newBarcode, string originalBarcode)
+ {
+ return new List<SplitResult>
+ {
+ new SplitResult
+ {
+ materialCode = lockInfo.MaterielCode,
+ supplierCode = lockInfo.SupplyCode,
+ quantityTotal = splitQty.ToString("F2"),
+ batchNumber = newBarcode,
+ batch = lockInfo.BatchNo,
+ factory = lockInfo.FactoryArea,
+ date = DateTime.Now.ToString("yyyy-MM-dd"),
+ },
+ new SplitResult
+ {
+ materialCode = lockInfo.MaterielCode,
+ supplierCode = lockInfo.SupplyCode,
+ quantityTotal = remainQty.ToString("F2"),
+ batchNumber = originalBarcode,
+ batch = lockInfo.BatchNo,
+ factory = lockInfo.FactoryArea,
+ date = DateTime.Now.ToString("yyyy-MM-dd"),
+ }
+ };
+ }
+
+
+
+ #region 鎵嬪姩鎷嗗寘
/// <summary>
/// 鎵嬪姩鎷嗗寘
@@ -554,12 +539,7 @@
_unitOfWorkManage.CommitTran();
- return WebResponseContent.Instance.OK("鎵嬪姩鎷嗗寘鎴愬姛", new
- {
- NewBarcode = splitResult.NewBarcode,
- OriginalBarcode = originalBarcode,
- SplitQuantity = splitQuantity
- });
+ return WebResponseContent.Instance.OK("鎵嬪姩鎷嗗寘鎴愬姛", splitResult);
}
catch (Exception ex)
{
@@ -676,7 +656,7 @@
/// <summary>
/// 鎵ц鎵嬪姩鎷嗗寘閫昏緫 - 澧炲己鍒嗛厤鏁伴噺鎺у埗
/// </summary>
- private async Task<SplitResultDto> ExecuteManualSplitLogic(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail,
+ private async Task<List<SplitResult>> ExecuteManualSplitLogic(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail,
decimal splitQuantity, string palletCode)
{
_logger.LogInformation($"寮�濮嬫墽琛屾墜鍔ㄦ媶鍖呴�昏緫 - 鍘熸潯鐮�: {stockDetail.Barcode}, 鎷嗗寘鏁伴噺: {splitQuantity}");
@@ -700,8 +680,12 @@
// 璁板綍鎷嗗寘鍓嶇殑鍒嗛厤鏁伴噺
decimal originalAssignQtyBefore = lockInfo.AssignQuantity;
decimal originalOrderQtyBefore = lockInfo.OrderQuantity;
-
- // 1. 鍒涘缓鏂板簱瀛樻槑缁�
+ decimal remainQty = originalAssignQtyBefore - splitQuantity;
+ if (remainQty < 0)
+ {
+ throw new InvalidOperationException($"鎷嗗寘鍚庡墿浣欐暟閲忎负璐熸暟锛屽師鍒嗛厤鏁伴噺: {originalAssignQtyBefore}, 鎷嗗寘鏁伴噺: {splitQuantity}");
+ }
+ // 鍒涘缓鏂板簱瀛樻槑缁�
var newStockDetail = new Dt_StockInfoDetail
{
StockId = stockDetail.StockId,
@@ -717,18 +701,23 @@
BarcodeQty = stockDetail.BarcodeQty,
BarcodeUnit = stockDetail.BarcodeUnit,
BusinessType = stockDetail.BusinessType,
- InboundOrderRowNo = stockDetail.InboundOrderRowNo,
+ InboundOrderRowNo = stockDetail.InboundOrderRowNo,
};
await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
_logger.LogInformation($"鍒涘缓鏂板簱瀛樻槑缁� - 鏉$爜: {newBarcode}, 搴撳瓨鏁伴噺: {splitQuantity}");
- // 2. 鏇存柊鍘熷簱瀛樻槑缁�
+ // 鏇存柊鍘熷簱瀛樻槑缁�
decimal originalStockQtyBefore = stockDetail.StockQuantity;
stockDetail.StockQuantity -= splitQuantity;
+ if (stockDetail.StockQuantity < 0)
+ {
+ stockDetail.StockQuantity = 0;
+ _logger.LogWarning($"鍘熷簱瀛樻暟閲忓嚭鐜拌礋鏁帮紝閲嶇疆涓�0");
+ }
await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
_logger.LogInformation($"鏇存柊鍘熷簱瀛樻槑缁� - 搴撳瓨鏁伴噺浠� {originalStockQtyBefore} 鍑忓皯鍒� {stockDetail.StockQuantity}");
- // 3. 鍒涘缓鏂伴攣瀹氫俊鎭�
+ // 鍒涘缓鏂伴攣瀹氫俊鎭�
var newLockInfo = new Dt_OutStockLockInfo
{
OrderNo = lockInfo.OrderNo,
@@ -755,35 +744,35 @@
lineNo = lockInfo.lineNo,
WarehouseCode = lockInfo.WarehouseCode,
BarcodeQty = lockInfo.BarcodeQty,
- BarcodeUnit = lockInfo.BarcodeUnit,
+ BarcodeUnit = lockInfo.BarcodeUnit,
};
await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync();
_logger.LogInformation($"鍒涘缓鏂伴攣瀹氫俊鎭� - 鏉$爜: {newBarcode}, 鍒嗛厤鏁伴噺: {splitQuantity}");
- // 4. 鏇存柊鍘熼攣瀹氫俊鎭�
- lockInfo.AssignQuantity -= splitQuantity;
- lockInfo.OrderQuantity -= splitQuantity;
+ // 鏇存柊鍘熼攣瀹氫俊鎭�
+ lockInfo.AssignQuantity = remainQty;
+ lockInfo.OrderQuantity = remainQty;
_logger.LogInformation($"鏇存柊鍘熼攣瀹氫俊鎭� - 鍒嗛厤鏁伴噺浠� {originalAssignQtyBefore} 鍑忓皯鍒� {lockInfo.AssignQuantity}");
_logger.LogInformation($"鏇存柊鍘熼攣瀹氫俊鎭� - 璁㈠崟鏁伴噺浠� {originalOrderQtyBefore} 鍑忓皯鍒� {lockInfo.OrderQuantity}");
await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
- // 閲嶈淇锛氭墜鍔ㄦ媶鍖呬笉浼氭敼鍙樿鍗曟槑缁嗙殑鍒嗛厤鏁伴噺锛屽洜涓烘�诲垎閰嶆暟閲忎笉鍙�
- // 鍙槸浠庝竴涓攣瀹氫俊鎭浆绉诲埌鍙︿竴涓攣瀹氫俊鎭�
+
_logger.LogInformation($"璁㈠崟鏄庣粏鍒嗛厤鏁伴噺淇濇寔涓嶅彉 - 宸插垎閰嶆暟閲�: {orderDetail.AllocatedQuantity}");
- // 5. 璁板綍鎷嗗寘鍘嗗彶
+ // 璁板綍鎷嗗寘鍘嗗彶
await RecordSplitHistory(lockInfo, stockDetail, splitQuantity, newBarcode, false);
+
+ // 鍒涘缓鎷嗗寘缁撴灉鍒楄〃
+ var splitResults = CreateSplitResults(lockInfo, splitQuantity, remainQty, newBarcode, stockDetail.Barcode);
_logger.LogInformation($"鎵嬪姩鎷嗗寘閫昏緫鎵ц瀹屾垚");
- return new SplitResultDto { NewBarcode = newBarcode };
+ return splitResults;
}
-
- #endregion
-
+
#endregion
@@ -848,7 +837,7 @@
decimal originalAssignQtyBefore = originalLockInfo.AssignQuantity;
decimal originalOrderQtyBefore = originalLockInfo.OrderQuantity;
- // 閲嶈淇锛氭仮澶嶅垎閰嶆暟閲忓拰璁㈠崟鏁伴噺
+
originalLockInfo.AssignQuantity += splitRecord.SplitQty;
originalLockInfo.OrderQuantity += splitRecord.SplitQty;
@@ -885,17 +874,20 @@
await _stockInfoDetailService.Db.Updateable(originalStock).ExecuteCommandAsync();
}
- // 鍒犻櫎鏂伴攣瀹氫俊鎭�
- _logger.LogInformation($"鍒犻櫎鏂伴攣瀹氫俊鎭� - 鏉$爜: {newLockInfo.CurrentBarcode}, 鍒嗛厤鏁伴噺: {newLockInfo.AssignQuantity}");
- await _outStockLockInfoService.Db.Deleteable<Dt_OutStockLockInfo>()
- .Where(x => x.Id == newLockInfo.Id)
- .ExecuteCommandAsync();
+ if (newLockInfo != null)
+ {
+ // 鍒犻櫎鏂伴攣瀹氫俊鎭�
+ _logger.LogInformation($"鍒犻櫎鏂伴攣瀹氫俊鎭� - 鏉$爜: {newLockInfo?.CurrentBarcode}, 鍒嗛厤鏁伴噺: {newLockInfo?.AssignQuantity}");
+ await _outStockLockInfoService.Db.Deleteable<Dt_OutStockLockInfo>()
+ .Where(x => x.Id == newLockInfo.Id)
+ .ExecuteCommandAsync();
- // 鍒犻櫎鏂板簱瀛樻槑缁�
- _logger.LogInformation($"鍒犻櫎鏂板簱瀛樻槑缁� - 鏉$爜: {newStockDetail.Barcode}, 搴撳瓨鏁伴噺: {newStockDetail.StockQuantity}");
- await _stockInfoDetailService.Db.Deleteable<Dt_StockInfoDetail>()
- .Where(x => x.Barcode == newLockInfo.CurrentBarcode)
- .ExecuteCommandAsync();
+ // 鍒犻櫎鏂板簱瀛樻槑缁�
+ _logger.LogInformation($"鍒犻櫎鏂板簱瀛樻槑缁� - 鏉$爜: {newStockDetail.Barcode}, 搴撳瓨鏁伴噺: {newStockDetail.StockQuantity}");
+ await _stockInfoDetailService.Db.Deleteable<Dt_StockInfoDetail>()
+ .Where(x => x.Barcode == newLockInfo.CurrentBarcode)
+ .ExecuteCommandAsync();
+ }
// 鏍囪鎷嗗寘璁板綍涓哄凡鎾ら攢
splitRecord.IsReverted = true;
@@ -1108,7 +1100,7 @@
return WebResponseContent.Instance.Error("鑾峰彇鏉$爜鐘舵�佸け璐�");
}
}
- /// <summary>
+ /// <summary>
/// 鑾峰彇鎿嶄綔寤鸿
/// </summary>
private List<string> GetOperationSuggestions(BarcodeStatusInfoDto statusInfo)
@@ -1284,7 +1276,7 @@
NewBarcode = x.NewBarcode,
SplitQuantity = x.SplitQty,
Operator = x.Operator,
- IsReverted = x.IsReverted ,
+ IsReverted = x.IsReverted,
IsAutoSplit = x.IsAutoSplit
}).ToList()
};
@@ -1374,61 +1366,708 @@
#endregion
-
- #region 鍒嗘壒鍥炲簱
+ #region 缁熶竴鍥炲簱閫昏緫
+ private async Task<Dt_Task> GetCurrentTask(string orderNo, string palletCode)
+ {
+ // 鍏堝皾璇曢�氳繃璁㈠崟鍙峰拰鎵樼洏鍙锋煡鎵句换鍔�
+ var task = await _taskRepository.Db.Queryable<Dt_Task>()
+ .Where(x => x.OrderNo == orderNo && x.PalletCode == palletCode)
+ .FirstAsync();
+
+ if (task == null)
+ {
+ // 濡傛灉鎵句笉鍒帮紝鍐嶉�氳繃鎵樼洏鍙锋煡鎵�
+ task = await _taskRepository.Db.Queryable<Dt_Task>()
+ .Where(x => x.PalletCode == palletCode)
+ .FirstAsync();
+ }
+
+ return task;
+ }
+ private async Task<PalletStatusAnalysis> AnalyzePalletStatus(string orderNo, string palletCode, int stockId)
+ {
+ var result = new PalletStatusAnalysis
+ {
+ OrderNo = orderNo,
+ PalletCode = palletCode,
+ StockId = stockId
+ };
+
+ // 鍒嗘瀽鏈垎鎷g殑鍑哄簱閿佸畾璁板綍
+ var remainingLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(it => it.OrderNo == orderNo &&
+ it.PalletCode == palletCode &&
+ it.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�)
+ .ToListAsync();
+
+ if (remainingLocks.Any())
+ {
+ result.HasRemainingLocks = true;
+ result.RemainingLocks = remainingLocks;
+ result.RemainingLocksReturnQty = remainingLocks.Sum(x => x.AssignQuantity - x.PickedQty);
+ _logger.LogInformation($"鍙戠幇{remainingLocks.Count}鏉℃湭鍒嗘嫞閿佸畾璁板綍锛屾�绘暟閲�: {result.RemainingLocksReturnQty}");
+ }
+
+ // 鍒嗘瀽鎵樼洏涓婄殑搴撳瓨璐х墿
+ var palletStockGoods = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(it => it.StockId == stockId &&
+ (it.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt() ||
+ it.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() ||
+ it.Status == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()))
+ .Where(it => it.StockQuantity > 0)
+ .ToListAsync();
+
+ if (palletStockGoods.Any())
+ {
+ result.HasPalletStockGoods = true;
+ result.PalletStockGoods = palletStockGoods;
+ result.PalletStockReturnQty = palletStockGoods.Sum(x => x.StockQuantity);
+ _logger.LogInformation($"鍙戠幇{palletStockGoods.Count}涓簱瀛樿揣鐗╋紝鎬绘暟閲�: {result.PalletStockReturnQty}");
+
+ // 璁板綍璇︾粏鐘舵�佸垎甯�
+ var statusGroups = palletStockGoods.GroupBy(x => x.Status);
+ foreach (var group in statusGroups)
+ {
+ _logger.LogInformation($"搴撳瓨鐘舵�亄group.Key}: {group.Count()}涓揣鐗╋紝鏁伴噺: {group.Sum(x => x.StockQuantity)}");
+ }
+ }
+
+ //鍒嗘瀽鎷嗗寘璁板綍
+ var splitRecords = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
+ .Where(it => it.OrderNo == orderNo &&
+ it.PalletCode == palletCode &&
+ !it.IsReverted && it.Status != (int)SplitPackageStatusEnum.宸叉嫞閫� &&
+ it.Status != (int)SplitPackageStatusEnum.宸插洖搴�)
+ .ToListAsync();
+
+ if (splitRecords.Any())
+ {
+ result.HasSplitRecords = true;
+ result.SplitRecords = splitRecords;
+ result.SplitReturnQty = await CalculateSplitReturnQuantity(splitRecords, stockId);
+
+ _logger.LogInformation($"鍙戠幇{splitRecords.Count}鏉℃湭鎷i�夋媶鍖呰褰曪紝鎬绘暟閲�: {result.SplitReturnQty}");
+ }
+
+ // 4. 璁$畻鎬诲洖搴撴暟閲忓拰绌烘墭鐩樼姸鎬�
+ result.TotalReturnQty = result.RemainingLocksReturnQty + result.PalletStockReturnQty + result.SplitReturnQty;
+ result.HasItemsToReturn = result.TotalReturnQty > 0;
+ result.IsEmptyPallet = !result.HasItemsToReturn;
+
+ // 5. 妫�鏌ユ槸鍚︽湁杩涜涓殑浠诲姟
+ result.HasActiveTasks = await _taskRepository.Db.Queryable<Dt_Task>()
+ .Where(x => x.OrderNo == orderNo && x.TaskType == TaskTypeEnum.InPick.ObjToInt() &&
+ x.PalletCode == palletCode &&
+ x.TaskStatus == (int)TaskStatusEnum.New)
+ .AnyAsync();
+
+ _logger.LogInformation($"鎵樼洏鐘舵�佸垎鏋愬畬鎴� - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}, " +
+ $"鎬诲洖搴撴暟閲�: {result.TotalReturnQty}, 鏄惁绌烘墭鐩�: {result.IsEmptyPallet}, " +
+ $"鏈夎繘琛屼腑浠诲姟: {result.HasActiveTasks}");
+
+ return result;
+ }
+ private async Task<decimal> CalculateSplitReturnQuantity(List<Dt_SplitPackageRecord> splitRecords, int stockId)
+ {
+ decimal totalQty = 0;
+ var processedBarcodes = new HashSet<string>();
+
+ foreach (var splitRecord in splitRecords)
+ {
+ if (splitRecord.Status != (int)SplitPackageStatusEnum.宸叉挙閿�)
+ continue;
+ // 妫�鏌ュ師鏉$爜
+ if (!processedBarcodes.Contains(splitRecord.OriginalBarcode))
+ {
+ var originalStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(it => it.Barcode == splitRecord.OriginalBarcode && it.StockId == stockId &&
+ it.Status != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+ .FirstAsync();
+
+ if (originalStock != null && originalStock.StockQuantity > 0)
+ {
+ totalQty += originalStock.StockQuantity;
+ processedBarcodes.Add(splitRecord.OriginalBarcode);
+ }
+ }
+
+ // 妫�鏌ユ柊鏉$爜
+ if (!processedBarcodes.Contains(splitRecord.NewBarcode))
+ {
+ var newStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(it => it.Barcode == splitRecord.NewBarcode && it.StockId == stockId && it.Status != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+ .FirstAsync();
+
+ if (newStock != null && newStock.StockQuantity > 0)
+ {
+ totalQty += newStock.StockQuantity;
+ processedBarcodes.Add(splitRecord.NewBarcode);
+ }
+ }
+ }
+
+ return totalQty;
+ }
/// <summary>
- /// 鍒嗘壒鍥炲簱 - 閲婃斁鏈嫞閫夌殑搴撳瓨
+ /// 缁熶竴鍥炲簱鏂规硶 - 澶勭悊鎵樼洏涓婃墍鏈夊墿浣欒揣鐗�
/// </summary>
- public async Task<WebResponseContent> BatchReturnStock(string orderNo, string palletCode)
+ public async Task<WebResponseContent> ExecutePalletReturn(string orderNo, string palletCode, string returnReason = "鍒嗘壒鍥炲簱")
{
try
{
_unitOfWorkManage.BeginTran();
- // 鏌ユ壘鎵樼洏涓婃湭瀹屾垚鐨勯攣瀹氳褰曪紙鍙鐞嗗嚭搴撲腑鐨勮褰曪級
- var unfinishedLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
- .Where(x => x.OrderNo == orderNo &&
- x.PalletCode == palletCode &&
- x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�)
- .ToListAsync();
+ if (string.IsNullOrEmpty(orderNo) || string.IsNullOrEmpty(palletCode))
+ return WebResponseContent.Instance.Error("璁㈠崟鍙峰拰鎵樼洏鐮佷笉鑳戒负绌�");
- if (!unfinishedLocks.Any())
- return WebResponseContent.Instance.Error("璇ユ墭鐩樻病鏈夋湭瀹屾垚鐨勯攣瀹氳褰�");
+ // 鑾峰彇搴撳瓨淇℃伅
+ var stockInfo = await _stockInfoService.Db.Queryable<Dt_StockInfo>().FirstAsync(x => x.PalletCode == palletCode);
+ if (stockInfo == null)
+ return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩� {palletCode} 瀵瑰簲鐨勫簱瀛樹俊鎭�");
- // 鎸夊嚭搴撴壒娆″垎缁勫鐞�
- var batchGroups = unfinishedLocks.GroupBy(x => x.OutboundBatchNo); // 浣跨敤 OutboundBatchNo
+ var task = await GetCurrentTask(orderNo, palletCode);
+ if (task == null)
+ return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟淇℃伅");
- foreach (var batchGroup in batchGroups)
+ // 鍒嗘瀽鎵樼洏鐘舵��
+ var statusAnalysis = await AnalyzePalletStatus(orderNo, palletCode, stockInfo.Id);
+ if (!statusAnalysis.HasItemsToReturn)
+ return await HandleNoReturnItems(orderNo, palletCode, task, stockInfo.Id);
+
+ // 妫�鏌ユ槸鍚︽湁杩涜涓殑浠诲姟
+ if (statusAnalysis.HasActiveTasks)
{
- var outboundBatchNo = batchGroup.Key;
- var batchLocks = batchGroup.ToList();
-
- // 閲婃斁搴撳瓨鍜岄攣瀹氳褰�
- foreach (var lockInfo in batchLocks)
- {
- await ReleaseLockAndStock(lockInfo);
- }
-
- // 鏇存柊鎵规鐘舵��
- await UpdateBatchStatusForReturn(outboundBatchNo, batchLocks);
-
- // 鏇存柊璁㈠崟鏄庣粏鐨勫凡鍒嗛厤鏁伴噺
- await UpdateOrderDetailAfterReturn(batchLocks);
+ return WebResponseContent.Instance.Error($"鎵樼洏 {palletCode} 鏈夎繘琛屼腑鐨勪换鍔★紝涓嶈兘鎵ц鍥炲簱鎿嶄綔");
}
+
+ // 鎵ц鍥炲簱鎿嶄綔
+ await ExecuteReturnDataOperations(orderNo, palletCode, stockInfo, task, statusAnalysis);
+
+ // 閲婃斁鎵�鏈夐攣瀹氫互渚块噸鏂板垎閰�
+ await ReleaseAllLocksForReallocation(orderNo, palletCode, statusAnalysis);
_unitOfWorkManage.CommitTran();
- return WebResponseContent.Instance.OK("鍒嗘壒鍥炲簱鎴愬姛");
+ // 鏀堕泦鎵�鏈夐渶瑕佸洖搴撶殑鏉$爜
+ var returnBarcodes = await CollectReturnBarcodes(statusAnalysis);
+
+ // 鍒涘缓ESS鍥炲簱浠诲姟
+ if (returnBarcodes.Any())
+ {
+ _logger.LogInformation($"鍒涘缓鍥炲簱AGV浠诲姟 - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}, 鏉$爜鏁伴噺: {returnBarcodes.Count}, 鍘熷洜: {returnReason}");
+ await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InPick, stockInfo.PalletType);
+ }
+
+ // 鏇存柊璁㈠崟鐘舵�侊紙涓嶈Е鍙慚ES鍥炰紶锛�
+ await UpdateOrderStatusForReturn(orderNo);
+
+ return WebResponseContent.Instance.OK($"鍥炲簱鎿嶄綔鎴愬姛锛屽叡鍥炲簱鏁伴噺锛歿statusAnalysis.TotalReturnQty}", new
+ {
+ ReturnQuantity = statusAnalysis.TotalReturnQty,
+ ReturnBarcodes = returnBarcodes,
+ Reason = returnReason,
+ PalletCode = palletCode,
+ OrderNo = orderNo
+ });
}
catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
- _logger.LogError($"鍒嗘壒鍥炲簱澶辫触 - OrderNo: {orderNo}, PalletCode: {palletCode}, Error: {ex.Message}");
- return WebResponseContent.Instance.Error($"鍒嗘壒鍥炲簱澶辫触锛歿ex.Message}");
+ _logger.LogError($"鍥炲簱鎿嶄綔澶辫触 - OrderNo: {orderNo}, PalletCode: {palletCode}, Error: {ex.Message}");
+ return WebResponseContent.Instance.Error($"鍥炲簱鎿嶄綔澶辫触: {ex.Message}");
+ }
+ }
+ private async Task ExecuteReturnDataOperations(string orderNo, string palletCode, Dt_StockInfo stockInfo,Dt_Task task, PalletStatusAnalysis statusAnalysis)
+ {
+ _logger.LogInformation($"寮�濮嬫墽琛屽洖搴撴暟鎹搷浣� - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+
+ // 1. 澶勭悊鏈垎鎷g殑閿佸畾璁板綍
+ if (statusAnalysis.HasRemainingLocks)
+ {
+ _logger.LogInformation($"澶勭悊 {statusAnalysis.RemainingLocks.Count} 鏉℃湭鍒嗘嫞閿佸畾璁板綍");
+ await HandleRemainingLocksReturn(statusAnalysis.RemainingLocks);
+ }
+
+ // 2. 澶勭悊鎵樼洏涓婄殑搴撳瓨璐х墿
+ if (statusAnalysis.HasPalletStockGoods)
+ {
+ _logger.LogInformation($"澶勭悊 {statusAnalysis.PalletStockGoods.Count} 涓簱瀛樿揣鐗�");
+ await HandlePalletStockGoodsReturn(statusAnalysis.PalletStockGoods, stockInfo.Id);
+ }
+
+ // 3. 澶勭悊鎷嗗寘璁板綍
+ if (statusAnalysis.HasSplitRecords)
+ {
+ _logger.LogInformation($"澶勭悊 {statusAnalysis.SplitRecords.Count} 鏉℃媶鍖呰褰�");
+ await HandleSplitRecordsReturn(statusAnalysis.SplitRecords, stockInfo.Id);
+ }
+
+ _logger.LogInformation($"鍥炲簱鏁版嵁鎿嶄綔瀹屾垚 - 鎬诲洖搴撴暟閲�: {statusAnalysis.TotalReturnQty}");
+ }
+ /// <summary>
+ /// 鍒嗘壒鍥炲簱 - 璋冪敤缁熶竴鍥炲簱鏂规硶
+ /// </summary>
+ public async Task<WebResponseContent> BatchReturnStock(string orderNo, string palletCode)
+ {
+ return await ExecutePalletReturn(orderNo, palletCode, "鍒嗘壒鍥炲簱");
+ }
+
+ /// <summary>
+ /// 鍓╀綑鍥炲簱 - 璋冪敤缁熶竴鍥炲簱鏂规硶
+ /// </summary>
+ public async Task<WebResponseContent> ReturnRemaining(string orderNo, string palletCode, string reason)
+ {
+ return await ExecutePalletReturn(orderNo, palletCode, reason);
+ }
+
+ /// <summary>
+ /// 鍙栬蛋绌虹 - 鍏堟墽琛屽洖搴撳啀娓呯悊 - 澧炲己鐗堟湰
+ /// </summary>
+ public async Task<WebResponseContent> RemoveEmptyPallet(string orderNo, string palletCode)
+ {
+ try
+ {
+ _unitOfWorkManage.BeginTran();
+
+ _logger.LogInformation($"寮�濮嬪彇璧扮┖绠� - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+
+ // 1. 楠岃瘉绌虹鍙栬蛋鏉′欢锛堝繀椤诲叏閮ㄥ畬鎴愭嫞閫夛級
+ var validationResult = await ValidateEmptyPalletRemoval(orderNo, palletCode);
+ if (!validationResult.IsValid)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(validationResult.ErrorMessage);
+ }
+
+ var completedLocks = validationResult.Data;
+
+ // 2. 娓呯悊宸插畬鎴愮殑閿佸畾璁板綍锛堟爣璁颁负宸插彇璧帮級
+ await CleanupCompletedLocks(completedLocks);
+
+ // 3. 娓呯悊瀵瑰簲鐨勫簱瀛樿褰曠姸鎬�
+ foreach (var lockInfo in completedLocks)
+ {
+ await CleanupStockInfo(lockInfo);
+ }
+
+ // 4. 鏇存柊鐩稿叧璁㈠崟鐘舵��
+ await UpdateOrderStatusAfterPalletRemoval(orderNo);
+
+ // 5. 璁板綍鎿嶄綔鍘嗗彶
+ await RecordEmptyPalletRemoval(orderNo, palletCode, completedLocks);
+
+ _unitOfWorkManage.CommitTran();
+
+ _logger.LogInformation($"鍙栬蛋绌虹鎴愬姛 - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+
+ return WebResponseContent.Instance.OK("鍙栬蛋绌虹鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ _logger.LogError($"鍙栬蛋绌虹澶辫触 - OrderNo: {orderNo}, PalletCode: {palletCode}, Error: {ex.Message}");
+ return WebResponseContent.Instance.Error($"鍙栬蛋绌虹澶辫触锛歿ex.Message}");
+ }
+ }
+ /// <summary>
+ /// 鏀堕泦闇�瑕佸洖搴撶殑鏉$爜
+ /// </summary>
+ private async Task<List<string>> CollectReturnBarcodes(PalletStatusAnalysis status)
+ {
+ var returnBarcodes = new HashSet<string>();
+
+ try
+ {
+ _logger.LogInformation($"寮�濮嬫敹闆嗗洖搴撴潯鐮� - 璁㈠崟: {status.OrderNo}, 鎵樼洏: {status.PalletCode}");
+
+ // 1. 鏀堕泦鏈垎鎷i攣瀹氳褰曠殑鏉$爜
+ if (status.HasRemainingLocks)
+ {
+ foreach (var lockInfo in status.RemainingLocks)
+ {
+ if (!string.IsNullOrEmpty(lockInfo.CurrentBarcode))
+ {
+ returnBarcodes.Add(lockInfo.CurrentBarcode);
+ _logger.LogInformation($"娣诲姞閿佸畾璁板綍鏉$爜: {lockInfo.CurrentBarcode}");
+ }
+ }
+ }
+
+ // 2. 鏀堕泦鎵樼洏涓婂簱瀛樿揣鐗╃殑鏉$爜
+ if (status.HasPalletStockGoods)
+ {
+ foreach (var stockDetail in status.PalletStockGoods)
+ {
+ if (!string.IsNullOrEmpty(stockDetail.Barcode) && stockDetail.StockQuantity > 0)
+ {
+ returnBarcodes.Add(stockDetail.Barcode);
+ _logger.LogInformation($"娣诲姞搴撳瓨璐х墿鏉$爜: {stockDetail.Barcode}, 鏁伴噺: {stockDetail.StockQuantity}");
+ }
+ }
+ }
+
+ // 3. 鏀堕泦鎷嗗寘璁板綍鐩稿叧鐨勬潯鐮�
+ if (status.HasSplitRecords)
+ {
+ foreach (var splitRecord in status.SplitRecords)
+ {
+ // 娣诲姞鍘熸潯鐮�
+ if (!string.IsNullOrEmpty(splitRecord.OriginalBarcode))
+ {
+ var originalStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .FirstAsync(x => x.Barcode == splitRecord.OriginalBarcode && x.StockId == status.StockId);
+
+ if (originalStock != null && originalStock.StockQuantity > 0)
+ {
+ returnBarcodes.Add(splitRecord.OriginalBarcode);
+ _logger.LogInformation($"娣诲姞鎷嗗寘鍘熸潯鐮�: {splitRecord.OriginalBarcode}, 鏁伴噺: {originalStock.StockQuantity}");
+ }
+ }
+
+ // 娣诲姞鏂版潯鐮�
+ if (!string.IsNullOrEmpty(splitRecord.NewBarcode))
+ {
+ var newStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .FirstAsync(x => x.Barcode == splitRecord.NewBarcode && x.StockId == status.StockId);
+
+ if (newStock != null && newStock.StockQuantity > 0)
+ {
+ returnBarcodes.Add(splitRecord.NewBarcode);
+ _logger.LogInformation($"娣诲姞鎷嗗寘鏂版潯鐮�: {splitRecord.NewBarcode}, 鏁伴噺: {newStock.StockQuantity}");
+ }
+ }
+ }
+ }
+
+ _logger.LogInformation($"鍥炲簱鏉$爜鏀堕泦瀹屾垚 - 鍏� {returnBarcodes.Count} 涓潯鐮�: {string.Join(", ", returnBarcodes)}");
+
+ return returnBarcodes.ToList();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"鏀堕泦鍥炲簱鏉$爜澶辫触 - Error: {ex.Message}");
+ return returnBarcodes.ToList();
}
}
#endregion
+
+ #region 鍥炲簱鎿嶄綔鏍稿績鏂规硶
+
+ /// <summary>
+ /// 鎵ц鍥炲簱鎿嶄綔 - 澧炲己鐗堟湰
+ /// </summary>
+ private async Task ExecuteReturnOperations(string orderNo, string palletCode, Dt_StockInfo stockInfo,
+ Dt_Task task, PalletStatusAnalysis statusAnalysis)
+ {
+ _logger.LogInformation($"寮�濮嬫墽琛屽洖搴撴搷浣� - 璁㈠崟: {orderNo}, 鎵樼洏: {palletCode}");
+
+ // 澶勭悊鏈垎鎷g殑閿佸畾璁板綍
+ if (statusAnalysis.HasRemainingLocks)
+ {
+ _logger.LogInformation($"澶勭悊 {statusAnalysis.RemainingLocks.Count} 鏉℃湭鍒嗘嫞閿佸畾璁板綍");
+ await HandleRemainingLocksReturn(statusAnalysis.RemainingLocks);
+ }
+
+ //澶勭悊鎵樼洏涓婄殑搴撳瓨璐х墿
+ if (statusAnalysis.HasPalletStockGoods)
+ {
+ _logger.LogInformation($"澶勭悊 {statusAnalysis.PalletStockGoods.Count} 涓簱瀛樿揣鐗�");
+ await HandlePalletStockGoodsReturn(statusAnalysis.PalletStockGoods, stockInfo.Id);
+ }
+
+ //澶勭悊鎷嗗寘璁板綍
+ if (statusAnalysis.HasSplitRecords)
+ {
+ _logger.LogInformation($"澶勭悊 {statusAnalysis.SplitRecords.Count} 鏉℃媶鍖呰褰�");
+ await HandleSplitRecordsReturn(statusAnalysis.SplitRecords, stockInfo.Id);
+ }
+
+ _logger.LogInformation($"鍥炲簱鎿嶄綔瀹屾垚 - 鎬诲洖搴撴暟閲�: {statusAnalysis.TotalReturnQty}");
+ }
+
+ /// <summary>
+ /// 澶勭悊鏈垎鎷g殑閿佸畾璁板綍鍥炲簱
+ /// </summary>
+ private async Task HandleRemainingLocksReturn(List<Dt_OutStockLockInfo> remainingLocks)
+ {
+ foreach (var lockInfo in remainingLocks)
+ {
+ // 璁$畻鍥炲簱鏁伴噺锛堟湭鎷i�夌殑閮ㄥ垎锛�
+ decimal returnQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
+
+ if (returnQty > 0)
+ {
+ // 鎭㈠搴撳瓨鐘舵��
+ var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .FirstAsync(x => x.Barcode == lockInfo.CurrentBarcode && x.StockId == lockInfo.StockId);
+
+ if (stockDetail != null)
+ {
+ stockDetail.StockQuantity += returnQty;
+ stockDetail.OutboundQuantity -= returnQty;
+
+ // 纭繚鍑哄簱鏁伴噺涓嶄細涓鸿礋鏁�
+ if (stockDetail.OutboundQuantity < 0)
+ {
+ stockDetail.OutboundQuantity = 0;
+ }
+
+ // 鍥炲簱鍚庡簱瀛樼姸鎬佹仮澶嶄负鍏ュ簱瀹屾垚锛堝彲鐢ㄧ姸鎬侊級
+ stockDetail.Status = (int)StockStatusEmun.鍏ュ簱瀹屾垚;
+ await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
+
+ _logger.LogInformation($"鎭㈠搴撳瓨 - 鏉$爜: {stockDetail.Barcode}, 鏁伴噺: {returnQty}, 鏂板簱瀛�: {stockDetail.StockQuantity}");
+ }
+
+ // 鏇存柊閿佸畾璁板綍鐘舵�佷负宸插洖搴�
+ lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
+ lockInfo.Operator = App.User.UserName;
+ await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
+
+ _logger.LogInformation($"鏇存柊閿佸畾鐘舵�� - 閿佸畾ID: {lockInfo.Id}, 鍥炲簱鏁伴噺: {returnQty}");
+ }
+ }
+ }
+
+ /// <summary>
+ /// 澶勭悊鎵樼洏涓婄殑搴撳瓨璐х墿鍥炲簱
+ /// </summary>
+ private async Task HandlePalletStockGoodsReturn(List<Dt_StockInfoDetail> palletStockGoods, int stockId)
+ {
+ foreach (var stockDetail in palletStockGoods)
+ {
+ // 鍙鐞嗗嚭搴撻攣瀹氱姸鎬佺殑搴撳瓨
+ if (stockDetail.Status == (int)StockStatusEmun.鍑哄簱閿佸畾 && stockDetail.StockQuantity > 0)
+ {
+ // 鎭㈠搴撳瓨鐘舵�佷负鍙敤鐘舵��
+ stockDetail.Status = (int)StockStatusEmun.鍏ュ簱瀹屾垚;
+ await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
+
+ _logger.LogInformation($"鎭㈠搴撳瓨璐х墿 - 鏉$爜: {stockDetail.Barcode}, 鏁伴噺: {stockDetail.StockQuantity}");
+ }
+ }
+ }
+
+ /// <summary>
+ /// 澶勭悊鎷嗗寘璁板綍鍥炲簱
+ /// </summary>
+ private async Task HandleSplitRecordsReturn(List<Dt_SplitPackageRecord> splitRecords, int stockId)
+ {
+ foreach (var splitRecord in splitRecords)
+ {
+ // 澶勭悊鏂版潯鐮�
+ var newLockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.CurrentBarcode == splitRecord.NewBarcode &&
+ x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�)
+ .FirstAsync();
+
+ if (newLockInfo != null)
+ {
+ await HandleSingleLockReturn(newLockInfo);
+ }
+
+ // 澶勭悊鍘熸潯鐮�
+ var originalLockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.CurrentBarcode == splitRecord.OriginalBarcode &&
+ x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�)
+ .FirstAsync();
+
+ if (originalLockInfo != null)
+ {
+ await HandleSingleLockReturn(originalLockInfo);
+ }
+
+ // 鏇存柊鎷嗗寘璁板綍鐘舵�佷负宸插洖搴�
+ splitRecord.Status = (int)SplitPackageStatusEnum.宸插洖搴�;
+ await _splitPackageService.Db.Updateable(splitRecord).ExecuteCommandAsync();
+ }
+ }
+
+ /// <summary>
+ /// 澶勭悊鍗曚釜閿佸畾璁板綍鍥炲簱
+ /// </summary>
+ private async Task HandleSingleLockReturn(Dt_OutStockLockInfo lockInfo)
+ {
+ decimal returnQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
+
+ if (returnQty > 0)
+ {
+ // 鎭㈠搴撳瓨
+ var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .FirstAsync(x => x.Barcode == lockInfo.CurrentBarcode && x.StockId == lockInfo.StockId);
+
+ if (stockDetail != null)
+ {
+ stockDetail.StockQuantity += returnQty;
+ stockDetail.OutboundQuantity -= returnQty;
+
+ if (stockDetail.OutboundQuantity < 0)
+ {
+ stockDetail.OutboundQuantity = 0;
+ }
+
+ stockDetail.Status = (int)StockStatusEmun.鍏ュ簱瀹屾垚;
+ await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
+ }
+
+ // 鏇存柊閿佸畾鐘舵��
+ lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
+ lockInfo.Operator = App.User.UserName;
+ await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
+
+ _logger.LogInformation($"澶勭悊鎷嗗寘鐩稿叧閿佸畾 - 鏉$爜: {lockInfo.CurrentBarcode}, 鍥炲簱鏁伴噺: {returnQty}");
+ }
+ }
+
+ /// <summary>
+ /// 閲婃斁鎵�鏈夐攣瀹氫互渚块噸鏂板垎閰�
+ /// </summary>
+ private async Task ReleaseAllLocksForReallocation(string orderNo, string palletCode, PalletStatusAnalysis statusAnalysis)
+ {
+ // 鏇存柊璁㈠崟鏄庣粏鐨勫凡鍒嗛厤鏁伴噺
+ if (statusAnalysis.HasRemainingLocks)
+ {
+ var orderDetailGroups = statusAnalysis.RemainingLocks.GroupBy(x => x.OrderDetailId);
+
+ foreach (var group in orderDetailGroups)
+ {
+ var orderDetailId = group.Key;
+ var returnedQty = group.Sum(x => x.AssignQuantity - x.PickedQty);
+
+ var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+ .FirstAsync(x => x.Id == orderDetailId);
+
+ if (orderDetail != null)
+ {
+ orderDetail.AllocatedQuantity -= returnedQty;
+ orderDetail.LockQuantity = orderDetail.AllocatedQuantity;
+
+ await UpdateBatchAllocateStatus(orderDetail);
+ await _outboundOrderDetailService.Db.Updateable(orderDetail).ExecuteCommandAsync();
+
+ _logger.LogInformation($"鏇存柊璁㈠崟鏄庣粏 - OrderDetailId: {orderDetailId}, 鍑忓皯鍒嗛厤鏁伴噺: {returnedQty}");
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region 杈呭姪鏂规硶
+
+ /// <summary>
+ /// 澶勭悊娌℃湁鍥炲簱鐗╁搧鐨勬儏鍐�
+ /// </summary>
+ private async Task<WebResponseContent> HandleNoReturnItems(string orderNo, string palletCode, Dt_Task originalTask, int stockId)
+ {
+ _logger.LogInformation($"鎵樼洏 {palletCode} 娌℃湁闇�瑕佸洖搴撶殑鐗╁搧");
+
+ // 妫�鏌ユ槸鍚︽槸绌烘墭鐩�
+ var statusAnalysis = await AnalyzePalletStatus(orderNo, palletCode, stockId);
+ if (statusAnalysis.IsEmptyPallet)
+ {
+ try
+ {
+ var locationtype = 0;
+ var stockInfo = await _stockInfoService.Db.Queryable<Dt_StockInfo>()
+ .Where(x => x.PalletCode == palletCode)
+ .FirstAsync();
+
+ if (stockInfo == null)
+ {
+ var firstLocation = await _locationInfoService.Db.Queryable<Dt_LocationInfo>().FirstAsync(x => x.LocationCode == originalTask.SourceAddress);
+ locationtype = firstLocation?.LocationType ?? 1;
+ }
+ else
+ {
+ locationtype = stockInfo.LocationType;
+ _stockInfoService.DeleteData(stockInfo);
+ }
+
+ var targetAddress = originalTask.TargetAddress;
+
+ await CleanupZeroStockData(stockId);
+
+
+ var emptystockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = palletCode, LocationType = locationtype };
+ emptystockInfo.Details = new List<Dt_StockInfoDetail>();
+ _stockInfoService.AddMaterielGroup(emptystockInfo);
+ //绌烘墭鐩樺浣曞鐞� 杩樻湁涓�涓嚭搴撲换鍔¤澶勭悊銆�
+ originalTask.PalletType = PalletTypeEnum.Empty.ObjToInt();
+
+ await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty, PalletTypeEnum.Empty.ObjToInt());
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($" HandleNoReturnItems 澶辫触: {ex.Message}");
+ return WebResponseContent.Instance.Error($" 鍥炲簱绌烘墭鐩樺け璐ワ紒");
+ }
+ return WebResponseContent.Instance.OK("绌烘墭鐩樺洖搴撲换鍔″垱寤烘垚鍔�");
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error("鎵樼洏鐘舵�佸紓甯革細鏈夌墿鍝佷絾鏃犳硶璁$畻鍥炲簱鏁伴噺");
+ }
+ }
+ private async Task CleanupZeroStockData(int stockId)
+ {
+ try
+ {
+ // 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()))
+ .ExecuteCommandAsync();
+
+ await _stockInfoService.Db.Deleteable<Dt_StockInfo>()
+ .Where(x => x.Id == stockId).ExecuteCommandAsync();
+
+ _logger.LogInformation($"娓呯悊闆跺簱瀛樻槑缁嗚褰� - StockId: {stockId}, 鍒犻櫎璁板綍鏁�: {deleteDetailCount}");
+
+
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogWarning($"娓呯悊闆跺簱瀛樻暟鎹け璐� - StockId: {stockId}, Error: {ex.Message}");
+ // 娉ㄦ剰锛氭竻鐞嗗け璐ヤ笉搴旇褰卞搷涓绘祦绋�
+ }
+ }
+ /// <summary>
+ /// 鏇存柊璁㈠崟鐘舵�侊紙鍥炲簱鍚庯級
+ /// </summary>
+ private async Task UpdateOrderStatusForReturn(string orderNo)
+ {
+ // 妫�鏌ヨ鍗曟槸鍚︽墍鏈夋墭鐩橀兘宸插畬鎴愭垨宸插洖搴�
+ var allLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == orderNo)
+ .ToListAsync();
+
+ var activeLocks = allLocks.Where(x =>
+ x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓� ||
+ x.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�).ToList();
+
+ // 濡傛灉娌℃湁娲昏穬鐨勯攣瀹氳褰曪紝鏇存柊璁㈠崟鐘舵��
+ if (!activeLocks.Any())
+ {
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(x => new Dt_OutboundOrder
+ {
+ OrderStatus = (int)OutOrderStatusEnum.鍑哄簱瀹屾垚,
+ })
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+
+ _logger.LogInformation($"鏇存柊璁㈠崟鐘舵�佷负鍑哄簱瀹屾垚 - 璁㈠崟: {orderNo}");
+ }
+ }
+
+ #endregion
+
+
+
#region 楠岃瘉鏂规硶
private async Task<ValidationResult<(Dt_OutStockLockInfo, Dt_OutboundOrderDetail, Dt_StockInfoDetail, Dt_OutboundBatch)>> ValidatePickingRequest(
@@ -1510,7 +2149,7 @@
/// <summary>
/// 妫�鏌ュ苟鎵ц鑷姩鎷嗗寘锛堝鏋滈渶瑕侊級
/// </summary>
- private async Task<AutoSplitResult> CheckAndAutoSplitIfNeeded(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail, string palletCode)
+ private async Task<List<SplitResult>> CheckAndAutoSplitIfNeeded(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail, string palletCode)
{
// 妫�鏌ユ槸鍚﹂渶瑕佽嚜鍔ㄦ媶鍖呯殑鏉′欢锛�
// 1. 搴撳瓨鏁伴噺澶т簬鍒嗛厤鏁伴噺
@@ -1529,16 +2168,12 @@
// 鎵ц鑷姩鎷嗗寘
var splitResult = await ExecuteAutoSplitLogic(lockInfo, stockDetail, splitQuantity, palletCode);
- return new AutoSplitResult
- {
- NewBarcode = splitResult.NewBarcode,
- SplitQuantity = splitQuantity
- };
+ return splitResult;
}
/// <summary>
/// 鎵ц鑷姩鎷嗗寘閫昏緫
/// </summary>
- private async Task<SplitResultDto> ExecuteAutoSplitLogic(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail,
+ private async Task<List<SplitResult>> ExecuteAutoSplitLogic(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail,
decimal splitQuantity, string palletCode)
{
_logger.LogInformation($"寮�濮嬫墽琛岃嚜鍔ㄦ媶鍖呴�昏緫 - 鍘熸潯鐮�: {stockDetail.Barcode}, 鎷嗗寘鏁伴噺: {splitQuantity}");
@@ -1549,8 +2184,9 @@
// 閲嶈淇锛氳褰曟媶鍖呭墠鐨勫垎閰嶆暟閲�
decimal originalAssignQtyBefore = lockInfo.AssignQuantity;
decimal originalOrderQtyBefore = lockInfo.OrderQuantity;
+ decimal remainQty = originalAssignQtyBefore; // 鑷姩鎷嗗寘鍚庡師鏉$爜鍒嗛厤鏁伴噺淇濇寔涓嶅彉
- // 1. 鍒涘缓鏂板簱瀛樻槑缁嗭紙鍓╀綑閮ㄥ垎锛�
+ // 鍒涘缓鏂板簱瀛樻槑缁嗭紙鍓╀綑閮ㄥ垎锛�
var newStockDetail = new Dt_StockInfoDetail
{
StockId = stockDetail.StockId,
@@ -1566,20 +2202,18 @@
BarcodeQty = stockDetail.BarcodeQty,
BarcodeUnit = stockDetail.BarcodeUnit,
BusinessType = stockDetail.BusinessType,
- InboundOrderRowNo = stockDetail.InboundOrderRowNo,
+ InboundOrderRowNo = stockDetail.InboundOrderRowNo,
};
await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
_logger.LogInformation($"鍒涘缓鏂板簱瀛樻槑缁� - 鏉$爜: {newBarcode}, 搴撳瓨鏁伴噺: {splitQuantity}");
- // 2. 鏇存柊鍘熷簱瀛樻槑缁�
- // 閲嶈淇锛氬師搴撳瓨鏁伴噺璁剧疆涓哄垎閰嶆暟閲忥紙淇濇寔涓嶅彉锛�
- decimal originalStockQtyBefore = stockDetail.StockQuantity;
- // 娉ㄦ剰锛氳嚜鍔ㄦ媶鍖呮椂锛屽師搴撳瓨鏁伴噺淇濇寔涓嶅彉锛屽洜涓烘垜浠鍒嗘嫞鐨勫氨鏄垎閰嶆暟閲�
+ // 鏇存柊鍘熷簱瀛樻槑缁�
+ // 閲嶈淇锛氳嚜鍔ㄦ媶鍖呮椂锛屽師搴撳瓨鏁伴噺淇濇寔涓嶅彉锛屽洜涓烘垜浠鍒嗘嫞鐨勫氨鏄垎閰嶆暟閲�
// stockDetail.StockQuantity 淇濇寔涓嶅彉
_logger.LogInformation($"鍘熷簱瀛樻槑缁嗕繚鎸佷笉鍙� - 搴撳瓨鏁伴噺: {stockDetail.StockQuantity}");
- // 3. 鍒涘缓鏂伴攣瀹氫俊鎭紙鍓╀綑閮ㄥ垎锛�
+ // 鍒涘缓鏂伴攣瀹氫俊鎭紙鍓╀綑閮ㄥ垎锛�
var newLockInfo = new Dt_OutStockLockInfo
{
OrderNo = lockInfo.OrderNo,
@@ -1606,25 +2240,28 @@
lineNo = lockInfo.lineNo,
WarehouseCode = lockInfo.WarehouseCode,
BarcodeQty = lockInfo.BarcodeQty,
- BarcodeUnit = lockInfo.BarcodeUnit,
+ BarcodeUnit = lockInfo.BarcodeUnit,
};
await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync();
_logger.LogInformation($"鍒涘缓鏂伴攣瀹氫俊鎭� - 鏉$爜: {newBarcode}, 鍒嗛厤鏁伴噺: {splitQuantity}");
- // 4. 閲嶈淇锛氳嚜鍔ㄦ媶鍖呮椂锛屽師閿佸畾淇℃伅鐨勫垎閰嶆暟閲忎繚鎸佷笉鍙�
+ // 鑷姩鎷嗗寘鏃讹紝鍘熼攣瀹氫俊鎭殑鍒嗛厤鏁伴噺淇濇寔涓嶅彉
// 鍥犱负鑷姩鎷嗗寘鍚庯紝鍘熸潯鐮佷粛鐒堕渶瑕佽鍒嗘嫞锛屽垎閰嶆暟閲忎笉搴旇鏀瑰彉
_logger.LogInformation($"鍘熼攣瀹氫俊鎭繚鎸佷笉鍙� - 鍒嗛厤鏁伴噺: {lockInfo.AssignQuantity}, 璁㈠崟鏁伴噺: {lockInfo.OrderQuantity}");
- // 5. 璁板綍鎷嗗寘鍘嗗彶
- await RecordSplitHistory(lockInfo, stockDetail, splitQuantity, newBarcode, true, originalStockQtyBefore);
+ // 璁板綍鎷嗗寘鍘嗗彶
+ await RecordSplitHistory(lockInfo, stockDetail, splitQuantity, newBarcode, true, stockDetail.StockQuantity);
+
+ // 鍒涘缓鎷嗗寘缁撴灉鍒楄〃
+ var splitResults = CreateSplitResults(lockInfo, splitQuantity, remainQty, newBarcode, stockDetail.Barcode);
_logger.LogInformation($"鑷姩鎷嗗寘閫昏緫鎵ц瀹屾垚");
- return new SplitResultDto { NewBarcode = newBarcode };
+ return splitResults;
}
-
+
#endregion
#region 鏍稿績閫昏緫鏂规硶
@@ -1635,7 +2272,7 @@
{
_logger.LogInformation($"寮�濮嬫墽琛屽垎鎷i�昏緫 - 鏉$爜: {stockDetail.Barcode}, 鍒嗛厤鏁伴噺: {lockInfo.AssignQuantity}, 瀹為檯鎷i��: {actualPickedQty}");
- // 閲嶈淇锛氬啀娆¢獙璇佽鍗曟槑缁嗙殑鍒嗛厤鏁伴噺锛堥槻姝㈠苟鍙戞搷浣滐級
+ // 鍐嶆楠岃瘉璁㈠崟鏄庣粏鐨勫垎閰嶆暟閲忥紙闃叉骞跺彂鎿嶄綔锛�
if (orderDetail.AllocatedQuantity < actualPickedQty)
{
throw new InvalidOperationException($"璁㈠崟鏄庣粏鍒嗛厤鏁伴噺涓嶈冻锛岄渶瑕佹嫞閫� {actualPickedQty}锛屽彲鐢ㄥ垎閰嶆暟閲� {orderDetail.AllocatedQuantity}");
@@ -1646,7 +2283,7 @@
throw new InvalidOperationException($"璁㈠崟鏄庣粏閿佸畾鏁伴噺涓嶈冻锛岄渶瑕佹嫞閫� {actualPickedQty}锛屽彲鐢ㄩ攣瀹氭暟閲� {orderDetail.LockQuantity}");
}
- // 1. 鏇存柊閿佸畾淇℃伅
+ // 鏇存柊閿佸畾淇℃伅
lockInfo.PickedQty += actualPickedQty;
_logger.LogInformation($"鏇存柊閿佸畾淇℃伅 - 宸叉嫞閫夋暟閲忎粠 {lockInfo.PickedQty - actualPickedQty} 澧炲姞鍒� {lockInfo.PickedQty}");
@@ -1665,7 +2302,7 @@
lockInfo.Operator = App.User.UserName;
await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
- // 2. 鏇存柊搴撳瓨淇℃伅
+ // 鏇存柊搴撳瓨淇℃伅
decimal originalStockQty = stockDetail.StockQuantity;
decimal originalOutboundQty = stockDetail.OutboundQuantity;
@@ -1783,7 +2420,7 @@
StockDetail = stockDetail
};
}
-
+
#endregion
#region 鏁版嵁鏇存柊鏂规硶
@@ -1791,16 +2428,25 @@
private async Task UpdateBatchAndOrderData(Dt_OutboundBatch batch, Dt_OutboundOrderDetail orderDetail, decimal pickedQty, string orderNo)
{
_logger.LogInformation($"寮�濮嬫洿鏂版壒娆″拰璁㈠崟鏁版嵁 - 鎷i�夋暟閲�: {pickedQty}");
+ var latestOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().FirstAsync(x => x.Id == orderDetail.Id);
+ if (latestOrderDetail == null)
+ throw new InvalidOperationException("鏈壘鍒拌鍗曟槑缁�");
+
+ orderDetail = latestOrderDetail;
// 閲嶈淇锛氶獙璇佸垎閰嶆暟閲忎笉浼氬彉鎴愯礋鏁�
if (orderDetail.AllocatedQuantity < pickedQty)
{
- throw new InvalidOperationException($"鏇存柊璁㈠崟鏁版嵁鏃跺垎閰嶆暟閲忎笉瓒筹紝闇�瑕佸噺灏� {pickedQty}锛屽綋鍓嶅垎閰嶆暟閲� {orderDetail.AllocatedQuantity}");
+ decimal actualPickedQty = orderDetail.AllocatedQuantity;
+ _logger.LogWarning($"鍒嗛厤鏁伴噺涓嶈冻锛岃皟鏁存嫞閫夋暟閲� - 鍘熼渶瑕�: {pickedQty}, 瀹為檯鍙敤: {actualPickedQty}");
+ pickedQty = actualPickedQty;
}
if (orderDetail.LockQuantity < pickedQty)
{
- throw new InvalidOperationException($"鏇存柊璁㈠崟鏁版嵁鏃堕攣瀹氭暟閲忎笉瓒筹紝闇�瑕佸噺灏� {pickedQty}锛屽綋鍓嶉攣瀹氭暟閲� {orderDetail.LockQuantity}");
+ decimal actualPickedQty = orderDetail.LockQuantity;
+ _logger.LogWarning($"閿佸畾鏁伴噺涓嶈冻锛岃皟鏁存嫞閫夋暟閲� - 鍘熼渶瑕�: {pickedQty}, 瀹為檯鍙敤: {actualPickedQty}");
+ pickedQty = actualPickedQty;
}
// 1. 鏇存柊鎵规瀹屾垚鏁伴噺
@@ -1816,7 +2462,7 @@
}
await _outboundBatchRepository.Db.Updateable(batch).ExecuteCommandAsync();
- // 2. 鏇存柊璁㈠崟鏄庣粏
+ // 鏇存柊璁㈠崟鏄庣粏
decimal originalOverOutQty = orderDetail.OverOutQuantity;
decimal originalAllocatedQty = orderDetail.AllocatedQuantity;
decimal originalLockQty = orderDetail.LockQuantity;
@@ -1825,14 +2471,15 @@
orderDetail.AllocatedQuantity -= pickedQty;
// LockQuantity 鍚屾鍑忓皯
orderDetail.LockQuantity = orderDetail.AllocatedQuantity;
-
+ if (orderDetail.AllocatedQuantity < 0) orderDetail.AllocatedQuantity = 0;
+ if (orderDetail.LockQuantity < 0) orderDetail.LockQuantity = 0;
_logger.LogInformation($"鏇存柊璁㈠崟鏄庣粏 - 宸插嚭搴撴暟閲忎粠 {originalOverOutQty} 澧炲姞鍒� {orderDetail.OverOutQuantity}");
_logger.LogInformation($"鏇存柊璁㈠崟鏄庣粏 - 宸插垎閰嶆暟閲忎粠 {originalAllocatedQty} 鍑忓皯鍒� {orderDetail.AllocatedQuantity}");
_logger.LogInformation($"鏇存柊璁㈠崟鏄庣粏 - 閿佸畾鏁伴噺浠� {originalLockQty} 鍑忓皯鍒� {orderDetail.LockQuantity}");
await _outboundOrderDetailService.Db.Updateable(orderDetail).ExecuteCommandAsync();
- // 3. 妫�鏌ヨ鍗曠姸鎬�
+ // 妫�鏌ヨ鍗曠姸鎬�
await CheckAndUpdateOrderStatus(orderNo);
_logger.LogInformation($"鎵规鍜岃鍗曟暟鎹洿鏂板畬鎴�");
@@ -1842,7 +2489,7 @@
{
_logger.LogInformation($"寮�濮嬫仮澶嶆壒娆″拰璁㈠崟鏁版嵁");
- // 1. 鎭㈠鎵规瀹屾垚鏁伴噺
+ // 鎭㈠鎵规瀹屾垚鏁伴噺
var batch = await _outboundBatchRepository.Db.Queryable<Dt_OutboundBatch>()
.FirstAsync(x => x.BatchNo == revertResult.LockInfo.OutboundBatchNo);
@@ -1850,7 +2497,11 @@
{
decimal originalCompletedQty = batch.CompletedQuantity;
batch.CompletedQuantity -= pickingRecord.PickQuantity;
-
+ if (batch.CompletedQuantity < 0)
+ {
+ batch.CompletedQuantity = 0;
+ _logger.LogWarning($"鎵规瀹屾垚鏁伴噺鍑虹幇璐熸暟锛岄噸缃负0");
+ }
_logger.LogInformation($"鎭㈠鎵规瀹屾垚鏁伴噺 - 浠� {originalCompletedQty} 鍑忓皯鍒� {batch.CompletedQuantity}");
// 閲嶆柊璁$畻鎵规鐘舵��
@@ -1868,7 +2519,7 @@
await _outboundBatchRepository.Db.Updateable(batch).ExecuteCommandAsync();
}
- // 2. 鎭㈠璁㈠崟鏄庣粏
+ // 鎭㈠璁㈠崟鏄庣粏
var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
.FirstAsync(x => x.Id == pickingRecord.OrderDetailId);
@@ -1880,7 +2531,11 @@
// 閲嶈淇锛氬彧鎭㈠鐩稿叧鏁伴噺锛屽垎閰嶆暟閲忎繚鎸佷笉鍙�
orderDetail.OverOutQuantity -= pickingRecord.PickQuantity;
- // 娉ㄦ剰锛欰llocatedQuantity 鍜� LockQuantity 鍦ㄥ彇娑堝垎鎷f椂涓嶅簲璇ユ敼鍙�
+ orderDetail.AllocatedQuantity += pickingRecord.PickQuantity;
+ orderDetail.LockQuantity += pickingRecord.PickQuantity;
+ if (orderDetail.OverOutQuantity < 0) orderDetail.OverOutQuantity = 0;
+ if (orderDetail.AllocatedQuantity < 0) orderDetail.AllocatedQuantity = 0;
+ if (orderDetail.LockQuantity < 0) orderDetail.LockQuantity = 0;
_logger.LogInformation($"鎭㈠璁㈠崟鏄庣粏 - 宸插嚭搴撴暟閲忎粠 {originalOverOutQty} 鍑忓皯鍒� {orderDetail.OverOutQuantity}");
_logger.LogInformation($"璁㈠崟鏄庣粏鍒嗛厤鏁伴噺淇濇寔涓嶅彉: {originalAllocatedQty}");
@@ -1992,6 +2647,99 @@
}
#endregion
+ private async Task CreateReturnTaskAndHandleESS(string orderNo, string palletCode, Dt_Task originalTask, TaskTypeEnum taskTypeEnum, int palletType)
+ {
+ var firstLocation = await _locationInfoService.Db.Queryable<Dt_LocationInfo>()
+ .FirstAsync(x => x.LocationCode == originalTask.SourceAddress);
+
+ // 鍒嗛厤鏂拌揣浣�
+ var newLocation = _locationInfoService.AssignLocation(firstLocation.LocationType);
+
+ Dt_Task returnTask = new()
+ {
+ CurrentAddress = stations[originalTask.TargetAddress],
+ Grade = 0,
+ PalletCode = palletCode,
+ NextAddress = "",
+ // OrderNo = originalTask.OrderNo,
+ OrderNo = orderNo,
+ Roadway = newLocation.RoadwayNo,
+ SourceAddress = stations[originalTask.TargetAddress],
+ TargetAddress = newLocation.LocationCode,
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ TaskType = taskTypeEnum.ObjToInt(),
+ PalletType = palletType,
+ WarehouseId = originalTask.WarehouseId
+
+ };
+ // 淇濆瓨鍥炲簱浠诲姟
+ await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
+ var targetAddress = originalTask.TargetAddress;
+
+ // 鍒犻櫎鍘熷鍑哄簱浠诲姟
+ _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
+ // await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
+
+
+
+ // 缁� ESS 鍙戦�佹祦鍔ㄤ俊鍙峰拰鍒涘缓浠诲姟
+ await SendESSCommands(palletCode, targetAddress, returnTask);
+ }
+ /// <summary>
+ /// 缁橢SS涓嬩换鍔�
+ /// </summary>
+ /// <param name="palletCode"></param>
+ /// <param name="targetAddress"></param>
+ /// <param name="returnTask"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ private async Task SendESSCommands(string palletCode, string targetAddress, Dt_Task returnTask)
+ {
+ try
+ {
+ // 1. 鍙戦�佹祦鍔ㄤ俊鍙�
+ var moveResult = await _eSSApiService.MoveContainerAsync(new WIDESEA_DTO.Basic.MoveContainerRequest
+ {
+ slotCode = movestations[targetAddress],
+ containerCode = palletCode
+ });
+
+ //if (moveResult)
+ //{
+ // 2. 鍒涘缓鍥炲簱浠诲姟
+ var essTask = new TaskModel()
+ {
+ taskType = "putaway",
+ taskGroupCode = "",
+ groupPriority = 0,
+ tasks = new List<TasksType>{ new() {
+ taskCode = returnTask.TaskNum.ToString(),
+ taskPriority = 0,
+ taskDescribe = new TaskDescribeType
+ {
+ containerCode = palletCode,
+ containerType = "CT_KUBOT_STANDARD",
+ fromLocationCode = stations.GetValueOrDefault(targetAddress) ?? "",
+ toStationCode = "",
+ toLocationCode = returnTask.TargetAddress,
+ deadline = 0,
+ storageTag = ""
+ }
+ } }
+ };
+
+ var resultTask = await _eSSApiService.CreateTaskAsync(essTask);
+ _logger.LogInformation($"ReturnRemaining 鍒涘缓浠诲姟鎴愬姛: {resultTask}");
+ //}
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"ReturnRemaining ESS鍛戒护鍙戦�佸け璐�: {ex.Message}");
+ throw new Exception($"ESS绯荤粺閫氫俊澶辫触: {ex.Message}");
+ }
+ }
+
+
#region 杈呭姪鏂规硶
private async Task<string> GenerateNewBarcode()
@@ -2013,7 +2761,7 @@
SplitQty = splitQty,
SplitTime = DateTime.Now,
Status = (int)SplitPackageStatusEnum.宸叉媶鍖�,
- IsAutoSplit = isAutoSplit ,
+ IsAutoSplit = isAutoSplit,
// SplitType = isAutoSplit ? "鑷姩鎷嗗寘" : "鎵嬪姩鎷嗗寘"
OriginalStockQuantity = originalStockQuantity ?? stockDetail.StockQuantity,
//RemainingStockQuantity = stockDetail.StockQuantity - splitQty
@@ -2145,12 +2893,5 @@
}
#endregion
- }
-
-
- // 鏀寔绫�
- public class SplitResultDto
- {
- public string NewBarcode { 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/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 353663f..d222228 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"
@@ -140,7 +140,7 @@
private bool CanReassignOrder(Dt_OutboundOrder outboundOrder)
{
// 鍏佽閲嶆柊鍒嗛厤鐨勭姸鎬�
- var allowedStatus = new[] {OutOrderStatusEnum.鏈紑濮�, OutOrderStatusEnum.鍑哄簱涓�,OutOrderStatusEnum.閮ㄥ垎瀹屾垚};
+ var allowedStatus = new[] { OutOrderStatusEnum.鏈紑濮�, OutOrderStatusEnum.鍑哄簱涓�, OutOrderStatusEnum.閮ㄥ垎瀹屾垚 };
return allowedStatus.Contains((OutOrderStatusEnum)outboundOrder.OrderStatus);
}
@@ -682,12 +682,18 @@
decimal remainingAssign = assignQuantity;
// 鎸夊厛杩涘厛鍑哄垎閰嶅簱瀛樻槑缁�
- var sortedDetails = stock.Details
+ var sorteds = stock.Details
.Where(d => d.MaterielCode == detail.MaterielCode &&
- d.BatchNo == detail.BatchNo &&
- (d.StockQuantity - d.OutboundQuantity) > 0)
- .OrderBy(d => d.CreateDate)
- .ToList();
+ (d.StockQuantity - d.OutboundQuantity) > 0);
+ // .OrderBy(d => d.CreateDate);
+
+ if (!string.IsNullOrEmpty(detail.BatchNo))
+ {
+ sorteds= stock.Details.Where(x => x.BatchNo == detail.BatchNo);
+ }
+
+ var sortedDetails= sorteds.ToList().OrderBy(d => d.CreateDate);
+
foreach (var stockDetail in sortedDetails)
{
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 35490c5..fd2dbf8 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"
@@ -20,6 +20,7 @@
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
+using WIDESEA_Core.Utilities;
using WIDESEA_DTO.Allocate;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Inbound;
@@ -30,6 +31,7 @@
using WIDESEA_IOutboundService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Basic;
namespace WIDESEA_OutboundService
{
@@ -56,7 +58,7 @@
private readonly IAllocateService _allocateService;
private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
private readonly IInboundOrderDetailService _inboundOrderDetailService;
-
+ private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
private readonly ILogger<OutboundPickingService> _logger;
@@ -77,7 +79,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) : 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) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -96,6 +98,7 @@
_allocateService = allocateService;
_inboundOrderRepository = inboundOrderRepository;
_inboundOrderDetailService = inboundOrderDetailService;
+ _warehouseAreaRepository = warehouseAreaRepository;
}
@@ -747,13 +750,13 @@
PickTime = DateTime.Now,
Operator = App.User.UserName,
OutStockLockId = result.FinalLockInfo.Id,
- BarcodeUnit=result.FinalLockInfo.BarcodeUnit,
- BarcodeQty=result.FinalLockInfo.BarcodeQty,
- BatchNo= result.FinalLockInfo.BatchNo,
- lineNo= result.FinalLockInfo.lineNo ,
- SupplyCode= result.FinalLockInfo.SupplyCode ,
- WarehouseCode = result.FinalLockInfo.WarehouseCode ,
-
+ BarcodeUnit = result.FinalLockInfo.BarcodeUnit,
+ BarcodeQty = result.FinalLockInfo.BarcodeQty,
+ BatchNo = result.FinalLockInfo.BatchNo,
+ lineNo = result.FinalLockInfo.lineNo,
+ SupplyCode = result.FinalLockInfo.SupplyCode,
+ WarehouseCode = result.FinalLockInfo.WarehouseCode,
+
};
@@ -1383,7 +1386,7 @@
.SetColumns(it => new Dt_OutStockLockInfo
{
Status = (int)OutLockStockStatusEnum.宸查噴鏀�, // 闇�瑕佹柊澧炶繖涓姸鎬�
- // ReleaseTime = DateTime.Now,
+ // ReleaseTime = DateTime.Now,
Operator = App.User.UserName
})
.Where(it => lockIds.Contains(it.Id))
@@ -1777,7 +1780,7 @@
{
newStatus = (int)OutOrderStatusEnum.鍑哄簱瀹屾垚;
}
- else if (hasPartial )
+ else if (hasPartial)
{
newStatus = (int)OutOrderStatusEnum.鍑哄簱涓�;
}
@@ -1852,7 +1855,7 @@
.SetColumns(it => new Dt_OutboundOrderDetail
{
OrderDetailStatus = newStatus,
-
+
})
.Where(it => it.Id == orderDetailId)
.ExecuteCommandAsync();
@@ -1934,13 +1937,13 @@
ReqCode = Guid.NewGuid().ToString(),
ReqTime = DateTime.Now.ToString(),
BusinessType = "3",
-
+
FactoryArea = outboundOrder.FactoryArea,
OperationType = 1,
Operator = App.User.UserName,
OrderNo = outboundOrder.UpperOrderNo,
- // documentsNO = outboundOrder.OrderNo,
- // status = outboundOrder.OrderStatus,
+ // documentsNO = outboundOrder.OrderNo,
+ // status = outboundOrder.OrderStatus,
fromWarehouse = allocate?.FromWarehouse ?? "",
toWarehouse = allocate?.ToWarehouse ?? "",
Details = new List<AllocateDtoDetail>()
@@ -1958,7 +1961,7 @@
LineNo = group.Key.lineNo,
WarehouseCode = group.Key.WarehouseCode,
Qty = group.Sum(x => x.PickedQty),
-
+
Unit = group.Key.Unit,
Barcodes = group.Select(row => new BarcodeInfo
{
@@ -1969,13 +1972,13 @@
Qty = row.PickedQty
}).ToList()
-
+
}).ToList();
allocatefeedmodel.Details = groupedData;
var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
if (result != null && result.code == 200)
- {
+ {
await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
.SetColumns(x => x.ReturnToMESStatus == 1)
.Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
@@ -2436,8 +2439,8 @@
FactoryArea = originalLock.FactoryArea,
lineNo = originalLock.lineNo,
WarehouseCode = originalLock.WarehouseCode,
- BarcodeQty=originalLock.BarcodeQty,
- BarcodeUnit=originalLock.BarcodeUnit,
+ BarcodeQty = originalLock.BarcodeQty,
+ BarcodeUnit = originalLock.BarcodeUnit,
};
@@ -2550,7 +2553,7 @@
{
List<Dt_InboundOrder> InOders = _inboundOrderRepository.QueryData().Where(x => x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).ToList();
List<string> InOderCodes = InOders.Select(x => x.UpperOrderNo).ToList();
- return WebResponseContent.Instance.OK("鎴愬姛",data: InOderCodes);
+ return WebResponseContent.Instance.OK("鎴愬姛", data: InOderCodes);
}
public WebResponseContent GetAvailablePickingOrders()
@@ -2566,7 +2569,7 @@
try
{
Dt_InboundOrder inboundOrder = Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == noStockOut.inOder && x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
- if(inboundOrder == null)
+ if (inboundOrder == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒伴噰璐崟锛歿noStockOut.inOder}");
}
@@ -2593,7 +2596,7 @@
//鍓╀綑鍏ュ簱鏁伴噺鍗宠櫄鎷熷嚭鍏ュ簱鍓╀綑鍙嚭鏁伴噺
decimal outQuantity = matchedDetail.OrderQuantity - matchedDetail.ReceiptQuantity;
- if(outQuantity == 0)
+ if (outQuantity == 0)
{
return WebResponseContent.Instance.Error($"璇ラ噰璐崟涓殑鏉$爜瀵瑰簲鐨勫彲鍑烘暟閲忎负0");
}
@@ -2607,7 +2610,7 @@
if ((matchedCode.LockQuantity + matchedCode.NoStockOutQty) > matchedCode.OrderQuantity)
{
- return WebResponseContent.Instance.Error($"鍑哄簱鍗曟槑缁嗘暟閲忔孩鍑簕matchedCode.LockQuantity - matchedCode.OrderQuantity}");
+ return WebResponseContent.Instance.Error($"鍑哄簱鍗曟槑缁嗘暟閲忔孩鍑簕matchedCode.LockQuantity - matchedCode.OrderQuantity}");
}
matchedDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt();
matchedCode.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
@@ -2618,7 +2621,7 @@
_unitOfWorkManage.CommitTran();
return WebResponseContent.Instance.OK();
}
- catch(Exception ex)
+ catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
@@ -2643,7 +2646,7 @@
}
matchedDetail.NoStockOutQty = 0;
- if(matchedDetail.ReceiptQuantity==0 && matchedDetail.OverInQuantity==0)
+ if (matchedDetail.ReceiptQuantity == 0 && matchedDetail.OverInQuantity == 0)
{
matchedDetail.OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt();
}
@@ -2671,23 +2674,23 @@
return WebResponseContent.Instance.OK();
}
- catch(Exception ex)
+ catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
}
}
- public WebResponseContent NoStockOutSubmit(NoStockOutSubmit noStockOutSubmit)
+ public async Task<WebResponseContent> NoStockOutSubmit(NoStockOutSubmit noStockOutSubmit)
{
try
{
- Dt_InboundOrder inboundOrder = Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.InOderSubmit && x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
+ Dt_InboundOrder inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.InOderSubmit && x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
if (inboundOrder == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒伴噰璐崟锛歿noStockOutSubmit.InOderSubmit}");
}
- Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.OutOderSubmit && x.OrderStatus != OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
+ Dt_OutboundOrder outboundOrder = _inboundOrderRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.OutOderSubmit && x.OrderStatus != OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
if (outboundOrder == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒板嚭搴撳崟锛歿noStockOutSubmit.OutOderSubmit}");
@@ -2696,9 +2699,9 @@
List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
foreach (var BarCode in noStockOutSubmit.BarCodeSubmit)
{
- var inboundOrderDetail = inboundOrder.Details.FirstOrDefault(detail => detail.Barcode == BarCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt());
+ var inboundOrderDetail = inboundOrder.Details.FirstOrDefault(detail => detail.Barcode == BarCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt());
- if(inboundOrderDetail == null)
+ if (inboundOrderDetail == null)
{
return WebResponseContent.Instance.Error($"鍦ㄩ噰璐崟 {noStockOutSubmit.InOderSubmit} 涓湭鎵惧埌鏉$爜涓� {BarCode} 鐨勬槑缁嗐��");
}
@@ -2715,7 +2718,7 @@
outboundOrderDetail.LockQuantity += outboundOrderDetail.NoStockOutQty;
outboundOrderDetail.OverOutQuantity = outboundOrderDetail.LockQuantity;
- if(outboundOrderDetail.OrderQuantity == outboundOrderDetail.OverOutQuantity)
+ if (outboundOrderDetail.OrderQuantity == outboundOrderDetail.OverOutQuantity)
{
outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
}
@@ -2752,9 +2755,115 @@
_outboundOrderService.UpdateData(outboundOrder);
_unitOfWorkManage.CommitTran();
+ if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+ {
+ 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 = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new FeedbackInboundDetailsModel
+ {
+ materialCode = group.Key.MaterielCode,
+ supplyCode = group.Key.SupplyCode,
+ batchNo = group.Key.BatchNo,
+ lineNo = group.Key.lineNo,
+ warehouseCode = group.Key.WarehouseCode,
+ qty = group.Sum(x => x.BarcodeQty),
+ // warehouseCode= "1072",
+ unit = group.Key.BarcodeUnit,
+ barcodes = group.Select(row => new FeedbackBarcodesModel
+ {
+ barcode = row.Barcode,
+ qty = row.BarcodeQty
+ }).ToList()
+ }).ToList();
+ feedmodel.details = groupedData;
+
+ var result = await _invokeMESService.FeedbackInbound(feedmodel);
+ if (result != null && result.code == 200)
+ {
+ _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
+ .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+ _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
+ .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
+ }
+ }
+ if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
+ {
+ 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,
+ orderNo = outboundOrder.UpperOrderNo,
+ documentsNO = outboundOrder.OrderNo,
+ status = outboundOrder.OrderStatus,
+ details = new List<FeedbackOutboundDetailsModel>()
+ };
+
+
+ foreach (var detail in outboundOrder.Details)
+ {
+ // 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
+ var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == outboundOrder.OrderNo &&
+ x.OrderDetailId == detail.Id &&
+ x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
+ .ToListAsync();
+
+ var detailModel = new FeedbackOutboundDetailsModel
+ {
+ materialCode = detail.MaterielCode,
+ lineNo = detail.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
+ warehouseCode = detail.WarehouseCode,
+ qty = detail.OverOutQuantity, // 浣跨敤璁㈠崟鏄庣粏鐨勫凡鍑哄簱鏁伴噺
+ currentDeliveryQty = detail.OverOutQuantity,
+ unit = detail.Unit,
+ barcodes = detailLocks.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = lockInfo.CurrentBarcode,
+ supplyCode = lockInfo.SupplyCode,
+ batchNo = lockInfo.BatchNo,
+ unit = lockInfo.Unit,
+ qty = lockInfo.PickedQty // 鏉$爜绾у埆鐨勬暟閲忎粛鐢ㄩ攣瀹氳褰�
+ }).ToList()
+ };
+
+ feedmodel.details.Add(detailModel);
+ }
+ var result = await _invokeMESService.FeedbackOutbound(feedmodel);
+ 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)
+ .Where(x => x.Id == outboundOrder.Id)
+ .ExecuteCommandAsync();
+ }
+ }
+
+
return WebResponseContent.Instance.OK();
}
- catch(Exception ex)
+ catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
@@ -2762,11 +2871,183 @@
}
#endregion
+ public WebResponseContent UnPalletQuantity(string orderNo)
+ {
+ // 鍒濆鍖栬繑鍥濪TO锛堥粯璁ゅ�奸兘涓�0锛岄伩鍏峮ull锛�
+ var resultDTO = new PalletSumQuantityDTO
+ {
+ StockSumQuantity = 0,
+ StockCount = 0,
+ UniqueUnit = ""
+ };
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (string.IsNullOrWhiteSpace(orderNo))
+ {
+ return content.Error("浼犲叆鐨勮鍗曞彿orderNo涓虹┖鎴栫┖鐧�");
+ }
+ var orderDetail = Db.Queryable<Dt_PickingRecord>().Where(s => s.OrderNo == orderNo).ToList();
+ if (orderDetail == null)
+ {
+ return content.Error("鏈壘鍒板崟鎹�");
+ }
+ var unitGroups = orderDetail.GroupBy(d => d.BarcodeUnit).ToList();
+ if (unitGroups.Count == 1)
+ {
+ resultDTO.UniqueUnit = unitGroups.First().Key;
+ }
+ else
+ {
+ resultDTO.UniqueUnit = "";
+ }
+ var validDetails = _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList();
+ resultDTO.StockSumQuantity = orderDetail.Sum(d => d.PickQuantity);
+ resultDTO.StockCount = orderDetail.Count;
+ if (validDetails.Any())
+ {
+ resultDTO.StockSumQuantity -= validDetails.Sum(d => d.StockQuantity);
+ // 鏄庣粏璁板綍鏁帮細绗﹀悎鏉′欢鐨勬湁鏁堣褰曟潯鏁�
+ resultDTO.StockCount -= validDetails.Count;
+ }
+ return content.OK("", resultDTO);
+ }
+ catch (Exception ex)
+ {
+ return content.Error("SumQuantity 缁熻搴撳瓨鏁伴噺澶辫触锛岃鍗曞彿锛歿OrderNo}");
+ }
+ }
+
+ public WebResponseContent BarcodeMaterielGroup(BarcodeMaterielGroupDTO materielGroupDTO)
+ {
+
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
+ if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
+
+ // materielGroupDTO.WarehouseCode
+ var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseType).Select(x => x.Code).First();
+ if (string.IsNullOrEmpty(code))
+ {
+ return content = WebResponseContent.Instance.Error($"浠撳簱涓病鏈夎{materielGroupDTO.WarehouseType}缂栧彿銆�");
+ }
+
+
+ // Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo);
+
+ var dbinboundOrderDetails = Db.Queryable<Dt_PickingRecord>().Where(x=>x.OrderNo== materielGroupDTO.OrderNo && !x.IsCancelled && x.Barcode==materielGroupDTO.Barcodes).ToList();
+
+ if (dbinboundOrderDetails != null && !dbinboundOrderDetails.Any())
+ {
+ return content = WebResponseContent.Instance.Error($"鍗曟嵁涓病鏈夎{materielGroupDTO.Barcodes}鏉$爜鏁版嵁銆�");
+ }
+
+ List<string?> materielCodes = dbinboundOrderDetails.GroupBy(x => x.Barcode).Select(x => x.Key).ToList();
+
+ Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(materielGroupDTO.PalletCode);
+
+
+
+ (bool, string, object?) result = CheckMaterielGroupParam(materielGroupDTO, materielCodes, stockInfo);
+ if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
+
+ if (stockInfo == null)
+ {
+ stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = materielGroupDTO.locationType.ObjToInt() };
+ stockInfo.Details = new List<Dt_StockInfoDetail>();
+ }
+
+ foreach (var item in dbinboundOrderDetails)
+ {
+ stockInfo.Details.Add(new Dt_StockInfoDetail
+ {
+ StockId = stockInfo == null ? 0 : stockInfo.Id,
+ Barcode = item.Barcode,
+ MaterielCode = item.MaterielCode,
+ BatchNo = item.BatchNo,
+ Unit = item.BarcodeUnit,
+ InboundOrderRowNo = item.lineNo,
+ SupplyCode = item.SupplyCode,
+ WarehouseCode = materielGroupDTO.WarehouseType,
+ StockQuantity = item.PickQuantity,
+ BarcodeQty = item.BarcodeQty,
+ BarcodeUnit = item.BarcodeUnit,
+ FactoryArea = item.FactoryArea,
+ Status = 0,
+ OrderNo = item.OrderNo,
+
+ });
+ item.WarehouseCode = item.WarehouseCode;
+ }
+
+ if (stockInfo.Id == 0)
+ {
+ stockInfo.PalletCode = materielGroupDTO.PalletCode;
+ stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+ }
+ stockInfo.PalletType = (int)PalletTypeEnum.None;
+
+ List<int> updateDetailIds = dbinboundOrderDetails.Select(x => x.Id).ToList();
+
+ try
+ {
+ _unitOfWorkManage.BeginTran();
+
+ _stockService.StockInfoService.AddMaterielGroup(stockInfo);
+ _unitOfWorkManage.CommitTran();
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+
+ }
+ return content;
+
+ }
+
+
+ public (bool, string, object?) CheckMaterielGroupParam(BarcodeMaterielGroupDTO materielGroupDTO, List<string> barcodeCodes, Dt_StockInfo stockInfo)
+ {
+ (bool, string, object?) result = ModelValidate.ValidateModelData(materielGroupDTO);
+ if (!result.Item1) return result;
+
+ if (_taskRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode) != null)
+ {
+ return (false, "璇ユ墭鐩樺彿宸叉湁浠诲姟", materielGroupDTO);
+ }
+
+ if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+ {
+ return (false, "宸蹭笂鏋剁殑鎵樼洏涓嶈兘鍐嶆缁勭洏", materielGroupDTO);
+ }
+
+ if (_stockService.StockInfoDetailService.ExistBarcodes(barcodeCodes))
+ {
+ return (false, $"{barcodeCodes[0]} 鏉$爜鍦ㄥ簱瀛樹腑宸插瓨鍦�", materielGroupDTO);
+ }
+
+
+
+ return (true, "鎴愬姛", materielGroupDTO);
+ }
+
#endregion
}
-
+
#region 鏀寔绫诲畾涔�
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/Outbound/OutboundPickingController.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/Outbound/OutboundPickingController.cs"
index 95ae57a..051be09 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/Outbound/OutboundPickingController.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/Outbound/OutboundPickingController.cs"
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_Core.BaseController;
using WIDESEA_DTO.Outbound;
@@ -140,9 +141,9 @@
}
[HttpPost, HttpGet, Route("NoStockOutSubmit"), AllowAnonymous]
- public WebResponseContent NoStockOutSubmit([FromBody] NoStockOutSubmit noStockOutSubmit)
+ public async Task<WebResponseContent> NoStockOutSubmit([FromBody] NoStockOutSubmit noStockOutSubmit)
{
- return Service.NoStockOutSubmit(noStockOutSubmit);
+ return await Service.NoStockOutSubmit(noStockOutSubmit);
}
}
}
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/Outbound/PickingReturnController.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/Outbound/PickingReturnController.cs"
new file mode 100644
index 0000000..45460a8
--- /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_WMSServer/Controllers/Outbound/PickingReturnController.cs"
@@ -0,0 +1,44 @@
+锘縰sing Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using WIDESEA_Core;
+using WIDESEA_Core.Attributes;
+using WIDESEA_Core.BaseController;
+using WIDESEA_DTO.Inbound;
+using WIDESEA_IOutboundService;
+using WIDESEA_Model.Models;
+
+namespace WIDESEA_WMSServer.Controllers.Outbound
+{
+ [Route("api/PickingReturn")]
+ [ApiController]
+ public class PickingReturnController : ApiBaseController<IOutboundPickingService, Dt_PickingRecord>
+ {
+ private readonly IOutStockLockInfoService _outStockLockInfoService;
+ public PickingReturnController(IOutboundPickingService service, IOutStockLockInfoService outStockLockInfoService) : base(service)
+ {
+ _outStockLockInfoService = outStockLockInfoService;
+ }
+
+ [HttpPost, Route("UnPalletQuantity"), AllowAnonymous, MethodParamsValidate]
+ public WebResponseContent UnPalletQuantity(string orderNo)
+ {
+ return Service.UnPalletQuantity(orderNo);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="materielGroupDTO"></param>
+ /// <returns></returns>
+ [HttpPost, Route("BarcodeMaterielGroup"), AllowAnonymous, MethodParamsValidate]
+ public WebResponseContent BarcodeMaterielGroup([FromBody] BarcodeMaterielGroupDTO data)
+ {
+ var content = Service.BarcodeMaterielGroup(data);
+
+ return content;
+
+ }
+
+
+ }
+}
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/Jobs/InventoryLockJob.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/Jobs/InventoryLockJob.cs"
index 248f47e..495eef0 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/Jobs/InventoryLockJob.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/Jobs/InventoryLockJob.cs"
@@ -1,5 +1,9 @@
锘縰sing Quartz;
using SqlSugar;
+using SqlSugar.Extensions;
+using WIDESEA_Common.StockEnum;
+using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Basic;
namespace WIDESEA_WMSServer.Jobs
{
@@ -16,7 +20,24 @@
}
public Task Execute(IJobExecutionContext context)
{
- return Task.CompletedTask;
+
+ // 绗竴姝ワ細鏇存柊ValidDate鐨勫師鐢烻QL锛圫QL Server锛�
+ string updateSql = @"
+ UPDATE s
+ SET s.ValidDate = DATEADD(DAY, m.ValidityDays, s.CreateDate)
+ FROM Dt_StockInfoDetail s
+ INNER JOIN Dt_MaterialExpirationDate m ON SUBSTRING(s.MaterielCode, 1, 6) = m.MaterialCode
+ WHERE s.ValidDate IS NULL";
+ int updateValidDateResult = _db.Ado.ExecuteCommand(updateSql);
+
+ // 绗簩姝ワ細鏇存柊杩囨湡鐘舵�佺殑鍘熺敓SQL
+ string updateStatusSql = @"
+ UPDATE Dt_StockInfoDetail
+ SET Status = 98
+ WHERE ValidDate IS NOT NULL AND ValidDate < GETDATE()";
+ int updateStatusResult = _db.Ado.ExecuteCommand(updateStatusSql);
+
+ return Task.CompletedTask;
}
}
}
--
Gitblit v1.9.3