添加单灯调试

This commit is contained in:
hehaibing-1996
2024-06-25 13:48:57 +08:00
parent 7f35077c07
commit 7228b74cb5
8 changed files with 211 additions and 68 deletions

View File

@ -136,11 +136,17 @@ namespace WCS.BLL.HardWare
//清空错误 //清空错误
ExceptionMessages.Clear(); ExceptionMessages.Clear();
ProcessingExceptions.Clear(); ProcessingExceptions.Clear();
this.IsWarning = false; //清空报警状态以免报警后 处理了异常后续无法亮灯
//货架所有模组发送指令进入入库模式 //货架所有模组发送指令进入入库模式
Logs.Write($"货架{ShelfCode}开始发送指令进入入库模式", LogsType.Instore);
foreach (var module in Modules.Where(t => t.IsEnable).ToList()) foreach (var module in Modules.Where(t => t.IsEnable).ToList())
{ {
Logs.Write($"货架{ShelfCode}模组【{module.ModuleCode}】发送指令进入入库模式", LogsType.Instore);
module.GoInInstoreMode(TcpCleint); module.GoInInstoreMode(TcpCleint);
} }
Logs.Write($"货架{ShelfCode}指令发送完毕", LogsType.Instore);
//延时获取异常 //延时获取异常
var timeOut = 3000; var timeOut = 3000;
var timeSpan = TimeSpan.FromMilliseconds(0); var timeSpan = TimeSpan.FromMilliseconds(0);
@ -178,7 +184,7 @@ namespace WCS.BLL.HardWare
if (notInstoreList.Count > 0) if (notInstoreList.Count > 0)
{ {
Logs.Write($"货架{ShelfCode}存在模组未进入入库模式", LogsType.Instore);
foreach (var item in notInstoreList) foreach (var item in notInstoreList)
{ {
ExceptionMessages.Add($"模组{item.ModuleCode}未进入入库模式!"); ExceptionMessages.Add($"模组{item.ModuleCode}未进入入库模式!");
@ -205,6 +211,7 @@ namespace WCS.BLL.HardWare
} }
//没有报警才亮蓝灯 //没有报警才亮蓝灯
Logs.Write($"货架{ShelfCode}IsWarning现在为{IsWarning}", LogsType.Instore);
if (!IsWarning) if (!IsWarning)
WarningLight.BlueLight(TcpCleint); WarningLight.BlueLight(TcpCleint);
//绑定当前进入入库PDA/WCS前端的IP //绑定当前进入入库PDA/WCS前端的IP
@ -399,7 +406,7 @@ namespace WCS.BLL.HardWare
else else
{ {
//剩余物料全出 //剩余物料全出
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},剩余物料灯全亮!", LogsType.Outstore); Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},剩余所有物料灯全亮(发送命令)", LogsType.Outstore);
} }
var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId) var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)
@ -1117,9 +1124,11 @@ namespace WCS.BLL.HardWare
ClientIp = WebSocketIpAddress ClientIp = WebSocketIpAddress
}; };
WarningManager.SendWarning(warningModel); WarningManager.SendWarning(warningModel);
this.IsWarning = true;
#endregion #endregion
Logs.Write($"货架【{ShelfCode},模组{module}发现物料丢失,开始发送红灯】", LogsType.Instore);
WarningLight.WaringLightAlwaysRed(TcpCleint); WarningLight.WaringLightAlwaysRed(TcpCleint);
Logs.Write($"货架【{ShelfCode},模组{module}发现物料丢失,发送红灯完成】", LogsType.Instore);
} }
//库位未配置、返回数据异常 //库位未配置、返回数据异常
else else
@ -1151,9 +1160,11 @@ namespace WCS.BLL.HardWare
ClientIp = WebSocketIpAddress ClientIp = WebSocketIpAddress
}; };
WarningManager.SendWarning(warningModel); WarningManager.SendWarning(warningModel);
this.IsWarning = true;
#endregion #endregion
Logs.Write($"货架【{ShelfCode},模组{module}发现物料未扫描上架,开始发送红灯】", LogsType.Instore);
WarningLight.WaringLightAlwaysRed(TcpCleint); WarningLight.WaringLightAlwaysRed(TcpCleint);
Logs.Write($"货架【{ShelfCode},模组{module}发现物料未扫描上架,发送红灯完成】", LogsType.Instore);
} }
else else
{ {
@ -1809,7 +1820,7 @@ namespace WCS.BLL.HardWare
else else
{ {
//剩余物料全出 //剩余物料全出
Logs.Write($"发料单{OrderNumber},剩余物料灯全亮!", LogsType.Outstore); Logs.Write($"发料单{OrderNumber},剩余所有物料灯全亮(发送命令)", LogsType.Outstore);
} }
var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId) var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel.InStore;
namespace WCS.BLL.Services.IService namespace WCS.BLL.Services.IService
{ {
@ -15,5 +16,8 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> queryByMatSnOut(QueryByMatSnRequest request); public Task<ResponseBase> queryByMatSnOut(QueryByMatSnRequest request);
public Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request); public Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request);
public Task<ResponseBase> queryInstoreStatusSingle(QueryByMatSnRequestSingle request); public Task<ResponseBase> queryInstoreStatusSingle(QueryByMatSnRequestSingle request);
public Task<ResponseBase> debugStoreinfoSingle(DebugStoreinfoSingleRequest request);
} }
} }

