20241014 批量模板导入 增加逻辑:识别为待上线的,必须选成上线或下线才能确认执行

单程租入改为不允许录入还箱信息
dev
dengyu 1 month ago
parent 1d07748dd4
commit 449baf2dfd

@ -1700,5 +1700,8 @@ public static class MultiLanguageConst
[Description("箱号无法进行此操作")]
public const string CM_CtnCannotDo = "Cntrno can not do this.";
[Description("还存在未处理上线状态的导入明细")]
public const string CM_NoDealTempDetail = "Exists some Detail need to deal.";
#endregion
}

@ -139,4 +139,17 @@ public class CM_RentOneWayController : ApiController
//return res;
}
/// <summary>
/// 单程 待租出 明细视图
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost]
[Route("CM_RentOneWay_NeedRent_View")]
public Task<DataResult<List<VW_CM_RentOneWay_NeedRentRes>>> CM_RentOneWay_NeedRent_View([FromBody] PageRequest request)
{
var res = _invokeService.CM_RentOneWay_NeedRent_View(request);
return res;
}
}

@ -0,0 +1,130 @@
using DS.Module.Core;
using DS.Module.Core.Enums;
using DS.WMS.Core.Op.Entity;
using FluentValidation;
using Masuit.Tools.Systems;
using SqlSugar;
using System.ComponentModel;
namespace DS.WMS.ContainerManagement.Info.Dtos;
/// <summary>
/// 箱管_单程 待单程租出箱明细 返回实体
/// </summary>
public class VW_CM_RentOneWay_NeedRentRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// Desc:箱号
/// </summary>
public string Cntrno { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
public string CtnCode { get; set; }
/// <summary>
/// Desc:箱型
/// </summary>
public string Ctnall { get; set; }
/// <summary>
/// Desc:箱主Id
/// </summary>
public long CtnOwnerId { get; set; }
/// <summary>
/// Desc:箱主
/// </summary>
public string CtnOwner { get; set; }
/// <summary>
/// Desc:是否上线id(是否管理中)
/// </summary>
public CM_IsOnlineEnum? IsOnlineId { get; set; } = 0;
/// <summary>
/// Desc:是否上线(是否管理中)
/// </summary>
public string IsOnline => IsOnlineId?.GetDescription();
/// <summary>
/// Desc:箱来源Id: 自有箱/短租租入/长租租入/买箱
/// </summary>
public CM_CtnSourceEnum? CtnSourceId { get; set; }
/// <summary>
/// Desc:箱来源: 自有箱/短租租入/长租租入/买箱
/// </summary>
public string CtnSource => CtnSourceId?.GetDescription();
/// <summary>
/// Desc:箱业务状态id: 短租租出 长租租出 单程 卖箱
/// </summary>
public CM_CtnBizStateEnum? CtnBizStateId { get; set; }
/// <summary>
/// Desc:箱业务状态: 短租租出 长租租出 单程 卖箱
/// </summary>
public string CtnBizState => CtnBizStateId?.GetDescription();
/// <summary>
/// <summary>
/// Desc:箱状态Id
/// </summary>
public CMCtnStateEnum? CtnStateId { get; set; }
/// <summary>
/// Desc:箱状态
/// </summary>
public string CtnState => CtnStateId?.GetDescription();
/// <summary>
/// Desc:箱流转状态Id
/// </summary>
public CMCtnFlowStateEnum? CtnFlowStateId { get; set; }
/// <summary>
/// Desc:箱流转状态
/// </summary>
public string CtnFlowState => CtnFlowStateId?.GetDescription();
/// <summary>
/// Desc:当前港口代码
/// </summary>
public long? Portid { get; set; }
/// <summary>
/// Desc:当前港口五字码
/// </summary>
public string PortCode { get; set; }
/// <summary>
/// Desc:当前港口
/// </summary>
public string Port { get; set; }
/// <summary>
/// Desc:业务编号/提单号
/// </summary>
public string Mblno { get; set; }
/// <summary>
/// Desc:船名航次
/// </summary>
public string VesselVoyno { get; set; }
/// <summary>
/// 状态时间
/// </summary>
public DateTime StateTime { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// Desc:关联放箱单号
/// </summary>
public string? CtnReleaseNo { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}

@ -18,5 +18,12 @@ public class CM_State_Change_Temp : CM_State_Change
/// </summary>
[SugarColumn(ColumnDescription = "父节点号", IsNullable = false)]
public long Pid { get; set; }
/// <summary>
/// 处理结果备注
/// </summary>
[SugarColumn(ColumnDescription = "处理结果备注", IsNullable = false)]
public string DealRemark { get; set; }
}

@ -0,0 +1,133 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Enums;
using Masuit.Tools.Systems;
using SqlSugar;
using System.ComponentModel;
namespace DS.WMS.ContainerManagement.Info.Entity;
/// <summary>
/// 箱管_单程 待单程租出箱明细
/// </summary>
[SqlSugar.SugarTable("VW_CM_RentOneWay_NeedRent", "箱管_单程 待单程租出箱明细")]
public class VW_CM_RentOneWay_NeedRent : BaseOrgModelV2<long>
{
/// <summary>
/// 箱当前状态id
/// </summary>
[SugarColumn(ColumnDescription = "箱当前状态id", IsNullable = false)]
public long Id { get; set; }
/// <summary>
/// Desc:箱号
/// </summary>
[SugarColumn(ColumnDescription = "箱号", IsNullable = false, Length = 20)]
public string Cntrno { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "箱型代码", Length = 10, IsNullable = true)]
public string CtnCode { get; set; }
/// <summary>
/// Desc:箱型
/// </summary>
[SugarColumn(ColumnDescription = "箱型", IsNullable = false, Length = 20)]
public string Ctnall { get; set; }
/// <summary>
/// Desc:箱主Id
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "箱主Id", IsNullable = false, DefaultValue = "0")]
public long CtnOwnerId { get; set; }
/// <summary>
/// Desc:箱主
/// </summary>
[SugarColumn(ColumnDescription = "箱主", IsNullable = true, Length = 50)]
public string CtnOwner { get; set; }
/// <summary>
/// Desc:是否上线id(是否管理中)
/// </summary>
[SugarColumn(ColumnDescription = "是否上线id", IsNullable = true, DefaultValue = "0")]
public CM_IsOnlineEnum? IsOnlineId { get; set; } = 0;
/// <summary>
/// Desc:箱来源Id: 自有箱/短租租入/长租租入/买箱
/// </summary>
[SugarColumn(ColumnDescription = "箱来源Id", IsNullable = true, Length = 20)]
public CM_CtnSourceEnum? CtnSourceId { get; set; }
/// <summary>
/// Desc:箱业务状态id: 短租租出 长租租出 单程 卖箱
/// </summary>
[SugarColumn(ColumnDescription = "箱业务状态Id", IsNullable = true)]
public CM_CtnBizStateEnum? CtnBizStateId { get; set; }
/// <summary>
/// <summary>
/// Desc:箱状态Id
/// </summary>
[SugarColumn(ColumnDescription = "箱状态Id", IsNullable = true)]
public CMCtnStateEnum? CtnStateId { get; set; }
/// <summary>
/// Desc:箱流转状态Id
/// </summary>
[SugarColumn(ColumnDescription = "箱流转状态Id", IsNullable = true)]
public CMCtnFlowStateEnum? CtnFlowStateId { get; set; }
/// <summary>
/// Desc:当前港口代码
/// </summary>
[SugarColumn(ColumnDescription = "当前港口代码", IsNullable = true)]
public long? Portid { get; set; }
/// <summary>
/// Desc:当前港口五字码
/// </summary>
[SugarColumn(ColumnDescription = "当前港口五字码", IsNullable = true, Length = 10)]
public string PortCode { get; set; }
/// <summary>
/// Desc:当前港口
/// </summary>
[SugarColumn(ColumnDescription = "当前港口", IsNullable = true, Length = 50)]
public string Port { get; set; }
/// <summary>
/// Desc:业务编号/提单号
/// </summary>
[SugarColumn(ColumnDescription = "业务编号/提单号", IsNullable = true, Length = 20)]
public string Mblno { get; set; }
/// <summary>
/// Desc:船名航次
/// </summary>
[SugarColumn(ColumnDescription = "船名航次", IsNullable = true, Length = 100)]
public string VesselVoyno { get; set; }
/// <summary>
/// 状态时间
/// </summary>
[Description("状态时间")]
public DateTime StateTime { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Description("创建时间")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 备注
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "备注", IsNullable = true, Length = 400)]
public string Remark { get; set; }
/// <summary>
/// Desc:关联放箱单号
/// </summary>
[SugarColumn(ColumnDescription = "关联放箱单号", IsNullable = true, Length = 50)]
public string CtnReleaseNo { get; set; }
}

