change-入库完成时入库库存改为系统+1,不从plc读

change-统计库存从视图查询改为直接查询
collectionStore
liuwf 7 months ago
parent 272745dfb9
commit ffcbace19f

@ -423,7 +423,8 @@ namespace Aucma.Scada.Business
//读取PLC获取货道信息存放数量、在途数量, //读取PLC获取货道信息存放数量、在途数量,
#region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息 #region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
var item = taskHandle.ReadSpaceInfoByPlc(spaceInfo); var item = taskHandle.ReadSpaceInfoByPlc(spaceInfo);
spaceInfo.spaceStock = item.spaceStock; // spaceInfo.spaceStock = item.spaceStock;
spaceInfo.spaceStock = spaceInfo.spaceStock + 1;
spaceInfo.onRouteAmount = item.onRouteAmount; spaceInfo.onRouteAmount = item.onRouteAmount;
// spaceInfo.spaceStatus = item.spaceStatus; // spaceInfo.spaceStatus = item.spaceStatus;
#endregion #endregion
@ -508,10 +509,21 @@ namespace Aucma.Scada.Business
return materialName; return materialName;
} }
/// <summary> /// <summary>
/// 获取仓库物料库存 /// 获取仓库物料库存
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<BaseSpaceInfo> GetStock()
{
List<BaseSpaceInfo> infos = _spaceInfoService.GetSpaceInfosByTwoStoreCode(appConfig.shellStoreCode, appConfig.linerStoreCode);
return infos;
}
/// <summary>
/// 获取仓库物料库存20240223弃用
/// </summary>
/// <returns></returns>
public List<dynamic> GetMaterialStock() public List<dynamic> GetMaterialStock()
{ {
return _spaceInfoService.GetMaterialStock(appConfig.shellStoreCode, appConfig.linerStoreCode); return _spaceInfoService.GetMaterialStock(appConfig.shellStoreCode, appConfig.linerStoreCode);

@ -262,7 +262,7 @@ namespace Aucma.Scada.Business
//读取PLC应答字为2时上位机清空写入的入库内容 //读取PLC应答字为2时上位机清空写入的入库内容
if (_plc.readInt32ByAddress(plcConfig.in_shell_answer) == 2) if (_plc.readInt32ByAddress(plcConfig.in_shell_answer) == 2)
{ {
logHelper.PlcLog("内胆入库应答字为2货道号:" + plcConfig.in_shell_spaceCode + ";复位写0"); logHelper.PlcLog("箱壳入库应答字为2货道号:" + plcConfig.in_shell_spaceCode + ";复位写0");
//写入货道号 //写入货道号
_plc.writeInt32ByAddress(plcConfig.in_shell_spaceCode, 0); _plc.writeInt32ByAddress(plcConfig.in_shell_spaceCode, 0);
//写入应答字 //写入应答字

@ -219,8 +219,7 @@ namespace Aucma.Scada.Business
{ {
if (_plc != null) if (_plc != null)
{ {
if (_plc.IsConnected)
{
do do
{ {
//读取PLC出库任务完成 //读取PLC出库任务完成
@ -239,11 +238,8 @@ namespace Aucma.Scada.Business
Thread.Sleep(1000); Thread.Sleep(1000);
} while (isFlag); } while (isFlag);
}
else
{
logHelper.Info($"仓库{appConfig.shellStoreCode}PLC未连接");
}
} }
else else
{ {
@ -489,7 +485,7 @@ namespace Aucma.Scada.Business
var shellTasks = GetTaskInfoByTaskStatus(appConfig.shellStoreCode,3); var shellTasks = GetTaskInfoByTaskStatus(appConfig.shellStoreCode,3);
var linerTasks = GetTaskInfoByTaskStatus(appConfig.linerStoreCode, 3); var linerTasks = GetTaskInfoByTaskStatus(appConfig.linerStoreCode, 3);
if (shellTasks == null || linerTasks == null) continue;
RealTaskInfo shellTask = null; RealTaskInfo shellTask = null;
RealTaskInfo linerTask = null; RealTaskInfo linerTask = null;

@ -16,6 +16,7 @@ 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 lastCode;
#region 委托事件 #region 委托事件
public delegate void RefreshMaterialCodeStr(string materialCodeStr, string ip); public delegate void RefreshMaterialCodeStr(string materialCodeStr, string ip);
public static event RefreshMaterialCodeStr RefreshMaterialCodeStrEvent; public static event RefreshMaterialCodeStr RefreshMaterialCodeStrEvent;
@ -186,10 +187,11 @@ namespace Aucma.Core.Scanner
} }
string strCode = Encoding.GetEncoding("UTF-8").GetString(buffer).Trim().TrimEnd('\0'); string strCode = Encoding.GetEncoding("UTF-8").GetString(buffer).Trim().TrimEnd('\0');
RefreshLogMessageEvent?.Invoke("相机ip:" + hashmap.Value + " Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode + "]"); RefreshLogMessageEvent?.Invoke("相机ip:" + hashmap.Value + " Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode + "]");
if (!string.IsNullOrEmpty(strCode)) if (!string.IsNullOrEmpty(strCode) && lastCode!=strCode)
{ {
RefreshMaterialCodeStrEvent?.Invoke(strCode,hashmap.Value); RefreshMaterialCodeStrEvent?.Invoke(strCode,hashmap.Value);
lastCode = strCode;
} }
} }

@ -191,7 +191,7 @@
<lvc:CartesianChart.AxisX> <lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding MaterialNameList}" FontSize="20"> <lvc:Axis Labels="{Binding MaterialNameList}" FontSize="20">
<lvc:Axis.Separator> <lvc:Axis.Separator>
<lvc:Separator Visibility="Hidden" StrokeThickness="1.5" StrokeDashArray="0" Stroke="#404F56" > <lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="0" Stroke="#404F56" >
</lvc:Separator> </lvc:Separator>
</lvc:Axis.Separator> </lvc:Axis.Separator>
</lvc:Axis> </lvc:Axis>

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
[plcSystem] [plcSystem]
دل؟اPLCIP=127.0.0.1 دل؟اPLCIP=10.10.92.22
دل؟اPLC<EFBFBD>ث؟غ=6000 دل؟اPLC<EFBFBD>ث؟غ=2015
トレオィPLCIP=127.0.0.1 トレオィPLCIP=127.0.0.1
トレオィPLCカヒソレ=6001 トレオィPLCカヒソレ=6001

@ -6,6 +6,7 @@ using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using HighWayIot.Common; using HighWayIot.Common;
using HighWayIot.Config; using HighWayIot.Config;
using HighWayIot.Log4net;
using LiveCharts; using LiveCharts;
using LiveCharts.Wpf; using LiveCharts.Wpf;
using MySqlX.XDevAPI.Relational; using MySqlX.XDevAPI.Relational;
@ -424,29 +425,36 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
/// </summary> /// </summary>
private void RefreshMaterialStats() private void RefreshMaterialStats()
{ {
App.Current.Dispatcher.Invoke((Action)(() => try
{ {
App.Current.Dispatcher.Invoke((Action)(() =>
//获取物料型号统计 {
List<dynamic> materialStats = assemblyPlanBusiness.GetMaterialStats();
if (materialStats != null) //获取物料型号统计
{ List<dynamic> materialStats = assemblyPlanBusiness.GetMaterialStats();
ModelStatistics.Clear(); if (materialStats != null)
MaterialNameList = new List<string>(); {
ChartValues<double> materialAchievement = new ChartValues<double>(); ModelStatistics.Clear();
foreach (var item in materialStats) MaterialNameList = new List<string>();
{ ChartValues<double> materialAchievement = new ChartValues<double>();
MaterialNameList.Add(item.MATERIAL_NAME); foreach (var item in materialStats)
materialAchievement.Add(Convert.ToDouble(item.PRODUCT_AMOUNT)); {
} MaterialNameList.Add(item.MATERIAL_NAME);
var materialColumn = new ColumnSeries(); materialAchievement.Add(Convert.ToDouble(item.PRODUCT_AMOUNT));
materialColumn.DataLabels = true; }
materialColumn.Title = "型号"; var materialColumn = new ColumnSeries();
materialColumn.Values = materialAchievement; materialColumn.DataLabels = true;
materialColumn.Foreground = Brushes.White; materialColumn.Title = "型号";
ModelStatistics.Add(materialColumn); materialColumn.Values = materialAchievement;
} materialColumn.Foreground = Brushes.White;
})); ModelStatistics.Add(materialColumn);
}
}));
}
catch (Exception ex)
{
LogHelper.Instance.Error(ex.Message.ToString());
}
} }
/// <summary> /// <summary>

@ -14,6 +14,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.Runtime.InteropServices.WindowsRuntime;
using System.Windows.Media; using System.Windows.Media;
namespace Aucma.Scada.UI.viewModel.InStoreInfo namespace Aucma.Scada.UI.viewModel.InStoreInfo
@ -289,49 +290,80 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
this.Query(); this.Query();
} }
/// <summary> /// <summary>
/// 柱状体加载 /// 柱状体加载
/// </summary> /// </summary>
public void Init() public void Init()
{ {
Query(); try
ChartValues<double> shellAchievement = new ChartValues<double>();
ChartValues<double> linerAchievement = new ChartValues<double>();
MaterialNameList = new List<string>();
List<dynamic> info = inStoreBusiness.GetMaterialStock();
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
if (info != null) Query();
ChartValues<int> shellAchievement = new ChartValues<int>();
ChartValues<int> linerAchievement = new ChartValues<int>();
MaterialNameList = new List<string>();
// List<dynamic> info = inStoreBusiness.GetMaterialStock();
List<BaseSpaceInfo> list = inStoreBusiness.GetStock();
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
Achievement.Clear(); if (list != null && list.Count > 0)
foreach (var item in info)
{ {
MaterialNameList.Add(item.parentMaterialName); Achievement.Clear();
shellAchievement.Add(Convert.ToDouble(item.shellStock)); foreach (var item in list)
linerAchievement.Add(Convert.ToDouble(item.linerStock)); {
MaterialNameList.Add(SubStringByName(item.typeNameA));
if (item.storeCode == appConfig.shellStoreCode)
{
shellAchievement.Add(item.spaceStock);
linerAchievement.Add(0);
}
else if (item.storeCode == appConfig.linerStoreCode)
{
linerAchievement.Add(item.spaceStock);
shellAchievement.Add(0);
}
}
} }
}
var shellColumn = new ColumnSeries(); var shellColumn = new ColumnSeries();
shellColumn.DataLabels = true; shellColumn.DataLabels = true;
shellColumn.Title = "箱壳"; shellColumn.Title = "箱壳";
shellColumn.Values = shellAchievement; shellColumn.Values = shellAchievement;
shellColumn.Foreground = Brushes.White; shellColumn.Foreground = Brushes.White;
var linerColumn = new ColumnSeries(); var linerColumn = new ColumnSeries();
linerColumn.DataLabels = true; linerColumn.DataLabels = true;
linerColumn.Title = "内胆"; linerColumn.Title = "内胆";
linerColumn.Values = linerAchievement; linerColumn.Values = linerAchievement;
linerColumn.Foreground = Brushes.White; linerColumn.Foreground = Brushes.White;
linerColumn.Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)); linerColumn.Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226));
Achievement.Add(shellColumn); Achievement.Add(shellColumn);
Achievement.Add(linerColumn); Achievement.Add(linerColumn);
})); }));
}catch(Exception ex)
{
logHelper.Error(ex.Message.ToString());
}
} }
/// <summary>
/// 截取逗号之间的名称
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private string SubStringByName(string name)
{
string result = string.Empty;
int firstCommaIndex = name.IndexOf(',');
int secondCommaIndex = name.IndexOf(',', firstCommaIndex + 1);
if (firstCommaIndex != -1 && secondCommaIndex != -1)
{
result = name.Substring(firstCommaIndex + 1, secondCommaIndex - firstCommaIndex - 1);
}
return result;
}
/// <summary> /// <summary>
/// 刷新入库任务列表 /// 刷新入库任务列表
/// </summary> /// </summary>

