diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs index eca8327d..9f3d7ce3 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs @@ -196,7 +196,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService public DataResult CancelFlowInstance(CancelFlowInstanceReq req) { var instance = Db.Queryable().First(x => x.Id == req.Id); - if (instance.IsNull()) + if (instance == null) { return DataResult.Failed("该工作流不存在!", MultiLanguageConst.FlowInstanceNotExist); } @@ -266,7 +266,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService public DataResult StartFlowInstance(string id) { var instance = Db.Queryable().First(x => x.Id == long.Parse(id)); - if (instance.IsNull()) + if (instance == null) { return DataResult.Failed("该工作流不存在!", MultiLanguageConst.FlowInstanceNotExist); } @@ -321,7 +321,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService { var instance = GetFlowInstance(req.Id); - if (instance.IsNull()) + if (instance == null) { return DataResult.Failed("该工作流不存在!", MultiLanguageConst.FlowInstanceNotExist); } @@ -416,7 +416,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService instance.ActivityType = runtime.NextNodeType; instance.ActivityName = runtime.NextNode.Name; instance.MakerList = runtime.NextNodeType == 4 ? "1" : GetNextMakers(runtime); - instance.FlowStatus = (runtime.NextNodeType == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running); + instance.FlowStatus = runtime.NextNodeType == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running; } else { @@ -428,12 +428,16 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService #endregion 一般审核 - var serializerSettings = new JsonSerializerSettings + if (!string.IsNullOrEmpty(instance.MakerList) && instance.MakerList != "1") { - // 设置为驼峰命名 - ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() - }; - instance.Content = JsonConvert.SerializeObject(runtime.ToFlowRoot(), Formatting.None, serializerSettings); + var serializerSettings = new JsonSerializerSettings + { + // 设置为驼峰命名 + ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() + }; + instance.Content = JsonConvert.SerializeObject(runtime.ToFlowRoot(), Formatting.None, serializerSettings); + } + instance.Note = auditNote; Db.Updateable(instance).ExecuteCommand(); diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs index b68ab460..da3b835c 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs @@ -442,12 +442,18 @@ public class FlowRuntime public FlowRoot ToFlowRoot() { var root = ChildNodes.First(x => x.Id == "root"); - var list = ChildNodes.Where(x => x.Id != "root").ToList(); + var info = root.Adapt(); info.Child = list.First(x => x.Pid == "root"); - UpdateChild(info.Child); - + try + { + UpdateChild(info.Child); + } + catch + { + } + return info; } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/SeaExportOrder.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/SeaExportOrder.cs new file mode 100644 index 00000000..9bda1677 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/SeaExportOrder.cs @@ -0,0 +1,1293 @@ +using System.ComponentModel; +using DS.Module.Core; + +namespace DS.WMS.Core.Op.Dtos.TaskInteraction; + +/// +/// 海运出口信息 +/// +public class SeaExportOrder +{ + /// + /// 财务日期 + /// + [Description("财务日期")] + public string AccountDate { get; set; } + + /// + /// 主提单号 + /// + [Description("主提单号")] + public string MBLNO { get; set; } + + /// + /// 分提单号 + /// + [Description("分提单号")] + public string HBLNO { get; set; } + + /// + /// 委托单位Id + /// + public long CustomerId { get; set; } + + /// + /// 委托编号 + /// + [Description("委托编号")] + public string CustomerNo { get; set; } + + /// + /// 运单号 + /// + [Description("运单号")] + public string TransNo { get; set; } + + /// + /// 委托单位名称 + /// + [Description("委托单位名称")] + public string CustomerName { get; set; } + + /// + /// 装运方式 整箱、拼箱单票、拼箱主票、拼箱分票 + /// + [Description("装运方式")] + public string BLType { get; set; } + + ///// + ///// 发货人 t_info_client CUSTNAME + ///// + //public long? ShipperId { get; set; } + + ///// + ///// 收货人 t_info_client CUSTNAME + ///// + //public long? ConsigneeId { get; set; } + + ///// + ///// 通知人 t_info_client CUSTNAME + ///// + //public long? NotifyPartyId { get; set; } + + ///// + ///// 国外代理人Id t_info_client CUSTNAME + ///// + //public long? AgentId { get; set; } + + /// + /// 国外代理人 t_info_client CUSTNAME + /// + [Description("国外代理人")] + public string Agent { get; set; } + + /// + /// 发货人内容 + /// + [Description("发货人内容")] + public string ShipperContent { get; set; } + + /// + /// 收货人内容 + /// + [Description("收货人内容")] + public string ConsigneeContent { get; set; } + + /// + /// 通知人内容 + /// + [Description("通知人内容")] + public string NotifyPartyContent { get; set; } + + /// + /// 国外代理内容 + /// + [Description("国外代理内容")] + public string AgentContent { get; set; } + + /// + /// 场站Id t_crm_client CUSTNAME + /// + public long YardId { get; set; } + + /// + /// 场站 t_crm_client CUSTNAME + /// + [Description("场站")] + public string Yard { get; set; } + + /// + /// 场站备注 + /// + [Description("场站备注")] + public string YardRemark { get; set; } + + /// + /// 船名 t_code_vessel + /// + [Description("船名")] + public string Vessel { get; set; } + + ///// + ///// 船名Id t_code_vessel + ///// + //public long VesselId { get; set; } + + /// + /// 航次 + /// + [Description("航次")] + public string Voyno { get; set; } + + /// + /// 开船日期 + /// + [Description("开船日期")] + public DateTime? ETD { get; set; } + + /// + /// 预抵日期 + /// + [Description("预抵日期")] + public DateTime? ETA { get; set; } + + /// + /// ATD + /// + public DateTime? ATD { get; set; } + + /// + /// ATA 实际到港(目的港)时间 + /// + [Description("实际到港日期")] + public DateTime? ATA { get; set; } + + /// + /// 截港日期 + /// + [Description("截港日期")] + public DateTime? ClosingDate { get; set; } + + /// + /// 收货地 + /// + [Description("收货地")] + public string ReceiptPlace { get; set; } + + ///// + ///// 装货港Id + ///// + //public long ReceiptPlaceId { get; set; } + + ///// + ///// 装货港代码 + ///// + //public long LoadPortId { get; set; } + + /// + /// 装货港 + /// + [Description("装货港")] + public string LoadPort { get; set; } + + ///// + ///// 卸货港代码 + ///// + //public long DischargePortId { get; set; } + + /// + /// 卸货港 + /// + [Description("卸货港")] + public string DischargePort { get; set; } + + ///// + ///// 交货地代码 + ///// + //public long DeliveryPlaceId { get; set; } + + /// + /// 交货地 + /// + [Description("交货地")] + public string DeliveryPlace { get; set; } + + ///// + ///// 目的地代码 + ///// + //public long DestinationId { get; set; } + + /// + /// 目的地 + /// + [Description("目的地")] + public string Destination { get; set; } + + /// + /// 提单份数 + /// + public string NoBill { get; set; } + + /// + /// 副本份数 + /// + public string CopyNoBill { get; set; } + + /// + /// 签单方式 t_code_issutype + /// + [Description("签单方式")] + public string IssueType { get; set; } + + /// + /// 签单日期 + /// + [Description("签单日期")] + public DateTime? IssueDate { get; set; } + + ///// + ///// 签单地点Id + ///// + //public long IssuePlaceId { get; set; } + + /// + /// 签单地点 + /// + [Description("签单地点")] + public string IssuePlace { get; set; } + + /// + /// 签单状态 + /// + public DateTime? BLIssueSatus { get; set; } + + ///// + ///// 付款地点Id + ///// + //public long PrepareAtId { get; set; } + + /// + /// 预付地点 + /// + public string PrepareAt { get; set; } + + /// + /// 预付地点 + /// + public string PayableAt { get; set; } + + /// + /// 运输条款 CY-CY t_code_service + /// + [Description("运输条款")] + public string Service { get; set; } + + /// + /// 唛头 N/M + /// + [Description("唛头")] + public string Marks { get; set; } + + /// + /// 箱号封号 + /// + public string CntrSealNo { get; set; } + + /// + /// 件数包装 + /// + public string NoPkgs { get; set; } + + /// + /// 货物描述 + /// + [Description("货物描述")] + public string Description { get; set; } + + /// + /// 品名 t_code_goods + /// + [Description("品名")] + public string GoodsName { get; set; } + + ///// + ///// 品名Id + ///// + //public long GoodsId { get; set; } + + /// + /// 货物毛重 + /// + [Description("货物毛重")] + public string GrossWeight { get; set; } + + /// + /// 货物尺码 + /// + [Description("货物尺码")] + public string Measurement { get; set; } + + /// + /// 件数 + /// + [Description("件数")] + public int? PKGS { get; set; } + + /// + /// 包装 t_code_package + /// + [Description("包装")] + public string KindPkgs { get; set; } + + /// + /// 毛重 + /// + public decimal? KGS { get; set; } + + /// + /// 尺码 + /// + public decimal? CBM { get; set; } + + /// + /// 件数大写 + /// + public string TotalNo { get; set; } + + /// + /// 集装箱大写 + /// + public string CntrNo { get; set; } + + /// + /// 箱TEU + /// + public int TEU { get; set; } + + /// + /// 集装箱 + /// + public string CntrTotal { get; set; } + + /// + /// 操作员 + /// + public long OperatorId { get; set; } + + /// + /// 客服 + /// + public long CustomerService { get; set; } + + /// + /// Desc:单证 + /// + public long Doc { get; set; } + + ///// + ///// 外国客服 + ///// + //public long ForeignCustomerService { get; set; } + + ///// + ///// 航线Id + ///// + //public long LaneId { get; set; } + + /// + /// 航线 + /// + [Description("航线")] + public string Lane { get; set; } + + /// + /// 揽货人Id + /// + public long SaleId { get; set; } + + /// + /// 揽货人 + /// + [Description("揽货人")] + public string Sale { get; set; } + + /// + /// 船公司Id + /// + public long CarrierId { get; set; } + + /// + /// 船公司 + /// + [Description("船公司")] + public string Carrier { get; set; } + + /// + /// 货代公司Id + /// + public long ForwarderId { get; set; } + + /// + /// 货代公司 + /// + [Description("货代公司")] + public string Forwarder { get; set; } + + ///// + ///// 报关行Id + ///// + //public long CustomserId { get; set; } + + /// + /// 报关行 + /// + [Description("报关行")] + public string Customser { get; set; } + + /// + /// 承运车队Id + /// + public long TruckerId { get; set; } + + /// + /// 承运车队 + /// + [Description("车队")] + public string Trucker { get; set; } + + /// + /// 发票号 + /// + public string InvoiceNo { get; set; } + + /// + /// 货物标识 S/R/D/O + /// + [Description("货物标识")] + public string CargoId { get; set; } + + /// + /// 危险品分类 + /// + public string DangerClass { get; set; } + + /// + /// 危险品编号 + /// + public string DangerNo { get; set; } + + /// + /// 危险品页号 + /// + public string DangerPage { get; set; } + + /// + /// 危险品标签 + /// + public string DangerLabel { get; set; } + + /// + /// 冷藏通风量 + /// + public string ReeferQuantity { get; set; } + + /// + /// 温度单位 + /// + public string TemperatureUnit { get; set; } + + /// + /// 设置温度 + /// + public string TemperatureSet { get; set; } + + /// + /// 最低温度 + /// + public string TemperatureMin { get; set; } + + /// + /// 最高温度 + /// + public string TemperatureMax { get; set; } + + ///// + ///// Desc:业务来源Id + ///// + //public long SourceId { get; set; } + + ///// + ///// Desc:业务来源明细Id + ///// + //public long SourceDetailId { get; set; } + + /// + /// Desc:业务来源明细 + /// + [Description("业务来源明细")] + public string SourceDetailName { get; set; } + + /// + /// Desc:报关票数 + /// + public int CustomsNum { get; set; } + + /// + /// 运费协议号(约号) + /// + public string ContractNo { get; set; } + + /// + /// 订舱类型 + /// + [Description("订舱类型")] + public string BookingType { get; set; } + + /// + /// 订舱编号 + /// + [Description("订舱编号")] + public string BookingNo { get; set; } + + /// + /// Desc:保险人 + /// + public string Insuranceer { get; set; } + + /// + /// Desc:保险单号 + /// + public string InsuranceNo { get; set; } + + /// + /// Desc:保险金额 + /// + public decimal? InsuranceAmount { get; set; } + + /// + /// Desc:是否生成凭证 + /// + public bool? IsVoucher { get; set; } = false; + + /// + /// Desc:凭证号 + /// + public string VoucherNo { get; set; } + + /// + /// Desc:备注 + /// + public string Remark { get; set; } + + /// + /// Desc:熏蒸 + /// + public bool? IsFumigation { get; set; } = false; + + /// + /// Desc:仓储 + /// + public bool? IsStorage { get; set; } = false; + + /// + /// Desc:陆运 + /// + public bool? IsLand { get; set; } = false; + + /// + /// Desc:报关 + /// + public bool? IsCustoms { get; set; } = false; + + /// + /// Desc:报检 + /// + public bool? IsInspection { get; set; } = false; + + /// + /// Desc:订舱 + /// + public bool? IsBooking { get; set; } = false; + + /// + /// Desc:使用代理 + /// + public bool? IsAgent { get; set; } = false; + + /// + /// Desc:分单签单 + /// + public bool? IsHBLNO { get; set; } = false; + + ///// + ///// Desc:服务项目9 + ///// + //public bool? Service9 { get; set; } = false; + + ///// + ///// Desc:服务项目10 + ///// + //public bool? Service10 { get; set; } = false; + + /// + /// Desc:装箱类型 + /// + public string PackingType { get; set; } + + ///// + ///// Desc:仓库Id + ///// + //public long WareHouseId { get; set; } + + /// + /// Desc:仓库 + /// + public string WareHouse { get; set; } + + /// + /// 截单日期 + /// + public DateTime CloseDocDate { get; set; } + + /// + /// 集港日期 + /// + public DateTime IntoPortDocDate { get; set; } + + ///// + ///// Desc:所属业务部门 + ///// + //public long SaleDeptId { get; set; } + + /// + /// Desc:MBL付费方式 t_code_frt + /// + public string MBLFrt { get; set; } + + /// + /// Desc:结算方式 + /// + public string StlName { get; set; } + + /// + /// Desc:月结算时间 + /// + public DateTime StlDate { get; set; } + + /// + /// Desc:委托方式 + /// + public string OrderType { get; set; } + + /// + /// Desc:订舱编号 + /// + public string OrderNo { get; set; } + + /// + /// Desc:操作员代码 + /// + [Description("操作员代码")] + public string OperatorCode { get; set; } + + /// + /// Desc:是否为操作 + /// + public bool IsOperator { get; set; } + + /// + /// Desc:操作员邮箱 + /// + public string OperatorEmail { get; set; } + + /// + /// Desc:操作员电话 + /// + public string OperatorTel { get; set; } + + /// + /// Desc:操作员传真 + /// + public string OperatorFax { get; set; } + + /// + /// Desc:场站自结 + /// + public string FinancialStaffCode { get; set; } + + /// + /// Desc:是否为财务 + /// + public bool? IsFinancialStaff { get; set; } = false; + + /// + /// Desc:财务邮箱 + /// + public string FinancialStaffEmail { get; set; } + + /// + /// Desc:财务电话 + /// + public string FinancialStaffTel { get; set; } + + /// + /// Desc:财务传真 + /// + public string FinancialStaffFax { get; set; } + + /// + /// Desc:业务来源代码 + /// + public string SourceCode { get; set; } + + /// + /// Desc:联系人 + /// + public string LinkMan { get; set; } + + /// + /// Desc:海关代码 + /// + public string HSCode { get; set; } + + /// + /// Desc:EDI备注 + /// + public string EdiRemark { get; set; } + + ///// + ///// Desc:邮件方案 + ///// + //public long MailProjectId { get; set; } + + /// + /// Desc:CSR/IR号 + /// + public string IRCode { get; set; } + + /// + /// Desc:服务合同号 + /// + public string ServiceContractNo { get; set; } + + /// + /// Desc:申请放箱号 + /// + public string ApplyNo { get; set; } + + /// + /// Desc:报关单号 + /// + [Description("报关单号")] + public string CustomNo { get; set; } + + /// + /// Desc: 报关日期 + /// + [Description("报关日期")] + public DateTime CustomDate { get; set; } + + ///// + ///// 单位编码 + ///// + //public long? EnterpriseId { get; set; } + + /// + /// 单位 + /// + public string Enterprise { get; set; } + + /// + /// Desc:商检单号 + /// + public string InspectionNo { get; set; } + + /// + /// Desc:商检日期 + /// + public DateTime InspectionDate { get; set; } + + /// + /// Desc:贸易条款 + /// + [Description("贸易条款")] + public string TradeTerm { get; set; } + + /// + /// Desc:贸易方式 + /// + [Description("贸易方式")] + public string TermDelivery { get; set; } + + /// + /// Desc:清关日期 + /// + [Description("清关日期")] + public DateTime ClearCustomDate { get; set; } + + /// + /// Desc:报检项目 + /// + public string InsperctService { get; set; } + + ///// + ///// 船代Id + ///// + //public long ShipAgencyId { get; set; } + + /// + /// 船代 + /// + [Description("船代")] + public string ShipAgency { get; set; } + + /// + /// Desc:湿度 + /// + public string Humidity { get; set; } + + ///// + ///// Master发货人 + ///// + //public long? MasterShipperId { get; set; } + + ///// + ///// Master收货人 t_info_client CUSTNAME + ///// + //public long? MasterConsigneeId { get; set; } + + ///// + ///// Master通知人 t_info_client CUSTNAME + ///// + //public long? MasterNotifyPartyId { get; set; } + + /// + /// Master收货人内容 + /// + public string MasterConsigneeContent { get; set; } + + /// + /// Master通知人内容 + /// + public string MasterNotifyPartyContent { get; set; } + + /// + /// Master发货人内容 + /// + public string MasterShipperContent { get; set; } + + /// + /// Master单描述 + /// + public string MasterDescription { get; set; } + + /// + /// Desc:是否SOC + /// + public bool? IsContainerSoc { get; set; } = false; + + /// + /// Desc:运输状态 + /// + [Description("运输状态")] + public string TranStatus { get; set; } + + /// + /// Desc: + /// + public string ManifestStatus { get; set; } + + /// + /// 是否多品名 + /// + public bool IsMoreGood { get; set; } + + /// + /// 是否打印小票 + /// + public bool IsPrintReceipt { get; set; } + + /// + /// 船名 t_code_vessel + /// + [Description("船名")] + public string Vessel2N { get; set; } + + ///// + ///// 船名Id t_code_vessel + ///// + //public long VesselId2N { get; set; } + + /// + /// 二程航次 + /// + [Description("二程航次")] + public string Voyno2N { get; set; } + + /// + /// 交货日期 + /// + [Description("交货日期")] + public DateTime DeliveryDate { get; set; } + + /// + /// 场站联系人 + /// + public string YardATTN { get; set; } + + /// + /// 场站联系方式 + /// + public string YardTel { get; set; } + + ///// + ///// 销售公司Id + ///// + //public long SaleOrgId { get; set; } + + ///// + ///// 中转港Id + ///// + //public long TransPortId { get; set; } + + /// + /// 中转港 + /// + [Description("中转港")] + public string TransPort { get; set; } + + /// + /// 转运备注 + /// + public string TransRemark { get; set; } + + /// + /// 预录 + /// + public int PreRecord { get; set; } + + /// + /// 备注 + /// + public string? Note { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } + + /// + /// 截单备注 + /// + public string CloseDocRemark { get; set; } + + /// + /// 订舱备注 + /// + public string BookingRemark { get; set; } + + /// + /// Desc:提单签发状态 + /// + public int BLIssueStatus { get; set; } + + /// + /// Desc:整票提交状态 + /// + public AuditStatusEnum BillSubmitStatus { get; set; } + + /// + /// 是否订阅运踪 0 没有订阅 1 订阅起运港 2 订阅目的港 3 订阅起运港目的港 + /// + public string IsBookingYZ { get; set; } + + /// + /// VGM截止日期 + /// + [Description("VGM截止日期")] + public DateTime? CloseVgmDate { get; set; } + + /// + /// 中转港代码 + /// + public string TransPortCode { get; set; } + + /// + /// 第三付款地 + /// + public string ThirdPayAt { get; set; } + + /// + /// 发货人 t_info_client CUSTNAME + /// + [Description("发货人")] + public string Shipper { get; set; } + + /// + /// 收货人 t_info_client CUSTNAME + /// + [Description("收货人")] + public string Consignee { get; set; } + + /// + /// 通知人 t_info_client CUSTNAME + /// + public string NotifyParty { get; set; } + + /// + /// 内部航次 + /// + public string InnerVoyno { get; set; } + + ///// + ///// 第二通知人Id t_info_client CUSTNAME + ///// + //public long? SecondNotifyPartyId { get; set; } + + /// + /// 第二通知人 t_info_client CUSTNAME + /// + public string SecondNotifyParty { get; set; } + + /// + /// 第二通知人内容 + /// + public string SecondNotifyPartyContent { get; set; } + + ///// + ///// 委托单位联系人Id + ///// + //public long CustomerContactId { get; set; } + + ///// + ///// 场站联系人Id + ///// + //public long YardContactId { get; set; } + + ///// + ///// 车队联系人Id + ///// + //public long CarrierContactId { get; set; } + + ///// + ///// 第三付款地Id + ///// + //public long ThirdPayAtId { get; set; } + + ///// + ///// 预付地点Id + ///// + //public long PayableAtId { get; set; } + + /// + /// Desc:单证人员 + /// + [Description("单证")] + public string DocName { get; set; } + + /// + /// 操作员名称 + /// + [Description("操作员")] + public string OperatorName { get; set; } + + /// + /// 客服名称 + /// + [Description("客服")] + public string CustomerServiceName { get; set; } + + /// + /// 外国客服名称 + /// + public string ForeignCustomerServiceName { get; set; } + + /// + /// 截VGM时间 + /// + public DateTime? VGMCloseDate { get; set; } + + /// + /// 单证备注 + /// + public string DocRemark { get; set; } + + /// + /// 操作备注 + /// + public string OperatorRemark { get; set; } + + /// + /// 申请箱使 + /// + public string ApplyCtnRemark { get; set; } + + /// + /// 客户编号 + /// + public string CustomerNum { get; set; } + + ///// + ///// 国内发货人 t_info_client CUSTNAME + ///// + //public long? ShipperCnId { get; set; } + + /// + /// 国内发货人 t_info_client CUSTNAME + /// + public string ShipperCn { get; set; } + + /// + /// 所属分部名称 + /// + [Description("所属分部")] + public string SaleOrgName { get; set; } + + /// + /// 所属部门名称 + /// + [Description("所属部门")] + public string SaleDeptName { get; set; } + + /// + /// 最后下货纸比对状态 NO_DIFF-无异常;DIFF-有差异;NO_YARD-无场站数据;EXPT-异常 + /// + public string LstShipOrderCompareRlt { get; set; } + + /// + /// 最后下货纸比对时间 + /// + public DateTime? LstShipOrderCompareDate { get; set; } + + /// + /// 最后下货纸比对批次号 + /// + public string LstShipOrderCompareId { get; set; } + + /// + /// 最后下货纸比对状态 NO_DIFF-无异常;DIFF-有差异;NO_YARD-无场站数据;EXPT-异常 + /// + public string LstShipOrderCompareRltName { get; set; } + + /// + /// 最后下货纸比对方式 MANUAL-手动 AUTO-自动 + /// + public string LstShipOrderCompareMode { get; set; } + + /// + /// 最后格式单比对状态 NO_DIFF-无异常;DIFF-有差异; + /// + public string LstDraftCompareRlt { get; set; } + + /// + /// 最后格式单比对时间 + /// + public DateTime? LstDraftCompareDate { get; set; } + + /// + /// CNPTNo + /// + public string CNPTNo { get; set; } + + /// + /// 装运方式代码 整箱、拼箱单票、拼箱主票、拼箱分票代码 + /// + public string BLTypeCode { get; set; } + + /// + /// Desc:结算方式代码 + /// + public string StlCode { get; set; } + + /// + /// Desc:贸易方式代码 + /// + public string TermDeliveryCode { get; set; } + + /// + /// Desc:贸易条款代码 + /// + public string TradeTermCode { get; set; } + + /// + /// 签单方式代码 t_code_issutype + /// + public string IssueTypeCode { get; set; } + + /// + /// Desc:MBL付费方式代码 t_code_frt + /// + public string MBLFrtCode { get; set; } + /// + /// 运输条款代码 CY-CY t_code_service + /// + public string ServiceCode { get; set; } + + /// + /// 收货地代码 + /// + public string ReceiptPlaceCode { get; set; } + /// + /// 装货港代码 + /// + public string LoadPortCode { get; set; } + + /// + /// 卸货港代码 + /// + public string DischargePortCode { get; set; } + + /// + /// 交货地代码 + /// + public string DeliveryPlaceCode { get; set; } + + /// + /// 目的地代码 + /// + public string DestinationCode { get; set; } + + /// + /// 预付地点 + /// + public string PayableAtCode { get; set; } + /// + /// 第三付款地代码 + /// + public string ThirdPayAtCode { get; set; } + + /// + /// 签单地点代码 + /// + public string IssuePlaceCode { get; set; } + + /// + /// 航线代码 + /// + public string LaneCode { get; set; } + + /// + /// 舱位类型 + /// + public string ShippingSpaceType { get; set; } + + /// + /// 出单方式 + /// + public string IssuingWay { get; set; } + + /// + /// 包装名称 t_code_package + /// + public string KindPkgsName { get; set; } + + ///// + ///// 约主Id + ///// + //public long ContractClientId { get; set; } + + /// + /// 约主名称 + /// + public string ContractClientName { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/MailActionExecutor.cs similarity index 96% rename from ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailActionExecutor.cs rename to ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/MailActionExecutor.cs index b479f451..5558e81a 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/MailActionExecutor.cs @@ -4,13 +4,13 @@ using DS.Module.SqlSugar; using DS.Module.UserModule; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Info.Entity; -using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity.TaskInteraction; using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Op.Interface.TaskInteraction; using DS.WMS.Core.Sys.Entity; using HtmlAgilityPack; +using Mapster; using Masuit.Tools; using Masuit.Tools.Systems; using Microsoft.Extensions.Configuration; @@ -19,7 +19,7 @@ using Newtonsoft.Json; using RazorEngineCore; using SqlSugar; -namespace DS.WMS.Core.Op.Method.TaskInteraction +namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor { /// /// 用于邮件发送的执行器 @@ -87,17 +87,17 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction } string title, content = string.Empty; - var templateModel = new MailTemplateModel { Primary = result.Data }; + var templateModel = new MailTemplateModel { Primary = result.Data.Adapt() }; IRazorEngine razorEngine = new RazorEngine(); try { - var titleTemplate = razorEngine.Compile>>(mailConfig.Title); + var titleTemplate = razorEngine.Compile>>(mailConfig.Title); title = await titleTemplate.RunAsync(x => { x.Model = templateModel; }); - var contentTemplate = razorEngine.Compile>>(mailConfig.Content); + var contentTemplate = razorEngine.Compile>>(mailConfig.Content); content = await contentTemplate.RunAsync(x => { x.Model = templateModel; @@ -145,6 +145,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction StringWriter writer = new(); htmlDoc.Save(writer); content = writer.ToString(); + writer.Close(); //设置收件人 List receiverIds = []; @@ -152,7 +153,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction receiverIds.Add(templateModel.Primary.CarrierId); if (mailConfig.Receiver.IsBooking) - receiverIds.Add(templateModel.Primary.CarrierId); + receiverIds.Add(templateModel.Primary.ForwarderId); if (mailConfig.Receiver.IsYard) receiverIds.Add(templateModel.Primary.YardId); diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs index d8851223..a6c2a0e2 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs @@ -1,9 +1,9 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.WMS.Core.Op.Dtos.TaskInteraction; -using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction; +using DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor; using DS.WMS.Core.TaskPlat; using SqlSugar; diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TemplateTranslator.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TemplateTranslator.cs new file mode 100644 index 00000000..c10749e6 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TemplateTranslator.cs @@ -0,0 +1,9 @@ +using RazorEngineCore; + +namespace DS.WMS.Core.Op.Method.TaskInteraction +{ + internal class TemplateTranslator + { + + } +} diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowCondition.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowCondition.cs index d29cef54..9fb303dd 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowCondition.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowCondition.cs @@ -10,7 +10,6 @@ namespace DS.WMS.Core.TaskPlat.Entity [SugarTable("task_flow_condition", "任务编排流程条件表")] public class TaskFlowCondition : BaseModelV2 { - /// /// 流程主键 /// @@ -18,22 +17,16 @@ namespace DS.WMS.Core.TaskPlat.Entity public long ConfigId { get; set; } /// - /// 条件字段名称 - /// - [SugarColumn(ColumnDescription = "条件字段名称", IsNullable = true, Length = 255)] - public string? FieldName { get; set; } - - /// - /// 符合条件情况下字段的值 + /// 条件类型 1=用于匹配要执行的流程 2=用于判断流程内部要执行的节点 /// - [SugarColumn(ColumnDescription = "符合条件情况下字段的值", IsNullable = true, Length = 255)] - public string? MatchValue { get; set; } + [SugarColumn(ColumnDescription = "条件类型 1=用于匹配要执行的流程 2=用于判断流程内部要执行的节点", IsNullable = false)] + public int Type { get; set; } /// - /// 匹配类型 1=完全相等 2=包含 3=起始 4=结尾 + /// 条件表达式 /// - [SugarColumn(ColumnDescription = "匹配类型 1=完全相等 2=包含 3=起始 4=结尾", IsNullable = false)] - public int MatchType { get; set; } + [SugarColumn(ColumnDescription = "条件表达式", IsNullable = false, ColumnDataType = "text")] + public string? Content { get; set; } } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs index b115993c..96988732 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs @@ -1,5 +1,4 @@ -using DS.Module.Core; -using DS.Module.Core.Data; +using DS.Module.Core.Data; using SqlSugar; namespace DS.WMS.Core.TaskPlat.Entity @@ -7,7 +6,7 @@ namespace DS.WMS.Core.TaskPlat.Entity /// /// 任务编排流程表 /// - [SugarTable("task_flow_config", "任务编排流程表")] + [SugarTable("task_flow_config_new", "任务编排流程表")] public class TaskFlowConfig : BaseModelV2 { @@ -42,16 +41,28 @@ namespace DS.WMS.Core.TaskPlat.Entity public long? MainConfigId { get; set; } /// - /// 下一执行流程主键 + /// 父项流程主键 /// - [SugarColumn(ColumnDescription = "下一执行流程主键", IsNullable = true)] - public long? NextExecuteConfigId { get; set; } + [SugarColumn(ColumnDescription = "父项流程主键", IsNullable = true)] + public long? ParentConfigId { get; set; } /// - /// 发生异常时是否继续执行 + /// 当执行过程中发生异常时是否继续执行下一个节点 /// - [SugarColumn(ColumnDescription = "发生异常时是否继续执行", IsNullable = false, Length = 1)] + [SugarColumn(ColumnDescription = "当执行过程中发生异常时是否继续执行下一个节点", IsNullable = false, Length = 1)] public bool IsExceptionContinue { get; set; } + + /// + /// 当无匹配的执行流程时是否作为默认的执行流程 + /// + [SugarColumn(ColumnDescription = "当无匹配的执行流程时是否作为默认的执行流程", IsNullable = false, Length = 1)] + public bool IsUnMatchDefault { get; set; } + + /// + /// 当匹配到多项执行流程时是否作为默认的执行流程 + /// + [SugarColumn(ColumnDescription = "当匹配到多项执行流程时是否作为默认的执行流程", IsNullable = false, Length = 1)] + public bool IsMoreMatchDefault { get; set; } } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs index 331638b6..86cdf4b2 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs @@ -35,6 +35,7 @@ namespace DS.WMS.Core.TaskPlat.Interface /// BC任务主键 /// 返回回执 Task SyncBookingSlotChange(long taskPKId); + Task> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext); /// diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs index 040efa42..8fb94dca 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs @@ -65,6 +65,6 @@ namespace DS.WMS.Core.TaskPlat.Interface /// 业务类型 /// 要转交的人员信息列表 Task TransferTask(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, List userInfos); - + Task TestTaskFlow(string taskType, long taskId); } } diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/MyModuleTest1.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/MyModuleTest1.cs index 976ecbd9..42eecd5c 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/MyModuleTest1.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/MyModuleTest1.cs @@ -14,6 +14,7 @@ namespace DS.WMS.Core.TaskPlat.Method { public Task TestMethod11(TaskFlowDataContext dataContext) { + //throw new ArgumentException("缺少参数:Age"); var address = dataContext.Get("Address"); var height = dataContext.Get("Height"); var info = dataContext.Get(nameof(TaskManageOrderMessageInfo)); @@ -28,7 +29,8 @@ namespace DS.WMS.Core.TaskPlat.Method public Task TestMethod12(TaskFlowDataContext dataContext) { //throw new Exception("TestMethod12内的测试异常"); - return Task.FromResult(DataResult.Successed($"TestMethod12返回的成功结果")); + //return Task.FromResult(DataResult.Successed($"TestMethod12返回的成功结果")); + return Task.FromResult(DataResult.Failed($"TestMethod12返回的失败结果")); } } } diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs index c3ceb123..14117097 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs @@ -1119,50 +1119,53 @@ namespace DS.WMS.Core.TaskPlat.Method /// /// 对比BC与海运出口订单(任务台使用) /// - public async Task> ExcuteCompareTask(TaskFlowDataContext dataContext) + public async Task> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext) { - try + var taskBcId = dataContext.Get(TaskFlowDataNameConst.TaskBCId); + if (taskBcId == null) { - var taskBcId = dataContext.Get(TaskFlowDataNameConst.TaskBCId); - if (taskBcId == null) - { - throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCId)}"); - } + throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCId)}"); + } + try + { var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); var taskBcInfo = await tenantDb.Queryable().Where(x => x.Id == taskBcId).FirstAsync(); if (taskBcInfo == null) { - string msg = $"执行ExcuteCompareTask时,根据未获取到BC信息"; - logger.LogInformation(msg); - return DataResult.Failed("对比失败:" + msg); + throw new Exception($"根据BC子任务主键:{taskBcId}未查询到BC信息"); } var taskBcCtnList = await tenantDb.Queryable().Where(x => x.P_ID == taskBcInfo.Id).ToListAsync(); - // 运费协议号(约号)是唯一的,服务合同号可能不是唯一的 + var seaExport = await tenantDb.Queryable().Where(x => x.MBLNO == taskBcInfo.MBL_NO).FirstAsync(); + if (seaExport == null) + { + throw new Exception($"根据提单号:{taskBcInfo.MBL_NO}未查询到海运出口订单信息"); + } + var seaExportCtnList = await tenantDb.Queryable().Where(x => x.BSNO == seaExport.Id.ToString()).ToListAsync(); + + // 运费协议号(约号)是唯一的,服务合同号可能不是唯一的 // BC信息 ParserBCInfoDto bcSrcDto = new ParserBCInfoDto() { ContractNo = taskBcInfo.CONTRACTNO, Vessel = taskBcInfo.VESSEL, VoyNo = taskBcInfo.VOYNO, - //TemperatureMin = taskBcInfo - - + //TemperatureMin = seaExport.TemperatureMin, + //TemperatureMax = seaExport.TemperatureMax, + //TemperatureSet = seaExport.TemperatureSet, + Humidity = seaExport.Humidity, + DischargePort = taskBcInfo.PORTDISCHARGE, + Destination = taskBcInfo.PLACEDELIVERY, + ETD = taskBcInfo.ETD?.ToString("yyyy-MM-dd"), + CtnList = taskBcCtnList.GroupBy(x => x.CTNALL).Select(x => new ParserBCCTNInfoDto + { + CtnALL = x.Key, + CtnNum = x.ToList().Sum(a => a.CTNNUM) + }).ToList() }; - //bcTargetDto.CtnList = dto.DataObj.CtnList.GroupBy(x => x.CtnAll) - // .Select(x => - // { - // return new ParserBCCTNInfoDto - // { - // CtnALL = x.Key, - // CtnNum = x.ToList().Sum(a => a.CtnNum) - // }; - // }).ToList(); - - var seaExport = await tenantDb.Queryable().Where(x => x.MBLNO == taskBcInfo.MBL_NO).FirstAsync(); // 订单信息 ParserBCInfoDto bcTargetDto = new ParserBCInfoDto() @@ -1176,20 +1179,26 @@ namespace DS.WMS.Core.TaskPlat.Method Humidity = seaExport.Humidity, DischargePort = seaExport.DischargePort, Destination = seaExport.Destination, - - //CtnList = new List(), + ETD = seaExport.ETD?.ToString("yyyy-MM-dd"), + + CtnList = seaExportCtnList.GroupBy(x => x.CtnAll).Select(x => new ParserBCCTNInfoDto + { + CtnALL = x.Key, + CtnNum = x.ToList().Sum(a => a.CtnNum) + }).ToList() }; + //if (seaExport.CargoId == "R" && seaExport.EdiRemark) + //{ + //} } - catch (Exception) + catch (Exception ex) { - - throw; + logger.LogInformation("对比失败:" + ex.Message); + return DataResult.Failed("对比失败:" + ex.Message); } - - return default; - + return DataResult.Success(default); } #region 生成并推送邮件 @@ -1293,7 +1302,7 @@ namespace DS.WMS.Core.TaskPlat.Method { var opId = bookingOrderEntity.OperatorId; - var opUser = db.Queryable().Filter(null,true).First(x => x.Id == bookingOrderEntity.OperatorId && x.TenantId == long.Parse(user.TenantId)); + var opUser = db.Queryable().Filter(null, true).First(x => x.Id == bookingOrderEntity.OperatorId && x.TenantId == long.Parse(user.TenantId)); //var opUser = _userService.GetUserInfo(opId.ToString()).Data; @@ -1924,7 +1933,7 @@ namespace DS.WMS.Core.TaskPlat.Method private async Task PushEmail(EmailApiUserDefinedDto emailApiUserDefinedDto, string filePath) { List emailList = new List(); - + bool result = false; string msg = string.Empty; @@ -2091,7 +2100,7 @@ namespace DS.WMS.Core.TaskPlat.Method //普通和合票都按单票处理 await GenerateSendEmail(taskBcInfo, taskBaseInfo, orderInfo, currSeaExport, true); } - + } else { diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs index c1ec1228..02524acc 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -9,6 +9,7 @@ using DS.Module.SqlSugar; using DS.Module.UserModule; using DS.WMS.Core.Code.Dtos; using DS.WMS.Core.Code.Interface; +using DS.WMS.Core.Invoice.Dtos; using DS.WMS.Core.Map.Dtos; using DS.WMS.Core.Map.Interface; using DS.WMS.Core.Op.Entity; @@ -2205,10 +2206,9 @@ namespace DS.WMS.Core.TaskPlat.Method IsPublic = t.IS_PUBLIC }).ToListAsync(); - - //var sql = tenantDb.Queryable() // .LeftJoin((t, a) => t.Id == a.TaskId) + // .Where(whereList) // .Where((t, a) => t.IS_PUBLIC == 1 || (t.IS_PUBLIC == 0 && a.Status != null && (t.CreateBy == userId || a.UserId == userId))) // .GroupBy((t, a) => new { t.TASK_TYPE, t.STATUS, a.Status, t.IS_PUBLIC }) // .Select((t, a) => new @@ -2748,6 +2748,36 @@ namespace DS.WMS.Core.TaskPlat.Method return DataResult.FailedData(portInfo); } + + public async Task TestTaskFlow(string taskType, long taskId) + { + var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); + + + var taskTypeEnum = (TaskBaseTypeEnum)Enum.Parse(typeof(TaskBaseTypeEnum), taskType); + + TaskManageOrderMessageInfo p1 = new TaskManageOrderMessageInfo() + { + Main = new TaskManageOrderMessageMainInfo() + { + BCInfo = new TaskManageOrderBCInfo() + { + Vessel = "TESTVESSEL" + } + } + }; + TaskFlowDataContext dataContext = new( + ((TaskFlowDataNameConst.TaskManageOrderMessageInfo), p1), + (("Name"), "QD-ZXF"), + (("Age"), 19), + (("Height"), 160) + ); + + TaskFlowRuner taskFlow = new TaskFlowRuner(tenantDb, serviceProvider); + await taskFlow.Run(taskTypeEnum, taskId, dataContext); + + return DataResult.Successed("测试成功"); + } #endregion } } diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowDto.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowDto.cs new file mode 100644 index 00000000..4e8b8583 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowDto.cs @@ -0,0 +1,37 @@ +namespace DS.WMS.Core.TaskPlat.Other +{ + public class ContitionContent + { + /// + /// 逻辑操作符 + /// + public string LogicalOperator { get; set; } + + /// + /// 条件组 + /// + public List Conditions { get; set; } + + /// + /// 条件组 + /// + public List Groups { get; set; } + } + public class ConditionDetail + { + /// + /// 字段 + /// + public string Field { get; set; } + + /// + /// 操作符 + /// + public string Operator { get; set; } + + /// + /// 值 + /// + public string Value { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs index 937b44e0..261ecc3c 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs @@ -1,6 +1,7 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.WMS.Core.TaskPlat.Entity; +using DS.WMS.Core.TaskPlat.Other; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json; @@ -66,89 +67,32 @@ namespace DS.WMS.Core.TaskPlat await tenantDb.Insertable(log).ExecuteCommandAsync(); logger.LogInformation(msg); return (null, false, false); - //throw new Exception(msg); } var allConfigIdList = allConfigList.Select(x => x.Id); var allConditionList = await tenantDb.Queryable() - .Where(x => allConfigIdList.Contains(x.ConfigId)) - .ToListAsync(); + .Where(x => allConfigIdList.Contains(x.ConfigId) && x.Type == 1) + .ToListAsync(); // 判断每项流程达成的条件数量 Dictionary configMatchCount = allConfigList.ToDictionary(x => x.Id, x => 0); foreach (var configItem in allConfigList) { - var conditionListGroup = allConditionList.Where(x => x.ConfigId == configItem.Id); - foreach (var conditionItem in conditionListGroup) + var conditionItem = allConditionList.FirstOrDefault(x => x.ConfigId == configItem.Id); + if (conditionItem != null && !string.IsNullOrEmpty(conditionItem.Content)) { - string? valStr; - if (conditionItem.FieldName.Contains('.')) - { - var firstKey = conditionItem.FieldName.Split('.').First(); - - if (!dataContext.ContainsKey(firstKey)) continue; - - var obj = dataContext.Get(firstKey)!; - - var propertyPath = conditionItem.FieldName.Substring(conditionItem.FieldName.IndexOf('.') + 1); - var (_, val, _) = GetPropertyValue(obj, propertyPath); - if (val == null) continue; - - valStr = val.ToString(); - } - else - { - if (!dataContext.ContainsKey(conditionItem.FieldName)) continue; - - var obj = dataContext.Get(conditionItem.FieldName)!; - valStr = obj.ToString(); - } + var contitionContent = JsonConvert.DeserializeObject(conditionItem.Content)!; var oldValue = configMatchCount[configItem.Id]; - if (conditionItem.MatchType == 1) + if (MatchByCondition(contitionContent, dataContext)) { - if (valStr?.Equals(conditionItem.MatchValue, StringComparison.CurrentCultureIgnoreCase) == true) - { - configMatchCount[configItem.Id] = oldValue + 1; - } - else - { - configMatchCount[configItem.Id] = oldValue - 1; - } - } - else if (conditionItem.MatchType == 2) - { - if (valStr?.Contains(conditionItem.MatchValue, StringComparison.CurrentCultureIgnoreCase) == true) - { - configMatchCount[configItem.Id] = oldValue + 1; - } - else - { - configMatchCount[configItem.Id] = oldValue - 1; - } + configMatchCount[configItem.Id] = oldValue + 1; } - else if (conditionItem.MatchType == 3) + else { - if (valStr?.StartsWith(conditionItem.MatchValue, StringComparison.CurrentCultureIgnoreCase) == true) - { - configMatchCount[configItem.Id] = oldValue + 1; - } - else - { - configMatchCount[configItem.Id] = oldValue - 1; - } - } - else if (conditionItem.MatchType == 4) - { - if (valStr?.EndsWith(conditionItem.MatchValue, StringComparison.CurrentCultureIgnoreCase) == true) - { - configMatchCount[configItem.Id] = oldValue + 1; - } - else - { - configMatchCount[configItem.Id] = oldValue - 1; - } + configMatchCount[configItem.Id] = oldValue - 1; } + } } @@ -180,13 +124,20 @@ namespace DS.WMS.Core.TaskPlat } var targetConfig = allConfigList.First(x => x.Id == bestMatched.Value.Key); + // 待执行的流程(节点列表) var configList = await tenantDb.Queryable().Where(x => x.MainConfigId == targetConfig.Id).ToListAsync(); var configIdList = configList.Select(x => x.Id).ToList(); - var moduleIdList = configList.Select(x => x.ExecuteModuleId).ToList(); + // 待注入的参数列表 var paramList = await tenantDb.Queryable().Where(x => configIdList.Contains(x.ConfigId)).ToListAsync(); + + // 待执行的模块列表 + var moduleIdList = configList.Select(x => x.ExecuteModuleId).ToList(); var moduleList = await tenantDb.Queryable().Where(x => moduleIdList.Contains(x.Id)).ToListAsync(); + // 待判断的条件列表 + var conditionList = await tenantDb.Queryable().Where(x => configIdList.Contains(x.ConfigId) && x.Type == 2).ToListAsync(); + TaskFlowLog flowLog = new() { Id = SnowFlakeSingle.Instance.NextId(), @@ -201,41 +152,73 @@ namespace DS.WMS.Core.TaskPlat }; // 执行流程 - long? nextExecuteConfigId = targetConfig.Id; + List waitMatchConfigList = new([targetConfig]); for (int i = 0; i < configList.Count; i++) { - if (nextExecuteConfigId == null || nextExecuteConfigId == 0) - { - break; - } - var executeConfig = configList.FirstOrDefault(x => x.Id == nextExecuteConfigId); - if (executeConfig == null) - { - break; - } - nextExecuteConfigId = executeConfig.NextExecuteConfigId; - TaskFlowLogDetail flowLogDetail = new() { - ConfigId = executeConfig.Id, PId = flowLog.Id, IsSuccess = true, }; + TaskFlowConfig? executeConfig = null; try { + if (waitMatchConfigList == null || waitMatchConfigList.Count == 0) + { + break; + } + + // 对节点列表里面的节点进行依次判断,取出要执行的节点 + var matchedConfigList = new List(); + foreach (var waitMatchConfigItem in waitMatchConfigList) + { + var condition = conditionList.FirstOrDefault(x => x.ConfigId == waitMatchConfigItem.Id); + if (condition == null || string.IsNullOrEmpty(condition.Content)) + { + matchedConfigList.Add(waitMatchConfigItem); + continue; + } + + var contitionContent = JsonConvert.DeserializeObject(condition.Content)!; + if (MatchByCondition(contitionContent, dataContext)) + { + matchedConfigList.Add(waitMatchConfigItem); + continue; + } + } + if (matchedConfigList.Count == 1) + { + executeConfig = matchedConfigList[0]; + } + else if (matchedConfigList.Count > 1) + { + executeConfig = matchedConfigList.FirstOrDefault(x => x.IsMoreMatchDefault); + } + + if (executeConfig == null) + { + executeConfig = waitMatchConfigList.FirstOrDefault(x => x.IsUnMatchDefault); + } + + if (executeConfig == null) + { + flowLog.IsComplete = false; + flowLog.IsSuccess = false; + flowLog.Note += $"【执行时未找到符合执行条件的节点,经判断条件的节点Id如下:{string.Join(',', waitMatchConfigList.Select(x => x.Id))}】"; + + break; + } + + flowLogDetail.ConfigId = executeConfig.Id; + + // 如果当前节点要执行(或者配置了默认执行节点)取出下一批要进行条件判断的节点列表 + waitMatchConfigList = configList.Where(x => x.ParentConfigId == executeConfig.Id).ToList(); + + // 注入参数 var paramItemList = paramList.Where(x => x.ConfigId == executeConfig.Id).ToList(); foreach (var paramItem in paramItemList) { dataContext.Set(paramItem.FieldName!, paramItem.FieldValue!); - - //if (dataContext.ContainsKey(paramItem.FieldName!)) - //{ - // dataContext[paramItem.FieldName!] = paramItem.FieldValue!; - //} - //else - //{ - // dataContext.TryAdd(paramItem.FieldName!, paramItem.FieldValue!); - //} } var module = moduleList.FirstOrDefault(x => x.Id == executeConfig.ExecuteModuleId); @@ -375,6 +358,120 @@ namespace DS.WMS.Core.TaskPlat return await Run(taskBaseType, taskId, dataContext); } + /// + /// 递归解析并判断条件 + /// + static bool MatchByCondition(ContitionContent conditionContent, TaskFlowDataContext dataContext) + { + bool? thisScopeResult = null; + + if (conditionContent == null || conditionContent.Conditions == null || conditionContent.Conditions.Count == 0) + { + return true; + } + + foreach (var item in conditionContent.Conditions) + { + var itemResult = false; + + string? valStr = null; + if (item.Field!.Contains('.')) + { + var firstKey = item.Field.Split('.').First(); + + if (dataContext.ContainsKey(firstKey)) + { + var obj = dataContext.Get(firstKey)!; + + var propertyPath = item.Field.Substring(item.Field.IndexOf('.') + 1); + var (_, val, _) = GetPropertyValue(obj, propertyPath); + + if (val != null) + valStr = val.ToString(); + } + } + else + { + if (dataContext.ContainsKey(item.Field)) + { + var obj = dataContext.Get(item.Field)!; + valStr = obj.ToString(); + } + } + + switch (item.Operator) + { + case "equal": + itemResult = valStr?.Equals(item.Value, StringComparison.OrdinalIgnoreCase) == true; break; + case "not_equal": + itemResult = valStr?.Equals(item.Value, StringComparison.OrdinalIgnoreCase) != true; break; + case "contains": + itemResult = valStr?.Contains(item.Value, StringComparison.OrdinalIgnoreCase) == true; break; + case "not_contain": + itemResult = valStr?.Contains(item.Value, StringComparison.OrdinalIgnoreCase) != true; break; + case "start_with": + itemResult = valStr?.StartsWith(item.Value, StringComparison.OrdinalIgnoreCase) == true; break; + case "end_with": + itemResult = valStr?.EndsWith(item.Value, StringComparison.OrdinalIgnoreCase) == true; break; + case "greater_than": + { + itemResult = double.TryParse(valStr, out double temp1) && double.TryParse(item.Value, out double temp2) && temp1 > temp2; break; + } + case "greater_than_or_equal": + { + itemResult = double.TryParse(valStr, out double temp1) && double.TryParse(item.Value, out double temp2) && temp1 >= temp2; break; + } + case "less_than": + { + itemResult = double.TryParse(valStr, out double temp1) && double.TryParse(item.Value, out double temp2) && temp1 < temp2; break; + } + case "less_than_or_equal": + { + itemResult = double.TryParse(valStr, out double temp1) && double.TryParse(item.Value, out double temp2) && temp1 <= temp2; break; + } + } + + if (thisScopeResult == null) + { + thisScopeResult = itemResult; + } + else + { + if (conditionContent.LogicalOperator == "and") + { + thisScopeResult = thisScopeResult.Value && itemResult; + } + else if (conditionContent.LogicalOperator == "or") + { + thisScopeResult = thisScopeResult.Value || itemResult; + } + } + } + + //thisScopeResult ??= true; // 实际这里的thisScopeResult的值啃腚不为null + + if (conditionContent.Groups != null && conditionContent.Groups.Count > 0) + { + // 组的结果 + var groupResult = new List(); + foreach (var item in conditionContent.Groups) + { + // 递归调用,向组里添加结果 + groupResult.Add(MatchByCondition(item, dataContext)); + } + + if (conditionContent.LogicalOperator == "and") + { + return thisScopeResult == true && groupResult.All(a => a); + } + else if (conditionContent.LogicalOperator == "or") + { + return thisScopeResult == true || groupResult.Any(a => a); + } + } + return thisScopeResult == true; + } + /// /// 深度获取对象属性值 /// diff --git a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user index 21e5222f..fb7be066 100644 --- a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user +++ b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user @@ -1,7 +1,7 @@  - D:\Code\ds8-solution-pro\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml + D:\Source\Repos\DS8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml MvcControllerEmptyScaffolder root/Common/MVC/Controller diff --git a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs index c4f78192..91ea4422 100644 --- a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs +++ b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs @@ -1,10 +1,14 @@ using DS.Module.Core; using DS.Module.Core.Attributes; +using DS.Module.Core.Data; using DS.Module.DjyServiceStatus; +using DS.WMS.Core.Invoice.Dtos; +using DS.WMS.Core.TaskPlat; using DS.WMS.Core.TaskPlat.Dtos; using DS.WMS.Core.TaskPlat.Interface; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; namespace DS.WMS.TaskApi.Controllers; @@ -207,4 +211,13 @@ public class TaskManageController : ApiController return PhysicalFile(fileFullPath, "application/octet-stream", fileName); } + /// + /// 测试执行任务编排 + /// + /// + [HttpGet("TestTaskFlow")] + public async Task TestTaskFlow([FromQuery] string taskType, [FromQuery] long taskId) + { + return await taskManageService.TestTaskFlow(taskType, taskId); + } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.TaskApi/Program.cs b/ds-wms-service/DS.WMS.TaskApi/Program.cs index f458ac3c..0dbcd8d2 100644 --- a/ds-wms-service/DS.WMS.TaskApi/Program.cs +++ b/ds-wms-service/DS.WMS.TaskApi/Program.cs @@ -46,7 +46,6 @@ builder.Services.AddSaasDbInstall();// builder.Services.AddMultiLanguageInstall();//Է builder.Services.AddDjyModuleInstall();//Djy builder.Services.AddRuleEngineModuleInstall();//DjyУ - builder.Services.AddTaskPlatMapsterSetup(); // ȫֵMapsterԶӳ // builder.Services.AddEndpointsApiExplorer(); // builder.Services.AddSwaggerGen();