change-去除本地sqlite数据库的使用

dev
liuwf 4 months ago
parent b6c9a4166a
commit 31ede07349

@ -262,7 +262,7 @@ namespace SlnMesnac.Business
if (plc == null)
{
_logger.LogInformation("读取小包出口信号,PLC连接信息为空......");
_logger.LogInformation("2F读取小包出口信号,PLC连接信息为空......");
Thread.Sleep(3000);
continue;
}
@ -271,7 +271,7 @@ namespace SlnMesnac.Business
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2¥С°ü³ö¿Úµ½Î»ÐźÅ")))
{
_logger.LogInformation("等待小包出口信号触发......");
// _logger.LogInformation("等待小包出口信号触发......");
Thread.Sleep(5000);
continue;
}
@ -280,7 +280,7 @@ namespace SlnMesnac.Business
if (!string.IsNullOrWhiteSpace(rfid))
{
_logger.LogInformation("小包出口已经有RFID了无需再读");
//_logger.LogInformation("小包出口已经有RFID了无需再读");
Thread.Sleep(5000);
continue;
}
@ -331,7 +331,7 @@ namespace SlnMesnac.Business
continue;
}
RefreshMessage($"小包出口读取到RFID条码{epcStr},开始绑定流程:");
RefreshMessage($"2F小包出口读取到RFID条码{epcStr},开始绑定流程:");
_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
if (productPlanDto == null)

@ -85,7 +85,7 @@ namespace SlnMesnac.Business
_configInfoBusiness = configInfoBusiness;
TestTran();
// TestTran();
}
@ -204,34 +204,48 @@ namespace SlnMesnac.Business
continue;
}
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("设备叫料")))
{
// RefreshMessage("3F等待设备叫料信号触发......");
Thread.Sleep(5000);
continue;
}
MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
if (prodPlan == null || productPlanDto == null)
{
//throw new ArgumentException($"未获取到需要执行的生产计划");
RefreshMessage($"未获取到需要执行的生产计划");
RefreshMessage($"3F未获取到需要执行的生产计划");
Thread.Sleep(5000);
continue;
}
BaseRealTask task = _baseRealTaskService.GetExeTask();
if (task != null)
WcsTaskManual wcsTaskManual = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WcsTaskManual>().Where(x=>x.TaskType==999).First();
WcsTask wcsTask = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WcsTask>().Where(x=>x.NextPointId==9 && x.TaskType==41).First();
if(wcsTaskManual!=null || wcsTask != null)
{
RefreshMessage("已经叫料请等待AGV送料......");
RefreshMessage("3F已经叫料请等待AGV送料......");
Thread.Sleep(5000);
continue;
}
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("设备叫料")))
{
RefreshMessage("等待设备叫料信号触发......");
Thread.Sleep(5000);
continue;
}
//BaseRealTask task = _baseRealTaskService.GetExeTask();
//if (task != null)
//{
// RefreshMessage("已经叫料请等待AGV送料......");
// Thread.Sleep(5000);
// continue;
//}
RefreshMessage("设备要料信号触发成功");
RefreshMessage("3F设备要料信号触发成功");
RefreshProdPlanExecEvent?.Invoke(prodPlan);
@ -253,17 +267,17 @@ namespace SlnMesnac.Business
if (ApplyDeliveryHandle(wmsRaw.rawOutstockId.ToString()))
{
RefreshMessage("根据计划自动申请叫料成功");
RefreshMessage("3F根据计划自动申请叫料成功");
#region 本地创建一个叫料任务
BaseRealTask realTask = new BaseRealTask();
realTask.PlanCode = prodPlan.PlanCode;
realTask.PlanAmount = prodPlan.PlanAmount;
realTask.PlanComplete = prodPlan.CompleteAmount;
realTask.MaterialId = prodPlan.MaterialId;
realTask.Status = 1;
realTask.CreateTime = DateTime.Now;
realTask.UpdateTime = DateTime.Now;
_baseRealTaskService.InsertTask(realTask);
//BaseRealTask realTask = new BaseRealTask();
//realTask.PlanCode = prodPlan.PlanCode;
//realTask.PlanAmount = prodPlan.PlanAmount;
//realTask.PlanComplete = prodPlan.CompleteAmount;
//realTask.MaterialId = prodPlan.MaterialId;
//realTask.Status = 1;
//realTask.CreateTime = DateTime.Now;
//realTask.UpdateTime = DateTime.Now;
//_baseRealTaskService.InsertTask(realTask);
#endregion
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备叫料"), false);
}
@ -297,34 +311,44 @@ namespace SlnMesnac.Business
//mes计划
MesProductPlan prodPlan = null;
//本地叫料任务
BaseRealTask localPlan = null;
// BaseRealTask localPlan = null;
try
{
localPlan = _baseRealTaskService.GetExeTask();
// localPlan = _baseRealTaskService.GetExeTask();
if (localPlan == null)
{
RefreshMessage("本地未获取到叫料任务......");
Thread.Sleep(3000);
continue;
}
//if (localPlan == null)
//{
// RefreshMessage("本地未获取到叫料任务......");
// Thread.Sleep(3000);
// continue;
//}
if (plc == null)
{
RefreshMessage("读取物料到位信号,PLC连接信息为空......");
// RefreshMessage("读取物料到位信号,PLC连接信息为空......");
Thread.Sleep(3000);
continue;
}
//判断请求翻转信号
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("物料到位")))
{
RefreshMessage("等待物料到位信号触发......");
// RefreshMessage("等待物料到位信号触发......");
Thread.Sleep(3000);
continue;
}
WcsTask wcsTask = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WcsTask>().Where(x => x.NextPointId == 9 && (x.TaskType == 41 || x.TaskType == 42)).First();
if (wcsTask == null)
{
RefreshMessage("3F到位信号触发,但是未检测到有原材料出库任务......");
Thread.Sleep(5000);
continue;
}
// TODO 投料时间校验
bool timeCheck = JudgeProductTime();
if (!timeCheck)
@ -332,13 +356,13 @@ namespace SlnMesnac.Business
Thread.Sleep(1000 * 15);
continue;
}
RefreshMessage($"投料时间校验通过");
RefreshMessage($"3F投料时间校验通过");
// 调用调度接口判断AGV小车是否已经离开到位否则不允许投料
bool positionCheck = JudgeAgvPosition();
if (!positionCheck)
{
RefreshMessage($"收到物料到位信号,但是AGV还未离开,禁止投料");
RefreshMessage($"3F收到物料到位信号,但是AGV还未离开,禁止投料");
Thread.Sleep(1000 * 5);
continue;
}
@ -348,7 +372,7 @@ namespace SlnMesnac.Business
if (productPlanDto == null || prodPlan == null)
{
RefreshMessage($"收到物料到位信号,未获取到正在执行的生产计划,请开始执行计划");
RefreshMessage($"3F收到物料到位信号,未获取到正在执行的生产计划,请开始执行计划");
Thread.Sleep(5000);
continue;
@ -396,21 +420,17 @@ namespace SlnMesnac.Business
sqlSugarClient.AsTenant().BeginTran();
//1.完成本地计划
if (localPlan != null)
{
List<BaseRealTask> localList = _baseRealTaskService.Query(x => x.Status != 2);
foreach (var item in localList)
{
item.Status = 2;
item.UpdateTime = DateTime.Now;
}
sqlSugarClient.AsTenant().GetConnection("local").Updateable(localList).ExecuteCommand();
//localPlan.Status = 2;
//localPlan.UpdateTime = DateTime.Now;
//sqlSugarClient.AsTenant().GetConnection("local").Updateable(localPlan).ExecuteCommand();
//if (localPlan != null)
//{
// List<BaseRealTask> localList = _baseRealTaskService.Query(x => x.Status != 2);
// foreach (var item in localList)
// {
// item.Status = 2;
// item.UpdateTime = DateTime.Now;
// }
// sqlSugarClient.AsTenant().GetConnection("local").Updateable(localList).ExecuteCommand();
}
//}
//2.生成小包条码
GenerateBarcode(40);
@ -604,7 +624,7 @@ namespace SlnMesnac.Business
}
else
{
RefreshMessage($"收到物料到位请求投料信号,但是距离上次投料不满20min,禁止投料");
RefreshMessage($"收到物料到位请求投料信号,投料间隔:{IntervalMin}min,距上次投料:{systemRunTime}min,禁止投料");
return false;
}
}

@ -110,6 +110,15 @@ namespace SlnMesnac.Config
set { iniHelper.IniWriteValue("system", "SpiralTwoTime", value); }
}
/// <summary>
///3F投料生产模式默认手动1-手动模式2-自动模式
/// </summary>
public string ProductMode
{
get { return iniHelper.IniReadValue("system", "ProductMode"); }
set { iniHelper.IniWriteValue("system", "ProductMode", value); }
}
/// <summary>
///无计划时按照无计划订单处理MaterialId可修改

