Commit afc4a833 by Seniorious

手持机加盘盈

parent 2f0d3ead
......@@ -7,6 +7,7 @@ using Common.Utility.Model;
using Common.Utility.RabbitMQ;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.IdentityModel.Tokens;
using Models.SqlModel;
using Models.Table;
using Models.ToolsModel;
......@@ -17,6 +18,7 @@ using SqlSugar;
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;
......@@ -34,8 +36,10 @@ namespace APIs.Controllers
private readonly IInventoryService _inventoryService;
private readonly IInvService _invService;
private readonly IUsersService _usersService;
private readonly ILogService _logService;
public BaseInfoController(IMapper mapper,IPoliceService policeService, IEquipmentTypeService equipmentTypeService,
IEquipmentSizeService equipmentSizeService,ICarService carService, IInventoryService inventoryService, IInvService invService, IUsersService usersService)
IEquipmentSizeService equipmentSizeService,ICarService carService, IInventoryService inventoryService,
IInvService invService, IUsersService usersService, ILogService logService)
{
_carService = carService;
_equipmentSizeService = equipmentSizeService;
......@@ -44,6 +48,7 @@ namespace APIs.Controllers
_inventoryService = inventoryService;
_invService = invService;
_usersService = usersService;
_logService = logService;
Mapper = mapper;
}
......@@ -85,11 +90,11 @@ namespace APIs.Controllers
/// <param name=""></param>
/// <returns></returns>
[HttpPost]
public virtual async Task<ApiResult> UploadHandRecord([FromBody] Models.ReqModel.InvReq req)
public virtual async Task<ApiResult> UploadHandRecord([FromBody] HandRecordsReq req)
{
try
{
var rs = _invService.AddInvLogs(req).Result;
var rs = await _logService.AddHandLogs(req);
var src = rs ? new ApiResult
{
......@@ -123,7 +128,20 @@ namespace APIs.Controllers
{
try
{
var rs = _invService.AddInvLogs(req).Result;
Expression<Func<Inventory, bool>> expression = s => s.lostFlag == "1";
var inv = await _inventoryService.Query(expression);
var lostInv = inv?.Select(s => new Inventory()
{
id = s.id,
epc = s.epc,
typeName = s.typeName,
sizeName = s.sizeName,
lostFlag = "0",
updateTime = DateTime.Now,
}).ToList();
var rs = _invService.AddInvLogs(req, lostInv).Result;
var src = rs ? new ApiResult
{
......@@ -157,7 +175,8 @@ namespace APIs.Controllers
{
try
{
var invlist = await _inventoryService.Query();
Expression<Func<Inventory, bool>> expression = s => /*!s.lostFlag.Equals("1") &&*/ !s.bussinessState.Equals("destruction");
var invlist = await _inventoryService.Query(expression);
if (invlist == null)
{
......@@ -169,17 +188,33 @@ namespace APIs.Controllers
return error;
}
var inv = invlist.Select(s => new
var baseinv = invlist.Select(s => new
{
id = s.id,
typeId = s.typeId,
typeName = s.typeName,
sizeId = s.sizeId,
sizeName = s.sizeName,
equipId = s.id,
epc = s.epc,
state = s.state,
}).ToList();
var inv = baseinv.GroupBy(x => new { x.typeId, x.typeName, x.sizeName, x.sizeId })
.Select(s => new
{
typeId = s.Key.typeId,
typeName = s.Key.typeName,
sizeId = s.Key.sizeId,
sizeName = s.Key.sizeName,
epcList = baseinv.Where(a => a.sizeId.Equals(s.Key.sizeId))
.Select(b => new
{
equipId = b.equipId,
epc = b.epc,
state = b.state,
}).ToList()
}).ToList();
var src = new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
......
......@@ -9,6 +9,6 @@ namespace Repositories.IRepository.IBussiness
{
public interface IInvSummaryRepository : IBaseRepository<InvSummary>
{
Task<bool> AddInvLogs(InvSummary model, List<Inventory> inList, List<Inventory> lostList);
Task<bool> AddInvLogs(InvSummary model, List<Inventory> inList, List<Inventory> lostList, List<Inventory> getList);
}
}
......@@ -19,7 +19,7 @@ namespace Repositories.Repository.Bussiness
_suger = sugarUnitOfWork;
}
public async Task<bool> AddInvLogs(InvSummary model, List<Inventory> inList, List<Inventory> lostList)
public async Task<bool> AddInvLogs(InvSummary model, List<Inventory> inList, List<Inventory> lostList, List<Inventory> getList)
{
using (var context = _suger.GetDbClient())
{
......@@ -31,6 +31,8 @@ namespace Repositories.Repository.Bussiness
var result2 = context.Updateable(lostList).WhereColumns(it => new { it.id }).UpdateColumns(it => new { it.lostFlag, it.updateTime }).ExecuteCommand();
var result3 = context.Updateable(getList).WhereColumns(it => new { it.id }).UpdateColumns(it => new { it.lostFlag, it.updateTime }).ExecuteCommand();
var linvSum = context.InsertNav(model)
.Include(z1 => z1.DetailList)
.ExecuteCommand();
......
......@@ -11,6 +11,6 @@ namespace Services.Interface
{
public interface IInvService : IBaseServices<InvSummary>
{
Task<bool> AddInvLogs(InvReq model);
Task<bool> AddInvLogs(InvReq model, List<Inventory> lostList);
}
}
......@@ -25,7 +25,7 @@ namespace Services
mapper = _mapper;
}
public Task<bool> AddInvLogs(InvReq model)
public Task<bool> AddInvLogs(InvReq model, List<Inventory> lostInv)
{
InvSummary inv = new InvSummary()
{
......@@ -34,7 +34,6 @@ namespace Services
useName = model.userName,
invSum = model.invSum,
resultSum = model.resultSum,
overView = model.overView,
createTime = DateTime.Now,
updateTime = DateTime.Now,
};
......@@ -50,6 +49,7 @@ namespace Services
{
id = detail.invId,
state = "0",
updateTime = DateTime.Now
});
}else if(detail.state == 1)
{
......@@ -57,22 +57,52 @@ namespace Services
{
id = detail.invId,
lostFlag = "1",
updateTime = DateTime.Now
});
}
inv.DetailList.Add(new InvDetail()
if(detail.state != 2)
{
invId = detail.invId,
typeName = detail.typeName,
sizeName = detail.sizeName,
epc = detail.epc,
state = detail.state,
createTime = DateTime.Now,
updateTime = DateTime.Now,
});
inv.DetailList.Add(new InvDetail()
{
invId = detail.invId,
typeName = detail.typeName,
sizeName = detail.sizeName,
epc = detail.epc,
state = detail.state,
createTime = DateTime.Now,
updateTime = DateTime.Now,
});
}
}
return _invSummaryRepository.AddInvLogs(inv, inList, lostList);
var lostIds = lostList.Select(s => s.id);
List<Inventory> addList = new List<Inventory>();
foreach(var item in lostInv)
{
if (!lostIds.Contains(item.id))
{
addList.Add(item);
}
}
inv.DetailList.AddRange(lostInv.Select(s => new InvDetail()
{
invId = s.id,
typeName = s.typeName,
sizeName = s.sizeName,
epc = s.epc,
state = 2,
createTime = DateTime.Now,
updateTime = DateTime.Now,
}).ToList());
inv.overView = $"盘盈{addList.Count()}件,盘亏{lostList.Count()}件,更新在库{inList.Count()}件";
return _invSummaryRepository.AddInvLogs(inv, inList, lostList, lostInv);
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论