using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Web.Http;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers
|
{
|
//生产上料单Controller
|
public class Sc_MaterToSourceBillController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
//获取系统参数
|
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
|
|
|
/// <summary>
|
/// 返回生产上料单列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Sc_MaterToSourceBill/list")]
|
[HttpGet]
|
public object list(string sWhere)
|
{
|
try
|
{
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_Sc_MaterToSourceBillList " + sWhere, "h_v_Sc_MaterToSourceBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_Sc_MaterToSourceBillList where 1 = 1 ";
|
string sql = sql1 + sWhere;
|
ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillList");
|
}
|
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 = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
//
|
|
#region 报工平台上料防错单弹窗查找数据
|
[Route("Sc_MaterToSourceBill/GetMESMaterToSourceFrom")]
|
[HttpGet]
|
public object GetMESMaterToSourceFrom(string HSourceInterID, string HSourceEntryID, string HSourceBillNo, string HSourceBillType)
|
{
|
try
|
{
|
//根据选择资源ID获取当前生产工单、责任人
|
ds = oCN.RunProcReturn("exec h_p_JIT_GetInfoByICMOStatusInterID @HSourceInterID=" + HSourceInterID + ",@HSourceEntryID=" + HSourceEntryID + ",@HSourceBillNo='" + HSourceBillNo + "',@HSourceBillType='" + HSourceBillType + "'", "h_p_JIT_GetInfoByICMOStatusInterID");
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取资源绑定数据成功!";
|
objJsonResult.data = ds;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "暂无资源绑定!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = e.Message.ToString();
|
objJsonResult.data = null;
|
|
}
|
return objJsonResult;
|
}
|
#endregion
|
|
#region 报工平台上料防错一键扫码方法
|
[Route("Sc_MaterToSourceBill/get_CheckTypeByBarCode_Json")]
|
[HttpGet]
|
public object get_CheckTypeByBarCode_Json(string HBarCode,string HSourceID)
|
{
|
|
//根据递入的条码前三位,判断条码类型(生产资源、物料条码)
|
ds = oCN.RunProcReturn(" select HSourceName,BarCodeType from Xt_BarCodeType where HSourceNumber= '" + HBarCode.Substring(0, 3) + "'", "Xt_BarCodeType");
|
|
//无返回数据则为物料条码
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
//1.查询条形码在条码档案表中是否存在
|
//2.匹配用料清单的物料编码是否一致
|
|
}
|
else
|
{
|
string sBarBillName = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HSourceName"]);
|
string sBarBillType = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0]["BarCodeType"]);
|
|
//判断条码类型为 基础资料条码 或 源单条码
|
if (sBarBillType == "基础资料条码")
|
{
|
|
//部门条码
|
if (sBarBillName == "生产资源")
|
{
|
DAL.ClsGy_Source_View dal = new DAL.ClsGy_Source_View();
|
//将递入的条码去掉前三位后转化成整形
|
int ID;
|
if (int.TryParse(HBarCode.Remove(0, 3), out ID))
|
{
|
if (int.Parse(HSourceID)!= ID)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "生产资源条码与生产订单绑定资源不匹配!";
|
return objJsonResult;
|
}
|
else
|
{
|
if (dal.GetInfoByID(ID))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取资源绑定数据成功!";
|
objJsonResult.Verify = "资源条码";
|
objJsonResult.data = dal;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无效资源条码!";
|
return objJsonResult;
|
}
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "错误的部门条码!";
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无效基础资料条码!";
|
return objJsonResult;
|
}
|
}
|
//源单条码
|
else if (sBarBillType == "源单条码")
|
{
|
|
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无效条码类型!";
|
return objJsonResult;
|
}
|
}
|
return objJsonResult;
|
}
|
#endregion
|
}
|
}
|