using DAL;
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using SQLHelper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI;
using WebAPI.Models;
using WebAPI.Service;
namespace WebAPI.Controllers
{
public class MouldController : ApiController
{
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
public DataSet ds = new DataSet();
private json objJsonResult = new json();
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
#region 器具扫码模块调用方法
#region 器具扫码模块 扫描器具条码调用方法
///
/// 扫描器具条码
///
///
[Route("MouldController/Get_CheckTypeByMouldBarCode_Json")]
[HttpGet]
public object Get_CheckTypeByMouldBarCode_Json(string sBarCode, Int64 HInterID, string HBillType, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, bool HRedBlueFlag, string HSourceBillNo, string HSourceBillType, Int64 HStockOrgID, Int64 HStockOutOrgID)
{
Int64 HBarCodeQty = 0; //允许扫描条码个数(0、1、2、3.....,其中0为不控制)
#region 获取系统参数
string sErrMsg = "";
if (oSystemParameter.ShowBillByOrgID(HStockOrgID, ref sErrMsg) == true)
{
//器具采购入库单
if (HBillType == "3801")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdInBill_BarCodeQty);
}
//器具领用出库单
else if (HBillType == "3802")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdOutBill_BarCodeQty);
}
//器具领用退库单
else if (HBillType == "3803")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdBackBill_BarCodeQty);
}
//器具改制出库单
else if (HBillType == "3825")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldRepairOutBill_BarCodeQty);
}
//器具改制入库单
else if (HBillType == "3826")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldRepairInBill_BarCodeQty);
}
//器具其他入库单
else if (HBillType == "3827")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldOtherInBill_BarCodeQty);
}
//器具其他出库单
else if (HBillType == "3828")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldOtherOutBill_BarCodeQty);
}
//器具暂借入库单
else if (HBillType == "3829")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldBorrowInBill_BarCodeQty);
}
//器具暂借出库单
else if (HBillType == "3830")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldBorrowOutBill_BarCodeQty);
}
//器具报废入库单
else if (HBillType == "3831")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldScrapInBill_BarCodeQty);
}
//器具报废出库单
else if (HBillType == "3832")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldScrapOutBill_BarCodeQty);
}
//器具直接调拨单
else if (HBillType == "3814")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdMoveBill_BarCodeQty);
}
//器具分步调出单
else if (HBillType == "3840")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldMoveStockStepOutBill_BarCodeQty);
}
//器具分步调入单
else if (HBillType == "3841")
{
HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldMoveStockStepInBill_BarCodeQty);
}
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "获取系统参数失败! " + sErrMsg;
objJsonResult.data = null;
return objJsonResult;
}
#endregion
try
{
ds = oCn.RunProcReturn("exec h_p_WMS_CheckMouldBarCode_Add '" + sBarCode + "'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID.ToString() + "," + HSPID.ToString() + "," + HSCWhID.ToString() + "," + HSCSPID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HRedBlueFlag + "','" + HMaker + "'," + HStockOrgID.ToString() + "," + HStockOutOrgID.ToString() + "," + HBarCodeQty.ToString(), "h_p_WMS_CheckMouldBarCode_Add");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "将器具信息写入器具出入库临时表失败!";
objJsonResult.data = null;
return objJsonResult;
}
else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
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("MouldController/GetMouldBillEntryTmpList_Json")]
[HttpGet]
public object GetMouldBillEntryTmpList_Json(Int64 HInterID, string HBillNo, string HBillType)
{
try
{
ds = oCn.RunProcReturn("exec h_p_WMS_MouldBillEntryTmpList " + HInterID.ToString() + ",'" + HBillType + "'", "h_p_WMS_MouldBillEntryTmpList");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "没有返回任何记录!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
List