箱唛接口功能
This commit is contained in:
135
src/WMS.Web.Domain/Entitys/BoxMark.cs
Normal file
135
src/WMS.Web.Domain/Entitys/BoxMark.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛表
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_wms_box_mark")]
|
||||
public class BoxMark : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱唛编号
|
||||
/// </summary>
|
||||
public string BillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱唛编号-首位
|
||||
/// </summary>
|
||||
public int FirstBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱唛编号-末尾序号
|
||||
/// </summary>
|
||||
public int LastBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单编号
|
||||
/// </summary>
|
||||
public string OrderBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public int MaterialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品数量
|
||||
/// </summary>
|
||||
public decimal ProductQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 装箱数量
|
||||
/// </summary>
|
||||
public decimal CratingQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 装箱净重
|
||||
/// </summary>
|
||||
public decimal CratingNetWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 装箱毛重
|
||||
/// </summary>
|
||||
public decimal CratingGrossWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尾箱数量
|
||||
/// </summary>
|
||||
public decimal TailboxQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尾箱净重
|
||||
/// </summary>
|
||||
public decimal TailboxNetWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尾箱毛重
|
||||
/// </summary>
|
||||
public decimal TailboxGrossWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public int CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间(生成时间)
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId)
|
||||
{
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成编号
|
||||
/// </summary>
|
||||
/// <param name="firstBillNo"></param>
|
||||
/// <param name="lastBillNo"></param>
|
||||
public void GenerateBillNo(int firstBillNo,int lastBillNo)
|
||||
{
|
||||
this.FirstBillNo=Convert.ToInt32(DateTime.Now.ToString("yyMMdd"));
|
||||
if (this.FirstBillNo == firstBillNo)
|
||||
this.LastBillNo = lastBillNo + 1;
|
||||
else
|
||||
this.LastBillNo = 1;
|
||||
|
||||
if (this.LastBillNo.ToString().Length >= 5)
|
||||
{
|
||||
this.BillNo = "XM" + this.FirstBillNo + this.LastBillNo;
|
||||
return;
|
||||
}
|
||||
|
||||
string lastStr = this.LastBillNo.ToString();
|
||||
while (true)
|
||||
{
|
||||
lastStr = "0" + lastStr;
|
||||
if (lastStr.Length >= 5) break;
|
||||
}
|
||||
this.BillNo = "XM" + this.FirstBillNo + lastStr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
24
src/WMS.Web.Domain/IService/IBoxMarkService.cs
Normal file
24
src/WMS.Web.Domain/IService/IBoxMarkService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
|
||||
namespace WMS.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛-服务接口
|
||||
/// </summary>
|
||||
public interface IBoxMarkService
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo);
|
||||
}
|
||||
}
|
||||
45
src/WMS.Web.Domain/Infrastructure/IBoxMarkRepositories.cs
Normal file
45
src/WMS.Web.Domain/Infrastructure/IBoxMarkRepositories.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
|
||||
namespace WMS.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛-仓储接口
|
||||
/// </summary>
|
||||
public interface IBoxMarkRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 列表分页
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<(List<BoxMarkQueryResponse> list, int total)> GetPagedList(BoxMarkQueryRequest dto, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(BoxMark entity, bool isTransaction = true);
|
||||
|
||||
/// <summary>
|
||||
/// 详情-根据最新的ID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<BoxMark> GetBy();
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteRange(List<int> ids, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
17
src/WMS.Web.Domain/Mappers/BoxMarkMapper.cs
Normal file
17
src/WMS.Web.Domain/Mappers/BoxMarkMapper.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
|
||||
namespace WMS.Web.Domain.Mappers
|
||||
{
|
||||
public class BoxMarkMapper : Profile
|
||||
{
|
||||
public BoxMarkMapper()
|
||||
{
|
||||
CreateMap<GenerateBoxMarkDto, BoxMark>();
|
||||
}
|
||||
}
|
||||
}
|
||||
62
src/WMS.Web.Domain/Services/BoxMarkService.cs
Normal file
62
src/WMS.Web.Domain/Services/BoxMarkService.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛-服务
|
||||
/// </summary>
|
||||
public class BoxMarkService : IBoxMarkService
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
public readonly IBasicsRepositories _transactionRepositories;
|
||||
private readonly IBoxMarkRepositories _boxMarkRepositories;
|
||||
public BoxMarkService(IMapper mapper,
|
||||
IBasicsRepositories transactionRepositories,
|
||||
IBoxMarkRepositories boxMarkRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_boxMarkRepositories = boxMarkRepositories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo)
|
||||
{
|
||||
//1.获取最新的箱唛信息
|
||||
var entity_new = await _boxMarkRepositories.GetBy();
|
||||
|
||||
//2.dto映射实体
|
||||
var entity = new BoxMark();
|
||||
entity= _mapper.Map(dto, entity);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
|
||||
var new_firstBillNo = entity_new == null ? 0 : entity_new.FirstBillNo;
|
||||
var new_lastBillNo = entity_new == null ? 0 : entity_new.LastBillNo;
|
||||
entity.GenerateBillNo(new_firstBillNo, new_lastBillNo);
|
||||
|
||||
//添加
|
||||
var isSuccess = await _boxMarkRepositories.Add(entity);
|
||||
if (!isSuccess)
|
||||
return Result<InStockTask>.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user