From 6a3eafd629adb8385ac109ebe9c401cf4893b239 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 31 Oct 2024 15:49:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BLIssueManage/BLIssueManageBaseDto.cs | 66 ++ .../Op/Dtos/Enum/BLIssueActionEnum.cs | 45 + .../Op/Dtos/Enum/BLIssueBusiTypeEnum.cs | 21 + .../Op/Dtos/Enum/BLIssueStatusEnum.cs | 12 +- .../DS.WMS.Core/Op/Dtos/Enum/BLTypeEnum.cs | 21 + .../Entity/BLIssueManage/BLIssueManageBase.cs | 67 ++ .../BLIssueManage/BLIssueManageService.cs | 812 +++++++++++++++++- 7 files changed, 1032 insertions(+), 12 deletions(-) create mode 100644 ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueBusiTypeEnum.cs create mode 100644 ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLTypeEnum.cs diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/BLIssueManage/BLIssueManageBaseDto.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/BLIssueManage/BLIssueManageBaseDto.cs index af37e939..4b1237b4 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/BLIssueManage/BLIssueManageBaseDto.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/BLIssueManage/BLIssueManageBaseDto.cs @@ -330,5 +330,71 @@ namespace DS.WMS.Core.Op.Dtos /// 客服名称 /// public string CustomerServiceName { get; set; } + + /// + /// 船证签入日期 + /// + public Nullable ShipCertCheckInDate { get; set; } + + /// + /// 船证签入备注 + /// + public string ShipCertCheckInNote { get; set; } + + /// + /// 船证签入人 + /// + public long ShipCertCheckInBy { get; set; } + + /// + /// 船证签入人名称 + /// + public string ShipCertCheckInUserName { get; set; } + + + /// + /// 船证签出日期 + /// + public Nullable ShipCertCheckOutDate { get; set; } + + /// + /// 船证签出备注 + /// + public string ShipCertCheckOutNote { get; set; } + + /// + /// 船证签出人 + /// + public long ShipCertCheckOutBy { get; set; } + + /// + /// 船证签出人名称 + /// + public string ShipCertCheckOutUserName { get; set; } + + /// + /// 是否船证已签入 + /// + public bool IsShipCertCheckIn { get; set; } + + /// + /// 是否船证已签出 + /// + public bool IsShipCertCheckOut { get; set; } + + /// + /// 是否已签入 + /// + public bool IsCheckIn { get; set; } + + /// + /// 是否已签出 + /// + public bool IsCheckOut { get; set; } + + /// + /// 是否换签(背书) + /// + public bool IsChangeEndorse { get; set; } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueActionEnum.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueActionEnum.cs index 7cbf6053..1f381ae5 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueActionEnum.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueActionEnum.cs @@ -32,5 +32,50 @@ namespace DS.WMS.Core.Op.Dtos /// [Description("取消签出")] CheckOutCancel, + /// + /// 船证签入 + /// + [Description("签入")] + ShipCertCheckIn, + /// + /// 船证签出 + /// + [Description("船证签出")] + ShipCertCheckOut, + /// + /// 取消船证签入 + /// + [Description("取消船证签入")] + ShipCertCheckInCancel, + /// + /// 取消船证签出 + /// + [Description("取消船证签出")] + ShipCertCheckOutCancel, + /// + /// 换签(背书) + /// + [Description("换签(背书)")] + ChangeEndorse, + /// + /// 船证签出 + /// + [Description("取消换签(背书)")] + ChangeEndorseCancel, + /// + /// 驳回放单通知 + /// + [Description("驳回放单通知")] + RejectReleaeNotice, + /// + /// 更改提单 + /// + [Description("更改提单")] + BLModify, + /// + /// 状态更改 + /// + [Description("状态更改")] + StatusModify, } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueBusiTypeEnum.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueBusiTypeEnum.cs new file mode 100644 index 00000000..992f38a5 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueBusiTypeEnum.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.WMS.Core.Op.Dtos.Enum +{ + /// + /// 提单管理业务类型枚举 + /// + public enum BLIssueBusiTypeEnum + { + /// + /// 海运出口 + /// + [Description("海运出口")] + SeaExport + } +} diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueStatusEnum.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueStatusEnum.cs index 938a19a2..4e8a749d 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueStatusEnum.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLIssueStatusEnum.cs @@ -56,6 +56,16 @@ namespace DS.WMS.Core.Op.Dtos /// 未签出 /// [Description("未签出")] - UnCheckOut + UnCheckOut, + /// + /// 换签(背书) + /// + [Description("换签(背书)")] + ChangeEndorse, + /// + /// 驳回放单通知 + /// + [Description("驳回放单通知")] + RejectReleaeNotice } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLTypeEnum.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLTypeEnum.cs new file mode 100644 index 00000000..a0411ddf --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/BLTypeEnum.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.WMS.Core.Op.Dtos.Enum +{ + /// + /// 单据类型 + /// + public enum BLTypeEnum + { + /// + /// 提单 + /// + [Description("提单")] + BL + } +} diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/BLIssueManage/BLIssueManageBase.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/BLIssueManage/BLIssueManageBase.cs index 7b6ae7b1..c3296d82 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/BLIssueManage/BLIssueManageBase.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/BLIssueManage/BLIssueManageBase.cs @@ -302,5 +302,72 @@ namespace DS.WMS.Core.Op.Entity /// [SqlSugar.SugarColumn(ColumnDescription = "不含税其他币种利润", Length = 18, DecimalDigits = 3, IsNullable = true)] public Nullable NoTaxProfitOther { get; set; } + + /// + /// 船证签入日期 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签入日期", IsNullable = true)] + public Nullable ShipCertCheckInDate { get; set; } + + /// + /// 船证签入备注 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签入备注", IsNullable = true, Length = 500)] + public string ShipCertCheckInNote { get; set; } + + /// + /// 船证签入人 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签入人", IsNullable = true)] + public long ShipCertCheckInBy { get; set; } + + /// + /// 船证签入人名称 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签入人名称", IsNullable = true)] + public string ShipCertCheckInUserName { get; set; } + + + /// + /// 船证签出日期 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签出日期", IsNullable = true)] + public Nullable ShipCertCheckOutDate { get; set; } + + /// + /// 船证签出备注 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签出备注", IsNullable = true, Length = 500)] + public string ShipCertCheckOutNote { get; set; } + + /// + /// 船证签出人 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签出人", IsNullable = true)] + public long ShipCertCheckOutBy { get; set; } + + /// + /// 船证签出人名称 + /// + [SqlSugar.SugarColumn(ColumnDescription = "船证签出人名称", IsNullable = true)] + public string ShipCertCheckOutUserName { get; set; } + + /// + /// 是否船证已签入 + /// + [SqlSugar.SugarColumn(ColumnDescription = "是否船证已签入", IsNullable = true)] + public bool IsShipCertCheckIn { get; set; } + + /// + /// 是否船证已签出 + /// + [SqlSugar.SugarColumn(ColumnDescription = "是否船证已签出", IsNullable = true)] + public bool IsShipCertCheckOut { get; set; } + + /// + /// 是否换签(背书) + /// + [SqlSugar.SugarColumn(ColumnDescription = "是否换签(背书)", IsNullable = true)] + public bool IsChangeEndorse { get; set; } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/BLIssueManage/BLIssueManageService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/BLIssueManage/BLIssueManageService.cs index f9b0754a..1e9f1877 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/BLIssueManage/BLIssueManageService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/BLIssueManage/BLIssueManageService.cs @@ -68,6 +68,7 @@ using DS.Module.Core.Enums; using DS.WMS.Core.Application.Dtos; using iText.Layout.Element; using AngleSharp.Html; +using DS.WMS.Core.Op.Dtos.Enum; namespace DS.WMS.Core.Op.Method { @@ -170,6 +171,10 @@ namespace DS.WMS.Core.Op.Method DischargePort = data.order.DischargePort, CustomerService = data.order.CustomerService, CustomerServiceName = data.order.CustomerServiceName, + BusiType = BLIssueBusiTypeEnum.SeaExport.ToString(), + BusiTypeName = BLIssueBusiTypeEnum.SeaExport.GetDescription(), + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), }); start++; @@ -259,6 +264,8 @@ namespace DS.WMS.Core.Op.Method DischargePort = data.order.DischargePort, CustomerService = data.order.CustomerService, CustomerServiceName = data.order.CustomerServiceName, + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), }; var saveRlt = await Save(dto); @@ -274,6 +281,9 @@ namespace DS.WMS.Core.Op.Method blModel.CheckInUserName = user.UserName; blModel.CheckInDate = nowDate; blModel.CheckInNote = model.Notes; + blModel.Status = BLIssueStatusEnum.CheckIn.ToString(); + blModel.StatusName = BLIssueStatusEnum.CheckIn.GetDescription(); + await tenantDb.Updateable(blModel) .UpdateColumns(x => new @@ -283,6 +293,8 @@ namespace DS.WMS.Core.Op.Method x.CheckInUserName, x.CheckInDate, x.CheckInNote, + x.Status, + x.StatusName }).ExecuteCommandAsync(); @@ -381,6 +393,8 @@ namespace DS.WMS.Core.Op.Method blModel.CheckInUserName = null; blModel.CheckInDate = null; blModel.CheckInNote = null; + blModel.Status = null; + blModel.StatusName = null; await tenantDb.Updateable(blModel) .UpdateColumns(x => new @@ -390,6 +404,8 @@ namespace DS.WMS.Core.Op.Method x.CheckInUserName, x.CheckInDate, x.CheckInNote, + x.Status, + x.StatusName }).ExecuteCommandAsync(); @@ -480,6 +496,8 @@ namespace DS.WMS.Core.Op.Method blModel.CheckOutUserName = user.UserName; blModel.CheckOutDate = nowDate; blModel.CheckOutNote = model.Notes; + blModel.Status = BLIssueStatusEnum.CheckOut.ToString(); + blModel.StatusName = BLIssueStatusEnum.CheckOut.GetDescription(); await tenantDb.Updateable(blModel) .UpdateColumns(x => new @@ -489,6 +507,8 @@ namespace DS.WMS.Core.Op.Method x.CheckOutUserName, x.CheckOutDate, x.CheckOutNote, + x.Status, + x.StatusName }).ExecuteCommandAsync(); @@ -551,6 +571,8 @@ namespace DS.WMS.Core.Op.Method blModel.CheckOutUserName = null; blModel.CheckOutDate = null; blModel.CheckOutNote = null; + blModel.Status = null; + blModel.StatusName = null; await tenantDb.Updateable(blModel) .UpdateColumns(x => new @@ -560,6 +582,8 @@ namespace DS.WMS.Core.Op.Method x.CheckOutUserName, x.CheckOutDate, x.CheckOutNote, + x.Status, + x.StatusName }).ExecuteCommandAsync(); @@ -592,7 +616,98 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task ShipCertCheckIn(ShipCertCheckInOutDto model) { - return null; + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel == null || blModel.Id == 0) + { + var dto = new BLIssueManageBaseInputDto + { + BookingId = data.order.Id, + BLNo = data.order.MBLNO, + CustomerId = data.order.CustomerId, + CustomerName = data.order.CustomerName, + SaleId = data.order.SaleId, + Sale = data.order.Sale, + IssueType = data.order.IssueType, + IssueTypeCode = data.order.IssueTypeCode, + IssuePlaceCode = data.order.IssuePlaceCode, + IssuePlace = data.order.IssuePlace, + LoadPortId = data.order.LoadPortId, + LoadPortCode = data.order.LoadPortCode, + LoadPort = data.order.LoadPort, + DischargePortId = data.order.DischargePortId, + DischargePortCode = data.order.DischargePortCode, + DischargePort = data.order.DischargePort, + CustomerService = data.order.CustomerService, + CustomerServiceName = data.order.CustomerServiceName, + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), + }; + + var saveRlt = await Save(dto); + + if (saveRlt.Succeeded) + blModel = saveRlt.Data; + } + + if (!blModel.IsShipCertCheckIn) + { + blModel.IsShipCertCheckIn = true; + blModel.IsShipCertificate = true; + blModel.ShipCertCheckInBy = long.Parse(user.UserId); + blModel.ShipCertCheckInUserName = user.UserName; + blModel.ShipCertCheckInDate = nowDate; + blModel.ShipCertCheckInNote = model.Notes; + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.IsShipCertificate, + x.IsShipCertCheckIn, + x.ShipCertCheckInBy, + x.ShipCertCheckInUserName, + x.ShipCertCheckInDate, + x.ShipCertCheckInNote, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.ShipCertCheckIn.ToString(), + ActionName = BLIssueActionEnum.ShipCertCheckIn.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + + return DataResult.Successed("成功"); } #endregion @@ -604,7 +719,67 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task ShipCertCheckInCancel(ShipCertCheckInOutDto model) { - return null; + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel != null && blModel.Id > 0) + { + if (blModel.IsShipCertCheckIn) + { + blModel.IsShipCertCheckIn = false; + blModel.ShipCertCheckInBy = 0; + blModel.ShipCertCheckInUserName = null; + blModel.ShipCertCheckInDate = null; + blModel.ShipCertCheckInNote = null; + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.IsShipCertCheckIn, + x.ShipCertCheckInBy, + x.ShipCertCheckInUserName, + x.ShipCertCheckInDate, + x.ShipCertCheckInNote, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.ShipCertCheckInCancel.ToString(), + ActionName = BLIssueActionEnum.ShipCertCheckInCancel.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + } + + return DataResult.Successed("成功"); } #endregion @@ -616,7 +791,95 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task ShipCertCheckOut(ShipCertCheckInOutDto model) { - return null; + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel == null || blModel.Id == 0) + { + var dto = new BLIssueManageBaseInputDto + { + BookingId = data.order.Id, + BLNo = data.order.MBLNO, + CustomerId = data.order.CustomerId, + CustomerName = data.order.CustomerName, + SaleId = data.order.SaleId, + Sale = data.order.Sale, + IssueType = data.order.IssueType, + IssueTypeCode = data.order.IssueTypeCode, + IssuePlaceCode = data.order.IssuePlaceCode, + IssuePlace = data.order.IssuePlace, + LoadPortId = data.order.LoadPortId, + LoadPortCode = data.order.LoadPortCode, + LoadPort = data.order.LoadPort, + DischargePortId = data.order.DischargePortId, + DischargePortCode = data.order.DischargePortCode, + DischargePort = data.order.DischargePort, + CustomerService = data.order.CustomerService, + CustomerServiceName = data.order.CustomerServiceName, + }; + + var saveRlt = await Save(dto); + + if (saveRlt.Succeeded) + blModel = saveRlt.Data; + } + if (!blModel.IsShipCertCheckOut) + { + blModel.IsShipCertCheckOut = true; + blModel.IsShipCertificate = true; + blModel.ShipCertCheckOutBy = long.Parse(user.UserId); + blModel.ShipCertCheckOutUserName = user.UserName; + blModel.ShipCertCheckOutDate = nowDate; + blModel.ShipCertCheckOutNote = model.Notes; + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.IsShipCertificate, + x.IsShipCertCheckOut, + x.ShipCertCheckOutBy, + x.ShipCertCheckOutUserName, + x.ShipCertCheckOutDate, + x.ShipCertCheckOutNote, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.ShipCertCheckOut.ToString(), + ActionName = BLIssueActionEnum.ShipCertCheckOut.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + + return DataResult.Successed("成功"); } #endregion @@ -628,7 +891,67 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task ShipCertCheckOutCancel(ShipCertCheckInOutDto model) { - return null; + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel != null && blModel.Id > 0) + { + if (blModel.IsShipCertCheckOut) + { + blModel.IsShipCertCheckOut = false; + blModel.ShipCertCheckOutBy = 0; + blModel.ShipCertCheckOutUserName = null; + blModel.ShipCertCheckOutDate = null; + blModel.ShipCertCheckOutNote = null; + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.IsShipCertCheckOut, + x.ShipCertCheckOutBy, + x.ShipCertCheckOutUserName, + x.ShipCertCheckOutDate, + x.ShipCertCheckOutNote, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.ShipCertCheckOutCancel.ToString(), + ActionName = BLIssueActionEnum.ShipCertCheckOutCancel.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + } + + return DataResult.Successed("成功"); } #endregion @@ -640,9 +963,105 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task BLCheckChangeEndorse(BLCheckInOutDto model) { - return null; - } - #endregion + /* + 只能提单签入才能换单背书 + */ + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + if (orderList.Any(p => !p.bl.IsCheckIn)) + { + string s = string.Join(",", orderList.Where(p => !p.bl.IsCheckIn) + .Select(b => b.bl.BLNo).ToArray()); + + return DataResult.Failed($"提单号:{s} 不能操作,只有已提单已签入才能进行 提单换签(背书)"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel == null || blModel.Id == 0) + { + var dto = new BLIssueManageBaseInputDto + { + BookingId = data.order.Id, + BLNo = data.order.MBLNO, + CustomerId = data.order.CustomerId, + CustomerName = data.order.CustomerName, + SaleId = data.order.SaleId, + Sale = data.order.Sale, + IssueType = data.order.IssueType, + IssueTypeCode = data.order.IssueTypeCode, + IssuePlaceCode = data.order.IssuePlaceCode, + IssuePlace = data.order.IssuePlace, + LoadPortId = data.order.LoadPortId, + LoadPortCode = data.order.LoadPortCode, + LoadPort = data.order.LoadPort, + DischargePortId = data.order.DischargePortId, + DischargePortCode = data.order.DischargePortCode, + DischargePort = data.order.DischargePort, + CustomerService = data.order.CustomerService, + CustomerServiceName = data.order.CustomerServiceName, + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), + }; + + var saveRlt = await Save(dto); + + if (saveRlt.Succeeded) + blModel = saveRlt.Data; + } + + if (blModel.IsCheckIn) + { + blModel.Status = BLIssueStatusEnum.ChangeEndorse.ToString(); + blModel.StatusName = BLIssueStatusEnum.ChangeEndorse.GetDescription(); + blModel.IsChangeEndorse = true; + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.Status, + x.StatusName, + x.IsChangeEndorse, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.ChangeEndorse.ToString(), + ActionName = BLIssueActionEnum.ChangeEndorse.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + + return DataResult.Successed("成功"); + } + #endregion #region 取消提单换签(背书) /// @@ -652,7 +1071,103 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task BLCheckChangeEndorseCancel(BLCheckInOutDto model) { - return null; + /* + 只能提单签入才能换单背书 + */ + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + if (orderList.Any(p => !p.bl.IsCheckIn)) + { + string s = string.Join(",", orderList.Where(p => !p.bl.IsCheckIn) + .Select(b => b.bl.BLNo).ToArray()); + + return DataResult.Failed($"提单号:{s} 不能操作,只有已提单已签入才能进行 提单换签(背书)"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel == null || blModel.Id == 0) + { + var dto = new BLIssueManageBaseInputDto + { + BookingId = data.order.Id, + BLNo = data.order.MBLNO, + CustomerId = data.order.CustomerId, + CustomerName = data.order.CustomerName, + SaleId = data.order.SaleId, + Sale = data.order.Sale, + IssueType = data.order.IssueType, + IssueTypeCode = data.order.IssueTypeCode, + IssuePlaceCode = data.order.IssuePlaceCode, + IssuePlace = data.order.IssuePlace, + LoadPortId = data.order.LoadPortId, + LoadPortCode = data.order.LoadPortCode, + LoadPort = data.order.LoadPort, + DischargePortId = data.order.DischargePortId, + DischargePortCode = data.order.DischargePortCode, + DischargePort = data.order.DischargePort, + CustomerService = data.order.CustomerService, + CustomerServiceName = data.order.CustomerServiceName, + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), + }; + + var saveRlt = await Save(dto); + + if (saveRlt.Succeeded) + blModel = saveRlt.Data; + } + + if (blModel.IsChangeEndorse) + { + blModel.Status = null; + blModel.StatusName = null; + blModel.IsChangeEndorse = false; + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.Status, + x.StatusName, + x.IsChangeEndorse, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.ChangeEndorseCancel.ToString(), + ActionName = BLIssueActionEnum.ChangeEndorseCancel.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + + return DataResult.Successed("成功"); } #endregion @@ -664,7 +1179,100 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task BLRejectReleaseNotice(BLCheckInOutDto model) { - return null; + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + if (orderList.Any(p => !p.bl.IsCheckIn)) + { + string s = string.Join(",", orderList.Where(p => !p.bl.IsCheckIn) + .Select(b => b.bl.BLNo).ToArray()); + + return DataResult.Failed($"提单号:{s} 不能操作,只有已提单已签入才能进行 驳回放单通知"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel == null || blModel.Id == 0) + { + var dto = new BLIssueManageBaseInputDto + { + BookingId = data.order.Id, + BLNo = data.order.MBLNO, + CustomerId = data.order.CustomerId, + CustomerName = data.order.CustomerName, + SaleId = data.order.SaleId, + Sale = data.order.Sale, + IssueType = data.order.IssueType, + IssueTypeCode = data.order.IssueTypeCode, + IssuePlaceCode = data.order.IssuePlaceCode, + IssuePlace = data.order.IssuePlace, + LoadPortId = data.order.LoadPortId, + LoadPortCode = data.order.LoadPortCode, + LoadPort = data.order.LoadPort, + DischargePortId = data.order.DischargePortId, + DischargePortCode = data.order.DischargePortCode, + DischargePort = data.order.DischargePort, + CustomerService = data.order.CustomerService, + CustomerServiceName = data.order.CustomerServiceName, + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), + }; + + var saveRlt = await Save(dto); + + if (saveRlt.Succeeded) + blModel = saveRlt.Data; + } + + if (blModel.IsCheckIn) + { + blModel.Status = BLIssueStatusEnum.RejectReleaeNotice.ToString(); + blModel.StatusName = BLIssueStatusEnum.RejectReleaeNotice.GetDescription(); + blModel.IsChangeEndorse = true; + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.Status, + x.StatusName, + x.IsChangeEndorse, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.RejectReleaeNotice.ToString(), + ActionName = BLIssueActionEnum.RejectReleaeNotice.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + + return DataResult.Successed("成功"); } #endregion @@ -676,7 +1284,98 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task BLModify(BLCheckInOutDto model) { - return null; + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + if (orderList.Any(p => !p.bl.IsCheckIn)) + { + string s = string.Join(",", orderList.Where(p => !p.bl.IsCheckIn) + .Select(b => b.bl.BLNo).ToArray()); + + return DataResult.Failed($"提单号:{s} 不能操作,只有已提单已签入才能进行 更改提单(其他)"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel == null || blModel.Id == 0) + { + var dto = new BLIssueManageBaseInputDto + { + BookingId = data.order.Id, + BLNo = data.order.MBLNO, + CustomerId = data.order.CustomerId, + CustomerName = data.order.CustomerName, + SaleId = data.order.SaleId, + Sale = data.order.Sale, + IssueType = data.order.IssueType, + IssueTypeCode = data.order.IssueTypeCode, + IssuePlaceCode = data.order.IssuePlaceCode, + IssuePlace = data.order.IssuePlace, + LoadPortId = data.order.LoadPortId, + LoadPortCode = data.order.LoadPortCode, + LoadPort = data.order.LoadPort, + DischargePortId = data.order.DischargePortId, + DischargePortCode = data.order.DischargePortCode, + DischargePort = data.order.DischargePort, + CustomerService = data.order.CustomerService, + CustomerServiceName = data.order.CustomerServiceName, + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), + }; + + var saveRlt = await Save(dto); + + if (saveRlt.Succeeded) + blModel = saveRlt.Data; + } + + if (blModel.IsCheckIn) + { + blModel.Status = BLIssueStatusEnum.BLModify.ToString(); + blModel.StatusName = BLIssueStatusEnum.BLModify.GetDescription(); + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.Status, + x.StatusName, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.RejectReleaeNotice.ToString(), + ActionName = BLIssueActionEnum.RejectReleaeNotice.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + + return DataResult.Successed("成功"); } #endregion @@ -688,7 +1387,98 @@ namespace DS.WMS.Core.Op.Method /// 返回回执 public async Task BLModifyStatus(BLCheckInOutDto model) { - return null; + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (model.bookids.Length == 0) + return DataResult.Failed("请求参数错误,请选择提单记录"); + + var orderList = tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .LeftJoin((l, r) => l.Id == r.BookingId) + .Where((l, r) => model.bookids.Contains(l.Id) && l.Deleted == false) + .Select((l, r) => new { order = l, bl = r }) + .ToList(); + + if (orderList.Count != model.bookids.Length) + { + return DataResult.Failed("部分订单查询失败,请重新查询台账"); + } + + if (orderList.Any(p => !p.bl.IsCheckIn)) + { + string s = string.Join(",", orderList.Where(p => !p.bl.IsCheckIn) + .Select(b => b.bl.BLNo).ToArray()); + + return DataResult.Failed($"提单号:{s} 不能操作,只有已提单已签入才能进行 状态更改"); + } + + DateTime nowDate = DateTime.Now; + + foreach (var data in orderList) + { + var blModel = data.bl; + + if (blModel == null || blModel.Id == 0) + { + var dto = new BLIssueManageBaseInputDto + { + BookingId = data.order.Id, + BLNo = data.order.MBLNO, + CustomerId = data.order.CustomerId, + CustomerName = data.order.CustomerName, + SaleId = data.order.SaleId, + Sale = data.order.Sale, + IssueType = data.order.IssueType, + IssueTypeCode = data.order.IssueTypeCode, + IssuePlaceCode = data.order.IssuePlaceCode, + IssuePlace = data.order.IssuePlace, + LoadPortId = data.order.LoadPortId, + LoadPortCode = data.order.LoadPortCode, + LoadPort = data.order.LoadPort, + DischargePortId = data.order.DischargePortId, + DischargePortCode = data.order.DischargePortCode, + DischargePort = data.order.DischargePort, + CustomerService = data.order.CustomerService, + CustomerServiceName = data.order.CustomerServiceName, + BLType = BLTypeEnum.BL.ToString(), + BLTypeName = BLTypeEnum.BL.GetDescription(), + }; + + var saveRlt = await Save(dto); + + if (saveRlt.Succeeded) + blModel = saveRlt.Data; + } + + if (blModel.IsCheckIn) + { + blModel.Status = BLIssueStatusEnum.StatusModify.ToString(); + blModel.StatusName = BLIssueStatusEnum.StatusModify.GetDescription(); + + await tenantDb.Updateable(blModel) + .UpdateColumns(x => new + { + x.Status, + x.StatusName, + }).ExecuteCommandAsync(); + + + var log = new BLIssueManageLog + { + Pid = blModel.Id, + ActionCode = BLIssueActionEnum.StatusModify.ToString(), + ActionName = BLIssueActionEnum.StatusModify.GetDescription(), + Note = model.Notes, + Result = "成功", + CreateBy = long.Parse(user.UserId), + CreateUserName = user.UserName, + CreateTime = nowDate, + }; + + await tenantDb.Insertable(log).ExecuteCommandAsync(); + } + } + + return DataResult.Successed("成功"); } #endregion