| | |
| | | decimal? id = data["id"]?.ToObject<decimal>(); |
| | | string? no = data["no"]?.ToString(); |
| | | string? user = data["user"]?.ToString(); |
| | | decimal? mnum = data["mnum"]?.ToObject<decimal?>(); |
| | | string? dnum = data["dnum"]?.ToString(); |
| | | |
| | | var (result, message) = new SJService().GenUpdate(id, no, user); |
| | | var (result, message) = new SJService().GenUpdate(id, no, user, mnum, dnum); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.result = result; |
| | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取附件信息 |
| | | /// </summary> |
| | | /// <param name="data">包含itemNo的JSON对象</param> |
| | | /// <returns>附件列表</returns> |
| | | [HttpPost("getAttachments")] |
| | | public ResponseResult GetAttachments([FromBody] JObject data) |
| | | { |
| | | var itemNo = data["itemNo"]?.ToString(); |
| | | try |
| | | { |
| | | dynamic resultInfos = new System.Dynamic.ExpandoObject(); |
| | | var tbBillList = new SJService().GetAttachments(itemNo); |
| | | if (tbBillList == null || tbBillList.Count == 0) |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "该检验单未上传附件信息!", |
| | | data = null |
| | | }; |
| | | } |
| | | resultInfos.tbBillList = tbBillList; |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 预览FTP文件 |
| | | /// </summary> |
| | | /// <param name="itemNo">物料编码</param> |
| | | /// <param name="fileName">文件名</param> |
| | | /// <param name="ftpServer">FTP服务器地址</param> |
| | | /// <returns>文件内容</returns> |
| | | [HttpGet("PreviewFtpFile")] |
| | | public IActionResult PreviewFtpFile([FromQuery] string itemNo, [FromQuery] string fileName, [FromQuery] string ftpServer) |
| | | { |
| | | try |
| | | { |
| | | var fileBytes = new SJService().GetFtpFile(itemNo, fileName, ftpServer); |
| | | if (fileBytes == null) |
| | | { |
| | | return NotFound(new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "文件不存在或无法访问", |
| | | data = null |
| | | }); |
| | | } |
| | | |
| | | var contentType = new SJService().GetContentType(fileName); |
| | | return File(fileBytes, contentType, fileName); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return StatusCode(500, new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = ex.Message, |
| | | data = null |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下载FTP文件 |
| | | /// </summary> |
| | | /// <param name="itemNo">物料编码</param> |
| | | /// <param name="fileName">文件名</param> |
| | | /// <param name="ftpServer">FTP服务器地址</param> |
| | | /// <returns>文件下载</returns> |
| | | [HttpGet("DownloadFtpFile")] |
| | | public IActionResult DownloadFtpFile([FromQuery] string itemNo, [FromQuery] string fileName, [FromQuery] string ftpServer) |
| | | { |
| | | try |
| | | { |
| | | var fileBytes = new SJService().GetFtpFile(itemNo, fileName, ftpServer); |
| | | if (fileBytes == null) |
| | | { |
| | | return NotFound(new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "文件不存在或无法访问", |
| | | data = null |
| | | }); |
| | | } |
| | | |
| | | var contentType = new SJService().GetContentType(fileName); |
| | | |
| | | // 设置下载响应头 |
| | | Response.Headers.Add("Content-Disposition", $"attachment; filename=\"{fileName}\""); |
| | | |
| | | return File(fileBytes, contentType, fileName); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return StatusCode(500, new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = ex.Message, |
| | | data = null |
| | | }); |
| | | } |
| | | } |
| | | } |