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<Dt_Packinfo, IPackinfoRepository>, IPackinfoService
|
{
|
private readonly IMapper _mapper;
|
private readonly IPackTypeRepository _typeRepository;
|
public PackinfoService(IPackinfoRepository BaseDal,IMapper mapper, IPackTypeRepository typeRepository) : base(BaseDal)
|
{
|
_mapper = mapper;
|
_typeRepository = typeRepository;
|
}
|
/// <summary>
|
/// 接收MES成品码垛
|
/// </summary>
|
/// <returns></returns>
|
public WebResponseContent ReceivePackaxisTask(List<MESProPackInfoDTO> mESProPackInfoDTOs)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
List<Dt_PackType> packTypes = _typeRepository.QueryData();
|
List<Dt_Packinfo> packinfos = new List<Dt_Packinfo>();
|
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<Dt_Packinfo>(item);
|
packinfo.PackType = packType.Id;
|
packinfos.Add(packinfo);
|
}
|
BaseDal.AddData(packinfos);
|
content.OK();
|
}
|
catch (Exception ex)
|
{
|
content.Error(ex.Message);
|
}
|
return content;
|
}
|
}
|
}
|