首次提交:添加src文件夹代码

This commit is contained in:
2026-02-27 14:02:43 +08:00
commit d330cfbca7
4184 changed files with 5546478 additions and 0 deletions

767082
6098-6_202602271353.sql Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class AlarmContentService : ServiceBase
{
public AlarmContentService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TAlarmContent> GetAll()
{
using (var Context = new BakingEntities())
{
return (from c in Context.Set<TAlarmContent>().Where(x => !string.IsNullOrEmpty(x.Desc))
select c).ToList();
}
}
}
}

View File

@@ -0,0 +1,113 @@
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class AlarmService : ServiceBase
{
public AlarmService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public TAlarm GetInAlarm(Variable node, string desc)
{
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TAlarm>()
where a.Desc == desc
&& a.StationId == node.StationId
&& a.StopTime == null
select a).FirstOrDefault();
}
}
public List<TAlarm> GetInAlarm(int stationId)
{
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TAlarm>()
where a.StationId == stationId
&& a.StopTime == null
select a).ToList();
}
}
public List<TAlarm> GetAllInAlarms()
{
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TAlarm>()
where a.StopTime == null
select a).ToList();
}
}
public int CancelAlarm(TAlarm alarm)
{
alarm.Status = EAlarmStatus.Renew.GetDescription();
alarm.StopTime = DateTime.Now;
using (var Context = new BakingEntities())
{
Context.Set<TAlarm>().Attach(alarm);//将数据附加到上下文支持实体修改和新实体重置为UnChanged
Context.Entry<TAlarm>(alarm).State = EntityState.Modified;
return Context.SaveChanges();
}
}
//一个信号报警
public int Insert(Variable node)
{
TAlarm model = new TAlarm()
{
Desc = node.VarDesc,
StationId = node.StationId,
StartTime = DateTime.Now,
Status = EAlarmStatus.Alert.GetDescription(),
};
using (var Context = new BakingEntities())
{
Context.Set<TAlarm>().Add(model);
return Context.SaveChanges();
}
}
public List<TAlarm> GetAlarmReport(string startTime, string endTime)
{
DateTime startDateTime = DateTime.Parse(startTime + " 00:00:01");
DateTime endDateTime = DateTime.Parse(endTime + " 23:59:59");
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TAlarm>()
where a.StartTime >= startDateTime
&& a.StartTime <= endDateTime
select a).ToList();
}
}
public int Insert(Variable node, string desc)
{
TAlarm model = new TAlarm()
{
Desc = desc,
StationId = node.StationId,
StartTime = DateTime.Now,
Status = EAlarmStatus.Alert.GetDescription()
};
using (var Context = new BakingEntities())
{
Context.Set<TAlarm>().Add(model);
return Context.SaveChanges();
}
}
}
}

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>

View File

@@ -0,0 +1,55 @@
using Cowain.Bake.Common.Interface;
using Prism.Ioc;
using Prism.Modularity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cowain.Bake.BLL
{
public class BLLModule : IModule
{
public void OnInitialized(IContainerProvider containerProvider) //IUnityContainer
{
// 将容器实例注册为单例
MyAppContainer.Current = containerProvider;
//containerProvider.Resolve<MemoryDataProvider>();
//
}
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterSingleton<BLL.AlarmContentService>();
containerRegistry.RegisterSingleton<BLL.AlarmService>();
containerRegistry.RegisterSingleton<BLL.BatteryInfoService>();
containerRegistry.RegisterSingleton<BLL.BatteryNGService>();
containerRegistry.RegisterSingleton<BLL.CavityInfoService>();
containerRegistry.RegisterSingleton<BLL.MesDataService>();
containerRegistry.RegisterSingleton<BLL.CavityInfoService>();
containerRegistry.RegisterSingleton<BLL.DeviceConfigService>();
containerRegistry.RegisterSingleton<BLL.ElectricEnergyService>();
containerRegistry.RegisterSingleton<BLL.LogService>();
//containerRegistry.RegisterSingleton<BLL.MemoryDataProvider>(); //IMemoryDataProvider
containerRegistry.RegisterSingleton<BLL.MenuInfoService>();
containerRegistry.RegisterSingleton<BLL.PalletInfoService>();
containerRegistry.RegisterSingleton<BLL.ProcessParamService>();
containerRegistry.RegisterSingleton<BLL.ProductionInformationService>();
containerRegistry.RegisterSingleton<BLL.RoleInfoService>();
containerRegistry.RegisterSingleton<BLL.StationService>();
containerRegistry.RegisterSingleton<BLL.SysSetupService>();
containerRegistry.RegisterSingleton<BLL.StoveSctualPatrolService>();
containerRegistry.RegisterSingleton<BLL.TagListService>();
containerRegistry.RegisterSingleton<BLL.TaskRecordService>();
containerRegistry.RegisterSingleton<BLL.TaskStepService>();
containerRegistry.RegisterSingleton<BLL.TaskTypeService>();
containerRegistry.RegisterSingleton<BLL.UserService>();
}
}
// 定义一个静态类用于保存全局的IUnityContainer实例
public static class MyAppContainer
{
public static IContainerProvider Current { get; set; }
}
}

View File

@@ -0,0 +1,811 @@
using Cowain.Bake.Common;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class BatteryInfoService : ServiceBase
{
public BatteryInfoService(IUnityContainer unityContainer) : base(unityContainer)
{
}
/// <summary>
/// 托盘中是否还有电芯
/// </summary>
public bool IsIntoStation(int palletVID)
{
using (var Context = new BakingEntities())
{
TBatteryInfo battery = (from b in Context.Set<TBatteryInfo>()
where b.BatteryStatus < (int)EBatteryStatus.Over && b.PalletVirtualId == palletVID
select b).FirstOrDefault();
if (null == battery)
{
return false;
}
else
{
return true;
}
}
}
public int UpdateCoolTempAndUnBindingTime(List<TBatteryInfo> batters, List<TBatteryInfo> tempBattery)
{
using (var Context = new BakingEntities())
{
foreach (var battery in batters)
{
var temp = tempBattery.Where(x => x.BatteryCode == battery.BatteryCode).FirstOrDefault();
if (null == temp)
{
battery.CoolTemp = 30;
LogHelper.Instance.Fatal($"冷却下料通过电芯条码找查失败,电芯条码为:{battery.BatteryCode}");
}
else
{
battery.CoolTemp = temp.CoolTemp;
}
battery.UnbindingTime = DateTime.Now;
Context.Entry(battery).State = System.Data.Entity.EntityState.Modified;
}
return Context.SaveChanges();
}
}
public List<TBatteryInfo> GetBatteryInfos(int palletVID)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => x.PalletVirtualId == palletVID).ToList();
}
}
public int InsertBattery(string batteryCode, int status, int dummyStatus, string remarks)
{
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<int>($"call ProcGetBatteryVirtualId('{batteryCode}',{status},{dummyStatus},'{remarks}')").FirstOrDefault();
}
}
public List<int> InsertBattery(string batteryCodes)
{
string sql = $"Call ProcGetBatterysVirtualId('{batteryCodes}')";
DataTable dt = GetDataTable(sql);
// 通过索引获取列数据
List<int> VIds = new List<int>();
foreach (DataRow row in dt.Rows)
{
VIds.Add((int)row[0]);
}
return VIds;
}
/// <summary>
/// 电芯条码是否重复
/// </summary>
/// <param name="batteryCode"></param>
/// <returns></returns>B
public bool IsBatteryCodeRepeat(string batteryCode)
{
using (var Context = new BakingEntities())
{
TBatteryInfo battery = Context.Set<TBatteryInfo>().Where(x => x.BatteryCode == batteryCode).FirstOrDefault(); //FirstOrDefault EF并不会继续检索整个表
if (null == battery)
{
return false;
}
return true;
}
}
public int InsertBatch(int[] batteryVirtualId, int palletVirtualId)
{
string sql = "";
int index = 0;
if (Global.PALLET_ROWS < Global.PALLET_COLS) //7行少24列多
{
for (int x = 0; x < Global.PALLET_ROWS; ++x)
{
for (int y = 0; y < Global.PALLET_COLS; ++y)
{
index = (x * Global.PALLET_COLS) + y + 1; //数组是0...120数据是1...120,所以下标从1开始
if (0 != batteryVirtualId[index])
{
sql += $"update TBatteryInfo set PalletVirtualId={palletVirtualId}, BatteryStatus={(int)EBatteryStatus.ToPallet},PositionX={x + 1}, PositionY={y + 1},BindingTime=NOW() where Id={batteryVirtualId[index]};";
}
}
}
}
else
{
for (int y = 0; y < Global.PALLET_COLS; ++y) //2 //48行2列,行多列少
{
for (int x = 0; x < Global.PALLET_ROWS; ++x) //48
{
index = (y * Global.PALLET_ROWS) + x + 1; //数组是0...120数据是1...120,所以下标从1开始
if (0 != batteryVirtualId[index])
{
sql += $"update TBatteryInfo set PalletVirtualId={palletVirtualId}, BatteryStatus={(int)EBatteryStatus.ToPallet},PositionX={x + 1}, PositionY={y + 1},BindingTime=NOW() where Id={batteryVirtualId[index]};";
}
}
}
}
if (string.IsNullOrEmpty(sql))
{
return 0;
}
sql = "START TRANSACTION;" + sql + "COMMIT;"; //使用事务批量更新
using (var Context = new BakingEntities())
{
return Context.Database.ExecuteSqlCommand(sql);
}
}
public List<TBatteryInfo> GetCavityBattery(string cavityName)
{
string sql = $@"SELECT *
FROM TCavityInfo td
LEFT JOIN TPalletInfo ti ON td.PalletId=ti.Id
LEFT JOIN TBatteryInfo tbi ON ti.VirtualId=tbi.PalletVirtualId
WHERE td.Name='{cavityName}' AND tbi.BatteryCode is not null ORDER BY PositionX, PositionY ";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<TBatteryInfo>(sql).ToList();
}
}
public bool IsDummy(int batteryId)
{
using (var Context = new BakingEntities())
{
TBatteryInfo battery = Context.Set<TBatteryInfo>().Where(x => x.Id == batteryId && x.DummyFlag == true).FirstOrDefault(); //FirstOrDefault EF并不会继续检索整个表
if (null == battery)
{
return false;
}
return true;
}
}
//public bool IsDummy(string batteryCode)
//{
// using (var Context = new BakingEntities())
// {
// TBatteryInfo battery = Context.Set<TBatteryInfo>().Where(x => x.BatteryCode == batteryCode && x.DummyFlag == true).FirstOrDefault(); //FirstOrDefault EF并不会继续检索整个表
// if (null == battery)
// {
// return false;
// }
// return true;
// }
//}
public TBatteryInfo FindDummy(TPalletInfo palletInfo, List<TBatteryInfo> batterys)
{
TBatteryInfo batteryInfo = null;
TBatteryInfo dummyInfo = batterys.Where(x => x.DummyFlag == true).FirstOrDefault();
//正常情况下是不会出现的
if (null == dummyInfo) //找水含量电芯位置
{
LogHelper.Instance.Error($"夹具【{palletInfo.PalletCode}】下料过种中,没有找到水含量电芯!", true);
return null;
}
if (dummyInfo.BatteryStatus <= (int)EBatteryStatus.ToPallet)
{
return dummyInfo;
}
using (var Context = new BakingEntities())
{
//假电芯取走,取同一行相邻的假电芯
if (Global.PALLET_ROWS < Global.PALLET_COLS) //7行少24列多
{
batteryInfo = (from b in batterys
where b.BatteryStatus <= (int)EBatteryStatus.ToPallet && b.PositionX == dummyInfo.PositionX
orderby Math.Abs(b.PositionY.Value - dummyInfo.PositionY.Value)
select b).FirstOrDefault(); //b.PositionY - dummyInfo.PositionY
}
else
{
batteryInfo = (from b in batterys
where b.BatteryStatus <= (int)EBatteryStatus.ToPallet && b.PositionY == dummyInfo.PositionY
orderby Math.Abs(b.PositionX.Value - dummyInfo.PositionX.Value)
select b).FirstOrDefault(); //b.PositionY - dummyInfo.PositionY
}
if (null != batteryInfo) //同一行相邻的假电芯
{
SetDummy(batteryInfo.Id);
return batteryInfo;//取同一行相邻的假电芯,直接返回
}
if (Global.PALLET_ROWS < Global.PALLET_COLS) //7行少24列多
{
batteryInfo = (from b in batterys
where b.BatteryStatus <= (int)EBatteryStatus.ToPallet
orderby Math.Abs(b.PositionY.Value - dummyInfo.PositionY.Value)
select b).FirstOrDefault(); //b.PositionY - dummyInfo.PositionY
}
else
{
batteryInfo = (from b in batterys
where b.BatteryStatus <= (int)EBatteryStatus.ToPallet
orderby Math.Abs(b.PositionX.Value - dummyInfo.PositionX.Value)
select b).FirstOrDefault(); //b.PositionY - dummyInfo.PositionY
}
if (null != batteryInfo) //另一行相邻的假电芯
{
SetDummy(batteryInfo.Id);
return batteryInfo;//另一行相邻的假电芯,直接返回
}
LogHelper.Instance.Error($"空夹具,没有电芯了");
return null;
}
}
public int SetDummy(int id)
{
using (var Context = new BakingEntities())
{
TBatteryInfo dummy = Context.Set<TBatteryInfo>().Where(x => x.Id == id).FirstOrDefault();
if (null == dummy)
{
return 0;
}
dummy.DummyFlag = true;
Context.Entry(dummy).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
public List<TBatteryInfo> GetBatterys(List<int> Ids)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => Ids.Contains(x.Id)).ToList();
}
}
public int SetDummyToWaterPlatform(int palletId)
{
using (var Context = new BakingEntities())
{
var dummys = (from pallet in Context.Set<TPalletInfo>()
join battery in Context.Set<TBatteryInfo>() on pallet.VirtualId equals battery.PalletVirtualId
where pallet.Id == palletId && battery.DummyFlag == true && battery.BatteryStatus < (int)EBatteryStatus.ToWaterPlatform
select battery).ToList();
if (0 == dummys.Count)
{
LogHelper.Instance.Warn($"下料时,却没有假电芯的信息,托盘号:{palletId}");
return 0;
}
dummys.ForEach(x => x.BatteryStatus = (sbyte)EBatteryStatus.ToWaterPlatform);
int result = Context.SaveChanges();
if (result != dummys.Count)
{
LogHelper.Instance.Debug($"下料修改假电芯状态失败,palletId:{palletId},在测水含量数:{dummys.Count},实际修改数:{result}");
}
return result;
}
}
public int UpdateStatus(int id, int status)
{
using (var Context = new BakingEntities())
{
var battery = Context.Set<TBatteryInfo>().Where(x => x.Id == id).FirstOrDefault();
if (null == battery)
{
LogHelper.Instance.Error("修改电芯状态失败!");
return 0;
}
battery.BatteryStatus = (sbyte)status;
Context.Entry(battery).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
public List<BatteryInfoEntity> GetOutbound()
{
string sql = $@"SELECT
TBatteryInfo.Id,
TBatteryInfo.PalletVirtualId,
TBatteryInfo.BatteryStatus,
TBatteryInfo.BatteryCode,
TBatteryInfo.PositionX,
TBatteryInfo.PositionY ,
TBatteryInfo.ScanTime,
TPalletInfo1.PalletCode,
TPalletInfo1.LoadingBegingTime,
TPalletInfo1.LoadingOverTime,
TPalletInfo1.BakingPosition,
TPalletInfo1.BakingBeginTime,
TPalletInfo1.BakingOverTime,
TPalletInfo1.UnLoadingBegingTime,
TPalletInfo1.UnLoadingOverTime,
TPalletInfo1.WaterValue
FROM TBatteryInfo
LEFT JOIN
(SELECT VirtualId, PalletCode, LoadingBegingTime,LoadingOverTime, BakingPosition, BakingBeginTime, BakingOverTime,UnLoadingBegingTime, UnLoadingOverTime, WaterValue
FROM TPalletInfo
UNION
SELECT VirtualId, PalletCode, LoadingBegingTime,LoadingOverTime, BakingPosition, BakingBeginTime, BakingOverTime, UnLoadingBegingTime,UnLoadingOverTime, WaterValue
FROM TPalletInfoHistory) AS TPalletInfo1
ON
TBatteryInfo.PalletVirtualId = TPalletInfo1.VirtualId
where TBatteryInfo.BatteryStatus = {(int)EBatteryStatus.Over}; ";
try
{
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<BatteryInfoEntity>(sql).Take(100).ToList();
}
}
catch (Exception ex)
{
LogHelper.Instance.Error($"GetOutbound;失败,{ex.Message},{ex.StackTrace}");
}
return null;
}
public bool IsExistBattery(int palletVirtualId, int positionX, int positionY)
{
using (var Context = new BakingEntities())
{
var batteryInfo = Context.Set<TBatteryInfo>().Where(x => x.PalletVirtualId == palletVirtualId
&& x.PositionX == positionX && x.PositionY == positionY).FirstOrDefault();
if (null == batteryInfo)
{
return false;
}
else
{
return true;
}
}
}
public List<TBatteryInfo> GetWaterBatteryCode(int? VirtualId)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => x.PalletVirtualId == VirtualId && x.DummyFlag == true).ToList();
}
}
public int SetBatteryOutBound(int palletVID)
{
using (var Context = new BakingEntities())
{
string sql = $"update TBatteryInfo set BatteryStatus={(int)EBatteryStatus.Over} where PalletVirtualId={palletVID} and BatteryStatus < {(int)EBatteryStatus.Over};"; //表示已经出站了
return Context.Database.ExecuteSqlCommand(sql);
}
}
public List<TBatteryInfo> QueryBattery(DateTime startTime, DateTime endTime, string batteryCodes = "")
{
var strTolist = CommonCoreHelper.Instance.StringToListConverter(batteryCodes);
List<TBatteryInfo> cellList = new List<TBatteryInfo>();
using (var Context = new BakingEntities())
{
if (!strTolist.Any())
{
cellList = Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime).ToList();
}
else
{
cellList = Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime && strTolist.Contains(x.BatteryCode)).ToList();
}
return cellList.OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).ToList();
}
}
//托盘中是否有假电芯
public bool IsPalletDummy(int palletVID)
{
using (var Context = new BakingEntities())
{
TBatteryInfo dummy = (from b in Context.Set<TBatteryInfo>()
where b.DummyFlag == true && b.PalletVirtualId == palletVID
select b).FirstOrDefault();
if (null == dummy)
{
return false;
}
else
{
return true;
}
}
}
public TBatteryInfo GetBatteryInfos(string batteryCode)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => x.BatteryCode == batteryCode).OrderByDescending(x => x.Id).FirstOrDefault();
}
}
public List<BatteryInfoEntity> Query(string batteryCode)
{
string sql = $@"SELECT
TBatteryInfo.Id,
TBatteryInfo.PalletVirtualId,
TBatteryInfo.BatteryStatus,
TBatteryInfo.BatteryCode,
TBatteryInfo.PositionX,
TBatteryInfo.PositionY ,
TBatteryInfo.ScanTime,
TBatteryInfo.CoolTemp,
TPalletInfo1.PalletCode,
TPalletInfo1.LoadingBegingTime,
TPalletInfo1.LoadingOverTime,
TPalletInfo1.BakingPosition,
TPalletInfo1.BakingBeginTime,
TPalletInfo1.BakingOverTime,
TPalletInfo1.UnLoadingBegingTime,
TPalletInfo1.UnLoadingOverTime,
TPalletInfo1.BakingCount,
TPalletInfo1.WaterValue
FROM TBatteryInfo
LEFT JOIN
(SELECT VirtualId, PalletCode, LoadingBegingTime,LoadingOverTime, BakingPosition, BakingBeginTime, BakingOverTime,UnLoadingBegingTime, UnLoadingOverTime,BakingCount, WaterValue
FROM TPalletInfo
UNION
SELECT VirtualId, PalletCode, LoadingBegingTime,LoadingOverTime, BakingPosition, BakingBeginTime, BakingOverTime, UnLoadingBegingTime,UnLoadingOverTime,BakingCount, WaterValue
FROM TPalletInfoHistory) AS TPalletInfo1
ON
TBatteryInfo.PalletVirtualId = TPalletInfo1.VirtualId
where TBatteryInfo.BatteryCode = '{batteryCode}'; ";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<BatteryInfoEntity>(sql).ToList();
}
}
public List<BatteryInfoEntity> Query(DateTime startTime, DateTime endTime)
{
string sql = $@"SELECT
TBatteryInfo.Id,
TBatteryInfo.PalletVirtualId,
TBatteryInfo.BatteryStatus,
TBatteryInfo.BatteryCode,
TBatteryInfo.PositionX,
TBatteryInfo.PositionY ,
TBatteryInfo.ScanTime,
TBatteryInfo.CoolTemp,
TPalletInfo1.PalletCode,
TPalletInfo1.LoadingBegingTime,
TPalletInfo1.LoadingOverTime,
TPalletInfo1.BakingPosition,
TPalletInfo1.BakingBeginTime,
TPalletInfo1.BakingOverTime,
TPalletInfo1.UnLoadingBegingTime,
TPalletInfo1.UnLoadingOverTime,
TPalletInfo1.BakingCount,
TPalletInfo1.WaterValue
FROM TBatteryInfo
LEFT JOIN
(SELECT VirtualId, PalletCode, LoadingBegingTime,LoadingOverTime, BakingPosition, BakingBeginTime, BakingOverTime,UnLoadingBegingTime, UnLoadingOverTime, BakingCount, WaterValue
FROM TPalletInfo
UNION
SELECT VirtualId, PalletCode, LoadingBegingTime,LoadingOverTime, BakingPosition, BakingBeginTime, BakingOverTime, UnLoadingBegingTime,UnLoadingOverTime, BakingCount , WaterValue
FROM TPalletInfoHistory) AS TPalletInfo1
ON
TBatteryInfo.PalletVirtualId = TPalletInfo1.VirtualId
where TBatteryInfo.ScanTime >= '{startTime}' and TBatteryInfo.ScanTime <= '{endTime}'; ";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<BatteryInfoEntity>(sql).ToList();
}
}
public List<BatteryInfoEntity> GetBatteryToPallet(int palletVID)
{
using (var Context = new BakingEntities())
{
return (from b in Context.Set<TBatteryInfo>()
join p in Context.Set<TPalletInfo>() on b.PalletVirtualId equals p.VirtualId
where b.PalletVirtualId == palletVID
select new BatteryInfoEntity()
{
Id = b.Id,
BatteryCode = b.BatteryCode,
PalletCode = p.PalletCode,
PositionX = b.PositionX,
PositionY = b.PositionY,
ScanTime = b.ScanTime,
BindingTime = b.BindingTime
}).ToList();
}
}
public BatteryInfoEntity QueryBatteryWaterValue(string code) //modify by lsm 三张表联查
{
using (var Context = new BakingEntities())
{
var cellPallet = Context.Set<TBatteryInfo>().Join(Context.Set<TPalletInfo>(),
c => c.PalletVirtualId,
p => p.VirtualId,
(c, p) => new { BatteryInfo = c, PalletInfo = p }).Join(Context.Set<TCavityInfo>(),
c => c.PalletInfo.BakingPosition,
p => p.Id,
(c, p) =>
new BatteryInfoEntity
{
Id = c.PalletInfo.Id,
BatteryStatus = c.BatteryInfo.BatteryStatus,
BatteryCode = c.BatteryInfo.BatteryCode,
PositionX = c.BatteryInfo.PositionX,
PositionY = c.BatteryInfo.PositionY,
ScanTime = c.PalletInfo.ScanTime,
PalletCode = c.PalletInfo.PalletCode,
BakingLocation = p.Name,
BakingBeginTime = c.PalletInfo.BakingBeginTime,
BakingOverTime = c.PalletInfo.BakingOverTime,
PalletVirtualId = c.PalletInfo.VirtualId,
WaterValue = c.PalletInfo.WaterValue
}).Where(x => x.BatteryCode == code).OrderBy(x => x.Id).FirstOrDefault();
if (null != cellPallet)
{
return cellPallet;
}
return Context.Set<TBatteryInfo>().Join(Context.Set<TPalletInfoHistory>(),
c => c.PalletVirtualId,
p => p.VirtualId,
(c, p) => new { BatteryInfo = c, PalletInfo = p }).Join(Context.Set<TCavityInfo>(),
c => c.PalletInfo.BakingPosition,
p => p.Id,
(c, p) =>
new BatteryInfoEntity
{
Id = c.PalletInfo.Id,
BatteryStatus = c.BatteryInfo.BatteryStatus,
BatteryCode = c.BatteryInfo.BatteryCode,
PositionX = c.BatteryInfo.PositionX,
PositionY = c.BatteryInfo.PositionY,
ScanTime = c.PalletInfo.ScanTime,
PalletCode = c.PalletInfo.PalletCode,
BakingLocation = p.Name,
BakingBeginTime = c.PalletInfo.BakingBeginTime,
BakingOverTime = c.PalletInfo.BakingOverTime,
PalletVirtualId = c.PalletInfo.VirtualId,
WaterValue = c.PalletInfo.WaterValue
}).Where(x => x.BatteryCode == code).OrderBy(x => x.Id).FirstOrDefault();
}
}
public bool IsDummyByPalletId(int palletId)
{
using (var Context = new BakingEntities())
{
TBatteryInfo dummy = (from battery in Context.Set<TBatteryInfo>()
join pallet in Context.Set<TPalletInfo>() on battery.PalletVirtualId equals pallet.VirtualId
where pallet.Id == palletId && battery.DummyFlag == true
select battery).FirstOrDefault();
if (null == dummy)
{
return false;
}
else
{
return true;
}
}
}
//int GetMaxPosX()
//{
// using (var Context = new BakingEntities())
// {
// return (Context.Set<TBatteryInfo>().Max(x=>x.PositionY) ?? 0) + 1;
// }
//}
//public int Inbound(int[] batteryIds, int layer, int stoveNumber,int batteryStatus = (int)EBatteryStatus.InBound)
//{
// string sql = "";
// for (int x = 0; x < batteryIds.Count(); ++x)
// {
// if (0 != batteryIds[x])
// {
// sql += $"update TBatteryInfo set BatteryStatus={batteryStatus},Layer={layer},PositionY={x + 1},PositionX={GetMaxPosX()},InboundTime=NOW(),StoveNumber={stoveNumber} where Id={batteryIds[x]};";
// }
// }
// if (string.IsNullOrEmpty(sql))
// {
// return 0;
// }
// using (var Context = new BakingEntities())
// {
// return Context.Database.ExecuteSqlCommand(sql);
// }
//}
//public bool UpdatePreheatStatus()
//{
// string sql = $"UPDATE TBatteryInfo set BatteryStatus = {(int)EBatteryStatus.Preheat} WHERE BatteryStatus = {(int)EBatteryStatus.InBound};";
// using (var Context = new BakingEntities())
// {
// return Context.Database.ExecuteSqlCommand(sql) > 0 ? true : false;
// }
//}
//public bool UpdateOutbound(int[] batteryIds, int batteryStatus = (int)EBatteryStatus.OutBound)
//{
// string sql = "";
// for (int x = 0; x < batteryIds.Count(); ++x)
// {
// if (0 != batteryIds[x])
// {
// sql += $"update TBatteryInfo set BatteryStatus={batteryStatus},OutboundTime=NOW() where Id={batteryIds[x]};";
// }
// }
// using (var Context = new BakingEntities())
// {
// return Context.Database.ExecuteSqlCommand(sql) > 0 ? true : false;
// }
//}
public int InsertBattery(string batteryCode, sbyte status, sbyte scannPos)
{
string sql = $"Call ProcGetBatteryVirtualId('{batteryCode}',{status},{scannPos})";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<int>(sql).FirstOrDefault();
}
}
public TBatteryInfo GetBattery(int batteryId)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => x.Id == batteryId).FirstOrDefault();
}
}
public List<TBatteryInfo> GetBattery(int[] batteryIds)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => batteryIds.Contains(x.Id)).ToList();
}
}
//一个电芯会存在多次!电芯条码不是唯一
public List<TBatteryInfo> GetBatterys(List<string> codeBatterys)
{
string sql = "";
string codes = "";
if (0 == codeBatterys.Count)
{
return null;
}
foreach (var code in codeBatterys)
{
codes += $"'{code}',";
}
codes = codes.Remove(codes.Length - 1, 1);
sql = $"SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY BatteryCode ORDER BY ID DESC ) AS rn FROM " +
$"TBatteryInfo WHERE BatteryCode IN({ codes})) AS temp WHERE rn = 1; ";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<TBatteryInfo>(sql).ToList();
}
}
public TBatteryInfo GetBattery(string batteryCode)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => x.BatteryCode == batteryCode).OrderByDescending(x => x.Id).FirstOrDefault();
}
}
public bool IsExist(string batteryCode, int batteryId)
{
using (var Context = new BakingEntities())
{
var battery = Context.Set<TBatteryInfo>().Where(x => x.BatteryCode == batteryCode && x.Id == batteryId).FirstOrDefault();
if (battery == null)
{
return false;
}
else
{
return true;
}
}
}
public List<TBatteryInfo> GetIncomingCell()
{
using (var Context = new BakingEntities())
{
var cellList = Context.Set<TBatteryInfo>().OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(620).ToList();
if (cellList == null)
{
return null;
}
return cellList;
}
}
public List<OutputEntity> GetProductionOutPut(DateTime startDateTime, DateTime endDateTime)
{
using (var Context = new BakingEntities())
{
List<OutputEntity> output = Context.Database.SqlQuery<OutputEntity>($"call ProcProductionQtyQuery ('{startDateTime}','{endDateTime}')").ToList();
if (output == null)
{
return null;
}
return output;
}
}
public List<TBatteryInfo> QueryIncomingCell(DateTime startTime, DateTime endTime)
{
using (var Context = new BakingEntities())
{
var cellList = Context.Set<TBatteryInfo>().Where(x => x.ScanTime > startTime && x.ScanTime < endTime).OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(1000).ToList();
if (cellList == null)
{
return null;
}
return cellList;
}
}
public List<TBatteryInfo> QueryIncomingCellByCode(string code)
{
using (var Context = new BakingEntities())
{
var cellList = Context.Set<TBatteryInfo>().Where(x => x.BatteryCode.Contains(code)).OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(1000).ToList();
if (cellList == null)
{
return null;
}
return cellList;
}
}
public int GetPPM(DateTime startTime, DateTime endTime, int stoveNumber = 1)
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime).Count();
//List<TBatteryInfo> list = Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime).ToList();
}
}
}
}

View File

@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using Unity;
using System.Linq;
using Cowain.Bake.BLL;
using Cowain.Bake.Model;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Model.Entity;
namespace Cowain.Bake.BLL
{
public class BatteryNGService : ServiceBase
{
public BatteryNGService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TBatteryNG> GetAllNGCell( )
{
using (var Context = new BakingEntities())
{
return Context.Set<TBatteryNG>().ToList().OrderByDescending(x=>x.Id).Take(200).ToList();
}
}
public TBatteryNG GetCurrentNGBattery(string batteryCode) //存在多次复投
{
using (var Context = new BakingEntities())
{
return (from n in Context.Set<TBatteryNG>()
join b in Context.Set<TBatteryInfo>() on n.BatteryCode equals b.BatteryCode
where b.BatteryCode == batteryCode
orderby b.Id descending
select n).FirstOrDefault();
}
}
public List<TBatteryNG> QueryNGCell(DateTime startTime, DateTime endTime, string batteryCode)
{
using (var Context = new BakingEntities())
{
if(string.IsNullOrEmpty(batteryCode))
{
return (from n in Context.Set<TBatteryNG>()
where n.CreateTime > startTime && n.CreateTime < endTime
select n).ToList();
}
else
{
return (from n in Context.Set<TBatteryNG>()
where n.CreateTime > startTime && n.CreateTime < endTime && n.BatteryCode == batteryCode
select n).ToList();
}
}
}
public int Insert(string palletCode, string batteryCode, string desc)
{
TBatteryNG NG = new TBatteryNG()
{
PalletCode = palletCode,
BatteryCode = batteryCode,
CreateTime = DateTime.Now,
Desc = desc,
};
using (var Context = new BakingEntities())
{
Context.Set<TBatteryNG>().Add(NG);
return Context.SaveChanges();
}
}
}
}

View File

