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.
1836 lines
94 KiB
1836 lines
94 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using NFine.Domain.Entity.ProductManage;
|
|
using NFine.Domain.IRepository.ProductManage;
|
|
using NFine.Repository;
|
|
using NFine.Repository.ProductManage;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace NFine.Application
|
|
{
|
|
public class ASNManageApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
|
|
public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string ParentId = "";
|
|
//加载前删除空白单据
|
|
// string sqlDelete = @"DELETE a FROM dbo.ICSASN a
|
|
// LEFT JOIN dbo.ICSASNDETAIL b ON a.ASNCode=b.ASNCode
|
|
// WHERE b.ASNCode IS NULL";
|
|
// SqlHelper.ExecuteNonQuery(sqlDelete);
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
string sqlAccount = string.Empty;
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT distinct a.ID, a.ASNCode,a.VenCode,b.VenName AS VENDORNAME,w.WorkPointName,w.WorkPointCode,a.MUSERName,
|
|
a.MTIME,CONVERT(NVARCHAR(50),a.PlanArriveDate,23) as EXPARRIVALDATE,
|
|
CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END AS STATUS
|
|
,a.EATTRIBUTE1,
|
|
CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END AS STATUSHidden
|
|
,a.EATTRIBUTE2,a.EATTRIBUTE10,ISNULL(d.Quantity,0) AS Quantity,ISNULL(d.CountNum,0) as CountNum,convert(nvarchar(20),c.MTIME,120) DMTIME
|
|
FROM dbo.ICSASN a
|
|
LEFT JOIN (SELECT ISNULL(SUM(Quantity),0) AS Quantity,COUNT(*) AS CountNum,ASNCode,WorkPoint FROM ICSASNDetail
|
|
GROUP BY ASNCode,WorkPoint) d on a.ASNCode=d.ASNCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSASNDetail e on a.ASNCode=e.ASNCode and a.WorkPoint=e.WorkPoint
|
|
left join ICSInventoryLotDetail f on e.LotNo=f.LotNo and e.WorkPoint=f.WorkPoint
|
|
left join ICSPurchaseOrder g on f.TransCode=g.POCode and f.TransSequence=g.Sequence and f.WorkPoint=g.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor b ON a.VenCode=b.VenCode and a.WOrkPoint=b.WorkPoint
|
|
LEFT JOIN ICSDeliveryNotice c ON a.ASNCode = c.ASNCode
|
|
LEFT JOIN Sys_WorkPoint w on a.WorkPoint=w.WorkPointCode
|
|
WHERE 1=1";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["STNO"].ToString()))
|
|
{
|
|
sql += " and a.ASNCode like '%" + queryParam["STNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and b.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
sql += " and a.MTIME >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeTo"].ToString()))
|
|
{
|
|
sql += " and a.MTIME <= '" + queryParam["TimeTo"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and g.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["PoCode"].ToString()))
|
|
{
|
|
sql += " and g.POCode like '%" + queryParam["PoCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["MUSERName"].ToString()))
|
|
{
|
|
sql += " and a.MUSERName like '%" + queryParam["MUSERName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "0")
|
|
sql += " AND CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END = '0'";
|
|
else if (ReleaseState == "1")
|
|
sql += " and CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END = '1'";
|
|
else if (ReleaseState == "2")
|
|
sql += " and CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END = '2'";
|
|
else if (ReleaseState == "3")
|
|
{
|
|
sql += " and CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END='3'";
|
|
}
|
|
else if (ReleaseState == "4")
|
|
sql += " and CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END = '4'";
|
|
}
|
|
}
|
|
//多站点
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode.Contains("Vendor"))
|
|
{
|
|
sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode + "'";
|
|
}
|
|
ParentId = SqlHelper.Organize_F_ParentId(NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode);
|
|
if (!string.IsNullOrWhiteSpace(ParentId) && ParentId != "0" && NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "Vendor")
|
|
{
|
|
return SqlHelper.FindTablePageBySql_OtherTemp(sql.ToString(), sql, ParentId, parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
else
|
|
{
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
}
|
|
|
|
public DataTable GetGridJsonAdmin(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string ParentId = "";
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT distinct a.ID, a.ASNCode,a.venCode,b.VenName ,CONVERT(NVARCHAR(50),a.Mtime,23) as CREATETIME,w.WorkPointName,w.WorkPointCode,ISNULL(d.Quantity,0) AS Quantity,
|
|
a.MUserName,
|
|
CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END AS STATUS,
|
|
CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END AS STATUSHidden
|
|
,a.EATTRIBUTE10,ISNULL(d.CountNum,0) as CountNum
|
|
,CASE WHEN p.LotNo IS NULL THEN '否' ELSE '是' END ISRK
|
|
FROM dbo.ICSASN a
|
|
LEFT JOIN (SELECT ISNULL(SUM(Quantity),0) AS Quantity,COUNT(*) AS CountNum,ASNCode,WorkPoint
|
|
FROM ICSASNDetail
|
|
GROUP BY ASNCode,WorkPoint) d on a.ASNCode=d.ASNCode and a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSASNDetail e on a.ASNCode=e.ASNCode and a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor b ON a.venCOde=b.venCOde and a.WOrkPoint=b.WorkPoint
|
|
LEFT JOIN (SELECT ASNCode,WorkPoint,DNCode
|
|
FROM ICSDeliveryNotice)
|
|
c ON a.ASNCode = c.ASNCode AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN Sys_WorkPoint w on a.WorkPoint=w.WorkPointCode
|
|
LEFT join ICSInventoryLotDetail m on e.LotNo=m.LotNo and e.WorkPoint=m.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder n ON m.TransCode=n.POCode AND m.TransSequence=n.Sequence AND a.WorkPoint=n.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory o ON n.InvCode=o.InvCode AND n.WorkPoint=o.WorkPoint
|
|
LEFT JOIN dbo.ICSWareHouseLotInfoLog p ON e.LotNo=p.LotNo AND e.WorkPoint=p.WorkPoint
|
|
WHERE 1=1 and a.status in ( '1','2')";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["STNO"].ToString()))
|
|
{
|
|
sql += " and a.ASNCode like '%" + queryParam["STNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
sql += " and a.venCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and b.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql += " and o.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and o.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
sql += " and a.Mtime >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeTo"].ToString()))
|
|
{
|
|
sql += " and a.Mtime <= '" + queryParam["TimeTo"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
sql += " and CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END = '1'";
|
|
else if (ReleaseState == "2")
|
|
sql += " and CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END = '2'";
|
|
else if (ReleaseState == "3")
|
|
sql += " and CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END= '3'";
|
|
|
|
}
|
|
//多站点
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode.Contains("Vendor"))
|
|
{
|
|
sql += " and a.venCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode + "'";
|
|
}
|
|
ParentId = SqlHelper.Organize_F_ParentId(NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode);
|
|
if (!string.IsNullOrWhiteSpace(ParentId) && ParentId != "0" && NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "Vendor")
|
|
{
|
|
return SqlHelper.FindTablePageBySql_OtherTemp(sql.ToString(), sql, ParentId, parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
else
|
|
{
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 子表查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJson(string STNO, ref Pagination jqgridparam,string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string EATTRIBUTE = SqlHelper.GetEATTRIBUTE("ICSPurchaseOrder", "e").TrimEnd(',');
|
|
string sql = @"SELECT a.ID, a.LotNo,d.InvCode,d.InvName,x.ContainerCode as XH,
|
|
y.ContainerCode as ZB,b.Quantity,
|
|
a.ASNCode,f.BatchCode,f.ProjectCode,m.TransCode,m.TransSequence,d.InvDesc
|
|
,d.ClassName,d.InvStd,w.WorkPointName,w.WorkPointCode,CASE WHEN p.LotNo IS NULL THEN '否' ELSE '是' END ISRK
|
|
," + EATTRIBUTE + "";
|
|
sql+= @"
|
|
FROM dbo.ICSASNDetail a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LotNo =b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on b.ExtensionID=f.ID and b.WorkPoint=f.WorkPoint
|
|
left join ICSInventoryLotDetail m on b.LotNo=m.LotNo and b.WorkPoint=m.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot c ON b.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory d ON b.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder e ON m.TransCode=e.POCode AND m.TransSequence=e.Sequence AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN Sys_WorkPoint w on e.WorkPoint=w.WorkPointCode
|
|
LEFT JOIN ICSContainer X ON c.ContainerID=X.ID AND c.WorkPoint=x.WorkPoint and X.ContainerType='ContainerType01'
|
|
left join ICSContainer y on X.ContainerID=y.ID and X.WorkPoint=y.WorkPoint and y.ContainerType='ContainerType04'
|
|
LEFT JOIN dbo.ICSWareHouseLotInfoLog p ON a.LotNo=p.LotNo AND a.WorkPoint=p.WorkPoint AND p.BusinessCode='1'and isnull(p.EATTRIBUTE1,'')<>'1'
|
|
WHERE (b.TYPE='200' OR ISNULL(b.EATTRIBUTE7,'') ='入库前分批') AND a.ASNCode='" + STNO + "' and a.WorkPoint='" + WorkPoint + "' ";
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择条码信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJson_Add(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
string sql = @"SELECT a.ID,a.ID as ZJID, a.LOTNO,d.InvCode,d.InvName,g.ContainerCode,b.Quantity,
|
|
a.ASNCode,m.BatchCode,f.POCode,f.Sequence,d.InvDesc,d.ClassName,d.InvStd
|
|
FROM dbo.ICSASNDetail a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LotNo =b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
left join ICSExtension m on b.ExtensionID=m.ID and b.WorkPoint=m.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
|
|
left join dbo.ICSContainer g on c.ContainerID=g.ID and a.WorkPoint=g.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory d ON b.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
left join ICSInventoryLotDetail e on b.LotNo=e.LotNo and b.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder f ON e.TransCode=f.POCode AND e.TransSequence=f.Sequence and a.WorkPoint=f.WorkPoint
|
|
WHERE 1=1
|
|
AND a.ASNCode='" + queryParam["STNO"].ToString() + "' and a.WorkPoint='" + queryParam["WorkPoint"].ToString() + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 子表查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJson(string CartonNo, string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID,c.ItemCODE,d.INVNAME,c.VenderLotNO,c.LOTQTY,c.TYPE
|
|
FROM dbo.ICSITEMLot2Carton a
|
|
LEFT JOIN dbo.ICSCarton b ON a.CartonNO=b.CartonNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSITEMLot c ON a.LotNo_ID=c.ID AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON c.ItemCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
WHERE a.CartonNO='" + CartonNo + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
if (!string.IsNullOrEmpty(queryJson))
|
|
{
|
|
sql += @"UNION ALL
|
|
SELECT a.ID,a.ItemCODE,b.INVNAME,a.VenderLotNO,a.LOTQTY,a.TYPE FROM
|
|
dbo.ICSITEMLot a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.ItemCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.ID IN (" + queryJson.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetSubGridJsonByCreate(string POCode, string PORow)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID, a.POCode,a.PORow,a.PODate,a.ORDERNO,a.VenCode,a.VenName,a.InvCode,
|
|
b.INVNAME,b.INVSTD,b.INVDESC,b.INVUOM,a.Quantity,ISNULL(c.CreatedQty,0) AS CreatedQty,isnull(c.InQty,0) as InQty,a.WorkPoint
|
|
FROM dbo.ICSPO_PoMain a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN (SELECT SUM(x.LOTQTY) CreatedQty,TransNO,TransLine,x.WorkPoint,
|
|
SUM(CASE WHEN y.LotNO IS NOT NULL THEN x.LOTQTY ELSE 0 END) AS InQty
|
|
FROM dbo.ICSITEMLot x
|
|
LEFT JOIN dbo.ICSWareHouseLotInfo y ON x.LotNO=y.LotNO AND x.WorkPoint=y.WorkPoint
|
|
GROUP BY TransNO,TransLine,x.WorkPoint) c ON a.POCode=c.TransNO AND a.PORow=c.TransLine AND a.WorkPoint=c.WorkPoint
|
|
WHERE 1=1
|
|
and a.POCode='" + POCode + "' and a.PORow='" + PORow + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string dtPre = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public int CreateItemLotNo(string POCode, string PORow, string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
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(POCode, PORow, WorkPoint);
|
|
string Pre = VenCode + DateTime.Now.ToString("yyMMdd");
|
|
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;
|
|
|
|
for (int i = 0; i < createPageCount; i++)
|
|
{
|
|
if (i + 1 == createPageCount)
|
|
{
|
|
if (minPackQty * createPageCount > thisCreateQty)
|
|
{
|
|
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
|
|
}
|
|
}
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSITEMLot", "LotNO", Pre, 5);
|
|
sql += string.Format(@"INSERT INTO dbo.ICSITEMLot
|
|
( ID ,LotNO ,ItemCODE ,TransNO ,TransLine ,VENDORITEMCODE ,VENDORCODE ,
|
|
VenderLotNO ,PRODUCTDATE ,LOTQTY ,ACTIVE ,Exdate ,WorkPoint ,
|
|
MUSER ,MUSERName ,MTIME ,TYPE,ORDERNO)
|
|
SELECT NEWID(),'{0}',InvCode,POCode,PORow,'',NULL,
|
|
'{1}',GETDATE(),'{2}','Y','2999-12-31 00:00:00.000','{3}',
|
|
'{4}','{5}',GETDATE(),'采购原料',ORDERNO
|
|
FROM dbo.ICSPO_PoMain WHERE POCode='{6}' AND PORow='{7}' AND WorkPoint='{3}'",
|
|
LotNo, VendorLot, LOTQTY, WorkPoint, MUSER, MUSERNAME, POCode, PORow);
|
|
sql += "\r\n";
|
|
}
|
|
int count = SqlHelper.ExecuteNonQuery(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 DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
|
|
}
|
|
|
|
public string GetVendorCode(string POCode, string PORow, string WorkPoint)
|
|
{
|
|
string sql = string.Format(@"SELECT VenCode FROM dbo.ICSPO_PoMain
|
|
WHERE POCode='{0}' AND PORow='{1}' AND WorkPoint='{2}'", POCode, PORow, WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
string VenCode = string.Empty;
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
VenCode = dt.Rows[0][0].ToString();
|
|
}
|
|
return VenCode;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除送货单内的条码或者箱号
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string DeleteInfo(string keyValue,string WorkPoint)
|
|
{
|
|
|
|
string msg = "";
|
|
string sql = string.Format(@" DELETE FROM dbo.ICSASNDetail
|
|
WHERE ID IN (
|
|
SELECT ID FROM dbo.ICSASNDetail WHERE LotNo IN (
|
|
SELECT LotNo FROM dbo.ICSContainerLot WHERE ContainerID IN (
|
|
SELECT a.ContainerID
|
|
FROM dbo.ICSContainerLot a
|
|
LEFT JOIN dbo.ICSASNDetail b ON a.LotNO=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
WHERE b.ID IN ({0}) AND a.WorkPoint='{1}')
|
|
))", keyValue.TrimEnd(','), WorkPoint);
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
sql = string.Format(@" DELETE
|
|
FROM dbo.ICSASNDetail
|
|
WHERE ID IN ({0}) and WorkPoint ='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新送货单
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string UpdateSTNO(string keyValue, string WorkPoint, string EATTRIBUTE1)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string[] keyValues = keyValue.Split(',');
|
|
string sql = string.Empty;
|
|
sql = "UPDATE ICSASN SET MTIME = getdate(),EATTRIBUTE1='{2}' WHERE ASNCode = {0} AND WorkPoint in ('{1}')";
|
|
sql = string.Format(sql, keyValues[0].TrimStart(',').TrimEnd(','), WorkPoint, EATTRIBUTE1);
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除送货单
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string DeleteSTNO(string keyValue, string WorkPoint, string EATTRIBUTE1)
|
|
{
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = "SELECT ASNCode FROM dbo.ICSDeliveryNotice WHERE ASNCode IN (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
string STNO = dr["ASNCode"].ToString();
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
msg += "送货单号:" + STNO + "已生成到货单,无法删除!";
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
sql = string.Format(@" DELETE FROM dbo.ICSASNDetail WHERE ASNCode IN ({0}) and WorkPoint in ('{1}')
|
|
DELETE FROM dbo.ICSASN WHERE ASNCode IN ({0}) and WorkPoint in ('{1}')
|
|
UPDATE ICSASN SET EATTRIBUTE1='{2}'WHERE ASNCode IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint, EATTRIBUTE1);
|
|
|
|
//string sql = string.Format(@"SELECT * FROM dbo.ICSASNDETAIL
|
|
// WHERE LOTNO IN (
|
|
// SELECT LotNO FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}') and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
//if (dt == null || dt.Rows.Count <= 0)
|
|
//{
|
|
// sql = string.Format(@"DELETE FROM dbo.ICSCarton WHERE CartonNO in ({0}) and WorkPoint='{1}'
|
|
// DELETE FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
// DbHelper.ExecuteNonQuery(CommandType.Text, sql);
|
|
//}
|
|
//else
|
|
//{
|
|
// msg = "所选箱号中已有加入送货单中,请先在送单号中删除!";
|
|
//}
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
public int UpDateBySTNO(string keyValue, string Status, string WorkPoint)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE ICSASN SET Status = '{1}' WHERE ASNCode IN ({0}) AND WorkPoint in({2})";
|
|
sql = string.Format(sql, keyValue.TrimEnd(','), Status,WorkPoint.TrimEnd(','));
|
|
return SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单号
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <param name="Status"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <param name="EATTRIBUTE1"></param>
|
|
/// <returns></returns>
|
|
public string UpDateBySTNODH(string keyValue)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
|
|
//keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
sql += $@"
|
|
UPDATE ICSASN SET EATTRIBUTE1 = '{jo["EATTRIBUTE1"]}' WHERE ASNCode = '{jo["objArr"]}' AND WorkPoint = '{jo["WorkPoint"]}' ";
|
|
|
|
}
|
|
|
|
try
|
|
{
|
|
SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
//throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
public int UpDateBySTNOAdmin(string keyValue, string Status, string WorkPoint)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE ICSASN SET Status = '{1}' WHERE ASNCode IN ({0}) AND WorkPoint in({2})";
|
|
sql = string.Format(sql, keyValue.TrimEnd(','), Status, WorkPoint.TrimEnd(','));
|
|
return SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
|
|
|
|
public string ChangeStatusBySTNO(string keyValue)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = "SELECT STNO FROM dbo.ICSPOArrive WHERE STNO IN (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
string STNO = dr["STNO"].ToString();
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
msg += "送货单号:" + STNO + "已生成到货单,无法删除!";
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
sql = string.Format(@"DELETE FROM dbo.ICSASNDETAIL WHERE STNO IN ({0}) and WorkPoint ='{1}'
|
|
DELETE FROM dbo.ICSASN WHERE STNO IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//string sql = string.Format(@"SELECT * FROM dbo.ICSASNDETAIL
|
|
// WHERE LOTNO IN (
|
|
// SELECT LotNO FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}') and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
//if (dt == null || dt.Rows.Count <= 0)
|
|
//{
|
|
// sql = string.Format(@"DELETE FROM dbo.ICSCarton WHERE CartonNO in ({0}) and WorkPoint='{1}'
|
|
// DELETE FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
// DbHelper.ExecuteNonQuery(CommandType.Text, sql);
|
|
//}
|
|
//else
|
|
//{
|
|
// msg = "所选箱号中已有加入送货单中,请先在送单号中删除!";
|
|
//}
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除送货单
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string DeleteCartonNo(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.ICSASNDETAIL
|
|
WHERE LOTNO IN (
|
|
SELECT LotNO FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}') and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt == null || dt.Rows.Count <= 0)
|
|
{
|
|
sql = string.Format(@"DELETE FROM dbo.ICSCarton WHERE CartonNO in ({0}) and WorkPoint='{1}'
|
|
DELETE FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
DbHelper.ExecuteNonQuery(CommandType.Text, sql);
|
|
}
|
|
else
|
|
{
|
|
msg = "所选箱号中已有加入送货单中,请先在送单号中删除!";
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择条码
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetInfoBySelectItemCode(string queryJson, ref Pagination jqgridparam,string WorkPoint)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID, a.LotNO,d.InvCode,d.InvName,a.Quantity,a.TYPE,
|
|
g.ProjectCode,e.POCode,e.Sequence,d.InvDesc,d.ClassName,d.INVSTD,g.BatchCode,a.Amount,a.WorkPoint
|
|
FROM dbo.ICSInventoryLot a
|
|
left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSASNDetail c ON a.LotNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory d ON a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
left join ICSInventoryLotDetail f on a.LotNo=f.LotNo and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder e ON f.TransCode=e.POCode AND f.TransSequence=e.Sequence
|
|
WHERE c.LotNo is null and B.LotNo IS NULL and ISNULL(a.EATTRIBUTE1,'') ='' and a.Type='200' AND e.Status<>'3'";
|
|
//AND a.TYPE='采购'";
|
|
if (!string.IsNullOrEmpty(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
sql += " and d.InvCode like '%" + queryParam["InvCode"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
sql += " and d.InvName like '%" + queryParam["InvName"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["OrderNo"].ToString()))
|
|
sql += " and g.ProjectCode like '%" + queryParam["OrderNo"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TransNo"].ToString()))
|
|
sql += " and e.POCode like '%" + queryParam["TransNo"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TransLine"].ToString()))
|
|
sql += " and e.Sequence like '%" + queryParam["TransLine"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
sql += " and e.VenCode='" + queryParam["VenCode"].ToString() + "'";
|
|
}
|
|
sql += " and a.WorkPoint='" + WorkPoint + "'";
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取供应商列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetVendor()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"select '' as F_VenCode,'' as cVenName
|
|
union all
|
|
SELECT DISTINCT a.F_VenCode,isnull(b.VenName,'') as cVenName FROM dbo.Sys_SRM_User a
|
|
LEFT JOIN dbo.ICSVendor b ON a.F_VenCode=b.VenCode and a.F_Location=b.WorkPoint
|
|
WHERE a.F_VenCode IS NOT NULL AND a.F_VenCode <>''";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and b.WorkPoint in(" + WorkPoint.TrimEnd(',') + ")";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取供应商列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetASNCode(string VenCode)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"
|
|
select '' as F_VenCode,'' as cVenName
|
|
union all
|
|
SELECT asncode AS F_VenCod,asncode AS cVenName FROM icsasn a WHERE status='2'";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and a.WorkPoint in(" + WorkPoint.TrimEnd(',') + ")";
|
|
}
|
|
if(!string.IsNullOrWhiteSpace(VenCode))
|
|
{
|
|
sql += " AND vencode='"+VenCode+"'";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取组织号信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetWorkPoint()
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
string sql = @" select '' as WorkPointCode,'' as WorkPointName
|
|
union all
|
|
SELECT distinct (b.WorkPointCode),b.WorkPointName FROM Sys_SRM_User a
|
|
LEFT JOIN Sys_WorkPoint b ON a.F_Location=b.WorkPointCode where b.WorkPointCode is not null";
|
|
//if (role != "admin")
|
|
//{
|
|
// sql += " and a.F_Account='" + role + "'";
|
|
//}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
public string GetSTNO(string WorkPoint)
|
|
{
|
|
string STNO = string.Empty;
|
|
string VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode;
|
|
WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(VenCode))
|
|
{
|
|
string Date = DateTime.Now.ToString("yy");
|
|
string Pre = "DN" + VenCode + Date;
|
|
STNO = GetSerialCode(WorkPoint, "ICSASN", "STNO", Pre, 5);
|
|
}
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
string sql = string.Empty;
|
|
string configSql = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string Status = "";
|
|
|
|
#region [获取送货单配置信息,判断状态]
|
|
string F_ItemName = SqlHelper.GetSHDZDSHItemsDetails("ASNAudit", WorkPoint);
|
|
if (!string.IsNullOrWhiteSpace(F_ItemName))
|
|
{
|
|
Status = "2";
|
|
}
|
|
else
|
|
{
|
|
Status = "0";
|
|
}
|
|
#endregion
|
|
|
|
|
|
sql = @"INSERT INTO dbo.ICSASN( ID ,MTIME,MUSER,MUSERNAME ,ASNCode ,VenCode ,WorkPoint,Status)
|
|
VALUES (NEWID(),GETDATE(),'" + VenCode + "','" + MUSERNAME + "','" + STNO + "','" + VenCode + "'," + WorkPoint + ",'" + Status + "')";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
return STNO;
|
|
}
|
|
|
|
public string GetSTNOByPerson(string VenCode, string ExpArrivalDate,string WorkPoint)
|
|
{
|
|
string STNO = string.Empty;
|
|
string Date = DateTime.Now.ToString("yy");
|
|
string Pre = "DN" + VenCode + Date;
|
|
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
STNO = GetSerialCode(WorkPoint, "ICSASN", "STNO", Pre, 5);
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
string sql = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string Status = "";
|
|
|
|
#region [获取送货单配置信息,判断状态]
|
|
string F_ItemName = SqlHelper.GetSHDZDSHItemsDetails("ASNAudit", WorkPoint);
|
|
if (!string.IsNullOrWhiteSpace(F_ItemName))
|
|
{
|
|
Status = "2";
|
|
}
|
|
else
|
|
{
|
|
Status = "0";
|
|
}
|
|
#endregion
|
|
sql = @"INSERT INTO dbo.ICSASN
|
|
( ID ,ASNCode,VenCode,Status ,MUSER ,MUSERName ,MTIME,WorkPoint)
|
|
VALUES (NEWID(),'" + STNO + "','" + VenCode + "','" + Status + "','" + MUSER + "','" + MUSERNAME + "',getdate(),'" + WorkPoint + "')";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
return STNO;
|
|
}
|
|
|
|
//public string CheckSTNO_ItemCode(string JsonData, string STNO, string WorkPoint, string ICSASN)
|
|
//{
|
|
// string msg = "";
|
|
// string APIURL = ConfigurationManager.ConnectionStrings["APIURLLOT"].ConnectionString;
|
|
// string result = SqlHelper.HttpPost(APIURL, ICSASN);
|
|
// 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;
|
|
// }
|
|
// return msg;
|
|
//}
|
|
|
|
public string CheckSTNO_ItemCode(string JsonData, string STNO, string WorkPoint)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSASNDetail
|
|
( ID ,ASNCode ,Sequence ,MUSER ,
|
|
LotNo , Quantity ,Amount ,DNQuantity ,DNAmount ,MUSERName,
|
|
MTIME,WorkPoint)
|
|
SELECT NEWID(),'" + STNO + "',ROW_NUMBER()over(partition by LotNO order by mtime desc),'" + MUSER + @"',
|
|
a.LotNO,a.Quantity,a.Quantity*Amount as Amount,0,0,'" + MUSERNAME + @"',
|
|
getdate()," + WorkPoint.TrimEnd(',') + @"
|
|
FROM dbo.ICSInventoryLot a
|
|
WHERE a.ID IN (" + JsonData.TrimEnd(',') + ")";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public string CheckSTNO_CartonNo(string JsonData, string STNO, string WorkPoint)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSASNDetail
|
|
( ID ,ASNCode ,Sequence ,MUSER ,
|
|
LotNo , Quantity ,Amount ,DNQuantity ,DNAmount ,MUSERName,
|
|
MTIME,WorkPoint)
|
|
SELECT NEWID(),'" + STNO + "',ROW_NUMBER()over( order by b.LotNO desc),'" + MUSER + @"',
|
|
a.LotNO,b.Quantity,b.Quantity*b.Amount as Amount,0,0,'" + MUSERNAME + @"'
|
|
,getdate(),'" + WorkPoint.TrimEnd(',') + @"'
|
|
FROM ICSContainer d
|
|
LEFT JOIN dbo.ICSContainerLot a ON a.ContainerID=d.ID
|
|
left JOIN dbo.ICSInventoryLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory c ON c.InvCode=b.InvCode AND a.WorkPoint=c.WorkPoint
|
|
WHERE d.ID IN(" + JsonData.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取箱号主表信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetCartonGridJson(string queryJson, ref Pagination jqgridparam, string WorkPoint)
|
|
{
|
|
string sql = string.Empty;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
if (queryParam["Type"].ToString() == "ContainerType01")
|
|
{
|
|
// sql = @"SELECT DISTINCT a.ContainerCode,a.ID+d.InvCode as ID,
|
|
//a.MUSERName, a.MTIME,Dil.F_ItemName,d.InvCode,d.InvName,d.InvStd
|
|
//FROM ICSContainer a
|
|
//inner JOIN dbo.ICSContainerLot c ON a.ID=c.ContainerID and a.WorkPoint=c.WorkPoint
|
|
//LEFT join dbo.ICSInventoryLot lot on c.LotNo=lot.LotNo and a.WorkPoint=lot.WorkPoint and lot.Type='200'
|
|
//left join Sys_SRM_ItemsDetail Dil on F_ItemId='6230217e-4413-4427-9bec-c67ba789eca9' and F_EnabledMark='1' and a.ContainerType=Dil.F_ItemCode
|
|
//LEFT JOIN ICSInventory d ON d.InvCode=lot.InvCode AND d.WorkPoint=lot.WorkPoint
|
|
//WHERE
|
|
// a.ID not IN
|
|
// (SELECT b.ContainerID FROM dbo.ICSASNDETAIL a inner JOIN dbo.ICSContainerLot b ON a.LotNO =b.LotNO AND a.WorkPoint=b.WorkPoint)
|
|
//and a.EATTRIBUTE1='1' and a.ContainerID=''
|
|
|
|
|
|
//";
|
|
sql = @"SELECT DISTINCT a.ContainerCode,a.ID+d.InvCode as ID,
|
|
a.MUSERName, a.MTIME,Dil.F_ItemName,d.InvCode,d.InvName,d.InvStd
|
|
FROM ICSContainer a
|
|
inner JOIN dbo.ICSContainerLot c ON a.ID=c.ContainerID and a.WorkPoint=c.WorkPoint
|
|
LEFT join dbo.ICSInventoryLot lot on c.LotNo=lot.LotNo and a.WorkPoint=lot.WorkPoint and lot.Type='200'
|
|
left join Sys_SRM_ItemsDetail Dil on F_ItemId='6230217e-4413-4427-9bec-c67ba789eca9' and F_EnabledMark='1' and a.ContainerType=Dil.F_ItemCode
|
|
LEFT JOIN ICSInventory d ON d.InvCode=lot.InvCode AND d.WorkPoint=lot.WorkPoint
|
|
LEFT JOIN (SELECT b.ContainerID FROM dbo.ICSASNDETAIL a inner JOIN dbo.ICSContainerLot b ON a.LotNO =b.LotNO AND a.WorkPoint=b.WorkPoint) e ON a.id=e.ContainerID
|
|
WHERE
|
|
e.ContainerID IS null
|
|
and a.EATTRIBUTE1='1' and a.ContainerID=''
|
|
|
|
|
|
";
|
|
}
|
|
else
|
|
{
|
|
// sql = @"SELECT DISTINCT a.ContainerCode,a.ID,
|
|
//a.MUSERName, a.MTIME,Dil.F_ItemName
|
|
//FROM ICSContainer a
|
|
//left join ICSContainer xz on a.ID=xz.ContainerID and a.WorkPoint=xz.WorkPoint
|
|
//inner JOIN dbo.ICSContainerLot c ON xz.ID=c.ContainerID and xz.WorkPoint=c.WorkPoint
|
|
//LEFT join dbo.ICSInventoryLot lot on c.LotNo=lot.LotNo and a.WorkPoint=lot.WorkPoint and lot.Type='200'
|
|
//left join Sys_SRM_ItemsDetail Dil on F_ItemId='6230217e-4413-4427-9bec-c67ba789eca9' and F_EnabledMark='1' and a.ContainerType=Dil.F_ItemCode
|
|
//WHERE
|
|
// xz.ID not IN
|
|
// (SELECT b.ContainerID FROM dbo.ICSASNDETAIL a inner JOIN dbo.ICSContainerLot b ON a.LotNO =b.LotNO AND a.WorkPoint=b.WorkPoint)
|
|
//and
|
|
//a.EATTRIBUTE1='1'
|
|
|
|
|
|
//";
|
|
sql = @" SELECT DISTINCT a.ContainerCode,a.ID,
|
|
a.MUSERName, a.MTIME,Dil.F_ItemName
|
|
FROM ICSContainer a
|
|
left join ICSContainer xz on a.ID=xz.ContainerID and a.WorkPoint=xz.WorkPoint
|
|
inner JOIN dbo.ICSContainerLot c ON xz.ID=c.ContainerID and xz.WorkPoint=c.WorkPoint
|
|
LEFT join dbo.ICSInventoryLot lot on c.LotNo=lot.LotNo and a.WorkPoint=lot.WorkPoint and lot.Type='200'
|
|
left join Sys_SRM_ItemsDetail Dil on F_ItemId='6230217e-4413-4427-9bec-c67ba789eca9' and F_EnabledMark='1' and a.ContainerType=Dil.F_ItemCode
|
|
LEFT JOIN (SELECT b.ContainerID FROM dbo.ICSASNDETAIL a inner JOIN dbo.ICSContainerLot b ON a.LotNO =b.LotNO AND a.WorkPoint=b.WorkPoint) e ON xz.ID=e.ContainerID
|
|
WHERE
|
|
e.ContainerID IS NULL AND a.EATTRIBUTE1='1'
|
|
|
|
|
|
";
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
//if (queryParam["Type"].ToString()== "ContainerType01")
|
|
//{
|
|
// sql += " and a.ContainerID ='' ";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CartonNo"].ToString()))
|
|
{
|
|
sql += " and a.ContainerCode like '%" + queryParam["CartonNo"].ToString() + "%' ";
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["OrderNo"].ToString()))
|
|
//{
|
|
// sql += " and b.OrderNO like '%" + queryParam["OrderNo"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["TransNo"].ToString()))
|
|
//{
|
|
// sql += " and b.TransNO like '%" + queryParam["TransNO"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["TransLine"].ToString()))
|
|
//{
|
|
// sql += " and b.TransLine like '%" + queryParam["TransLine"].ToString() + "%' ";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and a.EATTRIBUTE8 = '" + queryParam["VenCode"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Type"].ToString()))
|
|
{
|
|
sql += " and a.ContainerType = '" + queryParam["Type"].ToString() + "' ";
|
|
}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint='" + WorkPoint + "'";
|
|
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 箱号子表查询
|
|
/// </summary>
|
|
/// <param name="CartonNo"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetCartonSubGridJson(string CartonNo, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.LotNO, a.ID,c.ItemCODE,d.INVNAME,c.VenderLotNO,c.LOTQTY,
|
|
c.TYPE,b.EATTRIBUTE8,c.ORDERNO,c.TransNO,c.TransLine,d.INVDESC,d.INVTYPE,e.MEMO,d.INVSTD,d.INVPARSETYPE
|
|
FROM dbo.ICSITEMLot2Carton a
|
|
LEFT JOIN dbo.ICSCarton b ON a.CartonNO=b.CartonNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSITEMLot c ON a.LotNo_ID=c.ID AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON c.ItemCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSPO_PoMain e ON c.TransNO=e.POCode AND c.TransLine =e.PORow AND a.WorkPoint=e.WorkPoint
|
|
WHERE a.CartonNO='" + CartonNo + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetASNListGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string ParentId = "";
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sqlAccount = string.Empty;
|
|
// string sql = @"SELECT a.ASNDETAILID, a.STNO,a.ITEMCODE,d.INVNAME,d.INVTYPE,d.INVDESC,h.ReMark,a.LOTNO,b.VenderLotNO,
|
|
//b.LOTQTY,c.CartonNO,e.VENDORCODE,f.cVenName,
|
|
//b.TransNO,b.TransLine,g.F_RealName,CONVERT(NVARCHAR(50),e.CREATETIME,23) as CREATETIME,d.INVSTD,d.INVPARSETYPE,case
|
|
//when a.RECEIVEQTY is null then '否'
|
|
//else '是'
|
|
//end as IsReceive
|
|
//,w.WorkPointName,w.WorkPointCode
|
|
//FROM dbo.ICSASNDETAIL a
|
|
//LEFT JOIN dbo.ICSITEMLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
//LEFT JOIN dbo.ICSITEMLot2Carton c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
//LEFT JOIN dbo.ICSINVENTORY d ON a.ITEMCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
//LEFT JOIN dbo.ICSASN e ON a.STNO=e.STNO AND a.WorkPoint=e.WorkPoint
|
|
//LEFT JOIN dbo.ICSVendor f ON e.VENDORCODE=f.cVenCode AND a.WorkPoint=f.WorkPoint
|
|
//LEFT JOIN dbo.Sys_SRM_User g ON e.LOGUSER=g.F_Account and g.F_Location=a.WorkPoint
|
|
//LEFT JOIN dbo.ICSPO_PoMain h ON b.TransNO=h.POCode AND b.TransLine=h.PORow AND a.WorkPoint=h.WorkPoint
|
|
//LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
//where 1=1";
|
|
string sql = @"SELECT DISTINCT a.ID, a.ASNCode,b.InvCode,d.INVNAME,d.INVDESC,a.LOTNO,exc.BatchCode,
|
|
b.Quantity,c.ContainerID,e.VenCode,f.VenName,
|
|
det.TransCode,det.TransSequence,g.F_RealName,CONVERT(NVARCHAR(50),e.MTIME,23) as CREATETIME,d.INVSTD,case
|
|
when a.DNQuantity is null then '否'
|
|
else '是'
|
|
end as IsReceive
|
|
,w.WorkPointName,w.WorkPointCode,CAST(ISNULL(II.repairqty,0) AS DECIMAL(18,3)) AS RepairQty,CAST(ISNULL(cc.NGQTY,0) AS DECIMAL(18,3))as NGQTY,CAST(ISNULL(cc.YLQTY,0) AS DECIMAL(18,3)) as YLQTY
|
|
FROM dbo.ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLotDetail det ON b.LotNO=det.LotNo AND b.WorkPoint=det.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON b.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSExtension exc ON b.ExtensionID=exc.ID
|
|
LEFT JOIN dbo.ICSASN e ON a.ASNCode=e.ASNCode AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor f ON e.VenCode=f.VenCode AND a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.Sys_SRM_User g ON e.VenCode=g.F_Account and g.F_Location=a.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder h ON det.TransCode=h.POCode AND det.TransSequence=h.Sequence AND a.WorkPoint=h.WorkPoint
|
|
LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
LEFT JOIN ( SELECT c.TransCode,c.TransSequence,
|
|
(SUM(ISNULL(a.Quantity, 0)) - SUM(ISNULL(a.DNQuantity, 0))) AS repairqty,a.WorkPoint
|
|
FROM ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LOTNO = b.LotNO AND a.WorkPoint = b.WorkPoint AND a.Quantity IS NOT NULL
|
|
LEFT JOIN dbo.ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint
|
|
GROUP BY c.TransCode,c.TransSequence,a.WorkPoint
|
|
) II ON h.POCode = II.TransCode AND h.Sequence = II.TransSequence AND h.WorkPoint = II.WorkPoint
|
|
left join (
|
|
|
|
select c.TransCode,c.TransSequence,sum(isnull(a.UnqualifiedQuantity,0)) NGQTY,sum(isnull(a.Quantity,0)) YLQTY,a.WorkPoint from ICSINSPECTION a
|
|
left join dbo.ICSInventoryLot b on a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint
|
|
group by c.TransCode,c.TransSequence,b.EATTRIBUTE2,a.WorkPoint
|
|
having b.EATTRIBUTE2 is null) cc on h.POCode=cc.TransCode and h.Sequence=cc.TransSequence AND h.WorkPoint=cc.WorkPoint
|
|
where 1=1 ";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["STNO"].ToString()))
|
|
{
|
|
sql += " and a.AsnCode like '%" + queryParam["STNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and e.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and f.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BeginDate"].ToString()))
|
|
{
|
|
sql += " and e.MTIME >= '" + queryParam["BeginDate"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
sql += " and e.MTIME <= '" + queryParam["EndDate"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenderLotNO"].ToString()))
|
|
{
|
|
sql += " and exc.BatchCode = '%" + queryParam["VenderLotNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["IsReceive"].ToString()))
|
|
{
|
|
string IsReceive = queryParam["IsReceive"].ToString();
|
|
if (IsReceive == "1")
|
|
{
|
|
sql += " and case when a.DNQuantity is null then '否'else '是'end ='是' ";
|
|
}
|
|
else if (IsReceive == "2")
|
|
{
|
|
sql += " and case when a.DNQuantity is null then '否'else '是'end ='否' ";
|
|
}
|
|
}
|
|
}
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode.Contains("Vendor"))
|
|
{
|
|
sql += " and e.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode + "'";
|
|
}
|
|
//组织架构代码
|
|
ParentId = SqlHelper.Organize_F_ParentId(NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode);
|
|
if (!string.IsNullOrWhiteSpace(ParentId) && ParentId != "0" && NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "Vendor")
|
|
{
|
|
return SqlHelper.FindTablePageBySql_OtherTemp(sql.ToString(), sql, ParentId, parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
else
|
|
{
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
}
|
|
|
|
public DataTable GetASNListExport(string keyVaule)
|
|
{
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT DISTINCT a.ASNCode AS 送货单号,b.InvCode AS 物料编码,d.INVNAME AS 物料名称,d.InvStd AS 规格型号,case
|
|
when a.DNQuantity is null then '否'
|
|
else '是'
|
|
end as 是否到货,a.LOTNO AS 条码,exc.BatchCode AS 条码批次,
|
|
b.Quantity AS 数量,CAST(ISNULL(II.repairqty,0) AS DECIMAL(18,3)) AS 补货数量,CAST(ISNULL(cc.YLQTY,0) AS DECIMAL(18,3)) as 合格数量
|
|
,CAST(ISNULL(cc.NGQTY,0) AS DECIMAL(18,3))as 不合格数量
|
|
,c.ContainerID AS 箱号,e.VenCode AS 供应商编码,f.VenName AS 供应商名称,
|
|
det.TransCode AS 采购单号,det.TransSequence AS 采购单行,g.F_RealName AS 维护人,CONVERT(NVARCHAR(50),e.MTIME,23) as 维护时间
|
|
,w.WorkPointName AS 组织名称,w.WorkPointCode AS 组织号
|
|
FROM dbo.ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLotDetail det ON b.LotNO=det.LotNo AND b.WorkPoint=det.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON b.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSExtension exc ON b.ExtensionID=exc.ID
|
|
LEFT JOIN dbo.ICSASN e ON a.ASNCode=e.ASNCode AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor f ON e.VenCode=f.VenCode AND a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.Sys_SRM_User g ON e.VenCode=g.F_Account and g.F_Location=a.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder h ON det.TransCode=h.POCode AND det.TransSequence=h.Sequence AND a.WorkPoint=h.WorkPoint
|
|
LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
LEFT JOIN ( SELECT c.TransCode,c.TransSequence,
|
|
(SUM(ISNULL(a.Quantity, 0)) - SUM(ISNULL(a.DNQuantity, 0))) AS repairqty,a.WorkPoint
|
|
FROM ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LOTNO = b.LotNO AND a.WorkPoint = b.WorkPoint AND a.Quantity IS NOT NULL
|
|
LEFT JOIN dbo.ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint
|
|
GROUP BY c.TransCode,c.TransSequence,a.WorkPoint
|
|
) II ON h.POCode = II.TransCode AND h.Sequence = II.TransSequence AND h.WorkPoint = II.WorkPoint
|
|
left join (
|
|
|
|
select c.TransCode,c.TransSequence,sum(isnull(a.UnqualifiedQuantity,0)) NGQTY,sum(isnull(a.Quantity,0)) YLQTY,a.WorkPoint from ICSINSPECTION a
|
|
left join dbo.ICSInventoryLot b on a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint
|
|
group by c.TransCode,c.TransSequence,b.EATTRIBUTE2,a.WorkPoint
|
|
having b.EATTRIBUTE2 is null) cc on h.POCode=cc.TransCode and h.Sequence=cc.TransSequence AND h.WorkPoint=cc.WorkPoint
|
|
where 1=1 ";
|
|
sql += " and a.ID in (" + keyVaule + ")";
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetASNListExport(string ORDERNO, string STNO, string BeginDate, string EndDate, string VenCode, string VenName, string VenderLotNO, string IsReceive)
|
|
{
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT DISTINCT a.ASNCode AS 送货单号,b.InvCode AS 物料编码,d.INVNAME AS 物料名称,d.InvStd AS 规格型号,case
|
|
when a.DNQuantity is null then '否'
|
|
else '是'
|
|
end as 是否到货,a.LOTNO AS 条码,exc.BatchCode AS 条码批次,
|
|
b.Quantity AS 数量,CAST(ISNULL(II.repairqty,0) AS DECIMAL(18,3)) AS 补货数量,CAST(ISNULL(cc.YLQTY,0) AS DECIMAL(18,3)) as 合格数量
|
|
,CAST(ISNULL(cc.NGQTY,0) AS DECIMAL(18,3))as 不合格数量
|
|
,c.ContainerID AS 箱号,e.VenCode AS 供应商编码,f.VenName AS 供应商名称,
|
|
det.TransCode AS 采购单号,det.TransSequence AS 采购单行,g.F_RealName AS 维护人,CONVERT(NVARCHAR(50),e.MTIME,23) as 维护时间
|
|
,w.WorkPointName AS 组织名称,w.WorkPointCode AS 组织号
|
|
FROM dbo.ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLotDetail det ON b.LotNO=det.LotNo AND b.WorkPoint=det.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON b.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSExtension exc ON b.ExtensionID=exc.ID
|
|
LEFT JOIN dbo.ICSASN e ON a.ASNCode=e.ASNCode AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor f ON e.VenCode=f.VenCode AND a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.Sys_SRM_User g ON e.VenCode=g.F_Account and g.F_Location=a.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder h ON det.TransCode=h.POCode AND det.TransSequence=h.Sequence AND a.WorkPoint=h.WorkPoint
|
|
LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
LEFT JOIN ( SELECT c.TransCode,c.TransSequence,
|
|
(SUM(ISNULL(a.Quantity, 0)) - SUM(ISNULL(a.DNQuantity, 0))) AS repairqty,a.WorkPoint
|
|
FROM ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LOTNO = b.LotNO AND a.WorkPoint = b.WorkPoint AND a.Quantity IS NOT NULL
|
|
LEFT JOIN dbo.ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint
|
|
GROUP BY c.TransCode,c.TransSequence,a.WorkPoint
|
|
) II ON h.POCode = II.TransCode AND h.Sequence = II.TransSequence AND h.WorkPoint = II.WorkPoint
|
|
left join (
|
|
|
|
select c.TransCode,c.TransSequence,sum(isnull(a.UnqualifiedQuantity,0)) NGQTY,sum(isnull(a.Quantity,0)) YLQTY,a.WorkPoint from ICSINSPECTION a
|
|
left join dbo.ICSInventoryLot b on a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLotDetail c ON b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint
|
|
group by c.TransCode,c.TransSequence,b.EATTRIBUTE2,a.WorkPoint
|
|
having b.EATTRIBUTE2 is null) cc on h.POCode=cc.TransCode and h.Sequence=cc.TransSequence AND h.WorkPoint=cc.WorkPoint
|
|
where 1=1 ";
|
|
if (!string.IsNullOrWhiteSpace(ORDERNO))
|
|
sql += " and a.ORDERNO like '%" + ORDERNO + "%'";
|
|
if (!string.IsNullOrWhiteSpace(STNO))
|
|
sql += " and a.ASNCode like '%" + STNO + "%'";
|
|
if (!string.IsNullOrWhiteSpace(BeginDate))
|
|
sql += " and e.MTIME >= '" + BeginDate + "'";
|
|
if (!string.IsNullOrWhiteSpace(BeginDate))
|
|
sql += " and e.MTIME <= '" + EndDate + "'";
|
|
if (!string.IsNullOrWhiteSpace(VenCode))
|
|
sql += " and e.VenCode like '%" + VenCode + "%'";
|
|
if (!string.IsNullOrWhiteSpace(VenCode))
|
|
sql += " and f.VenName like '%" + VenName + "%'";
|
|
if (!string.IsNullOrWhiteSpace(VenderLotNO))
|
|
sql += " and exc.BatchCode like '%" + VenderLotNO + "%'";
|
|
if (IsReceive == "1")
|
|
{
|
|
sql += " and case when a.DNQuantity is null then '否'else '是'end ='是' ";
|
|
}
|
|
else if (IsReceive == "2")
|
|
{
|
|
sql += " and case when a.DNQuantity is null then '否'else '是'end ='否' ";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode.Contains("Vendor"))
|
|
{
|
|
sql += " and e.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode + "'";
|
|
}
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public string CheckIsAll(string STNO,string WorkPoint)
|
|
{
|
|
string sql = @"SELECT * FROM dbo.ICSASNDetail WHERE ASNCode='" + STNO + "' AND ISNULL(DNQuantity,0)<>0";
|
|
sql += " and WorkPoint in('"+ WorkPoint + "')";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return "0";
|
|
}
|
|
else
|
|
{
|
|
return "1";
|
|
}
|
|
}
|
|
public DataTable GetLoadShowForColumnByASN(string WorkPoint)
|
|
{
|
|
//string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
|
|
string sql = @"
|
|
select * from ICSColumnEnable where TableCode='icsasn' and WorkPoint='" + WorkPoint + "' order by cast(code as int) ";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
|
|
}
|
|
|
|
public DataTable SelectICSColumnEnableForLotEnablebyASN(string WorkPoint)
|
|
{
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @" select ColumnCode from ICSColumnEnable
|
|
where Enable='0' and TableCode='icsasn' and WorkPoint='" + WorkPoint + "' order by cast(Code as int)";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
#region 送货单退回
|
|
public int UpdateBackRemark(string STNO, string ReturnRemark, string WorkPoint)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE ICSASN SET EATTRIBUTE2 = '{0}',STATUS='4' WHERE ASNCode ='{1}'";
|
|
sql = string.Format(sql, ReturnRemark, STNO);
|
|
return SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
public string GetICSASNCode(string RoleEnCode, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
string Date = DateTime.Now.ToString("yy");
|
|
string Pre = "DN" + RoleEnCode + Date;
|
|
string ASNCode = GetSerialCode(WorkPoint, "ICSASN", "STNO", Pre, 5);
|
|
return ASNCode;
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetLotByContainer(string Value, string WorkPoint)
|
|
{
|
|
Value = Value.TrimEnd(',');
|
|
string sql = @"
|
|
WITH ICSBomALL AS
|
|
(
|
|
SELECT
|
|
ContainerCode AS TContainerCode,
|
|
ContainerCode AS PContainerCode,
|
|
ContainerCode AS ContainerCode,
|
|
ID,
|
|
ContainerID,
|
|
0 AS [Level],
|
|
CAST(1 AS nvarchar(MAX)) AS SortSeq,
|
|
CAST('00001' AS nvarchar(MAX)) AS Sort
|
|
FROM ICSContainer
|
|
WHERE ContainerCode in ({0})
|
|
UNION ALL
|
|
SELECT
|
|
b.TContainerCode,
|
|
b.ContainerCode AS PContainerCode,
|
|
a.ContainerCode,
|
|
a.ID,
|
|
a.ContainerID,
|
|
b.[Level]+1 AS [Level],
|
|
CAST(b.SortSeq AS nvarchar(MAX))+'.'+CAST(row_number() over (order by a.ContainerCode) AS nvarchar(MAX)) AS SortSeq,
|
|
CAST(b.Sort+'.'+REPLICATE('0',5-len(row_number() over (order by a.ContainerCode)))+CAST(row_number() over (order by a.ContainerCode) AS nvarchar(MAX)) AS nvarchar(MAX)) AS Sort
|
|
FROM
|
|
ICSContainer a
|
|
INNER JOIN ICSBomALL b ON a.ID=b.ContainerID
|
|
)
|
|
SELECT a.ID,
|
|
con.ContainerCode,
|
|
con.ContainerName,
|
|
a.LotNo,
|
|
lotD.TransCode,
|
|
lotD.TransSequence,
|
|
a.InvCode,
|
|
inv.InvName,
|
|
inv.InvStd,
|
|
inv.InvUnit,
|
|
inv.InvDesc,
|
|
a.Quantity AS Quantity,
|
|
a.Quantity*(a.Amount/a.Quantity) AS Amount,
|
|
'' AS WHCode,
|
|
'' AS WHName,
|
|
'' AS LocationCode,
|
|
'' AS LocationName,
|
|
ext.BatchCode AS BatchCode,
|
|
inv.AmountUnit,
|
|
ext.ID AS ExtensionID,
|
|
ext.ProjectCode,
|
|
ext.Version,
|
|
--ext.BatchCode,
|
|
ext.Brand,
|
|
ext.cFree1,
|
|
ext.cFree2,
|
|
ext.cFree3,
|
|
ext.cFree4,
|
|
ext.cFree5,
|
|
ext.cFree6,
|
|
ext.cFree7,
|
|
ext.cFree8,
|
|
ext.cFree9,
|
|
ext.cFree10,
|
|
a.MUSER AS [User],
|
|
a.MTIME AS [MTime],
|
|
a.WorkPoint
|
|
FROM ICSInventoryLot a
|
|
left join dbo.ICSInventoryLotDetail lotD on a.LotNo=lotD.LotNo and a.WorkPoint=lotD.WorkPoint
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
|
|
LEFT JOIN ICSContainerLot conlot ON a.LotNo=conlot.LotNo AND a.WorkPoint=conlot.WorkPoint
|
|
|
|
LEFT JOIN ICSContainer con ON conlot.ContainerID=con.ID AND conlot.WorkPoint=con.WorkPoint
|
|
|
|
LEFT JOIN ICSBomALL bom ON bom.ID=con.ContainerID
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
|
|
WHERE bom.ContainerCode in ({0}) AND a.WorkPoint='{1}'
|
|
UNION ALL
|
|
SELECT a.ID,
|
|
con.ContainerCode,
|
|
con.ContainerName,
|
|
a.LotNo,
|
|
lotD.TransCode,
|
|
lotD.TransSequence,
|
|
a.InvCode,
|
|
inv.InvName,
|
|
inv.InvStd,
|
|
inv.InvUnit,
|
|
inv.InvDesc,
|
|
a.Quantity AS Quantity,
|
|
a.Quantity*(a.Amount/a.Quantity) AS Amount,
|
|
'' AS WHCode,
|
|
'' AS WHName,
|
|
'' AS LocationCode,
|
|
'' AS LocationName,
|
|
ext.BatchCode AS BatchCode,
|
|
inv.AmountUnit,
|
|
ext.ID AS ExtensionID,
|
|
ext.ProjectCode,
|
|
ext.Version,
|
|
--ext.BatchCode,
|
|
ext.Brand,
|
|
ext.cFree1,
|
|
ext.cFree2,
|
|
ext.cFree3,
|
|
ext.cFree4,
|
|
ext.cFree5,
|
|
ext.cFree6,
|
|
ext.cFree7,
|
|
ext.cFree8,
|
|
ext.cFree9,
|
|
ext.cFree10,
|
|
a.MUSER AS [User],
|
|
a.MTIME AS [MTime],
|
|
a.WorkPoint
|
|
FROM ICSInventoryLot a
|
|
left join dbo.ICSInventoryLotDetail lotD on a.LotNo=lotD.LotNo and a.WorkPoint=lotD.WorkPoint
|
|
INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
|
|
LEFT JOIN ICSContainerLot conlot ON a.LotNo=conlot.LotNo AND a.WorkPoint=conlot.WorkPoint
|
|
|
|
LEFT JOIN ICSContainer con ON conlot.ContainerID=con.ID AND conlot.WorkPoint=con.WorkPoint
|
|
|
|
LEFT JOIN ICSBomALL bom ON bom.ID=conlot.ContainerID
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
|
|
WHERE bom.ContainerCode in ({0}) AND a.WorkPoint='{1}'
|
|
";
|
|
sql = string.Format(sql, Value, WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
|
|
}
|
|
|
|
public string SaveICSASNAndDetail(string ICSASN,string WorkPoint)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
string str1 = "";
|
|
string firstPOCode = null;
|
|
string ID = Guid.NewGuid().ToString();
|
|
string Status;
|
|
#region [获取送货单配置信息,判断状态]
|
|
string F_ItemName = SqlHelper.GetSHDZDSHItemsDetails("ASNAudit", WorkPoint);
|
|
if (!string.IsNullOrWhiteSpace(F_ItemName))
|
|
{
|
|
Status = "2";
|
|
}
|
|
else
|
|
{
|
|
Status = "0";
|
|
}
|
|
#endregion
|
|
|
|
string ISManger = SqlHelper.GetSHDZDSHItemsDetails("ASNISManger", WorkPoint);
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSASN);
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
//创建送货单主表
|
|
sql += @" INSERT INTO dbo.ICSASN
|
|
( ID ,ASNCode ,VenCode,Status,
|
|
MUSER ,MUSERName ,MTIME,WorkPoint,EATTRIBUTE1)
|
|
VALUES ( newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','{6}')";
|
|
sql = string.Format(sql, jo["ASNCode"].ToString(), jo["VenCode"].ToString(), Status, MUSER, MUSERNAME, jo["WorkPoint"].ToString(), jo["EATTRIBUTE1"].ToString());
|
|
|
|
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["Detail"].ToString());
|
|
foreach (var detail in resdetail)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(ISManger))
|
|
{
|
|
string poCode = (string)detail["POCode"];
|
|
if (firstPOCode == null)
|
|
{
|
|
firstPOCode = poCode;
|
|
}
|
|
else if (firstPOCode != poCode)
|
|
{
|
|
msg = "本次送货单条码存在多订单,请分单做送货单!!";
|
|
break;
|
|
}
|
|
}
|
|
//创建送货单子表
|
|
JObject det = (JObject)detail;
|
|
sql += @" INSERT INTO dbo.ICSASNDetail
|
|
( ID ,ASNCode ,Sequence,LotNo,Quantity,Amount,DNQuantity,DNAmount,
|
|
MUSER ,MUSERName ,MTIME,WorkPoint)
|
|
VALUES ( newid(),'{0}','{1}','{2}','{3}','{4}',0,0,'{5}','{6}',getdate(),'{7}')";
|
|
sql = string.Format(sql, jo["ASNCode"].ToString(), det["Sequence"].ToString(), det["LotNo"].ToString(), det["Quantity"].ToString(), det["Amount"].ToString(), MUSER, MUSERNAME, jo["WorkPoint"].ToString());
|
|
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
if (string.IsNullOrWhiteSpace(msg))
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
public string UpdateICSASNAndDetail(string ICSASN)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
string idss = "";
|
|
string Code = "";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSASN);
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["Detail"].ToString());
|
|
foreach (var detail in resdetail)
|
|
{
|
|
Code = jo["ASNCode"].ToString();
|
|
JObject det = (JObject)detail;
|
|
//sql += @" update ICSASN set Status='1' where ASNCode='{1}'";
|
|
if (string.IsNullOrWhiteSpace(det["ZJID"].ToString()))
|
|
{
|
|
string DetailID = Guid.NewGuid().ToString();
|
|
sql += @"INSERT INTO dbo.ICSASNDetail
|
|
( ID ,ASNCode ,Sequence,LotNo,Quantity,Amount,DNQuantity,DNAmount,
|
|
MUSER ,MUSERName ,MTIME,WorkPoint)
|
|
VALUES ( '{0}','{1}','{2}','{3}','{4}','{5}',0,0,'{6}','{7}',getdate(),'{8}')";
|
|
sql = string.Format(sql, DetailID, jo["ASNCode"].ToString(), det["Sequence"].ToString(), det["LotNo"].ToString(), det["Quantity"].ToString(),
|
|
det["Amount"].ToString(), MUSER, MUSERNAME, jo["WorkPoint"].ToString());
|
|
idss += "'" + DetailID + "',";
|
|
}
|
|
else
|
|
{
|
|
idss += "'" + det["ZJID"].ToString() + "',";
|
|
}
|
|
}
|
|
}
|
|
sql += @"DELETE ICSASNDetail where ASNCode ='{0}' and id not in ({1})";
|
|
sql = string.Format(sql, Code, idss.Substring(0, idss.Length - 1));
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
public DataTable GetGridJsonUpload(string queryJson,string STNO, ref Pagination jqgridparam, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select b.InvCode,d.InvName ,b.BatchCode,b.BatchCodeNum,a.VenCode,e.VenName,c.FileName,c.CerateTime from dbo.ICSASN a
|
|
left join (select ASNCode,InvCode ,BatchCode,a.WorkPoint,sum(a.Quantity) as BatchCodeNum from dbo.ICSASNDetail a
|
|
left join dbo.ICSInventoryLot b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
left join dbo.ICSExtension c on b.ExtensionID=c.ID and b.WorkPoint=c.WorkPoint
|
|
group by a.ASNCode,b.InvCode,c.BatchCode,a.WorkPoint)b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSASNShippingReport c on a.ASNCode=c.ASNCode and b.InvCode=c.InvCode and b.BatchCode=c.BatchCode and c.IsEable='1'
|
|
left join dbo.ICSInventory d on b.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join dbo.ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
where a.ASNCode='{0}'
|
|
";
|
|
sql = string.Format(sql,STNO);
|
|
//if (!string.IsNullOrWhiteSpace(queryJson))
|
|
//{
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["CartonNo"].ToString()))
|
|
// {
|
|
// sql += " and a.ContainerID like '%" + queryParam["CartonNo"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
// {
|
|
// sql += " and a.EATTRIBUTE8 = '" + queryParam["VenCode"].ToString() + "' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["Type"].ToString()))
|
|
// {
|
|
// sql += " and a.ContainerType = '" + queryParam["Type"].ToString() + "' ";
|
|
// }
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
// sql += " and a.WorkPoint='" + WorkPoint + "'";
|
|
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
public DataTable GetGridJsonUpload2(string queryJson, string STNO, ref Pagination jqgridparam, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select b.InvCode,d.InvName ,b.BatchCode,b.BatchCodeNum,a.VenCode,e.VenName,c.FileName,c.CerateTime from dbo.ICSOASN a
|
|
left join (select OASNCode,InvCode ,BatchCode,a.WorkPoint,sum(a.Quantity) as BatchCodeNum from dbo.ICSOASNDetail a
|
|
left join dbo.ICSInventoryLot b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
left join dbo.ICSExtension c on b.ExtensionID=c.ID and b.WorkPoint=c.WorkPoint
|
|
group by a.OASNCode,b.InvCode,c.BatchCode,a.WorkPoint)b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSASNShippingReport c on a.OASNCode=c.ASNCode and b.InvCode=c.InvCode and b.BatchCode=c.BatchCode and c.IsEable='1'
|
|
left join dbo.ICSInventory d on b.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join dbo.ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
where a.OASNCode='{0}'
|
|
";
|
|
sql = string.Format(sql, STNO);
|
|
//if (!string.IsNullOrWhiteSpace(queryJson))
|
|
//{
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["CartonNo"].ToString()))
|
|
// {
|
|
// sql += " and a.ContainerID like '%" + queryParam["CartonNo"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
// {
|
|
// sql += " and a.EATTRIBUTE8 = '" + queryParam["VenCode"].ToString() + "' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["Type"].ToString()))
|
|
// {
|
|
// sql += " and a.ContainerType = '" + queryParam["Type"].ToString() + "' ";
|
|
// }
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
// sql += " and a.WorkPoint='" + WorkPoint + "'";
|
|
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
public string UpLoadFile(string STNO,string InvCode, string BatchCode, string VenCode, string BatchCodeNum, string FileName, string PathName)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql += @"update ICSASNShippingReport set IsEable='0' where ASNCode='{0}' and InvCode='{1}' and BatchCode='{2}' and EATTRIBUTE1='1'";
|
|
sql += @"
|
|
INSERT INTO ICSASNShippingReport
|
|
( ID, ASNCode, InvCode, BatchCode, BatchCodeQty, VenCode, FileName, FilePath, CerateTime, CreateUser,IsEable,EATTRIBUTE1)
|
|
VALUES ( newid(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}',getdate(),'{7}','1','1')";
|
|
sql = string.Format(sql, STNO, InvCode, BatchCode, BatchCodeNum, VenCode, FileName, PathName, MUSER);
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "上传失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
public string UpLoadFile2(string STNO, string InvCode, string BatchCode, string VenCode, string BatchCodeNum, string FileName, string PathName)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql += @"update ICSASNShippingReport set IsEable='0' where ASNCode='{0}' and InvCode='{1}' and BatchCode='{2}' and EATTRIBUTE1='2'";
|
|
sql += @"
|
|
INSERT INTO ICSASNShippingReport
|
|
( ID, ASNCode, InvCode, BatchCode, BatchCodeQty, VenCode, FileName, FilePath, CerateTime, CreateUser,IsEable,EATTRIBUTE1)
|
|
VALUES ( newid(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}',getdate(),'{7}','1','2')";
|
|
sql = string.Format(sql, STNO, InvCode, BatchCode, BatchCodeNum, VenCode, FileName, PathName, MUSER);
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "上传失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
public string CheckIsASNAudit()
|
|
{
|
|
string F_ItemName = SqlHelper.GetSHDZDSHItemsDetails("ASNAudit","");
|
|
if (!string.IsNullOrWhiteSpace(F_ItemName))
|
|
{
|
|
return "0";
|
|
}
|
|
else
|
|
{
|
|
return "1";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public bool ISEableReport(string Code ,string VenCode, string Type)
|
|
{
|
|
bool ISEableReport = true;
|
|
string sqlSeach = "";
|
|
string sql = @"SELECT * FROM Sys_SRM_ItemsDetail a
|
|
LEFT JOIN Sys_SRM_Items b ON a.F_ItemId = b.F_Id
|
|
WHERE b.F_EnCode = 'ANSReportEable' and a.F_EnabledMark = '1' and F_ItemCode = '"+VenCode+"'";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt.Rows.Count >0)
|
|
{
|
|
if (Type == "1")
|
|
{
|
|
sqlSeach = @" select b.InvCode,d.InvName ,b.BatchCode,b.BatchCodeNum,a.VenCode,e.VenName,c.FileName,c.CerateTime from dbo.ICSASN a
|
|
left join (select ASNCode,InvCode ,BatchCode,a.WorkPoint,sum(a.Quantity) as BatchCodeNum from dbo.ICSASNDetail a
|
|
left join dbo.ICSInventoryLot b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
left join dbo.ICSExtension c on b.ExtensionID=c.ID and b.WorkPoint=c.WorkPoint
|
|
group by a.ASNCode,b.InvCode,c.BatchCode,a.WorkPoint)b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSASNShippingReport c on a.ASNCode=c.ASNCode and b.InvCode=c.InvCode and b.BatchCode=c.BatchCode and c.IsEable='1'
|
|
left join dbo.ICSInventory d on b.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join dbo.ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
where a.ASNCode='" + Code + "' ";
|
|
sqlSeach += @" select * from ICSASNShippingReport where ASNCode='" + Code + "' and IsEable='1' and EATTRIBUTE1='1'";
|
|
}
|
|
else
|
|
{
|
|
sqlSeach = @" select b.InvCode,d.InvName ,b.BatchCode,b.BatchCodeNum,a.VenCode,e.VenName,c.FileName,c.CerateTime from dbo.ICSOASN a
|
|
left join (select OASNCode,InvCode ,BatchCode,a.WorkPoint,sum(a.Quantity) as BatchCodeNum from dbo.ICSOASNDetail a
|
|
left join dbo.ICSInventoryLot b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
left join dbo.ICSExtension c on b.ExtensionID=c.ID and b.WorkPoint=c.WorkPoint
|
|
group by a.OASNCode,b.InvCode,c.BatchCode,a.WorkPoint)b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSASNShippingReport c on a.OASNCode=c.ASNCode and b.InvCode=c.InvCode and b.BatchCode=c.BatchCode and c.IsEable='1'
|
|
left join dbo.ICSInventory d on b.InvCode=d.InvCode and a.WorkPoint=d.WorkPoint
|
|
left join dbo.ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
where a.OASNCode='" + Code + "' ";
|
|
sqlSeach += @" select * from ICSASNShippingReport where ASNCode='" + Code + "' and IsEable='1' and EATTRIBUTE1='2'";
|
|
}
|
|
DataSet ds = SqlHelper.GetDataSetBySql(sqlSeach);
|
|
if (ds.Tables[0].Rows.Count!= ds.Tables[1].Rows.Count)
|
|
{
|
|
ISEableReport = false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return ISEableReport;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 获取组织号信息对应认证资料
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetVendorBYQcc()
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
string sql = @" select '' as WorkPointCode,'' as WorkPointName
|
|
union all
|
|
SELECT distinct (b.WorkPointCode),b.WorkPointName FROM Sys_SRM_User a
|
|
LEFT JOIN Sys_WorkPoint b ON a.F_Location=b.WorkPointCode where b.WorkPointCode is not null";
|
|
//if (role != "admin")
|
|
//{
|
|
// sql += " and a.F_Location=" + WorkPoint + "";
|
|
//}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public string IsASNByCarton()
|
|
{
|
|
string F_ItemName = SqlHelper.GetSHDZDSHItemsDetails("ASNByCarton", "");
|
|
if (!string.IsNullOrWhiteSpace(F_ItemName))
|
|
{
|
|
return "0";
|
|
}
|
|
else
|
|
{
|
|
return "1";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|