wangxinhui
2026-03-07 d82252f08a32f5786ffe231b7fd301b6a60781d6
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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_Common.Utilities;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_IPackInfoRepository;
using WIDESEAWCS_IPackInfoService;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_PackInfoRepository;
 
namespace WIDESEAWCS_PackInfoService
{
    public class StationPackInfoService : ServiceBase<Dt_StationPackInfo, IStationPackInfoRepository>, IStationPackInfoService
    {
        public StationPackInfoService(IStationPackInfoRepository BaseDal) : base(BaseDal)
        {
        }
        private readonly IStationPackDetailRepository _stationPackDetailRepository;
        private readonly IPackinfoRepository _packInfoRepository;
        private readonly IPackaxisTaskRepository _packaxisTaskRepository;
        public StationPackInfoService(IStationPackInfoRepository BaseDal, IStationPackDetailRepository stationPackDetailRepository, IPackinfoRepository packInfoRepository, IPackaxisTaskRepository packaxisTaskRepository) : base(BaseDal)
        {
            _stationPackDetailRepository = stationPackDetailRepository;
            _packInfoRepository = packInfoRepository;
            _packaxisTaskRepository = packaxisTaskRepository;
        }
        /// <summary>
        /// 手动清空码垛执行工位数据
        /// </summary>
        /// <param name="StationCode"></param>
        /// <returns></returns>
        public WebResponseContent ManualClearPalletStationData(string StationCode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_StationPackInfo packInfo = BaseDal.QueryFirst(x => x.StationCode == StationCode);
                if (packInfo.PackType != 0 )
                {
                    packInfo.PackType = 0;
                    packInfo.OrderNo = "";
                    packInfo.MakeCode = "";
                    packInfo.MaterielCode = "";
                    packInfo.PackNum = 0;
                    packInfo.AssignNum = 0;
                    packInfo.ExecutingNum = 0;
                    packInfo.OverNum = 0;
                    content.Status = BaseDal.UpdateData(packInfo);
                    //同时删除码垛待执行明细表
 
                    //删除码垛工位执行明细,修改待码垛信息箱码状态为0
                    List<Dt_StationPackDetail> stationPackDetails = _stationPackDetailRepository.QueryData(x => x.StationPackId == packInfo.id);
                    List<string> barCodes = stationPackDetails.Select(x => x.BoxCode).ToList();
                    List<Dt_Packinfo> packinfos = _packInfoRepository.QueryData(x => barCodes.Contains(x.BarCode)).ToList();
                    packinfos.ForEach(x => x.PackStatus = 0);//改变状态
                    _packInfoRepository.UpdateData(packinfos);
                    _stationPackDetailRepository.DeleteData(stationPackDetails);
                }
                else
                {
                    return WebResponseContent.Instance.Error("清除失败,该工位没有码垛数据!");
                }
                     
            }
            catch(Exception e)
            {
                WebResponseContent.Instance.Error(e.Message);
            }
            return content;
        }
    }
}