| | |
| | | { |
| | | search += "and B.prefix like '%'+@prefix+'%' "; |
| | | dynamicParams.Add("@prefix", prefix); |
| | | } |
| | | } |
| | | if (search == "") |
| | | { |
| | | search = "and 1=1 "; |
| | |
| | | //search = search.Substring(3);//截取索引2后面的字符 |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.right_code,A.right_name,B.prefix,B.filingdate,B.incbit from TRight A |
| | | var sql = @"select A.right_code,A.right_name,B.prefix,B.filingdate,B.incbit,A.Type from TRight A |
| | | left join T_CodeRules B on A.right_code=B.rightcode |
| | | where A.parent_id<>'0' and A.is_delete<>'1' " + search + ""; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | |
| | | #endregion |
| | | |
| | | #region[编码规则编辑保存] |
| | | public static ToMessage SaveEncodingRules(string rightcode,string rightname, string prefix, string filingdate, string incbit, string lm_user) |
| | | public static ToMessage SaveEncodingRules(string rightcode, string rightname, string prefix, string filingdate, string incbit, string lm_user) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | mes.data = null; |
| | | } |
| | | } |
| | | else |
| | | else |
| | | { |
| | | //首次写入前按位数补充0 |
| | | string value = ""; |
| | |
| | | #endregion |
| | | |
| | | #region[车间公告新增编辑提交] |
| | | public static ToMessage SystemAnnouncementAddUpdate(string id,DataTable dt, string ancetitle, string ancecont, string cancel, string level,string username, string opertype) |
| | | public static ToMessage SystemAnnouncementAddUpdate(string id, DataTable dt, string ancetitle, string ancecont, string cancel, string level, string username, string opertype) |
| | | { |
| | | var sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | id=id, |
| | | id = id, |
| | | wksp_code = dt.Rows[0]["WKSP_CODE"].ToString(), |
| | | title = ancetitle, |
| | | contents = ancecont, |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[SOP列表查询] |
| | | public static ToMessage SystemSopSearch(string search, string check, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string sech = ""; |
| | | try |
| | | { |
| | | if (search != "" && search != null) |
| | | { |
| | | sech += "and concat(isnull(AA.partcode,''),isnull(AA.partname,''),isnull(AA.partname,''),isnull(AA.eqptype_name,''),isnull(AA.filetype_name,''),isnull(AA.file_name,''),isnull(AA.file_version,''),isnull(AA.username,'')) like '%@search%' "; |
| | | dynamicParams.Add("@search", search); |
| | | } |
| | | if (check == "Y") |
| | | { |
| | | sech += "and AA.rn=1 "; |
| | | dynamicParams.Add("@rn", 1); |
| | | } |
| | | |
| | | if (search == "") |
| | | { |
| | | sech = "and 1=1 "; |
| | | } |
| | | search = search.Substring(3);//截取索引2后面的字符 |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select AA.id,AA.partcode,AA.partname,AA.partspec,AA.eqptype_code,AA.eqptype_name,AA.filetype_code,AA.filetype_name,AA.file_name,AA.file_version,AA.file_path, |
| | | AA.username,AA.lm_date,AA.rn from( |
| | | select top 100 A.id,M.partcode,M.partname,M.partspec,A.eqptype_code,T.name as eqptype_name,A.filetype_code, |
| | | (case when A.filetype_code='P001' then '作业指导书' when A.filetype_code='P002' then '检验指导书' when A.filetype_code='P003' then '图纸' end) as filetype_name, |
| | | A.file_name,A.file_version,A.file_path,U.username,A.lm_date, |
| | | row_number() over(partition by A.materiel_code,A.filetype_code order by replace(A.file_version,'V','') desc) rn |
| | | from TK_Sop_Matfile A |
| | | left join TMateriel_Info M on A.materiel_code=M.partcode |
| | | left join TEqpType T on A.eqptype_code=T.code |
| | | left join TUser U on A.lm_user=U.usercode |
| | | ) as AA where " + sech + " order by AA.lm_date"; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.count = total; |
| | | mes.data = data.ToList(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件上传查找设备类型数据] |
| | | public static ToMessage SystemSopDeviceSearch() |
| | | { |
| | | string sql = ""; |
| | | try |
| | | { |
| | | //获取设备类型 |
| | | sql = @"select code,name from TEqpType order by code"; |
| | | var data = DapperHelper.selecttable(sql); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件作业文件上传获取最大版本号] |
| | | public static ToMessage SystemSopMaxVersion(string devicetypecode, string filetypecode, string partcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取SOP文件作业文件上传获取最大版本号 |
| | | sql = @"select isnull(max(substring(file_version,charindex('V',file_version)+1,len(file_version)-charindex('V',file_version))),0)+1 as file_version |
| | | from TK_Sop_Matfile where materiel_code=@partcode and eqptype_code=@devicetypecode and filetype_code=@filetypecode "; |
| | | dynamicParams.Add("@devicetypecode", devicetypecode); |
| | | dynamicParams.Add("@filetypecode", filetypecode); |
| | | dynamicParams.Add("@partcode", partcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "获取版本号成功!"; |
| | | mes.data = "V" + data.Rows[0]["version"].ToString(); |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "获取版本号失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件上传提交] |
| | | public static ToMessage SystemSopSava(string devicetypecode, string filetypecode, string partcode, string fileversion,string file_name, string defilename, string username, string strPath) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | //写入SOP文件表 |
| | | sql = @"insert into TK_Sop_Matfile(materiel_code,eqptype_code,filetype_code,file_name,define_name,file_version,file_path,lm_user,lm_date) |
| | | values(@wksp_code,@title,@contents,@if_cancel,@cancel_date,@lm_user,@lm_date,@priority)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = partcode, |
| | | eqptype_code = devicetypecode, |
| | | filetype_code = filetypecode, |
| | | file_name = file_name, |
| | | define_name = defilename, |
| | | file_version= fileversion, |
| | | file_path= strPath, |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "上传成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "上传失败!"; |
| | | mes.data = null; |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件删除] |
| | | public static ToMessage SystemSopDelete(string id, string filepath) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | sql = @"delete TK_Sop_Matfile where id=@id"; |
| | | list.Add(new { str = sql, parm = new { id = id } }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | string FilePath = System.Web.HttpContext.Current.Server.MapPath(filepath);//获取文件路径 |
| | | if (System.IO.File.Exists(FilePath))//判断文件是否存在 |
| | | { |
| | | System.IO.File.Delete(FilePath);//执行IO文件删除,需引入命名空间System.IO; |
| | | } |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "删除成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "删除失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | } |