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.
6830 lines
258 KiB
6830 lines
258 KiB
using Dapper;
|
|
using Dapper.Contrib.Extensions;
|
|
using ICSSoft.SendMail;
|
|
using Newtonsoft.Json;
|
|
using NFine.Application.DHAY;
|
|
using NFine.Application.Entity;
|
|
using NFine.Application.Models;
|
|
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using NFine.Repository;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace NFine.Application.BBWMS
|
|
{
|
|
public class IQCQualityApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
public DataTable GetGridJsonChengPing(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
case when a.Enable=1 then '是'
|
|
else '否' end as EnableText
|
|
,a.*
|
|
from ICSInspectionRulesGroup a with(nolock)
|
|
where 1=1
|
|
--and a.WorkPoint='UFDATA_106_2019'
|
|
{0}
|
|
<1>
|
|
<2>
|
|
<3>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["RulesCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.RulesCode like '%" + queryParam["RulesCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["RulesName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.RulesName like '%" + queryParam["RulesName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["Enable"].ToString()))
|
|
{
|
|
|
|
sql = sql.Replace("<3>", " and a.Enable =" + queryParam["Enable"].ToString() + " ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public DataTable GetCheckItemDetailList(string id, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionList a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
order by a.ListCode asc
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", "and a.GroupID='" + id + "'");
|
|
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable GetCheckItemGroupPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
case when a.Enable=1 then '是'
|
|
else '否' end as EnableText
|
|
,a.*
|
|
from ICSInspectionGroup a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
<2>
|
|
--<3>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["GroupCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.GroupCode like '%" + queryParam["GroupCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["GroupName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.GroupName like '%" + queryParam["GroupName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["Enable"].ToString()))
|
|
//{
|
|
|
|
// sql = sql.Replace("<3>", " and a.Enable =" + queryParam["Enable"].ToString() + " ");
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("<3>", " ");
|
|
//}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public DataTable GetBadCodeGroupPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from ICSBadCodeGroup a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
<2>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BCGCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.BCGCode like '%" + queryParam["BCGCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BCGDesc"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.BCGDesc like '%" + queryParam["BCGDesc"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public DataTable GetBadCodeGroupDetailList(string id, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadCode a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
order by a.BadCode asc
|
|
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", "and a.BCGroupID='" + id + "'");
|
|
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public List<ICSInspectionGroupEntity> GetAllCheckGroupList(string code)
|
|
{
|
|
var returnValue = new List<ICSInspectionGroupEntity>();
|
|
|
|
string sql = "select * from ICSInspectionGroup with(nolock) where GroupCode like '%" + code + "%' {0} ";
|
|
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
returnValue = MsSqlData.Query<ICSInspectionGroupEntity>(sql).ToList();
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string DeleteAql(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
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;
|
|
var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionRulesGroup a with(nolock)
|
|
where a.ID in ('" + string.Join("','", idList) + "') and a.workpoint=@WorkPoint ";
|
|
var para = new { WorkPoint = WorkPoint };
|
|
var entityList = MsSqlData.Query<ICSInspectionRulesGroupEntity>(sql, para).ToList();
|
|
|
|
|
|
foreach (var item in entityList)
|
|
{
|
|
//var count = MsSqlData.ExecuteScalar(" select count(1) from IcsCheckingFixtureTransfer with(nolock) where CheckFixtureNo='" + item.CheckFixtureNo + "'").ToInt();
|
|
//if (count > 0)
|
|
//{
|
|
// throw new Exception("当前检具已经存在履历,不能删除");
|
|
//}
|
|
}
|
|
|
|
|
|
var result = MsSqlData.Delete<ICSInspectionRulesGroupEntity>(entityList);
|
|
if (!result)
|
|
{
|
|
returnValue = "删除失败";
|
|
}
|
|
|
|
string sql2 = @"delete from ICSInspectionRulesList where RulesID in ('" + string.Join("','", idList) + "') and a.workpoint=@WorkPoint ";
|
|
List<SqlParameter> paras = new List<SqlParameter>();
|
|
paras.Add(new SqlParameter("@WorkPoint", SqlDbType.NVarChar) { Value = WorkPoint });
|
|
var line = Repository().ExecuteBySql(new StringBuilder(sql2), paras.ToArray());
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetItem2RuleList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
a.ID
|
|
,b.InvCode
|
|
,b.InvName
|
|
,b.InvStd
|
|
,c.RulesCode
|
|
,c.RulesName
|
|
,c.RulesDesc
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
,a.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=a.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
from ICSInventoryInspectionRulesGroup a with(nolock)
|
|
join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
join ICSInspectionRulesGroup c with(nolock) on a.RulesCode=c.RulesCode and a.WorkPoint=c.WorkPoint
|
|
where 1=1
|
|
{0}
|
|
) a
|
|
where 1=1
|
|
<1>
|
|
<2>
|
|
<3>
|
|
<4>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + queryParam["InvName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["RulesCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<3>", " and a.RulesCode like '%" + queryParam["RulesCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["RulesName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<4>", " and a.RulesName like '%" + queryParam["RulesName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public string SaveItem2AqlSingle(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
var model = JsonConvert.DeserializeObject<ICSInventoryInspectionRulesGroup>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
//修改
|
|
var entity = MsSqlData.Get<ICSInventoryInspectionRulesGroup>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
|
|
entity.RulesCode = model.RulesCode;
|
|
var sql1 = @"select top 1 * from ICSInspectionRulesGroup a with(nolock) where a.RulesCode = '" + entity.RulesCode + "' and a.WorkPoint=@WorkPoint ";
|
|
var aql = MsSqlData.Query<ICSInspectionRulesGroupEntity>(sql1, para).FirstOrDefault();
|
|
if (aql == null)
|
|
{
|
|
throw new Exception("当前Aql不存在");
|
|
}
|
|
|
|
entity.RulesName = aql.RulesName;
|
|
entity.RulesDesc = aql.RulesDesc;
|
|
entity.Type = aql.Type;
|
|
entity.Enable = model.Enable;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
var result = MsSqlData.Update<ICSInventoryInspectionRulesGroup>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public int UpLoadFinalJudgeFile(string iD, string fileName)
|
|
{
|
|
var returnValue = 1;
|
|
|
|
var dtNow = DateTime.Now;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
|
|
try
|
|
{
|
|
|
|
var entity = MsSqlData.Get<IcsMatCheckResult>(iD);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
|
|
entity.SpecialFile = fileName;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
var result = MsSqlData.Update<IcsMatCheckResult>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = 0;
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = 0;
|
|
}
|
|
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public ICSInventoryInspectionRulesGroup GetItem2Aql(string keyValue)
|
|
{
|
|
var returnValue = new ICSInventoryInspectionRulesGroup();
|
|
|
|
try
|
|
{
|
|
returnValue = MsSqlData.Get<ICSInventoryInspectionRulesGroup>(keyValue);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = null;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string SetData_PR(string savePath)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
DateTime time = DateTime.Now;
|
|
|
|
//DataSet dsSave = new DataSet();
|
|
//dsSave.Tables.Add(data.Copy());
|
|
|
|
//dsSave.Tables[0].TableName = "IcsCheckingFixture";
|
|
|
|
var para = new { WorkPoint = WorkPoint };
|
|
string sql0 = @"
|
|
select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode='CheckAttr'
|
|
|
|
";
|
|
var enumList = MsSqlData.Query<SysEnumValueDto>(sql0, para).ToList();
|
|
//var chicun = enumList.Where(x => x.Ext1 == "尺寸").Select(x => x.value);
|
|
|
|
|
|
List<ICSInventoryInspectionRulesGroup> list = new List<ICSInventoryInspectionRulesGroup>();
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
var item = data.Rows[i];
|
|
if (item["物料代码"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "物料代码为空");
|
|
}
|
|
if (item["Aql代码"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "Aql代码为空");
|
|
}
|
|
if (item["检验属性"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "检验属性为空");
|
|
}
|
|
//if (item["类型"].ToStringExt() == "")
|
|
//{
|
|
// throw new Exception("第" + (i + 1) + "行," + "类型为空");
|
|
//}
|
|
ICSInventoryInspectionRulesGroup entity = new ICSInventoryInspectionRulesGroup();
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.InvCode = item["物料代码"].ToStringExt();
|
|
entity.RulesCode = item["Aql代码"].ToStringExt();
|
|
entity.EATTRIBUTE1 = enumList.Where(x => x.label == item["检验属性"].ToStringExt()).FirstOrDefault()?.value;
|
|
|
|
|
|
|
|
var count = MsSqlData.ExecuteScalar
|
|
(
|
|
" select count(1) from ICSInventoryInspectionRulesGroup a with(nolock) where InvCode='" + entity.InvCode + "' and a.EATTRIBUTE1='" + entity.EATTRIBUTE1 + "' "
|
|
).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前物料Aql关系已经存在");
|
|
}
|
|
|
|
var itemCode = MsSqlData.Query<ICSInventoryDto>(
|
|
@"select top 1 * from ICSInventory a with(nolock)
|
|
where a.InvCode = '" + entity.InvCode + "'")
|
|
.FirstOrDefault();
|
|
if (itemCode == null)
|
|
{
|
|
throw new Exception("当前物料不存在");
|
|
}
|
|
|
|
var aql = MsSqlData.Query<ICSInspectionRulesGroupEntity>(
|
|
@"select top 1 * from ICSInspectionRulesGroup a with(nolock)
|
|
where a.RulesCode = '" + entity.RulesCode + "'")
|
|
.FirstOrDefault();
|
|
if (aql == null)
|
|
{
|
|
throw new Exception("当前Aql不存在");
|
|
}
|
|
|
|
entity.RulesName = aql.RulesName;
|
|
entity.RulesDesc = aql.RulesDesc;
|
|
entity.Type = aql.Type;
|
|
entity.Enable = true;
|
|
entity.Editable = true;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = time;
|
|
entity.WorkPoint = WorkPoint;
|
|
list.Add(entity);
|
|
}
|
|
if (list.Count == 0)
|
|
{
|
|
throw new Exception("没有导入数据");
|
|
}
|
|
var result = MsSqlData.Insert<ICSInventoryInspectionRulesGroup>(list);
|
|
if (!result)
|
|
{
|
|
|
|
throw new Exception("导入失败");
|
|
}
|
|
returnValue = "true";
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetMaterialCheckLog(string keyValue)
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
string sql = @"SELECT top 10 * FROM (SELECT DISTINCT
|
|
a.InvCode,
|
|
d.InvName,
|
|
d.InvStd,
|
|
REPLACE(d.ClassName, '编码规则', '') WLFL,
|
|
a.AsnCode,
|
|
a.InvBatcgNo,
|
|
a.InvBatcgQty,
|
|
a.VenCode,
|
|
c.VenName,
|
|
CASE WHEN e.EATTRIBUTE1='是' THEN '是' ELSE '否' END AS SFJL,
|
|
FORMAT( CONVERT( datetime,a.EATTRIBUTE3,120), 'yyyy/MM/dd') CHUJIANSHIJIAN,
|
|
isnull(ZB.MUSERName,a.MUSERName) MUSERName,a.Result JYXJG,
|
|
a.FirstCheckUser,a.FirstCheckTime
|
|
,a.Result,b.BLMX,
|
|
a.IQCGroupHeaderResult ,
|
|
a.IQCGroupHeaderRemark ,
|
|
a.IQCGroupHeaderUser,
|
|
a.IQCGroupHeaderTime,
|
|
BLXX.BRGDesc,
|
|
BLXX1.BadReasonDesc,
|
|
BLFL.BadDesc,
|
|
a.SQEEngineerResult ,
|
|
a.SQEEngineerRemark ,
|
|
a.SQEEngineerUser,
|
|
a.SQEEngineerTime,
|
|
a.IQCHeaderResult ,
|
|
a.IQCHeaderRemark ,
|
|
a.IQCHeaderUser,
|
|
a.IQCHeaderTime,
|
|
a.EATTRIBUTE1 SQEFA,
|
|
A.FinalResult ,
|
|
a.FinalUser,
|
|
a.FinalTime,
|
|
CASE WHEN a.Result='OK' OR (a.Result='NG' AND a.IsCheckComplete='是') THEN '是'
|
|
ELSE '否' END AS SFJA,
|
|
CASE WHEN e.TransCode IS NULL THEN F.TransCode ELSE E.TransCode END AS LYDJ
|
|
FROM IcsMatCheckResult a
|
|
LEFT JOIN ICSVendor c on a.VenCode=c.VenCode AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN ICSInventory d on a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN (
|
|
SELECT DISTINCT a.ASNCode,b.InvCode,a.EATTRIBUTE1,c.BatchCode,a.WorkPoint,bb.TransCode FROM ICSASNDetail a
|
|
LEFT JOIN ICSInventoryLot b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN ICSInventoryLotDetail bb on a.LotNo=bb.LotNo and a.WorkPoint=bb.WorkPoint
|
|
LEFT JOIN ICSExtension c on b.ExtensionID=c.ID and c.WorkPoint=b.WorkPoint
|
|
)e ON a.AsnCode=e.ASNCode and a.InvCode=e.InvCode and a.InvBatcgNo=e.BatchCode and a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN (
|
|
SELECT DISTINCT a.OASNCode,b.InvCode,a.EATTRIBUTE1,c.BatchCode,a.WorkPoint,bb.TransCode FROM ICSOASNDetail a
|
|
LEFT JOIN ICSInventoryLot b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN ICSInventoryLotDetail bb on a.LotNo=bb.LotNo and a.WorkPoint=bb.WorkPoint
|
|
LEFT JOIN ICSExtension c on b.ExtensionID=c.ID and c.WorkPoint=b.WorkPoint
|
|
)f ON a.AsnCode=f.OASNCode and a.InvCode=f.InvCode and a.InvBatcgNo=e.BatchCode and a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN ICSBadReasonGroup BLXX ON BLXX.BRGCode=A.BCGCode
|
|
LEFT JOIN ICSBadReason BLXX1 ON BLXX1.BadReasonCode=A.BadReasonCode
|
|
LEFT JOIN ICSBadCode BLFL ON BLFL.BadCode=A.BRGCode
|
|
LEFT JOIN (SELECT CheckNo,STRING_AGG(BLMX, '; ') BLMX FROM VIEW_JY WHERE BLMX<>'' GROUP BY CheckNo) B ON a.CheckNo=b.CheckNo
|
|
LEFT JOIN (SELECT DISTINCT CheckNo,MUSERName,CONVERT(NVARCHAR(10),MTIME,102) TIME FROM IcsMatCheckResultDetail) ZB ON ZB.CheckNo=A.CheckNo
|
|
where a.WorkPoint='{0}'
|
|
UNION ALL
|
|
|
|
SELECT DISTINCT a.InvCode,C.InvName,C.InvStd, REPLACE(C.ClassName, '编码规则', '') WLFL,ISNULL(D.ASNCode,E.OASNCode) ASNCode,F.BatchCode InvBatcgNo,
|
|
SUM(A.Quantity) InvBatcgQty,ISNULL(D.MUSER,E.MUSER) VenCode,ISNULL(D.MUSERName,E.MUSERName) VENNAME,'' SFJL,
|
|
FORMAT( CONVERT( datetime,a.MTIME,120), 'yyyy/MM/dd') CHUJIANSHIJIAN,'' MUSERName,'OK' JYXJG,'免检' Result, null FirstCheckUser,null FirstCheckTime, '' BLMX,
|
|
'' ZZJG,'' ZZBZ,'' IQCGroupHeaderUser,'' IQCGroupHeaderTime,'' BRGDesc,'' BadReasonDesc,'' BadDesc,'' SQEJG,'' SQEBZ,
|
|
'' SQEEngineerUser,'' SQEEngineerTime,'' ZGJG,'' ZGBZ,'' IQCHeaderUser,'' IQCHeaderTime,'' SQEFA,'' ZZPD,'' FinalUser,'' FinalTime,
|
|
'' SFJA, A.TransCode LYDJ
|
|
FROM ICSWareHouseLotInfoLog a
|
|
INNER JOIN ICSWareHouseLotInfo b on a.LotNo=b.LotNo
|
|
LEFT JOIN ICSInventory C ON C.InvCode=A.InvCode
|
|
LEFT JOIN ICSASNDetail D ON D.LotNo=A.LotNo
|
|
LEFT JOIN ICSOASNDetail E ON E.LotNo=A.LotNo
|
|
LEFT JOIN ICSInventoryLoT EE ON EE.LotNo=A.LotNo
|
|
LEFT JOIN ICSExtension F ON F.ID=EE.ExtensionID
|
|
left join ICSInspection lot on lot.lotno=a.lotno
|
|
WHERE (a.BusinessCode='1' or a.BusinessCode='9') AND lot.lotno is null
|
|
and a.MUSER<>'admin'
|
|
GROUP BY a.InvCode,C.InvName,C.InvStd, REPLACE(C.ClassName, '编码规则', ''),ISNULL(D.ASNCode,E.OASNCode),F.BatchCode,
|
|
ISNULL(D.MUSER,E.MUSER),ISNULL(D.MUSERName,E.MUSERName),FORMAT( CONVERT( datetime,a.MTIME,120), 'yyyy/MM/dd'),A.MUSERName,A.TransCode
|
|
) A WHERE 1=1
|
|
and a.InvCode='{0}'
|
|
";
|
|
sql = string.Format(sql, keyValue, WorkPoint);
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable GetBadReasonGroupPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from ICSBadReasonGroup a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
<2>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BRGCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.BRGCode like '%" + queryParam["BRGCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BRGDesc"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.BRGDesc like '%" + queryParam["BRGDesc"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public DataTable ExportAllCheckItemGroup(string groupCode, string GroupName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
case when a.Enable=1 then '是'
|
|
else '否' end as EnableText
|
|
,a.*
|
|
from ICSInspectionGroup a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
<2>
|
|
--<3>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(groupCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.GroupCode like '%" + groupCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(GroupName))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.GroupName like '%" + GroupName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["Enable"].ToString()))
|
|
//{
|
|
|
|
// sql = sql.Replace("<3>", " and a.Enable =" + queryParam["Enable"].ToString() + " ");
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("<3>", " ");
|
|
//}
|
|
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public string ImportCheckItem(string savePath)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
DateTime time = DateTime.Now;
|
|
|
|
//DataSet dsSave = new DataSet();
|
|
//dsSave.Tables.Add(data.Copy());
|
|
DateTime dtNow = DateTime.Now;
|
|
//dsSave.Tables[0].TableName = "IcsCheckingFixture";
|
|
ICSInspectionGroupEntity entity = new ICSInspectionGroupEntity();
|
|
List<ICSInspectionListEntity> list = new List<ICSInspectionListEntity>();
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
var item = data.Rows[i];
|
|
if (i == 0)
|
|
{
|
|
if (item["检验类型编码"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第1行," + "检验类型编码为空");
|
|
}
|
|
if (item["检验类型名称"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第1行," + "检验类型名称为空");
|
|
}
|
|
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.WorkPoint = WorkPoint;
|
|
entity.GroupCode = item["检验类型编码"].ToStringExt();
|
|
entity.GroupName = item["检验类型名称"].ToStringExt();
|
|
entity.Enable = true;
|
|
|
|
}
|
|
if (item["检验项目代码"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "检验项目代码为空");
|
|
}
|
|
if (item["检验项目名称"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "检验项目名称为空");
|
|
}
|
|
if (item["最大值"].ToDecimal() <= 0)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "最大值必须大于0");
|
|
}
|
|
if (item["最小值"].ToDecimal() <= 0)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "最小值必须大于0");
|
|
}
|
|
//if (item["单位"].ToStringExt() == "")
|
|
//{
|
|
// throw new Exception("第" + (i + 1) + "行," + "检验项目名称为空");
|
|
//}
|
|
|
|
ICSInspectionListEntity detail = new ICSInspectionListEntity();
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.GroupID = entity.ID;
|
|
detail.ListCode = item["检验项目代码"].ToStringExt();
|
|
detail.ListName = item["检验项目名称"].ToStringExt();
|
|
detail.Unit = item["单位"].ToStringExt();
|
|
detail.SetValueMax = item["最大值"].ToDecimal();
|
|
detail.SetValueMin = item["最小值"].ToDecimal();
|
|
detail.Enable = true;
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
|
|
if (detail.SetValueMax <= 0 || detail.SetValueMin <= 0)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "值必须大于0");
|
|
}
|
|
|
|
if (detail.SetValueMax <= detail.SetValueMin)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "最大值必须大于最小值");
|
|
}
|
|
|
|
|
|
list.Add(detail);
|
|
}
|
|
|
|
|
|
if (list.Count == 0)
|
|
{
|
|
throw new Exception("没有导入数据");
|
|
}
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
if (list.Select(x => x.ListCode).Distinct().Count() != list.Count)
|
|
{
|
|
throw new Exception("检验项目代码重复");
|
|
}
|
|
}
|
|
|
|
var result = MsSqlData.Insert<ICSInspectionGroupEntity>(entity);
|
|
if (!result)
|
|
{
|
|
throw new Exception("导入失败");
|
|
}
|
|
|
|
result = MsSqlData.Insert<ICSInspectionListEntity>(list);
|
|
if (!result)
|
|
{
|
|
throw new Exception("导入失败");
|
|
}
|
|
returnValue = "true";
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public ICSInventoryInspectionListDto GetItem2CheckItem(string keyValue)
|
|
{
|
|
var returnValue = new ICSInventoryInspectionListDto();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var sql = @"select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
a.ID
|
|
,c.InvCode
|
|
,c.InvName
|
|
,a.ListCode
|
|
,a.ListName
|
|
,b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=b.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
,a.SetValueMax
|
|
,a.SetValueMin
|
|
,a.Unit
|
|
,a.Enable
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
,a.EATTRIBUTE1
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID
|
|
left join ICSInventory c with(nolock) on b.InvCode=c.InvCode
|
|
where 1=1
|
|
and a.WorkPoint=@WorkPoint
|
|
) a
|
|
where 1=1
|
|
and a.ID=@Id";
|
|
|
|
var para = new
|
|
{
|
|
ID = keyValue,
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
returnValue = MsSqlData.Query<ICSInventoryInspectionListDto>(sql, para).FirstOrDefault();
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
public string SaveItem2CheckItemSingle(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<ICSInventoryInspectionListDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
//修改
|
|
var entity = MsSqlData.Get<ICSInventoryInspectionListEntity>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
|
|
entity.ListName = model.ListName;
|
|
entity.Unit = model.Unit;
|
|
entity.SetValueMax = model.SetValueMax;
|
|
entity.SetValueMin = model.SetValueMin;
|
|
entity.Enable = model.Enable;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.EATTRIBUTE1 = model.EATTRIBUTE1;
|
|
var result = MsSqlData.Update<ICSInventoryInspectionListEntity>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable ExportAllMaterialInStorageCheck(string invCode, string invName, string isCheck, string StartDate, string EndDate,
|
|
string checkStartDate,string CheckEndDate)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select a.InvCode as 物料编码
|
|
,a.InvName as 物料名称
|
|
,a.DNCode as 到货单号
|
|
,a.InvBatcgNo as 物料批号
|
|
,a.DNQuantity as 到货数量
|
|
,a.DHDate as 到货时间
|
|
,a.VenCode as 供应商编码
|
|
,a.VenName as 供应商名称
|
|
,a.ASNCode as 送货单号
|
|
,a.IsUrgentItem as 加急料
|
|
,a.IsCheck as 是否检验
|
|
,a.Result as 初判结果
|
|
,a.CheckDate as 初检时间
|
|
,a.WHCode as 仓库代码
|
|
,a.DrawingNumber as 图号
|
|
from
|
|
(
|
|
|
|
select
|
|
--distinct
|
|
max(b.ID) DetailId --子表主键
|
|
,Max(c.ID) LotNoId --条码ID
|
|
,c.InvCode
|
|
,inv.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,sum(b.DNQuantity) DNQuantity --到货数量
|
|
,max(a.VenCode) VenCode --供应商编码
|
|
,max(e.VenName ) VenName --供应商名称
|
|
,a.ASNCode
|
|
,max(b.EATTRIBUTE1) as IsUrgentItem --加急料
|
|
,max(inv.InvUnit) InvUnit
|
|
,sum(c.Quantity) Quantity
|
|
,max(c2.FileName) OutReport
|
|
,max(c2.FilePath) FilePath
|
|
,max(g.id) CheckID
|
|
,case when max(g.CheckNo) is null then '否'else '是' end as IsCheck
|
|
,max(g.Result) Result
|
|
,max(g.FirstCheckTime) CheckDate
|
|
,max(g.WHCode) WHCode
|
|
,max(l.CreateDateTime) DHDate
|
|
,max(l.DNCode) DNCode
|
|
,max(l.DrawingNumber) DrawingNumber
|
|
,'1' as DocType
|
|
from ICSASN a with(nolock)
|
|
left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail cc with(nolock) on b.lotno=cc.lotno and cc.WorkPoint=c.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.ASNCode,t.BatchCode,t.invcode,t.FileName,t.FilePath
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on a.ASNCode=c2.ASNCode and c1.BatchCode=c2.BatchCode and c.invcode=c2.invcode
|
|
left join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPoint
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
left join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.ASNCode=g.AsnCode
|
|
left join (SELECT t.ASNCode,t.InvCode,t.ExtensionID,max(t.CreateDateTime) CreateDateTime,max( t.DNCode) DNCode,b.EATTRIBUTE2 DrawingNumber
|
|
from ICSDeliveryNotice t with(nolock)
|
|
INNER JOIN ICSPurchaseOrder b ON t.POID=b.POID AND t.PODetailID=b.PODetailID AND t.WorkPoint=b.WorkPoint
|
|
GROUP BY t.ASNCode,t.InvCode,t.ExtensionID,b.EATTRIBUTE2 ) l
|
|
on a.ASNCode=l.ASNCode and c.InvCode=l.InvCode and l.ExtensionID=c.ExtensionID
|
|
left join ( select a.LotNo from ICSASNDetail a
|
|
inner join ICSWareHouseLotInfo b on a.lotno=b.lotno
|
|
left join ICSInspection c on c.LotNo=a.LotNo
|
|
where c.lotno is null
|
|
) lot on b.lotno=lot.lotno
|
|
where inv.InvIQC=1
|
|
<1>
|
|
{0}
|
|
|
|
and lot.lotno is null
|
|
|
|
group by c.InvCode,inv.InvName ,c1.BatchCode,a.ASNCode
|
|
|
|
|
|
union all
|
|
|
|
select
|
|
--distinct
|
|
max(b.ID) DetailId --子表主键
|
|
,Max(c.ID) LotNoId --条码ID
|
|
,c.InvCode
|
|
,d.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,sum(b.ODNQuantity) DNQuantity --到货数量
|
|
,max(a.VenCode) VenCode --供应商编码
|
|
,max(e.VenName ) VenName --供应商名称
|
|
,a.OASNCode as ASNCode
|
|
,max(b.EATTRIBUTE1) as IsUrgentItem --加急料
|
|
,max(d.InvUnit) InvUnit
|
|
,sum(c.Quantity) Quantity
|
|
,max(c2.FileName) OutReport
|
|
,max(c2.FilePath) FilePath
|
|
,max(g.id) CheckID
|
|
,case when max(g.CheckNo) is null then '否'else '是' end as IsCheck
|
|
,max(g.Result) Result
|
|
,max(g.FirstCheckTime) CheckDate
|
|
,max(g.WHCode) WHCode
|
|
,max(l.CreateDateTime) DHDate
|
|
,max(l.DNCode) DNCode
|
|
,max(l.DrawingNumber) DrawingNumber
|
|
,'2' as DocType
|
|
from ICSOASN a with(nolock)
|
|
left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCode
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo
|
|
left join ICSInspection wl with(nolock) on b.LotNo=wl.LotNo and b.WorkPoint=wl.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.ASNCode,t.BatchCode,t.invcode,t.FileName,t.FilePath
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on a.OASNCode=c2.ASNCode and c1.BatchCode=c2.BatchCode and c.invcode=c2.invcode
|
|
left join ICSInventory d with(nolock) on c.InvCode=d.InvCode
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode
|
|
left join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.OASNCode=g.AsnCode
|
|
left join (SELECT t.OASNCode,t.InvCode,t.ExtensionID,max(t.CreateDateTime) CreateDateTime,max( t.ODNCode) DNCode,b.EATTRIBUTE2 DrawingNumber
|
|
from ICSODeliveryNotice t with(nolock)
|
|
LEFT JOIN ICSOutsourcingOrder b ON t.OOId=b.OOId AND t.OODetailID=b.OODetailID AND t.workpoint=b.workpoint
|
|
GROUP BY t.OASNCode,t.InvCode,t.ExtensionID,b.EATTRIBUTE2 )l on a.OASNCode=l.OASNCode and c.InvCode=l.InvCode and l.ExtensionID=c.ExtensionID
|
|
left join (select a.LotNo from ICSOASNDetail a
|
|
inner join ICSWareHouseLotInfo b on a.lotno=b.lotno
|
|
left join ICSInspection c on c.LotNo=a.LotNo
|
|
where c.lotno is null
|
|
) lot on b.lotno=lot.lotno
|
|
where d.InvIQC=1
|
|
and lot.lotno is null
|
|
|
|
{0}
|
|
<1>
|
|
|
|
group by c.InvCode,d.InvName ,c1.BatchCode,a.OASNCode
|
|
) a
|
|
where 1=1 AND a.DNQuantity>0
|
|
|
|
|
|
<2>
|
|
<3>
|
|
<4>
|
|
<9>
|
|
<10>
|
|
<11>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(invCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode like '%" + invCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(invName))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + invName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(StartDate))
|
|
{
|
|
sql = sql.Replace("<3>", " and a.DHDate>='" + StartDate + " 00:00:00' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(EndDate))
|
|
{
|
|
sql = sql.Replace("<4>", " and a.DHDate<='" + EndDate + " 23:59:59' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
//{
|
|
// sql = sql.Replace("<5>", " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ");
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("<5>", " ");
|
|
//}
|
|
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
//{
|
|
// sql = sql.Replace("<6>", " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ");
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("<6>", " ");
|
|
//}
|
|
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
//{
|
|
// sql = sql.Replace("<7>", " and a.VenName like '%" + queryParam["VenName"].ToString() + "%' ");
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("<7>", " ");
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["InvBatcgNo"].ToString()))
|
|
//{
|
|
// sql = sql.Replace("<8>", " and a.InvBatcgNo like '%" + queryParam["InvBatcgNo"].ToString() + "%' ");
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("<8>", " ");
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(isCheck))
|
|
{
|
|
sql = sql.Replace("<9>", " and a.IsCheck='" + isCheck + "' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<9>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(checkStartDate))
|
|
{
|
|
sql = sql.Replace("<10>", " and a.CheckDate>='" + checkStartDate + " 00:00:00' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<10>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(CheckEndDate))
|
|
{
|
|
sql = sql.Replace("<11>", " and a.CheckDate<='" + CheckEndDate + " 23:59:59' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<11>", " ");
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable ExportAllCPMaterialInStorageCheck(string invCode, string invName, string isCheck, string StartDate, string EndDate,
|
|
string checkStartDate, string CheckEndDate,string CheckCode, string InvBatcgNo)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string wheresql = string.Empty;
|
|
string workPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
#region 查询条件
|
|
|
|
if (!string.IsNullOrWhiteSpace(invCode))
|
|
{
|
|
wheresql += $"and b.InvCode like '%{invCode}%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(invName))
|
|
{
|
|
wheresql += $"and inv.InvName like '%{invName}%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(StartDate))
|
|
{
|
|
wheresql += $"and b.Mtime >='{StartDate}' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(EndDate))
|
|
{
|
|
wheresql += $"and b.Mtime <'{EndDate}' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(CheckCode))
|
|
{
|
|
wheresql += $"and a.CheckCode like '%{CheckCode}%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(InvBatcgNo))
|
|
{
|
|
wheresql += $"and c1.BatchCode like '%{InvBatcgNo}%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(isCheck))
|
|
{
|
|
if (isCheck == "是")
|
|
{
|
|
wheresql += "and g.CheckNo is not null ";
|
|
}
|
|
else if (isCheck == "否")
|
|
{
|
|
wheresql += "and g.CheckNo is null ";
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(checkStartDate))
|
|
{
|
|
wheresql += $"and g.FirstCheckTime < '{checkStartDate}' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(CheckEndDate))
|
|
{
|
|
wheresql += $"and g.FirstCheckTime < '{CheckEndDate}' ";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
|
|
wheresql += $" and a.WorkPoint='{workPoint}' ";
|
|
}
|
|
#endregion
|
|
#region [SQL]
|
|
string sql = $@" select
|
|
c.InvCode 物料编码
|
|
,inv.InvName 物料名称
|
|
,c1.BatchCode as 批次 --物料批号
|
|
,b.CheckCode 送检单号
|
|
,sum(c.Quantity) 数量
|
|
,g.FirstCheckTime 初检时间
|
|
,case when g.CheckNo is null then '否'else '是' end as 是否检验
|
|
,g.Result 初判结果
|
|
,c2.FilePath 出货报告
|
|
,g.WHCode IQC判入仓库
|
|
FROM ICSInspectionSheet b with(nolock)
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail cc with(nolock) on b.lotno=cc.lotno and cc.WorkPoint=c.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.*
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on b.CheckCode=c2.ASNCode and c1.BatchCode=c2.BatchCode and c.invcode=c2.invcode
|
|
left join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPoint
|
|
left join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and b.CheckCode=g.AsnCode
|
|
where inv.InvFQC=1 {wheresql}
|
|
|
|
GROUP BY c.InvCode,inv.InvName ,c1.BatchCode ,b.CheckCode ,inv.InvUnit
|
|
,c2.FilePath , g.CheckNo ,g.Result ,g.FirstCheckTime
|
|
,g.WHCode,c.ID
|
|
|
|
";
|
|
|
|
#endregion
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public string DeleteMatCheck(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var model = JsonConvert.DeserializeObject<IcsMatCheckResultDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("数据获取失败");
|
|
}
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
InvCode = model.InvCode,
|
|
AsnCode = model.AsnCode,
|
|
InvBatcgNo = model.InvBatcgNo,
|
|
|
|
};
|
|
string sql = @" select * from [IcsMatCheckResult] a with(nolock)
|
|
where InvCode=@InvCode
|
|
and AsnCode=@AsnCode
|
|
and InvBatcgNo=@InvBatcgNo and a.WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<IcsMatCheckResult>(sql, para).ToList();
|
|
if (entityList == null|| entityList.Count==0)
|
|
{
|
|
throw new Exception("当前选择数据不能查到对应检验记录");
|
|
}
|
|
|
|
|
|
|
|
foreach (var item in entityList)
|
|
{
|
|
//var count = MsSqlData.ExecuteScalar(" select count(1) from IcsCheckingFixtureTransfer with(nolock) where CheckFixtureNo='" + item.CheckFixtureNo + "'").ToInt();
|
|
//if (count > 0)
|
|
//{
|
|
// throw new Exception("当前检具已经存在履历,不能删除");
|
|
//}
|
|
|
|
|
|
Pagination pagination = null;
|
|
var invLotNos = GetMaterialInStorageCheckDetailList(item.AsnCode, item.InvBatcgNo, item.InvCode, ref pagination);
|
|
|
|
//删除检验主表记录
|
|
if (invLotNos != null && invLotNos.Rows.Count > 0)
|
|
{
|
|
var lotNos = invLotNos.Select("1=1").Select(x => x["LotNo"].ToString());
|
|
|
|
DeleteInspection(lotNos, para);
|
|
|
|
}
|
|
|
|
var result = MsSqlData.Delete<IcsMatCheckResult>(entityList);
|
|
if (!result)
|
|
{
|
|
throw new Exception("删除失败");
|
|
}
|
|
|
|
var sql2 = @" delete from IcsMatCheckResultDetail where CheckNo='"+item.CheckNo+"' and WorkPoint=@WorkPoint ";
|
|
var count= MsSqlData.Execute(sql2, para);
|
|
//if (count == 0)
|
|
//{
|
|
// throw new Exception("删除失败");
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public string IQC1Back(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<IcsMatCheckResultDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
var entity = MsSqlData.Get<IcsMatCheckResult>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
|
|
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
|
|
Pagination pagination = null;
|
|
var invLotNos = GetMaterialInStorageCheckDetailList(entity.AsnCode, entity.InvBatcgNo, entity.InvCode, ref pagination);
|
|
|
|
var result = true;
|
|
//return "";
|
|
switch (model.BackType)
|
|
{
|
|
case "IQC1Back":
|
|
if (!entity.SQEEngineerResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据已经被SQE判定");
|
|
}
|
|
|
|
if (entity.IQCGroupHeaderResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据还没有被判定");
|
|
}
|
|
|
|
|
|
//删除检验主表记录
|
|
if (invLotNos != null && invLotNos.Rows.Count > 0)
|
|
{
|
|
var lotNos = invLotNos.Select("1=1").Select(x => x["LotNo"].ToString());
|
|
|
|
DeleteInspection(lotNos, para);
|
|
|
|
}
|
|
|
|
//删除当前检验角色检验记录
|
|
entity.IQCGroupHeaderResult = null;
|
|
entity.IQCGroupHeaderRemark = null;
|
|
entity.IQCGroupHeaderUser = null;
|
|
entity.IQCGroupHeaderTime = null;
|
|
break;
|
|
case "SQEBack":
|
|
|
|
if (!entity.IQCHeaderResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据已经被IQC主管判定");
|
|
}
|
|
if (!entity.FinalResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据已经被追最终判定");
|
|
}
|
|
if (entity.SQEEngineerResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据还没有被判定");
|
|
}
|
|
|
|
//删除检验主表记录
|
|
if (invLotNos != null && invLotNos.Rows.Count > 0)
|
|
{
|
|
var lotNos = invLotNos.Select("1=1").Select(x => x["LotNo"].ToString());
|
|
|
|
DeleteInspection(lotNos, para);
|
|
|
|
|
|
}
|
|
|
|
//删除当前检验角色检验记录
|
|
entity.SQEEngineerResult = null;
|
|
entity.SQEEngineerRemark = null;
|
|
entity.SQEEngineerUser = null;
|
|
entity.SQEEngineerTime = null;
|
|
entity.EATTRIBUTE1 = null;
|
|
break;
|
|
case "IQC2Back":
|
|
|
|
if (!entity.FinalResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据已经被追最终判定");
|
|
}
|
|
if (entity.IQCHeaderResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据还没有被判定");
|
|
}
|
|
|
|
//删除检验主表记录
|
|
if (invLotNos != null && invLotNos.Rows.Count > 0)
|
|
{
|
|
var lotNos = invLotNos.Select("1=1").Select(x => x["LotNo"].ToString());
|
|
|
|
DeleteInspection(lotNos, para);
|
|
|
|
|
|
}
|
|
|
|
//删除当前检验角色检验记录
|
|
entity.IQCHeaderResult = null;
|
|
entity.IQCHeaderRemark = null;
|
|
entity.IQCHeaderUser = null;
|
|
entity.IQCHeaderTime = null;
|
|
|
|
break;
|
|
case "FinalJudgeBack":
|
|
|
|
if (entity.FinalResult.IsNullOrEmpty())
|
|
{
|
|
throw new Exception("当前数据还没有被最终判定");
|
|
}
|
|
|
|
//删除检验主表记录
|
|
if (invLotNos != null && invLotNos.Rows.Count > 0)
|
|
{
|
|
var lotNos = invLotNos.Select("1=1").Select(x => x["LotNo"].ToString());
|
|
|
|
DeleteInspection(lotNos, para);
|
|
|
|
|
|
}
|
|
|
|
//删除当前检验角色检验记录
|
|
entity.FinalUser = null;
|
|
entity.FinalResult = null;
|
|
entity.FinalTime = null;
|
|
entity.GoodQty = 0;
|
|
entity.NgQty = 0;
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.IsCheckComplete = null;
|
|
result = MsSqlData.Update<IcsMatCheckResult>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
private void DeleteInspection(IEnumerable<string> lotNos, object para)
|
|
{
|
|
var isInstorageSql = @"select count(1) from ICSWareHouseLotInfo a with(nolock) where a.LotNo in ('" + string.Join("','", lotNos) + "') and WorkPoint=@WorkPoint";
|
|
|
|
var count = MsSqlData.ExecuteScalar(isInstorageSql, para).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前检验单号对应条码已经入库");
|
|
}
|
|
|
|
var sql = @"delete from ICSInspection where LotNo in ('" + string.Join("','", lotNos) + "') and WorkPoint=@WorkPoint";
|
|
var sql2 = @"delete FROM ICSDeliveryNotice WHERE EATTRIBUTE1 in ('" + string.Join("','", lotNos) + "') and WorkPoint=@WorkPoint";
|
|
|
|
var aa = MsSqlData.Execute(sql, para);
|
|
aa = MsSqlData.Execute(sql2, para);
|
|
}
|
|
|
|
public DataTable ExportMaterialInStorageFinalList(string invCode, string invName, string isCheckComplete, string startDate, string endDate, string aSNCode
|
|
, string venCode, string venName, string invBatcgNo, string juegeProgess, string bcgCode)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.ASNCode 送货单号
|
|
,InvCode 物料编码
|
|
,InvName 物料名称
|
|
,InvBatcgNo 批次
|
|
,InvBatcgQty 批次数量
|
|
,VenCode 供应商
|
|
,VenName 供应商名称
|
|
,a.IQCGroupHeaderResult IQC组长判定
|
|
,a.IQCHeaderResult IQC主管判定
|
|
,a.SQEEngineerResult SQE工程师判定
|
|
,a.FinalResult 最终判定
|
|
,a.EATTRIBUTE1 SQE处理方案
|
|
,a.DHDate 到货时间
|
|
,a.IQCGroupHeaderUser IQC组长判定人员
|
|
,a.IQCGroupHeaderTime IQC组长判定时间
|
|
,a.IQCHeaderUser IQC主管判定人员
|
|
,a.IQCHeaderTime IQC主管判定时间
|
|
,a.SQEEngineerUser SQE工程师判定人员
|
|
,a.SQEEngineerTime SQE工程师判定时间
|
|
,a.FinalUser 最终判定人员
|
|
,a.FinalTime 最终判定时间
|
|
,a.BcgDesc 不良分类
|
|
,a.HasReturnItem 仓库已退实物
|
|
,a.Urgent 加急
|
|
,a.FirstCheckUser 初检人员
|
|
,a.FirstCheckTime 初检时间
|
|
,a.EATTRIBUTE7 异常单号
|
|
,a.Remark 备注
|
|
,a.DrawingNumber 图号
|
|
from
|
|
(
|
|
select
|
|
distinct
|
|
a.ID
|
|
,a.CheckNo
|
|
,a.AsnCode ASNCode
|
|
,a.InvCode
|
|
,b.InvName
|
|
,a.InvBatcgNo
|
|
,a.InvBatcgQty
|
|
,a.VenCode
|
|
,c.VenName
|
|
,c2.FileName OutReport --出货报告
|
|
,c2.FilePath
|
|
,a.IQCGroupHeaderResult
|
|
,a.IQCHeaderResult
|
|
,a.SQEEngineerResult
|
|
,a.FinalResult
|
|
,a.IsCheckComplete
|
|
,a.EATTRIBUTE1
|
|
,a.EATTRIBUTE3 CheckDate
|
|
,case when l.CreateDateTime is not null then l.CreateDateTime
|
|
when l2.CreateDateTime is not null then l2.CreateDateTime
|
|
else null end as DHDate
|
|
,a.IQCGroupHeaderUser
|
|
,a.IQCGroupHeaderTime
|
|
,a.IQCHeaderUser
|
|
,a.IQCHeaderTime
|
|
,a.SQEEngineerUser
|
|
,a.SQEEngineerTime
|
|
,a.FinalUser
|
|
,a.FinalTime
|
|
,a.BRGCode
|
|
,bcg.BcgDesc
|
|
,a.HasReturnItem
|
|
,a.Urgent
|
|
,a.FirstCheckUser
|
|
,a.FirstCheckTime
|
|
,a.WgNgFile
|
|
,a.Remark
|
|
,a.EATTRIBUTE7
|
|
,case when po.EATTRIBUTE2 is null then oo.EATTRIBUTE2
|
|
else po.EATTRIBUTE2 end as DrawingNumber
|
|
from IcsMatCheckResult a with(nolock)
|
|
left join ICSBadCodeGroup bcg with(nolock) on a.BRGCode=bcg.bcgcode and a.WorkPoint=bcg.WorkPoint
|
|
left join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSVendor c with(nolock) on a.VenCode=c.VenCode and a.WorkPoint=c.WorkPoint
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.*
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on a.ASNCode=c2.ASNCode and a.InvBatcgNo=c2.BatchCode and a.invcode=c2.invcode
|
|
left join ICSDeliveryNotice l with(nolock) on a.ASNCode=l.ASNCode AND a.WorkPoint=l.WorkPoint AND a.InvCode=l.InvCode
|
|
left join ICSODeliveryNotice l2 with(nolock) on a.ASNCode=l2.OASNCode AND a.WorkPoint=l2.WorkPoint AND a.InvCode=l2.InvCode
|
|
left JOIN ICSPurchaseOrder po with(nolock) ON po.POID=l.POID AND po.PODetailID=l.PODetailID and l.workpoint=po.workpoint
|
|
LEFT JOIN ICSOutsourcingOrder oo with(nolock) ON oo.OOId=l2.OOId AND oo.OODetailID=l2.OODetailID AND oo.workpoint=l2.workpoint
|
|
where 1=1 AND b.InvIQC='1'
|
|
{0}
|
|
and a.Result='NG' and isnull(a.EATTRIBUTE4,'') !='1'
|
|
) a
|
|
where 1=1
|
|
|
|
--and a.AsnCode=''
|
|
--order by a.CheckNo
|
|
|
|
<1>
|
|
<2>
|
|
<3>
|
|
<4>
|
|
<5>
|
|
<6>
|
|
<7>
|
|
<8>
|
|
<9>
|
|
<10>
|
|
<11>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(invCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode like '%" + invCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(invName))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + invName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(startDate))
|
|
{
|
|
sql = sql.Replace("<3>", " and a.DHDate>='" + startDate + " 00:00:00' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(endDate))
|
|
{
|
|
sql = sql.Replace("<4>", " and a.DHDate<='" + endDate + " 23:59:59' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(aSNCode))
|
|
{
|
|
sql = sql.Replace("<5>", " and a.ASNCode like '%" + aSNCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<5>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(venCode))
|
|
{
|
|
sql = sql.Replace("<6>", " and a.VenCode like '%" + venCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<6>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(venName))
|
|
{
|
|
sql = sql.Replace("<7>", " and a.VenName like '%" + venName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<7>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(invBatcgNo))
|
|
{
|
|
sql = sql.Replace("<8>", " and a.InvBatcgNo like '%" + invBatcgNo + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<8>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(isCheckComplete))
|
|
{
|
|
if (isCheckComplete == "是")
|
|
sql = sql.Replace("<9>", " and a.IsCheckComplete='" + isCheckComplete + "' ");
|
|
else
|
|
sql = sql.Replace("<9>", " and a.IsCheckComplete is null ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<9>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(juegeProgess))
|
|
{
|
|
var aa = juegeProgess;
|
|
if (aa == "1")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCGroupHeaderResult is null ");
|
|
}
|
|
if (aa == "2")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCGroupHeaderResult is not null ");
|
|
}
|
|
if (aa == "3")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.SQEEngineerResult is null ");
|
|
}
|
|
if (aa == "4")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.SQEEngineerResult is not null ");
|
|
}
|
|
if (aa == "5")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCHeaderResult is null ");
|
|
}
|
|
if (aa == "6")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCHeaderResult is not null ");
|
|
}
|
|
if (aa == "7")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.FinalResult is null ");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<10>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(bcgCode))
|
|
{
|
|
sql = sql.Replace("<11>", " and a.BcgDesc like '%" + bcgCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<11>", " ");
|
|
}
|
|
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public string UpdateMaterialReUrgent(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var models = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
if (models == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
var sql = @"select * from IcsMatCheckResult a with(nolock) where a.id in ('" + string.Join("','", models) + "') and a.WorkPoint=@WorkPoint";
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
//查询已存在条码记录
|
|
var getList = MsSqlData.Query<IcsMatCheckResult>(sql, para).ToList();
|
|
|
|
foreach (var item in getList)
|
|
{
|
|
item.Urgent = "是";
|
|
item.MUSER = MUSER;
|
|
item.MUSERName = MUSERNAME;
|
|
item.MTIME = dtNow;
|
|
var result = MsSqlData.Update<IcsMatCheckResult>(item);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string UpdateMaterialHasReturnItem(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<IcsMatCheckResultDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
|
|
|
|
var sql = @"select * from IcsMatCheckResult a with(nolock) where a.id in ('" + model.ID + "') and a.WorkPoint=@WorkPoint";
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
//查询已存在条码记录
|
|
var getList = MsSqlData.Query<IcsMatCheckResult>(sql, para).ToList();
|
|
//return "";
|
|
foreach (var item in getList)
|
|
{
|
|
if (item.NgQty > 0)
|
|
{
|
|
item.HasReturnItem = "是";
|
|
item.HasReturnTime = dtNow;
|
|
item.WHRemark = model.WHRemark;
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
item.MUSER = MUSER;
|
|
item.MUSERName = MUSERNAME;
|
|
item.MTIME = dtNow;
|
|
var result = MsSqlData.Update<IcsMatCheckResult>(item);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string ImportItem2CheckGroup(string savePath)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
DateTime time = DateTime.Now;
|
|
|
|
//DataSet dsSave = new DataSet();
|
|
//dsSave.Tables.Add(data.Copy());
|
|
DateTime dtNow = DateTime.Now;
|
|
//dsSave.Tables[0].TableName = "IcsCheckingFixture";
|
|
//ICSInspectionGroupEntity entity = new ICSInspectionGroupEntity();
|
|
List<ICSInventoryInspectionListDto> dtolist = new List<ICSInventoryInspectionListDto>();
|
|
List<ICSInventoryInspectionGroupEntity> list = new List<ICSInventoryInspectionGroupEntity>();
|
|
List<ICSInventoryInspectionListEntity> detailList = new List<ICSInventoryInspectionListEntity>();
|
|
|
|
var para = new { WorkPoint = WorkPoint };
|
|
string sql0 = @"
|
|
select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode='CheckAttr'
|
|
|
|
";
|
|
var enumList = MsSqlData.Query<SysEnumValueDto>(sql0, para).ToList();
|
|
|
|
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
|
|
var item = data.Rows[i];
|
|
if (item["物料代码"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "物料代码为空");
|
|
}
|
|
if (item["物料名称"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "物料名称为空");
|
|
}
|
|
if (item["检验项目编码"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "检验项目编码为空");
|
|
}
|
|
if (item["检验项目名称"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "检验项目名称为空");
|
|
}
|
|
if (item["检验属性"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "检验属性为空");
|
|
}
|
|
if (item["启用(是否)"].ToStringExt() == "")
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "启用(是否)为空");
|
|
}
|
|
|
|
var dto = new ICSInventoryInspectionListDto();
|
|
dto.InvCode = item["物料代码"].ToStringExt();
|
|
dto.InvName = item["物料名称"].ToStringExt();
|
|
dto.ListCode = item["检验项目编码"].ToStringExt();
|
|
dto.ListName = item["检验项目名称"].ToStringExt();
|
|
dto.EATTRIBUTE1 = item["检验方法"].ToStringExt();
|
|
dto.CheckAttr = item["检验属性"].ToStringExt();
|
|
|
|
var enumValue = enumList.Where(x => x.label == dto.CheckAttr).FirstOrDefault();
|
|
if (enumValue == null)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "检验属性不能识别");
|
|
}
|
|
dto.CheckAttr = enumValue.value;
|
|
dto.SetValueMax = item["设计最大值"].ToDecimal();
|
|
dto.SetValueMin = item["设计最小值"].ToDecimal();
|
|
dto.Unit = item["单位"].ToStringExt();
|
|
dto.Enable = item["启用(是否)"].ToStringExt() == "是" ? true : false;
|
|
dtolist.Add(dto);
|
|
|
|
|
|
|
|
if (enumValue.Ext1 == "尺寸")
|
|
{
|
|
//尺寸
|
|
if (!dto.SetValueMax.HasValue || !dto.SetValueMin.HasValue || dto.Unit.IsEmpty())
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + " 当属性为尺寸时,最大值,最小值,单位必填");
|
|
}
|
|
if (dto.SetValueMax.Value <= dto.SetValueMin.Value)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + " 最大值必须大于最小值");
|
|
}
|
|
}
|
|
|
|
string dtPre = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSInventoryInspectionGroup','GroupCode','" + "IGC" + dtPre + "',3";
|
|
var serialNo = MsSqlData.ExecuteScalar(sql).ToStringExt();
|
|
|
|
ICSInventoryInspectionGroupEntity entity = new ICSInventoryInspectionGroupEntity();
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.InvCode = dto.InvCode;
|
|
entity.GroupCode = serialNo;
|
|
entity.GroupName = serialNo;
|
|
entity.EATTRIBUTE1 = dto.CheckAttr;
|
|
entity.Enable = true;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.WorkPoint = WorkPoint;
|
|
|
|
|
|
|
|
var detail = new ICSInventoryInspectionListEntity();
|
|
detail = ConvertExt.Mapping<ICSInventoryInspectionListDto, ICSInventoryInspectionListEntity>(dto);
|
|
detail.InvGroupID = entity.ID;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
|
|
var sql4Count = @" select
|
|
count(1)
|
|
from
|
|
(
|
|
select
|
|
a.ID
|
|
, c.InvCode
|
|
, c.InvName
|
|
, a.ListCode
|
|
, a.ListName
|
|
, b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID = b.ID
|
|
left join ICSInventory c with(nolock) on b.InvCode = c.InvCode
|
|
|
|
) a
|
|
where 1 = 1
|
|
and a.InvCode = @InvCode and a.ListCode=@ListCode ";
|
|
var para2 = new { InvCode = dto.InvCode, ListCode = dto.ListCode, CheckAttr = dto.CheckAttr };
|
|
var count = MsSqlData.ExecuteScalar(sql4Count, para2).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "当前物料检验项目关系已经存在");
|
|
}
|
|
|
|
|
|
var itemCode = MsSqlData.Query<ICSInventoryDto>(
|
|
@"select top 1 * from ICSInventory a with(nolock)
|
|
where a.InvCode = '" + entity.InvCode + "'")
|
|
.FirstOrDefault();
|
|
if (itemCode == null)
|
|
{
|
|
throw new Exception("第" + (i + 1) + "行," + "当前物料不存在");
|
|
}
|
|
|
|
|
|
list.Add(entity);
|
|
detailList.Add(detail);
|
|
}
|
|
|
|
|
|
if (list.Count == 0 || detailList.Count == 0)
|
|
{
|
|
throw new Exception("没有导入数据");
|
|
}
|
|
//if (list != null && list.Count > 0)
|
|
//{
|
|
// if (list.Select(x => x.InvCode).Distinct().Count() != list.Count)
|
|
// {
|
|
// throw new Exception("一个物料只能绑定一个检验类型");
|
|
// }
|
|
//}
|
|
var groupList = dtolist.GroupBy(x => new { x.ListCode, x.InvCode });
|
|
|
|
if (groupList.Count() != dtolist.Count)
|
|
{
|
|
var codeError = groupList.Where(x => x.Count() > 1).FirstOrDefault();
|
|
// var conGroupList= groupList.Count()
|
|
throw new Exception("当前物料检验项目代码重复,对应物料和检验项目代码: " + codeError.Key.ListCode + "|" + codeError.Key.InvCode);
|
|
}
|
|
|
|
|
|
var result = MsSqlData.Insert<ICSInventoryInspectionGroupEntity>(list);
|
|
if (!result)
|
|
{
|
|
throw new Exception("导入失败");
|
|
}
|
|
result = MsSqlData.Insert<ICSInventoryInspectionListEntity>(detailList);
|
|
if (!result)
|
|
{
|
|
throw new Exception("导入失败");
|
|
}
|
|
|
|
returnValue = "true";
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
|
|
public List<SelectItemDto> GetSelectBadReasonList(string keyValue)
|
|
{
|
|
var returnValue = new List<SelectItemDto>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var sql = @"select
|
|
a.*
|
|
from ICSBadReason a with(nolock)
|
|
where 1=1
|
|
and a.WorkPoint=@WorkPoint
|
|
and a.BRGroupID=(
|
|
select
|
|
a.ID
|
|
from ICSBadReasonGroup a with(nolock)
|
|
where 1=1
|
|
and a.BRGCode=@BRGroupID
|
|
)
|
|
order by a.BadReasonCode asc ";
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
BRGroupID = keyValue
|
|
};
|
|
var query = MsSqlData.Query<ICSBadReasonEntity>(sql, para);
|
|
|
|
int index = 0;
|
|
returnValue = query.Select(x =>
|
|
{
|
|
++index;
|
|
SelectItemDto item = new SelectItemDto();
|
|
|
|
item.key = index;
|
|
item.value = x.BadReasonCode;
|
|
item.label = x.BadReasonDesc;
|
|
return item;
|
|
}).ToList();
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public List<SelectItemDto> GetSelectBadReasonGroupList()
|
|
{
|
|
var returnValue = new List<SelectItemDto>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var sql = @"select
|
|
a.*
|
|
from ICSBadReasonGroup a with(nolock)
|
|
where 1=1
|
|
and a.WorkPoint=@WorkPoint
|
|
order by a.Mtime asc ";
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
var query = MsSqlData.Query<ICSBadReasonGroupEntity>(sql, para);
|
|
|
|
int index = 0;
|
|
returnValue = query.Select(x =>
|
|
{
|
|
++index;
|
|
SelectItemDto item = new SelectItemDto();
|
|
|
|
item.key = index;
|
|
item.value = x.BRGCode;
|
|
item.label = x.BRGDesc;
|
|
return item;
|
|
}).ToList();
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public List<SelectItemDto> GetSelectBadCodeGroupList()
|
|
{
|
|
var returnValue = new List<SelectItemDto>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var sql = @"select
|
|
a.*
|
|
from ICSBadCodeGroup a with(nolock)
|
|
where 1=1
|
|
and a.WorkPoint=@WorkPoint
|
|
order by a.Mtime asc ";
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
var query = MsSqlData.Query<ICSBadCodeGroupEntity>(sql, para);
|
|
|
|
int index = 0;
|
|
returnValue = query.Select(x =>
|
|
{
|
|
++index;
|
|
SelectItemDto item = new SelectItemDto();
|
|
|
|
item.key = index;
|
|
item.value = x.BCGCode;
|
|
item.label = x.BCGDesc;
|
|
return item;
|
|
}).ToList();
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public IcsMatCheckResultDto GetMaterialReJudgeMain(string keyValue)
|
|
{
|
|
var returnValue = new IcsMatCheckResultDto();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
|
|
var para1 = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
Id = keyValue
|
|
|
|
};
|
|
|
|
var sqlMain = @"select top 1
|
|
a.*
|
|
,b.InvName
|
|
,e.VenName
|
|
,case when l.CreateDateTime is not null then l.CreateDateTime
|
|
when l2.CreateDateTime is not null then l2.CreateDateTime
|
|
else null end as DHDate
|
|
from IcsMatCheckResult a with(nolock)
|
|
left join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
left join ICSDeliveryNotice l with(nolock) on a.ASNCode=l.ASNCode
|
|
left join ICSODeliveryNotice l2 with(nolock) on a.ASNCode=l2.OASNCode
|
|
where 1 = 1
|
|
and a.WorkPoint= @WorkPoint
|
|
--and a.CheckNo='CR202410300001'
|
|
and a.ID=@Id";
|
|
|
|
returnValue = MsSqlData.Query<IcsMatCheckResultDto>(sqlMain, para1).FirstOrDefault();
|
|
|
|
if (returnValue == null)
|
|
{
|
|
throw new Exception("当前检验单数据查询失败");
|
|
}
|
|
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
CheckNo = returnValue.CheckNo
|
|
};
|
|
var sql1 = @"select
|
|
a.*
|
|
|
|
from IcsMatCheckResultDetail a with(nolock)
|
|
where 1 = 1
|
|
and a.WorkPoint = @WorkPoint
|
|
and a.CheckNo=@CheckNo
|
|
order by a.CheckAttr ,a.CheckItemCode";
|
|
var detailList = MsSqlData.Query<IcsMatCheckResultDetailDto>(sql1, para);
|
|
|
|
|
|
|
|
// var para = new { WorkPoint = WorkPoint };
|
|
string sql0 = @"
|
|
select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode='CheckAttr'
|
|
|
|
";
|
|
var enumList = MsSqlData.Query<SysEnumValueDto>(sql0, para).ToList();
|
|
var chicun = enumList.Where(x => x.Ext1 == "尺寸").Select(x => x.value);
|
|
returnValue.CCList = detailList.Where(x => chicun.Contains(x.CheckAttr)).ToList();
|
|
|
|
chicun = enumList.Where(x => x.Ext1 == "外观").Select(x => x.value);
|
|
returnValue.WGList = detailList.Where(x => chicun.Contains(x.CheckAttr)).ToList();
|
|
|
|
chicun = enumList.Where(x => x.Ext1 == "性能").Select(x => x.value);
|
|
returnValue.XNList = detailList.Where(x => chicun.Contains(x.CheckAttr)).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = new IcsMatCheckResultDto();
|
|
returnValue.CCList = new List<IcsMatCheckResultDetailDto>();
|
|
returnValue.WGList = new List<IcsMatCheckResultDetailDto>();
|
|
returnValue.XNList = new List<IcsMatCheckResultDetailDto>();
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetMaterialInStorageFinalPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
distinct
|
|
a.ID
|
|
,a.CheckNo
|
|
,a.AsnCode ASNCode
|
|
,a.InvCode
|
|
,b.InvName
|
|
,a.InvBatcgNo
|
|
,a.InvBatcgQty
|
|
,a.VenCode
|
|
,c.VenName
|
|
,c2.FileName OutReport --出货报告
|
|
,c2.FilePath
|
|
,a.IQCGroupHeaderResult
|
|
,a.IQCHeaderResult
|
|
,a.SQEEngineerResult
|
|
,a.FinalResult
|
|
,a.IsCheckComplete
|
|
,a.EATTRIBUTE1
|
|
,a.EATTRIBUTE3 CheckDate
|
|
,case when l.CreateDateTime is not null then l.CreateDateTime
|
|
when l2.CreateDateTime is not null then l2.CreateDateTime
|
|
else null end as DHDate
|
|
,a.IQCGroupHeaderUser
|
|
,a.IQCGroupHeaderTime
|
|
,a.IQCHeaderUser
|
|
,a.IQCHeaderTime
|
|
,a.SQEEngineerUser
|
|
,a.SQEEngineerTime
|
|
,a.FinalUser
|
|
,a.FinalTime
|
|
,a.BRGCode
|
|
,bcg.BcgDesc
|
|
,a.HasReturnItem
|
|
,a.Urgent
|
|
,a.FirstCheckUser
|
|
,a.FirstCheckTime
|
|
,a.WgNgFile
|
|
,a.SQEFile
|
|
,a.GoodQty
|
|
,a.NgQty
|
|
,a.HasReturnTime
|
|
,a.WHRemark
|
|
,a.Remark
|
|
,a.EATTRIBUTE7
|
|
,case when po.EATTRIBUTE2 is null then oo.EATTRIBUTE2
|
|
else po.EATTRIBUTE2 end as DrawingNumber
|
|
from IcsMatCheckResult a with(nolock)
|
|
left join ICSBadCodeGroup bcg with(nolock) on a.BRGCode=bcg.bcgcode and a.WorkPoint=bcg.WorkPoint
|
|
left join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSVendor c with(nolock) on a.VenCode=c.VenCode and a.WorkPoint=c.WorkPoint
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.*
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on a.ASNCode=c2.ASNCode and a.InvBatcgNo=c2.BatchCode and a.invcode=c2.invcode
|
|
left join ICSDeliveryNotice l with(nolock) on a.ASNCode=l.ASNCode AND a.WorkPoint=l.WorkPoint AND a.InvCode=l.InvCode
|
|
left join ICSODeliveryNotice l2 with(nolock) on a.ASNCode=l2.OASNCode AND a.WorkPoint=l2.WorkPoint AND a.InvCode=l2.InvCode
|
|
left JOIN ICSPurchaseOrder po with(nolock) ON po.POID=l.POID AND po.PODetailID=l.PODetailID and l.workpoint=po.workpoint
|
|
LEFT JOIN ICSOutsourcingOrder oo with(nolock) ON oo.OOId=l2.OOId AND oo.OODetailID=l2.OODetailID AND oo.workpoint=l2.workpoint
|
|
where b.InvIQC='1'
|
|
{0}
|
|
and a.Result='NG' and isnull(a.EATTRIBUTE4,'') !='1'
|
|
) a
|
|
where 1=1
|
|
|
|
--and a.AsnCode=''
|
|
--order by a.CheckNo
|
|
|
|
<1>
|
|
<2>
|
|
<3>
|
|
<4>
|
|
<5>
|
|
<6>
|
|
<7>
|
|
<8>
|
|
<9>
|
|
<10>
|
|
<11>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + queryParam["InvName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["StartDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<3>", " and a.DHDate>='" + queryParam["StartDate"].ToString() + " 00:00:00' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<4>", " and a.DHDate<='" + queryParam["EndDate"].ToString() + " 23:59:59' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<5>", " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<5>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<6>", " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<6>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<7>", " and a.VenName like '%" + queryParam["VenName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<7>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvBatcgNo"].ToString()))
|
|
{
|
|
sql = sql.Replace("<8>", " and a.InvBatcgNo like '%" + queryParam["InvBatcgNo"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<8>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["IsCheckComplete"].ToString()))
|
|
{
|
|
if (queryParam["IsCheckComplete"].ToString() == "是")
|
|
sql = sql.Replace("<9>", " and a.IsCheckComplete='" + queryParam["IsCheckComplete"].ToString() + "' ");
|
|
else
|
|
sql = sql.Replace("<9>", " and a.IsCheckComplete is null ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<9>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["JuegeProgess"].ToString()))
|
|
{
|
|
var aa = queryParam["JuegeProgess"].ToString();
|
|
if (aa == "1")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCGroupHeaderResult is null ");
|
|
}
|
|
if (aa == "2")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCGroupHeaderResult is not null ");
|
|
}
|
|
if (aa == "3")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.SQEEngineerResult is null ");
|
|
}
|
|
if (aa == "4")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.SQEEngineerResult is not null ");
|
|
}
|
|
if (aa == "5")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCHeaderResult is null ");
|
|
}
|
|
if (aa == "6")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.IQCHeaderResult is not null ");
|
|
}
|
|
if (aa == "7")
|
|
{
|
|
sql = sql.Replace("<10>", " and a.FinalResult is null ");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<10>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BcgCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<11>", " and a.BcgDesc like '%" + queryParam["BcgCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<11>", " ");
|
|
}
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public DataTable GetCPMaterialInStorageFinalPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
distinct
|
|
a.ID
|
|
,a.CheckNo
|
|
,a.AsnCode CheckCode
|
|
,a.InvCode
|
|
,b.InvName
|
|
,a.InvBatcgNo
|
|
,a.InvBatcgQty
|
|
,a.VenCode
|
|
,c.VenName
|
|
,c2.FileName OutReport --出货报告
|
|
,c2.FilePath
|
|
,a.IQCGroupHeaderResult
|
|
,a.IQCHeaderResult
|
|
,a.SQEEngineerResult
|
|
,a.FinalResult
|
|
,a.IsCheckComplete
|
|
,a.EATTRIBUTE1
|
|
,a.EATTRIBUTE3 CheckDate
|
|
,l.MTIME DHDate
|
|
,a.IQCGroupHeaderUser
|
|
,a.IQCGroupHeaderTime
|
|
,a.IQCHeaderUser
|
|
,a.IQCHeaderTime
|
|
,a.SQEEngineerUser
|
|
,a.SQEEngineerTime
|
|
,a.FinalUser
|
|
,a.FinalTime
|
|
,a.BRGCode
|
|
,bcg.BcgDesc
|
|
,a.HasReturnItem
|
|
,a.Urgent
|
|
,a.FirstCheckUser
|
|
,a.FirstCheckTime
|
|
,a.WgNgFile
|
|
,a.SQEFile
|
|
,a.GoodQty
|
|
,a.NgQty
|
|
,a.HasReturnTime
|
|
,a.WHRemark
|
|
from IcsMatCheckResult a with(nolock)
|
|
left join ICSBadCodeGroup bcg with(nolock) on a.BRGCode=bcg.bcgcode and a.WorkPoint=bcg.WorkPoint
|
|
left join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSVendor c with(nolock) on a.VenCode=c.VenCode and a.WorkPoint=c.WorkPoint
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.*
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on a.ASNCode=c2.ASNCode and a.InvBatcgNo=c2.BatchCode and a.invcode=c2.invcode
|
|
left join ICSInspectionSheet l with(nolock) on a.ASNCode=l.CheckCode
|
|
where b.InvFQC='1'
|
|
{0}
|
|
and
|
|
a.Result='NG' and isnull(a.EATTRIBUTE4,'') !='1'
|
|
) a
|
|
where 1=1
|
|
|
|
--and a.AsnCode=''
|
|
--order by a.CheckNo
|
|
|
|
<1>
|
|
<2>
|
|
<3>
|
|
<4>
|
|
<5>
|
|
<8>
|
|
<9>
|
|
<11>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + queryParam["InvName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["StartDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<3>", " and a.DHDate>='" + queryParam["StartDate"].ToString() + " 00:00:00' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<4>", " and a.DHDate<='" + queryParam["EndDate"].ToString() + " 23:59:59' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<5>", " and a.CheckCode like '%" + queryParam["ASNCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<5>", " ");
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvBatcgNo"].ToString()))
|
|
{
|
|
sql = sql.Replace("<8>", " and a.InvBatcgNo like '%" + queryParam["InvBatcgNo"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<8>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["IsCheckComplete"].ToString()))
|
|
{
|
|
if (queryParam["IsCheckComplete"].ToString() == "是")
|
|
sql = sql.Replace("<9>", " and a.IsCheckComplete='" + queryParam["IsCheckComplete"].ToString() + "' ");
|
|
else
|
|
sql = sql.Replace("<9>", " and a.IsCheckComplete is null ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<9>", " ");
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BcgCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<11>", " and a.BcgDesc like '%" + queryParam["BcgCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<11>", " ");
|
|
}
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public string SaveMaterialCheckResult(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
var otherApp = new DHICSRCVIQCsApp();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<IcsMatCheckResultDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
|
|
var getCountSql = @"select Count(1) from IcsMatCheckResult a with(nolock) where a.AsnCode=@AsnCode
|
|
and a.InvCode=@InvCode
|
|
and a.InvBatcgNo=@InvBatcgNo
|
|
and a.WorkPoint=@WorkPoint
|
|
";
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
AsnCode = model.AsnCode,
|
|
InvCode = model.InvCode,
|
|
InvBatcgNo = model.InvBatcgNo,
|
|
};
|
|
var getCount = MsSqlData.ExecuteScalar(getCountSql, para).ToInt();
|
|
if (getCount > 0)
|
|
{
|
|
throw new Exception("当前批次号已经存在检验记录");
|
|
}
|
|
|
|
string dtPre = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','IcsMatCheckResult','CheckNo','" + "CR" + dtPre + "',4";
|
|
var serialNo = MsSqlData.ExecuteScalar(sql).ToStringExt();
|
|
|
|
var entity = new IcsMatCheckResult();
|
|
entity = ConvertExt.Mapping<IcsMatCheckResultDto, IcsMatCheckResult>(model);
|
|
entity.CheckNo = serialNo;
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.FirstCheckUser = MUSERNAME;
|
|
entity.FirstCheckTime = dtNow;
|
|
entity.WorkPoint = WorkPoint;
|
|
entity.WgNgFile = model.WgNgFile;
|
|
// entity.EATTRIBUTE3 = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
|
|
MsSqlData.Insert<IcsMatCheckResult>(entity);
|
|
|
|
//合格给到仓库进行入库,不合格则由IQC组长进行判定;
|
|
#region 合格
|
|
if (model.Result == "OK")
|
|
{
|
|
Pagination pagination = new Pagination();
|
|
var itemLotDt = GetMaterialInStorageCheckDetailList(model.AsnCode, model.InvBatcgNo, model.InvCode, ref pagination);
|
|
var itemLotList = JsonConvert.DeserializeObject<List<IcsItemLotInIQCCheckDto>>(itemLotDt.ToJson());
|
|
|
|
GoodInStorage(dtNow, model, itemLotList);
|
|
}
|
|
#endregion
|
|
|
|
#region 检验项目保存
|
|
List<IcsMatCheckResultDetail> detailList = new List<IcsMatCheckResultDetail>();
|
|
|
|
foreach (var item in model.CCList)
|
|
{
|
|
IcsMatCheckResultDetail detail = ConvertExt.Mapping<IcsMatCheckResultDetailDto, IcsMatCheckResultDetail>(item);
|
|
detail.CheckNo = serialNo;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
// detail.CheckItemCod
|
|
detailList.Add(detail);
|
|
}
|
|
|
|
foreach (var item in model.WGList)
|
|
{
|
|
IcsMatCheckResultDetail detail = ConvertExt.Mapping<IcsMatCheckResultDetailDto, IcsMatCheckResultDetail>(item);
|
|
detail.CheckNo = serialNo;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
|
|
detailList.Add(detail);
|
|
}
|
|
|
|
foreach (var item in model.XNList)
|
|
{
|
|
IcsMatCheckResultDetail detail = ConvertExt.Mapping<IcsMatCheckResultDetailDto, IcsMatCheckResultDetail>(item);
|
|
detail.CheckNo = serialNo;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
|
|
detailList.Add(detail);
|
|
}
|
|
|
|
if (detailList.Count > 0)
|
|
{
|
|
MsSqlData.Insert<IcsMatCheckResultDetail>(detailList);
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 实验抽选数量拒收单
|
|
if (model.FinalItemLotList != null && model.FinalItemLotList.Count > 0)
|
|
{
|
|
// var goodList = model.FinalItemLotList.Where(x => x.LeftQty.HasValue && x.GoodQty > 0).ToList();
|
|
var ngList = model.FinalItemLotList.Where(x => x.SampleQty.HasValue && x.SampleQty > 0).ToList();
|
|
|
|
//GoodInStorage(dtNow, model, goodList);
|
|
|
|
|
|
if (ngList.Count > 0)
|
|
{
|
|
var itemLotNos = ngList.Select(x => x.LotNo);
|
|
var lotNoStr = string.Empty;
|
|
foreach (var str in itemLotNos)
|
|
{
|
|
lotNoStr += "'" + str + "',";
|
|
}
|
|
|
|
//记录日志
|
|
InsertOperateLog(serialNo, JsonConvert.SerializeObject(itemLotNos), entity.GetType().Name, "实验");
|
|
if (model.EATTRIBUTE2 == "1")
|
|
{
|
|
var msg = otherApp.CreateRejection4KBS(lotNoStr);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else if (model.EATTRIBUTE2 == "2")
|
|
{
|
|
var msg = otherApp.CreateBBWWRejection(lotNoStr);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
SendEmail(model);
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
public string SaveCPMaterialCheckResult(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
var otherApp = new DHICSRCVIQCsApp();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<IcsMatCheckResultDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
|
|
var getCountSql = @"select Count(1) from IcsMatCheckResult a with(nolock) where a.AsnCode=@AsnCode
|
|
and a.InvCode=@InvCode
|
|
and a.InvBatcgNo=@InvBatcgNo
|
|
and a.WorkPoint=@WorkPoint
|
|
";
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
AsnCode = model.AsnCode,
|
|
InvCode = model.InvCode,
|
|
InvBatcgNo = model.InvBatcgNo,
|
|
};
|
|
var getCount = MsSqlData.ExecuteScalar(getCountSql, para).ToInt();
|
|
if (getCount > 0)
|
|
{
|
|
throw new Exception("当前批次号已经存在检验记录");
|
|
}
|
|
|
|
string dtPre = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','IcsMatCheckResult','CheckNo','" + "CR" + dtPre + "',4";
|
|
var serialNo = MsSqlData.ExecuteScalar(sql).ToStringExt();
|
|
|
|
var entity = new IcsMatCheckResult();
|
|
entity = ConvertExt.Mapping<IcsMatCheckResultDto, IcsMatCheckResult>(model);
|
|
entity.CheckNo = serialNo;
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.FirstCheckUser = MUSERNAME;
|
|
entity.FirstCheckTime = dtNow;
|
|
entity.WorkPoint = WorkPoint;
|
|
entity.WgNgFile = model.WgNgFile;
|
|
// entity.EATTRIBUTE3 = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
|
|
MsSqlData.Insert<IcsMatCheckResult>(entity);
|
|
|
|
//合格给到仓库进行入库,不合格则由IQC组长进行判定;
|
|
#region 合格
|
|
if (model.Result == "OK")
|
|
{
|
|
Pagination pagination = new Pagination();
|
|
var itemLotDt = GetCPMaterialInStorageCheckDetailList(model.AsnCode, model.InvBatcgNo, model.InvCode, ref pagination);
|
|
var itemLotList = JsonConvert.DeserializeObject<List<IcsItemLotInIQCCheckDto>>(itemLotDt.ToJson());
|
|
|
|
GoodInStorage(dtNow, model, itemLotList);
|
|
}
|
|
#endregion
|
|
|
|
#region 检验项目保存
|
|
List<IcsMatCheckResultDetail> detailList = new List<IcsMatCheckResultDetail>();
|
|
|
|
foreach (var item in model.CCList)
|
|
{
|
|
IcsMatCheckResultDetail detail = ConvertExt.Mapping<IcsMatCheckResultDetailDto, IcsMatCheckResultDetail>(item);
|
|
detail.CheckNo = serialNo;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
// detail.CheckItemCod
|
|
detailList.Add(detail);
|
|
}
|
|
|
|
foreach (var item in model.WGList)
|
|
{
|
|
IcsMatCheckResultDetail detail = ConvertExt.Mapping<IcsMatCheckResultDetailDto, IcsMatCheckResultDetail>(item);
|
|
detail.CheckNo = serialNo;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
|
|
detailList.Add(detail);
|
|
}
|
|
|
|
foreach (var item in model.XNList)
|
|
{
|
|
IcsMatCheckResultDetail detail = ConvertExt.Mapping<IcsMatCheckResultDetailDto, IcsMatCheckResultDetail>(item);
|
|
detail.CheckNo = serialNo;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
|
|
detailList.Add(detail);
|
|
}
|
|
|
|
if (detailList.Count > 0)
|
|
{
|
|
MsSqlData.Insert<IcsMatCheckResultDetail>(detailList);
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 实验抽选数量拒收单
|
|
if (model.FinalItemLotList != null && model.FinalItemLotList.Count > 0)
|
|
{
|
|
// var goodList = model.FinalItemLotList.Where(x => x.LeftQty.HasValue && x.GoodQty > 0).ToList();
|
|
var ngList = model.FinalItemLotList.Where(x => x.SampleQty.HasValue && x.SampleQty > 0).ToList();
|
|
|
|
//GoodInStorage(dtNow, model, goodList);
|
|
|
|
|
|
if (ngList.Count > 0)
|
|
{
|
|
var itemLotNos = ngList.Select(x => x.LotNo);
|
|
var lotNoStr = string.Empty;
|
|
foreach (var str in itemLotNos)
|
|
{
|
|
lotNoStr += "'" + str + "',";
|
|
}
|
|
|
|
//记录日志
|
|
InsertOperateLog(serialNo, JsonConvert.SerializeObject(itemLotNos), entity.GetType().Name, "实验");
|
|
if (model.EATTRIBUTE2 == "1")
|
|
{
|
|
var msg = otherApp.CreateRejection4KBS(lotNoStr);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else if (model.EATTRIBUTE2 == "2")
|
|
{
|
|
var msg = otherApp.CreateBBWWRejection(lotNoStr);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
SendEmail(model);
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string SaveMaterialCheckReJudgeResult(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<IcsMatCheckResultDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
var entity = MsSqlData.Get<IcsMatCheckResult>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
Pagination pagination = new Pagination();
|
|
var itemLotDt = GetMaterialInStorageCheckDetailList(model.AsnCode, model.InvBatcgNo, model.InvCode, ref pagination);
|
|
var itemLotList = JsonConvert.DeserializeObject<List<IcsItemLotInIQCCheckDto>>(itemLotDt.ToJson());
|
|
|
|
switch (model.JudgeRole)
|
|
{
|
|
case "IQCGroupHeader":
|
|
entity.IQCGroupHeaderResult = model.IQCGroupHeaderResult;
|
|
entity.IQCGroupHeaderRemark = model.IQCGroupHeaderRemark;
|
|
entity.IQCGroupHeaderUser = MUSERNAME;
|
|
entity.IQCGroupHeaderTime = dtNow;
|
|
entity.BRGCode = model.BRGCode;
|
|
//if (entity.IQCGroupHeaderResult == "")
|
|
//{
|
|
// entity
|
|
//}
|
|
|
|
//IQC组长 2.1.合格交给仓库进行入库,不合格由SQE工程师进行复判;
|
|
#region IQC组长
|
|
if (entity.IQCGroupHeaderResult == "OK")
|
|
{
|
|
entity.IsCheckComplete = "是";
|
|
GoodInStorage(dtNow, model, itemLotList);
|
|
}
|
|
#endregion
|
|
|
|
break;
|
|
case "IQCHeader":
|
|
entity.IQCHeaderResult = model.IQCHeaderResult;
|
|
entity.IQCHeaderRemark = model.IQCHeaderRemark;
|
|
entity.BRGCode = model.BRGCode;
|
|
entity.BadReasonCode = model.BadReasonCode;
|
|
entity.BCGCode = model.BCGCode;
|
|
entity.IQCHeaderUser = MUSERNAME;
|
|
entity.IQCHeaderTime = dtNow;
|
|
|
|
//IQC主管判定 合格后由仓库进行入库,不合格则进行最终判定;
|
|
if (entity.IQCHeaderResult == "OK")
|
|
{
|
|
entity.IsCheckComplete = "是";
|
|
GoodInStorage(dtNow, model, itemLotList);
|
|
}
|
|
|
|
break;
|
|
case "SQEEngineer":
|
|
entity.SQEEngineerResult = model.SQEEngineerResult;
|
|
entity.SQEEngineerRemark = model.SQEEngineerRemark;
|
|
// entity.BRGCode = model.BRGCode;
|
|
entity.SQEEngineerUser = MUSERNAME;
|
|
entity.SQEEngineerTime = dtNow;
|
|
if (entity.SQEEngineerResult == "OK")
|
|
{
|
|
entity.IsCheckComplete = "是";
|
|
GoodInStorage(dtNow, model, itemLotList);
|
|
}
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
entity.EATTRIBUTE1 = model.EATTRIBUTE1;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.SQEFile = model.SQEFile;
|
|
entity.EATTRIBUTE7 = model.EATTRIBUTE7;
|
|
entity.Remark = model.Remark;
|
|
var result = MsSqlData.Update<IcsMatCheckResult>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
|
|
|
|
|
|
DataTable dt = new DataTable();
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
private void GoodInStorage(DateTime dtNow, IcsMatCheckResultDto model, List<IcsItemLotInIQCCheckDto> list)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
if (list.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var para = new
|
|
{
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
var lotNos = list.Select(x => x.LotNo);
|
|
var sql = @"select * from ICSInspection a with(nolock) where a.LotNo in ('" + string.Join("','", lotNos) + "') and a.WorkPoint=@WorkPoint";
|
|
//查询已存在条码记录
|
|
var getList = MsSqlData.Query<ICSInspection>(sql, para).ToList();
|
|
|
|
|
|
List<ICSInspection> checkMainList4Insert = new List<ICSInspection>();
|
|
List<ICSInspection> checkMainList4Update = new List<ICSInspection>();
|
|
foreach (var item in list)
|
|
{
|
|
|
|
// var isEdit = false;
|
|
var inspection = getList.Where(x => x.LotNo == item.LotNo).FirstOrDefault();
|
|
if (inspection == null)
|
|
{
|
|
inspection = new ICSInspection();
|
|
inspection.ID = Guid.NewGuid().ToString();
|
|
inspection.LotNo = item.LotNo;
|
|
inspection.InvCode = item.InvCode;
|
|
inspection.Quantity = item.Quantity;
|
|
|
|
inspection.BCCode = model.BCGCode;
|
|
inspection.BRCode = model.BadReasonCode;
|
|
inspection.Type = "1";
|
|
//inspection.Result = false;
|
|
inspection.Enable = true;
|
|
inspection.WaiveQuantity = 0;
|
|
inspection.SampleQuantity = item.SampleQty.ToDecimal();
|
|
inspection.UnqualifiedQuantity = item.NgQty.ToDecimal();
|
|
inspection.QualifiedQuantity = inspection.Quantity - inspection.SampleQuantity - inspection.UnqualifiedQuantity;
|
|
inspection.MUSER = MUSER;
|
|
inspection.MUSERName = MUSERNAME;
|
|
inspection.MTIME = dtNow;
|
|
inspection.WorkPoint = WorkPoint;
|
|
|
|
checkMainList4Insert.Add(inspection);
|
|
}
|
|
else
|
|
{
|
|
inspection.BCCode = model.BCGCode;
|
|
inspection.BRCode = model.BadReasonCode;
|
|
inspection.WaiveQuantity = 0;
|
|
inspection.SampleQuantity = item.SampleQty.ToDecimal();
|
|
inspection.UnqualifiedQuantity = item.NgQty.ToDecimal();
|
|
inspection.QualifiedQuantity = inspection.Quantity - inspection.SampleQuantity - inspection.UnqualifiedQuantity;
|
|
inspection.MUSER = MUSER;
|
|
inspection.MUSERName = MUSERNAME;
|
|
inspection.MTIME = dtNow;
|
|
checkMainList4Update.Add(inspection);
|
|
}
|
|
|
|
}
|
|
var line = true;
|
|
if (checkMainList4Insert.Count > 0)
|
|
line = MsSqlData.Insert<ICSInspection>(checkMainList4Insert);
|
|
if (checkMainList4Update.Count > 0)
|
|
line = MsSqlData.Update<ICSInspection>(checkMainList4Update);
|
|
}
|
|
|
|
|
|
public string SaveMaterialCheckFinalJudgeResult(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
// List<decimal> list2 = new List<decimal>();
|
|
// decimal maxaa = list2.Select(x => x).ToList().Max();
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var otherApp = new DHICSRCVIQCsApp();
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<IcsMatCheckResultDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
var entity = MsSqlData.Get<IcsMatCheckResult>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
if (model.FinalItemLotList == null || model.FinalItemLotList.Count == 0)
|
|
{
|
|
throw new Exception("当前检验报告不存在物料条码");
|
|
}
|
|
|
|
switch (model.FinalResult)
|
|
{
|
|
case "判退":
|
|
case "NG":
|
|
//③判退:所有的条码不合格,不能输入合格或不合格数量,点击确定即可;(条码拒收)
|
|
//使用当前基础班的拒收
|
|
|
|
//var goodList2 = model.FinalItemLotList.Where(x => x.GoodQty.HasValue && x.GoodQty > 0).ToList();
|
|
//var ngList2 = model.FinalItemLotList.Where(x => x.NgQty.HasValue && x.NgQty > 0).ToList();
|
|
#region //入库检验数据
|
|
|
|
GoodInStorage(dtNow, model, model.FinalItemLotList);
|
|
#endregion
|
|
|
|
|
|
var itemLotNos = model.FinalItemLotList.Select(x => x.LotNo);
|
|
if (itemLotNos.Count() == 0)
|
|
{
|
|
throw new Exception("不存在物料条码");
|
|
}
|
|
var lotNoStr = string.Empty;
|
|
foreach (var str in itemLotNos)
|
|
{
|
|
lotNoStr += "'" + str + "',";
|
|
}
|
|
|
|
//记录日志
|
|
InsertOperateLog(model.CheckNo, JsonConvert.SerializeObject(itemLotNos), entity.GetType().Name, "判退");
|
|
// return "";
|
|
if (entity.EATTRIBUTE2 == "1")
|
|
{
|
|
var msg = otherApp.CreateRejection4BB(lotNoStr);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else if (entity.EATTRIBUTE2 == "2")
|
|
{
|
|
var msg = otherApp.CreateBBWWRejection(lotNoStr);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
//发邮件
|
|
// 参考SRM邮件格式
|
|
//通过物料条码找采购订单/委外订单 采购人员 人员邮箱
|
|
//
|
|
SendEmail(model);
|
|
break;
|
|
case "返工":
|
|
//合格入库 新增 ICSInspection ;不合格拒收,先保存检验记录,在调用拒收单
|
|
|
|
var goodList = model.FinalItemLotList.Where(x => x.GoodQty.HasValue && x.GoodQty > 0).ToList();
|
|
var ngList = model.FinalItemLotList.Where(x => x.NgQty.HasValue && x.NgQty > 0).ToList();
|
|
#region //入库检验数据
|
|
|
|
GoodInStorage(dtNow, model, model.FinalItemLotList);
|
|
#endregion
|
|
|
|
#region //不合格拒收
|
|
if (ngList.Count > 0)
|
|
{
|
|
var itemLotNos2 = ngList.Select(x => x.LotNo);
|
|
var lotNoStr2 = string.Empty;
|
|
foreach (var str in itemLotNos2)
|
|
{
|
|
lotNoStr2 += "'" + str + "',";
|
|
}
|
|
|
|
//记录日志
|
|
InsertOperateLog(model.CheckNo, JsonConvert.SerializeObject(itemLotNos2), entity.GetType().Name, "返工");
|
|
|
|
if (entity.EATTRIBUTE2 == "1")
|
|
{
|
|
var msg = otherApp.CreateRejection4KBS(lotNoStr2);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else if (entity.EATTRIBUTE2 == "2")
|
|
{
|
|
var msg = otherApp.CreateBBWWRejection(lotNoStr2);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
SendEmail(model);
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
break;
|
|
case "让步接收":
|
|
case "合格":
|
|
entity.SpecialNo = model.SpecialNo;
|
|
entity.SpecialFile = model.SpecialFile;
|
|
|
|
var goodList3 = model.FinalItemLotList.Where(x => x.GoodQty.HasValue && x.GoodQty > 0).ToList();
|
|
var ngList3 = model.FinalItemLotList.Where(x => x.NgQty.HasValue && x.NgQty > 0).ToList();
|
|
#region //入库检验数据
|
|
|
|
GoodInStorage(dtNow, model, model.FinalItemLotList);
|
|
#endregion
|
|
|
|
#region //不合格拒收
|
|
if (ngList3.Count > 0)
|
|
{
|
|
var itemLotNos3 = ngList3.Select(x => x.LotNo);
|
|
var lotNoStr3 = string.Empty;
|
|
foreach (var str in itemLotNos3)
|
|
{
|
|
lotNoStr3 += "'" + str + "',";
|
|
}
|
|
|
|
//记录日志
|
|
InsertOperateLog(model.CheckNo, JsonConvert.SerializeObject(itemLotNos3), entity.GetType().Name, "让步接收");
|
|
|
|
if (entity.EATTRIBUTE2 == "1")
|
|
{
|
|
var msg = otherApp.CreateRejection4KBS(lotNoStr3);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else if (entity.EATTRIBUTE2 == "2")
|
|
{
|
|
var msg = otherApp.CreateBBWWRejection(lotNoStr3);
|
|
if (!msg.IsNullOrEmpty())
|
|
{
|
|
throw new Exception(msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
SendEmail(model);
|
|
}
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
entity.IsCheckComplete = "是";
|
|
entity.Remark = model.Remark;
|
|
entity.FinalResult = model.FinalResult;
|
|
entity.FinalUser = MUSERNAME;
|
|
entity.FinalTime = dtNow;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
|
|
entity.GoodQty = model.FinalItemLotList.Sum(x => x.GoodQty ?? 0);
|
|
entity.NgQty = model.FinalItemLotList.Sum(x => x.NgQty ?? 0);
|
|
|
|
var result = MsSqlData.Update<IcsMatCheckResult>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetMaterialCheckMain4WG(string keyValue)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var para = new { WorkPoint = WorkPoint };
|
|
string sql0 = @"
|
|
select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode='CheckAttr'
|
|
|
|
";
|
|
var enumList = MsSqlData.Query<SysEnumValueDto>(sql0, para).ToList();
|
|
var chicun = enumList.Where(x => x.Ext1 == "外观").Select(x => x.value);
|
|
if (chicun.Count() == 0)
|
|
{
|
|
return new DataTable();
|
|
}
|
|
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.ID
|
|
,c.InvCode
|
|
,c.InvName
|
|
,a.ListCode CheckItemCode
|
|
,a.ListName CheckItemName
|
|
,a.EATTRIBUTE1 as CheckWay --检验方法
|
|
,b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=b.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
,a.SetValueMax
|
|
,a.SetValueMin
|
|
,a.Unit
|
|
,d.RulesCode
|
|
,d.RulesName CheckAqlName
|
|
,e.Type RulesType
|
|
,10 as AqlQty
|
|
,0 as GoodQty
|
|
,0 as NgQty
|
|
,'' as Result
|
|
,'' as Remark
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory c with(nolock) on b.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup d with(nolock) on b.InvCode=d.InvCode and b.EATTRIBUTE1=d.EATTRIBUTE1 and b.WorkPoint=d.WorkPoint
|
|
left join ICSInspectionRulesGroup e with(nolock) on d.rulescode=e.RulesCode
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
and b.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and d.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and a.Enable=1";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", " and b.InvCode='" + keyValue + "' ");
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable GetMaterialCheckMain4CC(string keyValue)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var para = new { WorkPoint = WorkPoint };
|
|
string sql0 = @"
|
|
select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode='CheckAttr'
|
|
|
|
";
|
|
var enumList = MsSqlData.Query<SysEnumValueDto>(sql0, para).ToList();
|
|
var chicun = enumList.Where(x => x.Ext1 == "尺寸").Select(x => x.value);
|
|
if (chicun.Count() == 0)
|
|
{
|
|
return new DataTable();
|
|
}
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.ID
|
|
,c.InvCode
|
|
,c.InvName
|
|
,a.ListCode CheckItemCode
|
|
,a.ListName CheckItemName
|
|
,a.EATTRIBUTE1 as CheckWay --检验方法
|
|
,b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=b.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
,a.SetValueMax
|
|
,a.SetValueMin
|
|
,a.Unit
|
|
,d.RulesCode
|
|
,d.RulesName CheckAqlName
|
|
,d.RulesDesc
|
|
,e.Type RulesType
|
|
,NULL as S1
|
|
, NULL as S2
|
|
, NULL as S3
|
|
, NULL as S4
|
|
, NULL as S5
|
|
, NULL as S6
|
|
, NULL as S7
|
|
, NULL as S8
|
|
, NULL as S9
|
|
, NULL as S10
|
|
,'' as Result
|
|
,'' as Remark
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory c with(nolock) on b.InvCode=c.InvCode and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup d with(nolock) on b.InvCode=d.InvCode and b.EATTRIBUTE1=d.EATTRIBUTE1 and b.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionRulesGroup e with(nolock) on d.rulescode=e.RulesCode
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
and b.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and d.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and a.Enable=1";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", " and b.InvCode='" + keyValue + "' ");
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
|
|
public DataTable GetCPMaterialCheckMain4CC(string keyValue)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var para = new { WorkPoint = WorkPoint };
|
|
string sql0 = @"
|
|
select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode='CheckAttr'
|
|
|
|
";
|
|
var enumList = MsSqlData.Query<SysEnumValueDto>(sql0, para).ToList();
|
|
var chicun = enumList.Where(x => x.Ext1 == "尺寸").Select(x => x.value);
|
|
if (chicun.Count() == 0)
|
|
{
|
|
return new DataTable();
|
|
}
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.ID
|
|
,c.InvCode
|
|
,c.InvName
|
|
,a.ListCode CheckItemCode
|
|
,a.ListName CheckItemName
|
|
,a.EATTRIBUTE1 as CheckWay --检验方法
|
|
,b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=b.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
,a.SetValueMax
|
|
,a.SetValueMin
|
|
,a.Unit
|
|
,d.RulesCode
|
|
,d.RulesName CheckAqlName
|
|
,d.RulesDesc
|
|
,e.Type RulesType
|
|
,0 as S1
|
|
,0 as S2
|
|
,0 as S3
|
|
,0 as S4
|
|
,0 as S5
|
|
,0 as S6
|
|
,0 as S7
|
|
,0 as S8
|
|
,0 as S9
|
|
,0 as S10
|
|
,'' as Result
|
|
,'' as Remark
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory c with(nolock) on b.InvCode=c.InvCode and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup d with(nolock) on b.InvCode=d.InvCode and b.EATTRIBUTE1=d.EATTRIBUTE1 and b.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionRulesGroup e with(nolock) on d.rulescode=e.RulesCode
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
and b.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and d.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and a.Enable=1";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", " and b.InvCode='" + keyValue + "' ");
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable GetMaterialCheckMain4XN(string keyValue)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
var para = new { WorkPoint = WorkPoint };
|
|
string sql0 = @"
|
|
select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode='CheckAttr'
|
|
|
|
";
|
|
var enumList = MsSqlData.Query<SysEnumValueDto>(sql0, para).ToList();
|
|
var chicun = enumList.Where(x => x.Ext1 == "性能").Select(x => x.value);
|
|
if (chicun.Count() == 0)
|
|
{
|
|
return new DataTable();
|
|
}
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.ID
|
|
,c.InvCode
|
|
,c.InvName
|
|
,a.ListCode CheckItemCode
|
|
,a.ListName CheckItemName
|
|
,a.EATTRIBUTE1 as CheckWay --检验方法
|
|
,b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=b.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
,a.SetValueMax
|
|
,a.SetValueMin
|
|
,a.Unit
|
|
,d.RulesCode
|
|
,d.RulesName CheckAqlName
|
|
,e.Type RulesType
|
|
,0 as S1
|
|
,0 as S2
|
|
,0 as S3
|
|
,0 as S4
|
|
,0 as S5
|
|
,0 as S6
|
|
,0 as S7
|
|
,0 as S8
|
|
,0 as S9
|
|
,0 as S10
|
|
,'' as Result
|
|
,'' as Remark
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventory c with(nolock) on b.InvCode=c.InvCode and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup d with(nolock) on b.InvCode=d.InvCode and b.EATTRIBUTE1=d.EATTRIBUTE1 and b.WorkPoint=b.WorkPoint
|
|
left join ICSInspectionRulesGroup e with(nolock) on d.rulescode=e.RulesCode
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
and b.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and d.EATTRIBUTE1 in ('" + string.Join("','", chicun) + "') and a.Enable=1";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", " and b.InvCode='" + keyValue + "' ");
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("{0}", "");
|
|
}
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable GetMaterialCheckMain(string keyValue)
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
distinct
|
|
b.ID DetailId --子表主键
|
|
,c.ID LotNoId --条码ID
|
|
,c.InvCode
|
|
,d.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.DNQuantity --到货数量
|
|
,a.VenCode --供应商编码
|
|
,e.VenName --供应商名称
|
|
,a.AsnCode
|
|
,b.EATTRIBUTE1 as IsUrgentitem --加急料
|
|
,d.InvUnit
|
|
,c.Quantity as InvBatcgQty --批次数量
|
|
,f.RulesCode
|
|
,f.Id as InvRuleId
|
|
,0 as AqlCheckQty --抽检数量
|
|
,0 as AllowNgQty --允许不良数(关键)
|
|
,'' as Result
|
|
|
|
from ICSASN a with(nolock)
|
|
left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPoint
|
|
left join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPoint
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPoint
|
|
where 1=1
|
|
and a.WorkPoint = '{1}'
|
|
|
|
union all
|
|
select
|
|
distinct
|
|
b.ID DetailId --子表主键
|
|
,c.ID LotNoId --条码ID
|
|
,c.InvCode
|
|
,d.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.ODNQuantity --到货数量
|
|
,a.VenCode --供应商编码
|
|
,e.VenName --供应商名称
|
|
,a.OAsnCode
|
|
,b.EATTRIBUTE1 as IsUrgentitem --加急料
|
|
,d.InvUnit
|
|
,c.Quantity as InvBatcgQty --批次数量
|
|
,f.RulesCode
|
|
,f.Id as InvRuleId
|
|
,0 as AqlCheckQty --抽检数量
|
|
,0 as AllowNgQty --允许不良数(关键)
|
|
,'' as Result
|
|
|
|
from ICSOASN a with(nolock)
|
|
left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPoint
|
|
left join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPoint
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPoint
|
|
where 1=1
|
|
and a.WorkPoint = '{1}'
|
|
) a
|
|
where 1=1
|
|
and a.DetailId='{0}'
|
|
|
|
|
|
|
|
";
|
|
sql = string.Format(sql, keyValue, NFine.Code.OperatorProvider.Provider.GetCurrent().Location);
|
|
// sql = sql.Replace("{1}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
var dt = Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
var sql2 = @"select
|
|
a.*
|
|
from ICSInspectionRulesList a with(nolock)
|
|
where 1=1
|
|
and a.WorkPoint = '{1}'
|
|
and a.RulesID=(
|
|
select
|
|
a.ID
|
|
from ICSInspectionRulesGroup a with(nolock)
|
|
where 1=1
|
|
and a.RulesCode='{0}'
|
|
)
|
|
order by a.SetValueMin asc
|
|
";
|
|
sql2 = string.Format(sql2, dt.Rows[0]["RulesCode"].ToString(), NFine.Code.OperatorProvider.Provider.GetCurrent().Location);
|
|
var dt2 = Repository().FindDataSetBySql(sql2.ToString(), parameter.ToArray()).Tables[0];
|
|
if (dt2 != null && dt2.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in dt2.Rows)
|
|
{
|
|
if (item["SetValueMin"].ToDecimal() <= dt.Rows[0]["InvBatcgQty"].ToDecimal() &&
|
|
item["SetValueMax"].ToDecimal() >= dt.Rows[0]["InvBatcgQty"].ToDecimal())
|
|
{
|
|
dt.Rows[0]["AqlCheckQty"] = item["SampleQuantity"].ToDecimal();
|
|
dt.Rows[0]["AllowNgQty"] = item["EATTRIBUTE1"].ToDecimal();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetMaterialCheckMain2(string keyValue, decimal qty)
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
string sql = @"
|
|
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
distinct
|
|
b.ID DetailId --子表主键
|
|
,c.ID LotNoId --条码ID
|
|
,c.InvCode
|
|
,d.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.DNQuantity --到货数量
|
|
,a.VenCode --供应商编码
|
|
,e.VenName --供应商名称
|
|
,a.AsnCode
|
|
,b.EATTRIBUTE1 as IsUrgentitem --加急料
|
|
,d.InvUnit
|
|
,c.Quantity as InvBatcgQty --批次数量
|
|
,f.RulesCode
|
|
,f.Id as InvRuleId
|
|
,0 as AqlCheckQty --抽检数量
|
|
,0 as AllowNgQty --允许不良数(关键)
|
|
,'' as Result
|
|
,'' as WgNgFile
|
|
from ICSASN a with(nolock)
|
|
left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPoint
|
|
left join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPoint
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPoint
|
|
where 1=1
|
|
and a.WorkPoint = '{1}'
|
|
|
|
union all
|
|
|
|
select
|
|
distinct
|
|
b.ID DetailId --子表主键
|
|
,c.ID LotNoId --条码ID
|
|
,c.InvCode
|
|
,d.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.ODNQuantity --到货数量
|
|
,a.VenCode --供应商编码
|
|
,e.VenName --供应商名称
|
|
,a.OAsnCode
|
|
,b.EATTRIBUTE1 as IsUrgentitem --加急料
|
|
,d.InvUnit
|
|
,c.Quantity as InvBatcgQty --批次数量
|
|
,f.RulesCode
|
|
,f.Id as InvRuleId
|
|
,0 as AqlCheckQty --抽检数量
|
|
,0 as AllowNgQty --允许不良数(关键)
|
|
,'' as Result
|
|
,'' as WgNgFile
|
|
from ICSOASN a with(nolock)
|
|
left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPoint
|
|
left join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPoint
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPoint
|
|
where 1=1
|
|
and a.WorkPoint = '{1}'
|
|
|
|
) a
|
|
where 1=1
|
|
and a.DetailId='{0}'
|
|
|
|
|
|
|
|
|
|
";
|
|
sql = string.Format(sql, keyValue, NFine.Code.OperatorProvider.Provider.GetCurrent().Location);
|
|
// sql = sql.Replace("{1}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
var dt = Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
var sql2 = @"select
|
|
a.*
|
|
from ICSInspectionRulesList a with(nolock)
|
|
where 1=1
|
|
and a.WorkPoint = '{1}'
|
|
and a.RulesID=(
|
|
select
|
|
a.ID
|
|
from ICSInspectionRulesGroup a with(nolock)
|
|
where 1=1
|
|
and a.RulesCode='{0}'
|
|
)
|
|
order by a.SetValueMin asc
|
|
";
|
|
sql2 = string.Format(sql2, dt.Rows[0]["RulesCode"].ToString(), NFine.Code.OperatorProvider.Provider.GetCurrent().Location);
|
|
var dt2 = Repository().FindDataSetBySql(sql2.ToString(), parameter.ToArray()).Tables[0];
|
|
if (dt2 != null && dt2.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in dt2.Rows)
|
|
{
|
|
if (item["SetValueMin"].ToDecimal() <= qty &&
|
|
item["SetValueMax"].ToDecimal() >= qty)
|
|
{
|
|
dt.Rows[0]["AqlCheckQty"] = item["SampleQuantity"].ToDecimal();
|
|
dt.Rows[0]["AllowNgQty"] = item["EATTRIBUTE1"].ToDecimal();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetCPMaterialCheckMain2(string keyValue, decimal qty)
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
string sql = @"
|
|
|
|
select
|
|
distinct
|
|
d.ID DetailId --子表主键
|
|
,c.ID LotNoId --条码ID
|
|
,c.InvCode
|
|
,d.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.Quantity DNQuantity --到货数量
|
|
,b.CheckCode
|
|
,d.InvUnit
|
|
,c.Quantity as InvBatcgQty --批次数量
|
|
,f.RulesCode
|
|
,f.Id as InvRuleId
|
|
,0 as AqlCheckQty --抽检数量
|
|
,0 as AllowNgQty --允许不良数(关键)
|
|
,'' as Result
|
|
,'' as WgNgFile
|
|
from ICSInspectionSheet b with(nolock)
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPoint
|
|
left join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPoint
|
|
left join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPoint
|
|
where b.Id='{0}'
|
|
and b.WorkPoint = '{1}'
|
|
|
|
|
|
";
|
|
sql = string.Format(sql, keyValue, NFine.Code.OperatorProvider.Provider.GetCurrent().Location);
|
|
// sql = sql.Replace("{1}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
var dt = Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
var sql2 = @"select
|
|
a.*
|
|
from ICSInspectionRulesList a with(nolock)
|
|
where 1=1
|
|
and a.WorkPoint = '{1}'
|
|
and a.RulesID=(
|
|
select
|
|
a.ID
|
|
from ICSInspectionRulesGroup a with(nolock)
|
|
where 1=1
|
|
and a.RulesCode='{0}'
|
|
)
|
|
order by a.SetValueMin asc
|
|
";
|
|
sql2 = string.Format(sql2, dt.Rows[0]["RulesCode"].ToString(), NFine.Code.OperatorProvider.Provider.GetCurrent().Location);
|
|
var dt2 = Repository().FindDataSetBySql(sql2.ToString(), parameter.ToArray()).Tables[0];
|
|
if (dt2 != null && dt2.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in dt2.Rows)
|
|
{
|
|
if (item["SetValueMin"].ToDecimal() <= qty &&
|
|
item["SetValueMax"].ToDecimal() >= qty)
|
|
{
|
|
dt.Rows[0]["AqlCheckQty"] = item["SampleQuantity"].ToDecimal();
|
|
dt.Rows[0]["AllowNgQty"] = item["EATTRIBUTE1"].ToDecimal();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return dt;
|
|
}
|
|
|
|
public string UpdateUrgent(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var models = JsonConvert.DeserializeObject<List<IcsMatCheckResultDto>>(keyValue);
|
|
if (models == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
foreach (var model in models)
|
|
{
|
|
|
|
|
|
var para = new
|
|
{
|
|
AsnCode = model.AsnCode,
|
|
InvBatcgNo = model.InvBatcgNo,
|
|
InvCode = model.InvCode,
|
|
WorkPoint = WorkPoint,
|
|
};
|
|
#region 送货单
|
|
var sql = @"
|
|
select a.* from ICSASNDetail a with(nolock)
|
|
where a.id in (
|
|
select
|
|
distinct a.Id
|
|
from ICSASNDetail a with(nolock)
|
|
left join ICSASN b with(nolock) on a.ASNCode=b.ASNCode
|
|
left join ICSInventoryLot c with(nolock) on a.LotNo=c.LotNo
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
where 1=1
|
|
and a.ASNCode=@AsnCode
|
|
and c1.BatchCode=@InvBatcgNo
|
|
and c.InvCode=@InvCode
|
|
and a.WorkPoint=@WorkPoint
|
|
)
|
|
";
|
|
var list = MsSqlData.Query<ICSASNDetailEntity>(sql, para).ToList();
|
|
|
|
foreach (var item in list)
|
|
{
|
|
if (item.EATTRIBUTE1 == "是")
|
|
{
|
|
continue;
|
|
}
|
|
item.EATTRIBUTE1 = "是";
|
|
item.MUSER = MUSER;
|
|
item.MUSERName = MUSERNAME;
|
|
item.MTIME = dtNow;
|
|
item.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Update<ICSASNDetailEntity>(item);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 委外送货单
|
|
sql = @"select a.* from ICSOASNDetail a with(nolock)
|
|
where a.id in (
|
|
select
|
|
distinct a.Id
|
|
from ICSOASNDetail a with(nolock)
|
|
left join ICSOASN b with(nolock) on a.OASNCode=b.OASNCode
|
|
left join ICSInventoryLot c with(nolock) on a.LotNo=c.LotNo
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
where 1=1
|
|
and a.OASNCode=@AsnCode
|
|
and c1.BatchCode=@InvBatcgNo
|
|
and c.InvCode=@InvCode
|
|
and a.WorkPoint=@WorkPoint
|
|
)
|
|
";
|
|
|
|
var list2 = MsSqlData.Query<ICSOASNDetailEntity>(sql, para).ToList();
|
|
|
|
foreach (var item in list2)
|
|
{
|
|
if (item.EATTRIBUTE1 == "是")
|
|
{
|
|
continue;
|
|
}
|
|
item.EATTRIBUTE1 = "是";
|
|
item.MUSER = MUSER;
|
|
item.MUSERName = MUSERNAME;
|
|
item.MTIME = dtNow;
|
|
item.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Update<ICSOASNDetailEntity>(item);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetMaterialInStorageCheckDetailList(string id, string lotno, string invCode, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"select
|
|
( Row_Number() over( ORDER BY a.ASNCode,a.InvBatcgNo,a.LotNo )) AS RowNo
|
|
,a.*
|
|
from
|
|
(
|
|
select
|
|
distinct
|
|
a.ASNCode
|
|
,d.TransCode
|
|
,d.TransSequence
|
|
,c.InvCode
|
|
,inv.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.LotNo
|
|
,c.Quantity
|
|
,f.ContainerCode as XiangCode--箱号编码
|
|
,g.ContainerCode as ZhanCode --栈板编码
|
|
from ICSASN a with(nolock)
|
|
left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join ICSInventoryLotDetail d on b.LotNo=d.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPoint
|
|
left join ICSContainerLot e with(nolock) on b.LotNo=e.LotNo and b.WorkPoint=e.WorkPoint
|
|
left join ICSContainer f with(nolock) on e.ContainerID =f.ID and e.WorkPoint=f.WorkPoint
|
|
left join ICSContainer g with(nolock) on f.ContainerID=g.ID and g.ContainerType='ContainerType04' and f.WorkPoint=g.WorkPoint
|
|
where 1=1
|
|
{0}
|
|
|
|
|
|
union all
|
|
|
|
select
|
|
distinct
|
|
a.OASNCode
|
|
,d.TransCode
|
|
,d.TransSequence
|
|
,c.InvCode
|
|
,inv.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.LotNo
|
|
,c.Quantity
|
|
|
|
,f.ContainerCode as XiangCode--箱号编码
|
|
,g.ContainerCode as ZhanCode --栈板编码
|
|
from ICSOASN a with(nolock)
|
|
left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join ICSInventoryLotDetail d on b.LotNo=d.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPoint
|
|
left join ICSContainerLot e with(nolock) on b.LotNo=e.LotNo and b.WorkPoint=e.WorkPoint
|
|
left join ICSContainer f with(nolock) on e.ContainerID =f.ID and e.WorkPoint=f.WorkPoint
|
|
left join ICSContainer g with(nolock) on f.ContainerID=g.ID and g.ContainerType='ContainerType04' and f.WorkPoint=g.WorkPoint
|
|
where 1=1
|
|
--and a.WorkPoint = 'UFDATA_106_2019'
|
|
-- and a.OASNCode='DN010000052200103' and c1.BatchCode=''
|
|
{0}
|
|
|
|
) a
|
|
where a.InvCode='" + invCode + @"'
|
|
|
|
<1>
|
|
|
|
|
|
order by a.ASNCode,a.InvBatcgNo,a.LotNo
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", " and a.ASNCode='" + id + "' and a.InvBatcgNo='" + lotno + "' ");
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetCPMaterialInStorageCheckDetailList(string code, string invBatcgNo, string invCode, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string workPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
#region [SQL]
|
|
string sql = $@"select
|
|
b.CheckCode
|
|
,c.InvCode
|
|
,inv.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.LotNo
|
|
,c.Quantity
|
|
,f.ContainerCode as XiangCode--箱号编码
|
|
,g.ContainerCode as ZhanCode --栈板编码
|
|
|
|
FROM ICSInspectionSheet b with(nolock)
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join ICSInventoryLotDetail d on b.LotNo=d.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPoint
|
|
left join ICSContainerLot e with(nolock) on b.LotNo=e.LotNo and b.WorkPoint=e.WorkPoint
|
|
left join ICSContainer f with(nolock) on e.ContainerID =f.ID and e.WorkPoint=f.WorkPoint
|
|
left join ICSContainer g with(nolock) on f.ContainerID=g.ID and g.ContainerType='ContainerType04' and f.WorkPoint=g.WorkPoint
|
|
where b.CheckCode='{code}' AND b.InvCode='{invCode}' AND c1.BatchCode='{invBatcgNo}'
|
|
";
|
|
#endregion
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
public DataTable GetMaterialInStorageCheckPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
--distinct
|
|
max(b.ID) DetailId --子表主键
|
|
,Max(c.ID) LotNoId --条码ID
|
|
,c.InvCode
|
|
,inv.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,sum(b.DNQuantity) DNQuantity --到货数量
|
|
,max(a.VenCode) VenCode --供应商编码
|
|
,max(e.VenName ) VenName --供应商名称
|
|
,a.ASNCode
|
|
,max(b.EATTRIBUTE1) as IsUrgentItem --加急料
|
|
,max(inv.InvUnit) InvUnit
|
|
,sum(c.Quantity) Quantity
|
|
,max(c2.FileName) OutReport
|
|
,max(c2.FilePath) FilePath
|
|
,max(g.id) CheckID
|
|
,case when max(g.CheckNo) is null then '否'else '是' end as IsCheck
|
|
,max(g.Result) Result
|
|
,max(g.FirstCheckTime) CheckDate
|
|
,max(g.WHCode) WHCode
|
|
,max(l.CreateDateTime) DHDate
|
|
,max(l.DNCode) DNCode
|
|
,max(l.DrawingNumber) DrawingNumber
|
|
,'1' as DocType
|
|
from ICSASN a with(nolock)
|
|
left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail cc with(nolock) on b.lotno=cc.lotno and cc.WorkPoint=c.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.ASNCode,t.BatchCode,t.invcode,t.FileName,t.FilePath
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on a.ASNCode=c2.ASNCode and c1.BatchCode=c2.BatchCode and c.invcode=c2.invcode
|
|
left join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPoint
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
|
|
left join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.ASNCode=g.AsnCode
|
|
left join (SELECT t.ASNCode,t.InvCode,t.ExtensionID,max(t.CreateDateTime) CreateDateTime,max( t.DNCode) DNCode,b.EATTRIBUTE2 DrawingNumber
|
|
from ICSDeliveryNotice t with(nolock)
|
|
INNER JOIN ICSPurchaseOrder b ON t.POID=b.POID AND t.PODetailID=b.PODetailID AND t.WorkPoint=b.WorkPoint
|
|
GROUP BY t.ASNCode,t.InvCode,t.ExtensionID,b.EATTRIBUTE2 ) l
|
|
on a.ASNCode=l.ASNCode and c.InvCode=l.InvCode and l.ExtensionID=c.ExtensionID
|
|
left join ( select a.LotNo from ICSASNDetail a
|
|
inner join ICSWareHouseLotInfo b on a.lotno=b.lotno
|
|
left join ICSInspection c on c.LotNo=a.LotNo
|
|
where c.lotno is null
|
|
) lot on b.lotno=lot.lotno
|
|
where inv.InvIQC=1
|
|
<1>
|
|
{0}
|
|
|
|
and lot.lotno is null
|
|
|
|
group by c.InvCode,inv.InvName ,c1.BatchCode,a.ASNCode
|
|
|
|
|
|
union all
|
|
|
|
select
|
|
--distinct
|
|
max(b.ID) DetailId --子表主键
|
|
,Max(c.ID) LotNoId --条码ID
|
|
,c.InvCode
|
|
,d.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,sum(b.ODNQuantity) DNQuantity --到货数量
|
|
,max(a.VenCode) VenCode --供应商编码
|
|
,max(e.VenName ) VenName --供应商名称
|
|
,a.OASNCode as ASNCode
|
|
,max(b.EATTRIBUTE1) as IsUrgentItem --加急料
|
|
,max(d.InvUnit) InvUnit
|
|
,sum(c.Quantity) Quantity
|
|
,max(c2.FileName) OutReport
|
|
,max(c2.FilePath) FilePath
|
|
,max(g.id) CheckID
|
|
,case when max(g.CheckNo) is null then '否'else '是' end as IsCheck
|
|
,max(g.Result) Result
|
|
,max(g.FirstCheckTime) CheckDate
|
|
,max(g.WHCode) WHCode
|
|
,max(l.CreateDateTime) DHDate
|
|
,max(l.DNCode) DNCode
|
|
,max(l.DrawingNumber) DrawingNumber
|
|
,'2' as DocType
|
|
from ICSOASN a with(nolock)
|
|
left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCode
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo
|
|
left join ICSInspection wl with(nolock) on b.LotNo=wl.LotNo and b.WorkPoint=wl.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.ASNCode,t.BatchCode,t.invcode,t.FileName,t.FilePath
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on a.OASNCode=c2.ASNCode and c1.BatchCode=c2.BatchCode and c.invcode=c2.invcode
|
|
left join ICSInventory d with(nolock) on c.InvCode=d.InvCode
|
|
left join ICSVendor e with(nolock) on a.VenCode=e.VenCode
|
|
left join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.OASNCode=g.AsnCode
|
|
left join (SELECT t.OASNCode,t.InvCode,t.ExtensionID,max(t.CreateDateTime) CreateDateTime,max( t.ODNCode) DNCode,b.EATTRIBUTE2 DrawingNumber
|
|
from ICSODeliveryNotice t with(nolock)
|
|
LEFT JOIN ICSOutsourcingOrder b ON t.OOId=b.OOId AND t.OODetailID=b.OODetailID AND t.workpoint=b.workpoint
|
|
GROUP BY t.OASNCode,t.InvCode,t.ExtensionID,b.EATTRIBUTE2 )l on a.OASNCode=l.OASNCode and c.InvCode=l.InvCode and l.ExtensionID=c.ExtensionID
|
|
left join (select a.LotNo from ICSOASNDetail a
|
|
inner join ICSWareHouseLotInfo b on a.lotno=b.lotno
|
|
left join ICSInspection c on c.LotNo=a.LotNo
|
|
where c.lotno is null
|
|
) lot on b.lotno=lot.lotno
|
|
where d.InvIQC=1
|
|
and lot.lotno is null
|
|
|
|
{0}
|
|
<1>
|
|
|
|
group by c.InvCode,d.InvName ,c1.BatchCode,a.OASNCode
|
|
) a
|
|
where 1=1 AND a.DNQuantity>0
|
|
|
|
|
|
<2>
|
|
<3>
|
|
<4>
|
|
<5>
|
|
<6>
|
|
<7>
|
|
<8>
|
|
<9>
|
|
<10>
|
|
<11>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + queryParam["InvName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["StartDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<3>", " and a.DHDate>='" + queryParam["StartDate"].ToString() + " 00:00:00' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<4>", " and a.DHDate<='" + queryParam["EndDate"].ToString() + " 23:59:59' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<5>", " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<5>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<6>", " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<6>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<7>", " and a.VenName like '%" + queryParam["VenName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<7>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvBatcgNo"].ToString()))
|
|
{
|
|
sql = sql.Replace("<8>", " and a.InvBatcgNo like '%" + queryParam["InvBatcgNo"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<8>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["IsCheck"].ToString()))
|
|
{
|
|
sql = sql.Replace("<9>", " and a.IsCheck='" + queryParam["IsCheck"].ToString() + "' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<9>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CheckStartDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<10>", " and a.CheckDate>='" + queryParam["CheckStartDate"].ToString() + " 00:00:00' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<10>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CheckEndDate"].ToString()))
|
|
{
|
|
sql = sql.Replace("<11>", " and a.CheckDate<='" + queryParam["CheckEndDate"].ToString() + " 23:59:59' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<11>", " ");
|
|
}
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public DataTable GetCPMaterialInStorageCheckPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string wheresql = string.Empty;
|
|
string workPoint=NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
#region 查询条件
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
wheresql += $"and b.InvCode like '%{queryParam["InvCode"]}%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
wheresql += $"and inv.InvName like '%{queryParam["InvName"]}%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["StartDate"].ToString()))
|
|
{
|
|
wheresql += $"and b.Mtime >='{queryParam["StartDate"]}' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
wheresql += $"and b.Mtime <'{queryParam["EndDate"]}' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CheckCode"].ToString()))
|
|
{
|
|
wheresql += $"and b.CheckCode like '%{queryParam["CheckCode"]}%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvBatcgNo"].ToString()))
|
|
{
|
|
wheresql += $"and c1.BatchCode like '%{queryParam["InvBatcgNo"]}%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["IsCheck"].ToString()))
|
|
{
|
|
if (queryParam["IsCheck"].ToString() == "是")
|
|
{
|
|
wheresql += "and g.CheckNo is not null ";
|
|
}
|
|
else if (queryParam["IsCheck"].ToString() == "否")
|
|
{
|
|
wheresql += "and g.CheckNo is null ";
|
|
}
|
|
wheresql += $"and c1.BatchCode like '%{queryParam["InvBatcgNo"]}%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CheckStartDate"].ToString()))
|
|
{
|
|
wheresql += $"and g.FirstCheckTime < '{queryParam["CheckStartDate"]}' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CheckEndDate"].ToString()))
|
|
{
|
|
wheresql += $"and g.FirstCheckTime < '{queryParam["CheckEndDate"]}' ";
|
|
}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
|
|
wheresql += $" and b.WorkPoint='{workPoint}' ";
|
|
}
|
|
#endregion
|
|
#region [SQL]
|
|
string sql = $@" select
|
|
max(b.ID) DetailId,
|
|
c.InvCode
|
|
,inv.InvName
|
|
,c1.BatchCode as InvBatcgNo --物料批号
|
|
,b.CheckCode --送检单号
|
|
,inv.InvUnit
|
|
,sum(c.Quantity) Quantity
|
|
,c2.FilePath
|
|
,case when g.CheckNo is null then '否'else '是' end as IsCheck
|
|
,g.Result Result
|
|
,g.FirstCheckTime CheckDate
|
|
,g.WHCode WHCode
|
|
FROM ICSInspectionSheet b with(nolock)
|
|
left join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPoint
|
|
left join ICSInventoryLotDetail cc with(nolock) on b.lotno=cc.lotno and cc.WorkPoint=c.WorkPoint
|
|
left join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID
|
|
left join (
|
|
select *
|
|
from
|
|
(
|
|
select t.*
|
|
,row_number() over(partition by t.ASNCode,t.BatchCode,t.invcode order by t.CerateTime desc) RowSeq
|
|
from ICSASNShippingReport t with(nolock)
|
|
) t where t.RowSeq=1
|
|
) c2 on b.CheckCode=c2.ASNCode and c1.BatchCode=c2.BatchCode and c.invcode=c2.invcode
|
|
left join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPoint
|
|
left join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and b.CheckCode=g.AsnCode
|
|
where inv.InvFQC=1 {wheresql}
|
|
|
|
GROUP BY c.InvCode,inv.InvName ,c1.BatchCode ,b.CheckCode ,inv.InvUnit
|
|
,c2.FilePath , g.CheckNo ,g.Result ,g.FirstCheckTime
|
|
,g.WHCode
|
|
|
|
";
|
|
|
|
#endregion
|
|
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public string DeleteItem2CheckItem(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
try
|
|
{
|
|
var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
where a.ID in ('" + string.Join("','", idList) + "')";
|
|
var entityList = MsSqlData.Query<ICSInventoryInspectionListEntity>(sql).ToList();
|
|
|
|
foreach (var item in entityList)
|
|
{
|
|
var delSql = @" delete from ICSInventoryInspectionGroup where id='" + item.InvGroupID + "' " +
|
|
" delete from ICSInventoryInspectionList where InvGroupID='" + item.InvGroupID + "' ";
|
|
|
|
var result = MsSqlData.Execute(delSql);
|
|
}
|
|
|
|
//var result = MsSqlData.Delete<ICSInventoryInspectionGroupEntity>(entityList);
|
|
//if (!result)
|
|
//{
|
|
// returnValue = "删除失败";
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public string SaveItem2CheckItem(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var connString = MsSqlData.FromMd5(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString);
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<ICSInventoryInspectionGroupDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
using (var connection = new SqlConnection())
|
|
{
|
|
connection.ConnectionString = connString;
|
|
connection.Open();
|
|
using (var trans = connection.BeginTransaction())
|
|
{
|
|
try
|
|
{
|
|
if (model.CheckItemList.GroupBy(x => new { x.ListCode, x.InvCode }).Count() != model.CheckItemList.Count)
|
|
{
|
|
throw new Exception("当前物料检验项目代码重复");
|
|
}
|
|
|
|
foreach (var item in model.CheckItemList)
|
|
{
|
|
string dtPre = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSInventoryInspectionGroup','GroupCode','" + "IGC" + dtPre + "',3";
|
|
var serialNo = MsSqlData.ExecuteScalar(sql).ToStringExt();
|
|
|
|
var entity = new ICSInventoryInspectionGroupEntity();
|
|
entity.InvCode = item.InvCode;
|
|
entity.GroupCode = serialNo;
|
|
entity.GroupName = serialNo;
|
|
entity.Enable = true;
|
|
entity.EATTRIBUTE1 = item.CheckAttr;
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.WorkPoint = WorkPoint;
|
|
connection.Insert<ICSInventoryInspectionGroupEntity>(entity, trans);
|
|
|
|
|
|
|
|
var detail = new ICSInventoryInspectionListEntity();
|
|
detail = ConvertExt.Mapping<ICSInventoryInspectionListDto, ICSInventoryInspectionListEntity>(item);
|
|
detail.InvGroupID = entity.ID;
|
|
detail.ID = Guid.NewGuid().ToString();
|
|
detail.MUSER = MUSER;
|
|
detail.MUSERName = MUSERNAME;
|
|
detail.MTIME = dtNow;
|
|
detail.WorkPoint = WorkPoint;
|
|
|
|
var sql4Count = @" select
|
|
count(1)
|
|
from
|
|
(
|
|
select
|
|
a.ID
|
|
, c.InvCode
|
|
, c.InvName
|
|
, a.ListCode
|
|
, a.ListName
|
|
, b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID = b.ID
|
|
left join ICSInventory c with(nolock) on b.InvCode = c.InvCode
|
|
|
|
) a
|
|
where 1 = 1
|
|
and a.InvCode = @InvCode and a.ListCode=@ListCode ";
|
|
var para2 = new { InvCode = item.InvCode, ListCode = item.ListCode };
|
|
var count = connection.ExecuteScalar<int>(sql4Count, para2, trans);
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前物料检验项目关系已经存在");
|
|
}
|
|
|
|
|
|
connection.Insert<ICSInventoryInspectionListEntity>(detail, trans);
|
|
|
|
|
|
}
|
|
trans.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
trans.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable ExportAllItem2CheckItem(string invCode, string invName, string ListCode, string ListName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
a.ID
|
|
,c.InvCode
|
|
,c.InvName
|
|
,a.ListCode
|
|
,a.ListName
|
|
,b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=b.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
,a.SetValueMax
|
|
,a.SetValueMin
|
|
,a.Unit
|
|
,a.Enable
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID
|
|
left join ICSInventory c with(nolock) on b.InvCode=c.InvCode
|
|
where 1=1
|
|
{0}
|
|
) a
|
|
where 1=1
|
|
<1>
|
|
<2>
|
|
<3>
|
|
<4> ";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(invCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode like '%" + invCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(invName))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + invName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(ListCode))
|
|
{
|
|
|
|
sql = sql.Replace("<3>", " and a.ListCode =" + ListCode + " ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(ListName))
|
|
{
|
|
|
|
sql = sql.Replace("<4>", " and a.ListName =" + ListName + " ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable GetItem2CheckItemPageList(string queryJson, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
a.ID
|
|
,c.InvCode
|
|
,c.InvName
|
|
,a.ListCode
|
|
,a.ListName
|
|
,b.EATTRIBUTE1 as CheckAttr --检验属性
|
|
,( select t.label from V_QuerySysEnumItem t where t.value=b.EATTRIBUTE1 and t.F_EnCode='CheckAttr'
|
|
) as CheckAttrText
|
|
,a.SetValueMax
|
|
,a.SetValueMin
|
|
,a.Unit
|
|
,a.Enable
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
,a.EATTRIBUTE1 --检验方法
|
|
from ICSInventoryInspectionList a with(nolock)
|
|
left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID
|
|
left join ICSInventory c with(nolock) on b.InvCode=c.InvCode
|
|
where 1=1
|
|
{0}
|
|
) a
|
|
where 1=1
|
|
<1>
|
|
<2>
|
|
<3>
|
|
<4>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode = '" + queryParam["InvCode"].ToString() + "' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + queryParam["InvName"].ToString() + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ListCode"].ToString()))
|
|
{
|
|
|
|
sql = sql.Replace("<3>", " and a.ListCode ='" + queryParam["ListCode"].ToString() + "' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ListName"].ToString()))
|
|
{
|
|
|
|
sql = sql.Replace("<4>", " and a.ListName ='" + queryParam["ListName"].ToString() + " '");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination);
|
|
}
|
|
|
|
public string DeleteCheckItemGroup(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
try
|
|
{
|
|
var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionGroup a with(nolock)
|
|
where a.ID in ('" + string.Join("','", idList) + "')";
|
|
var entityList = MsSqlData.Query<ICSInspectionGroupEntity>(sql).ToList();
|
|
|
|
|
|
foreach (var item in entityList)
|
|
{
|
|
//var count = MsSqlData.ExecuteScalar(" select count(1) from IcsCheckingFixtureTransfer with(nolock) where CheckFixtureNo='" + item.CheckFixtureNo + "'").ToInt();
|
|
//if (count > 0)
|
|
//{
|
|
// throw new Exception("当前检具已经存在履历,不能删除");
|
|
//}
|
|
|
|
var count = MsSqlData.ExecuteScalar
|
|
(
|
|
" select count(1) from ICSInventoryInspectionGroup with(nolock) where GroupCode='" + item.GroupCode + "' "
|
|
).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前物料检验类型关系已经存在,不能删除");
|
|
}
|
|
}
|
|
|
|
|
|
var result = MsSqlData.Delete<ICSInspectionGroupEntity>(entityList);
|
|
if (!result)
|
|
{
|
|
returnValue = "删除失败";
|
|
}
|
|
|
|
string sql2 = @"delete from ICSInspectionList where GroupID in ('" + string.Join("','", idList) + "')";
|
|
var line = Repository().ExecuteBySql(new StringBuilder(sql2));
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public string SaveCheckItemGroup(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<ICSInspectionGroupDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
if (model.DetailList != null && model.DetailList.Count > 0)
|
|
{
|
|
if (model.DetailList.Select(x => x.ListCode).Distinct().Count() != model.DetailList.Count)
|
|
{
|
|
throw new Exception("检验项目代码重复");
|
|
}
|
|
}
|
|
|
|
if (model.ID.IsNullOrEmpty())
|
|
{
|
|
//新增
|
|
var count = MsSqlData.ExecuteScalar(" select count(1) from ICSInspectionGroup with(nolock) where GroupCode='" + model.GroupCode + "'").ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前检验类型已经存在");
|
|
}
|
|
|
|
model.ID = Guid.NewGuid().ToString();
|
|
model.MUSER = MUSER;
|
|
model.MUSERName = MUSERNAME;
|
|
model.MTIME = dtNow;
|
|
model.WorkPoint = WorkPoint;
|
|
|
|
var result = MsSqlData.Insert<ICSInspectionGroupEntity>(model);
|
|
if (!result)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSInspectionListDto, ICSInspectionListEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.GroupID = model.ID;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSInspectionListEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//修改
|
|
var entity = MsSqlData.Get<ICSInspectionGroupEntity>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
ConvertExt.Mapping<ICSInspectionGroupDto, ICSInspectionGroupEntity>(model, entity);
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
var result = MsSqlData.Update<ICSInspectionGroupEntity>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionList a with(nolock)
|
|
where a.GroupID ='" + entity.ID + "' ";
|
|
var entityList = MsSqlData.Query<ICSInspectionListEntity>(sql).ToList();
|
|
|
|
MsSqlData.Delete<ICSInspectionListEntity>(entityList);
|
|
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSInspectionListDto, ICSInspectionListEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.GroupID = model.ID;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSInspectionListEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public ICSInspectionGroupDto GetCheckItemGroup(string keyValue)
|
|
{
|
|
var returnValue = new ICSInspectionGroupDto();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
var entity = MsSqlData.Get<ICSInspectionGroupEntity>(keyValue);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("获取单个检验项目组失败");
|
|
}
|
|
|
|
returnValue = ConvertExt.Mapping<ICSInspectionGroupEntity, ICSInspectionGroupDto>(entity);
|
|
|
|
var para = new { WorkPoint = WorkPoint };
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionList a with(nolock)
|
|
where a.GroupID ='" + entity.ID + "' and a.WorkPoint=@WorkPoint " +
|
|
"order by a.ListCode asc ";
|
|
var entityList = MsSqlData.Query<ICSInspectionListDto>(sql, para).ToList();
|
|
|
|
//int i = 0;
|
|
for (int i = 0; i < entityList.Count; i++)
|
|
{
|
|
entityList[i].key = i + 1;
|
|
}
|
|
|
|
|
|
returnValue.DetailList = entityList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = null;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable ExportAllBadReasonGroup(string bRGCode, string bRGDesc)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from ICSBadReasonGroup a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
<2>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bRGCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.bRGCode like '%" + bRGCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(bRGDesc))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.bRGDesc like '%" + bRGDesc + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
|
|
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public string DeleteBadReasonGroup(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
try
|
|
{
|
|
var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadReasonGroup a with(nolock)
|
|
where a.ID in ('" + string.Join("','", idList) + "') and a.WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSBadReasonGroupEntity>(sql, para).ToList();
|
|
|
|
|
|
foreach (var item in entityList)
|
|
{
|
|
//var count = MsSqlData.ExecuteScalar(" select count(1) from IcsCheckingFixtureTransfer with(nolock) where CheckFixtureNo='" + item.CheckFixtureNo + "'").ToInt();
|
|
//if (count > 0)
|
|
//{
|
|
// throw new Exception("当前检具已经存在履历,不能删除");
|
|
//}
|
|
}
|
|
|
|
|
|
var result = MsSqlData.Delete<ICSBadReasonGroupEntity>(entityList);
|
|
if (!result)
|
|
{
|
|
returnValue = "删除失败";
|
|
}
|
|
|
|
string sql2 = @"delete from ICSBadReason where BRGroupID in ('" + string.Join("','", idList) + "') and WorkPoint=@WorkPoint";
|
|
var line = MsSqlData.Execute(sql2, para);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public string SaveBadReasonGroup(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<ICSBadReasonGroupDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
if (model.ID.IsNullOrEmpty())
|
|
{
|
|
//新增
|
|
var sql1 = @" select count(1) from ICSBadReasonGroup a with(nolock) where BRGCode='" + model.BRGCode + "' and a.WorkPoint=@WorkPoint";
|
|
var count = MsSqlData.ExecuteScalar(sql1, para).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前不良状态已经存在");
|
|
}
|
|
|
|
model.ID = Guid.NewGuid().ToString();
|
|
model.MUSER = MUSER;
|
|
model.MUSERName = MUSERNAME;
|
|
model.MTIME = dtNow;
|
|
model.WorkPoint = WorkPoint;
|
|
|
|
var result = MsSqlData.Insert<ICSBadReasonGroupEntity>(model);
|
|
if (!result)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSBadReasonDto, ICSBadReasonEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.BRGroupID = model.ID;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSBadReasonEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//修改
|
|
var entity = MsSqlData.Get<ICSBadReasonGroupEntity>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
ConvertExt.Mapping<ICSBadReasonGroupDto, ICSBadReasonGroupEntity>(model, entity);
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
var result = MsSqlData.Update<ICSBadReasonGroupEntity>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadReason a with(nolock)
|
|
where a.BRGroupID ='" + entity.ID + "' and a.WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSBadReasonEntity>(sql, para).ToList();
|
|
|
|
MsSqlData.Delete<ICSBadReasonEntity>(entityList);
|
|
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSBadReasonDto, ICSBadReasonEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.BRGroupID = model.ID;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSBadReasonEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public ICSBadReasonGroupDto GetBadReasonGroup(string keyValue)
|
|
{
|
|
var returnValue = new ICSBadReasonGroupDto();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
try
|
|
{
|
|
var entity = MsSqlData.Get<ICSBadReasonGroupEntity>(keyValue);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("获取单个规则失败");
|
|
}
|
|
|
|
returnValue = ConvertExt.Mapping<ICSBadReasonGroupEntity, ICSBadReasonGroupDto>(entity);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadReason a with(nolock)
|
|
where a.BRGroupID ='" + entity.ID + "' and a.WorkPoint=@WorkPoint order by a.BadReasonCode asc ";
|
|
var entityList = MsSqlData.Query<ICSBadReasonDto>(sql, para).ToList();
|
|
|
|
//int i = 0;
|
|
for (int i = 0; i < entityList.Count; i++)
|
|
{
|
|
entityList[i].key = i + 1;
|
|
}
|
|
|
|
|
|
returnValue.DetailList = entityList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = null;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetBadReasonDetailList(string id, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
#region [SQL]
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadReason a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
order by a.BadReasonCode asc
|
|
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", "and a.BRGroupID='" + id + "'");
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public DataTable ExportAllBadCodeGroup(string bCGCode, string bCGDesc)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from ICSBadCodeGroup a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
<2>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bCGCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.bCGCode like '%" + bCGCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(bCGDesc))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.bCGDesc like '%" + bCGDesc + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
|
|
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public string DeleteBadCodeGroup(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
try
|
|
{
|
|
var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadCodeGroup a with(nolock)
|
|
where a.ID in ('" + string.Join("','", idList) + "') and a.WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSBadCodeGroupEntity>(sql, para).ToList();
|
|
|
|
|
|
foreach (var item in entityList)
|
|
{
|
|
//var count = MsSqlData.ExecuteScalar(" select count(1) from IcsCheckingFixtureTransfer with(nolock) where CheckFixtureNo='" + item.CheckFixtureNo + "'").ToInt();
|
|
//if (count > 0)
|
|
//{
|
|
// throw new Exception("当前检具已经存在履历,不能删除");
|
|
//}
|
|
}
|
|
|
|
|
|
var result = MsSqlData.Delete<ICSBadCodeGroupEntity>(entityList);
|
|
if (!result)
|
|
{
|
|
returnValue = "删除失败";
|
|
}
|
|
|
|
string sql2 = @"delete from ICSBadCode where BCGroupID in ('" + string.Join("','", idList) + "') and WorkPoint=@WorkPoint";
|
|
var line = MsSqlData.Execute(sql2, para);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public string SaveBadCodeGroup(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<ICSBadCodeGroupDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
if (model.ID.IsNullOrEmpty())
|
|
{
|
|
//新增
|
|
var sql1 = @" select count(1) from ICSBadCodeGroup with(nolock) where BCGCode='" + model.BCGCode + "' and WorkPoint=@WorkPoint";
|
|
var count = MsSqlData.ExecuteScalar(sql1, para).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前不良状态已经存在");
|
|
}
|
|
|
|
model.ID = Guid.NewGuid().ToString();
|
|
model.MUSER = MUSER;
|
|
model.MUSERName = MUSERNAME;
|
|
model.MTIME = dtNow;
|
|
model.WorkPoint = WorkPoint;
|
|
|
|
var result = MsSqlData.Insert<ICSBadCodeGroupEntity>(model);
|
|
if (!result)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSBadCodeDto, ICSBadCodeEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.BCGroupID = model.ID;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSBadCodeEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//修改
|
|
var entity = MsSqlData.Get<ICSBadCodeGroupEntity>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
ConvertExt.Mapping<ICSBadCodeGroupDto, ICSBadCodeGroupEntity>(model, entity);
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
var result = MsSqlData.Update<ICSBadCodeGroupEntity>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadCode a with(nolock)
|
|
where a.BCGroupID ='" + entity.ID + "' and WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSBadCodeEntity>(sql, para).ToList();
|
|
|
|
MsSqlData.Delete<ICSBadCodeEntity>(entityList);
|
|
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSBadCodeDto, ICSBadCodeEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.BCGroupID = model.ID;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSBadCodeEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public ICSBadCodeGroupDto GetBadCodeGroup(string keyValue)
|
|
{
|
|
var returnValue = new ICSBadCodeGroupDto();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
try
|
|
{
|
|
var entity = MsSqlData.Get<ICSBadCodeGroupEntity>(keyValue);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("获取单个规则失败");
|
|
}
|
|
|
|
returnValue = ConvertExt.Mapping<ICSBadCodeGroupEntity, ICSBadCodeGroupDto>(entity);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSBadCode a with(nolock)
|
|
where a.BCGroupID ='" + entity.ID + "' and WorkPoint=@WorkPoint order by a.BadCode asc ";
|
|
var entityList = MsSqlData.Query<ICSBadCodeDto>(sql, para).ToList();
|
|
|
|
//int i = 0;
|
|
for (int i = 0; i < entityList.Count; i++)
|
|
{
|
|
entityList[i].key = i + 1;
|
|
}
|
|
|
|
|
|
returnValue.DetailList = entityList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = new ICSBadCodeGroupDto();
|
|
returnValue.DetailList = new List<ICSBadCodeDto>();
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string DeleteItem2AqlFile(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
try
|
|
{
|
|
var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInventoryInspectionRulesGroupFile a with(nolock)
|
|
where a.ID in ('" + string.Join("','", idList) + "') and WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSInventoryInspectionRulesGroupFile>(sql, para).ToList();
|
|
|
|
|
|
var result = MsSqlData.Delete<ICSInventoryInspectionRulesGroupFile>(entityList);
|
|
if (!result)
|
|
{
|
|
returnValue = "删除失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetItem2AqlFileList(string keyValue)
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
string sql = @"select
|
|
a.ID
|
|
,b.InvCode
|
|
,b.InvName
|
|
,b.InvStd
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
,d.FileName
|
|
,d.ID as FileID
|
|
from ICSInventoryInspectionRulesGroup a with(nolock)
|
|
join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
join ICSInspectionRulesGroup c with(nolock) on a.RulesCode=c.RulesCode and a.WorkPoint=c.WorkPoint
|
|
join ICSInventoryInspectionRulesGroupFile d with(nolock)on a.ID=d.IIRGID and a.WorkPoint=d.WorkPoint
|
|
where 1=1
|
|
and a.workpoint='{1}'
|
|
|
|
and a.InvCode='{0}'
|
|
";
|
|
sql = string.Format(sql, keyValue, WorkPoint);
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public int UpLoadItemRuleFile(string id, string fileName)
|
|
{
|
|
var returnValue = 1;
|
|
|
|
var dtNow = DateTime.Now;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
|
|
var sql1 = @" select count(1) from ICSInventoryInspectionRulesGroupFile with(nolock) where IIRGID='" + id + "' and FileName='" + fileName + "' and WorkPoint=@WorkPoint";
|
|
var count = MsSqlData.ExecuteScalar(sql1, para).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前物料规则文件已经存在");
|
|
}
|
|
|
|
var count2 = MsSqlData.ExecuteScalar
|
|
(" select count(1) from ICSInventoryInspectionRulesGroupFile with(nolock) where IIRGID='" + id + "' and WorkPoint=@WorkPoint ", para).ToInt();
|
|
if (count2 >= 3)
|
|
{
|
|
throw new Exception("当前物料规则文件已经超过3个,不能再次上传");
|
|
}
|
|
|
|
|
|
ICSInventoryInspectionRulesGroupFile entity = new ICSInventoryInspectionRulesGroupFile();
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.IIRGID = id;
|
|
entity.FileCode = fileName;
|
|
entity.FileName = fileName;
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSInventoryInspectionRulesGroupFile>(entity);
|
|
if (!result2)
|
|
{
|
|
returnValue = 0;
|
|
}
|
|
|
|
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string DeleteItem2Aql(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
try
|
|
{
|
|
var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInventoryInspectionRulesGroup a with(nolock)
|
|
where a.ID in ('" + string.Join("','", idList) + "') and WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSInventoryInspectionRulesGroup>(sql, para).ToList();
|
|
|
|
|
|
foreach (var item in entityList)
|
|
{
|
|
//var count = MsSqlData.ExecuteScalar(" select count(1) from IcsCheckingFixtureTransfer with(nolock) where CheckFixtureNo='" + item.CheckFixtureNo + "'").ToInt();
|
|
//if (count > 0)
|
|
//{
|
|
// throw new Exception("当前检具已经存在履历,不能删除");
|
|
//}
|
|
|
|
string sql2 = @"delete from ICSInventoryInspectionRulesGroupFile where IIRGID in ('" + string.Join("','", idList) + "') and WorkPoint=@WorkPoint ";
|
|
var line = MsSqlData.Execute(sql2, para);
|
|
}
|
|
|
|
|
|
var result = MsSqlData.Delete<ICSInventoryInspectionRulesGroup>(entityList);
|
|
if (!result)
|
|
{
|
|
returnValue = "删除失败";
|
|
}
|
|
|
|
//string sql2 = @"delete from ICSInspectionRulesList where RulesID in ('" + string.Join("','", idList) + "')";
|
|
//var line = Repository().ExecuteBySql(new StringBuilder(sql2));
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable ExportAllItem2AqlList(string rulesCode, string rulesName, string invCode, string invName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
a.*
|
|
from
|
|
(
|
|
select
|
|
b.InvCode
|
|
,b.InvName
|
|
,b.InvStd
|
|
,c.RulesCode
|
|
,c.RulesName
|
|
,c.RulesDesc
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
from ICSInventoryInspectionRulesGroup a with(nolock)
|
|
join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
join ICSInspectionRulesGroup c with(nolock) on a.RulesCode=c.RulesCode and a.WorkPoint=c.WorkPoint
|
|
where 1=1
|
|
{0}
|
|
) a
|
|
where 1=1
|
|
--and a.wo
|
|
<1>
|
|
<2>
|
|
<3>
|
|
<4>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(rulesCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.InvCode like '%" + rulesCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(rulesName))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.InvName like '%" + rulesName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(invCode))
|
|
{
|
|
sql = sql.Replace("<3>", " and a.RulesCode like '%" + invCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(invName))
|
|
{
|
|
sql = sql.Replace("<4>", " and a.RulesName like '%" + invName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<4>", " ");
|
|
}
|
|
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
//{
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
// // sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = sql.Replace("{0}", "");
|
|
//}
|
|
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
//{
|
|
// sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
//}
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public string SaveItem2Aql(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<ICSInventoryInspectionRulesGroupDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
foreach (var item in model.ItemList)
|
|
{
|
|
|
|
foreach (var item2 in model.AqlList)
|
|
{
|
|
|
|
var count = MsSqlData.ExecuteScalar
|
|
(
|
|
" select count(1) from ICSInventoryInspectionRulesGroup a with(nolock) where InvCode='" + item.InvCode + "' and a.EATTRIBUTE1='" + model.EATTRIBUTE1 + "' and WorkPoint=@WorkPoint "
|
|
, para).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前物料Aql关系已经存在");
|
|
}
|
|
|
|
|
|
var entity = new ICSInventoryInspectionRulesGroup();
|
|
entity.InvCode = item.InvCode;
|
|
entity.RulesCode = item2.RulesCode;
|
|
entity.RulesName = item2.RulesName;
|
|
entity.RulesDesc = item2.RulesDesc;
|
|
entity.Type = item2.Type;
|
|
entity.EATTRIBUTE1 = model.EATTRIBUTE1;
|
|
entity.Enable = true;
|
|
entity.Editable = true;
|
|
|
|
entity.ID = Guid.NewGuid().ToString();
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
entity.WorkPoint = WorkPoint;
|
|
|
|
var result2 = MsSqlData.Insert<ICSInventoryInspectionRulesGroup>(entity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public List<ICSInspectionRulesGroupEntity> GetAllAqlList(string code)
|
|
{
|
|
var returnValue = new List<ICSInspectionRulesGroupEntity>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
|
|
string sql = string.Empty;
|
|
if (code.IsNullOrEmpty())
|
|
{
|
|
sql = "select * from ICSInspectionRulesGroup with(nolock) where WorkPoint=@WorkPoint ";
|
|
}
|
|
else
|
|
{
|
|
sql = "select * from ICSInspectionRulesGroup with(nolock) where WorkPoint=@WorkPoint and RulesCode like '%" + code + "%'";
|
|
}
|
|
|
|
returnValue = MsSqlData.Query<ICSInspectionRulesGroupEntity>(sql, para).ToList();
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public List<ICSInventoryDto> GetAllItemList(string code)
|
|
{
|
|
var returnValue = new List<ICSInventoryDto>();
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
string sql = "select * from ICSInventory with(nolock) where WorkPoint=@WorkPoint and InvCode like '%" + code + "%' ";
|
|
returnValue = MsSqlData.Query<ICSInventoryDto>(sql, para).ToList();
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable ExportAllAqlList(string rulesCode, string rulesName, string enable)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
#region [SQL]
|
|
string sql = @"
|
|
select
|
|
case when a.Enable=1 then '是'
|
|
else '否' end as EnableText
|
|
,a.*
|
|
from ICSInspectionRulesGroup a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
<2>
|
|
<3>
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
//sql = string.Format(sql, Figure);
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(rulesCode))
|
|
{
|
|
sql = sql.Replace("<1>", " and a.RulesCode like '%" + rulesCode + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<1>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(rulesName))
|
|
{
|
|
sql = sql.Replace("<2>", " and a.RulesName like '%" + rulesName + "%' ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<2>", " ");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(enable))
|
|
{
|
|
|
|
sql = sql.Replace("<3>", " and a.Enable =" + enable + " ");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace("<3>", " ");
|
|
}
|
|
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public ICSInspectionRulesGroupDto GetAql(string keyValue)
|
|
{
|
|
var returnValue = new ICSInspectionRulesGroupDto();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
try
|
|
{
|
|
var entity = MsSqlData.Get<ICSInspectionRulesGroupEntity>(keyValue);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("获取单个规则失败");
|
|
}
|
|
|
|
returnValue = ConvertExt.Mapping<ICSInspectionRulesGroupEntity, ICSInspectionRulesGroupDto>(entity);
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionRulesList a with(nolock)
|
|
where a.RulesID ='" + entity.ID + "' and WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSInspectionRulesListDto>(sql, para).ToList();
|
|
|
|
//int i = 0;
|
|
for (int i = 0; i < entityList.Count; i++)
|
|
{
|
|
entityList[i].key = i + 1;
|
|
}
|
|
|
|
|
|
returnValue.DetailList = entityList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = null;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public string SaveAql(string keyValue)
|
|
{
|
|
string returnValue = string.Empty;
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
try
|
|
{
|
|
var dtNow = DateTime.Now;
|
|
var model = JsonConvert.DeserializeObject<ICSInspectionRulesGroupDto>(keyValue);
|
|
if (model == null)
|
|
{
|
|
throw new Exception("传入参数错误");
|
|
}
|
|
|
|
if (model.ID.IsNullOrEmpty())
|
|
{
|
|
//新增
|
|
var sql1 = @" select count(1) from ICSInspectionRulesGroup with(nolock) where RulesCode='" + model.RulesCode + "' and WorkPoint=@WorkPoint ";
|
|
var count = MsSqlData.ExecuteScalar(sql1, para).ToInt();
|
|
if (count > 0)
|
|
{
|
|
throw new Exception("当前规则代码已经存在");
|
|
}
|
|
|
|
model.ID = Guid.NewGuid().ToString();
|
|
model.MUSER = MUSER;
|
|
model.MUSERName = MUSERNAME;
|
|
model.MTIME = dtNow;
|
|
model.WorkPoint = WorkPoint;
|
|
|
|
var result = MsSqlData.Insert<ICSInspectionRulesGroupEntity>(model);
|
|
if (!result)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSInspectionRulesListDto, ICSInspectionRulesListEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.RulesID = model.ID;
|
|
detailEntity.Enable = true;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSInspectionRulesListEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "新增失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//修改
|
|
var entity = MsSqlData.Get<ICSInspectionRulesGroupEntity>(model.ID);
|
|
if (entity == null)
|
|
{
|
|
throw new Exception("当前数据不存在");
|
|
}
|
|
ConvertExt.Mapping<ICSInspectionRulesGroupDto, ICSInspectionRulesGroupEntity>(model, entity);
|
|
entity.MUSER = MUSER;
|
|
entity.MUSERName = MUSERNAME;
|
|
entity.MTIME = dtNow;
|
|
var result = MsSqlData.Update<ICSInspectionRulesGroupEntity>(entity);
|
|
if (!result)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionRulesList a with(nolock)
|
|
where a.RulesID ='" + entity.ID + "' and WorkPoint=@WorkPoint ";
|
|
var entityList = MsSqlData.Query<ICSInspectionRulesListEntity>(sql, para).ToList();
|
|
|
|
MsSqlData.Delete<ICSInspectionRulesListEntity>(entityList);
|
|
|
|
|
|
foreach (var item in model.DetailList)
|
|
{
|
|
var detailEntity = ConvertExt.Mapping<ICSInspectionRulesListDto, ICSInspectionRulesListEntity>(item);
|
|
detailEntity.ID = Guid.NewGuid().ToString();
|
|
detailEntity.RulesID = model.ID;
|
|
detailEntity.Enable = true;
|
|
detailEntity.MUSER = MUSER;
|
|
detailEntity.MUSERName = MUSERNAME;
|
|
detailEntity.MTIME = dtNow;
|
|
detailEntity.WorkPoint = WorkPoint;
|
|
var result2 = MsSqlData.Insert<ICSInspectionRulesListEntity>(detailEntity);
|
|
if (!result2)
|
|
{
|
|
returnValue = "修改失败";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnValue = ex.Message;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
public DataTable GetAqlSubGridJsonList(string id, ref Pagination pagination)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
// var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
//object Figure = GetDecimalDigits();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
#region [SQL]
|
|
string sql = @"select
|
|
a.*
|
|
from ICSInspectionRulesList a with(nolock)
|
|
where 1=1
|
|
{0}
|
|
<1>
|
|
order by a.SetValueMin asc
|
|
|
|
";
|
|
// sql += " WHERE 1=1 and a.MOStatus<>'3' ";
|
|
sql = sql.Replace("<1>", "and a.RulesID='" + id + "'");
|
|
|
|
//sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'");
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
public List<SysEnumValueDto> GetSelectItemList(string key)
|
|
{
|
|
var returnValue = new List<SysEnumValueDto>();
|
|
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 = @"select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode=@EnCode
|
|
";
|
|
var para = new
|
|
{
|
|
EnCode = key,
|
|
|
|
};
|
|
returnValue = MsSqlData.Query<SysEnumValueDto>(sql, para).ToList();
|
|
for (int i = 0; i < returnValue.Count; i++)
|
|
{
|
|
returnValue[i].key = i + 1;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
public void InsertOperateLog(string key, string data, string entityName = null, string sourceType = null)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var dtNow = DateTime.Now;
|
|
|
|
var entity = new SysModifyLog();
|
|
entity.BillCode = key;
|
|
entity.BillType = "Add";
|
|
entity.SourceType = sourceType;
|
|
entity.EntityName = entityName;
|
|
entity.JsonData = data;
|
|
entity.TenantId = WorkPoint;
|
|
|
|
entity.CreationTime = dtNow;
|
|
entity.CreatorUserId = MUSER;
|
|
entity.CreatorUserName = MUSERNAME;
|
|
entity.LastModificationTime = dtNow;
|
|
entity.LastModifierUserId = MUSER;
|
|
entity.LastModifierUserName = MUSERNAME;
|
|
|
|
var result2 = MsSqlData.Insert<SysModifyLog>(entity);
|
|
}
|
|
|
|
private void SendEmail(IcsMatCheckResultDto model)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
try
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
List<DbParameter> parameter1 = new List<DbParameter>();
|
|
|
|
|
|
string sqls = @" select *
|
|
from V_QuerySysEnumItem a
|
|
where a.F_EnCode = 'SQEPD'";
|
|
DataTable dts = Repository().FindDataSetBySql(sqls.ToString(), parameter1.ToArray()).Tables[0];
|
|
if (dts == null || dts.Rows.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string Email = string.Empty;
|
|
foreach (DataRow drs in dts.Rows)
|
|
{
|
|
Email += drs["Ext1"].ToString() + ",";
|
|
}
|
|
|
|
|
|
SendEmail(model, Email);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
InsertOperateLog(model.CheckNo, JsonConvert.SerializeObject(ex), new IcsMatCheckResult().GetType().Name, "拒收单邮件");
|
|
}
|
|
}
|
|
|
|
|
|
private void SendEmail(IcsMatCheckResultDto model, string email)
|
|
{
|
|
try
|
|
{
|
|
DateTime dtNow = DateTime.Now;
|
|
string MailOpen = ConfigurationManager.ConnectionStrings["MailOpen"].ConnectionString;
|
|
if (MailOpen == "true")
|
|
{
|
|
string SendHost = ConfigurationManager.ConnectionStrings["SendHost"].ConnectionString;
|
|
string StrSendPort = ConfigurationManager.ConnectionStrings["SendPort"].ConnectionString;
|
|
int SendPort = 25;
|
|
if (!string.IsNullOrEmpty(StrSendPort))
|
|
SendPort = Convert.ToInt32(ConfigurationManager.ConnectionStrings["SendPort"].ConnectionString);
|
|
string SendDisplayName = ConfigurationManager.ConnectionStrings["SendDisplayName"].ConnectionString;
|
|
string SendAddress = ConfigurationManager.ConnectionStrings["SendAddress"].ConnectionString;
|
|
string SendPassword = ConfigurationManager.ConnectionStrings["SendPassword"].ConnectionString;
|
|
|
|
|
|
string TOAddress = email;
|
|
string CCAddress = "";
|
|
string Subject = "您好!有来自检验拒收的订单";
|
|
bool isBodyHtml = false;
|
|
|
|
|
|
string body = "";
|
|
body += "\r\n";
|
|
body += "您好!有来自SQE拒收的信息:供应商:" + model.VenName + " ,到货时间:" + model.DHDate.Value.ToShortDateString() + " ,物料编码:" + model.InvCode + ",物料名称:"
|
|
+ model.InvName + ",来料数量:" + model.FinalItemLotList.Sum(x => x.Quantity) + ",拒收数量:" + model.FinalItemLotList.Sum(x => x.NgQty) + ",可登陆咖博士WMS系统查看相关信息!";
|
|
body += "\r\n";
|
|
body += " ";
|
|
body += "\r\n";
|
|
body += " 苏州咖博士咖啡系统科技有限公司";
|
|
body += "\r\n";
|
|
body += " " + dtNow.ToString("yyyy-MM-dd");
|
|
string StrConn = MsSqlData.FromMd5(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString);
|
|
//try
|
|
//{
|
|
if (!string.IsNullOrEmpty(TOAddress))
|
|
{
|
|
|
|
//MailHelper.SendEmail(StrConn, SendHost, SendPort, SendDisplayName, SendAddress, SendPassword, TOAddress, CCAddress, Subject, isBodyHtml, body, POCode);
|
|
ICSSendMail.SendEmail(StrConn, SendHost, SendPort, SendDisplayName, SendAddress, SendPassword, TOAddress, CCAddress, Subject, isBodyHtml, body);
|
|
|
|
}
|
|
else
|
|
{
|
|
//throw new Exception("供应商邮箱地址未维护,邮件发送失败!");
|
|
// msg += "供应商:" + cVenCode + "邮箱地址未维护,邮件发送失败!";
|
|
}
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
//InsertData(StrConn, SendHost, SendPort, SendDisplayName, SendAddress, SendPassword, TOAddress, CCAddress, Subject, isBodyHtml, body, "0", "");
|
|
//}
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("供应商:" + model.VenName + "邮件发送失败! \r\n" + ex.Message);
|
|
|
|
// msg += "供应商:" + cVenCode + "邮件发送失败! \r\n" + ex.Message;
|
|
// InsertOperateLog("拒收单邮件", JsonConvert.SerializeObject(ex), new IcsMatCheckResult().GetType().Name, "判退");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetVendorFileList(string keyValue, string InvCode, string BatchCode)
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var para = new { WorkPoint = WorkPoint };
|
|
|
|
string sql = @" select distinct a.ASNCode as Code,a.BatchCode,a.InvCode,b.VenCode,a.FileName from ICSASNShippingReport a
|
|
left join dbo.ICSASN b on a.ASNCode=b.ASNCode
|
|
where a.ASNCode='{0}' and a.InvCode='{1}' and a.BatchCode='{2}'
|
|
";
|
|
sql = string.Format(sql, keyValue, InvCode, BatchCode);
|
|
|
|
return Repository().FindDataSetBySql(sql.ToString(), parameter.ToArray()).Tables[0];
|
|
}
|
|
|
|
|
|
public DataTable GetInspectionFile(ref Pagination jqgridparam,string id,string batchCode)
|
|
{
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT * FROM dbo.ICSInspectionFile WHERE InspectionID='{0}' and EATTRIBUTE1='{1}' ";
|
|
sql = string.Format(sql, id,batchCode);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传文件
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public int InsertICSInspectionFile(string ID, string UploadfileName, string fileName,string batchCode)
|
|
{
|
|
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,EATTRIBUTE1) values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GetDate(),'{5}','{6}')", ID, UploadfileName, fileName, MUSER, MUSERName, WorkPoint, batchCode);
|
|
sql += "\r\n";
|
|
StringBuilder Str = new StringBuilder(sql);
|
|
return Repository().ExecuteBySql(Str);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|