647556386
2026-01-06 61654768aa92e6c3fd288344c0c895ba4d19d127
Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
已添加1个文件
已修改9个文件
743 ■■■■ 文件已修改
项目代码/WIDESEA_WMSClient/config/buttons.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/UndoPalletGroup.vue 170 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js 317 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/BigGreenService/BigGreenService.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Common/OrderEnum/InboundOrderMenu.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs 175 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WIDESEA_WMSClient/config/buttons.js
@@ -307,6 +307,22 @@
    type: 'warning',
    onClick: function () {
    }
},{
    name: "撤销组盘",
    icon: '',
    class: '',
    value: 'UndoPalletGroup',
    type: 'warning',
    onClick: function () {
    }
},,{
    name: "关闭单据",
    icon: '',
    class: '',
    value: 'CloseOrder',
    type: 'warning',
    onClick: function () {
    }
},
]
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/inbound/extend/UndoPalletGroup.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,170 @@
<template>
  <vol-box v-model="show" title="撤销组盘" :width="500" :height="300">
    <template #content>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-form-item label="托盘条码:" prop="code">
          <el-input
            v-model="form.code"
            placeholder="请扫描/输入托盘条码"
            @keydown.enter.prevent="submit"
            clearable
            @paste="handlePaste"
            @input="handleInput"
            ref="boxCodeInput"
            autocomplete="off"
            maxlength="50"
          />
        </el-form-item>
      </el-form>
    </template>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="onCancel">取消</el-button>
        <el-button type="primary" @click="submit">确认撤销</el-button>
      </div>
    </template>
  </vol-box>
