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
|
{
|
//首件检验单Controller
|
//数据库主表QC_FirstPieceCheckBillMain
|
//数据库子表QC_FirstPieceCheckBillSub
|
public class QC_FirstPieceCheckBillController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
|
#region 首件检验单保存
|
/// <summary>
|
/// 新增单据-保存按钮
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("QC_FirstPieceCheckBill/set_SaveBill")]
|
[HttpPost]
|
public object set_SaveBill([FromBody] JObject sMainSub)
|
{
|
var _value = sMainSub["sMainSub"].ToString();
|
string msg1 = _value.ToString();
|
//保存单据
|
return objJsonResult = AddBillMain(msg1);
|
}
|
|
public json AddBillMain(string msg1)
|
{
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();
|
string msg3 = sArray[1].ToString();
|
string OperationType = sArray[2].ToString().Trim();
|
bool bResult;
|
try
|
{
|
msg2 = "[" + msg2.ToString() + "]";
|
List<Model.ClsQC_FirstPieceCheckBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsQC_FirstPieceCheckBillMain>>(msg2);
|
DAL.ClsQC_FirstPieceCheckBill BillNew = new DAL.ClsQC_FirstPieceCheckBill();
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = mainList[0].HDate;//日期
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
BillNew.omodel.HYear = sYear;
|
BillNew.omodel.HPeriod = sPeriod;
|
//固定赋值=================================
|
BillNew.omodel.HInterID = mainList[0].HInterID;//递入type得到的单据ID
|
BillNew.omodel.HBillNo = mainList[0].HBillNo;//递入type得到的单据号
|
BillNew.omodel.HDate = HDate;
|
BillNew.omodel.HRemark = mainList[0].HRemark;//备注
|
BillNew.omodel.HMaker = mainList[0].HMaker;
|
BillNew.omodel.HSourceID = ClsPub.isLong(mainList[0].HSourceID);
|
BillNew.omodel.HICMOInterID = ClsPub.isLong(mainList[0].HICMOInterID);
|
BillNew.omodel.HICMOBillNo = ClsPub.isStrNull(mainList[0].HICMOBillNo);
|
BillNew.omodel.HICMOInterID = ClsPub.isLong(mainList[0].HICMOInterID);
|
BillNew.omodel.HICMOQty = ClsPub.isLong(mainList[0].HICMOQty);
|
BillNew.omodel.HProcExchInterID = ClsPub.isLong(mainList[0].HProcExchInterID);
|
BillNew.omodel.HProcExchEntryID = ClsPub.isLong(mainList[0].HProcExchEntryID);
|
BillNew.omodel.HProcExchBillNo = ClsPub.isStrNull(mainList[0].HProcExchBillNo);
|
BillNew.omodel.HProcExchQty = ClsPub.isLong(mainList[0].HProcExchQty);
|
BillNew.omodel.HMaterID = ClsPub.isLong(mainList[0].HMaterID);
|
BillNew.omodel.HFirstCheckEmp = ClsPub.isLong(mainList[0].HFirstCheckEmp);
|
BillNew.omodel.HLastResult = ClsPub.isBool(mainList[0].HLastResult);
|
BillNew.omodel.HMainSourceInterID = ClsPub.isLong(mainList[0].HMainSourceInterID);
|
BillNew.omodel.HMainSourceEntryID = ClsPub.isLong(mainList[0].HMainSourceEntryID);
|
BillNew.omodel.HMainSourceBillNo = ClsPub.isStrNull(mainList[0].HMainSourceBillNo);
|
BillNew.omodel.HMainSourceBillType = ClsPub.isStrNull(mainList[0].HMainSourceBillType);
|
BillNew.omodel.HBillStatus = 1;
|
List<Model.ClsQC_FirstPieceCheckBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsQC_FirstPieceCheckBillSub>>(msg3);
|
BillNew.DetailColl = new List<Model.ClsQC_FirstPieceCheckBillSub>();
|
for (int i = 0; i < subList.ToArray().Length; i++)
|
{
|
if (i >= 0)//HQty
|
{
|
Model.ClsQC_FirstPieceCheckBillSub oSub = new Model.ClsQC_FirstPieceCheckBillSub();
|
oSub.HEntryID = i+1;
|
oSub.HRemark = ClsPub.isStrNull(subList[i].HRemark);
|
oSub.HSourceInterID = ClsPub.isLong(subList[i].HSourceInterID);
|
oSub.HSourceEntryID = ClsPub.isLong(subList[i].HSourceEntryID);
|
oSub.HSourceBillType = ClsPub.isStrNull(subList[i].HSourceBillType);
|
oSub.HSourceBillNo = ClsPub.isStrNull(subList[i].HSourceBillNo);
|
oSub.HRelationQty = DBUtility.ClsPub.isDoule(subList[i].HRelationQty);
|
oSub.HRelationMoney = DBUtility.ClsPub.isDoule(subList[i].HRelationMoney);
|
oSub.HCloseMan = DBUtility.ClsPub.isStrNull(subList[i].HCloseMan);
|
oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(subList[i].HEntryCloseDate);
|
oSub.HCloseType = DBUtility.ClsPub.isBool(subList[i].HCloseType);
|
oSub.HQCCheckItemID = DBUtility.ClsPub.isLong(subList[i].HQCCheckItemID);
|
oSub.HQCStd = DBUtility.ClsPub.isStrNull(subList[i].HQCStd);
|
oSub.HUnit = DBUtility.ClsPub.isStrNull(subList[i].HUnit);
|
oSub.HQCNote = DBUtility.ClsPub.isStrNull(subList[i].HQCNote);
|
oSub.HResult = DBUtility.ClsPub.isStrNull(subList[i].HResult);
|
oSub.HMax = DBUtility.ClsPub.isStrNull(subList[i].HMax);
|
oSub.HMin = DBUtility.ClsPub.isStrNull(subList[i].HMin);
|
oSub.HAvg = DBUtility.ClsPub.isStrNull(subList[i].HAvg);
|
oSub.HBillNo_bak = DBUtility.ClsPub.isStrNull(mainList[0].HBillNo);
|
BillNew.DetailColl.Add(oSub);
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无明细行信息!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
//保存完毕后处理
|
if (OperationType.Equals("1") || OperationType.Equals("2"))
|
{
|
bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
|
}
|
else
|
{
|
bResult = BillNew.ModifyBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
|
}
|
//提示
|
if (bResult == true)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
//objJsonResult.Message = "单据存盘完毕!单据号:" + mainList[0].HBillNo.Trim();
|
objJsonResult.Message = ClsPub.sExeReturnInfo+"单据号:" + mainList[0].HBillNo.Trim();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!原因:" + ClsPub.sExeReturnInfo;
|
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 首件检验单根据源单类型获取信息-源单为生产状态临时表(3722)
|
/// <summary>
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("QC_FirstPieceCheckBill/get_ICMOBillStatus_Tmp")]
|
[HttpGet]
|
public object get_ICMOBillStatus_Tmp(int HInterID,int HEntryID,string HBillType)
|
{
|
try
|
{
|
if (HInterID == 0 || HBillType.Equals(""))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "参数不全,获取源单信息失败!HInterID:"+ HInterID+ ";HEntryID:"+ HEntryID + ";HBillType:"+ HBillType+";";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
ds = oCN.RunProcReturn("exec h_p_QC_GetInfoByICMOStatusBill " + HInterID + "," + HEntryID + "," + HBillType, "h_p_QC_GetInfoByICMOStatusBill");
|
}
|
if (ds == null || 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
|
//
|
}
|
}
|