750 lines
30 KiB
C#
750 lines
30 KiB
C#
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();
|
||
// }
|
||
//}
|
||
|
||
//5,4,5一层的水含量
|
||
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();
|
||
}
|
||
}
|
||
}
|
||
}
|