This commit is contained in:
陶坤
2024-05-15 18:49:11 +08:00
parent 65bb836721
commit e3d3726cbe
18 changed files with 446 additions and 70 deletions

View File

@ -14,5 +14,6 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> queryByMatSn(QueryByMatSnRequest request);
public Task<ResponseBase> queryByMatSnOut(QueryByMatSnRequest request);
public Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request);
public Task<ResponseBase> queryInstoreStatusSingle(QueryByMatSnRequestSingle request);
}
}

View File

@ -23,6 +23,8 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
public Task<ResponseBase> GoInOutstoreSingle(GetOutOrderDetailRequest request);
public Task<ResponseBase> GoOutOutstore(GetOutOrderDetailRequest request);
}
}

View File

@ -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,
};
}
}
}

View File

@ -499,6 +499,98 @@ namespace WCS.BLL.Services.Service
throw ex;
}
}
public async Task<ResponseBase> GoInOutstoreSingle(GetOutOrderDetailRequest request)
{
try
{
//获取出库单
var order = await DbHelp.db.Queryable<OutOrder>()
.WhereIF(request.OrderId != 0, t => t.Id == request.OrderId)
.WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber == request.OrderNumber)
.FirstAsync();
if (order == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"不存在对应的出库单据{request.OrderNumber}",
Data = null
};
}
//如果是按物料编码出库 需要计算物料明细、并进行物料锁定
if (order.SyncType == SyncTypeEnum.ByMatCode)
{
var result = CaculateOutOrderMatDetails(order, request.UserName);
if (result.Code != 200)
{
return result;
}
}
//获取需要出库的物料明细
var outOrderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
.Where(t => t.OrderId == order.Id)
.Where(t => t.IsSended == false)
.Includes(t => t.StoreInfo)
.ToList();
if (outOrderMatDetails == null || outOrderMatDetails.Count == 0)
{
return new ResponseCommon()
{
Code = 201,
Message = $"出库单据{request.OrderNumber}物料已全部完成出库!",
Data = null
};
}
if (request.IsStart)//&& order.OutOrderExeStatus != OutOrderExeStatus.发料完成
{
order.OutOrderExeStatus = OutOrderExeStatus.;
DbHelp.db.Updateable(order).ExecuteCommand();
}
//返回需求明细
//获取出库需求
List<OutOrderDetail> outorderdetal = DbHelp.db.Queryable<OutOrderDetail>()
.WhereIF(request.OrderId != 0, t => t.OrderId == request.OrderId)
.WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber == request.OrderNumber)
.ToList();
OutResponseCommonSingle orcs = new OutResponseCommonSingle();
orcs.Data = new List<OutDetail>();
foreach (OutOrderDetail outdetail in outorderdetal)
{
OutDetail od = new OutDetail();
od.OrderId = outdetail.OrderId;
od.OrderNumber= outdetail.OrderNumber;
od.MatCode=outdetail.MatCode;
od.MatBatch=outdetail.MatBatch;
od.ReqQty = outdetail.ReqQty;
od.CreateTime = outdetail.CreateTime;
od.CreateUser = outdetail.CreateUser;
od.MatName = outdetail.MatName;
od.OutQty = outdetail.OutQty;
od.LightColor = "";
orcs.Data.Add(od);
}
//返回
return new OutResponseCommonSingle()
{
Code = 200,
Message = "Success",
Data = orcs.Data
};
}
catch (Exception ex)
{
await GoOutOutstore(request);
throw ex;
}
}
//计算、加锁
private ResponseBase CaculateOutOrderMatDetails(OutOrder order, string createUser = "")
{