| | |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using static Gs.Toolbox.UtilityHelper; |
| | | |
| | | namespace Gs.Wom.WorkService; |
| | | |
| | | [ApiGroup(ApiGroupNames.WOM)] |
| | | public class WorkWeightController : IRomteService |
| | | namespace Gs.Wom.WorkService |
| | | { |
| | | private readonly IHttpContextAccessor _http; |
| | | private readonly string _userCode, _userGuid, _orgFids; |
| | | |
| | | public WorkWeightController(IHttpContextAccessor httpContextAccessor) |
| | | [ApiGroup(ApiGroupNames.WOM)] |
| | | public class WorkWeightController : IRomteService |
| | | { |
| | | _http = httpContextAccessor; |
| | | (_userCode, _userGuid, _orgFids) = |
| | | GetUserGuidAndOrgGuid(_http); |
| | | } |
| | | private readonly IHttpContextAccessor _http; |
| | | private readonly string _userCode, _userGuid, _orgFids; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取称重列表 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<List<dynamic>> GetModelList([FromBody] dynamic model) |
| | | { |
| | | string lineId = model.lineId; |
| | | var lst = new List<dynamic>(); |
| | | var dset = new DataSet(); |
| | | try |
| | | public WorkWeightController(IHttpContextAccessor httpContextAccessor) |
| | | { |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@inLineId", lineId) |
| | | }; |
| | | dset = DbHelperSQL.RunProcedure("work_weight_lst", parameters, "0"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "work_weight_lst error:" + ex.Message); |
| | | _http = httpContextAccessor; |
| | | (_userCode, _userGuid, _orgFids) = |
| | | GetUserGuidAndOrgGuid(_http); |
| | | } |
| | | |
| | | if (dset != null && dset.Tables.Count > 0 && |
| | | dset.Tables[0].Rows.Count > 0) |
| | | lst = dset.Tables[0].TableToDynamicList(); |
| | | return ReturnDto<List<dynamic>>.QuickReturn(lst, ReturnCode.Success, |
| | | "读取成功!"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 增加一条重量信息 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditModel([FromBody] dynamic model) |
| | | { |
| | | string lineId = model.lineId; |
| | | string realWeight = model.realWeight; |
| | | string realWeightTxt = model.realWeightTxt; |
| | | dynamic mObj = new ExpandoObject(); |
| | | mObj.outMsg = ""; |
| | | mObj.outSum = -1; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | /// <summary> |
| | | /// 读取称重列表 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<List<dynamic>> GetModelList([FromBody] dynamic model) |
| | | { |
| | | using (var cmd = new SqlCommand("[work_weight_add]", conn)) |
| | | string lineId = model.lineId; |
| | | List<dynamic> lst = new List<dynamic>(); |
| | | var dset = new DataSet(); |
| | | try |
| | | { |
| | | try |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@inLineId",lineId) |
| | | }; |
| | | dset = DbHelperSQL.RunProcedure("work_weight_lst", parameters, "0"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "work_weight_lst error:" + ex.Message); |
| | | } |
| | | if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0) |
| | | lst = dset.Tables[0].TableToDynamicList(); |
| | | return ReturnDto<List<dynamic>>.QuickReturn(lst, ReturnCode.Success, |
| | | "读取成功!"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 增加一条重量信息 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditModel([FromBody] dynamic model) |
| | | { |
| | | string lineId = model.lineId; |
| | | string realWeight = model.realWeight; |
| | | string realWeightTxt = model.realWeightTxt; |
| | | dynamic mObj = new ExpandoObject(); |
| | | mObj.outMsg = ""; |
| | | mObj.outSum = -1; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[work_weight_add]", conn)) |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 300), |
| | | new("@outSum", SqlDbType.Int), |
| | | new("@lineId", lineId), |
| | | new("@realWeight", realWeight), |
| | | new("@realWeightTxt", realWeightTxt), |
| | | new("@inEdtUserGuid", _userGuid) |
| | | new("@inEdtUserGuid", _userGuid), |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | mObj.outMsg = parameters[0].Value.ToString(); |
| | | mObj.outSum = int.Parse(parameters[1].Value.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), |
| | | "work_weight_add error:" + ex.Message); |
| | | mObj.outMsg = ex.Message; |
| | | mObj.outSum = -1; |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | mObj.outMsg = parameters[0].Value.ToString(); |
| | | mObj.outSum = int.Parse(parameters[1].Value.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), |
| | | "work_weight_add error:" + ex.Message); |
| | | mObj.outMsg = ex.Message; |
| | | mObj.outSum = -1; |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | if (mObj.outSum <= 0) |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, mObj.outMsg); |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, mObj.outMsg); |
| | | } |
| | | |
| | | if (mObj.outSum <= 0) |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, |
| | | mObj.outMsg); |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, |
| | | mObj.outMsg); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取iqc称重 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<string?> GetIqcWeight([FromBody] dynamic model) |
| | | { |
| | | var rtnInt = ""; |
| | | var dset = new DataSet(); |
| | | try |
| | | /// <summary> |
| | | /// 读取iqc称重 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<string?> GetIqcWeight([FromBody] dynamic model) |
| | | { |
| | | SqlParameter[] parameters = |
| | | string? rtnInt = ""; |
| | | var dset = new DataSet(); |
| | | try |
| | | { |
| | | new("@inLineId", "") |
| | | }; |
| | | dset = DbHelperSQL.RunProcedure("iqc_detect01_get_weight", |
| | | parameters, "0"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "GetIqcWeight error:" + ex.Message); |
| | | } |
| | | |
| | | if (dset != null && dset.Tables.Count > 0 && |
| | | dset.Tables[0].Rows.Count > 0) |
| | | rtnInt = dset.Tables[0].Rows[0]["realWeight"].ToString(); |
| | | return ReturnDto<string>.QuickReturn(rtnInt, ReturnCode.Success, |
| | | "读取成功!"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 编辑iqc重量 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditIqcWeight([FromBody] dynamic model) |
| | | { |
| | | string iqcGuid = model.iqcGuid; |
| | | string weightType = model.weightType; |
| | | string weight = model.weight; |
| | | dynamic mObj = new ExpandoObject(); |
| | | mObj.outMsg = ""; |
| | | mObj.outSum = -1; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[iqc_detect01_edt_weight]", conn)) |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@inLineId","") |
| | | }; |
| | | dset = DbHelperSQL.RunProcedure("iqc_detect01_get_weight", parameters, "0"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | try |
| | | LogHelper.Debug(ToString(), "GetIqcWeight error:" + ex.Message); |
| | | } |
| | | if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0) |
| | | { |
| | | rtnInt = dset.Tables[0].Rows[0]["realWeight"].ToString(); |
| | | } |
| | | return ReturnDto<string>.QuickReturn(rtnInt, ReturnCode.Success, "读取成功!"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 编辑iqc重量 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditIqcWeight([FromBody] dynamic model) |
| | | { |
| | | string iqcGuid = model.iqcGuid; |
| | | string weightType = model.weightType; |
| | | string weight = model.weight; |
| | | dynamic mObj = new ExpandoObject(); |
| | | mObj.outMsg = ""; |
| | | mObj.outSum = -1; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[iqc_detect01_edt_weight]", conn)) |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 300), |
| | | new("@outSum", SqlDbType.Int), |
| | | new("@weightType", weightType), |
| | | new("@weight", weight), |
| | | new("@iqcGuid", iqcGuid), |
| | | new("@inEdtUserGuid", _userGuid) |
| | | new("@inEdtUserGuid", _userGuid), |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | mObj.outMsg = parameters[0].Value.ToString(); |
| | | mObj.outSum = int.Parse(parameters[1].Value.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), |
| | | "iqc_detect01_edt_weight error:" + ex.Message); |
| | | mObj.outMsg = ex.Message; |
| | | mObj.outSum = -1; |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | mObj.outMsg = parameters[0].Value.ToString(); |
| | | mObj.outSum = int.Parse(parameters[1].Value.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "iqc_detect01_edt_weight error:" + ex.Message); |
| | | mObj.outMsg = ex.Message; |
| | | mObj.outSum = -1; |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | if (mObj.outSum <= 0) |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, mObj.outMsg); |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, mObj.outMsg); |
| | | } |
| | | |
| | | if (mObj.outSum <= 0) |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, |
| | | mObj.outMsg); |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, |
| | | mObj.outMsg); |
| | | } |
| | | } |
| | | } |