| | |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Globalization; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | |
| | | { |
| | | [RoutePrefix(prefix: "api/SystemSetting")] |
| | | [ControllerGroup("系统设置", "在线接口")] |
| | | [ChannelActionFilter] |
| | | public class SystemSettingController : ApiController |
| | | { |
| | | //定义全局信息返回变量 |
| | | ToMessage mes = new ToMessage(); |
| | | RedisHelper redis = new RedisHelper(); |
| | | string FileIP = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; |
| | | |
| | | #region[编码规则查询] |
| | | /// <summary> |
| | |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[车间公告列表] |
| | | /// <summary> |
| | | /// 车间公告列表 |
| | | /// </summary> |
| | | /// <param name="wkspcode">车间编码</param> |
| | | /// <param name="ancetitle">公告主题</param> |
| | | /// <param name="ancecont">公告内容</param> |
| | | /// <param name="cancel">是否撤销</param> |
| | | /// <param name="level">公告等级</param> |
| | | /// <param name="page">页码</param> |
| | | /// <param name="rows">每页显示条数</param> |
| | | /// <param name="prop">排序字段</param> |
| | | /// <param name="order">排序规则</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemAnnouncementSearch")] |
| | | [HttpGet] |
| | | public HttpResponseMessage SystemAnnouncementSearch(string wkspcode = null, string ancetitle = null,string ancecont=null,string cancel=null,string level=null, int page = 0, int rows = 0, string prop = null, string order = null) |
| | | { |
| | | int startNum = rows * (page - 1) + 1; //起始记录rowNum |
| | | int endNum = rows * page; //结束记录 rowNum |
| | | mes = SystemSettingBLL.SystemAnnouncementSearch(wkspcode, ancetitle, ancecont, cancel, level, startNum, endNum, prop, order); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[车间公告新增编辑提交] |
| | | /// <summary> |
| | | /// 车间公告新增编辑提交 |
| | | /// </summary> |
| | | /// <param name="id">id</param> |
| | | /// <param name="dt">车间集合</param> |
| | | /// <param name="ancetitle">公告主题</param> |
| | | /// <param name="ancecont">公告内容</param> |
| | | /// <param name="level">公告等级</param> |
| | | /// <param name="cancel">是否撤销</param> |
| | | /// <param name="opertype">操作类型</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemAnnouncementAddUpdate")] |
| | | [HttpPost] |
| | | public HttpResponseMessage SystemAnnouncementAddUpdate(DataTable dt,string ancetitle,string ancecont,string level,string cancel,string opertype, string id = null) |
| | | { |
| | | var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员 |
| | | mes = SystemSettingBLL.SystemAnnouncementAddUpdate(id,dt, ancetitle, ancecont, cancel, level, username, opertype); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[车间公告删除] |
| | | /// <summary> |
| | | /// 车间公告删除 |
| | | /// </summary> |
| | | /// <param name="id">id</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemAnnouncementDelete")] |
| | | [HttpPost] |
| | | public HttpResponseMessage SystemAnnouncementDelete(string id) |
| | | { |
| | | mes = SystemSettingBLL.SystemAnnouncementDelete(id); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[SOP列表查询] |
| | | /// <summary> |
| | | /// SOP列表查询 |
| | | /// </summary> |
| | | /// <param name="search">搜索关键字</param> |
| | | /// <param name="check">是否选中最高版本</param> |
| | | /// <param name="page">页码</param> |
| | | /// <param name="rows">每页显示条数</param> |
| | | /// <param name="prop">排序字段</param> |
| | | /// <param name="order">排序规则</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemSopSearch")] |
| | | [HttpGet] |
| | | public HttpResponseMessage SystemSopSearch(string search = null, string check = null,int page = 0, int rows = 0, string prop = null, string order = null) |
| | | { |
| | | int startNum = rows * (page - 1) + 1; //起始记录rowNum |
| | | int endNum = rows * page; //结束记录 rowNum |
| | | mes = SystemSettingBLL.SystemSopSearch(search, check, startNum, endNum, prop, order); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件上传查找设备类型数据] |
| | | /// <summary> |
| | | /// SOP文件上传查找设备类型数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemSopDeviceSearch")] |
| | | [HttpGet] |
| | | public HttpResponseMessage SystemSopDeviceSearch() |
| | | { |
| | | mes = SystemSettingBLL.SystemSopDeviceSearch(); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件作业文件上传获取最大版本号] |
| | | /// <summary> |
| | | /// SOP文件作业文件上传获取最大版本号 |
| | | /// </summary> |
| | | /// <param name="devicetypecode">设备类型编号</param> |
| | | /// <param name="filetypecode">文件类型编号</param> |
| | | /// <param name="partcode">物料编码</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemSopMaxVersion")] |
| | | [HttpGet] |
| | | public HttpResponseMessage SystemSopMaxVersion(string devicetypecode,string filetypecode,string partcode) |
| | | { |
| | | mes = SystemSettingBLL.SystemSopMaxVersion(devicetypecode, filetypecode, partcode); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件上传提交] |
| | | /// <summary> |
| | | /// SOP文件上传提交 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemSopSava")] |
| | | [HttpPost] |
| | | public HttpResponseMessage SystemSopSava() |
| | | { |
| | | string savePath = ""; |
| | | HttpPostedFile files = HttpContext.Current.Request.Files[0];//获取上传的文件 |
| | | string devicetypecode = HttpContext.Current.Request["devicetypecode"].ToString();//设备类型编码 |
| | | string partcode = HttpContext.Current.Request["partcode"].ToString();//物料编码 |
| | | string filetypecode = HttpContext.Current.Request["filetypecode"].ToString();//文件类型编码 |
| | | string fileversion = HttpContext.Current.Request["fileversion"].ToString();//文件版本号 |
| | | string defilename = HttpContext.Current.Request["defilename"].ToString();//文件名称 |
| | | var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员 |
| | | if (files == null || files.ContentLength <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "文件不能为空!"; |
| | | } |
| | | else |
| | | { |
| | | |
| | | string file_name = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo) + Path.GetFileName(files.FileName); //时间戳加文件名 |
| | | int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte |
| | | string fileEx = System.IO.Path.GetExtension(file_name);//获取上传文件的扩展名 |
| | | int Maxsize = 40000 * 1024;//定义上传文件的最大空间大小为40M |
| | | string FileType = ".pdf";//定义上传文件的类型字符串 |
| | | string FileType1 = ".mp4";//定义上传文件的类型字符串 |
| | | |
| | | if (!FileType.Contains(fileEx) && !FileType1.Contains(fileEx)) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "文件类型不对,只能导入pdf格式的文件和mp4格式文件!"; |
| | | } |
| | | else |
| | | { |
| | | if (filesize >= Maxsize) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "上传文件超过40M,不能上传!"; |
| | | } |
| | | else |
| | | { |
| | | string path = System.Web.HttpContext.Current.Server.MapPath("/File/DeviceFile/"); |
| | | |
| | | if (Directory.Exists(path) == false)//如果不存在就创建file文件夹 |
| | | { |
| | | Directory.CreateDirectory(path); //添加文件夹 |
| | | } |
| | | savePath = Path.Combine(path, file_name); |
| | | if (Directory.Exists(savePath) == true) //如果存在重名文件就提示 |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "已存在同名文件!"; |
| | | } |
| | | else |
| | | { |
| | | files.SaveAs(savePath); //将选择的文件保存到指定文件夹下 |
| | | string FilesName = System.Web.HttpContext.Current.Server.MapPath("/File/DeviceFile/" + file_name); |
| | | string StrPath = "/File/DeviceFile/" + file_name; |
| | | mes = SystemSettingBLL.SystemSopSava(devicetypecode, filetypecode, partcode,fileversion,file_name,defilename,username, StrPath); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件删除] |
| | | /// <summary> |
| | | /// SOP文件删除 |
| | | /// </summary> |
| | | /// <param name="id">文件id</param> |
| | | /// <param name="filepath">文件地址</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemSopDelete")] |
| | | [HttpPost] |
| | | public HttpResponseMessage SystemSopDelete(string id,string filepath) |
| | | { |
| | | mes = SystemSettingBLL.SystemSopDelete(id,filepath); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[SOP文件预览] |
| | | /// <summary> |
| | | /// SOP文件预览 |
| | | /// </summary> |
| | | /// <param name="id">文件id</param> |
| | | /// <param name="filepath">文件地址</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SystemSopView")] |
| | | [HttpPost] |
| | | public HttpResponseMessage SystemSopView(string id, string filepath) |
| | | { |
| | | mes.code = "200"; |
| | | mes.data = Url.Content(FileIP + filepath); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | } |
| | | } |