1
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using OracleInternal.SqlAndPlsqlParser.LocalParsing;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
@ -7,6 +10,7 @@ using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.BLL.Tool.Api.ApiModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
@ -372,5 +376,119 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> queryInstoreStatusSingle(QueryByMatSnRequestSingle request)
|
||||
{
|
||||
//获取货架
|
||||
//var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
//if (shelf == null)//货架不存在
|
||||
//{
|
||||
// return new ResponseCommon()
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"货架[{request.ShelfCode}]不存在!",
|
||||
// };
|
||||
//}
|
||||
List<ModuleInfo> MI = DbHelp.db.Queryable<ModuleInfo>().Where(it => it.ModuleCode == request.ShelfCode).ToList();
|
||||
if (MI.Count == 0)
|
||||
{
|
||||
return new ResponseCommonSingle()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
ResponseCommonSingle rcs = new ResponseCommonSingle();
|
||||
rcs.Data = new List<Detail>();
|
||||
|
||||
string sendIP = MI[0].CleintIp; //单灯IP
|
||||
int PCBId = MI[0].BoardId; //单灯PCB板ID
|
||||
|
||||
List<StoreInfo> SI = DbHelp.db.Queryable<StoreInfo>().Where(it => it.ModuleCode == request.ShelfCode).ToList();
|
||||
|
||||
List<ShelfInfo> si = DbHelp.db.Queryable<ShelfInfo>().Where(it => it.ShelfCode == MI[0].ShelfCode).ToList();
|
||||
int warnLightID = si[0].LightId;
|
||||
|
||||
foreach (QueryByMatSnRequestSingle.MatSnListDetail matSnListDetail in request.MatSnList)
|
||||
{
|
||||
Detail detail = new Detail();
|
||||
try
|
||||
{
|
||||
InventoryDetail inventoryDetail = new InventoryDetail();
|
||||
inventoryDetail.MatSN = matSnListDetail.MatSn;
|
||||
inventoryDetail.MatCode = matSnListDetail.MatCode;
|
||||
inventoryDetail.MatName = matSnListDetail.MatName;
|
||||
inventoryDetail.MatSpec = matSnListDetail.MatSpec;
|
||||
inventoryDetail.MatBatch = matSnListDetail.MatBatch;
|
||||
inventoryDetail.MatQty = matSnListDetail.MatQty;
|
||||
inventoryDetail.MatCustomer = matSnListDetail.MatCustomer;
|
||||
inventoryDetail.MatSupplier = matSnListDetail.MatSupplier;
|
||||
inventoryDetail.StoreCode = request.ShelfCode;
|
||||
inventoryDetail.StoreId = SI[0].Id;
|
||||
|
||||
int count = DbHelp.db.Insertable(inventoryDetail).ExecuteCommand();
|
||||
|
||||
InOutRecord ior = new InOutRecord();
|
||||
ior.MatSN = matSnListDetail.MatSn;
|
||||
ior.MatCode = matSnListDetail.MatCode;
|
||||
ior.MatName = matSnListDetail.MatName;
|
||||
ior.MatSpec = matSnListDetail.MatSpec;
|
||||
ior.MatBatch = matSnListDetail.MatBatch;
|
||||
ior.MatQty = matSnListDetail.MatQty;
|
||||
ior.MatCustomer = matSnListDetail.MatCustomer;
|
||||
ior.MatSupplier = matSnListDetail.MatSupplier;
|
||||
ior.StoreCode = request.ShelfCode;
|
||||
ior.StoreId = SI[0].Id;
|
||||
ior.Direction = 0;
|
||||
ior.OperateTime = DateTime.Now;
|
||||
ior.OperateUser = request.UserName;
|
||||
int count1 = DbHelp.db.Insertable(ior).ExecuteCommand();
|
||||
|
||||
detail.matsn = matSnListDetail.MatSn;
|
||||
detail.result = "入库成功";
|
||||
rcs.Data.Add(detail);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
detail.matsn = matSnListDetail.MatSn;
|
||||
detail.result = "入库失败";
|
||||
detail.reason = ee.Message;
|
||||
rcs.Data.Add(detail);
|
||||
}
|
||||
}
|
||||
//亮灯
|
||||
TCPClient tCPClient = TCPClientManager.GetTCPClientByIPHost(sendIP);
|
||||
byte[] data1 = new byte[8];
|
||||
data1[0] = 0xff;
|
||||
data1[1] = 0x02;
|
||||
data1[2] = 0x00;
|
||||
data1[3] = 0x0a;
|
||||
data1[4] = (byte)warnLightID;
|
||||
data1[5] = 0x03;
|
||||
data1[6] = 0x02;
|
||||
data1[7] = 0x02;
|
||||
byte[] senddata1 = Tool.Helper.Crc16(data1,data1.Length,false);
|
||||
tCPClient.Send(senddata1); //报警灯短亮一次
|
||||
|
||||
byte[] data2 = new byte[8];
|
||||
data2[0] = 0xff;
|
||||
data2[1] = 0x01;
|
||||
data2[2] = 0x00;
|
||||
data2[3] = 0x0a;
|
||||
data2[4] = 0x01;
|
||||
data2[5] = (byte)PCBId;
|
||||
data2[6] = 0x03;
|
||||
data2[7] = 0x02;
|
||||
byte[] senddata2 = Tool.Helper.Crc16(data2, data2.Length, false);
|
||||
tCPClient.Send(senddata2); //库位灯短亮一次
|
||||
|
||||
return new ResponseCommonSingle()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"入库成功!",
|
||||
Data = rcs.Data,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user