using System.Data;
|
using System.Data.SqlClient;
|
using System.Dynamic;
|
using System.Text;
|
using Gs.Toolbox;
|
using Gs.Toolbox.ApiCore.Abstract.Mvc;
|
using Gs.Toolbox.ApiCore.Common.Mvc;
|
using Gs.Toolbox.ApiCore.Group;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using static Gs.Toolbox.UtilityHelper;
|
|
namespace Gs.Wom.WorkService
|
{
|
|
[ApiGroup(ApiGroupNames.WOM)]
|
public class WorkCollectController : IRomteService
|
{
|
private readonly IHttpContextAccessor _http;
|
private readonly string _userCode, _userGuid, _orgFids;
|
public WorkCollectController(IHttpContextAccessor httpContextAccessor)
|
{
|
_http = httpContextAccessor;
|
(_userCode, _userGuid, _orgFids) =
|
GetUserGuidAndOrgGuid(_http);
|
}
|
#region
|
|
|
/// <summary>
|
/// 读取,采集,采集的时候返回列表
|
/// </summary>
|
/// <param name="guid"></param>
|
/// <returns></returns>
|
[RequestMethod(RequestMethods.POST)]
|
public ReturnDto<ExpandoObject> GetModel([FromBody] dynamic model)
|
{
|
string barCode = model.barCode.ToString();//追溯码
|
string processNo = model.processNo;//工序
|
string banCi = model.banCi;//班次
|
string gongWei = model.gongWei;//工位
|
string checkResult = model.checkResult; //结果
|
string badDescription = model.badDescription;//不良描述
|
//水检值
|
string t001 = model.t001;
|
string t002 = model.t002;
|
string t003 = model.t003;
|
string t004 = model.t004;
|
string t005 = model.t005;
|
string t006 = model.t006;
|
string t007 = model.t007;
|
string t008 = model.t008;
|
string t009 = model.t009;
|
string t010 = model.t010;
|
string t011 = model.t011;
|
dynamic m = new ExpandoObject();
|
m.list = new List<dynamic>();
|
m.list2 = new List<dynamic>();
|
m.list3 = new List<dynamic>();
|
m.outMsg = "";
|
m.outSum = -1;
|
string _strMsg = "";
|
int _sum = 0;
|
SqlParameter[] parameters =
|
{
|
new("@inP3",checkResult),
|
new("@inP4", barCode),
|
new("@inEdtUserGuid", _userGuid),
|
new("@processNo",processNo),
|
new("@banCi",banCi),
|
new("@gongWei",gongWei),
|
new("@badDescription",badDescription),
|
new("@t001",t001),
|
new("@t002",t002),
|
new("@t003",t003),
|
new("@t004",t004),
|
new("@t005",t005),
|
new("@t006",t006),
|
new("@t007",t007),
|
new("@t008",t008),
|
new("@t009",t009),
|
new("@t010",t010),
|
new("@t011",t011),
|
};
|
var dset = new DataSet();
|
try
|
{
|
dset = DbHelperSQL.RunProcedure("[work_collect_mx]",
|
parameters, "0");
|
if (dset != null && dset.Tables.Count > 0 &&
|
dset.Tables[0].Rows.Count > 0)
|
{
|
//0返回消息和返回值
|
_strMsg = dset.Tables[0].Rows[0]["outMsg"].ToString();
|
_sum = int.Parse(dset.Tables[0].Rows[0]["outSum"].ToString());
|
//1统计和头表
|
if (dset.Tables.Count > 1 && dset.Tables[1].Rows.Count > 0)
|
{
|
var dr = dset.Tables[1].Rows[0];
|
m = dr.RowToDynamic();
|
}
|
m.outMsg = _strMsg;
|
m.outSum = _sum;
|
//2良品列表
|
if (dset.Tables.Count > 2)
|
{
|
var _tb = dset.Tables[2].TableToDynamicList();
|
m.list = _tb;
|
}
|
//3不良品列表
|
if (dset.Tables.Count > 3)
|
{
|
var _tb2 = dset.Tables[3].TableToDynamicList();
|
m.list2 = _tb2;
|
}
|
}
|
else
|
{
|
m.outMsg = "没有找到该条码!";
|
m.outSum = -1;
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Debug(this.ToString(), ex.Message);
|
m.outMsg = ex.Message;
|
m.outSum = -1;
|
}
|
if (m.outSum > 0)
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, m.outMsg);
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, m.outMsg);
|
}
|
#endregion
|
}
|
}
|