| | |
| | | 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 Microsoft.AspNetCore.Mvc; |
| | | using static Gs.Toolbox.UtilityHelper; |
| | | |
| | | namespace Gs.Wom.WorkService; |
| | | |
| | | [ApiGroup(ApiGroupNames.WOM)] |
| | | public class WorkCollectController : IRomteService |
| | | namespace Gs.Wom.WorkService |
| | | { |
| | | private readonly IHttpContextAccessor _http; |
| | | private readonly string _userCode, _userGuid, _orgFids; |
| | | |
| | | public WorkCollectController(IHttpContextAccessor httpContextAccessor) |
| | | [ApiGroup(ApiGroupNames.WOM)] |
| | | public class WorkCollectController : IRomteService |
| | | { |
| | | _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 collectGuid = model.collectGuid; |
| | | //水检值 |
| | | 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; |
| | | string t012 = model.t012; |
| | | string t013 = model.t013; |
| | | dynamic m = new ExpandoObject(); |
| | | m.list = new List<dynamic>(); |
| | | m.list2 = new List<dynamic>(); |
| | | m.list3 = new List<dynamic>(); |
| | | m.outMsg = ""; |
| | | m.outSum = -1; |
| | | var _strMsg = ""; |
| | | var _sum = 0; |
| | | SqlParameter[] parameters = |
| | | private readonly IHttpContextAccessor _http; |
| | | private readonly string _userCode, _userGuid, _orgFids; |
| | | public WorkCollectController(IHttpContextAccessor httpContextAccessor) |
| | | { |
| | | 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), |
| | | new("@t012", t012), |
| | | new("@t013", t013), |
| | | new("@collectGuid", collectGuid) |
| | | }; |
| | | var dset = new DataSet(); |
| | | try |
| | | _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) |
| | | { |
| | | dset = DbHelperSQL.RunProcedure("[work_collect_mx]", |
| | | parameters, "0"); |
| | | if (dset != null && dset.Tables.Count > 0 && |
| | | dset.Tables[0].Rows.Count > 0) |
| | | 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 collectGuid = model.collectGuid; |
| | | //水检值 |
| | | 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; |
| | | string t012 = model.t012; |
| | | string t013 = model.t013; |
| | | 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 = |
| | | { |
| | | //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) |
| | | 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), |
| | | new("@t012",t012), |
| | | new("@t013",t013), |
| | | new("@collectGuid",collectGuid), |
| | | }; |
| | | 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) |
| | | { |
| | | var dr = dset.Tables[1].Rows[0]; |
| | | m = dr.RowToDynamic(); |
| | | //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; |
| | | } |
| | | } |
| | | |
| | | m.outMsg = _strMsg; |
| | | m.outSum = _sum; |
| | | //2良品列表 |
| | | if (dset.Tables.Count > 2) |
| | | else |
| | | { |
| | | var _tb = dset.Tables[2].TableToDynamicList(); |
| | | m.list = _tb; |
| | | } |
| | | |
| | | //3不良品列表 |
| | | if (dset.Tables.Count > 3) |
| | | { |
| | | var _tb2 = dset.Tables[3].TableToDynamicList(); |
| | | m.list2 = _tb2; |
| | | m.outMsg = "没有找到该条码!"; |
| | | m.outSum = -1; |
| | | } |
| | | } |
| | | else |
| | | catch (Exception ex) |
| | | { |
| | | m.outMsg = "没有找到该条码!"; |
| | | System.Text.StringBuilder sbLog = new System.Text.StringBuilder(); |
| | | sbLog.Append("_userGuid:" + _userGuid.ToString()); |
| | | sbLog.Append("processNo:" + processNo.ToString()); |
| | | sbLog.Append("gongWei:" + gongWei.ToString()); |
| | | sbLog.Append("inP4:" + barCode); |
| | | LogHelper.Debug(this.ToString(), ex.Message + ":" + sbLog.ToString()); |
| | | 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); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | var sbLog = new StringBuilder(); |
| | | sbLog.Append("_userGuid:" + _userGuid); |
| | | sbLog.Append("processNo:" + processNo); |
| | | sbLog.Append("gongWei:" + gongWei); |
| | | sbLog.Append("inP4:" + barCode); |
| | | LogHelper.Debug(ToString(), ex.Message + ":" + sbLog); |
| | | 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 |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |