首次提交:添加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

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>