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.
249 lines
9.1 KiB
C#
249 lines
9.1 KiB
C#
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;
|
|
|
|
namespace Estsh.Core.Services
|
|
{
|
|
public class CarrierDateService : BaseService<WmsRack>, ICarrierDateService
|
|
{
|
|
private readonly ICarrierDateRepository repository;
|
|
public CarrierDateService(ICarrierDateRepository _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 cartonNo, string partNo, string partSpec, 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 a.rack_no like '%" + rackNo.Trim() + "%'";
|
|
}
|
|
if (cartonNo != null && !cartonNo.Trim().Equals(""))
|
|
{
|
|
strWhere += "and b.carton_no like '%" + cartonNo + "%'";
|
|
}
|
|
if (partNo != null && !partNo.Trim().Equals(""))
|
|
{
|
|
strWhere += "and b.part_no like '%" + partNo + "%'";
|
|
}
|
|
if (partSpec != null && !partSpec.Trim().Equals(""))
|
|
{
|
|
strWhere += "and b.part_spec like '%" + partSpec + "%'";
|
|
}
|
|
//if (enabled != null && !enabled.Trim().Equals(""))
|
|
//{
|
|
// strWhere += "and a.enabled like '%" + enabled + "%'";
|
|
//}
|
|
strWhere += " and b.factory_id = " + factoryId + " and a.factory_id=" + factoryId + " and a.enabled='Y' and b.enabled='Y' and c.enum_type='sys_stock_status' ";
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |