change - 泡后库稳定版

foamRearStore
liuwf 9 months ago
parent be7da78db4
commit 7e5e507973

Binary file not shown.

@ -5,6 +5,7 @@ using HighWayIot.Repository.service;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms;
namespace Aucma.Scada.Business namespace Aucma.Scada.Business
{ {
@ -31,6 +32,8 @@ namespace Aucma.Scada.Business
private AppConfig appConfig = AppConfig.Instance; private AppConfig appConfig = AppConfig.Instance;
private RegisterServices registerServices = RegisterServices.Instance; private RegisterServices registerServices = RegisterServices.Instance;
#endregion #endregion
#region 接口引用 #region 接口引用
@ -59,6 +62,21 @@ namespace Aucma.Scada.Business
/// <param name="planInfo"></param> /// <param name="planInfo"></param>
public delegate void NextPassExecutePlanInfo(ExecutePlanInfo planInfo,BaseSpaceInfo spaceInfo = null); public delegate void NextPassExecutePlanInfo(ExecutePlanInfo planInfo,BaseSpaceInfo spaceInfo = null);
public event NextPassExecutePlanInfo NextPassExecutePlanInfoEvent; public event NextPassExecutePlanInfo NextPassExecutePlanInfoEvent;
/// <summary>
/// 弹框提示
/// </summary>
/// <param name="taskInfos"></param>
public delegate void PrintMessage(string log);
public event PrintMessage PrintMessageEvent;
/// <summary>
/// 找出库货道
/// </summary>
/// <param name="taskInfos"></param>
public delegate BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType);
public event GetSpaceInfoByMaterialType GetSpaceInfoByMaterialTypeEvent;
#endregion #endregion
private AssemblyPlanBusiness() private AssemblyPlanBusiness()
@ -129,6 +147,7 @@ namespace Aucma.Scada.Business
var productPlanInfo = _productPlanInfoService.GetProductPlanByPlanCode(productPlanCode); var productPlanInfo = _productPlanInfoService.GetProductPlanByPlanCode(productPlanCode);
if (productPlanInfo != null) if (productPlanInfo != null)
{ {
ExecutePlanInfo executePlanInfo = new ExecutePlanInfo(); ExecutePlanInfo executePlanInfo = new ExecutePlanInfo();
executePlanInfo.executePlanCode = System.Guid.NewGuid().ToString("N"); executePlanInfo.executePlanCode = System.Guid.NewGuid().ToString("N");
executePlanInfo.productPlanCode = productPlanInfo.planCode; executePlanInfo.productPlanCode = productPlanInfo.planCode;
@ -137,8 +156,28 @@ namespace Aucma.Scada.Business
executePlanInfo.materialCode = productPlanInfo.materialCode; executePlanInfo.materialCode = productPlanInfo.materialCode;
executePlanInfo.materialName = productPlanInfo.materialName; executePlanInfo.materialName = productPlanInfo.materialName;
executePlanInfo.executeOrder = _executePlanInfoService.GetExecuteOrderByProductLineCode(appConfig.stationCode); executePlanInfo.executeOrder = _executePlanInfoService.GetExecuteOrderByProductLineCode(appConfig.stationCode);
executePlanInfo.executeStatus = 1;
if (spaceInfo == null)
{//下总装计划 筛选货道
spaceInfo = GetSpaceInfoByMaterialTypeEvent?.Invoke(appConfig.foamStoreCode, executePlanInfo.materialCode);
if(transmitAmount > spaceInfo.spaceStock)
{
//弹框提示
PrintMessageEvent?.Invoke($"收到出库计划数:{transmitAmount},匹配到货道:{spaceInfo.spaceCode},库存数:{spaceInfo.spaceStock},已自动将计划数改为库存!");
executePlanInfo.planAmount = spaceInfo.spaceStock;
}
else
{
executePlanInfo.planAmount = transmitAmount; executePlanInfo.planAmount = transmitAmount;
}
}
else // 手动出一个或者整道出
{
executePlanInfo.planAmount = transmitAmount;
}
executePlanInfo.executeStatus = 1;
executePlanInfo.createdTime = DateTime.Now; executePlanInfo.createdTime = DateTime.Now;
result = _executePlanInfoService.InsertExecutePlanInfo(executePlanInfo); result = _executePlanInfoService.InsertExecutePlanInfo(executePlanInfo);

@ -113,10 +113,11 @@ namespace Aucma.Scada.Business
_baseBomInfoService = registerServices.GetService<IBaseBomInfoService>(); _baseBomInfoService = registerServices.GetService<IBaseBomInfoService>();
_recordInStoreService = registerServices.GetService<IRecordInStoreService>(); _recordInStoreService = registerServices.GetService<IRecordInStoreService>();
_printBarCodeServices = registerServices.GetService<IPrintBarCodeServices>(); _printBarCodeServices = registerServices.GetService<IPrintBarCodeServices>();
_iMaterialCompletionServices = registerServices.GetService<IMaterialCompletionServices>();
_productPlanInfoServices = registerServices.GetService<IProductPlanInfoService>(); _productPlanInfoServices = registerServices.GetService<IProductPlanInfoService>();
taskHandle.InStoreFinsihEvent += InStoreFinish; taskHandle.InStoreFinsihEvent += InStoreFinish;
taskHandle.InStoreAnswerEvent += InStoreAnswer; taskHandle.InStoreAnswerEvent += InStoreAnswer;
taskHandle.InStoreFinsihBySpaceCodeEvent += InStoreAllBySpaceCode;
MvCodeHelper.RefreshMaterialCodeStrEvent += InStore; MvCodeHelper.RefreshMaterialCodeStrEvent += InStore;
MvCodeHelper.RefreshLogMessageEvent += PrintLogInfoMessage; MvCodeHelper.RefreshLogMessageEvent += PrintLogInfoMessage;
MvCodeHelper.MessageNoReadEvent += MessageNoRead; MvCodeHelper.MessageNoReadEvent += MessageNoRead;
@ -189,7 +190,7 @@ namespace Aucma.Scada.Business
/// 入库 /// 入库
/// </summary> /// </summary>
/// <param name="materialType"></param> /// <param name="materialType"></param>
private void InStore(string materialCode) public void InStore(string materialCode)
{ {
try try
{ {
@ -210,24 +211,12 @@ namespace Aucma.Scada.Business
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
spaceInfo.materialType = materialType; spaceInfo.materialType = materialType;
spaceInfo.typeNameA = GetMaterialName(materialType); spaceInfo.typeNameA = GetMaterialName(materialType);
// 入库禁止出库
spaceInfo.outStoreFlag = 2;
RefreshScanMateriaCodeEvent?.Invoke(materialCode, GetMaterialName(materialType), spaceInfo.spaceName, appConfig.foamStoreCode); //刷新界面扫码信息 RefreshScanMateriaCodeEvent?.Invoke(materialCode, GetMaterialName(materialType), spaceInfo.spaceName, appConfig.foamStoreCode); //刷新界面扫码信息
var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务 var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务
if (result) if (result)
{ {
#region delete/20240105/正式生产启用 更新过点数据,插入记录到MATERIAL_COMPLETION表
//PrintBarCode print = _printBarCodeServices.query(materialCode);
//string planCode = _productPlanInfoServices.GetPlanCode(print.OrderCode, appConfig.stationCode);
//MaterialCompletion completion = new MaterialCompletion();
//completion.OrderCode = print.OrderCode;
//completion.MaterialBarcode = materialCode;
//completion.MaterialCode = print.MaterialCode;
//completion.MaterialName = print.MaterialName;
//completion.StationName = appConfig.stationCode;
//completion.CompleteDate = DateTime.Now;
//completion.planCode = planCode;
//_iMaterialCompletionServices.Add(completion);
#endregion
_spaceInfoService.UpdateSpaceInfo(spaceInfo); _spaceInfoService.UpdateSpaceInfo(spaceInfo);
} }
} }
@ -246,6 +235,17 @@ namespace Aucma.Scada.Business
} }
} }
/// <summary>
/// 根据指定货道异常入库
/// </summary>
public void ExceptionInstore(string spaceCode)
{
BaseSpaceInfo space = _spaceInfoService.GetSpaceInfoBySpaceCode(appConfig.foamStoreCode,spaceCode);
if(space != null)
{
CreateInStoreTask(space, "");
}
}
/// <summary> /// <summary>
/// 创建入库任务 /// 创建入库任务
/// </summary> /// </summary>
@ -317,14 +317,6 @@ namespace Aucma.Scada.Business
/// <param name="e"></param> /// <param name="e"></param>
private void PassDownFoamTask() private void PassDownFoamTask()
{ {
#region 出库不需要堵塞整个库
////出库时堵塞入库,这个地方如果有问题的话改为操作StartPassDown将_isBlocked初始值true给while开始出库时设成false结束while出库完成后改为ture重新调用StartPassDown
//if (_isBlocked)
//{
// PrintLogInfoMessage("正在出库,当前入库状态堵塞,出库完成后进行释放");
// _autoResetEvent.WaitOne();
//}
#endregion
try try
{ {
@ -403,6 +395,28 @@ namespace Aucma.Scada.Business
//} //}
#endregion #endregion
/// <summary>
/// 在途为0后根据货道完成该货道所有入库任务
/// </summary>
/// <param name="spaceCode"></param>
public void InStoreAllBySpaceCode(string spaceCode)
{
try
{
List<RealTaskInfo> list = _taskInfoService.GetAllInstoreTaskByStoreCode(appConfig.foamStoreCode, spaceCode, 1, 2);
if (list != null && list.Count > 0)
{
foreach (RealTaskInfo task in list)
{
InStoreFinish(task.taskCode);
}
}
}
catch (Exception ex)
{
logHelper.Info("InStoreAllBySpaceCode异常:"+ex.Message.ToString());
}
}
/// <summary> /// <summary>
/// 入库完成 /// 入库完成
@ -410,42 +424,13 @@ namespace Aucma.Scada.Business
/// <param name="storeCode"></param> /// <param name="storeCode"></param>
/// <param name="spaceCode"></param> /// <param name="spaceCode"></param>
/// <param name="materialType"></param> /// <param name="materialType"></param>
private void InStoreFinish(string taskCode) public void InStoreFinish(string taskCode)
{ {
try try
{ {
var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode, appConfig.foamStoreCode); var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode, appConfig.foamStoreCode);
if (taskInfo != null) if (taskInfo != null)
{ {
var spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.storeCode, taskInfo.spaceCode);
if (spaceInfo != null)
{
spaceInfo.materialType = taskInfo.materialType;
//spaceInfo.spaceStock = spaceInfo.spaceStock + 1;
//spaceInfo.onRouteAmount -= 1;
//读取PLC获取货道信息存放数量、在途数量,
#region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
var item = taskHandle.ReadSpaceInfoByPlc(spaceInfo);
spaceInfo.spaceStock = item.spaceStock;
spaceInfo.onRouteAmount = item.onRouteAmount;
spaceInfo.spaceStatus = item.spaceStatus;
#endregion
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
#region 添加货道明细
BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
spaceDetail.materialType = taskInfo.materialType;
spaceDetail.materialCode = taskInfo.materialCode;
spaceDetail.materialName = GetMaterialName(taskInfo.materialType);
spaceDetail.storeCode = spaceInfo.storeCode;
spaceDetail.spaceCode = spaceInfo.spaceCode;
spaceDetail.materialAmount = 1;
_baseSpaceDetailService.InsertSpaceDetail(spaceDetail);
#endregion
#region 添加入库记录 #region 添加入库记录
RecordInstore recordInstore = new RecordInstore(); RecordInstore recordInstore = new RecordInstore();
recordInstore.storeCode = taskInfo.storeCode; recordInstore.storeCode = taskInfo.storeCode;
@ -459,7 +444,41 @@ namespace Aucma.Scada.Business
_recordInStoreService.InsertRecordInStore(recordInstore); _recordInStoreService.InsertRecordInStore(recordInstore);
#endregion #endregion
#region 更新过点数据,插入记录到MATERIAL_COMPLETION表
if (!string.IsNullOrEmpty(taskInfo.materialCode))
{
PrintBarCode print = _printBarCodeServices.query(taskInfo.materialCode);
if (print != null)
{
string planCode = _productPlanInfoServices.GetPlanCode(print.OrderCode, appConfig.stationCode);
MaterialCompletion completion = new MaterialCompletion();
completion.OrderCode = print.OrderCode;
completion.MaterialBarcode = taskInfo.materialCode;
completion.MaterialCode = print.MaterialCode;
completion.MaterialName = print.MaterialName;
completion.StationName = appConfig.stationCode;
completion.CompleteDate = DateTime.Now;
completion.planCode = planCode;
_iMaterialCompletionServices.Add(completion);
}
} }
#endregion
#region 添加货道明细,取消记录库存明细
BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
spaceDetail.materialType = taskInfo.materialType;
spaceDetail.materialCode = taskInfo.materialCode;
spaceDetail.materialName = GetMaterialName(taskInfo.materialType);
spaceDetail.storeCode = appConfig.foamStoreCode;
spaceDetail.spaceCode = taskInfo.spaceCode;
spaceDetail.materialAmount = 1;
spaceDetail.createTime = DateTime.Now;
_baseSpaceDetailService.InsertSpaceDetail(spaceDetail);
#endregion
//清除任务信息 //清除任务信息
_taskInfoService.DeleteTaskInfo(taskCode, appConfig.foamStoreCode); _taskInfoService.DeleteTaskInfo(taskCode, appConfig.foamStoreCode);
} }
@ -593,7 +612,10 @@ namespace Aucma.Scada.Business
} }
var list = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1).ToList(); var list = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1).ToList();
if(list==null || list.Count == 0)
{
list = _spaceInfoService.GetEmptySpaceInfo(appConfig.foamStoreCode);
}
if (list.Count > 0) if (list.Count > 0)
{ {
result = list.OrderByDescending(x => x.spaceStock).First(); result = list.OrderByDescending(x => x.spaceStock).First();

@ -52,7 +52,7 @@ namespace Aucma.Scada.Business
/// <summary> /// <summary>
/// 已下传的任务信息 /// 已下传的任务信息
/// </summary> /// </summary>
private List<RealTaskInfo> foamRearTaskInfos ; private List<RealTaskInfo> foamRearTaskInfos;
/// <summary> /// <summary>
/// 实时任务 /// 实时任务
@ -96,6 +96,14 @@ namespace Aucma.Scada.Business
/// <param name="taskCode"></param> /// <param name="taskCode"></param>
public delegate void InStoreFinsih(string taskCode); public delegate void InStoreFinsih(string taskCode);
public event InStoreFinsih InStoreFinsihEvent; public event InStoreFinsih InStoreFinsihEvent;
/// <summary>
/// 在途清0完成货道任务
/// </summary>
/// <param name="taskCode"></param>
public delegate void InStoreFinsihBySpaceCode(string spaceCode);
public event InStoreFinsihBySpaceCode InStoreFinsihBySpaceCodeEvent;
#endregion #endregion
private InStoreTaskHandle() private InStoreTaskHandle()
@ -135,6 +143,19 @@ namespace Aucma.Scada.Business
int OnAmount = spaceInfo.onRouteAmount; int OnAmount = spaceInfo.onRouteAmount;
ReadSpaceInfoByPlc(spaceInfo); ReadSpaceInfoByPlc(spaceInfo);
if (spaceInfo.onRouteAmount == 0)
{
//自动完成该货道的所有入库任务
InStoreFinsihBySpaceCodeEvent?.Invoke(spaceInfo.spaceCode);
//该货道没有入库任务了,重置货道出库标识,可以再次出库
spaceInfo.outStoreFlag = 1;
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
RefreshFoamStockEvent?.Invoke();
// 删除多余入库任务
}
if (spaceInfo.spaceStock == 0 && spaceInfo.onRouteAmount == 0) if (spaceInfo.spaceStock == 0 && spaceInfo.onRouteAmount == 0)
{ {
// 清空型号供新型号使用 // 清空型号供新型号使用
@ -142,6 +163,7 @@ namespace Aucma.Scada.Business
spaceInfo.typeNameA = null; spaceInfo.typeNameA = null;
//重置货道,可以再次入库 //重置货道,可以再次入库
spaceInfo.inStoreFlag = 1; spaceInfo.inStoreFlag = 1;
spaceInfo.outStoreFlag = 1;
_spaceInfoService.UpdateSpaceInfo(spaceInfo); _spaceInfoService.UpdateSpaceInfo(spaceInfo);
RefreshFoamStockEvent?.Invoke(); RefreshFoamStockEvent?.Invoke();
} }
@ -240,7 +262,7 @@ namespace Aucma.Scada.Business
/// </summary> /// </summary>
/// <param name="taskInfo"></param> /// <param name="taskInfo"></param>
/// <returns></returns> /// <returns></returns>
public void JudgeIsFinish(RealTaskInfo taskInfo,IPlc _plc,SpaceAddress spaceAddress) public void JudgeIsFinish(RealTaskInfo taskInfo, IPlc _plc, SpaceAddress spaceAddress)
{ {
// 测试方法模拟plc正式启用删除 // 测试方法模拟plc正式启用删除
// _plc.writeInt32ByAddress(spaceAddress.inStoreFinish, 1); // _plc.writeInt32ByAddress(spaceAddress.inStoreFinish, 1);
@ -275,7 +297,7 @@ namespace Aucma.Scada.Business
/// </summary> /// </summary>
private void RealReadShellPlcSpace() private void RealReadShellPlcSpace()
{ {
if (foamRearTaskInfos != null && foamRearTaskInfos.Count>0) if (foamRearTaskInfos != null && foamRearTaskInfos.Count > 0)
{ {
List<string> spaceCodes = foamRearTaskInfos.Select(x => x.spaceCode).Distinct().ToList(); List<string> spaceCodes = foamRearTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
@ -462,7 +484,6 @@ namespace Aucma.Scada.Business
if (_plc != null) if (_plc != null)
{ {
spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore); spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore);
spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute); spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute);
// spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus); // spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus);
@ -525,5 +546,5 @@ namespace Aucma.Scada.Business
#endregion #endregion
} }
} }

@ -129,7 +129,7 @@ namespace Aucma.Scada.Business
} }
/// <summary> /// <summary>
/// 修改异常货道标识 /// 设置异常货道标识
/// </summary> /// </summary>
/// <param name="storeCode"></param> /// <param name="storeCode"></param>
/// <param name="spaceCode"></param> /// <param name="spaceCode"></param>
@ -143,6 +143,7 @@ namespace Aucma.Scada.Business
BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode); BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode);
if (spaceInfo != null) if (spaceInfo != null)
{ {
spaceInfo.unusualFlag = spaceInfo.unusualFlag == 1 ? 2 : 1; spaceInfo.unusualFlag = spaceInfo.unusualFlag == 1 ? 2 : 1;
result = _spaceInfoService.UpdateSpaceInfo(spaceInfo); result = _spaceInfoService.UpdateSpaceInfo(spaceInfo);
logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};异常标识:{spaceInfo.unusualFlag};修改{(result == true ? "" : "")}"); logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};异常标识:{spaceInfo.unusualFlag};修改{(result == true ? "" : "")}");
@ -170,7 +171,7 @@ namespace Aucma.Scada.Business
BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode); BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode);
if (spaceInfo != null) if (spaceInfo != null)
{ {
spaceInfo.spaceStatus = spaceInfo.spaceStatus == 1 ? 2 : 1; spaceInfo.spaceStatus = spaceInfo.spaceStatus == 1 ? 4 : 1;
result = _spaceInfoService.UpdateSpaceInfo(spaceInfo); result = _spaceInfoService.UpdateSpaceInfo(spaceInfo);
logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};货道状态:{spaceInfo.unusualFlag};修改{(result == true ? "" : "")}"); logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};货道状态:{spaceInfo.unusualFlag};修改{(result == true ? "" : "")}");
} }

