using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Web.Http;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers.CJGL
|
{
|
public class Cj_SingleStationController : ApiController
|
{
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
|
#region 工序单品不良采集 用户查询关联字段
|
[Route("Cj_SingleStation/Cj_CollectionOfSingleProductDefectsUserList")]
|
[HttpGet]
|
public object Cj_CollectionOfSingleProductDefectsUserList(string sWhere, string user)
|
{
|
try
|
{
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = new DataTable();
|
return objJsonResult;
|
}
|
|
ds = oCN.RunProcReturn("select * from h_v_Cj_UserAssociationList where 1=1 "+sWhere, "h_v_Cj_UserAssociationList");
|
|
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
|
|
#region 工序单品不良采集 扫码查询
|
[Route("Cj_SingleStation/HBardCodeList")]
|
[HttpGet]
|
public object HBardCodeList(string HBarCode, string user)
|
{
|
try
|
{
|
|
ds = oCN.RunProcReturn(@"select * from h_v_Gy_BarCodeBillHICOMProcessExchange where 条码='" + HBarCode + "'", "h_v_Gy_BarCodeBillHICOMProcessExchange");
|
if (ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "条码查无数据!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "";
|
objJsonResult.data = ds.Tables[0];
|
}
|
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 工序单品不良采集 保存
|
[Route("Cj_SingleStation/ProcessBLSave")]
|
[HttpPost]
|
public object ProcessBLSave([FromBody] JObject sMainSub)
|
{
|
var _value = sMainSub["sMainSub"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString(); //主表数据
|
string HResult = sArray[1].ToString();
|
string user = sArray[2].ToString();
|
|
try
|
{
|
var msg3 = msg2.ToString();
|
msg2 = "[" + msg2.ToString() + "]";
|
List<Model.ClsSc_QualityReportBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_QualityReportBillMain>>(msg2);
|
|
long HInterID = mainList[0].HInterID;//递入type得到的单据ID
|
string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
|
DateTime HDate = DateTime.Now;//日期
|
string HRemark = mainList[0].HRemark;//备注
|
long HEmpID = mainList[0].HEmpID;//质检员
|
long HGroupID = mainList[0].HGroupID;//班组
|
long HDeptID = mainList[0].HDeptID;//车间
|
string HMaker = user;//制单人
|
|
ds = oCN.RunProcReturn("select * from Sc_QualityReportBillMain where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_QualityReportBillMain");
|
if (ds.Tables[0].Rows.Count != 0) {
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已存在!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.BeginTran();
|
|
if (ds.Tables[0].Rows.Count == 0)//新增
|
{
|
//主表
|
oCN.RunProc(@"Insert Into Sc_QualityReportBillMain
|
(HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate
|
,HYear,HPeriod,HRemark,HMaker,HMakeDate
|
,HEmpID,HGroupID,HDeptID)
|
values('3717','3717',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
|
"," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
|
",'" + HEmpID + "'," + HGroupID + "," + HDeptID + ") ");
|
|
}
|
|
//保存子表
|
objJsonResult = AddBillSub_NoTable(msg3, HInterID, HResult);
|
|
if (objJsonResult.code == "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = objJsonResult.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.Commit();
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = null;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
public json AddBillSub_NoTable(string msg3, long HInterID, string HResult)
|
{
|
Model.ClsSc_QualityReportBillSub oSub = Newtonsoft.Json.JsonConvert.DeserializeObject<Model.ClsSc_QualityReportBillSub>(msg3);
|
|
if (oSub.HMaterID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "物料不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.RunProc($@"Insert into Sc_QualityReportBillSub
|
(HInterID,HENTRYID,HBillNo_bak,HEmpID,HBarCode,HBadReasonID,HAddr,HMaker,HMakeDate
|
,HMaterID,HUnitID,HRemark,HSourceID,HICMOInterID,HICMOEntryID,HICMOBillNo,HReportType
|
,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
|
,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo)
|
values({HInterID},1,'{oSub.HBillNo_bak}',{oSub.HEmpID},'{oSub.HBarCode}',{oSub.HBadReasonID},'','{oSub.HMaker}','{oSub.HMakeDate}'
|
,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HICMOInterID},{oSub.HICMOEntryID},'{oSub.HICMOBillNo}',{oSub.HReportType}
|
,0,0,'','',0,0
|
,0,'{HResult}',{oSub.HProcExchInterID},{oSub.HProcExchEntryID},'{oSub.HProcExchBillNo}')");
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = null;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
#endregion
|
}
|
}
|