View File

@ -1,4 +1,5 @@
using OracleInternal.SqlAndPlsqlParser.LocalParsing; using OracleInternal.SqlAndPlsqlParser.LocalParsing;
using System;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -13,6 +14,7 @@ using WCS.DAL.Db;
using WCS.DAL.DbModels; using WCS.DAL.DbModels;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel.InOutRecord; using WCS.Model.ApiModel.InOutRecord;
using WCS.Model.ApiModel.InStore;
using WCS.Model.ApiModel.MXBackgroundThread; using WCS.Model.ApiModel.MXBackgroundThread;
namespace WCS.BLL.Services.Service namespace WCS.BLL.Services.Service
@ -23,67 +25,78 @@ namespace WCS.BLL.Services.Service
public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request) public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request)
{ {
//校验货架编码规则 try
//取配置文件中得货架编码规则
bool isValid = false;
var patterns = LocalFile.Config.ModuleCodePatterns;
if (patterns != null && patterns.Count > 0)
{ {
foreach (var pattern in patterns) //校验货架编码规则
//取配置文件中得货架编码规则
bool isValid = false;
var patterns = LocalFile.Config.ModuleCodePatterns;
if (patterns != null && patterns.Count > 0)
{ {
isValid = Regex.IsMatch(request.ModuleCode, pattern); foreach (var pattern in patterns)
//匹配到第一个符合条件的货架码 就直接退出循环 认为匹配成功
if (isValid)
break;
}
}
//如果配置文件缺失 使用默认正则进行匹配
else
{
isValid = Regex.IsMatch(request.ModuleCode, LocalFile.DefaultModuleCodePattern);
}
if (!isValid)
{
return new ResponseBase()
{
Code = 202,
Message = $"模组编码{request.ModuleCode}不满足模组编码规则!",
};
}
//找到模组对应的货架
var shelf = ShelfManager.Shelves.Where(t => t.ModulesStr.Contains(request.ModuleCode)).FirstOrDefault();
if (shelf == null)//未找到
{
return new ResponseBase()
{
Code = 201,
Message = "未找到模组对应的货架",
};
}
//已找到模组对应货架
shelf.GoInInstore(request.IpAdress);
if (shelf.CurrentMode == Mode.)
//成功进入入库模式
return new ShelfGoInInstoreResponse()
{
Code = 200,
Message = $"货架进入入库模式成功!{string.Join(",", shelf.ExceptionMessages)}",
Data = new ShelfGoInInstoreDto()
{ {
ShelfCode = shelf.ShelfCode, isValid = Regex.IsMatch(request.ModuleCode, pattern);
ModulesStr = shelf.ModulesStr, //匹配到第一个符合条件的货架码 就直接退出循环 认为匹配成功
if (isValid)
break;
} }
}; }
else //如果配置文件缺失 使用默认正则进行匹配
else
{
isValid = Regex.IsMatch(request.ModuleCode, LocalFile.DefaultModuleCodePattern);
}
if (!isValid)
{
return new ResponseBase()
{
Code = 202,
Message = $"模组编码{request.ModuleCode}不满足模组编码规则!",
};
}
//找到模组对应的货架
var shelf = ShelfManager.Shelves.Where(t => t.ModulesStr.Contains(request.ModuleCode)).FirstOrDefault();
if (shelf == null)//未找到
{
return new ResponseBase()
{
Code = 201,
Message = "未找到模组对应的货架",
};
}
//已找到模组对应货架
shelf.GoInInstore(request.IpAdress);
if (shelf.CurrentMode == Mode.)
//成功进入入库模式
return new ShelfGoInInstoreResponse()
{
Code = 200,
Message = $"货架进入入库模式成功!{string.Join(",", shelf.ExceptionMessages)}",
Data = new ShelfGoInInstoreDto()
{
ShelfCode = shelf.ShelfCode,
ModulesStr = shelf.ModulesStr,
}
};
else
return new ShelfGoInInstoreResponse()
{
Code = 201,
Message = $"货架进入入库模式失败:{string.Join(",", shelf.ExceptionMessages)}",
Data = null
};
}
catch (Exception ex)
{
return new ShelfGoInInstoreResponse() return new ShelfGoInInstoreResponse()
{ {
Code = 201, Code = 300,
Message = $"货架进入入库模式失败:{string.Join(",", shelf.ExceptionMessages)}", Message = $"货架进入入库模式发生异常:{ex.Message}",
Data = null Data = null
}; };
}
} }
public ResponseBase shelfGoOutInStore(ShelfGoOutInStoreRequest request) public ResponseBase shelfGoOutInStore(ShelfGoOutInStoreRequest request)
@ -537,5 +550,31 @@ namespace WCS.BLL.Services.Service
}; };
} }
public async Task<ResponseBase> debugStoreinfoSingle(DebugStoreinfoSingleRequest request)
{
//找到模组
var module = await DbHelp.db.Queryable<ModuleInfo>().Where(it => it.ModuleCode == request.ShelfCode).FirstAsync();
if (module == null)
{
return new ResponseBase()
{
Code = 201,
Message = $"模组[{request.ShelfCode}]不存在!",
};
}
string sendIP = module.CleintIp; //单灯IP
int PCBId = module.BoardId; //单灯PCB板ID
TCPClient tcpClient = TCPClientManager.GetTCPClientByIPHost(sendIP);
byte[] senddata = Tool.Helper.StoreLightOnOff(PCBId, "绿", request.OnOff == true ? 0x01 : 0x00);
tcpClient.Send(senddata); //库位灯短亮一次
return new ResponseBase()
{
Code = 200,
Message = $"Success",
};
}
} }
} }

