using Dapper;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Linq;
|
using System.Web;
|
using VueWebApi.Tools;
|
|
namespace VueWebApi.DLL.DAL
|
{
|
public class AppQualityManagementDAL
|
{
|
public static DataTable dt; //定义全局变量dt
|
public static bool res; //定义全局变量dt
|
public static ToMessage mes = new ToMessage(); //定义全局返回信息对象
|
public static string strProcName = ""; //定义全局sql变量
|
public static List<SqlParameter> listStr = new List<SqlParameter>(); //定义全局参数集合
|
public static SqlParameter[] parameters; //定义全局SqlParameter参数数组
|
|
#region[入厂检验,扫描采购到货生成标签]
|
public static ToMessage InFactoryCheckScanLabCode(string labcode)
|
{
|
string sql = "";
|
var dynamicParams = new DynamicParameters();
|
Dictionary<string, object> list = new Dictionary<string, object>();
|
try
|
{
|
//判断条码是否有效(采购到货功能编码:2060)
|
sql = @"select * from T_BarCodeBill where hbarcode=@labcode and rightcode=@rightcode and hbarcodestatus='Y'";
|
dynamicParams.Add("@labcode", labcode);
|
dynamicParams.Add("@rightcode", "2060");
|
var data0 = DapperHelper.selectdata(sql, dynamicParams);
|
if (data0.Rows.Count <= 0)
|
{
|
mes.code = "300";
|
mes.count = 0;
|
mes.Message = "不是有效的标签条码!";
|
mes.data = null;
|
return mes;
|
}
|
//判断条码是否检验
|
sql = @"select * from TStepCheckRecord where hbarcode=@labcode and check_type='InCheck'";
|
dynamicParams.Add("@labcode", labcode);
|
var data = DapperHelper.selectdata(sql, dynamicParams);
|
if (data0.Rows.Count > 0)
|
{
|
mes.code = "300";
|
mes.count = 0;
|
mes.Message = "此标签条码已检验!";
|
mes.data = null;
|
return mes;
|
}
|
//获取标签信息
|
sql = @"select A.hbillno,A.hmaterialcode as partcode,M.partname,M.partspec,A.hbarcode,M.stocktype_code,A.hqty,
|
A.hcustomercode,C.name as hcustomername,A.hbatchno,A.qualitystatus
|
from T_BarCodeBill A
|
left join TMateriel_Info M on A.hmaterialcode=M.partcode
|
left join TCustomer C on A.hcustomercode=C.code
|
where A.hbarcode=@labcode";
|
dynamicParams.Add("@labcode", labcode);
|
var data1 = DapperHelper.selectdata(sql, dynamicParams);
|
if (data1.Rows.Count > 0)
|
{
|
//获取绑定的入厂质检方案、抽样方式、样本数
|
sql = @"select code as checkstandcode,name as checkstandname,sampmethod,sampscare
|
from TStepCheckStandard
|
where PATINDEX('%;' + RTRIM(@partcode) + ';%',';' + suitpart + ';')>0 or PATINDEX('%;' + RTRIM(@stocktype_code) + ';%',';' + suitpart + ';')>0
|
and checktype='InCheck'";
|
dynamicParams.Add("@partcode", data1.Rows[0]["partcode"].ToString());//物料编码
|
dynamicParams.Add("@stocktype_code", data1.Rows[0]["stocktype_code"].ToString());//存货类型编码
|
var data2 = DapperHelper.selectdata(sql, dynamicParams);
|
list.Add("labcont", data1);
|
list.Add("chekstand", data2);
|
mes.code = "200";
|
mes.count = 0;
|
mes.Message = "查询成功!";
|
mes.data = list;
|
}
|
else
|
{
|
mes.code = "300";
|
mes.Message = "此标签条码不存在!";
|
mes.data = null;
|
}
|
}
|
catch (Exception e)
|
{
|
mes.code = "300";
|
mes.count = 0;
|
mes.Message = e.Message;
|
mes.data = null;
|
}
|
return mes;
|
}
|
#endregion
|
|
#region[入厂检验,根据选择的检验方案查找检验项目]
|
public static ToMessage InFactoryCheckItem(string checkstandcode)
|
{
|
string sql = "";
|
var dynamicParams = new DynamicParameters();
|
try
|
{
|
//质检方案编码获取检验项
|
sql = @"select A.stepcheckitem_seq, B.code,B.name,A.required,A.numberjudge,A.unit,A.decimalnum,
|
A.standvalue,A.uppervalue,A.lowervalue,A.stepcheckitem_desc
|
from TStepCheckStandardSub A
|
left join TStepCheckItem B on A.stepcheckitem_code=B.code
|
where A.stepstaned_code=@checkstandcode
|
order by A.stepcheckitem_seq";
|
dynamicParams.Add("@checkstandcode", checkstandcode);//质检方案编码
|
var data = DapperHelper.selectdata(sql, dynamicParams);
|
if (data.Rows.Count > 0)
|
{
|
mes.code = "200";
|
mes.count = 0;
|
mes.Message = "查询成功!";
|
mes.data = data;
|
}
|
else
|
{
|
mes.code = "300";
|
mes.count = 0;
|
mes.Message = "当前质检方案无检验项!";
|
mes.data = null;
|
}
|
}
|
catch (Exception e)
|
{
|
mes.code = "300";
|
mes.count = 0;
|
mes.Message = e.Message;
|
mes.data = null;
|
}
|
return mes;
|
}
|
|
#endregion
|
}
|
}
|