雷神教育集团
2026-03-06 75c4ed0d3c640e66bc95dc170de52b753629e3ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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);
<<<<<<< HEAD
                    packinfo.PackType = packType.id;
=======
                    packinfo.PackType = packType.Id;
>>>>>>> main
                    packinfos.Add(packinfo);
                }
                BaseDal.AddData(packinfos);
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}