分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-03-14 73a926018601d9a5a5a3d3f4c051537f45a8eff4
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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Comm.MES_Info;
using WIDESEA_Comm.MES_Info.Request;
using WIDESEA_Common;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.ManageUser;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using WIDESEA_Entity.DomainModels.Mes;
using WIDESEA_WMS.Common;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
using static WIDESEA_Comm.MES_Info.BasicSN;
 
namespace WIDESEA_WMS
{
    public partial class ToMesServer
    {
        /// <summary>
        /// 外协入库(检测上料)
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public WebResponseContent OutsourceInbound(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string stationNo = saveModel.MainData["stationNo"].ToString();  //缓存架编号
                string user = saveModel.MainData["creator"].ToString();
                string sn = saveModel.MainData["dataSN"].ToString();   //车轮SN号
 
                int i = 1;  //车轮数量
                foreach (var item in sn.Split(","))
                {
                    if(item!= null)
                    {
                        var info = freeDB.Select<VV_MES_Info>().Where(x => x.SN == item).First();
                        if (info == null)
                        {
                            return content.Error($"第{i}个车轮无检测上料工单信息,请核查工单后在扫描!");
                        }
                        i++;
                    }
                    
                }
                
 
                dt_agvtask agvtask = new dt_agvtask
                {
                    agv_barcode = stationNo,
                    agv_code = user,
                    agv_createtime = DateTime.Now,
                    agv_fromaddress = stationNo,
                    agv_qty = i,
                    agv_grade = 1,
                    agv_tasktype = AGVTaskTypeEnum.TaskType_Inbound.ToString(),
                    agv_taskstate = AGVTaskStateEnum.Create.ToString(),
                    agv_toaddress = "",
                };
                freeDB.Add(agvtask);
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error($"呼叫AGV失败:{ex.Message}");
            }
        }
    }
}