@ -53,29 +53,8 @@ namespace Aucma.Scada.Business
plcPool.disConnectAll(); plcPool.disConnectAll();
} }
/// <summary>
/// 开启海康扫码器
/// </summary>
public void InitHikRobot()
{
try
{
Task.Run(() =>
{
Thread.Sleep(2000);
MvCodeHelper.Shell();
});
}
catch (Exception ex)
{
Console.WriteLine("InitHikRobotAndGun()开启海康扫码器和扫码枪方法异常" + ex.Message.ToString());
}
}
/// <summary> /// <summary>
/// 关闭海康扫码器 /// 关闭海康扫码器
/// </summary> /// </summary>

@ -1,4 +1,5 @@
using Aucma.Scada.Model.domain; using Aucma.Core.Scanner;
using Aucma.Scada.Model.domain;
using HighWayIot.Config; using HighWayIot.Config;
using HighWayIot.Log4net; using HighWayIot.Log4net;
using HighWayIot.Repository.service; using HighWayIot.Repository.service;
@ -39,6 +40,7 @@ namespace Aucma.Scada.Business
private OutStoreTaskHandle taskHandleBusiness = OutStoreTaskHandle.Instance; private OutStoreTaskHandle taskHandleBusiness = OutStoreTaskHandle.Instance;
private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance; private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance;
#endregion #endregion
@ -70,6 +72,11 @@ namespace Aucma.Scada.Business
private IRecordOutStoreService _recordOutStoreService; private IRecordOutStoreService _recordOutStoreService;
private IRecordProductfinishService _recordProductfinishService; private IRecordProductfinishService _recordProductfinishService;
private IPrintBarCodeServices _printBarCodeServices;
// 过点数据表
private IMaterialCompletionServices _iMaterialCompletionServices;
#endregion #endregion
#region 委托事件 #region 委托事件
@ -77,7 +84,7 @@ namespace Aucma.Scada.Business
/// 初始化出库任务 /// 初始化出库任务
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
public delegate void RefreshOutStoreTask(RealTaskInfo taskInfos); public delegate void RefreshOutStoreTask();
public event RefreshOutStoreTask RefreshOutStoreTaskEvent; public event RefreshOutStoreTask RefreshOutStoreTaskEvent;
/// <summary> /// <summary>
@ -106,6 +113,8 @@ namespace Aucma.Scada.Business
private OutStoreBusiness() private OutStoreBusiness()
{ {
_iMaterialCompletionServices = registerServices.GetService<IMaterialCompletionServices>();
_printBarCodeServices = registerServices.GetService<IPrintBarCodeServices>();
_spaceInfoService = registerServices.GetService<IBaseSpaceInfoService>(); _spaceInfoService = registerServices.GetService<IBaseSpaceInfoService>();
_taskInfoService = registerServices.GetService<IRealTaskInfoService>(); _taskInfoService = registerServices.GetService<IRealTaskInfoService>();
_bomInfoService = registerServices.GetService<IBaseBomInfoService>(); _bomInfoService = registerServices.GetService<IBaseBomInfoService>();
@ -115,12 +124,23 @@ namespace Aucma.Scada.Business
_recordOutStoreService = registerServices.GetService<IRecordOutStoreService>(); _recordOutStoreService = registerServices.GetService<IRecordOutStoreService>();
_recordProductfinishService = registerServices.GetService<IRecordProductfinishService>(); _recordProductfinishService = registerServices.GetService<IRecordProductfinishService>();
assemblyPlanBusiness.NextPassExecutePlanInfoEvent += PlanHandle; assemblyPlanBusiness.NextPassExecutePlanInfoEvent += PlanHandle;
MvCodeHelper.OutMaterialCodeStrEvent += OutStoreFinishHandle;
//assemblyPlanBusiness.PrintLogAndRefreshEvent += PrintLogInfoMessage;
assemblyPlanBusiness.GetSpaceInfoByMaterialTypeEvent += GetSpaceInfoByMaterialType;
taskHandleBusiness.OutStoreAnswerEvent += OutStoreAnswer; taskHandleBusiness.OutStoreAnswerEvent += OutStoreAnswer;
taskHandleBusiness.OutStoreFinsihEvent += OutStoreFinish; // taskHandleBusiness.OutStoreFinsihEvent += OutStoreFinish;
// test();
StartPassDown(); StartPassDown();
} }
public void test()
{
//var productInfo = _productPlanInfoService.GetProductPlanByPlanCode("2402290019");
//productInfo.beginTime = DateTime.Now;
//productInfo.completeAmount = productInfo.completeAmount + 1;
//_productPlanInfoService.UpdateProductPlanInfo(productInfo);
}
/// <summary> /// <summary>
/// 接收下达的组装计划根据BOM获取需要出库的泡后、内胆物料信息 /// 接收下达的组装计划根据BOM获取需要出库的泡后、内胆物料信息
@ -134,19 +154,41 @@ namespace Aucma.Scada.Business
{ {
if (planInfo != null) if (planInfo != null)
{ {
// var bomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, appConfig.foamMaterialType);
var bomInfo = _bomInfoService.GetBomInfoByMaterialCode(planInfo.materialCode); var bomInfo = _bomInfoService.GetBomInfoByMaterialCode(planInfo.materialCode);
if (bomInfo==null) if (bomInfo==null)
{ {
PrintLogInfoMessage($"物料:{planInfo.materialCode}获取Bom信息为空"); PrintLogInfoMessage($"物料:{planInfo.materialCode}获取Bom信息为空");
return; return;
} }
// 组装计划出库
//if (spaceInfo == null)
//{
// //筛选后的货道
// spaceInfo = GetSpaceInfoByMaterialType(appConfig.foamStoreCode, bomInfo.materialCode);
// if (spaceInfo == null)
// {
// PrintLogInfoMessage($"物料:{planInfo.materialCode};未匹配到货道");
// return;
// }
// for (int i = 0; i < spaceInfo.spaceStock; i++)
// {
// string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 7);
// OutStore(appConfig.foamStoreCode, bomInfo, planInfo.executePlanCode, taskCode, spaceInfo);
// Thread.Sleep(500);
// }
//}
// else // 指定货道出一个或者整道出
// {
for (int i = 0; i < planInfo.planAmount - planInfo.completeAmount; i++) for (int i = 0; i < planInfo.planAmount - planInfo.completeAmount; i++)
{ {
string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 10); string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 7);
OutStore(appConfig.foamStoreCode, bomInfo, planInfo.executePlanCode, taskCode,spaceInfo); OutStore(appConfig.foamStoreCode, bomInfo, planInfo.executePlanCode, taskCode, spaceInfo);
Thread.Sleep(500); Thread.Sleep(500);
} }
// }
} }
}); });
} }
@ -163,13 +205,8 @@ namespace Aucma.Scada.Business
try try
{ {
PrintLogInfoMessage($"收到出库计划,物料码:{bomInfo.materialCode}"); PrintLogInfoMessage($"收到出库计划,物料码:{bomInfo.materialCode}");
#region Delete By wenjy 2023-10-30 11:41:00 取消通过数据库获取货道数量、在途量改为通过PLC获取货道信息
//BaseSpaceInfo spaceInfo = _spaceInfoService.OutStoreGetSpaceInfoByMaterialCode(storeCode, bomInfo.materialCode);
#endregion
if(spaceInfo == null)
{
spaceInfo = GetSpaceInfoByMaterialType(storeCode, bomInfo.materialCode);
}
if (spaceInfo != null) if (spaceInfo != null)
{ {
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
@ -208,10 +245,6 @@ namespace Aucma.Scada.Business
{ {
bool result = false; bool result = false;
try try
{
//获取出库的货道明细物料信息
BaseSpaceDetail spaceDetail = GetSpaceDetailFirstOrderByCreatTime(spaceInfo);
if (spaceDetail != null)
{ {
#region 出库任务赋值 #region 出库任务赋值
RealTaskInfo realTaskInfo = new RealTaskInfo(); RealTaskInfo realTaskInfo = new RealTaskInfo();
@ -223,32 +256,30 @@ namespace Aucma.Scada.Business
realTaskInfo.storeCode = spaceInfo.storeCode; realTaskInfo.storeCode = spaceInfo.storeCode;
realTaskInfo.spaceCode = spaceInfo.spaceCode; realTaskInfo.spaceCode = spaceInfo.spaceCode;
realTaskInfo.spaceName = spaceInfo.spaceName; realTaskInfo.spaceName = spaceInfo.spaceName;
realTaskInfo.materialType = spaceDetail.materialType; realTaskInfo.materialType = spaceInfo.materialType;
realTaskInfo.materialCode = spaceDetail.materialCode;
realTaskInfo.planAmount = 1; realTaskInfo.planAmount = 1;
realTaskInfo.taskStatus = 1; realTaskInfo.taskStatus = 1;
realTaskInfo.createTime = DateTime.Now; realTaskInfo.createTime = DateTime.Now;
#endregion
#endregion
result = _taskInfoService.AddTaskInfo(realTaskInfo); result = _taskInfoService.AddTaskInfo(realTaskInfo);
if (result) if (result)
{ {
// 禁止入库
spaceInfo.inStoreFlag = 2;
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
PrintLogInfoMessage("出库任务创建成功"); PrintLogInfoMessage("出库任务创建成功");
RefreshOutStoreTaskEvent?.Invoke(realTaskInfo); RefreshOutStoreTaskEvent?.Invoke();
UpdateSpaceAndDetial(spaceInfo, spaceDetail); // UpdateSpaceAndDetial(spaceInfo, spaceDetail);
} }
else else
{ {
PrintLogInfoMessage("出库任务创建失败"); PrintLogInfoMessage("出库任务创建失败");
} }
}
else
{
PrintLogInfoMessage("出库任务创建失败,货道明细为空");
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -324,7 +355,7 @@ namespace Aucma.Scada.Business
while (true) while (true)
{ {
PassDownTaskInfo(); PassDownTaskInfo();
Thread.Sleep(500); Thread.Sleep(1000);
} }
}); });
@ -357,7 +388,9 @@ namespace Aucma.Scada.Business
taskInfo.taskStatus = 2; taskInfo.taskStatus = 2;
_taskInfoService.UpdateTaskInfo(taskInfo); _taskInfoService.UpdateTaskInfo(taskInfo);
RefreshScanMateriaCodeEvent?.Invoke(taskInfo.materialCode, taskInfo.materialType, taskInfo.spaceName, taskInfo.storeCode); //刷新出库任务界面
RefreshOutStoreTaskEvent?.Invoke();
// RefreshScanMateriaCodeEvent?.Invoke(taskInfo.materialCode, taskInfo.materialType, taskInfo.spaceName, taskInfo.storeCode);
} }
else if (result == 2) else if (result == 2)
{ {
@ -411,20 +444,21 @@ namespace Aucma.Scada.Business
PrintLogInfoMessage("出库应答成功,自动释放信号量,进行下发新任务"); PrintLogInfoMessage("出库应答成功,自动释放信号量,进行下发新任务");
semaphore.Release(); semaphore.Release();
// 视为出库完成,后续改为监测在库数 // 视为出库完成,后续改为监测在库数
OutStoreFinish(storeCode, taskCode); // OutStoreFinish(storeCode, taskCode);
} }
/// <summary>
/// 出库完成
/// </summary>
/// <param name="storeCode"></param>
/// <param name="taskCode"></param>
private void OutStoreFinish(string storeCode, string taskCode)
{
PrintLogInfoMessage($"出库任务:{taskCode};执行完成");
OutStoreFinishHandle(taskCode, appConfig.foamStoreCode); ///// <summary>
} ///// 出库完成
///// </summary>
///// <param name="storeCode"></param>
///// <param name="taskCode"></param>
//private void OutStoreFinish(string storeCode, string taskCode)
//{
// PrintLogInfoMessage($"出库任务:{taskCode};执行完成");
// OutStoreFinishHandle(taskCode, appConfig.foamStoreCode);
//}
/// <summary> /// <summary>
/// 信号量释放,根据任务完成数量,执行完成后进行释放 /// 信号量释放,根据任务完成数量,执行完成后进行释放
@ -447,66 +481,104 @@ namespace Aucma.Scada.Business
/// <param name="storeCode"></param> /// <param name="storeCode"></param>
/// <param name="spaceCode"></param> /// <param name="spaceCode"></param>
/// <param name="materialType"></param> /// <param name="materialType"></param>
private void OutStoreFinishHandle(string taskCode, string storeCode) private void OutStoreFinishHandle(string code)
{ {
try try
{ {
var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode, storeCode);
// 插入出库记录
PrintLogInfoMessage($"{code}:出库完成");
RealTaskInfo taskInfo = _taskInfoService.GetTaskInfoByTaskCode(SubStringMaterialCode(code), appConfig.foamStoreCode, 2);
if (taskInfo != null) if (taskInfo != null)
{ {
var spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.storeCode, taskInfo.spaceCode); //更新计划信息
UpdatePlanInfo(taskInfo.planCode);
//刷新界面
RefreshScanMateriaCodeEvent?.Invoke(code, code.Substring(7, 10), taskInfo.spaceName, appConfig.foamStoreCode); //刷新界面扫码信息
if (spaceInfo != null)
{
// taskHandleBusiness.WritePlc(spaceInfo.storeCode, spaceInfo.spaceCode);
//读取PLC获取货道信息存放数量、在途数量
#region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
var item = taskHandleBusiness.ReadSpaceInfoByPlc(spaceInfo);
spaceInfo.spaceStock = item.spaceStock;
spaceInfo.onRouteAmount = item.onRouteAmount;
//spaceInfo.spaceStatus = item.spaceStatus;
#endregion
if (spaceInfo.spaceStock == 0)
{
spaceInfo.materialType = string.Empty;
} }
else
{
//刷新界面
RefreshScanMateriaCodeEvent?.Invoke(code, code.Substring(7, 10), "", appConfig.foamStoreCode); //刷新界面扫码信息
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
#region 根据创建时间删除没有型号的任务
#endregion
}
// _taskInfoService.DeleteTaskInfoByCode(taskInfo);
// 查询该型号的类型任务按照时间排序删除第一条, 清除任务信息
_taskInfoService.DeleteFirstTaskByStoreCode(appConfig.foamStoreCode, 2);
#region 添加出库记录 #region 添加出库记录
RecordOutstore recordOutstore = new RecordOutstore(); RecordOutstore recordOutstore = new RecordOutstore();
recordOutstore.storeCode = taskInfo.storeCode; recordOutstore.storeCode = appConfig.foamStoreCode;
if (taskInfo != null)
{
recordOutstore.spaceCode = taskInfo.spaceCode; recordOutstore.spaceCode = taskInfo.spaceCode;
recordOutstore.materialCode = taskInfo.materialCode; }
recordOutstore.materialType = taskInfo.materialType; recordOutstore.materialCode = code;
recordOutstore.materialName = GetMaterialName(taskInfo.materialType); recordOutstore.materialType = code.Substring(7, 10);
recordOutstore.materialName = GetMaterialName(recordOutstore.materialType);
recordOutstore.outStoreAmount = 1; recordOutstore.outStoreAmount = 1;
recordOutstore.outStoreTime = DateTime.Now; recordOutstore.outStoreTime = DateTime.Now;
_recordOutStoreService.InsertReocrdOutStoreService(recordOutstore); _recordOutStoreService.InsertReocrdOutStoreService(recordOutstore);
#endregion #endregion
}
//更新计划信息
UpdatePlanInfo(taskInfo.planCode);
RefreshStoreStockEvent?.Invoke(); // 根据条码查询明细并删除
_spaceDetailService.DeleteSpaceDetailByMaterialCode(code);
//清除任务信息
_taskInfoService.DeleteTaskInfo(taskCode, storeCode);
_spaceDetailService.DeleteSpaceDetailByMaterialCode(taskInfo.materialCode); // 刷新任务页面
RefreshOutStoreTaskEvent?.Invoke();
//刷新界面 #region 出库更新过点数据,插入记录到MATERIAL_COMPLETION表
RefreshScanMateriaCodeEvent?.Invoke(string.Empty, string.Empty, string.Empty, taskInfo.storeCode); if (!string.IsNullOrEmpty(code))
{
PrintBarCode print = _printBarCodeServices.query(code);
if (print != null)
{
// string planCode = _productPlanInfoServices.GetPlanCode(print.OrderCode, appConfig.stationCode);
MaterialCompletion completion = new MaterialCompletion();
completion.OrderCode = print.OrderCode;
completion.MaterialBarcode = code;
completion.MaterialCode = print.MaterialCode;
completion.MaterialName = print.MaterialName;
completion.StationName = appConfig.outstationCode;
completion.CompleteDate = DateTime.Now;
// completion.planCode = planCode;
_iMaterialCompletionServices.Add(completion);
}
} }
#endregion
} }
catch (Exception ex) catch (Exception ex)
{ {
PrintLogErrorMessage("出库完成逻辑处理异常", ex); PrintLogErrorMessage("出库完成逻辑处理异常:"+ ex);
}
}
/// <summary>
/// 截条码类型
/// </summary>
/// <param name="materialCode"></param>
/// <returns></returns>
private string SubStringMaterialCode(string materialCode)
{
string result = string.Empty;
if (!string.IsNullOrEmpty(materialCode))
{
result = materialCode.Substring(7, 10);
} }
return result;
} }
@ -518,9 +590,11 @@ namespace Aucma.Scada.Business
{ {
try try
{ {
var executeInfo = _executePlanInfoService.GetExecutePlanInfoByPlanCode(planCode); var executeInfo = _executePlanInfoService.GetExecutePlanInfoByPlanCode(planCode);
if (executeInfo != null) if (executeInfo != null)
{ {
executeInfo.completeAmount += 1; executeInfo.completeAmount += 1;
if (executeInfo.completeAmount == executeInfo.planAmount) if (executeInfo.completeAmount == executeInfo.planAmount)
@ -533,8 +607,12 @@ namespace Aucma.Scada.Business
var productInfo = _productPlanInfoService.GetProductPlanByPlanCode(executeInfo.productPlanCode); var productInfo = _productPlanInfoService.GetProductPlanByPlanCode(executeInfo.productPlanCode);
if (productInfo != null) if (productInfo != null)
{ {
if(productInfo.completeAmount==0)
{
productInfo.beginTime = DateTime.Now;
}
productInfo.completeAmount += 1; productInfo.completeAmount += 1;
if (productInfo.completeAmount == productInfo.planAmount) if (productInfo.completeAmount >= productInfo.planAmount)
{ {
productInfo.endTime = DateTime.Now; productInfo.endTime = DateTime.Now;
} }
@ -613,6 +691,16 @@ namespace Aucma.Scada.Business
return result; return result;
} }
/// <summary>
/// 泡后库出库删除所有任务信息
/// </summary>
/// <param name="taskInfo"></param>
/// <summary>
public bool DeleteAllTaskByStoreCode(string storeCode, int taskType)
{
return _taskInfoService.DeleteAllTaskByStoreCode(storeCode, taskType);
}
/// <summary> /// <summary>
/// 根据货道手动出一个 /// 根据货道手动出一个
/// </summary> /// </summary>
@ -637,7 +725,7 @@ namespace Aucma.Scada.Business
else else
{ {
// 不关联生产计划 // 不关联生产计划
result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 10), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1); result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 7), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1);
} }
} }
@ -677,9 +765,9 @@ namespace Aucma.Scada.Business
#endregion #endregion
else else
{ {
for(int i = 1; i < spaceInfo.spaceStock; i++) for(int i = 1; i <= spaceInfo.spaceStock; i++)
{ {
result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 10), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1); result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 7), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1);
if (!result) if (!result)
{ {
return false; return false;
@ -707,7 +795,7 @@ namespace Aucma.Scada.Business
/// 日志输出,界面刷新同时记录文件 /// 日志输出,界面刷新同时记录文件
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
private void PrintLogInfoMessage(string message) public void PrintLogInfoMessage(string message)
{ {
RefreshLogMessageEvent?.Invoke(message); RefreshLogMessageEvent?.Invoke(message);
logHelper.Info(message); logHelper.Info(message);
@ -754,12 +842,12 @@ namespace Aucma.Scada.Business
return materialName; return materialName;
} }
/// 通过PLC读取货道信息在库数量、货道状态) /// 出库找货道
/// </summary> /// </summary>
/// <param name="storeCode"></param> /// <param name="storeCode"></param>
/// <param name="materialType"></param> /// <param name="materialType"></param>
/// <returns></returns> /// <returns></returns>
private BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType) public BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType)
{ {
BaseSpaceInfo result = null; BaseSpaceInfo result = null;
@ -767,33 +855,23 @@ namespace Aucma.Scada.Business
{ {
List<BaseSpaceInfo> info = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType,2); List<BaseSpaceInfo> info = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType,2);
if (info != null) if (info != null && info.Count>0)
{
if (info.Count > 0)
{ {
foreach (BaseSpaceInfo item in info) foreach (BaseSpaceInfo item in info)
{ {
var spaceInfo = taskHandleBusiness.ReadSpaceInfoByPlc(item); var spaceInfo = taskHandleBusiness.ReadSpaceInfoByPlc(item);
item.spaceStock = spaceInfo.spaceStock; item.spaceStock = spaceInfo.spaceStock;
item.onRouteAmount = spaceInfo.onRouteAmount; item.onRouteAmount = spaceInfo.onRouteAmount;
// item.spaceStatus = spaceInfo.spaceStatus;
} }
//result = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0).OrderBy(x => x.spaceStock).OrderBy(x => x.spaceCode).First(); result = info.OrderByDescending(x => x.spaceStock).First();
var list = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0).ToList();
if (list.Count > 0)
{
result = info.OrderBy(x => x.spaceStock).First();
} }
else else
{ {
PrintLogInfoMessage("未获取到匹配的货道,请排查货道库存及货道状态是否可用"); PrintLogInfoMessage("未获取到匹配的货道,请排查货道库存及货道状态是否可用");
} }
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -62,6 +62,8 @@ namespace Aucma.Scada.Business
services.AddSingleton<IRecordOutStoreService, RecordOutStoreServiceImpl>(); services.AddSingleton<IRecordOutStoreService, RecordOutStoreServiceImpl>();
services.AddSingleton<IRecordProductfinishService, RecordProductfinishServiceImpl>(); services.AddSingleton<IRecordProductfinishService, RecordProductfinishServiceImpl>();
services.AddSingleton<IPrintBarCodeServices, PrintBarCodeServicesImpl>(); services.AddSingleton<IPrintBarCodeServices, PrintBarCodeServicesImpl>();
services.AddSingleton<IMaterialCompletionServices, MaterialCompletionServiceImpl>();
} }
public T GetService<T>() public T GetService<T>()

@ -20,12 +20,18 @@ namespace Aucma.Core.Scanner
private static AppConfig appConfig = AppConfig.Instance; private static AppConfig appConfig = AppConfig.Instance;
public static bool m_bGrabbing = true; public static bool m_bGrabbing = true;
private static string SheellLastCode; private static string SheellLastCode;
// 箱壳扫码器ip private static string LinerLastCode;
// 入库扫码器ip
private static string ShellScannerIp = appConfig.foamHikRobotIp; private static string ShellScannerIp = appConfig.foamHikRobotIp;
// 出库扫码器ip
private static string LinerScannerIp = appConfig.foamOutHikRobotIp;
#region 全局变量定义 #region 全局变量定义
public static DateTime ShellLiveTime = DateTime.Now; public static DateTime ShellLiveTime = DateTime.Now;
public static DateTime LinerLiveTime = DateTime.Now;
#endregion #endregion
#region 委托事件 #region 委托事件
@ -35,16 +41,23 @@ namespace Aucma.Core.Scanner
/// </summary> /// </summary>
/// <param name="materialCodeStr"></param> /// <param name="materialCodeStr"></param>
/// <param name="ip"></param> /// <param name="ip"></param>
public delegate void RefreshState(bool flag); public delegate void RefreshState(string ip, bool flag);
public static event RefreshState RefreshStateEvent; public static event RefreshState RefreshStateEvent;
//NoRead事件通知 //NoRead事件通知
public delegate void MessageNoRead(); public delegate void MessageNoRead();
public static event MessageNoRead MessageNoReadEvent; public static event MessageNoRead MessageNoReadEvent;
//入库扫码
public delegate void RefreshMaterialCodeStr(string materialCodeStr); public delegate void RefreshMaterialCodeStr(string materialCodeStr);
public static event RefreshMaterialCodeStr RefreshMaterialCodeStrEvent; public static event RefreshMaterialCodeStr RefreshMaterialCodeStrEvent;
//出库扫码
public delegate void OutMaterialCodeStr(string materialCodeStr);
public static event OutMaterialCodeStr OutMaterialCodeStrEvent;
/// <summary> /// <summary>
/// 日志信息刷新 /// 日志信息刷新
/// </summary> /// </summary>
@ -64,8 +77,8 @@ namespace Aucma.Core.Scanner
{ {
//更新扫码器存活时间 //更新扫码器存活时间
ShellLiveTime = DateTime.Now; ShellLiveTime = DateTime.Now;
Console.WriteLine("箱壳No Read 处理"); Console.WriteLine("入库No Read 处理");
MessageNoReadEvent(); MessageNoReadEvent?.Invoke();
} }
for (Int32 i = 0; i < stBcrResult.nCodeNum; i++) for (Int32 i = 0; i < stBcrResult.nCodeNum; i++)
@ -79,7 +92,7 @@ namespace Aucma.Core.Scanner
else else
{ {
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode); string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
Console.WriteLine(DateTime.Now + ":箱壳扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]"); Console.WriteLine(DateTime.Now + ":入库扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
if (string.IsNullOrEmpty(SheellLastCode) || SheellLastCode != strCode.Trim().TrimEnd('\0')) if (string.IsNullOrEmpty(SheellLastCode) || SheellLastCode != strCode.Trim().TrimEnd('\0'))
{ {
@ -90,7 +103,59 @@ namespace Aucma.Core.Scanner
} }
if (SheellLastCode == strCode.Trim().TrimEnd('\0')) if (SheellLastCode == strCode.Trim().TrimEnd('\0'))
{ {
Console.WriteLine("箱壳和上次扫描结果一样,不作处理"); Console.WriteLine("入库和上次扫描结果一样,不作处理");
}
}
}
MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
for (int i = 0; i < stOcrInfo.nOCRAllNum; i++)
{
string strOcrCharCode = Encoding.UTF8.GetString(stOcrInfo.stOcrRowInfo[i].chOcr);
Console.WriteLine("Get OcrInfo:" + "ocrNum[" + i.ToString() + "], ocrLen[" + Convert.ToString(stOcrInfo.stOcrRowInfo[i].nOcrLen) + "], ocrChar[" + strOcrCharCode.Trim().TrimEnd('\0') + "]");
}
}
public static void LinerImageCallbackFunc(IntPtr pData, IntPtr pstFrameInfoEx2, IntPtr pUser)
{
var stFrameInfo = (MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2)Marshal.PtrToStructure(pstFrameInfoEx2, typeof(MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2));
MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2 stBcrResult = (MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2)Marshal.PtrToStructure(stFrameInfo.UnparsedBcrList.pstCodeListEx2, typeof(MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2));
// Console.WriteLine("CodeNum[" + Convert.ToString(stBcrResult.nCodeNum) + "]");
if (stBcrResult.nCodeNum == 0)
{
// 更新存活时间
LinerLiveTime = DateTime.Now;
Console.WriteLine("出库No Read 处理");
MessageNoReadEvent();
}
for (Int32 i = 0; i < stBcrResult.nCodeNum; i++)
{
bool bIsValidUTF8 = IsTextUTF8(stBcrResult.stBcrInfoEx2[i].chCode);
if (bIsValidUTF8)
{
string strCode = Encoding.UTF8.GetString(stBcrResult.stBcrInfoEx2[i].chCode);
Console.WriteLine("Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
}
else
{
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
Console.WriteLine(DateTime.Now + ":出库扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
if (string.IsNullOrEmpty(LinerLastCode) || LinerLastCode != strCode.Trim().TrimEnd('\0'))
{
// 更新存活时间
LinerLiveTime = DateTime.Now;
OutMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'));
LinerLastCode = strCode.Trim().TrimEnd('\0');
}
if (LinerLastCode == strCode.Trim().TrimEnd('\0'))
{
Console.WriteLine("出库和上次扫描一样,不作处理");
} }
} }
@ -98,6 +163,7 @@ namespace Aucma.Core.Scanner
MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)); MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
Console.WriteLine("ocrAllNum[" + Convert.ToString(stOcrInfo.nOCRAllNum) + "]");
for (int i = 0; i < stOcrInfo.nOCRAllNum; i++) for (int i = 0; i < stOcrInfo.nOCRAllNum; i++)
{ {
string strOcrCharCode = Encoding.UTF8.GetString(stOcrInfo.stOcrRowInfo[i].chOcr); string strOcrCharCode = Encoding.UTF8.GetString(stOcrInfo.stOcrRowInfo[i].chOcr);
@ -123,9 +189,9 @@ namespace Aucma.Core.Scanner
if (MvCodeReader.MV_CODEREADER_OK != nRet) if (MvCodeReader.MV_CODEREADER_OK != nRet)
{ {
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库",false);
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
Thread.Sleep(1000 * 10); Thread.Sleep(1000 * 10);
Console.WriteLine("Enum device failed:{0:x8}", nRet); Console.WriteLine("Enum device failed:{0:x8}", nRet);
break; break;
@ -134,9 +200,9 @@ namespace Aucma.Core.Scanner
if (0 == stDevList.nDeviceNum) if (0 == stDevList.nDeviceNum)
{ {
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
Thread.Sleep(1000 * 10); Thread.Sleep(1000 * 10);
break; break;
@ -169,9 +235,9 @@ namespace Aucma.Core.Scanner
} }
if (nDevIndex < 0) if (nDevIndex < 0)
{ {
Console.WriteLine("未找到箱壳扫码器"); Console.WriteLine("未找到入库扫码器");
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
Thread.Sleep(1000 * 30); Thread.Sleep(1000 * 30);
break; break;
} }
@ -183,7 +249,7 @@ namespace Aucma.Core.Scanner
{ {
Console.WriteLine("Create device failed:{0:x8}", nRet); Console.WriteLine("Create device failed:{0:x8}", nRet);
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
break; break;
} }
@ -194,12 +260,12 @@ namespace Aucma.Core.Scanner
{ {
Console.WriteLine("Open device failed:{0:x8}", nRet); Console.WriteLine("Open device failed:{0:x8}", nRet);
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
break; break;
} }
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(true); RefreshStateEvent?.Invoke("入库", true);
// ch:注册回调函数 | en:Register image callback // ch:注册回调函数 | en:Register image callback
ImageCallback = new MvCodeReader.cbOutputEx2delegate(ShellImageCallbackFunc); ImageCallback = new MvCodeReader.cbOutputEx2delegate(ShellImageCallbackFunc);
nRet = device.MV_CODEREADER_RegisterImageCallBackEx2_NET(ImageCallback, IntPtr.Zero); nRet = device.MV_CODEREADER_RegisterImageCallBackEx2_NET(ImageCallback, IntPtr.Zero);
@ -207,7 +273,7 @@ namespace Aucma.Core.Scanner
{ {
Console.WriteLine("Register image callback failed!"); Console.WriteLine("Register image callback failed!");
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
break; break;
} }
@ -217,7 +283,7 @@ namespace Aucma.Core.Scanner
{ {
Console.WriteLine("Start grabbing failed:{0:x8}", nRet); Console.WriteLine("Start grabbing failed:{0:x8}", nRet);
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
break; break;
} }
@ -231,16 +297,15 @@ namespace Aucma.Core.Scanner
TimeSpan timeSpan = dateTime.Subtract(ShellLiveTime); TimeSpan timeSpan = dateTime.Subtract(ShellLiveTime);
if (timeSpan.TotalMinutes >= 10) if (timeSpan.TotalMinutes >= 10)
{ {
Console.WriteLine("箱壳扫码器超时"); Console.WriteLine("入库扫码器超时");
//CloseShell();
//Shell();
break; break;
} }
} }
// Console.ReadLine(); // Console.ReadLine();
// 刷新扫码器状态 // 刷新扫码器状态
RefreshStateEvent?.Invoke(false); RefreshStateEvent?.Invoke("入库", false);
// ch:停止抓图 | en:Stop grabbing // ch:停止抓图 | en:Stop grabbing
nRet = device.MV_CODEREADER_StopGrabbing_NET(); nRet = device.MV_CODEREADER_StopGrabbing_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet) if (MvCodeReader.MV_CODEREADER_OK != nRet)
@ -270,6 +335,170 @@ namespace Aucma.Core.Scanner
} }
public static void Liner()
{
LinerLiveTime = DateTime.Now;
MvCodeReader.cbOutputEx2delegate ImageCallback;
MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2 stFrameInfo = new MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2();
MvCodeReader device = new MvCodeReader();
int nRet = MvCodeReader.MV_CODEREADER_OK;
do
{
// ch:枚举设备 | en:Enum device
MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST stDevList = new MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST();
nRet = MvCodeReader.MV_CODEREADER_EnumDevices_NET(ref stDevList, MvCodeReader.MV_CODEREADER_GIGE_DEVICE);
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
// 刷新扫码器状态
RefreshStateEvent?.Invoke("入库", false);
RefreshStateEvent?.Invoke("出库", false);
Thread.Sleep(1000 * 10);
Console.WriteLine("Enum device failed:{0:x8}", nRet);
break;
}
Console.WriteLine("Enum device count : " + Convert.ToString(stDevList.nDeviceNum));
if (0 == stDevList.nDeviceNum)
{
// 刷新扫码器状态
RefreshStateEvent?.Invoke("入库", false);
RefreshStateEvent?.Invoke("出库", false);
Thread.Sleep(1000 * 10);
break;
}
MvCodeReader.MV_CODEREADER_DEVICE_INFO stDevInfo; // 通用设备信息
Int32 nDevIndex = -1;
// ch:打印设备信息 | en:Print device info
for (Int32 i = 0; i < stDevList.nDeviceNum; i++)
{
stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(stDevList.pDeviceInfo[i], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
if (MvCodeReader.MV_CODEREADER_GIGE_DEVICE == stDevInfo.nTLayerType)
{
MvCodeReader.MV_CODEREADER_GIGE_DEVICE_INFO stGigEDeviceInfo = (MvCodeReader.MV_CODEREADER_GIGE_DEVICE_INFO)MvCodeReader.ByteToStruct(stDevInfo.SpecialInfo.stGigEInfo, typeof(MvCodeReader.MV_CODEREADER_GIGE_DEVICE_INFO));
uint nIp1 = ((stGigEDeviceInfo.nCurrentIp & 0xff000000) >> 24);
uint nIp2 = ((stGigEDeviceInfo.nCurrentIp & 0x00ff0000) >> 16);
uint nIp3 = ((stGigEDeviceInfo.nCurrentIp & 0x0000ff00) >> 8);
uint nIp4 = (stGigEDeviceInfo.nCurrentIp & 0x000000ff);
// Console.WriteLine("\n" + i.ToString() + ": [GigE] User Define Name : " + stGigEDeviceInfo.chUserDefinedName);
string ip = ((stGigEDeviceInfo.nCurrentIp & 0xff000000) >> 24) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x00ff0000) >> 16) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x0000ff00) >> 8) + "." + (stGigEDeviceInfo.nCurrentIp & 0x000000ff);
string ipStr = nIp1 + "." + nIp2 + "." + nIp3 + "." + nIp4;
if (ipStr == LinerScannerIp)
{
Console.WriteLine("device IP :" + ipStr);
nDevIndex = i;
}
}
}
if (nDevIndex < 0)
{
Console.WriteLine("未找到出库扫码器");
// 刷新扫码器状态
RefreshStateEvent?.Invoke("出库", false);
Thread.Sleep(1000 * 30);
break;
}
stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(stDevList.pDeviceInfo[nDevIndex], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
// ch:创建设备 | en:Create device
nRet = device.MV_CODEREADER_CreateHandle_NET(ref stDevInfo);
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Create device failed:{0:x8}", nRet);
break;
}
// ch:打开设备 | en:Open device
nRet = device.MV_CODEREADER_OpenDevice_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Open device failed:{0:x8}", nRet);
// 刷新扫码器状态
RefreshStateEvent?.Invoke("出库", false);
break;
}
// 刷新扫码器状态
RefreshStateEvent?.Invoke("出库", true);
// ch:注册回调函数 | en:Register image callback
ImageCallback = new MvCodeReader.cbOutputEx2delegate(LinerImageCallbackFunc);
nRet = device.MV_CODEREADER_RegisterImageCallBackEx2_NET(ImageCallback, IntPtr.Zero);
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Register image callback failed!");
break;
}
// ch:开启抓图 || en: start grab image
nRet = device.MV_CODEREADER_StartGrabbing_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Start grabbing failed:{0:x8}", nRet);
break;
}
Console.WriteLine("Press enter to exit");
Console.WriteLine(DateTime.Now.ToString());
while (true)
{
Thread.Sleep(1000 * 60);
DateTime dateTime = DateTime.Now;
TimeSpan timeSpan = dateTime.Subtract(LinerLiveTime);
if (timeSpan.TotalMinutes >= 10)
{
Console.WriteLine("出库扫码器超时");
//CloseShell();
//Shell();
break;
}
}
//Console.ReadLine();
// ch:停止抓图 | en:Stop grabbing
nRet = device.MV_CODEREADER_StopGrabbing_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Stop grabbing failed{0:x8}", nRet);
break;
}
// ch:关闭设备 | en:Close device
nRet = device.MV_CODEREADER_CloseDevice_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Close device failed{0:x8}", nRet);
break;
}
// ch:销毁设备 | en:Destroy device
nRet = device.MV_CODEREADER_DestroyHandle_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Destroy device failed:{0:x8}", nRet);
break;
}
} while (false);
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
// ch:销毁设备 | en:Destroy device
nRet = device.MV_CODEREADER_DestroyHandle_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
Console.WriteLine("Destroy device failed:{0:x8}", nRet);
}
}
Thread.Sleep(1000);
Liner();
}

