ldj/Model/wms/tables/WmsPlate.cs

387 lines
11 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// <summary>
///INTERFACE CLASS FOR TABLE t_wmsPlate
///By wm
///on 05/22/2020
/// </summary>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DeiNiu.Utils;
namespace DeiNiu.wms.Data.Model
{
[Serializable]
public class WmsPlate : WmsPlate_base
{
public WmsPlate()
{
}
public WmsPlate(string plateId)
{
cmdParameters[0] = plateId;
getModel(100);
}
public WmsPlate(int id) : base(id)
{
}
public WmsPlate(DataRow dr) : base(dr)
{
}
protected override void getImp()
{
model_imp = new WmsPlate_Imp();
}
//begin cust db operation, query, excute sql etc.
//begin cust db operation, query, excute sql etc.
public DataTable getPlateById(string plateid)
{
cmdParameters[0] = plateid;
return CustQuery(100).Tables[0];
}
public bool deleteByPlateId(string plateid)
{
cmdParameters[0] = plateid;
return CustOper(200) > 0;
}
public DataSet getPlateWaves()
{
return CustQuery(300);
}
public DataTable getPlatesByWave(string waveOrder, int color)
{
cmdParameters[0] = waveOrder;
if (color > 0)
{
cmdParameters[1] = color;
return CustQuery(500).Tables[0];
}
else return CustQuery(400).Tables[0]; ;
}
public DataTable getPartionPickDetailByPlateId(string plateid)
{
cmdParameters[0] = plateid;
return CustQuery(101).Tables[0];
}
public DataTable getPlatesByPickOrder(string pickOrderNo)
{
cmdParameters[0] = pickOrderNo;
return CustQuery(600).Tables[0];
}
public void setFree()
{
this.waveNo = "";
this.preInOrderNo = "";
this.pickOrderNo = "";
this.customerId = "";
this.transNo = "";
this.partion = 0;
this.locationId = "";
this.terminal = 0;
this.state = 0;
this.jobNo = "";
this.inPlate = "";
Update();
}
public WmsPlate getParentPlate(string plateId)
{
cmdParameters[0] = plateId;
DataTable dt = CustQuery(700).Tables[0];
foreach (DataRow dr in dt.Rows)
{
return new WmsPlate(dr);
}
return new WmsPlate();
}
/*public List<WmsPlate> getSubPlates(string plateId)
{
List<WmsPlate> lst = new List<WmsPlate>();
cmdParameters[0] = plateId;
DataTable dt = CustQuery(800).Tables[0];
foreach (DataRow dr in dt.Rows)
{
lst.Add(new WmsPlate(dr));
}
return lst;
}
*/
public List<string> getSubPlateIds(string plateId)
{
List<string> lst = new List<string>();
cmdParameters[0] = plateId;
DataTable dt = CustQuery(800).Tables[0];
foreach (DataRow dr in dt.Rows)
{
lst.Add(dr["subPlateId"].ToString());
}
return lst;
}
public List<WmsPlate> getSubPlates(string plateId)
{
List<WmsPlate> lstp = new List<WmsPlate>();
cmdParameters[0] = plateId;
DataTable dt = CustQuery(1000).Tables[0];
foreach (DataRow dr in dt.Rows)
{
lstp.Add(new WmsPlate(dr));
}
return lstp;
}
/// <summary>
/// 迭代取容器里所有商品,包含子容器及其子容器...
/// </summary>
/// <param name="plateId"></param>
/// <returns></returns>
/* public List<WmsPlateStock_tmp> getPlateStoks(string plateId, bool showSub = false)
{
List<WmsPlateStock_tmp> stks = new List<WmsPlateStock_tmp>();
DataTable dt = new WmsPlateStock_tmp().getStockLst(plateId);
foreach (DataRow dr in dt.Rows)
{
stks.Add(new WmsPlateStock_tmp(dr));
}
if (!showSub)
{
return stks;
}
List<WmsPlate> subPlate = getSubPlates(plateId);
foreach (WmsPlate obj in subPlate)
{
stks.Concat(getPlateStoks(obj.plateId, showSub));
}
return stks;
}
*/
private List<DataTable> getPlateJobsDts(List<DataTable> dts,string plateId, bool showSub = false)
{
// LogHelper.debug(this.GetType(), string.Format(" plate contents dts size {2}, plateId {0},showSub {1}", plateId, showSub,dts.Count));
dts.Add(new WmsPlateStock_tmp().getStockLst(plateId));
LogHelper.debug(this.GetType(), string.Format(" plate contents dts size {2}, plateId {0},showSub {1}", plateId, showSub, dts.Count));
if (!showSub)
{
return dts;
}
List<string> subPlate = getSubPlateIds(plateId);
LogHelper.debug(this.GetType(), string.Format(" plate {0} sub plate count {1} ",plateId,subPlate.Count ));
foreach (string p in subPlate)
{
LogHelper.debug(this.GetType(), string.Format("2 subplate size {2}, plateId {0},sub plate id {1}", plateId, p, subPlate.Count));
// dts.Concat(getPlateJobsDts(dts,obj.plateId, showSub));
if (p.Equals(plateId))
{
continue;
}
dts=(getPlateJobsDts(dts, p, showSub));
}
return dts;
}
public DataTable getPateJobsDt(string plateId, bool showSub = false)
{
List<DataTable> dts = new List<DataTable>();
dts = getPlateJobsDts(dts ,plateId, showSub);
DataTable d = dts[0];
for (int i = 1; i < dts.Count;i++)
{
d= unionTables(d, dts[i],i+"");
}
return d;
}
private Dictionary<string, List<WmsOutPickRequest>> getPlatePlateRequest(Dictionary<string, List<WmsOutPickRequest>> requests, string plateId, bool showSub = false)
{
// LogHelper.debug(this.GetType(), string.Format(" plate contents dts size {2}, plateId {0},showSub {1}", plateId, showSub, requests.Count));
List<WmsOutPickRequest> lst = new WmsPlateStock_tmp().getPickRequests(plateId,enumOutStoreType.);
foreach(WmsOutPickRequest p in lst)
{
if (!requests.ContainsKey(p.pickOrderNo))
{
requests.Add(p.pickOrderNo, lst);
// LogHelper.debug(this.GetType(), string.Format(" plateId {0} contents request {1}", plateId, p.pickOrderNo));
}
}
// LogHelper.debug(this.GetType(), string.Format(" plateId {0} contents request size {2}, showSub {1}", plateId, showSub, lst.Count));
if (!showSub)
{
return requests;
}
List<string> subPlate = getSubPlateIds(plateId);
// LogHelper.debug(this.GetType(), string.Format(" plate {0} sub plate count {1} ", plateId, subPlate.Count));
foreach (string p in subPlate)
{
// dts.Concat(getPlateJobsDts(dts,obj.plateId, showSub));
requests = getPlatePlateRequest(requests, p, showSub) ;
}
return requests;
}
public List<WmsOutPickRequest> getPlateRequests(string plateId, bool showSub = false)
{
List<WmsOutPickRequest> lst = new List<WmsOutPickRequest>();
Dictionary<string, List<WmsOutPickRequest>> requests = new Dictionary<string, List<WmsOutPickRequest>>();
requests = getPlatePlateRequest(requests, plateId, showSub);
// LogHelper.debug(this.GetType(), string.Format(" plate {0} request list count {1} ", plateId, requests.Count));
foreach (string p in requests.Keys)
{
lst= lst.Concat(requests[p]).ToList();
}
LogHelper.debug(this.GetType(), string.Format(" plate {0} request count {1} ", plateId, lst.Count));
return lst ;
}
public static DataTable unionTables(DataTable dt1,DataTable dt2,string newName)
{
DataTable dt = dt1.Copy();
dt.TableName= newName;
foreach(DataRow item in dt2.Rows)
{
DataRow dr = dt.NewRow();
dr.ItemArray =item.ItemArray;
dt.Rows.Add(dr);
}
return dt;
}
/// <summary>
/// 固定容器
/// </summary>
/// <param name="flowNo"></param>
/// <returns></returns>
public DataTable queryRegistedPlate(string flowNo)
{
cmdParameters[0] = flowNo;
return CustQuery(900).Tables[0];
}
/// <summary>
/// 拣货子容器
/// </summary>
/// <param name="flowNo"></param>
/// <returns></returns>
public DataTable queryStockTmpPlate(string flowNo)
{
cmdParameters[0] = flowNo;
return CustQuery(910).Tables[0];
}
public DataTable queryFromPlate(string flowNo)
{
DataTable dt = queryStockTmpPlate(flowNo);
if(dt.Rows.Count > 0) //若存在 临时库存,返回库存相关内容
{
return dt;
}
return queryRegistedPlate(flowNo); // 固定容器, 返回定义
}
public int releaseSubPlate(string fromPlate)
{
cmdParameters[0] = fromPlate;
return CustOper(1100);
}
public DataTable getLineId(string customerId)
{
cmdParameters[0] = customerId;
return CustQuery(1200).Tables[0];
}
/// <summary>
/// 根据货物货区属性和客户ID查找最新在用的wmsplate
/// </summary>
/// <param name="custId">pickorder custid</param>
/// <param name="part">货区114115.。。</param>
/// <returns></returns>
public WmsPlate getLatestPlate(string custId, string goodsId)
{
cmdParameters[0] = custId;
cmdParameters[1] = goodsId;
DataTable dt = CustQuery(1300).Tables[0];
foreach (DataRow dr in dt.Rows)
{
return new WmsPlate(dr);
}
return new WmsPlate();
}
}
}