@ -47,10 +47,9 @@ public interface ICM_BaseInfoService
public Task<DataResult> CM_DealExcel(CM_DealExcelReq model);
/// <summary>
/// 判断箱号的箱型与当前的该箱基础信息的箱型是否一致
/// 判断箱号是否合规
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
//DataResult CM_CheckCtnCtnall(CM_DealExcelReq model);
public bool ValidateContainerNumber(string containerNumber, out string trueCntrno);
}

@ -59,4 +59,12 @@ public interface ICM_RentOneWayService
/// <param name="ids">当前状态IDs</param>
/// <returns></returns>
Task<DataResult> CM_RentOneWay_AddCtn(long id, params long[] ids);
/// <summary>
/// 单程业务 待租出 明细_视图
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<DataResult<List<VW_CM_RentOneWay_NeedRentRes>>> CM_RentOneWay_NeedRent_View(PageRequest request);
}

@ -149,7 +149,6 @@ public class CM_BaseInfoService : ICM_BaseInfoService
public DataResult<CM_CheckCntrnoRes> CM_CheckCntrno(CM_CheckCntrno req)
{
var Cntrno = req.Cntrno;
Cntrno = Cntrno.Replace("", ",");
@ -211,7 +210,7 @@ public class CM_BaseInfoService : ICM_BaseInfoService
return result;
}
public static bool ValidateContainerNumber(string containerNumber,out string trueCntrno)
public bool ValidateContainerNumber(string containerNumber,out string trueCntrno)
{
// 集装箱号的校验规则
// - 由4位字母ISO代码+ 6位数字 + 1位校验码组成

@ -504,4 +504,35 @@ public class CM_RentOneWayService : CMServiceBase, ICM_RentOneWayService
//return result > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
/// <summary>
/// 单程 待租出 明细_视图
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult<List<VW_CM_RentOneWay_NeedRentRes>>> CM_RentOneWay_NeedRent_View(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//if (request.PageCondition.SortConditions == null || request.PageCondition.SortConditions.Count() == 0)
//{
// request.PageCondition.SortConditions = new SortCondition[]{new SortCondition
// {
// SortField = nameof(VW_CM_RentOut_NeedRentRes.StateTime),
// ListSortDirection = System.ComponentModel.ListSortDirection.Descending
// } };
//}
request.SetDefaultOrderField("StateTime");
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<VW_CM_RentOneWay_NeedRent>()
.Where(whereList)
.Select<VW_CM_RentOneWay_NeedRentRes>()
.ToQueryPage(request.PageCondition);
return data;
}
}