@ -40,7 +40,7 @@ namespace Aucma.Scada.UI
else else
{ {
mainBusiness.InitPlc(); mainBusiness.InitPlc();
mainBusiness.InitHikRobot(); // mainBusiness.InitHikRobot();
} }
} }
private void Application_Exit(object sender, ExitEventArgs e) private void Application_Exit(object sender, ExitEventArgs e)

@ -116,6 +116,12 @@
</Border.Background> </Border.Background>
</Border> </Border>
<TextBlock x:Name="Scanner1" Text="{Binding Scanner1UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner1UIColor}" FontSize="15" Margin="10,0"/> <TextBlock x:Name="Scanner1" Text="{Binding Scanner1UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner1UIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="Scanner2Status" ImageSource="{Binding Scanner2UIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="Scanner2" Text="{Binding Scanner2UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner2UIColor}" FontSize="15" Margin="10,0"/>
</StackPanel> </StackPanel>
</Grid> </Grid>

@ -9,7 +9,7 @@
mc:Ignorable="d" FontFamily="Microsoft YaHei" Background="#1152AC" mc:Ignorable="d" FontFamily="Microsoft YaHei" Background="#1152AC"
d:DesignHeight="750" d:DesignWidth="1920" > d:DesignHeight="750" d:DesignWidth="1920" >
<UserControl.Resources> <UserControl.Resources>
<local1:PlanStatusConverter x:Key="PlanStatusConverter" /> <local1:PlanStatusConverter x:Key="PlanStatusConverter"/>
<Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}"> <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontSize" Value="20"/> <Setter Property="FontSize" Value="20"/>
@ -250,7 +250,7 @@
<lvc:CartesianChart.AxisY> <lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="20" MinValue="0"> <lvc:Axis FontSize="20" MinValue="0">
<lvc:Axis.Separator> <lvc:Axis.Separator>
<lvc:Separator Step="10" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" > <lvc:Separator Step="50" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
</lvc:Separator> </lvc:Separator>
</lvc:Axis.Separator> </lvc:Axis.Separator>
</lvc:Axis> </lvc:Axis>
@ -293,13 +293,13 @@
Foreground="#FFFFFF" > Foreground="#FFFFFF" >
<!--resourceStyle 399行修改选中字体颜色--> <!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding executePlanCode}" Header="计划编号" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <!--<DataGridTextColumn Binding="{Binding executePlanCode}" Header="计划编号" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<!--<DataGridTextColumn Binding="{Binding productPlanCode}" Header="生产计划" Width="1*" IsReadOnly="True"/>--> <!--<DataGridTextColumn Binding="{Binding productPlanCode}" Header="生产计划" Width="1*" IsReadOnly="True"/>-->
<DataGridTextColumn Binding="{Binding materialName}" Header="产品型号" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding materialName}" Header="产品型号" Width="1.7*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding planAmount}" Header="计划数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding planAmount}" Header="计划数" Width="0.6*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding completeAmount}" Header="完成数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding completeAmount}" Header="完成数" Width="0.6*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding beginTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="开始时间" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding beginTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="开始时间" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding executeStatus,Converter={StaticResource PlanStatusConverter}}" Header="执行状态" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding executeStatus,Converter={StaticResource PlanStatusConverter}}" Header="执行状态" Width="0.7*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding endTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="完成时间" Width="1*" IsReadOnly="True"/>--> <!--<DataGridTextColumn Binding="{Binding endTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="完成时间" Width="1*" IsReadOnly="True"/>-->
<!--<DataGridTextColumn Binding="{Binding createdTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="创建时间" Width="1*" IsReadOnly="True"/>--> <!--<DataGridTextColumn Binding="{Binding createdTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="创建时间" Width="1*" IsReadOnly="True"/>-->
<DataGridTemplateColumn Header="操作" Width="2*"> <DataGridTemplateColumn Header="操作" Width="2*">
@ -366,7 +366,7 @@
<lvc:CartesianChart.AxisY> <lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="20" MinValue="0"> <lvc:Axis FontSize="20" MinValue="0">
<lvc:Axis.Separator> <lvc:Axis.Separator>
<lvc:Separator Step="10" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" > <lvc:Separator Step="50" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
</lvc:Separator> </lvc:Separator>
</lvc:Axis.Separator> </lvc:Axis.Separator>
</lvc:Axis> </lvc:Axis>

@ -164,7 +164,7 @@
<lvc:CartesianChart.AxisY> <lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="15" MinValue="0"> <lvc:Axis FontSize="15" MinValue="0">
<lvc:Axis.Separator> <lvc:Axis.Separator>
<lvc:Separator Step="1" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" > <lvc:Separator Step="50" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
</lvc:Separator> </lvc:Separator>
</lvc:Axis.Separator> </lvc:Axis.Separator>
</lvc:Axis> </lvc:Axis>
@ -200,6 +200,11 @@
<Button Content="查询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/> <Button Content="查询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/>
<Button Content="重置" Command="{Binding ResetCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/> <Button Content="重置" Command="{Binding ResetCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/>
<Label Content="货道号:" Margin="150 0 0 0" Foreground="White" FontSize="20"/>
<TextBox x:Name="SpaceCodeText" Style="{StaticResource TextBoxStyle}" Margin="10 0 0 0" Width="50" Height="25" Foreground= "#FFFFFF" VerticalAlignment="Center" FontSize="20"/>
<Button Content="手动入库" Style="{StaticResource BUTTON_AGREE}" Background="#FF9900" BorderBrush="#FF9900" Foreground="White" Margin="20 0 0 0" Height="36" Width="120" FontSize="20" Click="Button_Click"/>
</StackPanel> </StackPanel>
</Border> </Border>
<DataGrid Grid.Row="1" Name="DG" ItemsSource="{Binding InstoreTask}" Background="Transparent" <DataGrid Grid.Row="1" Name="DG" ItemsSource="{Binding InstoreTask}" Background="Transparent"
@ -210,12 +215,22 @@
Foreground="#FFFFFF" > Foreground="#FFFFFF" >
<!--resourceStyle 399行修改选中字体颜色--> <!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding taskCode}" Header="任务编号" Width="0.4*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding taskCode}" Header="任务编号" Width="0.3*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding materialCode}" Header="物料编码" Width="1.6*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding materialCode}" Header="物料编码" Width="1.0*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding materialType}" Header="物料类型" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <!--<DataGridTextColumn Binding="{Binding materialType}" Header="物料类型" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding spaceCode}" Header="入库货道" Width="0.5*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding spaceCode}" Header="入库货道" Width="0.3*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding taskStatus,Converter={StaticResource TaskStatusConverter}}" Header="入库状态" Width="0.5*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding taskStatus,Converter={StaticResource TaskStatusConverter}}" Header="入库状态" Width="0.4*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding createTime,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="任务时间" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding createTime,StringFormat=\{0:MM月dd日 HH:mm:ss\}}" Header="任务时间" Width="0.7*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTemplateColumn Header="操作" Width="0.6*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="完成" CommandParameter="{Binding taskCode}" Background="#007DFA" Foreground="White" Margin="10,0,0,0" Height="25" BorderBrush="DeepSkyBlue" BorderThickness="0" Width="70" Command="{Binding DataContext.CompletePlanCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid }}" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>

