using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.BaseController;
|
using WIDESEAWCS_QuartzJob.Models;
|
using WIDESEAWCS_QuartzJob.Service;
|
|
namespace WIDESEAWCS_Server.Controllers.QuartzJob
|
{
|
[Route("api/DeviceProtocol")]
|
[ApiController]
|
public class DeviceProtocolController : ApiBaseController<IDeviceProtocolService, Dt_DeviceProtocol>
|
{
|
public DeviceProtocolController(IDeviceProtocolService service) : base(service)
|
{
|
}
|
[HttpPost, Route("GetImportData"), AllowAnonymous]
|
public WebResponseContent GetImportData(List<IFormFile> fileInput)
|
{
|
return Service.GetImportData(fileInput);
|
}
|
|
[HttpPost, Route("GetImportData2"), AllowAnonymous]
|
public void GetImportData2()
|
{
|
try
|
{
|
List<Dt_DeviceProtocol> dt_Devices = new List<Dt_DeviceProtocol>();
|
for (int i = 0; i <= 16; i++)
|
{
|
int gtnum = 0;
|
if(i == 1)
|
{
|
gtnum = 3;
|
}else if(i == 2)
|
{
|
gtnum = 4;
|
}
|
else if (i == 3)
|
{
|
gtnum = 10;
|
}
|
else if (i == 4)
|
{
|
gtnum = 13;
|
}
|
else if (i == 5)
|
{
|
gtnum = 14;
|
}
|
else if (i == 6)
|
{
|
gtnum = 20;
|
}
|
else if (i == 7)
|
{
|
gtnum = 23;
|
}
|
else if (i == 8)
|
{
|
gtnum = 24;
|
}
|
else if (i == 9)
|
{
|
gtnum = 30;
|
}
|
else if (i == 10)
|
{
|
gtnum = 33;
|
}
|
else if (i == 11)
|
{
|
gtnum = 34;
|
}
|
else if (i == 12)
|
{
|
gtnum = 50;
|
}
|
else if (i == 13)
|
{
|
gtnum = 51;
|
}
|
else if (i == 14)
|
{
|
gtnum = 60;
|
}
|
else if (i == 15)
|
{
|
gtnum = 70;
|
}
|
else if (i == 16)
|
{
|
gtnum = 74;
|
}
|
|
|
Dt_DeviceProtocol dt_DeviceProtocol = new Dt_DeviceProtocol();
|
dt_DeviceProtocol.DeviceId = 1002;
|
dt_DeviceProtocol.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtocol.DeviceProDataBlock = "DB500";
|
dt_DeviceProtocol.DeviceProOffset = (decimal)0 + (30 * i); //指值多少
|
dt_DeviceProtocol.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtocol.DeviceProParamName = "StationFree"; //名称
|
dt_DeviceProtocol.DeviceProDataLength = 1; //长度
|
dt_DeviceProtocol.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtocol.DeviceProParamDes = "";
|
dt_DeviceProtocol.DeviceProRemark = "空闲状态"; //备注
|
dt_DeviceProtocol.Creater = "admin";
|
dt_DeviceProtocol.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtocol);
|
|
Dt_DeviceProtocol dt_DeviceProtoco2 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco2.DeviceId = 1002;
|
dt_DeviceProtoco2.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco2.DeviceProDataBlock = "DB500";
|
dt_DeviceProtoco2.DeviceProOffset = (decimal)0.1 + (30 * i); //指值多少
|
dt_DeviceProtoco2.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtoco2.DeviceProParamName = "HandShake"; //名称
|
dt_DeviceProtoco2.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco2.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtoco2.DeviceProParamDes = "";
|
dt_DeviceProtoco2.DeviceProRemark = "申请"; //备注
|
dt_DeviceProtoco2.Creater = "admin";
|
dt_DeviceProtoco2.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco2);
|
|
Dt_DeviceProtocol dt_DeviceProtoco3 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco3.DeviceId = 1002;
|
dt_DeviceProtoco3.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco3.DeviceProDataBlock = "DB500";
|
dt_DeviceProtoco3.DeviceProOffset = (decimal)0.7 + (30 * i); //指值多少d
|
dt_DeviceProtoco3.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtoco3.DeviceProParamName = "Online"; //名称
|
dt_DeviceProtoco3.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco3.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtoco3.DeviceProParamDes = "";
|
dt_DeviceProtoco3.DeviceProRemark = "0出库 1脱机入库"; //备注
|
dt_DeviceProtoco3.Creater = "admin";
|
dt_DeviceProtoco3.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco3);
|
|
|
|
|
Dt_DeviceProtocol dt_DeviceProtoco4 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco4.DeviceId = 1002;
|
dt_DeviceProtoco4.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco4.DeviceProDataBlock = "DB500";
|
dt_DeviceProtoco4.DeviceProOffset = (decimal)0.2 + (30 * i); //指值多少d
|
dt_DeviceProtoco4.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtoco4.DeviceProParamName = "Request1"; //名称
|
dt_DeviceProtoco4.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco4.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtoco4.DeviceProParamDes = "";
|
dt_DeviceProtoco4.DeviceProRemark = "备用1"; //备注
|
dt_DeviceProtoco4.Creater = "admin";
|
dt_DeviceProtoco4.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco4);
|
|
Dt_DeviceProtocol dt_DeviceProtoco5 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco5.DeviceId = 1002;
|
dt_DeviceProtoco5.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco5.DeviceProDataBlock = "DB500";
|
dt_DeviceProtoco5.DeviceProOffset = (decimal)0.3 + (30 * i); //指值多少d
|
dt_DeviceProtoco5.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtoco5.DeviceProParamName = "Request2"; //名称
|
dt_DeviceProtoco5.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco5.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtoco5.DeviceProParamDes = "";
|
dt_DeviceProtoco5.DeviceProRemark = "备用2"; //备注
|
dt_DeviceProtoco5.Creater = "admin";
|
dt_DeviceProtoco5.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco5);
|
|
Dt_DeviceProtocol dt_DeviceProtoco6 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco6.DeviceId = 1002;
|
dt_DeviceProtoco6.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco6.DeviceProDataBlock = "DB500";
|
dt_DeviceProtoco6.DeviceProOffset = (decimal)24 + (30 * i); //指值多少d
|
dt_DeviceProtoco6.DeviceProDataType = "int"; //类型
|
dt_DeviceProtoco6.DeviceProParamName = "Request3"; //名称
|
dt_DeviceProtoco6.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco6.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtoco6.DeviceProParamDes = "";
|
dt_DeviceProtoco6.DeviceProRemark = "备用3"; //备注
|
dt_DeviceProtoco6.Creater = "admin";
|
dt_DeviceProtoco6.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco6);
|
|
Dt_DeviceProtocol dt_DeviceProtoco7 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco7.DeviceId = 1002;
|
dt_DeviceProtoco7.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco7.DeviceProDataBlock = "DB500";
|
dt_DeviceProtoco7.DeviceProOffset = (decimal)26 + (30 * i); //指值多少d
|
dt_DeviceProtoco7.DeviceProDataType = "int"; //类型
|
dt_DeviceProtoco7.DeviceProParamName = "Request4"; //名称
|
dt_DeviceProtoco7.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco7.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtoco7.DeviceProParamDes = "";
|
dt_DeviceProtoco7.DeviceProRemark = "备用4"; //备注
|
dt_DeviceProtoco7.Creater = "admin";
|
dt_DeviceProtoco7.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco7);
|
|
Dt_DeviceProtocol dt_DeviceProtoco8 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco8.DeviceId = 1002;
|
dt_DeviceProtoco8.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco8.DeviceProDataBlock = "DB500";
|
dt_DeviceProtoco8.DeviceProOffset = (decimal)2 + (30 * i); //指值多少d
|
dt_DeviceProtoco8.DeviceProDataType = "int"; //类型
|
dt_DeviceProtoco8.DeviceProParamName = "Barcodest"; //名称
|
dt_DeviceProtoco8.DeviceProDataLength = 20; //长度
|
dt_DeviceProtoco8.DeviceProParamType = "ReadDeviceCommand"; //读取
|
dt_DeviceProtoco8.DeviceProParamDes = "";
|
dt_DeviceProtoco8.DeviceProRemark = "托盘条码"; //备注
|
dt_DeviceProtoco8.Creater = "admin";
|
dt_DeviceProtoco8.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco8);
|
|
}
|
|
for (int i = 0; i <= 16; i++)
|
{
|
int gtnum = 0;
|
if (i == 1)
|
{
|
gtnum = 3;
|
}
|
else if (i == 2)
|
{
|
gtnum = 4;
|
}
|
else if (i == 3)
|
{
|
gtnum = 10;
|
}
|
else if (i == 4)
|
{
|
gtnum = 13;
|
}
|
else if (i == 5)
|
{
|
gtnum = 14;
|
}
|
else if (i == 6)
|
{
|
gtnum = 20;
|
}
|
else if (i == 7)
|
{
|
gtnum = 23;
|
}
|
else if (i == 8)
|
{
|
gtnum = 24;
|
}
|
else if (i == 9)
|
{
|
gtnum = 30;
|
}
|
else if (i == 10)
|
{
|
gtnum = 33;
|
}
|
else if (i == 11)
|
{
|
gtnum = 34;
|
}
|
else if (i == 12)
|
{
|
gtnum = 50;
|
}
|
else if (i == 13)
|
{
|
gtnum = 51;
|
}
|
else if (i == 14)
|
{
|
gtnum = 60;
|
}
|
else if (i == 15)
|
{
|
gtnum = 70;
|
}
|
else if (i == 16)
|
{
|
gtnum = 74;
|
}
|
|
|
Dt_DeviceProtocol dt_DeviceProtoco2 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco2.DeviceId = 1002;
|
dt_DeviceProtoco2.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco2.DeviceProDataBlock = "DB501";
|
dt_DeviceProtoco2.DeviceProOffset = (decimal)0 + (10 * i); //指值多少
|
dt_DeviceProtoco2.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtoco2.DeviceProParamName = "HandShake"; //名称
|
dt_DeviceProtoco2.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco2.DeviceProParamType = "DeviceCommand"; //读取
|
dt_DeviceProtoco2.DeviceProParamDes = "";
|
dt_DeviceProtoco2.DeviceProRemark = "反馈信号"; //备注
|
dt_DeviceProtoco2.Creater = "admin";
|
dt_DeviceProtoco2.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco2);
|
|
Dt_DeviceProtocol dt_DeviceProtoco3 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco3.DeviceId = 1002;
|
dt_DeviceProtoco3.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco3.DeviceProDataBlock = "DB501";
|
dt_DeviceProtoco3.DeviceProOffset = (decimal)2 + (10 * i); //指值多少d
|
dt_DeviceProtoco3.DeviceProDataType = "int"; //类型
|
dt_DeviceProtoco3.DeviceProParamName = "StationNum"; //名称
|
dt_DeviceProtoco3.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco3.DeviceProParamType = "DeviceCommand"; //读取
|
dt_DeviceProtoco3.DeviceProParamDes = "";
|
dt_DeviceProtoco3.DeviceProRemark = "站台编号"; //备注
|
dt_DeviceProtoco3.Creater = "admin";
|
dt_DeviceProtoco3.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco3);
|
|
|
|
|
Dt_DeviceProtocol dt_DeviceProtoco4 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco4.DeviceId = 1002;
|
dt_DeviceProtoco4.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco4.DeviceProDataBlock = "DB501";
|
dt_DeviceProtoco4.DeviceProOffset = (decimal)0.1 + (10 * i); //指值多少d
|
dt_DeviceProtoco4.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtoco4.DeviceProParamName = "Request1"; //名称
|
dt_DeviceProtoco4.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco4.DeviceProParamType = "DeviceCommand"; //读取
|
dt_DeviceProtoco4.DeviceProParamDes = "";
|
dt_DeviceProtoco4.DeviceProRemark = "备用1"; //备注
|
dt_DeviceProtoco4.Creater = "admin";
|
dt_DeviceProtoco4.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco4);
|
|
Dt_DeviceProtocol dt_DeviceProtoco5 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco5.DeviceId = 1002;
|
dt_DeviceProtoco5.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco5.DeviceProDataBlock = "DB501";
|
dt_DeviceProtoco5.DeviceProOffset = (decimal)0.2 + (10 * i); //指值多少d
|
dt_DeviceProtoco5.DeviceProDataType = "bool"; //类型
|
dt_DeviceProtoco5.DeviceProParamName = "Request2"; //名称
|
dt_DeviceProtoco5.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco5.DeviceProParamType = "DeviceCommand"; //读取
|
dt_DeviceProtoco5.DeviceProParamDes = "";
|
dt_DeviceProtoco5.DeviceProRemark = "备用2"; //备注
|
dt_DeviceProtoco5.Creater = "admin";
|
dt_DeviceProtoco5.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco5);
|
|
Dt_DeviceProtocol dt_DeviceProtoco6 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco6.DeviceId = 1002;
|
dt_DeviceProtoco6.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco6.DeviceProDataBlock = "DB501";
|
dt_DeviceProtoco6.DeviceProOffset = (decimal)4 + (10 * i); //指值多少d
|
dt_DeviceProtoco6.DeviceProDataType = "int"; //类型
|
dt_DeviceProtoco6.DeviceProParamName = "Request3"; //名称
|
dt_DeviceProtoco6.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco6.DeviceProParamType = "DeviceCommand"; //读取
|
dt_DeviceProtoco6.DeviceProParamDes = "";
|
dt_DeviceProtoco6.DeviceProRemark = "备用3"; //备注
|
dt_DeviceProtoco6.Creater = "admin";
|
dt_DeviceProtoco6.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco6);
|
|
Dt_DeviceProtocol dt_DeviceProtoco7 = new Dt_DeviceProtocol();
|
dt_DeviceProtoco7.DeviceId = 1002;
|
dt_DeviceProtoco7.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtoco7.DeviceProDataBlock = "DB501";
|
dt_DeviceProtoco7.DeviceProOffset = (decimal)6 + (10 * i); //指值多少d
|
dt_DeviceProtoco7.DeviceProDataType = "int"; //类型
|
dt_DeviceProtoco7.DeviceProParamName = "Request4"; //名称
|
dt_DeviceProtoco7.DeviceProDataLength = 1; //长度
|
dt_DeviceProtoco7.DeviceProParamType = "DeviceCommand"; //读取
|
dt_DeviceProtoco7.DeviceProParamDes = "";
|
dt_DeviceProtoco7.DeviceProRemark = "备用4"; //备注
|
dt_DeviceProtoco7.Creater = "admin";
|
dt_DeviceProtoco7.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtoco7);
|
|
|
|
}
|
|
foreach (var deviceProtocol in dt_Devices)
|
{
|
base.AddData(deviceProtocol);
|
}
|
}
|
catch (Exception ex)
|
{
|
|
throw;
|
}
|
|
|
}
|
|
/// <summary>
|
/// 添加读取模块,不包含堆垛机与RGV
|
/// </summary>
|
[HttpPost, Route("GetImportData3"), AllowAnonymous]
|
public void GetImportData3()
|
{
|
try
|
{
|
List<Dt_DeviceProtocol> dt_Devices = new List<Dt_DeviceProtocol>();
|
for (int i = 0; i <= 30; i++)
|
{
|
int gtnum = 0;
|
if (i == 1)
|
{
|
gtnum = 1;
|
}
|
else if (i == 2)
|
{
|
gtnum = 2;
|
}
|
else if (i == 3)
|
{
|
gtnum = 3;
|
}
|
else if (i == 4)
|
{
|
gtnum = 4;
|
}
|
|
|
else if (i == 5)
|
{
|
gtnum = 10;
|
}
|
else if (i == 6)
|
{
|
gtnum = 11;
|
}
|
else if (i == 7)
|
{
|
gtnum = 12;
|
}
|
else if (i == 8)
|
{
|
gtnum = 13;
|
}
|
else if (i == 9)
|
{
|
gtnum = 14;
|
}
|
|
|
else if (i == 10)
|
{
|
gtnum = 20;
|
}
|
else if (i == 11)
|
{
|
gtnum = 21;
|
}
|
else if (i == 12)
|
{
|
gtnum = 22;
|
}
|
else if (i == 13)
|
{
|
gtnum = 23;
|
}
|
else if (i == 14)
|
{
|
gtnum = 24;
|
}
|
|
else if (i == 15)
|
{
|
gtnum = 30;
|
}
|
else if (i == 16)
|
{
|
gtnum = 31;
|
}
|
else if (i == 17)
|
{
|
gtnum = 32;
|
}
|
else if (i == 18)
|
{
|
gtnum = 33;
|
}
|
else if (i == 19)
|
{
|
gtnum = 34;
|
}
|
|
else if (i == 20)
|
{
|
gtnum = 50;
|
}
|
else if (i == 21)
|
{
|
gtnum = 51;
|
}
|
else if (i == 22)
|
{
|
gtnum = 60;
|
}
|
else if (i == 23)
|
{
|
gtnum = 61;
|
}
|
else if (i == 24)
|
{
|
gtnum = 62;
|
}
|
|
else if (i == 25)
|
{
|
gtnum = 70;
|
}
|
else if (i == 26)
|
{
|
gtnum = 71;
|
}
|
else if (i == 27)
|
{
|
gtnum = 72;
|
}
|
else if (i == 28)
|
{
|
gtnum = 73;
|
}
|
else if (i == 29)
|
{
|
gtnum = 74;
|
}
|
else if (i == 30)
|
{
|
gtnum = 40;
|
}
|
|
|
Dt_DeviceProtocol dt_DeviceProtocol = new Dt_DeviceProtocol();
|
dt_DeviceProtocol.DeviceId = 1002;
|
dt_DeviceProtocol.DeviceChildCode = (1010 + gtnum).ToString();
|
dt_DeviceProtocol.DeviceProDataBlock = "DB500";
|
dt_DeviceProtocol.DeviceProOffset = (decimal)80 + (50 * gtnum); //指值多少
|
dt_DeviceProtocol.DeviceProDataType = "int"; //类型
|
dt_DeviceProtocol.DeviceProParamName = "RedStAdd"; //名称
|
dt_DeviceProtocol.DeviceProDataLength = 1; //长度
|
dt_DeviceProtocol.DeviceProParamType = "ReadDeviceCommandPLC"; //读取
|
dt_DeviceProtocol.DeviceProParamDes = "";
|
dt_DeviceProtocol.DeviceProRemark = "是否空闲状态"; //备注
|
dt_DeviceProtocol.Creater = "admin";
|
dt_DeviceProtocol.CreateDate = DateTime.Now;
|
dt_Devices.Add(dt_DeviceProtocol);
|
|
}
|
|
|
|
foreach (var deviceProtocol in dt_Devices)
|
{
|
base.AddData(deviceProtocol);
|
}
|
}
|
catch (Exception ex)
|
{
|
|
throw;
|
}
|
|
|
}
|
|
|
|
}
|
}
|