View File

@ -245,10 +245,10 @@ namespace WCS.BLL.Services.Service
/// <returns></returns> /// <returns></returns>
public async Task<ResponseCommon<object>> GenerateStoreInfo() public async Task<ResponseCommon<object>> GenerateStoreInfo()
{ {
var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList(); //var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList();
foreach (var shelfInfo in shelfInfos) //foreach (var shelfInfo in shelfInfos)
{ //{
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().Where(t => t.ShelfId == shelfInfo.Id).ToListAsync(); var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().ToListAsync();
ModuleInfos.ForEach(moduleInfo => ModuleInfos.ForEach(moduleInfo =>
{ {
for (int i = 1; i <= moduleInfo.LightCount; i++) for (int i = 1; i <= moduleInfo.LightCount; i++)
@ -259,8 +259,8 @@ namespace WCS.BLL.Services.Service
ShelfTypeId = 1, ShelfTypeId = 1,
ModuleId = moduleInfo.Id, ModuleId = moduleInfo.Id,
ModuleCode = moduleInfo.ModuleCode, ModuleCode = moduleInfo.ModuleCode,
ShelfId = shelfInfo.Id, ShelfId = moduleInfo.ShelfId,
ShelfCode = shelfInfo.ShelfCode, ShelfCode = moduleInfo.ShelfCode,
BoardId = moduleInfo.BoardId, BoardId = moduleInfo.BoardId,
LightNumber = i, LightNumber = i,
Priority = 1, Priority = 1,
@ -274,7 +274,7 @@ namespace WCS.BLL.Services.Service
DbHelp.db.Insertable(storeInfo).ExecuteCommand(); DbHelp.db.Insertable(storeInfo).ExecuteCommand();
} }
}); });
} //}
return new ResponseCommon<object>() { Message = "111" }; return new ResponseCommon<object>() { Message = "111" };
} }

