You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
5.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Estsh.Core.Dapper;
using Estsh.Core.Models;
using Estsh.Core.Repository.IRepositories;
using Estsh.Core.Services.IServices;
using Estsh.Core.Util;
using System.Collections;
/***************************************************************************************************
*
* 更新人sitong.dong
* 描述:厂区定义
* 修改时间2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Services
{
public class OrgService : BaseService<SysFactory>, IOrgService
{
private readonly IOrgRepository repository;
public OrgService(IOrgRepository _repository) : base(_repository)
{
repository = _repository;
}
/// <summary>
/// 根据分页条件获取分页菜单数据
/// </summary>
/// <param name="menuName">查询条件</param>
/// <param name="pager"></param>
/// <param name="direction">排序方式</param>
/// <param name="sort">排序字段</param>
/// <returns></returns>
public Hashtable getMenuListByPage(String factoryCode, String factoryName, string enabled, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
String strWhere = " 1=1 ";
if (factoryCode != null && !factoryCode.Trim().Equals(""))
{
strWhere += " and factory_code like '%" + factoryCode.Trim() + "%'";
}
if (factoryName != null && !factoryName.Trim().Equals(""))
{
strWhere += " and factory_name like '%" + factoryName.Trim() + "%'";
}
if (enabled != null && !enabled.Trim().Equals(""))
{
strWhere += " and enabled like '%" + enabled.Trim() + "%'";
}
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += typeof(SysFactory).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += typeof(SysFactory).GetEntityColumnName("FactoryId") + " " + direction;
}
result = repository.getListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
return result;
}
/// <summary>
/// 保存
/// </summary>
/// <param name="htParams">参数</param>
/// <returns></returns>
public int SaveOrg(SysFactory htParams)
{
return repository.SaveOrg(htParams);
}
/// <summary>
/// 根据工厂ID查找工厂信息
/// </summary>
/// <param name="factory_id">工厂ID</param>
/// <returns></returns>
public Hashtable getRow(String factory_id)
{
Hashtable hsTalbe = new Hashtable();
string strWhere = " and factory_id='" + factory_id + "'";
List<SysFactory> dt = repository.getFactoryList(strWhere);
if (dt != null && dt.Count > 0)
{
hsTalbe.Add("factoryId", dt[0].FactoryId);
hsTalbe.Add("factoryName", dt[0].FactoryName);
hsTalbe.Add("factoryCode", dt[0].FactoryCode);
hsTalbe.Add("factoryDesc", dt[0].FactoryDesc);
hsTalbe.Add("enabled", dt[0].Enabled);
hsTalbe.Add("createTime", dt[0].CreateTime);
//hsTalbe.Add("createHms", dt[0].CreateHms);
hsTalbe.Add("createUserid", dt[0].CreateUserId);
}
return hsTalbe;
}
/// <summary>
/// 更新
/// </summary>
/// <param name="htParams"></param>
/// <returns></returns>
public int UpdateOrg(SysFactory htParams)
{
return repository.UpdateOrg(htParams);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="htParams"></param>
/// <returns></returns>
public int DeleteOrg(String ids)
{
ids = ids.Substring(0, ids.LastIndexOf(','));
return this.repository.DeleteOrg(ids);
}
/// <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>
/// 判断厂区代码是否已存在
/// </summary>
/// <param name="facCode">厂区代码</param>
/// <returns>false不存在 true :已存在</returns>
public bool IsExistFac(string facCode)
{
Hashtable hsTalbe = new Hashtable();
string strWhere = " and factory_code ='" + facCode + "'";
List<SysFactory> dt = repository.getFactoryList(strWhere);
if (dt == null || dt.Count < 1)
{
return false;
}
return true;
}
}
}