</template>
<script>
import VolBox from '@/components/basic/VolBox.vue'
export default {
  components: { VolBox },
  props: {
    value: { type: Boolean, default: false }
  },
  data() {
    return {
      show: false,
      form: {
        code: ''
      },
      rules: {
        code: [
          { required: true, message: '请输入托盘号', trigger: ['blur', 'change'] },
          { min: 1, max: 50, message: '托盘号长度不能超过50个字符', trigger: ['blur', 'input'] }
        ]
      }
    }
  },
  methods: {
    open() {
      this.show = true
    },
    async submit() {
      try {
        await this.$refs.form.validate()
      } catch (error) {
        this.$message.warning('请输入有效的托盘号')
        this.focusAndSelectInput()
        return
      }
      try {
        const response = await this.http.post(
          `/api/InboundOrder/UndoPalletGroup?code=${encodeURIComponent(this.form.code.trim())}`
        )
        const { status, message, data } = response
        if (status) {
          this.$message.success(message || '撤销组盘成功')
          this.refresh()
          if (message && message.includes('托盘仍有剩余明细')) {
            this.form.code = ''
            this.$refs.form.clearValidate('code')
            this.focusAndSelectInput()
          } else {
            this.show = false
          }
        } else {
          this.$message.error(message || data?.message || '撤销组盘失败')
          this.focusAndSelectInput()
        }
      } catch (error) {
        console.error('撤销组盘请求异常:', error)
        this.$message.error('网络异常或接口错误,请稍后重试')
        this.focusAndSelectInput()
      }
    },
    handleInput(value) {
      this.form.code = value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase()
    },
    handlePaste(e) {
      const clipboardData = e.clipboardData || window.clipboardData
      const pastedText = clipboardData.getData('text')
      const cleanedText = pastedText.replace(/[^a-zA-Z0-9]/g, '').toUpperCase()
      if (cleanedText) {
        this.form.code = cleanedText
        setTimeout(() => {
          this.submit()
        }, 50)
      }
      e.preventDefault()
    },
    focusAndSelectInput() {
      this.$nextTick(() => {
        setTimeout(() => {
          const inputRef = this.$refs.boxCodeInput
          if (inputRef) {
            const inputEl = inputRef.$el ? inputRef.$el.querySelector('input') : inputRef
            if (inputEl) {
              inputEl.focus()
              inputEl.select()
            }
          }
        }, 100)
      })
    },
    onCancel() {
      this.$message.info('取消撤销组盘')
      this.show = false
    },
    refresh() {
      this.$emit('refresh')
    }
  },
  watch: {
    value(val) {
      this.show = val
    },
    show(val) {
      this.$emit('input', val)
      if (val) {
        // å¼¹çª—打开时延迟聚焦,确保DOM已渲染
        this.$nextTick(() => {
          setTimeout(() => {
            const inputRef = this.$refs.boxCodeInput
            if (inputRef) {
              const inputEl = inputRef.$el ? inputRef.$el.querySelector('input') : inputRef
              if (inputEl) {
                inputEl.focus()
                inputEl.select() // é€‰ä¸­å†…容,方便直接扫码覆盖
              }
            }
          }, 100)
        })
      } else {
        this.form.code = ''
        if (this.$refs.form) {
          this.$refs.form.clearValidate()
        }
      }
    }
  }
}
</script>
<style scoped>
.dialog-footer {
  text-align: right;
}
</style>
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js
@@ -1,24 +1,13 @@
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
import gridHeader from "./extend/EmptyTrayInbound.vue";
import gridBody from "./extend/Pallet.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";
import gridFooter from "./extend/UndoPalletGroup.vue";
let extension = {
  components: {
    //查询界面扩展组件
    gridHeader: gridHeader,
    gridBody: gridBody,
    gridFooter: "",
    gridFooter: gridFooter,
    //新建、编辑弹出框扩展组件
    modelHeader: "",
    modelBody: "",
@@ -27,243 +16,7 @@
  tableAction: "", //指定某张表的权限(这里填写表名,默认不用填写)
  buttons: {
    view: [
      {
        name: "撤销组盘",
        type: "primary",
        value: "撤销组盘",
        onClick: function () {
          console.log("撤销组盘按钮被点击");
          const mountNode = document.createElement("div");
          document.body.appendChild(mountNode);
          // å“åº”式表单数据:托盘号(必填)
          const formData = reactive({
            palletCode: "", // æ‰˜ç›˜å·è¾“入框
            barcode: "",
          });
          // æäº¤è¡¨å•的统一逻辑
          const submitForm = async () => {
            const formRef = vnode.component.refs.cancelPalletForm;
            try {
              // æ‰§è¡Œè¡¨å•校验(托盘号必填)
              await formRef.validate();
            } catch (err) {
              ElMessage.warning("请输入有效的托盘号");
              return;
            }
            // å‘起撤销组盘请求
            try {
              const response = await http.post(
                "/api/InboundOrder/UndoPalletGroup?palletCode=" +
                formData.palletCode.trim() +
                "&barcode=" +
                formData.barcode.trim()
              );
              const { status, message, data } = response;
              if (status) {
                ElMessage.success(response.message);
                this.refresh(); // æˆåŠŸåŽåˆ·æ–°åˆ—è¡¨
                // å…³é—­å¯¹è¯æ¡†
                render(null, mountNode);
                document.body.removeChild(mountNode);
              } else {
                ElMessage.error(message || data?.message || "撤销组盘失败");
                selectPalletCodeInput(); // é€‰ä¸­è¾“入框方便重新输入
              }
            } catch (error) {
              console.error("撤销组盘请求异常:", error);
              ElMessage.error("网络异常或接口错误,请稍后重试");
              selectPalletCodeInput();
            }
          };
          // é€‰ä¸­è¾“入框文本(方便重新输入)
          const selectPalletCodeInput = () => {
            setTimeout(() => {
              const inputRef = vnode.component.refs.palletCodeInput;
              if (inputRef) {
                const targetInput =
                  inputRef.$el?.querySelector("input") || inputRef;
                targetInput?.focus();
                targetInput?.select();
              }
            }, 100);
          };
          // åˆ›å»ºå¯¹è¯æ¡†VNode
          const vnode = createVNode(
            ElDialog,
            {
              title: "撤销组盘",
              width: "400px",
              modelValue: true,
              appendToBody: true,
              onOpened: () => {
                // å¯¹è¯æ¡†æ‰“开后自动聚焦输入框
                setTimeout(() => {
                  const inputRef = vnode.component.refs.palletCodeInput;
                  inputRef?.focus();
                }, 100);
              },
              "onUpdate:modelValue": (isVisible) => {
                if (!isVisible) {
                  render(null, mountNode);
                  document.body.removeChild(mountNode);
                }
              },
            },
            {
              default: () =>
                h(
                  ElForm,
                  {
                    model: formData,
                    rules: {
                      palletCode: [
                        {
                          required: true,
                          message: "请输入托盘号",
                          trigger: ["blur", "enter"],
                        },
                        {
                          min: 1,
                          max: 50,
                          message: "托盘号长度不能超过50个字符",
                          trigger: ["blur", "input"],
                        },
                      ],
                    },
                    ref: "cancelPalletForm",
                  },
                  [
                    // æ‰˜ç›˜å·è¾“入项
                    h(
                      ElFormItem,
                      { label: "托盘条码", prop: "palletCode", required: true },
                      [
                        h(ElInput, {
                          type: "text",
                          modelValue: formData.palletCode,
                          "onUpdate:modelValue": (val) => {
                            formData.palletCode = val;
                          },
                          ref: "palletCodeInput",
                          placeholder: "扫码输入或手动输入托盘号",
                          maxLength: 50,
                          // ç›‘听回车事件(扫码枪默认会发送回车)
                          onKeydown: (e) => {
                            if (e.key === "Enter") {
                              e.preventDefault();
                              submitForm();
                            }
                          },
                        }),
                      ]
                    ),
                    h(ElFormItem, { label: " å†…箱标签", prop: "barcode" }, [
                      h(ElInput, {
                        type: "text",
                        modelValue: formData.barcode,
                        "onUpdate:modelValue": (val) => {
                          formData.barcode = val;
                        },
                        placeholder: "可选,扫码输入或手动输入条码",
                        maxLength: 50,
                        onKeydown: (e) => {
                          if (e.key === "Enter") {
                            e.preventDefault();
                            submitForm();
                          }
                        },
                      }),
                    ]),
                    // åº•部按钮区
                    h(
                      "div",
                      { style: { textAlign: "right", marginTop: "16px" } },
                      [
                        h(
                          ElButton,
                          {
                            type: "text",
                            onClick: () => {
                              render(null, mountNode);
                              document.body.removeChild(mountNode);
                              ElMessage.info("取消撤销组盘");
                            },
                          },
                          "取消"
                        ),
                        h(
                          ElButton,
                          {
                            type: "primary",
                            onClick: submitForm.bind(this), // ç»‘定this上下文
                          },
                          "确认撤销"
                        ),
                      ]
                    ),
                  ]
                ),
            }
          );
          vnode.appContext = this.$.appContext;
          render(vnode, mountNode);
        },
      },
      // {
      //   name: '分批入库',
      //   type: 'primary',
      //   value: '分批入库',
      //   onClick: async function () {
      //     console.log('分批入库按钮被点击,开始校验');
      //     const selectedRows = this.$refs.table.getSelected();
      //     // æ ¡éªŒ1:是否选中行(至少选择一条)
      //     if (selectedRows.length === 0) {
      //       console.log('校验不通过:未选中任何单据');
      //       ElMessage.warning('请选择至少一条单据');
      //       return;
      //     }
      //     // æ”¶é›†æ‰€æœ‰é€‰ä¸­å•据的编号(过滤无单据号的异常行)
      //     const inboundOrderNos = selectedRows
      //       .filter(row => row.inboundOrderNo)
      //       .map(row => row.inboundOrderNo);
      //     // æ ¡éªŒ2:是否有有效单据号
      //     if (inboundOrderNos.length === 0) {
      //       console.log('校验不通过:选中单据无有效编号');
      //       ElMessage.warning('选中的单据中无有效编号,请重新选择');
      //       return;
      //     }
      //     try {
      //       console.log('发起分批入库请求,参数:', { inboundOrderNos });
      //       const response = await http.post('/api/InboundOrder/BatchOrderFeedbackToMes', {
      //         orderNos: inboundOrderNos,
      //         inout: 1
      //       });
      //       const { status, message, data } = response;
      //       if (status) {
      //         console.log('分批入库成功,后端返回:', data);
      //         ElMessage.success(`分批入库成功!`);
      //         this.refresh(); // å…¥åº“成功后刷新列表(复用原有逻辑)
      //       } else {
      //         console.log('分批入库失败,后端提示:', message);
      //         ElMessage.error(message || data?.message || '分批入库失败');
      //       }
      //     } catch (error) {
      //       console.error('分批入库请求异常:', error);
      //       ElMessage.error('网络异常或接口错误,请稍后重试');
      //     }
      //   }
      // },
    ],
    box: [],
    detail: [],
@@ -277,6 +30,14 @@
      if (EmptyTrayInboundBtn != null) {
        EmptyTrayInboundBtn.onClick = () => {
          this.$refs.gridHeader.open();
        };
      }
      var UndoPalletGroupBtn = this.buttons.find(
        (x) => x.value == "UndoPalletGroup"
      );
      if (UndoPalletGroupBtn != null) {
        UndoPalletGroupBtn.onClick = () => {
          this.$refs.gridFooter.open();
        };
      }
      var BatchInOrderFeedbackToMesBtn = this.buttons.find(
@@ -308,34 +69,34 @@
        };
      }
      // let BatchInOrderFeedbackToMesBtn = this.buttons.find((x) => x.value == "BatchInOrderFeedbackToMes");
      // if (BatchInOrderFeedbackToMesBtn != null) {
      //   BatchInOrderFeedbackToMesBtn.onClick = ()=> {
      //     let selectedRows = this.$refs.table.getSelected();
      //     // æ ¡éªŒæ˜¯å¦æœ‰é€‰ä¸­æ•°æ®
      //     if (!selectedRows || selectedRows.length === 0) {
      //       return this.$Message.warning("请先选择需要处理的单据");
      //     }
      //     if (selectedRows.length > 1) {
      //       return this.$Message.warning("请选择一条数据");
      //     }
      //     this.http.post(`api/Inbound/BatchInOrderFeedbackToMes?orderNo=${selectedRows[0].orderNo}`,{},"数据处理中...")
      //       .then((x) => {
      //         if (x.status) {
      //           this.$Message.success("分批出库回调完成");
      //           this.refresh();
      //         } else {
      //           return this.$Message.error("分批出库回调失败");
      //         }
      //       })
      //       .catch((error) => {
      //         // å¢žåŠ å¼‚å¸¸æ•èŽ·ï¼Œå¤„ç†ç½‘ç»œé”™è¯¯ç­‰æƒ…å†µ
      //         //_this.$Message.error('请求失败:' + (error.message || '未知错误'));
      //       });
      //   };
      // }
      var CloseOrderBtn = this.buttons.find(
        (x) => x.value == "CloseOrder"
      );
      if (CloseOrderBtn != null) {
        CloseOrderBtn.onClick = () => {
          var rows = this.$refs.table.getSelected();
          // æ ¡éªŒæ˜¯å¦æœ‰é€‰ä¸­æ•°æ®
          if (!rows || rows.length === 0) {
            return this.$Message.error("请先选择需要关闭的单据");
          }
          if (rows.length > 1) {
            return this.$Message.error("请选择一条单据");
          }
          this.http.post(`api/InboundOrder/HandCloseOrder?orderIds=${rows[0].id}`, {}, "数据处理中...")
            .then((x) => {
              if (x.status) {
                this.$Message.success(x.message);
                this.refresh();
              } else {
                return this.$Message.error(x.message);
              }
            })
            .catch((error) => {
              // å¢žåŠ å¼‚å¸¸æ•èŽ·ï¼Œå¤„ç†ç½‘ç»œé”™è¯¯ç­‰æƒ…å†µ
              //_this.$Message.error('请求失败:' + (error.message || '未知错误'));
            });
        };
      }
      var GroupPalletBtn = this.buttons.find((x) => x.value == "GroupPallet");
      if (GroupPalletBtn != null) {
        GroupPalletBtn.onClick = () => {
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/BigGreenService/BigGreenService.cs
@@ -1,4 +1,5 @@
using IBigBreenService;
using Microsoft.IdentityModel.Tokens;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -11,6 +12,7 @@
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.Helper;
using WIDESEA_Model.Models;
namespace BigGreenService
@@ -59,13 +61,13 @@
                : Math.Round((decimal)inStockLocation / totalLocation, 4)*100;
            //计算入库任务和出库任务完成数量
            var inboundCount =_taskHtyRepository.Db.Queryable<Dt_Task_Hty>().Where(x => x.TaskType >= 500 && x.TaskType < 900).Count();
            var outboundCount =_taskHtyRepository.Db.Queryable<Dt_Task_Hty>().Where(x => x.TaskType >= 100 && x.TaskType < 500).Count();
            var inboundCount =_taskHtyRepository.Db.Queryable<Dt_Task_Hty>().Where(x => x.TaskType >= 500 && x.TaskType < 900 && x.CreateDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")).Count();
            var outboundCount =_taskHtyRepository.Db.Queryable<Dt_Task_Hty>().Where(x => x.TaskType >= 100 && x.TaskType < 500 && x.CreateDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")).Count();
            //计算有货料箱数量
            var inStockPallet = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType ==(int) PalletTypeEnum.None).Count();
            var inStockPallet = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType ==(int) PalletTypeEnum.None && !string.IsNullOrEmpty(x.LocationCode)).Count();
            //计算空箱数量
            var freeStockPallet = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType == (int)PalletTypeEnum.Empty).Count();
            var freeStockPallet = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType == (int)PalletTypeEnum.Empty && !string.IsNullOrEmpty(x.LocationCode)).Count();
            // 4. èŽ·å–è¿‘7日每日出入库明细(核心修改:调用上面的方法)
            var dailyInOutBoundList = Get7DaysDailyInOutBound();
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Common/OrderEnum/InboundOrderMenu.cs
@@ -31,10 +31,10 @@
        å…¥åº“完成 = 2,
        /// <summary>
        /// å…³é—­
        /// æ‰‹åЍ关闭
        /// </summary>
        [Description("关闭")]
        å…³é—­ = 99,
        [Description("手动关闭")]
        æ‰‹åЍ关闭 = 99,
        /// <summary>
        /// å–消
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs
@@ -24,8 +24,10 @@
        WebResponseContent UnPalletQuantity(string orderNo);
        WebResponseContent UndoPalletGroup(string palletCode , string barcode = "");
        WebResponseContent UndoPalletGroup(string code);
        WebResponseContent UnPalletGroupBarcode(string orderNo);
        WebResponseContent HandCloseOrder(List<int> orderIds);
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs
@@ -18,6 +18,7 @@
using WIDESEA_Core.Utilities;
using WIDESEA_DTO.Base;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicService;
using WIDESEA_IInboundService;
using WIDESEA_IRecordService;
@@ -466,7 +467,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
                if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
@@ -659,9 +660,9 @@
                {
                    resultDTO.UniqueUnit = "";
                }
                var inbound =_inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo);
                var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo);
                var inboundDetails = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.OrderId == inbound.First().Id).ToList();
                resultDTO.StockSumQuantity = inboundDetails.Where(x=>x.ReceiptQuantity==0).Sum(x=>x.OrderQuantity);
                resultDTO.StockSumQuantity = inboundDetails.Where(x => x.ReceiptQuantity == 0).Sum(x => x.OrderQuantity);
                resultDTO.StockCount = inboundDetails.Where(x => x.ReceiptQuantity == 0).Count();
                //var validDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList();
                //resultDTO.StockSumQuantity = orderDetail.Details.Sum(d => d.OrderQuantity);