@ -251,10 +251,11 @@ public class CM_RentOneWay_InService : CMServiceBase, ICM_RentOneWay_InService
//如果是提箱/还箱 分别产生变动
//20241014 现在租入不处理还箱
foreach (var detail in body)
{
if (detail.PickupPortid != null)
if (detail.PickupDate != null)
{
var changerec = new CM_State_ChangeReq();
@ -312,63 +313,64 @@ public class CM_RentOneWay_InService : CMServiceBase, ICM_RentOneWay_InService
await _Changeservice.AddCM_State_ChangeAsync(changerec);
}
if (detail.DropoffDate != null)
{
var changerec = new CM_State_ChangeReq();
//20241014 单程租入现在仅仅是租入 不处理还箱
//if (detail.DropoffDate != null)
//{
// var changerec = new CM_State_ChangeReq();
changerec.Cntrno = detail.Cntrno;
changerec.CtnCode = detail.CtnCode;
changerec.Ctnall = detail.Ctnall;
changerec.UsedState = "USED";
changerec.CtnOwnerId = data.OldContainerOwnerId;
changerec.CtnOwner = data.OldContainerOwner;
// changerec.Cntrno = detail.Cntrno;
// changerec.CtnCode = detail.CtnCode;
// changerec.Ctnall = detail.Ctnall;
// changerec.UsedState = "USED";
// changerec.CtnOwnerId = data.OldContainerOwnerId;
// changerec.CtnOwner = data.OldContainerOwner;
//默认长租租入
//changerec.CtnSourceId = detail.sour
// //默认长租租入
// //changerec.CtnSourceId = detail.sour
changerec.CtnBizStateId = CM_CtnBizStateEnum.;
changerec.ChangeSourceId = CMChangeSourceEnum.;
changerec.ChangeSourceDetailId = data.Id;
changerec.CtnFlowStateId = null;
// changerec.CtnBizStateId = CM_CtnBizStateEnum.单程租入业务还箱;
// changerec.ChangeSourceId = CMChangeSourceEnum.单程;
// changerec.ChangeSourceDetailId = data.Id;
// changerec.CtnFlowStateId = null;
changerec.CtnStateId = CMCtnStateEnum.AV;
changerec.CtnBreakStateId = CMCtnBreakStateEnum.AV;
changerec.IsHeavy = false;
// changerec.CtnStateId = CMCtnStateEnum.AV;
// changerec.CtnBreakStateId = CMCtnBreakStateEnum.AV;
// changerec.IsHeavy = false;
changerec.Billno = detail.Mblno;
//changerec.IsOnlineId = CM_IsOnlineEnum.待上线;
// changerec.Billno = detail.Mblno;
// //changerec.IsOnlineId = CM_IsOnlineEnum.待上线;
if (detail.DropoffPortid != null)
{
changerec.Portid = detail.DropoffPortid;
changerec.PortCode = detail.DropoffPortCode;
changerec.Port = detail.DropoffPort;
}
// if (detail.DropoffPortid != null)
// {
// changerec.Portid = detail.DropoffPortid;
// changerec.PortCode = detail.DropoffPortCode;
// changerec.Port = detail.DropoffPort;
// }
changerec.ChangeTime = data.Bsdate;
changerec.CtnFlowStateId = null;
// changerec.ChangeTime = data.Bsdate;
// changerec.CtnFlowStateId = null;
//如果没有填写提箱日期 则变动来源id设为租箱主单 变动日期设为业务日期
//如果填写了提箱日期 则变动来源id设为租箱主单 变动日期设为提箱日期
// //如果没有填写提箱日期 则变动来源id设为租箱主单 变动日期设为业务日期
// //如果填写了提箱日期 则变动来源id设为租箱主单 变动日期设为提箱日期
if (detail.PickupDate != null)
{
changerec.CtnStateId = CMCtnStateEnum.AV;
changerec.ChangeSourceDetailId = detail.Id;//还箱变动 来源是明细表
changerec.CtnFlowStateId = CMCtnFlowStateEnum.;
// if (detail.PickupDate != null)
// {
// changerec.CtnStateId = CMCtnStateEnum.AV;
// changerec.ChangeSourceDetailId = detail.Id;//还箱变动 来源是明细表
// changerec.CtnFlowStateId = CMCtnFlowStateEnum.已还箱;
changerec.ChangeTime = detail.DropoffDate;
changerec.IsOnlineId = CM_IsOnlineEnum.线;
}
// changerec.ChangeTime = detail.DropoffDate;
// changerec.IsOnlineId = CM_IsOnlineEnum.上线;
// }
if (changerec.ChangeTime == null) changerec.ChangeTime = DateTime.Now;
// if (changerec.ChangeTime == null) changerec.ChangeTime = DateTime.Now;
//await TenantDb.Insertable(changerec).ExecuteReturnEntityAsync();
// //await TenantDb.Insertable(changerec).ExecuteReturnEntityAsync();
//await _Changeservice.UpdateCM_CurrentStateAsync(changerec);
// //await _Changeservice.UpdateCM_CurrentStateAsync(changerec);
await _Changeservice.AddCM_State_ChangeAsync(changerec);
}
// await _Changeservice.AddCM_State_ChangeAsync(changerec);
//}
}

