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.
1361 lines
69 KiB
1361 lines
69 KiB
using NFine.Code;
|
|
using NFine.Domain.Entity.SystemManage;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using NFine.Repository;
|
|
using System.Text;
|
|
using System;
|
|
using System.Configuration;
|
|
using NFine.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class WatchPanelApp : RepositoryFactory<ModuleEntity>
|
|
{
|
|
string workpoint = ConfigurationManager.ConnectionStrings["WorkPointCode"].ConnectionString;
|
|
private static string U9IP = ConfigurationManager.ConnectionStrings["U9connstr"].ConnectionString;
|
|
private static string StratTimecfg = ConfigurationManager.ConnectionStrings["StratTime"].ConnectionString;
|
|
private static string EndTimecfg = ConfigurationManager.ConnectionStrings["EndTime"].ConnectionString;
|
|
private static string advDays = ConfigurationManager.ConnectionStrings["advDays"].ConnectionString;
|
|
private static string workPoint = ConfigurationManager.ConnectionStrings["WorkPoint"].ConnectionString;
|
|
|
|
string StratTime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString()).ToString("yyyy-MM-dd") + ' ' + StratTimecfg;
|
|
string EndTime = DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-MM-dd") + ' ' + EndTimecfg;
|
|
|
|
//private string ERPName = U9IP.Substring(U9IP.IndexOf("Server=") + 7, 9) + "." + U9IP.Substring(U9IP.IndexOf("Catalog=") + 8, 7);
|
|
//string dsaq = ConfigurationManager.ConnectionStrings["advDays"].ConnectionString;
|
|
|
|
private static string conbegin = "Data Source=";
|
|
private static int end = U9IP.IndexOf(";Uid=");
|
|
private static string ERPName = "[" + U9IP.Substring(conbegin.Length, end - conbegin.Length).Replace(";Database=", "].");
|
|
private static string ERPName1 = ERPName.Split('.')[ERPName.Split('.').Length - 1];
|
|
|
|
string EndTime2 = "";
|
|
|
|
//到货明细
|
|
public DataTable GetList1(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @"
|
|
select * from (
|
|
SELECT *,
|
|
收货数量 -已检数量 待检数量,
|
|
CASE WHEN 收货数量 -已检数量> 0 THEN '待检验' WHEN 已检待入> 0 THEN '待入库' ELSE '完成' END 状态
|
|
FROM (
|
|
SELECT dd.orderno 订单号,dd.itemcode 料号,dd.planqty 收货数量,inv.invname 物料名称,
|
|
isnull((
|
|
SELECT SUM (lotqty)
|
|
FROM icsitemlot lot
|
|
WHERE lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
|
|
AND isnull(IQCStatus,'') !='' AND cc.workpoint=lot.workpoint),0) 已检数量,
|
|
isnull((
|
|
SELECT SUM (lotqty)
|
|
FROM icsitemlot lot
|
|
WHERE lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
|
|
AND isnull(IQCStatus,'') !='' AND cc.workpoint=lot.workpoint
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM ICSWareHouseLotInfo info
|
|
WHERE info.lotno=lot.lotno AND info.workpoint=lot.workpoint)),0) 已检待入
|
|
FROM ICSINVReceipt cc
|
|
LEFT JOIN ICSINVReceiptDetail dd ON cc.ReceiptNO=dd.ReceiptNO AND dd.workpoint=cc.workpoint
|
|
LEFT JOIN ICSINVENTORY inv ON inv.invcode=dd.itemcode AND dd.workpoint=inv.workpoint
|
|
WHERE cc.mtime >=DATEADD(week, -1,getdate())
|
|
and cc.workpoint='" + workpoint + @"'
|
|
) ff ) gg
|
|
|
|
";
|
|
|
|
DataTable dt = Repository().FindTablePageBySql_Other(SqlText, "WMSconnstr", parameter.ToArray(), ref jqgridparam);
|
|
|
|
|
|
return dt;
|
|
|
|
}
|
|
|
|
//来料不合格明细
|
|
public DataTable GetList2(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @"
|
|
select * from (
|
|
SELECT cc.receiptNo 到货单,dd.orderno 采购订单号,dd.itemcode 料号, inv.invname 物料名称,
|
|
sum(lot.lotqty) 不合格数量 ,kk.CKITEMDESC 不良原因
|
|
|
|
FROM ICSINVReceipt cc
|
|
LEFT JOIN ICSINVReceiptDetail dd ON cc.ReceiptNO=dd.ReceiptNO AND dd.workpoint=cc.workpoint
|
|
LEFT JOIN ICSINVENTORY inv ON inv.invcode=dd.itemcode AND dd.workpoint=inv.workpoint
|
|
left join icsitemlot lot on lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
|
|
AND cc.workpoint=lot.workpoint
|
|
left join (select * from (select ROW_NUMBER()over(partition by LOTNO order by mtime desc,id ) rowId,lotno ,errdata ,CKITEMDESC
|
|
from ICSIQCErrList ck where workpoint='" + workpoint + @"' ) as AuctionRecords
|
|
where rowId=1) kk on kk.lotno=lot.lotno
|
|
WHERE 1=1
|
|
and cc.mtime >=DATEADD(MONTH, -1,getdate())
|
|
and kk.errdata='不合格'
|
|
and cc.workpoint='" + workpoint + @"'
|
|
group by cc.receiptNo ,dd.orderno ,dd.itemcode , inv.invname ,kk.CKITEMDESC ) jj
|
|
";
|
|
|
|
DataTable dt = Repository().FindTablePageBySql_Other(SqlText, "WMSconnstr", parameter.ToArray(), ref jqgridparam);
|
|
|
|
|
|
return dt;
|
|
|
|
}
|
|
|
|
public DataTable GetWIPDATA()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @"
|
|
select distinct mo.mocode 生产订单号,mo.moseq 行号,mo.itemcode 物料编码,inv.invname 物料名称,
|
|
mo.moplanqty 数量,sim.MUSERName 加工人员,sim.opcode 加工工序
|
|
,row_number() over (partition by mo.mocode ,mo.moseq , sim.MUSERName ,sim.opcode order by sim.mtime desc,sim.id desc) rn
|
|
from icsmo mo
|
|
left join ICSITEMLot lot on lot.transno =mo.mocode and lot.TransLine=mo.moseq and lot.workpoint =mo.workpoint
|
|
left join ICSLOTSIMULATION sim on mo.WorkPoint=sim.WorkPoint and sim.lotno=lot.lotno
|
|
left join ICSINVENTORY inv on inv.invcode=mo.itemcode and inv.workpoint=mo.workpoint
|
|
where sim.mtime>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
|
|
and mo.WorkPoint='" + workpoint + @"'
|
|
|
|
";
|
|
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
//测试
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
DataRow newRow;
|
|
newRow = dt.NewRow();
|
|
newRow["生产订单号"] = "MO-0001" + i.ToString();
|
|
newRow["行号"] = "22";
|
|
dt.Rows.Add(newRow);
|
|
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
|
|
//车间人员信息
|
|
public DataTable GetWIPUser()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @"
|
|
select distinct mo.mocode 生产订单号,mo.moseq 行号,mo.itemcode 物料编码,inv.invname 物料名称,
|
|
mo.moplanqty 数量,sim.MUSERName 加工人员,sim.opcode 加工工序
|
|
,row_number() over (partition by mo.mocode ,mo.moseq , sim.MUSERName ,sim.opcode order by sim.mtime desc,sim.id desc) rn
|
|
from icsmo mo
|
|
left join ICSITEMLot lot on lot.transno =mo.mocode and lot.TransLine=mo.moseq and lot.workpoint =mo.workpoint
|
|
left join ICSLOTSIMULATION sim on mo.WorkPoint=sim.WorkPoint and sim.lotno=lot.lotno
|
|
left join ICSINVENTORY inv on inv.invcode=mo.itemcode and inv.workpoint=mo.workpoint
|
|
where sim.mtime>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
|
|
and mo.WorkPoint='" + workpoint + @"'
|
|
|
|
";
|
|
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
//测试
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
DataRow newRow;
|
|
newRow = dt.NewRow();
|
|
newRow["生产订单号"] = "MO-0001" + i.ToString();
|
|
newRow["行号"] = "22";
|
|
dt.Rows.Add(newRow);
|
|
|
|
}
|
|
return dt;
|
|
}
|
|
//收料信息
|
|
public DataTable GetWIPRCV()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @"
|
|
select B.CreatedOn 到货时间,A.DescFlexField_PrivateDescSeg1 送货单号,A.DocNO 收货单号,B.DocLineNo 收货单行号
|
|
,ISNULL(B.QCBillNo,'') AS 质检单号,CASE WHEN A.Status='0' THEN '开立' WHEN A.Status='2' THEN '检验完成' WHEN A.Status='3' THEN '核准中' ELSE '业务关闭' END AS 状态
|
|
,A.Supplier_ShortName 供应商名称,A.DescFlexField_PubDescSeg13 紧急程度,B.ItemInfo_ItemCode 料号
|
|
,B.ItemInfo_ItemName 品名,C.INVSTD 规格型号,C.INVUOM 单位,B.ArriveQtyTU 到货数量,B.QualifiedQtyTU 合格数量
|
|
,case when B.Status='5' then B.QualifiedQtyTU When B.Status='5' AND ISNULL(B.QCBillNo,'')='' then B.QualifiedQtyTU ELSE 0 end as U9已上架数量
|
|
,ISNULL(F.QTY,0) AS WMS已上架数量,B.ArriveQtyTU-ISNULL(F.QTY,0) AS WMS未上架数量,E.Name 库管员
|
|
from
|
|
{0}.DBO.PM_Receivement A
|
|
LEFT JOIN (SELECT a.ID,b.CreatedOn,b.DocLineNo,b.QCBillNo,b.ItemInfo_ItemCode,b.ItemInfo_ItemName,b.ItemInfo_ItemID,b.WhMan
|
|
,sum(b.ArriveQtyTU) ArriveQtyTU,SUM(b.QualifiedQtyTU) QualifiedQtyTU,b.Status
|
|
from {0}.DBO.PM_Receivement a LEFT JOIN {0}.DBO.PM_RcvLine b on b.Receivement=a.ID
|
|
where (SplitFlag=0 OR SplitFlag=2)
|
|
GROUP BY a.ID,b.CreatedOn,b.DocLineNo,b.QCBillNo,b.ItemInfo_ItemCode,b.ItemInfo_ItemName,b.ItemInfo_ItemID,b.WhMan,b.Status ) B
|
|
ON B.ID=A.ID
|
|
LEFT JOIN ICSINVENTORY C on C.ID=B.ItemInfo_ItemID
|
|
LEFT JOIN {0}.DBO.CBO_Operators_trl E on E.ID=B.WhMan
|
|
LEFT JOIN (SELECT ASN.STNO,ASN.ITEMCODE,SUM(ISNULL(WHLOT.LotQty,0)) AS QTY FROM ICSASNDETAIL ASN
|
|
LEFT JOIN ICSITEMLot LOT ON LOT.LotNO=ASN.LOTNO AND LOT.WorkPoint=ASN.WorkPoint
|
|
LEFT JOIN ICSWareHouseLotInfo WHLOT ON WHLOT.LotNO=LOT.LotNO AND WHLOT.WorkPoint=LOT.WorkPoint
|
|
GROUP BY ASN.STNO,ASN.ITEMCODE) F ON F.STNO=A.DescFlexField_PrivateDescSeg1 AND F.ITEMCODE=B.ItemInfo_ItemCode
|
|
where 1=1 and B.CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
|
|
order by B.CreatedOn";
|
|
|
|
SqlText = string.Format(SqlText, ERPName, workpoint);
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
//收料图表
|
|
public DataTable GetWIPRCVChart()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @"
|
|
SELECT top 1 (SELECT COUNT(ID) FROM {0}.DBO.PM_RcvLine
|
|
where (SplitFlag=0 OR SplitFlag=2)
|
|
and CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00' and status<>'5') as U9dk,
|
|
(SELECT COUNT(ID) FROM {0}.DBO.PM_RcvLine
|
|
where (SplitFlag=0 OR SplitFlag=2)
|
|
and CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00' and status='5') as U9gb
|
|
from {0}.DBO.PM_RcvLine";
|
|
|
|
SqlText = string.Format(SqlText, ERPName, workpoint);
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
|
|
//发料信息
|
|
public DataTable GetMaterialPick()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = $@" SELECT
|
|
a.ApplyCode,
|
|
A.Sequence,
|
|
--a.SAPSequence,
|
|
a.InvCode,
|
|
c.LotNo,
|
|
c.Quantity,
|
|
e.StartLocation,
|
|
e.EndLocation
|
|
-- e.TaskCode
|
|
FROM
|
|
ICSMOApply a
|
|
-- INNER JOIN ICSContainerReceiptsNumber b ON a.ApplyCode= b.TransCode
|
|
INNER JOIN ICSWareHouseLotInfoLog c ON a.ApplyCode= c.TransCode
|
|
AND
|
|
c.TransType= '15'
|
|
AND a.Sequence= c.TransSequence
|
|
INNER JOIN ( SELECT DISTINCT e.StartLocation,e.EndLocation FROM
|
|
ICSForkLiftTaskLog e WHERE e.EndLocation is not null AND e.EndLocation!=''AND (e.EATTRIBUTE1 IS NULL OR e.EATTRIBUTE1!='己回库') ) e ON c.FromLocationCode= e.StartLocation
|
|
|
|
WHERE
|
|
a.WorkPoint in({workPoint})";
|
|
|
|
//if (!string.IsNullOrWhiteSpace(StratTime))
|
|
//{
|
|
// SqlText += " and a.CreatedOn>'" + StratTime + "'";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(EndTime))
|
|
//{
|
|
// SqlText += " and a.CreatedOn<'" + EndTime + "'";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(advDays))
|
|
//{
|
|
// SqlText += @" and a.MTIME>CAST(CAST(DATEADD(day, -" + advDays + @", GETDATE()) as date) as varchar(10)) + ' 00:00:00'
|
|
// and a.MTIME<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
|
|
//}
|
|
//if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
|
|
//{
|
|
// SqlText += @" and a.MTIME>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
|
|
// and a.MTIME<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
|
|
//}
|
|
SqlText += @"order by a.MTIME ";
|
|
|
|
//SqlText = string.Format(SqlText, ERPName, workpoint);
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
//发料图表
|
|
public DataTable GetMaterialPickChart()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @" SELECT top 1
|
|
(SELECT COUNT(*) from {0}.DBO.MO_MO a
|
|
where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00')-
|
|
(SELECT COUNT(*) from {0}.DBO.MO_MO a
|
|
LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) 子件项数,MOCode from ICSMaterialPick GROUP BY MOCode) b on a.DocNo=b.MOCode
|
|
LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) 完成项数,MOCode from ICSMaterialPick where Quantity<=HasQuantity GROUP BY MOCode) c on a.DocNo=c.MOCode
|
|
where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00' and b.子件项数=c.完成项数)
|
|
as 未完成工单,
|
|
|
|
(SELECT COUNT(*) from {0}.DBO.MO_MO a
|
|
LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) 子件项数,MOCode from ICSMaterialPick GROUP BY MOCode) b on a.DocNo=b.MOCode
|
|
LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) 完成项数,MOCode from ICSMaterialPick where Quantity<=HasQuantity GROUP BY MOCode) c on a.DocNo=c.MOCode
|
|
where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00' and b.子件项数=c.完成项数) as 领料完成工单
|
|
from {0}.DBO.MO_MO";
|
|
|
|
SqlText = string.Format(SqlText, ERPName, workpoint, advDays);
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
|
|
//查询月度每日下单行数与每日完成出库行数
|
|
public DataTable GetGridJson_MonthDaliyComplete()
|
|
{
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1'))
|
|
drop table #temp1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1OO'))
|
|
drop table #temp1OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2'))
|
|
drop table #temp2
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2OO'))
|
|
drop table #temp2OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111'))
|
|
drop table #temp111
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111OO'))
|
|
drop table #temp111OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222'))
|
|
drop table #temp222
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222OO'))
|
|
drop table #temp222OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3'))
|
|
drop table #TempPX3
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3OO'))
|
|
drop table #TempPX3OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLL'))
|
|
drop table #tempSCLL
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLLOO'))
|
|
drop table #tempSCLLOO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempAll'))
|
|
drop table #tempAll
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempRK'))
|
|
drop table #tempRK
|
|
|
|
select ApplyCode,count(*) Count,WorkPoint into #temp1 from ICSMOApply WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by ApplyCode,WorkPoint
|
|
|
|
select ApplyCode,sum(Quantity) Qty,WorkPoint into #temp2 from ICSMOApply WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by ApplyCode,WorkPoint
|
|
|
|
|
|
select a.ApplyCode,a.WorkPoint,a.Count,b.Qty into #temp111 from #temp1 a
|
|
left join #temp2 b on a.ApplyCode = b.ApplyCode
|
|
and a.WorkPoint = b.WorkPoint
|
|
|
|
|
|
select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222 from ICSWareHouseLotInfoLog WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and BusinessCode =14
|
|
|
|
|
|
|
|
select aa.ApplyCode '单号',aa.WorkPoint '站点',aa.Count '行数',aa.Qty '总数量',bb.MTIME '时间',bb.Quantity '数量', bb.id,
|
|
row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
|
|
into #TempPX3
|
|
from #temp111 aa
|
|
inner join #temp222 bb on aa.ApplyCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
|
|
|
|
|
|
|
|
---详情
|
|
-- select *,case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end 入行数
|
|
-- from(
|
|
-- select TT.*,
|
|
-- ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
-- , ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 AND TT2.站点=TT.站点),0) 之前已入数量
|
|
--
|
|
-- from #TempPX3 TT
|
|
-- ) gg
|
|
|
|
|
|
---汇总
|
|
select CONVERT(varchar(10), 时间, 21) 日期, sum(case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end) 入行数和 into #tempSCLL
|
|
from(
|
|
select TT.*,
|
|
ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
, ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 之前已入数量
|
|
|
|
from #TempPX3 TT
|
|
) gg
|
|
group by CONVERT(varchar(10), 时间, 21)
|
|
|
|
|
|
|
|
select ApplyCode,count(*) Count,WorkPoint into #temp1OO from ICSOApply WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by ApplyCode,WorkPoint
|
|
|
|
select ApplyCode,sum(Quantity) Qty,WorkPoint into #temp2OO from ICSOApply WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by ApplyCode,WorkPoint
|
|
|
|
|
|
select a.ApplyCode,a.WorkPoint,a.Count,b.Qty into #temp111OO from #temp1OO a
|
|
left join #temp2OO b on a.ApplyCode = b.ApplyCode
|
|
and a.WorkPoint = b.WorkPoint
|
|
|
|
|
|
select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222OO from ICSWareHouseLotInfoLog WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and BusinessCode =6
|
|
|
|
|
|
|
|
select aa.ApplyCode '单号',aa.WorkPoint '站点',aa.Count '行数',aa.Qty '总数量',bb.MTIME '时间',bb.Quantity '数量', bb.id,
|
|
row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
|
|
into #TempPX3OO
|
|
from #temp111OO aa
|
|
inner join #temp222OO bb on aa.ApplyCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
|
|
|
|
|
|
|
|
--详情
|
|
-- select *,case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end 入行数
|
|
-- from(
|
|
-- select TT.*,
|
|
-- ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
-- , ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 AND TT2.站点=TT.站点),0) 之前已入数量
|
|
--
|
|
-- from #TempPX3 TT
|
|
-- ) gg
|
|
|
|
|
|
---汇总
|
|
select CONVERT(varchar(10), 时间, 21) 日期, sum(case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end) 入行数和 into #tempSCLLOO
|
|
from(
|
|
select TT.*,
|
|
ISNULL( (select sum(数量) from #TempPX3OO TT2
|
|
WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
, ISNULL( (select sum(数量) from #TempPX3OO TT2
|
|
WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 之前已入数量
|
|
|
|
from #TempPX3OO TT
|
|
) gg
|
|
group by CONVERT(varchar(10), 时间, 21)
|
|
|
|
|
|
select a.日期,a.入行数和 + isnull(b.入行数和,0) 入行数和 into #tempRK from #tempSCLL a
|
|
left join #tempSCLLOO b on a.日期 = b.日期
|
|
|
|
select a.MTIME,sum(FLQty) FLQty into #tempAll from(
|
|
SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) FLQty from ICSMOApply WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by CONVERT(VARCHAR(10), CreateDateTime, 23)
|
|
union
|
|
SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) FLQty from ICSOApply WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by CONVERT(VARCHAR(10), CreateDateTime, 23)) a GROUP BY a.MTIME
|
|
|
|
select a.MTIME,a.FLQty,b.入行数和 RkQty from #tempAll a
|
|
left join #tempRK b on a.MTIME = b.日期 order by a.MTIME";
|
|
DataTable dt = Repository().GetDataTableBySql_Other(sql, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
|
|
|
|
|
|
//查询月度每日合格数数与每日完成入库数
|
|
public DataTable GetGridJson_MonthDaliyRcv()
|
|
{
|
|
string SqlText = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1'))
|
|
drop table #temp1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1OO'))
|
|
drop table #temp1OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2'))
|
|
drop table #temp2
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2OO'))
|
|
drop table #temp2OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111'))
|
|
drop table #temp111
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111OO'))
|
|
drop table #temp111OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222'))
|
|
drop table #temp222
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222OO'))
|
|
drop table #temp222OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3'))
|
|
drop table #TempPX3
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3OO'))
|
|
drop table #TempPX3OO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLL'))
|
|
drop table #tempSCLL
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLLOO'))
|
|
drop table #tempSCLLOO
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempAll'))
|
|
drop table #tempAll
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempRK'))
|
|
drop table #tempRK
|
|
|
|
select DNCode,count(*) Count,WorkPoint into #temp1 from ICSDeliveryNotice WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by DNCode,WorkPoint
|
|
|
|
select DNCode,sum(Quantity) Qty,WorkPoint into #temp2 from ICSDeliveryNotice WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by DNCode,WorkPoint
|
|
|
|
|
|
select a.DNCode,a.WorkPoint,a.Count,b.Qty into #temp111 from #temp1 a
|
|
left join #temp2 b on a.DNCode = b.DNCode
|
|
and a.WorkPoint = b.WorkPoint
|
|
|
|
|
|
select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222 from ICSWareHouseLotInfoLog WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and BusinessCode =2
|
|
|
|
|
|
|
|
select aa.DNCode '单号',aa.WorkPoint '站点',aa.Count '行数',aa.Qty '总数量',bb.MTIME '时间',bb.Quantity '数量', bb.id,
|
|
row_number() over (partition by aa.DNCode order by bb.MTIME ,bb.id) rn
|
|
into #TempPX3
|
|
from #temp111 aa
|
|
inner join #temp222 bb on aa.DNCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
|
|
|
|
|
|
|
|
---详情
|
|
-- select *,case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end 入行数
|
|
-- from(
|
|
-- select TT.*,
|
|
-- ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
-- , ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 AND TT2.站点=TT.站点),0) 之前已入数量
|
|
--
|
|
-- from #TempPX3 TT
|
|
-- ) gg
|
|
|
|
|
|
---汇总
|
|
select CONVERT(varchar(10), 时间, 21) 日期, sum(case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end) 入行数和 into #tempSCLL
|
|
from(
|
|
select TT.*,
|
|
ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
, ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 之前已入数量
|
|
|
|
from #TempPX3 TT
|
|
) gg
|
|
group by CONVERT(varchar(10), 时间, 21)
|
|
|
|
|
|
|
|
select RCVCode,count(*) Count,WorkPoint into #temp1OO from ICSManufactureReceive WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and STATUS =1
|
|
group by RCVCode,WorkPoint
|
|
|
|
select RCVCode,sum(Quantity) Qty,WorkPoint into #temp2OO from ICSManufactureReceive WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and STATUS =1
|
|
group by RCVCode,WorkPoint
|
|
|
|
|
|
select a.RCVCode,a.WorkPoint,a.Count,b.Qty into #temp111OO from #temp1OO a
|
|
left join #temp2OO b on a.RCVCode = b.RCVCode
|
|
and a.WorkPoint = b.WorkPoint
|
|
|
|
|
|
select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222OO from ICSWareHouseLotInfoLog WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and BusinessCode =18
|
|
|
|
|
|
|
|
select aa.RCVCode '单号',aa.WorkPoint '站点',aa.Count '行数',aa.Qty '总数量',bb.MTIME '时间',bb.Quantity '数量', bb.id,
|
|
row_number() over (partition by aa.RCVCode order by bb.MTIME ,bb.id) rn
|
|
into #TempPX3OO
|
|
from #temp111OO aa
|
|
inner join #temp222OO bb on aa.RCVCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
|
|
|
|
|
|
|
|
--详情
|
|
-- select *,case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end 入行数
|
|
-- from(
|
|
-- select TT.*,
|
|
-- ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
-- , ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
-- WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 AND TT2.站点=TT.站点),0) 之前已入数量
|
|
--
|
|
-- from #TempPX3 TT
|
|
-- ) gg
|
|
|
|
|
|
---汇总
|
|
select CONVERT(varchar(10), 时间, 21) 日期, sum(case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end) 入行数和 into #tempSCLLOO
|
|
from(
|
|
select TT.*,
|
|
ISNULL( (select sum(数量) from #TempPX3OO TT2
|
|
WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
, ISNULL( (select sum(数量) from #TempPX3OO TT2
|
|
WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 之前已入数量
|
|
|
|
from #TempPX3OO TT
|
|
) gg
|
|
group by CONVERT(varchar(10), 时间, 21)
|
|
|
|
|
|
select a.日期,a.入行数和 + isnull(b.入行数和,0) 入行数和 into #tempRK from #tempSCLL a
|
|
left join #tempSCLLOO b on a.日期 = b.日期
|
|
|
|
select xx.Mtime,sum(LLQty) FLQty into #tempAll from(
|
|
SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) LLQty from ICSDeliveryNotice WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by CONVERT(VARCHAR(10), CreateDateTime, 23)
|
|
union all
|
|
SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) LLQty from ICSManufactureReceive WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and status =1
|
|
group by CONVERT(VARCHAR(10), CreateDateTime, 23)) xx group by xx.Mtime
|
|
|
|
select a.MTIME,a.FLQty,b.入行数和 RkQty from #tempAll a
|
|
left join #tempRK b on a.MTIME = b.日期 order by a.MTIME";
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
|
|
|
|
//查询配、发料及时率
|
|
public DataTable GetGridJson_MonthLLPer()
|
|
{
|
|
string SqlText = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1'))
|
|
drop table #temp1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2'))
|
|
drop table #temp2
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3'))
|
|
drop table #TempPX3
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLL'))
|
|
drop table #tempSCLL
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempALL'))
|
|
drop table #tempALL
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempX'))
|
|
drop table #tempX
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111'))
|
|
drop table #temp111
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempWc'))
|
|
drop table #tempWc
|
|
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1JS'))
|
|
drop table #temp1JS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2JS'))
|
|
drop table #temp2JS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3JS'))
|
|
drop table #TempPX3JS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLLJS'))
|
|
drop table #tempSCLLJS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempALLJS'))
|
|
drop table #tempALLJS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempXJS'))
|
|
drop table #tempXJS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111JS'))
|
|
drop table #temp111JS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempALLDataJS'))
|
|
drop table #tempALLDataJS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempLastJS'))
|
|
drop table #tempLastJS
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempJs'))
|
|
drop table #tempJs
|
|
|
|
select ApplyCode,count(*) Count,WorkPoint into #temp1 from ICSMOApply WITH (NOLOCK)
|
|
where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and EATTRIBUTE ='01'
|
|
group by ApplyCode,WorkPoint
|
|
|
|
select ApplyCode,sum(Quantity) Qty,WorkPoint into #tempX from ICSMOApply WITH (NOLOCK)
|
|
where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and EATTRIBUTE ='01'
|
|
group by ApplyCode,WorkPoint
|
|
|
|
select a.ApplyCode,a.WorkPoint,a.Count,b.Qty into #temp111 from #temp1 a
|
|
left join #tempX b on a.ApplyCode = b.ApplyCode
|
|
and a.WorkPoint = b.WorkPoint
|
|
|
|
|
|
select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp2 from ICSWareHouseLotInfoLog WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -30, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and BusinessCode =14
|
|
|
|
|
|
select aa.ApplyCode '单号',aa.WorkPoint '站点',aa.Count '行数',aa.Qty '总数量',bb.MTIME '时间',bb.Quantity '数量', bb.id,
|
|
row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
|
|
into #TempPX3
|
|
from #temp111 aa
|
|
inner join #temp2 bb on aa.ApplyCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
|
|
|
|
|
|
---汇总
|
|
select 时间,sum(case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end) 行数和 into #tempSCLL
|
|
from(
|
|
select TT.*,
|
|
ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 累计入数量
|
|
, ISNULL( (select sum(数量) from #TempPX3 TT2
|
|
WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号 and TT2.站点=TT.站点),0) 之前已入数量
|
|
|
|
from #TempPX3 TT
|
|
) gg
|
|
group by 时间
|
|
|
|
SELECT NeedDate,count(*) Qty into #tempALL from ICSMOApply WITH (NOLOCK)
|
|
where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and EATTRIBUTE ='01'
|
|
group by NeedDate
|
|
|
|
|
|
|
|
select a.NeedDate,ISNULL(Convert(decimal(18,2),Round(Convert(decimal(18,6),isnull(b.行数和,0))/Convert(decimal(18,6),isnull(a.Qty,0)),2)*100),100) Per into #tempWc from #tempALL a
|
|
left join #tempSCLL b on a.NeedDate = b.时间 order by a.NeedDate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select ApplyCode,count(*) Count into #temp1JS from ICSMOApply WITH (NOLOCK)
|
|
where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and EATTRIBUTE ='01'
|
|
group by ApplyCode
|
|
|
|
select ApplyCode,sum(Quantity) Qty into #tempXJS from ICSMOApply WITH (NOLOCK)
|
|
where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
|
|
and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and EATTRIBUTE ='01'
|
|
group by ApplyCode
|
|
|
|
select a.ApplyCode,a.Count,b.Qty into #temp111JS from #temp1JS a
|
|
left join #tempXJS b on a.ApplyCode = b.ApplyCode
|
|
|
|
|
|
select TransCode, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp2JS from ICSWareHouseLotInfoLog WITH (NOLOCK)
|
|
where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -30, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and BusinessCode =14
|
|
|
|
|
|
select aa.ApplyCode '单号',aa.Count '行数',aa.Qty '总数量',bb.MTIME '时间',bb.Quantity '数量', bb.id,
|
|
row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
|
|
into #TempPX3JS
|
|
from #temp111JS aa
|
|
inner join #temp2JS bb on aa.ApplyCode=bb.TransCode
|
|
|
|
|
|
---汇总
|
|
select 时间,单号, sum(case when 总数量>之前已入数量 and 总数量<=累计入数量 then 行数 else 0 end) 行数和 into #tempSCLLJS
|
|
from(
|
|
select TT.*,
|
|
ISNULL( (select sum(数量) from #TempPX3JS TT2
|
|
WHERE TT2.RN<=TT.RN AND TT2.单号=TT.单号),0) 累计入数量
|
|
, ISNULL( (select sum(数量) from #TempPX3JS TT2
|
|
WHERE TT2.RN<TT.RN AND TT2.单号=TT.单号),0) 之前已入数量
|
|
|
|
from #TempPX3JS TT
|
|
) gg
|
|
group by 时间,单号
|
|
|
|
|
|
--SELECT sum(行数和) FROM #tempSCLL where 时间 ='2024-01-15' GROUP BY 时间
|
|
|
|
|
|
select distinct b.NeedDate ,a.单号,case when a.时间 <= b.NeedDate then 行数和 else 0 end 行数和 into #tempALLDataJS
|
|
from #tempSCLLJS a
|
|
left join ICSMOApply b on a.单号 = b.ApplyCode
|
|
--GROUP BY b.NeedDate,a.单号
|
|
|
|
select sum(行数和) 行数和,NeedDate into #tempLastJS from #tempALLDataJS GROUP BY NeedDate
|
|
|
|
SELECT NeedDate ,count(*) Qty into #tempALLJS
|
|
from ICSMOApply WITH (NOLOCK)
|
|
where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
and EATTRIBUTE ='01'
|
|
group by NeedDate
|
|
|
|
|
|
|
|
select a.NeedDate,ISNULL(Convert(decimal(18,2),Round(Convert(decimal(18,6),isnull(b.行数和,0))/Convert(decimal(18,6),isnull(a.Qty,0)),2)*100),100) Per into #tempJs from #tempALLJS a
|
|
left join #tempLastJS b on a.NeedDate = b.NeedDate order by a.NeedDate
|
|
|
|
|
|
select a.NeedDate,a.Per 'WcPer',b.Per 'JsPer' from #tempWc a left join #tempJs b on a.NeedDate = b.NeedDate
|
|
|
|
|
|
";
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
return dt;
|
|
}
|
|
|
|
|
|
|
|
//查询一期库存状态
|
|
public DataTable GetGridJson_WareStatusOne()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
|
|
string SqlText = @"select a.LocationCode,isnull(b.Qty,0) Qty from ICSLocation a left join (
|
|
select LocationCode,isnull(max(Quantity),0) Qty
|
|
from ICSWareHouseLotInfo GROUP BY LocationCode) b on a.LocationCode = b.LocationCode
|
|
where SUBSTRING(SUBSTRING(a.LocationCode,CHARINDEX('-',a.LocationCode)+1,len(a.LocationCode)),1,1) = '0'";
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
return dt;
|
|
}
|
|
|
|
|
|
//查询二期库存状态
|
|
public DataTable GetGridJson_WareStatusTwo()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
|
|
string SqlText = @"select a.LocationCode,isnull(b.Qty,0) Qty from ICSLocation a left join (
|
|
select LocationCode,isnull(max(Quantity),0) Qty
|
|
from ICSWareHouseLotInfo GROUP BY LocationCode) b on a.LocationCode = b.LocationCode
|
|
where SUBSTRING(SUBSTRING(a.LocationCode,CHARINDEX('-',a.LocationCode)+1,len(a.LocationCode)),1,1) = '2'";
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
return dt;
|
|
}
|
|
|
|
|
|
//查询三期库存状态
|
|
public DataTable GetGridJson_WareStatusThree()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
|
|
string SqlText = @"select a.LocationCode,isnull(b.Qty,0) Qty from ICSLocation a left join (
|
|
select LocationCode,isnull(max(Quantity),0) Qty
|
|
from ICSWareHouseLotInfo GROUP BY LocationCode) b on a.LocationCode = b.LocationCode
|
|
where SUBSTRING(SUBSTRING(a.LocationCode,CHARINDEX('-',a.LocationCode)+1,len(a.LocationCode)),1,1) = '3'";
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
return dt;
|
|
}
|
|
|
|
|
|
//查询物料配料进度
|
|
public DataTable GetGridJson_ApplyStatus()
|
|
{
|
|
#region 注释
|
|
// //范围内的所有生产领料单号
|
|
// string SqlText = @"select distinct a.DispatcherName,a.ReceiverName,a.ApplyCode,a.Urgency,
|
|
//a.MTIME,isnull(b.MUSER,'') MUSER,isnull(c.F_RealName,'') MUSERName,a.NeedDate+' '+a.NeedTime NeedTime,a.WorkPoint
|
|
//from ICSMOApply a
|
|
//left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
|
|
//left join Sys_SRM_User c on b.MUSER = c.F_Account
|
|
//where a.EATTRIBUTE ='01'
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23) ";
|
|
// DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
// //是否配料
|
|
// SqlText = @"select distinct a.ApplyCode,a.WorkPoint from ICSMOApply a
|
|
// left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
|
|
// where b.TransType ='15' and a.EATTRIBUTE ='01'
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23) ";
|
|
// DataTable dtPL = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
// //是否配料完成
|
|
// SqlText = @"select distinct a.ApplyCode,a.WorkPoint from (
|
|
//select sum(Quantity) Quantity,sum(IssueQuantity) IssueQuantity,ApplyCode,WorkPoint
|
|
//from ICSMOApply
|
|
//where EATTRIBUTE ='01'
|
|
//and CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
//and CONVERT(VARCHAR(10), MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
//group by ApplyCode,WorkPoint) a where a.Quantity = a.IssueQuantity";
|
|
// DataTable dtPLCom = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
|
|
// //运输中
|
|
// SqlText = @"select distinct a.ApplyCode,a.WorkPoint FROM ICSMOApply a
|
|
//left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
|
|
//left join ICSContainerLot c on b.LotNo = c.lotNo and b.WorkPoint = c.WorkPoint
|
|
//left join ICSContainer d on c.ContainerID = d.ID
|
|
//left join ICSAGVTaskLog e on d.ContainerCode = e.ContainerCode and d.WorkPoint = e.WorkPoint
|
|
//where (e.EATTRIBUTE2 = '未完成')
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)";
|
|
// DataTable dtYsing = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
// //运输完成
|
|
// SqlText = @"select distinct a.ApplyCode,a.WorkPoint FROM ICSMOApply a
|
|
//left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
|
|
//left join ICSContainerLot c on b.LotNo = c.lotNo and b.WorkPoint = c.WorkPoint
|
|
//left join ICSContainer d on c.ContainerID = d.ID
|
|
//left join ICSAGVTaskLog e on d.ContainerCode = e.ContainerCode and d.WorkPoint = e.WorkPoint
|
|
//where e.EATTRIBUTE2 = '已完成'
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
//and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)";
|
|
// DataTable dtYsed = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
// //收料完成
|
|
// // SqlText = @"select distinct ApplyCode,WorkPoint from ICSMOApply where isnull(MUSERName,'') <> 'JOB'
|
|
// //and CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
// //and CONVERT(VARCHAR(10), MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)";
|
|
// // DataTable dtSlCom = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
|
|
// dt.Columns.Add("Status", typeof(string));
|
|
#endregion
|
|
|
|
string sql = @"if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempPL'))
|
|
drop table #tempPL
|
|
|
|
--配料完成
|
|
select distinct a.ApplyCode,a.WorkPoint into #tempPL from (
|
|
select sum(Quantity) Quantity,sum(IssueQuantity) IssueQuantity,ApplyCode,WorkPoint
|
|
from ICSMOApply
|
|
where EATTRIBUTE ='01'
|
|
and CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by ApplyCode,WorkPoint) a where a.Quantity = a.IssueQuantity
|
|
|
|
|
|
select distinct a.DispatcherName,a.ReceiverName,a.ApplyCode,a.Urgency,
|
|
max(a.MTIME) MTIME,isnull(b.MUSER,'') MUSER,isnull(c.F_RealName,'') MUSERName,a.NeedDate+' '+a.NeedTime NeedTime,h.LocationCode,
|
|
case when b.TransType ='15' then '拣料' else
|
|
(case when d.ApplyCode is not null then '拣料完成' else
|
|
(case when g.EATTRIBUTE2 ='未完成' then '运输' else
|
|
(case when g.EATTRIBUTE2 ='已完成' then '运输完成' else '下单' end) end) end) end as 'Status'
|
|
from ICSMOApply a
|
|
left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
|
|
left join Sys_SRM_User c on b.MUSER = c.F_Account
|
|
left join #tempPL d on a.ApplyCode = d.ApplyCode and a.WorkPoint = d.WorkPoint
|
|
left join ICSContainerLot e on b.LotNo = e.lotNo and b.WorkPoint = e.WorkPoint
|
|
left join ICSContainer f on e.ContainerID = f.ID
|
|
left join ICSAGVTaskLog g on f.ContainerCode = g.ContainerCode and f.WorkPoint = g.WorkPoint
|
|
left join ICSInventoryDetail h on a.InvCode = h.InvCode and a.WHCode = h.WHCode
|
|
where a.EATTRIBUTE ='01' and isnull(a.MUSERName,'') = 'JOB'
|
|
and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
|
|
and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)
|
|
group by a.DispatcherName,a.ReceiverName,a.ApplyCode,a.Urgency,b.MUSER,
|
|
c.F_RealName,a.NeedDate,a.NeedTime,b.TransType,d.ApplyCode,g.EATTRIBUTE2,h.LocationCode";
|
|
DataTable dt = Repository().GetDataTableBySql_Other(sql, "WMSconnstr", null);
|
|
List<DataRow> DrList = dt.Select("1=1").OrderByDescending(x => x["Urgency"].ToString()).ThenBy(x => x["NeedTime"]).ToList();
|
|
DataTable dtNew = new DataTable();
|
|
if (DrList.Count > 0)
|
|
{
|
|
dtNew = DrList[0].Table.Clone();
|
|
foreach (DataRow item in DrList)
|
|
{
|
|
dtNew.ImportRow(item);
|
|
}
|
|
}
|
|
|
|
return dtNew;
|
|
}
|
|
|
|
|
|
//查询物料账龄分布
|
|
public DataTable GetGridJson_ItemAge()
|
|
{
|
|
DataTable dt = new DataTable();
|
|
GetItemAge.ZWMS_SK_KB_WXQKCZLClient client = new GetItemAge.ZWMS_SK_KB_WXQKCZLClient();
|
|
List<GetItemAge.ZgcnyStrc> list = new List<GetItemAge.ZgcnyStrc>();
|
|
List<GetItemAge.ZwxqkczlStrc> listX = new List<GetItemAge.ZwxqkczlStrc>();
|
|
client.ClientCredentials.UserName.UserName = "NWBG";
|
|
client.ClientCredentials.UserName.Password = "nwbg321";
|
|
|
|
|
|
|
|
list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') });
|
|
list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-1).Year.ToString() + DateTime.Now.AddMonths(-1).Month.ToString().PadLeft(2, '0') });
|
|
list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-2).Year.ToString() + DateTime.Now.AddMonths(-2).Month.ToString().PadLeft(2, '0') });
|
|
list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-3).Year.ToString() + DateTime.Now.AddMonths(-3).Month.ToString().PadLeft(2, '0') });
|
|
list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-4).Year.ToString() + DateTime.Now.AddMonths(-4).Month.ToString().PadLeft(2, '0') });
|
|
list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-5).Year.ToString() + DateTime.Now.AddMonths(-5).Month.ToString().PadLeft(2, '0') });
|
|
|
|
|
|
dt.Columns.Add("YearRound", typeof(string));
|
|
dt.Columns.Add("Qty1", typeof(decimal));
|
|
dt.Columns.Add("Qty2", typeof(decimal));
|
|
dt.Columns.Add("Qty3", typeof(decimal));
|
|
dt.Columns.Add("Qty4", typeof(decimal));
|
|
dt.Columns.Add("Qty5", typeof(decimal));
|
|
dt.Columns.Add("Qty6", typeof(decimal));
|
|
|
|
GetItemAge.ZwmsSkKbWxqkczlResponse res = client.ZwmsSkKbWxqkczl(new GetItemAge.ZwmsSkKbWxqkczl
|
|
{
|
|
Zflag = "Y",
|
|
ItGcny = list.ToArray(),
|
|
ItWxqkczl = listX.ToArray()
|
|
});
|
|
|
|
List<GetItemAge.ZwxqkczlStrc> list1 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-5).Year.ToString() + DateTime.Now.AddMonths(-5).Month.ToString().PadLeft(2, '0')).ToList();
|
|
List<GetItemAge.ZwxqkczlStrc> list2 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-4).Year.ToString() + DateTime.Now.AddMonths(-4).Month.ToString().PadLeft(2, '0')).ToList();
|
|
List<GetItemAge.ZwxqkczlStrc> list3 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-3).Year.ToString() + DateTime.Now.AddMonths(-3).Month.ToString().PadLeft(2, '0')).ToList();
|
|
List<GetItemAge.ZwxqkczlStrc> list4 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-2).Year.ToString() + DateTime.Now.AddMonths(-2).Month.ToString().PadLeft(2, '0')).ToList();
|
|
List<GetItemAge.ZwxqkczlStrc> list5 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-1).Year.ToString() + DateTime.Now.AddMonths(-1).Month.ToString().PadLeft(2, '0')).ToList();
|
|
List<GetItemAge.ZwxqkczlStrc> list6 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0')).ToList();
|
|
|
|
|
|
dt.Rows.Add("1年以下", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("1-2年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("2-3年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("3-4年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("4-5年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("5-6年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("6-7年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("7-8年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("8-9年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("9-10年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock);
|
|
|
|
dt.Rows.Add("10年以上", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
|
|
list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
|
|
list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
|
|
list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
|
|
list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
|
|
list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock);
|
|
|
|
return dt;
|
|
}
|
|
|
|
|
|
//查询193/199/zmm188处理进度
|
|
public List<DataTable> GetGridJson_StoreStatus()
|
|
{
|
|
List<DataTable> dtList = new List<DataTable>();
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("Month", typeof(string));
|
|
dt.Columns.Add("QtyHangCount", typeof(decimal));
|
|
dt.Columns.Add("QtyCount", typeof(decimal));
|
|
|
|
DataTable dt1 = new DataTable();
|
|
dt1.Columns.Add("Month", typeof(string));
|
|
dt1.Columns.Add("QtyHangCount", typeof(decimal));
|
|
dt1.Columns.Add("QtyCount", typeof(decimal));
|
|
|
|
DataTable dt2 = new DataTable();
|
|
dt2.Columns.Add("Month", typeof(string));
|
|
dt2.Columns.Add("QtyHangCount", typeof(decimal));
|
|
dt2.Columns.Add("QtyCount", typeof(decimal));
|
|
GetStoreStatus.ZWMS_WS_HGPJDClient client = new GetStoreStatus.ZWMS_WS_HGPJDClient();
|
|
client.ClientCredentials.UserName.UserName = "NWBG";
|
|
client.ClientCredentials.UserName.Password = "nwbg321";
|
|
|
|
List<GetStoreStatus.ZhgpJd> list = new List<GetStoreStatus.ZhgpJd>();
|
|
GetStoreStatus.ZwmsWsHgpjdResponse res = client.ZwmsWsHgpjd(new GetStoreStatus.ZwmsWsHgpjd
|
|
{
|
|
THgjd = list.ToArray()
|
|
});
|
|
|
|
|
|
#region 193库位
|
|
List<GetStoreStatus.ZhgpJd> list193 = res.THgjd.ToList().Where(x => x.Lgort == "193").ToList();//193库位
|
|
|
|
foreach (GetStoreStatus.ZhgpJd item in list193)
|
|
{
|
|
dt.Rows.Add(item.Spmon, item.Zbhgh, item.Zbhgs);
|
|
}
|
|
dtList.Add(dt);
|
|
#endregion
|
|
|
|
#region 199库位
|
|
List<GetStoreStatus.ZhgpJd> list199 = res.THgjd.ToList().Where(x => x.Lgort == "199").ToList();//199库位
|
|
foreach (GetStoreStatus.ZhgpJd item in list199)
|
|
{
|
|
dt1.Rows.Add(item.Spmon, item.Zbhgh, item.Zbhgs);
|
|
}
|
|
dtList.Add(dt1);
|
|
#endregion
|
|
|
|
#region 188库位
|
|
List<GetStoreStatus.ZhgpJd> list188 = res.THgjd.ToList().Where(x => x.Tcode == "ZMM188").ToList();//188库位
|
|
foreach (GetStoreStatus.ZhgpJd item in list188)
|
|
{
|
|
dt2.Rows.Add(item.Spmon, item.Zbhgh, item.Zbhgs);
|
|
}
|
|
dtList.Add(dt2);
|
|
#endregion
|
|
return dtList;
|
|
}
|
|
|
|
//查询库存物料周转天数
|
|
public DataTable GetGridJson_ItemZzDays()
|
|
{
|
|
DataTable dt = new DataTable();
|
|
GetItemZzDays.ZWMS_SK_KCWLZZTSClient client = new GetItemZzDays.ZWMS_SK_KCWLZZTSClient();
|
|
client.ClientCredentials.UserName.UserName = "NWBG";
|
|
client.ClientCredentials.UserName.Password = "nwbg321";
|
|
|
|
dt.Columns.Add("Week", typeof(string));
|
|
dt.Columns.Add("Days", typeof(string));
|
|
|
|
GetItemZzDays.ZwmsSkKcwlzztsResponse res = client.ZwmsSkKcwlzzts(new GetItemZzDays.ZwmsSkKcwlzzts { T_906t1 = new GetItemZzDays.Zmm906t1[] { } });
|
|
List<GetItemZzDays.Zmm906t1> list = res.T_906t1.ToList().OrderBy(x => x.Zcycle).ToList();
|
|
foreach (GetItemZzDays.Zmm906t1 item in list)
|
|
{
|
|
dt.Rows.Add(item.Zcycle, item.Zaging);
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
//发货信息
|
|
public DataTable GetSo()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @"
|
|
SELECT DISTINCT a1.CreatedOn ,A1.BusinessDate 日期,A1.DocNo 销售出库单,A2.DocLineNo 行号,A5.Code 物料编码,A6.NameCombineName 存货名称,
|
|
A5.SPECS 规格型号,A10.Name 单位,ISNULL(A2.ShipQtyInvAmount, 0) 应发数量,ISNULL(so.HasQuantity, 0) 已发数量,ISNULL(A2.ShipQtyInvAmount,0)-isnull(so.HasQuantity, 0) WMS未发数量
|
|
from {0}.DBO.SM_Ship A1
|
|
LEFT JOIN {0}.dbo.SM_ShipLine A2 ON A2.Ship=A1.ID
|
|
LEFT JOIN {0}.dbo.SM_ShipLine_Trl A3 ON A2.ID=A3.ID AND A3.SysMLFlag='zh-CN'
|
|
LEFT JOIN {0}.dbo.CBO_ItemMaster A5 ON A2.ItemInfo_ItemID=A5.ID
|
|
LEFT JOIN {0}.dbo.CBO_ItemMaster_Trl A6 ON A6.ID = A5.ID AND A6.SysMLFlag='zh-CN'
|
|
LEFT JOIN {0}.dbo.CBO_Wh A7 ON A2.WH=A7.ID
|
|
LEFT JOIN {0}.dbo.CBO_Wh_Trl A8 ON A8.ID = A7.ID AND A8.SysMLFlag='zh-CN'
|
|
LEFT JOIN {0}.dbo.Base_UOM A9 ON A2.PriceUOM=A9.ID
|
|
LEFT JOIN {0}.dbo.Base_UOM_Trl A10 ON A10.ID = A9.ID AND A10.SysMLFlag='zh-CN'
|
|
LEFT JOIN ICSSODispatch so on A1.DocNo=so.DispatchCode AND A2.DocLineNo=so.DispatchRow
|
|
where 1=1 AND ISNULL(A2.WH,'')!=''";
|
|
|
|
if (!string.IsNullOrWhiteSpace(StratTime))
|
|
{
|
|
SqlText += " and a1.CreatedOn>'" + StratTime + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(EndTime))
|
|
{
|
|
SqlText += " and a1.CreatedOn<'" + EndTime + "'";
|
|
}
|
|
if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && !string.IsNullOrWhiteSpace(advDays))
|
|
{
|
|
SqlText += " and a1.CreatedOn>CAST(CAST(DATEADD(day, -" + advDays + ", GETDATE()) as date) as varchar(10)) + ' 00:00:00'";
|
|
}
|
|
if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
|
|
{
|
|
SqlText += " and a1.CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'";
|
|
}
|
|
SqlText += @"order by a1.CreatedOn ";
|
|
|
|
SqlText = string.Format(SqlText, ERPName, workpoint);
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
|
|
//工单欠料信息
|
|
public DataTable GetOwe()
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string SqlText = @" SELECT a.DocNo U9工单,a.startDate 开工日期,BItem.Code 母件料号,BItem.Name 母件名称,BItem.SPECS 母件规格,A.ProductQty 工单数量,
|
|
UOM.Name 母件单位,cBItem.Code 子件料号,cBItem.Name 子件名称,cBItem.SPECS 子件规格,--b.id,c.id,d.MO,
|
|
b.ActualReqQty,c.IssuedQty,d.qty,
|
|
ISNULL(b.ActualReqQty, 0)-ISNULL(c.IssuedQty, 0)+ISNULL(d.qty, 0) as 子件欠料数量
|
|
from {0}.DBO.MO_MO a
|
|
LEFT JOIN {0}.DBO.CBO_ItemMaster BItem on BItem.ID=a.ItemMaster
|
|
LEFT JOIN {0}.DBO.Base_UOM_Trl UOM ON UOM.ID = BItem.InventoryUOM
|
|
LEFT JOIN {0}.DBO.MO_MoPickList b on a.ID=B.MO
|
|
LEFT JOIN {0}.DBO.CBO_ItemMaster cBItem on b.ItemMaster=cBItem.ID
|
|
LEFT JOIN {0}.DBO.MO_IssueDocLine c on a.ID=c.MO and b.ItemMaster=c.Item
|
|
LEFT JOIN (SELECT b.MO,b.IssuedQty as qty,b.Item from {0}.DBO.mo_IssueDoc a
|
|
INNER JOIN {0}.DBO.MO_IssueDocLine b on a.ID=b.IssueDoc
|
|
INNER JOIN {0}.DBO.MO_IssueDocLine c on b.SourceIssueDocLine=c.ID
|
|
where a.IssueType='1' ) d on a.ID=d.MO and b.ItemMaster=d.Item
|
|
where a.DocState<>3 ";
|
|
|
|
//if (!string.IsNullOrWhiteSpace(StratTime))
|
|
//{
|
|
// SqlText += " and a.CreatedOn>'" + StratTime + "'";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(EndTime))
|
|
//{
|
|
// SqlText += " and a.CreatedOn<'" + EndTime + "'";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(advDays))
|
|
{
|
|
SqlText += @" and a.startDate>CAST(CAST(DATEADD(day, -" + advDays + @", GETDATE()) as date) as varchar(10)) + ' 00:00:00'
|
|
and a.startDate<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
|
|
}
|
|
if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
|
|
{
|
|
SqlText += @" and a.startDate>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
|
|
and a.startDate<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
|
|
}
|
|
SqlText += @"order by a.startDate ";
|
|
|
|
SqlText = string.Format(SqlText, ERPName, workpoint);
|
|
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
|
|
return dt;
|
|
}
|
|
|
|
public static void WriteLogFile(string input, string txtName)
|
|
{
|
|
try
|
|
{
|
|
string logAdress = "C:\\看板日志" + "\\";
|
|
if (!System.IO.Directory.Exists(logAdress))
|
|
{
|
|
System.IO.Directory.CreateDirectory(logAdress);//不存在就创建目录
|
|
}
|
|
|
|
string adress = logAdress + txtName;
|
|
if (!System.IO.Directory.Exists(adress))
|
|
{
|
|
System.IO.Directory.CreateDirectory(adress);//不存在就创建目录
|
|
}
|
|
|
|
// string logAdress = ConfigurationManager.AppSettings["logAdress"].ToString();
|
|
/**/
|
|
///指定日志文件的目录
|
|
string fname = adress + "\\" + "log" + DateTime.Now.ToString("yy-MM-dd") + ".txt";
|
|
/**/
|
|
///定义文件信息对象
|
|
|
|
FileInfo finfo = new FileInfo(fname);
|
|
|
|
if (!finfo.Exists)
|
|
{
|
|
FileStream fs;
|
|
fs = File.Create(fname);
|
|
fs.Close();
|
|
finfo = new FileInfo(fname);
|
|
}
|
|
|
|
/**/
|
|
///判断文件是否存在以及是否大于2K
|
|
if (finfo.Length > 1024 * 1024 * 10)
|
|
{
|
|
/**/
|
|
///文件超过10MB则重命名
|
|
File.Move(logAdress + "\\Log\\" + txtName + ".txt", Directory.GetCurrentDirectory() + DateTime.Now.TimeOfDay + "\\Log\\" + txtName + ".txt");
|
|
/**/
|
|
///删除该文件
|
|
//finfo.Delete();
|
|
}
|
|
//finfo.AppendText();
|
|
/**/
|
|
///创建只写文件流
|
|
|
|
using (FileStream fs = finfo.OpenWrite())
|
|
{
|
|
/**/
|
|
///根据上面创建的文件流创建写数据流
|
|
StreamWriter w = new StreamWriter(fs);
|
|
|
|
/**/
|
|
///设置写数据流的起始位置为文件流的末尾
|
|
|
|
///设置写数据流的起始位置为文件流的末尾
|
|
w.BaseStream.Seek(0, SeekOrigin.End);
|
|
|
|
w.WriteLine("*****************Start*****************");
|
|
w.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
/**/
|
|
///写入当前系统时间并换行
|
|
|
|
/**/
|
|
///写入日志内容并换行
|
|
w.WriteLine(input);
|
|
|
|
/**/
|
|
///写入------------------------------------“并换行
|
|
w.WriteLine("------------------END------------------------");
|
|
|
|
/**/
|
|
///清空缓冲区内容,并把缓冲区内容写入基础流
|
|
w.Flush();
|
|
|
|
/**/
|
|
///关闭写数据流
|
|
w.Close();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{ }
|
|
|
|
}
|
|
}
|
|
}
|