using Magicodes.ExporterAndImporter.Excel.Utility; using Microsoft.AspNetCore.Http; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Core.BaseRepository; using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseServices; using WIDESEAWCS_IPackInfoRepository; using WIDESEAWCS_Common.Utilities; using WIDESEAWCS_Model.Models; using WIDESEAWCS_Core.Helper; using WIDESEAWCS_IPackInfoService; using WIDESEAWCS_DTO.PackInfo; using AutoMapper; namespace WIDESEAWCS_PackInfoService { public class PackinfoService : ServiceBase, IPackinfoService { private readonly IMapper _mapper; private readonly IPackTypeRepository _typeRepository; public PackinfoService(IPackinfoRepository BaseDal,IMapper mapper, IPackTypeRepository typeRepository) : base(BaseDal) { _mapper = mapper; _typeRepository = typeRepository; } /// /// 接收MES成品码垛 /// /// public WebResponseContent ReceivePackaxisTask(List mESProPackInfoDTOs) { WebResponseContent content = new WebResponseContent(); try { List packTypes = _typeRepository.QueryData(); List packinfos = new List(); foreach (var item in mESProPackInfoDTOs) { Dt_PackType? packType = packTypes.FirstOrDefault(x=>x.PackWidth==item.Width && x.PackLength==item.Length && x.PackHeight==item.Height); if (packType == null) throw new Exception($"未找到条码{item.BarCode},{item.Length}*{item.Width}*{item.Height}码垛配置"); Dt_Packinfo packinfo = _mapper.Map(item); packinfo.PackType = packType.Id; packinfos.Add(packinfo); } BaseDal.AddData(packinfos); content.OK(); } catch (Exception ex) { content.Error(ex.Message); } return content; } } }