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.
1032 lines
56 KiB
1032 lines
56 KiB
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
using NFine.Code;
|
|
using NFine.Repository;
|
|
using System.Data.Common;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using System.Net;
|
|
using System.IO;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace NFine.Application.OMAY
|
|
{
|
|
public class ICSMoCreateLotApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
//奥美工单生成条码主表查询
|
|
public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @" select distinct a.ID, a.MODetailID,a.MOCode,a.Sequence, CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,a.StartDate
|
|
,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,CAST( a.Quantity AS DECIMAL(18,{0})) -CAST(a.RCVQuantity AS DECIMAL(18,{0})) as ERPNum,a.MOMemo
|
|
,case when a.EATTRIBUTE1='1' then 1 else 0 end MoTypeValue
|
|
,case when a.EATTRIBUTE1='1' then '非标准' else '标准' end MoType
|
|
,case when b.AmountEnable='1' then '1' else '0' end AmountEnable
|
|
,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.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10
|
|
from ICSMO a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
|
|
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='3'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
|
|
)c
|
|
on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
|
|
sql += " WHERE 1=1 and a.MOStatus<>'3' and a.ApsStatus='Y' and isnull(a.OrderStatus,'') <> 'Close'";
|
|
sql = string.Format(sql, Figure);
|
|
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["SelGDLX"].ToString()))
|
|
{
|
|
sql += " and a.MOType like '%" + queryParam["SelGDLX"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
|
|
{
|
|
string POStatus = queryParam["POStatus"].ToString();
|
|
if (POStatus == "0")
|
|
{
|
|
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
|
|
}
|
|
else if (POStatus == "1")
|
|
{
|
|
sql += " and ISNULL(c.LOTQTY,0)>=a.Quantity";
|
|
}
|
|
else
|
|
{
|
|
sql += " and ISNULL(c.LOTQTY,0)<a.Quantity";
|
|
}
|
|
}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
{
|
|
sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
//生成条码子表查询
|
|
public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, string Type, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
|
|
,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,
|
|
case when isnull(d.ID,'')='' then '未入库' else '已入库' end as isStorage,
|
|
case when g.InvIQC='1'and isnull(e.ID,'')='' then '未检验' else '免检' end as isInspection,
|
|
case when g.InvIQC='1' then '是' else '否' end as isExemption,a.Amount,
|
|
convert(varchar(20),a.ProductDate,23) as ProductDate,convert(varchar(20),a.ExpirationDate,23) as ExpirationDate ,g.EffectiveDays
|
|
from ICSInventoryLot a
|
|
left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
|
|
group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail c on a.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
left join dbo.ICSWareHouseLotInfo d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
|
|
left join ICSInspection e on a.LotNo=e.LotNo and e.Enable='1' and a.WorkPoint=e.WorkPoint
|
|
left join ICSInventory g on a.InvCode=g.InvCode and a.WorkPoint=g.WorkPoint
|
|
WHERE isnull(a.EATTRIBUTE1,'')='' and a.Type='" + Type + "' and c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
|
|
sql = string.Format(sql, Figure);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//获取小数点数位
|
|
public object GetDecimalDigits()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
try
|
|
{
|
|
string sql = string.Empty;
|
|
sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1' and WorkPoint='" + WorkPoint + "'";
|
|
object Figure = SqlHelper.ExecuteScalar(sql);
|
|
return Figure;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message.ToString());
|
|
}
|
|
}
|
|
|
|
//工单生成条码获取物料数量信息
|
|
public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint, string MoTypeValue)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
if (MoTypeValue=="0")
|
|
{
|
|
sql = @"select
|
|
d.Enable, a.InvCode,b.ClassCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity as Quantity,
|
|
--cast( isnull(h.BL,0)*a.Quantity AS DECIMAL(18,4)) as AbsolveQty,
|
|
9999 as AbsolveQty,
|
|
cast( isnull(h.BL,0)*a.Amount AS DECIMAL(18,4)) as AbsolveAmount,
|
|
cast( isnull(c.LOTQTY,0) as DECIMAL(18,4)) as CreatedQty,
|
|
CAST( ((isnull(h.BL,0)*a.Quantity) -(isnull(c.LOTQTY,0))) as DECIMAL(18,4)) as thisCreateQty,
|
|
cast( a.Amount as DECIMAL(18,4)) as Amount,
|
|
isnull(b.EffectiveEnable,0) as EffectiveEnable,
|
|
cast( isnull(b.EffectiveDays,0) as DECIMAL(18,4)) as EffectiveDays
|
|
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
|
|
from ICSMO a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
|
|
left join (
|
|
select b.TransCode,PARSENAME(REPLACE(b.TransSequence, '~', '.'), 2) as TransSequence ,sum(isnull(Quantity,0)) FCPQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,PARSENAME(REPLACE(b.TransSequence, '~', '.'), 2)
|
|
) f on a.MOCode=f.TransCode and a.Sequence=f.TransSequence
|
|
left join
|
|
(
|
|
|
|
select case when Flag>0 then ( case when PSLNUM>MLNUM then MLNUM else PSLNUM end) else PSLNUM end as BL ,MODetailID from (
|
|
select a.MODetailID,
|
|
case when isnull(sum(a.PSLYL),0)=0 then 0 else sum(a.PSLLSS)/sum(a.PSLYL)* max(isnull(F_Define1,0)/100.0) end as PSLNUM,
|
|
case when isnull(sum(a.MLYL),0)=0 then 0 else sum(a.MLLSS)/sum(a.MLYL)*max(isnull(F_Define1,0)/100.0) end as MLNUM,
|
|
sum(Flag) as Flag
|
|
from (
|
|
select a.MODetailID ,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('01','04','05') then a.Quantity else 0 end PSLYL,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('01','04','05') then a.IssueQuantity else 0 end PSLLSS,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then a.Quantity else 0 end MLYL,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then a.IssueQuantity else 0 end MLLSS,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then 1 else 0 end Flag
|
|
from dbo.ICSMOPick a
|
|
inner join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
where a.EATTRIBUTE1<>'1')a
|
|
left join Sys_SRM_ItemsDetail flag on flag.F_ItemCode='GDCS0001'
|
|
group by MODetailID )a) h on a.MODetailID=h.MODetailID
|
|
left join ICSConfiguration d on d.Code='CompleteVerification001' and a.WorkPoint =d.WorkPoint
|
|
left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
|
|
WHERE 1 =1 and a.MOStatus<>'3' and a.ApsStatus='Y' and isnull(a.OrderStatus,'') <> 'Close' ";
|
|
|
|
}
|
|
else
|
|
{
|
|
sql = @"select
|
|
d.Enable, a.InvCode,b.ClassCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity as Quantity,
|
|
--cast( isnull(h.BL,0)*a.Quantity AS DECIMAL(18,4)) as AbsolveQty,
|
|
9999 as AbsolveQty,
|
|
cast( isnull(h.BL,0)*a.Amount AS DECIMAL(18,4)) as AbsolveAmount,
|
|
cast( isnull(c.LOTQTY,0) as DECIMAL(18,4)) as CreatedQty,
|
|
CAST( ((isnull(h.BL,0)*a.Quantity) -(isnull(c.LOTQTY,0))) as DECIMAL(18,4)) as thisCreateQty,
|
|
cast( a.Amount as DECIMAL(18,4)) as Amount,
|
|
isnull(b.EffectiveEnable,0) as EffectiveEnable,
|
|
cast( isnull(b.EffectiveDays,0) as DECIMAL(18,4)) as EffectiveDays
|
|
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
|
|
from ICSMO a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
|
|
left join (
|
|
select b.TransCode,PARSENAME(REPLACE(b.TransSequence, '~', '.'), 2) as TransSequence ,sum(isnull(Quantity,0)) FCPQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,PARSENAME(REPLACE(b.TransSequence, '~', '.'), 2)
|
|
) f on a.MOCode=f.TransCode and a.Sequence=f.TransSequence
|
|
left join
|
|
(
|
|
select MinBL as BL ,MODetailID from (
|
|
select a.MODetailID,
|
|
min(ALLBL)*max(isnull(F_Define1,0)/100.0) as MinBL
|
|
from (
|
|
select a.MODetailID ,
|
|
case when a.Quantity =0 then 0 when a.IssueQuantity=0 then 0 else a.IssueQuantity/a.Quantity end as ALLBL
|
|
from dbo.ICSMOPick a
|
|
inner join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
where a.EATTRIBUTE1<>'1' and a.IssueQuantity>0 )a
|
|
left join Sys_SRM_ItemsDetail flag on flag.F_ItemCode='GDCS0001'
|
|
group by MODetailID )a) h on a.MODetailID=h.MODetailID
|
|
left join ICSConfiguration d on d.Code='CompleteVerification001' and a.WorkPoint =d.WorkPoint
|
|
left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
|
|
WHERE 1 =1 and a.MOStatus<>'3' and a.EATTRIBUTE1='1' and a.ApsStatus='Y' and isnull(a.OrderStatus,'') <> 'Close' ";
|
|
}
|
|
|
|
|
|
sql += " and a.MOCode = '" + MOCode + "' and a.Sequence = '" + Sequence + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
sql = string.Format(sql, Figure);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
//查询超生比例
|
|
public DataTable GetScale()
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" SELECT Top 1 a.F_Define1 as Prorate
|
|
FROM [dbo].[Sys_SRM_ItemsDetail] a
|
|
LEFT JOIN [dbo].[Sys_SRM_Items] b ON a.F_ItemId=b.F_Id AND b.F_EnabledMark='1'
|
|
WHERE b.F_EnCode='CS0001' ORDER BY a.F_ItemCode";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
//调用接口来显示本次可生产数量
|
|
public object GetAbsolveQty(string MOCode, string Sequence,string Qty)
|
|
{
|
|
decimal AvailQty = 0;
|
|
decimal AllQty = 0;
|
|
string msg = "";
|
|
string sql = @"select
|
|
a.WorkPoint as WorkPoint,
|
|
a.MODetailID as DetailID,
|
|
'生产订单' as Type,
|
|
cast( isnull(c.LOTQTY,0) as DECIMAL(18,4)) as InQty,
|
|
" + Qty + @" as Qty,
|
|
flag.F_Define1 as Prorate
|
|
from ICSMO a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
|
|
left join (
|
|
select b.TransCode,PARSENAME(REPLACE(b.TransSequence, '~', '.'), 2) as TransSequence ,sum(isnull(Quantity,0)) FCPQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,PARSENAME(REPLACE(b.TransSequence, '~', '.'), 2)
|
|
) f on a.MOCode=f.TransCode and a.Sequence=f.TransSequence
|
|
left join ICSConfiguration d on d.Code='CompleteVerification001' and a.WorkPoint =d.WorkPoint
|
|
left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
|
|
left join Sys_SRM_ItemsDetail flag on flag.F_ItemCode='GDCS0001'
|
|
WHERE 1 =1 and a.MOStatus<>'3' and a.ApsStatus='Y' and isnull(a.OrderStatus,'') <> 'Close'
|
|
and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
|
|
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
string Inputstr = JsonConvert.SerializeObject(dt);
|
|
|
|
string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Completeamnew/Approve";
|
|
string result = HttpPost(APIURL, Inputstr);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
else
|
|
{
|
|
if (msg == "")
|
|
{
|
|
JObject dataObj = JObject.Parse(Obj["Data"].ToString());
|
|
AvailQty = decimal.Parse(dataObj["AvailQty"].ToString());
|
|
AllQty = decimal.Parse(dataObj["AllQty"].ToString());
|
|
|
|
|
|
//JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
|
|
//foreach (var item in res)
|
|
//{
|
|
// JObject jo = (JObject)item;
|
|
// //var aa= jo["min_lotqty"].ToString();
|
|
// Num = Convert.ToDecimal(jo["AllQty"].ToString());
|
|
//}
|
|
|
|
}
|
|
}
|
|
|
|
var Header = new
|
|
{
|
|
msg = msg,
|
|
AvailQty = AvailQty,
|
|
AllQty= AllQty,
|
|
};
|
|
return Header;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//接口api解析
|
|
public static string HttpPost(string url, string body)
|
|
|
|
{
|
|
try
|
|
{
|
|
Encoding encoding = Encoding.UTF8;
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
request.Method = "POST";
|
|
request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
|
|
request.ContentType = "application/json; charset=utf-8";
|
|
|
|
byte[] buffer = encoding.GetBytes(body);
|
|
request.ContentLength = buffer.Length;
|
|
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
|
|
{
|
|
return reader.ReadToEnd();
|
|
}
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
//工单生成条码
|
|
public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
|
|
decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
|
|
decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
|
|
decimal LOTQTY = minPackQty;
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
//string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
|
|
string Pre = "CP" + MOCode + (Convert.ToInt32(Sequence)).ToString("D4");
|
|
string sql = string.Empty;
|
|
//string VendorLot = queryParam["VendorLot"].ToString();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
|
|
string InvCode = queryParam["ClassCode"].ToString();
|
|
string sqls = string.Empty;
|
|
string Colspan = "";
|
|
string str1 = "";
|
|
string LotNo=string.Empty;
|
|
List<string> ExtensionIDList = new List<string>();
|
|
for (int i = 0; i < createPageCount; i++)
|
|
{
|
|
if (i + 1 == createPageCount)
|
|
{
|
|
if (minPackQty * createPageCount > thisCreateQty)
|
|
{
|
|
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
|
|
}
|
|
}
|
|
|
|
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
|
|
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
|
|
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
|
|
bool flag = true;
|
|
foreach (var item in ExtensionIDList)
|
|
{
|
|
if (item == Colspan + WorkPoint)
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
if (ExtensionID == null && flag == true)
|
|
{
|
|
str1 = Guid.NewGuid().ToString();
|
|
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
|
|
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
|
|
MUSER, MUSERNAME, WorkPoints);
|
|
}
|
|
else if (ExtensionID != null)
|
|
{
|
|
str1 = ExtensionID.ToString();
|
|
}
|
|
|
|
ExtensionIDList.Add(Colspan + WorkPoint);
|
|
|
|
|
|
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
|
|
if (AMEnable == "true")
|
|
{
|
|
|
|
LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
|
|
}
|
|
else
|
|
{
|
|
LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
|
|
}
|
|
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
|
|
LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
|
|
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
|
|
//{
|
|
sql += string.Format(@"insert into ICSInventoryLot
|
|
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount
|
|
,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
|
|
select
|
|
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
|
|
from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
|
|
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
|
|
|
|
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
|
|
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
|
|
sql += "\r\n";
|
|
//}
|
|
|
|
}
|
|
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
return count;
|
|
}
|
|
|
|
|
|
public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
|
|
{
|
|
string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
|
|
sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
|
|
//return Repository().FindTableBySql(sql.ToString());
|
|
return SqlHelper.ExecuteScalar(sql).ToString();
|
|
//return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
|
|
}
|
|
|
|
|
|
|
|
//副产品
|
|
public DataTable GetGridJsonFCP(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
object Figure = GetDecimalDigits();
|
|
#region [SQL]
|
|
string sql = @"select a.ID,d.MOCode,d.Sequence+'~'+ a.Sequence as Sequence,a.PickID,a.InvCode as ZInvCode,d.InvCode as MInvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
|
|
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MODetailID,
|
|
CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
|
|
,case when d.EATTRIBUTE1='1' then 1 else 0 end MoTypeValue
|
|
,case when d.EATTRIBUTE1='1' then '非标准' else '标准' end MoType
|
|
,case when b.AmountEnable='1' then '1' else '0' end AmountEnable
|
|
,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.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10
|
|
from ICSMOPick a
|
|
inner join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' and d.ApsStatus='Y' and isnull(d.OrderStatus,'') <> 'Close'
|
|
inner join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
|
|
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='18'
|
|
where isnull(ee.EATTRIBUTE1,'')=''
|
|
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
|
|
)c
|
|
on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
where a.EATTRIBUTE1='1' and SUBSTRING(b.ClassCode, 1, 2) not IN ('05') ";
|
|
sql = string.Format(sql, Figure);
|
|
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
|
|
{
|
|
string POStatus = queryParam["POStatus"].ToString();
|
|
if (POStatus == "0")
|
|
{
|
|
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
|
|
}
|
|
else if (POStatus == "1")
|
|
{
|
|
sql += " and ISNULL(c.LOTQTY,0)>=a.Quantity";
|
|
}
|
|
else
|
|
{
|
|
sql += " and ISNULL(c.LOTQTY,0)<a.Quantity";
|
|
}
|
|
}
|
|
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
{
|
|
sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
//副产品生成条码获取物料数量信息
|
|
public DataTable GetSubGridJsonFCPCreate(string FCPMOCode, string Sequence, string WorkPoint, string MoTypeValue)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
object Figure = GetDecimalDigits();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
if (MoTypeValue=="0")
|
|
{
|
|
sql = @"
|
|
select
|
|
a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, a.Quantity as Quantity,
|
|
--cast( isnull(h.BL,0)*a.Quantity AS DECIMAL(18,4)) as AbsolveQty,
|
|
9999 as AbsolveQty,
|
|
cast( isnull(h.BL,0)*a.Amount AS DECIMAL(18,4)) as AbsolveAmount,
|
|
cast( isnull(c.LOTQTY,0)+isnull(f.GDQTY,0) as DECIMAL(18,4)) as CreatedQty,
|
|
CAST( ((isnull(h.BL,0)* case when b.AmountEnable='1' then a.Amount else a.Quantity end) -(isnull(c.LOTQTY,0)+isnull(f.GDQTY,0))) as DECIMAL(18,4)) as thisCreateQty,
|
|
cast( a.Amount as DECIMAL(18,4)) as Amount,
|
|
isnull(b.EffectiveEnable,0) as EffectiveEnable,
|
|
cast( isnull(b.EffectiveDays,0) as DECIMAL(18,4)) as EffectiveDays
|
|
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
|
|
from ICSMOPick a
|
|
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' and d.ApsStatus='Y' and isnull(d.OrderStatus,'') <> 'Close'
|
|
--汇总副产品已生成条码数量
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence
|
|
--汇总工单已生成条码
|
|
left join (
|
|
select b.TransCode,b.TransSequence ,sum(isnull(Quantity,0)) GDQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) f on d.MOCode=f.TransCode and d.Sequence+'~'+a.Sequence=f.TransSequence
|
|
left join
|
|
(select case when Flag>0 then ( case when PSLNUM>MLNUM then MLNUM else PSLNUM end) else PSLNUM end as BL ,MODetailID from (
|
|
select a.MODetailID,
|
|
case when isnull(sum(a.PSLYL),0)=0 then 0 else sum(a.PSLLSS)/sum(a.PSLYL)* max(isnull(F_Define1,0)/100.0) end as PSLNUM,
|
|
case when isnull(sum(a.MLYL),0)=0 then 0 else sum(a.MLLSS)/sum(a.MLYL)*max(isnull(F_Define1,0)/100.0) end as MLNUM,
|
|
sum(Flag) as Flag
|
|
from (
|
|
select a.MODetailID ,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('01','04','05') then a.Quantity else 0 end PSLYL,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('01','04','05') then a.IssueQuantity else 0 end PSLLSS,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then a.Quantity else 0 end MLYL,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then a.IssueQuantity else 0 end MLLSS,
|
|
case when SUBSTRING(b.ClassCode, 1, 2) IN ('03') then 1 else 0 end Flag
|
|
from dbo.ICSMOPick a
|
|
inner join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
where a.EATTRIBUTE1 <> '1')a
|
|
left join Sys_SRM_ItemsDetail flag on flag.F_ItemCode='GDCS0001'
|
|
group by MODetailID )a) h on a.MODetailID=h.MODetailID
|
|
left join ICSExtension e on d.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
|
|
|
|
WHERE 1=1 ";
|
|
}
|
|
else
|
|
{
|
|
sql = @"
|
|
select
|
|
a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, a.Quantity as Quantity,
|
|
--cast( isnull(h.BL,0)*a.Quantity AS DECIMAL(18,4)) as AbsolveQty,
|
|
9999 as AbsolveQty,
|
|
cast( isnull(h.BL,0)*a.Amount AS DECIMAL(18,4)) as AbsolveAmount,
|
|
cast( isnull(c.LOTQTY,0)+isnull(f.GDQTY,0) as DECIMAL(18,4)) as CreatedQty,
|
|
CAST( ((isnull(h.BL,0)* case when b.AmountEnable='1' then a.Amount else a.Quantity end ) -(isnull(c.LOTQTY,0)+isnull(f.GDQTY,0))) as DECIMAL(18,4)) as thisCreateQty,
|
|
cast( a.Amount as DECIMAL(18,4)) as Amount,
|
|
isnull(b.EffectiveEnable,0) as EffectiveEnable,
|
|
cast( isnull(b.EffectiveDays,0) as DECIMAL(18,4)) as EffectiveDays
|
|
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
|
|
from ICSMOPick a
|
|
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' and d.ApsStatus='Y' and isnull(d.OrderStatus,'') <> 'Close'
|
|
--汇总副产品已生成条码数量
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence
|
|
--汇总工单已生成条码
|
|
left join (
|
|
select b.TransCode,b.TransSequence ,sum(isnull(Quantity,0)) GDQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) f on d.MOCode=f.TransCode and d.Sequence+'~'+a.Sequence=f.TransSequence
|
|
left join
|
|
(select MinBL as BL ,MODetailID from (
|
|
select a.MODetailID,
|
|
min(ALLBL)*max(isnull(F_Define1,0)/100.0) as MinBL
|
|
from (
|
|
select a.MODetailID ,
|
|
case when a.Quantity =0 then 0 when a.IssueQuantity=0 then 0 else a.IssueQuantity/a.Quantity end as ALLBL
|
|
from dbo.ICSMOPick a
|
|
inner join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
where a.EATTRIBUTE1<>'1' and a.IssueQuantity>0 )a
|
|
left join Sys_SRM_ItemsDetail flag on flag.F_ItemCode='GDCS0001'
|
|
group by MODetailID )a) h on a.MODetailID=h.MODetailID
|
|
left join ICSExtension e on d.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
|
|
|
|
WHERE 1=1 ";
|
|
}
|
|
|
|
sql += " and d.MOCode='" + FCPMOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
sql = string.Format(sql, Figure);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
//副产品调用接口获取可生成数量
|
|
|
|
public object GetFCPAbsolveQty(string MOCode, string Sequence, string Qty)
|
|
{
|
|
decimal AvailQty = 0;
|
|
decimal AllQty = 0;
|
|
string msg = "";
|
|
string sql = @"
|
|
select
|
|
a.WorkPoint as WorkPoint,
|
|
a.MODetailID as DetailID,
|
|
'生产订单' as Type,
|
|
cast( isnull(c.LOTQTY,0) as DECIMAL(18,4)) as InQty,
|
|
" + Qty + @" as Qty,
|
|
flag.F_Define1 as Prorate
|
|
from ICSMOPick a
|
|
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' and d.ApsStatus='Y' and isnull(d.OrderStatus,'') <> 'Close'
|
|
--汇总副产品已生成条码数量
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (
|
|
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='18'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence
|
|
--汇总工单已生成条码
|
|
left join (
|
|
select b.TransCode,b.TransSequence ,sum(isnull(Quantity,0)) GDQTY from ICSInventoryLot a
|
|
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
|
|
where isnull(a.EATTRIBUTE1,'')=''
|
|
group by b.TransCode,b.TransSequence
|
|
) f on d.MOCode=f.TransCode and d.Sequence=f.TransSequence
|
|
left join ICSExtension e on d.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
|
|
left join Sys_SRM_ItemsDetail flag on flag.F_ItemCode='GDCS0001'
|
|
WHERE 1=1
|
|
and d.MOCode='" + MOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "'";
|
|
|
|
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
string Inputstr = JsonConvert.SerializeObject(dt);
|
|
|
|
string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Completeamnew05/Approve";
|
|
string result = HttpPost(APIURL, Inputstr);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
else
|
|
{
|
|
if (msg == "")
|
|
{
|
|
JObject dataObj = JObject.Parse(Obj["Data"].ToString());
|
|
AvailQty = decimal.Parse(dataObj["AvailQty"].ToString());
|
|
AllQty = decimal.Parse(dataObj["AllQty"].ToString());
|
|
|
|
}
|
|
}
|
|
|
|
var Header = new
|
|
{
|
|
msg = msg,
|
|
AvailQty = AvailQty,
|
|
AllQty = AllQty,
|
|
};
|
|
return Header;
|
|
}
|
|
|
|
|
|
|
|
//联副产品
|
|
public int SubmitFormFCP(string FCPMOCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
|
|
decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
|
|
decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
|
|
decimal LOTQTY = minPackQty;
|
|
string Sequences = Sequence.Replace("~", "");
|
|
string Pre = "FCP" + FCPMOCode + (Convert.ToInt32(Sequences)).ToString("D4");
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string sql = string.Empty;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
|
|
string InvCode = queryParam["ClassCode"].ToString();
|
|
string sqls = string.Empty;
|
|
string Colspan = "";
|
|
string str1 = "";
|
|
string LotNo = string.Empty;
|
|
List<string> ExtensionIDList = new List<string>();
|
|
for (int i = 0; i < createPageCount; i++)
|
|
{
|
|
if (i + 1 == createPageCount)
|
|
{
|
|
if (minPackQty * createPageCount > thisCreateQty)
|
|
{
|
|
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
|
|
}
|
|
}
|
|
|
|
|
|
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
|
|
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
|
|
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
|
|
bool flag = true;
|
|
foreach (var item in ExtensionIDList)
|
|
{
|
|
if (item == Colspan + WorkPoint)
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
if (ExtensionID == null && flag == true)
|
|
{
|
|
str1 = Guid.NewGuid().ToString();
|
|
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
|
|
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
|
|
MUSER, MUSERNAME, WorkPoints);
|
|
}
|
|
else if (ExtensionID != null)
|
|
{
|
|
str1 = ExtensionID.ToString();
|
|
}
|
|
ExtensionIDList.Add(Colspan + WorkPoint);
|
|
|
|
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
|
|
if (AMEnable == "true")
|
|
{
|
|
|
|
LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
|
|
}
|
|
else
|
|
{
|
|
LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
|
|
}
|
|
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
|
|
LotNo, FCPMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
|
|
sql += string.Format(@"insert into ICSInventoryLot
|
|
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
|
|
select
|
|
newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','18','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
|
|
from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' where d.MOCode='{6}' and d.Sequence+'~'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
|
|
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FCPMOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
|
|
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
|
|
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
|
|
sql += "\r\n";
|
|
}
|
|
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
return count;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DataTable GetByproductGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
#region [SQL]
|
|
string sql = @" select a.ID,a.LotNo,a.InvCode,c.InvName,c.InvStd,a.Quantity,a.MUSERName,b.MTIME as WMTIME,a.MTIME
|
|
from dbo.ICSInventoryLot a
|
|
left join dbo.ICSWareHouseLotInfo b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
inner join dbo.ICSInventory c on a.InvCode=c.InvCode
|
|
where a.Type='19'";
|
|
// sql += " WHERE 1=1";
|
|
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["MTDOCCode"].ToString()))
|
|
{
|
|
sql += " and a.MTDOCCode like '%" + queryParam["MTDOCCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
|
|
{
|
|
string POStatus = queryParam["POStatus"].ToString();
|
|
if (POStatus == "0")
|
|
{
|
|
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
|
|
}
|
|
else if (POStatus == "1")
|
|
{
|
|
sql += " and ISNULL(b.MTIME,'')<>''";
|
|
}
|
|
else
|
|
{
|
|
sql += " and ISNULL(b.MTIME,'')=''";
|
|
}
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetInvCode()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"
|
|
select '' as Code,'' as InvCode
|
|
union all
|
|
SELECT InvCode +'--'+InvStd +'--'+InvName as Code ,InvCode as InvCode FROM dbo.ICSInventory WITH (NOLOCK) WHERE 1=1 and SUBSTRING(ClassCode, 1, 2) IN ('05') and EATTRIBUTE6<>'1' ";
|
|
|
|
sql += " and WorkPoint='" + WorkPoint + "' order by InvCode asc";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
|
|
public DataTable SeachAmountEnablebyInvCode(string InvCode)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
DataTable dt = new DataTable();
|
|
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
select isnull(AmountEnable,0) as AmountEnable ,ClassCode,isnull(EATTRIBUTE1,'1') as EATTRIBUTE1,InvName,InvStd from dbo.ICSInventory where InvCode='" + InvCode + "' and WorkPoint='" + WorkPoint + "'";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
public int SubmitFormFCPNoCode (string keyValue, string WorkPoint, string AMEnable)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
|
|
decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
|
|
string InvCode = queryParam["InvCode"].ToString();
|
|
decimal LOTQTY = minPackQty;
|
|
//string Sequences = Sequence.Replace("~", "");
|
|
//string Pre = "FCP" + FCPMOCode + (Convert.ToInt32(Sequences)).ToString("D4");
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string sql = string.Empty;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
// string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
|
|
string ClassCode = queryParam["ClassCode"].ToString();
|
|
string sqls = string.Empty;
|
|
string Colspan = "";
|
|
string str1 = "";
|
|
string LotNo = string.Empty;
|
|
List<string> ExtensionIDList = new List<string>();
|
|
for (int i = 0; i < createPageCount; i++)
|
|
{
|
|
//if (i + 1 == createPageCount)
|
|
//{
|
|
// if (minPackQty * createPageCount > thisCreateQty)
|
|
// {
|
|
// LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
|
|
// }
|
|
//}
|
|
|
|
|
|
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
|
|
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
|
|
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
|
|
bool flag = true;
|
|
foreach (var item in ExtensionIDList)
|
|
{
|
|
if (item == Colspan + WorkPoint)
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
if (ExtensionID == null && flag == true)
|
|
{
|
|
str1 = Guid.NewGuid().ToString();
|
|
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
|
|
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
|
|
MUSER, MUSERNAME, WorkPoints);
|
|
}
|
|
else if (ExtensionID != null)
|
|
{
|
|
str1 = ExtensionID.ToString();
|
|
}
|
|
ExtensionIDList.Add(Colspan + WorkPoint);
|
|
|
|
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
|
|
if (AMEnable == "true")
|
|
{
|
|
|
|
LotNo = SqlHelper.GetLOTNumber(ClassCode, WorkPoint);
|
|
}
|
|
sql += string.Format(@"insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
|
|
values(newid(),'{0}','{1}',getdate(),'{2}','{3}','{4}','19','{5}','{6}',getdate(),'{7}','{8}','','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')",
|
|
LotNo, InvCode, queryParam["ExpirationDate"].ToString(), LOTQTY, str1, MUSER, MUSERNAME, WorkPoints, queryParam["Amount"].ToString(),
|
|
queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
|
|
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
|
|
sql += "\r\n";
|
|
}
|
|
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
return count;
|
|
}
|
|
|
|
|
|
|
|
public string DeleteFCPLot(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
|
|
WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
|
|
if (dtASN != null && dtASN.Rows.Count > 0)
|
|
{
|
|
msg = "所选条码已生成检验单,无法删除!";
|
|
}
|
|
sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
|
|
(SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
|
|
if (dtCarton != null && dtCarton.Rows.Count > 0)
|
|
{
|
|
msg += "所选条码已入库,无法删除!";
|
|
}
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
string sqls = string.Format(@"DELETE FROM dbo.ICSInventoryLot WHERE LotNo IN ({0}) and WorkPoint ='{1}' and Type='19' ", keyValue.TrimEnd(','), WorkPoint);
|
|
SqlHelper.CmdExecuteNonQueryLi(sqls);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|