|
|
using Estsh.Core.Dapper;
|
|
|
using Estsh.Core.IRepositories;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Repository.IRepositories;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Util;
|
|
|
using System.Collections;
|
|
|
using System.Data;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:关键数据管理
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
public class KeyDataDefineService : BaseService<SysKeydata>, IKeyDataDefineService
|
|
|
{
|
|
|
private readonly IKeyDataDefineRepository repository;
|
|
|
|
|
|
public KeyDataDefineService(IKeyDataDefineRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="partNo"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getKeyDataListByPage(String keydata_name_search, String enabled_search, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (keydata_name_search != null && !keydata_name_search.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and keydata_name like '%" + keydata_name_search.Trim() + "%'";
|
|
|
}
|
|
|
if (enabled_search != null && !enabled_search.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and enabled = '" + enabled_search.Trim() + "'";
|
|
|
}
|
|
|
String orderBy = "";
|
|
|
if (sort != null && !"".Equals(sort.Trim()))
|
|
|
{
|
|
|
orderBy += typeof(SysKeydata).GetEntityColumnName(sort.Trim()) + " ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
orderBy += typeof(SysKeydata).GetEntityColumnName("KeydataId") + " ";
|
|
|
}
|
|
|
|
|
|
result = repository.getListByPage(pager.pageSize, pager.pageNo, strWhere, sort + " " );
|
|
|
return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveKeyData(SysKeydata htParams)
|
|
|
{
|
|
|
return repository.saveKeyData(htParams);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateKeyData(SysKeydata htParams)
|
|
|
{
|
|
|
return repository.updateKeyData(htParams);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看菜单详情
|
|
|
/// </summary>
|
|
|
/// <param name="keydata_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getKeyDataDetail(String keydata_id)
|
|
|
{
|
|
|
keydata_id = " keydata_id = " + keydata_id;
|
|
|
List<SysKeydata> dt = repository.getList(keydata_id, "");
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("keydataId", dt[0].KeydataId);
|
|
|
|
|
|
result.Add("keydataName", dt[0].KeydataName);
|
|
|
result.Add("keydataDesc", dt[0].KeydataDesc);
|
|
|
result.Add("maxValue", dt[0].MaxValue);
|
|
|
result.Add("minValue", dt[0].MinValue);
|
|
|
result.Add("maxTolerance", dt[0].MaxTolerance);
|
|
|
result.Add("minTolerance", dt[0].MinTolerance);
|
|
|
result.Add("enabled", dt[0].Enabled);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int deleteKeyData(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.deleteKeyData(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int EnableData(String ids)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.EnableData(ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int DisableData(String ids)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.DisableData(ids);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取 站点 信息
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<KeyValueResult> getTerminalName()
|
|
|
{
|
|
|
return repository.getTerminalName();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取 产线 信息
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<KeyValueResult> getBoardName()
|
|
|
{
|
|
|
return repository.getBoardName();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 判断是否存在 用户输入的零件号
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <param name="part_no"></param>
|
|
|
/// <returns></returns>
|
|
|
public String isExsitPart_no(String part_no)
|
|
|
{
|
|
|
return this.repository.isExsitPart_no(part_no);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="menuName">查询条件</param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序字段</param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getTableListByPage(String keydata_name_search, String enabled_search, Pager pager, String direction, String sort, Boolean isPage)
|
|
|
{
|
|
|
int rowCount = 0;
|
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (keydata_name_search != null && !keydata_name_search.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and keydata_name like '%" + keydata_name_search.Trim() + "%'";
|
|
|
}
|
|
|
if (enabled_search != null && !enabled_search.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and enabled = '" + enabled_search.Trim() + "'";
|
|
|
}
|
|
|
|
|
|
if (isPage)
|
|
|
{
|
|
|
rowCount = pager.pageSize;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rowCount = pager.pageSize;
|
|
|
}
|
|
|
Hashtable result = repository.getTableListByPage(rowCount, pager.pageNo, strWhere, sort + " " );
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 读取文件并更新至数据库
|
|
|
/// </summary>
|
|
|
/// <param name="inputStream">文件全路径</param>
|
|
|
/// <param name="userInfo">登录用户信息</param>
|
|
|
public Hashtable ImportExcel(List<KeyDataDefine> inputStream, int userId)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
if (inputStream == null || inputStream.Count == 0)
|
|
|
{
|
|
|
result.Add("message", "导入数据为空,请重新导入");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
// 处理表身数据
|
|
|
if (repository.InsertData(inputStream, userId.ToString()))
|
|
|
{
|
|
|
result.Add("message", "导入成功");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "导入失败");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |