添加单灯调试
This commit is contained in:
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InStore;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
@ -15,5 +16,8 @@ namespace WCS.BLL.Services.IService
|
||||
public Task<ResponseBase> queryByMatSnOut(QueryByMatSnRequest request);
|
||||
public Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request);
|
||||
public Task<ResponseBase> queryInstoreStatusSingle(QueryByMatSnRequestSingle request);
|
||||
|
||||
public Task<ResponseBase> debugStoreinfoSingle(DebugStoreinfoSingleRequest request);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using OracleInternal.SqlAndPlsqlParser.LocalParsing;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -13,6 +14,7 @@ using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.InStore;
|
||||
using WCS.Model.ApiModel.MXBackgroundThread;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
@ -23,67 +25,78 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request)
|
||||
{
|
||||
//校验货架编码规则
|
||||
//取配置文件中得货架编码规则
|
||||
bool isValid = false;
|
||||
var patterns = LocalFile.Config.ModuleCodePatterns;
|
||||
if (patterns != null && patterns.Count > 0)
|
||||
try
|
||||
{
|
||||
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);
|
||||
//匹配到第一个符合条件的货架码 就直接退出循环 认为匹配成功
|
||||
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()
|
||||
foreach (var pattern in patterns)
|
||||
{
|
||||
ShelfCode = shelf.ShelfCode,
|
||||
ModulesStr = shelf.ModulesStr,
|
||||
isValid = Regex.IsMatch(request.ModuleCode, pattern);
|
||||
//匹配到第一个符合条件的货架码 就直接退出循环 认为匹配成功
|
||||
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()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架进入入库模式失败:{string.Join(",", shelf.ExceptionMessages)}",
|
||||
Code = 300,
|
||||
Message = $"货架进入入库模式发生异常:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,10 +245,10 @@ namespace WCS.BLL.Services.Service
|
||||
/// <returns></returns>
|
||||
public async Task<ResponseCommon<object>> GenerateStoreInfo()
|
||||
{
|
||||
var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
||||
foreach (var shelfInfo in shelfInfos)
|
||||
{
|
||||
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().Where(t => t.ShelfId == shelfInfo.Id).ToListAsync();
|
||||
//var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
||||
//foreach (var shelfInfo in shelfInfos)
|
||||
//{
|
||||
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().ToListAsync();
|
||||
ModuleInfos.ForEach(moduleInfo =>
|
||||
{
|
||||
for (int i = 1; i <= moduleInfo.LightCount; i++)
|
||||
@ -259,8 +259,8 @@ namespace WCS.BLL.Services.Service
|
||||
ShelfTypeId = 1,
|
||||
ModuleId = moduleInfo.Id,
|
||||
ModuleCode = moduleInfo.ModuleCode,
|
||||
ShelfId = shelfInfo.Id,
|
||||
ShelfCode = shelfInfo.ShelfCode,
|
||||
ShelfId = moduleInfo.ShelfId,
|
||||
ShelfCode = moduleInfo.ShelfCode,
|
||||
BoardId = moduleInfo.BoardId,
|
||||
LightNumber = i,
|
||||
Priority = 1,
|
||||
@ -274,7 +274,7 @@ namespace WCS.BLL.Services.Service
|
||||
DbHelp.db.Insertable(storeInfo).ExecuteCommand();
|
||||
}
|
||||
});
|
||||
}
|
||||
//}
|
||||
return new ResponseCommon<object>() { Message = "111" };
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user