@ -0,0 +1,203 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.domain
{
[SugarTable("wcs_task_manual"), TenantAttribute("mes")]
public class WcsTaskManual
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(ColumnName = "objid", IsPrimaryKey = true)]
public long ObjId { get; set; }
/// <summary>
/// wcs_warehouse_order 主键id
/// </summary>
[SugarColumn(ColumnName = "master_id")]
public long? MasterId { get; set; }
/// <summary>
/// wms出入库记录表id
/// </summary>
[SugarColumn(ColumnName = "order_id")]
public long? OrderId { get; set; }
/// <summary>
/// 流水号
/// </summary>
[SugarColumn(ColumnName = "serial_no")]
public long? SerialNo { get; set; }
/// <summary>
/// 设备编号
/// </summary>
[SugarColumn(ColumnName = "equipment_no")]
public string EquipmentNo { get; set; }
/// <summary>
/// 容器号(托盘或者箱号)
/// </summary>
[SugarColumn(ColumnName = "container_no")]
public string ContainerNo { get; set; }
/// <summary>
/// 任务类型,字典表
/// </summary>
[SugarColumn(ColumnName = "task_type")]
public int? TaskType { get; set; }
/// <summary>
/// 任务状态,字典表
/// </summary>
[SugarColumn(ColumnName = "task_status")]
public int? TaskStatus { get; set; }
/// <summary>
/// 物料ID
/// </summary>
[SugarColumn(ColumnName = "material_id")]
public long? MaterialId { get; set; }
/// <summary>
/// 物料号
/// </summary>
[SugarColumn(ColumnName = "material_no")]
public string MaterialNo { get; set; }
/// <summary>
/// 数量
/// </summary>
[SugarColumn(ColumnName = "qty")]
public int? Qty { get; set; }
/// <summary>
/// 起始点编号
/// </summary>
[SugarColumn(ColumnName = "start_point_no")]
public string StartPointNo { get; set; }
/// <summary>
/// 起始点id
/// </summary>
[SugarColumn(ColumnName = "start_point_id")]
public long? StartPointId { get; set; }
/// <summary>
/// 当前点编号
/// </summary>
[SugarColumn(ColumnName = "curr_point_no")]
public string CurrPointNo { get; set; }
/// <summary>
/// 当前点id
/// </summary>
[SugarColumn(ColumnName = "curr_point_id")]
public long? CurrPointId { get; set; }
/// <summary>
/// 下一点位id
/// </summary>
[SugarColumn(ColumnName = "next_point_id")]
public long? NextPointId { get; set; }
/// <summary>
/// 下一点位编号
/// </summary>
[SugarColumn(ColumnName = "next_point_no")]
public string NextPointNo { get; set; }
/// <summary>
/// 结束点编号
/// </summary>
[SugarColumn(ColumnName = "end_point_no")]
public string EndPointNo { get; set; }
/// <summary>
/// 结束点id
/// </summary>
[SugarColumn(ColumnName = "end_point_id")]
public long? EndPointId { get; set; }
/// <summary>
/// 所属楼层
/// </summary>
[SugarColumn(ColumnName = "floor_no")]
public int? FloorNo { get; set; }
/// <summary>
/// 是否可用 0:不可用 1:可用
/// </summary>
[SugarColumn(ColumnName = "use_flag")]
public int UseFlag { get; set; }
/// <summary>
/// 创建者
/// </summary>
[SugarColumn(ColumnName = "create_by")]
public string CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "create_time")]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新者
/// </summary>
[SugarColumn(ColumnName = "update_by")]
public string UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnName = "update_time")]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 备用字段1
/// </summary>
[SugarColumn(ColumnName = "ud1")]
public int? Ud1 { get; set; }
/// <summary>
/// 备用字段2
/// </summary>
[SugarColumn(ColumnName = "ud2")]
public string Ud2 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[SugarColumn(ColumnName = "ud3")]
public string Ud3 { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnName = "remark")]
public string Remark { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "from_floor_no")]
public int? FromFloorNo { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "is_empty")]
public string IsEmpty { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "ctu_execute")]
public string CtuExecute { get; set; }
}
}

