179 lines
5.1 KiB
C#
179 lines
5.1 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|