添加单灯调试
This commit is contained in:
@ -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",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user