@ -40,6 +40,14 @@ namespace HighWayIot.Repository.service
/// <returns></returns> /// <returns></returns>
List<BaseSpaceInfo> GetSpaceInfosByStoreCode(string storeCode); List<BaseSpaceInfo> GetSpaceInfosByStoreCode(string storeCode);
/// <summary>
/// 获取箱壳内胆的库存数量
/// </summary>
/// <param name="storeCode"></param>
/// <returns></returns>
List<BaseSpaceInfo> GetSpaceInfosByTwoStoreCode(string storeCode1,string storeCode2);
/// <summary> /// <summary>
/// 通过物料类型获取货道信息,如果没有返回空白货道 /// 通过物料类型获取货道信息,如果没有返回空白货道
/// </summary> /// </summary>

@ -208,6 +208,26 @@ namespace HighWayIot.Repository.service.Impl
return spaceInfos; return spaceInfos;
} }
/// <summary>
/// 通过两个仓库编号获取库存大于0货道信息
/// </summary>
/// <param name="storeCode1"></param>
/// <param name="storeCode2"></param>
/// <returns></returns>
public List<BaseSpaceInfo> GetSpaceInfosByTwoStoreCode(string storeCode1, string storeCode2)
{
List<BaseSpaceInfo> spaceInfos = null;
try
{
spaceInfos = _mesRepository.GetList(x => (x.storeCode == storeCode1 || x.storeCode == storeCode2) && x.spaceStock>0).ToList();
}
catch (Exception ex)
{
logHelper.Error("获取货道信息异常", ex);
}
return spaceInfos;
}
/// <summary> /// <summary>
/// 更新货道信息 /// 更新货道信息
/// </summary> /// </summary>
@ -242,7 +262,8 @@ namespace HighWayIot.Repository.service.Impl
try try
{ {
var _db = _mesRepository.Context; var _db = _mesRepository.Context;
List<dynamic> query = _db.Queryable<dynamic>().AS("GET_STORE_MATERIALSTOCK").Where("STORE_CODE in (@shellStore,@linerStore)", new { shellStore = shellStoreCode, linerStore = linerStoreCode }).ToList();
List<dynamic> query = _db.Queryable<dynamic>().AS("GET_STORE_MATERIALSTOCK").Where("STORE_CODE in (@shellStore,@linerStore) and SPACE_STOCK>0", new { shellStore = shellStoreCode, linerStore = linerStoreCode }).ToList();
if(query.Count > 0) if(query.Count > 0)
{ {

Loading…
Cancel
Save