Commit 61423228 by Seniorious

添加盘点相关接口

parent 4384e118
...@@ -17,6 +17,7 @@ using SqlSugar; ...@@ -17,6 +17,7 @@ using SqlSugar;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Security.Cryptography.Xml;
using static Microsoft.AspNetCore.Razor.Language.TagHelperMetadata; using static Microsoft.AspNetCore.Razor.Language.TagHelperMetadata;
namespace APIs.Controllers namespace APIs.Controllers
...@@ -30,23 +31,113 @@ namespace APIs.Controllers ...@@ -30,23 +31,113 @@ namespace APIs.Controllers
private readonly IEquipmentTypeService _equipmentTypeService; private readonly IEquipmentTypeService _equipmentTypeService;
private readonly IEquipmentSizeService _equipmentSizeService; private readonly IEquipmentSizeService _equipmentSizeService;
private readonly ICarService _carService; private readonly ICarService _carService;
private readonly IInventoryService _inventoryService;
private readonly IInvService _invService;
public BaseInfoController(IMapper mapper,IPoliceService policeService, IEquipmentTypeService equipmentTypeService, public BaseInfoController(IMapper mapper,IPoliceService policeService, IEquipmentTypeService equipmentTypeService,
IEquipmentSizeService equipmentSizeService,ICarService carService) IEquipmentSizeService equipmentSizeService,ICarService carService, IInventoryService inventoryService, IInvService invService)
{ {
_carService = carService; _carService = carService;
_equipmentSizeService = equipmentSizeService; _equipmentSizeService = equipmentSizeService;
_equipmentTypeService = equipmentTypeService; _equipmentTypeService = equipmentTypeService;
_policeService = policeService; _policeService = policeService;
_inventoryService = inventoryService;
_invService = invService;
Mapper = mapper; Mapper = mapper;
} }
/// <summary> /// <summary>
/// 盘库记录上传
/// </summary>
/// <param name=""></param>
/// <returns></returns>
[HttpPost]
public virtual async Task<ApiResult> UploadInv([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>
/// <returns></returns>
[HttpGet]
public async Task<ApiResult> GetInventory()
{
try
{
var invlist = await _inventoryService.Query();
if (invlist == null)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = "库存为空",
};
return error;
}
var inv = invlist.Select(s => new
{
id = s.id,
typeId = s.typeId,
typeName = s.typeName,
sizeId = s.sizeId,
sizeName = s.sizeName,
epc = s.epc,
state = s.state,
}).ToList();
var src = new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
msg = ResultCode.OPERATE_SUCCESS.Msg,
data = inv
};
return src;
}
catch (Exception ex)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ex.Message,
};
return error;
}
}
/// <summary>
/// 根据人员id删除照片及照片数据库信息 /// 根据人员id删除照片及照片数据库信息
/// </summary> /// </summary>
/// <param name=""></param> /// <param name=""></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult> DeletePictureById([FromForm] DelPicReq req) public async Task<ApiResult> DeletePictureById([FromBody] DelPicReq req)
{ {
try try
{ {
......
...@@ -60,6 +60,8 @@ namespace APIs ...@@ -60,6 +60,8 @@ namespace APIs
services.AddScoped<IEquipmentSizeService, EquipmentSizeService>(); services.AddScoped<IEquipmentSizeService, EquipmentSizeService>();
services.AddScoped<IEquipmentTypeService, EquipmentTypeService>(); services.AddScoped<IEquipmentTypeService, EquipmentTypeService>();
services.AddScoped<ILogService, LogService>(); services.AddScoped<ILogService, LogService>();
services.AddScoped<IInventoryService, InventoryService>();
services.AddScoped<IInvService, InvService>();
#endregion #endregion
#region Repository #region Repository
...@@ -69,6 +71,9 @@ namespace APIs ...@@ -69,6 +71,9 @@ namespace APIs
services.AddScoped<IEquipmentTypeRepository, EquipmentTypeRepository>(); services.AddScoped<IEquipmentTypeRepository, EquipmentTypeRepository>();
services.AddScoped<ILogDetailRepository, LogDetailRepository>(); services.AddScoped<ILogDetailRepository, LogDetailRepository>();
services.AddScoped<ILogSummaryRepository, LogSummaryRepository>(); services.AddScoped<ILogSummaryRepository, LogSummaryRepository>();
services.AddScoped<IInventoryRepository, InventoryRepository>();
services.AddScoped<IInvSummaryRepository, InvSummaryRepository>();
services.AddScoped<IInvDetailRepository, InvDetailRepository>();
#endregion #endregion
#region 注册RabbitMQ消费者 #region 注册RabbitMQ消费者
......
namespace Models.ReqModel
{
public class InvReq
{
public DateTime useTime { get; set; }
public string userName { get; set; }
public int invSum { get; set; }
public int resultSum { get; set; }
public string overView { get; set; }
public List<InvInfo> data { get; set; }
}
public class InvInfo
{
public string invId { get; set; }
public string epc { get; set; }
public string typeName { get; set; }
public string sizeName { get; set; }
public int state { get; set; }
}
}
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Table
{
[SugarTable("base_inv_detail")]
public class InvDetail : BaseTable
{
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public int id { get; set; }
[SugarColumn(ColumnName = "summary_id")]
public String summaryId { get; set; }
[SugarColumn(ColumnName = "inv_id")]
public String invId { get; set; }
[SugarColumn(ColumnName = "type_name")]
public String typeName { get; set; }
[SugarColumn(ColumnName = "size_name")]
public String sizeName { get; set; }
public String epc { get; set; }
public int state { get; set; }
}
}
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Table
{
[SugarTable("base_inv_summary")]
public class InvSummary : BaseTable
{
[SugarColumn(IsPrimaryKey = true)]
public String id { get; set; }
[SugarColumn(ColumnName = "use_time")]
public DateTime? useTime { get; set; }
[SugarColumn(ColumnName = "user_name")]
public String? useName { get; set; }
[SugarColumn(ColumnName = "inv_sum")]
public int? invSum { get; set; }
[SugarColumn(ColumnName = "result_sum")]
public int? resultSum { get; set; }
public String? overView { get; set; }
[SugarColumn(ColumnName = "org_id")]
public String orgId { get; set; }
[SugarColumn(ColumnName = "location_id")]
public String locationId { get; set; }
[SugarColumn(ColumnName = "location_name")]
public String locationName { get; set; }
[Navigate(NavigateType.OneToMany, nameof(InvDetail.summaryId))]
public List<InvDetail> DetailList { get; set; } = new List<InvDetail>();
}
}
...@@ -12,7 +12,6 @@ namespace Models.Table ...@@ -12,7 +12,6 @@ namespace Models.Table
public class Inventory : BaseTable public class Inventory : BaseTable
{ {
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)] [SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public String id { get; set; } public String id { get; set; }
[SugarColumn(ColumnName = "type_id")] [SugarColumn(ColumnName = "type_id")]
public String typeId { get; set; } public String typeId { get; set; }
...@@ -20,11 +19,9 @@ namespace Models.Table ...@@ -20,11 +19,9 @@ namespace Models.Table
public String sizeId { get; set; } public String sizeId { get; set; }
[SugarColumn(ColumnName = "supplier_id")] [SugarColumn(ColumnName = "supplier_id")]
public String supplierId { get; set; } public String supplierId { get; set; }
public String epc { get; set; } public String epc { get; set; }
[SugarColumn(ColumnName = "org_id")] [SugarColumn(ColumnName = "org_id")]
public String orgId { get; set; } public String orgId { get; set; }
public String state { get; set; } public String state { get; set; }
[SugarColumn(ColumnName = "bussiness_state")] [SugarColumn(ColumnName = "bussiness_state")]
public String bussinessState { get; set; } public String bussinessState { get; set; }
...@@ -43,7 +40,9 @@ namespace Models.Table ...@@ -43,7 +40,9 @@ namespace Models.Table
[SugarColumn(ColumnName = "lost_flag")] [SugarColumn(ColumnName = "lost_flag")]
public String lostFlag { get; set; } public String lostFlag { get; set; }
public String price { get; set; } public String price { get; set; }
[SugarColumn(ColumnName = "type_name")]
public String typeName { get; set; }
[SugarColumn(ColumnName = "size_name")]
public String sizeName { get; set; }
} }
} }
...@@ -8,8 +8,6 @@ using System.Threading.Tasks; ...@@ -8,8 +8,6 @@ using System.Threading.Tasks;
namespace Models.Table namespace Models.Table
{ {
[SugarTable("base_log_detail")] [SugarTable("base_log_detail")]
public class LogDetail : BaseTable public class LogDetail : BaseTable
{ {
...@@ -26,7 +24,6 @@ namespace Models.Table ...@@ -26,7 +24,6 @@ namespace Models.Table
public String? equipmentSize { get; set; } public String? equipmentSize { get; set; }
[SugarColumn(ColumnName = "error_state")] [SugarColumn(ColumnName = "error_state")]
public int? errorState { get; set; } public int? errorState { get; set; }
public int? state { get; set; } public int? state { get; set; }
[SugarColumn(ColumnName = "car_id")] [SugarColumn(ColumnName = "car_id")]
public int? carid { get; set; } public int? carid { get; set; }
......
...@@ -31,7 +31,6 @@ namespace Models.Table ...@@ -31,7 +31,6 @@ namespace Models.Table
public String? planName { get; set; } public String? planName { get; set; }
[Navigate(NavigateType.OneToMany, nameof(LogDetail.summaryId))] [Navigate(NavigateType.OneToMany, nameof(LogDetail.summaryId))]
public List<LogDetail> DetailList { get; set; } = new List<LogDetail>(); public List<LogDetail> DetailList { get; set; } = new List<LogDetail>();
} }
......
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 IInvDetailRepository : IBaseRepository<InvDetail>
{
}
}
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 IInvSummaryRepository : IBaseRepository<InvSummary>
{
Task<bool> AddInvLogs(InvSummary model);
}
}
...@@ -63,7 +63,6 @@ namespace Repositories.Repository ...@@ -63,7 +63,6 @@ namespace Repositories.Repository
{ {
return await context.Queryable<TEntity>().ToListAsync(); return await context.Queryable<TEntity>().ToListAsync();
} }
} }
public async Task<TEntity> QueryOneOrderDesc(Expression<Func<TEntity, bool>> whereExpresson, Expression<Func<TEntity, object>> orderExpression) public async Task<TEntity> QueryOneOrderDesc(Expression<Func<TEntity, bool>> whereExpresson, Expression<Func<TEntity, object>> orderExpression)
......
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 InvDetailRepository : BaseRepository<InvDetail>, IInvDetailRepository
{
public InvDetailRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
}
}
}
using AutoMapper;
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 InvSummaryRepository : BaseRepository<InvSummary>, IInvSummaryRepository
{
protected readonly ILocalSugarUnitOfWork _suger;
public IMapper mapper;
public InvSummaryRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
_suger = sugarUnitOfWork;
}
public async Task<bool> AddInvLogs(InvSummary model)
{
using (var context = _suger.GetDbClient())
{
try
{
context.BeginTran();
var linvSum = context.InsertNav(model)
.Include(z1 => z1.DetailList)
.ExecuteCommand();
context.CommitTran();
return linvSum;
}
catch (Exception e)
{
throw e;
}
}
}
}
}
using Common.Utility.Model;
using Models.Table;
using Models.ReqModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interface
{
public interface IInvService : IBaseServices<InvSummary>
{
Task<bool> AddInvLogs(InvReq model);
}
}
using AutoMapper;
using Models.ReqModel;
using Models.Table;
using Repositories.IRepository.IBussiness;
using Repositories.Repository.Bussiness;
using Services.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services
{
public class InvService : BaseService<InvSummary>, IInvService
{
private readonly IInvSummaryRepository _invSummaryRepository;
private readonly IInvDetailRepository _invDetailRepository;
public IMapper mapper;
public InvService(IInvSummaryRepository invSummaryRepository, IInvDetailRepository invDetailRepository, IMapper _mapper)
{
base.BaseDal = invSummaryRepository;
_invSummaryRepository = invSummaryRepository;
_invDetailRepository = invDetailRepository;
mapper = _mapper;
}
public Task<bool> AddInvLogs(InvReq model)
{
InvSummary inv = new InvSummary()
{
id = Guid.NewGuid().ToString(),
useTime = model.useTime,
useName = model.userName,
invSum = model.invSum,
resultSum = model.resultSum,
overView = model.overView,
createTime = DateTime.Now,
updateTime = DateTime.Now,
};
foreach (var detail in model.data)
{
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);
}
}
}
...@@ -30,7 +30,6 @@ namespace Services ...@@ -30,7 +30,6 @@ namespace Services
public Task<bool> AddLogs(RecordsReq model) public Task<bool> AddLogs(RecordsReq model)
{ {
LogSummary log = mapper.Map<LogSummary>(model); LogSummary log = mapper.Map<LogSummary>(model);
log.updateTime = DateTime.Now; log.updateTime = DateTime.Now;
log.createTime = DateTime.Now; log.createTime = DateTime.Now;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论