@@ -680,91 +681,139 @@
            }
        }
        public WebResponseContent UndoPalletGroup(string palletCode, string barcode = "")
        /// <summary>
        /// æ’¤é”€ç»„盘(智能识别输入是托盘号或条码)
        /// </summary>
        /// <param name="code">托盘号或条码</param>
        /// <returns>操作结果</returns>
        public WebResponseContent UndoPalletGroup(string code)
        {
            if (string.IsNullOrWhiteSpace(palletCode))
            if (string.IsNullOrWhiteSpace(code))
            {
                return WebResponseContent.Instance.Error("托盘号不能为空");
                return WebResponseContent.Instance.Error("托盘号或条码不能为空");
            }
            try
            {
                _unitOfWorkManage.BeginTran();
                // 2. æŸ¥è¯¢æ‰˜ç›˜åº“存主记录(避免无数据抛异常)
                var stock = _stockRepository.Db.Queryable<Dt_StockInfo>()
                    .Includes(o => o.Details)
                    .First(x => x.PalletCode == palletCode
                                         && (x.StockStatus == (int)StockStatusEmun.组盘暂存
                                             || x.StockStatus == StockStatusEmun.入库确认.ObjToInt()));
                // æ™ºèƒ½è¯†åˆ«è¾“入类型
                string palletCode = null;
                string barcode = null;
                if (stock == null)
                // 1. å…ˆå°è¯•按托盘号查询
                var stockByPallet = _stockRepository.Db.Queryable<Dt_StockInfo>()
                    .Includes(o => o.Details)
                    .First(x => x.PalletCode == code
                        && (x.StockStatus == (int)StockStatusEmun.组盘暂存
                            || x.StockStatus == StockStatusEmun.入库确认.ObjToInt()));
                if (stockByPallet != null)
                {
                    return WebResponseContent.Instance.Error($"未找到托盘号{palletCode}对应的库存记录");
                    // è¯†åˆ«ä¸ºæ‰˜ç›˜å·
                    palletCode = code;
                }
                else
                {
                    var detail = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(d => d.Barcode == code).First();
                    if (detail != null)
                    {
                        var stockInfo = _stockRepository
                            .Db.Queryable<Dt_StockInfo>()
                            .Where(s => s.Id == detail.StockId&& (s.StockStatus == (int)StockStatusEmun.组盘暂存 || s.StockStatus == StockStatusEmun.入库确认.ObjToInt()))
                            .First();
                        if (stockInfo != null)
                        {
                            barcode = code;
                            palletCode = stockInfo.PalletCode;
                        }
                    }
                    else
                    {
                        _unitOfWorkManage.RollbackTran();
                        return WebResponseContent.Instance.Error($"未找到 {code} å¯¹åº”的托盘或条码记录");
                    }
                }
                // 3. åœºæ™¯1:删除指定条码
                // æ ¹æ®è¯†åˆ«ç»“果执行撤销逻辑
                if (!string.IsNullOrWhiteSpace(barcode))
                {
                    // ===== æ’¤é”€æŒ‡å®šæ¡ç  =====
                    var stock = _stockRepository.Db.Queryable<Dt_StockInfo>()
                        .Includes(o => o.Details)
                        .First(x => x.PalletCode == palletCode
                            && (x.StockStatus == (int)StockStatusEmun.组盘暂存
                                || x.StockStatus == StockStatusEmun.入库确认.ObjToInt()));
                    if (stock == null)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return WebResponseContent.Instance.Error($"未找到托盘号 {palletCode} å¯¹åº”的库存记录");
                    }
                    var targetDetail = stock.Details?.FirstOrDefault(x => x.Barcode == barcode);
                    if (targetDetail == null)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return WebResponseContent.Instance.Error($"托盘{palletCode}下未找到条码{barcode}的明细记录");
                        return WebResponseContent.Instance.Error($"托盘 {palletCode} ä¸‹æœªæ‰¾åˆ°æ¡ç  {barcode} çš„æ˜Žç»†è®°å½•");
                    }
                    ResetInboundOrderStatus(new List<string> { targetDetail.OrderNo }, new List<string> { targetDetail.Barcode });
                    // åˆ é™¤æŒ‡å®šæ˜Žç»†
                    _stockDetailRepository.DeleteData(targetDetail);
                    // é‡æ–°æŸ¥è¯¢å‰©ä½™æ˜Žç»†ï¼ˆä¿è¯æ•°æ®å‡†ç¡®æ€§ï¼‰
                    var remainingDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>()
                        .Where(x => x.StockId == stock.Id)
                        .ToList();
                    // å‰©ä½™æ˜Žç»†ä¸ºç©º â†’ åˆ é™¤ä¸»è¡¨ + é‡ç½®å…¥åº“单及明细状态
                    if (!remainingDetails.Any())
                    {
                        // é‡ç½®å…¥åº“单及明细状态
                        ResetInboundOrderStatus(stock.Details.Select(d => d.OrderNo).Distinct().ToList());
                        _stockRepository.DeleteData(stock);
                        _unitOfWorkManage.CommitTran();
                        return WebResponseContent.Instance.OK($"条码{barcode}撤销成功,托盘无剩余明细,已删除托盘并重置关联入库单状态");
                        return WebResponseContent.Instance.OK($"条码 {barcode} æ’¤é”€æˆåŠŸï¼Œæ‰˜ç›˜æ— å‰©ä½™æ˜Žç»†ï¼Œå·²åˆ é™¤æ‰˜ç›˜å¹¶é‡ç½®å…³è”å…¥åº“å•çŠ¶æ€");
                    }
                    _unitOfWorkManage.CommitTran();
                    return WebResponseContent.Instance.OK($"条码{barcode}撤销成功,托盘仍有剩余明细");
                    return WebResponseContent.Instance.OK($"条码 {barcode} æ’¤é”€æˆåŠŸï¼Œæ‰˜ç›˜ä»æœ‰å‰©ä½™æ˜Žç»†");
                }
                // åˆ é™¤æ•´æ‰˜ç›˜ï¼ˆæ— æ¡ç ä¼ å…¥ï¼‰
                if (stock.Details == null || !stock.Details.Any())
                else
                {
                    // ===== æ’¤é”€æ•´ä¸ªæ‰˜ç›˜ =====
                    var stock = _stockRepository.Db.Queryable<Dt_StockInfo>()
                        .Includes(o => o.Details)
                        .First(x => x.PalletCode == palletCode
                            && (x.StockStatus == (int)StockStatusEmun.组盘暂存
                                || x.StockStatus == StockStatusEmun.入库确认.ObjToInt()));
                    if (stock == null)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return WebResponseContent.Instance.Error($"未找到托盘号 {palletCode} å¯¹åº”的库存记录");
                    }
                    if (stock.Details == null || !stock.Details.Any())
                    {
                        _stockRepository.DeleteData(stock);
                        _unitOfWorkManage.CommitTran();
                        return WebResponseContent.Instance.OK("托盘无明细记录,已直接删除托盘主数据");
                    }
                    var relatedOrderNos = stock.Details.Select(d => d.OrderNo).Distinct().ToList();
                    if (!relatedOrderNos.Any())
                    {
                        _unitOfWorkManage.RollbackTran();
                        return WebResponseContent.Instance.Error("库存明细未关联任何入库单号,无法完成撤销");
                    }
                    ResetInboundOrderStatus(relatedOrderNos, stock.Details.Select(d => d.Barcode).ToList());
                    _stockDetailRepository.DeleteData(stock.Details);
                    _stockRepository.DeleteData(stock);
                    _unitOfWorkManage.CommitTran();
                    return WebResponseContent.Instance.OK("托盘无明细记录,已直接删除托盘主数据");
                    return WebResponseContent.Instance.OK("托盘撤销成功,已重置关联入库单及明细状态");
                }
                // æœ‰æ˜Žç»† â†’ é‡ç½®å…¥åº“单及明细状态 + åˆ é™¤åº“å­˜
                var relatedOrderNos = stock.Details.Select(d => d.OrderNo).Distinct().ToList();
                if (!relatedOrderNos.Any())
                {
                    _unitOfWorkManage.RollbackTran();
                    return WebResponseContent.Instance.Error("库存明细未关联任何入库单号,无法完成撤销");
                }
                // é‡ç½®å…¥åº“单主状态 + æ˜Žç»†çŠ¶æ€
                ResetInboundOrderStatus(relatedOrderNos, stock.Details.Select(d => d.Barcode).ToList());
                // 4.3 åˆ é™¤åº“存明细和主表
                _stockDetailRepository.DeleteData(stock.Details);
                _stockRepository.DeleteData(stock);
                _unitOfWorkManage.CommitTran();
                return WebResponseContent.Instance.OK("托盘撤销成功,已重置关联入库单及明细状态");
            }
            catch (Exception ex)
            {
@@ -803,6 +852,10 @@
                {
                    detail.ReceiptQuantity = 0;
                    detail.OrderDetailStatus = 0;
                    if(inboundOrder.BusinessType == "11")
                    {
                        detail.WarehouseCode = "";
                    }
                    _inboundOrderDetailRepository.UpdateData(detail);
                }
            }
