using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.MES;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_StorageBasicRepository;
namespace WIDESEA_StoragIntegrationServices
{
public partial class WCSService
{
///
/// 涂总精排点
///
///
///
public WebResponseContent Queue(RequestTaskDto json)
{
WebResponseContent content = new WebResponseContent();
try
{
//查找对应的PVI码车身信息
var carinfo = _carBodyInfoRepository.QueryFirst(x => x.RFID == json.PVI);
if (carinfo == null) throw new Exception($"{json.PVI}车身信息未找到");
VINRespon respon = new VINRespon();
if (!string.IsNullOrEmpty(carinfo.VIN))
{
respon = new VINRespon
{
VIN = carinfo.VIN,
Color = carinfo.carBodyCharacteristic,
SkyLight = carinfo.skylightCharacteristic,
VechicleModel = carinfo.vehicleCharacteristic,
};
return content.OK(data: respon);
}
var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position);
if (station == null) throw new Exception("站台未找到");
//涂总工单绑定
WebResponseContent webResponse = _mesService.bindWorkOrder("EL01RB01", json.PVI);
if (!webResponse.Status) throw new Exception($"绑定失败:{webResponse.msg},请求信息:{json.ToJson()}");
//过点信息
WebResponseContent content1 = _mesService.PassPoint(json);
if (!content1.Status) throw new Exception($"过点失败:{content1.msg},请求信息:{json.ToJson()}");
//获取VIN号
WebResponseContent responseContent = _mesService.getCharacteristic(json);
if (!responseContent.Status) throw new Exception($"BDC请求车辆特征信息:{responseContent.msg},请求信息:{json.ToJson()}");
respon = new VINRespon
{
VIN = responseContent.Data.ToString().Substring(35, 17),
Color = carinfo.carBodyCharacteristic,
SkyLight = carinfo.skylightCharacteristic,
VechicleModel = carinfo.vehicleCharacteristic,
};
var mesLock = _mesLockInfoRepository.QueryFirst(x => x.carBodyID == carinfo.Id);
if (mesLock != null)
{
mesLock.LockStatue = 2;
_mesLockInfoRepository.UpdateData(mesLock);
}
content.OK(data: respon);
}
catch (Exception ex)
{
content.Error(ex.Message);
}
return content;
}
}
}