添加项目文件。
This commit is contained in:
178
SamplePre.ProcessBll/BLL/ActionMangerBll.cs
Normal file
178
SamplePre.ProcessBll/BLL/ActionMangerBll.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using DataDAL;
|
||||
using Models.Ext;
|
||||
using Models.Models;
|
||||
using SamplePre.Common;
|
||||
using SamplePre.DAL.DBContext;
|
||||
using SamplePre.Models.Ext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SamplePre.ProcessBll.BLL
|
||||
{
|
||||
public class ActionMangerBll
|
||||
{
|
||||
|
||||
|
||||
|
||||
public int DelProcessParmMap(int id)
|
||||
{
|
||||
|
||||
|
||||
int val = DBFactory.Instance.Deleteable<sys_action_parm_map>().Where(p=>p.id == id).ExecuteCommand();
|
||||
return val;
|
||||
}
|
||||
|
||||
public int DelSysActionData(string actionId)
|
||||
{
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
|
||||
int val = _db.Deleteable<sys_action>().Where(p => p.id == actionId).ExecuteCommand();
|
||||
|
||||
int val2 = _db.Deleteable<sys_action_parm_map>().Where(p => p.process_id == actionId).ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public List<sys_action_parm_map_ext> GetProcess_parm_mapByProcessId(string processId)
|
||||
{
|
||||
|
||||
var result = DBFactory.Instance.Queryable<sys_action_parm_map>()
|
||||
.LeftJoin<sys_parm>((a, b) => a.parm_id == b.id)
|
||||
.Where((a, b) => a.process_id == processId && b.title != null)
|
||||
.Select((a, b) => new sys_action_parm_map_ext
|
||||
{
|
||||
id = a.id,
|
||||
process_id = a.process_id,
|
||||
parm_id = a.parm_id,
|
||||
title = b.title,
|
||||
unit = b.unit,
|
||||
data_type = b.data_type,
|
||||
data_value = b.data_value,
|
||||
plc_type = b.plc_type
|
||||
|
||||
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
|
||||
return result;//standardDal.GetProcess_parm_mapByProcessId(processId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取系统动作字典
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public List<sys_action_ext> GetTreeListSysAction()
|
||||
{
|
||||
|
||||
List<sys_action_ext> treeListItems = new List<sys_action_ext>();
|
||||
|
||||
|
||||
//获取动作
|
||||
List<sys_action_ext> actions = QuerySysAction();
|
||||
|
||||
//拼装组
|
||||
var groups = actions.GroupBy(p => new { p.action_unitname, p.action_unit }).ToList();
|
||||
foreach (var item in groups)
|
||||
{
|
||||
treeListItems.Add(new sys_action_ext()
|
||||
{
|
||||
id = item.Key.action_unit,
|
||||
action_name = item.Key.action_unitname,
|
||||
action_unit = "0"
|
||||
});
|
||||
}
|
||||
|
||||
//组织数据
|
||||
foreach (var item in actions)
|
||||
{
|
||||
treeListItems.Add(item);
|
||||
}
|
||||
|
||||
|
||||
return treeListItems;
|
||||
|
||||
}
|
||||
|
||||
public bool IsExtisPlCcode(string text)
|
||||
{
|
||||
var val = DBFactory.Instance.Queryable<sys_action>().Where(p=>p.plc_type == text).ToList();
|
||||
if(val.Count > 0) return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public List<sys_action_ext> QuerySysAction()
|
||||
{
|
||||
var result = DBFactory.Instance.Queryable<sys_action>()
|
||||
.LeftJoin<sys_dict>((a, s) => a.action_unit == s.id)
|
||||
.Where((a, s) => s.class_id == 2)
|
||||
.Select((a, s) => new sys_action_ext
|
||||
{
|
||||
id = a.id,
|
||||
action_name = a.action_name,
|
||||
action_unit = a.action_unit,
|
||||
action_adress = a.action_adress,
|
||||
plc_type = a.plc_type,
|
||||
remark = a.remark,
|
||||
action_unitname = s.data_value
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询系统动作参数
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public List<sys_parm> QuerySysParm()
|
||||
{
|
||||
//string querySql = "select * from sys_parm ";
|
||||
List<sys_parm> data = DBFactory.Instance.Queryable<sys_parm>().ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存动作中的参数
|
||||
/// </summary>
|
||||
/// <param name="actionParams"></param>
|
||||
public int SaveActionParm(List<sys_action_parm_map> actionParams)
|
||||
{
|
||||
|
||||
int val = DBFactory.Instance.Insertable(actionParams).ExecuteCommand();
|
||||
return val;
|
||||
}
|
||||
|
||||
public int SaveSysAction(sys_action process)
|
||||
{
|
||||
int val = DBFactory.Instance.Insertable(process).ExecuteCommand();
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
80
SamplePre.ProcessBll/BLL/CommunicationBll.cs
Normal file
80
SamplePre.ProcessBll/BLL/CommunicationBll.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Models.Const;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SamplePre.ProcessBll.BLL
|
||||
{
|
||||
public class CommunicationBll
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 读取PLC状态数据-数组
|
||||
/// </summary>
|
||||
/// <param name="Dbno"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="lenth"></param>
|
||||
/// <returns></returns>
|
||||
public ushort[] ReadSateData(int Dbno, int start, int lenth)
|
||||
{
|
||||
|
||||
if (SystemConst.ProtocolType == Communication.CommProtocolType.S7)
|
||||
{
|
||||
//读取下位机状态
|
||||
ushort[] data1 = SystemConst.MasterPLC.ReadArraysShort(Dbno, start, lenth);
|
||||
|
||||
return data1;
|
||||
}
|
||||
|
||||
//这里应该增加一个协议数据解析层,解析后的格式返回给UI,后续完善
|
||||
///
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入plc指令,字节数组
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="Dbno"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="bytes"></param>
|
||||
/// <returns></returns>
|
||||
public bool WritePlcData<T>(int Dbno, int start, T[] bytes)
|
||||
{
|
||||
bool val = false;
|
||||
//if (SystemConst.ProtocolType == Communication.CommProtocolType.S7)
|
||||
//{
|
||||
//写入PLC
|
||||
val = SystemConst.MasterPLC.WriteArraysBtye(Dbno, start, bytes);
|
||||
//}
|
||||
//else if (SystemConst.ProtocolType == Communication.CommProtocolType.ModbusTcp)
|
||||
//{
|
||||
// //写入PLC
|
||||
// val = SystemConst.MasterPLC.WriteArraysBtye(Dbno, start, bytes);
|
||||
//}
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写plc数据,单数据
|
||||
/// </summary>
|
||||
/// <param name="Dbno"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public bool WriteSingleData(string Dbno, object obj)
|
||||
{
|
||||
//写入PLC
|
||||
var val = SystemConst.MasterPLC.WriteSingleData(Dbno, obj);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
50
SamplePre.ProcessBll/BLL/MonitorBll.cs
Normal file
50
SamplePre.ProcessBll/BLL/MonitorBll.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using DataDAL;
|
||||
using DataDAL.DBContext;
|
||||
using Models.Const;
|
||||
using Models.Models;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using SamplePre.Common;
|
||||
using SamplePre.Communication;
|
||||
using SamplePre.DAL;
|
||||
using SamplePre.DAL.DBContext;
|
||||
using SamplePre.Models.Ext;
|
||||
using SamplePre.Models.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SamplePre.ProcessBll.SampleSequence
|
||||
{
|
||||
/// <summary>
|
||||
/// 样本序列管理业务逻辑
|
||||
/// </summary>
|
||||
public class MonitorBll
|
||||
{
|
||||
SampleSequenceDal sampleSequenceDal = new SampleSequenceDal();
|
||||
|
||||
|
||||
|
||||
SOPDal sopDal = new SOPDal();
|
||||
|
||||
|
||||
public List<sys_dict> GetSampleType()
|
||||
{
|
||||
|
||||
|
||||
List<sys_dict> data = DBFactory.Instance.Queryable<sys_dict>().Where(p => p.class_id == 3).ToList();
|
||||
|
||||
return data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
518
SamplePre.ProcessBll/BLL/SOPManagerBll.cs
Normal file
518
SamplePre.ProcessBll/BLL/SOPManagerBll.cs
Normal file
@@ -0,0 +1,518 @@
|
||||
using DataDAL;
|
||||
using Models.Const;
|
||||
using Models.Ext;
|
||||
using Models.Models;
|
||||
using Newtonsoft.Json;
|
||||
using SamplePre.Common;
|
||||
using SamplePre.DAL;
|
||||
using SamplePre.DAL.DBContext;
|
||||
using SamplePre.Models;
|
||||
using SamplePre.Models.Ext;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
|
||||
namespace SamplePre.ProcessBll.BLL
|
||||
{
|
||||
public class SOPManagerBll
|
||||
{
|
||||
|
||||
SOPDal sopDal = new SOPDal();
|
||||
|
||||
public List<sys_action_parm_map_ext> GetActionParmById(string actionID)
|
||||
{
|
||||
|
||||
var result = DBFactory.Instance.Queryable<sys_action_parm_map>()
|
||||
.LeftJoin<sys_parm>((a, b) => a.parm_id == b.id)
|
||||
.Where((a, b) => a.process_id == actionID && b.title != null)
|
||||
.Select((a, b) => new sys_action_parm_map_ext
|
||||
{
|
||||
id = a.id,
|
||||
process_id = a.process_id,
|
||||
parm_id = a.parm_id,
|
||||
title = b.title,
|
||||
unit = b.unit,
|
||||
data_type = b.data_type,
|
||||
data_value = b.data_value,
|
||||
plc_type = b.plc_type
|
||||
|
||||
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
//List<sys_action_parm_map_ext> paramsList = standardDal.GetProcess_parm_mapByProcessId(actionID);
|
||||
return result;//paramsList;
|
||||
}
|
||||
|
||||
|
||||
public List<sys_standard_action_parm_ext> GetStrandActionParamByStrandId(string standId)
|
||||
{
|
||||
|
||||
var result = DBFactory.Instance.Queryable<sys_standard_action_parm>()
|
||||
.LeftJoin< sys_action >((a,b)=>a.action_id == b.id)
|
||||
.LeftJoin< sys_parm >((a,b,c)=>a.parm_id == c.id)
|
||||
.Where((a,b,c)=>a.standard_id == standId)
|
||||
.OrderBy((a,b,c)=>a.action_seqno)
|
||||
.Select((a,b,c)=> new sys_standard_action_parm_ext {
|
||||
id = a.id,
|
||||
standard_id = a.standard_id,
|
||||
action_id = a.action_id,
|
||||
action_seqno = a.action_seqno,
|
||||
parm_id = a.parm_id,
|
||||
parm_seqno = a.parm_seqno,
|
||||
standard_process_id = a.standard_process_id,
|
||||
data_value = a.data_value,
|
||||
action_name = b.action_name,
|
||||
title = c.title,
|
||||
unit = c.unit,
|
||||
data_type = c.data_type,
|
||||
plc_type = c.plc_type
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
//List<sys_standard_action_parm_ext> paramsList = sopDal.GetStrandActionParamByStrandId(standId);
|
||||
return result; //paramsList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除动作下的参数配置
|
||||
/// </summary>
|
||||
/// <param name="standId"></param>
|
||||
/// <param name="actionId"></param>
|
||||
/// <param name="seqno"></param>
|
||||
public int removeActionParmByActionId(string standId, string actionId, int seqno)
|
||||
{
|
||||
|
||||
var val = DBFactory.Instance.Deleteable<sys_standard_action_parm>(p => p.standard_id == standId && p.action_id == actionId && p.action_seqno == seqno)
|
||||
.ExecuteCommand();
|
||||
return val;
|
||||
//sopDal.removeActionParmByActionId(standId, actionId, seqno);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除动作下的参数配置byid
|
||||
/// </summary>
|
||||
/// <param name="standId"></param>
|
||||
/// <param name="actionId"></param>
|
||||
/// <param name="seqno"></param>
|
||||
public int removeActionParmByParamId(string standId, string actionId, int seqno,string paramId)
|
||||
{
|
||||
|
||||
var val = DBFactory.Instance.Deleteable<sys_standard_action_parm>(p => p.standard_id == standId && p.action_id == actionId && p.action_seqno == seqno && p.parm_id == paramId)
|
||||
.ExecuteCommand();
|
||||
return val;
|
||||
//sopDal.removeActionParmByActionId(standId, actionId, seqno);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int updateStandardActionParm(sys_standard_action_parm item)
|
||||
{
|
||||
//sopDal.updateStandardActionParm(item);
|
||||
|
||||
int val = DBFactory.Instance.Updateable<sys_standard_action_parm>()
|
||||
.SetColumns(p=> new sys_standard_action_parm() { data_value = item.data_value })
|
||||
.Where(p=>p.id == item.id)
|
||||
.ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public bool IsExisAction(string actionId)
|
||||
{
|
||||
|
||||
List<sys_standard_action_parm> data = DBFactory.Instance.Queryable<sys_standard_action_parm>().Where(p => p.action_id == actionId).ToList();
|
||||
|
||||
return data.Count() > 0 ? true : false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<sys_standard_action_ext> QueryStandardActionByStandardId(string standId)
|
||||
{
|
||||
|
||||
var result = DBFactory.Instance.Queryable<sys_standard_action>().
|
||||
LeftJoin<sys_action>((a, b) => a.process_id == b.id).
|
||||
Where((a, b) => a.standard_id == standId).
|
||||
Select((a, b) => new sys_standard_action_ext {
|
||||
id = a.id,
|
||||
standard_id = a.standard_id,
|
||||
process_id = a.process_id,
|
||||
process_no = a.process_no,
|
||||
action_name = b.action_name,
|
||||
remark = b.remark
|
||||
}).ToList();
|
||||
|
||||
|
||||
return result;//standardDal.QueryStandardActionByStandardId(standId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新动作序号
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateActionSeqno(sys_standard_action_ext action)
|
||||
{
|
||||
// return sopDal.UpdateActionSeqno(action);
|
||||
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
var val = _db.Updateable<sys_standard_action>()
|
||||
.SetColumns(it => new sys_standard_action() { process_no = action.new_action_seqno })
|
||||
.Where(p => p.standard_id == action.standard_id && p.process_id == action.process_id && p.process_no == action.process_no)
|
||||
.ExecuteCommand();
|
||||
|
||||
|
||||
////参数里的动作顺序
|
||||
var val2 = _db.Updateable<sys_standard_action_parm>()
|
||||
.SetColumns(it => new sys_standard_action_parm() { action_seqno = action.new_action_seqno })
|
||||
.Where(p => p.standard_id == action.standard_id && p.action_id == action.process_id && p.action_seqno == action.process_no)
|
||||
.ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除标准,及标准下的所有配置
|
||||
/// </summary>
|
||||
/// <param name="iD"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int DelStandardActionParamByStandId(string standardId)
|
||||
{
|
||||
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
|
||||
_db.Deleteable<sys_standard>().Where(p => p.id == standardId).ExecuteCommand();
|
||||
_db.Deleteable<sys_standard_action>().Where(p => p.standard_id == standardId).ExecuteCommand();
|
||||
_db.Deleteable<sys_standard_action_parm>().Where(p => p.standard_id == standardId).ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
//return sopDal.DelStandardActionParamByStandId(iD);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取标准下的动作,动作中包含参数的预览
|
||||
/// </summary>
|
||||
/// <param name="standID"></param>
|
||||
/// <returns></returns>
|
||||
public List<sys_standard_action_ext> QueryStandardProcessByStandardId(string standID)
|
||||
{
|
||||
return sopDal.QueryStandardProcessByStandardId(standID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存标准动作表、动作参数表
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public int SaveStandardAction_param(sys_standard_action action)
|
||||
{
|
||||
//return standardDal.Save_standard_process_map(procemodel);
|
||||
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
//保存标准动作
|
||||
_db.Insertable<sys_standard_action>(action).ExecuteCommand();
|
||||
|
||||
|
||||
//保存标准动作参数表
|
||||
//获取动作下的参数
|
||||
List<sys_action_parm_map_ext> paramList = GetActionParmById(action.process_id);
|
||||
List<sys_standard_action_parm> new_parms = new List<sys_standard_action_parm>();
|
||||
foreach (var item in paramList)
|
||||
{
|
||||
//保存标准动作参数表
|
||||
sys_standard_action_parm parmmodel = new sys_standard_action_parm()
|
||||
{
|
||||
id = Guid.NewGuid().ToString(),
|
||||
standard_id = action.standard_id,
|
||||
action_id = action.process_id,
|
||||
action_seqno = action.process_no,
|
||||
parm_id = item.parm_id,
|
||||
data_value = item.data_value,
|
||||
parm_seqno = item.id
|
||||
};
|
||||
new_parms.Add(parmmodel);
|
||||
}
|
||||
_db.Insertable<sys_standard_action_parm>(new_parms).ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// sop导出
|
||||
/// </summary>
|
||||
/// <param name="sysStandardId"></param>
|
||||
public void ExprotSop(string sysStandardId ,string filePath)
|
||||
{
|
||||
//标准信息
|
||||
sys_standard sysStandard = DBFactory.Instance.Queryable<sys_standard>().Where(p=>p.id == sysStandardId).Single();
|
||||
|
||||
//标准动作信息
|
||||
List<sys_standard_action> standardActions = DBFactory.Instance.Queryable<sys_standard_action>().Where(p => p.standard_id == sysStandardId).ToList();
|
||||
|
||||
//标准动作信息
|
||||
List<sys_standard_action_parm> standardActionsParams = DBFactory.Instance.Queryable<sys_standard_action_parm>().Where(p => p.standard_id == sysStandardId).ToList();
|
||||
|
||||
|
||||
SopDataInfo sopDataInfo = new SopDataInfo();
|
||||
sopDataInfo.sysStandard = sysStandard;
|
||||
sopDataInfo.sysStandActions = standardActions;
|
||||
sopDataInfo.sysStandardActionParms = standardActionsParams;
|
||||
|
||||
|
||||
// 2. 序列化:格式化易读、保留中文
|
||||
string jsonStr = JsonConvert.SerializeObject(sopDataInfo);
|
||||
|
||||
// 3. 写入TXT文件
|
||||
File.WriteAllText(filePath, jsonStr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入SOP
|
||||
/// </summary>
|
||||
/// <param name="selectFilePath"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public bool ImportSop(string selectFilePath)
|
||||
{
|
||||
|
||||
string fileContent = File.ReadAllText(selectFilePath, System.Text.Encoding.UTF8);
|
||||
|
||||
SopDataInfo sopDataInfo = JsonConvert.DeserializeObject<SopDataInfo>(fileContent);
|
||||
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
//开始事务
|
||||
_db.BeginTran();
|
||||
|
||||
//标准
|
||||
sopDataInfo.sysStandard.id = Guid.NewGuid().ToString();
|
||||
sopDataInfo.sysStandard.standard_name = sopDataInfo.sysStandard.standard_name + "_imp";
|
||||
DBFactory.Instance.Insertable<sys_standard>(sopDataInfo.sysStandard).ExecuteCommand();
|
||||
|
||||
|
||||
//标准动作
|
||||
foreach (var item in sopDataInfo.sysStandActions)
|
||||
{
|
||||
item.id = Guid.NewGuid().ToString();
|
||||
item.standard_id = sopDataInfo.sysStandard.id;
|
||||
}
|
||||
DBFactory.Instance.Insertable<sys_standard_action>(sopDataInfo.sysStandActions).ExecuteCommand();
|
||||
//标准动作参数
|
||||
foreach (var item in sopDataInfo.sysStandardActionParms)
|
||||
{
|
||||
item.id = Guid.NewGuid().ToString();
|
||||
item.standard_id = sopDataInfo.sysStandard.id;
|
||||
}
|
||||
DBFactory.Instance.Insertable<sys_standard_action_parm>(sopDataInfo.sysStandardActionParms).ExecuteCommand();
|
||||
|
||||
//提交事务
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取左侧标准树
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public List<TreeListItem> GetStandardData()
|
||||
{
|
||||
List<TreeListItem> treeListItems = new List<TreeListItem>();
|
||||
|
||||
//获取样本
|
||||
List<sys_dict> yangbens = SystemConst.dictDatas.Where(p => p.class_id == 3).ToList(); //sopBll.QueryGyData(); //standardDal.QueryGyData();
|
||||
|
||||
foreach (var item in yangbens)
|
||||
{
|
||||
treeListItems.Add(new TreeListItem() { ID = item.id, DisplayText = item.data_value, ParentID = "0" });
|
||||
}
|
||||
|
||||
//获取标准
|
||||
List<sys_standard> SopList = QueryAllGyStandards(); //standardDal.QueryAllGyStandards();
|
||||
foreach (var item in SopList)
|
||||
{
|
||||
treeListItems.Add(new TreeListItem() { ID = item.id, DisplayText = item.standard_name, ParentID = item.sample_id });
|
||||
}
|
||||
|
||||
return treeListItems;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有标准
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<sys_standard> QueryAllGyStandards()
|
||||
{
|
||||
List<sys_standard> data = DBFactory.Instance.Queryable<sys_standard>().ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取动作字典
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public List<sys_action_ext> QuerySysAction()
|
||||
{
|
||||
var result = DBFactory.Instance.Queryable<sys_action>()
|
||||
.LeftJoin<sys_dict>((a, s) => a.action_unit == s.id)
|
||||
.Where((a, s) => s.class_id == 2)
|
||||
.Select((a, s) => new sys_action_ext
|
||||
{
|
||||
id = a.id,
|
||||
action_name = a.action_name,
|
||||
action_unit = a.action_unit,
|
||||
action_adress = a.action_adress,
|
||||
plc_type = a.plc_type,
|
||||
remark = a.remark,
|
||||
action_unitname = s.data_value
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除标准的动作
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
public void removeStandAction(sys_standard_action_ext sysStandardAction)
|
||||
{
|
||||
//移除动作
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
|
||||
var va11 = _db.Deleteable<sys_standard_action>(p => p.id == sysStandardAction.id).ExecuteCommand();
|
||||
|
||||
//移除动作下的参数配置
|
||||
var val2 = _db.Deleteable<sys_standard_action_parm>(p => p.standard_id == sysStandardAction.standard_id
|
||||
&& p.action_id == sysStandardAction.process_id
|
||||
&& p.action_seqno == sysStandardAction.process_no).ExecuteCommand();
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存动作参数配置
|
||||
/// </summary>
|
||||
/// <param name="actionParms"></param>
|
||||
/// <returns></returns>
|
||||
public int SaveStandardActionParam(List<sys_standard_action_parm> actionParms)
|
||||
{
|
||||
int val = DBFactory.Instance.Insertable<sys_standard_action_parm>(actionParms).ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public int SaveStandardCopy(sys_standard new_sysStandard, List<sys_standard_action> newStandActions, List<sys_standard_action_parm> sysStandardActionParms)
|
||||
{
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
|
||||
_db.Insertable<sys_standard>(new_sysStandard).ExecuteCommand();
|
||||
|
||||
_db.Insertable<sys_standard_action>(newStandActions).ExecuteCommand();
|
||||
|
||||
_db.Insertable<sys_standard_action_parm>(sysStandardActionParms).ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
539
SamplePre.ProcessBll/BLL/SampleSequenceBll.cs
Normal file
539
SamplePre.ProcessBll/BLL/SampleSequenceBll.cs
Normal file
@@ -0,0 +1,539 @@
|
||||
using DataDAL;
|
||||
using DataDAL.DBContext;
|
||||
using Models.Models;
|
||||
using SamplePre.Common;
|
||||
using SamplePre.DAL;
|
||||
using SamplePre.DAL.DBContext;
|
||||
using SamplePre.Models.Ext;
|
||||
using SamplePre.Models.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.Odbc;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SamplePre.ProcessBll.SampleSequence
|
||||
{
|
||||
/// <summary>
|
||||
/// 样本序列管理业务逻辑
|
||||
/// </summary>
|
||||
public class SampleSequenceBll
|
||||
{
|
||||
SampleSequenceDal sampleSequenceDal = new SampleSequenceDal();
|
||||
|
||||
|
||||
|
||||
SOPDal sopDal = new SOPDal();
|
||||
|
||||
|
||||
public List<sys_dict> GetSampleType()
|
||||
{
|
||||
|
||||
|
||||
List<sys_dict> data = DBFactory.Instance.Queryable<sys_dict>().Where(p => p.class_id == 3).ToList();
|
||||
|
||||
return data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取标准动作参数
|
||||
/// </summary>
|
||||
/// <param name="standId"></param>
|
||||
/// <returns></returns>
|
||||
public List<sys_standard_action_parm_ext> GetStrandActionParamByStrandId(string standId)
|
||||
{
|
||||
var result = DBFactory.Instance.Queryable<sys_standard_action_parm>()
|
||||
.LeftJoin<sys_action>((a, b) => a.action_id == b.id)
|
||||
.LeftJoin<sys_parm>((a, b, c) => a.parm_id == c.id)
|
||||
.LeftJoin<sys_standard>((a, b, c,d) => a.standard_id == d.id)
|
||||
.Where((a, b, c, d) => a.standard_id == standId)
|
||||
.OrderBy((a, b, c, d) => a.action_seqno)
|
||||
.Select((a, b, c, d) => new sys_standard_action_parm_ext
|
||||
{
|
||||
id = a.id,
|
||||
standard_id = a.standard_id,
|
||||
action_id = a.action_id,
|
||||
action_seqno = a.action_seqno,
|
||||
parm_id = a.parm_id,
|
||||
parm_seqno = a.parm_seqno,
|
||||
standard_process_id = a.standard_process_id,
|
||||
data_value = a.data_value,
|
||||
action_name = b.action_name,
|
||||
title = c.title,
|
||||
unit = c.unit,
|
||||
data_type = c.data_type,
|
||||
plc_type = c.plc_type,
|
||||
actionAndseqno = $"{d.standard_name}: {a.action_seqno}{b.action_name}"
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
|
||||
//List<sys_standard_action_parm_ext> datas = sopDal.GetStrandActionParamByStrandId(standId);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<sys_action_ext> QuerySysAction()
|
||||
{
|
||||
var result = DBFactory.Instance.Queryable<sys_action>()
|
||||
.LeftJoin<sys_dict>((a, s) => a.action_unit == s.id)
|
||||
.Where((a, s) => s.class_id == 2)
|
||||
.Select((a, s) => new sys_action_ext
|
||||
{
|
||||
id = a.id,
|
||||
action_name = a.action_name,
|
||||
action_unit = a.action_unit,
|
||||
action_adress = a.action_adress,
|
||||
plc_type = a.plc_type,
|
||||
remark = a.remark,
|
||||
action_unitname = s.data_value
|
||||
})
|
||||
.ToList();
|
||||
|
||||
//List<sys_action_ext> sysActions = standardDal.QuerySysAction();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public int DelTubeInputByCode(string code)
|
||||
{
|
||||
|
||||
|
||||
int val = DBFactory.Instance.Deleteable<tube_input>().Where(p => p.qrcode == code).ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存下发命令记录
|
||||
/// </summary>
|
||||
/// <param name="cmdExec"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int SaveCmdExec(sample_exec_ext cmdExec)
|
||||
{
|
||||
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
|
||||
//主记录
|
||||
int val = _db.Insertable<sample_exec>(cmdExec).ExecuteCommand();
|
||||
//明细
|
||||
int val2 = _db.Insertable<sample_exec_detail>(cmdExec.sampleExecDetails).ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
public List<sys_standard> QuerySysStandards(string sampleId)
|
||||
{
|
||||
|
||||
List<sys_standard> data = DBFactory.Instance.Queryable<sys_standard>().Where(p => p.sample_id == sampleId).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public string QueryQrcode()
|
||||
{
|
||||
string qrcode = "";
|
||||
|
||||
List<sys_dict> data = DBFactory.Instance.Queryable<sys_dict>().Where(p => p.class_id == 1).ToList();
|
||||
if (data.Count > 0)
|
||||
{
|
||||
qrcode = (int.Parse(data[0].data_value) + 1).ToString("0000");
|
||||
}
|
||||
return qrcode;
|
||||
|
||||
}
|
||||
|
||||
public int SaveDataAndQrcode(tube_input qRcode, sys_dict sys_Dict)
|
||||
{
|
||||
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
|
||||
//保存样品记录
|
||||
_db.Insertable<tube_input>(qRcode).ExecuteCommand();
|
||||
|
||||
//更新二维码
|
||||
int val = _db.Updateable<sys_dict>()
|
||||
.SetColumns(p => new sys_dict() { data_value = sys_Dict.data_value })
|
||||
.Where(p => p.class_id == 1)
|
||||
.ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public List<tube_input> GetTubeData(DateTime dt1, DateTime dt2)
|
||||
{
|
||||
List<tube_input> data = DBFactory.Instance.Queryable<tube_input>().Where(p => p.input_date >= dt1 && p.input_date <= dt2).ToList();
|
||||
|
||||
|
||||
return data;;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成指令字节数组byte
|
||||
/// </summary>
|
||||
/// <param name="sysAction"></param>
|
||||
/// <param name="standardProcessParms"></param>
|
||||
/// <returns></returns>
|
||||
public List<byte> CreateCmdBytes(List<sys_action_ext> sysAction, List<string> sopIds, List<sys_standard_action_parm_ext> standardProcessParms)
|
||||
{
|
||||
string cmdReamrk = "";
|
||||
|
||||
List<byte> sop = new List<byte>();
|
||||
|
||||
try
|
||||
{
|
||||
//起始位
|
||||
sop.Insert(0, 0xCC);
|
||||
cmdReamrk += $"【0 开始:{sop[0]}】 ";
|
||||
|
||||
//插入总字节数-占位
|
||||
sop.Insert(1, 0);
|
||||
//cmdReamrk += $"【1 总字节数:{Convert.ToByte(seq + 1)}】 ";
|
||||
|
||||
//插入总动作数
|
||||
sop.Insert(2, 0);
|
||||
//cmdReamrk += $"【2 总动作数:0】 ";
|
||||
|
||||
int seq = 3;
|
||||
|
||||
//总动作数
|
||||
int actionCount = 0;
|
||||
//===============
|
||||
foreach (string standrad_id in sopIds)
|
||||
{
|
||||
//查询标准下的动作
|
||||
var standardActions = GetStrandActionByStrandId(standrad_id);
|
||||
//动作排序
|
||||
standardActions = standardActions.OrderBy(p => p.process_no).ToList();
|
||||
|
||||
actionCount += standardActions.Count();
|
||||
|
||||
foreach (var actionItem in standardActions)
|
||||
{
|
||||
//int start = seq; //记录起始位置
|
||||
|
||||
//转换PLC映射名称
|
||||
string action_plc = sysAction.FirstOrDefault(p => p.id == actionItem.process_id)?.plc_type;
|
||||
//动作类型(如:离心)
|
||||
byte action_byte = Convert.ToByte(action_plc);
|
||||
sop.Insert(seq, action_byte);
|
||||
cmdReamrk += $"【{seq} 动作:{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
//查询动作下的参数
|
||||
var paramData = standardProcessParms.Where(p => p.action_id == actionItem.process_id && p.action_seqno == actionItem.process_no && p.standard_id == standrad_id).ToList();
|
||||
//插入动作字节长度
|
||||
int actionLenth = (int)(paramData.Count() * 5 + 2);
|
||||
sop.Insert(seq, (byte)actionLenth);
|
||||
cmdReamrk += $"【{seq} 动作字节长度:{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
foreach (var item in paramData)
|
||||
{
|
||||
//转换plc参数类型
|
||||
string param_plc = item.plc_type;//parms.FirstOrDefault(p => p.title == item.title).plc_type;
|
||||
|
||||
//参数类型(如:时间)
|
||||
byte parm_byte = Convert.ToByte(param_plc);
|
||||
sop.Insert(seq, parm_byte);
|
||||
cmdReamrk += $"【{seq} 参数类型:{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
|
||||
sys_standard_action_parm_ext actionParm = standardProcessParms.FirstOrDefault(p => p.title == item.title);
|
||||
string param_val = actionParm.data_value;
|
||||
if (actionParm.unit.ToUpper() == "ML") //都转换成最小单位ul
|
||||
{
|
||||
param_val = (float.Parse(param_val) * 1000).ToString();
|
||||
}
|
||||
|
||||
|
||||
//参数值
|
||||
float paramval = 0;
|
||||
paramval = float.Parse(param_val);
|
||||
|
||||
cmdReamrk += $"【{seq} 参数值float:{paramval}】 ";
|
||||
|
||||
|
||||
byte[] paramval_bytes = BitConverter.GetBytes(paramval);
|
||||
|
||||
sop.Insert(seq, paramval_bytes[0]);
|
||||
cmdReamrk += $"【{seq} 参数值byte:{sop[seq]}-";
|
||||
seq++;
|
||||
sop.Insert(seq, paramval_bytes[1]);
|
||||
cmdReamrk += $"{sop[seq]}-";
|
||||
seq++;
|
||||
sop.Insert(seq, paramval_bytes[2]);
|
||||
cmdReamrk += $"{sop[seq]}-";
|
||||
seq++;
|
||||
sop.Insert(seq, paramval_bytes[3]);
|
||||
cmdReamrk += $"{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//结束
|
||||
sop.Insert(seq, 0xEE);
|
||||
cmdReamrk += $"【{seq} 结束:{sop[seq]}-";
|
||||
seq++;
|
||||
sop.Insert(seq, 0xEE);
|
||||
cmdReamrk += $"{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
|
||||
//修改总字节数
|
||||
sop[1] = (byte)sop.Count;
|
||||
cmdReamrk += $"【1 总字节数:{sop[1]}】 ";
|
||||
|
||||
//修改总动作数据
|
||||
sop[2] = (byte)actionCount;
|
||||
cmdReamrk += $"【2 总动作数:{sop[2]}】 ";
|
||||
|
||||
LoggerHelper.Logger.Info($"{cmdReamrk}");
|
||||
|
||||
|
||||
return sop;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
LoggerHelper.Logger.Error(ex.StackTrace);
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成指令字节数组ushort
|
||||
/// </summary>
|
||||
/// <param name="sysAction"></param>
|
||||
/// <param name="standardProcessParms"></param>
|
||||
/// <returns></returns>
|
||||
public List<ushort> CreateCmdUshorts(List<sys_action_ext> sysAction, List<sys_standard_action_ext> standardActions, List<sys_standard_action_parm_ext> standardProcessParms)
|
||||
{
|
||||
string cmdReamrk = "";
|
||||
|
||||
List<ushort> sop = new List<ushort>();
|
||||
|
||||
try
|
||||
{
|
||||
//起始位
|
||||
sop.Insert(0, 0xCC);
|
||||
cmdReamrk += $"【0 开始:{sop[0]}】 ";
|
||||
|
||||
//插入总字节数
|
||||
sop.Insert(1, 0);
|
||||
//cmdReamrk += $"【1 总字节数:{0}】 ";
|
||||
|
||||
//插入总动作数
|
||||
sop.Insert(2, Convert.ToByte(standardActions.Count()));
|
||||
cmdReamrk += $"【2 总动作数:{Convert.ToByte(standardActions.Count())}】 ";
|
||||
|
||||
|
||||
|
||||
int seq = 3;
|
||||
foreach (var actionItem in standardActions)
|
||||
{
|
||||
int start = seq; //记录起始位置
|
||||
|
||||
//转换PLC映射名称
|
||||
string action_plc = sysAction.FirstOrDefault(p => p.id == actionItem.process_id)?.plc_type;
|
||||
//动作类型(如:离心)
|
||||
ushort action_byte = Convert.ToUInt16(action_plc);
|
||||
sop.Insert(seq, action_byte);
|
||||
cmdReamrk += $"【{seq} 动作:{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
//查询动作下的参数
|
||||
var paramData = standardProcessParms.Where(p => p.action_id == actionItem.process_id && p.action_seqno == actionItem.process_no).ToList();
|
||||
//插入动作寄存器长度
|
||||
int actionLenth = (int)(paramData.Count() * 3 + 2);
|
||||
sop.Insert(seq, (byte)actionLenth);
|
||||
cmdReamrk += $"【{seq} 动作长度:{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
foreach (var item in paramData)
|
||||
{
|
||||
//转换plc参数类型
|
||||
string param_plc = item.plc_type;//parms.FirstOrDefault(p => p.title == item.title).plc_type;
|
||||
|
||||
//参数类型(如:时间)
|
||||
ushort parm_byte = Convert.ToUInt16(param_plc);
|
||||
sop.Insert(seq, parm_byte);
|
||||
cmdReamrk += $"【{seq} 参数类型:{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
|
||||
sys_standard_action_parm_ext actionParm = standardProcessParms.FirstOrDefault(p => p.title == item.title);
|
||||
string param_val = actionParm.data_value;
|
||||
if (actionParm.unit.ToUpper() == "ML") //都转换成最小单位ul
|
||||
{
|
||||
param_val = (float.Parse(param_val) * 1000).ToString();
|
||||
}
|
||||
|
||||
|
||||
//参数值
|
||||
float paramval = 0;
|
||||
paramval = float.Parse(param_val);
|
||||
|
||||
cmdReamrk += $"【{seq} 参数值float:{paramval}】 ";
|
||||
|
||||
//===float转ushort数组
|
||||
byte[] bytes = BitConverter.GetBytes(paramval);
|
||||
var a = BitConverter.ToUInt16(new byte[] { bytes[0], bytes[1] }, 0);
|
||||
var b = BitConverter.ToUInt16(new byte[] { bytes[2], bytes[3] }, 0);
|
||||
|
||||
ushort[] ushorts = { b, a };
|
||||
|
||||
sop.Insert(seq, ushorts[0]);
|
||||
cmdReamrk += $"【{seq} 参数值ushort:{sop[seq]}-";
|
||||
seq++;
|
||||
|
||||
sop.Insert(seq, ushorts[1]);
|
||||
cmdReamrk += $"{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
//============
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//结束
|
||||
sop.Insert(seq, 0xEE);
|
||||
cmdReamrk += $"【{seq} 结束:{sop[seq]}-";
|
||||
seq++;
|
||||
sop.Insert(seq, 0xEE);
|
||||
cmdReamrk += $"{sop[seq]}】 ";
|
||||
seq++;
|
||||
|
||||
|
||||
//修改总寄存器数量
|
||||
sop[1] = (ushort)sop.Count;
|
||||
cmdReamrk += $"【1 总寄存器数:{sop[1]}】 ";
|
||||
|
||||
LoggerHelper.Logger.Info($"{cmdReamrk}");
|
||||
|
||||
|
||||
return sop;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
LoggerHelper.Logger.Error(ex.StackTrace);
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<sample_exec_detail_ext> GetSampleExecDetails()
|
||||
{
|
||||
var result = DBFactory.Instance.Queryable<sample_exec_detail>()
|
||||
.LeftJoin<sample_exec>((a, b) => a.master_id == b.id)
|
||||
.LeftJoin<tube_input>((a, b, c) => a.qrcode == c.qrcode)
|
||||
.Where((a, b, c) => b.exec_state == "执行中")
|
||||
.Select((a, b, c) => new sample_exec_detail_ext {
|
||||
id = a.id,
|
||||
master_id = a.master_id,
|
||||
qrcode = a.qrcode,
|
||||
exec_state = b.exec_state,
|
||||
item_name= c.item_name,
|
||||
standrad_id = c.standrad_id,
|
||||
standrad = c.standrad,
|
||||
input_date = c.input_date,
|
||||
input_user = c.input_user
|
||||
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
return result;// sampleSequenceDal.GetSampleExecDetails();
|
||||
}
|
||||
|
||||
public List<tube_input> QueryTubeInputByBachNo(string bachNo)
|
||||
{
|
||||
return DBFactory.Instance.Queryable<tube_input>().Where(p => p.bach_no == bachNo).ToList();
|
||||
}
|
||||
|
||||
public List<sys_standard_action_ext> GetStrandActionByStrandId(string standrad_id)
|
||||
{
|
||||
|
||||
|
||||
List<sys_standard_action_ext> data = DBFactory.Instance.Queryable<sys_standard_action>()
|
||||
.LeftJoin<sys_action>((a, b) => a.process_id == b.id)
|
||||
.Where((a, b) => a.standard_id == standrad_id)
|
||||
.Select((a, b) => new sys_standard_action_ext
|
||||
{
|
||||
id = a.id,
|
||||
standard_id = a.standard_id,
|
||||
process_id = a.process_id,
|
||||
process_no = a.process_no,
|
||||
action_name = b.action_name,
|
||||
remark = b.remark
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
86
SamplePre.ProcessBll/BLL/SysParamBll.cs
Normal file
86
SamplePre.ProcessBll/BLL/SysParamBll.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using Models.Models;
|
||||
using SamplePre.DAL;
|
||||
using SamplePre.DAL.DBContext;
|
||||
using SamplePre.Models.Ext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SamplePre.ProcessBll.BLL
|
||||
{
|
||||
public class SysParamBll
|
||||
{
|
||||
public int DelSysParm(string id)
|
||||
{
|
||||
|
||||
int val = DBFactory.Instance.Deleteable<sys_parm>().Where(p => p.id == id).ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断该参数是否被使用,已使用不能删除
|
||||
/// </summary>
|
||||
/// <param name="parmId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public bool IsExtisActionParam(string parmId)
|
||||
{
|
||||
|
||||
//动作参数
|
||||
List<sys_action_parm_map> data = DBFactory.Instance.Queryable<sys_action_parm_map>()
|
||||
.Where(p=>p.parm_id == parmId).ToList();
|
||||
if(data.Count > 0) return true;
|
||||
|
||||
//标准动作参数配置表
|
||||
List<sys_standard_action_parm> data2 = DBFactory.Instance.Queryable<sys_standard_action_parm>()
|
||||
.Where(p => p.parm_id == parmId).ToList();
|
||||
if (data2.Count > 0) return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断plc编码是否存在
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public bool IsExtisPlCcode(string plcCode)
|
||||
{
|
||||
List<sys_parm> data2 = DBFactory.Instance.Queryable<sys_parm>()
|
||||
.Where(p => p.plc_type == plcCode).ToList();
|
||||
if (data2.Count > 0) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<sys_parm> QuerySysParm()
|
||||
{
|
||||
|
||||
List<sys_parm> data = DBFactory.Instance.Queryable<sys_parm>().ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public int SaveSysParm(sys_parm parm)
|
||||
{
|
||||
int val = DBFactory.Instance.Insertable<sys_parm>(parm).ExecuteCommand();
|
||||
return val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新参数数据
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int UpdateSysParm(sys_parm parm)
|
||||
{
|
||||
int val = DBFactory.Instance.Updateable<sys_parm>(parm).ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
SamplePre.ProcessBll/BLL/SystemBll.cs
Normal file
107
SamplePre.ProcessBll/BLL/SystemBll.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using DataDAL;
|
||||
using Models.Ext;
|
||||
using Models.Models;
|
||||
using S7.Net.Types;
|
||||
using SamplePre.DAL;
|
||||
using SamplePre.DAL.DBContext;
|
||||
using SamplePre.Models.Ext;
|
||||
using SamplePre.Models.Models;
|
||||
using SamplePre.Models.Tables;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SamplePre.ProcessBll.BLL
|
||||
{
|
||||
public class SystemBll
|
||||
{
|
||||
|
||||
|
||||
SystemDal systemDal = new SystemDal();
|
||||
|
||||
|
||||
public int DelDictClassById(int classid)
|
||||
{
|
||||
var val = DBFactory.Instance.Deleteable<sys_dict_class>(p => p.id == classid).ExecuteCommand();
|
||||
return val;
|
||||
}
|
||||
|
||||
public int DelSysDictByid(sys_dict sys_Dict)
|
||||
{
|
||||
var val = DBFactory.Instance.Deleteable<sys_dict>(p => p.id == sys_Dict.id).ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据分类id查询字典明细
|
||||
/// </summary>
|
||||
/// <param name="classid"></param>
|
||||
/// <returns></returns>
|
||||
public List<sys_dict> QueryDictByClassId(int classid)
|
||||
{
|
||||
List<sys_dict> data = DBFactory.Instance.Queryable<sys_dict>().Where(p => p.class_id == classid).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字典分类
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<sys_dict_class> QueryDictClassData()
|
||||
{
|
||||
List<sys_dict_class> data = DBFactory.Instance.Queryable<sys_dict_class>().ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<sys_dict> QueryDictData()
|
||||
{
|
||||
List<sys_dict> data = DBFactory.Instance.Queryable<sys_dict>().ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public int SaveSysDict(sys_dict sysDict)
|
||||
{
|
||||
var val = DBFactory.Instance.Insertable<sys_dict>(sysDict).ExecuteCommand();
|
||||
return val;
|
||||
}
|
||||
|
||||
public int SaveSysDictClass(sys_dict_class sysDictClass)
|
||||
{
|
||||
var val = DBFactory.Instance.Insertable<sys_dict_class>(sysDictClass).ExecuteCommand();
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询系统功能
|
||||
/// </summary>
|
||||
/// <param name="classid"></param>
|
||||
/// <returns></returns>
|
||||
public List<config_function> QueryFunctionList()
|
||||
{
|
||||
List<config_function> data = DBFactory.Instance.Queryable<config_function>().ToList();
|
||||
|
||||
List<config_function> newData = new List<config_function>();
|
||||
foreach (var item in data.Where(p=>p.parent_id == 0))
|
||||
{
|
||||
foreach(var newItem in data.Where(p => p.parent_id == item.id).ToList())
|
||||
{
|
||||
newItem.description = item.name;
|
||||
newData.Add(newItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return newData;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user