@ -69,6 +69,9 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
private readonly ICM_RentOneWayService _CM_RentOneWay;
private readonly ICM_RentOneWay_InService _CM_RentOneWay_In;
private readonly ICM_CtnScrapService _CM_CtnScrap;
private readonly ICM_BaseInfoService _CM_BaseInfo;
/// <summary>
///
/// </summary>
@ -93,6 +96,9 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
_CM_RentOneWay = _serviceProvider.GetRequiredService<ICM_RentOneWayService>();
_CM_RentOneWay_In = _serviceProvider.GetRequiredService<ICM_RentOneWay_InService>();
_CM_CtnScrap = _serviceProvider.GetRequiredService<ICM_CtnScrapService>();
_CM_BaseInfo = _serviceProvider.GetRequiredService<ICM_BaseInfoService>();
}
/// <summary>
@ -297,6 +303,11 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
insertrecords= tempList.Where(x => !DoneIdList.Contains(x.Id)).ToList();
}
if (insertrecords.Exists(x => x.IsOnlineId == CM_IsOnlineEnum.线))
{
return await Task.FromResult(DataResult.Failed("添加失败!", MultiLanguageConst.CM_NoDealTempDetail));
}
foreach (var item in insertrecords)
{
var saverec= item.Adapt<CM_State_Change>();
@ -304,6 +315,8 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
saverec.ChangeSourceId = CMChangeSourceEnum.;
saverec.ChangeSourceDetailId = item.Id;
saverec.IsOnline = saverec.IsOnlineId?.GetDescription();
var _addrec = saverec.Adapt<CM_State_ChangeReq>();
await TenantDb.Insertable(saverec).ExecuteReturnEntityAsync();
@ -963,7 +976,7 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
{
newchange.VesselVoyno = Vessel +" : "+ Voyno;
}
newchange.IsOnlineId= CM_IsOnlineEnum.线;
changelist.Add(newchange);
}
@ -972,6 +985,57 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
{
await tenantDb.Deleteable<CM_State_Change_Temp>(x => x.Pid == req.Id).ExecuteCommandAsync();
//20241014 对于识别结果 做如下操作:
//1判断箱号是否合规 不合规的记录错误DealRemark=“箱号错误”) 是否上线记录成待上线,
//2在箱当前状态表中查找是否有此箱号如果没有或者有但是isonline不等于已上线 是否上线记录成待上线
foreach (var ctn in changelist)
{
var trueCntrno = "";
var istrue = _CM_BaseInfo.ValidateContainerNumber(ctn.Cntrno, out trueCntrno);
if (istrue == true)
{
}
else
{
ctn.IsOnlineId = CM_IsOnlineEnum.线;
ctn.DealRemark = $"箱号错误";
if (!string.IsNullOrWhiteSpace(trueCntrno))
{
ctn.DealRemark += $",应为{trueCntrno}";
}
}
}
var _cntrnoList = changelist.Where(x => x.IsOnlineId == CM_IsOnlineEnum.线).Select(s => s.Cntrno).ToList();
var _currentStatusList = await tenantDb.Queryable<CM_CurrentState>().Where(x => _cntrnoList.Contains(x.Cntrno)).ToListAsync();
foreach (var ctn in changelist.Where(x => x.IsOnlineId == CM_IsOnlineEnum.线))
{
if (_currentStatusList.Exists(x => x.Cntrno == ctn.Cntrno))
{
var _rec = _currentStatusList.FirstOrDefault(x => x.Cntrno == ctn.Cntrno);
if (_rec.IsOnlineId != CM_IsOnlineEnum.线)
{
ctn.IsOnlineId = CM_IsOnlineEnum.线;
ctn.DealRemark = $"箱号目前非上线状态";
}
}
else
{
ctn.IsOnlineId = CM_IsOnlineEnum.线;
ctn.DealRemark = $"未找到此箱号";
}
}
foreach (var ctn in changelist)
{
ctn.IsOnline= ctn.IsOnlineId?.GetDescription();
}
var _r3 = await tenantDb.Insertable(changelist).ExecuteCommandAsync();
}

