|
|
using Dapper;using Dapper.Contrib.Extensions;using ICSSoft.SendMail;using Newtonsoft.Json;using Newtonsoft.Json.Linq;using NFine.Application.DHAY;using NFine.Application.Entity;using NFine.Application.Models;using NFine.Application.SystemManage;using NFine.Application.WMS;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.DHAY{ public class IQCQualityApp : RepositoryFactory<ICSVendor> { DataActionApp actionapp = new DataActionApp(); 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 = @"
selectcase 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 GetGridJsonGroup(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 = @"
selectcase 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 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 = @"
selectcase 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 = @"
selecta.*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 DataTable GetAllCheckGroupList(string code) { var workpont = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string sql = $@"select b.* from ICSInspectionGroup a with(nolock)
LEFT JOIN ICSInspectionList b with(nolock) ON a.Id = b.groupid AND a.Workpoint = b.workpoint and b.enable='1' where a.GroupCode='{code}' and a.workpoint='{workpont}' and a.Enable='1'";
var returnValue = SqlHelper.ExecuteTable(sql);
return returnValue; }
public DataTable GetEditCheckGroupList(string code, string INVCode) { var workpont = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string sql = $@"select b.* from ICSInventoryInspectionGroup a with(nolock)
LEFT JOIN ICSInventoryInspectionList b with(nolock) ON a.Id = b.InvGroupID AND a.Workpoint = b.workpoint and b.enable='1' where a.GroupCode='{code}' and A.InvCode='{INVCode}' and a.workpoint='{workpont}' and a.Enable='1' order by case when b.EATTRIBUTE6 = 'Size' then 1 when b.EATTRIBUTE6 = 'Carton' then 2 else 3 end, b.SetValueMin asc";
var returnValue = SqlHelper.ExecuteTable(sql); if (returnValue.Rows.Count == 0) { sql = $@"select b.* from ICSInspectionGroup a with(nolock)
LEFT JOIN ICSInspectionList b with(nolock) ON a.Id = b.groupid AND a.Workpoint = b.workpoint and b.enable='1' where a.GroupCode='{code}' and a.workpoint='{workpont}' and a.Enable='1' order by case when b.EATTRIBUTE6 = 'Size' then 1 when b.EATTRIBUTE6 = 'Carton' then 2 else 3 end, b.SetValueMin asc";
returnValue = SqlHelper.ExecuteTable(sql); }
return returnValue; }
public string DeleteAql(string keyValue) { string returnValue = string.Empty; try { 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 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("当前检具已经存在履历,不能删除");
//}
}
string chksql = @" select ListCode from ICSInspectionList
where EATTRIBUTE5 in (select RulesCode from ICSInspectionRulesGroup where ID in ('{0}')) AND WorkPoint='{1}'";
chksql = string.Format(chksql, string.Join("', '", idList), WorkPoint); DataTable chkdt = Repository().FindDataSetBySql(chksql.ToString(), parameter.ToArray()).Tables[0]; if (chkdt.Rows.Count > 0) { throw new Exception("所选AQL已绑定检验项目,无法删除!"); } 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 string DeleteCheckGroup(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 ICSInspectionGroup a with(nolock)where a.ID in ('" + string.Join("','", idList) + "') and a.workpoint=@WorkPoint ";
var para = new { WorkPoint = WorkPoint }; var entityList = MsSqlData.Query<ICSInspectionGroupEntity>(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<ICSInspectionGroupEntity>(entityList); if (!result) { returnValue = "删除失败"; }
string sql2 = @"delete from ICSInspectionList where GroupID 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 = @"
selecta.*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 CheckAttrTextfrom 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.WorkPointwhere 1=1{0}) awhere 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 awhere 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 string UploadFileInspectionRules(string savePath) { try { List<DbParameter> parameter = new List<DbParameter>(); 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;
var para = new { WorkPoint = WorkPoint }; List<string> TypeList = new List<string>(); string sql0 = @"
SELECT a.Name FROM dbo.ICSType a WHERE TableCode='ICSInspectionList' and ColumnCode='EATTRIBUTE6' and Workpoint='11' ";
DataTable typedt = Repository().FindDataSetBySql(sql0.ToString(), parameter.ToArray()).Tables[0]; foreach (DataRow dr in typedt.Rows) { TypeList.Add(dr["Name"].ToString()); } List<TempInspectGuid> GuidInfoList = new List<TempInspectGuid>(); string sql = ""; string setValueMax = ""; string setValueMin = ""; for (int i = 0; i < data.Rows.Count; i++) { var item = data.Rows[i]; if (item["检验项目组代码"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "检验项目组代码为空"; } if (item["检验项目组名称"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "检验项目组名称为空"; } if (item["检验类型"].ToString() == "") { return "第" + (i + 1) + "行," + "检验类型为空"; } if (item["检验项目代码"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "检验项目代码为空"; } if (item["检验项目名称"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "检验项目名称为空"; } if (item["检验类型"].ToString() == "定量") { if (item["标准下限"].ToString() == "" || item["标准上限"].ToString() == "") { return "第" + (i + 1) + "行," + "检验类型为定量时,标准上下限不能为空"; } if (Convert.ToDecimal(item["标准下限"]) >= Convert.ToDecimal(item["标准上限"])) { return "第" + (i + 1) + "行," + "标准下限必须小于标准上限"; } if (item["单位"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "检验类型为定量时,单位不能为空"; } if (item["检验仪器"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "检验类型为定量时,检验仪器不能为空"; } setValueMax = item["标准上限"].ToString(); setValueMin = item["标准下限"].ToString(); } else { if (item["标准下限"].ToString() != "") { setValueMin = item["标准下限"].ToString(); } else { setValueMin = ""; } if (item["标准上限"].ToString() != "") { setValueMax = item["标准上限"].ToString(); } else { setValueMax = ""; } } if (item["检验实际值是否必填"].ToString() != "是" && item["检验实际值是否必填"].ToString() != "否") { return "第" + (i + 1) + "行," + "检验实际值是否必填只能填写是或者否"; } if (item["AQL代码"].ToString() == "") { return "第" + (i + 1) + "行," + "AQL代码为空"; } if (!TypeList.Contains(item["检验类型"].ToString())) { return "第" + (i + 1) + "行," + "所填写检验类型不存在"; } string NeedActualValue = ""; if (item["检验实际值是否必填"].ToString() == "是") { NeedActualValue = "True"; } else { NeedActualValue = "False"; } string guid = ""; string chksql = ""; DataTable chkdt = new DataTable(); if (GuidInfoList.Count != 0) { foreach (TempInspectGuid GuidInfo in GuidInfoList) { if (GuidInfo.GroupCode == item["检验项目组代码"].ToStringExt()) { guid = GuidInfo.GUID; } } if (guid == "") { TempInspectGuid GuidInfo = new TempInspectGuid(); chksql = @" select ID from ICSInspectionGroup
where GroupCode='{0}' and WorkPoint='{1}'";
chksql = string.Format(chksql, item["检验项目组代码"].ToStringExt(), WorkPoint); chkdt = Repository().FindDataSetBySql(chksql.ToString(), parameter.ToArray()).Tables[0]; if (chkdt.Rows.Count != 0) { guid = chkdt.Rows[0]["ID"].ToString(); } else { guid = Guid.NewGuid().ToString(); } GuidInfo.GroupCode = item["检验项目组代码"].ToStringExt(); GuidInfo.GUID = guid; GuidInfoList.Add(GuidInfo); } } else { TempInspectGuid GuidInfo = new TempInspectGuid(); chksql = @" select ID from ICSInspectionGroup
where GroupCode='{0}' and WorkPoint='{1}'";
chksql = string.Format(chksql, item["检验项目组代码"].ToStringExt(), WorkPoint); chkdt = Repository().FindDataSetBySql(chksql.ToString(), parameter.ToArray()).Tables[0]; if (chkdt.Rows.Count != 0) { guid = chkdt.Rows[0]["ID"].ToString(); } else { guid = Guid.NewGuid().ToString(); } GuidInfo.GroupCode = item["检验项目组代码"].ToStringExt(); GuidInfo.GUID = guid; GuidInfoList.Add(GuidInfo); }
chksql = @" SELECT ListCode FROM ICSInspectionList
WHERE ListCode='{0}' AND GroupID='{3}' AND WorkPoint='{1}' select RulesCode from ICSInspectionRulesGroup where RulesCode='{2}' and WorkPoint='{1}'";
chksql = string.Format(chksql, item["检验项目代码"].ToStringExt(), WorkPoint, item["AQL代码"].ToStringExt(), guid); chkdt = Repository().FindDataSetBySql(chksql.ToString(), parameter.ToArray()).Tables[0]; if (chkdt.Rows.Count != 0) { return "第" + (i + 1) + "行," + "所填写检验项目代码已存在"; } chkdt = Repository().FindDataSetBySql(chksql.ToString(), parameter.ToArray()).Tables[1]; if (chkdt.Rows.Count == 0) { return "第" + (i + 1) + "行," + "所填写AQL代码不存在"; }
sql += @" IF NOT EXISTS(select GroupCode from ICSInspectionGroup where GroupCode='{0}' and WorkPoint='{4}')
BEGIN INSERT INTO ICSInspectionGroup (ID,GroupCode,GroupName,Enable,MUSER,MUSERName,MTIME,WorkPoint) VALUES ('{5}','{0}','{1}',1,'{2}','{3}',GETDATE(),'{4}') INSERT INTO ICSInspectionList (ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSER,MUSERName,MTIME,WorkPoint ,EATTRIBUTE1,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7) VALUES (NEWID(),'{5}','{6}','{7}','{8}',{9},{10},1,'{2}','{3}',GETDATE(),'{4}' ,'{11}','{12}','{13}',(SELECT Code FROM ICSType WHERE ColumnCode='EATTRIBUTE6' AND TableCode='ICSInspectionList' AND Name='{14}' AND WorkPoint='{4}') ,'{15}') END ELSE BEGIN INSERT INTO ICSInspectionList (ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSER,MUSERName,MTIME,WorkPoint ,EATTRIBUTE1,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7) VALUES (NEWID(),'{5}','{6}','{7}','{8}',{9},{10},1,'{2}','{3}',GETDATE(),'{4}' ,'{11}','{12}','{13}',(SELECT Code FROM ICSType WHERE ColumnCode='EATTRIBUTE6' AND TableCode='ICSInspectionList' AND Name='{14}' AND WorkPoint='{4}') ,'{15}') END";
if (setValueMax != "") { sql = string.Format(sql, item["检验项目组代码"].ToStringExt(), item["检验项目组名称"].ToStringExt(), MUSER, MUSERNAME, WorkPoint , guid, item["检验项目代码"].ToStringExt(), item["检验项目名称"].ToStringExt(), item["单位"].ToStringExt() , setValueMax, setValueMin, item["检验标准"].ToStringExt(), NeedActualValue , item["AQL代码"].ToStringExt(), item["检验类型"].ToStringExt(), item["检验仪器"].ToStringExt()); } else { sql = string.Format(sql, item["检验项目组代码"].ToStringExt(), item["检验项目组名称"].ToStringExt(), MUSER, MUSERNAME, WorkPoint , guid, item["检验项目代码"].ToStringExt(), item["检验项目名称"].ToStringExt(), item["单位"].ToStringExt() , "NULL", "NULL", item["检验标准"].ToStringExt(), NeedActualValue , item["AQL代码"].ToStringExt(), item["检验类型"].ToStringExt(), item["检验仪器"].ToStringExt()); }
} if (SqlHelper.CmdExecuteNonQuery(sql) == 0) { return "导入失败"; } returnValue = "true";
return returnValue; } catch (Exception ex) { throw new Exception(ex.Message); } } /// <summary>
/// 东辉AQL导入列表
/// </summary>
/// <param name="savePath"></param>
/// <returns></returns>
public string UploadFileInspectionAQL(string savePath) { try { List<DbParameter> parameter = new List<DbParameter>(); 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;
var para = new { WorkPoint = WorkPoint }; List<TempInspectGuid> GuidInfoList = new List<TempInspectGuid>(); string sql = ""; decimal setValueMin = 0; decimal setValueMax = 0; decimal setAllowNGQty = 0; string AQLType = "";
// 【新增】缓存:AQL编码 -> 主表ID(确保相同AQL只插入一次主表)
Dictionary<string, string> aqlMainIdCache = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
// 【保留】连续性校验缓存
string lastAqlCode = string.Empty; decimal lastSetValueMax = 0;
for (int i = 0; i < data.Rows.Count; i++) { var item = data.Rows[i]; string chksql = ""; DataTable chkdt = new DataTable(); string currentAqlCode = item["AQL代码"].ToString().Trim(); string mainTableId = string.Empty; // 主表(ICSInspectionRulesGroup)的ID
// AQL代码校验(原有逻辑)
if (string.IsNullOrEmpty(currentAqlCode)) { return "第" + (i + 1) + "行," + "AQL代码为空"; } else { chksql = @" select RulesCode from ICSInspectionRulesGroup
where RulesCode='{0}' and WorkPoint='{1}'";
chksql = string.Format(chksql, currentAqlCode, WorkPoint); chkdt = Repository().FindDataSetBySql(chksql.ToString(), parameter.ToArray()).Tables[0]; if (chkdt.Rows.Count != 0) { return "第" + (i + 1) + "行," + "AQL代码已存在"; } }
// AQL名称校验(原有逻辑)
if (item["AQL名称"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "AQL名称为空"; }
// 取样数量校验(原有逻辑)
if (item["取样数量"].ToString() == "") { return "第" + (i + 1) + "行," + "取样数量为空"; } else { if (Convert.ToDecimal(item["取样数量"].ToString()) <= 0) { return "第" + (i + 1) + "行," + "取样数量必须大于0"; } }
// 允许不良数处理(原有逻辑)
if (item["允许不良数"].ToStringExt() == "") { setAllowNGQty = 0; } else { setAllowNGQty = Convert.ToDecimal(item["允许不良数"].ToString()); }
// 取样类别校验(原有逻辑)
if (item["取样类别"].ToStringExt() == "") { return "第" + (i + 1) + "行," + "取样类别为空"; } else { chksql = @" SELECT a.Code,a.Name FROM dbo.ICSType a
WHERE a.Name='{0}' AND TableCode='ICSInspectionRulesList' and ColumnCode='EATTRIBUTE2' and Workpoint='{1}'";
chksql = string.Format(chksql, item["取样类别"].ToString(), WorkPoint); chkdt = Repository().FindDataSetBySql(chksql.ToString(), parameter.ToArray()).Tables[0]; if (chkdt.Rows.Count == 0) { return "第" + (i + 1) + "行," + "取样类别:" + item["取样类别"].ToString() + "不存在"; } else { AQLType = chkdt.Rows[0]["Code"].ToString(); } }
// 批量下限处理(修改:必填校验)
if (item["批量下限"].ToString() != "") { setValueMin = Convert.ToDecimal(item["批量下限"]); } else { return "第" + (i + 1) + "行," + "批量下限不能为空"; }
// 批量上限处理(修改:必填校验)
if (item["批量上限"].ToString() != "") { setValueMax = Convert.ToDecimal(item["批量上限"]); } else { return "第" + (i + 1) + "行," + "批量上限不能为空"; }
// 批量上下限大小校验(原有逻辑)
if (setValueMax <= setValueMin) { return "第" + (i + 1) + "行," + "批量上限不能小于批量下限"; }
// 同AQL编码的上下限连续性校验(原有逻辑)
if (i > 0) { if (currentAqlCode.Equals(lastAqlCode, StringComparison.OrdinalIgnoreCase)) { if (setValueMin != lastSetValueMax + 1) { return $"第{i + 1}行,AQL编码【{currentAqlCode}】连续性错误:上一行批量上限为{lastSetValueMax},当前行批量下限应为{lastSetValueMax + 1},实际为{setValueMin}"; } } }
// 【核心修改】判断是否需要插入主表
if (!aqlMainIdCache.ContainsKey(currentAqlCode)) { // 1. 新AQL编码:生成主表ID,插入主表
mainTableId = Guid.NewGuid().ToString(); sql += $@"
INSERT INTO ICSInspectionRulesGroup (ID, RulesCode, RulesName, Type, Enable, MUSER, MUSERName, MTIME, WorkPoint) VALUES ('{mainTableId}', '{currentAqlCode}', '{item["AQL名称"].ToStringExt()}', '1', 1, '{MUSER}', '{MUSERNAME}', GETDATE(), '{WorkPoint}'); ";
// 缓存AQL编码与主表ID的映射
aqlMainIdCache.Add(currentAqlCode, mainTableId); } else { // 2. 已有AQL编码:直接使用缓存的主表ID(不插入主表)
mainTableId = aqlMainIdCache[currentAqlCode]; }
// 【固定插入子表】无论AQL是否重复,都插入子表,关联主表ID
sql += $@"
INSERT INTO ICSInspectionRulesList (ID, RulesID, SetValueMin, SetValueMax, SampleQuantity, Enable, MUSER, MUSERName, MTIME, WorkPoint, EATTRIBUTE1, EATTRIBUTE2) VALUES (NEWID(), '{mainTableId}', {setValueMin}, {setValueMax}, '{Convert.ToDecimal(item["取样数量"].ToString())}', '1', '{MUSER}', '{MUSERNAME}', GETDATE(), '{WorkPoint}', {setAllowNGQty}, '{AQLType}'); ";
// 更新连续性校验缓存
lastAqlCode = currentAqlCode; lastSetValueMax = setValueMax; }
// 执行SQL(注意:SqlHelper.CmdExecuteNonQuery需支持批量执行多行SQL)
if (SqlHelper.CmdExecuteNonQuery(sql) == 0) { return "导入失败"; } returnValue = "true";
return returnValue; } catch (Exception ex) { throw new Exception(ex.Message); } } public class TempInspectGuid { public string GroupCode { get; set; } public string GUID { get; set; } }
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 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, a.FirstCheckTime CHUJIANSHIJIAN, a.Result, a.IQCGroupHeaderResult ZZJG, a.IQCGroupHeaderRemark ZZBZ, a.IQCGroupHeaderUser, a.IQCGroupHeaderTime, BLXX.BRGDesc, BLXX1.BadReasonDesc, BLFL.BadDesc, a.SQEEngineerResult SQEJG, a.SQEEngineerRemark SQEBZ, a.SQEEngineerUser, a.SQEEngineerTime, a.IQCHeaderResult ZGJG, a.IQCHeaderRemark ZGBZ, a.IQCHeaderUser, a.IQCHeaderTime, a.EATTRIBUTE1 SQEFA, A.FinalResult ZZPD, a.FinalUser, a.FinalTime, CASE WHEN a.Result='OK' OR (a.Result='NG' AND a.IsCheckComplete='是') THEN '是' ELSE '否' END AS SFJA, b.CheckAttr, b.CheckAttrText, b.CheckItemCode, b.CheckItemName, b.CheckWay, b.CheckAqlName, CONVERT(decimal(18, 2), b.SetValueMax) AS SetValueMax, CONVERT(decimal(18, 2), b.SetValueMin) AS SetValueMin, b.Unit, CONVERT(decimal(18, 2), b.S1) AS S1, CONVERT(decimal(18, 2), b.S2) AS S2, CONVERT(decimal(18, 2), b.S3) AS S3, CONVERT(decimal(18, 2), b.S4) AS S4, CONVERT(decimal(18, 2), b.S5) AS S5, CONVERT(decimal(18, 2), b.S6) AS S6, CONVERT(decimal(18, 2), b.S7) AS S7, CONVERT(decimal(18, 2), b.S8) AS S8, CONVERT(decimal(18, 2), b.S9) AS S9, CONVERT(decimal(18, 2), b.S10) AS S10, B.AqlQty,B.GoodQty,B.NgQty,B.Result JYXJG,B.Remark JYXBZ,B.MUSER,B.MUSERName,B.MTIME FROM IcsMatCheckResult a left JOIN IcsMatCheckResultDetail b on a.CheckNo=b.CheckNo AND a.WorkPoint=b.WorkPoint 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 WHERE 1=1 and a.InvCode='{0}' AND a.CheckNo IN(select TOP 10 CheckNo from IcsMatCheckResultwhere InvCode='{0}' order by MTIME desc)order by b.MTIME desc";
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 = @"
selecta.*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 = @"
selectcase 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,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE4,d.Name as Type,case when a.EATTRIBUTE4='true' then '是' else '否' end CEATTRIBUTE4, case when a.Enable='1' then '是' else '否' end CEnablefrom ICSInventoryInspectionList a with(nolock)left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.IDleft join ICSInventory c with(nolock) on b.InvCode=c.InvCodeLEFT JOIN ICSType d ON a.WorkPoint=d.WorkPoint AND d.TableCode='ICSInventoryInspectionList' AND d.ColumnCode='EATTRIBUTE6' AND a.EATTRIBUTE6=d.Code AND d.Enable='1'where 1=1and a.WorkPoint=@WorkPoint) awhere 1=1and 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.EATTRIBUTE1 = model.EATTRIBUTE1; entity.EATTRIBUTE2 = model.EATTRIBUTE2; entity.EATTRIBUTE3 = model.EATTRIBUTE3; entity.EATTRIBUTE4 = model.EATTRIBUTE4; entity.EATTRIBUTE5 = model.EATTRIBUTE5; entity.EATTRIBUTE6 = model.EATTRIBUTE6; entity.MUSER = MUSER; entity.MUSERName = MUSERNAME; entity.MTIME = dtNow; 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 仓库代码from(selectdistinctmax(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,'1' as DocTypefrom ICSASN a with(nolock)left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPointleft join ICSInventoryLotDetail cc with(nolock) on b.lotno=cc.lotno and cc.WorkPoint=c.WorkPointleft 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 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.WorkPointleft join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPointleft join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.ASNCode=g.AsnCodeleft join (SELECT ASNCode,InvCode,ExtensionID,max(CreateDateTime) CreateDateTime,max( t.DNCode) DNCode,PODetailIDfrom ICSDeliveryNotice t with(nolock) GROUP BY ASNCode,InvCode,ExtensionID,PODetailID ) lon a.ASNCode=l.ASNCode and c.InvCode=l.InvCode and l.PODetailID=cc.TransCode+'~'+cc.TransSequence
where 1=1{0}and inv.InvIQC=1and b.lotno not in ( 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)group by c.InvCode,inv.InvName ,c1.BatchCode,a.ASNCode
union all
selectdistinctmax(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,'' as OutReport,'' as 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,'2' as DocTypefrom ICSOASN a with(nolock)left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCodeleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNoleft join ICSInspection wl with(nolock) on b.LotNo=wl.LotNo and b.WorkPoint=wl.WorkPointleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID left join ICSInventory d with(nolock) on c.InvCode=d.InvCodeleft join ICSVendor e with(nolock) on a.VenCode=e.VenCodeleft join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.OASNCode=g.AsnCodeleft join (SELECT OASNCode,InvCode,ExtensionID,max(CreateDateTime) CreateDateTime,max( t.ODNCode) DNCodefrom ICSODeliveryNotice t with(nolock) GROUP BY OASNCode,InvCode,ExtensionID )l on a.OASNCode=l.OASNCode and c.InvCode=l.InvCode and l.ExtensionID=c.ExtensionIDwhere 1=1and d.InvIQC=1and b.lotno not in (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){0}group by c.InvCode,d.InvName ,c1.BatchCode,a.OASNCode) awhere 1=1 AND a.DNQuantity>0
<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(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 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 = @"
selecta.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 初检时间from(selectdistincta.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.CreateDateTimewhen l2.CreateDateTime is not null then l2.CreateDateTimeelse 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.WgNgFilefrom IcsMatCheckResult a with(nolock) left join ICSBadCodeGroup bcg with(nolock) on a.BRGCode=bcg.bcgcode and a.WorkPoint=bcg.WorkPointleft join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPointleft join ICSVendor c with(nolock) on a.VenCode=c.VenCode and a.WorkPoint=c.WorkPointleft 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.ASNCodeleft join ICSODeliveryNotice l2 with(nolock) on a.ASNCode=l2.OASNCodewhere 1=1{0}and a.Result='NG') awhere 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
//{
// 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 UpdateMaterialReUrgent(string keyValue, string time) { 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 = keyValue.Substring(1, keyValue.Length - 2).Split(',').ToList(); 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; item.EATTRIBUTE6 = time; 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 awhere 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(selecta.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.IDleft join ICSInventory c with(nolock) on b.InvCode = c.InvCode
) awhere 1 = 1and 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=1and a.WorkPoint=@WorkPointand a.BRGroupID=(selecta.IDfrom ICSBadReasonGroup a with(nolock)where 1=1and 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=1and a.WorkPoint=@WorkPointorder 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=1and a.WorkPoint=@WorkPointorder 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.CreateDateTimewhen l2.CreateDateTime is not null then l2.CreateDateTimeelse null end as DHDatefrom IcsMatCheckResult a with(nolock)left join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPointleft join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPointleft join ICSDeliveryNotice l with(nolock) on a.ASNCode=l.ASNCodeleft join ICSODeliveryNotice l2 with(nolock) on a.ASNCode=l2.OASNCodewhere 1 = 1and 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 = 1and a.WorkPoint = @WorkPoint and a.CheckNo=@CheckNoorder by a.CheckAttr ,a.CheckItemCode";
var detailList = MsSqlData.Query<IcsMatCheckResultDetailDto>(sql1, para);
// var para = new { WorkPoint = WorkPoint };
string sql0 = @"
select *from V_QuerySysEnumItem awhere 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 = @"
selecta.*from(selectdistincta.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,a.EATTRIBUTE6,case when l.CreateDateTime is not null then l.CreateDateTimewhen l2.CreateDateTime is not null then l2.CreateDateTimeelse 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.WHRemarkfrom IcsMatCheckResult a with(nolock) left join ICSBadCodeGroup bcg with(nolock) on a.BRGCode=bcg.bcgcode and a.WorkPoint=bcg.WorkPointleft join ICSInventory b with(nolock) on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPointleft join ICSVendor c with(nolock) on a.VenCode=c.VenCode and a.WorkPoint=c.WorkPointleft 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.ASNCodeleft join ICSODeliveryNotice l2 with(nolock) on a.ASNCode=l2.OASNCodewhere 1=1{0}and a.Result='NG') awhere 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 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=@InvCodeand a.InvBatcgNo=@InvBatcgNoand 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.CreateWWRejection4KBS(lotNoStr); if (!msg.IsNullOrEmpty()) { throw new Exception(msg); } } else {
} SendEmail("1", 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); } else { SendEmail("3", model); }
break; case "SQEEngineer": entity.SQEEngineerResult = model.SQEEngineerResult; entity.SQEEngineerRemark = model.SQEEngineerRemark; // entity.BRGCode = model.BRGCode;
entity.SQEEngineerUser = MUSERNAME; entity.SQEEngineerTime = dtNow; if (entity.SQEEngineerResult == "NG") { SendEmail("2", model); }
break; default: break; }
entity.EATTRIBUTE1 = model.EATTRIBUTE1; entity.MUSER = MUSER; entity.MUSERName = MUSERNAME; entity.MTIME = dtNow; entity.SQEFile = model.SQEFile; 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.CreateRejection4KBS(lotNoStr); if (!msg.IsNullOrEmpty()) { throw new Exception(msg); } } else if (entity.EATTRIBUTE2 == "2") { var msg = otherApp.CreateWWRejection4KBS(lotNoStr); if (!msg.IsNullOrEmpty()) { throw new Exception(msg); } } else {
} //发邮件
// 参考SRM邮件格式
//通过物料条码找采购订单/委外订单 采购人员 人员邮箱
//
SendEmail("1", 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.CreateWWRejection4KBS(lotNoStr2); if (!msg.IsNullOrEmpty()) { throw new Exception(msg); } } else {
} SendEmail("1", 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.CreateWWRejection4KBS(lotNoStr3); if (!msg.IsNullOrEmpty()) { throw new Exception(msg); } } else {
} SendEmail("1", 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 awhere 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 Remarkfrom ICSInventoryInspectionList a with(nolock) left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID and a.WorkPoint=b.WorkPointleft join ICSInventory c with(nolock) on b.InvCode=c.InvCode and b.WorkPoint=c.WorkPointleft join ICSInventoryInspectionRulesGroup d with(nolock) on b.InvCode=d.InvCode and b.EATTRIBUTE1=d.EATTRIBUTE1 and b.WorkPoint=d.WorkPointleft 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 awhere 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 Remarkfrom ICSInventoryInspectionList a with(nolock)left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID and a.WorkPoint=b.WorkPointleft join ICSInventory c with(nolock) on b.InvCode=c.InvCode and b.WorkPoint=b.WorkPointleft join ICSInventoryInspectionRulesGroup d with(nolock) on b.InvCode=d.InvCode and b.EATTRIBUTE1=d.EATTRIBUTE1 and b.WorkPoint=b.WorkPointleft 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 awhere 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 Remarkfrom ICSInventoryInspectionList a with(nolock)left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.ID and a.WorkPoint=b.WorkPointleft join ICSInventory c with(nolock) on b.InvCode=c.InvCode and b.WorkPoint=b.WorkPointleft join ICSInventoryInspectionRulesGroup d with(nolock) on b.InvCode=d.InvCode and b.EATTRIBUTE1=d.EATTRIBUTE1 and b.WorkPoint=b.WorkPointleft 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(selectdistinctb.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.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPointleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPointleft join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPointleft join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPointleft join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPointwhere 1=1and a.WorkPoint = '{1}'
union allselectdistinctb.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.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPointleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPointleft join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPointleft join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPointleft join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPointwhere 1=1and a.WorkPoint = '{1}') awhere 1=1and 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=1and a.WorkPoint = '{1}'and a.RulesID=(selecta.IDfrom ICSInspectionRulesGroup a with(nolock)where 1=1and 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(selectdistinctb.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 WgNgFilefrom ICSASN a with(nolock)left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPointleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPointleft join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPointleft join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPointleft join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPointwhere 1=1and a.WorkPoint = '{1}'
union all
selectdistinctb.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 WgNgFilefrom ICSOASN a with(nolock)left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPointleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID and c.WorkPoint=c1.WorkPointleft join ICSInventory d with(nolock) on c.InvCode=d.InvCode and c.WorkPoint=c.WorkPointleft join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPointleft join ICSInventoryInspectionRulesGroup f with(nolock) on c.InvCode=f.InvCode and c.WorkPoint=f.WorkPointwhere 1=1and a.WorkPoint = '{1}'
) awhere 1=1and 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=1and a.WorkPoint = '{1}'and a.RulesID=(selecta.IDfrom ICSInspectionRulesGroup a with(nolock)where 1=1and 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 (selectdistinct a.Idfrom ICSASNDetail a with(nolock)left join ICSASN b with(nolock) on a.ASNCode=b.ASNCodeleft join ICSInventoryLot c with(nolock) on a.LotNo=c.LotNoleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID where 1=1and a.ASNCode=@AsnCodeand c1.BatchCode=@InvBatcgNoand c.InvCode=@InvCodeand 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 (selectdistinct a.Idfrom ICSOASNDetail a with(nolock)left join ICSOASN b with(nolock) on a.OASNCode=b.OASNCodeleft join ICSInventoryLot c with(nolock) on a.LotNo=c.LotNoleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID where 1=1and a.OASNCode=@AsnCodeand c1.BatchCode=@InvBatcgNoand c.InvCode=@InvCodeand 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 distincta.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.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPointleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID left join ICSInventoryLotDetail d on b.LotNo=d.LotNo and b.WorkPoint=b.WorkPointleft join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPointleft join ICSContainerLot e with(nolock) on b.LotNo=e.LotNo and b.WorkPoint=e.WorkPointleft join ICSContainer f with(nolock) on e.ContainerID =f.ID and e.WorkPoint=f.WorkPointleft join ICSContainer g with(nolock) on f.ContainerID=g.ID and g.ContainerType='ContainerType04' and f.WorkPoint=g.WorkPointwhere c.Quantity>0 AND 1=1{0}
union all
select distincta.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.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPointleft join ICSExtension c1 with(nolock) on c.ExtensionID=c1.ID left join ICSInventoryLotDetail d on b.LotNo=d.LotNo and b.WorkPoint=b.WorkPointleft join ICSInventory inv with(nolock) on c.InvCode=inv.InvCode and c.WorkPoint=inv.WorkPointleft join ICSContainerLot e with(nolock) on b.LotNo=e.LotNo and b.WorkPoint=e.WorkPointleft join ICSContainer f with(nolock) on e.ContainerID =f.ID and e.WorkPoint=f.WorkPointleft join ICSContainer g with(nolock) on f.ContainerID=g.ID and g.ContainerType='ContainerType04' and f.WorkPoint=g.WorkPointwhere c.Quantity>0 AND 1=1--and a.WorkPoint = 'UFDATA_106_2019'-- and a.OASNCode='DN010000052200103' and c1.BatchCode='' {0}
) awhere 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 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(selectdistinctmax(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,'1' as DocTypefrom ICSASN a with(nolock)left join ICSASNDetail b with(nolock) on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPointleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNo and b.WorkPoint=b.WorkPointleft join ICSInventoryLotDetail cc with(nolock) on b.lotno=cc.lotno and cc.WorkPoint=c.WorkPointleft 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 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.WorkPointleft join ICSVendor e with(nolock) on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPointleft join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.ASNCode=g.AsnCodeleft join (SELECT ASNCode,InvCode,ExtensionID,max(CreateDateTime) CreateDateTime,max( t.DNCode) DNCode,PODetailIDfrom ICSDeliveryNotice t with(nolock) GROUP BY ASNCode,InvCode,ExtensionID,PODetailID ) lon a.ASNCode=l.ASNCode and c.InvCode=l.InvCode and l.PODetailID=cc.TransCode+'~'+cc.TransSequencewhere 1=1<1>{0}and inv.InvIQC=1and b.lotno not in ( 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)group by c.InvCode,inv.InvName ,c1.BatchCode,a.ASNCode
union all
selectdistinctmax(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--,'' as OutReport--,'' as 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,'2' as DocTypefrom ICSOASN a with(nolock)left join ICSOASNDetail b with(nolock) on a.OASNCode=b.OASNCodeleft join ICSInventoryLot c with(nolock) on b.LotNo=c.LotNoleft join ICSInspection wl with(nolock) on b.LotNo=wl.LotNo and b.WorkPoint=wl.WorkPointleft 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 a.OASNCode=c2.ASNCode and c1.BatchCode=c2.BatchCode and c.invcode=c2.invcode left join ICSInventory d with(nolock) on c.InvCode=d.InvCodeleft join ICSVendor e with(nolock) on a.VenCode=e.VenCodeleft join IcsMatCheckResult g with(nolock) on c.InvCode=g.InvCode and c1.BatchCode=g.InvBatcgNo and a.OASNCode=g.AsnCodeleft join (SELECT OASNCode,InvCode,ExtensionID,max(CreateDateTime) CreateDateTime,max( t.ODNCode) DNCodefrom ICSODeliveryNotice t with(nolock) GROUP BY OASNCode,InvCode,ExtensionID )l on a.OASNCode=l.OASNCode and c.InvCode=l.InvCode and l.ExtensionID=c.ExtensionIDwhere 1=1and d.InvIQC=1and b.lotno not in (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){0}<1>
group by c.InvCode,d.InvName ,c1.BatchCode,a.OASNCode) awhere 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 string DeleteItem2CheckItem(string keyValue) { string returnValue = string.Empty; try { var idList = JsonConvert.DeserializeObject<List<string>>(keyValue);
string sql = @"select
a.*from ICSInventoryInspectionGroup a with(nolock)where a.InvCode in ('" + string.Join("','", idList) + "')";
var entityList = MsSqlData.Query<ICSInventoryInspectionGroupEntity>(sql).ToList();
foreach (var item in entityList) { var delSql = @" delete from ICSInventoryInspectionGroup where id='" + item.ID + "' " + " delete from ICSInventoryInspectionList where InvGroupID='" + item.ID + "' ";
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 = model.GroupCode; entity.GroupName = model.GroupCodeName; 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(selecta.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.IDleft join ICSInventory c with(nolock) on b.InvCode = c.InvCode
) awhere 1 = 1and 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 string UpdateItem2CheckItem(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("传入参数错误"); }
// 校验:确保检验项目列表不为空
if (model.CheckItemList == null || !model.CheckItemList.Any()) { throw new Exception("检验项目列表不能为空"); }
// 获取当前操作的物料编码(假设所有检验项目属于同一个物料,取第一个即可)
string targetInvCode = model.CheckItemList.FirstOrDefault()?.InvCode; if (string.IsNullOrEmpty(targetInvCode)) { throw new Exception("物料编码不能为空"); }
// 获取当前操作的检验项目组编码
string targetGroupCode = model.GroupCode; if (string.IsNullOrEmpty(targetGroupCode)) { throw new Exception("检验项目组编码不能为空"); }
using (var connection = new SqlConnection(connString)) { connection.Open(); using (var trans = connection.BeginTransaction()) { try { // 1. 先删除关联的明细表数据(ICSInventoryInspectionList)
// 条件:通过主表ID关联,主表的InvCode和GroupCode匹配当前操作
string deleteDetailSql = @"
DELETE FROM ICSInventoryInspectionList WHERE InvGroupID IN ( SELECT ID FROM ICSInventoryInspectionGroup WHERE InvCode = @InvCode AND GroupCode = @GroupCode)";
var deleteDetailParams = new { InvCode = targetInvCode, GroupCode = targetGroupCode }; connection.Execute(deleteDetailSql, deleteDetailParams, trans);
// 2. 再删除主表数据(ICSInventoryInspectionGroup)
string deleteMainSql = @"
DELETE FROM ICSInventoryInspectionGroup WHERE InvCode = @InvCode AND GroupCode = @GroupCode";
var deleteMainParams = new { InvCode = targetInvCode, GroupCode = targetGroupCode }; connection.Execute(deleteMainSql, deleteMainParams, trans);
// 3. 校验检验项目是否重复(原有逻辑保留)
if (model.CheckItemList.GroupBy(x => new { x.ListCode, x.InvCode }).Count() != model.CheckItemList.Count) { throw new Exception("当前物料检验项目代码重复"); }
// 4. 新增数据(原有逻辑保留,新增前已删除旧数据)
foreach (var item in model.CheckItemList) { // 新增主表记录
var entity = new ICSInventoryInspectionGroupEntity(); entity.InvCode = item.InvCode; entity.GroupCode = model.GroupCode; entity.GroupName = model.GroupCodeName; // 建议从DTO中获取GroupName,避免与Code一致
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 = ConvertExt.Mapping<ICSInventoryInspectionListDto, ICSInventoryInspectionListEntity>(item); detail.InvGroupID = entity.ID; // 关联主表ID
detail.ID = Guid.NewGuid().ToString(); detail.MUSER = MUSER; detail.MUSERName = MUSERNAME; detail.MTIME = dtNow; detail.WorkPoint = WorkPoint;
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 = @"
selecta.*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.MTIMEfrom ICSInventoryInspectionList a with(nolock)left join ICSInventoryInspectionGroup b with(nolock) on a.InvGroupID=b.IDleft join ICSInventory c with(nolock) on b.InvCode=c.InvCodewhere 1=1{0}) awhere 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]; } /// <summary>
/// 查询物料检验项目关联表(主表)
/// </summary>
/// <param name="queryJson"></param>
/// <param name="pagination"></param>
/// <returns></returns>
public DataTable GetItemMainGridJson(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 = @"
selecta.*from(select distincta.InvCode,b.InvName,a.GroupCode,a.GroupName,a.MUSER,a.MUSERName,a.MTIMEfrom ICSInventoryInspectionGroup a with(nolock)left join ICSInventory b with(nolock) on b.InvCode=a.InvCode and b.WorkPoint=a.WorkPointwhere 1=1{0}) awhere 1=1<1><2><3><4> ";
#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["GroupCode"].ToString())) {
sql = sql.Replace("<3>", " and a.GroupCode ='" + queryParam["GroupCode"].ToString() + "' "); } else { sql = sql.Replace("<3>", " "); } if (!string.IsNullOrWhiteSpace(queryParam["GroupName"].ToString())) {
sql = sql.Replace("<4>", " and a.GroupName like '%" + queryParam["GroupName"].ToString() + "%' "); } else { sql = sql.Replace("<4>", " "); } } sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"); return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref pagination); }
public DataTable GetItemSubGridJson(string InvCode, ref Pagination pagination) { DataTable dt = new DataTable(); List<DbParameter> parameter = new List<DbParameter>(); string ordersql = ""; #region [SQL]
string sql = @"
selecta.*from(select a.ID,c.InvCode,c.InvName,a.ListCode,a.ListName,a.SetValueMax,a.SetValueMin,a.Unit,a.Enable,a.MUSER,a.MUSERName,a.MTIME,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE5,a.EATTRIBUTE6,b.Name as Type,case when a.EATTRIBUTE4='true' then '是' else '否' end CEATTRIBUTE4, case when a.Enable='1' then '是' else '否' end CEnablefrom ICSInventoryInspectionList a with(nolock)left join ICSInventoryInspectionGroup d with(nolock) on a.InvGroupID=d.IDleft join ICSInventory c with(nolock) on d.InvCode=c.InvCodeLEFT JOIN ICSType b ON a.WorkPoint=b.WorkPoint AND b.TableCode='ICSInventoryInspectionList' AND b.ColumnCode='EATTRIBUTE6' AND a.EATTRIBUTE6=b.Code AND b.Enable='1' where 1=1{0}) awhere a.InvCode = '" + InvCode + @"'";
#endregion
ordersql = @" order by
case when EATTRIBUTE6 = 'Size' then 1 when EATTRIBUTE6 = 'Carton' then 2 else 3 end, SetValueMin asc";
sql = sql.Replace("{0}", "and a.WorkPoint = '" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"); return Repository().FindTablePageBySql(sql.ToString(),ordersql.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 = @"
selecta.*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 = @"
selecta.*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 FileIDfrom 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.WorkPointwhere 1=1and 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 = @"
selecta.*from(select b.InvCode,b.InvName,b.InvStd ,c.RulesCode,c.RulesName,c.RulesDesc,a.MUSER,a.MUSERName,a.MTIMEfrom 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.WorkPointwhere 1=1{0}) awhere 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 A with(nolock)
LEFT JOIN ICSInventoryInspectionGroup B with(nolock) on B.InvCode=A.InvCode AND B.WorkPoint=A.WorkPoint where A.WorkPoint=@WorkPoint and A.InvIQC=1 AND B.InvCode IS NULL and A.InvCode like '%" + code + "%' ";
returnValue = MsSqlData.Query<ICSInventoryDto>(sql, para).ToList();
return returnValue; }
public List<ICSInventoryDto> GetEditItemList(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 A with(nolock)
where A.WorkPoint=@WorkPoint and A.InvCode = '" + code + "' ";
returnValue = MsSqlData.Query<ICSInventoryDto>(sql, para).ToList();
return returnValue; }
public List<ICSInventory2InspectionGroup> GetEditInfoData(string code) { var returnValue = new List<ICSInventory2InspectionGroup>();
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 1 A.InvCode,A.EATTRIBUTE1 AS CheckAttr,B.F_ItemName AS CheckAttrName
,A.GroupCode,A.GroupName from ICSInventoryInspectionGroup A LEFT JOIN Sys_SRM_ItemsDetail B ON B.F_ItemCode=A.EATTRIBUTE1 LEFT JOIN Sys_SRM_Items C ON C.F_Id=B.F_ItemId AND C.F_EnCode='InspectionGroupType' where A.InvCode='" + code + "' and A.WorkPoint='" + WorkPoint + "'";
returnValue = MsSqlData.Query<ICSInventory2InspectionGroup>(sql, para).ToList();
return returnValue; }
public List<ICSInventoryDto> GetItemCodeSearch(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 A.InvCode,A.InvName from ICSInventory A with(nolock)
LEFT JOIN ICSInventoryInspectionGroup B with(nolock) on B.InvCode = A.InvCode AND B.WorkPoint = A.WorkPoint where A.WorkPoint = @WorkPoint and A.InvIQC = 1 AND B.InvCode IS NULL and A.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 是否启用 ,a.GroupCode AS 检验项目组编码 ,a.GroupName AS 检验项目组名称 ,c.Name AS 检验类型 ,b.ListCode AS 检验项目编码 ,b.ListName AS 检验项目名称 ,b.SetValueMin AS 标准下限 ,b.SetValueMax AS 标准上限 ,b.Unit AS 标准单位 ,b.EATTRIBUTE1 AS 检验标准 ,b.EATTRIBUTE2 AS 抽样水准 ,b.EATTRIBUTE3 AS 允收标准 ,Case When b.EATTRIBUTE4='True' Then '是' ELSE '否' END AS 抽检实际值是否必填 ,b.EATTRIBUTE5 AS AQL代码 ,Case When b.Enable='True' Then '是' ELSE '否' END AS 是否可用 from ICSInspectionGroup a with(nolock) LEFT JOIN ICSInspectionList b with(nolock) on b.GroupID=a.ID AND b.WorkPoint=a.WorkPoint LEFT JOIN ICSType c with(nolock) on c.ColumnCode='EATTRIBUTE6' AND c.TableCode='ICSInspectionList' AND c.Code=b.EATTRIBUTE6 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.GroupCode like '%" + rulesCode + "%' "); } else { sql = sql.Replace("<1>", " "); }
if (!string.IsNullOrWhiteSpace(rulesName)) { sql = sql.Replace("<2>", " and a.GroupName 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 Order by SetValueMin";
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 ICSInspectionGroupDto GetGroup(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; var para = new { WorkPoint = WorkPoint }; try { var entity = MsSqlData.Get<ICSInspectionGroupEntity>(keyValue); if (entity == null) { throw new Exception("获取单个规则失败"); }
returnValue = ConvertExt.Mapping<ICSInspectionGroupEntity, ICSInspectionGroupDto>(entity);
string sql = @"select
a.*from ICSInspectionList a with(nolock)where a.GroupID ='" + entity.ID + @"' and WorkPoint=@WorkPoint order by case when a.EATTRIBUTE6 = 'Size' then 1 when a.EATTRIBUTE6 = 'Carton' then 2 else 3 end, a.SetValueMin asc";
var entityList = MsSqlData.Query<ICSInspectionListDto>(sql, para).ToList(); 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 GetICSAql() { 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 }; DataTable dt; try {
string sql = $@"select
a.RulesCode Code,a.RulesName+'('+a.RulesCode+')' Namefrom ICSInspectionRulesGroup a with(nolock)where a.Enable ='1' and WorkPoint='{WorkPoint}' ";
dt = SqlHelper.ExecuteTable(sql);
} catch (Exception ex) { throw new Exception(ex.Message); }
return dt; }
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.Type = "1"; 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 string SaveCheckGroup(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<ICSInspectionGroupDto>(keyValue); if (model == null) { throw new Exception("传入参数错误"); } var checkList = model.DetailList.GroupBy(x => new { x.ListCode }); if (checkList.Count() != model.DetailList.Count()) { throw new Exception("存在检验项目代码重复,一个检验项目组中不能有相同的检验项目!"); } if (model.ID.IsNullOrEmpty()) { //新增
var sql1 = @" select count(1) from ICSInspectionGroup with(nolock) where GroupCode='" + model.GroupCode + "' 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<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.Enable = model.Enable ;
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 + "' and WorkPoint=@WorkPoint ";
var entityList = MsSqlData.Query<ICSInspectionListEntity>(sql, para).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.Enable = true;
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 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.*,b.Name as Typefrom ICSInspectionRulesList a with(nolock)LEFT JOIN ICSType b ON a.WorkPoint=b.WorkPoint AND b.TableCode='ICSInspectionRulesList' AND b.ColumnCode='EATTRIBUTE2' AND a.EATTRIBUTE2=b.Code AND b.Enable='1' 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 DataTable GetGroupSubGridJsonList(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.*,b.Name as Type,case when a.EATTRIBUTE4='true' then '是' else '否' end CEATTRIBUTE4, case when a.Enable='1' then '是' else '否' end CEnable
from ICSInspectionList a with(nolock)LEFT JOIN ICSType b ON a.WorkPoint=b.WorkPoint AND b.TableCode='ICSInspectionList' AND b.ColumnCode='EATTRIBUTE6' AND a.EATTRIBUTE6=b.Code AND b.Enable='1' where 1=1{0}<1>order by case when a.EATTRIBUTE6 = 'Size' then 1 when a.EATTRIBUTE6 = 'Carton' then 2 else 3 end, a.SetValueMin 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
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
b.F_EnCode ,b.F_FullName ,a.F_ItemCode as value ,a.F_ItemName as label ,a.F_Define1 as Ext1 ,a.F_Define2 as Ext2 ,a.F_Define3 as Ext3 ,a.F_Define4 as Ext4 from [dbo].[Sys_SRM_ItemsDetail] a with(nolock) left join [Sys_SRM_Items] b with(nolock) on a.F_ItemId=b.F_Id where b.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 DataTable GetSelectCheckGroup() {
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string sql = $@"SELECT GroupCode Code,GroupName Name FROM ICSInspectionGroup WHERE Enable='1' and WorkPoint='{WorkPoint}' ";
var returnValue = SqlHelper.ExecuteTable(sql);
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(string type, 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 awhere 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() + ","; }
if (type == "1") { SendEmail(model, Email); } else if (type == "2") { SendEmailSQE(model, Email); } else { SendEmailIQC(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, "判退");
} }
private void SendEmailSQE(IcsMatCheckResultDto model, string email) { try { DateTime dtNow = DateTime.Now; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; 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 sql = $" select BcgDesc from ICSBadCodeGroup where workpoint='{WorkPoint}' and bcgcode='{model.BRGCode}' "; var dt = SqlHelper.CmdExecuteDataTable(sql);
string TOAddress = email; string CCAddress = ""; string Subject = "您好!有来自SQE复判NG的信息"; bool isBodyHtml = false;
string body = ""; body += "\r\n"; body += "您好!有来自SQE复判NG的信息:供应商:" + model.VenName + " ,到货时间:" + model.DHDate.Value.ToShortDateString() + " ,物料编码:" + model.InvCode + ",物料名称:" + model.InvName + ",来料数量:" + model.InvBatcgQty + ",不良分类:" + dt.Rows[0]["BcgDesc"] + ",SQE处理方案:" + model.EATTRIBUTE1 + ",可登陆咖博士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, "判退");
} }
private void SendEmailIQC(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 = "您好!有来自IQC复判NG的信息"; bool isBodyHtml = false;
string body = ""; body += "\r\n"; body += "您好!有来自IQC复判NG的信息:供应商:" + model.VenName + " ,到货时间:" + model.DHDate.Value.ToShortDateString() + " ,物料编码:" + model.InvCode + ",物料名称:" + model.InvName + ",来料数量:" + model.InvBatcgQty + ",可登陆咖博士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, "判退");
} }
/// <summary>
/// 采购
/// </summary>
/// <param name="jqgridparam"></param>
/// <returns></returns>
public DataTable GetICSInspection(ref Pagination jqgridparam, string MenuID, string queryJson) { string DataActionsql = actionapp.DataActionSqlGet(MenuID); string ERPSign = Configs.GetValue("ERPSign"); string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; DataTable dt = new DataTable(); var queryParam = queryJson.ToJObject(); List<DbParameter> parameter = new List<DbParameter>(); string sql = string.Empty;
if (ERPSign == "U8") { sql = @"
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1')) drop table #TempLLData_1 if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1')) drop table #TempLLData_1_1 if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1')) drop table #TempIcsinsp_1
select * into #TempIcsinsp_1 from dbo.ICSInspection where workpoint='" + WorkPoint + @"' and Enable='1'
select DISTINCT a.ID as DHID, d.ID , l.EATTRIBUTE3 as Address, h.EATTRIBUTE5,h.EATTRIBUTE6,h.EATTRIBUTE7, h.ID as JYID, a.DNCode , -- a.Sequence , a.ASNCode , l.POCode, c.InvCode , c.InvName , c.INVSTD , c.ClassName, c.EATTRIBUTE3 as InvEATTRIBUTE3, CAST(b.DNQuantity as decimal(18,4)) as AllNumber, CAST(ISNULL(h.QualifiedQuantity, b.DNQuantity)as decimal(18,4))as YLOTQTY , CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY, CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY, CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint, --CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity, c.InvUnit , b.LotNo , g.BadReasonDesc as BadReasonDesc , g.BadReasonCode as BRCodeValue, j.BadCode as BCCodeValue, j.BadDesc as BadDesc, k.ContainerID, q.ContainerCode, isnull(h.EATTRIBUTE2,'') as InspectionEATTRIBUTE2, isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime, CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime, CONVERT(VARCHAR(100),h.MTIME,120) as MTIME, CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState, a.VenCode, m.VenName, CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH, isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 , CASE WHEN h.Result='1' THEN '合格' when h.Result='0' THEN '不合格' ELSE '' END AS Result, n.FileName ,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0) WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*b.DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,o.Editable ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2 WHERE hH2.LotNo=b.LotNo AND hH2.WorkPoint=b.WorkPoint),0) WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK ,case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent, case when isnull(qq.EATTRIBUTE1,'')='' then '否' else '是' end Rejected,c.InvIQC{2} into #TempLLData_1 FROM ICSDeliveryNotice a inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1' inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.ExtensionID=d.ExtensionID AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint LEFT JOIN #TempIcsinsp_1 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint LEFT JOIN ICSContainer q on k.ContainerID=q.ContainerID AND k.WorkPoint=q.WorkPoint inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND d.WorkPoint=l.WorkPoint left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND b.DNQuantity BETWEEN p.SetValueMin AND p.SetValueMax left join ICSDeliveryNotice qq on e.LotNo =qq.EATTRIBUTE1 and qq.DNType='3' and a.WorkPoint=qq.WorkPoint left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint where b.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
select * into #TempLLData_1_1 from #TempLLData_1 where InvIQC='1' ";
} else { sql = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
drop table #TempLLData_1 if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1')) drop table #TempIcsinsp_1 if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1')) drop table #TempLLData_1_1select *into #TempIcsinsp_1from dbo.ICSInspectionwhere workpoint='" + WorkPoint + @"' and Enable='1'
select DISTINCT a.ID as DHID, l.EATTRIBUTE3 as Address, h.EATTRIBUTE5,h.EATTRIBUTE6,h.EATTRIBUTE7, d.ID , h.ID as JYID, a.DNCode , a.Sequence , a.ASNCode , l.POCode, c.InvCode , c.InvName , c.INVSTD , c.ClassName, c.EATTRIBUTE3 as InvEATTRIBUTE3, isnull(h.EATTRIBUTE2,'') as InspectionEATTRIBUTE2, CAST(d.Quantity as decimal(18,4)) as AllNumber, CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY , CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY, CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY, CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint, CASE WHEN lotInfo.ID is null THEN '否' ELSE '是' END as IsWH, -- CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity, c.InvUnit , d.LotNo , g.BadReasonDesc as BadReasonDesc , g.BadReasonCode as BRCodeValue, j.BadCode as BCCodeValue, j.BadDesc as BadDesc, k.ContainerID, isnull(h.MUSERName,'开发者') MUSERName, CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime, CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime, CONVERT(VARCHAR(100),h.MTIME,120) as MTIME, CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState, a.VenCode, m.VenName, isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,CASE WHEN h.Result='1' THEN '合格' when h.Result='0' THEN '不合格' ELSE '' END AS Result, n.FileName ,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0) WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*b.DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,o.Editable ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2 WHERE hH2.LotNo=d.LotNo AND hH2.WorkPoint=a.WorkPoint),0) WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK , case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC{2} into #TempLLData_1 FROM ICSDeliveryNotice a --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1' inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint LEFT JOIN #TempIcsinsp_1 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND a.WorkPoint=l.WorkPoint left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin left JOIN ICSWareHouseLotInfo lotInfo ON lotInfo.LotNo=e.LotNo AND lotInfo.WorkPoint=e.WorkPoint where d.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
select * into #TempLLData_1_1 from #TempLLData_1 ";
}
string wheresql = ""; if (!string.IsNullOrWhiteSpace(queryJson)) { if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) { wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString())) { wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString())) { wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString())) { wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString())) { wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvStd"].ToString())) { wheresql += " and c.InvStd like '%" + queryParam["InvStd"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["CusBatch"].ToString())) { wheresql += " and d.EATTRIBUTE3 like '%" + queryParam["CusBatch"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString())) { wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' "; } if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString())) { wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' "; } if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString())) { wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString())) { wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' "; }
if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString())) { string ReleaseState = queryParam["ReleaseState"].ToString(); if (ReleaseState == "1") wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'"; else if (ReleaseState == "0") wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'"; else wheresql += " "; } if (!string.IsNullOrWhiteSpace(queryParam["selIsWH"].ToString())) { if (queryParam["selIsWH"].ToString() == "0") { wheresql += " and lotInfo.ID is null "; } if (queryParam["selIsWH"].ToString() == "1") { wheresql += " and lotInfo.ID is not null "; } }
if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString())) { string printState = queryParam["selIsPrint"].ToString(); if (printState == "否") wheresql += " and isnull(task.ValueParameters,'') ='' "; else if (printState == "是") wheresql += " and isnull(task.ValueParameters,'') <>''"; } if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString())) { string selEnableShow = queryParam["selEnableShow"].ToString(); if (selEnableShow == "1") wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0"; else if (selEnableShow == "0") wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0"; } if (!string.IsNullOrWhiteSpace(queryParam["Rejected"].ToString())) { string selEnableShow = queryParam["Rejected"].ToString(); if (selEnableShow == "1") wheresql += "and isnull(qq.EATTRIBUTE1,'')<>''"; else if (selEnableShow == "2") wheresql += "and isnull(qq.EATTRIBUTE1,'')=''"; } if (!string.IsNullOrWhiteSpace(queryParam["EATTRIBUTE7"].ToString())) { wheresql += " and l.EATTRIBUTE7 like '%" + queryParam["EATTRIBUTE7"].ToString() + "%' "; } } wheresql += " " + DataActionsql; List<string> tableName = new List<string> { "ICSInspection", "ICSInventory" }; List<string> tablenameJC = new List<string> { "h.", "c." }; //sql = SqlHelper.GetEATTRIBUTE(sql, "ICSInspection", "", wheresql, WorkPoint);//
sql = SqlHelper.GetEATTRIBUTE(sql, tableName, tablenameJC, wheresql, WorkPoint);//
//sql = string.Format(sql, wheresql, WorkPoint);
return Repository().FindTablePageBySql_OtherTemp(sql, "#TempLLData_1_1", @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
drop table #TempLLData_1 if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1')) drop table #TempIcsinsp_1 if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempLLData_1_1')) drop table #TempLLData_1_1 ",
"connstr", parameter.ToArray(), ref jqgridparam); // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
/// 新增检验
/// </summary>
/// <param name="queryJson"></param>
/// <returns></returns>
public string CreateICSInspection(string keyValue, string ICSInspections) { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string msg = ""; string sql = string.Empty; JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections); try { foreach (var item in res) { object CARID = Guid.NewGuid(); JObject jo = (JObject)item;
string sqls = string.Empty; string type = jo["Type"].ToString(); if (jo["FlagVersion"].ToString() == "1") { #region 2024-08-09 检验添加是否入库验证
var checksql = $@"SELECT ID FROM ICSWareHouseLotInfo WHERE LotNo='{jo["LotNo"]}' AND WorkPoint='{WorkPoint}'"; var checkdt = SqlHelper.CmdExecuteDataTable(checksql); if (checkdt.Rows.Count > 0) { msg = $"条码:{jo["LotNo"]}已经入库,不能再次检验"; return msg; }
#endregion
if (!string.IsNullOrWhiteSpace(jo["JYID"].ToString())) { sqls += "update ICSInspectionDetailGroup set InspectionID='{2}' WHERE InspectionID='{3}' and WorkPoint='{1}' ";
} sqls += @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'"; sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint, CARID, jo["JYID"].ToString()); SqlHelper.CmdExecuteNonQueryLi(sqls); sql += @"INSERT INTO dbo.ICSInspection
( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,Result,EATTRIBUTE1) Values('{13}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate(),'{9}','{10}','{11}','1','{12}','{14}','{15}') ";
sql = string.Format(sql, jo["LotNo"].ToString(), jo["InvCode"].ToString(), jo["AllNumber"].ToString(), jo["YLOTQTY"].ToString(), jo["NLOTQTY"].ToString(), jo["SpecialQTY"].ToString(), jo["BCCode"].ToString(), jo["BRCode"].ToString(), jo["Type"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["SampleQuantity"].ToString(), CARID, jo["Result"].ToString(), jo["FlagVersion"].ToString()); } else { var lotNosql = string.Empty; var dt = new DataTable(); if (jo["FlagVersion"].ToString() == "2") { //获取各种单据类型的条码数量信息
if (type == "1") { lotNosql = $@"SELECT b.LotNo,b.Quantity,b.InvCode FROM ICSDeliveryNotice a
INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode INNER JOIN ICSExtension d ON d.ID=b.ExtensionID AND b.WorkPoint=d.WorkPoint LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint INNER JOIN ICSPurchaseOrder l ON m.TransID = l.ID AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID AND l.PODetailID=a.PODetailID WHERE d.BatchCode='{jo["BatchCode"]}' AND a.WorkPoint='{WorkPoint}' AND a.DNCode='{jo["DNCode"]}' AND a.Sequence='{jo["Sequence"]}' AND a.DNType='1'";
} else if (type == "2") { lotNosql = $@"SELECT d.LotNo,d.Quantity,d.InvCode FROM ICSODeliveryNotice a
LEFT JOIN ICSOASNDetail b ON a.OASNCode = b.OASNCode AND a.WorkPoint = b.WorkPoint inner JOIN ICSInventoryLot d ON b.LotNo = d.LotNo AND a.InvCode = d.InvCode AND b.WorkPoint = d.WorkPoint left join ICSInventoryLotDetail e on d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint inner JOIN ICSOutsourcingOrder l ON e.TransID = l.ID AND d.WorkPoint = l.WorkPoint WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' AND a.ODNType = '1'";
} else if (type == "3") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMO a
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND e.ExtensionID = f.ID
WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
} else if (type == "4") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSOtherIn a
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint and c.InvIQC = '1' left join ICSInventoryLotDetail b on a.InCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')= '' left join ICSExtension f on e.ExtensionID = f.ID and e.WorkPoint = f.WorkPoint WHERE a.WorkPoint = '{WorkPoint}' AND a.InCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
} else if (type == "5") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMOApplyNeg a
LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode = ad.ApplyNegCode AND a.WorkPoint = ad.WorkPoint inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.ApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.ApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
} else if (type == "6") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode = ad.OApplyNegCode AND a.WorkPoint = ad.WorkPoint inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.OApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.OApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
} else if (type == "7") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
from ICSSDN a inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.SDNCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.SDNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
} else if (type == "8") { lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode FROM ICSDeliveryNotice a
left join ICSInventoryLotDetail e on a.DNCode = e.TransCode and a.Sequence = e.TransSequence and a.WorkPoint = e.WorkPoint inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint-- and c.InvIQC = '1'
inner JOIN ICSInventoryLot d ON e.LotNo = d.LotNo AND a.InvCode = d.InvCode AND a.WorkPoint = d.WorkPoint and d.type = '7'
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.DNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' and a.DNType = '1' ";
} else if (type == "9") { lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode
FROM ICSODeliveryNotice a
inner join ICSInventoryLotDetail e on e.TransCode = a.ODNCode AND e.TransSequence = a.Sequence AND e.WorkPoint = a.WorkPoint
inner JOIN ICSInventoryLot d ON d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint and d.type = '8' inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint--and c.InvIQC = '1' LEFT JOIN dbo.ICSInspection h ON h.LotNo = d.LotNo AND h.WorkPoint = d.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
} else if (type == "10") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode
from ICSMO a inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
LEFT JOIN ICSMOPick pick ON a.MODetailID = pick.MODetailID AND a.WorkPoint = pick.WorkPoint AND pick.EATTRIBUTE1 = '1'
left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence + '~' + pick.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' AND a.MOStatus <> '3' ";
}
} else if (jo["FlagVersion"].ToString() == "3") { if (type == "1") { lotNosql = $@"SELECT b.LotNo,b.Quantity,b.InvCode FROM ICSDeliveryNotice a
INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode INNER JOIN ICSExtension d ON d.ID=b.ExtensionID AND b.WorkPoint=d.WorkPoint LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint INNER JOIN ICSPurchaseOrder l ON m.TransID = l.ID AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID AND l.PODetailID=a.PODetailID WHERE a.WorkPoint='{WorkPoint}' AND a.DNCode='{jo["DNCode"]}' AND a.Sequence='{jo["Sequence"]}' AND a.DNType='1'";
} else if (type == "2") { lotNosql = $@"SELECT d.LotNo,d.Quantity,d.InvCode FROM ICSODeliveryNotice a
LEFT JOIN ICSOASNDetail b ON a.OASNCode = b.OASNCode AND a.WorkPoint = b.WorkPoint inner JOIN ICSInventoryLot d ON b.LotNo = d.LotNo AND a.InvCode = d.InvCode AND b.WorkPoint = d.WorkPoint
left join ICSInventoryLotDetail e on d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint
inner JOIN ICSOutsourcingOrder l ON e.TransID = l.ID AND d.WorkPoint = l.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND a.ODNType = '1'";
} else if (type == "3") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMO a
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1' left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND e.ExtensionID=f.ID WHERE a.WorkPoint='{WorkPoint}' AND a.MOCode='{jo["DNCode"]}' AND a.Sequence='{jo["Sequence"]}' ";
} else if (type == "4") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSOtherIn a
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint and c.InvIQC = '1' left join ICSInventoryLotDetail b on a.InCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')= '' left join ICSExtension f on e.ExtensionID = f.ID and e.WorkPoint = f.WorkPoint WHERE a.WorkPoint = '{WorkPoint}' AND a.InCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
} else if (type == "5") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMOApplyNeg a
LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode = ad.ApplyNegCode AND a.WorkPoint = ad.WorkPoint inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.ApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.ApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
} else if (type == "6") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode = ad.OApplyNegCode AND a.WorkPoint = ad.WorkPoint inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.OApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.OApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
} else if (type == "7") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
from ICSSDN a inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.SDNCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.SDNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
} else if (type == "8") { lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode FROM ICSDeliveryNotice a
left join ICSInventoryLotDetail e on a.DNCode = e.TransCode and a.Sequence = e.TransSequence and a.WorkPoint = e.WorkPoint inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint-- and c.InvIQC = '1'
inner JOIN ICSInventoryLot d ON e.LotNo = d.LotNo AND a.InvCode = d.InvCode AND a.WorkPoint = d.WorkPoint and d.type = '7'
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.DNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' and a.DNType = '1' ";
} else if (type == "9") { lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode
FROM ICSODeliveryNotice a
inner join ICSInventoryLotDetail e on e.TransCode = a.ODNCode AND e.TransSequence = a.Sequence AND e.WorkPoint = a.WorkPoint
inner JOIN ICSInventoryLot d ON d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint and d.type = '8' inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint--and c.InvIQC = '1' LEFT JOIN dbo.ICSInspection h ON h.LotNo = d.LotNo AND h.WorkPoint = d.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
} else if (type == "10") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode
from ICSMO a inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
LEFT JOIN ICSMOPick pick ON a.MODetailID = pick.MODetailID AND a.WorkPoint = pick.WorkPoint AND pick.EATTRIBUTE1 = '1'
left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence + '~' + pick.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND a.MOStatus <> '3' ";
}
} else {
if (type == "1") { lotNosql = $@"SELECT b.LotNo,b.Quantity,b.InvCode FROM ICSDeliveryNotice a
INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode INNER JOIN ICSExtension d ON d.ID=b.ExtensionID AND b.WorkPoint=d.WorkPoint LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint INNER JOIN ICSPurchaseOrder l ON m.TransID = l.ID AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID AND l.PODetailID=a.PODetailID WHERE a.WorkPoint='{WorkPoint}' AND a.DNCode='{jo["DNCode"]}' AND a.DNType='1'";
} else if (type == "2") { lotNosql = $@"SELECT d.LotNo,d.Quantity,d.InvCode FROM ICSODeliveryNotice a
LEFT JOIN ICSOASNDetail b ON a.OASNCode = b.OASNCode AND a.WorkPoint = b.WorkPoint inner JOIN ICSInventoryLot d ON b.LotNo = d.LotNo AND a.InvCode = d.InvCode AND b.WorkPoint = d.WorkPoint left join ICSInventoryLotDetail e on d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint inner JOIN ICSOutsourcingOrder l ON e.TransID = l.ID AND d.WorkPoint = l.WorkPoint WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.ODNType = '1'";
} else if (type == "3") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMO a
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1' left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND e.ExtensionID=f.ID WHERE a.WorkPoint='{WorkPoint}' AND a.MOCode='{jo["DNCode"]}' ";
} else if (type == "4") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSOtherIn a
inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint and c.InvIQC = '1' left join ICSInventoryLotDetail b on a.InCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')= '' left join ICSExtension f on e.ExtensionID = f.ID and e.WorkPoint = f.WorkPoint WHERE a.WorkPoint = '{WorkPoint}' AND a.InCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
} else if (type == "5") { lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMOApplyNeg a
LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode = ad.ApplyNegCode AND a.WorkPoint = ad.WorkPoint inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.ApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.ApplyNegCode = '{jo["DNCode"]}' ";
} else if (type == "6") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode = ad.OApplyNegCode AND a.WorkPoint = ad.WorkPoint inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.OApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.OApplyNegCode = '{jo["DNCode"]}' ";
} else if (type == "7") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
from ICSSDN a inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
left join ICSInventoryLotDetail b on a.SDNCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.SDNCode = '{jo["DNCode"]}' ";
} else if (type == "8") { lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode FROM ICSDeliveryNotice a
left join ICSInventoryLotDetail e on a.DNCode = e.TransCode and a.Sequence = e.TransSequence and a.WorkPoint = e.WorkPoint inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint-- and c.InvIQC = '1'
inner JOIN ICSInventoryLot d ON e.LotNo = d.LotNo AND a.InvCode = d.InvCode AND a.WorkPoint = d.WorkPoint and d.type = '7'
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.DNCode = '{jo["DNCode"]}' and a.DNType = '1' ";
} else if (type == "9") { lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode
FROM ICSODeliveryNotice a
inner join ICSInventoryLotDetail e on e.TransCode = a.ODNCode AND e.TransSequence = a.Sequence AND e.WorkPoint = a.WorkPoint
inner JOIN ICSInventoryLot d ON d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint and d.type = '8' inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint--and c.InvIQC = '1' LEFT JOIN dbo.ICSInspection h ON h.LotNo = d.LotNo AND h.WorkPoint = d.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' ";
} else if (type == "10") { lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode
from ICSMO a inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
LEFT JOIN ICSMOPick pick ON a.MODetailID = pick.MODetailID AND a.WorkPoint = pick.WorkPoint AND pick.EATTRIBUTE1 = '1'
left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence + '~' + pick.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.MOStatus <> '3' ";
} } dt = SqlHelper.CmdExecuteDataTable(lotNosql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { #region 2024-08-09 检验添加是否入库验证
var checksql = $@"SELECT ID FROM ICSWareHouseLotInfo WHERE LotNo='{dt.Rows[i]["LotNo"]}' AND WorkPoint='{WorkPoint}'"; var checkdt = SqlHelper.CmdExecuteDataTable(checksql); if (checkdt.Rows.Count > 0) { msg = $"条码:{jo["LotNo"]}已经入库,不能再次检验"; return msg; }
#endregion
object id = Guid.NewGuid(); sql += $@" update ICSInspectionDetailGroup set InspectionID='{id}' WHERE InspectionID=(Select ID from ICSInspection WHERE LotNO='{dt.Rows[i]["LotNo"]}' and Enable='1' and WorkPoint='{WorkPoint}') and WorkPoint='{WorkPoint}' ;
update ICSInspection set Enable='0' WHERE LotNO='{dt.Rows[i]["LotNo"]}' and Enable='1' and WorkPoint='{WorkPoint}' ; INSERT INTO dbo.ICSInspection ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,Result,EATTRIBUTE1) Values('{id}','{dt.Rows[i]["LotNo"]}','{dt.Rows[i]["InvCode"]}','{dt.Rows[i]["Quantity"]}','{dt.Rows[i]["Quantity"]}','0','0','','','{type}',getdate(),'{MUSER}','{MUSERNAME}','{WorkPoint}','1','0','1','{jo["FlagVersion"]}') ; ";
} }
}
} //}
if (SqlHelper.ExecuteNonQuery(sql) > 0) {
} else { msg = "新增失败"; } } catch (Exception ex) { throw new Exception(ex.Message); }
return msg; }
public DataTable GetRulesDetail(string LotNo) { DataTable dt = new DataTable(); //var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>(); string sql = string.Empty; //增加pp子表查询 主要查询U8到货单数量
sql = @"select DISTINCT
CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity, b.LotNo , b.Quantity, '抽检', g.RulesCode, c.InvCode, c.InvStd, c.InvName,h.UnqualifiedQuantity,h.EATTRIBUTE2,h.EATTRIBUTE3,h.WaiveQuantity,h.EATTRIBUTE4 ,h.EATTRIBUTE5,h.EATTRIBUTE6,h.EATTRIBUTE7,h.EATTRIBUTE8 ,Case When h.Result=1 then 'OK' ELSE 'NG' END AS Result FROM ICSDeliveryNotice a inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1' inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint LEFT JOIN dbo.ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint --and Enable='1' LEFT JOIN ICSInventoryInspectionRulesGroup g ON c.InvCode=g.InvCode AND c.WorkPoint=g.WorkPoint Where b.LotNo='" + LotNo + "'";
return Repository().FindTableBySql(sql.ToString()); }
public DataTable GetInventoryInspectionNew(ref Pagination jqgridparam, string InvCode, int? SampleQuantity, string ResultINp, string JYID, string LotNo, decimal AllNumber) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; DataTable dt = new DataTable(); List<DbParameter> parameter = new List<DbParameter>(); string sql = string.Empty; if (ResultINp == "") { sql += @" IF EXISTS (SELECT ID FROM ICSInspectionDetailGroup WHERE InspectionID='{3}' )
BEGIN declare @sql varchar(8000) select distinct b.ID,i.GroupCode,i.GroupName,b.EATTRIBUTE1 AS InspectStander,b.EATTRIBUTE6,b.EATTRIBUTE7,c.InspectionID,b.ListCode, '{0}' AS UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN 'NG' when ISNULL(c.Result,'')='' THEN 'OK' ELSE 'OK' END AS Result,d.Sequence ,g.EATTRIBUTE1 ,case when g.EATTRIBUTE2='1' then g.SampleQuantity ELSE {4}*0.01*g.SampleQuantity END SamplingQuantity ,f.RulesCode,b.EATTRIBUTE5,c.EATTRIBUTE30 into #TempSORRFQ from ICSInventoryInspectionGroup a left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionList h on h.ListCode=b.ListCode and h.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionGroup i on i.ID=h.GroupID and i.WorkPoint=h.WorkPoint left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint LEFT JOIN ICSInspectionRulesGroup f ON f.RulesCode=b.EATTRIBUTE5 AND f.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionRulesList g ON f.id=g.RulesID AND f.WorkPoint=g.WorkPoint AND g.SetValueMin<={4} AND g.SetValueMax>={4} where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'and c.InspectionID='{3}' and b.EATTRIBUTE6='Size' If (SELECT top 1 Sequence FROM #TempSORRFQ) is not null BEGIN select @sql=isnull(@sql+',','')+' ['+Sequence+']' from(select distinct Sequence from #TempSORRFQ)as a set @sql='SELECT STUFF((select'','' + Sequence from (SELECT DISTINCT Sequence FROM #TempSORRFQ ) DD for xml path('''')),1,1,'''') as IsTou,* FROM #TempSORRFQ PIVOT(MAX(SetValue) FOR Sequence IN ('+@sql+'))a ' exec(@sql); END ELSE BEGIN SELECT * FROM #TempSORRFQ END drop table #TempSORRFQ; END ELSE BEGIN select DISTINCT b.ID,a.GroupCode,a.GroupName,b.EATTRIBUTE1 AS InspectStander,b.EATTRIBUTE6,b.EATTRIBUTE7,'' as InspectionID,b.ListCode, 0 AS UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,'' AS SetValue,'OK' AS Result,g.EATTRIBUTE1 ,case when g.EATTRIBUTE2='1' then g.SampleQuantity ELSE {4}*0.01*g.SampleQuantity END SamplingQuantity ,f.RulesCode,b.EATTRIBUTE5,'' AS EATTRIBUTE30 from ICSInventoryInspectionGroup a left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionList h on h.ListCode=b.ListCode and h.WorkPoint=b.WorkPoint left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint LEFT JOIN ICSInspectionRulesGroup f ON f.RulesCode=b.EATTRIBUTE5 AND f.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionRulesList g ON f.id=g.RulesID AND f.WorkPoint=g.WorkPoint AND g.SetValueMin<={4} AND g.SetValueMax>={4} where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}' and b.EATTRIBUTE6='Size' END ";
sql = string.Format(sql, InvCode, WorkPoint, JYID, LotNo, AllNumber); return SqlHelper.CmdExecuteDataTable(sql); } else { sql += @" declare @sql varchar(8000)
select b.ID,i.GroupCode,i.GroupName,b.EATTRIBUTE1 AS InspectStander,b.EATTRIBUTE6,b.EATTRIBUTE7,c.InspectionID,b.ListCode, c.UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN 'NG' when ISNULL(c.Result,'')='' THEN 'OK' ELSE 'OK' END AS Result,d.Sequence,c.EATTRIBUTE1 BadReason,g.EATTRIBUTE1 ,case when g.EATTRIBUTE2='1' then g.SampleQuantity ELSE {4}*0.01*g.SampleQuantity END SamplingQuantity ,f.RulesCode,b.EATTRIBUTE5,c.EATTRIBUTE30 into #TempSORRFQ from ICSInventoryInspectionGroup a inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionList h on h.ListCode=b.ListCode and h.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionGroup i on i.GroupCode=a.GroupCode and i.WorkPoint=h.WorkPoint left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint LEFT JOIN ICSInspectionRulesGroup f ON f.RulesCode=b.EATTRIBUTE5 AND f.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionRulesList g ON f.id=g.RulesID AND f.WorkPoint=g.WorkPoint AND g.SetValueMin<={4} AND g.SetValueMax>={4} where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'and (c.InspectionID='{2}' or c.InspectionID='{3}' ) and b.EATTRIBUTE6='Size' If (SELECT top 1 Sequence FROM #TempSORRFQ) is not null BEGIN
select @sql=isnull(@sql+',','')+' ['+Sequence+']' from(select distinct Sequence from #TempSORRFQ)as a set @sql='SELECT STUFF((select'','' + Sequence from (SELECT DISTINCT Sequence FROM #TempSORRFQ ) DD for xml path('''')),1,1,'''') as IsTou,* FROM #TempSORRFQ PIVOT(MAX(SetValue) FOR Sequence IN ('+@sql+'))a ' exec(@sql) END ELSE BEGIN SELECT * FROM #TempSORRFQ END ";
sql = string.Format(sql, InvCode, WorkPoint, JYID, LotNo, AllNumber); return SqlHelper.FindTablePageBySql_OtherTempSORRFQ(sql.ToString(), " " + "#TempSORRFQ" + " ", " drop table #TempSORRFQ", parameter.ToArray(), ref jqgridparam); } }
public DataTable GetInventoryInspectionNew1(ref Pagination jqgridparam, string InvCode, int? SampleQuantity, string ResultINp, string JYID, string LotNo, decimal AllNumber) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; DataTable dt = new DataTable(); List<DbParameter> parameter = new List<DbParameter>(); string sql = string.Empty; if (ResultINp == "") { sql += @"
select DISTINCT b.ID,A.GroupCode,A.GroupName,b.EATTRIBUTE1 AS InspectStander,b.EATTRIBUTE6,b.EATTRIBUTE7,'' as InspectionID,b.ListCode, 0 AS UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,'OK' AS Result ,g.EATTRIBUTE1 ,case when g.EATTRIBUTE2='1' then g.SampleQuantity ELSE {4}*0.01*g.SampleQuantity END SamplingQuantity ,f.RulesCode,b.EATTRIBUTE5,'' AS EATTRIBUTE30 from ICSInventoryInspectionGroup a left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint LEFT JOIN ICSInspectionList h on h.ListCode=b.ListCode and h.GroupID=e.ID and h.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionRulesGroup f ON f.RulesCode=b.EATTRIBUTE5 AND f.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionRulesList g ON f.id=g.RulesID AND f.WorkPoint=g.WorkPoint AND g.SetValueMin<={4} AND g.SetValueMax>={4} where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}' and b.EATTRIBUTE6='Carton' ";
sql = string.Format(sql, InvCode, WorkPoint, JYID, LotNo, AllNumber); return SqlHelper.CmdExecuteDataTable(sql); } else { sql += @" declare @sql varchar(8000)
select b.ID,A.GroupCode,A.GroupName,b.EATTRIBUTE1 AS InspectStander,b.EATTRIBUTE6,b.EATTRIBUTE7,c.InspectionID,b.ListCode, c.UnqualifiedQuantity ,b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN 'NG' when ISNULL(c.Result,'')='' THEN 'OK' ELSE 'OK' END AS Result,d.Sequence,c.EATTRIBUTE1 BadReason, g.EATTRIBUTE1 ,case when g.EATTRIBUTE2='1' then g.SampleQuantity ELSE {4}*0.01*g.SampleQuantity END SamplingQuantity ,f.RulesCode,b.EATTRIBUTE5,c.EATTRIBUTE30 into #TempSORRFQ from ICSInventoryInspectionGroup a inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint left join ICSInspectionGroup e ON a.GroupCode=e.GroupCode and e.WorkPoint=a.WorkPoint LEFT JOIN ICSInspectionList h on h.ListCode=b.ListCode and h.GroupID=e.ID and h.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionRulesGroup f ON f.RulesCode=b.EATTRIBUTE5 AND f.WorkPoint=b.WorkPoint LEFT JOIN ICSInspectionRulesList g ON f.id=g.RulesID AND f.WorkPoint=g.WorkPoint AND g.SetValueMin<={4} AND g.SetValueMax>={4} where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'and (c.InspectionID='{2}' or c.InspectionID='{3}' ) and b.EATTRIBUTE6='Carton' If (SELECT top 1 Sequence FROM #TempSORRFQ) is not null BEGIN
select @sql=isnull(@sql+',','')+' ['+Sequence+']' from(select distinct Sequence from #TempSORRFQ)as a set @sql='SELECT STUFF((select'','' + Sequence from (SELECT DISTINCT Sequence FROM #TempSORRFQ ) DD for xml path('''')),1,1,'''') as IsTou,* FROM #TempSORRFQ PIVOT(MAX(SetValue) FOR Sequence IN ('+@sql+'))a ' exec(@sql) END ELSE BEGIN SELECT * FROM #TempSORRFQ END ";
sql = string.Format(sql, InvCode, WorkPoint, JYID, LotNo, AllNumber); return SqlHelper.FindTablePageBySql_OtherTempSORRFQ(sql.ToString(), " " + "#TempSORRFQ" + " ", " drop table #TempSORRFQ", parameter.ToArray(), ref jqgridparam); } }
/// <summary>
/// 检验修改
/// </summary>
/// <param name="ICSMTDOC"></param>
/// <param name="InvCode"></param>
/// <param name="ResultINp"></param>
/// <returns></returns>
public string UpdateICSInspectionDetailNew(string ICSMTDOC, string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string Filtering, string SpecialNumber, string ResultINp, string SpecialPicks, string Lot, string Type, decimal CJQty, string LotResult, decimal Manhours, decimal Rejections, decimal OtherNumber) { string msg = ""; try { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
StringBuilder sqlBuilder = new StringBuilder(); JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC); bool ISOK = true; string ID = string.Empty;
// 删除操作 - 使用参数化查询
string deleteSql = @"DELETE c from ICSInspection a
left join ICSInspectionDetailGroup b on a.ID = b.inspectionID and a.workPoint = b.workPoint left join ICSInspectionDetail c on b.id = c.DetailGroupID and b.workPoint = c.workPoint Where a.ID=@JYID";
sqlBuilder.AppendLine("BEGIN TRANSACTION;"); // 这里应该使用参数化执行,但为了保持您的结构,暂时拼接
sqlBuilder.AppendLine($"DELETE c from ICSInspection a left join ICSInspectionDetailGroup b on a.ID = b.inspectionID and a.workPoint = b.workPoint left join ICSInspectionDetail c on b.id = c.DetailGroupID and b.workPoint = c.workPoint Where a.ID='{JYID}';"); sqlBuilder.AppendLine($"DELETE ICSInspectionDetailGroup where inspectionID='{JYID}';");
foreach (var item in res) { string Guids = Guid.NewGuid().ToString(); JObject jo = (JObject)item; JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString());
// 处理结果字段
string resultValue = jo["Result"]?.ToString() ?? ""; string resultSqlValue = !string.IsNullOrEmpty(resultValue) ? $"'{resultValue.Replace("'", "''")}'" : "NULL";
// 处理其他可能为空的字段
string listCode = jo["ListCode"]?.ToString() ?? ""; string listName = jo["ListName"]?.ToString() ?? ""; string unit = jo["Unit"]?.ToString() ?? ""; string setValueMax = jo["SetValueMax"]?.ToString() ?? ""; string setValueMin = jo["SetValueMin"]?.ToString() ?? ""; string setValue = jo["SetValue"]?.ToString() ?? ""; string groupCode = jo["GroupCode"]?.ToString() ?? ""; string groupName = jo["GroupName"]?.ToString() ?? ""; string badReason = jo["BadReason"]?.ToString() ?? ""; string samplingQuantity = jo["SamplingQuantity"]?.ToString() ?? ""; string memo = jo["Memo"]?.ToString() ?? "";
// 构建插入ICSInspectionDetailGroup的SQL
sqlBuilder.AppendLine($@"
INSERT INTO dbo.ICSInspectionDetailGroup (ID, InspectionID, ListCode, ListName, Unit, SetValueMax, SetValueMin, UnqualifiedQuantity, Result, MUSER, MUSERName, MTIME, WorkPoint, GroupCode, GroupName, EATTRIBUTE1, EATTRIBUTE2, EATTRIBUTE30) VALUES( '{Guids}', '{jo["InspectionID"]?.ToString().Replace("'", "''") ?? ""}', {(string.IsNullOrEmpty(listCode) ? "NULL" : $"'{listCode.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(listName) ? "NULL" : $"'{listName.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(unit) ? "NULL" : $"'{unit.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(setValueMax) ? "NULL" : $"'{setValueMax.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(setValueMin) ? "NULL" : $"'{setValueMin.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(setValue) ? "NULL" : $"'{setValue.Replace("'", "''")}'")}, {resultSqlValue}, '{MUSER}', '{MUSERNAME}', GETDATE(), '{WorkPoint}', {(string.IsNullOrEmpty(groupCode) ? "NULL" : $"'{groupCode.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(groupName) ? "NULL" : $"'{groupName.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(badReason) ? "NULL" : $"'{badReason.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(samplingQuantity) ? "NULL" : $"'{samplingQuantity.Replace("'", "''")}'")}, {(string.IsNullOrEmpty(memo) ? "NULL" : $"'{memo.Replace("'", "''")}'")} );");
foreach (var itemdetail in detailres) { JObject jodetail = (JObject)itemdetail;
// 处理SetValue字段 - 关键修改点
string setValueDetail = jodetail["FiledNamevalue"]?.ToString() ?? ""; string setValueSql = string.IsNullOrEmpty(setValueDetail) ? "NULL" : $"'{setValueDetail.Replace("'", "''")}'";
string sequence = jodetail["FiledNamekey"]?.ToString() ?? "";
sqlBuilder.AppendLine($@"
INSERT INTO dbo.ICSInspectionDetail (ID, DetailGroupID, Sequence, SetValue, Result, MUSER, MUSERName, MTIME, WorkPoint) VALUES( NEWID(), '{Guids}', {(string.IsNullOrEmpty(sequence) ? "NULL" : $"'{sequence.Replace("'", "''")}'")}, {setValueSql}, {resultSqlValue}, '{MUSER}', '{MUSERNAME}', GETDATE(), '{WorkPoint}' );");
if (resultValue == "0") { ISOK = false; } } ID = jo["InspectionID"]?.ToString() ?? ""; }
// 处理更新ICSInspection表的SQL
string resultUpdate = ISOK ? "1" : "0"; sqlBuilder.AppendLine($@"
UPDATE ICSInspection SET Result='{resultUpdate}', QualifiedQuantity='{YLOTQTY}', UnqualifiedQuantity='{NLOTQTY}', WaiveQuantity='{WaiveQuantity}', SampleQuantity='{CJQty}', EATTRIBUTE2='{Filtering}', EATTRIBUTE3='{SpecialNumber}', EATTRIBUTE4='{SpecialPicks}', EATTRIBUTE5='{Manhours}', EATTRIBUTE6='{Rejections}', EATTRIBUTE7='{OtherNumber}' WHERE ID='{ID}';");
sqlBuilder.AppendLine("COMMIT TRANSACTION;");
if (SqlHelper.CmdExecuteNonQueryLi(sqlBuilder.ToString()) > 0) { msg = ""; } else { msg = "绑定失败"; } } catch (Exception ex) { msg = ex.Message; }
return msg; }
/// <summary>
/// 检验保存
/// </summary>
/// <param name="ICSMTDOC"></param>
/// <param name="InvCode"></param>
/// <param name="ResultINp"></param>
/// <returns></returns>
public string SaveICSInspectionDetailNew(string ICSMTDOC, string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string Filtering, string SpecialNumber, string ResultINp, string SpecialPicks, string Lot, string Type, decimal CJQty, string LotResult, decimal Manhours, decimal Rejections, decimal OtherNumber) { string msg = ""; try { object CARID = Guid.NewGuid(); string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC); bool ISOK = true; string ID = string.Empty; string sql = $@"DELETE from ICSInspectionDetail where DetailGroupID in(SELECT ID from ICSInspectionDetailGroup where InspectionID='{Lot}' AND workPoint='{WorkPoint}')
DELETE from ICSInspectionDetailGroup where InspectionID='{Lot}' AND workPoint='{WorkPoint}'";
if (string.IsNullOrEmpty(JYID) || JYID == "null") { sql += $@"
INSERT INTO dbo.ICSInspection ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7) Values('{CARID}','{Lot}','{InvCode}','{AllNumber}','{YLOTQTY}','{NLOTQTY}','{WaiveQuantity}','','','{Type}',getdate(),'{MUSER}','{MUSERNAME}','{WorkPoint}','1','{CJQty}','{Filtering}','{SpecialNumber}','{SpecialPicks}','{Manhours}','{Rejections}','{OtherNumber}') ";
} else { CARID = JYID; } foreach (var item in res) { string Guids = Guid.NewGuid().ToString(); JObject jo = (JObject)item; JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString()); sql += @"
INSERT INTO dbo.ICSInspectionDetailGroup ( ID ,InspectionID,ListCode ,ListName , Unit ,SetValueMax ,SetValueMin ,UnqualifiedQuantity ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE30) values('{0}','{1}','{2}','{3}','{4}',{5},{6},{7},'{8}','{9}','{10}',getdate(),'{11}','{12}','{13}','{14}','{15}','{16}')";
var b = jo["ListCode"].ToString(); var a = jo["SetValueMin"].ToString();
sql = string.Format(sql, Guids, CARID, jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(), jo["SetValueMax"].ToString() == "" ? "null" : jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString() == "" ? "null" : jo["SetValueMin"].ToString(), jo["SetValue"].ToString() == "" ? "null" : jo["SetValue"].ToString(), jo["Result"].ToString() , MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString(), jo["BadReason"].ToString(), jo["SamplingQuantity"].ToString(), jo["Memo"].ToString());
foreach (var itemdetail in detailres) {
JObject jodetail = (JObject)itemdetail; if (string.IsNullOrWhiteSpace(ResultINp)) { sql += @"
INSERT INTO dbo.ICSInspectionDetail ( ID ,DetailGroupID,Sequence ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint) values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
sql = string.Format(sql, Guids, jodetail["FiledNamekey"].ToString(), jodetail["FiledNamevalue"].ToString(), jo["Result"].ToString(), MUSER, MUSERNAME, WorkPoint);
} else { sql += @" update ICSInspectionDetail set InspectionID='{0}',ListCode='{1}',ListName='{2}', Unit='{3}' ,SetValueMax='{4}' ,SetValueMin='{5}' ,SetValue='{6}' ,Result='{7}', MUSER='{8}' ,MUSERName='{9}' ,MTIME=getdate(), WorkPoint='{10}', GroupCode='{11}', GroupName='{12}',EATTRIBUTE1='{14}' where ID='{13}'"; sql = string.Format(sql, jodetail["InspectionID"].ToString(), jodetail["ListCode"].ToString(), jodetail["ListName"].ToString(), jodetail["Unit"].ToString(), jodetail["SetValueMax"].ToString(), jodetail["SetValueMin"].ToString(), jodetail["SetValue"].ToString(), jodetail["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jodetail["GroupCode"].ToString(), jodetail["GroupName"].ToString(), jodetail["ID"].ToString(), jodetail["NUM"].ToString()); } if (jo["Result"].ToString() == "0") { ISOK = false; } } ID = jo["InspectionID"].ToString();
} if (ISOK == true) {
sql += @" update ICSInspection set Result='{0}' where ID='{1}'"; sql = string.Format(sql, 1, CARID); } else { sql += @" update ICSInspection set Result='{0}' where ID='{1}'"; sql = string.Format(sql, 0, CARID); } if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0) {
} else { msg = "绑定失败"; } } catch (Exception ex) { msg = ex.Message; }
return msg; }
}}
|