View File

@ -107,7 +107,7 @@ namespace WCS.BLL.Tool
} }
//出库库位灯亮灯 //出库库位灯亮灯
public static byte[] OutstoreLight(List<int> board_id, string lightcolor,int status) public static byte[] OutstoreLight(List<int> board_id, string lightcolor, int status)
{ {
byte color = 0x00; byte color = 0x00;
switch (lightcolor) switch (lightcolor)
@ -155,7 +155,7 @@ namespace WCS.BLL.Tool
} }
//出库警示灯亮灯 //出库警示灯亮灯
public static byte[] OutstoreWarnLight(int lightid ,string lightcolor, int status,int beestatus) public static byte[] OutstoreWarnLight(int lightid, string lightcolor, int status, int beestatus)
{ {
byte color = 0x00; byte color = 0x00;
switch (lightcolor) switch (lightcolor)
@ -230,5 +230,59 @@ namespace WCS.BLL.Tool
byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, true); byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, true);
return senddata1; return senddata1;
} }
/// <summary>
/// 库位灯常亮/关闭
/// </summary>
/// <param name="board_id"></param>
/// <param name="lightcolor"></param>
/// <param name="status">0X00 关闭 0X01 常亮 0X02 闪烁 0X03 短亮一次</param>
/// <returns></returns>
public static byte[] StoreLightOnOff(int board_id, string lightcolor, int status)
{
byte color = 0x00;
switch (lightcolor)
{
case "红":
color = 0x01;
break;
case "绿":
color = 0x02;
break;
case "黄":
color = 0x03;
break;
case "蓝":
color = 0x04;
break;
case "紫":
color = 0x05;
break;
case "青":
color = 0x06;
break;
case "白":
color = 0x07;
break;
case "无":
color = 0x00;
break;
}
byte[] data1 = new byte[3 + 5];
data1[0] = 0xff;
data1[1] = 0x01;
byte[] length_base = BitConverter.GetBytes(data1.Length + 2);
data1[2] = length_base[1];
data1[3] = length_base[0];
data1[4] = 0x01;
data1[5] = (byte)board_id;
data1[5 + 1] = (byte)status;
data1[5 + 2] = color;
byte[] data = Crc16(data1, data1.Length, true);
return data;
}
} }
} }

View File

@ -41,6 +41,10 @@ namespace WCS.BLL
/// 出库流程日志 /// 出库流程日志
/// </summary> /// </summary>
Outstore, Outstore,
/// <summary>
/// 入库流程日志
/// </summary>
Instore,
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.InStore
{
public class DebugStoreinfoSingleRequest : RequestBase
{
public string ShelfCode { get; set; }
public bool OnOff { get; set; } = false;
}
}

View File

@ -4,6 +4,7 @@ using WCS.BLL.Manager;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.BLL.Tool; using WCS.BLL.Tool;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel.InStore;
namespace WebApi.Controllers namespace WebApi.Controllers
{ {
@ -147,7 +148,24 @@ namespace WebApi.Controllers
return await _instoreService.queryInstoreStatusSingle(request); return await _instoreService.queryInstoreStatusSingle(request);
//ShelfManager. //ShelfManager.
// //
}
catch (Exception ex)
{
return new ResponseCommon()
{
Code = 300,
Message = $"<22><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>:{ex.Message}",
};
}
}
[Route("debugStoreinfoSingle")]
[HttpPost(Name = "debugStoreinfoSingle")]
public async Task<ResponseBase> debugStoreinfoSingle(DebugStoreinfoSingleRequest request)
{
try
{
return await _instoreService.debugStoreinfoSingle(request);
} }
catch (Exception ex) catch (Exception ex)
{ {