You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2595 lines
131 KiB
2595 lines
131 KiB
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using NFine.Code;
|
|
using NFine.Repository;
|
|
using System.Data.Common;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using ICS.Application.Entity;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using System.Data.SqlClient;
|
|
using ICS.Data;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class PickMaterialApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
public static DataTable Invmes = new DataTable();
|
|
//工单备料(工单子件)
|
|
public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlstring = new StringBuilder();
|
|
#region [SQL]
|
|
|
|
// sql = @"select a.ID,b.MOCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,c.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
//case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
//from ICSMOPick a
|
|
//left join ICSMO b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
|
|
//left join ICSWarehouse c on a.WHCode=c.WarehouseCode and a.WorkPoint=c.WorkPoint
|
|
//left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
//left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and e.ID is null";
|
|
|
|
sqlstring.Append($@"select a.MOCode as Code,a.CreateDateTime as MTIME,a.createperson as MUSER,
|
|
case when max(d.SourceID) is null then '未合并' else '已合并' end as IsNew,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,
|
|
f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
|
|
from ICSMO a
|
|
inner join ICSMOPick b on b.MODetailID=a.MODetailID and b.WorkPoint=a.WorkPoint
|
|
left join ICSMOPickMerge d on d.SourceID=b.ID and d.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.WorkPoint='{WorkPoint}' ");
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlstring.Append($" and a.MOCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlstring.Append($" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
}
|
|
|
|
sqlstring.Append(@" group by a.MOCode, a.WorkPoint,a.CreateDateTime,a.createperson,f.Colspan,f.ProjectCode,
|
|
f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4,
|
|
f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10");
|
|
|
|
#endregion
|
|
return Repository().FindTablePageBySql(sqlstring.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//工单备料(工单子件)子表查询
|
|
public DataTable GetSubGridJson1(string Code)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select a.ID,b.MOCode as Code,a.Sequence+'-'+b.Sequence AS Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,c.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.IssueQuantity as IssueQuantity
|
|
|
|
from ICSMOPick a
|
|
left join ICSMO b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
|
|
left join ICSWarehouse c on a.WHCode=c.WarehouseCode and a.WorkPoint=c.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where b.MOCode='{0}' and a.WorkPoint='{1}'";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//工单领料(发料申请)
|
|
public DataTable GetGridJson2(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// select a.ID,a.ApplyCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName ,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
//case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSMOApply a
|
|
|
|
// left join ICSWarehouse b on a.WHCode = b.WarehouseCode and a.WorkPoint = b.WorkPoint
|
|
|
|
// left join ICSInventory d on a.InvCode = d.InvCode and a.WorkPoint = d.WorkPoint
|
|
|
|
// left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
|
|
sqlString.Append($@"
|
|
SELECT * from (select row_number() over(partition by a.ApplyCode ORDER BY a.ApplyCode) as row,
|
|
a.ApplyCode as Code,a.CreateDateTime as MTIME,a.createperson as MUSER,a.WHCode,detail.LocationCode AS Area,
|
|
a.EATTRIBUTE,a.Sets,a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Desks,a.DispatchNumber,a.DispatcherName,
|
|
a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator,
|
|
case when max(e.SourceID) is null then '未合并' else '已合并' end as IsNew,f.Colspan ,
|
|
f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,
|
|
f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.ID
|
|
from ICSMOApply a
|
|
left JOIN ICSInventory b ON b.InvCode=a.InvCode
|
|
LEFT JOIN ICSInventoryDetail detail ON b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.WorkPoint='{WorkPoint}' ");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.ApplyCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.WHCode like '%{queryParam["WHCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sqlString.Append($@" and detail.LocationCode like '%{queryParam["Area"]}%' ");
|
|
}
|
|
|
|
}
|
|
sqlString.Append(@" group by a.ApplyCode, a.WorkPoint,a.CreateDateTime,a.createperson,
|
|
f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,
|
|
f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.WHCode,detail.LocationCode,a.ID,a.EATTRIBUTE,a.Sets,a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Desks,a.DispatchNumber,a.DispatcherName,
|
|
a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator) as t where t.row=1");
|
|
#endregion
|
|
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//工单领料(发料申请)子表查询
|
|
public DataTable GetSubGridJson2(string queryJson, string Code)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT * FROM (select row_number() over(partition by a.ApplyCode,a.InvCode,a.Sequence ORDER BY a.ApplyCode) as row,
|
|
a.ID,a.ApplyCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName ,a.InvCode,
|
|
a.EATTRIBUTE,a.Sets,a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Desks,a.DispatchNumber,a.DispatcherName,
|
|
a.ReceiverNumber,a.ReceiverName,a.Urgency,a.NeedDate,a.NeedTime,a.RemarksTerm,a.TextNumber,a.InvDescribe,a.Unit,a.StockIndicator,
|
|
d.InvName,d.InvDesc,d.InvStd,d.InvUnit,detail.LocationCode AS Area,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.IssueQuantity as IssueQuantity
|
|
from ICSMOApply a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.ApplyCode='{0}' and a.WorkPoint='{1}'";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sql += " and a.WHCode like '%" + queryParam["WHCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql += " ) c WHERE c.row=1 ";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//工单材料出库(材料出库)
|
|
public DataTable GetGridJson3(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"select a.ID,a.IssueCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode ,b.WarehouseName ,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
// case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSMOIssue a
|
|
//left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
//left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
//left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint ";
|
|
// sql += " WHERE 1=1 and e.ID is null";
|
|
sqlString.Append($@"SELECT * FROM(SELECT row_number ( ) OVER ( partition BY a.IssueCode ORDER BY a.IssueCode ) AS row,
|
|
a.IssueCode as Code,a.CreateDateTime as MTIME,a.createperson as MUSER,
|
|
case when max(e.SourceID) is null then '未合并' else '已合并'
|
|
end as IsNew,f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,
|
|
f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
|
|
from ICSMOIssue a
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
where a.WorkPoint = '{WorkPoint}' ");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.IssueCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
}
|
|
sqlString.Append(@"group by a.IssueCode,a.CreateDateTime,a.createperson,f.Colspan,f.ProjectCode,f.BatchCode,
|
|
f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,
|
|
f.cFree8, f.cFree9, f.cFree10 ) AS t WHERE t.row= 1 ");
|
|
#endregion
|
|
|
|
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//工单材料出库(材料出库)子表查询
|
|
public DataTable GetSubGridJson3(string Code)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select a.ID,a.IssueCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode ,b.WarehouseName ,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.IssueQuantity as IssueQuantity
|
|
from ICSMOIssue a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.IssueCode='{0}' and a.WorkPoint='{1}'";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
//委外备料(委外备料)
|
|
public DataTable GetGridJson4(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
sqlString.Append($@"select * from (select row_number() over(partition by b.OOCode order by b.OOCode) row, b.OOCode as Code,
|
|
b.CreateDateTime as MTIME,
|
|
b.CreatePerson as MUSER,
|
|
case
|
|
when max(e.SourceID) is null then '未合并'
|
|
else '已合并'
|
|
end as IsNew,
|
|
f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,
|
|
f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
|
|
from ICSOOPick a
|
|
inner join ICSOutsourcingOrder b on a.OODetailID = b.OODetailID and a.WorkPoint = b.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
WHERE b.WorkPoint = '{WorkPoint}' ");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.OOCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
}
|
|
sqlString.Append(@" group by b.OOCode,b.CreateDateTime,b.CreatePerson,f.Colspan ,f.ProjectCode ,
|
|
f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4,
|
|
f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10) t where t.row=1");
|
|
|
|
#endregion
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//委外备料(委外备料)子表查询
|
|
public DataTable GetSubGridJson4(string Code)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select a.ID,b.OOCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,c.WarehouseName ,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.IssueQuantity as IssueQuantity
|
|
from ICSOOPick a
|
|
left join ICSOutsourcingOrder b on a.OODetailID=b.OODetailID and a.WorkPoint=b.WorkPoint
|
|
left join ICSWarehouse c on a.WHCode=c.WarehouseCode and a.WorkPoint=c.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where b.OOCode='{0}' and b.WorkPoint='{1}'";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
//委外领料(委外发料申请)
|
|
public DataTable GetGridJson5(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"select a.ID,a.ApplyCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
//case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSOApply a
|
|
//left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
//left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
//left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and e.ID is null";
|
|
sqlString.Append($@"select * from (select row_number() over (partition by a.ApplyCode order by a.ApplyCode ) row, a.ApplyCode as Code,a.CreateDateTime as MTIME,a.CreatePerson as MUSER,
|
|
case when max(e.SourceID) is null then '未合并'
|
|
else '已合并'
|
|
end as IsNew,f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
|
|
f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID
|
|
from ICSOApply a
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
where a.WorkPoint = '{WorkPoint}'");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.ApplyCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.WHCode like '%{queryParam["WHCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sqlString.Append($@" and detail.LocationCode like '%{queryParam["Area"]}%' ");
|
|
}
|
|
|
|
}
|
|
sqlString.Append(@"group by a.ApplyCode,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,
|
|
f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,
|
|
f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID ) t where row=1");
|
|
#endregion
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//委外领料(委外发料申请)子表查询
|
|
public DataTable GetSubGridJson5(string Code, string queryJson)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT * FROM (select row_number() over(partition by a.ApplyCode,a.InvCode,a.Sequence ORDER BY a.ApplyCode) as row,
|
|
a.ID,a.ApplyCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity,detail.LocationCode AS Area,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.IssueQuantity as IssueQuantity
|
|
from ICSOApply a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.ApplyCode='{0}' and a.WorkPoint='{1}'";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sql += " and a.WHCode like '%" + queryParam["WHCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql += " ) c WHERE c.row=1 ";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//委外材料出库(委外发料申请)
|
|
public DataTable GetGridJson6(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"select a.ID,a.IssueCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseCode,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
//case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSOIssue a
|
|
//left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
//left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
//left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and e.ID is null";
|
|
sqlString.Append($@"select * from(select row_number() over(partition by a.IssueCode order by a.IssueCode) row, a.IssueCode as Code,
|
|
a.CreateDateTime as MTIME,
|
|
a.CreatePerson as MUSER,
|
|
case
|
|
when max(e.SourceID) is null then '未合并'
|
|
else '已合并'
|
|
end as IsNew,f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,
|
|
f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,
|
|
f.cFree8,f.cFree9,f.cFree10
|
|
from ICSOIssue a
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
where a.WorkPoint = '{WorkPoint}'");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.IssueCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
}
|
|
sqlString.Append(@"group by a.IssueCode,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,
|
|
f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,
|
|
f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10) t where t.row=1");
|
|
|
|
#endregion
|
|
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
//委外材料出库(委外发料申请)子表查询
|
|
public DataTable GetSubGridJson6(string Code)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select a.ID,a.IssueCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseCode,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.IssueQuantity as IssueQuantity
|
|
from ICSOIssue a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.IssueCode='{0}' and a.WorkPoint='{1}'";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//销售发货(销售发货)
|
|
public DataTable GetGridJson7(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"select a.ID,a.SDNCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
//case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSSDN a
|
|
//left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
//left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
//left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and a.Type='1' and e.ID is null";
|
|
sqlString.Append($@"SELECT * from (SELECT Row_Number() over(partition by a.SDNCode Order by a.SDNCode) as r, a.SDNCode AS Code,
|
|
a.CreateDateTime AS MTIME,
|
|
a.CreatePerson AS MUSER,
|
|
(CASE WHEN max(e.SourceID) IS NULL THEN '未合并' ELSE '已合并' END) AS IsNew,
|
|
f.Colspan, f.ProjectCode, f.BatchCode, f.Version, f.Brand,
|
|
f.cFree1, f.cFree2, f.cFree3, f.cFree4, f.cFree5, f.cFree6, f.cFree7, f.cFree8, f.cFree9, f.cFree10,a.ID
|
|
FROM ICSSDN a
|
|
LEFT JOIN ICSMOPickMerge e ON a.ID = e.SourceID AND a.WorkPoint = e.WorkPoint
|
|
LEFT JOIN ICSExtension f ON a.ExtensionID = f.ID AND a.WorkPoint = f.WorkPoint
|
|
LEFT JOIN ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
WHERE a.WorkPoint = '{WorkPoint}' ");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($" and a.SDNCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.WHCode like '%{queryParam["WHCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sqlString.Append($@" and detail.LocationCode like '%{queryParam["Area"]}%' ");
|
|
}
|
|
|
|
}
|
|
sqlString.Append(@"GROUP BY a.SDNCode, a.CreateDateTime, a.CreatePerson, f.Colspan, f.ProjectCode, f.BatchCode, f.Version, f.Brand,
|
|
f.cFree1, f.cFree2, f.cFree3, f.cFree4, f.cFree5, f.cFree6, f.cFree7, f.cFree8, f.cFree9, f.cFree10,a.ID) t WHERE t.r=1");
|
|
#endregion
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//销售发货(销售发货)子表查询
|
|
public DataTable GetSubGridJson7(string Code, string queryJson)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT * FROM (select row_number() over(partition by a.SDNCode,a.InvCode,a.Sequence ORDER BY a.SDNCode) as row,
|
|
a.ID,a.SDNCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode
|
|
,a.WorkPoint,a.Points,a.DeliveryType,a.DeliveryDescribe,a.InvDescribe,a.OtherDescribe,
|
|
a.SalesUnit,a.StockIndicator,a.IsSerialNumber,
|
|
d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity,detail.LocationCode AS Area
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.SDNQuantity as IssueQuantity
|
|
from ICSSDN a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.SDNCode='{0}' and a.WorkPoint='{1}'";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sql += " and a.WHCode like '%" + queryParam["WHCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql += " ) c WHERE c.row=1 ";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
//其它出库(其它出库)
|
|
public DataTable GetGridJson8(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"select a.ID,a.OutCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
//case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
//from ICSOtherOut a
|
|
//left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
//left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
//left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and e.ID is null ";
|
|
sqlString.Append($@"select * from(select row_number() over(partition by a.OutCode order by a.OutCode) row, a.OutCode as Code,
|
|
a.CreateDateTime as MTIME,
|
|
a.CreatePerson as MUSER,
|
|
case
|
|
when max(e.SourceID) is null then '未合并'
|
|
else '已合并'
|
|
end as IsNew,f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
|
|
f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID
|
|
from ICSOtherOut a
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
where a.WorkPoint = '{WorkPoint}'");
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.OutCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.WHCode like '%{queryParam["WHCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sqlString.Append($@" and detail.LocationCode like '%{queryParam["Area"]}%' ");
|
|
}
|
|
|
|
}
|
|
sqlString.Append(@" group by a.OutCode,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,f.BatchCode,
|
|
f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,
|
|
f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID) t where t.row=1");
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//其它出库(其它出库)子表查询
|
|
public DataTable GetSubGridJson8(string Code, string queryJson)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT * FROM (select row_number() over(partition by a.OutCode,a.InvCode,a.Sequence ORDER BY a.OutCode) as row,
|
|
a.ID,a.OutCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.Quantity,
|
|
a.InvCode,a.WorkPoint,a.OrderType, a.TypeDescribe,a.CostCenter,a.Remarks,a.PersonNumber,a.InvDescribe,
|
|
a.Unit,a.StockIndicator,
|
|
d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,detail.LocationCode AS Area
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.OutQuantity as IssueQuantity
|
|
from ICSOtherOut a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.OutCode='{0}' and a.WorkPoint='{1}'";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sql += " and a.WHCode like '%" + queryParam["WHCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql += " ) c WHERE c.row=1 ";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
//借用(借用)
|
|
public DataTable GetGridJson9(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"
|
|
//select a.ID,a.BrrowCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
// case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSBrrow a
|
|
// left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
// left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
// left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and e.ID is null ";
|
|
sqlString.Append($@"select * from(select row_number() over(partition by a.BrrowCode order by a.BrrowCode) row, a.BrrowCode as Code,
|
|
a.CreateDateTime as MTIME,
|
|
a.CreatePerson as MUSER,
|
|
case
|
|
when max(e.SourceID) is null then '未合并'
|
|
else '已合并'
|
|
end as IsNew,f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,
|
|
f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,
|
|
f.cFree8,f.cFree9,f.cFree10
|
|
from ICSBrrow a
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
where a.WorkPoint = '{WorkPoint}'");
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.BrrowCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
}
|
|
sqlString.Append(@"group by a.BrrowCode,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,
|
|
f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,
|
|
f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,
|
|
f.cFree10) t where t.row=1");
|
|
#endregion
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//借用(借用)子表查询
|
|
public DataTable GetSubGridJson9(string Code)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select a.ID,a.BrrowCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.BrrowQuantity as IssueQuantity
|
|
from ICSBrrow a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.BrrowCode='{0}' and a.WorkPoint='{1}'";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
//物料调拨
|
|
public DataTable GetGridJson10(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"
|
|
//select a.ID,a.BrrowCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
// case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSBrrow a
|
|
// left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
// left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
// left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and e.ID is null ";
|
|
sqlString.Append($@"select * from (select row_number() over(partition by a.TransferNO order by a.TransferNO) row,
|
|
a.TransferNO as Code,a.ID,a.CreateDateTime as MTIME,a.CreatePerson as MUSER,
|
|
case
|
|
when max(e.SourceID) is null then '未合并'
|
|
else '已合并'
|
|
end as IsNew,f.Colspan,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,
|
|
f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
|
|
from ICSTransfer a
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.ToWarehouseCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
where a.WorkPoint = '{WorkPoint}' and a.Status = '2'");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.TransferNO like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.ToWarehouseCode like '%{queryParam["WHCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sqlString.Append($@" and detail.LocationCode like '%{queryParam["Area"]}%' ");
|
|
}
|
|
|
|
}
|
|
sqlString.Append(@"group by a.TransferNO,a.CreateDateTime,a.CreatePerson,f.Colspan,f.ProjectCode,
|
|
f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,
|
|
f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10,a.ID) t where t.row=1");
|
|
#endregion
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
//物料调拨子表查询
|
|
public DataTable GetSubGridJson10(string Code, string queryJson)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT * from (select row_number() over(partition by a.TransferNO,a.InvCode,
|
|
a.Sequence ORDER BY a.TransferNO) as row, a.ID,a.TransferNO as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.FromWarehouseCode as WHCode,b.WarehouseName,detail.LocationCode AS Area,
|
|
a.InvCode,a.ToWarehouseCode,a.EATTRIBUTE1 AS ReceiveWork,a.WorkPoint,a.OrderType,
|
|
a.TypeDescribe,a.Remarks,a.PersonNumber,a.InvDescribe,
|
|
a.Unit,a.StockIndicator,a.ReceiveInvCode,a.ReceiveInvDescribe,
|
|
a.ReceiveStock,a.ReceiveSales,a.ReceiveSequence,a.Remark2,
|
|
d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.TransferQuantity as IssueQuantity
|
|
from ICSTransfer a
|
|
left join ICSWarehouse b on a.FromWarehouseCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInventoryDetail detail ON d.InvCode=detail.INVCode AND a.ToWarehouseCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.TransferNO='{0}' and b.WorkPoint='{1}'";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sql += " and a.ToWarehouseCode like '%" + queryParam["WHCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
|
|
{
|
|
sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql += " ) as t where t.row=1";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
//两步调拨
|
|
public DataTable GetGridJson11(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
StringBuilder sqlString = new StringBuilder();
|
|
#region [SQL]
|
|
// sql = @"
|
|
//select a.ID,a.BrrowCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
// case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
// from ICSBrrow a
|
|
// left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
// left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
// left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint";
|
|
// sql += " WHERE 1=1 and e.ID is null ";
|
|
sqlString.Append($@"select * from (select row_number() over(partition by a.OutCode order by a.OutCode)row, a.OutCode as Code, a.CreateDateTime as MTIME, a.CreatePerson as MUSER,
|
|
case when max(e.SourceID) is null then '未合并' else '已合并' end as IsNew,a.EATTRIBUTE1 AS ReceiveWork,tra.ToWarehouseCode,
|
|
f.Colspan, f.ProjectCode, f.BatchCode, f.Version, f.Brand,
|
|
f.cFree1, f.cFree2, f.cFree3, f.cFree4, f.cFree5, f.cFree6, f.cFree7, f.cFree8, f.cFree9, f.cFree10
|
|
FROM ICSOtherOut a
|
|
INNER JOIN ICSTransfer tra ON a.TransferDetailID = tra.TransferDetailID AND a.WorkPoint = tra.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID = e.SourceID and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
|
|
where a.WorkPoint = '{WorkPoint}'
|
|
and a.Status = '2' ");
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.OutCode like '%{queryParam["POCode"]}%' ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sqlString.Append($@" and a.InvCode like '%{queryParam["InvCode"]}%' ");
|
|
}
|
|
}
|
|
sqlString.Append(@" group by a.OutCode, a.CreateDateTime, a.CreatePerson,a.EATTRIBUTE1 ,tra.ToWarehouseCode, f.Colspan ,f.ProjectCode ,
|
|
f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,
|
|
f.cFree5, f.cFree6, f.cFree7, f.cFree8, f.cFree9, f.cFree10) t where t.row=1");
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
return Repository().FindTablePageBySql(sqlString.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//两步调拨子表查询
|
|
public DataTable GetSubGridJson11(string Code)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select a.ID,a.OutCode as Code,a.Sequence,a.MTIME,a.MUSERName,a.MUSER,a.WHCode ,b.WarehouseName,a.InvCode,d.InvName,d.InvDesc,d.InvStd,d.InvUnit,
|
|
case when e.SourceID is null then '未合并' else '已合并' end as IsNew,a.Quantity
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
|
|
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.OutQuantity as IssueQuantity
|
|
FROM ICSOtherOut a
|
|
INNER JOIN ICSTransfer tra ON a.TransferDetailID=tra.TransferDetailID AND a.WorkPoint=tra.WorkPoint
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory d on a.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join ICSMOPickMerge e on a.ID=e.SourceID and a.WorkPoint=e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.OutCode='{0}' and a.WorkPoint='{1}'";
|
|
sql = string.Format(sql, Code, WorkPoint);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// public DataTable GetICSMOPickMergeTemp(string ID,string Type)
|
|
// {
|
|
// string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
// ID = string.IsNullOrWhiteSpace(ID) ? "''" : ID.TrimEnd(',');
|
|
// #region sql
|
|
// string sql = @"SELECT row_number() over (order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
|
|
// c.Code,
|
|
// c.InvCode,
|
|
// c.InvName,
|
|
// c.InvStd,
|
|
// c.InvUnit,
|
|
// FLOOR(c.iQuantity) AS iQuantity,
|
|
// d.WarehouseCode,
|
|
// m.LotNO,
|
|
// (case when m.LotNo is null then 0 else FLOOR(ISNULL(d.Quantity, 0)) end) AS QTY,
|
|
// (case when m.LotNo is null then null else d.LocationCode end) AS LocationCode,
|
|
// CONVERT(varchar(100),d.MTIME, 23) MTIME,
|
|
// FLOOR(f.QTYTotal) QTYTotal INTO #temp
|
|
// FROM
|
|
// ({0}) c
|
|
// LEFT JOIN ICSWareHouseLotInfo d ON c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode AND d.WorkPoint='{1}' AND d.Quantity>0
|
|
// left join ICSInventoryLot m on d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint and c.ExtensionID=m.ExtensionID
|
|
// LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='{1}' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
|
|
|
|
|
|
//DECLARE @ItemCode VARCHAR(50),
|
|
// @QTY DECIMAL(18,3),
|
|
// @ItemCodeCurrent VARCHAR(50),
|
|
// @Lotno VARCHAR(50),
|
|
// @QTYCurrent DECIMAL(18,3),
|
|
// @iQuantityCurrent DECIMAL(18,3),
|
|
// @CanDelete BIT,
|
|
// @Row INT,
|
|
// @rowCurrent INT
|
|
//SET @Row = @@rowcount
|
|
//SET @rowCurrent=1
|
|
//SET @CanDelete=0
|
|
//SET @ItemCode=''
|
|
//SET @Lotno = ''
|
|
|
|
//WHILE @rowCurrent<=@Row
|
|
// BEGIN
|
|
// SELECT @ItemCodeCurrent=InvCode,@QTYCurrent=QTY,@iQuantityCurrent=iQuantity,@Lotno = Lotno FROM #temp WHERE rowNo=@rowCurrent
|
|
|
|
//PRINT(@rowCurrent)
|
|
// IF @ItemCode<>@ItemCodeCurrent
|
|
// BEGIN
|
|
// SET @ItemCode=@ItemCodeCurrent
|
|
// SET @QTY=0
|
|
// SET @CanDelete=0
|
|
// END
|
|
|
|
// IF @CanDelete=1
|
|
// BEGIN
|
|
// DELETE FROM #temp WHERE rowNo=@rowCurrent
|
|
// SET @rowCurrent += 1
|
|
// CONTINUE
|
|
// END
|
|
|
|
// SET @QTY += @QTYCurrent
|
|
// IF @LotNo is null or @QTY>=@iQuantityCurrent
|
|
// BEGIN
|
|
// SET @CanDelete=1
|
|
// END
|
|
|
|
// SET @rowCurrent += 1
|
|
// END
|
|
//SELECT * FROM #temp
|
|
//DROP TABLE #temp
|
|
//";
|
|
// #endregion
|
|
// string sqls = "";
|
|
// if (Type=="1")
|
|
// {
|
|
// #region 工单备料sql
|
|
// sqls = @" SELECT
|
|
// c.MOCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
// b.InvUnit,
|
|
// a.ExtensionID
|
|
// FROM
|
|
// ICSMOPick a
|
|
// inner join ICSMO c on a.MODetailID=c.MODetailID and a.WorkPoint=c.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE c.MOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY c.MOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "2")
|
|
// {
|
|
// return GetICSMOPickMergeByWorkorder(ID, WorkPoint);
|
|
// }
|
|
// if (Type=="3")
|
|
// {
|
|
// #region 工单材料出库SQL
|
|
// sqls = @" select
|
|
// a.IssueCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
// b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
// a.ExtensionID
|
|
// FROM
|
|
// ICSMOIssue a
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type=="4")
|
|
// {
|
|
// #region 委外备料SQL
|
|
// sqls = @" select
|
|
// c.OOCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
// b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
// a.ExtensionID
|
|
// FROM
|
|
// ICSOOPick a
|
|
// left join ICSOutsourcingOrder c on a.OODetailID=c.OODetailID and a.WorkPoint=c.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE c.OOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY c.OOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode, a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type=="5")
|
|
// {
|
|
// #region 委外领料SQL
|
|
// sqls = @" select
|
|
// a.ApplyCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
// a.ExtensionID
|
|
// FROM
|
|
// ICSOApply a
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type=="6")
|
|
// {
|
|
// #region 委外材料出库SQL
|
|
// sqls = @" select
|
|
// a.IssueCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSOIssue a
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type=="7")
|
|
// {
|
|
// #region 销售发货SQL
|
|
// sqls = @" select
|
|
// a.SDNCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSSDN a
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.SDNCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.SDNCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type=="8")
|
|
// {
|
|
// #region 其它出库SQL
|
|
// sqls = @" select
|
|
// a.OutCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
// b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
// a.ExtensionID
|
|
// FROM
|
|
// ICSOtherOut a
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "9")
|
|
// {
|
|
// #region 借用SQL
|
|
// sqls = @"select
|
|
// a.BrrowCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSBrrow a
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.BrrowCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.BrrowCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "10")
|
|
// {
|
|
// #region 物料调拨
|
|
// sqls = @" select
|
|
// a.TransferNO as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.FromWarehouseCode as WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSTransfer a
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.TransferNO in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "11")
|
|
// {
|
|
// #region 两步调出
|
|
// sqls = @"select
|
|
// a.OutCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WHCode ,
|
|
//a.ExtensionID
|
|
// from ICSOtherOut a
|
|
// INNER JOIN ICSTransfer tra ON a.TransferDetailID=tra.TransferDetailID AND a.WorkPoint=tra.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WHCode,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
|
|
// sqls = string.Format(sqls, ID,WorkPoint);
|
|
// sql = string.Format(sql, sqls, WorkPoint);
|
|
// DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
|
|
// DataTable dtCloned = table.Clone();
|
|
// foreach (DataColumn col in dtCloned.Columns)
|
|
// {
|
|
// col.DataType = typeof(string);
|
|
// }
|
|
// foreach (DataRow row in table.Rows)
|
|
// {
|
|
// DataRow newrow = dtCloned.NewRow();
|
|
// foreach (DataColumn column in dtCloned.Columns)
|
|
// {
|
|
// newrow[column.ColumnName] = row[column.ColumnName].ToString();
|
|
|
|
// }
|
|
// dtCloned.Rows.Add(newrow);
|
|
// }
|
|
// if (Invmes.Rows.Count > 0)
|
|
// {
|
|
// dtCloned.Merge(Invmes, false);
|
|
// }
|
|
// return dtCloned;
|
|
// }
|
|
public DataTable GetICSMOPickMergeTemp(string ID, string Type)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
ID = string.IsNullOrWhiteSpace(ID) ? "''" : ID.TrimEnd(',');
|
|
#region sql
|
|
|
|
#endregion
|
|
string sqls = "";
|
|
if (Type == "1")
|
|
{
|
|
#region 工单备料sql
|
|
sqls = @" SELECT
|
|
c.MOCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
b.InvUnit,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSMOPick a
|
|
inner join ICSMO c on a.MODetailID=c.MODetailID and a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE c.MOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY c.MOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "2")
|
|
{
|
|
sqls = @"select
|
|
a.ApplyCode as Code, a.InvCode, b.InvName, b.InvStd, b.InvUnit, SUM(ISNULL(a.Quantity, 0)) AS iQuantity, a.WhCode,a.ExtensionID
|
|
FROM
|
|
ICSMOApply a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
}
|
|
if (Type == "3")
|
|
{
|
|
#region 工单材料出库SQL
|
|
sqls = @" select
|
|
a.IssueCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSMOIssue a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "4")
|
|
{
|
|
#region 委外备料SQL
|
|
sqls = @" select
|
|
c.OOCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOOPick a
|
|
left join ICSOutsourcingOrder c on a.OODetailID=c.OODetailID and a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE c.OOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY c.OOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode, a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "5")
|
|
{
|
|
#region 委外领料SQL
|
|
sqls = @"select
|
|
a.ApplyCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,a.ExtensionID
|
|
FROM
|
|
ICSOApply a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "6")
|
|
{
|
|
#region 委外材料出库SQL
|
|
sqls = @" select
|
|
a.IssueCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOIssue a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "7")
|
|
{
|
|
#region 销售发货SQL
|
|
sqls = @" select
|
|
a.SDNCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSSDN a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.SDNCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.SDNCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "8")
|
|
{
|
|
#region 其它出库SQL
|
|
sqls = @" select
|
|
a.OutCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOtherOut a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "9")
|
|
{
|
|
#region 借用SQL
|
|
sqls = @"select
|
|
a.BrrowCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSBrrow a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.BrrowCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.BrrowCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "10")
|
|
{
|
|
#region 物料调拨
|
|
sqls = @"select
|
|
a.TransferNO as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.FromWarehouseCode as WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSTransfer a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.TransferNO in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "11")
|
|
{
|
|
#region 两步调出
|
|
sqls = @"select
|
|
a.OutCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WHCode ,
|
|
a.ExtensionID
|
|
from ICSOtherOut a
|
|
INNER JOIN ICSTransfer tra ON a.TransferDetailID=tra.TransferDetailID AND a.WorkPoint=tra.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WHCode,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
sqls = string.Format(sqls, ID, WorkPoint);
|
|
|
|
string sql = $@"SELECT row_number() over ( order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
|
|
c.Code,
|
|
c.InvCode,
|
|
c.InvName,
|
|
c.InvStd,
|
|
c.InvUnit,
|
|
FLOOR(c.iQuantity) AS iQuantity,
|
|
c.WHCode AS WarehouseCode,
|
|
d.LotNO,
|
|
FLOOR(ISNULL(d.Quantity, 0)) AS QTY,
|
|
d.LocationCode AS LocationCode,
|
|
CONVERT(varchar(100),d.MTIME, 23) MTIME,
|
|
FLOOR(f.QTYTotal) QTYTotal
|
|
FROM
|
|
({sqls}) c
|
|
left join (select d.WarehouseCode,d.Quantity,d.INVCode, m.LotNo, d.MTIME,d.LocationCode,m.ExtensionID
|
|
from ICSWareHouseLotInfo d ,ICSInventoryLot m
|
|
where d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint
|
|
and d.WorkPoint='{WorkPoint}' AND d.Quantity>0 ) d
|
|
on c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode and d.ExtensionID=c.ExtensionID
|
|
LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='{WorkPoint}' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
|
|
order by c.Code,c.InvCode,d.MTIME ";
|
|
|
|
var dataset = Repository().FindDataSetBySql(sql);
|
|
if (dataset.Tables.Count == 0)
|
|
return null;
|
|
DataTable table = dataset.Tables[0];
|
|
decimal qtyCount = 0;
|
|
bool remove = false;
|
|
List<int> removeList = new List<int>();
|
|
for (int i = 0; i < table.Rows.Count; i++)
|
|
{
|
|
|
|
if (i != 0
|
|
&& (!table.Rows[i]["InvCode"].ToString().Equals(table.Rows[i - 1]["InvCode"].ToString())
|
|
|| !table.Rows[i]["Code"].ToString().Equals(table.Rows[i - 1]["Code"].ToString()))
|
|
)
|
|
{
|
|
qtyCount = 0;
|
|
remove = false;
|
|
}
|
|
if (remove)
|
|
{
|
|
removeList.Add(i);
|
|
}
|
|
else
|
|
{
|
|
var lotQty = table.Rows[i]["QTY"].ToString().ToDecimal();
|
|
var orderQty = table.Rows[i]["iQuantity"].ToString().ToDecimal();
|
|
qtyCount += lotQty;
|
|
if (qtyCount >= orderQty)
|
|
{
|
|
remove = true;
|
|
}
|
|
}
|
|
}
|
|
if (removeList.Count > 0)
|
|
{
|
|
removeList.Reverse();
|
|
foreach (var item in removeList)
|
|
{
|
|
table.Rows.RemoveAt(item);
|
|
}
|
|
}
|
|
|
|
var result = ConvertCellToString(table);
|
|
if (Invmes.Rows.Count > 0)
|
|
{
|
|
result.Merge(Invmes, false);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 工单领料推荐
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <param name="workPoint"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSMOPickMergeByWorkorder(string Id, string workPoint)
|
|
{
|
|
string sql = $@"SELECT row_number() over (partition by c.Code,c.InvCode order by c.Code,c.InvCode,d.MTIME) AS rowNo,
|
|
c.Code,
|
|
c.InvCode,
|
|
c.InvName,
|
|
c.InvStd,
|
|
c.InvUnit,
|
|
FLOOR(c.iQuantity) AS iQuantity,
|
|
d.WarehouseCode,
|
|
d.LotNO,
|
|
FLOOR(ISNULL(d.Quantity, 0)) AS QTY,
|
|
d.LocationCode LocationCode,
|
|
CONVERT(varchar(100),d.MTIME, 23) MTIME,
|
|
FLOOR(f.QTYTotal) QTYTotal
|
|
FROM
|
|
(select
|
|
a.ApplyCode as Code, a.InvCode, b.InvName, b.InvStd, b.InvUnit, SUM(ISNULL(a.Quantity, 0)) AS iQuantity, a.WhCode,a.ExtensionID
|
|
FROM
|
|
ICSMOApply a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.ApplyCode in ({Id}) AND a.WorkPoint = '{workPoint}'
|
|
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID) c
|
|
left join (select d.WarehouseCode,d.Quantity,d.INVCode, m.LotNo, d.MTIME,d.LocationCode,m.ExtensionID from ICSWareHouseLotInfo d ,ICSInventoryLot m
|
|
where d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint
|
|
and d.WorkPoint='{workPoint}' AND d.Quantity>0 ) d on c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode and d.ExtensionID=c.ExtensionID
|
|
LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='1701' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
|
|
order by c.Code,c.InvCode,d.MTIME";
|
|
var dataset = Repository().FindDataSetBySql(sql);
|
|
if (dataset.Tables.Count == 0)
|
|
return null;
|
|
DataTable table = dataset.Tables[0];
|
|
decimal qtyCount = 0;
|
|
bool remove = false;
|
|
List<int> removeList = new List<int>();
|
|
|
|
for (int i = 0; i < table.Rows.Count; i++)
|
|
{
|
|
if (i != 0
|
|
&& !table.Rows[i]["InvCode"].ToString().Equals(table.Rows[i - 1]["InvCode"].ToString()))
|
|
{
|
|
qtyCount = 0;
|
|
remove = false;
|
|
}
|
|
if (remove)
|
|
{
|
|
removeList.Add(i);
|
|
}
|
|
else
|
|
{
|
|
var lotQty = table.Rows[i]["QTY"].ToString().ToDecimal();
|
|
var orderQty = table.Rows[i]["iQuantity"].ToString().ToDecimal();
|
|
qtyCount += lotQty;
|
|
if (qtyCount >= orderQty)
|
|
{
|
|
remove = true;
|
|
}
|
|
}
|
|
}
|
|
if (removeList.Count > 0)
|
|
{
|
|
removeList.Reverse();
|
|
foreach (var item in removeList)
|
|
{
|
|
table.Rows.RemoveAt(item);
|
|
}
|
|
}
|
|
|
|
var result = ConvertCellToString(table);
|
|
if (Invmes.Rows.Count > 0)
|
|
{
|
|
result.Merge(Invmes, false);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public DataTable ConvertCellToString(DataTable data)
|
|
{
|
|
DataTable dtCloned = data.Clone();
|
|
foreach (DataColumn col in dtCloned.Columns)
|
|
{
|
|
col.DataType = typeof(string);
|
|
}
|
|
foreach (DataRow row in data.Rows)
|
|
{
|
|
DataRow newrow = dtCloned.NewRow();
|
|
foreach (DataColumn column in dtCloned.Columns)
|
|
{
|
|
newrow[column.ColumnName] = row[column.ColumnName].ToString();
|
|
|
|
}
|
|
dtCloned.Rows.Add(newrow);
|
|
}
|
|
return dtCloned;
|
|
}
|
|
|
|
|
|
// public DataTable GetICSMOPickMergeTemp2(string ID, string Type)
|
|
// {
|
|
// string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
// #region sql
|
|
// string sql = @"SELECT row_number() over (order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
|
|
// c.MergeID,
|
|
// c.Code,
|
|
// c.InvCode,
|
|
// c.InvName,
|
|
// c.InvStd,
|
|
//c.InvUnit,
|
|
// FLOOR(c.iQuantity) AS iQuantity,
|
|
// d.WarehouseCode,
|
|
// d.LocationCode,
|
|
// d.LotNO,
|
|
// FLOOR(ISNULL(d.Quantity, 0)) AS QTY,
|
|
// CONVERT(varchar(100),d.MTIME, 23) MTIME,
|
|
// FLOOR(f.QTYTotal) QTYTotal INTO #temp
|
|
// FROM
|
|
// ({0}) c
|
|
// LEFT JOIN ICSWareHouseLotInfo d ON c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode AND d.WorkPoint='{1}' AND d.Quantity>0
|
|
// left join ICSInventoryLot m on d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint and c.ExtensionID=m.ExtensionID
|
|
// LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='{1}' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
|
|
|
|
//DECLARE @ItemCode VARCHAR(50),
|
|
// @QTY DECIMAL(18,3),
|
|
// @ItemCodeCurrent VARCHAR(50),
|
|
// @QTYCurrent DECIMAL(18,3),
|
|
// @iQuantityCurrent DECIMAL(18,3),
|
|
// @CanDelete BIT,
|
|
// @Row INT,
|
|
// @rowCurrent INT
|
|
//SET @Row = @@rowcount
|
|
//SET @rowCurrent=1
|
|
//SET @CanDelete=0
|
|
//SET @ItemCode=''
|
|
|
|
//WHILE @rowCurrent<=@Row
|
|
// BEGIN
|
|
// SELECT @ItemCodeCurrent=InvCode,@QTYCurrent=QTY,@iQuantityCurrent=iQuantity FROM #temp WHERE rowNo=@rowCurrent
|
|
|
|
//PRINT(@rowCurrent)
|
|
// IF @ItemCode<>@ItemCodeCurrent
|
|
// BEGIN
|
|
// SET @ItemCode=@ItemCodeCurrent
|
|
// SET @QTY=0
|
|
// SET @CanDelete=0
|
|
// END
|
|
|
|
// IF @CanDelete=1
|
|
// BEGIN
|
|
// DELETE FROM #temp WHERE rowNo=@rowCurrent
|
|
// SET @rowCurrent += 1
|
|
// CONTINUE
|
|
// END
|
|
|
|
// SET @QTY += @QTYCurrent
|
|
// IF @QTY>=@iQuantityCurrent
|
|
// BEGIN
|
|
// SET @CanDelete=1
|
|
// END
|
|
|
|
// SET @rowCurrent += 1
|
|
// END
|
|
//SELECT * FROM #temp
|
|
//DROP TABLE #temp
|
|
//";
|
|
// #endregion
|
|
// string sqls = "";
|
|
// if (Type == "1")
|
|
// {
|
|
// #region 工单备料sql
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// c.MOCode as Code,
|
|
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSMOPick a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// inner join ICSMO c on a.MODetailID=c.MODetailID and a.WorkPoint=c.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE c.MOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY c.MOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,x.MergeID,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "2")
|
|
// {
|
|
// #region 工单领料SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.ApplyCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
// a.ExtensionID
|
|
// FROM
|
|
// ICSMOApply a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,x.MergeID,a.ExtensionID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "3")
|
|
// {
|
|
// #region 工单材料出库SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.IssueCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSMOIssue a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "4")
|
|
// {
|
|
// #region 委外备料SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// c.OOCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSOOPick a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// left join ICSOutsourcingOrder c on a.OODetailID=c.OODetailID and a.WorkPoint=c.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE c.OOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY c.OOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID, x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "5")
|
|
// {
|
|
// #region 委外领料SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.ApplyCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSOApply a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "6")
|
|
// {
|
|
// #region 委外材料出库SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.IssueCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSOIssue a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "7")
|
|
// {
|
|
// #region 销售发货SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.SDNCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSSDN a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.SDNCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.SDNCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "8")
|
|
// {
|
|
// #region 其它出库SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.OutCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSOtherOut a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "9")
|
|
// {
|
|
// #region 借用SQL
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.BrrowCode as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSBrrow a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.BrrowCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.BrrowCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "10")
|
|
// {
|
|
// #region 物料调拨
|
|
// sqls = @" select
|
|
// x.MergeID,
|
|
// a.TransferNO as Code,
|
|
// a.InvCode,
|
|
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
//b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.FromWarehouseCode as WhCode,
|
|
//a.ExtensionID
|
|
// FROM
|
|
// ICSTransfer a
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.TransferNO in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
// if (Type == "11")
|
|
// {
|
|
// #region 两步调出
|
|
// sqls = @"select
|
|
// x.MergeID,
|
|
// a.OutCode as Code,
|
|
// a.InvCode,
|
|
// b.InvName,
|
|
// b.InvStd,
|
|
// b.InvUnit,
|
|
// SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
// a.WHCode as WhCode,
|
|
// a.ExtensionID
|
|
// FROM
|
|
// ICSOtherOut a
|
|
// INNER JOIN ICSTransfer tra ON a.TransferDetailID=tra.TransferDetailID AND a.WorkPoint=tra.WorkPoint
|
|
// inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
// LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
// WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
// GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WHCode,a.ExtensionID,x.MergeID";
|
|
// #endregion
|
|
// }
|
|
|
|
|
|
// sqls = string.Format(sqls, string.IsNullOrWhiteSpace(ID) ? "''" : ID.TrimEnd(','), WorkPoint);
|
|
// sql = string.Format(sql, sqls, WorkPoint);
|
|
// DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
|
|
// DataTable dtCloned = table.Clone();
|
|
// foreach (DataColumn col in dtCloned.Columns)
|
|
// {
|
|
// col.DataType = typeof(string);
|
|
// }
|
|
// foreach (DataRow row in table.Rows)
|
|
// {
|
|
// DataRow newrow = dtCloned.NewRow();
|
|
// foreach (DataColumn column in dtCloned.Columns)
|
|
// {
|
|
// newrow[column.ColumnName] = row[column.ColumnName].ToString();
|
|
|
|
// }
|
|
// dtCloned.Rows.Add(newrow);
|
|
// }
|
|
// if (Invmes.Rows.Count > 0)
|
|
// {
|
|
// dtCloned.Merge(Invmes, false);
|
|
// }
|
|
// return dtCloned;
|
|
// }
|
|
public DataTable GetICSMOPickMergeTemp2(string ID, string Type)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
string sqls = "";
|
|
if (Type == "1")
|
|
{
|
|
#region 工单备料sql
|
|
sqls = @" select
|
|
x.MergeID,
|
|
c.MOCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSMOPick a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
inner join ICSMO c on a.MODetailID=c.MODetailID and a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE c.MOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY c.MOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,x.MergeID,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "2")
|
|
{
|
|
#region 工单领料SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.ApplyCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSMOApply a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,x.MergeID,a.ExtensionID";
|
|
#endregion
|
|
}
|
|
if (Type == "3")
|
|
{
|
|
#region 工单材料出库SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.IssueCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSMOIssue a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "4")
|
|
{
|
|
#region 委外备料SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
c.OOCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOOPick a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
left join ICSOutsourcingOrder c on a.OODetailID=c.OODetailID and a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE c.OOCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY c.OOCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID, x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "5")
|
|
{
|
|
#region 委外领料SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.ApplyCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOApply a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.ApplyCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.ApplyCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "6")
|
|
{
|
|
#region 委外材料出库SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.IssueCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOIssue a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.IssueCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.IssueCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "7")
|
|
{
|
|
#region 销售发货SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.SDNCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSSDN a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.SDNCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.SDNCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "8")
|
|
{
|
|
#region 其它出库SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.OutCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOtherOut a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "9")
|
|
{
|
|
#region 借用SQL
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.BrrowCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSBrrow a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.BrrowCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.BrrowCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WhCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "10")
|
|
{
|
|
#region 物料调拨
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.TransferNO as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.FromWarehouseCode as WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSTransfer a
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.TransferNO in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.TransferNO,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.FromWarehouseCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
if (Type == "11")
|
|
{
|
|
#region 两步调出
|
|
sqls = @" select
|
|
x.MergeID,
|
|
a.OutCode as Code,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
SUM(ISNULL(a.Quantity, 0)) AS iQuantity,
|
|
a.WHCode as WhCode,
|
|
a.ExtensionID
|
|
FROM
|
|
ICSOtherOut a
|
|
INNER JOIN ICSTransfer tra ON a.TransferDetailID=tra.TransferDetailID AND a.WorkPoint=tra.WorkPoint
|
|
inner join ICSMOPickMerge x on a.ID=x.SourceID and a.WorkPoint=x.WorkPoint
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode = b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.OutCode in ({0}) AND a.WorkPoint = '{1}'
|
|
GROUP BY a.OutCode,a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.WHCode,a.ExtensionID,x.MergeID";
|
|
#endregion
|
|
}
|
|
|
|
|
|
sqls = string.Format(sqls, string.IsNullOrWhiteSpace(ID) ? "''" : ID.TrimEnd(','), WorkPoint);
|
|
#region sql
|
|
string sql = $@"SELECT row_number() over (order by c.Code,c.InvCode,d.MTIME,d.LotNO) AS rowNo,
|
|
c.MergeID,
|
|
c.Code,
|
|
c.InvCode,
|
|
c.InvName,
|
|
c.InvStd,
|
|
c.InvUnit,
|
|
FLOOR(c.iQuantity) AS iQuantity,
|
|
d.WarehouseCode,
|
|
d.LocationCode,
|
|
d.LotNO,
|
|
FLOOR(ISNULL(d.Quantity, 0)) AS QTY,
|
|
CONVERT(varchar(100),d.MTIME, 23) MTIME,
|
|
FLOOR(f.QTYTotal) QTYTotal
|
|
FROM
|
|
({sqls}) c
|
|
left join (select d.WarehouseCode,d.Quantity,d.INVCode, m.LotNo, d.MTIME,d.LocationCode,m.ExtensionID
|
|
from ICSWareHouseLotInfo d ,ICSInventoryLot m
|
|
where d.LotNo=m.LotNo and d.WorkPoint=m.WorkPoint
|
|
and d.WorkPoint='{WorkPoint}' AND d.Quantity>0 ) d
|
|
on c.InvCode=d.INVCode AND c.WhCode=d.WarehouseCode and d.ExtensionID=c.ExtensionID
|
|
LEFT JOIN (SELECT INVCode,WarehouseCode,SUM(Quantity) AS QTYTotal FROM ICSWareHouseLotInfo WHERE WorkPoint='{WorkPoint}' GROUP BY INVCode,WarehouseCode) f ON c.InvCode=f.INVCode AND c.WhCode=f.WarehouseCode
|
|
order by c.Code,c.InvCode,d.MTIME ";
|
|
#endregion
|
|
var dataset = Repository().FindDataSetBySql(sql);
|
|
if (dataset.Tables.Count == 0)
|
|
return null;
|
|
DataTable table = dataset.Tables[0];
|
|
decimal qtyCount = 0;
|
|
bool remove = false;
|
|
List<int> removeList = new List<int>();
|
|
for (int i = 0; i < table.Rows.Count; i++)
|
|
{
|
|
|
|
if (i != 0
|
|
&& (!table.Rows[i]["InvCode"].ToString().Equals(table.Rows[i - 1]["InvCode"].ToString())
|
|
|| !table.Rows[i]["Code"].ToString().Equals(table.Rows[i - 1]["Code"].ToString()))
|
|
)
|
|
{
|
|
qtyCount = 0;
|
|
remove = false;
|
|
}
|
|
if (remove)
|
|
{
|
|
removeList.Add(i);
|
|
}
|
|
else
|
|
{
|
|
var lotQty = table.Rows[i]["QTY"].ToString().ToDecimal();
|
|
var orderQty = table.Rows[i]["iQuantity"].ToString().ToDecimal();
|
|
qtyCount += lotQty;
|
|
if (qtyCount >= orderQty)
|
|
{
|
|
remove = true;
|
|
}
|
|
}
|
|
}
|
|
if (removeList.Count > 0)
|
|
{
|
|
removeList.Reverse();
|
|
foreach (var item in removeList)
|
|
{
|
|
table.Rows.RemoveAt(item);
|
|
}
|
|
}
|
|
|
|
var result = ConvertCellToString(table);
|
|
if (Invmes.Rows.Count > 0)
|
|
{
|
|
result.Merge(Invmes, false);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
public string MergeMaterial(string keyValue, string Type)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
|
|
string dataList = string.Empty;
|
|
List<string> arry = keyValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
if (arry.Count > 0)
|
|
{
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
foreach (var i in arry)
|
|
{
|
|
stringBuilder.Append($@"'{i}',");
|
|
}
|
|
dataList = stringBuilder.ToString(0, stringBuilder.Length - 1);
|
|
}
|
|
|
|
|
|
Int64 Merge_ID = 0;
|
|
DateTime time = DateTime.Now;
|
|
string Tday = time.ToString("yyyyMMdd");
|
|
string sqls = string.Format(@"SELECT MAX(A.MergeID) AS SourceID FROM ICSMOPickMerge A WHERE A.MergeID LIKE '{0}%' AND LEN(a.MergeID) = 13", Tday);
|
|
DataSet ds = SqlHelper.GetDataSetBySql(sqls);
|
|
DataTable dts = ds.Tables[0];
|
|
if (dts != null && dts.Rows.Count > 0)
|
|
{
|
|
string lot = dts.Rows[0]["SourceID"].ToString();
|
|
if (!string.IsNullOrWhiteSpace(lot))
|
|
Merge_ID = Convert.ToInt64(lot.Substring(lot.Length - 5));
|
|
}
|
|
string MergeID = Tday + (Merge_ID + 1).ToString().PadLeft(5, '0');
|
|
|
|
|
|
string order = string.Empty;
|
|
string orderCode = string.Empty;
|
|
string quantity = string.Empty;
|
|
string sqlString1 = string.Empty;
|
|
string sqlString2 = string.Empty;
|
|
|
|
|
|
if (Type == "1")//工单备料
|
|
{
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint)
|
|
select NEWID(),'{0}',b.ID ,'{1}','{2}','{3}',GETDATE(),'{4}'
|
|
from ICSMO a inner join ICSMOPick b on b.MODetailID=a.MODetailID and b.WorkPoint=a.WorkPoint
|
|
where a.MOCode in ({5})
|
|
";
|
|
}
|
|
if (Type == "2")//工单发料
|
|
{
|
|
order = "ICSMOApply";
|
|
orderCode = "b.ApplyCode";
|
|
quantity = "b.IssueQuantity";
|
|
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}',a.ApplyCode
|
|
from ICSMOApply a
|
|
where a.ApplyCode in ({5})";
|
|
}
|
|
if (Type == "3")//材料出库
|
|
{
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}'
|
|
from ICSMOIssue a
|
|
where a.IssueCode in ({5}) ";
|
|
}
|
|
if (Type == "4")//委外备料
|
|
{
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint)
|
|
select NEWID(),'{0}',b.ID ,'{1}','{2}','{3}',GETDATE(),'{4}'
|
|
from ICSOutsourcingOrder a inner join ICSOOPick b on a.OODetailID=b.OODetailID and b.WorkPoint=a.WorkPoint
|
|
where a.OOCode in ({5})";
|
|
}
|
|
if (Type == "5")//委外领料
|
|
{
|
|
order = "ICSOApply";
|
|
orderCode = "b.ApplyCode";
|
|
quantity = "b.IssueQuantity";
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}',a.ApplyCode
|
|
from ICSOApply a
|
|
where a.ApplyCode in ({5})";
|
|
}
|
|
if (Type == "6")//委外材料出库
|
|
{
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}'
|
|
from ICSOIssue a
|
|
where a.IssueCode in ({5})";
|
|
}
|
|
if (Type == "7")//销售发货
|
|
{
|
|
order = "ICSSDN";
|
|
orderCode = "b.SDNCode";
|
|
quantity = "b.SDNQuantity";
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}',a.SDNCode
|
|
from ICSSDN a
|
|
where a.SDNCode in ({5}) AND a.Type='1' ";
|
|
}
|
|
if (Type == "8")//其它出库
|
|
{
|
|
order = "ICSOtherOut";
|
|
orderCode = "b.OutCode";
|
|
quantity = "b.OutQuantity";
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}',a.OutCode
|
|
from ICSOtherOut a
|
|
where a.OutCode in ({5})";
|
|
}
|
|
if (Type == "9")//借用单
|
|
{
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}'
|
|
from ICSBrrow a
|
|
where a.BrrowCode in ({5})";
|
|
}
|
|
if (Type == "10")//物料调拨
|
|
{
|
|
order = "ICSTransfer";
|
|
orderCode = "b.TransferNO";
|
|
quantity = "b.TransferQuantity";
|
|
sql += @"INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}',a.TransferNO
|
|
from ICSTransfer a
|
|
where a.TransferNO in ({5})
|
|
";
|
|
}
|
|
if (Type == "11")//两步调出
|
|
{
|
|
sql += @" INSERT INTO dbo.ICSMOPickMerge
|
|
( ID ,MergeID ,SourceID ,Type,MUSER, MUSERName,MTIME,WorkPoint)
|
|
select NEWID(),'{0}',a.ID ,'{1}','{2}','{3}',GETDATE(),'{4}'
|
|
from ICSOtherOut a
|
|
INNER JOIN ICSTransfer tra ON a.TransferDetailID=tra.TransferDetailID AND a.WorkPoint=tra.WorkPoint
|
|
where a.OutCode in ({5})
|
|
";
|
|
}
|
|
sql = string.Format(sql, MergeID, Type, MUSER, MUSERNAME, WorkPoint, dataList);
|
|
sqlString1 += $@" SELECT a.ID FROM ICSMOPickMerge a WHERE a.SourceID IN (SELECT b.ID FROM {order} b WHERE {orderCode} IN({dataList}) )";
|
|
sqlString2 += $@" SELECT b.ID FROM {order} b WHERE {orderCode} IN({dataList}) AND {quantity}>0";
|
|
DataSet ds1 = SqlHelper.GetDataSetBySql(sqlString1);
|
|
DataSet ds2 = SqlHelper.GetDataSetBySql(sqlString2);
|
|
DataTable dts1 = ds1.Tables[0];
|
|
DataTable dts2 = ds2.Tables[0];
|
|
if ((dts1 != null && dts1.Rows.Count > 0))
|
|
{
|
|
|
|
}
|
|
else if (dts2 != null && dts2.Rows.Count > 0)
|
|
{
|
|
msg = "当前选择单据号存在已出库的单据号,合并拣料失败";
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) == 0)
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
public string CancelMergeMaterial(string keyValue, string Type)
|
|
{
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
keyValue = keyValue.TrimEnd(',');
|
|
List<string> arry = keyValue.Split(',').ToList();
|
|
string dataList = string.Empty;
|
|
if (arry.Count > 0)
|
|
{
|
|
foreach (var i in arry)
|
|
{
|
|
dataList += $@"'{i}',";
|
|
}
|
|
if (dataList.Any())
|
|
{
|
|
dataList = dataList.TrimEnd(',');
|
|
}
|
|
}
|
|
string sqls = $@" SELECT SourceID FROM ICSMOPickMerge WHERE EATTRIBUTE1 IN({dataList}) ";
|
|
DataSet ds = SqlHelper.GetDataSetBySql(sqls);
|
|
|
|
DataTable dts = ds.Tables[0];
|
|
|
|
if (dts == null || dts.Rows.Count <= 0)
|
|
{
|
|
msg = "当前单据未合并拣料,取消合并拣料失败";
|
|
return msg;
|
|
}
|
|
string sqlStrring = string.Empty;
|
|
if (Type == "2")//工单发料
|
|
{
|
|
sqlStrring = $@"select ID from ICSMOApply a where a.ID in ({sqls}) and a.IssueQuantity=0 ";
|
|
}
|
|
|
|
if (Type == "5")//委外领料
|
|
{
|
|
sqlStrring = $@"select ID from ICSOApply a where a.ID in ({sqls}) and a.IssueQuantity=0 ";
|
|
}
|
|
if (Type == "7")//销售发货
|
|
{
|
|
sqlStrring = $@"select ID from ICSSDN a where a.ID in ({sqls}) and a.SDNQuantity=0 AND a.Type='1' ";
|
|
}
|
|
if (Type == "8")//其它出库
|
|
{
|
|
sqlStrring = $@"select ID
|
|
from ICSOtherOut a
|
|
where a.ID in ({sqls}) and a.OutQuantity=0";
|
|
}
|
|
|
|
if (Type == "10")//物料调拨
|
|
{
|
|
sqlStrring = $@"select ID from ICSTransfer a where a.ID in ({sqls}) and a.TransferQuantity=0 ";
|
|
}
|
|
DataSet dsdata = SqlHelper.GetDataSetBySql(sqlStrring);
|
|
|
|
DataTable dtdsdatas = dsdata.Tables[0];
|
|
|
|
if (dtdsdatas == null || dtdsdatas.Rows.Count <= 0)
|
|
{
|
|
msg = "当前物料已经出库,取消合并失败";
|
|
return msg;
|
|
}
|
|
|
|
sql = $@"DELETE FROM ICSMOPickMerge WHERE SourceID IN({sqls})";
|
|
try
|
|
{
|
|
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "取消合并失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
public string CheckQty(string objArr)
|
|
{
|
|
objArr = objArr.TrimEnd(',');
|
|
string sql = @"select * from ICSMOPickMerge a
|
|
left join ICSMOPick b on a.SourceID=b.ID and a.WorkPoint=b.WorkPoint
|
|
left join ICSMO c on b.MODetailID=c.MODetailID and b.WorkPoint=c.WorkPoint
|
|
where MOCode in ({0})";
|
|
sql = string.Format(sql, objArr);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return "1";
|
|
}
|
|
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|