z8018
2025-12-17 20a71f4bafb8cda355948cc061827b8d4752966f
Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
已添加3个文件
已修改7个文件
732 ■■■■■ 文件已修改
项目代码/WIDESEA_WMSClient/src/extension/inbound/allocateinboundOrder.js 253 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Common/OrderEnum/TakeStockStatusEnum.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Core/CodeConfigEnum/RuleCodeEnum.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrder.cs 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrderDetail.cs 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs 185 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/inbound/allocateinboundOrder.js
@@ -3,12 +3,13 @@
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,解决提示无反应
import gridBody from '../inbound/extend/Pallet.vue'
import gridHeader from './extend/EmptyTrayInbound.vue'
let extension = {
    components: {
      //查询界面扩展组件
      gridHeader: '',
      gridBody: '',
      gridHeader: gridHeader,
      gridBody: gridBody,
      gridFooter: '',
      //新建、编辑弹出框扩展组件
      modelHeader: '',
@@ -17,32 +18,32 @@
    },
    tableAction: '', //指定某张表的权限(这里填写表名,默认不用填写)
    buttons: { view: [
       {
        name: '组盘',
        type: 'primary',
        value: '组盘',
        onClick: function () { // ä¿®å¤1:移除无用row参数,加日志调试
          console.log('组盘按钮被点击,开始校验');
          const selectedRows = this.$refs.table.getSelected();
      //  {
      //   name: '组盘',
      //   type: 'primary',
      //   value: '组盘',
      //   onClick: function () { // ä¿®å¤1:移除无用row参数,加日志调试
      //     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;
          }
      //     // æ ¡éªŒ1:是否选中行
      //     if (selectedRows.length === 0) {
      //       console.log('校验不通过:未选中任何单据');
      //       ElMessage.warning('请选择一条单据');
      //       return;
      //     }
      //     // æ ¡éªŒ2:是否选中单行
      //     if (selectedRows.length > 1) {
      //       console.log('校验不通过:选中多行单据');
      //       ElMessage.warning('只能选择一条单据');
      //       return;
      //     }
          const targetRow = selectedRows[0];
      //     const targetRow = selectedRows[0];
     
          this.$emit('openPalletDialog', targetRow.orderNo);
        }
      },
      //     this.$emit('openPalletDialog', targetRow.orderNo);
      //   }
      // },
      {
                name: '撤销组盘',
                type: 'primary',
@@ -243,196 +244,22 @@
      ElMessage.error('网络异常或接口错误,请稍后重试');
    }
  }
},
     {
  name: '空托盘入库',
  type: 'primary',
  value: '空托盘入库',
  onClick: function () {
    const mountNode = document.createElement('div');
    document.body.appendChild(mountNode);
    const boxCodeReg = /^[A-Z]\d{9}$/;
    // å“åº”式表单数据:料箱码(必填,扫码枪/手动输入)
    const formData = reactive({
      boxCode: '',
      warehouseCode:''
    });
    const warehouses = ref([]);
    const isLoadingWarehouses = ref(false);
    const getWarehouseList = async () => {
      isLoadingWarehouses.value = true;
      try {
        const { data, status } = await http.post('/api/LocationInfo/GetLocationTypes');
        if (status && Array.isArray(data)) {
          // æ ¼å¼åŒ–仓库选项:适配ElSelect的label-value格式
          warehouses.value = data.map(item => ({
            label: item.locationTypeDesc,
            value: item.locationType
          }));
        } else {
          ElMessage.error('获取区域列表失败');
          warehouses.value = [];
        }
      } catch (err) {
        ElMessage.error('区域数据请求异常,请稍后重试');
        warehouses.value = [];
      } finally {
        isLoadingWarehouses.value = false;
      }
    };
    // æäº¤è¡¨å•的统一逻辑(供回车触发和按钮点击共用)
    const submitForm = async () => {
      const formRef = vnode.component.refs.batchInForm;
      if (!boxCodeReg.test(formData.boxCode.trim())) {
        ElMessage.warning('料箱码格式错误');
        selectBoxCodeInput();
        return;
      }
      try {
        // æ‰§è¡Œè¡¨å•校验(料箱码必填)
        await formRef.validate();
      } catch (err) {
        const errorMsg = err?.[0]?.message || '请输入有效的料箱码';
        ElMessage.warning(errorMsg);
        selectBoxCodeInput();
        return;
      }
      http.post('/api/InboundOrder/EmptyMaterielGroup', {
        palletCode: formData.boxCode.trim(),
        warehouseCode:formData.warehouseCode
      }).then(({ data, status, message }) => {
        if (status) {
          ElMessage.success(`入库成功,料箱码:${formData.boxCode.trim()}`);
          this.refresh();
          formData.boxCode = '';
          setTimeout(() => {
            const inputRef = vnode.component.refs.boxCodeInput;
            inputRef?.focus();
          }, 100);
        } else {
          ElMessage.error(message || data?.message || '入库失败');
          selectBoxCodeInput();
        }
      }).catch(() => {
        ElMessage.error('请求失败,请稍后重试');
        selectBoxCodeInput();
      });
    };
    const selectBoxCodeInput = () => {
      setTimeout(() => {
        const inputRef = vnode.component.refs.boxCodeInput;
        if (inputRef) {
          const targetInput = inputRef.$el?.querySelector('input') || inputRef;
          targetInput?.focus();
          targetInput?.select();
        }
  }, 100);
}
    const vnode = createVNode(ElDialog, {
      title: '空托盘入库',
      width: '400px',
      modelValue: true,
      appendToBody: true,
      onOpened: async () => {
        await getWarehouseList();
        const inputRef = vnode.component.refs.boxCodeInput;
        inputRef?.focus();
      },
      'onUpdate:modelValue': (isVisible) => {
        if (!isVisible) {
          render(null, mountNode);
          document.body.removeChild(mountNode);
        }
      }
    }, {
      default: () => h(ElForm, {
        model: formData,
        rules: {
          boxCode: [
            { required: true, message: '请输入料箱码', trigger: ['blur', 'change'] },
            { pattern: boxCodeReg, message: '料箱码格式错误', trigger: ['blur', 'change'] }
          ],
          warehouseCode:[
            { required: true, message: '请选择区域', trigger: ['change', 'blur'] }
          ]
        },
        ref: 'batchInForm'
      }, [
        //仓库数据
        h(ElFormItem, { label: '区域', prop: 'warehouseCode', required: true }, [
          h(ElSelect, {
            modelValue: formData.warehouseCode,
            'onUpdate:modelValue': (val) => {
              formData.warehouseCode = val;
            },
            placeholder: '请选择入库区域',
            filterable: true, // æ”¯æŒæœç´¢ä»“库
            loading: isLoadingWarehouses.value, // åŠ è½½çŠ¶æ€
            style: { width: '100%' }
          }, [
            // æ¸²æŸ“仓库下拉选项
            warehouses.value.map(item => h(ElOption, {
              label: item.label,
              value: item.value
            }))
          ])
        ]),
        // æ–™ç®±ç è¾“入项(支持聚焦、回车提交)
        h(ElFormItem, { label: '料箱码', prop: 'boxCode', required: true }, [
          h(ElInput, {
            type: 'text',
            modelValue: formData.boxCode,
            'onUpdate:modelValue': (val) => {
              formData.boxCode = val;
            },
            ref: 'boxCodeInput',
            placeholder: '扫码输入或手动输入料箱码',
            // ç›‘听回车事件(扫码枪默认会发送回车)
            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
          }, '确定')
        ])
      ])
    });
    vnode.appContext = this.$.appContext;
    render(vnode, mountNode);
  }
}
    ], box: [], detail: [] },
},], box: [], detail: [] },
    methods: {
       //下面这些方法可以保留也可以删除
      onInit() {  
        var GroupPalletBtn = this.buttons.find(x => x.value == "GroupPallet");
        if (GroupPalletBtn != null) {
          GroupPalletBtn.onClick = () => {
               this.$refs.gridBody.open();
            }
        }
        var EmptyTrayInboundBtn = this.buttons.find(x => x.value == "EmptyTrayInbound");
        if (EmptyTrayInboundBtn != null) {
          EmptyTrayInboundBtn.onClick = () => {
               this.$refs.gridHeader.open();
            }
        }
      },
      onInited() {
        
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue
@@ -371,7 +371,7 @@
      this.sumLoading = true;
      this.sumError = '';
      try {
        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + this.docNo, {});
        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + this.orderNo, {});
        if (response.data) {
          this.totalStockSum = response.data.stockSumQuantity || 0;
          this.totalStockCount = response.data.stockCount || 0;
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Common/OrderEnum/TakeStockStatusEnum.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEA_Common.OrderEnum
{
    /// <summary>
    /// ç›˜ç‚¹çŠ¶æ€
    /// </summary>
    public enum TakeStockStatusEnum
    {
        /// <summary>
        /// æœªç›˜ç‚¹
        /// </summary>
        [Description("未盘点")]
        æœªç›˜ç‚¹ = 0,
        /// <summary>
        /// ç›˜ç‚¹ä¸­
        /// </summary>
        [Description("盘点中")]
        ç›˜ç‚¹ä¸­ = 1,
        /// <summary>
        /// ç›˜ç‚¹å®Œæˆ
        /// </summary>
        [Description("盘点完成")]
        ç›˜ç‚¹å®Œæˆ = 2,
        /// <summary>
        /// ç›˜ç‚¹å…³é—­
        /// </summary>
        [Description("盘点关闭")]
        ç›˜ç‚¹å…³é—­ = 3,
    }
    /// <summary>
    /// ç›˜ç‚¹æ˜Žç»†çŠ¶æ€
    /// </summary>
    public enum TakeStockDetailStatusEnum
    {
        /// <summary>
        /// æœªç›˜ç‚¹
        /// </summary>
        [Description("未盘点")]
        æœªç›˜ç‚¹ = 0,
        /// <summary>
        /// ç›˜ç‚¹ä¸­
        /// </summary>
        [Description("盘点出库中")]
        ç›˜ç‚¹å‡ºåº“中 = 1,
        /// <summary>
        /// ç›˜ç‚¹å‡ºåº“完成
        /// </summary>
        [Description("盘点出库完成")]
        ç›˜ç‚¹å‡ºåº“完成 = 2,
        /// <summary>
        /// ç›˜ç‚¹å®Œæˆ
        /// </summary>
        [Description("盘点完成")]
        ç›˜ç‚¹å®Œæˆ = 3
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Core/CodeConfigEnum/RuleCodeEnum.cs
@@ -51,6 +51,13 @@
        [Description("调拨单号编码规则")]
        AllocateOrderCodeRule,
        NewBarcodeRule
        NewBarcodeRule,
        /// <summary>
        /// ç›˜ç‚¹å•号编码规则
        /// </summary>
        [Description("盘点单号编码规则")]
        PDCodeRule
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs
@@ -54,5 +54,12 @@
        Task<WebResponseContent> GenerateOutboundBatchTasksAsync(int orderDetailId, decimal batchQuantity, string outStation);
        Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews, string station);
        /// <summary>
        /// åº“存盘点
        /// </summary>
        /// <param name="stockViews"></param>
        /// <returns></returns>
       Task <WebResponseContent> TakeOutbound(List<StockViewDTO> stockViews,string outStation);
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs
@@ -63,13 +63,8 @@
                    return content.Error($"仓库中没有该{palletDto.WarehouseType}编号。");
                }
                List<Dt_InboundOrderDetail> details = new List<Dt_InboundOrderDetail>();
                Dt_InboundOrder inboundOrder = new Dt_InboundOrder();
                details = _inboundOrderDetailRepository.QueryData(x => x.OutBoxbarcodes == palletDto.Barcode && x.OrderDetailStatus == (int)InOrderStatusEnum.未开始);
                if (details.Count <= 0)
                {
                    details = _inboundOrderDetailRepository.QueryData(x => x.Barcode == palletDto.Barcode && x.OrderDetailStatus == (int)InOrderStatusEnum.未开始);
                }
                var details = _inboundOrderDetailRepository.QueryData(x => (x.OutBoxbarcodes == palletDto.Barcode|| x.Barcode == palletDto.Barcode) && x.OrderDetailStatus == (int)InOrderStatusEnum.未开始);
                if (details.Count() <= 0)
                {
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrder.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,62 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.DB.Models;
using WIDESEA_Core.Enums;
namespace WIDESEA_Model.Models
{
    /// <summary>
    /// ç›˜ç‚¹å•
    /// </summary>
    [SugarTable(nameof(Dt_TakeStockOrder), "盘点单")]
    public class Dt_TakeStockOrder : BaseEntity
    {
        /// <summary>
        /// ä¸»é”®
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
        public int Id { get; set; }
        /// <summary>
        /// ç›˜ç‚¹å•号
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "盘点单号")]
        public string OrderNo { get; set; }
        /// <summary>
        /// ä»“库主键
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "所属仓库")]
        public int WarehouseId { get; set; }
        /// <summary>
        /// ç›˜ç‚¹çŠ¶æ€
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "盘点状态")]
        public int TakeStockStatus { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "备注")]
        public string Remark { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "所含盘点托盘")]
        public string AllPalletCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹æ˜Žç»†
        /// </summary>
        [PropertyValidate("盘点明细", NotNullAndEmpty = true), Navigate(NavigateType.OneToMany, nameof(Dt_TakeStockOrderDetail.TakeStockId), nameof(Id))]
        public List<Dt_TakeStockOrderDetail> Details { get; set; }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrderDetail.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,125 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.DB.Models;
namespace WIDESEA_Model.Models
{
    /// <summary>
    /// ç›˜ç‚¹å•明细
    /// </summary>
    [SugarTable(nameof(Dt_TakeStockOrderDetail), "盘点单明细")]
    public class Dt_TakeStockOrderDetail : BaseEntity
    {
        /// <summary>
        /// ä¸»é”®
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
        public int Id { get; set; }
        /// <summary>
        /// ç›˜ç‚¹å•主键
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "盘点单主键")]
        public int TakeStockId { get; set; }
        /// <summary>
        /// ç‰©æ–™ç¼–码
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "物料编码")]
        public string MaterielCode { get; set; }
        /// <summary>
        /// ç‰©æ–™åç§°
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 200, ColumnDescription = "物料名称")]
        public string MaterielName { get; set; }
        /// <summary>
        /// æ‰¹æ¬¡å·
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "批次号")]
        public string BatchNo { get; set; }
        /// <summary>
        /// ç‰©æ–™è§„æ ¼
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "物料规格")]
        public string MaterielSpec { get; set; }
        /// <summary>
        /// åŽŸä»“ä½
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "原仓位")]
        public string LocationCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹æ‰˜ç›˜
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "盘点托盘")]
        public string TakePalletCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹æ˜Žç»†çŠ¶æ€
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "盘点明细状态")]
        public int TakeDetalStatus { get; set; }
        /// <summary>
        /// å•位
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "单位")]
        public string Unit { get; set; }
        /// <summary>
        /// è´¦é¢æ•°é‡
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "账面数量")]
        public decimal SysQty { get; set; }
        /// <summary>
        /// å®žç›˜æ•°é‡
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "实盘数量")]
        public decimal Qty { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "备注")]
        public string Remark { get; set; }
        /// <summary>
        /// æ¡ç 
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "条码")]
        public string barcode { get; set; }
        /// <summary>
        /// ç‰©æ–™ä»“库
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "物料仓库")]
        public string WarehouseCode { get; set; }
        /// <summary>
        /// åŽ‚åŒº
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 10, ColumnDescription = "厂区")]
        public string FactoryArea { get; set; }
        /// <summary>
        /// ä¾›åº”商编号
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "供应商编号")]
        public string SupplyCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹å•单据
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "盘点单单据")]
        public string TakeStockNo { get; set; }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using SqlSugar;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -16,9 +17,13 @@
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.DB;
using WIDESEA_Core.Helper;
using WIDESEA_Core.Seed;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Check;
@@ -1098,6 +1103,186 @@
        #endregion
        /// <summary>
        /// é€‰å®šåº“存生成盘点单出库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<WebResponseContent> TakeOutbound(List<StockViewDTO> stockViews, string outStation)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<int> ids = stockViews.Select(x => x.StockId).ToList();
                //获取库存
                List<Dt_StockInfo> stockInfos = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => ids.Contains(x.Id)).Includes(x => x.Details).ToList();
                if (stockInfos.Count != stockViews.Count)
                {
                    StockViewDTO? stockViewDTO = stockViews.FirstOrDefault(x => !stockInfos.Select(x => x.PalletCode).ToList().Contains(x.PalletCode));
                    return content.Error($"未找到{stockViewDTO?.PalletCode}库存");
                }
                //获取货位
                List<string> locStrs = stockInfos.Select(x => x.LocationCode).ToList();
                List<Dt_LocationInfo> locationInfos = (List<Dt_LocationInfo>)_locationInfoService.Db.Queryable<Dt_LocationInfo>().Where(x => locStrs.Contains(x.LocationCode));
                if (stockInfos.Count != locationInfos.Count)
                {
                    string? locStr = locStrs.FirstOrDefault(x => !locationInfos.Select(x => x.LocationCode).ToList().Contains(x));
                    return content.Error($"未找到{locStr}货位数据");
                }
                Dt_TakeStockOrder takeStockOrder = new Dt_TakeStockOrder()
                {
                    WarehouseId = stockInfos.FirstOrDefault().WarehouseId,
                    TakeStockStatus = TakeStockStatusEnum.盘点中.ObjToInt(),
                    OrderNo = CreateCodeByRule(nameof(RuleCodeEnum.PDCodeRule)),
                    Details = new List<Dt_TakeStockOrderDetail>()
                };
                foreach (var item in stockInfos)
                {
                    if (item.Details.Count <= 0)
                    {
                        return content.Error($"未找到{item.PalletCode}库存明细数据");
                    }
                    Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode);
                    if (locationInfo == null && (locationInfo.EnableStatus == EnableStatusEnum.Disable.ObjToInt() || locationInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && item.StockStatus != StockStatusEmun.入库完成.ObjToInt())
                    {
                        content.Error($"{item.PalletCode}货位或库存状态不满足出库条件");
                    }
                }
                List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutInventory,outStation);
                if (tasks == null || tasks.Count <= 0)
                {
                    return content.Error($"生成任务失败");
                }
                stockInfos.ForEach(x =>
                {
                    x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                });
                tasks.ForEach(x =>
                {
                    x.OrderNo = takeStockOrder.OrderNo;
                });
                locationInfos.ForEach(x =>
                {
                    x.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                });
                _unitOfWorkManage.BeginTran();
                //更新库存状态
                _stockRepository.UpdateData(stockInfos);
                BaseDal.Db.InsertNav(takeStockOrder);
                //新建任务
                BaseDal.AddData(tasks);
                _locationInfoService.UpdateData(locationInfos);
                _unitOfWorkManage.CommitTran();
                TaskModel esstask = new TaskModel()
                {
                    taskType = "carry",
                    taskGroupCode = "",
                    groupPriority = 0,
                    tasks = new List<TasksType>()
                };
                foreach (var task in tasks)
                {
                    esstask.
                       tasks.Add(new TasksType
                       {
                           taskCode = task.TaskNum.ToString(),
                           taskPriority = 0,
                           taskDescribe = new TaskDescribeType
                           {
                               containerCode = task.PalletCode,
                               containerType = "CT_KUBOT_STANDARD",
                               fromLocationCode = task.SourceAddress ?? "",
                               toStationCode = "",
                               toLocationCode = task.TargetAddress,
                               deadline = 0,
                               storageTag = ""
                           }
                       }
                   );
                }
                var result = await _eSSApiService.CreateTaskAsync(esstask);
                _logger.LogInformation("创建任务PalletOutboundTask è¿”回:  " + result);
                if (result)
                {
                    return WebResponseContent.Instance.OK();
                }
                else
                {
                    return WebResponseContent.Instance.Error("下发机器人任务失败!");
                }
                content.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// å•据生成方法
        /// </summary>
        static object lock_code = new object();
        public string CreateCodeByRule(string ruleCode)
        {
            lock (lock_code)
            {
                string code = string.Empty;
                DateTime dateTime = DateTime.Now;
                DateTime now = DateTime.Now;
                try
                {
                    if (string.IsNullOrEmpty(ruleCode))
                        throw new ArgumentNullException(nameof(ruleCode));
                    SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig
                    {
                        IsAutoCloseConnection = true,
                        DbType = DbType.SqlServer,
                        ConnectionString = DBContext.ConnectionString
                    });
                    Dt_CodeRuleConfig codeRuleConfig = sugarClient.Queryable<Dt_CodeRuleConfig>().Where(x => x.RuleCode == ruleCode).First();
                    if (codeRuleConfig == null)
                        throw new ArgumentNullException(nameof(codeRuleConfig));
                    if (codeRuleConfig.ModifyDate != null)
                    {
                        dateTime = Convert.ToDateTime(codeRuleConfig.ModifyDate);
                    }
                    else
                    {
                        dateTime = Convert.ToDateTime(codeRuleConfig.CreateDate);
                    }
                    if (now.Year == dateTime.Year && now.Month == dateTime.Month && now.Day == dateTime.Day)
                    {
                        now = dateTime;
                        codeRuleConfig.CurrentVal = Convert.ToInt32(codeRuleConfig.CurrentVal) + 1;
                    }
                    else
                    {
                        codeRuleConfig.CurrentVal = 1;
                    }
                    codeRuleConfig.ModifyDate = DateTime.Now;
                    code = codeRuleConfig.StartStr + codeRuleConfig.Format;
                    code = code.Replace($"[{CodeFormatTypeEnum.YYYY}]", now.Year.ToString().PadLeft(4, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.MM}]", now.Month.ToString().PadLeft(2, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.DD}]", now.Day.ToString().PadLeft(2, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.ST}]", codeRuleConfig.StartStr?.ToString() ?? "");
                    code = code.Replace($"[{CodeFormatTypeEnum.NUM}]", codeRuleConfig.CurrentVal.ToString().PadLeft(codeRuleConfig.Length, '0'));
                    Dictionary<string, object> keyValuePairs = new Dictionary<string, object>() { { nameof(codeRuleConfig.CurrentVal), codeRuleConfig.CurrentVal }, { nameof(codeRuleConfig.Id), codeRuleConfig.Id }, { nameof(codeRuleConfig.ModifyDate), DateTime.Now } };
                    sugarClient.Updateable(keyValuePairs).AS(MainDb.CodeRuleConfig).WhereColumns(nameof(codeRuleConfig.Id)).ExecuteCommand();
                    sugarClient.Updateable(codeRuleConfig);
                }
                catch (Exception ex)
                {
                }
                return code;
            }
        }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs
@@ -108,6 +108,18 @@
            return await Service.GenerateOutboundBatchTasksAsync(data.orderDetailId,data.batchQuantity, data.outboundPlatform);
        }
        /// <summary>
        /// ç›˜ç‚¹åº“存出库
        /// </summary>
        /// <param name="stockViews"></param>
        /// <param name="outStation"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("TakeOutbound"), AllowAnonymous]
        public async Task<WebResponseContent> TakeOutbound([FromBody] List<StockViewDTO> stockViews, string outStation)
        {
            return await Service.TakeOutbound(stockViews, outStation);
        }
    }
}