@ -4,6 +4,8 @@ using DS.Module.ExcelModule.Model;
using DS.WMS.Core.Code.Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.HPSF;
using System.Text;
namespace DS.WMS.MainApi.Controllers
{
@ -42,13 +44,13 @@ namespace DS.WMS.MainApi.Controllers
/// <returns></returns>
[HttpPost]
[Route("ExportExcelStreamByColumn")]
public IActionResult ExportExcelStreamByColumn([FromBody] ExportByColumnReq req)
public async Task<IActionResult> ExportExcelStreamByColumn([FromBody] ExportByColumnReq req)
{
var result = _invokeService.ExportExcelStreamByColumn(req);
HttpContext.Response.Headers.Add("Content-Length", result.Length.ToString());
HttpContext.Response.Headers.Add("Content-Type", "charset=UTF-8");
return File(result, "application/octet-stream;charset=UTF-8", Path.GetFileName(Path.GetRandomFileName() + ".xlsx"));
//return new FileStreamResult(result, "application/octet-stream") { FileDownloadName = Guid.NewGuid().ToString() + ".xlsx" };
}
}
}

@ -130,7 +130,7 @@ public class ContainerManagementTest
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOut_Detail));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay_Detail));
tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay_In));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay_In));
//tenantDb.CodeFirst.InitTables(typeof(CM_BuyCtn));
//tenantDb.CodeFirst.InitTables(typeof(CM_BuyCtn_Detail));
@ -147,7 +147,7 @@ public class ContainerManagementTest
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_Templat));
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_TemplatDetail));
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_TemplatImport));
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_Temp));
tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_Temp));
}
Assert.True(true);

Loading…
Cancel
Save