using DBUtility;
|
using Model;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Web;
|
using System.Web.Http;
|
using System.Windows.Forms;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers.品质管理.产线返修平台
|
{
|
public class Sc_SourceLineRepairBillController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
public DAL.ClsSc_ICMOBillQualityStatus_Tmp BillOld = new DAL.ClsSc_ICMOBillQualityStatus_Tmp();
|
string user_LongShan = "";
|
string HName_LongShan = "";
|
|
#region 产线质检平台 保存
|
/// <summary>
|
/// 新增单据-保存按钮
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Sc_ICMOBillQualityStatus_Tmp/AddICMOBillQualityStatus_Tmp")]
|
[HttpPost]
|
public object AddICMOBillQualityStatus_Tmp([FromBody] JObject sMainSub)
|
{
|
try
|
{
|
//获取参数
|
var _value = sMainSub["sMainSub"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString(); //表头数据
|
int HSaveType = int.Parse(sArray[1].ToString()); //保存类型 1:不良品保存 2:报废保存
|
string user = sArray[2].ToString(); //操作用户的用户名
|
string HComputerName = SystemInformation.ComputerName; //设备名称
|
|
////判断是否有新增权限
|
//if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBillQualityStatus_Tmp_Edit", 1, false, user))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "无新增权限!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
msg2 = "[" + msg2.ToString() + "]";
|
List<Model.ClsSc_ICMOBillQualityStatus_Tmp> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_ICMOBillQualityStatus_Tmp>>(msg2);
|
BillOld.omodel = mainList[0];
|
if (HSaveType == 1)
|
{
|
BillOld.omodel.HSaveType = "不良品保存";
|
}
|
else if (HSaveType == 2)
|
{
|
BillOld.omodel.HSaveType = "报废品保存";
|
}
|
|
if (!BillOld.AddBill1(ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 产线质检平台 获取表头信息
|
[Route("Sc_ICMOBillQualityStatus_Tmp/getMainInfo")]
|
[HttpGet]
|
public object getMainInfo(string Czybm, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//查看权限
|
//if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "无查看权限!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
string sql = "exec h_p_Sc_ICMOBillQualityStatus_Tmp_Init '" + Czybm + "'";
|
ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOBillQualityStatus_Tmp_Init");
|
|
if(ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未找到相关数据!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 产线质检平台 获取子表信息
|
[Route("Sc_ICMOBillQualityStatus_Tmp/getSubInfo")]
|
[HttpGet]
|
public object getSubInfo(string HSplitNo, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//查看权限
|
//if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "无查看权限!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
string sql = @"select
|
a.HInterID, a.HDate 日期, a.HMaterID, b.HName 产品名称, a.HBarCode 条形码, a.HBadReasonID, c.HName 不良原因, a.HResult 判断结果
|
from Sc_ICMOBillQualityStatus_Tmp AS a
|
LEFT OUTER JOIN Gy_Material AS b on a.HMaterID = b.HItemID
|
LEFT OUTER JOIN Gy_BadReason AS c on a.HBadReasonID = c.HItemID
|
where a.HSplitNo = '" + HSplitNo + "' order by a.HDate desc, a.HInterID desc" ;
|
ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOBillQualityStatus_Tmp_Init");
|
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 产线质检平台 子表删除
|
[Route("Sc_ICMOBillQualityStatus_Tmp/deleteSubInfo")]
|
[HttpGet]
|
public object deleteSubInfo(int HInterID, string user)
|
{
|
try
|
{
|
//查看权限
|
//if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "无查看权限!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
string sql = @"delete from Sc_ICMOBillQualityStatus_Tmp where HInterID = " + HInterID ;
|
oCN.RunProc(sql);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 产线质检平台 获取不良率占比分析图数据
|
[Route("Sc_ICMOBillQualityStatus_Tmp/getBadReasonRateInfo")]
|
[HttpGet]
|
public object getBadReasonRateInfo(int HICMOInterID, int HICMOEntryID)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//查看权限
|
//if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "无查看权限!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
string sql = @"select
|
a.HBadReasonID
|
,b.HName HBadReasonName
|
, COUNT(a.HBadReasonID) HBadReasonQty
|
from Sc_ICMOBillQualityStatus_Tmp AS a
|
LEFT OUTER JOIN Gy_BadReason as b on a.HBadReasonID = b.HItemID " +
|
"where a.HICMOInterID = " + HICMOInterID + " and a.HICMOEntryID = " + HICMOEntryID +
|
" and ISNULL(a.HBadReasonID,0)<> 0" +
|
" group by a.HBadReasonID,b.HName order by COUNT(a.HBadReasonID) desc";
|
|
ds = oCN.RunProcReturn(sql, "getBadReasonRateInfo");
|
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 产线质检平台 根据条形码获取信息
|
[Route("Sc_ICMOBillQualityStatus_Tmp/getBarCodeInfo")]
|
[HttpGet]
|
public object getBarCodeInfo(string HBarCode)
|
{
|
try
|
{
|
//查看权限
|
//if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "无查看权限!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
if(HBarCode == null || HBarCode == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "条形码不可为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
string sql = "select * from Gy_BarCodeBill where HBarCode = '" + HBarCode + "'";
|
ds = oCN.RunProcReturn(sql, "Gy_BarCodeBill");
|
|
if(ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "该条码不存在!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
}
|
}
|