|
|
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.IRepositories;
|
|
|
using Estsh.Core.Dapper;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Dapper;
|
|
|
using System.Text;
|
|
|
using Estsh.Core.Model.EnumUtil;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:移动单管理
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
public class MovementInstockManageService : BaseService<WmsInstock>, IMovementInstockManageService
|
|
|
{
|
|
|
private readonly IMovementInstockManageRepository repository;
|
|
|
public MovementInstockManageService(IMovementInstockManageRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
|
|
|
public Hashtable getMoveHeaderListByPage(string orderNo, string orderType, string orderStatus, string startTime, string endTime, string enabled, int factoryId, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (orderNo != null && !orderNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_no like '%" + orderNo.Trim() + "%' ";
|
|
|
}
|
|
|
if (orderType != null && !orderType.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_type ='" + orderType.Trim() + "' ";
|
|
|
}
|
|
|
|
|
|
if (orderStatus != null && !orderStatus.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_status ='" + orderStatus.Trim() + "' ";
|
|
|
}
|
|
|
|
|
|
if (!String.IsNullOrEmpty(startTime) && !String.IsNullOrEmpty(endTime))
|
|
|
{
|
|
|
strWhere += " and a.create_time BETWEEN '" + startTime.Trim() + "' AND '" + endTime.Trim() + "'";
|
|
|
}
|
|
|
else if (String.IsNullOrEmpty(startTime) && !String.IsNullOrEmpty(endTime))
|
|
|
{
|
|
|
strWhere += " and a.create_time < '" + endTime.Trim() + "'";
|
|
|
}
|
|
|
else if (!String.IsNullOrEmpty(startTime) && String.IsNullOrEmpty(endTime))
|
|
|
{
|
|
|
strWhere += " and a.create_time >'" + startTime.Trim() + "'";
|
|
|
}
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.enabled = '" + enabled.Trim() + "' ";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
String orderBy = "";
|
|
|
if (sort != null && !"".Equals(sort.Trim()))
|
|
|
{
|
|
|
orderBy += "a.create_time desc";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
orderBy += "a.create_time desc";
|
|
|
//orderBy += typeof(WmsInstock).GetEntityColumnName("ruid") + " " + direction;
|
|
|
}
|
|
|
|
|
|
return repository.getMoveHeaderListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
|
|
|
|
|
|
}
|
|
|
|
|
|
public Hashtable getMoveDetailListByPage(string orderNo, string enabled, int factoryId)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (orderNo != null && !orderNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_no like '%" + orderNo.Trim() + "%' ";
|
|
|
}
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.enabled = '" + enabled.Trim() + "' ";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
|
|
|
return repository.getMoveDetailListByPage(strWhere);
|
|
|
|
|
|
}
|
|
|
|
|
|
public Hashtable getMoveSnListByPage(string orderNo, string partNo, string enabled, int factoryId)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (orderNo != null && !orderNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_no = '" + orderNo.Trim() + "' ";
|
|
|
}
|
|
|
if (partNo != null && !partNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.part_no = '" + partNo.Trim() + "' ";
|
|
|
}
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.enabled = '" + enabled.Trim() + "' ";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
|
|
|
return repository.getMoveSnListByPage(strWhere);
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<WmsInstock> getInstockListByPrintCount(string orderNo, string enabled, int factoryId)
|
|
|
{
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (orderNo != null && !orderNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_no = '" + orderNo.Trim() + "' ";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.enabled = '" + enabled.Trim() + "' ";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
|
|
|
List<WmsInstock> wmsInstocks = repository.getInstockListByPrintCount(strWhere);
|
|
|
|
|
|
List<WmsInstock> instockJsonList = new List<WmsInstock>();
|
|
|
int rowCount = wmsInstocks[0].RowCount;
|
|
|
int pageCount = 0;
|
|
|
int pageRowCount = 200;//打印页 行数
|
|
|
if (rowCount % pageRowCount > 0)
|
|
|
{
|
|
|
pageCount = rowCount / pageRowCount + 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pageCount = rowCount / pageRowCount;
|
|
|
}
|
|
|
for (int i = 0; i < pageCount; i++)
|
|
|
{
|
|
|
if (rowCount - pageRowCount * i > 0)//有余数
|
|
|
{
|
|
|
if (rowCount - pageRowCount * i < pageRowCount)
|
|
|
{
|
|
|
WmsInstock instock = new WmsInstock();
|
|
|
instock.SeqNum = i + 1;//序号
|
|
|
string beginNum = ((i) * pageRowCount + 1).ToString();
|
|
|
string endNum = ((i) * pageRowCount + (rowCount - pageRowCount * i)).ToString();
|
|
|
instock.RowRange = beginNum + "-" + endNum;//范围 (1001-2000)
|
|
|
instock.RowRign = 0;//处理标记 0未处理,1已处理
|
|
|
instockJsonList.Add(instock);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WmsInstock instock = new WmsInstock();
|
|
|
instock.SeqNum = i + 1;//序号
|
|
|
string beginNum = ((i) * pageRowCount + 1).ToString();
|
|
|
string endNum = ((i + 1) * pageRowCount).ToString();
|
|
|
instock.RowRange = beginNum + "-" + endNum;//范围 (1001-2000)
|
|
|
instock.RowRign = 0;//处理标记 0未处理,1已处理
|
|
|
instockJsonList.Add(instock);
|
|
|
}
|
|
|
}
|
|
|
else if (rowCount - pageRowCount * i == 0)
|
|
|
{
|
|
|
WmsInstock instock = new WmsInstock();
|
|
|
instock.SeqNum = i + 1;//序号
|
|
|
string beginNum = ((i) * pageRowCount + 1).ToString();
|
|
|
string endNum = (rowCount).ToString();
|
|
|
|
|
|
instock.RowRange = beginNum + "-" + endNum;//范围 (1-1000)
|
|
|
instock.RowRign = 0;//处理标记 0未处理,1已处理
|
|
|
instockJsonList.Add(instock);
|
|
|
}
|
|
|
else//没有余数
|
|
|
{
|
|
|
WmsInstock instock = new WmsInstock();
|
|
|
instock.SeqNum = i + 1;//序号
|
|
|
string beginNum = ((i) * pageRowCount + 1).ToString();
|
|
|
string endNum = (rowCount - ((i) * pageRowCount)).ToString();
|
|
|
|
|
|
instock.RowRange = beginNum + "-" + endNum;//范围 (1-1000)
|
|
|
instock.RowRign = 0;//处理标记 0未处理,1已处理
|
|
|
instockJsonList.Add(instock);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return instockJsonList;
|
|
|
}
|
|
|
public List<WmsInstockSn> getInstockListByPrintRange(string orderNo, string rowRange, string enabled, string factoryId)
|
|
|
{
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (orderNo != null && !orderNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_no = '" + orderNo.Trim() + "' ";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.enabled = '" + enabled.Trim() + "' ";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
string endrowCount = "0";
|
|
|
string[] rowRangeList = rowRange.Split("-");
|
|
|
if (rowRangeList.Count() == 2)
|
|
|
{
|
|
|
endrowCount = rowRangeList[1];
|
|
|
}
|
|
|
string rowCount = (Convert.ToInt32(rowRangeList[1]) + 1 - Convert.ToInt32(rowRangeList[0])).ToString();
|
|
|
return repository.getInstockListByPrintRange(strWhere, endrowCount, rowCount);
|
|
|
}
|
|
|
public List<WmsInstockSn> getMoveSnListByPrint(string orderNo, string enabled, int factoryId)
|
|
|
{
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (orderNo != null && !orderNo.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.order_no = '" + orderNo.Trim() + "' ";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.enabled = '" + enabled.Trim() + "' ";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
|
|
|
return repository.getMoveSnListByPrint(strWhere);
|
|
|
|
|
|
}
|
|
|
public Hashtable onBarcodeGenerator(String ids, string userId, string factoryId, string factoryCode)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.onBarcodeGenerator(ids, userId, factoryId, factoryCode);
|
|
|
}
|
|
|
public List<KeyValueResult> GetErpwarehouse()
|
|
|
{
|
|
|
return repository.GetErpwarehouse();
|
|
|
}
|
|
|
public List<KeyValueResult> GetMoveOrderType()
|
|
|
{
|
|
|
return repository.GetMoveOrderType();
|
|
|
}
|
|
|
public List<KeyValueResult> GetMoveOrderStatus()
|
|
|
{
|
|
|
return repository.GetMoveOrderStatus();
|
|
|
}
|
|
|
public List<KeyValueResult> getSelectFactory()
|
|
|
{
|
|
|
return repository.getSelectFactory();
|
|
|
}
|
|
|
|
|
|
public List<KeyValueResult> getSelectWarehouse()
|
|
|
{
|
|
|
return repository.getSelectWarehouse();
|
|
|
}
|
|
|
public List<SysWarehouse> getSelectWarehouse(string warehouseid)
|
|
|
{
|
|
|
return repository.getSelectWarehouse(warehouseid);
|
|
|
}
|
|
|
public List<SysWarehouse> getSelectWarehouseByName(string warehouseName)
|
|
|
{
|
|
|
return repository.getSelectWarehouseByName(warehouseName);
|
|
|
}
|
|
|
public List<SysZone> getSelectZone(string zoneid)
|
|
|
{
|
|
|
return repository.getSelectZone(zoneid);
|
|
|
}
|
|
|
public List<SysZone> getSelectZoneByName(string zoneName)
|
|
|
{
|
|
|
return repository.getSelectZoneByName(zoneName);
|
|
|
}
|
|
|
public List<KeyValueResult> getSelectZone()
|
|
|
{
|
|
|
return repository.getSelectZone();
|
|
|
}
|
|
|
public List<KeyValueResult> getSelectLocateDown(string zoneId)
|
|
|
{
|
|
|
return repository.getSelectLocateDown(zoneId);
|
|
|
}
|
|
|
|
|
|
public List<SysLocate> getSelectLocate(string locateid)
|
|
|
{
|
|
|
return repository.getSelectLocate(locateid);
|
|
|
}
|
|
|
public List<KeyValueResult> getSelectVendor()
|
|
|
{
|
|
|
return repository.getSelectVendor();
|
|
|
}
|
|
|
|
|
|
public List<SysVendor> getSelectVendor(string vendorId)
|
|
|
{
|
|
|
return repository.getSelectVendor(vendorId);
|
|
|
}
|
|
|
public List<KeyValueResult> getSelectCustomer()
|
|
|
{
|
|
|
return repository.getSelectCustomer();
|
|
|
}
|
|
|
|
|
|
public List<SysCustomer> getSelectCustomer(string customerId)
|
|
|
{
|
|
|
return repository.getSelectCustomer(customerId);
|
|
|
}
|
|
|
public List<KeyValueResult> GetPart()
|
|
|
{
|
|
|
return repository.GetPart(0);
|
|
|
}
|
|
|
|
|
|
public List<SysPart> GetPart(string PartNo)
|
|
|
{
|
|
|
return repository.GetPart(0, PartNo);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool saveMovementManage(WmsInstock htParams, IList<WmsInstockDetail> htDetailParams)
|
|
|
{
|
|
|
return repository.saveMovementManage(htParams, htDetailParams);
|
|
|
}
|
|
|
|
|
|
public List<SysVendor> GetfileVendor(string vendorName, int factoryId)
|
|
|
{
|
|
|
return this.repository.GetfileVendor(vendorName, factoryId);
|
|
|
}
|
|
|
public SysVendor GetVendorInfoByName(string vendorName, int factoryId)
|
|
|
{
|
|
|
return this.repository.GetVendorInfoByName(vendorName, factoryId);
|
|
|
}
|
|
|
public List<SysPart> GetPartNoInfo(string part_no)
|
|
|
{
|
|
|
return this.repository.GetPartNoInfo(part_no);
|
|
|
}
|
|
|
|
|
|
public List<SysPart> GetPartNoInfoByPartNo(string part_no)
|
|
|
{
|
|
|
return this.repository.GetPartNoInfoByPartNo(part_no);
|
|
|
}
|
|
|
public List<SysPart> GetPartSpecInfo(string partSpec)
|
|
|
{
|
|
|
return this.repository.GetPartSpecInfo(partSpec);
|
|
|
}
|
|
|
public List<SysPart> GetPartSpecInfoByPartSpec(string partSpec)
|
|
|
{
|
|
|
return this.repository.GetPartSpecInfoByPartSpec(partSpec);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 关闭
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool onClose(String ids, String empId)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.onClose(ids, empId);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool EnableData(String ids)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.EnableData(ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool DisableData(String ids)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.DisableData(ids);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 导入
|
|
|
/// </summary>
|
|
|
public Hashtable ImportExcel(List<MovementInstockManage> inputStream, int factoryId, string factoryCode, int empId)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
List<string> sqlLists = 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;
|
|
|
}
|
|
|
|
|
|
int OrderType = 0;
|
|
|
string orderNo = "";
|
|
|
int orderType = 0;
|
|
|
if (inputStream[0].OrderTypeDesc.Trim() == "零星入库单")
|
|
|
{
|
|
|
orderNo = repository.GetOrderNo("ShiftSporadicEntry", "I");//零星入库单
|
|
|
orderType = (int)WmsEnumUtil.InStockType.EXCEPTION_IN_STOCK;
|
|
|
}
|
|
|
else if (inputStream[0].OrderTypeDesc.Trim() == "委外退回单")
|
|
|
{
|
|
|
orderNo = repository.GetOrderNo("ShiftProduction", "T");//委外退回单
|
|
|
orderType = (int)WmsEnumUtil.InStockType.OUTSOURCE_BACK;
|
|
|
}
|
|
|
else if (inputStream[0].OrderTypeDesc.Trim() == "线外生产入库报工")
|
|
|
{
|
|
|
orderNo = repository.GetOrderNo("ShiftProduction", "S");//线外生产入库报工
|
|
|
orderType = (int)WmsEnumUtil.InStockType.OFFLINE_IN_STOCK;
|
|
|
}
|
|
|
else if (inputStream[0].OrderTypeDesc.Trim() == "生产入库单")
|
|
|
{
|
|
|
orderNo = repository.GetOrderNo("ShiftProduction", "C");//生产入库单
|
|
|
orderType = (int)WmsEnumUtil.InStockType.ProductionIn_ORDER;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "导入数据单据类型错误,请检查!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
int vendorId = 0;
|
|
|
string vendorCode = "";
|
|
|
List<SysVendor> sysVendors = repository.getSelectVendor(inputStream[0].VendorCode);
|
|
|
if (sysVendors.Count > 0)
|
|
|
{
|
|
|
vendorId = sysVendors[0].VendorId;
|
|
|
vendorCode = sysVendors[0].VendorCode;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "导入数据供应商代码不存在,请检查!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//判断零件号是否存在
|
|
|
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append("INSERT INTO dbo.wms_instock(order_no,order_type,order_status,vendor_id,vendor_code,customer_id,customer_code,ref_order_no,factory_id,factory_code,enabled,create_userid,create_time,guid)");
|
|
|
SqlStringBuilder.Append("VALUES(@orderNo, @orderType, @orderStatus,@vendorId,@vendorCode,@customerId,@customerCode,@refOrderNo, @factoryId, @factoryCode, @enabled, @createUserid, CONVERT(varchar(50), GETDATE(), 21), newid()) ");
|
|
|
sqlLists.Add(SqlStringBuilder.ToString());
|
|
|
DynamicParameters dynamic = new DynamicParameters();
|
|
|
dynamic.Add("@orderNo", orderNo);
|
|
|
dynamic.Add("@orderType", orderType);
|
|
|
dynamic.Add("@orderStatus", 10);
|
|
|
dynamic.Add("@vendorId", vendorId);
|
|
|
dynamic.Add("@vendorCode", vendorCode);
|
|
|
dynamic.Add("@customerId", 0);
|
|
|
dynamic.Add("@customerCode", "");
|
|
|
dynamic.Add("@refOrderNo", "");
|
|
|
dynamic.Add("@enabled", "Y");
|
|
|
dynamic.Add("@factoryId", factoryId);
|
|
|
dynamic.Add("@factoryCode", factoryCode);
|
|
|
dynamic.Add("@createUserid", empId);
|
|
|
parameters.Add(dynamic);
|
|
|
|
|
|
for (int i = 0; i < inputStream.Count; i++)
|
|
|
{
|
|
|
int PartId = 0;
|
|
|
string partNo = "";
|
|
|
string partSpec = "";
|
|
|
string unit = "";
|
|
|
List<SysPart> sysParts = repository.GetPartNoInfoByPartNo(inputStream[i].PartNo.Trim());
|
|
|
if (sysParts.Count > 0)
|
|
|
{
|
|
|
PartId = sysParts[0].PartId;
|
|
|
partNo = sysParts[0].PartNo;
|
|
|
partSpec = sysParts[0].PartSpec;
|
|
|
unit = string.IsNullOrEmpty(sysParts[0].Unit) ? "" : sysParts[0].Unit;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "导入数据零件号不存在,请检查!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
int warehouseId = 0;
|
|
|
string warehouseName = "";
|
|
|
List<SysWarehouse> sysWarehouses = repository.getSelectWarehouseByName(inputStream[i].WarehouseName.Trim());
|
|
|
if (sysWarehouses.Count > 0)
|
|
|
{
|
|
|
warehouseId = sysWarehouses[0].WarehouseId;
|
|
|
warehouseName = sysWarehouses[0].WarehouseName;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "导入数据仓库不存在,请检查!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
int zoneId = 0;
|
|
|
string zoneName = "";
|
|
|
string erpWarehouse = "";
|
|
|
List<SysZone> sysZones = repository.getSelectZoneByName(inputStream[i].ZoneName.Trim());
|
|
|
if (sysZones.Count > 0)
|
|
|
{
|
|
|
zoneId = sysZones[0].ZoneId;
|
|
|
zoneName = sysZones[0].ZoneName;
|
|
|
erpWarehouse = sysZones[0].ErpWarehouse;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "导入数据库区不存在,请检查!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
StringBuilder SqlDetailStringBuilder = new StringBuilder(1024);
|
|
|
SqlDetailStringBuilder.Append("INSERT INTO dbo.wms_instock_detail(order_no,item_no,part_id,part_no,part_spec,qty,rec_qty,unit,plan_date,plan_time,item_status");
|
|
|
SqlDetailStringBuilder.Append(", dest_warehouse_id, dest_warehouse_name, dest_zone_id");
|
|
|
SqlDetailStringBuilder.Append(", dest_zone_name,dest_locate_id,dest_locate_name , dest_erp_warehouse, factory_id, factory_code, enabled, create_userid, create_time, guid)");
|
|
|
SqlDetailStringBuilder.Append("VALUES(@orderNo, @itemNo, @partId, @partNo, @partSpec, @qty, @recQty, @unit, @planDate, @planTime, @itemStatus");
|
|
|
SqlDetailStringBuilder.Append(", @destWarehouseId, @destWarehouseName, @destZoneId, @destZoneName,@destLocateId,@destLocateName, @destErpWarehouse");
|
|
|
SqlDetailStringBuilder.Append(", @factoryId, @factoryCode, @enabled, @createUserid, CONVERT(varchar(50), GETDATE(), 21), newid())");
|
|
|
sqlLists.Add(SqlDetailStringBuilder.ToString());
|
|
|
dynamic = new DynamicParameters();
|
|
|
dynamic.Add("@orderNo", orderNo);
|
|
|
dynamic.Add("@itemNo", i + 1);
|
|
|
dynamic.Add("@partId", PartId);
|
|
|
dynamic.Add("@partNo", partNo);
|
|
|
dynamic.Add("@partSpec", partSpec);
|
|
|
dynamic.Add("@unit", unit);
|
|
|
dynamic.Add("@qty", inputStream[i].Qty);
|
|
|
dynamic.Add("@recQty", 0);
|
|
|
dynamic.Add("@planDate", inputStream[i].PlanDate);
|
|
|
dynamic.Add("@planTime", "");
|
|
|
dynamic.Add("@itemStatus", "10");
|
|
|
dynamic.Add("@destWarehouseId", warehouseId);
|
|
|
dynamic.Add("@destWarehouseName", warehouseName);
|
|
|
dynamic.Add("@destZoneId", zoneId);
|
|
|
dynamic.Add("@destZoneName", zoneName);
|
|
|
dynamic.Add("@destLocateId", 0);
|
|
|
dynamic.Add("@destLocateName", "");
|
|
|
|
|
|
dynamic.Add("@destErpWarehouse", erpWarehouse);
|
|
|
dynamic.Add("@factoryId", factoryId);
|
|
|
dynamic.Add("@factoryCode", factoryCode);
|
|
|
dynamic.Add("@enabled", "Y");
|
|
|
dynamic.Add("@createUserid", empId);
|
|
|
parameters.Add(dynamic);
|
|
|
}
|
|
|
|
|
|
if (repository.InsertData(sqlLists, 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |