using AngleSharp.Common;
|
using Masuit.Tools;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Common;
|
using WIDESEA_Common.MES;
|
using WIDESEA_Common.MES.Request;
|
using WIDESEA_Core;
|
using WIDESEA_Core.Const;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_DTO.WMS;
|
using WIDESEA_Model.Models;
|
using WIDESEAWCS_BasicInfoService;
|
using WIDESEAWCS_Model.Models;
|
|
namespace WIDESEA_StoragIntegrationServices
|
{
|
/// <summary>
|
/// 车身绑定工单(焊装直通涂装)
|
/// </summary>
|
public partial class MESService
|
{
|
public WebResponseContent pullLock(object jsondata)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
if (string.IsNullOrEmpty(jsondata.ToString())) throw new Exception("请求参数为空");
|
Console.WriteLine(jsondata);
|
var result = JsonConvert.DeserializeObject<pullLockInfo>(jsondata.ToString());
|
|
foreach (var item in result.data)
|
{
|
Dt_PalletStockInfo carinfo = null;
|
if (!string.IsNullOrEmpty(item.pvi))
|
{
|
carinfo = _palletStockInfoRepository.QueryFirst(x => x.PVI == item.pvi && x.pbMaterial == item.pbMaterial);
|
if (carinfo == null)
|
{
|
throw new Exception($"未找到指定PVI车身信息{item.pvi}");
|
}
|
}
|
else
|
{
|
carinfo = _palletStockInfoRepository.QueryData(x => x.pbMaterial == item.pbMaterial).OrderBy(x => x.CreateDate).FirstOrDefault();
|
}
|
|
if (carinfo == null)
|
{
|
throw new Exception("无法匹配车身,拉动锁定失败");
|
}
|
|
Dt_Task task = new Dt_Task()
|
{
|
CreateDate = DateTime.Now,
|
Creater = "System",
|
CurrentAddress = carinfo.LocationCode,
|
Grade = 5,
|
PalletCode = carinfo.PalletCode,
|
PVI = item.pvi,
|
Roadway = carinfo.RoadwayNo,
|
SourceAddress = carinfo.LocationCode,
|
TaskNum = _taskRepository.GetTaskNo().Result,
|
TaskType = (int)TaskOutboundTypeEnum.Outbound,
|
TaskState = (int)TaskOutStatusEnum.OutNew,
|
TargetAddress = ""
|
};
|
|
WMSTaskDTO taskDTO = new WMSTaskDTO()
|
{
|
Grade = task.Grade.Value,
|
PalletCode = task.PalletCode,
|
SourceAddress = task.SourceAddress,
|
TargetAddress = task.TargetAddress,
|
RoadWay = task.Roadway,
|
TaskState = task.TaskState.Value,
|
TaskType = task.TaskType,
|
TaskNum = task.TaskNum.Value
|
};
|
|
var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
|
var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue;
|
var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveTask)?.ConfigValue;
|
if (wmsBase == null || ipAddress == null)
|
{
|
throw new InvalidOperationException("WMS IP 未配置");
|
}
|
var wmsIpAddress = wmsBase + ipAddress;
|
|
_unitOfWorkManage.BeginTran();
|
var WCSresult = HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
|
content = JsonConvert.DeserializeObject<WebResponseContent>(WCSresult);
|
if (content != null && content.Status)
|
{
|
carinfo.StockStatus = 1;
|
carinfo.LockOrder = 1;
|
|
_taskRepository.AddData(task);
|
_palletStockInfoRepository.UpdateData(carinfo);
|
|
_unitOfWorkManage.CommitTran();
|
}
|
}
|
|
LogFactory.GetLog("MES拉动锁车").Info(true, $"\r\r--------------------------------------");
|
LogFactory.GetLog("MES拉动锁车").Info(true, jsondata.ToJsonString());
|
|
return content;
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran();
|
return content.Error(ex.Message);
|
}
|
}
|
}
|
}
|