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.
666 lines
39 KiB
666 lines
39 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.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
|
|
namespace NFine.Application
|
|
|
|
{
|
|
public class CreateItemLotApp : RepositoryFactory<ICSPO_PoMain>
|
|
{
|
|
|
|
public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID, a.POCode,a.Sequence,CONVERT(NVARCHAR(15),a.CreateDateTime,23) AS PODate,
|
|
a.ExtensionID,a.VenCode,ee.VenName,a.InvCode,cc.NGQTY AS RefuseLotQty,dd.returnqty AS BackLotQty,
|
|
b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(bb.LotQty,0) AS LotQty ,b.InvDesc,b.ClassCode,isnull(InQuantity,0) as InQuantity,a.WorkPoint as WorkPointCode
|
|
|
|
FROM dbo.ICSPurchaseOrder a
|
|
LEFT JOIN dbo.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
|
|
group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) bb
|
|
on a.POCode=bb.TransCode and a.Sequence=bb.TransSequence AND a.WorkPoint=bb.WorkPoint
|
|
left join (
|
|
select c.TransCode,c.TransSequence,sum(isnull(a.UnqualifiedQuantity,0)) NGQTY,a.WorkPoint
|
|
from ICSInspection a
|
|
left join ICSInventoryLot b on a.LotNo=b.LotNo
|
|
left join ICSInventoryLotDetail c on b.LotNo=c.LotNo
|
|
group by c.TransCode,c.TransSequence,a.WorkPoint) cc
|
|
on a.POCode=cc.TransCode and a.Sequence=cc.TransSequence AND a.WorkPoint=cc.WorkPoint
|
|
left join (select b.POCode,b.Sequence,sum(isnull(a.Quantity,0)) returnqty ,a.WorkPoint
|
|
FROM ICSDeliveryNotice a
|
|
left join ICSPurchaseOrder b on a.POID=b.ID
|
|
group by b.POCode,b.Sequence,a.DNType,a.WorkPoint having a.DNType='退货' ) dd
|
|
on a.POCode=dd.POCode and a.Sequence=dd.Sequence AND a.WorkPoint=dd.WorkPoint
|
|
left join ICSVendor ee on a.VenCode=ee.VenCode and a.WorkPoint=ee.WorkPoint
|
|
WHERE 1=1 AND a.ReleaseState = '1'";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ORDERNO"].ToString()))
|
|
{
|
|
sql += " and a.ExtensionID like '%" + queryParam["ORDERNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sql += " and a.POCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BeginDate"].ToString()))
|
|
{
|
|
sql += " and a.ReleaseDate >='" + queryParam["BeginDate"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
sql += " and a.ReleaseDate <='" + queryParam["EndDate"].ToString() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and ee.VenName like '%" + queryParam["VenName"].ToString() + "%'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].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 a.Quantity=ISNULL(bb.LOTQTY,0)-isnull(cc.NGQTY,0)-isnull(dd.returnqty,0)";
|
|
}
|
|
else
|
|
{
|
|
sql += " and a.Quantity>ISNULL(bb.LOTQTY,0)-isnull(cc.NGQTY,0)-isnull(dd.returnqty,0)";
|
|
}
|
|
}
|
|
}
|
|
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 == "Vendor")
|
|
{
|
|
sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID, a.OOCode,a.Sequence,CONVERT(NVARCHAR(15),a.CreateDateTime,23) AS PODate,a.OODetailID,
|
|
a.ExtensionID,a.VenCode,ee.VenName,a.InvCode,cc.NGQTY AS RefuseLotQty,dd.returnqty AS BackLotQty,
|
|
b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(bb.LotQty,0) AS LotQty ,b.InvDesc,b.ClassCode,isnull(InQuantity,0) as InQuantity,a.WorkPoint as WorkPointCode
|
|
FROM dbo.ICSOutsourcingOrder a
|
|
LEFT JOIN dbo.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
|
|
group by mm.TransCode,mm.TransSequence,ee.WorkPoint ) bb
|
|
on a.OOCode=bb.TransCode and a.Sequence=bb.TransSequence AND a.WorkPoint=bb.WorkPoint
|
|
left join (
|
|
select c.TransCode,c.TransSequence,sum(isnull(a.UnqualifiedQuantity,0)) NGQTY,a.WorkPoint
|
|
from ICSInspection a
|
|
left join ICSInventoryLot b on a.LotNo=b.LotNo
|
|
left join ICSInventoryLotDetail c on b.LotNo=c.LotNo
|
|
group by c.TransCode,c.TransSequence,a.WorkPoint) cc
|
|
on a.OOCode=cc.TransCode and a.Sequence=cc.TransSequence AND a.WorkPoint=cc.WorkPoint
|
|
left join (select b.OOCode,b.Sequence,sum(isnull(a.Quantity,0)) returnqty ,a.WorkPoint
|
|
FROM ICSODeliveryNotice a
|
|
left join ICSOutsourcingOrder b on a.OOID=b.ID
|
|
group by b.OOCode,b.Sequence,a.ODNType,a.WorkPoint having a.ODNType='退货' ) dd
|
|
on a.OOCode=dd.OOCode and a.Sequence=dd.Sequence AND a.WorkPoint=dd.WorkPoint
|
|
left join ICSVendor ee on a.VenCode=ee.VenCode and a.WorkPoint=ee.WorkPoint
|
|
WHERE 1=1 AND a.ReleaseState = '1'";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ORDERNO"].ToString()))
|
|
{
|
|
sql += " and a.ExtensionID like '%" + queryParam["ORDERNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sql += " and a.OOCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BeginDate"].ToString()))
|
|
{
|
|
sql += " and a.ReleaseDate >='" + queryParam["BeginDate"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
sql += " and a.ReleaseDate <='" + queryParam["EndDate"].ToString() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and ee.VenName like '%" + queryParam["VenName"].ToString() + "%'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].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 a.Quantity=ISNULL(bb.LOTQTY,0)-isnull(cc.NGQTY,0)-isnull(dd.returnqty,0)";
|
|
}
|
|
else
|
|
{
|
|
sql += " and a.Quantity>ISNULL(bb.LOTQTY,0)-isnull(cc.NGQTY,0)-isnull(dd.returnqty,0)";
|
|
}
|
|
}
|
|
}
|
|
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 == "Vendor")
|
|
{
|
|
sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
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 POCode, string PORow, string WorkPoint,ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
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,a.Quantity,a.PrintTimes,a.ProductDate,
|
|
CASE WHEN b.LotNoCount>0 THEN a.Quantity ELSE 0 END AS ruku,a.LastPrintTime
|
|
FROM dbo.ICSInventoryLot a
|
|
LEFT JOIN (SELECT COUNT(LotNO) LotNoCount,LotNO,WorkPoint from dbo.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
|
|
WHERE c.TransCode='" + POCode + "' and c.TransSequence='" + PORow + "' and a.WorkPoint in ('" + WorkPoint + "')";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击生成条码
|
|
/// </summary>
|
|
/// <param name="POCode">采购订单</param>
|
|
/// <param name="PORow">采购订单行</param>
|
|
/// <param name="WorkPoint">多站点</param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJsonByCreate(string POCode, string PORow, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" SELECT a.ID, a.POCode,a.Sequence, CONVERT(NVARCHAR(50),a.CreateDateTime,23) as PODate,a.ExtensionID,a.VenCode,mm.VenName,a.InvCode,
|
|
(a.Quantity-ISNULL(bb.LOTQTY,0)+isnull(cc.NGQTY,0)+isnull(dd.returnqty,0)) as thisCreateQty,
|
|
b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,isnull(c.InQty,0) as InQty,a.WorkPoint,ISNULL(bb.LOTQTY,0) AS CreatedQty,
|
|
isnull(cc.NGQTY,0) AS RefuseLotQty,isnull(dd.returnqty,0) AS BackLotQty,ISNULL(ee.repairqty,0) AS RepairQty,
|
|
isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,2)) as EffectiveDays ,
|
|
CAST( a.Amount as DECIMAL(18,2)) as Amount
|
|
FROM dbo.ICSPurchaseOrder a
|
|
LEFT JOIN dbo.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
|
|
group by b.TransCode,b.TransSequence
|
|
) bb on a.POCode=bb.TransCode and a.Sequence=bb.TransSequence
|
|
left join (
|
|
select c.TransCode,c.TransSequence,sum(isnull(a.UnqualifiedQuantity,0)) NGQTY from ICSInspection a
|
|
left join ICSInventoryLot b on a.LotNo=b.LotNo
|
|
left join ICSInventoryLotDetail c on b.lotNo=c.LotNo
|
|
group by c.TransCode,c.TransSequence
|
|
) cc on a.POCode=cc.TransCode and a.Sequence=cc.TransSequence
|
|
left join (
|
|
select b.POCode,b.Sequence,sum(isnull(a.Quantity,0)) returnqty
|
|
from ICSDeliveryNotice a
|
|
left join ICSPurchaseOrder b on a.POID=b.ID
|
|
group by b.POCode,b.Sequence,a.DNType
|
|
having a.DNType='退货' ) dd
|
|
on a.POCode=dd.POCode and a.Sequence=dd.Sequence
|
|
LEFT JOIN (
|
|
SELECT SUM(x.Quantity) CreatedQty,z.TransCode,z.TransSequence,x.WorkPoint,
|
|
SUM(CASE WHEN y.LotNO IS NOT NULL THEN x.Quantity ELSE 0 END) AS InQty
|
|
FROM dbo.ICSInventoryLot x
|
|
LEFT JOIN dbo.ICSWareHouseLotInfo y ON x.LotNO=y.LotNO AND x.WorkPoint=y.WorkPoint
|
|
left join ICSInventoryLotDetail z on x.LotNo=z.LotNo
|
|
GROUP BY z.TransCode,z.TransSequence,x.WorkPoint
|
|
) c ON a.POCode=c.TransCode AND a.Sequence=c.TransSequence AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN (SELECT c.TransCode,c.TransSequence,
|
|
0 AS repairqty,a.WorkPoint
|
|
FROM ICSASNDetail a
|
|
LEFT JOIN ICSInventoryLot b ON a.LotNO = b.LotNO AND a.WorkPoint = b.WorkPoint
|
|
left join ICSInventoryLotDetail c on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPoint
|
|
GROUP BY c.TransCode,c.TransSequence,a.WorkPoint
|
|
) ee ON a.POCode = ee.TransCode AND a.Sequence = ee.TransSequence AND a.WorkPoint = ee.WorkPoint
|
|
left join ICSVendor mm on a.VenCode=mm.VenCode
|
|
WHERE 1 =1
|
|
and a.POCode='" + POCode + "' and a.Sequence='" + PORow + "'";
|
|
sql += " and a.WorkPoint='" +WorkPoint+ "'";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击生成条码
|
|
/// </summary>
|
|
/// <param name="POCode">采购订单</param>
|
|
/// <param name="PORow">采购订单行</param>
|
|
/// <param name="WorkPoint">多站点</param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJsonByCreateWeiWai(string OOCode, string Sequence, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
SELECT a.ID, pp.Enable,a.OOCode,a.Sequence,CAST( a.Amount as DECIMAL(18,2)) as Amount, CONVERT(NVARCHAR(50),a.CreateDateTime,23) as PODate,a.ExtensionID,a.VenCode,mm.VenName,a.InvCode,
|
|
(a.Quantity-ISNULL(bb.LOTQTY,0)+isnull(cc.NGQTY,0)+isnull(dd.returnqty,0)) as thisCreateQty,
|
|
b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,isnull(c.InQty,0) as InQty,a.WorkPoint,ISNULL(bb.LOTQTY,0) AS CreatedQty,
|
|
isnull(cc.NGQTY,0) AS RefuseLotQty,isnull(dd.returnqty,0) AS BackLotQty,ISNULL(ee.repairqty,0) AS RepairQty,
|
|
isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,2)) as EffectiveDays
|
|
FROM dbo.ICSOutsourcingOrder a
|
|
LEFT JOIN dbo.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
|
|
group by b.TransCode,b.TransSequence
|
|
) bb on a.OOCode=bb.TransCode and a.Sequence=bb.TransSequence
|
|
left join (
|
|
select c.TransCode,c.TransSequence,sum(isnull(a.UnqualifiedQuantity,0)) NGQTY from ICSInspection a
|
|
left join ICSInventoryLot b on a.LotNo=b.LotNo
|
|
left join ICSInventoryLotDetail c on b.lotNo=c.LotNo
|
|
group by c.TransCode,c.TransSequence
|
|
) cc on a.OOCode=cc.TransCode and a.Sequence=cc.TransSequence
|
|
left join (
|
|
select b.OOCode,b.Sequence,sum(isnull(a.Quantity,0)) returnqty
|
|
from ICSODeliveryNotice a
|
|
left join ICSOutsourcingOrder b on a.OOID=b.ID
|
|
group by b.OOCode,b.Sequence,a.ODNType
|
|
having a.ODNType='退货' ) dd
|
|
on a.OOCode=dd.OOCode and a.Sequence=dd.Sequence
|
|
LEFT JOIN (
|
|
SELECT SUM(x.Quantity) CreatedQty,z.TransCode,z.TransSequence,x.WorkPoint,
|
|
SUM(CASE WHEN y.LotNO IS NOT NULL THEN x.Quantity ELSE 0 END) AS InQty
|
|
FROM dbo.ICSInventoryLot x
|
|
LEFT JOIN dbo.ICSWareHouseLotInfo y ON x.LotNO=y.LotNO AND x.WorkPoint=y.WorkPoint
|
|
left join ICSInventoryLotDetail z on x.LotNo=z.LotNo
|
|
GROUP BY z.TransCode,z.TransSequence,x.WorkPoint
|
|
) c ON a.OOCode=c.TransCode AND a.Sequence=c.TransSequence AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN (SELECT c.TransCode,c.TransSequence,
|
|
0 AS repairqty,a.WorkPoint
|
|
FROM ICSOASNDetail a
|
|
LEFT JOIN ICSInventoryLot b ON a.LotNO = b.LotNO AND a.WorkPoint = b.WorkPoint
|
|
left join ICSInventoryLotDetail c on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPoint
|
|
GROUP BY c.TransCode,c.TransSequence,a.WorkPoint
|
|
) ee ON a.OOCode = ee.TransCode AND a.Sequence = ee.TransSequence AND a.WorkPoint = ee.WorkPoint
|
|
left join ICSVendor mm on a.VenCode=mm.VenCode
|
|
left join ICSConfiguration pp on pp.Code='CompleteVerification'
|
|
WHERE 1 =1
|
|
|
|
and a.OOCode='" + OOCode + "' and a.Sequence='" + Sequence + "'";
|
|
sql += " and a.WorkPoint=" + WorkPoints + "";
|
|
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());
|
|
}
|
|
|
|
public string GetPoStatus(string POCode, string PORow)
|
|
{
|
|
string sqlU9 = "SELECT DBIpAddress,DBName FROM dbo.Sys_DataBase WHERE DBSourceName='ERP'";
|
|
DataTable dtU9 = SqlHelper.GetDataTableBySql(sqlU9);
|
|
string U9IP = dtU9.Rows[0]["DBIpAddress"].ToString();
|
|
string DBName = dtU9.Rows[0]["DBName"].ToString();
|
|
string msg = "";
|
|
string U9ConnStr = ConfigurationManager.ConnectionStrings["U9connstr"].ConnectionString;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = string.Format(@"select a.docno,b.DocLineNo,b.status,d.code 组织
|
|
from [{0}].{1}.dbo.PM_PurchaseOrder A
|
|
LEFT JOIN [{0}].{1}.dbo.PM_POLine B ON A.ID=B.PurchaseOrder and a.Org=b.CurrentOrg
|
|
LEFT JOIN [{0}].{1}.dbo.pm_poshipline C ON B.ID=C.poline and a.Org=c.CurrentOrg
|
|
left join [{0}].{1}.dbo.Base_Organization d with (nolock) on a.org=d.id
|
|
left join [{0}].{1}.dbo.Base_Organization_trl e with (nolock) on d.id=e.ID
|
|
WHERE d.code='" + WorkPoint + "'and a.docno='" + POCode + "' and b.doclineno='" + PORow + "'", U9IP, DBName);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
string poStatus = dt.Rows[0]["status"].ToString();
|
|
if (poStatus != "2")
|
|
{
|
|
msg = "该订单行不是审核状态,无法生成条码!";
|
|
}
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <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, string WorkPoint)
|
|
{
|
|
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 VenCode = GetVendorCode(POCode, PORow, WorkPoint);
|
|
string Pre = POCode + PORow;
|
|
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 sqls= string.Empty;
|
|
string Colspan = "";
|
|
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}'", Colspan);
|
|
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
|
|
if (ExtensionID == null)
|
|
{
|
|
ExtensionID = Guid.NewGuid();
|
|
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}' )",
|
|
ExtensionID, 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);
|
|
}
|
|
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSITEMLot", "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, POCode, PORow, MUSER, MUSERNAME, WorkPoint);
|
|
|
|
sql += string.Format(@" insert into ICSInventoryLot
|
|
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
|
|
select
|
|
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}'
|
|
from ICSPurchaseOrder where POCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
|
|
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoint, POCode, PORow, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
|
|
sql += "\r\n";
|
|
|
|
|
|
}
|
|
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
return count;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// 已改
|
|
/// <returns></returns>
|
|
public int SubmitFormWeiWai(string OOCode, string Sequence, string keyValue, string WorkPoint)
|
|
{
|
|
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(OOCode, Sequence, WorkPoint);
|
|
string Pre = OOCode + Sequence;
|
|
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 sqls = string.Empty;
|
|
string Colspan = "";
|
|
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}'", Colspan);
|
|
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
|
|
if (ExtensionID == null)
|
|
{
|
|
ExtensionID = Guid.NewGuid();
|
|
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}' )",
|
|
ExtensionID, 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);
|
|
}
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSITEMLot", "LotNO", Pre, 5);
|
|
// sqls= string.Format(@"select * from ICSInventoryLotDetail where TransCode='{0}' and TransSequence='{1}' )",
|
|
// POCode, PORow);
|
|
//DataTable dtASN = SqlHelper.GetDataTableBySql(sqls);
|
|
//if (dtASN == null && dtASN.Rows.Count <= 0)
|
|
//{
|
|
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}',getdate(),{5} )",
|
|
LotNo, OOCode, 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)
|
|
select
|
|
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),{5},'{9}'
|
|
from ICSOutsourcingOrder where OOCode='{6}' and Sequence='{7}' and WorkPoint={5} ",
|
|
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
|
|
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.ICSPurchaseOrder
|
|
WHERE POCode='{0}' AND Sequence='{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 DeleteItemLot(string keyValue, string WorkPoint)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = string.Empty;
|
|
string sql = string.Format(@"SELECT * FROM dbo.ICSASNDetail
|
|
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.ICSContainerLot 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))
|
|
{
|
|
sql = string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
|
|
return msg;
|
|
|
|
//keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
//string sql = @"DELETE FROM dbo.ICSITEMLot WHERE ID IN (" + keyValue.TrimEnd(',') + ")";
|
|
//int i = DbHelper.ExecuteNonQuery(CommandType.Text, sql);
|
|
//return i;
|
|
}
|
|
|
|
|
|
public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
|
|
{
|
|
string sql = @"select ColCode from ICSExtensionEnable
|
|
where Enable=0
|
|
order by cast(EATTRIBUTE1 as int)";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
public object GetQiSetNum(string keyValue)
|
|
{
|
|
int Num = 0;
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
|
|
string result = HttpPost(APIURL, keyValue);
|
|
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;
|
|
}
|
|
|
|
if (msg == "")
|
|
{
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
Num = Convert.ToInt32(jo["min_lotqty"].ToString());
|
|
}
|
|
|
|
}
|
|
var Header = new
|
|
{
|
|
msg = msg,
|
|
Num = Num,
|
|
};
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|