@@ -904,14 +957,36 @@
        {
            WebResponseContent content = new WebResponseContent();
            var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo).First();
            if(inbound == null)
            if (inbound == null)
            {
                return content.Error();
            }
            var details = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.OrderId == inbound.Id && x.ReceiptQuantity == 0).ToList();
            return content.OK(data:details);
            return content.OK(data: details);
        }
        public WebResponseContent HandCloseOrder(List<int> orderIds)
        {
            try
            {
                foreach (int id in orderIds)
                {
                    var inbound = _inboundOrderRepository.QueryFirst(x => x.Id == id);
                    if(inbound.OrderStatus !=(int)InOrderStatusEnum.未开始 && inbound.OrderStatus != (int)InOrderStatusEnum.入库中)
                    {
                        return WebResponseContent.Instance.Error($"该单据状态不可以关闭");
                    }
                    inbound.OrderStatus = (int)InOrderStatusEnum.手动关闭;
                    _inboundOrderRepository.UpdateData(inbound);
                }
                return WebResponseContent.Instance.OK($"单据关闭成功");
            }
            catch (Exception e)
            {
                return WebResponseContent.Instance.Error(e.Message);
            }
        }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs
@@ -83,6 +83,7 @@
                }
                Dt_InboundOrder inboundOrder = new Dt_InboundOrder();
                var details = _inboundOrderDetailRepository.QueryData(x => (x.OutBoxbarcodes == palletDto.Barcode|| x.Barcode == palletDto.Barcode) && x.OrderDetailStatus == (int)InOrderStatusEnum.未开始);
                if (details.Count() <= 0)
