using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Web.Http;
|
using WebAPI.Models;
|
namespace WebAPI.Controllers
|
{
|
/**
|
* 找货单单
|
*/
|
public class LookingForBillController : ApiController
|
{
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
public WebServer webserver = new WebServer();
|
/// <summary>
|
/// 根据包装单 返回此包装单内的相关信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("LookingFor/getPackUnionBillList")]
|
[HttpGet]
|
public object getPackUnionBillList(string HBarCode_Pack)
|
{
|
try
|
{
|
ds = getPackUnionBillList_s(HBarCode_Pack);
|
if (ds == null || Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = ds.Tables[0].Rows[0][1].ToString();
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "扫码成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 根据实物条码验证状态
|
/// </summary>
|
/// <returns></returns>
|
[Route("LookingFor/getPackUnionBillListDetailed")]
|
[HttpGet]
|
public object getPackUnionBillListDetailed(string HBarCode)
|
{
|
try
|
{
|
ds = getPackUnionBillListDetailed_s(HBarCode);
|
if (ds == null || Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = ds.Tables[0].Rows[0][1].ToString();
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = ds.Tables[0].Rows[0][1].ToString();
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 根据销售订单 返回此销售订单内的相关信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("LookingFor/getSellOrderList")]
|
[HttpGet]
|
public object getSellOrderList(string HSourceBillNo)
|
{
|
try
|
{
|
string sWhere = " Where HSourceBillNo = '" + HSourceBillNo.Trim() + "'";
|
ds = getSellOrderList_s(sWhere);
|
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 ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 根据实物条码 返回相关信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("LookingFor/getBarCodeDetails")]
|
[HttpGet]
|
public object getBarCodeDetails(string HBarCode)
|
{
|
try
|
{
|
string sWhere = " Where HBarCode = '" + HBarCode.Trim() + "'";
|
ds = getBarCodeDetails_s(sWhere);
|
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 ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 生成下架找货单
|
/// </summary>
|
/// <returns></returns>
|
[Route("LookingFor/set_SaveLookingForBill_Json")]
|
[HttpPost]
|
public object set_SaveLookingForBill_Json([FromBody]JObject oMain)
|
{
|
string oMainData = oMain["oMain"].ToString();
|
oMainData = oMainData.Substring(8,oMainData.Length-9);
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
try
|
{
|
List<LookingForBill> lsmain = new List<LookingForBill>();
|
ListModels oListModels = new ListModels();
|
List<LookingForBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LookingForBill>>(oMainData);
|
oCN.BeginTran();
|
var mainSql = "Insert Into LookingForBillMain " +
|
"(HInterID,HBillNo,HSourceInterID,HSourceBillNo,HCreateBy)" +
|
" values" +
|
"(" + list[0].HInterID + ",'" + list[0].HBillNo + "'," + list[0].HSourceInterID + ",'" + list[0].HSourceBillNo + "','" + list[0].HMaker + "')";
|
oCN.RunProc(mainSql);
|
for (int i = 0; i < list.Count; i++)
|
{
|
var subSql = "Insert Into LookingForBillSub " +
|
"(HWHID,HWHName,HSPID,HSPName,HBillType,HMTONo,HQty,HMaterID,HMaterName,HMaterNumber,HMaterModel,HBarCode,HGroupID,HGroup,HSourceID,HSource,HIsStatus,HStatus,HCreateBy,HMainItemID)" +
|
" values" +
|
"(" + list[i].HWHID + ",'" + list[i].HWHName + "'," + list[i].HSPID + ",'" + list[i].HSPName + "','1253','" + list[i].HMTONo + "',"+ list[i].HQty + ","
|
+ list[i].HMaterID + ",'"+ list[i].HMaterName + "','"+ list[i].HMaterNumber + "','"+ list[i].HMaterModel + "','" + list[i].HBarCode + "',"
|
+ list[i].HGroupID + ",'"+ list[i].HGroup + "',"+ list[i].HSourceID + ",'" + list[i].HSource + "',' ',' ','"+ list[i].HMaker + "',(select HItemID from LookingForBillMain where HBillNo = '"+ list[i].HBillNo + "'))";
|
oCN.RunProc(subSql);
|
var barCodeSql = "update Gy_BarCodeBill set HStatus='裁切中-" + list[i].HSource + "' where HBarCode = '"+ list[i].HBarCode + "'";
|
oCN.RunProc(barCodeSql);
|
}
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "生成找货单成功!单据号为:" + list[0].HBillNo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "上传失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 生成上架归还单
|
/// </summary>
|
/// <returns></returns>
|
[Route("LookingFor/set_SaveLookingForReturnBill_Json")]
|
[HttpPost]
|
public object set_SaveLookingForReturnBill_Json([FromBody] JObject oMain)
|
{
|
string oMainData = oMain["oMain"].ToString();
|
oMainData = oMainData.Substring(8, oMainData.Length - 9);
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
try
|
{
|
List<LookingForBill> lsmain = new List<LookingForBill>();
|
ListModels oListModels = new ListModels();
|
List<LookingForBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LookingForBill>>(oMainData);
|
oCN.BeginTran();
|
var mainSql = "Insert Into LookingForBillMain " +
|
"(HInterID,HBillNo,HSourceInterID,HSourceBillNo,HCreateBy)" +
|
" values" +
|
"(" + list[0].HInterID + ",'" + list[0].HBillNo + "'," + list[0].HSourceInterID + ",'" + list[0].HSourceBillNo + "','" + list[0].HMaker + "')";
|
oCN.RunProc(mainSql);
|
for (int i = 0; i < list.Count; i++)
|
{
|
var subSql = "Insert Into LookingForBillSub " +
|
"(HWHID,HWHName,HSPID,HSPName,HBillType,HMTONo,HQty,HMaterID,HMaterName,HMaterNumber,HMaterModel,HBarCode,HGroupID,HGroup,HSourceID,HSource,HIsStatus,HStatus,HCreateBy,HMainItemID)" +
|
" values" +
|
"(" + list[i].HWHID + ",'" + list[i].HWHName + "'," + list[i].HSPID + ",'" + list[i].HSPName + "','1252','" + list[i].HMTONo + "'," + list[i].HQty + ","
|
+ list[i].HMaterID + ",'" + list[i].HMaterName + "','" + list[i].HMaterNumber + "','" + list[i].HMaterModel + "','" + list[i].HBarCode + "',"
|
+ list[i].HGroupID + ",'" + list[i].HGroup + "'," + list[i].HSourceID + ",'" + list[i].HSource + "',' ',' ','" + list[i].HMaker + "',(select HItemID from LookingForBillMain where HBillNo = '" + list[i].HBillNo + "'))";
|
oCN.RunProc(subSql);
|
var barCodeSql = "update Gy_BarCodeBill set HStatus='在库' where HBarCode = '" + list[i].HBarCode + "'";
|
oCN.RunProc(barCodeSql);
|
}
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "生成归还单成功!单据号为:" + list[0].HBillNo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "上传失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 根据仓位二维码带出仓库仓位相关信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("LookingFor/getSpName_Json")]
|
[HttpGet]
|
public object getSpName_Json(string HBarCode)
|
{
|
try
|
{
|
string[] sArray = HBarCode.Remove(0, 3).Split(';');
|
long HSpID = DBUtility.ClsPub.isLong(sArray[1]);
|
long HWHID = DBUtility.ClsPub.isLong(sArray[0]);
|
string sWhere = " Where HWHID = " + HWHID + " and HItemID = "+ HSpID + "";
|
ds = getSpName_Json_s(sWhere);
|
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 ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
|
#region sql语句
|
|
public static DataSet getPackUnionBillList_s(string HBarCode_Pack)
|
{
|
return new SQLHelper.ClsCN().RunProcReturn("EXEC h_p_Kf_getPackUnionBillList " + "'"+HBarCode_Pack+"'", "h_p_Kf_getPackUnionBillList");
|
}
|
|
public static DataSet getPackUnionBillListDetailed_s(string HBarCode)
|
{
|
return new SQLHelper.ClsCN().RunProcReturn("EXEC h_p_Kf_getPackUnionBillListDetailed " + "'" + HBarCode + "'", "h_p_Kf_getPackUnionBillListDetailed");
|
}
|
|
public static DataSet getSellOrderList_s(string sWhere)
|
{
|
return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_getSellOrderList_s " + sWhere, "h_v_getSellOrderList_s");
|
}
|
|
public static DataSet getBarCodeDetails_s(string sWhere)
|
{
|
return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_getBarCodeDetails_s " + sWhere, "h_v_getBarCodeDetails_s");
|
}
|
|
public static DataSet getSpName_Json_s(string sWhere)
|
{
|
return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_StockPlace " + sWhere, "h_v_IF_StockPlace");
|
}
|
|
#endregion
|
|
}
|
}
|