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.
4434 lines
272 KiB
4434 lines
272 KiB
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using NFine.Code;
|
|
using NFine.Repository;
|
|
using System.Data.Common;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using ICS.Application.Entity;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using System.Data.SqlClient;
|
|
using ICS.Data;
|
|
using Newtonsoft.Json.Linq;
|
|
using NFine.Domain._03_Entity.WMS;
|
|
using System.Net;
|
|
using System.IO;
|
|
using NFine.Application.SystemManage;
|
|
using ICSSoft.SendMail;
|
|
using System.Security.Cryptography;
|
|
using NFine.Application.WMS;
|
|
|
|
namespace NFine.Application.DHAY
|
|
{
|
|
public class ICSRCVIQCsApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
DataActionApp actionapp = new DataActionApp();
|
|
|
|
// /// <summary>
|
|
// /// 采购
|
|
// /// </summary>
|
|
// /// <param name="jqgridparam"></param>
|
|
// /// <returns></returns>
|
|
// public DataTable GetICSInspection(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
// {
|
|
// string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
// string ERPSign = Configs.GetValue("ERPSign");
|
|
// string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
// DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
// List<DbParameter> parameter = new List<DbParameter>();
|
|
// string sql = string.Empty;
|
|
|
|
// if (ERPSign == "U8")
|
|
// {
|
|
// sql = @"
|
|
// if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
|
|
// drop table #TempLLData_1
|
|
// if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
|
|
// drop table #TempLLData_1_1
|
|
// if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
|
|
// drop table #TempIcsinsp_1
|
|
|
|
// select *
|
|
// into #TempIcsinsp_1
|
|
// from dbo.ICSInspection
|
|
// where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
// select DISTINCT
|
|
// a.ID as DHID,
|
|
// d.ID ,
|
|
// h.ID as JYID,
|
|
// a.DNCode ,
|
|
// -- a.Sequence ,
|
|
// a.ASNCode ,
|
|
// l.POCode,
|
|
// c.InvCode ,
|
|
// c.InvName ,
|
|
// c.INVSTD ,
|
|
// c.ClassName,
|
|
// c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
// CAST(b.DNQuantity as decimal(18,4)) as AllNumber,
|
|
// CAST(ISNULL(h.QualifiedQuantity, b.DNQuantity)as decimal(18,4))as YLOTQTY ,
|
|
// CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
|
|
// CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
|
|
// CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
|
|
// --CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
|
|
// c.InvUnit ,
|
|
// b.LotNo ,
|
|
// g.BadReasonDesc as BadReasonDesc ,
|
|
// g.BadReasonCode as BRCodeValue,
|
|
// j.BadCode as BCCodeValue,
|
|
// j.BadDesc as BadDesc,
|
|
// k.ContainerID,
|
|
// q.ContainerCode,
|
|
// isnull(h.EATTRIBUTE2,'') as InspectionEATTRIBUTE2,
|
|
// isnull(h.MUSERName,'开发者') MUSERName,
|
|
// CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
// CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
|
|
// CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
// CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
// a.VenCode,
|
|
// m.VenName,
|
|
// CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
// isnull(h.MUSERName,'') as Surveyor,
|
|
// h.MTime as ProvingTime
|
|
// ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
|
|
// ,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
// n.FileName
|
|
// ,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0)
|
|
// WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*b.DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity
|
|
// ,o.Editable
|
|
// ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
|
|
// WHERE hH2.LotNo=b.LotNo AND hH2.WorkPoint=b.WorkPoint),0)
|
|
// WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
|
|
// ,case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,
|
|
// case when isnull(qq.EATTRIBUTE1,'')='' then '否' else '是' end Rejected,c.InvIQC{2}
|
|
// into #TempLLData_1
|
|
// FROM ICSDeliveryNotice a
|
|
// inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
// inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
|
|
// inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.ExtensionID=d.ExtensionID AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
|
|
// left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
|
|
// LEFT JOIN #TempIcsinsp_1 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
|
|
// LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
// left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
// left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
// LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint
|
|
// LEFT JOIN ICSContainer q on k.ContainerID=q.ContainerID AND k.WorkPoint=q.WorkPoint
|
|
// inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND d.WorkPoint=l.WorkPoint
|
|
// left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
|
|
// left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
|
|
// left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
// LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
// left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint
|
|
// LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND b.DNQuantity BETWEEN p.SetValueMin AND p.SetValueMax
|
|
// left join ICSDeliveryNotice qq on e.LotNo =qq.EATTRIBUTE1 and qq.DNType='3' and a.WorkPoint=qq.WorkPoint
|
|
// left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
// where b.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
|
|
|
|
// select * into #TempLLData_1_1 from #TempLLData_1 where InvIQC='1'
|
|
|
|
// ";
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// sql = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
|
|
// drop table #TempLLData_1
|
|
// if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
|
|
// drop table #TempIcsinsp_1
|
|
// if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
|
|
// drop table #TempLLData_1_1
|
|
//select *
|
|
//into #TempIcsinsp_1
|
|
//from dbo.ICSInspection
|
|
//where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
// select DISTINCT
|
|
// a.ID as DHID,
|
|
// d.ID ,
|
|
// h.ID as JYID,
|
|
// a.DNCode ,
|
|
// a.Sequence ,
|
|
// a.ASNCode ,
|
|
// l.POCode,
|
|
// c.InvCode ,
|
|
// c.InvName ,
|
|
// c.INVSTD ,
|
|
// c.ClassName,
|
|
// c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
// isnull(h.EATTRIBUTE2,'') as InspectionEATTRIBUTE2,
|
|
// CAST(d.Quantity as decimal(18,4)) as AllNumber,
|
|
// CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
|
|
// CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
|
|
// CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
|
|
// CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
|
|
// CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
// -- CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
|
|
// c.InvUnit ,
|
|
// d.LotNo ,
|
|
// g.BadReasonDesc as BadReasonDesc ,
|
|
// g.BadReasonCode as BRCodeValue,
|
|
// j.BadCode as BCCodeValue,
|
|
// j.BadDesc as BadDesc,
|
|
// k.ContainerID,
|
|
// isnull(h.MUSERName,'开发者') MUSERName,
|
|
// CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
// CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
|
|
// CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
// CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
// a.VenCode,
|
|
// m.VenName,
|
|
// isnull(h.MUSERName,'') as Surveyor,
|
|
// h.MTime as ProvingTime
|
|
// ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
|
|
// ,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
// n.FileName
|
|
// ,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0)
|
|
// WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*b.DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity
|
|
// ,o.Editable
|
|
// ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
|
|
// WHERE hH2.LotNo=d.LotNo AND hH2.WorkPoint=a.WorkPoint),0)
|
|
// WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
|
|
// , case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC{2}
|
|
// into #TempLLData_1
|
|
// FROM ICSDeliveryNotice a
|
|
// --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
// left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
|
|
// inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
|
|
// inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
// LEFT JOIN #TempIcsinsp_1 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint
|
|
// LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
// left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
// left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
// LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
|
|
// inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND a.WorkPoint=l.WorkPoint
|
|
// left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
|
|
// left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
|
|
// left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
// LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
// left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint
|
|
// LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
// left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
// where d.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
|
|
|
|
// select * into #TempLLData_1_1 from #TempLLData_1
|
|
// ";
|
|
// }
|
|
|
|
// string wheresql = "";
|
|
// if (!string.IsNullOrWhiteSpace(queryJson))
|
|
// {
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
// {
|
|
// wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
// {
|
|
// wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
// {
|
|
// wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
// {
|
|
// wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
// {
|
|
// wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
// {
|
|
// wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
// {
|
|
// wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
// {
|
|
// wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
// {
|
|
// wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["CusBatch"].ToString()))
|
|
// {
|
|
// wheresql += " and d.EATTRIBUTE3 like '%" + queryParam["CusBatch"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
// {
|
|
// wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
|
|
// {
|
|
// wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
// {
|
|
// wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
|
|
// {
|
|
// wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
|
|
// }
|
|
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
// {
|
|
// string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
// if (ReleaseState == "1")
|
|
// wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
// else if (ReleaseState == "0")
|
|
// wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
// else
|
|
// wheresql += " ";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
// {
|
|
// if (queryParam["selIsWH"].ToString() == "0")
|
|
// {
|
|
// wheresql += " and lotInfo.ID is null ";
|
|
// }
|
|
// if (queryParam["selIsWH"].ToString() == "1")
|
|
// {
|
|
// wheresql += " and lotInfo.ID is not null ";
|
|
// }
|
|
// }
|
|
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
|
|
// {
|
|
// string printState = queryParam["selIsPrint"].ToString();
|
|
// if (printState == "否")
|
|
// wheresql += " and isnull(task.ValueParameters,'') ='' ";
|
|
// else if (printState == "是")
|
|
// wheresql += " and isnull(task.ValueParameters,'') <>''";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
// {
|
|
// string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
// if (selEnableShow == "1")
|
|
// wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
// else if (selEnableShow == "0")
|
|
// wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
// }
|
|
// if (!string.IsNullOrWhiteSpace(queryParam["Rejected"].ToString()))
|
|
// {
|
|
// string selEnableShow = queryParam["Rejected"].ToString();
|
|
// if (selEnableShow == "1")
|
|
// wheresql += "and isnull(qq.EATTRIBUTE1,'')<>''";
|
|
// else if (selEnableShow == "2")
|
|
// wheresql += "and isnull(qq.EATTRIBUTE1,'')=''";
|
|
// }
|
|
// }
|
|
// wheresql += " " + DataActionsql;
|
|
// List<string> tableName = new List<string> { "ICSInspection", "ICSInventory" };
|
|
// List<string> tablenameJC = new List<string> { "h.", "c." };
|
|
// //sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// sql = SqlHelper.GetEATTRIBUTE(sql, tableName, tablenameJC, wheresql, WorkPoint);//
|
|
// //sql = string.Format(sql, wheresql, WorkPoint);
|
|
// return Repository().FindTablePageBySql_OtherTemp(sql, "#TempLLData_1_1",
|
|
// @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
|
|
// drop table #TempLLData_1
|
|
// if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
|
|
// drop table #TempIcsinsp_1
|
|
// if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempLLData_1_1'))
|
|
// drop table #TempLLData_1_1 ",
|
|
// "connstr", parameter.ToArray(), ref jqgridparam);
|
|
// // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
// }
|
|
/// <summary>
|
|
/// 采购
|
|
/// </summary>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSInspection(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string ERPSign = Configs.GetValue("ERPSign");
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
|
|
if (ERPSign == "U8")
|
|
{
|
|
sql = @"
|
|
|
|
select DISTINCT
|
|
a.ID as DHID,
|
|
d.ID ,
|
|
h.ID as JYID,
|
|
a.DNCode ,
|
|
-- a.Sequence ,
|
|
a.ASNCode ,
|
|
l.POCode,
|
|
c.InvCode ,
|
|
c.InvName ,
|
|
c.INVSTD ,
|
|
c.ClassName,
|
|
c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(b.DNQuantity as decimal(18,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, b.DNQuantity)as decimal(18,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
|
|
CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
|
|
--CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
|
|
c.InvUnit ,
|
|
b.LotNo ,
|
|
g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,
|
|
j.BadCode as BCCodeValue,
|
|
j.BadDesc as BadDesc,
|
|
k.ContainerID,
|
|
q.ContainerCode,
|
|
isnull(h.EATTRIBUTE2,'') as InspectionEATTRIBUTE2,
|
|
isnull(h.MUSERName,'开发者') MUSERName,
|
|
CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
|
|
CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
a.VenCode,
|
|
m.VenName,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
isnull(h.MUSERName,'') as Surveyor,
|
|
h.MTime as ProvingTime
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName
|
|
,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0)
|
|
WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*b.DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity
|
|
,o.Editable
|
|
,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
|
|
WHERE hH2.LotNo=b.LotNo AND hH2.WorkPoint=b.WorkPoint),0)
|
|
WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
|
|
,case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,
|
|
case when isnull(qq.EATTRIBUTE1,'')='' then '否' else '是' end Rejected,c.InvIQC{2}
|
|
|
|
FROM ICSDeliveryNotice a
|
|
inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
|
|
inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.ExtensionID=d.ExtensionID AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
|
|
left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
|
|
LEFT JOIN ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint and h.Enable='1'
|
|
LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint
|
|
LEFT JOIN ICSContainer q on k.ContainerID=q.ContainerID AND k.WorkPoint=q.WorkPoint
|
|
inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND d.WorkPoint=l.WorkPoint
|
|
left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
|
|
left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND b.DNQuantity BETWEEN p.SetValueMin AND p.SetValueMax
|
|
left join ICSDeliveryNotice qq on e.LotNo =qq.EATTRIBUTE1 and qq.DNType='3' and a.WorkPoint=qq.WorkPoint
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where b.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
|
|
|
|
|
|
|
|
";
|
|
|
|
}
|
|
else
|
|
{
|
|
sql = @"
|
|
|
|
select DISTINCT
|
|
a.ID as DHID,
|
|
d.ID ,
|
|
h.ID as JYID,
|
|
a.DNCode ,
|
|
a.Sequence ,
|
|
a.ASNCode ,
|
|
l.POCode,
|
|
c.InvCode ,
|
|
c.InvName ,
|
|
c.INVSTD ,
|
|
c.ClassName,
|
|
c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
isnull(h.EATTRIBUTE2,'') as InspectionEATTRIBUTE2,
|
|
CAST(d.Quantity as decimal(18,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
|
|
CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
-- CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
|
|
c.InvUnit ,
|
|
d.LotNo ,
|
|
g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,
|
|
j.BadCode as BCCodeValue,
|
|
j.BadDesc as BadDesc,
|
|
k.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName,
|
|
CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
|
|
CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
a.VenCode,
|
|
m.VenName,
|
|
isnull(h.MUSERName,'') as Surveyor,
|
|
h.MTime as ProvingTime
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName
|
|
,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0)
|
|
WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*b.DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity
|
|
,o.Editable
|
|
,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
|
|
WHERE hH2.LotNo=d.LotNo AND hH2.WorkPoint=a.WorkPoint),0)
|
|
WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
|
|
, case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC{2}
|
|
FROM ICSDeliveryNotice a
|
|
--inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
|
|
inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint and h.Enable='1'
|
|
LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
|
|
inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND a.WorkPoint=l.WorkPoint
|
|
left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
|
|
left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where d.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
|
|
|
|
";
|
|
}
|
|
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
{
|
|
wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
{
|
|
wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CusBatch"].ToString()))
|
|
{
|
|
wheresql += " and d.EATTRIBUTE3 like '%" + queryParam["CusBatch"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
|
|
{
|
|
wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
|
|
{
|
|
wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
|
|
{
|
|
string printState = queryParam["selIsPrint"].ToString();
|
|
if (printState == "否")
|
|
wheresql += " and isnull(task.ValueParameters,'') ='' ";
|
|
else if (printState == "是")
|
|
wheresql += " and isnull(task.ValueParameters,'') <>''";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Rejected"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["Rejected"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += "and isnull(qq.EATTRIBUTE1,'')<>''";
|
|
else if (selEnableShow == "2")
|
|
wheresql += "and isnull(qq.EATTRIBUTE1,'')=''";
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
List<string> tableName = new List<string> { "ICSInspection", "ICSInventory" };
|
|
List<string> tablenameJC = new List<string> { "h.", "c." };
|
|
//sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, tableName, tablenameJC, wheresql, WorkPoint);//
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
return Repository().FindTablePageBySql(sql, parameter.ToArray(), ref jqgridparam);
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
public DataTable GetInspectionFile(ref Pagination jqgridparam, string queryJson, string JYID)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT * FROM dbo.ICSInspectionFile WHERE InspectionID='{0}'";
|
|
sql = string.Format(sql, JYID);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
//委外
|
|
public DataTable GetICSInspection2(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
|
|
drop table #TempWWLLData_2
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
|
|
drop table #TempWWLLData_2_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
|
|
drop table #TempIcsinsp_2
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode{2}
|
|
into #TempIcsinsp_2
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
select DISTINCT a.ID as DHID, d.ID ,h.ID as JYID, a.ODNCode as DNCode ,a.Sequence ,a.OASNCode ,l.OOCode,c.InvCode , c.InvName , c.INVSTD , c.ClassName,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(b.ODNQuantity as NUMERIC(10,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, b.ODNQuantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity,
|
|
CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
|
|
c.InvUnit , b.LotNo , g.BadReasonDesc as BadReasonDesc ,g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc,
|
|
k.ContainerID,isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,a.VenCode,m.VenName,
|
|
isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10
|
|
,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
|
|
WHERE hH2.LotNo=b.LotNo AND hH2.WorkPoint=b.WorkPoint),0)
|
|
WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
|
|
,case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,
|
|
case when isnull(qq.EATTRIBUTE1,'')='' then '否' else '是' end Rejected,c.InvIQC{3}
|
|
into #TempWWLLData_2
|
|
FROM ICSODeliveryNotice a
|
|
LEFT JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint AND a.ExtensionID=d.ExtensionID
|
|
left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
|
|
LEFT JOIN #TempIcsinsp_2 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint -- and Enable='1'
|
|
LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint
|
|
inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
|
|
left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
|
|
left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left join ICSDeliveryNotice qq on e.LotNo =qq.EATTRIBUTE1 and qq.DNType='3' and a.WorkPoint=qq.WorkPoint
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where b.LotNo is not null and ISNULL(CAST(b.ODNQuantity as VARCHAR), '')! =''
|
|
AND ISNULL(b.ODNQuantity, 0)<>0 {0} and a.workpoint='{1}'
|
|
select * into #TempWWLLData_2_1 from #TempWWLLData_2 where InvIQC='1'
|
|
";
|
|
#region 无SRM逻辑
|
|
// sql = @"UNION all
|
|
//select
|
|
// a.ID as DHID,
|
|
// d.ID ,
|
|
// h.ID as JYID,
|
|
// a.ODNCode as DNCode ,
|
|
// a.Sequence ,
|
|
// a.OASNCode ,
|
|
// c.InvCode ,
|
|
// c.InvName ,
|
|
// c.INVSTD ,
|
|
// c.ClassName,
|
|
// f.BatchCode ,
|
|
// CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
|
|
// CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
// CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
// CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
// c.InvUnit ,
|
|
// d.LotNo ,
|
|
// g.BadReasonDesc as BadReasonDesc ,
|
|
// g.BadReasonCode as BRCodeValue,
|
|
// j.BadCode as BCCodeValue,
|
|
// j.BadDesc as BadDesc,
|
|
// k.ContainerID,
|
|
// isnull(h.MUSERName,'开发者') MUSERName,
|
|
// CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
|
|
// CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
|
|
// CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState
|
|
// FROM ICSODeliveryNotice a
|
|
// inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
|
|
// inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
|
|
// LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
|
|
// LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
|
|
// left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
// left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
// LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
|
|
// left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
// where 1=1 {0}";
|
|
#endregion
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
{
|
|
wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
{
|
|
wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
|
|
{
|
|
wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
|
|
{
|
|
wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
|
|
{
|
|
string printState = queryParam["selIsPrint"].ToString();
|
|
if (printState == "否")
|
|
wheresql += " and isnull(task.ValueParameters,'') ='' ";
|
|
else if (printState == "是")
|
|
wheresql += " and isnull(task.ValueParameters,'') <>''";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Rejected"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["Rejected"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += "and isnull(qq.EATTRIBUTE1,'')<>''";
|
|
else if (selEnableShow == "2")
|
|
wheresql += "and isnull(qq.EATTRIBUTE1,'')=''";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempWWLLData_2_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
|
|
drop table #TempWWLLData_2
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
|
|
drop table #TempWWLLData_2_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
|
|
drop table #TempIcsinsp_2 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
//工单
|
|
public DataTable GetICSInspection3(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
|
|
drop table #TempMOData_3
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
|
|
drop table #TempMOData_3_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
|
|
drop table #TempIcsinsp_3
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode{2}
|
|
into #TempIcsinsp_3
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
select DISTINCT a.ID as GDID, e.ID , a.MOCode as DNCode, a.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') ='' and c.InvFQC='1' THEN '未检验' WHEN c.InvFQC='0' then '免检' ELSE '已检验' END AS TestState,
|
|
isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10--,c.InvIQC
|
|
,c.EATTRIBUTE3 as InvEATTRIBUTE3 ,c.InvFQC{3}
|
|
into #TempMOData_3
|
|
from ICSMO a
|
|
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
|
|
LEFT JOIN #TempIcsinsp_3 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where a.MOStatus<>'3' and e.LotNO is not null {0} and isnull(e.EATTRIBUTE1,'' )='' and a.workpoint='{1}'
|
|
select * into #TempMOData_3_1 from #TempMOData_3 where --InvIQC='1'
|
|
InvFQC='1'
|
|
";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_3_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
|
|
drop table #TempMOData_3
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
|
|
drop table #TempMOData_3_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
|
|
drop table #TempIcsinsp_3",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//其他入库
|
|
public DataTable GetICSInspection4(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
|
|
drop table #TempQTLLData_4
|
|
if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
|
|
drop table #TempQTLLData_4_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
|
|
drop table #TempIcsinsp_4
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode{2}
|
|
into #TempIcsinsp_4
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
select DISTINCT a.ID as GDID, e.ID , a.InCode as DNCode, a.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber, c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
|
|
isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10
|
|
,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
|
|
WHERE hH2.LotNo=e.LotNo AND hH2.WorkPoint=b.WorkPoint and hh2.InvCode=e.InvCode),0)
|
|
WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
|
|
,case e.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC{3}
|
|
INTO #TempQTLLData_4
|
|
from ICSOtherIn a
|
|
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
left join ICSInventoryLotDetail b on a.InCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')=''
|
|
left join ICSExtension f on e.ExtensionID=f.ID and e.WorkPoint=f.WorkPoint
|
|
|
|
LEFT JOIN #TempIcsinsp_4 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
|
|
LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where e.LotNO is not null {0} and a.workpoint='{1}'
|
|
select * into #TempQTLLData_4_1 from #TempQTLLData_4 where InvIQC='1' ";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
|
|
{
|
|
wheresql += " and case e.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
|
|
{
|
|
string printState = queryParam["selIsPrint"].ToString();
|
|
if (printState == "否")
|
|
wheresql += " and isnull(task.ValueParameters,'') ='' ";
|
|
else if (printState == "是")
|
|
wheresql += " and isnull(task.ValueParameters,'') <>''";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempQTLLData_4_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
|
|
drop table #TempQTLLData_4
|
|
if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
|
|
drop table #TempQTLLData_4_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
|
|
drop table #TempIcsinsp_4 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//生产退料
|
|
public DataTable GetICSInspection5(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
|
|
drop table #TempMOData_5
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
|
|
drop table #TempMOData_5_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
|
|
drop table #TempIcsinsp_5
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode{2}
|
|
into #TempIcsinsp_5
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
|
|
select DISTINCT a.ID as GDID, e.ID , a.ApplyNegCode as DNCode, ad.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber, c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC{3}
|
|
into #TempMOData_5
|
|
from ICSMOApplyNeg a
|
|
LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode=ad.ApplyNegCode AND a.WorkPoint=ad.WorkPoint
|
|
inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
left join ICSInventoryLotDetail b on a.ApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
|
|
LEFT JOIN #TempIcsinsp_5 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint-- and Enable='1'
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON ad.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where e.LotNO is not null {0} AND A.Workpoint='{1}'
|
|
select * into #TempMOData_5_1 from #TempMOData_5 where InvIQC='1' ";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_5_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
|
|
drop table #TempMOData_5
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
|
|
drop table #TempMOData_5_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
|
|
drop table #TempIcsinsp_5 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//委外退料
|
|
public DataTable GetICSInspection6(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
|
|
drop table #TempMOData_6
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
|
|
drop table #TempMOData_6_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
|
|
drop table #TempIcsinsp_6
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode{2}
|
|
into #TempIcsinsp_6
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
select DISTINCT a.ID as GDID, e.ID , a.OApplyNegCode as DNCode, ad.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber, c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC{3}
|
|
into #TempMOData_6
|
|
from ICSOApplyNeg a
|
|
LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode=ad.OApplyNegCode AND a.WorkPoint=ad.WorkPoint
|
|
inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
left join ICSInventoryLotDetail b on a.OApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
|
|
LEFT JOIN #TempIcsinsp_6 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON ad.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where e.LotNO is not null {0} and a.workpoint='{1}'
|
|
select * into #TempMOData_6_1 from #TempMOData_6 where InvIQC='1'
|
|
";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_6_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
|
|
drop table #TempMOData_6
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
|
|
drop table #TempMOData_6_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
|
|
drop table #TempIcsinsp_6 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
//销售退货
|
|
public DataTable GetICSInspection7(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
|
|
drop table #TempMOData_7
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
|
|
drop table #TempMOData_7_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
|
|
drop table #TempIcsinsp_7
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode{2}
|
|
into #TempIcsinsp_7
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
select DISTINCT a.ID as GDID, e.ID , a.SDNCode as DNCode, a.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber, c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC{3}
|
|
into #TempMOData_7
|
|
|
|
from ICSSDN a
|
|
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
left join ICSInventoryLotDetail b on a.SDNCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
|
|
LEFT JOIN #TempIcsinsp_7 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where e.LotNO is not null AND a.Type='2' {0} and a.workpoint='{1}'
|
|
|
|
select * into #TempMOData_7_1 from #TempMOData_7 where InvIQC='1' ";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_7_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
|
|
drop table #TempMOData_7
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
|
|
drop table #TempMOData_7_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
|
|
drop table #TempIcsinsp_7 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
//获取不良原因
|
|
public DataTable Select_ICSBadReason(string InvCode)
|
|
{
|
|
string sql = string.Empty;
|
|
|
|
DataTable dt = null;
|
|
sql = @"select '' as BadReasonCode,'' as BadReasonDesc from ICSBadReason a left join
|
|
ICSInventoryBadGroup b on a.BRGroupID=b.BRGroupID
|
|
union
|
|
select a.BadReasonCode,a.BadReasonDesc from ICSBadReason a left join
|
|
ICSInventoryBadGroup b on a.BRGroupID=b.BRGroupID
|
|
where b.InvCode='{0}'";
|
|
sql = string.Format(sql, InvCode);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
#region 获取不良原因
|
|
public DataTable GetBadReason(string InvCode,string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = $@"select a.ID,a.BadReasonCode,a.BadReasonDesc
|
|
from ICSBadReason a
|
|
left join ICSInventoryBadGroup b on a.BRGroupID=b.BRGroupID and a.WorkPoint=b.workPoint
|
|
where b.InvCode='{InvCode}' and a.workPoint='{WorkPoint}' ";
|
|
if (!string.IsNullOrEmpty(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BadReasonCode"].ToString()))
|
|
{
|
|
string[] values = queryParam["BadReasonCode"].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
string BadReasonCode = "'" + string.Join("','", values) + "'";
|
|
sql += " and a.InvCode in (" + BadReasonCode + ") ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BadReasonDesc"].ToString()))
|
|
{
|
|
string[] values = queryParam["BadReasonDesc"].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
string BadReasonDesc = "'" + string.Join("','", values) + "'";
|
|
sql += " and a.BadReasonDesc in (" + BadReasonDesc + ") ";
|
|
}
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
#endregion
|
|
|
|
//获取不良代码
|
|
public DataTable GetSelectICSBadCode(string InvCode)
|
|
{
|
|
string sql = string.Empty;
|
|
|
|
DataTable dt = null;
|
|
|
|
sql = @"
|
|
select '' as BadCode ,'' as BadDesc
|
|
from dbo.ICSBadCode a left join
|
|
ICSInventoryBadGroup b on a.BCGroupID=b.BCGroupID
|
|
union
|
|
select BadCode,BadDesc from dbo.ICSBadCode a left join
|
|
ICSInventoryBadGroup b on a.BCGroupID=b.BCGroupID where b.InvCode='{0}'";
|
|
// sql = @"select BadCode,BadDesc from dbo.ICSBadCode a left join
|
|
//ICSInventoryBadGroup b on a.BCGroupID=b.BCGroupID
|
|
//where b.InvCode='{0}'";
|
|
sql = string.Format(sql, InvCode);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增检验
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
//public string CreateICSInspection(string keyValue, string ICSInspections)
|
|
//{
|
|
// 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;
|
|
// JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
|
|
// foreach (var item in res)
|
|
// {
|
|
// object CARID = Guid.NewGuid();
|
|
// JObject jo = (JObject)item;
|
|
// string sqls = string.Empty;
|
|
|
|
// if (!string.IsNullOrWhiteSpace(jo["JYID"].ToString()))
|
|
// {
|
|
// sqls += "update ICSInspectionDetailGroup set InspectionID='{2}' WHERE InspectionID='{3}' and WorkPoint='{1}' ";
|
|
|
|
// }
|
|
// sqls += @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
|
|
// sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint, CARID, jo["JYID"].ToString());
|
|
// SqlHelper.CmdExecuteNonQueryLi(sqls);
|
|
// //if (jo["TestState"].ToString()=="已检验")
|
|
// //{
|
|
// // sql += @"UPDATE dbo.ICSInspection set QualifiedQuantity='{0}',UnqualifiedQuantity='{1}',WaiveQuantity='{2}',BCCode='{3}',BRCode='{4}',MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',WorkPoint='{7}' WHERE ID='{8}'";
|
|
// // sql = string.Format(sql, jo["YLOTQTY"].ToString(), jo["NLOTQTY"].ToString(), jo["SpecialQTY"].ToString(), jo["BCCode"].ToString(), jo["BRCode"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["JYID"].ToString());
|
|
// //}
|
|
// //else
|
|
// //{
|
|
|
|
// sql += @"
|
|
// -- IF EXISTS(select LotNo from dbo.ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{11}')
|
|
// -- BEGIN
|
|
// -- RAISERROR('条码:{0}已入库!',16,1);
|
|
// -- RETURN
|
|
// -- end
|
|
// INSERT INTO dbo.ICSInspection
|
|
// ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,Result,EATTRIBUTE2)
|
|
// Values('{13}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate(),'{9}','{10}','{11}','1','{12}','{14}','{15}')
|
|
// ";
|
|
// sql = string.Format(sql, jo["LotNo"].ToString(), jo["InvCode"].ToString(), jo["AllNumber"].ToString(), jo["YLOTQTY"].ToString(), jo["NLOTQTY"].ToString(), jo["SpecialQTY"].ToString(), jo["BCCode"].ToString(), jo["BRCode"].ToString(), jo["Type"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["SampleQuantity"].ToString(), CARID, jo["Result"].ToString(), jo["EATTRIBUTE2"].ToString());
|
|
|
|
// }
|
|
// //}
|
|
|
|
// try
|
|
// {
|
|
// if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
// {
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// msg = "新增失败";
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw new Exception(ex.Message);
|
|
// }
|
|
|
|
// return msg;
|
|
//}
|
|
|
|
|
|
public string CreateICSInspection(string keyValue, string ICSInspections)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
|
|
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 sql = string.Empty;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
|
|
foreach (var item in res)
|
|
{
|
|
object CARID = Guid.NewGuid();
|
|
JObject jo = (JObject)item;
|
|
#region 2024-08-09 检验添加是否入库验证
|
|
var checksql = $@"SELECT ID FROM ICSWareHouseLotInfo WHERE LotNo='{jo["LotNo"]}' AND WorkPoint='{WorkPoint}'";
|
|
var checkdt = SqlHelper.CmdExecuteDataTable(checksql);
|
|
if (checkdt.Rows.Count>0)
|
|
{
|
|
msg = $"条码:{jo["LotNo"]}已经入库,不能再次检验";
|
|
return msg;
|
|
}
|
|
|
|
#endregion
|
|
Dictionary<string, string> values = new Dictionary<string, string>();
|
|
foreach (JProperty prop in jo.Properties())
|
|
{
|
|
string key = prop.Name; // 获取键名
|
|
JToken value = prop.Value; // 获取值(JToken类型)
|
|
string stringValue = value?.Type == JTokenType.Null ? string.Empty : value.ToString();
|
|
if (key != "JYID")
|
|
{
|
|
values.Add(key, "'" + stringValue + "'");
|
|
|
|
}
|
|
|
|
}
|
|
values.Add("ID", "'" + CARID + "'");
|
|
values.Add("MTIME", "'" + DateTime.Now.ToString() + "'");
|
|
values.Add("MUSER", "'" + MUSER + "'");
|
|
values.Add("MUSERName", "'" + MUSERNAME + "'");
|
|
values.Add("WorkPoint", "'" + WorkPoint + "'");
|
|
values.Add("Enable", "'1'");
|
|
string sqls = string.Empty;
|
|
|
|
if (!string.IsNullOrWhiteSpace(jo["JYID"].ToString()))
|
|
{
|
|
sqls += "update ICSInspectionDetailGroup set InspectionID='{2}' WHERE InspectionID='{3}' and WorkPoint='{1}' ";
|
|
|
|
}
|
|
sqls += @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
|
|
sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint, CARID, jo["JYID"].ToString());
|
|
SqlHelper.CmdExecuteNonQueryLi(sqls);
|
|
sql += SqlHelper.InsertSQL("ICSInspection", values);
|
|
|
|
}
|
|
//}
|
|
|
|
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg=ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 在库检验保存检验结果
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string ICSWHLotInspection(string keyValue, string ICSInspections)
|
|
{
|
|
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;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
|
|
string sqls = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
object CARID = Guid.NewGuid();
|
|
decimal YLotQty = Convert.ToDecimal(jo["YLOTQTY"].ToString());
|
|
sqls += @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
|
|
sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint);
|
|
sqls += @"INSERT INTO dbo.ICSInspection
|
|
( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,Result,EATTRIBUTE1)
|
|
Values('{13}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate(),'{9}','{10}','{11}','1','{12}','{14}','{15}')
|
|
";
|
|
sqls = string.Format(sqls, jo["LotNo"].ToString(), jo["InvCode"].ToString(), jo["AllNumber"].ToString(), jo["YLOTQTY"].ToString()
|
|
, jo["NLOTQTY"].ToString(), "0", jo["BCCode"].ToString(), jo["BRCode"].ToString()
|
|
, jo["Type"].ToString(), MUSER, MUSERNAME, WorkPoint, "0", CARID, jo["Result"].ToString(), jo["DNCode"].ToString());
|
|
|
|
sqls += @"update ICSInspectDetail set InspectQuantity={2},MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',EATTRIBUTE1='已检验',EATTRIBUTE10='{4}'
|
|
where InspectCode='{0}' and LotNo='{3}' and WorkPoint='{1}' ";
|
|
//if (YLotQty == 0)
|
|
//{
|
|
// sqls += @"update ICSWareHouseLotInfo set Quantity=ISNULL(LockQuantity,0)
|
|
// where LotNo='{3}' and WorkPoint='{1}' ";
|
|
//}
|
|
//else
|
|
//{
|
|
// sqls += @"update ICSWareHouseLotInfo set Quantity={4}+ISNULL(LockQuantity,0)
|
|
// where LotNo='{3}' and WorkPoint='{1}'
|
|
// UPDATE ICSInventoryLot SET ExpirationDate='{7}'
|
|
// WHERE LotNo='{3}' AND WorkPoint='{1}' ";
|
|
//}
|
|
sqls = string.Format(sqls, jo["DNCode"].ToString(), WorkPoint, jo["YLOTQTY"].ToString(), jo["LotNo"].ToString(), jo["Memo"].ToString(), MUSER, MUSERNAME, Convert.ToDateTime(jo["ExpirationDate"]));
|
|
}
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sqls) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "保存失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 在库检验审核
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string ApproveWHLotInspection(string keyValue, string ICSInspections)
|
|
{
|
|
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;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
|
|
string sqls = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
sqls += @"update ICSInspectDetail set EATTRIBUTE1='已审核',EATTRIBUTE2='{3}',EATTRIBUTE3='{4}',EATTRIBUTE10='{5}'
|
|
where InspectCode='{0}' and LotNo='{1}' and WorkPoint='{2}' ";
|
|
sqls = string.Format(sqls, jo["DNCode"].ToString(), jo["LotNo"].ToString(), WorkPoint, MUSER, MUSERNAME, jo["Memo"].ToString());
|
|
}
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sqls) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "审核失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 在库检验复审
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string SecApproveWHLotInspection(string keyValue, string ICSInspections)
|
|
{
|
|
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 = "";
|
|
bool IsCQ = false;
|
|
string sql = string.Empty;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
|
|
string chksql = @"select Type from ICSInspect
|
|
where InspectCode='{0}' and WorkPoint='{1}'";
|
|
chksql = string.Format(chksql, res[0]["DNCode"].ToString(), WorkPoint);
|
|
DataTable chkdt = SqlHelper.GetDataTableBySql(chksql);
|
|
if (chkdt.Rows[0]["Type"].ToString() == "0")
|
|
{
|
|
IsCQ = false;
|
|
}
|
|
else
|
|
{
|
|
IsCQ = true;
|
|
}
|
|
string sqls = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
object CARID = Guid.NewGuid();
|
|
string newlotStr = "";
|
|
decimal AllNumber = Convert.ToDecimal(jo["AllNumber"].ToString());
|
|
decimal YLotQty = Convert.ToDecimal(jo["YLOTQTY"].ToString());
|
|
sqls += @"update ICSInspectDetail set EATTRIBUTE1='已复审',EATTRIBUTE4='{3}',EATTRIBUTE5='{4}',EATTRIBUTE10='{10}'
|
|
where InspectCode='{0}' and LotNo='{1}' and WorkPoint='{2}'
|
|
update ICSWareHouseLotInfo set Inspect=0
|
|
where LotNo='{1}' and WorkPoint='{2}'";
|
|
if (AllNumber != YLotQty)
|
|
{
|
|
//获取分批条码编号
|
|
string lotsql = @" select top 1 LotNo from ICSInventoryLot
|
|
where LotNo like '{0}-%' AND LotNo!='{0}'
|
|
AND WorkPoint='{1}'
|
|
order by MTIME desc";
|
|
lotsql = string.Format(lotsql, jo["LotNo"].ToString(), WorkPoint);
|
|
DataTable lotdt = SqlHelper.GetDataTableBySql(lotsql);
|
|
if (lotdt.Rows.Count == 0)
|
|
{
|
|
newlotStr = jo["LotNo"].ToString() + "-1";
|
|
}
|
|
else
|
|
{
|
|
newlotStr = jo["LotNo"].ToString() + "-" + (Convert.ToInt32(lotdt.Rows[0]["LotNo"].ToString().Split('-')[lotdt.Rows[0]["LotNo"].ToString().Split('-').Length - 1]) + 1).ToString();
|
|
}
|
|
if (IsCQ == false)
|
|
{
|
|
sqls += @"insert into ICSInventoryLot
|
|
select NEWID(),'{6}',InvCode,ProductDate,ExpirationDate,Quantity-{7},Amount,ExtensionID,'21',null,null,null,'{8}','{9}'
|
|
,GETDATE(),WorkPoint,'{1}',EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9
|
|
,EATTRIBUTE10,EATTRIBUTE11,EATTRIBUTE12,EATTRIBUTE13,EATTRIBUTE14,EATTRIBUTE15,EATTRIBUTE16
|
|
,EATTRIBUTE17,EATTRIBUTE18,EATTRIBUTE19,EATTRIBUTE20,EATTRIBUTE21,EATTRIBUTE22,EATTRIBUTE23
|
|
,EATTRIBUTE24,EATTRIBUTE25,EATTRIBUTE26,EATTRIBUTE27,EATTRIBUTE28,EATTRIBUTE29,EATTRIBUTE30 from ICSInventoryLot
|
|
where LotNo='{1}' and WorkPoint='{2}'
|
|
insert into ICSInventoryLotDetail
|
|
select '{6}',TransID,TransCode,TransSequence,'{8}','{9}',GETDATE(),WorkPoint
|
|
,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7
|
|
,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10,EATTRIBUTE11,EATTRIBUTE12,EATTRIBUTE13,EATTRIBUTE14,EATTRIBUTE15,EATTRIBUTE16
|
|
,EATTRIBUTE17,EATTRIBUTE18,EATTRIBUTE19,EATTRIBUTE20,EATTRIBUTE21,EATTRIBUTE22,EATTRIBUTE23
|
|
,EATTRIBUTE24,EATTRIBUTE25,EATTRIBUTE26,EATTRIBUTE27,EATTRIBUTE28,EATTRIBUTE29,EATTRIBUTE30 from ICSInventoryLotDetail
|
|
where LotNo='{1}' and WorkPoint='{2}'
|
|
insert into ICSWareHouseLotInfo
|
|
select NEWID(),'{6}',WarehouseCode,LocationCode,InvCode,Quantity-{7}-isnull(LockQuantity,0),InDate,0,0,0,'{8}','{9}'
|
|
,GETDATE(),WorkPoint,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8
|
|
,EATTRIBUTE9,EATTRIBUTE10,EATTRIBUTE11,EATTRIBUTE12,EATTRIBUTE13,EATTRIBUTE14,EATTRIBUTE15,EATTRIBUTE16
|
|
,EATTRIBUTE17,EATTRIBUTE18,EATTRIBUTE19,EATTRIBUTE20,EATTRIBUTE21,EATTRIBUTE22,EATTRIBUTE23
|
|
,EATTRIBUTE24,EATTRIBUTE25,EATTRIBUTE26,EATTRIBUTE27,EATTRIBUTE28,EATTRIBUTE29,EATTRIBUTE30 from ICSWareHouseLotInfo
|
|
where LotNo='{1}' and WorkPoint='{2}'
|
|
update ICSWareHouseLotInfo set Quantity={5}+ISNULL(LockQuantity,0)
|
|
where LotNo='{1}' and WorkPoint='{2}' ";
|
|
}
|
|
else
|
|
{
|
|
sqls += @"UPDATE ICSInventoryLot SET ExpirationDate=DateAdd(DAY,Convert(Int,(select F_Define1 from Sys_SRM_ItemsDetail
|
|
where F_ItemCode='Delay_day')),GETDATE())
|
|
WHERE LotNo='{1}' AND WorkPoint='{2}'
|
|
insert into ICSInventoryLot
|
|
select NEWID(),'{6}',InvCode,ProductDate,ExpirationDate,Quantity-{7},Amount,ExtensionID,'21',null,null,null,'{8}','{9}'
|
|
,GETDATE(),WorkPoint,'{1}',EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9
|
|
,EATTRIBUTE10,EATTRIBUTE11,EATTRIBUTE12,EATTRIBUTE13,EATTRIBUTE14,EATTRIBUTE15,EATTRIBUTE16
|
|
,EATTRIBUTE17,EATTRIBUTE18,EATTRIBUTE19,EATTRIBUTE20,EATTRIBUTE21,EATTRIBUTE22,EATTRIBUTE23
|
|
,EATTRIBUTE24,EATTRIBUTE25,EATTRIBUTE26,EATTRIBUTE27,EATTRIBUTE28,EATTRIBUTE29,EATTRIBUTE30 from ICSInventoryLot
|
|
where LotNo='{1}' and WorkPoint='{2}'
|
|
insert into ICSInventoryLotDetail
|
|
select '{6}',TransID,TransCode,TransSequence,'{8}','{9}',GETDATE(),WorkPoint
|
|
,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7
|
|
,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10,EATTRIBUTE11,EATTRIBUTE12,EATTRIBUTE13,EATTRIBUTE14,EATTRIBUTE15,EATTRIBUTE16
|
|
,EATTRIBUTE17,EATTRIBUTE18,EATTRIBUTE19,EATTRIBUTE20,EATTRIBUTE21,EATTRIBUTE22,EATTRIBUTE23
|
|
,EATTRIBUTE24,EATTRIBUTE25,EATTRIBUTE26,EATTRIBUTE27,EATTRIBUTE28,EATTRIBUTE29,EATTRIBUTE30 from ICSInventoryLotDetail
|
|
where LotNo='{1}' and WorkPoint='{2}'
|
|
insert into ICSWareHouseLotInfo
|
|
select NEWID(),'{6}',WarehouseCode,LocationCode,InvCode,Quantity-{7}-isnull(LockQuantity,0),InDate,0,0,0,'{8}','{9}'
|
|
,GETDATE(),WorkPoint,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8
|
|
,EATTRIBUTE9,EATTRIBUTE10,EATTRIBUTE11,EATTRIBUTE12,EATTRIBUTE13,EATTRIBUTE14,EATTRIBUTE15,EATTRIBUTE16
|
|
,EATTRIBUTE17,EATTRIBUTE18,EATTRIBUTE19,EATTRIBUTE20,EATTRIBUTE21,EATTRIBUTE22,EATTRIBUTE23
|
|
,EATTRIBUTE24,EATTRIBUTE25,EATTRIBUTE26,EATTRIBUTE27,EATTRIBUTE28,EATTRIBUTE29,EATTRIBUTE30 from ICSWareHouseLotInfo
|
|
where LotNo='{1}' and WorkPoint='{2}'
|
|
update ICSWareHouseLotInfo set Quantity={5}+ISNULL(LockQuantity,0)
|
|
where LotNo='{1}' and WorkPoint='{2}'";
|
|
}
|
|
}
|
|
sqls = string.Format(sqls, jo["DNCode"].ToString(), jo["LotNo"].ToString(), WorkPoint, MUSER, MUSERNAME, YLotQty, newlotStr, YLotQty, MUSER, MUSERNAME, jo["Memo"].ToString());
|
|
}
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sqls) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "保存失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
//生成采购拒收单
|
|
public string CreateRejection(string keyValue)
|
|
{
|
|
string msg = "";
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode,a.Sequence,a.ExtensionID,a.PODetailID from ICSDeliveryNotice a
|
|
inner join ICSASNDetail b on a.ASNCode=b.ASNCode
|
|
left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint AND c.ExtensionID=a.ExtensionID
|
|
left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
|
|
inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
|
|
WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
|
|
|
|
DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
|
|
|
|
string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,DNDetailID,DNID,b.LotNo,c.ExtensionID,a.PODetailID
|
|
from ICSDeliveryNotice a
|
|
left join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint AND a.ExtensionID=c.ExtensionID
|
|
left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
|
|
inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
|
|
left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint AND d.Enable='1'
|
|
WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
|
|
|
|
DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
|
|
|
|
List<RejectionHead> asn = new List<RejectionHead>();
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
RejectionHead ass = new RejectionHead();
|
|
ass.VenCode = dt.Rows[i]["VenCode"].ToString();
|
|
ass.ID = dt.Rows[i]["DNID"].ToString();
|
|
ass.DepCode = dt.Rows[i]["DepCode"].ToString();
|
|
ass.DNCode = dt.Rows[i]["DNCode"].ToString();
|
|
ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
ass.MTIME = System.DateTime.Now.ToString("s");
|
|
ass.WorkPoint = WorkPoint;
|
|
DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "' and ExtensionID='"+ dt.Rows[i]["ExtensionID"].ToString() + "' and PODetailID='"+ dt.Rows[i]["PODetailID"].ToString() + "'");
|
|
|
|
|
|
// DataRow[] drs = dtD.Select($"DNID='{dt.Rows[i]["DNID"]}' AND ExtensionID='{dt.Rows[i]["ExtensionID"]}'");
|
|
|
|
for (int j = 0; j < drs.Length; j++)
|
|
{
|
|
RejectionBody DetailList = new RejectionBody();
|
|
DetailList.Sequence = (j + 1).ToString();
|
|
DetailList.InvCode = drs[j]["InvCode"].ToString();
|
|
DetailList.Quantity = drs[j]["Quantity"].ToString();
|
|
DetailList.Amount = drs[j]["Amount"].ToString();
|
|
DetailList.Currency = drs[j]["Currency"].ToString();
|
|
DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
|
|
DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();
|
|
DetailList.LotNo = drs[j]["LotNo"].ToString();
|
|
|
|
ass.detail.Add(DetailList);
|
|
}
|
|
asn.Add(ass);
|
|
}
|
|
string input = JsonConvert.SerializeObject(asn);
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDoc/Create";
|
|
string result = HttpPost(APIURL, input);
|
|
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 CreateWLYRejection(string keyValue)
|
|
{
|
|
string msg = "";
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
//string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
|
|
// inner join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
// left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
|
|
// left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
|
|
// inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
|
|
// WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
|
|
string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
|
|
left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
|
|
left join dbo.ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
|
|
-- left JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
|
|
WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
|
|
|
|
//string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,DNDetailID,DNID,b.LotNo
|
|
// from ICSDeliveryNotice a
|
|
// left join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
// left join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
|
|
// left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
|
|
// inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
|
|
// left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint
|
|
// WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
|
|
string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,DNDetailID,DNID,d.LotNo
|
|
from ICSDeliveryNotice a
|
|
left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
|
|
left join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --AND a.ExtensionID=c.ExtensionID
|
|
inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
|
|
left join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
|
|
WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ") ";
|
|
DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
|
|
|
|
List<RejectionHead> asn = new List<RejectionHead>();
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
RejectionHead ass = new RejectionHead();
|
|
ass.VenCode = dt.Rows[i]["VenCode"].ToString();
|
|
ass.ID = dt.Rows[i]["DNID"].ToString();
|
|
ass.DepCode = dt.Rows[i]["DepCode"].ToString();
|
|
ass.DNCode = dt.Rows[i]["DNCode"].ToString();
|
|
ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
ass.MTIME = System.DateTime.Now.ToString("s");
|
|
ass.WorkPoint = WorkPoint;
|
|
DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "'");
|
|
|
|
for (int j = 0; j < drs.Length; j++)
|
|
{
|
|
RejectionBody DetailList = new RejectionBody();
|
|
DetailList.Sequence = (j + 1).ToString();
|
|
DetailList.InvCode = drs[j]["InvCode"].ToString();
|
|
DetailList.Quantity = drs[j]["Quantity"].ToString();
|
|
DetailList.Amount = drs[j]["Amount"].ToString();
|
|
DetailList.Currency = drs[j]["Currency"].ToString();
|
|
DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
|
|
DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();
|
|
DetailList.LotNo = drs[j]["LotNo"].ToString();
|
|
|
|
ass.detail.Add(DetailList);
|
|
}
|
|
asn.Add(ass);
|
|
}
|
|
string input = JsonConvert.SerializeObject(asn);
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDocNoTrans/Create";
|
|
string result = HttpPost(APIURL, input);
|
|
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 CreateWWRejection(string keyValue)
|
|
{
|
|
string msg = "";
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode from ICSODeliveryNotice a
|
|
left join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
|
|
inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
|
|
left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
|
|
inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
|
|
WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
|
|
|
|
string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,ODNDetailID,ODNID,b.LotNo
|
|
from ICSODeliveryNotice a
|
|
inner join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
inner join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint AND a.ExtensionID=c.ExtensionID
|
|
left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
|
|
inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND c.WorkPoint=l.WorkPoint
|
|
inner join ICSInspection d on c.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint and d.Enable='1'
|
|
WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
|
|
DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
|
|
|
|
List<WWRejectionHead> asn = new List<WWRejectionHead>();
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
WWRejectionHead ass = new WWRejectionHead();
|
|
ass.VenCode = dt.Rows[i]["VenCode"].ToString();
|
|
ass.ID = dt.Rows[i]["ODNID"].ToString();
|
|
ass.DepCode = dt.Rows[i]["DepCode"].ToString();
|
|
ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
|
|
ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
ass.MTIME = System.DateTime.Now.ToString("s");
|
|
ass.WorkPoint = WorkPoint;
|
|
|
|
DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
|
|
|
|
for (int j = 0; j < drs.Length; j++)
|
|
{
|
|
WWRejectionBody DetailList = new WWRejectionBody();
|
|
DetailList.Sequence = (j + 1).ToString();
|
|
DetailList.InvCode = drs[j]["InvCode"].ToString();
|
|
DetailList.Quantity = drs[j]["Quantity"].ToString();
|
|
DetailList.Amount = drs[j]["Amount"].ToString();
|
|
DetailList.Currency = drs[j]["Currency"].ToString();
|
|
DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
|
|
DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
|
|
DetailList.LotNo = drs[j]["LotNo"].ToString();
|
|
|
|
ass.detail.Add(DetailList);
|
|
}
|
|
asn.Add(ass);
|
|
}
|
|
string input = JsonConvert.SerializeObject(asn);
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDoc/Create";
|
|
string result = HttpPost(APIURL, input);
|
|
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 CreateWWWLYRejection(string keyValue)
|
|
{
|
|
string msg = "";
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode
|
|
from ICSODeliveryNotice a
|
|
left join ICSInventoryLotDetail e on a.ODNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
|
|
inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND e.WorkPoint=d.WorkPoint
|
|
left JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
|
|
WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
|
|
|
|
string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,ODNDetailID,ODNID,c.LotNo
|
|
from ICSODeliveryNotice a
|
|
left join ICSInventoryLotDetail e on a.ODNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
|
|
inner join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and e.WorkPoint=c.WorkPoint --AND a.ExtensionID=c.ExtensionID
|
|
inner join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
|
|
WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
|
|
DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
|
|
|
|
List<WWRejectionHead> asn = new List<WWRejectionHead>();
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
WWRejectionHead ass = new WWRejectionHead();
|
|
ass.VenCode = dt.Rows[i]["VenCode"].ToString();
|
|
ass.ID = dt.Rows[i]["ODNID"].ToString();
|
|
ass.DepCode = dt.Rows[i]["DepCode"].ToString();
|
|
ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
|
|
ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
ass.MTIME = System.DateTime.Now.ToString("s");
|
|
ass.WorkPoint = WorkPoint;
|
|
|
|
DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
|
|
|
|
for (int j = 0; j < drs.Length; j++)
|
|
{
|
|
WWRejectionBody DetailList = new WWRejectionBody();
|
|
DetailList.Sequence = (j + 1).ToString();
|
|
DetailList.InvCode = drs[j]["InvCode"].ToString();
|
|
DetailList.Quantity = drs[j]["Quantity"].ToString();
|
|
DetailList.Amount = drs[j]["Amount"].ToString();
|
|
DetailList.Currency = drs[j]["Currency"].ToString();
|
|
DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
|
|
DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
|
|
DetailList.LotNo = drs[j]["LotNo"].ToString();
|
|
|
|
ass.detail.Add(DetailList);
|
|
}
|
|
asn.Add(ass);
|
|
}
|
|
string input = JsonConvert.SerializeObject(asn);
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDocNoTrans/Create";
|
|
string result = HttpPost(APIURL, input);
|
|
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 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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除拒收单
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DelectRejection(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = string.Format(@"DELETE FROM dbo.ICSDeliveryNotice WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 删除委外拒收单
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DelectWWRejection(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = string.Format(@"DELETE FROM dbo.ICSODeliveryNotice WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetInventoryInspection(ref Pagination jqgridparam, string InvCode, int SampleQuantity, string ResultINp)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
if (ResultINp == "")
|
|
{
|
|
sql = "SELECT 1 AS NUM INTO #TEmpType";
|
|
for (int i = 2; i <= SampleQuantity; i++)
|
|
{
|
|
sql += @" UNION
|
|
SELECT " + i + " AS NUM";
|
|
}
|
|
|
|
sql += @" select c.ID,a.GroupCode,a.GroupName,c.InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,c.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result
|
|
INTO #TEmpTypedetail from ICSInventoryInspectionGroup a
|
|
left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetail c on b.ListCode=c.ListCode and b.ListName=c.ListName and b.WorkPoint=c.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'
|
|
|
|
SELECT a.NUM, NEWID() AS ID,b.GroupCode,b.GroupName,b.InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,b.SetValue,CASE WHEN b.Result='0' THEN '不合格' when ISNULL(b.Result,'')='' THEN '' ELSE '合格' END AS Result INTO ##SUMCount FROM #TEmpType a ,#TEmpTypedetail b ORDER BY a.NUM,b.GroupCode ASC
|
|
|
|
";
|
|
sql = string.Format(sql, InvCode, WorkPoint);
|
|
return SqlHelper.FindTablePageBySql_OtherTemp(sql.ToString(), " " + "##SUMCount" + " ", " DROP TABLE #TEmpType;DROP TABLE #TEmpTypedetail;DROP TABLE ##SUMCount", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
else
|
|
{
|
|
sql += @" select c.EATTRIBUTE1 as NUM, c.ID,a.GroupCode,a.GroupName,c.InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,c.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result
|
|
from ICSInventoryInspectionGroup a
|
|
left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetail c on b.ListCode=c.ListCode and b.ListName=c.ListName and b.WorkPoint=c.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'
|
|
|
|
";
|
|
sql = string.Format(sql, InvCode, WorkPoint);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
}
|
|
|
|
public string SaveICSInspectionDetail(string ICSMTDOC, string InvCode, string ResultINp)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
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 sql = string.Empty;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
|
|
bool ISOK = false;
|
|
string ID = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
ID = jo["InspectionID"].ToString();
|
|
if (string.IsNullOrWhiteSpace(ResultINp))
|
|
{
|
|
sql += @"
|
|
INSERT INTO dbo.ICSInspectionDetail
|
|
( ID ,InspectionID ,ListCode ,ListName ,
|
|
Unit ,SetValueMax ,SetValueMin ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName,EATTRIBUTE1)
|
|
values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',getdate(),'{10}','{11}','{12}','{13}')";
|
|
sql = string.Format(sql, jo["InspectionID"].ToString(), jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(), jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString(), jo["NUM"].ToString());
|
|
}
|
|
else
|
|
{
|
|
sql += @" update ICSInspectionDetail set InspectionID='{0}',ListCode='{1}',ListName='{2}', Unit='{3}' ,SetValueMax='{4}' ,SetValueMin='{5}' ,SetValue='{6}' ,Result='{7}', MUSER='{8}' ,MUSERName='{9}' ,MTIME=getdate(), WorkPoint='{10}', GroupCode='{11}', GroupName='{12}',EATTRIBUTE1='{14}' where ID='{13}'";
|
|
sql = string.Format(sql, jo["InspectionID"].ToString(), jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(), jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString(), jo["ID"].ToString(), jo["NUM"].ToString());
|
|
}
|
|
if (jo["Result"].ToString() == "0")
|
|
{
|
|
ISOK = true;
|
|
}
|
|
|
|
}
|
|
if (ISOK == true)
|
|
{
|
|
sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
|
|
sql = string.Format(sql, 0, ID);
|
|
}
|
|
else
|
|
{
|
|
sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
|
|
sql = string.Format(sql, 1, ID);
|
|
}
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "绑定失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 上传招标文件
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public int InsertICSInspectionFile(string ID, string UploadfileName, string fileName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string sql = "";
|
|
sql += string.Format(@"Insert into ICSInspectionFile(ID,InspectionID,FileCode,FileName,MUSER,MUSERName,MTIME,WorkPoint) values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GetDate(),'{5}')", ID, UploadfileName, fileName, MUSER, MUSERName, WorkPoint);
|
|
sql += "\r\n";
|
|
StringBuilder Str = new StringBuilder(sql);
|
|
return Repository().ExecuteBySql(Str);
|
|
}
|
|
|
|
|
|
public DataTable GetICSInspection8(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
//string ERPSign = Configs.GetValue("ERPSign");
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
|
|
sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
|
|
drop table #TempMOData_8
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
|
|
drop table #TempMOData_8_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
|
|
drop table #TempIcsinsp_8
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,EATTRIBUTE2,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode{2}
|
|
into #TempIcsinsp_8
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
select DISTINCT
|
|
a.ID as DHID,
|
|
d.ID ,
|
|
h.ID as JYID,
|
|
a.DNCode ,
|
|
a.Sequence ,
|
|
a.ASNCode ,
|
|
--l.POCode,
|
|
c.InvCode ,
|
|
c.InvName ,
|
|
c.INVSTD ,
|
|
c.ClassName,
|
|
c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(d.Quantity as decimal(18,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
c.InvUnit ,
|
|
d.LotNo ,
|
|
g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,
|
|
j.BadCode as BCCodeValue,
|
|
j.BadDesc as BadDesc,
|
|
k.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName,
|
|
CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
|
|
CONVERT(VARCHAR(100),d.MTime,120) as LotCreateDateTime,
|
|
CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
a.VenCode,
|
|
m.VenName,
|
|
isnull(h.MUSERName,'') as Surveyor,
|
|
--isnull(h.EATTRIBUTE2,'') as InspectionEATTRIBUTE2,
|
|
h.mtime as ProvingTime
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName,c.InvIQC{3}
|
|
into #TempMOData_8
|
|
FROM ICSDeliveryNotice a
|
|
--inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint-- and c.InvIQC='1'
|
|
inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint and d.type='7'
|
|
LEFT JOIN #TempIcsinsp_8 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint --and Enable='1'
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
|
|
left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
|
|
left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
where d.LotNo is not null and a.DNType='1' {0} and a.workpoint='{1}' and Isnull(d.EATTRIBUTE1,'') = ''
|
|
|
|
select * into #TempMOData_8_1 from #TempMOData_8 where InvIQC='1'
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
//{
|
|
// wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
//{
|
|
// wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
|
|
{
|
|
string printState = queryParam["selIsPrint"].ToString();
|
|
if (printState == "否")
|
|
wheresql += " and isnull(task.ValueParameters,'') ='' ";
|
|
else if (printState == "是")
|
|
wheresql += " and isnull(task.ValueParameters,'') <>''";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_8_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
|
|
drop table #TempMOData_8
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
|
|
drop table #TempMOData_8_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
|
|
drop table #TempIcsinsp_8 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetICSInspection9(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
#region
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
|
|
drop table #TempMOData_9
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
|
|
drop table #TempMOData_9_1
|
|
|
|
|
|
select
|
|
a.ID as DHID,
|
|
d.ID ,
|
|
h.ID as JYID,
|
|
a.ODNCode as DNCode ,
|
|
a.Sequence ,
|
|
a.OASNCode ,
|
|
c.InvCode ,
|
|
c.InvName ,
|
|
c.INVSTD ,
|
|
c.ClassName,
|
|
c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
f.BatchCode ,
|
|
CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
CONVERT(VARCHAR(100),d.MTime,120) as LotCreateDateTime,
|
|
c.InvUnit ,
|
|
d.LotNo ,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,
|
|
j.BadCode as BCCodeValue,
|
|
j.BadDesc as BadDesc,
|
|
k.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName,
|
|
CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,c.InvIQC
|
|
into #TempMOData_9
|
|
FROM ICSODeliveryNotice a
|
|
inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
|
|
inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='8'
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
where 1=1 {0} and a.workpoint='{1}'
|
|
|
|
select * into #TempMOData_9_1 from #TempMOData_9 where InvIQC='1'";
|
|
#endregion
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
//{
|
|
// wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
//{
|
|
// wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
|
|
{
|
|
string printState = queryParam["selIsPrint"].ToString();
|
|
if (printState == "否")
|
|
wheresql += " and isnull(task.ValueParameters,'') ='' ";
|
|
else if (printState == "是")
|
|
wheresql += " and isnull(task.ValueParameters,'') <>''";
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
sql = string.Format(sql, wheresql, WorkPoint);
|
|
//sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_9_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
|
|
drop table #TempMOData_9
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
|
|
drop table #TempMOData_9_1 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetICSInspection10(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
|
|
drop table #TempMOData_10
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
|
|
drop table #TempMOData_10_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
|
|
drop table #TempIcsinsp_10
|
|
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
|
|
SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode{2}
|
|
into #TempIcsinsp_10
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
select DISTINCT a.ID as GDID, e.ID , a.MOCode as DNCode, a.Sequence , h.ID as JYID, pick.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber, c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
isnull(h.MUSERName,'') as Surveyor, h.mtime as ProvingTime
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC{3}
|
|
into #TempMOData_10
|
|
from ICSMO a
|
|
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
LEFT JOIN ICSMOPick pick ON a.MODetailID=pick.MODetailID AND a.WorkPoint=pick.WorkPoint AND pick.EATTRIBUTE1='1'
|
|
left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence+'~'+ pick.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
|
|
LEFT JOIN #TempIcsinsp_10 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where a.MOStatus<>'3' and e.LotNO is not null {0} and a.workpoint='{1}'
|
|
|
|
select * into #TempMOData_10_1 from #TempMOData_10 where InvIQC='1' ";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
//sql = string.Format(sql, wheresql, WorkPoint);
|
|
sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_10_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
|
|
drop table #TempMOData_10
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
|
|
drop table #TempMOData_10_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
|
|
drop table #TempIcsinsp_10 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
//在库检验
|
|
public DataTable GetICSInspection11(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
try
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select DISTINCT a.ID as GDID, e.ID AS LotID , a.InspectCode as DNCode, d.Sequence , d.ID as ID, e.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
|
|
f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, g.Quantity-ISNULL(g.LockQuantity,0) as AllNumber,
|
|
Case When d.EATTRIBUTE1='未检验' Then 0 Else d.InspectQuantity END as YLOTQTY ,
|
|
Case When d.EATTRIBUTE1='未检验' Then 0 Else Convert(decimal(18,4),d.Quantity)-Convert(decimal(18,4),d.InspectQuantity) END as NLOTQTY,
|
|
Case When a.Type=0 Then '标准检验' ELSE '超期检验' END AS DocType,
|
|
c.InvUnit , d.LotNo ,i.ContainerID,CONVERT(varchar(100), e.ExpirationDate, 23) AS ExpirationDate,
|
|
isnull(a.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),a.MTIME,120) as MTIME,
|
|
d.EATTRIBUTE1 AS TestState,c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
isnull(d.MUSERName,'') as Surveyor, d.MTIME as ProvingTime,
|
|
a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
|
|
a.EATTRIBUTE9,a.EATTRIBUTE10,K.BadReasonDesc as BadReasonDesc ,
|
|
K.BadReasonCode as BRCodeValue,L.BadCode as BCCodeValue, L.BadDesc as BadDesc,d.EATTRIBUTE10 AS Memo
|
|
from ICSInspect a
|
|
inner join ICSInspectDetail d on d.InspectCode=a.InspectCode and d.WorkPoint=a.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=d.LotNo AND e.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSWareHouseLotInfo g ON g.LotNo=e.LotNo and g.WorkPoint=e.WorkPoint
|
|
inner JOIN dbo.ICSInventory c ON c.InvCode=e.InvCode AND c.WorkPoint=e.WorkPoint --and c.InvIQC='1'
|
|
left join ICSExtension f on f.ID=e.ExtensionID and f.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
|
|
LEFT JOIN DBO.ICSInspection J ON J.LotNo=D.LotNo AND J.EATTRIBUTE1=d.InspectCode AND J.WorkPoint=d.WorkPoint AND J.Enable=1
|
|
LEFT JOIN DBO.ICSBadReason K ON K.BadReasonCode=J.BRCode AND K.WorkPoint=J.WorkPoint
|
|
LEFT JOIN DBO.ICSBadCode L ON L.BadCode=J.BCCode AND L.WorkPoint=J.WorkPoint
|
|
where g.LotNO is not null {0} ";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.InspectCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and e.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and d.LotNo like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and d.EATTRIBUTE1='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and d.EATTRIBUTE1='未检验'";
|
|
else if (ReleaseState == "3")
|
|
wheresql += " and d.EATTRIBUTE1='已审核'";
|
|
else if (ReleaseState == "4")
|
|
wheresql += " and d.EATTRIBUTE1='已复审'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))!=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
|
|
}
|
|
}
|
|
if (DataActionsql != "")
|
|
{
|
|
sql += DataActionsql;
|
|
}
|
|
sql = string.Format(sql, wheresql);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
public DataTable GetICSInspection22(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
#region
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_22'))
|
|
drop table #TempMOData_22
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_22_1'))
|
|
drop table #TempMOData_22_1
|
|
|
|
|
|
select
|
|
a.ID as DHID,
|
|
d.ID ,
|
|
h.ID as JYID,
|
|
a.RCVCode as DNCode ,
|
|
a.Sequence ,
|
|
c.InvCode ,
|
|
c.InvName ,
|
|
c.INVSTD ,
|
|
c.ClassName,
|
|
f.BatchCode ,
|
|
CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
c.InvUnit ,c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
d.LotNo ,
|
|
g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,
|
|
j.BadCode as BCCodeValue,
|
|
j.BadDesc as BadDesc,
|
|
k.ContainerID,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
isnull(h.MUSERName,'开发者') MUSERName,
|
|
CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,c.InvIQC
|
|
into #TempMOData_22
|
|
FROM ICSPurchaseReceive a
|
|
inner join ICSInventoryLotDetail e on e.TransCode =a.RCVCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
|
|
inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='22'
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where 1=1 {0} and a.workpoint='{1}'
|
|
|
|
select * into #TempMOData_22_1 from #TempMOData_22 where InvIQC='1'";
|
|
#endregion
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
//{
|
|
// wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
//{
|
|
// wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
//{
|
|
// wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
//{
|
|
// wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString() == "0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
sql = string.Format(sql, wheresql, WorkPoint);
|
|
//sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_22_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_22'))
|
|
drop table #TempMOData_22
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_22_1'))
|
|
drop table #TempMOData_22_1 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
public DataTable GetICSInspection23(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
#region
|
|
string sql = @"
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_23'))
|
|
drop table #TempMOData_23
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_23_1'))
|
|
drop table #TempMOData_23_1
|
|
|
|
|
|
select
|
|
a.ID as DHID,
|
|
d.ID ,
|
|
h.ID as JYID,
|
|
a.RCVCode as DNCode ,
|
|
a.Sequence ,
|
|
c.InvCode ,
|
|
c.InvName ,
|
|
c.INVSTD ,
|
|
c.ClassName,
|
|
f.BatchCode ,
|
|
CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
|
|
CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
|
|
c.InvUnit ,c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
d.LotNo ,
|
|
g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,
|
|
j.BadCode as BCCodeValue,
|
|
j.BadDesc as BadDesc,
|
|
k.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName,
|
|
CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,c.InvIQC
|
|
into #TempMOData_23
|
|
FROM ICSOutsourcingReceive a
|
|
inner join ICSInventoryLotDetail e on e.TransCode =a.RCVCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
|
|
inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='23'
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint
|
|
where 1=1 {0} and a.workpoint='{1}'
|
|
|
|
select * into #TempMOData_23_1 from #TempMOData_23 where InvIQC='1'";
|
|
#endregion
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
//{
|
|
// wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
//{
|
|
// wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
//{
|
|
// wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
//{
|
|
// wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString()))
|
|
{
|
|
wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString()))
|
|
{
|
|
if (queryParam["selIsWH"].ToString()=="0")
|
|
{
|
|
wheresql += " and lotInfo.ID is null ";
|
|
}
|
|
if (queryParam["selIsWH"].ToString() == "1")
|
|
{
|
|
wheresql += " and lotInfo.ID is not null ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
sql = string.Format(sql, wheresql, WorkPoint);
|
|
//sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_23_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_23'))
|
|
drop table #TempMOData_23
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_23_1'))
|
|
drop table #TempMOData_23_1 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
public DataTable GetInventoryInspectionNew(ref Pagination jqgridparam, string InvCode, int? SampleQuantity, string ResultINp, string JYID,string LotNo)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
if (ResultINp == "")
|
|
{
|
|
sql += @" IF EXISTS (SELECT ID FROM ICSInspectionDetailGroup WHERE InspectionID='{3}' )
|
|
BEGIN
|
|
declare @sql varchar(8000)
|
|
select distinct b.ID,a.GroupCode,a.GroupName,e.EATTRIBUTE2,c.InspectionID,b.ListCode, c.UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result,d.Sequence
|
|
into #TempSORRFQ
|
|
from ICSInventoryInspectionGroup a
|
|
left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint
|
|
left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
|
|
left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'and c.InspectionID='{3}' and e.EATTRIBUTE1='1'
|
|
If (SELECT top 1 Sequence FROM #TempSORRFQ) is not null
|
|
BEGIN
|
|
select @sql=isnull(@sql+',','')+' ['+Sequence+']'
|
|
from(select distinct Sequence from #TempSORRFQ)as a
|
|
set @sql='SELECT STUFF((select'','' + Sequence from (SELECT DISTINCT Sequence FROM #TempSORRFQ ) DD for xml path('''')),1,1,'''') as IsTou,*
|
|
FROM #TempSORRFQ PIVOT(MAX(SetValue) FOR Sequence IN ('+@sql+'))a '
|
|
exec(@sql);
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
SELECT * FROM #TempSORRFQ
|
|
END
|
|
drop table #TempSORRFQ;
|
|
END
|
|
|
|
ELSE
|
|
BEGIN
|
|
select DISTINCT b.ID,a.GroupCode,a.GroupName,e.EATTRIBUTE2,d.ID as InspectionID,b.ListCode, c.UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result
|
|
from ICSInventoryInspectionGroup a
|
|
left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint and c.InspectionID='{3}'
|
|
left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
|
|
left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}' and e.EATTRIBUTE1='1'
|
|
END
|
|
|
|
";
|
|
sql = string.Format(sql, InvCode, WorkPoint, JYID,LotNo);
|
|
return SqlHelper.CmdExecuteDataTable(sql);
|
|
}
|
|
else
|
|
{
|
|
sql += @" declare @sql varchar(8000)
|
|
select b.ID,a.GroupCode,a.GroupName,e.EATTRIBUTE2,c.InspectionID,b.ListCode, c.UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result,d.Sequence,c.EATTRIBUTE1 BadReason,c.EATTRIBUTE2 SamplingQuantity
|
|
into #TempSORRFQ
|
|
from ICSInventoryInspectionGroup a
|
|
inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint
|
|
left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
|
|
left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'and (c.InspectionID='{2}' or c.InspectionID='{3}' ) and e.EATTRIBUTE1='1'
|
|
|
|
If (SELECT top 1 Sequence FROM #TempSORRFQ) is not null
|
|
BEGIN
|
|
|
|
select @sql=isnull(@sql+',','')+' ['+Sequence+']'
|
|
from(select distinct Sequence from #TempSORRFQ)as a
|
|
set @sql='SELECT STUFF((select'','' + Sequence from (SELECT DISTINCT Sequence FROM #TempSORRFQ ) DD for xml path('''')),1,1,'''') as IsTou,*
|
|
FROM #TempSORRFQ PIVOT(MAX(SetValue) FOR Sequence IN ('+@sql+'))a '
|
|
exec(@sql)
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
SELECT * FROM #TempSORRFQ
|
|
END
|
|
";
|
|
sql = string.Format(sql, InvCode, WorkPoint, JYID, LotNo);
|
|
return SqlHelper.FindTablePageBySql_OtherTempSORRFQ(sql.ToString(), " " + "#TempSORRFQ" + " ", " drop table #TempSORRFQ", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
}
|
|
|
|
|
|
public DataTable GetInventoryInspectionNew1(ref Pagination jqgridparam, string InvCode, int? SampleQuantity, string ResultINp, string JYID, string LotNo)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
if (ResultINp == "")
|
|
{
|
|
sql += @"
|
|
select DISTINCT b.ID,a.GroupCode,a.GroupName,e.EATTRIBUTE2,d.ID as InspectionID,b.ListCode, c.UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN 'OK' ELSE '合格' END AS Result
|
|
from ICSInventoryInspectionGroup a
|
|
left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint and c.InspectionID='{3}'
|
|
left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
|
|
left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}' and e.EATTRIBUTE1='2'
|
|
|
|
|
|
";
|
|
sql = string.Format(sql, InvCode, WorkPoint, JYID, LotNo);
|
|
return SqlHelper.CmdExecuteDataTable(sql);
|
|
}
|
|
else
|
|
{
|
|
sql += @" declare @sql varchar(8000)
|
|
select b.ID,a.GroupCode,a.GroupName,e.EATTRIBUTE2,c.InspectionID,b.ListCode, c.UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN 'OK' ELSE '合格' END AS Result,d.Sequence,c.EATTRIBUTE1 BadReason,c.EATTRIBUTE2 SamplingQuantity
|
|
into #TempSORRFQ
|
|
from ICSInventoryInspectionGroup a
|
|
inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint
|
|
left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
|
|
left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'and (c.InspectionID='{2}' or c.InspectionID='{3}' ) and e.EATTRIBUTE1='2'
|
|
|
|
If (SELECT top 1 Sequence FROM #TempSORRFQ) is not null
|
|
BEGIN
|
|
|
|
select @sql=isnull(@sql+',','')+' ['+Sequence+']'
|
|
from(select distinct Sequence from #TempSORRFQ)as a
|
|
set @sql='SELECT STUFF((select'','' + Sequence from (SELECT DISTINCT Sequence FROM #TempSORRFQ ) DD for xml path('''')),1,1,'''') as IsTou,*
|
|
FROM #TempSORRFQ PIVOT(MAX(SetValue) FOR Sequence IN ('+@sql+'))a '
|
|
exec(@sql)
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
SELECT * FROM #TempSORRFQ
|
|
END
|
|
";
|
|
sql = string.Format(sql, InvCode, WorkPoint, JYID, LotNo);
|
|
return SqlHelper.FindTablePageBySql_OtherTempSORRFQ(sql.ToString(), " " + "#TempSORRFQ" + " ", " drop table #TempSORRFQ", parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
}
|
|
public DataTable GetRulesDetail(string LotNo)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
//增加pp子表查询 主要查询U8到货单数量
|
|
sql = @"select DISTINCT
|
|
CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
|
|
b.LotNo ,
|
|
b.Quantity,
|
|
'抽检',
|
|
g.RulesCode,
|
|
c.InvCode,
|
|
c.InvStd,
|
|
c.InvName,h.UnqualifiedQuantity,h.EATTRIBUTE2,h.EATTRIBUTE3,h.WaiveQuantity,h.EATTRIBUTE4
|
|
FROM ICSDeliveryNotice a
|
|
inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
|
|
inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
|
|
left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint --and Enable='1'
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup g ON c.InvCode=g.InvCode AND c.WorkPoint=g.WorkPoint
|
|
Where b.LotNo='" + LotNo + "'";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 检验保存
|
|
/// </summary>
|
|
/// <param name="ICSMTDOC"></param>
|
|
/// <param name="InvCode"></param>
|
|
/// <param name="ResultINp"></param>
|
|
/// <returns></returns>
|
|
public string SaveICSInspectionDetailNew(string ICSMTDOC, string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string Filtering,string SpecialNumber, string ResultINp, string SpecialPicks, string Lot, string Type, decimal CJQty)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
object CARID = Guid.NewGuid();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
|
|
bool ISOK = false;
|
|
string ID = string.Empty;
|
|
string sql = $@"DELETE from ICSInspectionDetail where DetailGroupID in(SELECT ID from ICSInspectionDetailGroup where InspectionID='{Lot}' AND workPoint='{WorkPoint}')
|
|
DELETE from ICSInspectionDetailGroup where InspectionID='{Lot}' AND workPoint='{WorkPoint}'";
|
|
if (string.IsNullOrEmpty(JYID) || JYID == "null")
|
|
{
|
|
sql += $@"
|
|
INSERT INTO dbo.ICSInspection ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4)
|
|
Values('{CARID}','{Lot}','{InvCode}','{AllNumber}','{YLOTQTY}','{NLOTQTY}','{WaiveQuantity}','','','{Type}',getdate(),'{MUSER}','{MUSERNAME}','{WorkPoint}','1','{CJQty}','{Filtering}','{SpecialNumber}','{SpecialPicks}')
|
|
";
|
|
|
|
}
|
|
else
|
|
{
|
|
CARID = JYID;
|
|
}
|
|
foreach (var item in res)
|
|
{
|
|
string Guids = Guid.NewGuid().ToString();
|
|
JObject jo = (JObject)item;
|
|
JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString());
|
|
sql += @"
|
|
INSERT INTO dbo.ICSInspectionDetailGroup
|
|
( ID ,InspectionID,ListCode ,ListName ,
|
|
Unit ,SetValueMax ,SetValueMin ,UnqualifiedQuantity ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName,EATTRIBUTE1,EATTRIBUTE2)
|
|
values('{0}','{1}','{2}','{3}','{4}',{5},{6},{7},'{8}','{9}','{10}',getdate(),'{11}','{12}','{13}','{14}','{15}')";
|
|
var b = jo["ListCode"].ToString();
|
|
var a = jo["SetValueMin"].ToString();
|
|
|
|
sql = string.Format(sql, Guids, CARID, jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(),
|
|
jo["SetValueMax"].ToString()==""?"null": jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString() == "" ? "null" : jo["SetValueMin"].ToString(), jo["SetValue"].ToString() == "" ? "null" : jo["SetValue"].ToString(), jo["Result"].ToString()
|
|
, MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString(), jo["BadReason"].ToString(), jo["SamplingQuantity"].ToString());
|
|
|
|
foreach (var itemdetail in detailres)
|
|
{
|
|
|
|
JObject jodetail = (JObject)itemdetail;
|
|
if (string.IsNullOrWhiteSpace(ResultINp))
|
|
{
|
|
sql += @"
|
|
INSERT INTO dbo.ICSInspectionDetail
|
|
( ID ,DetailGroupID,Sequence ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint)
|
|
values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
|
|
sql = string.Format(sql, Guids, jodetail["FiledNamekey"].ToString(), jodetail["FiledNamevalue"].ToString(),
|
|
jo["Result"].ToString(),
|
|
MUSER, MUSERNAME, WorkPoint);
|
|
|
|
}
|
|
else
|
|
{
|
|
sql += @" update ICSInspectionDetail set InspectionID='{0}',ListCode='{1}',ListName='{2}', Unit='{3}' ,SetValueMax='{4}' ,SetValueMin='{5}' ,SetValue='{6}' ,Result='{7}', MUSER='{8}' ,MUSERName='{9}' ,MTIME=getdate(), WorkPoint='{10}', GroupCode='{11}', GroupName='{12}',EATTRIBUTE1='{14}' where ID='{13}'";
|
|
sql = string.Format(sql, jodetail["InspectionID"].ToString(), jodetail["ListCode"].ToString(), jodetail["ListName"].ToString(), jodetail["Unit"].ToString(), jodetail["SetValueMax"].ToString(), jodetail["SetValueMin"].ToString(), jodetail["SetValue"].ToString(), jodetail["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jodetail["GroupCode"].ToString(), jodetail["GroupName"].ToString(), jodetail["ID"].ToString(), jodetail["NUM"].ToString());
|
|
}
|
|
if (jo["Result"].ToString() == "0")
|
|
{
|
|
ISOK = true;
|
|
}
|
|
}
|
|
ID = jo["InspectionID"].ToString();
|
|
|
|
}
|
|
if (ISOK == true)
|
|
{
|
|
|
|
sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
|
|
sql = string.Format(sql, 0, CARID);
|
|
}
|
|
else
|
|
{
|
|
sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
|
|
sql = string.Format(sql, 1, CARID);
|
|
}
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "绑定失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
///// <summary>
|
|
///// 检验保存
|
|
///// </summary>
|
|
///// <param name="ICSMTDOC"></param>
|
|
///// <param name="InvCode"></param>
|
|
///// <param name="ResultINp"></param>
|
|
///// <returns></returns>
|
|
//public string SaveICSInspectionDetailNew( string ICSMTDOC,string InvCode,string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string BCCode, string BRCode, string ResultINp, string Lot, string Type, decimal CJQty)
|
|
//{
|
|
// string msg = "";
|
|
// try
|
|
// {
|
|
// object CARID = Guid.NewGuid();
|
|
// 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 sql = string.Empty;
|
|
// JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
|
|
// bool ISOK = false;
|
|
// string ID = string.Empty;
|
|
// if (string.IsNullOrEmpty(JYID)|| JYID == "null")
|
|
// {
|
|
// sql += $@"
|
|
// INSERT INTO dbo.ICSInspection ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity)
|
|
// Values('{CARID}','{Lot}','{InvCode}','{AllNumber}','{YLOTQTY}','{NLOTQTY}','{WaiveQuantity}','{BCCode}','{BRCode}','{Type}',getdate(),'{MUSER}','{MUSERNAME}','{WorkPoint}','1','{CJQty}')
|
|
// ";
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// CARID = JYID;
|
|
// }
|
|
// foreach (var item in res)
|
|
// {
|
|
// string Guids = Guid.NewGuid().ToString();
|
|
// JObject jo = (JObject)item;
|
|
// JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString());
|
|
// sql += @"
|
|
// INSERT INTO dbo.ICSInspectionDetailGroup
|
|
// ( ID ,InspectionID,ListCode ,ListName ,
|
|
// Unit ,SetValueMax ,SetValueMin ,UnqualifiedQuantity ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName)
|
|
// values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}')";
|
|
// sql = string.Format(sql, Guids, CARID, jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(),
|
|
// jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString()
|
|
// , MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString());
|
|
|
|
// foreach (var itemdetail in detailres)
|
|
// {
|
|
|
|
// JObject jodetail = (JObject)itemdetail;
|
|
// if (string.IsNullOrWhiteSpace(ResultINp))
|
|
// {
|
|
// sql += @"
|
|
// INSERT INTO dbo.ICSInspectionDetail
|
|
// ( ID ,DetailGroupID,Sequence ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint)
|
|
// values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
|
|
// sql = string.Format(sql, Guids,jodetail["FiledNamekey"].ToString(), jodetail["FiledNamevalue"].ToString(),
|
|
// jo["Result"].ToString(),
|
|
// MUSER, MUSERNAME, WorkPoint);
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// sql += @" update ICSInspectionDetail set InspectionID='{0}',ListCode='{1}',ListName='{2}', Unit='{3}' ,SetValueMax='{4}' ,SetValueMin='{5}' ,SetValue='{6}' ,Result='{7}', MUSER='{8}' ,MUSERName='{9}' ,MTIME=getdate(), WorkPoint='{10}', GroupCode='{11}', GroupName='{12}',EATTRIBUTE1='{14}' where ID='{13}'";
|
|
// sql = string.Format(sql, jodetail["InspectionID"].ToString(), jodetail["ListCode"].ToString(), jodetail["ListName"].ToString(), jodetail["Unit"].ToString(), jodetail["SetValueMax"].ToString(), jodetail["SetValueMin"].ToString(), jodetail["SetValue"].ToString(), jodetail["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jodetail["GroupCode"].ToString(), jodetail["GroupName"].ToString(), jodetail["ID"].ToString(), jodetail["NUM"].ToString());
|
|
// }
|
|
// if (jo["Result"].ToString() == "0")
|
|
// {
|
|
// ISOK = true;
|
|
// }
|
|
// }
|
|
// ID = jo["InspectionID"].ToString();
|
|
|
|
// }
|
|
// if (ISOK == true)
|
|
// {
|
|
// sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
|
|
// sql = string.Format(sql, 0, CARID);
|
|
// }
|
|
// else
|
|
// {
|
|
// sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
|
|
// sql = string.Format(sql, 1, CARID);
|
|
// }
|
|
// if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
// {
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// msg = "绑定失败";
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// msg = ex.Message;
|
|
// }
|
|
|
|
// return msg;
|
|
//}
|
|
|
|
/// <summary>
|
|
/// 检验暂存
|
|
/// </summary>
|
|
/// <param name="ICSMTDOC"></param>
|
|
/// <param name="InvCode"></param>
|
|
/// <param name="ResultINp"></param>
|
|
/// <returns></returns>
|
|
public string StagingICSInspectionDetailNew(string ICSMTDOC, string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string BCCode, string BRCode, string ResultINp, string Lot, string Type, decimal CJQty)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
object CARID = Guid.NewGuid();
|
|
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 sql = $@"IF EXISTS (SELECT ID FROM ICSInspectionDetailGroup WHERE InspectionID='{Lot}' or InspectionID='{JYID}' )
|
|
BEGIN
|
|
DELETE FROM ICSInspectionDetail WHERE DetailGroupID in (SELECT ID FROM ICSInspectionDetailGroup WHERE InspectionID='{Lot}' or InspectionID='{JYID}')
|
|
DELETE FROM ICSInspectionDetailGroup WHERE ID in (SELECT ID FROM ICSInspectionDetailGroup WHERE InspectionID='{Lot}' or InspectionID='{JYID}')
|
|
END;";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
|
|
bool ISOK = false;
|
|
string ID = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
string Guids = Guid.NewGuid().ToString();
|
|
JObject jo = (JObject)item;
|
|
JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString());
|
|
sql += @"
|
|
INSERT INTO dbo.ICSInspectionDetailGroup
|
|
( ID ,InspectionID,ListCode ,ListName ,
|
|
Unit ,SetValueMax ,SetValueMin ,UnqualifiedQuantity ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName)
|
|
values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}')";
|
|
sql = string.Format(sql, Guids, Lot, jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(),
|
|
jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString()
|
|
, MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString());
|
|
|
|
foreach (var itemdetail in detailres)
|
|
{
|
|
JObject jodetail = (JObject)itemdetail;
|
|
sql += $@"
|
|
INSERT INTO dbo.ICSInspectionDetail
|
|
( ID ,DetailGroupID,Sequence ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint)
|
|
values(newid(),'{Guids}','{jodetail["FiledNamekey"]}','{jodetail["FiledNamevalue"]}','{jo["Result"]}','{MUSER}','{MUSERNAME}',getdate(),'{WorkPoint}')";
|
|
var a = jo["Result"].ToString();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "操作失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 检验修改
|
|
/// </summary>
|
|
/// <param name="ICSMTDOC"></param>
|
|
/// <param name="InvCode"></param>
|
|
/// <param name="ResultINp"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSInspectionDetailNew(string ICSMTDOC, string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string Filtering, string SpecialNumber, string ResultINp, string SpecialPicks, string Lot, string Type, decimal CJQty)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
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 sql = string.Empty;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
|
|
bool ISOK = false;
|
|
string ID = string.Empty;
|
|
sql = @"DELETE c from ICSInspection a
|
|
left join ICSInspectionDetailGroup b on a.ID = b.inspectionID and a.workPoint = b.workPoint
|
|
left join ICSInspectionDetail c on b.id = c.DetailGroupID and b.workPoint = c.workPoint
|
|
Where a.ID='" + JYID + "'";
|
|
sql += "DELETE ICSInspectionDetailGroup where inspectionID='" + JYID + "'";
|
|
foreach (var item in res)
|
|
{
|
|
string Guids = Guid.NewGuid().ToString();
|
|
JObject jo = (JObject)item;
|
|
JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString());
|
|
sql += @"
|
|
INSERT INTO dbo.ICSInspectionDetailGroup
|
|
( ID ,InspectionID,ListCode ,ListName ,
|
|
Unit ,SetValueMax ,SetValueMin ,UnqualifiedQuantity ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName,EATTRIBUTE1,EATTRIBUTE2)
|
|
values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}','{14}','{15}')";
|
|
sql = string.Format(sql, Guids, jo["InspectionID"].ToString(), jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(),
|
|
jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString()
|
|
, MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString(), jo["BadReason"].ToString(), jo["SamplingQuantity"].ToString());
|
|
|
|
foreach (var itemdetail in detailres)
|
|
{
|
|
JObject jodetail = (JObject)itemdetail;
|
|
//if (string.IsNullOrWhiteSpace(ResultINp))
|
|
//{
|
|
sql += @"
|
|
INSERT INTO dbo.ICSInspectionDetail
|
|
( ID ,DetailGroupID,Sequence ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint)
|
|
values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
|
|
sql = string.Format(sql, Guids, jodetail["FiledNamekey"].ToString(), jodetail["FiledNamevalue"].ToString(),
|
|
jo["Result"].ToString(),
|
|
MUSER, MUSERNAME, WorkPoint);
|
|
//}
|
|
//else
|
|
//{
|
|
// sql += @" update ICSInspectionDetail set InspectionID='{0}',ListCode='{1}',ListName='{2}', Unit='{3}' ,SetValueMax='{4}' ,SetValueMin='{5}' ,SetValue='{6}' ,Result='{7}', MUSER='{8}' ,MUSERName='{9}' ,MTIME=getdate(), WorkPoint='{10}', GroupCode='{11}', GroupName='{12}',EATTRIBUTE1='{14}' where ID='{13}'";
|
|
// sql = string.Format(sql, jodetail["InspectionID"].ToString(), jodetail["ListCode"].ToString(), jodetail["ListName"].ToString(), jodetail["Unit"].ToString(), jodetail["SetValueMax"].ToString(), jodetail["SetValueMin"].ToString(), jodetail["SetValue"].ToString(), jodetail["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jodetail["GroupCode"].ToString(), jodetail["GroupName"].ToString(), jodetail["ID"].ToString(), jodetail["NUM"].ToString());
|
|
//}
|
|
if (jo["Result"].ToString() == "0")
|
|
{
|
|
ISOK = true;
|
|
}
|
|
}
|
|
ID = jo["InspectionID"].ToString();
|
|
|
|
}
|
|
if (ISOK == true)
|
|
{
|
|
|
|
sql += $@" update ICSInspection set Result='0',QualifiedQuantity='{YLOTQTY}',UnqualifiedQuantity='{NLOTQTY}',WaiveQuantity='{WaiveQuantity}',SampleQuantity='{CJQty}',EATTRIBUTE2='{Filtering}',EATTRIBUTE3='{SpecialNumber}',EATTRIBUTE4='{SpecialPicks}' where ID='{ID}'";
|
|
|
|
}
|
|
else
|
|
{
|
|
sql += $@" update ICSInspection set Result='1',QualifiedQuantity='{YLOTQTY}',UnqualifiedQuantity='{NLOTQTY}',WaiveQuantity='{WaiveQuantity}',SampleQuantity='{CJQty}',EATTRIBUTE2='{Filtering}',EATTRIBUTE3='{SpecialNumber}',EATTRIBUTE4='{SpecialPicks}' where ID='{ID}'";
|
|
|
|
}
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "绑定失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public DataTable SelectSORRFQColumnName(string InvCode, string JYID,string LotNo)
|
|
{
|
|
string sql = string.Empty;
|
|
if (!string.IsNullOrEmpty(JYID) && JYID != "null")
|
|
{
|
|
sql= @"declare @sql varchar(8000)
|
|
SELECT d.Sequence,d.SetValue
|
|
into #Temp
|
|
from ICSInventoryInspectionGroup a
|
|
inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
inner join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint and (c.InspectionID='{1}' or c.InspectionID='{2}')
|
|
inner JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1'
|
|
select distinct Sequence as ColCaption,Sequence as ColFiledName from #Temp
|
|
drop table #Temp
|
|
";
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
sql = @"declare @sql varchar(8000)
|
|
SELECT d.Sequence,d.SetValue
|
|
into #Temp
|
|
from ICSInventoryInspectionGroup a
|
|
inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint and c.InspectionID='{2}'
|
|
INNER JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
|
|
where a.InvCode='{0}' and b.Enable='1'
|
|
select distinct Sequence as ColCaption,Sequence as ColFiledName from #Temp
|
|
drop table #Temp";
|
|
}
|
|
|
|
sql = string.Format(sql, InvCode, JYID,LotNo);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable deleteSelectSORRFQColumnName(string InvCode, string JYID, string LotNo)
|
|
{
|
|
DataTable resultTable = null;
|
|
|
|
// 循环执行5次
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
string sql = string.Empty;
|
|
if (!string.IsNullOrEmpty(JYID) && JYID != "null")
|
|
{
|
|
sql = @"
|
|
WITH ToDelete AS (
|
|
SELECT TOP 1 *
|
|
FROM ICSInspectionDetail
|
|
WHERE Sequence <> '实际值1'
|
|
AND Sequence LIKE '实际%'
|
|
AND PATINDEX('%[0-9]%', Sequence) > 0
|
|
ORDER BY
|
|
CAST(
|
|
SUBSTRING(
|
|
Sequence,
|
|
PATINDEX('%[0-9]%', Sequence),
|
|
LEN(Sequence)
|
|
) AS INT
|
|
) DESC
|
|
)
|
|
DELETE FROM ToDelete;";
|
|
}
|
|
else
|
|
{
|
|
sql = @"
|
|
WITH ToDelete AS (
|
|
SELECT TOP 1 *
|
|
FROM ICSInspectionDetail
|
|
WHERE Sequence <> '实际值1'
|
|
AND Sequence LIKE '实际%'
|
|
AND PATINDEX('%[0-9]%', Sequence) > 0
|
|
ORDER BY
|
|
CAST(
|
|
SUBSTRING(
|
|
Sequence,
|
|
PATINDEX('%[0-9]%', Sequence),
|
|
LEN(Sequence)
|
|
) AS INT
|
|
) DESC
|
|
)
|
|
DELETE FROM ToDelete;";
|
|
}
|
|
|
|
sql = string.Format(sql, InvCode, JYID, LotNo);
|
|
resultTable = SqlHelper.GetDataTableBySql(sql);
|
|
|
|
|
|
}
|
|
|
|
return resultTable; // 返回最后一次执行的结果
|
|
}
|
|
|
|
public DataTable GetDeleteRulesDetail(string InvCode, string JYID)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
//增加pp子表查询 主要查询U8到货单数量
|
|
sql = @"
|
|
select a.ID as inspectionID,c.ID,a.lotNO,a.Invcode,c.SetValue from ICSInspection a
|
|
|
|
left join ICSInspectionDetailGroup b on a.ID=b.inspectionID and a.workPoint=b.workPoint
|
|
|
|
left join ICSInspectionDetail c on b.id=c.DetailGroupID and b.workPoint=c.workPoint
|
|
where a.id='{0}' and a.Invcode='{1}'";
|
|
sql = string.Format(sql, JYID, InvCode);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
public string DeleteICSInspection(string DetailID)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string sql = string.Empty;
|
|
sql = @"delete FROM ICSInspectionDetail where ID in ({0})";
|
|
sql = string.Format(sql, DetailID.TrimEnd(','));
|
|
string msg = "";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 数据导入
|
|
/// </summary>
|
|
/// <param name="savePath"></param>
|
|
/// <returns></returns>
|
|
public string SetData_PR(String savePath,string lotNo)
|
|
{
|
|
//数据获取
|
|
try
|
|
{
|
|
int index = 1;
|
|
string msg = "";
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
HomeWorkApp app = new HomeWorkApp();
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
string sql = "";
|
|
int count = 0;
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
|
|
var colsMain = new List<string>();
|
|
var cols = new List<string>();
|
|
//循环获取实际值的个数
|
|
foreach (DataColumn item in data.Columns)
|
|
{
|
|
if (item.ColumnName.StartsWith("实际值"))
|
|
cols.Add(item.ColumnName);
|
|
else
|
|
colsMain.Add(item.ColumnName);
|
|
}
|
|
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
if (cols.Count<=0)
|
|
{
|
|
throw new Exception("请填入实际值!");
|
|
}
|
|
|
|
index++;
|
|
|
|
//string GUID = Guid.NewGuid().ToString();
|
|
string groupCode = dr["检验项目组代码"].ToString().Trim();
|
|
string listCode = dr["检验项目代码"].ToString().Trim();
|
|
string groupName = dr["检验项目组名称"].ToString().Trim();
|
|
string unqualifiedQuantity = dr["不良数"].ToString().Trim();
|
|
string result = dr["结论"].ToString()=="不合格"?"0":"1";
|
|
string groupId = app.GetNewid();
|
|
|
|
sql+= $@"IF NOT EXISTS(SELECT GroupCode FROM ICSInspectionGroup WHERE GroupCode='{groupCode}' and
|
|
WorkPoint='{WorkPoint}' )
|
|
BEGIN
|
|
RAISERROR('第{index}行检验项目组编码:{groupCode}不存在,请确认!',16,1);
|
|
RETURN
|
|
end;
|
|
IF NOT EXISTS(SELECT ListCode FROM ICSInspectionList WHERE ListCode='{listCode}')
|
|
BEGIN
|
|
RAISERROR('第{index}行检验项目编码:{listCode}不存在,请确认!',16,1);
|
|
RETURN
|
|
end
|
|
INSERT INTO dbo.ICSInspectionDetailGroup
|
|
(ID, InspectionID, ListCode, ListName,
|
|
Unit, SetValueMax, SetValueMin, UnqualifiedQuantity, Result, MUSER, MUSERName, MTIME, WorkPoint, GroupCode, GroupName)
|
|
select '{groupId}','{lotNo}', ListCode, ListName, Unit, SetValueMax, SetValueMin,'{unqualifiedQuantity}', '{result}','{MUSER}', '{MUSERNAME}', getdate(), '{WorkPoint}', '{groupCode}', '{groupName}' FROM ICSInspectionList WHERE ListCode='{listCode}' ";
|
|
for (int i=0;i<cols.Count;i++)
|
|
{
|
|
sql += $@" INSERT INTO dbo.ICSInspectionDetail
|
|
(ID, DetailGroupID, Sequence, SetValue, Result, MUSER, MUSERName, MTIME, WorkPoint)
|
|
values(newid(), '{groupId}', '{cols[i]}','{ dr[cols[i]]}', '{result}', '{MUSER}', '{MUSERNAME}', getdate(), '{WorkPoint}')";
|
|
}
|
|
|
|
}
|
|
count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
if (count > 0)
|
|
{
|
|
msg = "导入成功";
|
|
}
|
|
else
|
|
{
|
|
return "无有效的导入数据。";
|
|
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 红字销售出库单检验
|
|
/// </summary>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <param name="MenuID"></param>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSSSDInspection(ref Pagination jqgridparam, string MenuID, string queryJson)
|
|
{
|
|
string DataActionsql = actionapp.DataActionSqlGet(MenuID);
|
|
string ERPSign = Configs.GetValue("ERPSign");
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = string.Empty;
|
|
|
|
sql = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
|
|
drop table #TempLLData_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
|
|
drop table #TempIcsinsp_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
|
|
drop table #TempLLData_1_1
|
|
select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,SampleQuantity,
|
|
MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
|
|
into #TempIcsinsp_1
|
|
from dbo.ICSInspection
|
|
where workpoint='" + WorkPoint + @"' and Enable='1'
|
|
|
|
select DISTINCT
|
|
a.ID as DHID,
|
|
d.ID ,
|
|
h.ID as JYID,
|
|
a.SSDCode ,
|
|
a.Sequence ,
|
|
c.InvCode ,
|
|
c.InvName ,
|
|
c.InvStd ,
|
|
c.ClassName,
|
|
c.EATTRIBUTE3 as InvEATTRIBUTE3,
|
|
CAST(d.Quantity as decimal(18,4)) as AllNumber,
|
|
CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
|
|
CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
|
|
CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
|
|
CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
|
|
-- CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
|
|
c.InvUnit ,
|
|
d.LotNo ,
|
|
g.BadReasonDesc as BadReasonDesc ,
|
|
g.BadReasonCode as BRCodeValue,
|
|
j.BadCode as BCCodeValue,
|
|
j.BadDesc as BadDesc,
|
|
k.ContainerID,
|
|
isnull(h.MUSERName,'开发者') MUSERName,
|
|
CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
|
|
CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
|
|
CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
|
|
CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState,
|
|
a.CusCode,a.CusName,
|
|
|
|
isnull(h.MUSERName,'') as Surveyor,
|
|
h.MTime as ProvingTime
|
|
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
|
|
,CASE WHEN h.Result='0' THEN '不合格' when ISNULL(h.Result,'')='' THEN '' ELSE '合格' END AS Result,
|
|
n.FileName
|
|
,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0)
|
|
WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*a.Quantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity
|
|
,o.Editable
|
|
,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
|
|
WHERE hH2.LotNo=d.LotNo AND hH2.WorkPoint=a.WorkPoint),0)
|
|
WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
|
|
, case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC
|
|
into #TempLLData_1
|
|
FROM ICSSSD a
|
|
--inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail e on a.SSDCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint AND a.ID=e.TransID
|
|
inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
|
|
inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN #TempIcsinsp_1 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint
|
|
LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
|
|
left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
|
|
left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
|
|
LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
|
|
|
|
left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
|
|
|
|
left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
|
|
left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint
|
|
LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
|
|
where d.LotNo is not null and a.Type='2' AND a.Status='1' AND a.WorkPoint='{1}' {0}
|
|
|
|
select * into #TempLLData_1_1 from #TempLLData_1
|
|
";
|
|
string wheresql = "";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
wheresql += " and a.SSDCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
{
|
|
wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
|
|
{
|
|
wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
|
|
{
|
|
wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
|
|
{
|
|
wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
|
|
{
|
|
wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
|
|
{
|
|
wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
|
|
{
|
|
string ReleaseState = queryParam["ReleaseState"].ToString();
|
|
if (ReleaseState == "1")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
|
|
else if (ReleaseState == "0")
|
|
wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
|
|
else
|
|
wheresql += " ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
|
|
{
|
|
string printState = queryParam["selIsPrint"].ToString();
|
|
if (printState == "否")
|
|
wheresql += " and isnull(task.ValueParameters,'') ='' ";
|
|
else if (printState == "是")
|
|
wheresql += " and isnull(task.ValueParameters,'') <>''";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
|
|
{
|
|
string selEnableShow = queryParam["selEnableShow"].ToString();
|
|
if (selEnableShow == "1")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
|
|
else if (selEnableShow == "0")
|
|
wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
|
|
}
|
|
}
|
|
wheresql += " " + DataActionsql;
|
|
sql = string.Format(sql, wheresql, WorkPoint);
|
|
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempLLData_1_1",
|
|
@" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
|
|
drop table #TempLLData_1
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
|
|
drop table #TempIcsinsp_1
|
|
if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempLLData_1_1'))
|
|
drop table #TempLLData_1_1 ",
|
|
"connstr", parameter.ToArray(), ref jqgridparam);
|
|
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 交期维护(咖博士)
|
|
/// </summary>
|
|
/// <param name="LeadModel"></param>
|
|
/// <returns></returns>
|
|
public string UpdateLeadTime(string LeadModel)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
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 SendHost="";
|
|
string SendPort = "";
|
|
string SendDisplayName = "";
|
|
string SendAddress = "";
|
|
string CusterJC = "";
|
|
string CusterQC = "";
|
|
string SendPassword = "";
|
|
JObject res = (JObject)JsonConvert.DeserializeObject(LeadModel);
|
|
var lot = res["LotNos"].ToString().TrimEnd(',');
|
|
string ID = string.Empty;
|
|
//获取邮箱信息
|
|
string sql = " SELECT F_ItemCode,F_Define1 FROM Sys_SRM_ItemsDetail WHERE F_ItemId='5f234982-69cc-4c64-9d1a-d43eef4e9ea0'";
|
|
DataTable itemdt = SqlHelper.GetDataTableBySql(sql);
|
|
if (itemdt.Rows.Count < 0)
|
|
{
|
|
throw new Exception("请先在自定义档案中配置发送人邮件信息");
|
|
|
|
}
|
|
else
|
|
{
|
|
for (int i=0;i< itemdt.Rows.Count; i++)
|
|
{
|
|
if (itemdt.Rows[i]["F_ItemCode"].ToString() == "SendHost")
|
|
{
|
|
SendHost = itemdt.Rows[i]["F_Define1"].ToString();
|
|
}
|
|
else if (itemdt.Rows[i]["F_ItemCode"].ToString() == "SendPort")
|
|
{
|
|
SendPort = itemdt.Rows[i]["F_Define1"].ToString();
|
|
}
|
|
else if (itemdt.Rows[i]["F_ItemCode"].ToString() == "SendDisplayName")
|
|
{
|
|
SendDisplayName = itemdt.Rows[i]["F_Define1"].ToString();
|
|
}
|
|
else if (itemdt.Rows[i]["F_ItemCode"].ToString() == "SendAddress")
|
|
{
|
|
SendAddress = itemdt.Rows[i]["F_Define1"].ToString();
|
|
}
|
|
else if (itemdt.Rows[i]["F_ItemCode"].ToString() == "CusterJC")
|
|
{
|
|
CusterJC = itemdt.Rows[i]["F_Define1"].ToString();
|
|
}
|
|
else if (itemdt.Rows[i]["F_ItemCode"].ToString() == "CusterQC")
|
|
{
|
|
CusterQC = itemdt.Rows[i]["F_Define1"].ToString();
|
|
}
|
|
else if (itemdt.Rows[i]["F_ItemCode"].ToString() == "SendPassword")
|
|
{
|
|
SendPassword = itemdt.Rows[i]["F_Define1"].ToString();
|
|
}
|
|
|
|
}
|
|
}
|
|
sql = $@"UPDATE [dbo].[ICSDeliveryNotice] SET EATTRIBUTE3='{res["LeadTime"]}',EATTRIBUTE4='{res["User"]}' WHERE EATTRIBUTE1 in ({lot}) and DNType='3' ; ";
|
|
sql = $@"SELECT c.TransCode as POCode,d.VenAddress,d.VenName,d.VenEmail,a.VenCode,a.Quantity FROM ICSDeliveryNotice a
|
|
INNER join ICSInventoryLot b on a.EATTRIBUTE1=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
INNER JOIN ICSInventoryLotDetail c on b.LotNo=c.LotNo AND b.WorkPoint=c.WorkPoint
|
|
INNER JOIN ICSVendor d ON a.VenCode=d.VenCode
|
|
WHERE a.DNType='3' AND a.EATTRIBUTE1 in ({lot})";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
SqlHelper.ExecuteWithTrans((dbConn, trans) =>
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(dbConn, trans, sql) == 0)
|
|
throw new Exception("修改数据失败");
|
|
|
|
int SendPorts = Convert.ToInt32(SendPort);
|
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
string cVenCode = dr["VenCode"].ToString();
|
|
string TOAddress = GetVendorEmail(cVenCode).TrimEnd(',');
|
|
string CCAddress = "";
|
|
string Subject = "有来自" + CusterJC + "SRM平台新发布的采购订单信息";
|
|
bool isBodyHtml = false;
|
|
string VenName = dr["VenName"].ToString();
|
|
string POCode = dr["POCode"].ToString();
|
|
string NowDate = DateTime.Now.GetDateTimeFormats('D')[0].ToString();
|
|
string body = VenName + ":";
|
|
body += "\r\n";
|
|
body += " 您好!有来自" + CusterJC + "SRM新发布的拒收采购订单:" + POCode + " ,拒收数量为:" + dr["Quantity"].ToString()+",请在交期"+ res["LeadTime"].ToDate().GetDateTimeFormats('D')[0].ToString() + "前送货,可登陆基础SRM系统查看相关信息!";
|
|
body += "\r\n";
|
|
body += " 顺颂商祺!";
|
|
body += "\r\n";
|
|
body += " " + CusterQC + "";
|
|
body += "\r\n";
|
|
body += " " + NowDate;
|
|
string connection = FromMd5(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString);
|
|
|
|
ICSSendMail.SendEmail(connection, SendHost, SendPorts, SendDisplayName, SendAddress, SendPassword, TOAddress, CCAddress, Subject, isBodyHtml, body);
|
|
}
|
|
|
|
}, ex =>{
|
|
msg = $"修改失败:{ex.Message}";
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
public string GetVendorEmail(string VenCode)
|
|
{
|
|
string sql = " SELECT F_Email FROM dbo.Sys_SRM_User WHERE F_VenCode='" + VenCode + "'";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
string Email = string.Empty;
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
Email += dr["F_Email"].ToString() + ",";
|
|
}
|
|
return Email;
|
|
}
|
|
public static string FromMd5(string str)
|
|
{
|
|
//return str;
|
|
return Decrypt(str, "&%#@?,:*_");
|
|
}
|
|
/// <summary>
|
|
/// 解密
|
|
/// </summary>
|
|
/// <param name="strText"></param>
|
|
/// <param name="sDecrKey"></param>
|
|
/// <returns></returns>
|
|
private static String Decrypt(String strText, String sDecrKey)
|
|
{
|
|
Byte[] byKey = { };
|
|
Byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
|
|
Byte[] inputByteArray = new byte[strText.Length];
|
|
try
|
|
{
|
|
byKey = System.Text.Encoding.UTF8.GetBytes(sDecrKey.Substring(0, 8));
|
|
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
|
|
inputByteArray = Convert.FromBase64String(strText);
|
|
MemoryStream ms = new MemoryStream();
|
|
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV),
|
|
CryptoStreamMode.Write);
|
|
cs.Write(inputByteArray, 0, inputByteArray.Length);
|
|
cs.FlushFinalBlock();
|
|
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
|
|
return encoding.GetString(ms.ToArray());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
}
|
|
}
|
|
}
|
|
}
|