@ -35,8 +35,9 @@
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock Grid.Column="0" Text="{Binding Date}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Text="{Binding Time}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Text="{Binding Date}" FontSize="20" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Text="{Binding Time}" FontSize="20" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Text="{Binding ModeName}" FontSize="20" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
</StackPanel>
@ -71,7 +72,7 @@
<Button Content="首 页" x:Name="Index" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="10,0,10,0"/>
<Button Content="设备监控" x:Name="DevMonitor" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=DevMonitor}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="生产管理" Visibility="Collapsed" x:Name="ProdMgmt" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ProdMgmt}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="手动叫料" x:Name="ManualDelivery" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ManualDelivery}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="投料管理" x:Name="ManualDelivery" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ManualDelivery}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="AGV监听" x:Name="AgvAndTaskPage" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=AgvAndTaskPage}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
@ -81,7 +82,7 @@
<Button Content="参数配置" x:Name="ConfigInfo" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ConfigInfo}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="配方管理" x:Name="RecipeManage" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=RecipeManage}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" />
<Button Content="键 盘" Visibility="Collapsed" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" />
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
</StackPanel>

@ -727,6 +727,8 @@ namespace SlnMesnac.WPF.Page
var result = MessageBox.Show("是否确认启动?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{
//
StartAll();
}
@ -876,9 +878,10 @@ namespace SlnMesnac.WPF.Page
MessageBoxAndLog("一键停止所有机器成功!");
//清空投料系统运行时间
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault();
configInfo.ConfigValue = "0";
_configInfoBusiness.UpdateConfigInfo(configInfo);
BaseConfigInfo runtime = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault();
BaseConfigInfo timeRangeSet = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "投料时间间隔").FirstOrDefault();
runtime.ConfigValue = timeRangeSet.ConfigValue;
_configInfoBusiness.UpdateConfigInfo(runtime);
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
xmlns:local1="clr-namespace:SlnMesnac.WPF.Converter.ProdMgmt"
mc:Ignorable="d"
Title="手动叫料" Height="750" Width="1000" Background="White" Name="window" WindowStartupLocation="CenterOwner">
Title="投料管理" Height="750" Width="1000" Background="White" Name="window" WindowStartupLocation="CenterOwner">
<Control.Resources>
<local1:PlanStatusConverter x:Key="PlanStatusConverter" />
<local1:PlanAmountConverter x:Key="PlanAmountConverter" />
@ -30,7 +30,7 @@
<WrapPanel Grid.Row="0" Margin="5 5 0 0">
<Label Content="选择库位" FontSize="20" VerticalAlignment="Center" Foreground="White" />
<TextBox x:Name="queryParam" FontSize="20" BorderThickness="3" Text="" Width="100" HorizontalAlignment="Left" VerticalContentAlignment="Center" Style="{StaticResource TextBoxStyle}" Foreground="White"/>
<Button Content="优先投料" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="35" Background="LimeGreen" BorderBrush="#007DFA" Margin="10,0,10,0" Command="{Binding QueryStringCommand}" CommandParameter="{Binding Text, ElementName=queryParam}" />
<Button Content="手动投料" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="35" Background="LimeGreen" BorderBrush="#007DFA" Margin="10,0,10,0" Command="{Binding QueryStringCommand}" CommandParameter="{Binding Text, ElementName=queryParam}" />
</WrapPanel>
<Border Grid.Row="1" BorderBrush="White" BorderThickness="1,1,0,1" CornerRadius="5">

@ -25,7 +25,7 @@ namespace SlnMesnac.WPF.ViewModel
public class MainWindowViewModel : ViewModelBase
{
private readonly ILogger<MainWindowViewModel> _logger;
private readonly DebugConfig debugConfig = DebugConfig.Instance;
private readonly DevMonitorPage devMonitorPage = new DevMonitorPage();
private readonly ProdMgmtPage prodMgmtPage = new ProdMgmtPage();
private readonly ProdStatisticsPage prodStatisticsPage = new ProdStatisticsPage();
@ -61,6 +61,17 @@ namespace SlnMesnac.WPF.ViewModel
}
}
private string _ModeName;
public string ModeName
{
get { return _ModeName; }
set
{
_ModeName = value;
RaisePropertyChanged(nameof(ModeName));
}
}
private string _PageName;
public string PageName
{
@ -142,6 +153,7 @@ namespace SlnMesnac.WPF.ViewModel
UserContent = prodMgmtPage;
PageName = "京源环保SCADA";
debugConfig.ProductMode = "1";
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x));
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
@ -162,6 +174,7 @@ namespace SlnMesnac.WPF.ViewModel
{
Date = DateTime.Now.ToString("yyyy年MM月dd日");
Time = DateTime.Now.ToString("HH:mm:ss");
ModeName = debugConfig.ProductMode == "1" ? "投料模式:手动" : "投料模式:自动";
}
#region 监听外部设备状态:PLC、喷码机、RFID

Loading…
Cancel
Save