@ -1,4 +1,9 @@
using Aucma.Scada.UI.viewModel.InStoreInfo; using Aucma.Scada.Business;
using Aucma.Scada.UI.viewModel.InStoreInfo;
using HighWayIot.Config;
using System;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
namespace Aucma.Scada.UI.Page.InStoreInfo namespace Aucma.Scada.UI.Page.InStoreInfo
@ -8,6 +13,11 @@ namespace Aucma.Scada.UI.Page.InStoreInfo
/// </summary> /// </summary>
public partial class InStoreInfoControl : UserControl public partial class InStoreInfoControl : UserControl
{ {
//异常入库
public delegate void ExceptionInstore(string materialCodeStr);
public static event ExceptionInstore ExceptionInstoreEvent;
public InStoreInfoControl() public InStoreInfoControl()
{ {
InitializeComponent(); InitializeComponent();
@ -15,5 +25,44 @@ namespace Aucma.Scada.UI.Page.InStoreInfo
InStoreInfoViewModel inStoreInfoViewModel = new InStoreInfoViewModel(); InStoreInfoViewModel inStoreInfoViewModel = new InStoreInfoViewModel();
this.DataContext = inStoreInfoViewModel; this.DataContext = inStoreInfoViewModel;
} }
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
try
{
if (string.IsNullOrEmpty(SpaceCodeText.Text))
{
MessageBox.Show("请输入1-9的货道编号!");
}
else
{
// 定义正则表达式模式
string pattern = "^[1-9]$";
// 创建正则表达式对象
Regex regex = new Regex(pattern);
// 使用 IsMatch 方法检查字符串
bool isMatch = regex.IsMatch(SpaceCodeText.Text);
if (isMatch)
{
MessageBoxResult result = MessageBox.Show($"确认异常入{SpaceCodeText.Text}库吗", "删除确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
// 入库
InStoreBusiness.Instance.ExceptionInstore("PH_00" + SpaceCodeText.Text);
}
}
else
{
MessageBox.Show("请输入1-9的货道编号!");
}
}
}catch (Exception ex)
{
}
}
} }
} }

