|
|
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 Estsh.Core.Dapper;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Dapper;
|
|
|
using System.Text;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:台车管理
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
public class CarrierManageService : BaseService<WmsRack>, ICarrierManageService
|
|
|
{
|
|
|
private readonly ICarrierManageRepository repository;
|
|
|
public CarrierManageService(ICarrierManageRepository _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 getCarrierListByPage(string rackNo, string enabled, int factoryId, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (rackNo != null && !rackNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and rack_no like '%" + rackNo.Trim() + "%'";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and enabled like '%" + enabled + "%'";
|
|
|
}
|
|
|
strWhere += " and factory_id = " + factoryId + " ";
|
|
|
|
|
|
String orderBy = "";
|
|
|
if (sort != null && !"".Equals(sort.Trim()))
|
|
|
{
|
|
|
orderBy += typeof(WmsRack).GetEntityColumnName(sort.Trim()) + " " + direction;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
orderBy += typeof(WmsRack).GetEntityColumnName("ruid") + " " + direction;
|
|
|
}
|
|
|
|
|
|
result = repository.getListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveCarrier(WmsRack htParams)
|
|
|
{
|
|
|
return repository.saveCarrier(htParams);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateCarrier(WmsRack htParams)
|
|
|
{
|
|
|
return repository.updateCarrier(htParams);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入零件免检
|
|
|
/// </summary>
|
|
|
public Hashtable ImportExcel(List<CarrierManage> inputStream, int factoryId, string factoryCode, int empId)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
List<string> SqlStrings = new List<string>();
|
|
|
List<DynamicParameters> Parameters = new List<DynamicParameters>();
|
|
|
|
|
|
DynamicParameters Params = new DynamicParameters();
|
|
|
|
|
|
//判断EXCEL是否存在数据
|
|
|
if (inputStream == null || inputStream.Count == 0)
|
|
|
{
|
|
|
result.Add("message", "导入数据为空,请重新导入!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//判断零件号是否存在
|
|
|
for (int i = 0; i < inputStream.Count; i++)
|
|
|
{
|
|
|
string rackNo = inputStream[i].RackNo.ToString();
|
|
|
List<CarrierManage> sysExemptions = repository.ifCarrierManage(rackNo);
|
|
|
if (sysExemptions.Count <= 0)
|
|
|
{
|
|
|
StringBuilder querySen = new StringBuilder(1024);
|
|
|
querySen.AppendLine("INSERT INTO dbo.wms_rack ");
|
|
|
querySen.AppendLine(" ( rack_no , ");
|
|
|
querySen.AppendLine(" rack_type , ");
|
|
|
querySen.AppendLine(" enabled , ");
|
|
|
querySen.AppendLine(" factory_id , ");
|
|
|
querySen.AppendLine(" factory_code , ");
|
|
|
querySen.AppendLine(" create_userid , ");
|
|
|
querySen.AppendLine(" create_time ");
|
|
|
querySen.AppendLine(" ) ");
|
|
|
querySen.AppendLine("VALUES ( @rackNo ,");
|
|
|
querySen.AppendLine(" @rackType,");
|
|
|
querySen.AppendLine(" @enabled,");
|
|
|
querySen.AppendLine(" @factoryId ,");
|
|
|
querySen.AppendLine(" @factoryCode ,");
|
|
|
querySen.AppendLine(" @createUserid,");
|
|
|
querySen.AppendLine(" @createTime");
|
|
|
querySen.AppendLine(" ) ");
|
|
|
|
|
|
Params = new DynamicParameters();
|
|
|
Params.Add("@rackNo", rackNo);
|
|
|
Params.Add("@rackType", "1");
|
|
|
|
|
|
Params.Add("@enabled", "Y");
|
|
|
Params.Add("@factoryId", factoryId);
|
|
|
Params.Add("@factoryCode", factoryCode);
|
|
|
Params.Add("@createUserid", empId);
|
|
|
Params.Add("@createTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
SqlStrings.Add(querySen.ToString());
|
|
|
Parameters.Add(Params);
|
|
|
}
|
|
|
}
|
|
|
if (repository.InsertData(SqlStrings, Parameters))
|
|
|
{
|
|
|
result.Add("message", "导入成功");
|
|
|
result.Add("flag", "OK");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "导入失败");
|
|
|
result.Add("flag", "error");
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", "导入失败");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看菜单详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getCarrierDetail(String ruid)
|
|
|
{
|
|
|
ruid = " ruid = " + ruid;
|
|
|
List<WmsRack> dt = repository.getList(ruid, "");
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("ruid", dt[0].Ruid);
|
|
|
result.Add("rackNo", dt[0].RackNo);
|
|
|
result.Add("rackType", dt[0].RackType);
|
|
|
result.Add("factoryId", dt[0].FactoryId);
|
|
|
result.Add("enabled", dt[0].Enabled);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public List<CarrierManage> getExportList(string rackNo, string enabled, string factoryId)
|
|
|
{
|
|
|
String strWhere = " 1=1 "; string orderBy = "";
|
|
|
if (rackNo != null && !rackNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and rack_no like '%" + rackNo.Trim() + "%'";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and enabled like '%" + enabled + "%'";
|
|
|
}
|
|
|
strWhere += " and factory_id = " + factoryId + " ";
|
|
|
|
|
|
orderBy = " order by rack_no ";
|
|
|
|
|
|
return repository.getExportList(strWhere, orderBy);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int EnableCarrier(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.EnableCarrier(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int DisableCarrier(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.DisableCarrier(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
}
|
|
|
} |