wangxinhui
2025-03-01 d11b1f9c98e8765d3cee15abd4474b0e05a5acbc
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs
@@ -24,10 +24,8 @@
using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Model.Models.Outbound;
using System.Diagnostics.Metrics;
using System.Reflection.Metadata;
using WIDESEA_Model.Models.Inbound;
using WIDESEA_DTO.Task;
namespace WIDESEA_TaskInfoService
@@ -467,7 +465,7 @@
                    OutboundQuantity = 0,
                    SerialNumber = stockInfoDetail_Hty?.SerialNumber ?? "0",
                    StockQuantity = model.Quantity,
                    Status = StockStatusEmun.MES退库.ObjToInt(),
                    Status = model.Quantity <= 0.0 ? StockStatusEmun.MES空托退库.ObjToInt() : StockStatusEmun.MES退库.ObjToInt(),
                    Unit = model.Unit
                };
                Dt_StockInfo stockInfo = new Dt_StockInfo()
@@ -475,8 +473,9 @@
                    PalletCode = model.CarrierCode,
                    PalletType = palletTypeInfo.PalletType,
                    WarehouseId = warehouse.WarehouseId,
                    StockStatus = StockStatusEmun.MES退库.ObjToInt(),
                    Details = new List<Dt_StockInfoDetail> { stockInfoDetail }
                    StockStatus = stockInfoDetail.StockQuantity <= 0.0 ? StockStatusEmun.MES空托退库.ObjToInt() : StockStatusEmun.MES退库.ObjToInt(),
                    Details = new List<Dt_StockInfoDetail> { stockInfoDetail },
                    Remark = stockInfoDetail.StockQuantity <= 0.0 ? StockStatusEmun.MES空托退库.ToString() : StockStatusEmun.MES退库.ToString()
                };
                //Dt_Task task = new Dt_Task()
                //{
@@ -523,7 +522,7 @@
                    {
                        return MesResponseContent.Instance.Error("仓库信息未配置");
                    }
                    Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == item.CarrierCode);
                    Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == item.CarrierCode || x.WarehouseId == warehouse.WarehouseId);
                    if (stockInfo == null)
                    {
                        return MesResponseContent.Instance.Error("未找到此载具编号库存");
@@ -884,8 +883,6 @@
            }
        }
        /// <summary>
        ///  PP库存查询
        /// </summary>
@@ -896,6 +893,7 @@
            MesResponseContent content = new MesResponseContent();
            try
            {
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA58.ToString());
                List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x =>
                x.WarehouseId == warehouse.WarehouseId &&
@@ -911,7 +909,6 @@
                    content.BSucc = true;
                    content.StrCode = "0000";
                    content.StrMsg = "执行成功";
                    content.DataTime = DateTime.Now;
                    content.MaterialCode = stock.MaterielCode;
                    content.Quantity = stock.StockQuantity;
                    content.Unit = stock.Unit;
@@ -928,6 +925,76 @@
                return MesResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// MES成品入库单接收
        /// </summary>
        /// <returns></returns>
        public MesResponseContent BagInfoSync(MesBagInfoModel bagInfoModel)
        {
            MesResponseContent content = new MesResponseContent();
            try
            {
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==bagInfoModel.WarehouseCode);
                if (warehouse==null)
                {
                    return content.Error("未找到仓库信息");
                }
                List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>();
                foreach (var item in bagInfoModel.BagDetails)
                {
                    mesProInOrderDetails.Add(_mapper.Map<Dt_MesProInOrderDetail>(item));
                }
                mesProInOrderDetails.ForEach(x =>
                {
                    x.OverInQuantity = 0;
                });
                Dt_MesProInOrder mesProInOrder = new Dt_MesProInOrder()
                {
                    WarehouseId = warehouse.WarehouseId,
                    BatchNo = bagInfoModel.BatchNo,
                    MesProStatus = InOrderStatusEnum.未开始.ObjToInt(),
                    UnPackStock=bagInfoModel.UnPackStock,
                    Details= mesProInOrderDetails
                };
                Db.InsertNav(mesProInOrder).Include(x=>x.Details).ExecuteCommand();
                return content.OK("接收成功");
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// æˆå“è¿”工提库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public MesResponseContent RworkTask(RworkTaskModel model)
        {
            try
            {
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString());
                //获取库存记录
                List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x =>
                  x.WarehouseId == warehouse.WarehouseId &&
                  x.StockStatus == (int)StockStatusEmun.入库完成).Includes(x => x.Details).ToList();
                Dt_StockInfo? stockInfo = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == model.ProductVersion));
                if (stockInfo == null)
                {
                    return MesResponseContent.Instance.Error($"尾数仓:{model.ProductVersion}无可用库存");
                }
                Dt_Task exsit2 = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
            }
            catch (Exception ex)
            {
                throw;
            }
            return MesResponseContent.Instance.OK();
        }
    }
}