Commit fc40bd0a by Seniorious

1

parent f3ff8f67
......@@ -7,6 +7,7 @@ using Common.Utility.Model;
using Common.Utility.RabbitMQ;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.CodeAnalysis;
using Microsoft.IdentityModel.Tokens;
using Models.SqlModel;
using Models.Table;
......@@ -15,12 +16,14 @@ using Newtonsoft.Json;
using Services;
using Services.Interface;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq.Expressions;
using System.Security.Cryptography.Xml;
using static Microsoft.AspNetCore.Razor.Language.TagHelperMetadata;
using static System.Net.Mime.MediaTypeNames;
namespace APIs.Controllers
{
......@@ -53,6 +56,80 @@ namespace APIs.Controllers
}
/// <summary>
/// 3.0平台获取图片
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public IActionResult DownloadLogPicture(string id)
{
try
{
// 读取文件内容
byte[] fileBytes = System.IO.File.ReadAllBytes($"LogPictures\\{id}.jpg");
// 获取文件的MIME类型
string contentType = "application/octet-stream"; // 默认使用二进制流的MIME类型,如果需要根据具体文件类型动态获取,请进行适当的处理。
// 返回文件结果
return File(fileBytes, contentType, $"{id}.jpg");
}
catch (Exception ex)
{
return new ContentResult
{
Content = "ERROR:" + ex,
ContentType = "text/plain",
StatusCode = 400
};
}
}
/// <summary>
/// 获取出入库照片
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult> GetLogPicture([FromBody] GetLogPictureReq req)
{
try
{
//读取图片
string imageBytes = "";
string url = $"LogPictures\\{req.logId}.jpg";
using (FileStream fileStream = new FileStream(url, FileMode.Open))
{
using (BinaryReader reader = new BinaryReader(fileStream))
{
imageBytes = Convert.ToBase64String(reader.ReadBytes((int)fileStream.Length));
}
}
var res = new DownloadPicRes() { picture = imageBytes };
var src = new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
msg = ResultCode.OPERATE_SUCCESS.Msg,
data = res
};
return src;
}
catch (Exception ex)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ex.Message,
};
return error;
}
}
/// <summary>
/// 获取账号
/// </summary>
/// <param name=""></param>
......@@ -175,7 +252,7 @@ namespace APIs.Controllers
{
try
{
Expression<Func<Inventory, bool>> expression = s => /*!s.lostFlag.Equals("1") &&*/ !s.bussinessState.Equals("destruction");
Expression<Func<Inventory, bool>> expression = s => s.locationType != "1" && !s.bussinessState.Equals("destruction");
var invlist = await _inventoryService.Query(expression);
if (invlist == null)
......@@ -240,7 +317,7 @@ namespace APIs.Controllers
/// <param name=""></param>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult> DeletePictureById([FromBody] DelPicReq req)
public async Task<ApiResult> DeletePictureById([FromForm] DelPicReq req)
{
try
{
......@@ -401,7 +478,7 @@ namespace APIs.Controllers
Directory.CreateDirectory(path);
var filePath = Path.Combine(path, fileName);
Image.FromStream(ms).Save(filePath);
System.Drawing.Image.FromStream(ms).Save(filePath);
//更新警员照片地址
police.picUrl = filePath;
......
......@@ -21,4 +21,9 @@
public string picture { get; set; }
}
public class GetLogPictureReq
{
public string logId { get; set;}
}
}
......@@ -54,11 +54,21 @@ namespace Repositories.Repository.Bussiness
//var invs = await context.Queryable<Inventory>().Where(x =>
//model.DetailList.Select(x => x.epc).Contains(x.epc)).ToListAsync();
var cabinetInv = inv.Where(s => s.state == "0").ToList();
for(int i = 0; i < cabinetInv.Count(); i++)
{
cabinetInv[i].locationType = "1";
}
context.BeginTran();
context.Updateable(cars).WhereColumns(it => new { it.id }).UpdateColumns(it => new { it.state, it.updateTime }).ExecuteCommand();//实体有多少列更新多少列
var result = context.Updateable(inv).WhereColumns(it => new { it.epc }).UpdateColumns(it => new { it.state, it.updateTime }).ExecuteCommand();//实体有多少列更新多少列
var result1 = context.Updateable(cabinetInv).WhereColumns(it => new { it.epc }).UpdateColumns(it => new { it.locationType }).ExecuteCommand();
var logSum = context.InsertNav(model)
.Include(z1 => z1.DetailList)
.ExecuteCommand();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论