diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
index 8460f14..79ac5ee 100644
--- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
+++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
@@ -5383,42 +5383,224 @@ namespace ICSSoft.DataProject
#endregion
- #region 获取调拨单
+ #region 获取未完成单据
///
- /// 获取未发,未发完调拨单
+ /// 根据传入类型,查询未完成单据
///
///
///
public static DataTable TransCodemationGet(TransferDoc JsonData)
{
+ // var language = LanguageHelper.GetName("WMSAPIInfo");
+ // if (JsonData==null)
+ // {
+ // throw new Exception(language.GetNameByCode("WMSAPIInfo007"));//"传送数据为空!"
+ // }
+ // using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
+ // {
+ // conn.Open();
+ // SqlTransaction sqlTran = conn.BeginTransaction();
+ // SqlCommand cmd = new SqlCommand();
+ // cmd.Transaction = sqlTran;
+ // cmd.Connection = conn;
+ // try
+ // {
+ // string Workpoint = "";
+ // Workpoint = JsonData.WorkPoint;
+
+ // string sql = @"SELECT DISTINCT TransferNO as TransCode FROM ICSTransfer
+ //WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by TransferNO desc";
+ // sql = string.Format(sql, Workpoint);
+
+ // DataTable table = DBHelper.SQlReturnData(sql, cmd);
+ // return table;
+ // }
+ // catch (Exception ex)
+ // {
+ // if (cmd.Transaction != null)
+ // cmd.Transaction.Rollback();
+ // log.Error(ex.Message);
+ // throw new Exception(ex.Message);
+ // }
+ // finally
+ // {
+ // if (conn.State == ConnectionState.Open)
+ // {
+ // conn.Close();
+ // }
+ // conn.Dispose();
+ // }
+ // }
var language = LanguageHelper.GetName("WMSAPIInfo");
- if (JsonData==null)
- {
- throw new Exception(language.GetNameByCode("WMSAPIInfo007"));//"传送数据为空!"
- }
using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
{
conn.Open();
- SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
- cmd.Transaction = sqlTran;
cmd.Connection = conn;
+ cmd.CommandTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TimeOut"]);
try
{
- string Workpoint = "";
- Workpoint = JsonData.WorkPoint;
+ if (string.IsNullOrEmpty(JsonData.TransType))
+ {
+ throw new Exception(language.GetNameByCode("WMSAPIInfo002"));//"单据类型不能为空!"
+ }
+ else if (!EnumHelper.HasDescriptions(typeof(TransTypeEnum), JsonData.TransType))
+ {
+ throw new Exception(language.GetNameByCode("WMSAPIInfo003"));//"单据类型不存在!"
+ }
+ else if (string.IsNullOrEmpty(JsonData.WorkPoint))
+ {
+ throw new Exception(language.GetNameByCode("WMSAPIInfo004"));//"站点不能为空!"
+ }
+
+ string TransType = JsonData.TransType;
+ #region SLQ
+ //string sqlCheck = @"IF NOT EXISTS(SELECT a.ID FROM {1} WHERE {2})
+ // BEGIN
+ // RAISERROR('" + language.GetNameByCode("WMSAPIInfo035") + @"',16,1);
+ // RETURN
+ // END
+ // ";
+ string sql = @"SELECT
+ {0}
+ FROM {1}
+ WHERE {2}
+ order by a.MTIME DESC";
+ #endregion
+
+ bool isDeliveryNotice = false; //送货、到货、含委外
+ bool MOApplyWithBin = false; //生产领料-库位
+ bool OtherOutDocWithBin = false; //杂发-库位
+ string columns = string.Empty; //查询源头单据表的特殊列名
+ string tableName = string.Empty; //查询源头单据表名
+ string where = string.Empty; //查询源头单据的过滤条件
+ bool isMerge = false; //合并发料
+ string columnsMerge = string.Empty; //合并发料查询源头单据表的特殊列名
+ string tableNameMerge = string.Empty; //合并发料查询源头单据表名
+ #region 出库
+ #region 采购退货
+ if (TransType == TransTypeEnum.PurchaseReceiveDoctNegative.GetDescription())
+ {
+ columns = @" DISTINCT a.DNCode AS TransCode";
+
+ tableName = @"ICSDeliveryNotice a ";
+
+ where = @" a.WorkPoint='{1}' AND a.DNType='2' AND a.Status='2' AND (a.Quantity-a.RCVQuantity)>0";
+ }
+ #endregion
+ #region 其他出库
+ else if (TransType == TransTypeEnum.OtherOutDoc.GetDescription())
+ {
+ columns = @" DISTINCT a.OutCode AS TransCode";
+
+ tableName = @"ICSOtherOut a ";
+
+ where = @" a.Status='1' AND a.WorkPoint='{1}' and a.Quantity>a.OutQuantity";
+ }
+ #endregion
+ #region 一步调拨(合并发料)
+ else if (TransType == TransTypeEnum.OneStepTransferDocIn.GetDescription())
+ {
+ columns = @" DISTINCT a.TransferNO AS TransCode";
+
+ tableName = @"ICSTransfer a ";
+
+ where = @" a.WorkPoint='{1}' AND a.Status='1' AND Quantity>ISNULL(TransferQuantity, 0) AND Type='1'";
+ }
+ #endregion
+ #region 生产发料(合并发料)
+ else if (TransType == TransTypeEnum.MOIssueDoc.GetDescription())
+ {
+ columns = @" DISTINCT b.MOCode AS TransCode";
+
+ tableName = @" ICSMOPick a
+ INNER JOIN ICSMO b ON a.MODetailID=b.MODetailID AND a.WorkPoint=b.WorkPoint ";
- string sql = @"SELECT DISTINCT TransferNO as TransCode FROM ICSTransfer
-WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by TransferNO desc";
- sql = string.Format(sql, Workpoint);
+ where = @" a.WorkPoint='{1}' AND a.SupplyType='3' AND b.MOStatus<>'3' and a.EATTRIBUTE1<>'1' and a.Quantity-a.IssueQuantity>0";
+ }
+ #endregion
+ #region 开立材料出库(合并发料)
+ else if (TransType == TransTypeEnum.MOIssue.GetDescription())
+ {
+ columns = @" DISTINCT a.IssueCode AS TransCode";
+
+ tableName = @" ICSMOIssue a ";
+
+ where = @" a.WorkPoint='{1}' AND a.Status<>'3' and a.Quantity-a.IssueQuantity>0";
+ }
+ #endregion
+ #region 生产发料-领料申请单
+ else if (TransType == TransTypeEnum.MOApply.GetDescription())
+ {
+ columns = @" DISTINCT a.ApplyCode AS TransCode";
+
+ tableName = @" ICSMOApply a
+ INNER JOIN ICSMO b ON b.MOCode=a.SourceCode and a.SourceSequence = b.Sequence AND a.WorkPoint=b.WorkPoint";
+
+ where = @" a.Status='2' AND a.WorkPoint='{1}' and a.Quantity-a.IssueQuantity>0";
+ }
+ #endregion
+ #region 开立委外材料出库(合并发料)
+ else if (TransType == TransTypeEnum.OOIssue.GetDescription())
+ {
+ columns = @" DISTINCT a.IssueCode AS TransCode";
+
+ tableName = @" ICSOIssue a ";
+ where = @" a.WorkPoint='{1}' AND a.Status<>'3' and a.Quantity-a.IssueQuantity>0";
+ }
+ #endregion
+ #region 委外领料申请单发料(合并发料)
+ else if (TransType == TransTypeEnum.OOApply.GetDescription())
+ {
+ columns = @" DISTINCT a.ApplyCode AS TransCode";
+
+ tableName = @" ICSOApply a ";
+
+ where = @" a.WorkPoint='{1}' AND a.Status<>'3' and a.Quantity-a.IssueQuantity>0";
+ }
+ #endregion
+ #region 委外发料(合并发料)
+ else if (TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription())
+ {
+ columns = @" DISTINCT b.OOCode AS TransCode";
+
+ tableName = @" ICSOOPick a
+ INNER JOIN ICSOutsourcingOrder b ON a.OODetailID=b.OODetailID AND a.WorkPoint=b.WorkPoint ";
+
+ where = @" a.WorkPoint='{1}' AND a.SupplyType='3' AND b.Status<>'3' and a.EATTRIBUTE1<>'1' and a.Quantity-a.IssueQuantity>0";
+ }
+ #endregion
+ #region 销售出库(合并发料)
+ else if (TransType == TransTypeEnum.SalesShipmentDoc.GetDescription())
+ {
+ columns = @" DISTINCT a.SDNCode AS TransCode";
+
+ tableName = @"ICSSDN a ";
+
+ where = @" a.WorkPoint='{1}' AND a.Type='1' AND a.Status<>'3' and a.Quantity-a.SDNQuantity>0";
+ }
+ #endregion
+ #region 盘点
+ else if (TransType == TransTypeEnum.Check.GetDescription())
+ {
+
+ columns = @" DISTINCT a.CheckCode AS TransCode";
+
+ tableName = @"ICSCheck a ";
+
+ where = @" a.WorkPoint='{1}' ";
+ }
+ #endregion
+ where = string.Format(where, JsonData.TransCode, JsonData.WorkPoint);
+ sql = string.Format(sql, columns, tableName, where, JsonData.TransCode);
+ log.Debug("源头单据sql : " + sql);
DataTable table = DBHelper.SQlReturnData(sql, cmd);
return table;
- }
+ #endregion
+ }
catch (Exception ex)
{
- if (cmd.Transaction != null)
- cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}