using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Web;
|
using WebAPI.Models;
|
using WebAPI.WebS;
|
|
namespace WebAPI.Service
|
{
|
public class YqnQbService
|
{
|
/// <summary>
|
/// 获取单据号
|
/// </summary>
|
/// <returns></returns>
|
public static ApiResult<DocumentsView> GetInterBillNo()
|
{
|
var hInterId= DBUtility.ClsPub.CreateBillID(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
|
var hBillNo= DBUtility.ClsPub.CreateBillCode(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
|
if (hInterId == 0 || string.IsNullOrEmpty(hBillNo))
|
return new ApiResult<DocumentsView> { code = -1, msg = "获取失败" };
|
DocumentsView documentsView = new DocumentsView()
|
{
|
HBillNo = hBillNo,
|
HInterID = hInterId
|
};
|
return new ApiResult<DocumentsView> { code = 1, msg = "获取成功", data = documentsView };
|
}
|
/// <summary>
|
/// 扫码方法
|
/// </summary>
|
public static ApiResult<DataSet> GetHbarCodeDetail(string sBillBarCode)
|
{
|
if (string.IsNullOrEmpty(sBillBarCode))
|
return new ApiResult<DataSet> { code = -1, msg = "条码不能为空" };
|
sBillBarCode = sBillBarCode.CompareTo("#") > 0 ? sBillBarCode.Split(Convert.ToChar("#"))[0] : sBillBarCode;
|
var dataSet = GetBarCodeDb(sBillBarCode);
|
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
|
return new ApiResult<DataSet> { code = -1, msg = "不存在流转卡号" };
|
return new ApiResult<DataSet> { code = 1, msg = "查询成功",data=dataSet };
|
}
|
/// <summary>
|
/// 流转卡回车方法
|
/// </summary>
|
public static ApiResult<DataSet> GetProcDetail(string sBillNo, string sProcNo)
|
{
|
if (string.IsNullOrEmpty(sBillNo)||string.IsNullOrEmpty(sProcNo))
|
return new ApiResult<DataSet> { code = -1, msg = "条码和流转卡不能为空" };
|
var dataSet = GetProcDb(sBillNo, sProcNo);
|
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
|
return new ApiResult<DataSet> { code = -1, msg = "流水号或流转卡号为空" };
|
return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
|
}
|
/// <summary>
|
/// 获取生产资源列表
|
/// </summary>
|
public static ApiResult<DataSet> GetSourceList(string sWhere)
|
{
|
var dataSet = GetSourceDb(sWhere);
|
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
|
return new ApiResult<DataSet> { code = -1, msg = "未查询到生产资源" };
|
return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
|
}
|
/// <summary>
|
/// 获取生产班组列表
|
/// </summary>
|
public static ApiResult<DataSet> GetGroupList(string sWhere)
|
{
|
var dataSet = GetGroupDb(sWhere);
|
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
|
return new ApiResult<DataSet> { code = -1, msg = "未查询到生产班组" };
|
return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
|
}
|
/// <summary>
|
/// 获取工作中心列表
|
/// </summary>
|
public static ApiResult<DataSet> GetWorkCenterList(string sWhere)
|
{
|
var dataSet = GetGroupDb(sWhere);
|
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
|
return new ApiResult<DataSet> { code = -1, msg = "未查询到工作中心" };
|
return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
|
}
|
/// <summary>
|
/// 进站接收单
|
/// </summary>
|
public static ApiResult SetStationInBill(ClsSc_StationInBillMain oMain)
|
{
|
WebS.WebService1 oWebs = new WebS.WebService1();
|
string sErrMsg = string.Empty;
|
var result = oWebs.set_SaveStationInBill(oMain, ref sErrMsg);
|
if (!result)
|
{
|
return new ApiResult { code = -1, msg = sErrMsg };
|
}
|
return new ApiResult { code = 1, msg = "操作成功" };
|
}
|
#region sql语句
|
public static DataSet GetBarCodeDb(string billBarCode)
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + billBarCode + "'", "h_v_Sc_ProcessExchangeBillList");
|
return dataSet;
|
}
|
public static DataSet GetSourceDb(string sWhere)
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 生产资源代码,HName 生产资源 from Gy_Source where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
|
return dataSet;
|
}
|
public static DataSet GetGroupDb(string sWhere)
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 生产班组代码,HName 生产班组 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
|
return dataSet;
|
}
|
|
public static DataSet GetProcDb(string sBillNo, string sProcNo)
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 工序号='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList");
|
return dataSet;
|
}
|
/// <summary>
|
/// 工作中心
|
/// </summary>
|
/// <param name="sWhere"></param>
|
/// <returns></returns>
|
public static DataSet GetWorkCenterDb(string sWhere)
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 工作中心代码,HName 工作中心 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
|
return dataSet;
|
}
|
#endregion
|
|
}
|
}
|