using System.Collections;
using Estsh.Core.Util;
using Estsh.Core.Repository.IRepositories;
using Estsh.Core.Services.IServices;
using Estsh.Core.Models;
using Estsh.Core.Model.Result;
using Aspose.Cells;
using System.Data;
using Estsh.Core.Dapper;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:看板模块Service类
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Services
{
///
/// 抽样业务处理类
///
public class SampleTestDefineService : BaseService, ISampleTestDefineService
{
private readonly ISampleTestDefineRepository repository;
public SampleTestDefineService(ISampleTestDefineRepository _repository) : base(_repository)
{
repository = _repository;
}
///
/// 根据分页条件获取分页抽样数据
///
///
///
///
///
///
public Hashtable GetListByPage(String type_name, String model_name, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
String strWhere = " 1=1 ";
if (type_name != null && !type_name.Trim().Equals(""))
{
strWhere += " AND c.type_id = " + type_name.Trim() + " ";
}
if (model_name != null && !model_name.Trim().Equals(""))
{
strWhere += " AND b.model_id = " + model_name.Trim() + " ";
}
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += typeof(GAbTestplan).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += " c.type_id " + direction;
}
result = repository.GetListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
return result;
}
///
/// 获取下拉框中的抽样车型ModelType数据
///
///
public List GetSelectModelType()
{
return repository.GetSelectModelType();
}
///
/// 获取下拉框中的抽样配置Model数据
///
///
public List GetSelectModel()
{
return repository.GetSelectModel();
}
///
/// 查看抽样详情
///
///
///
public List GetDetail(String testplan_id)
{
testplan_id = "a.testplan_id = '" + testplan_id + "' ";
return repository.GetList(testplan_id, "");
}
///
/// 保存抽样数据
///
///
///
public int Insert(GAbTestplan htParams)
{
return repository.Insert(htParams);
}
///
/// 更新抽样数据
///
///
///
public int Update(GAbTestplan htParams)
{
return repository.Update(htParams);
}
///
/// 删除抽样
///
///
///
public int Delete(String ids)
{
String[] idArray = ids.Split(',');
int count = 0;
foreach (String id in idArray)
{
if (!"".Equals(id))
{
count += this.repository.Delete(id);
}
}
return count;
}
///
/// 启用
///
///
///
public int EnableData(String ids)
{
ids = ids.Substring(0, ids.Length - 1);
return this.repository.EnableData(ids);
}
///
/// 禁用
///
///
///
public int DisableData(String ids)
{
ids = ids.Substring(0, ids.Length - 1);
return this.repository.DisableData(ids);
}
///
/// 导出信息
///
///
///
///
public Workbook ExportInfo(String type_name, String model_name)
{
type_name = string.Format(" b.model_name='{0}',c.type_name='{1}' ", type_name, model_name);
DataTable dt = this.repository.GetDataTable(type_name, "");
return AsposeExcelTools.DataTableToExcel2(dt);
}
}
}