@ -195,22 +195,7 @@
<Border Grid.Column="1" Grid.Row="1" BorderBrush="White" BorderThickness="1"> <Border Grid.Column="1" Grid.Row="1" BorderBrush="White" BorderThickness="1">
<TextBlock Text="{Binding typeNameA}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" /> <TextBlock Text="{Binding typeNameA}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border> </Border>
<!--<Border Grid.Column="0" Grid.Row="1" BorderBrush="White" BorderThickness="1" >
<TextBlock Text="型号2" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Grid.Row="1" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.SubmitCommand2, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding Text, ElementName=spaceCodeText}" Background="Transparent">
<TextBlock Text="{Binding typeCodeB}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
</Border>
<Border Grid.Column="0" Grid.Row="2" BorderBrush="White" BorderThickness="1" >
<TextBlock Text="型号3" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Grid.Row="2" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.SubmitCommand3, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding Text, ElementName=spaceCodeText}" Background="Transparent">
<TextBlock Text="{Binding typeCodeC}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
</Border>-->
</Grid> </Grid>
</Border> </Border>
@ -220,11 +205,11 @@
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition />
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition Width="2*"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="White" BorderThickness="1" > <Border Grid.Column="0" BorderBrush="White" BorderThickness="1" >
<TextBlock Text="状态" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="状态" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
@ -241,32 +226,33 @@
</Button> </Button>
</Border> </Border>
<Border Grid.Column="3" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.UpdateUnusualFlagCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent"> <!--<Border Grid.Column="4" BorderBrush="White" BorderThickness="1">
<TextBlock Text="异常" Foreground="{Binding unusualFlag,Converter={StaticResource StatusLabelConverter}}" FontSize="18" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Button>
</Border>
<Border Grid.Column="4" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.UpdateSpaceStatusCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent"> <Button Command="{Binding DataContext.UpdateSpaceStatusCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent">
<TextBlock Text="禁用" Foreground="{Binding spaceStatus,Converter={StaticResource StatusLabelConverter}}" FontSize="18" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="异常" Foreground="{Binding spaceStatus,Converter={StaticResource StatusLabelConverter}}" FontSize="18" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Button> </Button>
</Border> </Border>-->
<Border Grid.Column="5" BorderBrush="White" BorderThickness="1"> <Border Grid.Column="3" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.SpaceDetailCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent"> <Button Command="{Binding DataContext.SpaceDetailCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent">
<TextBlock Text="明细" FontSize="18" Foreground="Green" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="明细" FontSize="18" Foreground="Green" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Button> </Button>
</Border> </Border>
<Border Grid.Column="6" BorderBrush="White" BorderThickness="1"> <Border Grid.Column="4" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.OutOnlyOneCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent"> <Button Command="{Binding DataContext.OutOnlyOneCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent">
<TextBlock Text="出一个" Foreground="Green" FontSize="17" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" /> <TextBlock Text="出一个" Foreground="Green" FontSize="17" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
</Border> </Border>
<Border Grid.Column="7" BorderBrush="White" BorderThickness="1"> <Border Grid.Column="5" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.OutAllCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent"> <Button Command="{Binding DataContext.OutAllCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent">
<TextBlock Text="整道出" Foreground="Green" FontSize="17" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" /> <TextBlock Text="整道出" Foreground="Green" FontSize="17" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
</Border> </Border>
<Border Grid.Column="6" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.UpdateUnusualFlagCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding spaceCode}" Style="{StaticResource BUTTON_AGREE}" BorderBrush="Transparent" BorderThickness="0" Background="Transparent">
<TextBlock Text="异常货道" Foreground="{Binding unusualFlag,Converter={StaticResource StatusLabelConverter}}" FontSize="18" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Button>
</Border>
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>
@ -306,10 +292,11 @@
Foreground="#FFFFFF" > Foreground="#FFFFFF" >
<!--resourceStyle 399行修改选中字体颜色--> <!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding spaceCode}" Header="货道编号" Width="0.5*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <!--<DataGridTextColumn Binding="{Binding spaceCode}" Header="货道编号" Width="0.5*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding materialCode}" Header="物料编号" Width="1.2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding materialCode}" Header="物料编号" Width="1.5*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding materialName}" Header="物料名称" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding materialName}" Header="物料名称" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding materialType}" Header="物料类型" Width="1*" IsReadOnly="True"/>-->
<DataGridTextColumn Binding="{Binding createTime,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="入库时间" Width="1*" IsReadOnly="True"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>

@ -226,6 +226,7 @@
<Button Content="查询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/> <Button Content="查询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/>
<Button Content="重置" Command="{Binding ResetCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/> <Button Content="重置" Command="{Binding ResetCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#007DFA" BorderBrush="#007DFA" Foreground="White" Margin="20,0,0,0" Height="36" Width="80" FontSize="20"/>
<Button Content="全部删除" Command="{Binding DeleteAllCommand}" Style="{StaticResource BUTTON_AGREE}" Background="#FF9900" BorderBrush="#FF9900" Margin="20 0 0 0" Foreground="White" Height="36" Width="120" FontSize="20"/>
</StackPanel> </StackPanel>
</Border> </Border>
<DataGrid Grid.Row="2" Name="DG" ItemsSource="{Binding OutstoreTask}" Background="Transparent" <DataGrid Grid.Row="2" Name="DG" ItemsSource="{Binding OutstoreTask}" Background="Transparent"
@ -237,12 +238,12 @@
<!--resourceStyle 399行修改选中字体颜色--> <!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding taskCode}" Header="任务编号" Width="100" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding taskCode}" Header="任务编号" Width="100" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding materialCode}" Header="物料编码" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <!--<DataGridTextColumn Binding="{Binding materialCode}" Header="物料编码" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding materialType}" Header="物料类型" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding materialType}" Header="物料类型" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding spaceName}" Header="出库货道" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding spaceName}" Header="出库货道" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding taskStatus,Converter={StaticResource TaskStatusConverter}}" Header="出库状态" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding taskStatus,Converter={StaticResource TaskStatusConverter}}" Header="出库状态" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding createTime,StringFormat=\{0:yyyy-MM-dd HH:mm\}}" Header="创建时间" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding createTime,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="创建时间" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding beginTime,StringFormat=\{0:MM-dd HH:mm:ss\}}" Header="开始时间" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <!--<DataGridTextColumn Binding="{Binding beginTime,StringFormat=\{0:MM-dd HH:mm:ss\}}" Header="开始时间" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTemplateColumn Header="操作" Width="*"> <DataGridTemplateColumn Header="操作" Width="*">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>

File diff suppressed because it is too large Load Diff

@ -5,6 +5,8 @@ scadaConnStr=Data Source=10.100.72.20/ORCLCDB;User ID=c##aucma_scada;Password=au
#工位编号 #工位编号
stationCode=1006 stationCode=1006
#过点数据出库工位编号
outstationCode=1011
#工位名称 #工位名称
stationName=泡后库 stationName=泡后库
@ -23,6 +25,8 @@ instoreTaskType=1
#出库任务类型编号 #出库任务类型编号
outstoreTaskType=2 outstoreTaskType=2
#泡后扫码器IP #泡后入库扫码器IP
foamHikRobotIp=10.10.92.133 foamHikRobotIp=10.10.92.133
searchItems=SC232%SC233%SC234%310%%%% #泡后出库扫码器IP
foamOutHikRobotIp=10.10.92.134
searchItems=208%SC233%SC234%310%%%%%%%

@ -1,7 +1,6 @@
[plcSystem] [plcSystem]
ÅݺóPLCIP=10.10.92.49 ÅݺóPLCIP=10.10.92.49
ÅݺóPLC¶Ë¿Ú=2015 ÅݺóPLC¶Ë¿Ú=2015
[foam_inStore_address] [foam_inStore_address]
Èë¿â»õµÀºÅ=D7000 Èë¿â»õµÀºÅ=D7000
Èë¿âÓ¦´ð×Ö=D7010 Èë¿âÓ¦´ð×Ö=D7010

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "1296D2EF215B5C9FF53838D5B9FC5A2B6B1D38722C6D080F11FEFF784D1288AA" #pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "91B4FD94DB163FC1FDBF1F505CC5338B066AE77F590CB452328C8E665236A8C3"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
@ -144,6 +144,22 @@ namespace Aucma.Scada.UI {
#line default #line default
#line hidden #line hidden
#line 121 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Media.ImageBrush Scanner2Status;
#line default
#line hidden
#line 124 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock Scanner2;
#line default
#line hidden
private bool _contentLoaded; private bool _contentLoaded;
/// <summary> /// <summary>
@ -213,6 +229,12 @@ namespace Aucma.Scada.UI {
case 13: case 13:
this.Scanner1 = ((System.Windows.Controls.TextBlock)(target)); this.Scanner1 = ((System.Windows.Controls.TextBlock)(target));
return; return;
case 14:
this.Scanner2Status = ((System.Windows.Media.ImageBrush)(target));
return;
case 15:
this.Scanner2 = ((System.Windows.Controls.TextBlock)(target));
return;
} }
this._contentLoaded = true; this._contentLoaded = true;
} }

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "1296D2EF215B5C9FF53838D5B9FC5A2B6B1D38722C6D080F11FEFF784D1288AA" #pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "91B4FD94DB163FC1FDBF1F505CC5338B066AE77F590CB452328C8E665236A8C3"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
@ -144,6 +144,22 @@ namespace Aucma.Scada.UI {
#line default #line default
#line hidden #line hidden
#line 121 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Media.ImageBrush Scanner2Status;
#line default
#line hidden
#line 124 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock Scanner2;
#line default
#line hidden
private bool _contentLoaded; private bool _contentLoaded;
/// <summary> /// <summary>
@ -213,6 +229,12 @@ namespace Aucma.Scada.UI {
case 13: case 13:
this.Scanner1 = ((System.Windows.Controls.TextBlock)(target)); this.Scanner1 = ((System.Windows.Controls.TextBlock)(target));
return; return;
case 14:
this.Scanner2Status = ((System.Windows.Media.ImageBrush)(target));
return;
case 15:
this.Scanner2 = ((System.Windows.Controls.TextBlock)(target));
return;
} }
this._contentLoaded = true; this._contentLoaded = true;
} }

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\AssemblyPlan\AssemblyPlanControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B4DB7DC5AC844B473794BE5AD1EA1C85167140643555D4BEB710FCAB6D553509" #pragma checksum "..\..\..\..\Page\AssemblyPlan\AssemblyPlanControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "A15F1E36889794F4A747D3852DFE63D381EE96E6D6754CB133C1FAA47961EEFF"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\AssemblyPlan\AssemblyPlanControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B4DB7DC5AC844B473794BE5AD1EA1C85167140643555D4BEB710FCAB6D553509" #pragma checksum "..\..\..\..\Page\AssemblyPlan\AssemblyPlanControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "A15F1E36889794F4A747D3852DFE63D381EE96E6D6754CB133C1FAA47961EEFF"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "27725EFE70A99F62EE757B45F2A95B25B711DC8F9DE032F083EE71DCD4D1E6DA" #pragma checksum "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "416B2196F600FFAA27F093BCE2AD98352E095479A2F612BD81E3D94D8697A743"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
@ -43,7 +43,15 @@ namespace Aucma.Scada.UI.Page.InStoreInfo {
public partial class InStoreInfoControl : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector { public partial class InStoreInfoControl : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
#line 205 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" #line 204 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox SpaceCodeText;
#line default
#line hidden
#line 210 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid DG; internal System.Windows.Controls.DataGrid DG;
@ -51,7 +59,7 @@ namespace Aucma.Scada.UI.Page.InStoreInfo {
#line hidden #line hidden
#line 242 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" #line 257 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ListBox listBox; internal System.Windows.Controls.ListBox listBox;
@ -89,9 +97,20 @@ namespace Aucma.Scada.UI.Page.InStoreInfo {
switch (connectionId) switch (connectionId)
{ {
case 1: case 1:
this.DG = ((System.Windows.Controls.DataGrid)(target)); this.SpaceCodeText = ((System.Windows.Controls.TextBox)(target));
return; return;
case 2: case 2:
#line 205 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
#line default
#line hidden
return;
case 3:
this.DG = ((System.Windows.Controls.DataGrid)(target));
return;
case 4:
this.listBox = ((System.Windows.Controls.ListBox)(target)); this.listBox = ((System.Windows.Controls.ListBox)(target));
return; return;
} }

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "27725EFE70A99F62EE757B45F2A95B25B711DC8F9DE032F083EE71DCD4D1E6DA" #pragma checksum "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "416B2196F600FFAA27F093BCE2AD98352E095479A2F612BD81E3D94D8697A743"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
@ -43,7 +43,15 @@ namespace Aucma.Scada.UI.Page.InStoreInfo {
public partial class InStoreInfoControl : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector { public partial class InStoreInfoControl : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
#line 205 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" #line 204 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox SpaceCodeText;
#line default
#line hidden
#line 210 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid DG; internal System.Windows.Controls.DataGrid DG;
@ -51,7 +59,7 @@ namespace Aucma.Scada.UI.Page.InStoreInfo {
#line hidden #line hidden
#line 242 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml" #line 257 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ListBox listBox; internal System.Windows.Controls.ListBox listBox;
@ -89,9 +97,20 @@ namespace Aucma.Scada.UI.Page.InStoreInfo {
switch (connectionId) switch (connectionId)
{ {
case 1: case 1:
this.DG = ((System.Windows.Controls.DataGrid)(target)); this.SpaceCodeText = ((System.Windows.Controls.TextBox)(target));
return; return;
case 2: case 2:
#line 205 "..\..\..\..\Page\InStoreInfo\InStoreInfoControl.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
#line default
#line hidden
return;
case 3:
this.DG = ((System.Windows.Controls.DataGrid)(target));
return;
case 4:
this.listBox = ((System.Windows.Controls.ListBox)(target)); this.listBox = ((System.Windows.Controls.ListBox)(target));
return; return;
} }

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\InventoryInfo\BomFoamRearInventory.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "4118EDE7E02AB173F3E20E151078599BC65473CB5136EAEC887E470925918EE8" #pragma checksum "..\..\..\..\Page\InventoryInfo\BomFoamRearInventory.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "06E986B5DF67B38EB8833E582BEA3126482F553B2211106F1D88FC931F916321"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\InventoryInfo\BomFoamRearInventory.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "4118EDE7E02AB173F3E20E151078599BC65473CB5136EAEC887E470925918EE8" #pragma checksum "..\..\..\..\Page\InventoryInfo\BomFoamRearInventory.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "06E986B5DF67B38EB8833E582BEA3126482F553B2211106F1D88FC931F916321"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B40B749E130D1C75C21A96FD39EB3BCB1CEC2D6D6A130A6615B7AE24768E377A" #pragma checksum "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "E7BEA44FBAD7E55038BA853DE5C111A538C831C963C96BA8F11DBDC6C484EB4F"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
@ -50,7 +50,7 @@ namespace Aucma.Scada.UI.Page.OutStoreInfo {
#line hidden #line hidden
#line 231 "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml" #line 232 "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid DG; internal System.Windows.Controls.DataGrid DG;

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B40B749E130D1C75C21A96FD39EB3BCB1CEC2D6D6A130A6615B7AE24768E377A" #pragma checksum "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "E7BEA44FBAD7E55038BA853DE5C111A538C831C963C96BA8F11DBDC6C484EB4F"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
@ -50,7 +50,7 @@ namespace Aucma.Scada.UI.Page.OutStoreInfo {
#line hidden #line hidden
#line 231 "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml" #line 232 "..\..\..\..\Page\OutStoreInfo\OutStoreInfoControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid DG; internal System.Windows.Controls.DataGrid DG;

@ -39,7 +39,7 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
assemblyPlanBusiness.RefreshExecutePlanInfoEvent += RefreshDataGrid; assemblyPlanBusiness.RefreshExecutePlanInfoEvent += RefreshDataGrid;
outStoreBusiness.RefreshAssemblyPlanInitEvent += RefreshPlanInfoDataGrid; outStoreBusiness.RefreshAssemblyPlanInitEvent += RefreshPlanInfoDataGrid;
assemblyPlanBusiness.PrintMessageEvent += PrintMessage;
Init(); Init();
} }
@ -217,8 +217,13 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
public RelayCommand MaterialStatisticsCommand { get; set; } public RelayCommand MaterialStatisticsCommand { get; set; }
#endregion #endregion
public void PrintMessage(string info)
{
MessageBox.Show(info);
}
/// <summary> /// <summary>
/// 箱壳入库任务列表查询 /// 箱壳任务列表查询
/// </summary> /// </summary>
public void RefreshDataGrid(List<ExecutePlanInfo> executePlanInfos) public void RefreshDataGrid(List<ExecutePlanInfo> executePlanInfos)
{ {
@ -228,12 +233,37 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
executePlanInfos.ForEach( executePlanInfos.ForEach(
arg => arg =>
{ {
arg.materialName = GetSubstringBetweenCommas(arg.materialName);
PlanInfoDataGrid.Add(arg); PlanInfoDataGrid.Add(arg);
}); });
} }
RefreshStatisticsGauge(executePlanInfos); RefreshStatisticsGauge(executePlanInfos);
} }
static string GetSubstringBetweenCommas(string input)
{
// 找到第一个逗号的位置
int firstCommaIndex = input.IndexOf(',');
if (firstCommaIndex != -1)
{
// 找到第二个逗号的位置
int secondCommaIndex = input.IndexOf(',', firstCommaIndex + 1);
if (secondCommaIndex != -1)
{
// 使用Substring截取第一个逗号和第二个逗号之间的字符
return input.Substring(firstCommaIndex + 1, secondCommaIndex - firstCommaIndex - 1);
}
else
{
return "";
}
}
else
{
return "";
}
}
/// <summary> /// <summary>
/// 计划上移 /// 计划上移
/// </summary> /// </summary>

@ -11,6 +11,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Media; using System.Windows.Media;
namespace Aucma.Scada.UI.viewModel.InStoreInfo namespace Aucma.Scada.UI.viewModel.InStoreInfo
@ -21,12 +22,23 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>(); private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
private ObservableCollection<RealTaskInfo> taskItems = new ObservableCollection<RealTaskInfo>(); private ObservableCollection<RealTaskInfo> taskItems = new ObservableCollection<RealTaskInfo>();
/// <summary>
/// 删除计划
/// </summary>
public RelayCommand<object> CompletePlanCommand { get; set; }
private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance; private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance;
private OutStoreBusiness outStoreBusiness = OutStoreBusiness.Instance; private OutStoreBusiness outStoreBusiness = OutStoreBusiness.Instance;
private AppConfig appConfig = AppConfig.Instance; private AppConfig appConfig = AppConfig.Instance;
public InStoreInfoViewModel() public InStoreInfoViewModel()
{ {
CompletePlanCommand = new RelayCommand<object>(obj => CompletePlan(obj));
inStoreBusiness.RefreshInStoreTaskEvent += RefreshInStoreTask; inStoreBusiness.RefreshInStoreTaskEvent += RefreshInStoreTask;
inStoreBusiness.RefreshScanMateriaCodeEvent += RefreshScanInfo; inStoreBusiness.RefreshScanMateriaCodeEvent += RefreshScanInfo;
inStoreBusiness.RefreshLogMessageEvent += PrintMessageToListBox; inStoreBusiness.RefreshLogMessageEvent += PrintMessageToListBox;
@ -42,6 +54,18 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
} }
/// <summary>
/// 完成计划
/// </summary>
/// <param name="obj"></param>
public void CompletePlan(object obj)
{
string info = obj as string;
inStoreBusiness.InStoreFinish(info);
}
#region 参数定义 #region 参数定义
/// <summary> /// <summary>
/// 物料条码 /// 物料条码
@ -189,7 +213,10 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
try try
{ {
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss.ss")}==>{message}"); listItems.Add($"{DateTime.Now.ToString("HH:mm:ss.ss")}==>{message}");
while (listItems.Count > 120)
{
listItems.RemoveAt(0);
}
LogInfoListBox = listItems.OrderByDescending(x => x); LogInfoListBox = listItems.OrderByDescending(x => x);
} }
catch (Exception ex) catch (Exception ex)

@ -4,6 +4,7 @@ using Aucma.Scada.UI.Page.InventoryInfo;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using HighWayIot.Config; using HighWayIot.Config;
using HighWayIot.Log4net;
using HighWayIot.Plc; using HighWayIot.Plc;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -167,11 +168,14 @@ namespace Aucma.Scada.UI.viewModel.InventoryInfo
private void Query() private void Query()
{ {
try
App.Current.Dispatcher.Invoke((Action)(() =>
{ {
var info = inventoryInfoBusiness.GetSpaceInfos(appConfig.foamStoreCode).OrderBy(x=>x.objId); var info = inventoryInfoBusiness.GetSpaceInfos(appConfig.foamStoreCode);
if (info != null) if (info != null)
{
info = info.OrderBy(x => x.objId).ToList();
App.Current.Dispatcher.Invoke((Action)(() =>
{ {
if (spaceItems.Count > 0) if (spaceItems.Count > 0)
{ {
@ -181,11 +185,18 @@ namespace Aucma.Scada.UI.viewModel.InventoryInfo
foreach (var item in info) foreach (var item in info)
{ {
spaceItems.Add(item); spaceItems.Add(item);
}
Shapes = new ObservableCollection<BaseSpaceInfo>(spaceItems); // 创建新的 ObservableCollection
}));
} }
Shapes = spaceItems;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
} }
}));
} }
@ -294,11 +305,36 @@ namespace Aucma.Scada.UI.viewModel.InventoryInfo
spaceDetails.ForEach( spaceDetails.ForEach(
arg => arg =>
{ {
arg.materialName = GetSubstringBetweenCommas(arg.materialName);
SpaceDetailDataGrid.Add(arg); SpaceDetailDataGrid.Add(arg);
}); });
} }
} }
static string GetSubstringBetweenCommas(string input)
{
// 找到第一个逗号的位置
int firstCommaIndex = input.IndexOf(',');
if (firstCommaIndex != -1)
{
// 找到第二个逗号的位置
int secondCommaIndex = input.IndexOf(',', firstCommaIndex + 1);
if (secondCommaIndex != -1)
{
// 使用Substring截取第一个逗号和第二个逗号之间的字符
return input.Substring(firstCommaIndex + 1, secondCommaIndex - firstCommaIndex - 1);
}
else
{
return "";
}
}
else
{
return "";
}
}
/// <summary> /// <summary>
/// 手动出一个 /// 手动出一个

@ -13,6 +13,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
@ -33,7 +35,7 @@ namespace Aucma.Scada.UI.viewModel
public MainViewModel() public MainViewModel()
{ {
MvCodeHelper.RefreshStateEvent += RefreshScannerState;
// 创建一个DispatcherTimer对象 // 创建一个DispatcherTimer对象
DispatcherTimer timer = new DispatcherTimer(); DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1); timer.Interval = TimeSpan.FromSeconds(1);
@ -48,10 +50,39 @@ namespace Aucma.Scada.UI.viewModel
FormControlCommand = new RelayCommand<object>(obj => FormControl(obj)); FormControlCommand = new RelayCommand<object>(obj => FormControl(obj));
UserContent = inStoreInfoControl; UserContent = inStoreInfoControl;
MvCodeHelper.RefreshStateEvent += Scanner1State; InitHikRobot();
init(); init();
} }
/// <summary>
/// 开启海康扫码器
/// </summary>
public void InitHikRobot()
{
try
{
Task.Run(() =>
{
Thread.Sleep(2000);
MvCodeHelper.Shell();
});
Task.Run(() =>
{
Thread.Sleep(4000);
MvCodeHelper.Liner();
});
}
catch (Exception ex)
{
Console.WriteLine("InitHikRobotAndGun()开启海康扫码器和扫码枪方法异常" + ex.Message.ToString());
}
}
#region 参数定义 #region 参数定义
/// <summary> /// <summary>
/// PLC设备状态 /// PLC设备状态
@ -419,6 +450,17 @@ namespace Aucma.Scada.UI.viewModel
} }
public void RefreshScannerState(string ip, bool flag)
{
if(ip == "入库")
{
Scanner1State(flag);
}
else
{
Scanner2State(flag);
}
}
/// <summary> /// <summary>
/// 扫码器1连接状态-true:连接成功false:失败 /// 扫码器1连接状态-true:连接成功false:失败
/// </summary> /// </summary>
@ -429,13 +471,13 @@ namespace Aucma.Scada.UI.viewModel
{ {
if (type) if (type)
{ {
Scanner1UIStatusWb = "泡后库扫码器"; Scanner1UIStatusWb = "库扫码器";
Scanner1UIColor = "Green"; Scanner1UIColor = "Green";
Scanner1UIIcon = "templates/image/Green.png"; Scanner1UIIcon = "templates/image/Green.png";
} }
else else
{ {
Scanner1UIStatusWb = "泡后库扫码器"; Scanner1UIStatusWb = "库扫码器";
Scanner1UIColor = "Red"; Scanner1UIColor = "Red";
Scanner1UIIcon = "templates/image/Red.png"; Scanner1UIIcon = "templates/image/Red.png";
} }
@ -443,6 +485,63 @@ namespace Aucma.Scada.UI.viewModel
} }
#endregion #endregion
#region 扫码器2状态
/// <summary>
/// UI 展示状态-文字
/// </summary>
public string _scanner2UIStatusWb;
public string Scanner2UIStatusWb
{
get => _scanner2UIStatusWb;
set { _scanner2UIStatusWb = value; RaisePropertyChanged(nameof(Scanner2UIStatusWb)); }
}
/// <summary>
/// UI 展示状态-颜色
/// </summary>
public string _scanner2UIColor;
public string Scanner2UIColor
{
get => _scanner2UIColor;
set { _scanner2UIColor = value; RaisePropertyChanged(nameof(Scanner2UIColor)); }
}
/// <summary>
/// UI 展示状态-图标
/// </summary>
public string _scanner2UIIcon;
public string Scanner2UIIcon
{
get => _scanner2UIIcon;
set { _scanner2UIIcon = value; RaisePropertyChanged(nameof(Scanner2UIIcon)); }
}
/// <summary>
/// 扫码器1连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void Scanner2State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
Scanner2UIStatusWb = "出库扫码器";
Scanner2UIColor = "Green";
Scanner2UIIcon = "templates/image/Green.png";
}
else
{
Scanner2UIStatusWb = "出库扫码器";
Scanner2UIColor = "Red";
Scanner2UIIcon = "templates/image/Red.png";
}
});
}
#endregion
public string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); public string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
public string CurrentDateTime public string CurrentDateTime

