using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Web.Http;
|
using WebAPI.Models;
|
namespace WebAPI.Controllers
|
{
|
public class LMESController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
|
private json objJsonResult = new json();
|
/// <summary>
|
/// 返回进站扫描列表|工序进站接收单列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_StationInBillList_Json")]
|
[HttpGet]
|
public object MES_StationInBillList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_MES_StationInBillList", "h_v_MES_StationInBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_MES_StationInBillList where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_MES_StationInBillList");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回工序流转卡维护列表主表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_Sc_ProcessExchangeBillQuery_Json")]
|
[HttpGet]
|
public object MES_Sc_ProcessExchangeBillList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuery", "h_v_Sc_ProcessExchangeBillQuery");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_Sc_ProcessExchangeBillQuery where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessExchangeBillQuery");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回工序流转卡维护列表从表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_Sc_ProcessExchangeBillQuerySub_Json")]
|
[HttpGet]
|
public object MES_Sc_ProcessExchangeBillSub_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
string sql = "select * from h_v_Sc_ProcessExchangeBillQuerySub where hmainid = ";
|
string sql1 = sql + sWhere;
|
ds = oCN.RunProcReturn(sql1, "h_v_Sc_ProcessExchangeBillQuerySub");
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回工序出站汇报单列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_StationOutBillList_Json")]
|
[HttpGet]
|
public object MES_StationOutBillList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList ", "h_v_MES_StationInBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_MES_StationOutBillList where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回工序委外发出单列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_StationEntrustInBillList_Json")]
|
[HttpGet]
|
public object MES_StationEntrustInBillList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustInBillList ", "h_v_MES_StationEntrustInBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_MES_StationEntrustInBillList where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_MES_StationEntrustInBillList");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回工艺路线列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_Gy_RoutingBillList_Json")]
|
[HttpGet]
|
public object MES_Gy_RoutingBillList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList ", "h_v_Gy_RoutingBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_Gy_RoutingBillList where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回生产任务单列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_IF_ICMOBillList_Json")]
|
[HttpGet]
|
public object MES_IF_ICMOBillList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList ", "h_v_IF_ICMOBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_IF_ICMOBillList where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOBillList");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回工序委外接收单列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_StationEntrustOutBillList_Json")]
|
[HttpGet]
|
public object MES_StationEntrustOutBillList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustOutBillList ", "h_v_MES_StationEntrustOutBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_MES_StationEntrustOutBillList where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_MES_StationEntrustOutBillList");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
///<summary>
|
///封装状态码及返回信息的公用方法。
|
///参数:DataSet。
|
///返回值:json。
|
///</summary>
|
public object GetObjectJson(DataSet ds)
|
{
|
try
|
{
|
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 = "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;
|
}
|
}
|
|
///<summary>
|
///自定义错误信息方法。
|
///参数:string。
|
///返回值:object。
|
///</summary>
|
public object CustomError(string msg)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = msg;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
///<summary>
|
///统一正确信息方法。
|
///参数:string。
|
///返回值:object。
|
///</summary>
|
public object CustomCorrect(DataSet ds)
|
{
|
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 = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取信息成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 返回选择生产班组列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_GetProductionTeamList_Json")]
|
[HttpGet]
|
public object MES_GetProductionTeamList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
ds = oCN.RunProcReturn("Select HItemID,HNumber 班组代码,HName 班组 from h_v_IF_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "h_v_IF_Group");
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 返回选择生产资源列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/MES_GetProductionResourcesList_Json")]
|
[HttpGet]
|
public object MES_GetProductionResourcesList_Json(string sWhere)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
ds = oCN.RunProcReturn("Select HItemID,HNumber 生产资源代码,HName 生产资源 from Gy_Source where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return GetObjectJson(ds);
|
}
|
|
/// <summary>
|
/// 扫条码方法(进站接收单、出站汇报单)
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/TxtHBarCode_KeyDown")]
|
[HttpGet]
|
public object TxtHBarCode_KeyDown(string sBillBarCode)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sBillBarCode == null || sBillBarCode.Equals(""))
|
{
|
return CustomError("未输入条形码!");
|
}
|
else
|
{
|
//拆分条形码
|
string[] NewBarCode;
|
if (sBillBarCode.CompareTo("#") > 0)
|
{
|
NewBarCode = sBillBarCode.Split(Convert.ToChar("#"));
|
sBillBarCode = NewBarCode[0];
|
}
|
string sBillNo = sBillBarCode;
|
ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "'", "h_v_Sc_ProcessExchangeBillList");
|
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return CustomCorrect(ds);
|
}
|
|
/// <summary>
|
/// 流水号回车方法(进站接收单、出站汇报单)
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/TxtHProcNo_KeyDown")]
|
[HttpGet]
|
public object TxtHProcNo_KeyDown(string sProcNo, string sBillNo)
|
{
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (sProcNo == null || sProcNo.Equals("") || sBillNo == null || sBillNo.Equals(""))
|
{
|
return CustomError("流水号或流转卡号为空!");
|
}
|
else
|
{
|
ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 下道流转工序<>'转' and 委外标记=0 and 流转标记=1 and 工序号='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList");
|
}
|
|
}
|
catch (Exception e)
|
{
|
ds = null;
|
}
|
return CustomCorrect(ds);
|
}
|
|
|
/// <summary>
|
/// 保存提交方法
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("LEMS/Sub_SaveBill_Json")]
|
[HttpPost]
|
public object Sub_SaveBill_Json([FromBody]JObject oMain)
|
{
|
var _value = oMain["oMain"].ToString();
|
string msg1 = _value.ToString();
|
try
|
{
|
List<Model.ClsSc_StationInBillSub> lsmain = new List<Model.ClsSc_StationInBillSub>();
|
//反序列化
|
msg1 = "[" + msg1.ToString() + "]";
|
List<Model.ClsSc_StationInBillSub> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_StationInBillSub>>(msg1);
|
|
DAL.ClsSc_StationInBill BillNew = new DAL.ClsSc_StationInBill();
|
DAL.ClsSc_StationInBill BillOld = new DAL.ClsSc_StationInBill();
|
bool bResult;
|
//赋值ID
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
|
BillNew.omodel.HInterID = BillOld.omodel.HInterID;
|
BillNew.omodel.HYear = 2011;
|
BillNew.omodel.HPeriod = 1;
|
//BillNew.omodel.HBillNo = DBUtility.ClsPub.isStrNull(list[0].HBillNo);
|
//BillNew.omodel.HICMOBillNo = this.txtHICMOBillNo.Text.Trim();
|
//BillNew.omodel.HICMOInterID = DBUtility.ClsPub.isLong(this.txtHICMOBillNo.Tag);
|
//BillNew.omodel.HProcExchInterID = lngBillKey;
|
//BillNew.omodel.HProcExchEntryID = lngBillSubKey;
|
//BillNew.omodel.HProcExchBillNo = this.txtHProcExchBillNo.Text.Trim();
|
//BillNew.omodel.HProcID = DBUtility.ClsPub.isLong(this.txtHProcID.Tag);
|
//BillNew.omodel.HMaterID = DBUtility.ClsPub.isLong(this.txtHMaterID.Tag);
|
//BillNew.omodel.HStationInTime = DBUtility.ClsPub.isDate(this.txtHStationInTime.Text);
|
//BillNew.omodel.HEmpID = DBUtility.ClsPub.isLong(this.txtHEmpID.Tag);
|
//BillNew.omodel.HSourceID = DBUtility.ClsPub.isLong(this.txtHSourceID.Tag);
|
//BillNew.omodel.HGroupID = DBUtility.ClsPub.isLong(this.txtHGroupID.Tag);
|
//BillNew.omodel.HICMOQty = DBUtility.ClsPub.isDoule(this.txtHICMOQty.Text);
|
//BillNew.omodel.HPlanQty = DBUtility.ClsPub.isDoule(this.txtHPlanQty.Text);
|
//BillNew.omodel.HQty = DBUtility.ClsPub.isDoule(this.txtHQty.Text);
|
//BillNew.omodel.HPieceQty = DBUtility.ClsPub.isDoule(this.txtHPieceQty.Text);
|
//BillNew.omodel.HSourceName = DBUtility.ClsPub.isStrNull(this.txtHSourceName.Text);
|
//BillNew.omodel.HCenterID = DBUtility.ClsPub.isLong(this.txtHCenterID.Tag);
|
|
//BillNew.omodel.HProcNo = DBUtility.ClsPub.isLong(this.txtHProcNo.Text);
|
//BillNew.omodel.HOrderProcNO = DBUtility.ClsPub.isStrNull(this.txtHOrderProcNO.Text);
|
|
//保存完毕后处理
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
{
|
bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
|
}
|
else
|
{
|
bResult = BillNew.ModifyBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
|
}
|
if (bResult == true)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "生成汇报单成功!单据号为:";
|
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;
|
}
|
}
|
|
//以下是工序出站汇报单单据方法-----------
|
|
|
//
|
}
|
}
|