| | |
| | | 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.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using static Gs.Toolbox.UtilityHelper; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using System.Text; |
| | | using System.Dynamic; |
| | | using System.Data.SqlClient; |
| | | |
| | | |
| | | namespace GS.QC.Service; |
| | | |
| | | /// <summary> |
| | | /// 质保期方案 |
| | | /// </summary> |
| | | [ApiGroup(ApiGroupNames.QC)] |
| | | public class RkqcfaManager : IRomteService |
| | | namespace GS.QC.Service |
| | | { |
| | | private readonly IHttpContextAccessor _http; |
| | | |
| | | private readonly string _userCode, _userGuid, _orgFids; |
| | | |
| | | public RkqcfaManager(IHttpContextAccessor httpContextAccessor) |
| | | { |
| | | _http = httpContextAccessor; |
| | | (_userCode, _userGuid, _orgFids) = |
| | | GetUserGuidAndOrgGuid(_http); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 移出或移入 |
| | | /// 质保期方案 |
| | | /// </summary> |
| | | /// <param name="mode"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditModelOutIn([FromBody] dynamic mode) |
| | | [ApiGroup(ApiGroupNames.QC)] |
| | | public class RkqcfaManager : IRomteService |
| | | { |
| | | string _guid = mode.guid; |
| | | string _inFieldValue = mode.inFieldValue; |
| | | string _inItemsGuids = mode.inItemsGuids; |
| | | dynamic m = new ExpandoObject(); |
| | | m.outSum = -1; |
| | | m.outMsg = ""; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | private readonly IHttpContextAccessor _http; |
| | | |
| | | private readonly string _userCode, _userGuid, _orgFids; |
| | | public RkqcfaManager(IHttpContextAccessor httpContextAccessor) |
| | | { |
| | | using (var cmd = new SqlCommand("cqjy_itemsOutIn", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 300), |
| | | new("@outSum", SqlDbType.Int), |
| | | new("@inEdtUserGuid", _userGuid), |
| | | new("@inOrderGuid", _guid), |
| | | new("@inFieldValue", _inFieldValue), |
| | | new("@inItemsGuids", _inItemsGuids) |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | m.outMsg = parameters[0].Value.ToString(); |
| | | m.outSum = int.Parse(parameters[1].Value.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | m.outMsg = ex.Message; |
| | | LogHelper.Debug(ToString(), |
| | | "cqjy_itemsOutIn error:" + ex.Message); |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, |
| | | ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | _http = httpContextAccessor; |
| | | (_userCode, _userGuid, _orgFids) = |
| | | UtilityHelper.GetUserGuidAndOrgGuid(_http); |
| | | } |
| | | |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取编码 |
| | | /// </summary> |
| | | /// <param name="billType"></param> |
| | | /// <returns></returns> |
| | | private static string GetBillNo(string billType, string itemNo = "") |
| | | { |
| | | var sbSql = new StringBuilder(); |
| | | sbSql.Append(" DECLARE @hNo nvarchar(50) "); |
| | | sbSql.Append(" EXEC [getOrderNo] '" + billType + "',@hNo output,'" + |
| | | itemNo + "'"); |
| | | sbSql.Append(" select @hNo as t1"); |
| | | var str = ""; |
| | | try |
| | | #region |
| | | /// <summary> |
| | | /// 读取列表,支持分页 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<PageList<dynamic>> GetListPage([FromBody] PageQuery model) |
| | | { |
| | | str = DbHelperSQL.GetSingle(sbSql.ToString()).ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | str = Guid.NewGuid().ToString(); |
| | | } |
| | | |
| | | return str; |
| | | } |
| | | |
| | | #region |
| | | |
| | | /// <summary> |
| | | /// 读取列表,支持分页 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<PageList<dynamic>> GetListPage([FromBody] PageQuery model) |
| | | { |
| | | var currentPage = model.currentPage; |
| | | var everyPageSize = model.everyPageSize; |
| | | var sortName = string.IsNullOrEmpty(model.sortName) |
| | | ? "a.fabm" |
| | | : model.sortName; |
| | | var keyWhere = model.keyWhere; |
| | | var sbSql = new StringBuilder(); |
| | | sbSql.Append("select * from "); |
| | | sbSql.Append("( "); |
| | | sbSql.Append("select top 100000 ROW_NUMBER() over(order by " + |
| | | sortName + " " + model.sortOrder + |
| | | ") as rowIndex,a.* ,(case a.zt when 1 then '正常' when 0 then '禁用' end) as isStatusTxt,('('+org.FNumber+')'+org.NAME) as orgName from MES_CQJY_FA A LEFT JOIN SYS_ORGANIZATION ORG ON ORG.FID=A.fSubsidiary where 1=1" + |
| | | keyWhere); |
| | | sbSql.Append(") as T "); |
| | | sbSql.Append(" where T.rowindex>(" + currentPage + "-1)*" + |
| | | everyPageSize + " and T.rowindex<=" + currentPage + "*" + |
| | | everyPageSize); |
| | | sbSql.Append(" order by rowindex asc "); |
| | | sbSql.Append( |
| | | " select count(1) as intTotal from MES_CQJY_FA a LEFT JOIN SYS_ORGANIZATION ORG ON ORG.FID=A.fSubsidiary where 1=1 " + |
| | | keyWhere); |
| | | var dset = new DataSet(); |
| | | try |
| | | { |
| | | dset = DbHelperSQL.Query(sbSql.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "GetListPage error:" + ex.Message); |
| | | return ReturnDto<PageList<dynamic>>.QuickReturn( |
| | | default(PageList<dynamic>), ReturnCode.Exception, "读取失败"); |
| | | } |
| | | |
| | | var _pglist = new PageList<dynamic> |
| | | { |
| | | total = 0, |
| | | everyPageSize = 0, |
| | | pages = 0, |
| | | list = new List<dynamic>() |
| | | }; |
| | | if (dset != null && dset.Tables.Count > 0 && |
| | | dset.Tables[0].Rows.Count > 0) //有数据 |
| | | { |
| | | var intTotal = |
| | | int.Parse(dset.Tables[1].Rows[0]["intTotal"].ToString()); |
| | | var pages = intTotal % everyPageSize != 0 |
| | | ? intTotal / everyPageSize + 1 |
| | | : intTotal / everyPageSize; |
| | | _pglist.total = intTotal; |
| | | _pglist.everyPageSize = everyPageSize; |
| | | _pglist.pages = pages; |
| | | var _dy = dset.Tables[0].TableToDynamicList(); |
| | | _pglist.list = _dy; |
| | | } |
| | | |
| | | return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist, |
| | | ReturnCode.Success, "读取成功"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 删除实体 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<int?> DeleteModel([FromBody] dynamic model) |
| | | { |
| | | string guid = model.guid; |
| | | string mxGuid = model.mxGuid; |
| | | var rtnInt = (int)ReturnCode.Default; |
| | | var cont = 0; |
| | | try |
| | | { |
| | | cont = isChkOrUnChk(guid, 1); |
| | | if (cont > 0) |
| | | return ReturnDto<int>.QuickReturn(default(int?), |
| | | ReturnCode.Exception, "删除失败,该信息已被审核!"); |
| | | var sbCount = new StringBuilder(); |
| | | sbCount.Append( |
| | | "select COUNT(1) from [dbo].[MES_CQJY_FA_DETAIL] where pGuid='" + |
| | | guid + "'"); |
| | | cont = 0; |
| | | int currentPage = model.currentPage; |
| | | int everyPageSize = model.everyPageSize; |
| | | string sortName = string.IsNullOrEmpty(model.sortName) ? "a.fabm" : model.sortName; |
| | | string keyWhere = model.keyWhere; |
| | | System.Text.StringBuilder sbSql = new StringBuilder(); |
| | | sbSql.Append("select * from "); |
| | | sbSql.Append("( "); |
| | | sbSql.Append("select top 100000 ROW_NUMBER() over(order by " + sortName + " " + model.sortOrder + ") as rowIndex,a.* ,(case a.zt when 1 then '正常' when 0 then '禁用' end) as isStatusTxt,('('+org.FNumber+')'+org.NAME) as orgName from MES_CQJY_FA A LEFT JOIN SYS_ORGANIZATION ORG ON ORG.FID=A.fSubsidiary where 1=1" + keyWhere); |
| | | sbSql.Append(") as T "); |
| | | sbSql.Append(" where T.rowindex>(" + currentPage + "-1)*" + everyPageSize + " and T.rowindex<=" + currentPage + "*" + everyPageSize); |
| | | sbSql.Append(" order by rowindex asc "); |
| | | sbSql.Append(" select count(1) as intTotal from MES_CQJY_FA a LEFT JOIN SYS_ORGANIZATION ORG ON ORG.FID=A.fSubsidiary where 1=1 " + keyWhere); |
| | | DataSet dset = new DataSet(); |
| | | try |
| | | { |
| | | cont = int.Parse(DbHelperSQL.GetSingle(sbCount.ToString()) |
| | | .ToString()); |
| | | dset = Gs.Toolbox.DbHelperSQL.Query(sbSql.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "DeleteModel error:" + sbCount); |
| | | return ReturnDto<int>.QuickReturn(default(int?), |
| | | ReturnCode.Exception, "删除失败,请重试!"); |
| | | Gs.Toolbox.LogHelper.Debug(this.ToString(), "GetListPage error:" + ex.Message); |
| | | return ReturnDto<PageList<dynamic>>.QuickReturn(default(PageList<dynamic>), ReturnCode.Exception, "读取失败"); |
| | | } |
| | | |
| | | if (cont > 0) |
| | | return ReturnDto<int>.QuickReturn(default(int?), |
| | | ReturnCode.Exception, "请先删除下面的物料列表!"); |
| | | var strSql = new StringBuilder(); |
| | | strSql.Append(" delete from MES_CQJY_FA "); |
| | | strSql.Append(" where guid='" + guid + "'"); |
| | | var rows = DbHelperSQL.ExecuteSql(strSql.ToString()); |
| | | rtnInt = rows; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "DeleteModel error:" + ex.Message); |
| | | rtnInt = (int)ReturnCode.Exception; |
| | | return ReturnDto<int>.QuickReturn(default(int?), |
| | | ReturnCode.Exception, "删除失败," + ex.Message); |
| | | } |
| | | |
| | | if (rtnInt > 0) |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success, |
| | | "操作成功,共删除" + rtnInt + "条数据!"); |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, |
| | | "删除失败,请重试!"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 增加实体 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditModel([FromBody] dynamic model) |
| | | { |
| | | string guid = model.guid; |
| | | string famc = model.famc; |
| | | string bzqx = model.bzqx; |
| | | string fjxz = model.fjxz; |
| | | string yjrq = model.yjrq; |
| | | string bz = model.bz; |
| | | var zt = 1; |
| | | string fSubsidiary = model.fSubsidiary; |
| | | int? rtnInt = (int)ReturnCode.Default; |
| | | dynamic mObj = new ExpandoObject(); |
| | | mObj.outMsg = ""; |
| | | mObj.outSum = -1; |
| | | mObj.outGuid = ""; |
| | | mObj.outNo = ""; |
| | | |
| | | if (CheckGuid(guid)) |
| | | { |
| | | var cont = isChkOrUnChk(guid, 1); |
| | | if (cont > 0) |
| | | PageList<dynamic> _pglist = new PageList<dynamic> |
| | | { |
| | | mObj.outMsg = "删除失败,该信息已被审核!"; |
| | | mObj.outSum = -1; |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, |
| | | ReturnCode.Exception, mObj.outMsg); |
| | | total = 0, |
| | | everyPageSize = 0, |
| | | pages = 0, |
| | | list = new List<dynamic>() |
| | | }; |
| | | if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0)//有数据 |
| | | { |
| | | int intTotal = int.Parse(dset.Tables[1].Rows[0]["intTotal"].ToString()); |
| | | int pages = (intTotal % everyPageSize != 0) ? (intTotal / everyPageSize + 1) : (intTotal / everyPageSize); |
| | | _pglist.total = intTotal; |
| | | _pglist.everyPageSize = everyPageSize; |
| | | _pglist.pages = pages; |
| | | List<dynamic> _dy = dset.Tables[0].TableToDynamicList(); |
| | | _pglist.list = _dy; |
| | | } |
| | | return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist, ReturnCode.Success, "读取成功"); |
| | | } |
| | | |
| | | var fabm = ""; //方案编码 |
| | | var strSql = new StringBuilder(); |
| | | if (!CheckGuid(guid)) |
| | | |
| | | /// <summary> |
| | | /// 删除实体 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<int?> DeleteModel([FromBody] dynamic model) |
| | | { |
| | | guid = Guid.NewGuid().ToString(); |
| | | fabm = GetBillNo("JYFA(检验方案)"); |
| | | strSql.Append(" insert into MES_CQJY_FA"); |
| | | strSql.Append( |
| | | " ([guid] ,[fabm] ,[famc] ,[bzqx] ,[fjxz],[yjrq] ,[bz] ,[zt],fSubsidiary,checkStatus)"); |
| | | strSql.Append(" values("); |
| | | strSql.Append(" '" + guid + "','" + fabm + "','" + famc + "'," + |
| | | bzqx + "," + fjxz + "," + yjrq + ",'" + bz + "'," + |
| | | zt + "," + fSubsidiary + ",0)"); |
| | | } |
| | | else |
| | | { |
| | | strSql.Append(" update MES_CQJY_FA set [famc]='" + famc + |
| | | "' ,[bzqx]=" + bzqx + " ,[fjxz]=" + fjxz + |
| | | ",[yjrq]=" + yjrq + " ,[bz]='" + bz + "'"); |
| | | strSql.Append(" where guid='" + guid + "'"); |
| | | string guid = model.guid; |
| | | string mxGuid = model.mxGuid; |
| | | int rtnInt = (int)ReturnCode.Default; |
| | | int cont = 0; |
| | | try |
| | | { |
| | | cont = isChkOrUnChk(guid, 1); |
| | | if (cont > 0) |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "删除失败,该信息已被审核!"); |
| | | StringBuilder sbCount = new StringBuilder(); |
| | | sbCount.Append("select COUNT(1) from [dbo].[MES_CQJY_FA_DETAIL] where pGuid='" + guid + "'"); |
| | | cont = 0; |
| | | try |
| | | { |
| | | cont = int.Parse(DbHelperSQL.GetSingle(sbCount.ToString()).ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "DeleteModel error:" + sbCount.ToString()); |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "删除失败,请重试!"); |
| | | } |
| | | if (cont > 0) |
| | | { |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "请先删除下面的物料列表!"); |
| | | } |
| | | StringBuilder strSql = new StringBuilder(); |
| | | strSql.Append(" delete from MES_CQJY_FA "); |
| | | strSql.Append(" where guid='" + guid + "'"); |
| | | int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); |
| | | rtnInt = rows; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(this.ToString(), "DeleteModel error:" + ex.Message); |
| | | rtnInt = (int)ReturnCode.Exception; |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "删除失败," + ex.Message); |
| | | } |
| | | if (rtnInt > 0) |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success, "操作成功,共删除" + rtnInt.ToString() + "条数据!"); |
| | | else |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "删除失败,请重试!"); |
| | | } |
| | | |
| | | try |
| | | /// <summary> |
| | | /// 增加实体 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditModel([FromBody] dynamic model) |
| | | { |
| | | rtnInt = DbHelperSQL.ExecuteSql(strSql.ToString()); |
| | | mObj.outMsg = "操作成功!"; |
| | | mObj.outSum = rtnInt; |
| | | mObj.outGuid = guid; |
| | | mObj.outNo = fabm; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "EditModel error:" + ex.Message); |
| | | rtnInt = (int)ReturnCode.Exception; |
| | | mObj.outMsg = ex.Message; |
| | | string guid = model.guid; |
| | | string famc = model.famc; |
| | | string bzqx = model.bzqx; |
| | | string fjxz = model.fjxz; |
| | | string yjrq = model.yjrq; |
| | | string bz = model.bz; |
| | | int zt = 1; |
| | | string fSubsidiary = model.fSubsidiary; |
| | | int? rtnInt = (int)ReturnCode.Default; |
| | | dynamic mObj = new ExpandoObject(); |
| | | mObj.outMsg = ""; |
| | | mObj.outSum = -1; |
| | | } |
| | | mObj.outGuid = ""; |
| | | mObj.outNo = ""; |
| | | |
| | | if (mObj.outSum <= 0) |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, |
| | | mObj.outMsg); |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, |
| | | mObj.outMsg); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取实体 |
| | | /// </summary> |
| | | /// <param name="guid"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | [AllowAnonymous] |
| | | public ReturnDto<ExpandoObject> GetModel([FromBody] dynamic model) |
| | | { |
| | | dynamic m = new ExpandoObject(); |
| | | var sbSql = new StringBuilder(); |
| | | sbSql.Append(" select top 1 * from MES_CQJY_FA where 1=1 and guid='" + |
| | | model.guid.ToString() + "' "); |
| | | try |
| | | { |
| | | var dset = new DataSet(); |
| | | dset = DbHelperSQL.Query(sbSql.ToString()); |
| | | if (dset != null && dset.Tables.Count > 0 && |
| | | dset.Tables[0].Rows.Count > 0) |
| | | if (UtilityHelper.CheckGuid(guid)) |
| | | { |
| | | var dr = dset.Tables[0].Rows[0]; |
| | | m = dr.RowToDynamic(); |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, |
| | | "读取成功!"); |
| | | int cont = isChkOrUnChk(guid, 1); |
| | | if (cont > 0) |
| | | { |
| | | mObj.outMsg = "删除失败,该信息已被审核!"; |
| | | mObj.outSum = -1; |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, mObj.outMsg); |
| | | } |
| | | } |
| | | |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, |
| | | "读取失败!"); |
| | | string fabm = "";//方案编码 |
| | | StringBuilder strSql = new StringBuilder(); |
| | | if (!UtilityHelper.CheckGuid(guid)) |
| | | { |
| | | guid = Guid.NewGuid().ToString(); |
| | | fabm = GetBillNo("JYFA(检验方案)"); |
| | | strSql.Append(" insert into MES_CQJY_FA"); |
| | | strSql.Append(" ([guid] ,[fabm] ,[famc] ,[bzqx] ,[fjxz],[yjrq] ,[bz] ,[zt],fSubsidiary,checkStatus)"); |
| | | strSql.Append(" values("); |
| | | strSql.Append(" '" + guid + "','" + fabm + "','" + famc + "'," + bzqx + "," + fjxz + "," + yjrq + ",'" + bz + "'," + zt + "," + fSubsidiary + ",0)"); |
| | | } |
| | | else |
| | | { |
| | | strSql.Append(" update MES_CQJY_FA set [famc]='" + famc + "' ,[bzqx]=" + bzqx + " ,[fjxz]=" + fjxz + ",[yjrq]=" + yjrq + " ,[bz]='" + bz + "'"); |
| | | strSql.Append(" where guid='" + guid + "'"); |
| | | } |
| | | try |
| | | { |
| | | rtnInt = DbHelperSQL.ExecuteSql(strSql.ToString()); |
| | | mObj.outMsg = "操作成功!"; |
| | | mObj.outSum = rtnInt; |
| | | mObj.outGuid = guid; |
| | | mObj.outNo = fabm; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(this.ToString(), "EditModel error:" + ex.Message); |
| | | rtnInt = (int)ReturnCode.Exception; |
| | | mObj.outMsg = ex.Message; |
| | | mObj.outSum = -1; |
| | | } |
| | | if (mObj.outSum <= 0) |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, mObj.outMsg); |
| | | return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, mObj.outMsg); |
| | | } |
| | | catch (Exception ex) |
| | | |
| | | /// <summary> |
| | | /// 读取实体 |
| | | /// </summary> |
| | | /// <param name="guid"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | [AllowAnonymous] |
| | | public ReturnDto<System.Dynamic.ExpandoObject> GetModel([FromBody] dynamic model) |
| | | { |
| | | LogHelper.Debug(ToString(), "GetModel error:" + ex.Message); |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, |
| | | "读取失败!"); |
| | | dynamic m = new System.Dynamic.ExpandoObject(); |
| | | System.Text.StringBuilder sbSql = new StringBuilder(); |
| | | sbSql.Append(" select top 1 * from MES_CQJY_FA where 1=1 and guid='" + model.guid.ToString() + "' "); |
| | | try |
| | | { |
| | | DataSet dset = new DataSet(); |
| | | dset = DbHelperSQL.Query(sbSql.ToString()); |
| | | if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0) |
| | | { |
| | | System.Data.DataRow dr = dset.Tables[0].Rows[0]; |
| | | m = dr.RowToDynamic(); |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "读取成功!"); |
| | | } |
| | | else |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "读取失败!"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(this.ToString(), "GetModel error:" + ex.Message); |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "读取失败!"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 判断是否审核 |
| | | /// </summary> |
| | | /// <param name="guidList"></param> |
| | | /// <param name="status"></param> |
| | | /// <returns></returns> |
| | | private int isChkOrUnChk(string guidList, int status) |
| | | { |
| | | int cont = 0; |
| | | cont = int.Parse(DbHelperSQL.GetSingle("select count(1) from MES_CQJY_FA where guid='" + guidList + "' and isnull(checkstatus,0)=" + status + "").ToString()); |
| | | return cont; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// 移出或移入 |
| | | /// </summary> |
| | | /// <param name="mode"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> EditModelOutIn([FromBody] dynamic mode) |
| | | { |
| | | string _guid = mode.guid; |
| | | string _inFieldValue = mode.inFieldValue; |
| | | string _inItemsGuids = mode.inItemsGuids; |
| | | dynamic m = new ExpandoObject(); |
| | | m.outSum = -1; |
| | | m.outMsg = ""; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("cqjy_itemsOutIn", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 300), |
| | | new("@outSum", SqlDbType.Int), |
| | | new("@inEdtUserGuid", _userGuid), |
| | | new("@inOrderGuid", _guid), |
| | | new("@inFieldValue",_inFieldValue), |
| | | new("@inItemsGuids",_inItemsGuids), |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | m.outMsg = parameters[0].Value.ToString(); |
| | | m.outSum = int.Parse(parameters[1].Value.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | m.outMsg = ex.Message; |
| | | LogHelper.Debug(this.ToString(), "cqjy_itemsOutIn error:" + ex.Message); |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取编码 |
| | | /// </summary> |
| | | /// <param name="billType"></param> |
| | | /// <returns></returns> |
| | | private static string GetBillNo(string billType, string itemNo = "") |
| | | { |
| | | var sbSql = new StringBuilder(); |
| | | sbSql.Append(" DECLARE @hNo nvarchar(50) "); |
| | | sbSql.Append(" EXEC [getOrderNo] '" + billType + "',@hNo output,'" + |
| | | itemNo + "'"); |
| | | sbSql.Append(" select @hNo as t1"); |
| | | var str = ""; |
| | | try |
| | | { |
| | | str = DbHelperSQL.GetSingle(sbSql.ToString()).ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | str = Guid.NewGuid().ToString(); |
| | | } |
| | | return str; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断是否审核 |
| | | /// </summary> |
| | | /// <param name="guidList"></param> |
| | | /// <param name="status"></param> |
| | | /// <returns></returns> |
| | | private int isChkOrUnChk(string guidList, int status) |
| | | { |
| | | var cont = 0; |
| | | cont = int.Parse(DbHelperSQL |
| | | .GetSingle("select count(1) from MES_CQJY_FA where guid='" + |
| | | guidList + "' and isnull(checkstatus,0)=" + status + "") |
| | | .ToString()); |
| | | return cont; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |