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.

170 lines
5.3 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 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
{
/// <summary>
/// 抽样业务处理类
/// </summary>
public class SampleTestDefineService : BaseService<GAbTestplan>, ISampleTestDefineService
{
private readonly ISampleTestDefineRepository repository;
public SampleTestDefineService(ISampleTestDefineRepository _repository) : base(_repository)
{
repository = _repository;
}
/// <summary>
/// 根据分页条件获取分页抽样数据
/// </summary>
/// <param name="view_board_name"></param>
/// <param name="pager"></param>
/// <param name="direction"></param>
/// <param name="sort"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 获取下拉框中的抽样车型ModelType数据
/// </summary>
/// <returns></returns>
public List<KeyValueResult> GetSelectModelType()
{
return repository.GetSelectModelType();
}
/// <summary>
/// 获取下拉框中的抽样配置Model数据
/// </summary>
/// <returns></returns>
public List<KeyValueResult> GetSelectModel()
{
return repository.GetSelectModel();
}
/// <summary>
/// 查看抽样详情
/// </summary>
/// <param name="ruid"></param>
/// <returns></returns>
public List<GAbTestplan> GetDetail(String testplan_id)
{
testplan_id = "a.testplan_id = '" + testplan_id + "' ";
return repository.GetList(testplan_id, "");
}
/// <summary>
/// 保存抽样数据
/// </summary>
/// <param name="htParams"></param>
/// <returns></returns>
public int Insert(GAbTestplan htParams)
{
return repository.Insert(htParams);
}
/// <summary>
/// 更新抽样数据
/// </summary>
/// <param name="htParams"></param>
/// <returns></returns>
public int Update(GAbTestplan htParams)
{
return repository.Update(htParams);
}
/// <summary>
/// 删除抽样
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
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;
}
/// <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="type_name"></param>
/// <param name="model_name"></param>
/// <returns></returns>
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);
}
}
}