huanghongfeng
2025-06-19 f3ec4fe9c98a87b42b00b6ac4790fe156a32aa6b
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
using Masuit.Tools;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Comm.AGVInterface.Requset;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_Core.Const;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_Model.Models;
 
namespace WIDESEA_StoragIntegrationServices
{
    public partial class ToAGVService
    {
        /// <summary>
        /// PDA执行agv任务直走功能
        /// </summary>
        /// <param name="taskinfo"></param>
        /// <param name="operationType">操作类型(1-绑定 2-解绑)</param>
        /// <returns></returns>
        public  WebResponseContent UntieStation(SaveModel saveModel)
        {
 
            WebResponseContent content = new WebResponseContent();
 
            string CZTM = saveModel.MainData["CZTM"].ToString();
            if (string.IsNullOrEmpty(CZTM)) throw new Exception("车轴条码为空");
 
            string TargetAddress = saveModel.MainData["TargetAddress"].ToString();
            if (string.IsNullOrEmpty(TargetAddress)) return content.Error("未选择缓存台,缓存台不可为空");
            try
            {
                //调取wcs接口,读取该站台是否可放
                var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue;
                var ReceiveByWMSTask = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.GetPlcState)?.ConfigValue;
                if (ReceiveByWMSTask == null || ipAddress == null)
                {
                    throw new Exception("WMS IP 未配置");
                }
                var wmsIpAddrss = ipAddress + ReceiveByWMSTask;
 
                var respon = HttpHelper.Post(wmsIpAddrss, JsonConvert.SerializeObject(TargetAddress));   //http://localhost:9291/api/Task/ReceiveTask,
 
                if (respon == null) return content.OK("生成任务成功");
 
                WebResponseContent respone = JsonConvert.DeserializeObject<WebResponseContent>(respon.ToString());
                if (!respone.Status)
                {
                    return content.Error(respone.Message);
                }
 
                RequestTaskDto input=new RequestTaskDto();
                input.Position = TargetAddress;
                WebResponseContent agvtocon=genAgvSchedulingTask(input);
                if(agvtocon.Status)
                {
                    return content.OK("生成任务成功");
                }
                else
                {
                    return content.Error("错误信息:"+agvtocon.Message);
                }
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
    }
 
}