wet 2 years ago
commit 25dcc5ed79

@ -0,0 +1,43 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 订舱货物状态
/// </summary>
[SugarTable("booking_goods_status")]
[Description("订舱货物状态")]
public class BookingGoodsStatus : DBEntityTenant
{
/// <summary>
/// 状态名称
/// </summary>
public string StatusName { get; set; }
/// <summary>
/// 完成时间
/// </summary>
public DateTime? FinishTime { get; set; }
/// <summary>
/// 完成人
/// </summary>
public string FinishUser { get; set; }
/// <summary>
/// 完成人ID
/// </summary>
public long? FinishUserId { get; set; }
/// <summary>
/// 是否公开
/// </summary>
public bool IsPublic { get; set; }
/// <summary>
/// 附加数据
/// </summary>
public string ExtData { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

@ -0,0 +1,23 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 订舱货物状态管理
/// </summary>
[SugarTable("booking_goods_status_config")]
[Description("订舱货物状态管理")]
public class BookingGoodsStatusConfig : DBEntityTenant
{
/// <summary>
/// 状态名称
/// </summary>
public string StatusName { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int Sort { get; set; }
}
}

@ -0,0 +1,139 @@
using Myshipping.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System.Linq;
using System.Threading.Tasks;
using Myshipping.Application.Entity;
using Microsoft.Extensions.Logging;
using Furion.FriendlyException;
using Myshipping.Application.Enum;
using System.ComponentModel;
using System.Collections.Generic;
using System.IO;
using MiniExcelLibs;
using NPOI.HSSF.UserModel;
using Myshipping.Core.Helper;
using NPOI.SS.UserModel;
using Furion;
using System;
using System.Web;
using System.Text;
using Myshipping.Application.ConfigOption;
using Myshipping.Core.Service;
namespace Myshipping.Application
{
/// <summary>
/// 订舱货物状态服务
/// </summary>
[ApiDescriptionSettings("Application", Name = "BookingGoodsStatusConfig", Order = 1)]
public class BookingGoodsStatusConfigService : IBookingGoodsStatusConfigService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<BookingGoodsStatusConfig> _rep;
private readonly ILogger<BookingGoodsStatusConfig> _logger;
private readonly ISysCacheService _cache;
public BookingGoodsStatusConfigService(SqlSugarRepository<BookingGoodsStatusConfig> rep, ILogger<BookingGoodsStatusConfig> logger, ISysCacheService cache)
{
_rep = rep;
_logger = logger;
_cache = cache;
}
/// <summary>
/// 分页查询订舱货物状态
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/BookingGoodsStatusConfig/page")]
public async Task<dynamic> Page([FromQuery] QueryBookingGoodsStatusConfigInput input)
{
//初次使用没有数据,进行初始化
if (_rep.AsQueryable().Count(x => x.CreatedUserId == UserManager.UserId) == 0)
{
var dicData = await _cache.GetAllDictData();
var listGoodsStatus = dicData.Where(x => x.TypeCode == "booking_goods_status").ToList();
listGoodsStatus.ForEach(async itm =>
{
await _rep.InsertAsync(new BookingGoodsStatusConfig()
{
StatusName = itm.Value,
Sort = itm.Sort
});
});
}
var entities = await _rep.AsQueryable()
.Where(m => m.CreatedUserId == UserManager.UserId)
.WhereIF(!string.IsNullOrEmpty(input.StatusName), u => u.StatusName.Contains(input.StatusName))
.OrderBy(m => m.Sort)
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
/// <summary>
/// 保存订舱货物状态
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingGoodsStatusConfig/save")]
public async Task<long> Save(SaveBookingGoodsStatusConfigInput input)
{
BookingGoodsStatusConfig model = null;
if (input.Id > 0)
{
if (_rep.Count(x => x.StatusName == input.StatusName && x.Id != input.Id) > 0)
{
throw Oops.Bah($"已存在相同名称的状态:{input.StatusName}");
}
model = _rep.FirstOrDefault(x => x.Id == input.Id);
input.Adapt(model);
await _rep.UpdateAsync(model);
}
else
{
if (_rep.Count(x => x.StatusName == input.StatusName) > 0)
{
throw Oops.Bah($"已存在相同名称的状态:{input.StatusName}");
}
model = input.Adapt<BookingGoodsStatusConfig>();
await _rep.InsertAsync(model);
}
return model.Id;
}
/// <summary>
/// 删除订舱货物状态
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("/BookingGoodsStatusConfig/delete")]
public async Task Delete(long id)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == id);
entity.IsDeleted = true;
await _rep.UpdateAsync(entity);
}
/// <summary>
/// 获取订舱货物状态
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/BookingGoodsStatusConfig/detail")]
public async Task<BookingGoodsStatusConfig> Get(long id)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == id);
}
}
}

@ -0,0 +1,61 @@
using Myshipping.Core;
using System;
using System.ComponentModel.DataAnnotations;
namespace Myshipping.Application
{
/// <summary>
/// 订舱货物状态输入参数
/// </summary>
public class BookingGoodsStatusConfigInput
{
/// <summary>
/// 状态名称
/// </summary>
public string StatusName { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int Sort { get; set; }
}
/// <summary>
/// 订舱货物状态修改输入参数
/// </summary>
public class SaveBookingGoodsStatusConfigInput: BookingGoodsStatusConfigInput
{
/// <summary>
/// 主键
/// </summary>
[Required(ErrorMessage = "主键不能为空")]
public long Id { get; set; }
}
/// <summary>
/// 订舱货物状态获取(删除)输入参数
/// </summary>
public class GetBookingGoodsStatusConfigInput
{
/// <summary>
/// 主键
/// </summary>
[Required(ErrorMessage = "主键不能为空")]
public long Id { get; set; }
}
/// <summary>
/// 订舱货物状态查询输入参数
/// </summary>
public class QueryBookingGoodsStatusConfigInput : PageInputBase
{
/// <summary>
/// 状态名称
/// </summary>
public string StatusName { get; set; }
}
}

@ -0,0 +1,25 @@
using System;
namespace Myshipping.Application
{
/// <summary>
/// 订舱货物状态输出参数
/// </summary>
public class BookingGoodsStatusConfigOutput
{
/// <summary>
/// 主键
/// </summary>
public long Id { get; set; }
/// <summary>
/// 状态名称
/// </summary>
public string StatusName { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int Sort { get; set; }
}
}

@ -0,0 +1,15 @@
using Myshipping.Core;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Myshipping.Application.Entity;
namespace Myshipping.Application
{
public interface IBookingGoodsStatusConfigService
{
Task<dynamic> Page([FromQuery] QueryBookingGoodsStatusConfigInput input);
Task<long> Save(SaveBookingGoodsStatusConfigInput input);
Task Delete(long id);
Task<BookingGoodsStatusConfig> Get(long id);
}
}

@ -39,7 +39,7 @@ namespace Myshipping.Application
.Map(dest => dest.CloseVGMDate, src => src.CLOSEVGMDATE.HasValue ? src.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.PlaceReceiptId, src => src.PLACERECEIPTID)
.Map(dest => dest.PlaceReceipt, src => src.PLACERECEIPT)
.Map(dest => dest.PortLoadId, src => src.PORTLOAD)
.Map(dest => dest.PortLoadId, src => src.PORTLOADID)
.Map(dest => dest.PortLoad, src => src.PORTLOAD)
.Map(dest => dest.PortDischargeId, src => src.PORTDISCHARGEID)
.Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE)

Loading…
Cancel
Save