@@ -0,0 +1,749 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using Unity;
namespace Cowain.Bake.BLL
{
public class CavityInfoService : ServiceBase
{
public CavityInfoService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TCavityInfo> GetAll()
{
using (var Context = new BakingEntities())
{
return Context.Set<TCavityInfo>().OrderBy(x => x.Id).ToList();
}
}
public TCavityInfo GetStationDetailByName(string name)
{
using (var Context = new BakingEntities())
{
return Context.Set<TCavityInfo>().Where(x => x.Name == name).FirstOrDefault();
}
}
public int UpdateStationNonePallet(string stationName)
{
using (var Context = new BakingEntities())
{
var stationDtl = Context.Set<TCavityInfo>().Where(x => x.Name == stationName).ToList().FirstOrDefault();
stationDtl.PalletId = 0;
stationDtl.Lock = false;
return Context.SaveChanges();
}
}
public int UpdateStationReq(string stationName, sbyte status)
{
using (var Context = new BakingEntities())
{
var cavityInfo = Context.Set<TCavityInfo>().Where(x => x.Name == stationName).FirstOrDefault();
cavityInfo.Status = status;
return Context.SaveChanges();
}
}
public int ChangeStationStatus(string stationName, int status)
{
using (var Context = new BakingEntities())
{
TCavityInfo info = Context.Set<TCavityInfo>().Where(x => x.Name == stationName).FirstOrDefault();
if (null == info)
{
return 0;
}
info.Enable = status != 0 ;
Context.Set<TCavityInfo>().Attach(info);//将数据附加到上下文支持实体修改和新实体重置为UnChanged
Context.Entry<TCavityInfo>(info).State = EntityState.Modified;
return Context.SaveChanges();
}
}
public int UpdateLoadStatus(int machineId, int layer, int number, bool loadStatus)
{
using (var Context = new BakingEntities())
{
var model = Context.Set<TCavityInfo>().Where(x => x.StationId == machineId
&& x.Layer == layer
&& x.Column == number).FirstOrDefault();//.ForEach(x => x.IsLoad = loadStatus);
model.IsLoad = loadStatus;
return Context.SaveChanges();
}
}
/// <summary>
/// 是否符合请放,请取要求
/// </summary>
/// <param name="station"></param>
/// <param name="number"></param>
/// <param name="status"></param>
/// <returns></returns>
public bool IsAccordReq(TStation station, int number, sbyte status)
{
TCavityInfo model = new TCavityInfo();
using (var Context = new BakingEntities())
{
if (station.Type == (int)EStationType.Loading
|| station.Type == (int)EStationType.UnLoading)
{
if (status == (int)ECavityStatus.RequestPick) //请取
{
model = Context.Set<TCavityInfo>().Where(x => x.StationId == station.Id
&& x.Column == number
&& x.IsLoad == true
&& x.PalletId != 0
).FirstOrDefault(); //表示有盘
}
else if (status == (int)ECavityStatus.RequestPlace) //请放
{
model = Context.Set<TCavityInfo>().Where(x => x.StationId == station.Id
&& x.Column == number
&& x.IsLoad == false
&& x.PalletId == 0
).FirstOrDefault(); //表示无盘
}
}
else //炉子
{
if (status == (int)ECavityStatus.RequestPick) //请取
{
model = Context.Set<TCavityInfo>().Where(x => x.StationId == station.Id
&& x.Layer == number
&& x.IsLoad == true
&& x.PalletId != 0
).FirstOrDefault(); //表示有盘
}
else if (status == (int)ECavityStatus.RequestPlace) //请放
{
model = Context.Set<TCavityInfo>().Where(x => x.StationId == station.Id
&& x.Layer == number
&& x.IsLoad == false
&& x.PalletId == 0
).FirstOrDefault(); //表示无盘
}
}
}
if (null == model)
{
return false;
}
return true;
}
public bool UpdateReqStatus(TStation station, int number, sbyte status)
{
TCavityInfo model = null;
using (var Context = new BakingEntities())
{
if (station.Type == (int)EStationType.Loading
|| station.Type == (int)EStationType.UnLoading)
{
model = Context.Set<TCavityInfo>().Where(x => x.StationId == station.Id
&& x.Column == number
).FirstOrDefault();
}
else
{
model = Context.Set<TCavityInfo>().Where(x => x.StationId == station.Id
&& x.Layer == number
).FirstOrDefault();
}
model.Status = status;
Context.Entry(model).State = EntityState.Modified;
return Context.SaveChanges() > 0 ? true : false;
}
}
public bool UpdateUnBinding(string stationName)
{
using (var Context = new BakingEntities())
{
var model = Context.Set<TCavityInfo>().Where(x => x.Name == stationName).FirstOrDefault();
if (null != model)
{
model.PalletId = 0;
Context.Entry(model).State = EntityState.Modified;
return Context.SaveChanges() > 0 ? true : false;
}
return false;
}
}
public TCavityInfo GetStationID(string stationName)
{
using (var Context = new BakingEntities())
{
return (from ci in Context.Set<TCavityInfo>()
join s in Context.Set<TStation>() on ci.StationId equals s.Id into cs
from s in cs.DefaultIfEmpty() // 左连接 Scores
join pi in Context.Set<TDeviceConfig>() on s.DeviceId equals pi.Id into cp
from pi in cp.DefaultIfEmpty() // 左连接 Parents
where ci.Name == stationName
select ci).FirstOrDefault();
}
//string sql = $@"SELECT td.Id,tc.IsConnect,td.PalletId ,td.IsLoad FROM TCavityInfo td
// LEFT JOIN TStation t ON t.id=td.StationId
// LEFT JOIN TDeviceConfig tc ON tc.id=t.DeviceIds
// WHERE td.Name='{stationName}' LIMIT 1";
//return GetDataTable(sql);
}
public List<string> GetCanUseStationName()
{
using (var Context = new BakingEntities())
{
string sql = $@"SELECT td.Name FROM TCavityInfo td
LEFT JOIN TStation t ON td.StationId=t.Id
LEFT JOIN TDeviceConfig tc ON t.DeviceId=tc.Id
WHERE td.Name<>'AGV' AND td.Enable=1 AND td.Lock =0
AND td.IsLoad = 0 AND tc.IsConnect=1 AND t.Enable = 1 ORDER BY td.Id";
return Context.Database.SqlQuery<string>(sql).ToList();
}
}
public bool UnLockStation(int stationId, int layer, int number)
{
using (var Context = new BakingEntities())
{
TCavityInfo station = (from sd in Context.Set<TCavityInfo>()
where sd.StationId == stationId && sd.Layer == layer && sd.Column == number
select sd).FirstOrDefault(); //将托盘号绑定到AGV
if (null == station)
{
return false;
}
station.Lock = false;
Context.Entry(station).State = EntityState.Modified;
if (0 != Context.SaveChanges())
{
return true;
}
return false;
}
}
public bool LockStation(int stationId, int layer, int number)
{
using (var Context = new BakingEntities())
{
TCavityInfo station = (from sd in Context.Set<TCavityInfo>()
where sd.StationId == stationId && sd.Layer == layer && sd.Column == number
select sd).FirstOrDefault(); //将托盘号绑定到AGV
if (null == station)
{
return false;
}
station.Lock = true;
Context.Entry(station).State = EntityState.Modified;
if (0 != Context.SaveChanges())
{
return true;
}
return false;
}
}
public TCavityInfo GetStationDetailById(int id)
{
using (var Context = new BakingEntities())
{
return Context.Set<TCavityInfo>().Where(x => x.Id == id).FirstOrDefault();
}
}
public int SetRobotPos( int stationNumber)
{
using (var Context = new BakingEntities())
{
var model = (from a in Context.Set<TCavityInfo>()
join b in Context.Set<TStation>() on a.StationId equals b.Id
where b.Type == (int)EStationType.AGV
orderby a.Id
select a).FirstOrDefault();
model.StationNumber = (sbyte)stationNumber;
return Context.SaveChanges();
}
}
public int GetPalletId(int machineType, int number)
{
using (var Context = new BakingEntities())
{
var station = (from a in Context.Set<TCavityInfo>()
join b in Context.Set<TStation>() on a.StationId equals b.Id
where b.Type == machineType && a.Column == number
orderby a.Id
select a).FirstOrDefault();
if (null == station)
{
LogHelper.Instance.GetCurrentClassError($"通过设备ID={machineType},编号={number},查找夹具ID失败");
return 0;
}
return station.PalletId;
}
}
//public TCavityInfo GetStationDetail(int StationId, int X, int Y)
//{
// using (var Context = new BakingEntities())
// {
// TCavityInfo detail = (from s in Context.Set<TCavityInfo>()
// where s.StationId == StationId && s.Layer == X && s.Column == Y
// select s).FirstOrDefault();
// if (null == detail)
// {
// LogHelper.Instance.Error($"获取工站详细信息失败StationId:{StationId},Layer{X},Number{Y}");
// }
// return detail;
// }
//}
public int GetCavityId(int stationId, int layer, int column = 1)
{
using (var Context = new BakingEntities())
{
TCavityInfo detail = (from s in Context.Set<TCavityInfo>()
where s.StationId == stationId && s.Layer == layer && s.Column == column
select s).FirstOrDefault();
if (null == detail)
{
LogHelper.Instance.GetCurrentClassError($"通过设备ID={stationId},Layer:{layer},编号={column},查找夹具ID失败");
return 0;
}
else
{
return detail.Id;
}
}
}
public int UpdateDoorStatus(int machineId, int layer, bool doorStatus)
{
using (var Context = new BakingEntities())
{
Context.Set<TCavityInfo>().Where(x => x.StationId == machineId
&& x.Layer == layer).ToList().ForEach(x => x.IsOpen = doorStatus);
return Context.SaveChanges();
}
}
public int UpdateCavitySignal(int stationId, int layer, Int16 status)
{
using (var Context = new BakingEntities())
{
Context.Set<TCavityInfo>().Where(x => x.StationId == stationId
&& x.Layer == layer).ToList().ForEach(x => x.Status = (sbyte)status);
return Context.SaveChanges();
}
}
public List<ExCavityInfoModel> GetAllExInfo()
{
using (var Context = new BakingEntities())
{
// 查询语法的三表联查
return (from ci in Context.Set<TCavityInfo>()
join s in Context.Set<TStation>() on ci.StationId equals s.Id into cs
from s in cs.DefaultIfEmpty() // 左连接 Scores
join pi in Context.Set<TPalletInfo>() on ci.PalletId equals pi.Id into cp
from pi in cp.DefaultIfEmpty() // 左连接 Parents
//where s.Type != (int)EStationType.AGV
select new ExCavityInfoModel
{
StationId = s.Id,
Name = s.Name,
Desc = s.Desc,
Layers = s.Layers,
Columns = s.Columns,
Number = s.Number,
PosX = s.PosX,
PosY = s.PosY,
Type = s.Type,
LeftMargin = s.LeftMargin,
Enable = s.Enable,
Id = ci.Id,
CavityName = ci.Name,
IsLoad = ci.IsLoad,
PalletId = ci.PalletId,
Lock = ci.Lock,
Layer = ci.Layer,
Status = ci.Status??0,
Column = ci.Column,
StationX = ci.StationX,
StationY = ci.StationY,
IsOpen = ci.IsOpen,
CavityEnable = ci.Enable,
Remark = ci.Remark,
BakingPosition = pi.BakingPosition,
JobNum = pi.JobNum,
PalletStatus = pi.PalletStatus,
PalletCode = pi.PalletCode,
BatteryQty = pi.BatteryQty,
BakingCount = pi.BakingCount,
TotalBakingCount = pi.TotalBakingCount,
LoadingBegingTime = pi.LoadingBegingTime,
BakingBeginTime = pi.BakingBeginTime,
BakingOverTime = pi.BakingOverTime,
LastFlag = pi.LastFlag,
UnLoadingBegingTime = pi.LoadingBegingTime
}).OrderBy(x=>x.Id).ToList();
}
}
//public int TransferStationToAGV(int fromStation, int fromX, int fromY)
//{
// int result = 0;
// using (var Context = new BakingEntities())
// {
// TCavityInfo detail = (from s in Context.Set<TCavityInfo>()
// where s.StationId == fromStation && s.Layer == fromX && s.Column == fromY
// select s).FirstOrDefault();
// if (null == detail || 0 == detail.PalletId)
// {
// LogHelper.Instance.Error($"获取托盘失败StationId:{fromStation},Layer:{fromX},Number:{fromY}");
// return 0;
// }
// //using (var transaction = Context.Database.BeginTransaction())
// {
// try
// {
// (from a in Context.Set<TCavityInfo>()
// join b in Context.Set<TStation>() on a.StationId equals b.Id
// where b.Type == (int)EStationType.AGV
// select a).ToList().ForEach(x => x.PalletId = detail.PalletId); //将托盘号绑定到AGV
// result = Context.SaveChanges();
// if (0 == result)
// {
// LogHelper.Instance.Warn($"托盘绑定AGV失败1! 托盘号;{detail.PalletId}");
// }
// /////////////////////////////////////////////////////////
// Context.Set<TCavityInfo>().Where(x => x.Id == detail.Id).ToList().ForEach(x => x.PalletId = 0); //解绑
// result = Context.SaveChanges();
// if (0 == result)
// {
// LogHelper.Instance.Warn($"托盘绑定AGV失败2! 托盘号;{detail.PalletId}");
// }
// }
// catch (Exception ex)
// {
// // 回滚事务
// //transaction.Rollback();
// LogHelper.Instance.Warn("TransferPallet:" + ex.Message);
// }
// }
// return result;
// }
//}
public int UpdatePalletStatus(int palletId, string stationName, int statusCode)
{
using (var Context = new BakingEntities())
{
string sql = $@"UPDATE TCavityInfo t1 SET t1.`Lock`=0
WHERE t1.Name='{stationName}';";
Context.Database.ExecuteSqlCommand(sql);
sql = $@"UPDATE TPalletInfo set PalletStatus={statusCode}
WHERE Id={palletId};";
return Context.Database.ExecuteSqlCommand(sql);
}
}
public int UpdateStationPalletCode(string stationName, string palletCode)
{
//先解绑原来的
using (var Context = new BakingEntities())
{
var palletDtl = Context.Set<TPalletInfo>().Where(x => x.PalletCode == palletCode).ToList().FirstOrDefault();
var stationBindingDtl = Context.Set<TCavityInfo>().Where(x => x.PalletId == palletDtl.Id)
.ToList().FirstOrDefault(); //老工站如果是新夹具,就不解绑
if (stationBindingDtl != null)
{
if (1 != stationBindingDtl.PalletId) //新夹具
{
stationBindingDtl.PalletId = 0;
Context.SaveChanges();
}
}
//绑定现在的
var stationDtl = Context.Set<TCavityInfo>().Where(x => x.Name == stationName).ToList().FirstOrDefault();
if (stationDtl.PalletId == palletDtl.Id)
{
return 1;
}
if (stationDtl != null)
{
stationDtl.PalletId = palletDtl.Id;
stationDtl.Lock = false;
}
return Context.SaveChanges();
}
}
public int UpdateRemark(string stationName, string msg)
{
using (var Context = new BakingEntities())
{
TCavityInfo model = Context.Set<TCavityInfo>().Where(x => x.Name == stationName).FirstOrDefault();
if (null == model)
{
return 0;
}
var models = Context.Set<TCavityInfo>().Where(x => x.StationId == model.StationId && x.Layer == model.Layer).ToList();
foreach (var entity in models)
{
entity.Remark = msg;
Context.Entry<TCavityInfo>(entity).State = EntityState.Modified;
}
return Context.SaveChanges();
}
}
//public string GetStation(int? StationId)
//{
// using (var Context = new BakingEntities())
// {
// TCavityInfo detail = (from s in Context.Set<TCavityInfo>()
// where s.Id == StationId
// select s).FirstOrDefault();
// if (null == detail)
// {
// return null;
// }
// else
// {
// return detail.Name;
// }
// }
//}
public void GetPalletBakingPosAndUpdateLock(string palletCode)
{
using (var Context = new BakingEntities())
{
TPalletInfo palletInfo = Context.Set<TPalletInfo>().Where(x => x.PalletCode == palletCode).FirstOrDefault();
Context.Set<TCavityInfo>().Where(x => x.Id == palletInfo.BakingPosition).ToList().ForEach(x => x.Lock = false); //测试OK加在下料位解绑
Context.SaveChanges();
}
}
//public int[] GetLayerPalletId(int Layer, int StationId)
//{
// using (var Context = new BakingEntities())
// {
// return Context.Set<TCavityInfo>()
// .Where(x => x.Layer == Layer && x.StationId == (byte)StationId)
// .Select(x => x.PalletId).ToArray();
// }
//}
//545一层的水含量
public int[] GetLayerTypePalletId(int LayerType, int StationId)
{
using (var Context = new BakingEntities())
{
return Context.Set<TCavityInfo>()
.Where(x => x.LayerType == LayerType && x.StationId == (byte)StationId)
.Select(x => x.PalletId).ToArray();
}
}
public CavityHeaderModel GetHeadInfo(string cavityName)
{
string sql = $@"SELECT IFNULL(ti.BatteryQty , 0) BatteryQty,IFNULL(ti.TotalBakingCount , 0) TotalBakingCount,IFNULL(ti.BakingCount , 0) BakingCount,ti.JobNum,IFNULL(ti.VirtualId , 0) VirtualId,td.Lock,td.Id,td.Remark
,IF(td.Enable,'可用','禁用') Enable,IF(COALESCE(tb.DummyFlag, 0) = 1, '带水', '不带水') AS IsWater
,IFNULL(ti.Id , 0) PalletId,ti.PalletCode,ti.PalletStatus,ti.WaterValue,ti.LastFlag,td.Layer,td.LayerType,IFNULL(ti.BakingPosition , 0) BakingPosition
FROM TCavityInfo td
LEFT JOIN TPalletInfo ti ON td.PalletId=ti.Id
LEFT JOIN TBatteryInfo tb ON ti.VirtualId = tb.PalletVirtualId AND tb.DummyFlag = 1
WHERE td.Name='{cavityName}' limit 1";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<CavityHeaderModel>(sql).FirstOrDefault();
}
}
public CavityInfoModel GetCavityDetailByName(string name)
{
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TStation>()
join b in Context.Set<TCavityInfo>() on a.Id equals b.StationId
where b.Name == name
select new CavityInfoModel
{
StationId = a.Id,
Name = a.Name,
Desc = a.Desc,
Layers = a.Layers,
Columns = a.Columns,
Number = a.Number,
PosX = a.PosX,
PosY = a.PosY,
Type = a.Type,
LeftMargin = a.LeftMargin,
Enable = a.Enable,
Id = b.Id,
CavityName = b.Name,
IsLoad = b.IsLoad,
PalletId = b.PalletId,
Lock = b.Lock,
Layer = b.Layer,
Column = b.Column,
StationX = b.StationX,
StationY = b.StationY,
IsOpen = b.IsOpen,
Status = b.Status ?? 0,
CavityEnable = b.Enable,
Remark = b.Remark,
}).FirstOrDefault();
}
}
public List<CavityInfoModel> GetAllStation()
{
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TStation>()
join b in Context.Set<TCavityInfo>() on a.Id equals b.StationId
select new CavityInfoModel
{
StationId = a.Id,
Name = a.Name,
Desc = a.Desc,
Layers = a.Layers,
Columns = a.Columns,
Number = a.Number,
PosX = a.PosX,
PosY = a.PosY,
Type = a.Type,
LeftMargin = a.LeftMargin,
Enable = a.Enable,
Id = b.Id,
CavityName = b.Name,
IsLoad = b.IsLoad,
PalletId = b.PalletId,
Lock = b.Lock,
Layer = b.Layer,
Column = b.Column,
Status = b.Status ?? 0,
StationX = b.StationX,
StationY = b.StationY,
IsOpen = b.IsOpen,
CavityEnable = b.Enable,
Remark = b.Remark,
}).ToList();
}
}
public CavityInfoModel GetCavitynDetailById(int id)
{
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TStation>()
join b in Context.Set<TCavityInfo>() on a.Id equals b.StationId
where b.Id == id
select new CavityInfoModel
{
StationId = a.Id,
Name = a.Name,
Desc = a.Desc,
Layers = a.Layers,
Columns = a.Columns,
Number = a.Number,
PosX = a.PosX,
PosY = a.PosY,
Type = a.Type,
LeftMargin = a.LeftMargin,
Enable = a.Enable,
Id = b.Id,
CavityName = b.Name,
IsLoad = b.IsLoad,
PalletId = b.PalletId,
Lock = b.Lock,
Layer = b.Layer,
Column = b.Column,
StationNumber = b.StationNumber,
StationX = b.StationX,
StationY = b.StationY,
Status = b.Status ?? 0,
IsOpen = b.IsOpen,
CavityEnable = b.Enable,
Remark = b.Remark,
}).FirstOrDefault();
}
}
public List<CavityInfoModel> GetExAll()
{
using (var Context = new BakingEntities())
{
return (from a in Context.Set<TStation>()
join b in Context.Set<TCavityInfo>() on a.Id equals b.StationId
select new CavityInfoModel
{
StationId = a.Id,
Name = a.Name,
Desc = a.Desc,
Layers = a.Layers,
Columns = a.Columns,
Number = a.Number,
PosX = a.PosX,
PosY = a.PosY,
Type = a.Type,
LeftMargin = a.LeftMargin,
Enable = a.Enable,
Id = b.Id,
CavityName = b.Name,
IsLoad =b.IsLoad,
PalletId = b.PalletId,
Lock = b.Lock,
Layer = b.Layer,
Column = b.Column,
StationNumber = b.StationNumber,
StationX = b.StationX,
StationY = b.StationY,
IsOpen = b.IsOpen,
CavityEnable = b.Enable,
Remark = b.Remark,
Status = b.Status ?? 0,
}).ToList();
}
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using Prism.Ioc;
namespace Cowain.Bake.BLL.Converter
{
public class CavityInfoIdConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().CavityInfo.Where(x => x.Id == val).FirstOrDefault();
if (null == p)
{
return " ";
}
else
{
return p.Name;
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().CavityInfo.Where(x => x.Name == val).FirstOrDefault();
if (null == p)
{
return 0;
}
else
{
return p.Id;
}
}
return 0;
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Cowain.Bake.Common.Enums;
namespace Cowain.Bake.BLL.Converter
{
public class InvalidConvertor:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
EValidStatus status = (EValidStatus)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using Cowain.Bake.Common.Enums;
using System;
using System.Globalization;
using System.Windows.Data;
namespace Cowain.Bake.BLL.Converter
{
public class LogTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
E_LogType status = (E_LogType)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using Prism.Ioc;
namespace Cowain.Bake.BLL.Converter
{
public class PalletIdConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().GetPalletInfoById(val);
if (null == p)
{
return "";
}
else
{
return p.PalletCode;
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return 0;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using Prism.Ioc;
namespace Cowain.Bake.BLL.Converter
{
public class PalletVirtualIdConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().GetPalletInfoByVirtualId(val);
if (null == p)
{
return "";
}
else
{
return p.PalletCode;
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return 0;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Prism.Ioc;
namespace Cowain.Bake.BLL.Converter
{
public class ProcessParamIdConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().GetProcessParam(val);
if (null == p)
{
return "";
}
else
{
return p.ProcessParamName;
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return 0;
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Cowain.Bake.Common.Enums;
namespace Cowain.Bake.BLL.Converter
{
public class RoleConvertor:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
ERole status = (ERole)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using Prism.Ioc;
namespace Cowain.Bake.BLL.Converter
{
public class StationIdConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
throw new ArgumentNullException("value can not be null");
if (value is int val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().AllStation.Where(x => x.Id == val).FirstOrDefault();
if (null == p)
{
return null;
}
else
{
return p.Desc;
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().AllStation.Where(x => x.Name == val).FirstOrDefault();
if (null == p)
{
return 0;
}
else
{
return p.Id;
}
}
return 0;
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using Prism.Ioc;
namespace Cowain.Bake.BLL.Converter
{
public class TaskTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().TaskType.Where(x => x.Id == val).FirstOrDefault();
if (null == p)
{
return "手动任务";
}
else
{
return p.Name;
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string val)
{
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().TaskType.Where(x => x.Name == val).FirstOrDefault();
if (null == p)
{
return 0;
}
else
{
return p.Id;
}
}
return 0;
}
}
}

View File

@@ -0,0 +1,77 @@
using Cowain.Bake.Common.Models;
using Cowain.Bake.Model.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.BLL.Converter
{
public class VarValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] == null)
{
throw new ArgumentNullException("value[0] can not be null");
}
if (values[1] == null)
{
return null;
}
string varType = values[0].ToString();
string res = string.Empty;
if (values[1] is byte[] val && !string.IsNullOrEmpty(varType))
{
Variable variable = new Variable();
variable.VarType = varType;
//variable.CurValue = val;
Stopwatch sw = new Stopwatch();
sw.Start();
//switch (variable.VarType)
//{
// case "BOOL":
// res = variable.GetBool().ToString();
// break;
// case "BYTE":
// res = variable.GetByte().ToString();
// break;
// case "UINT16":
// res = variable.GetUInt16().ToString();
// break;
// case "INT16":
// res = variable.GetInt16().ToString();
// break;
// case "INT32":
// res = variable.GetInt32().ToString();
// break;
// case "UINT32":
// res = variable.GetUInt32().ToString();
// break;
// case "FLOAT":
// res = variable.GetFloat().ToString();
// break;
// default:
// break;
//}
int rt = (int)sw.ElapsedMilliseconds;
if (rt > 100)
{
//NLog.LogManager.GetCurrentClassLogger().Error("转换时间超时:" + rt);
}
}
return res;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3D24095D-B703-438D-AB17-C6BD7E9EF514}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cowain.Bake.BLL</RootNamespace>
<AssemblyName>Cowain.Bake.BLL</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cowain.Bake.Common">
<HintPath>..\Cowain.Bake.Common\bin\Debug\Cowain.Bake.Common.dll</HintPath>
</Reference>
<Reference Include="Cowain.Bake.Model">
<HintPath>..\Cowain.Bake.Model\bin\Debug\Cowain.Bake.Model.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>..\Libs\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\Libs\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.14.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.14.0\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4, Version=1.2.6.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.1.2.6\lib\net46\K4os.Compression.LZ4.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.2.6.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.2.6\lib\net46\K4os.Compression.LZ4.Streams.dll</HintPath>
</Reference>
<Reference Include="K4os.Hash.xxHash, Version=1.0.6.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="MySql.Data.EntityFramework, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\MySql.Data.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Prism, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\Prism.dll</HintPath>
</Reference>
<Reference Include="Prism.Unity.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\Prism.Unity.Wpf.dll</HintPath>
</Reference>
<Reference Include="Prism.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\Prism.Wpf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="Unity.Abstractions">
<HintPath>..\Libs\Unity.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Unity.Container">
<HintPath>..\Libs\Unity.Container.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AlarmContentService.cs" />
<Compile Include="AlarmService.cs" />
<Compile Include="BatteryInfoService.cs" />
<Compile Include="BatteryNGService.cs" />
<Compile Include="Converter\InvalidConvertor.cs" />
<Compile Include="Converter\LogTypeConverter.cs" />
<Compile Include="Converter\PalletIdConverter.cs" />
<Compile Include="Converter\PalletVirtualIdConverter.cs" />
<Compile Include="Converter\ProcessParamIdConvertor.cs" />
<Compile Include="Converter\RoleConvertor.cs" />
<Compile Include="Converter\CavityInfoIdConverter.cs" />
<Compile Include="Converter\StationIdConverter.cs" />
<Compile Include="Converter\TaskTypeConverter.cs" />
<Compile Include="Converter\VarValueConverter.cs" />
<Compile Include="BLLModule.cs" />
<Compile Include="DeviceConfigService.cs" />
<Compile Include="ElectricEnergyService.cs" />
<Compile Include="LogService.cs" />
<Compile Include="MemoryDataProvider.cs" />
<Compile Include="MenuInfoService.cs" />
<Compile Include="MesDataService.cs" />
<Compile Include="PalletInfoService.cs" />
<Compile Include="ProcessParamService.cs" />
<Compile Include="ProductionInformationService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RgvActionService.cs" />
<Compile Include="RoleInfoService.cs" />
<Compile Include="ServiceBase.cs" />
<Compile Include="CavityInfoService.cs" />
<Compile Include="StationService.cs" />
<Compile Include="StoveSctualPatrolService.cs" />
<Compile Include="SysSetupService.cs" />
<Compile Include="TagListService.cs" />
<Compile Include="TaskRecordService.cs" />
<Compile Include="TaskStepService.cs" />
<Compile Include="TaskTypeService.cs" />
<Compile Include="UserService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,131 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using System.Collections.Generic;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class DeviceConfigService : ServiceBase
{
public DeviceConfigService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TDeviceConfig> GetAll()
{
using (var Context = new BakingEntities())
{
return Context.Set<TDeviceConfig>().OrderBy(x=>x.Id).ToList();
}
}
public List<TDeviceConfig> GetUnEnableAll()
{
using (var Context = new BakingEntities())
{
return Context.Set<TDeviceConfig>().Where(x=>x.Enable == false).ToList();
}
}
public List<TDeviceConfig> GetDeviceByDesc(string parms)
{
using (var Context = new BakingEntities())
{
return Context.Set<TDeviceConfig>().Where(p => p.Desc.Contains(parms)).ToList();
}
}
public TDeviceConfig GetConfig(int stationId)
{
using (var Context = new BakingEntities())
{
return (from s in Context.Set<TStation>()
join d in Context.Set<TDeviceConfig>() on s.DeviceId equals d.Id
where s.Id == stationId
select d).FirstOrDefault();
}
}
public List<TDeviceConfig> GetConfig(EDeviceType devType)
{
using (var Context = new BakingEntities())
{
return Context.Set<TDeviceConfig>().Where(item => item.Type == (int)devType).ToList(); //item.Enable == true &&
}
}
public List<TDeviceConfig> GetConfig(EDeviceType devType, EDeviceName devName)
{
using (var Context = new BakingEntities())
{
var ulist = Context.Set<TDeviceConfig>().Where(item => item.Type == (int)devType &&
item.Name.ToLower().Contains(devName.ToString().ToLower())).ToList();
if (ulist.Count > 0)
{
return ulist;
}
return null;
}
}
public List<TDeviceConfig> GetConfig(EDeviceType devType, string subDevName)
{
using (var Context = new BakingEntities())
{
return Context.Set<TDeviceConfig>().Where(item => item.Type == (int)devType &&
item.Name.ToLower().Contains(subDevName.ToLower())).ToList();
}
}
public int UpdateStatus(int Id, bool status)
{
using (var Context = new BakingEntities())
{
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
if (null == conf)
{
return 0;
}
conf.IsConnect = status;
CommonCoreHelper.Instance.BlockStatusColor.Add(conf); //生产者
return Context.SaveChanges();
}
}
//public void UpdateMesJosn(string MesJosn)
//{
// using (var Context = new BakingEntities())
// {
// TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Type == (int)EDeviceType.MES).FirstOrDefault();
// if (null == conf)
// {
// return;
// }
// conf.Json = MesJosn;
// Context.SaveChanges();
// }
//}
public int UpdateEnable(int Id, bool status)
{
using (var Context = new BakingEntities())
{
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
if (null == conf)
{
return 0;
}
conf.Enable = status;
return Context.SaveChanges();
}
}
}
}

View File

@@ -0,0 +1,45 @@
using Cowain.Bake.Common.Interface;
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class ElectricEnergyService:ServiceBase
{
public ElectricEnergyService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public DataTable GetYestodayEnergy()
{
string sql = $@"CALL ProcGetYestodayEnergy()";
return GetDataTable(sql);
}
public List<TElectricEnergy> Query(int maincheId, DateTime dtStart, DateTime dtEnd)
{
using (var Context = new BakingEntities())
{
return Context.Set<TElectricEnergy>().Where(x => x.CreateTime >= dtStart
&& x.CreateTime <= dtEnd
&& x.StationId == maincheId).ToList();
}
}
public int Insert(TElectricEnergy model)
{
using (var Context = new BakingEntities())
{
Context.Set<TElectricEnergy>().Add(model);
return Context.SaveChanges();
}
}
}
}

View File

@@ -0,0 +1,60 @@
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class LogService: ServiceBase
{
public LogService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public int AddLog(string logText,string logLevel)
{
if (logText.Length>8000)
{
logText = logText.Substring(0,7900);
}
Model.TLog log = new Model.TLog();
log.Content = logText;
log.Level = 1;// logLevel;
log.CreateTime = DateTime.Now;
using (var Context = new BakingEntities())
{
Context.Set<TLog>().Add(log);
return Context.SaveChanges();
}
}
public List<Model.TLog> QueryByTimeAndText(DateTime startTime, DateTime endTime, E_LogType logType)
{
List<Model.TLog> logList = null;
using (var Context = new BakingEntities())
{
if (logType == E_LogType.All)
{
logList = Context.Set<Model.TLog>().Where(item => item.CreateTime > startTime && item.CreateTime < endTime)
.OrderByDescending(item => item.CreateTime).Take(3000).ToList();
}
else
{
logList = Context.Set<Model.TLog>().Where(item => item.CreateTime > startTime && item.CreateTime < endTime && item.Level == (sbyte)logType)
.OrderByDescending(item => item.CreateTime).Take(3000).ToList();
}
if (logList == null)
{
return null;
}
return logList;
}
}
}
}

View File

@@ -0,0 +1,48 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Interface;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using Cowain.Bake.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class MemoryDataProvider
{
protected static IUnityContainer _unityContainer =null;
public int DispMode { get; set; } //调度模试
public UserEntity CurrentUser { get; set; } = new UserEntity();
public List<TCavityInfo> CavityInfo { get; set; }
public List<TStation> AllStation { get; set; }
public List<TTaskType> TaskType { get; set; }
public MemoryDataProvider(IUnityContainer unityContainer)
{
_unityContainer = unityContainer;
CavityInfo = unityContainer.Resolve<CavityInfoService>().GetAll();
AllStation = unityContainer.Resolve<StationService>().GetAll();
TaskType = unityContainer.Resolve<TaskTypeService>().GetAll();
}
public TProcessParameter GetProcessParam(int id)
{
return _unityContainer.Resolve<ProcessParamService>().Get(id);
}
public TPalletInfo GetPalletInfoByVirtualId(int virtualId)
{
return _unityContainer.Resolve<PalletInfoService>().GetPalletInfoByVirtualId(virtualId);
}
public TPalletInfo GetPalletInfoById(int palletId)
{
return _unityContainer.Resolve<PalletInfoService>().GetPalletInfo(palletId);
}
}
}

View File

@@ -0,0 +1,63 @@
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class MenuInfoService : ServiceBase
{
public MenuInfoService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TMenuInfo> GetBaseMenuInfo()
{
using (var Context = new BakingEntities())
{
return Context.Set<TMenuInfo>().Where(x => x.ParentId == 0).OrderBy(x => x.MenuIndex).ToList();
}
}
public DataTable GetLabelName(string MethodName)
{
string sql = $@"SELECT ti.Header,ti.JSON->>'$.Value0' Value0,ti.JSON->>'$.Value1' Value1
FROM TMenuInfo ti
WHERE ti.MenuType=2 and ti.JSON->>'$.CMD'='{MethodName}';";
return GetDataTable(sql);
}
public List<TMenuInfo> GetMenuInfoList()
{
using (var Context = new BakingEntities())
{
return Context.Set<TMenuInfo>().Where(x=>x.State == true).OrderBy(x => x.Id).ThenBy(x => x.ParentId).ToList();
}
}
public DataTable GetImage()
{
string sql = $@"SELECT ti.Header,CAST(MenuImage AS char) MenuImage FROM TMenuInfo ti
WHERE ParentId>0";
return GetDataTable(sql);
}
public int GetMenuParam(string menuName)
{
string sql = $@"SELECT ifnull(ts.ParamValue,-1) ParaValue FROM TSysSetup ts
WHERE ts.ParamCode=(
SELECT IF(LENGTH(JSON)>4,JSON->>'$.CMD','') ParaID
FROM TMenuInfo
WHERE MenuType=2 AND Header='{menuName}');";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<int>(sql).FirstOrDefault();
}
}
}
}

View File

@@ -0,0 +1,114 @@
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.SqlServer;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class MesDataService : ServiceBase
{
List<sbyte> flags = new List<sbyte>();
public MesDataService(IUnityContainer unityContainer) : base(unityContainer)
{
flags.Add((sbyte)EMesUpLoadStatus.Wait);
flags.Add((sbyte)EMesUpLoadStatus.Fail);
}
public int ModifySendFlag(long id, sbyte sendFlag)
{
using (var Context = new BakingEntities())
{
var model = Context.Set<TMesData>().Where(x => x.Id == id).FirstOrDefault();
if (null == model)
{
return 0;
}
model.SendFlag = sendFlag;
Context.Entry(model).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
/*
* 条件 执行时间(有索引) 扫描行数
* col = 3 0.03 ms 1 次随机 I/O
* col NOT IN (1,2) 120 ms 980 万次逻辑读
*/
public List<TMesData> GetUpLoadData()
{
using (var Context = new BakingEntities())
{
return Context.Set<TMesData>().Where(x => flags.Contains(x.SendFlag)).OrderByDescending(x => x.Id).Take(5).ToList();
//return Context.Set<TMesData>().Where(x => x.SendFlag != (sbyte)EMesUpLoadStatus.Success).OrderBy(x => x.Id).Take(5).ToList();
}
}
public int Insert(string commandType, string content, EMesLogClass mesType)
{
TMesData model = new TMesData()
{
CommandType = commandType,
Content = content,
SendFlag = 0,
MsgType = (sbyte)mesType
};
return Insert<TMesData>(model);
}
public int Update(TMesData data)
{
using (var Context = new BakingEntities())
{
Context.Entry(data).State = EntityState.Modified;
return Context.SaveChanges();
}
}
public TMesData Query(int msgId)
{
string first = @"SELECT * FROM TMesData td WHERE JSON_CONTAINS(td.Content, '{""MsgNO"":"; //其中特殊字符(如转义字符)不会被解释
string sql = first + msgId + @"}');";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<TMesData>(sql).FirstOrDefault();
}
}
public List<MesDataEntity> GetMesDataCellState(string batteryCode, DateTime startDateTime, DateTime EndDateTime)
{
string sql = $"SELECT *,Content->>'$.Info.Cells' BatteryCode FROM TMesData WHERE CreateTime > '{startDateTime}' and CreateTime < '{EndDateTime}' and JSON_EXTRACT(Content, '$.Info.CellNo') = '{batteryCode}'";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<MesDataEntity>(sql).ToList();
}
}
public List<MesDataEntity> GetMesDataBakingOutput(string batteryCode, DateTime startDateTime, DateTime EndDateTime)
{
string sql = $"SELECT *,Content->>'$.Info.Cells' BatteryCode FROM TMesData WHERE CreateTime > '{startDateTime}' and CreateTime < '{EndDateTime}'" + "and JSON_CONTAINS(Content,'\\{\"CellNo\":\"" + batteryCode + "\"\\}','$.Info.Cells')";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<MesDataEntity>(sql).ToList();
}
}
public List<MesDataEntity> GetMesDataList(EMesLogClass msgType, DateTime dateTime1, DateTime dateTime2)
{
string sql = $@"SELECT *,Content->>'$.Info.Cells' BatteryCode FROM TMesData td WHERE ('{dateTime1}'< td.CreateTime and td.CreateTime < '{dateTime2}') AND MsgType = {(sbyte)msgType}";
using (var Context = new BakingEntities())
{
var MesData = Context.Database.SqlQuery<MesDataEntity>(sql).ToList();
return MesData;
}
}
}
}

View File

@@ -0,0 +1,714 @@
using Cowain.Bake.Common;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using Cowain.Bake.Model.Models;
using Prism.Ioc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class PalletInfoService : ServiceBase
{
public PalletInfoService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TPalletInfo> GetAll()
{
using (var Context = new BakingEntities())
{
var palletList = Context.Set<TPalletInfo>().OrderBy(x => x.Id).OrderByDescending(x => x.PalletCode).ToList();
if (palletList == null)
{
return null;
}
return palletList;
}
}
public TPalletInfo GetPalletInfo(string PalletCode)
{
using (var Context = new BakingEntities())
{
return Context.Set<TPalletInfo>().Where(x => x.PalletCode == PalletCode).FirstOrDefault();
}
}
public int UpdateWaterValue(int palletId, int palletstaus, string waterValue)
{
using (var Context = new BakingEntities())
{
var pallet = Context.Set<TPalletInfo>().Where(x => x.Id == palletId).FirstOrDefault();
if (null == pallet)
{
LogHelper.Instance.Error("修改托盘水含量数据失败!");
return 0;
}
pallet.PalletStatus = palletstaus;
pallet.WaterValue = waterValue;
Context.Entry(pallet).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
public List<MoveInfoEntity> GetMoveInfo()
{
using (var Context = new BakingEntities())
{
var tt = (from sd in Context.Set<TCavityInfo>()
join p in Context.Set<TPalletInfo>() on sd.PalletId equals p.Id
where sd.Name != "AGV"
orderby sd.Name
select new MoveInfoEntity
{
Name = sd.Name,
PalletStatus = p.PalletStatus,
PalletCode = p.PalletCode,
BatteryQty = p.BatteryQty,
BeginBakingTime = p.BakingBeginTime,
BakingOverTime = p.BakingOverTime
}).ToList();
return tt;
}
}
public List<TPalletInfo> Query(DateTime startTime, DateTime endTime, string palletCode)
{
using (var Context = new BakingEntities())
{
if (string.IsNullOrEmpty(palletCode))
{
string sql = $"SELECT * FROM TPalletInfo WHERE ScanTime > '{startTime}' AND ScanTime < '{endTime}' UNION ALL " +
$"SELECT * FROM TPalletInfoHistory WHERE ScanTime > '{startTime}' AND ScanTime < '{endTime}' order by ScanTime DESC";
return Context.Database.SqlQuery<TPalletInfo>(sql).ToList();
}
else
{
string sql = $"SELECT * FROM TPalletInfo WHERE ScanTime > '{startTime}' AND ScanTime < '{endTime}' AND PalletCode='{palletCode}' UNION ALL " +
$"SELECT * FROM TPalletInfoHistory WHERE ScanTime > '{startTime}' AND ScanTime < '{endTime}' AND PalletCode='{palletCode}' order by ScanTime DESC";
return Context.Database.SqlQuery<TPalletInfo>(sql).ToList();
}
}
}
public TPalletInfo GetRobotPallet()
{
using (var Context = new BakingEntities())
{
return (from pi in Context.Set<TPalletInfo>()
join ci in Context.Set<TCavityInfo>() on pi.Id equals ci.PalletId
where ci.Name == "AGV"
select pi).FirstOrDefault();
}
}
public int PalletInfoToHistory(int virtualId, int palletStatus, int batteryStauts, int stationType, int number)
{
using (var Context = new BakingEntities())
{
return Context.Database.ExecuteSqlCommand($"call ProcPalletInfoToHistory({virtualId},{palletStatus},{batteryStauts},{stationType},{number})");
}
}
public TPalletInfo GetPalletInfoByBatteryVirtualId(int? palletVirtualId)
{
using (var Context = new BakingEntities())
{
string sql = $"SELECT * FROM TPalletInfo WHERE VirtualId = {palletVirtualId} UNION ALL SELECT * FROM TPalletInfoHistory WHERE VirtualId = {palletVirtualId}; ";
return Context.Database.SqlQuery<TPalletInfo>(sql).FirstOrDefault();
}
}
public TPalletInfo GetPalletInfoOrHistory(int batteryVirtualId)
{
using (var Context = new BakingEntities())
{
TBatteryInfo batteryInfo = Context.Set<TBatteryInfo>().Where(x => x.Id == batteryVirtualId).FirstOrDefault();
if (null == batteryInfo)
{
LogHelper.Instance.Fatal($"没有找到电芯虚拟ID:{batteryVirtualId}的夹具!");
return null;
}
TPalletInfo palletInfo = Context.Set<TPalletInfo>().Where(x => x.VirtualId == batteryInfo.PalletVirtualId).FirstOrDefault();
if (palletInfo == null)
{
TPalletInfoHistory palletInfoHistory = Context.Set<TPalletInfoHistory>().Where(x => x.VirtualId == batteryInfo.PalletVirtualId).FirstOrDefault();
if (palletInfoHistory != null)
{
palletInfo = new TPalletInfo
{
VirtualId = palletInfoHistory.VirtualId,
Id = palletInfoHistory.Id,
PalletCode = palletInfoHistory.PalletCode,
PalletStatus = palletInfoHistory.PalletStatus,
BakingPosition = palletInfoHistory.BakingPosition,
LoadingPosition = palletInfoHistory.LoadingPosition,
UnLoadingPosition = palletInfoHistory.UnLoadingPosition,
BatteryQty = palletInfoHistory.BatteryQty,
BakingCount = palletInfoHistory.BakingCount,
LoadingBegingTime = palletInfoHistory.LoadingBegingTime,
LoadingOverTime = palletInfoHistory.LoadingOverTime,
InStoveTime = palletInfoHistory.InStoveTime,
BakingBeginTime = palletInfoHistory.BakingBeginTime,
BakingOverTime = palletInfoHistory.BakingOverTime,
OutStoveTime = palletInfoHistory.OutStoveTime,
UnLoadingBegingTime = palletInfoHistory.UnLoadingBegingTime,
UnLoadingOverTime = palletInfoHistory.UnLoadingOverTime,
JobNum = palletInfoHistory.JobNum,
ScanTime = palletInfoHistory.ScanTime,
CreateTime = palletInfoHistory.CreateTime,
LastFlag = palletInfoHistory.LastFlag,
WaterValue = palletInfoHistory.WaterValue,
UnLoadingCoolTemp = palletInfoHistory.UnLoadingCoolTemp
};
}
}
return palletInfo;
}
}
public int UpdateVirtualId(int VirtualId, string palletCode = "")
{
using (var Context = new BakingEntities())
{
var palletOld = Context.Set<TPalletInfo>().Where(x => x.PalletCode == palletCode).ToList().FirstOrDefault(); //当前夹具
var palletNew = Context.Set<TPalletInfo>().Where(x => x.VirtualId == VirtualId).ToList().FirstOrDefault(); //将要绑定的夹具
if (palletNew != null)
{
if (palletOld.VirtualId == palletNew.VirtualId)
{
return 0;
}
//表示这个虚拟码绑定过托盘,将之前所绑定的信息转移到当前托盘
palletOld.VirtualId = palletNew.VirtualId;
palletOld.BakingBeginTime = palletNew.BakingBeginTime;
palletOld.BakingOverTime = palletNew.BakingOverTime;
palletOld.BakingPosition = palletNew.BakingPosition;
palletOld.BatteryQty = palletNew.BatteryQty;
palletOld.JobNum = palletNew.JobNum;
palletOld.LastFlag = palletNew.LastFlag;
palletOld.LoadingBegingTime = palletNew.LoadingBegingTime;
palletOld.LoadingOverTime = palletNew.LoadingOverTime;
palletOld.LoadingPosition = palletNew.LoadingPosition;
palletOld.PalletStatus = palletNew.PalletStatus;
palletOld.ScanTime = palletNew.ScanTime;
palletOld.WaterValue = palletNew.WaterValue;
palletNew.VirtualId = 0;
palletNew.BatteryQty = 0;
palletNew.JobNum = null;
palletNew.LastFlag = false;
palletNew.PalletStatus = (int)EPalletStatus.BlankOver;
palletNew.ScanTime = null;
palletNew.WaterValue = "";
}
else
{
//没绑定的就将电芯信息绑定
palletOld.VirtualId = VirtualId;
}
return Context.SaveChanges();
}
}
public TPalletInfo GetPalletInfo(int palletId)
{
using (var Context = new BakingEntities())
{
return Context.Set<TPalletInfo>().Where(x => x.Id == palletId).FirstOrDefault();
}
}
public TPalletInfo GetPalletInfoByVirtualId(int virtualid)
{
using (var Context = new BakingEntities())
{
return Context.Set<TPalletInfo>().Where(x => x.VirtualId == virtualid).FirstOrDefault();
}
}
public bool SetUnBinding(int palletId)
{
using (var Context = new BakingEntities())
{
var pallet = Context.Set<TPalletInfo>().Where(x => x.Id == palletId).FirstOrDefault();
if (null == pallet)
{
return false;
}
pallet.VirtualId = 0;
pallet.BakingPosition = 0;
pallet.LoadingPosition = 0;
pallet.UnLoadingPosition = 0;
pallet.BatteryQty = 0;
pallet.BakingCount = 0;
pallet.LastFlag = false;
pallet.LoadingBegingTime = null;
pallet.LoadingOverTime = null;
pallet.InStoveTime = null;
pallet.BakingBeginTime = null;
pallet.BakingOverTime = null;
pallet.OutStoveTime = null;
pallet.UnLoadingBegingTime = null;
pallet.UnLoadingOverTime = null;
pallet.WaterValue = null;
pallet.JobNum = "";
return Context.SaveChanges() > 0 ? true : false;
}
}
public int UpdateOutStoveTime(int id)
{
using (var Context = new BakingEntities())
{
int[] status = new int[] { (int)EPalletStatus.BakeOver, (int)EPalletStatus.WaitTest, (int)EPalletStatus.TestOK }; //烘烤后出炉才要记录时间
var pallet = Context.Set<TPalletInfo>().Where(x => x.Id == id && status.Contains(x.PalletStatus)).FirstOrDefault();
if (pallet == null)
{
return 0;
}
pallet.OutStoveTime = DateTime.Now;
Context.Entry(pallet).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
public int UpdateNowJobNum(int? virtualid)
{
using (var Context = new BakingEntities())
{
TProductionInformation productionInformation = Context.Set<TProductionInformation>().Where(x => x.CurrentProduct == true).FirstOrDefault();
var pallet = Context.Set<TPalletInfo>().Where(x => x.VirtualId == virtualid).FirstOrDefault();
if (pallet == null)
{
LogHelper.Instance.Error("修改托盘工单失败!");
return 0;
}
pallet.JobNum = productionInformation.JobNum;
Context.Entry(pallet).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
public int ModifyBatteryQty(int palletId, int num = 1)
{
using (var Context = new BakingEntities())
{
var pallet = Context.Set<TPalletInfo>().Where(x => x.Id == palletId).FirstOrDefault();
if (pallet == null)
{
LogHelper.Instance.Error($"托盘托盘条码:{pallet.BatteryQty},修改夹具中的电芯数据失败!");
return 0;
}
if (pallet.BatteryQty <= 0 && num < 0)
{
LogHelper.Instance.Error($"托盘条码:{pallet.BatteryQty}中的电芯数据失败,夹具中的电芯数为0", true);
return 0;
}
pallet.BatteryQty += num;
Context.Entry(pallet).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
/// <summary>
/// 开始烘烤时
/// </summary>
/// <param name="palletId"></param>
/// <param name="stationDatailId"></param>
/// <returns></returns>
public int UpdateStartBakingInfo(List<ExCavityInfoModel> cavitys)
{
List<int> palletIds = cavitys.Select(x => x.PalletId).ToList(); //修改夹具状态
palletIds.RemoveAll(x => x == 0);
using (var Context = new BakingEntities())
{
List<TPalletInfo> pallets = Context.Set<TPalletInfo>().Where(x => palletIds.Contains(x.Id)).ToList();//.ForEach(x => x.PalletStatus = status);
pallets.ForEach(p =>
{
if (1 == p.Id) //防呆 不修改新夹具状态
{
LogHelper.Instance.GetCurrentClassError($"错误修改新夹具状态:{(int)EPalletStatus.Bake}");
}
else
{
p.PalletStatus = (int)EPalletStatus.Bake;
++p.BakingCount;
++p.TotalBakingCount;
p.BakingBeginTime = DateTime.Now;
p.BakingOverTime = null;
p.OutStoveTime = null;
p.UnLoadingBegingTime = null;
p.UnLoadingOverTime = null;
p.BakingPosition = cavitys.Where(x=>x.PalletId == p.Id).FirstOrDefault().Id;
}
});
//Context.Entry(pallets).State = EntityState.Modified; //会报错
return Context.SaveChanges();
}
}
public int UpdateBakingPos(string palletCode, int cavityId)
{
using (var Context = new BakingEntities())
{
TPalletInfo palletInfo = Context.Set<TPalletInfo>().Where(x => x.PalletCode == palletCode).FirstOrDefault();
if (null == palletInfo)
{
LogHelper.Instance.Error($"修改夹具的烘烤位置失败!夹具号:{palletCode},位置:{cavityId}");
return 0;
}
palletInfo.BakingPosition = cavityId;
Context.Entry(palletInfo).State = EntityState.Modified;
return Context.SaveChanges();
}
}
public int UpdateBakingOverTime(int[] palletIds)
{
int status = 0;
using (var Context = new BakingEntities())
{
List<TPalletInfo> pallets = Context.Set<TPalletInfo>().Where(x => palletIds.Contains(x.Id)).ToList(); //托盘Id不能为0
TPalletInfo pallet = pallets.Where(x => !string.IsNullOrEmpty(x.JobNum)).FirstOrDefault(); //去掉有夹具,但没有电芯
if (null == pallet)
{
LogHelper.Instance.Error($"烘烤完成后,查找工单失败!{string.Join(",", palletIds)}");
return 0;
}
pallets.ForEach(p =>
{
var proceParamModel = _unityContainer.Resolve<ProductionInformationService>().GetProductionInformation(pallet.JobNum);
if (proceParamModel != null)
{
if (proceParamModel.DummyRule == (int)DummyPlaceRule.EVERY_STOVE_NOT_PLACED_ANY)//每个炉子均不放假电芯
{
//status = (int)EPalletStatus.TestOK;
status = (int)EPalletStatus.BakeOver;
}
else
{
if (_unityContainer.Resolve<BLL.BatteryInfoService>().IsPalletDummy(p.VirtualId))//不带水烘烤结束后直接变为待测水含量
{
status = (int)EPalletStatus.BakeOver;//status只改变一次所以要重新赋值防止不带水的在左边将status改变为待测水含量两个都会是待测水含量
}
else
{
status = (int)EPalletStatus.BakeOver;
//status = (int)EPalletStatus.WaitTest;//这个要理解,如果是带水的夹具,就是烘烤完成,直接搬下料,如果是不带水的,就是待水含量测试,不能去下料,等测试结果
}
}
if (1 == p.Id) //防呆 不修改新夹具状态
{
LogHelper.Instance.GetCurrentClassError("错误修改新夹具状态!");
}
else
{
p.PalletStatus = status;
p.BakingOverTime = DateTime.Now;
}
}
});
return Context.SaveChanges();
}
}
public int UpdatePalletStatus(int[] palletIds, int status)
{
using (var Context = new BakingEntities())
{
List<TPalletInfo> pallets = Context.Set<TPalletInfo>().Where(x => palletIds.Contains(x.Id)).ToList();//.ForEach(x => x.PalletStatus = status);
pallets.ForEach(p =>
{
if (1 == p.Id) //防呆 不修改新夹具状态
{
LogHelper.Instance.GetCurrentClassError($"错误修改新夹具状态:{status}");
}
else
{
p.PalletStatus = status;
}
});
return Context.SaveChanges();
}
}
//先找到这一层,再找自己(这样那怕是在下料也没有关系)
public int UpdateDummyLayerValue(int bakingPosition, int status, string waterValue, int palletId) //下料要解锁烤箱的
{
List<int> result = null;
string palletIds = "";
using (var Context = new BakingEntities())
{
TCavityInfo bakingMachine = Context.Set<TCavityInfo>().Where(m => m.Id == bakingPosition).FirstOrDefault();
if (bakingMachine != null)
{
result = (from m in Context.Set<TCavityInfo>()
join p in Context.Set<TPalletInfo>() on m.PalletId equals p.Id into ms
from p in ms.DefaultIfEmpty()
where m.StationId == bakingMachine.StationId && m.LayerType == bakingMachine.LayerType
&& m.PalletId != 0 && p.PalletStatus == (int)EPalletStatus.WaitTest
select p.Id).ToList();
}
if (null == result || 0 == result.Count())
{
palletIds = palletId.ToString();
}
else
{
result.RemoveAll(x => x == 1); // 把所有 1 一次性清掉
if (1 == palletId)
{
LogHelper.Instance.Fatal("测试水含量中有为1的夹具");
return 0;
}
if (!result.Contains(palletId))
{
result.Add(palletId); //表示夹具不在烤箱里
}
palletIds = string.Join(",", result);
}
string sql = $"UPDATE TPalletInfo set PalletStatus = {status},WaterValue='{waterValue}' WHERE Id IN ({palletIds});";
return Context.Database.ExecuteSqlCommand(sql);
}
}
public int UpdateUnLoadingBegingTime(int id)
{
using (var Context = new BakingEntities())
{
TPalletInfo palletInfo = Context.Set<TPalletInfo>().Where(x => x.Id == id).FirstOrDefault();
if (null == palletInfo)
{
LogHelper.Instance.Debug($"记录下料时间失败");
return 0;
}
LogHelper.Instance.Debug($"记录下料时间成功!托盘ID:{id},虚拟ID:{palletInfo.VirtualId}");
palletInfo.UnLoadingBegingTime = DateTime.Now;
Context.Entry(palletInfo).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
public int UpdateUnLoadingOverTime(int id)
{
using (var Context = new BakingEntities())
{
TPalletInfo palletInfo = Context.Set<TPalletInfo>().Where(x => x.Id == id).FirstOrDefault();
if (null == palletInfo)
{
return 0;
}
palletInfo.UnLoadingOverTime = DateTime.Now;
Context.Entry(palletInfo).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
/// <summary>
/// 解除调度锁时判断这个位置的托盘是否还在机台上并且是待测水含量
/// </summary>
public TCavityInfo GetBakingStationPallet(int bakingStation)
{
using (var Context = new BakingEntities())
{
TPalletInfo palletInfo = Context.Set<TPalletInfo>().Where(x => x.BakingPosition == bakingStation).Where(p => p.PalletStatus == (int)EPalletStatus.WaitTest).FirstOrDefault();
if (null != palletInfo)
{
TCavityInfo stationDetail = Context.Set<TCavityInfo>().Where(x => x.PalletId == palletInfo.Id).FirstOrDefault();
return stationDetail;
}
return null;
}
}
public int SetJobNum(string stationName, string jobNum)
{
using (var Context = new BakingEntities())
{
TPalletInfo palletInfo = (from a in Context.Set<TCavityInfo>()
join b in Context.Set<TPalletInfo>() on a.PalletId equals b.Id
where a.Name == stationName
select b).FirstOrDefault(); //将托盘号绑定到AGV
if (null == palletInfo)
{
LogHelper.Instance.Warn($"设置工单的工站:{stationName}没有夹具, 导致设置失败!");
return 0;
}
palletInfo.JobNum = jobNum;
Context.Entry(palletInfo).State = EntityState.Modified;
return Context.SaveChanges();
}
}
public TPalletInfo GetPalletInfoByStation(string stationName)
{
using (var Context = new BakingEntities())
{
var palletInfo = (from a in Context.Set<TCavityInfo>()
join b in Context.Set<TPalletInfo>() on a.PalletId equals b.Id
where a.Name == stationName
select b).FirstOrDefault(); //将托盘号绑定到AGV
if (null != palletInfo)
{
if (0 == palletInfo.Id) //托盘ID=0也是NULL
{
return null;
}
}
return palletInfo;
}
}
public int UpdatePalletStatus(int palletId, int status)
{
using (var Context = new BakingEntities())
{
var pallet = Context.Set<TPalletInfo>().Where(x => x.Id == palletId).FirstOrDefault();
if (pallet == null
|| 1 == pallet.Id)
{
LogHelper.Instance.Error($"修改夹具状态失败! 夹具ID={pallet.Id}");
return 0;
}
pallet.PalletStatus = status;
Context.Entry(pallet).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
//public List<string> GetPalletCodeWithBindingInfo()
//{
// string sql = $@"SELECT CONCAT(ti.PalletCode,'@',IF(td.Name IS NOT NULL,'已绑定','未绑定'))
// PalletCodeWithBindingInfo
// FROM TPalletInfo ti
// LEFT JOIN TCavityInfo td ON td.PalletId=ti.Id;";
// var table = GetDataTable(sql);
// List<string> palletInfo = new List<string>();
// foreach (DataRow item in table.Rows)
// {
// palletInfo.Add(item[0].ToString());
// }
// return palletInfo;
//}
public int LoadingUpdatePalletStatus(int virtualId, int status, int batteryQty, bool Clealine)
{
using (var Context = new BakingEntities())
{
var palletInfo = Context.Set<TPalletInfo>().Where(x => x.VirtualId == virtualId).FirstOrDefault();
if (null == palletInfo || 1 == palletInfo.Id)
{
LogHelper.Instance.Warn($"上料完成,修改夹具状态失败!夹具ID={palletInfo}");
return 0;
}
palletInfo.BatteryQty = batteryQty;
palletInfo.PalletStatus = status;
palletInfo.LoadingOverTime = DateTime.Now;
palletInfo.LastFlag = Clealine;
Context.Entry(palletInfo).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
public TPalletInfo GetPalletCode(int cavityId)
{
using (var Context = new BakingEntities())
{
return (from s in Context.Set<TCavityInfo>()
join p in Context.Set<TPalletInfo>() on s.PalletId equals p.Id
where s.Id == cavityId
select p).FirstOrDefault();
}
}
public int SetPalletStatus(int type, int number, int status)
{
using (var Context = new BakingEntities())
{
var palletInfo = (from ci in Context.Set<TCavityInfo>()
join s in Context.Set<TStation>() on ci.StationId equals s.Id into cs
from s in cs.DefaultIfEmpty() // 左连接 Scores
join pi in Context.Set<TPalletInfo>() on ci.PalletId equals pi.Id into cp
from pi in cp.DefaultIfEmpty() // 左连接 Parents
where s.Type == type && ci.Column == number
select pi).FirstOrDefault();
//var palletInfo = (from s in Context.Set<TCavityInfo>()
// join p in Context.Set<TPalletInfo>() on s.PalletId equals p.Id
// where s.StationId == stationId && s.Column== number
// select p).FirstOrDefault();
if (null == palletInfo)
{
LogHelper.Instance.Error($"查找夹具失败{type}{number}");
return 0;
}
palletInfo.PalletStatus = status;
Context.Entry(palletInfo).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
//托盘绑定防呆
public int BindingPallet(string palletCode, int status, int stationType, int number)
{
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<int>($"call ProcBindPallet('{palletCode}',{status},{stationType},{number})").FirstOrDefault();
}
}
public int UpdateLast(string palletCode, string lastSting)
{
using (var Context = new BakingEntities())
{
TPalletInfo palletInfo = Context.Set<TPalletInfo>().Where(x => x.PalletCode == palletCode).FirstOrDefault();
if (null == palletInfo)
{
return 0;
}
bool last = false;
if (lastSting == EPalletLast.YesLast.GetDescription())
{
last = true;
}
palletInfo.LastFlag = last;
Context.Entry(palletInfo).State = System.Data.Entity.EntityState.Modified;
return Context.SaveChanges();
}
}
}
}

View File

@@ -0,0 +1,132 @@
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using System.Collections.Generic;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class ProcessParamService : ServiceBase
{
public ProcessParamService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public bool UpdateProcessParam(int paraID, string JSONPara)
{
using (var Context = new BakingEntities())
{
//保存老的,方便追查
string sql = $@"select Parameters from TProcessParameter where Id={paraID} limit 1";
var param = Context.Database.SqlQuery<string>(sql).FirstOrDefault();
_unityContainer.Resolve<LogService>().AddLog("WorkOrderService.AddParaLog:" + param + "->"
+ JSONPara, E_LogType.Operate.ToString());
sql = $@"UPDATE TProcessParameter set Parameters='{JSONPara}' WHERE Id={paraID}";
return Context.Database.ExecuteSqlCommand(sql) > 0 ? true : false; ;
}
}
//所有的配方
public List<TProcessParameter> GetAllFormula()
{
using (var Context = new BakingEntities())
{
var formulaList = Context.Set<TProcessParameter>().Where(x => x.BaseFalg != true).OrderBy(x => x.Id).ToList();
return formulaList;
}
}
public bool UpdateCurrentJobNum(int ID)
{
string sql = $@"call ProcUpdateCurrentJob({ID})";
using (var Context = new BakingEntities())
{
return Context.Database.ExecuteSqlCommand(sql) != 0;
}
}
public List<TProcessParameter> QueryFormulas(string formulaName)
{
using (var Context = new BakingEntities())
{
return Context.Set<TProcessParameter>().Where(x => x.ProcessParamName == formulaName).ToList();
}
}
public TProcessParameter QueryFormulaById(int formulaId, string parametersJson)
{
using (var Context = new BakingEntities())
{
var query = Context.Set<TProcessParameter>().Where(x => x.Id == formulaId && x.Parameters == parametersJson).FirstOrDefault();
return query;
}
}
public TProcessParameter GetReProcessParam(string jobNum)
{
using (var Context = new BakingEntities())
{
return (from proInfo in Context.Set<TProductionInformation>()
where proInfo.JobNum == jobNum
join param in Context.Set<TProcessParameter>() on proInfo.ReProcessParamId equals param.Id
select param).FirstOrDefault();
}
}
public string GetProcessParam(int id)
{
string sql = $@"SELECT Parameters FROM TProcessParameter WHERE Id={id}";
using (var Context = new BakingEntities())
{
return Context.Database.SqlQuery<string>(sql).FirstOrDefault();
}
}
public TProcessParameter Get(int id)
{
using (var Context = new BakingEntities())
{
return Context.Set<TProcessParameter>().Where(x => x.Id == id).FirstOrDefault();
}
}
public bool CreateNewProcessParam(string processParaName)
{
using (var Context = new BakingEntities())
{
string sql = $@"select count(*) from TProcessParameter where ProcessParamName='{processParaName}'";
if (0 != Context.Database.SqlQuery<int>(sql).First())
{
return false;
}
sql = $@"INSERT INTO TProcessParameter(ProcessParamName,Parameters,BaseFalg,CreateTime)
SELECT '{processParaName}' ProcessName,tp.Parameters,0,now() FROM TProcessParameter tp
WHERE tp.BaseFalg=1;";
return Context.Database.ExecuteSqlCommand(sql) != 0;
}
}
public List<TProcessParameter> QueryFormula(string formulaName)
{
using (var Context = new BakingEntities())
{
var queryList = Context.Set<TProcessParameter>().Where(x => x.ProcessParamName == formulaName).ToList();
return queryList;
}
}
public TProcessParameter GetProcessParam(string jobNum)
{
using (var Context = new BakingEntities())
{
return (from proInfo in Context.Set<TProductionInformation>()
where proInfo.JobNum == jobNum
join param in Context.Set<TProcessParameter>() on proInfo.ProcessParamId equals param.Id
select param).FirstOrDefault();
}
}
}
}

View File

@@ -0,0 +1,137 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class ProductionInformationService : ServiceBase
{
public ProductionInformationService(IUnityContainer unityContainer) : base(unityContainer)
{
}
//所有的工单,匹配对应的配方
public List<WorkOrderFormulaEntity> GetAllCellWorkOrderFormula()
{
using (var Context = new BakingEntities())
{
var workOrderFormulaList = Context.Set<TProductionInformation>().Join(Context.Set<TProcessParameter>(),
c => c.ProcessParamId,
p => p.Id,
(c, p) => new WorkOrderFormulaEntity
{
Id = c.Id,
JobNum = c.JobNum,
ProductionDatetime = c.ProductionDatetime,
CurrentProduct = c.CurrentProduct,
ProcessParamId = c.ProcessParamId,
DummyRule = c.DummyRule,
ReProcessParamId = c.ReProcessParamId,
Parameters = p.Parameters,
BaseFlag = p.BaseFalg,
ProcessParamName = p.ProcessParamName
}).OrderBy(x => x.Id).ThenByDescending(x => x.ProductionDatetime).ToList();
return workOrderFormulaList;
}
}
public List<TProductionInformation> GeAll()
{
using (var Context = new BakingEntities())
{
return Context.Set<TProductionInformation>().ToList();
}
}
public TProductionInformation GetCurrentProductInfo()
{
using (var Context = new BakingEntities())
{
return (from p in Context.Set<TProductionInformation>()
where p.CurrentProduct == true
select p).FirstOrDefault();
}
}
public TProductionInformation QueryWorkOrderById(int Id)
{
using (var Context = new BakingEntities())
{
var query = Context.Set<TProductionInformation>().FirstOrDefault(p => p.Id == Id);
return query;
}
}
public TProductionInformation GetProductionInformation(string jobNum)
{
using (var Context = new BakingEntities())
{
return Context.Set<TProductionInformation>().Where(x => x.JobNum == jobNum).FirstOrDefault();
}
}
//public TProductionInformation GetJobNum()
//{
// using (var Context = new BakingEntities())
// {
// TProductionInformation productionInformation = Context.Set<TProductionInformation>().Where(x => x.CurrentProduct == true).FirstOrDefault();
// return productionInformation;
// }
//}
public List<WorkOrderFormulaEntity> QueryWorkOrder(string workOrderName)
{
using (var Context = new BakingEntities())
{
var queryList = Context.Set<TProductionInformation>().Join(Context.Set<TProcessParameter>(),
c => c.ProcessParamId,
p => p.Id,
(c, p) => new WorkOrderFormulaEntity
{
Id = c.Id,
JobNum = c.JobNum,
ProductionDatetime = c.ProductionDatetime,
CurrentProduct = c.CurrentProduct,
ReProcessParamId = c.ReProcessParamId,
DummyRule = c.DummyRule,
ProcessParamId = c.ProcessParamId,
Parameters = p.Parameters,
BaseFlag = p.BaseFalg,
ProcessParamName = p.ProcessParamName
}).Where(x => x.JobNum == workOrderName).ToList();
return queryList;
}
}
public int Delete(int ParameterId)
{
using (var Context = new BakingEntities())
{
var q = (from ts in Context.Set<TProductionInformation>()
where ts.ProcessParamId == ParameterId
select ts).FirstOrDefault();
if (q != null)
{
Context.Set<TProductionInformation>().Remove(q);
return Context.SaveChanges();
}
return 0;
}
}
public bool GetIsInUse(int ID)
{
using (var Context = new BakingEntities())
{
TProductionInformation productionInformation = Context.Set<TProductionInformation>().Where(x => x.Id == ID).FirstOrDefault();
if (productionInformation.CurrentProduct == true)
{
return true;
}
return false;
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Cowain.Bake.BLL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cowain.Bake.BLL")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("362f196c-7c59-4dfb-9a3e-85f880791312")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,70 @@
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class RgvActionService : ServiceBase
{
private readonly List<TRgvAction> _actions;
public RgvActionService(IUnityContainer unityContainer) : base(unityContainer)
{
using (var Context = new BakingEntities())
{
_actions = Context.Set<TRgvAction>().ToList();
}
}
public List<TRgvAction> GetAll()
{
return _actions;
}
public int GetNext(int cmd)
{
var action = _actions.Find(x => x.StepId == cmd);
var next = _actions.Find(x => x.Id == action.Id + 1);
if (null == next)
{
return 0;
}
return next.StepId;
}
public int GetPrevious(int cmd)
{
var action = _actions.Find(x => x.StepId == cmd);
var next = _actions.Find(x => x.Id == action.Id - 1);
if (null == next)
{
return (int)ETaskStep.MoveFrom;
}
return next.StepId;
}
public TRgvAction GetAction(int cmd)
{
var action = _actions.Find(x => x.StepId == cmd);
if (null == action)
{
return _actions.Find(x => x.Id == 1);
}
return action;
}
public List<TRgvAction> GetPreviousActions(int cmd)
{
var firstAction = _actions.Find(x => x.StepId == (int)ETaskStep.Unexecuted);
var cmdAction = _actions.Find(x => x.StepId == cmd);
return _actions.Where(x => x.Id <= cmdAction.Id && x.Id >= firstAction.Id).OrderBy(x => x.Id).ToList(); //= cmdAction.Id
}
public List<TRgvAction> GetNextActions(int cmd)
{
return _actions.Where(x => x.StepId >= cmd).OrderBy(x=>x.Id).ToList();
}
}
}

View File

@@ -0,0 +1,22 @@
using Unity;
namespace Cowain.Bake.BLL
{
public class RoleInfoService : ServiceBase
{
public RoleInfoService(IUnityContainer unityContainer) : base(unityContainer)
{
}
//public int Update(TRoleInfo model)
//{
// using (var Context = new BakingEntities())
// {
// Context.Set<TRoleInfo>().Attach(model);//将数据附加到上下文支持实体修改和新实体重置为UnChanged
// Context.Entry<TRoleInfo>(model).State = EntityState.Modified;
// return Context.SaveChanges();
// }
//}
}
}

View File

@@ -0,0 +1,186 @@
using Cowain.Bake.Model;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using Unity;
namespace Cowain.Bake.BLL
{
public class ServiceBase
{
public readonly object _lockObj = new object();
protected IUnityContainer _unityContainer;
public ServiceBase(IUnityContainer unityContainer)
{
//using (var context = new DbContext()) // 创建DbContext
//第二层DbConnection由ADO.NET连接池管理;password=123456;Pooling=true;Max Pool Size=100;
//var data = context.Products.ToList(); // 触发连接获取
_unityContainer = unityContainer;
}
//public int Commit()
//{
// return this.Context.SaveChanges();
//}
public int Delete<T>(int Id) where T : class
{
using (var Context = new BakingEntities())
{
T t = Context.Set<T>().Find(Id);//也可以附加
if (t == null) throw new Exception("t is null");
Context.Set<T>().Remove(t);
return Context.SaveChanges();
}
}
public int Delete<T>(T t) where T : class
{
using (var Context = new BakingEntities())
{
if (t == null) throw new Exception("t is null");
Context.Set<T>().Attach(t);
Context.Set<T>().Remove(t);
return Context.SaveChanges();
}
}
public void Delete<T>(IEnumerable<T> tList) where T : class
{
using (var Context = new BakingEntities())
{
foreach (var t in tList)
{
Context.Set<T>().Attach(t);
}
Context.Set<T>().RemoveRange(tList);
Context.SaveChanges();
}
}
public List<T> Find<T>() where T : class
{
using (var Context = new BakingEntities())
{
return Context.Set<T>().ToList();
}
}
public T Find<T>(int id) where T : class
{
using (var Context = new BakingEntities())
{
return Context.Set<T>().Find(id);
}
}
public int Insert<T>(T t) where T : class
{
using (var Context = new BakingEntities())
{
Context.Set<T>().Add(t);
return Context.SaveChanges();
}
}
public int Insert<T>(IEnumerable<T> tList) where T : class
{
using (var Context = new BakingEntities())
{
Context.Set<T>().AddRange(tList);
return Context.SaveChanges();
}
}
public IQueryable<T> Query<T>(Expression<Func<T, bool>> funcWhere) where T : class
{
using (var Context = new BakingEntities())
{
return Context.Set<T>().Where<T>(funcWhere);
}
}
public int Update<T>(T t) where T : class
{
if (t == null) throw new Exception("t is null");
using (var Context = new BakingEntities())
{
Context.Set<T>().Attach(t);//将数据附加到上下文支持实体修改和新实体重置为UnChanged
Context.Entry<T>(t).State = EntityState.Modified;
return Context.SaveChanges();
}
}
public void Update<T>(IEnumerable<T> tList) where T : class
{
using (var Context = new BakingEntities())
{
foreach (var t in tList)
{
Context.Set<T>().Attach(t);
Context.Entry<T>(t).State = EntityState.Modified;
}
Context.SaveChanges();
}
}
public int UpdateListParas<T>(IEnumerable<T> tList) where T : class
{
using (var Context = new BakingEntities())
{
foreach (var t in tList)
{
Context.Set<T>().Attach(t);
Context.Entry<T>(t).State = EntityState.Modified;
}
return Context.SaveChanges();
}
}
public virtual void Dispose()
{
//if (this.Context != null)
//{
// this.Context.Dispose();
//}
}
public DataTable GetDataTable(string sql)
{
lock(_lockObj)
{
MySqlConnection conn = new MySqlConnection();
using (var Context = new BakingEntities())
{
conn.ConnectionString = Context.Database.Connection.ConnectionString;
}
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
DataTable table = new DataTable();
adapter.Fill(table);
conn.Close();//连接需要关闭
conn.Dispose();
return table;
}
}
}
}

View File

@@ -0,0 +1,103 @@
using Cowain.Bake.Model.Models;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Unity;
using System.Data.Entity;
namespace Cowain.Bake.BLL
{
public class StationService : ServiceBase
{
private readonly List<TStation> _station;
public StationService(IUnityContainer unityContainer) : base(unityContainer)
{
using (var Context = new BakingEntities())
{
_station = Context.Set<TStation>().OrderBy(x => x.Id).ToList();
}
}
/// <summary>
/// 获取工位列表信息
/// </summary>
/// <returns></returns>
public List<TStation> GetAll()
{
return _station;
}
public List<string> GetInfo(int deviceId)
{
var stations = _station.Where(m => m.DeviceId == deviceId).ToList();
return stations.Select(x => x.Id.ToString()).ToList();
}
public List<TStation> GetStaions(int deviceId)
{
return _station.Where(m => m.DeviceId == deviceId).ToList();
}
public List<TStation> GetStationsByType(int type)
{
return _station.Where(x => x.Type == type).OrderBy(x => x.Id).ToList();
}
public TStation GetStationByCavityId(int cavityId)
{
using (var Context = new BakingEntities())
{
return (from s in Context.Set<TStation>()
join c in Context.Set<TCavityInfo>() on s.Id equals c.StationId
where c.Id == cavityId
select s).FirstOrDefault();
}
}
public void UpdateEnableStatus(TStation machineModel)
{
using (var Context = new BakingEntities())
{
var pi = (from ts in Context.Set<TStation>()
where ts.Id == machineModel.Id
select ts).FirstOrDefault();
pi.Enable = machineModel.Enable;
Context.SaveChanges();
}
}
/// <summary>
/// 获取工位明细列表信息
/// </summary>
/// <returns></returns>
//public List<TCavityInfo> GetAllStationDetailList()
//{
// using (var Context = new BakingEntities())
// {
// var dataList = Context.Set<TCavityInfo>().OrderBy(x => x.StationId).ThenBy(s => s.Layer).ToList();
// return dataList;
// }
//}
public TStation GetStation(int stationId)
{
return _station.Where(p => p.Id == stationId).FirstOrDefault();
}
/// <summary>
/// 修改工位明细信息
/// </summary>
/// <param name="stationDetail"></param>
/// <returns></returns>
//public int UpdateStationDetailInfo(TCavityInfo stationDetail)
//{
// using (var Context = new BakingEntities())
// {
// Context.Set<TCavityInfo>().Attach(stationDetail);//将数据附加到上下文支持实体修改和新实体重置为UnChanged
// Context.Entry<TCavityInfo>(stationDetail).State = EntityState.Modified;
// return Context.SaveChanges();
// }
//}
}
}

View File

@@ -0,0 +1,73 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class StoveSctualPatrolService : ServiceBase
{
public StoveSctualPatrolService(IUnityContainer unityContainer) : base(unityContainer)
{
}
//批量插入数据太慢了
public int Insert(int palletVirtualId, int cavityId, string palletCode, float vacuum, string temperature)
{
TStoveSctualPatrol model = new TStoveSctualPatrol()
{
PalletVirtualId = palletVirtualId,
CavityId = cavityId,
PalletCode = palletCode,
Vacuum = vacuum,
Temperature = temperature
};
using (var Context = new BakingEntities())
{
Context.Set<TStoveSctualPatrol>().Add(model);
return Context.SaveChanges();
}
}
public int Insert(List<TStoveSctualPatrol> tempDatas)
{
if (0 == tempDatas.Count)
{
return 0;
}
using (var Context = new BakingEntities())
{
Context.Set<TStoveSctualPatrol>().AddRange(tempDatas);
return Context.SaveChanges();
}
}
//如果耗时不行,就用视图
public float GetStoveMaxTemp(int palletVirtualId)
{
using (var Context = new BakingEntities())
{
try
{
return Context.Database.SqlQuery<float>($"call GetStoveMaxTemp({palletVirtualId})").FirstOrDefault(); //20250408 有时会崩
}
catch(Exception ex)
{
LogHelper.Instance.Fatal($"GetStoveMaxTemp:{ex.Message},{palletVirtualId}");
}
return 90.6f;
}
}
}
}

View File

@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using Cowain.Bake.Model;
using Cowain.Bake.Common.Enums;
using System.Collections.Concurrent;
namespace Cowain.Bake.BLL
{
public class SysSetupService : ServiceBase
{
public ConcurrentDictionary<string, string> ParaDic = new ConcurrentDictionary<string, string>();
public SysSetupService(IUnityContainer unityContainer) : base(unityContainer)
{
GetAllPara();
}
public List<TSysSetup> GetAll()
{
using (var Context = new BakingEntities())
{
return Context.Set<TSysSetup>().OrderBy(item => item.Id).ToList();
}
}
public void GetAllPara()
{
ParaDic.Clear();
using (var Context = new BakingEntities())
{
var list = Context.Set<TSysSetup>().OrderBy(item => item.Id).ToList();
foreach (var item in list)
{
ParaDic.TryAdd(item.ParamCode, item.ParamValue);
}
}
}
public string GetValueByParaID(string paraID)
{
return ParaDic[paraID];
}
public string GetValueByID(long ID)
{
using (var Context = new BakingEntities())
{
var pi = (from ts in Context.Set<TSysSetup>()
where ts.Id == ID
select ts).FirstOrDefault();
return pi.ParamValue;
}
}
public bool UpdateValue(long ID, string value)
{
using (var Context = new BakingEntities())
{
var pi = (from ts in Context.Set<TSysSetup>()
where ts.Id == ID
select ts).FirstOrDefault();
pi.ParamValue = value;
var result = Context.SaveChanges() != 0;
GetAllPara();
return result;
}
}
public bool UpdateValue(string paramCode, string value)
{
using (var Context = new BakingEntities())
{
var pi = (from ts in Context.Set<TSysSetup>()
where ts.ParamCode == paramCode
select ts).FirstOrDefault();
pi.ParamValue = value;
var result = Context.SaveChanges() != 0;
GetAllPara();
return result;
}
}
public List<TSysSetup> GetShowParam()
{
using (var Context = new BakingEntities())
{
return Context.Set<TSysSetup>().Where(x=>x.Type == (int)EParamType.Sys).OrderBy(item => item.Id).ToList();
}
}
}
}

View File

@@ -0,0 +1,130 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class TagListService : ServiceBase
{
public TagListService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TTagList> GetAllParams()
{
using (var Context = new BakingEntities())
{
return Context.Set<TTagList>().OrderBy(item => item.TagType).ThenBy(p => p.Id).ToList();
}
}
public List<TTagList> GetParamsByParamDesc(string parms)
{
using (var Context = new BakingEntities())
{
return Context.Set<TTagList>().Where(p => p.VarDesc.Contains(parms)).ToList();
}
}
public TTagList GetParamsByVarName(string varName)
{
using (var Context = new BakingEntities())
{
return Context.Set<TTagList>().FirstOrDefault(p => p.VarName == varName);
}
}
public TTagList GetParamsById(long Id)
{
using (var Context = new BakingEntities())
{
return Context.Set<TTagList>().FirstOrDefault(p => p.Id == Id);
}
}
public int InsertParams(TTagList model)
{
using (var Context = new BakingEntities())
{
Context.Set<TTagList>().Add(model);
return Context.SaveChanges();
}
}
public int DeleteParams(int id)
{
using (var Context = new BakingEntities())
{
var model = Context.Set<TTagList>().Find(id);
if (model == null)
{
LogHelper.Instance.Info($"查找电池ID:{id}失败");
throw new Exception("t is null");
}
Context.Set<TTagList>().Remove(model);
return Context.SaveChanges();
}
}
public int UpdateParams(TTagList model)
{
using (var Context = new BakingEntities())
{
Context.Set<TTagList>().Attach(model);//将数据附加到上下文支持实体修改和新实体重置为UnChanged
Context.Entry<TTagList>(model).State = EntityState.Modified;
return Context.SaveChanges();
}
}
public List<TagEntity> GetTagList(int devId)
{
List<TTagList> tagList = null;
List<string> arrayId = _unityContainer.Resolve<StationService>().GetInfo(devId); //2 //var aa = arrayId.Intersect(bb); //求交集部分
using (var Context = new BakingEntities())
{
if (arrayId.Count() == 2)
{
tagList = Context.Set<TTagList>().ToList().
Where(m => m.StationIds.Split(',').Any(x => x == arrayId[0] || x == arrayId[1])).ToList();
}
else if (arrayId.Count() == 3)
{
tagList = Context.Set<TTagList>().ToList().
Where(m => m.StationIds.Split(',').Any(x => x == arrayId[0] || x == arrayId[1] || x == arrayId[2])).ToList();
}
else
{
tagList = Context.Set<TTagList>().ToList().
Where(m => m.StationIds.Split(',').Any(x => x == arrayId[0])).ToList();
}
List<TagEntity> list = new List<TagEntity>();
tagList.ForEach((x) => list.Add(new TagEntity()
{
Id = x.Id,
StationId = int.Parse(string.Join(",", x.StationIds.Split(',').Intersect(arrayId))),
StationIds = x.StationIds,
Address = x.Address,
VarName = x.VarName,
ParamName = x.ParamName,
VarType = x.VarType,
ArrayLen = x.ArrayLen,
Number = x.Number,
OperType = x.OperType,
VarDesc = x.VarDesc,
Json = x.Json,
TirgEnable = x.TirgEnable,
TrigJson = x.TrigJson,
TagType = x.TagType,
}));
return list;
}
}
}
}

View File

@@ -0,0 +1,265 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class TaskRecordService : ServiceBase
{
public TaskRecordService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TTaskRecord> GetAllTaskRun()
{
using (var Context = new BakingEntities())
{
var taskRunList = Context.Set<TTaskRecord>().OrderBy(x => x.Status).ThenByDescending(x => x.BuildTime).Take(1000).ToList();
if (taskRunList == null)
{
return null;
}
return taskRunList;
}
}
public List<TTaskRecord> Query(DateTime startTime, DateTime endTime)
{
using (var Context = new BakingEntities())
{
return Context.Set<TTaskRecord>().Where(x => x.BuildTime >= startTime && x.BuildTime <= endTime)
.OrderByDescending(x=>x.Id).ToList();
}
}
public int UpdateFinishStepId(int taskId)
{
using (var Context = new BakingEntities())
{
var task = Context.Set<TTaskRecord>().Where(x => x.Id == taskId).ToList().FirstOrDefault();
task.StepId = (int)ETaskStep.Finish;
return Context.SaveChanges();
}
}
public int DeleteNotFinishTask()
{
using (var Context = new BakingEntities())
{
var trq = (from a in Context.Set<TTaskRecord>()
where a.Status != (int)ETaskStatus.ExecutionCompleted
select a);
if (trq == null)
{
return 0;
}
foreach (var item in trq)
{
Context.Set<TTaskRecord>().Remove(item);
}
return Context.SaveChanges();
}
}
public int DeleteTask(long id)
{
using (var Context = new BakingEntities())
{
var trq = (from a in Context.Set<TTaskRecord>()
where a.Id == id
select a).FirstOrDefault();
if (trq == null)
{
return 0;
}
Context.Set<TTaskRecord>().Remove(trq);
return Context.SaveChanges();
}
}
public int DeleteUnexecuteTask()
{
using (var Context = new BakingEntities())
{
var trq = (from a in Context.Set<TTaskRecord>()
where a.Status != (int)ETaskStatus.ExecutionCompleted
select a).ToList();
if (trq == null)
{
return 0;
}
Context.Set<TTaskRecord>().RemoveRange(trq);
return Context.SaveChanges();
}
}
//是否有未执行或执行中的任务PLC有任务要执行
public TTaskRecord UnexecuteTask()
{
using (var Context = new BakingEntities())
{
return Context.Set<TTaskRecord>().Where(x => x.Status != (int)ETaskStatus.ExecutionCompleted).FirstOrDefault();
}
}
//public TaskEntity GetManualTask()
//{
// using (var Context = new BakingEntities())
// {
// var trq = (from a in Context.Set<TTaskRecord>()
// where a.Status != (int)ETaskStep.ExecutionCompleted
// orderby a.Id descending
// select a).FirstOrDefault();
// return null;
// }
//}
public int UpdateTask()
{
using (var Context = new BakingEntities())
{
LogHelper.Instance.Debug("修改任务开始");
return Context.Database.ExecuteSqlCommand("call ProcUpdateTask()");
}
}
public int BindPalletToRobot()
{
using (var Context = new BakingEntities())
{
return Context.Database.ExecuteSqlCommand("call ProcBindPalletToRobot()");
}
}
public (bool, int) IsPullInBaker()
{
using (var Context = new BakingEntities())
{
var record = (from taskRecord in Context.Set<TTaskRecord>()
join taskType in Context.Set<TTaskType>() on taskRecord.TaskTypeId equals taskType.Id
orderby taskRecord.Id descending
//where taskType.Id == 1 //上料满夹具->烤箱
select new
{
TypeId = taskType.Id,
PalletId = taskRecord.PalletId,
}).FirstOrDefault();
if (null == record)
{
return (false, 0);
}
if (1 != record.TypeId) //where taskType.Id == 1 //上料满夹具->烤箱
{
return (false, 0);
}
return (true, record.PalletId);
}
}
public TaskEntity GetTask()
{
try
{
using (var Context = new BakingEntities())
{
TaskEntity result = Context.Database.SqlQuery<TaskEntity>("CALL ProcGetTask(1);").FirstOrDefault(); //显示FirstOrDefault崩溃
if (null == result)
{
return null;
}
result.Status = (int)ETaskStatus.UnExecute;
result.StepId = (int)ETaskStep.Unexecuted;
result.BuildTime = DateTime.Now;
TTaskRecord taskRecord = new TTaskRecord()
{
PalletId = result.PalletId,
TaskTypeId = result.TaskTypeId,
Source = result.Source,
Target = result.Target,
Status = result.Status,
BuildTime = result.BuildTime,
StepId = result.StepId,
};
Context.Set<TTaskRecord>().Add(taskRecord);
if (0 >= Context.SaveChanges())
{
LogHelper.Instance.Error("任务插入数据库失败,{num}!");
return null;
}
result.Id = taskRecord.Id;
return result;
}
}
catch(Exception ex)
{
LogHelper.Instance.Fatal($"获取任务信息时崩溃,{ex.Message},{ex.StackTrace}");
}
return null;
}
public bool ModifyTaskStatus(ETaskStatus status)
{
using (var Context = new BakingEntities())
{
var task = (from a in Context.Set<TTaskRecord>()
where a.Status != (int)ETaskStatus.ExecutionCompleted
orderby a.Id descending //只修改ID最大的
select a).FirstOrDefault();
if (task == null)
{
LogHelper.Instance.Error($"没有找到任务,所以修改任务状态失败!状态为:{status}");
return false;
}
//修改状态时间
if (ETaskStatus.ExecutionCompleted == status)
{
task.EndTime = DateTime.Now;
}
else if (ETaskStatus.Executing == status)
{
task.StartTime = DateTime.Now;
}
task.Status = (int)status;
return Context.SaveChanges() > 0 ? true : false;
}
}
//public TaskStatusEntity GetTaskShowInfo()
//{
// // sql = $@"SELECT t1.id, t1.Source,t1.Target,ti.PalletCode
// //,CASE t1.Status WHEN 0 THEN '未执行' WHEN 1 THEN '执行中' WHEN 2 THEN '执行完成' ELSE '未执行' END 'Status'
// // FROM TTaskRecord t1
// //LEFT JOIN TPalletInfo ti ON t1.PalletId=ti.Id
// //ORDER BY t1.Id DESC LIMIT 1";
// return (from t in Context.Set<TTaskRecord>()
// join p in Context.Set<TPalletInfo>() on t.PalletId equals p.Id
// orderby t.Id descending
// select new TaskStatusEntity
// {
// Source = t.Source,
// Target = t.Target,
// Status = ((ETaskStep)t.Status).GetDescription(),
// PalletCode = p.PalletCode
// }).FirstOrDefault();
//}
}
}

View File

@@ -0,0 +1,99 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Unity;
namespace Cowain.Bake.BLL
{
public class TaskStepService : ServiceBase
{
public TaskStepService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public int UpdateEndTime(int taskId, ETaskStep taskStep) //int taskId,
{
using (var Context = new BakingEntities())
{
var model = Context.Set<TTaskStep>().Where(x => x.StepId == (int)taskStep && x.TaskRecordId == taskId).FirstOrDefault();
if (model == null)
{
LogHelper.Instance.Warn($"查找步骤失败,任务ID:{taskId},步骤:{taskStep}");
return 0;
}
model.EndTime = DateTime.Now;
return Context.SaveChanges();
}
}
//会修改TTaskRecord的StepId值
public int UpdateStartTime(int taskId, int count, int taskStep)
{
using (var Context = new BakingEntities())
{
var model = Context.Set<TTaskStep>().Where(x => x.StepId == taskStep && x.TaskRecordId == taskId).FirstOrDefault();
if (null == model)
{
LogHelper.Instance.Fatal($"修改步时间出现过为空任务ID:{taskId},步:{taskStep}");
return 0;
}
model.StartTime = DateTime.Now;
model.Count = count;
return Context.SaveChanges();
}
}
public List<TTaskStep> GetTaskStep(int taskRecodeId)
{
using (var Context = new BakingEntities())
{
return Context.Set<TTaskStep>().Where(x => x.TaskRecordId == taskRecodeId && x.Count != null).ToList();
}
}
public List<TTaskStep> GetTaskAllStep(int taskRecodeId)
{
using (var Context = new BakingEntities())
{
return Context.Set<TTaskStep>().Where(x => x.TaskRecordId == taskRecodeId).ToList();
}
}
//public TaskRecordStepModel GetLastStep()
//{
// using (var Context = new BakingEntities())
// {
// return (from tr in Context.Set<TTaskRecord>()
// join ts in Context.Set<TTaskStep>() on tr.Id equals ts.TaskRecordId into cs
// from ts in cs.DefaultIfEmpty() // 左连接 Scores
// where tr.Status != (int)ETaskStatus.ExecutionCompleted && ts.Count != null
// orderby ts.Id descending
// select new TaskRecordStepModel
// {
// Id = tr.Id,
// PalletId = tr.PalletId,
// TaskTypeId = tr.TaskTypeId,
// Source = tr.Source,
// Target = tr.Target,
// Status = tr.Status,
// BuildTime = tr.BuildTime,
// StartTime = tr.StartTime,
// EndTime = tr.EndTime,
// TaskStepId = ts.Id,
// Count = ts.Count,
// StepId = ts.StepId,
// StepStartTime = ts.StartTime,
// StepEndTime = ts.EndTime,
// }).FirstOrDefault();
// }
//}
}
}

View File

@@ -0,0 +1,156 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class TaskTypeService : ServiceBase
{
public TaskTypeService(IUnityContainer unityContainer) : base(unityContainer)
{
}
public List<TTaskType> GetAll()
{
using (var Context = new BakingEntities())
{
return Context.Set<TTaskType>().OrderBy(x => x.Id).ToList();
}
}
public TTaskType GetTaskType()
{
using (var Context = new BakingEntities())
{
var task = (from t in Context.Set<TTaskType>()
join r in Context.Set<TTaskRecord>() on t.Id equals r.TaskTypeId
where r.Status != (int)ETaskStatus.ExecutionCompleted
select t).FirstOrDefault();
return task;
}
}
public bool IsPullInBaker(int taskTypeId)
{
using (var Context = new BakingEntities())
{
var task = (from t in Context.Set<TTaskType>()
where t.Id == taskTypeId
select t).FirstOrDefault();
if (null == task
|| 1 != task.Id) // 1: 上料满夹具->烤箱
{
return false;
}
return true;
}
}
/// <summary>
/// 修改任务
/// </summary>
public int UpdateEnableTask(int id, bool enable)
{
using (var Context = new BakingEntities())
{
var pi = (from ts in Context.Set<TTaskType>()
where ts.Id == id
select ts).FirstOrDefault();
if (pi == null)
{
//任务不存在,无法修改
return 0;
}
pi.Enable = enable;
Context.Entry(pi).State = EntityState.Modified;
return Context.SaveChanges();
}
}
/// <summary>
/// 添加任务
/// </summary>
public int AddTaskConfig(TTaskType task)
{
using (var Context = new BakingEntities())
{
//var q = (from ts in Context.Set<TTaskType>()
// where ts.Priority == task.Priority
// select ts).Count();
//if (q > 0)
//{
// //优先级已经存在
// LogHelper.Instance.Error("优先级已经存在");
// return 0;
//}
var q = (from ts in Context.Set<TTaskType>()
where ts.SourceDeviceType == task.SourceDeviceType
&& ts.TargetDeviceType == task.TargetDeviceType
&& ts.PalletStatus == task.PalletStatus
select ts).Count();
if (q > 0)
{
//相同的任务已经存在
LogHelper.Instance.Error("相同的任务已经存在,【源设备类型】,【目标设置类型】,【状态】三个合起来,构成一个任务!", true);
return 0;
}
//可以新增
Context.Set<TTaskType>().Add(task);
return Context.SaveChanges();
}
}
/// <summary>
/// 修改任务
/// </summary>
public int EditTaskConfig(TTaskType task)
{
//【源设备类型】,【目标设置类型】,【状态】,三个合起来,构成一个唯一 ,否则就闪退
using (var Context = new BakingEntities())
{
//bool has = Context.Set<TTaskType>().Any(u => u.SourceDeviceType == task.SourceDeviceType
//&& u.TargetDeviceType == task.TargetDeviceType
//&& u.PalletStatus == task.PalletStatus);
//if (has)
//{
// return 0;
//}
var pi = (from ts in Context.Set<TTaskType>()
where ts.Id == task.Id
select ts).FirstOrDefault();
if (pi == null)
{
//任务不存在,无法修改
LogHelper.Instance.Error("任务不存在,无法修改");
return 0;
}
pi.Name = task.Name;
pi.SourceDeviceType = task.SourceDeviceType;
pi.TargetDeviceType = task.TargetDeviceType;
pi.PalletStatus = task.PalletStatus;
pi.Priority = task.Priority;
pi.Enable = task.Enable;
pi.Json = task.Json;
//可以新增
Context.Entry(pi).State = EntityState.Modified;
return Context.SaveChanges();
}
}
}
}

View File

@@ -0,0 +1,202 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using Prism.Ioc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.BLL
{
public class UserService : ServiceBase
{
public UserService(IUnityContainer unityContainer) : base(unityContainer)
{
_unityContainer = unityContainer;
}
/// <summary>
/// 登录
/// </summary>
/// <param name="name">用户名</param>
/// <param name="pwd">密码</param>
/// <returns>登录成功</returns>
public bool Login(string name, string pwd, out string msg)
{
msg = "";
using (var Context = new BakingEntities())
{
TUserManage ulist = Context.Set<TUserManage>().Where(item => item.UserId == name && item.Password == pwd).FirstOrDefault();
if (ulist != null)
{
if (!ulist.Valid ?? false)
{
msg = $"用户:{ulist.UserName},已注销!";
return false;
}
var ge = _unityContainer.Resolve<MemoryDataProvider>(); //重新开辟了内存。
ge.CurrentUser.Copy(ulist); //重新开辟了内存。
//获取菜单,后期需要修改,根据权限加载,现在是加载所有菜单
var ml = Context.Set<TMenuInfo>().Where(item => item.State == true).OrderBy(x => x.Id).ToList();
if (ml != null && ml.Count > 0)
{
ge.CurrentUser.Menus.Clear();
ml.ForEach(p => ge.CurrentUser.Menus.Add(p));
}
_unityContainer.Resolve<LogService>().AddLog(name, E_LogType.Operate.ToString());
return true;
}
else
{
return false;
}
}
}
//public int ModifyPassword(int id, string newPassword)
//{
// using (var Context = new BakingEntities())
// {
// var ulist = Context.Set<TUserManage>().Where(item => item.Id == id).ToList();
// if (ulist.Count == 1)
// {
// ulist[0].Password = newPassword;
// return Context.SaveChanges();
// }
// else
// return 0;
// }
//}
public List<TUserManage> GetAllUsers()
{
using (var Context = new BakingEntities())
{
return Context.Set<TUserManage>().ToList();
}
}
public List<TUserManage> QueryUser(string userEnter)
{
using (var Context = new BakingEntities())
{
List<TUserManage> user = Context.Set<TUserManage>().Where(x => x.UserId == userEnter).ToList();
return user;
}
}
public string GetCurrentUserAuthority()
{
using (var Context = new BakingEntities())
{
var memory = _unityContainer.Resolve<MemoryDataProvider>();
TUserManage user = Context.Set<TUserManage>().Where(x => x.UserId == memory.CurrentUser.UserId).FirstOrDefault();
return Context.Set<TRoleInfo>().Where(a => a.RoleId == user.RoleId).ToList()[0].AccessNode;
}
}
public bool IsHasAuthority(string target)
{
if (GetCurrentUserAuthority().Contains(target))
{
return true;
}
return false;
}
public List<TRoleInfo> GetAllRole()
{
using (var Context = new BakingEntities())
{
return Context.Set<TRoleInfo>().ToList();
}
}
public int GetCurrentRoleId()
{
using (var Context = new BakingEntities())
{
var memory = _unityContainer.Resolve<MemoryDataProvider>();
TUserManage user = Context.Set<TUserManage>().Where(x => x.UserId == memory.CurrentUser.UserId).FirstOrDefault();
return user.RoleId;
}
}
public bool CheckPermission(ERole permission)
{
// 获取当前登录用户的权限级别
int userPermissionLevel = GetCurrentRoleId();
// 根据权限级别判断是否具有指定权限
if (userPermissionLevel == (int)ERole.Admin) // 管理员
{
return true;
}
else if (userPermissionLevel == (int)ERole.Mantainer && (permission == ERole.Operater || permission == ERole.Mantainer))
{
return true;
}
else if (userPermissionLevel == (int)ERole.Operater && permission == ERole.Operater)
{
return true;
}
return false;
}
public List<TMenuInfo> GetAllMenuInfo()
{
using (var Context = new BakingEntities())
{
return Context.Set<TMenuInfo>().ToList();
}
}
public string GetAuthority(string role)
{
using (var Context = new BakingEntities())
{
return Context.Set<TRoleInfo>().Where(x => x.RoleName == role).FirstOrDefault().AccessNode;
}
}
public bool ValidPassword(string name, string pwd) //有效密码
{
using (var Context = new BakingEntities())
{
if (null == Context.Set<TUserManage>().Where(item => item.UserId == name && item.Password == pwd).FirstOrDefault())
{
return false;
}
else
{
return true;
}
}
}
public int ModifyPassword(string newPassword)
{
using (var Context = new BakingEntities())
{
var memory = _unityContainer.Resolve<MemoryDataProvider>();
var userInfo = Context.Set<TUserManage>().Where(item => item.UserId == memory.CurrentUser.UserId).FirstOrDefault();
if (null == userInfo)
{
return 0;
}
userInfo.Password = newPassword;
return Context.SaveChanges();
}
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>

Binary file not shown.

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>

Binary file not shown.

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<connectionStrings>
<add name="PreheatEntities" connectionString="metadata=res://*/DBMappering.csdl|res://*/DBMappering.ssdl|res://*/DBMappering.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=127.0.0.1;user id=root;database=6098-5;persistsecurityinfo=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]

View File

@@ -0,0 +1,130 @@
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.BLL.dll.config
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.BLL.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.BLL.pdb
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Common.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Model.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\EntityFramework.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\EntityFramework.SqlServer.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Google.Protobuf.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.Streams.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\K4os.Hash.xxHash.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Bcl.AsyncInterfaces.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Xaml.Behaviors.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\MySql.Data.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\MySql.Data.EntityFramework.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Newtonsoft.Json.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Prism.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Prism.Unity.Wpf.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Prism.Wpf.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Buffers.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Memory.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Numerics.Vectors.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Runtime.CompilerServices.Unsafe.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Text.Encodings.Web.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Text.Json.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Threading.Tasks.Extensions.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.ValueTuple.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Unity.Abstractions.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Unity.Container.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Opc.Ua.Core.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\CsvHelper.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\NLog.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\ZstdNet.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\BouncyCastle.Crypto.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Ubiety.Dns.Core.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Opc.Ua.Security.Certificates.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.ServiceModel.Primitives.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Bcl.HashCode.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Formats.Asn1.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Common.pdb
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Common.dll.config
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Model.pdb
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Model.dll.config
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Google.Protobuf.pdb
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Google.Protobuf.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.Streams.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\K4os.Hash.xxHash.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Bcl.AsyncInterfaces.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Xaml.Behaviors.pdb
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Xaml.Behaviors.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\Newtonsoft.Json.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Buffers.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Memory.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Numerics.Vectors.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Runtime.CompilerServices.Unsafe.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Text.Encodings.Web.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Text.Json.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.Threading.Tasks.Extensions.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\bin\Debug\System.ValueTuple.xml
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.csproj.AssemblyReference.cache
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.csproj.CoreCompileInputs.cache
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.csproj.CopyComplete
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.dll
E:\svn\DryingStove\branch\得壹烘烤线6098-006\src1111\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.pdb
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.BLL.dll.config
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.BLL.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.BLL.pdb
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Common.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Model.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\EntityFramework.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\EntityFramework.SqlServer.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Google.Protobuf.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.Streams.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\K4os.Hash.xxHash.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Bcl.AsyncInterfaces.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Xaml.Behaviors.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\MySql.Data.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\MySql.Data.EntityFramework.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Newtonsoft.Json.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Prism.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Prism.Unity.Wpf.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Prism.Wpf.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Buffers.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Memory.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Numerics.Vectors.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Runtime.CompilerServices.Unsafe.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Text.Encodings.Web.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Text.Json.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Threading.Tasks.Extensions.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.ValueTuple.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Unity.Abstractions.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Unity.Container.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Opc.Ua.Core.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\CsvHelper.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\NLog.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\ZstdNet.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\BouncyCastle.Crypto.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Ubiety.Dns.Core.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Opc.Ua.Security.Certificates.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.ServiceModel.Primitives.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Bcl.HashCode.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Formats.Asn1.dll
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Common.pdb
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Common.dll.config
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Model.pdb
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Cowain.Bake.Model.dll.config
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Google.Protobuf.pdb
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Google.Protobuf.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\K4os.Compression.LZ4.Streams.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\K4os.Hash.xxHash.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Bcl.AsyncInterfaces.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Xaml.Behaviors.pdb
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Microsoft.Xaml.Behaviors.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\Newtonsoft.Json.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Buffers.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Memory.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Numerics.Vectors.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Runtime.CompilerServices.Unsafe.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Text.Encodings.Web.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Text.Json.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.Threading.Tasks.Extensions.xml
D:\SourceCode\src\Cowain.Bake.BLL\bin\Debug\System.ValueTuple.xml
D:\SourceCode\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.csprojAssemblyReference.cache
D:\SourceCode\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.csproj.CoreCompileInputs.cache
D:\SourceCode\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.csproj.CopyComplete
D:\SourceCode\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.dll
D:\SourceCode\src\Cowain.Bake.BLL\obj\Debug\Cowain.Bake.BLL.pdb

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.8.5" targetFramework="net472" />
<package id="Google.Protobuf" version="3.14.0" targetFramework="net472" />
<package id="K4os.Compression.LZ4" version="1.2.6" targetFramework="net472" />
<package id="K4os.Compression.LZ4.Streams" version="1.2.6" targetFramework="net472" />
<package id="K4os.Hash.xxHash" version="1.0.6" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.31" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="7.0.2" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>

View File

@@ -0,0 +1,30 @@
using Cowain.Bake.Common.Enums;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class BatteryStatusConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
EBatteryStatus status = (EBatteryStatus)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
namespace Cowain.Bake.Common.Converter
{
public class BindingColor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value.ToString() == "报警")
{
return new SolidColorBrush(Colors.Red);
}
else if (value.ToString() == "警告")
{
return new SolidColorBrush(Colors.Gold);
}
else
{
return new SolidColorBrush(Colors.Green);
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,29 @@
using Cowain.Bake.Common.Enums;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
namespace Cowain.Bake.Common.Converter
{
public class BoolToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool boolValue)
{
return boolValue ? Brushes.Green : Brushes.Red;
}
return Brushes.Gray;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool boolValue)
{
return boolValue ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@@ -0,0 +1,43 @@
using Cowain.Bake.Common.Enums;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class DeviceTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var list = EnumHelper.GetEnumList<EDeviceType>();
return list.FirstOrDefault(s => s.EnumString == value.ToString())?.EnumDesc;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (value is true) ? parameter : Binding.DoNothing;
}
}
public class OperTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
OperTypeEnum paramEnum = (OperTypeEnum)int.Parse(value.ToString());
return paramEnum.GetDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (value is true) ? parameter : Binding.DoNothing;
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Cowain.Bake.Common.Enums;
namespace Cowain.Bake.Common.Converter
{
public class DummyRuleConvertor:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) { return null; }
int rule = System.Convert.ToInt32(value);
DummyPlaceRule a = (DummyPlaceRule)rule;
return a.GetDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Cowain.Bake.Common.Enums;
namespace Cowain.Bake.Common.Converter
{
public class DummyStatusConvertor:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
EPalletDummyState EPalletDummyState = (EPalletDummyState)value;
return EPalletDummyState.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class EnumDescriptionConverter : IValueConverter
{
private string GetEnumDescription(Enum enumObj)
{
FieldInfo fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
var descriptionAttr = fieldInfo
.GetCustomAttributes(false)
.OfType<DescriptionAttribute>()
.Cast<DescriptionAttribute>()
.SingleOrDefault();
if (descriptionAttr == null)
{
return enumObj.ToString();
}
else
{
return descriptionAttr.Description;
}
}
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Enum myEnum = (Enum)value;
string description = GetEnumDescription(myEnum);
return description;
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return string.Empty;
}
}
public class EnumDescriptionTypeConverter : EnumConverter
{
public EnumDescriptionTypeConverter(Type type) : base(type)
{
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
if (null != value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
if (null != fi)
{
var attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
return ((attributes.Length > 0) && (!string.IsNullOrEmpty(attributes[0].Description)))
? attributes[0].Description
: value.ToString();
}
}
return string.Empty;
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}

View File

@@ -0,0 +1,30 @@
using Cowain.Bake.Common.Enums;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class IntToDeviceTypeConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
EDeviceType status = (EDeviceType)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
/// <summary>
/// 状态转换器
/// </summary>
public class ObjectConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string[] parray = parameter.ToString().ToLower().Split(':'); //将参数字符分段 parray[0]为比较值parray[1]为true返回值parray[2]为false返回值
if (value == null)
return parray[2]; //如果数据源为空默认返回false返回值
if (parray[0].Contains("|")) //判断有多个比较值的情况
return parray[0].Split('|').Contains(value.ToString().ToLower()) ? parray[1] : parray[2]; //多值比较
return parray[0].Equals(value.ToString().ToLower()) ? parray[1] : parray[2]; //单值比较
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var returnValue = "otherValue";
string[] parray = parameter.ToString().ToLower().Split(':');
if (value == null)
return returnValue;
var valueStr = value.ToString().ToLower();
if (valueStr != parray[1])
return returnValue;
else
return parray[0].Contains('|') ? parray[0].Split('|')[0] : parray[0];
}
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Cowain.Bake.Common.Enums;
namespace Cowain.Bake.Common.Converter
{
public class PalletStatusConvertor:IValueConverter
{
private string GetEnumDescription(Enum enumObj)
{
FieldInfo fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
var descriptionAttr = fieldInfo
.GetCustomAttributes(false)
.OfType<DescriptionAttribute>()
.Cast<DescriptionAttribute>()
.SingleOrDefault();
if (descriptionAttr == null)
{
return enumObj.ToString();
}
else
{
return descriptionAttr.Description;
}
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
EPalletStatus status = (EPalletStatus)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
EPalletStatus e = EnumHelper.GetValueByDescription<EPalletStatus>((string)value);
return (int)e;
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class ProductOutputTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value?.Equals(parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (value is true) ? parameter : Binding.DoNothing;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class RadioButtonToIndexConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// 将 RadioButton 的值与 ViewModel 中的值进行比较并返回是否匹配
if (value == null || parameter == null)
return false;
return value.ToString() == parameter.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// 这个转换通常不需要,可以简单地返回 DependencyProperty.UnsetValue
if ((bool)value)
{
return parameter;
}
return DependencyProperty.UnsetValue;
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class ScaleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter == null)
throw new ArgumentNullException("value can not be null");
if (value == null)
throw new ArgumentNullException("value can not be null");
double c = System.Convert.ToDouble(parameter);
double index = System.Convert.ToDouble(value);
return index / c;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter == null)
throw new ArgumentNullException("value can not be null");
if (value == null)
throw new ArgumentNullException("value can not be null");
double c = System.Convert.ToDouble(parameter);
double index = System.Convert.ToDouble(value);
return System.Convert.ToInt32(index * c);
}
}
}

View File

@@ -0,0 +1,26 @@
using Cowain.Bake.Common.Enums;
using System;
using System.Globalization;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class SendFlagConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
EMesUpLoadStatus status = (EMesUpLoadStatus)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using Cowain.Bake.Common.Enums;
using Prism.Ioc;
namespace Cowain.Bake.Common.Converter
{
public class StationTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
EStationType status = (EStationType)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
EStationType e = EnumHelper.GetValueByDescription<EStationType>((string)value);
return (int)e;
}
}
}

View File

@@ -0,0 +1,26 @@
using Cowain.Bake.Common.Enums;
using System;
using System.Globalization;
using System.Windows.Data;
namespace Cowain.Bake.Common.Converter
{
public class TaskCmdConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
value = System.Convert.ToInt32(value);
ETaskStep status = (ETaskStep)value;
return status.FetchDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,76 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Cowain.Bake.Common.Core
{
public class BasicFramework
{
private static BasicFramework instance;
private static readonly object locker = new object();
public Dictionary<string, string> RegularDic = new Dictionary<string, string>();
public static BasicFramework Instance
{
get
{
lock (locker)
{
if (instance == null)
{
instance = new BasicFramework();
}
return instance;
}
}
}
BasicFramework()
{
SetRegularDic();
}
private void SetRegularDic()
{
RegularDic.Clear();
RegularDic.Add("decimal2", "^([1-9]+[\\d]*(.[0-9]{1,2})?)$");
RegularDic.Add("Int32", @"^(0|-?[1-9]\d*)$");// "^[0-9]*$");
RegularDic.Add("Int16", "^([1-9](\\d{0,3}))$|^([1-5]\\d{4})$|^(6[0-4]\\d{3})$|^(65[0-4]\\d{2})$|^(655[0-2]\\d)$|^(6553[0-5])$");
RegularDic.Add("bool", "^[01]$");
RegularDic.Add("Float", @"^(?!\.?$)\d+(\.\d+)?([eE][-+]?\d+)?$");
}
public static T DeepCopy<T>(T obj)
{
if (obj == null)
{
return obj;
}
if (obj is string || obj.GetType().IsValueType)
return obj;
object retval = Activator.CreateInstance(obj.GetType());
FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
foreach (var field in fields)
{
try
{
field.SetValue(retval, DeepCopy(field.GetValue(obj)));
}
catch (Exception ex)
{
LogHelper.Instance.GetCurrentClassError((typeof(BasicFramework) + "DeepCopy异常:" + ex.Message));
}
}
return (T)retval;
}
}
}

View File

@@ -0,0 +1,273 @@
using CsvHelper;
using CsvHelper.Configuration;
using Microsoft.Win32;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
namespace Cowain.Bake.Common.Core
{
public class CSVHelper
{
public static void WriteDataTableToCsv<T>(IEnumerable<T> list)
{
string filePath = GetFilePath();
if (string.IsNullOrEmpty(filePath))
{
return;
}
using (var writer = new StreamWriter(filePath))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(list);
}
}
//列头是中文,所有字段都写入
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, List<string> nameCols)
{
string filePath = GetFilePath();
if (string.IsNullOrEmpty(filePath))
{
return;
}
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
// 设置列头编码为UTF8以支持中文
Encoding = System.Text.Encoding.UTF8,
// 设置不写入列头
HasHeaderRecord = false
};
using (var writer = new StreamWriter(filePath, false, System.Text.Encoding.UTF8))
using (var csv = new CsvWriter(writer, config))
{
// 写入列头,使用中文列名
foreach(var col in nameCols)
{
csv.WriteField(col);
}
csv.NextRecord();
// 写入数据行
csv.WriteRecords(list);
}
}
// 将List的特定列写入CSV文件的方法
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, IEnumerable<string> columnsToSave)
{
string filePath = GetFilePath();
if (string.IsNullOrEmpty(filePath))
{
return;
}
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
// 设置列头编码为UTF8以支持中文
Encoding = System.Text.Encoding.UTF8,
// 设置不写入列头
HasHeaderRecord = false
};
using (var writer = new StreamWriter(filePath, false, System.Text.Encoding.UTF8))
using (var csv = new CsvWriter(writer, config))
{
// 写入列头
foreach (var columnName in columnsToSave)
{
csv.WriteField(columnName);
}
csv.NextRecord();
// 写入特定列数据
foreach (var person in list)
{
foreach (var columnName in columnsToSave)
{
var property = typeof(T).GetProperty(columnName);
if (property != null)
{
csv.WriteField(property.GetValue(person));
}
}
csv.NextRecord();
}
}
}
static string GetFilePath()
{
string filePath = "";
//创建一个保存文件式的对话框
SaveFileDialog saveFileDialog = new SaveFileDialog();
//设置保存的文件的类型,注意过滤器的语法
saveFileDialog.Filter = "CSV|*.csv";
if (saveFileDialog.ShowDialog() == true)
{
filePath = saveFileDialog.FileName;
}
return filePath;
}
public static void WriteMap<T, TMap>(IEnumerable<T> list, string filePath) where TMap : ClassMap
{
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
// 设置列头编码为UTF8以支持中文
Delimiter = ",",
HasHeaderRecord = true,
Encoding = System.Text.Encoding.UTF8
};
if (File.Exists(filePath))
{
config.HasHeaderRecord = false; // 获取字段描述作为列头
}
using (var writer = new StreamWriter(filePath, true, System.Text.Encoding.UTF8))
using (var csv = new CsvWriter(writer, config))
{
// 注册自定义映射
//csv.Context.RegisterClassMap<BatteryInfoMap>();
csv.Context.RegisterClassMap<TMap>();
// 写入记录
csv.WriteRecords(list);
}
}
public static void WriteMap<T, TMap>(IEnumerable<T> list ) where TMap : ClassMap //where TMap : ClassMap<T> // 约束:必须是 ClassMap<T> 或其子类
{
string filePath = GetFilePath();
if (string.IsNullOrEmpty(filePath))
{
return;
}
WriteMap<T, TMap>(list, filePath);
}
// 将List的特定列写入CSV文件的方法
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, IEnumerable<string> columnsToSave, IEnumerable<string> columnsToShow)
{
string filePath = GetFilePath();
if (string.IsNullOrEmpty(filePath))
{
return;
}
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
// 设置列头编码为UTF8以支持中文
Encoding = System.Text.Encoding.UTF8,
HasHeaderRecord = false
};
using (var writer = new StreamWriter(filePath, false, System.Text.Encoding.UTF8))
using (var csv = new CsvWriter(writer, config))
{
// 写入列头
foreach (var columnName in columnsToShow)
{
csv.WriteField(columnName);
}
csv.NextRecord();
// 写入特定列数据
foreach (var person in list)
{
foreach (var columnName in columnsToSave)
{
var property = typeof(T).GetProperty(columnName);
if (property != null)
{
csv.WriteField(property.GetValue(person));
}
}
csv.NextRecord();
}
}
}
// 将List的特定列写入CSV文件的方法
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, IEnumerable<string> columnsToSave, IEnumerable<string> columnsToShow, string filePath)
{
bool isFileExists = false;
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
// 设置列头编码为UTF8以支持中文
Encoding = System.Text.Encoding.UTF8,
HasHeaderRecord = false
};
if (File.Exists(filePath))
{
// 获取字段描述作为列头
isFileExists = true;
}
using (var writer = new StreamWriter(filePath, true, System.Text.Encoding.UTF8))
using (var csv = new CsvWriter(writer, config))
{
// 写入列头
if (!isFileExists)
{
foreach (var columnHeader in columnsToShow)
{
csv.WriteField(columnHeader);
}
csv.NextRecord();
}
// 写入特定列数据
foreach (var person in list)
{
foreach (var columnName in columnsToSave)
{
var property = typeof(T).GetProperty(columnName);
if (property != null)
{
csv.WriteField(property.GetValue(person));
}
}
csv.NextRecord();
}
}
}
// 将DataTable写入CSV文件的方法
public static void WriteDataTableToCsv(DataTable dataTable)
{
string filePath = GetFilePath();
if (string.IsNullOrEmpty(filePath))
{
return;
}
using (var writer = new StreamWriter(filePath))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
// 写入表头
foreach (DataColumn column in dataTable.Columns)
{
csv.WriteField(column.ColumnName);
}
csv.NextRecord();
// 写入数据行
foreach (DataRow row in dataTable.Rows)
{
for (var i = 0; i < dataTable.Columns.Count; i++)
{
csv.WriteField(row[i]);
}
csv.NextRecord();
}
}
}
}
}

View File

@@ -0,0 +1,46 @@
using Cowain.Bake.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
namespace Cowain.Bake.Common.Core
{
public class CommonCoreHelper
{
//IsCompleted:true,CompleteAdding()已被调用(表示不再有新项添加)该集合是否已被标记为“添加完成”(即 CompleteAdding() 已被调用)
public BlockingCollection<TTaskRecord> BlockTask = new BlockingCollection<TTaskRecord>();
public BlockingCollection<TDeviceConfig> BlockStatusColor = new BlockingCollection<TDeviceConfig>();
// 参数表示初始状态true表示初始有信号false表示初始无信号
public AutoResetEvent MainViewAutoEvent = new AutoResetEvent(true);
private static CommonCoreHelper instance;
public static CommonCoreHelper Instance
{
get
{
if (instance == null)
{
instance = new CommonCoreHelper();
}
return instance;
}
}
public List<string> StringToListConverter(string input)
{
string[] separators = { " ", ":", ",", ";" };
if (string.IsNullOrWhiteSpace(input))
{
return new List<string>();
}
string[] items = input.Split(separators, StringSplitOptions.RemoveEmptyEntries);
List<string> itemList = new List<string>(items);
return itemList;
}
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Cowain.Bake.Common.Core
{
public class INIHelper
{
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);
//ini文件名称
private static string inifilename = "Config.ini";
//获取ini文件路径
public static string inifilepath = Application.StartupPath + "\\" + inifilename;
public static string ReadValue(string key)
{
StringBuilder s = new StringBuilder(1024);
GetPrivateProfileString("Config", key, "", s, 1024, inifilepath);
return s.ToString();
}
public static bool ReadBool(string section, string key, bool value = false)
{
bool reVal = false;
StringBuilder s = new StringBuilder(1024);
GetPrivateProfileString(section, key, "", s, 1024, inifilepath);
bool b = bool.TryParse(s.ToString(), out reVal);
if (b)
{
return reVal;
}
return value;
}
public static string ReadString(string section, string key, string value = "")
{
StringBuilder s = new StringBuilder(1024);
GetPrivateProfileString(section, key, "", s, 1024, inifilepath);
if (0 == s.ToString().Length)
{
return value;
}
return s.ToString();
}
public static int ReadInt(string section, string key, int nDefault = 0)
{
// 每次从ini中读取多少字节
System.Text.StringBuilder temp = new StringBuilder(1024);
// section=配置节key=键名temp=上面path=路径
GetPrivateProfileString(section, key, "", temp, 1024, inifilepath);
string t = temp.ToString();
int v = 0;
if (int.TryParse(t, out v))
{
return v;
}
return nDefault;
}
public static float ReadFloat(string section, string key, float fDefault = 0)
{
// 每次从ini中读取多少字节
System.Text.StringBuilder temp = new System.Text.StringBuilder(255);
// section=配置节key=键名temp=上面path=路径
GetPrivateProfileString(section, key, "", temp, 255, inifilepath);
string t = temp.ToString();
float v = 0;
if (float.TryParse(t, out v))
{
return v;
}
return fDefault;
}
/// <param name="value"></param>
public static void Write(string section, string key, string value)
{
// section=配置节key=键名value=键值path=路径
WritePrivateProfileString(section, key, value, inifilepath);
}
public static void WriteValue(string key, string value)
{
try
{
WritePrivateProfileString("Config", key, value, inifilepath);
}
catch (Exception ex)
{
throw ex;
}
}
}
}

View File

@@ -0,0 +1,169 @@
using Cowain.Bake.Common.Enums;
using NLog;
using NLog.Config;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
namespace Cowain.Bake.Common.Core
{
public class LogHelper
{
private static LogHelper instance;
public static LogHelper Instance
{
get
{
if (instance == null)
{
instance = new LogHelper();
}
return instance;
}
}
private Logger logger; //初始化日志类
/// <summary>
/// 事件定义
/// </summary>
public Action<string> OnComplated;
public Action<string, bool, E_LogType> OnShowInvoke { set; get; }
/// <summary>
/// 时间触发
/// </summary>
/// <param name="msg">自定义消息</param>
/// <param name="isUI">是否触发事件通知</param>
private void Notice(string msg, bool isShow, E_LogType logType)
{
if (OnShowInvoke != null)
{
OnShowInvoke?.Invoke(msg, isShow, logType);
}
}
/// <summary>
/// 静态构造函数
/// </summary>
private LogHelper()
{
logger = NLog.LogManager.GetCurrentClassLogger(); //初始化日志类
//string rootPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//string fileName = string.Format(@"{0}NLog.config", rootPath);
////初始化配置日志
//NLog.LogManager.Configuration = new XmlLoggingConfiguration(fileName);
}
public void Trace(string msg)
{
To(msg, E_LogType.Trace, false);
}
public void Debug(string msg, bool isShow = false)
{
To(msg, E_LogType.Debug, isShow);
}
public void Info(string msg, bool isShow = false)
{
To(msg, E_LogType.Info, isShow);
}
public void Warn(string msg, bool isShow = false)
{
To(msg, E_LogType.Warn, isShow);
}
public void Error(string msg, bool isShow = false)
{
To(msg, E_LogType.Error, isShow);
}
public void Fatal(string msg, bool isShow = false)
{
To(msg, E_LogType.Fatal, isShow);
}
#region
public void GetCurrentClassDebug(string msg, bool isShow = false,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
To(msg, E_LogType.Debug, isShow);
}
public void GetCurrentClassInfo(string msg, bool isShow = false,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
To(msg, E_LogType.Info, isShow);
}
public void GetCurrentClassWarn(string msg, bool isShow = false,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
To(msg, E_LogType.Warn, isShow);
}
public void GetCurrentClassError(string msg, bool isShow = false,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
To(msg, E_LogType.Error, isShow);
}
public void GetCurrentClassFatal(string msg,bool isShow = false,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
To(msg, E_LogType.Fatal, isShow);
}
#endregion
private void To(string msg, E_LogType logType, bool isShow = false)
{
switch (logType)
{
case E_LogType.Debug:
logger.Debug(msg);
break;
case E_LogType.Info:
logger.Info(msg);
break;
case E_LogType.Warn:
logger.Warn(msg);
break;
case E_LogType.Error:
logger.Error(msg);
break;
case E_LogType.Fatal:
logger.Fatal(msg);
break;
default:
logger.Trace(msg);
break;
}
Notice(msg, isShow, logType);
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Cowain.Bake.Common.Core
{
public class MessageEventWaitHandle<T> : EventWaitHandle
{
private T message;
private readonly object lockEvent = new object();//定义锁
public MessageEventWaitHandle(bool initialState, EventResetMode mode)
: base(initialState, mode)
{
}
public bool Set(T message)
{
//lock (lockEvent)
{
this.message = message;
return base.Set();
}
}
public T GetMessage(int timeOut)
{
//lock (lockEvent)//因为这里锁住了set给不了信号
{
if (!base.WaitOne(timeOut)) //为假超时
{
base.Reset();
return default(T);
}
else
{
base.Reset();
return this.message;
}
}
}
}
}

View File

@@ -0,0 +1,222 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cowain.Bake.Common.Core
{
public class SettingProvider
{
const string MAIN = "Main";
private static SettingProvider instance;
public string PWD;
public string ProductionLineName;
private static readonly object locker = new object();
private int? _waterPallet;
//private int? _stoveLayers;
private int? _palletRows;
private int? _palletCols;
private Enums.EDispatchMode _dispMode;
public Enums.EDispatchMode DispMode
{
get
{
return _dispMode;
}
set
{
_dispMode = (Enums.EDispatchMode)value;
INIHelper.Write(MAIN, "DispatchMode", _dispMode.ToString());
}
}
public int WaterPallet
{
get
{
if (null == _waterPallet)
{
_waterPallet = INIHelper.ReadInt(MAIN, "WaterPallet", 0);
}
return _waterPallet ?? 0;
}
set
{
_waterPallet = value;
INIHelper.Write(MAIN, "WaterPallet", _waterPallet.ToString());
}
}
//public int StoveLayers
//{
// get
// {
// if (null == _stoveLayers)
// {
// _stoveLayers = INIHelper.ReadInt(MAIN, "StoveLayers", 0);
// }
// return _stoveLayers ?? 0;
// }
//}
public int PalletRows
{
get
{
if (null == _palletRows)
{
_palletRows = INIHelper.ReadInt(MAIN, "PalletRows", 48);
}
return _palletRows ?? 0;
}
}
public int PalletCols
{
get
{
if (null == _palletCols)
{
_palletCols = INIHelper.ReadInt(MAIN, "PalletCols", 2);
}
return _palletCols ?? 0;
}
}
public int? _skinType;
public int SkinType
{
get
{
if (null == _skinType)
{
_skinType = INIHelper.ReadInt(MAIN, "SkinType", 0);
}
return _skinType ?? 0;
}
set
{
_skinType = value;
INIHelper.Write(MAIN, "SkinType", _skinType.ToString());
}
}
public bool? _autoUpdate;
public bool AutoUpdate
{
get
{
if (null == _autoUpdate)
{
_autoUpdate = INIHelper.ReadBool(MAIN, "AutoUpdate", false);
}
return _autoUpdate ?? false;
}
set
{
_autoUpdate = value;
INIHelper.Write(MAIN, "AutoUpdate", _autoUpdate.Value ? "1" : "0");
}
}
public string _autoUpdateUrl;
public string AutoUpdateUrl
{
get
{
if (string.IsNullOrEmpty(_autoUpdateUrl))
{
_autoUpdateUrl = INIHelper.ReadString(MAIN, "AutoUpdateUrl", "http://127.0.0.1:6688/update/update.xml");
}
return _autoUpdateUrl;
}
set
{
_autoUpdateUrl = value;
INIHelper.Write(MAIN, "AutoUpdateUrl", _autoUpdateUrl);
}
}
private EIsReverseOrder? _stoveDispDirection;
public EIsReverseOrder StoveDispDirection
{
get
{
if (null == _stoveDispDirection)
{
_stoveDispDirection = (EIsReverseOrder)INIHelper.ReadInt(MAIN, "StoveDispDirection", 0);
}
return _stoveDispDirection.Value;
}
}
private EIsReverseOrder? _isReverseOrder;
public EIsReverseOrder IsReverseOrder
{
get
{
if (null == _isReverseOrder)
{
_isReverseOrder = (EIsReverseOrder)INIHelper.ReadInt(MAIN, "IsReverseOrder", 0);
}
return _isReverseOrder.Value;
}
}
private int? _countCmd;
public int CountCmd
{
get
{
if (null == _countCmd)
{
_countCmd = INIHelper.ReadInt(MAIN, "CountCmd", 0);
}
if (3000 <= _countCmd)
{
CountCmd = 0;
}
return _countCmd ?? 0;
}
set
{
_countCmd = value;
INIHelper.Write(MAIN, "CountCmd", _countCmd.ToString());
}
}
public static SettingProvider Instance
{
get
{
lock (locker)
{
if (instance == null)
{
instance = new SettingProvider();
}
return instance;
}
}
}
SettingProvider()
{
PWD = INIHelper.ReadString(MAIN, "PassWord", "cowain2024");
DispMode = (Enums.EDispatchMode)INIHelper.ReadInt(MAIN, "DispatchMode", 2);
ProductionLineName = INIHelper.ReadString(MAIN, "ProductionLineName", ""); //有乱码
}
}
}

View File

@@ -0,0 +1,310 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4E1A0D39-34EF-498D-A3A7-D1489C6A6FE4}</ProjectGuid>
<OutputType>library</OutputType>
<RootNamespace>Cowain.Bake.Common</RootNamespace>
<AssemblyName>Cowain.Bake.Common</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
<HintPath>..\packages\BouncyCastle.Cryptography.2.2.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference>
<Reference Include="Cowain.Bake.Model, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Cowain.Bake.Model\bin\Debug\Cowain.Bake.Model.dll</HintPath>
</Reference>
<Reference Include="CsvHelper, Version=33.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="Dapper">
<HintPath>..\Libs\Dapper.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\Libs\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Enums.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7ea1c1650d506225, processorArchitecture=MSIL">
<HintPath>..\packages\Enums.NET.4.0.1\lib\net45\Enums.NET.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="MathNet.Numerics, Version=4.15.0.0, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
<HintPath>..\packages\MathNet.Numerics.Signed.4.15.0\lib\net461\MathNet.Numerics.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Bcl.HashCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\Microsoft.Bcl.HashCode.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=2.3.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.2.3.2\lib\net462\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="MySql.Data.EntityFramework, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\MySql.Data.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\Libs\NLog.dll</HintPath>
</Reference>
<Reference Include="NPOI.Core, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.Core.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.OOXML.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.OpenXml4Net.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXmlFormats, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.OpenXmlFormats.dll</HintPath>
</Reference>
<Reference Include="Opc.Ua.Core">
<HintPath>..\Libs\Opc.Ua.Core.dll</HintPath>
</Reference>
<Reference Include="Oracle.ManagedDataAccess">
<HintPath>..\Libs\Oracle.ManagedDataAccess.dll</HintPath>
</Reference>
<Reference Include="Prism, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Core.8.1.97\lib\net47\Prism.dll</HintPath>
</Reference>
<Reference Include="Prism.Unity.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Unity.8.1.97\lib\net47\Prism.Unity.Wpf.dll</HintPath>
</Reference>
<Reference Include="Prism.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Wpf.8.1.97\lib\net47\Prism.Wpf.dll</HintPath>
</Reference>
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
<HintPath>..\packages\SixLabors.Fonts.1.0.0\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
</Reference>
<Reference Include="SixLabors.ImageSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
<HintPath>..\packages\SixLabors.ImageSharp.2.1.4\lib\net472\SixLabors.ImageSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Xml, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Xml.6.0.1\lib\net461\System.Security.Cryptography.Xml.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="System.Windows.Forms.DataVisualization.Design" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="Unity.Abstractions, Version=5.11.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\Unity.Abstractions.5.11.7\lib\net47\Unity.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Unity.Container, Version=5.11.11.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\Unity.Container.5.11.11\lib\net47\Unity.Container.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Wisdy">
<HintPath>..\Libs\Wisdy.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Converter\BatteryStatusConvertor.cs" />
<Compile Include="Converter\BindingColor.cs" />
<Compile Include="Converter\BooleanToVisibilityConverter.cs" />
<Compile Include="Converter\BoolToColorConverter.cs" />
<Compile Include="Converter\DeviceTypeConverter.cs" />
<Compile Include="Converter\DummyRuleConvertor.cs" />
<Compile Include="Converter\DummyStatusConvertor.cs" />
<Compile Include="Converter\EnumDescriptionTypeConverter.cs" />
<Compile Include="Converter\IntToDeviceTypeConvertor.cs" />
<Compile Include="Converter\ObjectConverter.cs" />
<Compile Include="Converter\PalletStatusConvertor.cs" />
<Compile Include="Converter\ProductOutputTypeConverter.cs" />
<Compile Include="Converter\RadioButtonToIndexConverter.cs" />
<Compile Include="Converter\ScaleConverter.cs" />
<Compile Include="Converter\SendFlagConvertor.cs" />
<Compile Include="Converter\StationTypeConverter.cs" />
<Compile Include="Converter\TaskCmdConvertor.cs" />
<Compile Include="Core\BasicFramework.cs" />
<Compile Include="Core\CommonCoreHelper.cs" />
<Compile Include="Core\CSVHelper.cs" />
<Compile Include="Core\LogHelper.cs" />
<Compile Include="Core\INIHelper.cs" />
<Compile Include="Core\MessageEventWaitHandle.cs" />
<Compile Include="Core\SettingProvider.cs" />
<Compile Include="Enums\EnumHelper.cs" />
<Compile Include="Enums\SysEnum.cs" />
<Compile Include="Global.cs" />
<Compile Include="Interface\ICommonFun.cs" />
<Compile Include="Interface\IDeviceDebug.cs" />
<Compile Include="Interface\IRecvMesHttp.cs" />
<Compile Include="Interface\IServerManager.cs" />
<Compile Include="Interface\ITrigService.cs" />
<Compile Include="MiniDump.cs" />
<Compile Include="Models\CommonModel.cs" />
<Compile Include="Models\MESModel.cs" />
<Compile Include="Models\VarValue.cs" />
<Compile Include="PasswordHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="ViewModelBase.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Resource Include="Fonts\iconfont.ttf" />
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Resource Include="Images\exit.png" />
</ItemGroup>
<ItemGroup>
<Page Include="Styles\BaseResources.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\ButtonStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\DataGrid.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\TextBoxStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\ToggleButtonStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\CowainLogo.jpg" />
<Resource Include="Images\CowainLogo.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Auto.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Manual.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\shuru.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\zhuye.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\gongyezujian-kaiguan.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\help-fill.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\CN-EN.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\skin.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\gongju1.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Cowain.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,228 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO.Ports;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Cowain.Bake.Common.Enums
{
public static class EnumHelper
{
public static string FetchDescription(this Enum value)
{
try
{
FieldInfo fi = value.GetType().GetField(value.ToString());
if (null == fi)
{
return "";
}
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attributes != null && attributes.Length > 0)
return attributes[0].Description;
else
return value.ToString();
}
catch
{
return "";
}
}
public static string GetEnumDescription(this Enum @enum, int value)
{
Type enumType = @enum.GetType();
if (Enum.IsDefined(enumType, value))
{
DescriptionAttribute[] descriptAttr = enumType.GetField(Enum.GetName(enumType, value)).GetDescriptAttr();
return descriptAttr == null || descriptAttr.Length == 0 ? "" : descriptAttr[0].Description;
}
return "枚举异常";
}
public static string GetDescription(this Enum enumName)
{
string str = string.Empty;
DescriptionAttribute[] descriptAttr = enumName.GetType().GetField(enumName.ToString()).GetDescriptAttr();
return descriptAttr == null || descriptAttr.Length == 0 ? enumName.ToString() : descriptAttr[0].Description;
}
public static ArrayList ToArrayList(this Enum en)
{
ArrayList arrayList = new ArrayList();
foreach (Enum @enum in Enum.GetValues(en.GetType()))
arrayList.Add(new KeyValuePair<Enum, string>(@enum, @enum.GetDescription()));
return arrayList;
}
public static DescriptionAttribute[] GetDescriptAttr(this FieldInfo fieldInfo)
{
if (fieldInfo != null)
return (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
return null;
}
public static dynamic Todynamic<T>(this Enum en)
{
Dictionary<int, string> valuePairs = new Dictionary<int, string>();
foreach (Enum @enum in Enum.GetValues(en.GetType()))
valuePairs.Add((int)Enum.Parse(typeof(T), @enum.ToString()), @enum.GetDescription());
return valuePairs;
}
public static dynamic ToStringKey<T>(this Enum en)
{
Dictionary<string, string> valuePairs = new Dictionary<string, string>();
foreach (Enum @enum in Enum.GetValues(en.GetType()))
valuePairs.Add(@enum.ToString(), @enum.GetDescription());
return valuePairs;
}
public static dynamic GetListDesc(this Enum en)
{
List<string> lst = new List<string>();
foreach (Enum @enum in Enum.GetValues(en.GetType()))
lst.Add(@enum.GetDescription());
return lst;
}
public static dynamic ListKeyString<T>(this Enum en)
{
List<string> lst = new List<string>();
foreach (Enum @enum in Enum.GetValues(en.GetType()))
lst.Add(@enum.ToString());
return lst;
}
/// <summary>
///
/// </summary>
/// <typeparam name="EnumType">The enum type.</typeparam>
/// <param name="description">The description.</param>
/// <returns>The enum value.</returns>
public static EnumType GetValueByDescription<EnumType>(this string description)
{
var type = typeof(EnumType);
foreach (var enumName in Enum.GetNames(type))
{
var enumValue = Enum.Parse(type, enumName);
if (description == ((Enum)enumValue).GetDescription())
return (EnumType)enumValue;
}
throw new ArgumentException("在指定的枚举类型值中没有此描述的值");
}
public static EnumType GetValueByKey<EnumType>(this string name)
{
var type = typeof(EnumType);
foreach (var enumName in Enum.GetNames(type))
{
var enumValue = Enum.Parse(type, enumName);
if (name == ((Enum)enumValue).ToString())
return (EnumType)enumValue;
}
throw new ArgumentException("在指定的枚举类型值中没有此描述的值");
}
public static List<string> GetDescriptions<T>() where T : Enum
{
return Enum.GetValues(typeof(T))
.Cast<T>()
.Select(e => GetDescription(e))
.ToList();
}
public static List<EnumModel> GetEnumList<EnumType>()
{
var type = typeof(EnumType);
List<EnumModel> enumModels = new List<EnumModel>();
foreach (var enumName in Enum.GetNames(type))
{
EnumModel enumModel = new EnumModel();
enumModel.EnumString= enumName;
var enumValue = Enum.Parse(type, enumName);
enumModel.EnumDesc= ((Enum)enumValue).GetDescription();
enumModel.EnumIntValue = int.Parse(((Enum)enumValue).ToString("D"));
enumModels.Add(enumModel);
}
return enumModels;
}
public static Parity GetParity(string name)
{
Parity parity = Parity.None;
var arr = System.Enum.GetValues(typeof(Parity));
foreach (Parity item in arr)
{
if (item.ToString() == name)
{
parity = item;
break;
}
}
return parity;
}
public static StopBits GetStopBits(string name)
{
StopBits stopBits = StopBits.One;
var arr = System.Enum.GetValues(typeof(StopBits));
foreach (StopBits item in arr)
{
if (item.ToString() == name)
{
stopBits = item;
break;
}
}
return stopBits;
}
public static Handshake GetHandshake(string name)
{
Handshake handshake = Handshake.None;
var arr = System.Enum.GetValues(typeof(Handshake));
foreach (Handshake item in arr)
{
if (item.ToString() == name)
{
handshake = item;
break;
}
}
return handshake;
}
public static bool IsDefined<T>(int value) where T : struct, Enum
{
return Enum.IsDefined(typeof(T), value);
}
//public static T GetNext<T>(this T value) where T : struct, Enum
//{
// var values = Enum.GetValues(typeof(T)).Cast<T>().ToArray();
// int currentIndex = Array.IndexOf(values, value);
// if (currentIndex < values.Length - 1)
// {
// return values[currentIndex + 1];
// }
// else
// {
// return values[0];
// }
//}
public static void GetEnum<T>(string a, ref T t)
{
foreach (T b in Enum.GetValues(typeof(T)))
{
if (GetDescription(b as Enum) == a)
t = b;
}
}
}
public class EnumModel
{
public string EnumString { get; set; }
public string EnumDesc { get; set; }
public int EnumIntValue { get; set; }
}
}

View File

@@ -0,0 +1,733 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cowain.Bake.Common.Enums
{
public enum EDeviceState
{
[Description("自动运行")] Run = 0,
[Description("待机")] Standby = 1,
[Description("正常停机")] Stop = 2,
[Description("故障停机")] FaultShutdown = 3,
[Description("待料")] WaitingMaterials = 4,
[Description("满料")] FullMaterial = 5,
}
public enum EAlarmStationId
{
Mom = 10000,
DevTemp = 10001,
}
public enum EIsReverseOrder
{
[Description("正向")] Positive = 0,
[Description("反向")] Reverse = 1,
}
public enum EAgvMoveStatus
{
Error = -1,
Wait = 0,
Normal = 1,
}
public enum ETaskStatus
{
[Description("无任务")] None = 0,
[Description("未执行")] UnExecute = 1,
[Description("执行中")] Executing, //是不用的
[Description("执行完成")] ExecutionCompleted,
}
public enum ETaskStep
{
[Description("无")] None = 0,
[Description("未执行")] Unexecuted = 1,
[Description("移至取位")] MoveFrom = 10,
[Description("取盘")] Pick = 20,
[Description("移至放位")] MoveTo = 11,
[Description("放盘")] Place = 30,
[Description("完成")] Finish = 50,
}
public enum EPalletDummyState
{
[Description("不带水满夹具")] Not_have = 0,
[Description("带水满夹具")] Have = 1,
[Description("不判断")] Null = 2,
}
public enum ETagType
{
[Description("通用")] General = 0,
[Description("报警")] Alarm = 1,
[Description("温度")] Temperature = 2,
[Description("PID")] PID = 3,
[Description("工艺参数")] ProcessParams = 4,
[Description("逻辑处理")] LogicHandle = 5, //上下料回复
[Description("电能表数据")] ElectricEnergy = 6,
[Description("输出IO")] OutputSignal = 7, //输出的IO信号BOOL类型
[Description("昨日耗电量")] YesterdayEnergy = 8,
[Description("每日耗电量预警")] DayEnergyAlarmValue = 9,
}
public enum Direction
{
Up,
Down,
Left,
Right
}
public enum DummyPlaceRule
{
[Description("每个夹具放一个(默认)")] EVERY_PALLET_PLACED_ONE = 1,
[Description("每个炉层放一个")] DEFAULT_EVERY_STOVE_LAYER_PLACED_ONE,
[Description("每个炉子均不放")] EVERY_STOVE_NOT_PLACED_ANY,
}
public enum EPalletStatus
{
//[Description("新盘托")] Init = 1,
[Description("上料中")] Loading = 5,
[Description("满载")] Advisable = 10,
[Description("烘烤中")] Bake = 15,
[Description("烘烤完成")] BakeOver = 20,
[Description("待测结果")] WaitTest = 25,
[Description("检测OK")] TestOK = 30,
[Description("检测NG")] TestNG = 35,
[Description("下料中")] Blank = 40,
[Description("空夹具")] BlankOver = 45,
[Description("维修")] Maintain = 50,
}
/// <summary>
/// 是否最后一盘
/// </summary>
public enum EPalletLast
{
[Description("否")]
NoLast = 0,
[Description("是")]
YesLast = 1,
}
public enum EStatusCode
{
[Description("未知")] UnKnow = 0,
[Description("运行")] Runing = 1,
[Description("待机")] Wait = 2,
[Description("报警")] Warn = 3,
[Description("宕机")] Deal,
}
/// <summary>
/// 炉子运行状态
/// </summary>
public enum EStoveWorkMode
{
[Description("空闲")] Free = 0,
[Description("待机")] Standby = 1,
[Description("停止")] Stop = 2,
[Description("工作")] Working = 3,
[Description("保压")] Pressurizing,
}
public enum EStoveSignal
{
[Description("初始化完成信号")]
Initialed,
[Description("露点温度")]
DewTemperature,
[Description("开门到位信号")]
OpenDoorPlace,
[Description("关门到位信号")]
CloseDoorPlace,
[Description("左夹具到位信号")]
TrayDetection1,
[Description("右夹具到位信号")]
TrayDetection2,
[Description("烘烤完成状态")]
BakingMark,
[Description("远程/本地模式")]
Remote, //true:远程, false:本地
[Description("温度")]
Temperature,
[Description("PID输出值")]
PID,
[Description("真空值")]
Vacuum,
[Description("工作时长")] //2024-10-12
WorkTime,
[Description("总工作时长")]
TotalWorkTime,
[Description("系统状态寄存器")]
CavityStatus,
[Description("腔体信号计数")]
CountCavitySignal,
[Description("初始化请求")]
Initial,
[Description("开门请求")]
OpenDoor,
[Description("关门请求")]
CloseDoor,
[Description("心跳")]
Heartbeat,
[Description("托盘记忆1")]
Tray1,
[Description("托盘记忆2")]
Tray2,
[Description("下发参数完成(开始烘烤)")]
BakingStart,
[Description("参数_层烘烤使能")]
HeatEnableStep,
[Description("参数_设定温度")]
SetTemp,
[Description("参数_温度公差")]
TemperatureTolerance,
[Description("参数_温度上限")]
TemperatureLimit,
[Description("参数_真空到达值")]
VacuumArriveValue,
[Description("参数_真空上限")]
VacuumUpValue,
[Description("参数_真空下限")]
VacuumDownValue,
[Description("参数_氮气到达值")]
NitrogenArriveValue,
[Description("参数_氮气上限")]
NitrogenUpValue,
[Description("参数_氮气下限")]
NitrogenDownValue,
[Description("参数_常压到达值")]
AtmosphericArriveValue,
[Description("参数_常压上限")]
AtmosphericUpValue,
[Description("参数_常压下限")]
AtmosphericDownValue,
[Description("参数_循环启动工步")]
CycleStartStep,
[Description("参数_循环结束工步")]
CycleEndStep,
[Description("参数_循环次数")]
CycleNumber,
[Description("参数_加热启用")]
HeatingEnabled,
[Description("参数_真空启用")]
VacuumEnabled,
[Description("参数_氮气启用")]
NitrogenEnabled,
[Description("参数_工步时间")]
StepWorkTime,
[Description("温度上限预警值")]
TemperatureUpperWarnValue,
[Description("真空上限预警值")]
VacuumUpperWarnValue,
}
public enum EMesLogClass
{
[Description("心跳")] EqptAlive = 1,
[Description("设备状态")] Status,
[Description("设备报警")] Alarm,
[Description("参数请求")] ParameterRequest,
[Description("参数变更")] ParameterChange,
[Description("联机请求")] EqptRun,
[Description("电芯状态获取")] GetCellState,
[Description("电芯进站")] EnterStation,
[Description("烘烤过程参数采集")] BakingParameter,
[Description("电芯出站")] ExitStation,
}
public enum EWindowsRowType
{
Upper = 1,
Mid = 2,
Lower = 3
}
public enum EKeyFlag
{
OK = 0,
NG = 1,
ProcessParam = 2
}
public enum EMenuType
{
[Description("视图")] Region = 1,
[Description("功能开关")] FunctionSwitch,
[Description("弹屏")] ShowDialog,
[Description("指令")] Cmd,
[Description("下拉框")] DropDown,
}
public enum ESkin
{
[Description("本色(默认)")] VS2010Theme = 0,
[Description("半透明风格")] Aero,
[Description("Office 2013 蓝色")] Vs2013BlueTheme,
[Description("Office 2013 深色")] Vs2013DarkTheme,
[Description("Office 2013 浅色")] Vs2013LightTheme,
[Description("深色风格")] ExpressionDark,
//[Description("商务")] Background01_png, //商务
//[Description("科技")] background0_png, //科技
//[Description("机械")] back1_png, //机械
//[Description("机械手")] backtest5_png, //机械手
//[Description("红树林")] backtest1_jpg, //红树林
//[Description("海边灯塔")] backtest2_jpg, //海边灯塔
//[Description("深林湖边")] backtest4_jpg //深林湖边
}
public enum EBatteryStatus
{
[Description("初始值")]
Initialise = 0,
[Description("入站验证失败")]
PullInFail = 5,
[Description("扫码完成")]
ScanOver = 10,
[Description("进入托盘")]
ToPallet = 20,
[Description("待水含量测试")]
ToWaterPlatform = 30,
[Description("已经出站")]
Over = 40,
[Description("记录出站")]
OutBoundRecord = 50,
}
public enum EMesUpLoadStatus
{
[Description("待发送")] Wait,
[Description("待发送")] Fail,
[Description("发送成功")] Success,
}
public enum ECavityStatus
{
[Description("未知")] None,
[Description("请放")] RequestPlace = 10, //请求放盘
[Description("请取")] RequestPick = 20, //请求取盘
}
public enum EStartAllow //启动允许
{
[Description("不允许")] Not = 0,
[Description("允许")] Ok,
}
public enum EDeviceStatus //设备状态
{
[Description("未知")] None = 0,
[Description("自动运行中")] Auto = 1,
[Description("停止中")] Stop,
[Description("启动中")] Start,
[Description("准备OK")] Ready,
[Description("初始化中")] Init,
[Description("报警中")] Alarm,
[Description("手动模式")] Manual,
[Description("维修模式")] Maintain,
[Description("模式未选择")] NotSelected,
}
public enum EDummyState
{
[Description("正常电芯")]
NotHave = 0,
[Description("水含量电芯")]
Have = 1,
}
public enum EScanCode
{
[Description("上料1#扫码枪")] LoadingBatteryScan1 = 1,
[Description("上料2#扫码枪")] LoadingBatteryScan2,
[Description("上料3#扫码枪")] LoadingBatteryScan3,
[Description("上料4#扫码枪")] LoadingBatteryScan4,
[Description("上料5#扫码枪")] LoadingBatteryScan5,
[Description("上料6#扫码枪")] LoadingBatteryScan6,
[Description("上料7#扫码枪")] LoadingBatteryScan7,
[Description("上料8#扫码枪")] LoadingBatteryScan8,
[Description("上料假电池扫码枪")] DummyScan,
[Description("1#托盘扫码枪")] PalletScan1,
[Description("2#托盘扫码枪")] PalletScan2,
[Description("下料1#扫码枪")] UnLoadingBatteryScan1,
[Description("下料2#扫码枪")] UnLoadingBatteryScan2,
[Description("下料3#扫码枪")] UnLoadingBatteryScan3,
[Description("下料4#扫码枪")] UnLoadingBatteryScan4,
[Description("下料5#扫码枪")] UnLoadingBatteryScan5,
[Description("下料6#扫码枪")] UnLoadingBatteryScan6,
[Description("下料7#扫码枪")] UnLoadingBatteryScan7,
[Description("下料8#扫码枪")] UnLoadingBatteryScan8,
}
public enum ESysSetup
{
[Description("工序名称")] ProcessName,
[Description("设备编号")] DeviceNum,
[Description("产线编号")] Line,
[Description("白班开始时间")] DayShift,
[Description("晚班开始时间")] NightShift,
[Description("假电池位置X")] DummyLocationX,
[Description("假电池位置Y")] DummyLocationY,
[Description("MOM状态模式")] MOMMode,
[Description("采集周期(ms)")] ReadPLCCycle,
[Description("数据采集周期(秒)")] DataCollectionCycle,
[Description("生产模式(0为调试模式1为正式模式)")] DebugMode, //只用于扫码还是生成条码
[Description("是否启用MOM(0为调试模式1为正式模式)")] MOMEnable,
[Description("扫码模式")] ScanCodeMode, //0:正常扫码1:复投扫码
[Description("数据文件路径")] DataFilePath, //数据路径
[Description("电芯条码长度")] BatteryCodeLen, //
[Description("隔膜含水量判断(小于)")] SeptumwaterTargetJudge,
[Description("负极片含水量判断(小于)")] CathodewaterTargetJudge,
[Description("正极片含水量判断(小于)")] AnodewaterTargetJudge,
[Description("露点温度报警阈值")] DewTempAlarmTargetValue,
}
public enum EDeviceType
{
/*
name:用于类型对应数据库的DType
Description:用于找查对应数据库的Name,另外还有一个编号
*/
[Description("PLC")] PLC = 1,
[Description("MOM")] MOM,
[Description("扫码枪")] SCANNER,
}
public enum EParamType
{
[Description("系统参数")] Sys = 1,
[Description("启用参数")] Enable,
[Description("MOM联机")] MOM,
}
public enum EDeviceName
{
[Description("Plc1")] StovePlc1 = 1,
[Description("Plc2")] StovePlc2,
[Description("Plc3")] StovePlc3,
[Description("Plc4")] StovePlc4,
[Description("Plc5")] StovePlc5,
[Description("上料机")] Loading,
[Description("Robot")] AGV,
[Description("MOM")] Mom,
}
public enum EDispatchMode
{
[Description("自动")]
Auto = 1,
[Description("手动")]
Manual = 2,
}
public enum EStationType
{
[Description("烤箱")] Stove = 1,
[Description("上料机")] Loading,
[Description("下料机")] UnLoading,
[Description("人工上料台")] ManualPlat,
[Description("AGV")] AGV,
[Description("扫码工站")] ScannCode
}
public enum EAgvPLC
{
//写PLC
[Description("心跳")] FromWcsHeart,
[Description("命令号")] Command,
[Description("命令计数")] Count,
[Description("取-工位号")] FromStation,
[Description("取-行号")] FromRow,
[Description("取-列号")] FromCol,
[Description("放-工位号")] ToStation,
[Description("放-行号")] ToRow,
[Description("放-列号")] ToCol,
//读PLC
[Description("反馈心跳")] ToWcsHeart,
[Description("反馈上位机命令")] RetCommand,
[Description("反馈上位机命令计数")] RetCount,
[Description("反馈上位机结果")] ToWcsResult,
}
public enum EAgvStatus
{
[Description("未初始化")] None,
[Description("待机")] Standby,
[Description("运行")] Working,
[Description("停止中")] Stop,
[Description("异常")] Fail,
}
public enum EProductionMode //MES有这二种MES
{
[Description("调试模式")] Debug,
[Description("正常模式")] Normal,
}
public enum EOperTypePLC
{
Readable = 1,
Writable = 2,
ReadWrite = 3
}
public enum EResultFlag //这个是MOM的
{
OK,
NG
}
public enum EResult
{
OK = 1,
NG = 2
}
//public enum EAgvResult
//{
// NG = -1,
// OK = 1,
//}
///// <summary>
///// 日志枚举类型
///// </summary>
public enum E_LogType
{
[Description("调试信息")] Debug = 0,
[Description("提示")] Info = 1,
[Description("警告")] Warn = 2,
[Description("错误")] Error = 3,
[Description("致命错误")] Fatal = 4,
[Description("操作日志")] Operate = 5,
[Description("跟踪")] Trace,
[Description("全部")] All,
}
public enum EAlarmStatus
{
[Description("恢复")] Renew,
[Description("报警")] Alert,
[Description("警告")] Warn
}
public enum EMOMMode
{
[Description("联机模式")] OnLine, //MOM会给设备下达工艺参数信息设备出入站要判断MOM回复信息是否尾OK值如果反馈NG需要将电芯放入到NG口
[Description("离线模式")] OffLine, //设备需要单机记录所有的生产信息以便MOM回复后上传信息
[Description("调机模式")] DebugMachine //设备运行修改MOM提供的工艺参数正常调用出入站接口所有这个模式下产出的电芯都需要放入到NG口待人为判定是否可以进入下一站。调机结束后需要再次调用本接口恢复为联机模式MOM重新下达工艺参数信息
}
public enum EMOMEnable
{
[Description("不启用")] Disable,
[Description("启用")] Enable,
}
public enum EDataType
{
[Description("System.Boolean")] BOOL,
[Description("System.UInt16")] UINT16,
[Description("System.Int16")] INT16,
[Description("System.UInt32")] UINT32,
[Description("System.Int32")] INT32,
[Description("System.String")] STR,
[Description("System.Single")] FLOAT, //REAL-FLOAT 一样
[Description("System.Double")] DOUBLE,
[Description("System.Single")] REAL, //REAL-FLOAT 一样
}
public enum ERole
{
[Description("管理员")]
Admin = 1,
[Description("操作员")]
Operater,
[Description("维修员")]
Mantainer
}
public enum EValidStatus
{
[Description("无效")]
Invalid,
[Description("有效")]
Valid
}
public enum OperTypeEnum
{
[Description("读")]
ParamRead,
[Description("写")]
ParamWrite,
[Description("读写")]
ParamReadWrite
}
public enum EStovePLC
{
[Description("初始化完成信号")]
Initialed,
[Description("开门到位信号")]
OpenDoorPlace,
[Description("关门到位信号")]
CloseDoorPlace,
[Description("左夹具到位信号")]
TrayDetection1,
[Description("右夹具到位信号")]
TrayDetection2,
[Description("烘烤完成状态")]
BakingMark,
[Description("远程/本地模式")]
Remote, //true:远程, false:本地
[Description("温度")]
Temperature,
[Description("真空值")]
Vacuum,
[Description("工作时长")] //2024-10-12
WorkTime,
[Description("系统状态寄存器")]
CavityStatus,
[Description("初始化请求")]
Initial,
[Description("开门请求")]
OpenDoor,
[Description("关门请求")]
CloseDoor,
[Description("心跳")]
Heartbeat,
[Description("托盘记忆1")]
Tray1,
[Description("托盘记忆2")]
Tray2,
[Description("下发参数完成(开始烘烤)")]
BakingStart,
[Description("参数_设定温度")]
SetTemp,
[Description("参数_温度公差")]
TemperatureTolerance,
[Description("参数_温度上限")]
TemperatureLimit,
[Description("参数_真空到达值")]
VacuumArriveValue,
[Description("参数_真空上限")]
VacuumUpValue,
[Description("参数_真空下限")]
VacuumDownValue,
[Description("参数_氮气到达值")]
NitrogenArriveValue,
[Description("参数_氮气上限")]
NitrogenUpValue,
[Description("参数_氮气下限")]
NitrogenDownValue,
[Description("参数_常压到达值")]
AtmosphericArriveValue,
[Description("参数_常压上限")]
AtmosphericUpValue,
[Description("参数_常压下限")]
AtmosphericDownValue,
[Description("参数_循环启动工步")]
CycleStartStep,
[Description("参数_循环结束工步")]
CycleEndStep,
[Description("参数_循环次数")]
CycleNumber,
[Description("参数_加热启用")]
HeatingEnabled,
[Description("参数_真空启用")]
VacuumEnabled,
[Description("参数_氮气启用")]
NitrogenEnabled,
[Description("参数_工步时间")]
StepWorkTime,
[Description("温度上限预警值")]
TemperatureUpperWarnValue,
[Description("真空上限预警值")]
VacuumUpperWarnValue,
}
}

Binary file not shown.

View File

@@ -0,0 +1,78 @@
using Cowain.Bake.Common.Core;
using Cowain.Bake.Model;
using System.Collections.Generic;
namespace Cowain.Bake.Common
{
public static class Global
{
public static string VS = " (V1.0.0.10)";
public const int MAX_READS = 1; //最大读取PLC次数
//public const int LAYER_IN_PALLET = 1;
public const int MAX_TCP_READ_OUTTIME = 500;
public const int SCANCODE_COUNT = 3; //扫码次数
public const int HEARTBEAT_INTERVAL_TIME = 10000;
public const int MAX_QUEUE_SIGNAL = 15;
public static bool AppExit = false;
public static int SECONDS_TO_MILLISCONDS = 1000;
public static int WINDOWS_CONTROLS_HEAD_HIGHT = 30;
public static int STOVE_LAYERS = 14;
public static int PALLET_ROWS = SettingProvider.Instance.PalletRows; //7;
public static int PALLET_COLS = SettingProvider.Instance.PalletCols;
public static int PALLET_TOTAL_BATTERYS = PALLET_ROWS * PALLET_COLS;
public static int PALLET_MAX_BATTERYS = 301;
public static int STOVE_MAX_LAYERS = 21;
public const int ONCE_SCAN_BATTERY = 8; //一次扫码几个电芯
public const int MAX_LOG_QTY = 100;
public const int DEW_STOVE_NUMBER = 3;
/// <summary>
/// 是否测试模式(1为正式生产0为调试模式)
/// </summary>
public static bool DebugMode = true;
}
public static class MyPath
{
public const string MAIN_APP = "D:\\Bake";
public const string PLC = "Cowain.Bake.Communication.PLC.";
public const string SCAN = "Cowain.Bake.Communication.Scan.";
public const string TESTER = "Cowain.Bake.Communication.Tester.";
public const string SCALE = "Cowain.Bake.Communication.ElectronicScale.";
public const string PRINTER = "Cowain.Bake.Communication.Printer.";
public const string SIGNAL_TRIGGER = "Cowain.Bake.Main.Station.";
public const string HEAD_CMD = "Cowain.Bake.Main.Common.HeaderCMD";
public const string MES_INTERFACE = @"D:\MOMlog\{0}\{1}\{2}\{3}\{4}.csv";
public const string SYS_LOG = @"D:\SysLog\{0}\{1}\{2}\{3}.csv";//D:\MESDATE\MES \年份\月份\日期\流水号.csv
public const string MOMDATE = @"D:\MOMDATE\MES\{0}\{1}\{2}\{3}.csv";//设备本地日志文件
}
public static class MyAgvPath
{
//imageSource = "file:///E:/svn/DryingStove/branch/得壹烘烤线6098-006/src/Cowain.Bake.Main/Images/png/RgvError.png"; //​绝对路径
public const string Normal = "pack://application:,,,/Cowain.Bake.Main;component/Images/png/RgvMove.png";
public const string Error = "pack://application:,,,/Cowain.Bake.Main;component/Images/png/RgvError.png";
public const string Wait = "pack://application:,,,/Cowain.Bake.Main;component/Images/png/RgvWait.png";
}
public static class ReflexFun
{
public const string OPC_READ_GROUPS = "ReadGroups";
public const string OPC_READ_SINGLES = "ReadSingles";
public const string TRIG_INSTANCE = "TrigInstance";
public const string TRIG_REPLY = "TrigReply";
public const string TRIG_FUNC = "TrigFunc";
public const string OPC_WRITE_NODE = "WriteNode";
public const string OPC_WRITE_NODES = "WriteNodes";
public const string OBJECT_TO_T = "ObjectToT";
}
public static class ProcessParas
{
public static List<TProcessParameter> processParameters { get; set; }
public static string StopReason { get; set; }
public static string Equipment { get; set; }
public static string Equipment2 { get; set; }
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@@ -0,0 +1,24 @@
using Cowain.Bake.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using static Cowain.Bake.Common.Models.MESModel;
namespace Cowain.Bake.Common.Interface
{
public interface ICommonFun
{
void ModifyOrderNum();
bool ManualTaskCmd(TTaskRecord task, short cmd);
void InitWindows();
void SetBatteryCodeLen();
string ManualMesOutUnBinding(TPalletInfo palletInfo, TBatteryInfo battery);
MESReturnCmdModel SendData(string info); //发送
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cowain.Bake.Common.Interface
{
public interface IDeviceDebug
{
object ExecDebug(string trigJson, string json); //Variable node string trigInfo, string replyJosn
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Cowain.Bake.Common.Interface
{
public interface IRecvMesHttp
{
string RecvInfo(HttpListenerRequest request);
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace Cowain.Bake.Common.Interface
{
public interface IServerManager
{
string Name { get; set; }
IUnityContainer _unityContainer { set; get; }
void Start();
void Stop();
}
}

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