Commit 2f0d3ead by Seniorious

手持机接口完善

parent 61423228
......@@ -33,8 +33,9 @@ namespace APIs.Controllers
private readonly ICarService _carService;
private readonly IInventoryService _inventoryService;
private readonly IInvService _invService;
private readonly IUsersService _usersService;
public BaseInfoController(IMapper mapper,IPoliceService policeService, IEquipmentTypeService equipmentTypeService,
IEquipmentSizeService equipmentSizeService,ICarService carService, IInventoryService inventoryService, IInvService invService)
IEquipmentSizeService equipmentSizeService,ICarService carService, IInventoryService inventoryService, IInvService invService, IUsersService usersService)
{
_carService = carService;
_equipmentSizeService = equipmentSizeService;
......@@ -42,10 +43,77 @@ namespace APIs.Controllers
_policeService = policeService;
_inventoryService = inventoryService;
_invService = invService;
_usersService = usersService;
Mapper = mapper;
}
/// <summary>
/// 获取账号
/// </summary>
/// <param name=""></param>
/// <returns></returns>
[HttpGet]
public virtual async Task<ApiResult> GetAccount()
{
try
{
var accountlist = await _usersService.Query();
var src = new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
msg = ResultCode.OPERATE_SUCCESS.Msg,
data = accountlist
};
return src;
}
catch (Exception ex)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ex.Message,
};
return error;
}
}
/// <summary>
/// 手持机出入库记录上传
/// </summary>
/// <param name=""></param>
/// <returns></returns>
[HttpPost]
public virtual async Task<ApiResult> UploadHandRecord([FromBody] Models.ReqModel.InvReq req)
{
try
{
var rs = _invService.AddInvLogs(req).Result;
var src = rs ? new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
msg = ResultCode.OPERATE_SUCCESS.Msg,
} : new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ResultCode.OPERATE_FAILED.Msg,
};
return src;
}
catch (Exception ex)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ex.Message,
};
return error;
}
}
/// <summary>
/// 盘库记录上传
/// </summary>
/// <param name=""></param>
......
......@@ -62,6 +62,7 @@ namespace APIs
services.AddScoped<ILogService, LogService>();
services.AddScoped<IInventoryService, InventoryService>();
services.AddScoped<IInvService, InvService>();
services.AddScoped<IUsersService, UsersService>();
#endregion
#region Repository
......@@ -74,6 +75,7 @@ namespace APIs
services.AddScoped<IInventoryRepository, InventoryRepository>();
services.AddScoped<IInvSummaryRepository, InvSummaryRepository>();
services.AddScoped<IInvDetailRepository, InvDetailRepository>();
services.AddScoped<IUsersRepository, UsersRepository>();
#endregion
#region 注册RabbitMQ消费者
......
......@@ -44,4 +44,17 @@ namespace Common.Utility.Model
public string? errorMsg { get; set; }
}
public class HandRecordsReq
{
public DateTime useTime { get; set; }
[AllowNull]
public String userName { get; set; }
public int outInState { get; set; }
[AllowNull]
public String equipments { get; set; }
[AllowNull]
public List<EquipmentList>? equipmentList { get; set; }
//
}
}
......@@ -9,6 +9,6 @@ namespace Repositories.IRepository.IBussiness
{
public interface IInvSummaryRepository : IBaseRepository<InvSummary>
{
Task<bool> AddInvLogs(InvSummary model);
Task<bool> AddInvLogs(InvSummary model, List<Inventory> inList, List<Inventory> lostList);
}
}
......@@ -18,5 +18,7 @@ namespace Repositories.IRepository.IBussiness
/// <returns></returns>
Task<bool> AddLogs(LogSummary model, List<Inventory> invs, List<Car> cars);
Task<bool> AddHandLogs(LogSummary model, List<Inventory> invs);
}
}
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Repositories.IRepository.IBussiness
{
public interface IUsersRepository : IBaseRepository<Users>
{
}
}
......@@ -19,20 +19,25 @@ namespace Repositories.Repository.Bussiness
_suger = sugarUnitOfWork;
}
public async Task<bool> AddInvLogs(InvSummary model)
public async Task<bool> AddInvLogs(InvSummary model, List<Inventory> inList, List<Inventory> lostList)
{
using (var context = _suger.GetDbClient())
{
try
{
context.BeginTran();
var result1 = context.Updateable(inList).WhereColumns(it => new { it.id }).UpdateColumns(it => new { it.state, it.updateTime }).ExecuteCommand();
var result2 = context.Updateable(lostList).WhereColumns(it => new { it.id }).UpdateColumns(it => new { it.lostFlag, it.updateTime }).ExecuteCommand();
var linvSum = context.InsertNav(model)
.Include(z1 => z1.DetailList)
.ExecuteCommand();
context.CommitTran();
return linvSum;
return true;
}
catch (Exception e)
{
......
......@@ -21,6 +21,30 @@ namespace Repositories.Repository.Bussiness
_suger = sugarUnitOfWork;
}
public async Task<bool> AddHandLogs(LogSummary model, List<Inventory> inv)
{
using (var context = _suger.GetDbClient())
{
try
{
context.BeginTran();
var result = context.Updateable(inv).WhereColumns(it => new { it.epc }).UpdateColumns(it => new { it.state, it.updateTime }).ExecuteCommand();//实体有多少列更新多少列
var logSum = context.InsertNav(model)
.Include(z1 => z1.DetailList)
.ExecuteCommand();
context.CommitTran();
}
catch (Exception e)
{
throw e;
}
}
return true;
}
public async Task<bool> AddLogs(LogSummary model, List<Inventory> inv, List<Car> cars)
{
using (var context = _suger.GetDbClient())
......
using Models.Table;
using Repositories.IRepository.IBussiness;
using Repositories.IRepository.IUnitOfWork;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Repositories.Repository.Bussiness
{
public class UsersRepository : BaseRepository<Users>, IUsersRepository
{
public UsersRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
}
}
}
......@@ -17,5 +17,6 @@ namespace Services.Interface
/// <param name="model"></param>
/// <returns></returns>
Task<bool> AddLogs(RecordsReq model);
Task<bool> AddHandLogs(HandRecordsReq model);
}
}
using Models.SqlModel;
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interface
{
public interface IUsersService : IBaseServices<Users>
{
}
}
......@@ -39,8 +39,27 @@ namespace Services
updateTime = DateTime.Now,
};
List<Inventory> inList = new List<Inventory>();
List<Inventory> lostList = new List<Inventory>();
foreach (var detail in model.data)
{
if(detail.state == 0)
{
inList.Add(new Inventory()
{
id = detail.invId,
state = "0",
});
}else if(detail.state == 1)
{
lostList.Add(new Inventory()
{
id = detail.invId,
lostFlag = "1",
});
}
inv.DetailList.Add(new InvDetail()
{
invId = detail.invId,
......@@ -53,7 +72,7 @@ namespace Services
});
}
return _invSummaryRepository.AddInvLogs(inv);
return _invSummaryRepository.AddInvLogs(inv, inList, lostList);
}
}
}
......@@ -28,12 +28,37 @@ namespace Services
mapper = _mapper;
}
public Task<bool> AddHandLogs(HandRecordsReq model)
{
LogSummary log = mapper.Map<LogSummary>(model);
log.updateTime = DateTime.Now;
log.createTime = DateTime.Now;
foreach (var item in model.equipmentList)
{
LogDetail logdetail = mapper.Map<LogDetail>(item);
logdetail.createTime = DateTime.Now;
logdetail.updateTime = DateTime.Now;
logdetail.state = model.outInState;
logdetail.errorMsg = item.errorMsg;
log.DetailList.Add(logdetail);
}
List<Inventory> inveqList = model.equipmentList?.Select(x => new Inventory()
{
updateTime = DateTime.Now,
epc = x.epc,
state = x.outInState.ToString()
}).ToList();
return _logSummaryRepository.AddHandLogs(log, inveqList);
}
public Task<bool> AddLogs(RecordsReq model)
{
LogSummary log = mapper.Map<LogSummary>(model);
log.updateTime = DateTime.Now;
log.createTime = DateTime.Now;
if (model.equipmentList!=null)
if (model.equipmentList != null)
{
foreach (var item in model.equipmentList)
{
......@@ -63,13 +88,13 @@ namespace Services
List<Inventory> inveqList = model.equipmentList?.Select(x => new Inventory()
{
updateTime = DateTime.Now,
epc=x.epc,
epc = x.epc,
state = x.outInState.ToString()
}).ToList();
List<Car> invCarList = model.carList?.Select(x => new Car()
{
updateTime=DateTime.Now,
id=x.carId,
updateTime = DateTime.Now,
id = x.carId,
state = x.outInState.ToString()
}).ToList();
return _logSummaryRepository.AddLogs(log, inveqList, invCarList);
......
using Models.Table;
using Repositories.IRepository.IBussiness;
using Services.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services
{
public class UsersService : BaseService<Users>, IUsersService
{
private readonly IUsersRepository _usersRepository;
public UsersService(IUsersRepository usersRepository)
{
base.BaseDal = usersRepository;
_usersRepository = usersRepository;
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论