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 WebAPI;
using WebAPI.Models;
using WebAPI.Service;
namespace WebAPI.Controllers
{
public class WEBSController : ApiController
{
public string sWhere = "";
public WebServer webserver = new WebServer();
public DataSet ds = new DataSet();
private json objjson = new json();
private json objJsonResult = new json();
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
public ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
public WebS.WebService1 oWebs = new WebS.WebService1();
public WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
#region 基础资料
#region 仓库资料
//根据仓库ID、组织ID,返回仓库信息
public Model.ClsGy_Warehouse_Model GetWhInfoByIDandOrg(long sHWhID, long HUSEORGID, ref string sErr)
{
DAL.ClsIF_Warehouse_View dal = new DAL.ClsIF_Warehouse_View();
if (dal.GetInfoByIDandOrgID(sHWhID, HUSEORGID))
{
return dal.omodel;
}
else
{
return null;
}
}
#endregion
#region 仓位资料
#endregion
#endregion
#region 删除条码出入库临时表记录
///
/// 删除条码出入库临时表记录
///
///
[Route("WEBSController/set_DelPonderationBillMain_Temp_InterIDAndSource_Json")]
[HttpPost]
public object set_DelPonderationBillMain_Temp_InterIDAndSource_Json(long HInterID, long HMaterID, long HAuxPropID, string HMTONo, long HSourceInterID, long HSourceEntryID, string HBillType)
{
try
{
if (oWebs.set_DelPonderationBillMain_Temp_InterIDAndSource(HInterID, HMaterID, HAuxPropID, HMTONo, HSourceInterID, HSourceEntryID, HBillType, ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //成功!
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败!
objJsonResult.data = null;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "删除条码出入库临时表记录失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 提交生单处理方法
#region 销售出库 上传生单
#region 销售出库 校验模式
///
/// 销售出库校验上传
///
///
[Route("WEBSController/set_SaveSellOutBill_BillCheck_Json")]
[HttpPost]
public object set_SaveSellOutBill_BillCheck_Json([FromBody] JObject oMain)
{
var _value = oMain["oMain"].ToString();
string msg1 = _value.ToString();
try
{
List lsmain = new List();
ListModels oListModels = new ListModels();
lsmain = oListModels.getSellOutBillMainByJson(msg1);
WebAPI.WebS.ClsKf_SellOutBillMain websLsmain = new WebS.ClsKf_SellOutBillMain();
websLsmain.HInterID = lsmain[0].HInterID;
websLsmain.HBillNo = lsmain[0].HBillNo;
websLsmain.HBillType = "1205";
websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
if (oWebs.set_SaveSellOutBill_BillCheck(websLsmain, ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //成功!
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败!
objJsonResult.data = null;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "销售出库校验失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#endregion
#region 生产补料 上传生单
#region 生产补料 校验模式
///
/// 生产补料校验上传
///
///
[Route("WEBSController/set_SaveMateReplenishOutBill_BillCheck_Json")]
[HttpPost]
public object set_SaveMateReplenishOutBill_BillCheck_Json([FromBody] JObject oMain)
{
var _value = oMain["oMain"].ToString();
string msg1 = _value.ToString();
try
{
List lsmain = new List();
ListModels oListModels = new ListModels();
lsmain = oListModels.getMateReplenishOutBillMainByJson(msg1);
WebAPI.WebS.ClsKf_MateReplenishOutBillMain websLsmain = new WebS.ClsKf_MateReplenishOutBillMain();
websLsmain.HInterID = lsmain[0].HInterID;
websLsmain.HBillNo = lsmain[0].HBillNo;
websLsmain.HBillType = "1254";
websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
if (oWebs.set_SaveMateReplenishOutBill_BillCheck(websLsmain, ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //成功!
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败!
objJsonResult.data = null;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "生产补料校验失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#endregion
#endregion
#region 源单条码处理方法
#region 生产入库 扫描源单条码
///
/// 生产入库 扫描源单条码
///
///
[Route("WEBSController/Get_SourceBarCode_ProductIn_Json")]
[HttpGet]
public object get_SourceBarCode_ProductIn_Json(Int64 HInterID, string HBillNo, string HBillType, string HSourceBillNo, string HSourceBillType, string HMaker, Int64 HStockOrgID)
{
try
{
WebSoBar = oWebs.get_SourceBarCode_ProductIn(HInterID, HBillNo, HBillType, HSourceBillNo, HSourceBillType, HMaker, HStockOrgID, ref DBUtility.ClsPub.sErrInfo);
if (WebSoBar == null)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功";
objJsonResult.data = WebSoBar;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "扫描源单条码失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 生产领料 扫描源单条码
#endregion
#region 销售出库 扫描源单条码
///
/// 销售出库 扫描源单条码
///
///
[Route("WEBSController/Get_SourceBarCode_SellOut_Json")]
[HttpGet]
public object get_SourceBarCode_SellOut_Json(Int64 HInterID, string HBillNo, string HBillType, string HSourceBillNo, string HSourceBillType, string HMaker, Int64 HFIFOWhID, Int64 HOWNERID)
{
try
{
WebSoBar = oWebs.get_SourceBarCode_SellOut(HInterID, HBillNo, HBillType, HSourceBillNo, HSourceBillType, HMaker, HFIFOWhID, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
if (WebSoBar == null)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功";
objJsonResult.data = WebSoBar;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "扫描源单条码失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 委外出库 扫描源单条码
#endregion
#region 直接调拨 扫描源单条码
#endregion
#region 分步式调出 扫描源单条码
#endregion
#region 分步式调入 扫描源单条码
#endregion
#endregion
#region 物料条码处理方法
///
/// 物料条码文本框 扫码调用
///
///
[Route("WEBSController/Get_BarCode_Json")]
[HttpGet]
public Object get_BarCode_Json(string sBarCode, Int64 HInterID, string HBillType, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Double HQty, bool HRedBlueFlag, bool SourceFlag, string HSourceBillNo, string HSourceBillType, Int64 HStockOrgID, string HScanStyle, string HCustom1, string HCustom2)
{
try
{
WebSoBar = oWebs.get_BarCode(sBarCode, HInterID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HStockOrgID, HScanStyle, HCustom1, HCustom2, ref DBUtility.ClsPub.sErrInfo);
if (WebSoBar == null)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功";
objJsonResult.data = WebSoBar;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "扫描条码失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 单据新增模块 获取单据列表信息处理方法
///
/// 获取单据列表信息
///
///
[Route("WEBSController/GetBillEntryTmpList_Json")]
[HttpGet]
public object GetBillEntryTmpList(long HInterID, string HBillNo, string HBillType, Int64 HStockOrgID, string sMouldManagerCtl, string sFIFOCtl)
{
try
{
string sSimpleMode = "N"; //是否启用扫码简易模式,只显示已扫码源单记录(Y,N)
string sReturn = "";
//获取系统参数
if (oSystemParameter.ShowBillByOrgID(HStockOrgID, ref sReturn) == true)
{
//判断是否启用器具管理(Y,N)
if (oSystemParameter.omodel.WMS_MouldManagerCtl == "Y") //启用模治具管理
{
sMouldManagerCtl = "Y";
}
//判断是否启用先进先出管理(Y,N),是否启用扫码简易模式,只显示已扫码源单记录(Y,N)
if (HBillType == "1204") //生产领料单
{
if (oSystemParameter.omodel.Kf_MateOutBill_FIFOCtl == "Y" || oSystemParameter.omodel.Kf_MateOutBill_FIFOList == "Y") //生产领料单-先进先出控制
{
sFIFOCtl = "Y";
}
if (oSystemParameter.omodel.Kf_MateOutBill_SimpleMode == "Y") //生产领料单-扫码简易模式
{
sSimpleMode = "Y";
}
}
else if (HBillType == "1205" && (oSystemParameter.omodel.Kf_SellOutBill_FIFOCtl == "Y" || oSystemParameter.omodel.Kf_SellOutBill_FIFOList == "Y")) //销售出库单-先进先出控制
{
sFIFOCtl = "Y";
}
else if (HBillType == "1211" && (oSystemParameter.omodel.Kf_EntrustOutBill_FIFOCtl == "Y" || oSystemParameter.omodel.Kf_EntrustOutBill_FIFOList == "Y")) //委外出库单-先进先出控制
{
sFIFOCtl = "Y";
}
else if (HBillType == "1207" && (oSystemParameter.omodel.Kf_MoveStockBill_FIFOCtl == "Y" || oSystemParameter.omodel.Kf_MoveStockBill_FIFOList == "Y")) //直接调拨单-先进先出控制
{
sFIFOCtl = "Y";
}
else if (HBillType == "1250" && (oSystemParameter.omodel.Kf_MoveStockStepOutBill_FIFOCtl == "Y" || oSystemParameter.omodel.Kf_MoveStockStepOutBill_FIFOList == "Y")) //分步式调出单-先进先出控制
{
sFIFOCtl = "Y";
}
DataSet ds = oCn.RunProcReturn("exec h_p_WMS_BillEntryTmpList_LayUI " + HInterID.ToString() + ",'" + HBillType + "','" + sMouldManagerCtl + "','" + sFIFOCtl + "','" + sSimpleMode + "'", "h_p_WMS_BillEntryTmpList_LayUI");
List