@@ -95,6 +96,10 @@
                {
                    return content.Error("未找到该条码主单信息");
                }
                if(inboundOrder.OrderStatus == (int)InOrderStatusEnum.手动关闭)
                {
                    return content.Error("该单据的状态不能组盘");
                }
                var warehouse =_warehouseAreaRepository.QueryFirst(x => x.Code == palletDto.WarehouseType);
                if(inboundOrder.BusinessType=="11" && inboundOrder.FactoryArea != warehouse.FactoryArea)
                {
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -2,6 +2,7 @@
using AutoMapper;
using MailKit.Search;
using SqlSugar;
using System.Text.RegularExpressions;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
@@ -546,5 +547,34 @@
            return result;
        }
        public override PageGridData<Dt_StockInfo> GetPageData(PageDataOptions options)
        {
            string wheres = ValidatePageOptions(options);
            //获取排序字段
            Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
            List<OrderByModel> orderByModels = new List<OrderByModel>();
            foreach (var item in orderbyDic)
            {
                OrderByModel orderByModel = new()
                {
                    FieldName = item.Key,
                    OrderByType = item.Value
                };
                orderByModels.Add(orderByModel);
            }
            ISugarQueryable<Dt_StockInfo> sugarQueryable1 = BaseDal.Db.Queryable<Dt_StockInfo>();
            int totalCount = 0;
            List<SearchParameters> searchParametersList = new List<SearchParameters>();
            var data = sugarQueryable1
                .WhereIF(!wheres.IsNullOrEmpty(), wheres)
                .Where(x => !string.IsNullOrEmpty(x.LocationCode))
                .OrderBy(orderByModels)
                .ToPageList(options.Page, options.Rows, ref totalCount);
            return new PageGridData<Dt_StockInfo>(totalCount, data);
        }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs
@@ -228,9 +228,9 @@
        }
        [HttpPost, Route("UndoPalletGroup"), AllowAnonymous, MethodParamsValidate]
        public WebResponseContent UndoPalletGroup(string palletCode,string barcode="")
        public WebResponseContent UndoPalletGroup(string code)
        {
            return Service.UndoPalletGroup(palletCode,barcode);
            return Service.UndoPalletGroup(code);
        }
        /// <summary>
        /// 
@@ -258,5 +258,11 @@
            return await _invokeMESService.BatchOrderFeedbackToMes(request.orderNos, request.inout);
        }
        [HttpPost, Route("HandCloseOrder"), AllowAnonymous, MethodParamsValidate]
        public WebResponseContent HandCloseOrder(List<int> orderIds)
        {
            return Service.HandCloseOrder(orderIds);
        }
    }
}