|  |  |  | 
|---|
|  |  |  | using System.Data; | 
|---|
|  |  |  | using Newtonsoft.Json.Linq; | 
|---|
|  |  |  | using Pub_Class; | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WebAPI.Controllers | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> a = new List<object>(); | 
|---|
|  |  |  | //添加列名 | 
|---|
|  |  |  | foreach (DataColumn col in ds.Tables[0].Columns) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Type dataType = col.DataType; | 
|---|
|  |  |  | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
|---|
|  |  |  | a.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //if (ds.Tables[0].Rows.Count != 0 || ds != null) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "Sucess!"; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | objJsonResult.list = a; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //else | 
|---|
|  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 查询列表方法 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回检验方案单列表 仅包含主表 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="sWhere"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("QC_Management/MES_QC_CheckProjectList_Json_Main")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object MES_QC_CheckProjectList_Json_Main(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无查询权限"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  * from h_v_Gy_QCCheckProjectList_Main order by 日期 desc ", "h_v_Gy_QCCheckProjectList_Main"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select * from h_v_Gy_QCCheckProjectList_Main where 1=1"; | 
|---|
|  |  |  | string sql = sql1 + sWhere + " order by 日期 desc "; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_QCCheckProjectList_Main"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "没有返回任何记录!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return GetObjectJson(ds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回检验方案单列表 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  * from h_v_Gy_QCCheckProjectList order by hmainid desc ", "h_v_Gy_QCCheckProjectList"); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  * from h_v_Gy_QCCheckProjectList order by 日期 desc ", "h_v_Gy_QCCheckProjectList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select * from h_v_Gy_QCCheckProjectList where 1=1"; | 
|---|
|  |  |  | string sql = sql1 + sWhere+ " order by hmainid desc "; | 
|---|
|  |  |  | string sql = sql1 + sWhere+ " order by 日期 desc "; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_QCCheckProjectList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select * from h_v_QC_PatrolProcCheckBillList where 关闭人='' "; | 
|---|
|  |  |  | string sql = sql1 + sqlWhere+ " order by hmainid desc "; | 
|---|
|  |  |  | string sql = sql1 + sqlWhere+ " order by 制单日期 desc "; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_QC_PatrolProcCheckBillList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "ID不能为空" }; | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_NEW  where hmainid= " + HID + " ", "h_v_Gy_QCCheckProjectList_NEW"); | 
|---|
|  |  |  | var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Edit  where hmainid= " + HID + " ", "h_v_Gy_QCCheckProjectList_Edit"); | 
|---|
|  |  |  | if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "不存在生产汇报单号" }; | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "不存在检验方案" }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 检验方案查询 | 
|---|
|  |  |  | [Route("QC_Management/MES_QC_CheckProjectListProjectDetaiList")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object MES_QC_CheckProjectListProjectDetaiList(string sWhere,string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | ds = oCN.RunProcReturn(string.Format(@"select * from h_v_Gy_QCCheckProjectList_Edit where 1=1 " + sWhere), "h_v_Gy_QCCheckProjectList_Edit"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "获取信息成功!"; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "没有返回任何记录!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | ds = oCN.RunProcReturn(string.Format(@"select 次序号 HPrjNo,检验项目ID HQCCheckItemID,检验项目代码 HQCCheckItemNumber,检验项目 HQCCheckItemName, | 
|---|
|  |  |  | 检验标准 HQCStd,最大检验标准 HQCStdMax,检验单位 HQCUnit,表体备注 HRemark from h_v_Gy_QCCheckProjectList_NEW | 
|---|
|  |  |  | where hinterid='"+HInterID+"'"), "h_v_Gy_QCCheckProjectList_NEW"); | 
|---|
|  |  |  | ds = oCN.RunProcReturn(string.Format(@"select * from h_v_Gy_QCCheckProjectList_Edit where hinterid='" + HInterID+"'"), "h_v_Gy_QCCheckProjectList_Edit"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "获取信息成功!"; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "获取信息成功!"; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | oItem.HBillStatus = 0; | 
|---|
|  |  |  | oItem.HPeriod = 0; | 
|---|
|  |  |  | oItem.HMaker = ""; | 
|---|
|  |  |  | oItem.HStandard = false; | 
|---|
|  |  |  | oItem.HMainSourceInterID = oItem.HInterID; | 
|---|
|  |  |  | //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") | 
|---|
|  |  |  | 
|---|
|  |  |  | oItemSub.HRelationQty = 0; | 
|---|
|  |  |  | oItemSub.HRelationMoney = 0; | 
|---|
|  |  |  | oItemSub.HCloseMan = ""; | 
|---|
|  |  |  | oItemSub.HDestructInspect = Convert.ToInt32(oItemSub.HDestructInspect); | 
|---|
|  |  |  | oItemSub.HKeyInspect = Convert.ToInt32(oItemSub.HKeyInspect); | 
|---|
|  |  |  | oBill.DetailColl.Add(oItemSub); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 检验方案审核/反审核 | 
|---|
|  |  |  | [Route("Gy_QCCheckProject/AuditGy_QCCheckProject")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object AuditGy_QCCheckProject(string HInterID, int Type, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有审核权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Check", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无权限审核!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (string.IsNullOrWhiteSpace(HInterID)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "HInterID为空!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DAL.ClsGy_QCCheckProjectMain oBill = new DAL.ClsGy_QCCheckProjectMain(); | 
|---|
|  |  |  | ClsPub.CurUserName = user; | 
|---|
|  |  |  | oCN.BeginTran();//开始事务 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //Type 1 审核  2  反审核 | 
|---|
|  |  |  | if (Type == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断单据是否已经审核 | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | string sql = "select * from  Gy_QCCheckProjectMain  where HInterID = " + HInterID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, oBill.MvarItemKey); | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "单据已审核!不能再次审核!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //审核单据 | 
|---|
|  |  |  | if (!oBill.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断单据是否已经反审核 | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | string sql = "select * from  Gy_QCCheckProjectMain  where HInterID = " + HInterID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, oBill.MvarItemKey); | 
|---|
|  |  |  | if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "单据未审核!不需要反审核!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //反审核单据 | 
|---|
|  |  |  | if (!oBill.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.Commit();//提交事务 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "执行成功!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "执行失败!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 来料检验 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 保存来料检验单 | 
|---|