@ -6,6 +6,7 @@ using HighWayIot.Config;
using HighWayIot.Log4net; using HighWayIot.Log4net;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
@ -23,12 +24,13 @@ namespace Aucma.Scada.UI.viewModel.OutStoreInfo
public OutStoreInfoViewModel() public OutStoreInfoViewModel()
{ {
outStoreBusiness.RefreshOutStoreTaskEvent += RefreshOutStoreTask; outStoreBusiness.RefreshOutStoreTaskEvent += RefreashOutStoreTask;
outStoreBusiness.RefreshScanMateriaCodeEvent += RefreshScanInfo; outStoreBusiness.RefreshScanMateriaCodeEvent += RefreshScanInfo;
outStoreBusiness.RefreshLogMessageEvent += PrintMessageToListBox; outStoreBusiness.RefreshLogMessageEvent += PrintMessageToListBox;
QueryCommand = new RelayCommand(Query); QueryCommand = new RelayCommand(Query);
ResetCommand = new RelayCommand(Reset); ResetCommand = new RelayCommand(Reset);
DeleteAllCommand = new RelayCommand(DeleteAll);
DeleteTaskInfoCommand = new RelayCommand<object>(obj => DeleteTaskInfo(obj)); DeleteTaskInfoCommand = new RelayCommand<object>(obj => DeleteTaskInfo(obj));
this.Query(); this.Query();
@ -168,6 +170,11 @@ namespace Aucma.Scada.UI.viewModel.OutStoreInfo
/// </summary> /// </summary>
public RelayCommand ResetCommand { get; set; } public RelayCommand ResetCommand { get; set; }
/// <summary>
/// 删除所有出库任务
/// </summary>
public RelayCommand DeleteAllCommand { get; set; }
/// <summary> /// <summary>
/// 删除 /// 删除
/// </summary> /// </summary>
@ -186,6 +193,11 @@ namespace Aucma.Scada.UI.viewModel.OutStoreInfo
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss.ss")}==>{message}"); listItems.Add($"{DateTime.Now.ToString("HH:mm:ss.ss")}==>{message}");
LogInfoListBox = listItems.OrderByDescending(x => x); LogInfoListBox = listItems.OrderByDescending(x => x);
while (listItems.Count > 120)
{
listItems.RemoveAt(0);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -197,23 +209,40 @@ namespace Aucma.Scada.UI.viewModel.OutStoreInfo
/// 刷新出库任务列表 /// 刷新出库任务列表
/// </summary> /// </summary>
/// <param name="taskInfo"></param> /// <param name="taskInfo"></param>
private void RefreshOutStoreTask(RealTaskInfo taskInfo) private void RefreashOutStoreTask()
{ {
// Query();
try try
{
List<RealTaskInfo> list = outStoreBusiness.GetOutStoreTask();
if (list != null && list.Count > 0)
{ {
App.Current.Dispatcher.Invoke((Action)(() => App.Current.Dispatcher.Invoke((Action)(() =>
{ {
taskInfo.materialType = outStoreBusiness.GetMaterialName(taskInfo.materialType); if(taskItems.Count > 0)
taskItems.Add(taskInfo); {
OutstoreTask = taskItems; taskItems.Clear();
}
foreach (RealTaskInfo item in list)
{
taskItems.Add(item);
}
OutstoreTask = new ObservableCollection<RealTaskInfo>(taskItems);
})); }));
} }
}
catch (Exception ex) catch (Exception ex)
{ {
logHelper.Error("入库任务列表刷新异常", ex); logHelper.Error("入库任务列表刷新异常", ex);
} }
} }
/// <summary> /// <summary>
/// 刷新扫码信息 /// 刷新扫码信息
/// </summary> /// </summary>
@ -285,6 +314,28 @@ namespace Aucma.Scada.UI.viewModel.OutStoreInfo
this.Query(); this.Query();
} }
/// <summary>
/// 删除所有任务
/// </summary>
/// <param name="obj"></param>
private void DeleteAll()
{
MessageBoxResult result = MessageBox.Show("是否删除所有出库任务?", "删除确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
if (outStoreBusiness.DeleteAllTaskByStoreCode(appConfig.foamStoreCode, 2))
{
MessageBox.Show("任务删除成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
// RefreashOutStoreTask();
Query();
}
}
}
/// <summary> /// <summary>
/// 删除任务 /// 删除任务
/// </summary> /// </summary>
@ -299,6 +350,7 @@ namespace Aucma.Scada.UI.viewModel.OutStoreInfo
{ {
MessageBox.Show("任务删除成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); MessageBox.Show("任务删除成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
Query(); Query();
return;
} }
} }
if (outStoreBusiness.DeleteTaskInfoByTaskCode(taskCode, false)) if (outStoreBusiness.DeleteTaskInfoByTaskCode(taskCode, false))

@ -45,6 +45,16 @@ namespace HighWayIot.Config
set { iniHelper.IniWriteValue("system", "stationCode", value); } set { iniHelper.IniWriteValue("system", "stationCode", value); }
} }
/// <summary>
/// 过点数据出库工位编号
/// </summary>
public string outstationCode
{
get { return iniHelper.IniReadValue("system", "outstationCode"); }
set { iniHelper.IniWriteValue("system", "outstationCode", value); }
}
/// <summary> /// <summary>
/// 工位名称 /// 工位名称
/// </summary> /// </summary>
@ -107,7 +117,7 @@ namespace HighWayIot.Config
} }
/// <summary> /// <summary>
/// 泡后库扫码器IP /// 泡后库入库扫码器IP
/// </summary> /// </summary>
public string foamHikRobotIp public string foamHikRobotIp
{ {
@ -115,6 +125,15 @@ namespace HighWayIot.Config
set { iniHelper.IniWriteValue("system", "foamHikRobotIp", value); } set { iniHelper.IniWriteValue("system", "foamHikRobotIp", value); }
} }
/// <summary>
/// 泡后库出库扫码器IP
/// </summary>
public string foamOutHikRobotIp
{
get { return iniHelper.IniReadValue("system", "foamOutHikRobotIp"); }
set { iniHelper.IniWriteValue("system", "foamOutHikRobotIp", value); }
}
public string searchItems public string searchItems
{ {
get { return iniHelper.IniReadValue("system", "searchItems"); } get { return iniHelper.IniReadValue("system", "searchItems"); }

@ -8,6 +8,13 @@ namespace HighWayIot.Repository.service
/// </summary> /// </summary>
public interface IBaseSpaceInfoService public interface IBaseSpaceInfoService
{ {
/// <summary>
/// 获取空货道:未分配物料型号的空白货道
/// </summary>
/// <returns></returns>
List<BaseSpaceInfo> GetEmptySpaceInfo(string store);
/// <summary> /// <summary>
/// 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道 /// 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道
/// </summary> /// </summary>

@ -5,6 +5,42 @@ namespace HighWayIot.Repository.service
{ {
public interface IRealTaskInfoService public interface IRealTaskInfoService
{ {
/// <summary>
/// 泡后库入库根据货道号查找所有执行中的任务
/// </summary>
/// <param name="taskInfo"></param>
/// <summary>
List<RealTaskInfo> GetAllInstoreTaskByStoreCode(string storeCode, string spaceCode, int taskType, int status);
/// <summary>
/// 泡后库出库删除所有任务信息
/// </summary>
/// <param name="taskInfo"></param>
/// <summary>
bool DeleteAllTaskByStoreCode(string storeCode, int taskType);
/// <summary>
/// 泡后库出库删除任务信息,根据时间删除第一条
/// </summary>
/// <param name="taskInfo"></param>
/// <summary>
bool DeleteFirstTaskByStoreCode(string storeCode, int taskType);
/// <summary>
/// 根据条码获取该型号出库任务按照时间排序第一条信息
/// </summary>
/// <param name="taskCode"></param>
/// <returns></returns>
RealTaskInfo GetTaskInfoByTaskCode(string materialType, string storeCode, int taskType);
/// <summary>
/// 泡后库出库根据条码型号删除任务信息
/// </summary>
/// <param name="taskInfo"></param>
bool DeleteTaskInfoByCode(RealTaskInfo taskInfo);
/// <summary> /// <summary>
/// 添加任务信息 /// 添加任务信息
/// </summary> /// </summary>

@ -26,8 +26,11 @@ namespace HighWayIot.Repository.service.Impl
try try
{ {
BaseSpaceDetail spaceDetail = this.GetSpaceDetailByMaterialCode(materialCode); BaseSpaceDetail spaceDetail = this.GetSpaceDetailByMaterialCode(materialCode);
if (spaceDetail != null)
{
result = _mesRepository.Delete(spaceDetail); result = _mesRepository.Delete(spaceDetail);
}
} }
catch (Exception ex) catch (Exception ex)

@ -23,7 +23,7 @@ namespace HighWayIot.Repository.service.Impl
/// <summary> /// <summary>
/// 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道 /// 未使用,入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道
/// </summary> /// </summary>
/// <param name="store"></param> /// <param name="store"></param>
/// <param name="materialType"></param> /// <param name="materialType"></param>
@ -87,14 +87,18 @@ namespace HighWayIot.Repository.service.Impl
/// 获取空货道:未分配物料型号的空白货道 /// 获取空货道:未分配物料型号的空白货道
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private List<BaseSpaceInfo> GetEmptySpaceInfo(string store) public List<BaseSpaceInfo> GetEmptySpaceInfo(string store)
{ {
List<BaseSpaceInfo> spaceInfos = null; List<BaseSpaceInfo> spaceInfos = null;
try try
{ {
Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true; Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.materialType == null && x.storeCode == store && x.spaceCapacity != x.spaceStock); exp = exp.And(x => x.materialType == null && x.storeCode == store && x.spaceCapacity != x.spaceStock && x.unusualFlag==1);
spaceInfos = _mesRepository.GetList(exp); spaceInfos = _mesRepository.GetList(exp);
if(spaceInfos.Count > 0)
{
spaceInfos.OrderBy(x => x.objId);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -223,20 +227,20 @@ namespace HighWayIot.Repository.service.Impl
Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true; Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true;
if(taskType==1) if(taskType==1)
{ {
exp = exp.And(x => x.storeCode == storeCode && x.materialType == materialType && x.spaceStatus == 1 && x.inStoreFlag == 1); //相同型号、启用状态的货道信息 exp = exp.And(x => x.storeCode == storeCode && x.materialType == materialType && x.spaceStatus == 1 && x.inStoreFlag == 1 && x.unusualFlag==1); //相同型号、启用状态的货道信息
}else if (taskType == 2) }else if (taskType == 2)
{ {
exp = exp.And(x => x.storeCode == storeCode && x.materialType == materialType && x.spaceStatus == 1); //相同型号、启用状态的货道信息 exp = exp.And(x => x.storeCode == storeCode && x.materialType == materialType && x.spaceStatus == 1 && x.outStoreFlag==1 && x.spaceStock>0 && x.unusualFlag == 1); //相同型号、启用状态的货道信息
} }
spaceInfos = _mesRepository.GetList(exp); spaceInfos = _mesRepository.GetList(exp);
spaceInfos = FilterSpaceList(spaceInfos,taskType); // spaceInfos = FilterSpaceList(spaceInfos,taskType);
if (spaceInfos==null || spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配 if (taskType==1 && ( spaceInfos==null || spaceInfos.Count == 0)) //入库任务没有指定该类型物料的货道信息,需获取空白货道信息进行分配
{ {
spaceInfos = GetEmptySpaceInfo(storeCode); spaceInfos = GetEmptySpaceInfo(storeCode);
} }

@ -67,7 +67,7 @@ namespace HighWayIot.Repository.service.Impl
try try
{ {
Expression<Func<ProductPlanInfo, bool>> exp = s1 => true; Expression<Func<ProductPlanInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.productLineCode == productLineCode); exp = exp.And(x => x.productLineCode == productLineCode && x.endTime==null);
planInfos = _mesRepository.GetList(exp); planInfos = _mesRepository.GetList(exp);
@ -109,7 +109,12 @@ namespace HighWayIot.Repository.service.Impl
bool result = false; bool result = false;
try try
{ {
result = _mesRepository.Update(productPlanInfo); Expression<Func<ProductPlanInfo, ProductPlanInfo>> columns = x => new ProductPlanInfo { completeAmount = productPlanInfo.completeAmount,beginTime = productPlanInfo.beginTime,endTime = productPlanInfo.endTime };
result= _mesRepository.Update(columns, x => x.objId == productPlanInfo.objId);
// string sql = $@"UPDATE PRODUCT_PLANINFO SET COMPLETE_AMOUNT= '{productPlanInfo.completeAmount}',BEGIN_TIME= '{productPlanInfo.beginTime}',END_TIME= '{productPlanInfo.endTime}' WHERE OBJ_ID={productPlanInfo.objId} ";
// _mesRepository._db().Ado.SqlQuery(sql);
// result = _mesRepository.Update(productPlanInfo);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -130,7 +135,7 @@ namespace HighWayIot.Repository.service.Impl
try try
{ {
Expression<Func<ProductPlanInfo, bool>> exp = s1 => true; Expression<Func<ProductPlanInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.materialCode == materialCode && x.productLineCode=="1006"); exp = exp.And(x => x.materialCode == materialCode && x.productLineCode=="1006" && x.endTime==null);
planInfo = _mesRepository.GetFirst(exp); planInfo = _mesRepository.GetFirst(exp);

@ -1,10 +1,12 @@
using Aucma.Scada.Model.domain; using Aucma.Scada.Model.domain;
using HighWayIot.Common; using HighWayIot.Common;
using HighWayIot.Log4net; using HighWayIot.Log4net;
using MySqlX.XDevAPI.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading.Tasks;
namespace HighWayIot.Repository.service.Impl namespace HighWayIot.Repository.service.Impl
{ {
@ -55,6 +57,109 @@ namespace HighWayIot.Repository.service.Impl
return result; return result;
} }
/// <summary>
/// 泡后库入库根据货道号查找所有执行中的任务
/// </summary>
/// <param name="taskInfo"></param>
/// <summary>
public List<RealTaskInfo> GetAllInstoreTaskByStoreCode(string storeCode, string spaceCode,int taskType,int status)
{
List<RealTaskInfo> taskList = null;
try
{
taskList = _mesRepository.GetList(x => x.storeCode == storeCode && x.spaceCode==spaceCode && x.taskType == taskType && x.taskStatus==status);
}
catch (Exception ex)
{
logHelper.Error("通过仓库编号获取待执行的任务信息异常", ex);
}
return taskList;
}
/// <summary>
/// 泡后库出库删除所有任务信息
/// </summary>
/// <param name="taskInfo"></param>
/// <summary>
public bool DeleteAllTaskByStoreCode(string storeCode, int taskType)
{
List<RealTaskInfo> taskList = null;
bool result = false;
try
{
taskList = _mesRepository.GetList(x => x.storeCode == storeCode && x.taskType == taskType);
if (taskList != null)
{
result = _mesRepository.Delete(taskList);
}
}
catch (Exception ex)
{
logHelper.Error("通过仓库编号获取待执行的任务信息异常", ex);
}
return result;
}
/// <summary>
/// 泡后库出库删除任务信息,根据时间删除第一条
/// </summary>
/// <param name="taskInfo"></param>
/// <summary>
public bool DeleteFirstTaskByStoreCode(string storeCode, int taskType)
{
RealTaskInfo taskInfo = null;
bool result = false;
try
{
List<RealTaskInfo> taskList = _mesRepository.GetList(x => x.storeCode == storeCode && x.taskType == taskType && x.taskStatus == 2);
if (taskList != null && taskList.Count>0)
{
taskInfo = taskList.OrderBy(x => x.createTime).FirstOrDefault();
result = _mesRepository.Delete(taskInfo);
}
}
catch (Exception ex)
{
logHelper.Error("通过仓库编号获取待执行的任务信息异常", ex);
}
return result;
}
/// <summary>
/// 泡后库出库删除任务信息
/// </summary>
/// <param name="taskInfo"></param>
public bool DeleteTaskInfoByCode(RealTaskInfo taskInfo)
{
bool result = false;
try
{
if (taskInfo != null)
{
result = _mesRepository.Delete(taskInfo);
}
}
catch (Exception ex)
{
logHelper.Error("删除任务信息异常", ex);
}
return result;
}
/// <summary> /// <summary>
/// 更新任务信息 /// 更新任务信息
/// </summary> /// </summary>
@ -159,6 +264,29 @@ namespace HighWayIot.Repository.service.Impl
return taskInfo; return taskInfo;
} }
/// <summary>
/// 根据条码获取该型号出库任务按照时间排序第一条信息
/// </summary>
/// <param name="taskCode"></param>
/// <returns></returns>
public RealTaskInfo GetTaskInfoByTaskCode(string materialType, string storeCode, int taskType)
{
RealTaskInfo taskInfo = null;
try
{
List<RealTaskInfo> list = _mesRepository.GetList(x => x.storeCode == storeCode && x.taskType==taskType && x.materialType == materialType);
if(list.Count > 0)
{
taskInfo = list.OrderBy(x => x.createTime).FirstOrDefault();
}
}
catch (Exception ex)
{
logHelper.Error("根据任务号获取任务信息异常", ex);
}
return taskInfo;
}
/// <summary> /// <summary>
/// 根据任务号获取任务信息 /// 根据任务号获取任务信息
@ -284,5 +412,36 @@ namespace HighWayIot.Repository.service.Impl
{ {
return _mesRepository.DeleteById(id); return _mesRepository.DeleteById(id);
} }
/// <summary>
/// 根据货道号找到对应的入库任务
/// </summary>
/// <param name="spaceCode"></param>
/// <returns></returns>
public List<RealTaskInfo> GetTaskInfosBySpaceCode(string storeCode,string spaceCode, int taskType, int taskStatus)
{
List<RealTaskInfo> realTaskInfos = null;
List<RealTaskInfo> filteredList = null;
try
{
Expression<Func<RealTaskInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.taskType == taskType && storeCode.Contains(x.storeCode));
exp = exp.And(x => x.taskStatus == taskStatus);
exp = exp.And(x => x.spaceCode == spaceCode);
realTaskInfos = _mesRepository.GetList(exp);
if (realTaskInfos == null || realTaskInfos.Count == 0) return null;
filteredList = realTaskInfos.GroupBy(rti => rti.spaceCode) // 按照 spaceCode 进行分组
.Select(group => group.OrderBy(rti => rti.createTime).First())
.ToList();
}
catch (Exception ex)
{
logHelper.Error("获取指定状态的任务信息异常", ex);
}
return filteredList;
}
} }
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save