|
|
|
|
using Estsh.Core.Dapper;
|
|
|
|
|
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;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* 更新人:sitong.dong
|
|
|
|
|
* 描述:总成/原材料零件号管理
|
|
|
|
|
* 修改时间:2022.06.22
|
|
|
|
|
* 修改日志:系统迭代升级
|
|
|
|
|
*
|
|
|
|
|
**************************************************************************************************/
|
|
|
|
|
namespace Estsh.Core.Services
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 菜单业务处理类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PartMasterService : BaseService<SysPart>, IPartMasterService
|
|
|
|
|
{
|
|
|
|
|
private readonly IPartMasterRepository repository;
|
|
|
|
|
|
|
|
|
|
public PartMasterService(IPartMasterRepository _repository) : base(_repository)
|
|
|
|
|
{
|
|
|
|
|
repository = _repository;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="PartMasterName"></param>
|
|
|
|
|
/// <param name="pager"></param>
|
|
|
|
|
/// <param name="direction"></param>
|
|
|
|
|
/// <param name="sort"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Hashtable getPartMasterListByPage(String part_type, String part_no, String partSpec, string enabled, int factoryId, Pager pager, String direction, String sort)
|
|
|
|
|
{
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
|
|
if (part_no != null && !part_no.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere = " a.part_no like '%" + part_no.Trim() + "%' ";
|
|
|
|
|
}
|
|
|
|
|
if (partSpec != null && !partSpec.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere += " AND a.part_spec like '%" + partSpec.Trim() + "%'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere += " AND a.enabled like '%" + enabled.Trim() + "%'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
|
|
|
|
|
|
|
String orderBy = "";
|
|
|
|
|
if (sort != null && !"".Equals(sort.Trim()))
|
|
|
|
|
{
|
|
|
|
|
orderBy += "a." + typeof(SysPart).GetEntityColumnName(sort.Trim()) + " " + direction;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
orderBy += " a." + typeof(SysPart).GetEntityColumnName("PartId") + " " + direction;
|
|
|
|
|
}
|
|
|
|
|
result = repository.getListByPage(part_type, pager.pageSize, pager.pageNo, strWhere, orderBy);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存菜单数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="htParams"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public int savePartMaster(SysPart htParams)
|
|
|
|
|
{
|
|
|
|
|
return repository.savePartMaster(htParams);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新菜单数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="htParams"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public int updatePartMaster(SysPart htParams)
|
|
|
|
|
{
|
|
|
|
|
return repository.updatePartMaster(htParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查看详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ruid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<SysPart> getPartMaster(String part_id)
|
|
|
|
|
{
|
|
|
|
|
part_id = "part_id = " + part_id;
|
|
|
|
|
return repository.getList(part_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除菜单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public int deletePartMaster(String ids)
|
|
|
|
|
{
|
|
|
|
|
String[] idArray = ids.Split(',');
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (String id in idArray)
|
|
|
|
|
{
|
|
|
|
|
if (!"".Equals(id))
|
|
|
|
|
{
|
|
|
|
|
count += this.repository.deletePartMaster(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SysPart getPartByExistName(string partNo)
|
|
|
|
|
{
|
|
|
|
|
return repository.getPartByExistName(partNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SysPart getPartByExistSpec(string partSpec)
|
|
|
|
|
{
|
|
|
|
|
return repository.getPartByExistSpec(partSpec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取下拉框中的菜单数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<KeyValueResult> getSelectPartMaster()
|
|
|
|
|
{
|
|
|
|
|
return repository.getSelectPartMaster();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取车型数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<KeyValueResult> getSelectPartMaster_Model_name()
|
|
|
|
|
{
|
|
|
|
|
return repository.getSelectPartMaster_Model_name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取座椅位置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<KeyValueResult> getSelectPartLocation()
|
|
|
|
|
{
|
|
|
|
|
return repository.getSelectPartLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Isnull(string value)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(value))
|
|
|
|
|
{
|
|
|
|
|
return "0";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取单位数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<KeyValueResult> getSelectPartMaster_Enum()
|
|
|
|
|
{
|
|
|
|
|
return repository.getSelectPartMaster_Enum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取默认库位数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<KeyValueResult> getSelectPartMaster_Locate()
|
|
|
|
|
{
|
|
|
|
|
return repository.getSelectPartMaster_Locate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取条码规则数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<KeyValueResult> getSelectPartMaster_TMGZ()
|
|
|
|
|
{
|
|
|
|
|
return repository.getSelectPartMaster_TMGZ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取工艺流程数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<KeyValueResult> getSelectPartMaster_Route()
|
|
|
|
|
{
|
|
|
|
|
return repository.getSelectPartMaster_Route();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="menuName">查询条件</param>
|
|
|
|
|
/// <param name="pager"></param>
|
|
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
|
|
/// <param name="sort">排序字段</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<PartMaster> getTableListByPage(String part_type, String part_no, Pager pager, String direction, String sort, Boolean isPage)
|
|
|
|
|
{
|
|
|
|
|
List<PartMaster> result = null;
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
|
|
int rowCount = 0;
|
|
|
|
|
if (part_no != null && !part_no.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere = " a.part_no like '%" + part_no.Trim() + "%' ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String orderBy = "";
|
|
|
|
|
if (sort != null && !"".Equals(sort.Trim()))
|
|
|
|
|
{
|
|
|
|
|
orderBy += typeof(SysPart).GetEntityColumnName(sort.Trim()) + " " + direction;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
orderBy += " a." + typeof(SysPart).GetEntityColumnName("PartId") + " " + direction;
|
|
|
|
|
}
|
|
|
|
|
if (isPage)
|
|
|
|
|
{
|
|
|
|
|
rowCount = pager.pageSize;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rowCount = pager.pageSize;
|
|
|
|
|
}
|
|
|
|
|
result = repository.getTableListByPage(part_type, rowCount, pager.pageNo, strWhere, orderBy);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int EnablePartMaster(String ids)
|
|
|
|
|
{
|
|
|
|
|
String[] idArray = ids.Split(',');
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (String id in idArray)
|
|
|
|
|
{
|
|
|
|
|
if (!"".Equals(id))
|
|
|
|
|
{
|
|
|
|
|
count += this.repository.EnablePartMaster(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
public int DisablePartMaster(String ids)
|
|
|
|
|
{
|
|
|
|
|
String[] idArray = ids.Split(',');
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (String id in idArray)
|
|
|
|
|
{
|
|
|
|
|
if (!"".Equals(id))
|
|
|
|
|
{
|
|
|
|
|
count += this.repository.DisablePartMaster(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<PartMaster> getExportList(String partType, String partNo, String partSpec, String enabled, int factoryId)
|
|
|
|
|
{
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
|
|
if (partType != null && !partType.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere = " a.part_type ='" + partType.Trim() + "' ";
|
|
|
|
|
}
|
|
|
|
|
if (partNo != null && !partNo.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere += " AND a.part_no like '%" + partNo.Trim() + "%'";
|
|
|
|
|
}
|
|
|
|
|
if (partSpec != null && !partSpec.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere += " AND a.part_spec like '%" + partSpec.Trim() + "%'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strWhere += " AND a.enabled = '" + enabled.Trim() + "'";
|
|
|
|
|
}
|
|
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
|
|
|
|
|
|
|
String orderBy = " order by part_no ";
|
|
|
|
|
|
|
|
|
|
return repository.getExportList(strWhere,orderBy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|