| | |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[查询工单基础资料] |
| | | [Route(template: "WrkOrderDataSelect")] |
| | | [HttpGet] |
| | | public JsonResult WrkOrderDataSelect() |
| | | { |
| | | mes = GeneralBasicDataBLL.WrkOrderDataSelect(); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | return Json(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: "WrkOrderSearch")] |
| | | [HttpGet] |
| | | public JsonResult WrkOrderSearch(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 = SopManageMentBLL.WrkOrderSearch(search, check, startNum, endNum, prop, order); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,工单SOP上传获取最大版本号] |
| | | /// <summary> |
| | | /// 系统设置,工单SOP上传获取最大版本号 |
| | | /// </summary> |
| | | /// <param name="wocode">工单编号</param> |
| | | /// <param name="partcode">物料编码</param> |
| | | /// <param name="filetypecode">文件类型编码</param> |
| | | /// <returns></returns> |
| | | [Route(template: "WrkOrderSopMaxVersion")] |
| | | [HttpGet] |
| | | public JsonResult WrkOrderSopMaxVersion(string wocode, string partcode, string filetypecode) |
| | | { |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = SopManageMentBLL.WrkOrderSopMaxVersion(wocode, partcode, filetypecode, us); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,工单SOP新增] |
| | | /// <summary> |
| | | /// 系统设置,工单SOP新增 |
| | | /// </summary> |
| | | /// <param name="wocode">工单编号</param> |
| | | /// <param name="partcode">物料编码</param> |
| | | /// <param name="filename">文件名称</param> |
| | | /// <param name="filetypecode">文件类型编码</param> |
| | | /// <param name="file">上传文件</param> |
| | | /// <param name="version">版本号</param> |
| | | /// <returns></returns> |
| | | [Route(template: "WrkOrderSopAddSeave")] |
| | | [HttpPost] |
| | | public JsonResult WrkOrderSopAddSeave([FromForm] string wocode, [FromForm] string partcode, [FromForm] string filename, [FromForm] string filetypecode, [FromForm] string version, IFormFile file) |
| | | { |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = SopManageMentBLL.WrkOrderSopAddSeave(wocode, partcode, filename, filetypecode, version, file, us); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,工单SOP删除] |
| | | /// <summary> |
| | | /// 系统设置,工单SOP删除 |
| | | /// </summary> |
| | | /// <param name="id">数据id</param> |
| | | /// <param name="wocode">工单编号</param> |
| | | /// <param name="partcode">物料编码</param> |
| | | /// <param name="filepath">文件路径</param> |
| | | /// <returns></returns> |
| | | [Route(template: "WrkOrderSopDeleteSeave")] |
| | | [HttpPost] |
| | | public JsonResult WrkOrderSopDeleteSeave(string id, string wocode, string partcode, string filepath) |
| | | { |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = SopManageMentBLL.WrkOrderSopDeleteSeave(id, wocode, partcode, filepath, us); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | return GeneralBasicDataDAL.MouldRepairItemSelect(); |
| | | } |
| | | #endregion |
| | | |
| | | #region[查询工单/产品基础资料] |
| | | public static ToMessage WrkOrderDataSelect() |
| | | { |
| | | return GeneralBasicDataDAL.WrkOrderDataSelect(); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[系统设置,工艺SOP上传获取最大版本号] |
| | | public static ToMessage ProcessSopMaxVersion(string partcode, string routecode, string stepcode, string filetypecode, User us) |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,设备SOP新增] |
| | | #region[系统设置,工艺SOP新增] |
| | | public static ToMessage ProcessSopAddSeave(string partcode, string routecode, string stepcode, string filename, string filetypecode,string version, IFormFile file, User us) |
| | | { |
| | | return SopManageMentDAL.ProcessSopAddSeave(partcode, routecode, stepcode, filename, filetypecode, version, file, us); |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,设备SOP删除] |
| | | #region[系统设置,工艺SOP删除] |
| | | public static ToMessage ProcessSopDeleteSeave(string id, string partcode,string routecode,string stepcode, string filepath, User us) |
| | | { |
| | | return SopManageMentDAL.ProcessSopDeleteSeave(id, partcode, routecode, stepcode, filepath, us); |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[系统设置,工单SOP查询] |
| | | public static ToMessage WrkOrderSearch(string search, string check, int startNum, int endNum, string prop, string order) |
| | | { |
| | | return SopManageMentDAL.WrkOrderSearch(search, check, startNum, endNum, prop, order); |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,工单SOP上传获取最大版本号] |
| | | public static ToMessage WrkOrderSopMaxVersion(string wocode, string partcode, string filetypecode, User us) |
| | | { |
| | | return SopManageMentDAL.WrkOrderSopMaxVersion(wocode, partcode, filetypecode, us); |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,工单SOP新增] |
| | | public static ToMessage WrkOrderSopAddSeave(string wocode, string partcode, string filename, string filetypecode, string version, IFormFile file, User us) |
| | | { |
| | | return SopManageMentDAL.WrkOrderSopAddSeave(wocode, partcode, filename, filetypecode, version, file, us); |
| | | } |
| | | #endregion |
| | | |
| | | #region[系统设置,工单SOP删除] |
| | | public static ToMessage WrkOrderSopDeleteSeave(string id, string wocode, string partcode, string filepath, User us) |
| | | { |
| | | return SopManageMentDAL.WrkOrderSopDeleteSeave(id, wocode, partcode, filepath, us); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[查询工单/产品基础资料] |
| | | public static ToMessage WrkOrderDataSelect() |
| | | { |
| | | string sql = ""; |
| | | try |
| | | { |
| | | sql = @"select P.wo_code,P.materiel_code,M.partname as materiel_name |
| | | from TK_Wrk_Man P |
| | | left join TMateriel_Info M on P.materiel_code=M.partcode"; |
| | | 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 |
| | | } |
| | | } |
| | |
| | | LogHelper.DbOperateLog(us.usercode, "新增工艺SOP", "产品:"+partcode+" SOP文件:" + file.FileName + " 工艺路线:" + routecode ?? "" + " 工序:" + stepcode.ToString(), us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "新增设备SOP成功!"; |
| | | mes.message = "新增工艺SOP成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = "新增设备SOP失败!"; |
| | | mes.message = "新增工艺SOP失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[系统设置,工单SOP查询] |
| | | public static ToMessage WrkOrderSearch(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.wo,''),isnull(AA.materielcode,''),isnull(AA.materielname,''),isnull(AA.filetypecode,''),isnull(AA.filetypename,''),isnull(AA.filename,''),isnull(AA.version,''),isnull(AA.username,'')) like '%'+@search+'%' "; |
| | | dynamicParams.Add("@search", search); |
| | | } |
| | | if (check == "Y") |
| | | { |
| | | sech += "and AA.rn=1 "; |
| | | dynamicParams.Add("@rn", 1); |
| | | } |
| | | |
| | | if (sech == "") |
| | | { |
| | | sech = "and 1=1 "; |
| | | } |
| | | sech = sech.Substring(3);//截取索引2后面的字符 |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select AA.id,AA.wo,AA.materielcode,AA.materielname,AA.filetypecode,AA.filetypename,AA.filename,AA.version,AA.filepath, |
| | | AA.username,AA.lm_date,AA.rn from( |
| | | select top 100 A.id,A.wo,A.materielcode,M.partname as materielname,A.filetypecode, |
| | | (case when A.filetypecode='P001' then '作业指导书' when A.filetypecode='P002' then '检验指导书' when A.filetypecode='P003' then '图纸' end) as filetypename, |
| | | A.filename,A.version,A.filepath,U.username,A.lm_date, |
| | | row_number() over(partition by A.wo,A.materielcode,A.filetypecode order by replace(A.version,'V','') desc) rn |
| | | from TWrkOrderSop A |
| | | left join TMateriel_Info M on A.materielcode=M.partcode |
| | | left join TUser U on A.lm_user=U.usercode |
| | | ) as AA where " + sech + ""; |
| | | 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 WrkOrderSopMaxVersion(string wocode, string partcode, string filetypecode, User us) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取SOP文件作业文件上传获取最大版本号 |
| | | sql = @"select isnull(max(substring(version,charindex('V',version)+1,len(version)-charindex('V',version))),0)+1 as file_version |
| | | from TWrkOrderSop where wo=@wo and materielcode=@materielcode and filetypecode=@filetypecode "; |
| | | dynamicParams.Add("@wo", wocode); |
| | | dynamicParams.Add("@materielcode", partcode); |
| | | dynamicParams.Add("@filetypecode", filetypecode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.message = "获取版本号成功!"; |
| | | mes.data = "V" + data.Rows[0]["file_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 WrkOrderSopAddSeave(string wocode, string partcode, string filename, string filetypecode, string version, IFormFile file, User us) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | if (file == null || file.Length <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.message = "文件不能为空!"; |
| | | } |
| | | else |
| | | { |
| | | //获取上传文件,组合存储路径 |
| | | string FileName = "SOP" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
| | | string filePath = "wwwroot/WrkOrderSopFile/" + FileName + file.FileName; //通过此对象获取文件名(存文件地址) |
| | | string filePath1 = "WrkOrderSopFile/" + FileName + file.FileName; //通过此对象获取文件名(存数据表地址) |
| | | |
| | | // 保存文件var stream = new FileStream(filePath, FileMode.Create) |
| | | using (var stream = new FileStream(filePath, FileMode.Create)) |
| | | { |
| | | file.CopyTo(stream); |
| | | } |
| | | //写入设备SOP表 |
| | | sql = @"insert into TWrkOrderSop(wo,materielcode,filetypecode,filename,filepath,version,lm_user,lm_date) |
| | | values(@wo,@materielcode,@filetypecode,@filename,@filepath,@version,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo=wocode, |
| | | materielcode = partcode, |
| | | filetypecode = filetypecode, |
| | | filename = file.FileName, |
| | | filepath = filePath1, |
| | | version = version, |
| | | lm_user = us.usercode, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "新增工单SOP", "工单:" + wocode + "产品:" + partcode + " SOP文件:" + file.FileName, us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "新增工单SOP成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = "新增工单SOP失败!"; |
| | | 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 WrkOrderSopDeleteSeave(string id, string wocode, string partcode, string filepath, User us) |
| | | { |
| | | var sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | //查询当前文件出去当前删除的,是否还被其他引用 |
| | | sql = @"select * from TWrkOrderSop where id<>@id and filepath=@filepath"; |
| | | dynamicParams.Add("@id", id); |
| | | dynamicParams.Add("@filepath", filepath); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count <= 0) |
| | | { |
| | | // 构建完整的文件路径 |
| | | var filePath = Path.Combine("wwwroot", filepath); |
| | | // 删除文件 |
| | | System.IO.File.Delete(filePath); |
| | | } |
| | | sql = @"delete TWrkOrderSop where id=@id"; |
| | | list.Add(new { str = sql, parm = new { id = id } }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "删除工艺SOP", "工单:" + wocode + "产品:" + partcode + " SOP文件地址:" + filepath, us.usertype); |
| | | 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 |
| | | |
| | | } |
| | | } |
| | |
| | | <Folder Include="wwwroot\MouldRecordImage\" /> |
| | | <Folder Include="wwwroot\DeviceSopFile\" /> |
| | | <Folder Include="wwwroot\ProcessSopFile\" /> |
| | | <Folder Include="wwwroot\WrkOrderSopFile\" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |