diff --git a/Myshipping.Application/Service/BookingCtn/Dto/BookingCtnInput.cs b/Myshipping.Application/Service/BookingCtn/Dto/BookingCtnInput.cs index dcaa8c7a..6ea4a43e 100644 --- a/Myshipping.Application/Service/BookingCtn/Dto/BookingCtnInput.cs +++ b/Myshipping.Application/Service/BookingCtn/Dto/BookingCtnInput.cs @@ -1,5 +1,6 @@ using Myshipping.Core; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace Myshipping.Application @@ -121,6 +122,8 @@ namespace Myshipping.Application /// public class AddBookingCtnInput : BookingCtnInput { + + public List ctnDetailInputs { get; set; } } /// diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index feefdd65..b31f7095 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -18,7 +18,9 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Identity; using Furion.FriendlyException; using Furion.Logging; - +using System; +using Microsoft.Extensions.Logging; + namespace Myshipping.Application { /// @@ -28,12 +30,16 @@ namespace Myshipping.Application public class BookingOrderService : IBookingOrderService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; - private readonly SqlSugarRepository _repCtn; - public BookingOrderService(SqlSugarRepository rep, SqlSugarRepository repCtn) + private readonly SqlSugarRepository _repCtn; + private readonly SqlSugarRepository _ctndetailrep; + private readonly ILogger _logger; + public BookingOrderService(SqlSugarRepository rep, SqlSugarRepository repCtn, SqlSugarRepository ctndetailrep, ILogger logger) { - _rep = rep; - _repCtn = repCtn; + this._logger = logger; + this._rep = rep; + this._repCtn = repCtn; + this._ctndetailrep = ctndetailrep; } /// @@ -46,41 +52,47 @@ namespace Myshipping.Application { var entities = await _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.BSSTATUS), u => u.BSSTATUS == input.BSSTATUS) - .WhereIF(!string.IsNullOrWhiteSpace(input.MBLNO), u => u.MBLNO == input.MBLNO) - .WhereIF(!string.IsNullOrWhiteSpace(input.HBLNO), u => u.HBLNO == input.HBLNO) - .WhereIF(!string.IsNullOrWhiteSpace(input.BOOKINGNO), u => u.BOOKINGNO == input.BOOKINGNO) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONTRACTNO), u => u.CONTRACTNO == input.CONTRACTNO) - .WhereIF(!string.IsNullOrWhiteSpace(input.SERVICECONTRACTNO), u => u.SERVICECONTRACTNO == input.SERVICECONTRACTNO) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPER), u => u.SHIPPER == input.SHIPPER) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEE), u => u.CONSIGNEE == input.CONSIGNEE) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTY), u => u.NOTIFYPARTY == input.NOTIFYPARTY) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTY2), u => u.NOTIFYPARTY2 == input.NOTIFYPARTY2) + .WhereIF(!string.IsNullOrWhiteSpace(input.MBLNO), u => input.MBLNO.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Contains(u.MBLNO)) + .WhereIF(!string.IsNullOrWhiteSpace(input.HBLNO), u => input.HBLNO.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Contains(u.HBLNO)) + .WhereIF(!string.IsNullOrWhiteSpace(input.BOOKINGNO), u => u.BOOKINGNO.IndexOf(input.BOOKINGNO) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.CONTRACTNO), u => u.CONTRACTNO.IndexOf(input.CONTRACTNO) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.SERVICECONTRACTNO), u => u.SERVICECONTRACTNO.IndexOf(input.SERVICECONTRACTNO) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPER), u => u.SHIPPER.Contains(input.SHIPPER)) + .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEE), u => u.CONSIGNEE.Contains(input.CONSIGNEE)) + .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTY), u => u.NOTIFYPARTY.Contains(input.NOTIFYPARTY)) + .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTY2), u => u.NOTIFYPARTY2.Contains(input.NOTIFYPARTY2)) .WhereIF(!string.IsNullOrWhiteSpace(input.YARDID), u => u.YARDID == input.YARDID) .WhereIF(!string.IsNullOrWhiteSpace(input.YARD), u => u.YARD == input.YARD) - .WhereIF(!string.IsNullOrWhiteSpace(input.VESSELID), u => u.VESSELID == input.VESSELID) - .WhereIF(!string.IsNullOrWhiteSpace(input.VESSEL), u => u.VESSEL == input.VESSEL) - .WhereIF(!string.IsNullOrWhiteSpace(input.VOYNO), u => u.VOYNO == input.VOYNO) - .WhereIF(!string.IsNullOrWhiteSpace(input.VOYNOINNER), u => u.VOYNOINNER == input.VOYNOINNER) - .WhereIF(!string.IsNullOrWhiteSpace(input.PLACERECEIPT), u => u.PLACERECEIPT == input.PLACERECEIPT) - .WhereIF(!string.IsNullOrWhiteSpace(input.PORTLOAD), u => u.PORTLOAD == input.PORTLOAD) - .WhereIF(!string.IsNullOrWhiteSpace(input.PORTDISCHARGE), u => u.PORTDISCHARGE == input.PORTDISCHARGE) - .WhereIF(!string.IsNullOrWhiteSpace(input.PLACEDELIVERY), u => u.PLACEDELIVERY == input.PLACEDELIVERY) - .WhereIF(!string.IsNullOrWhiteSpace(input.DESTINATION), u => u.DESTINATION == input.DESTINATION) + .WhereIF(!string.IsNullOrWhiteSpace(input.VESSELID), u => u.VESSELID.IndexOf(input.VESSELID) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.VESSEL), u => u.VESSEL.ToLower().IndexOf(u.VESSEL.ToLower()) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.VOYNO), u => u.VOYNO.IndexOf(input.VOYNO) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.VOYNOINNER), u => u.VOYNOINNER.IndexOf(input.VOYNOINNER) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.PLACERECEIPT), u => u.PLACERECEIPT.Contains(input.PLACERECEIPT)) + .WhereIF(!string.IsNullOrWhiteSpace(input.PLACERECEIPTID), u => u.PLACERECEIPTID == input.PLACERECEIPTID) + .WhereIF(!string.IsNullOrWhiteSpace(input.PORTLOAD), u => u.PORTLOAD.IndexOf(input.PORTLOAD) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.PORTDISCHARGE), u => u.PORTDISCHARGE.IndexOf(input.PORTDISCHARGE) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.PLACEDELIVERY), u => u.PLACEDELIVERY.Contains(input.PLACEDELIVERY)) + .WhereIF(!string.IsNullOrWhiteSpace(input.PLACEDELIVERYID), u => u.PLACEDELIVERYID == input.PLACEDELIVERYID) + .WhereIF(!string.IsNullOrWhiteSpace(input.DESTINATION), u => u.DESTINATION.Contains(input.DESTINATION)) + .WhereIF(!string.IsNullOrWhiteSpace(input.DESTINATIONID), u => u.DESTINATIONID == input.DESTINATIONID) .WhereIF(!string.IsNullOrWhiteSpace(input.NOBILL), u => u.NOBILL == input.NOBILL) .WhereIF(!string.IsNullOrWhiteSpace(input.COPYNOBILLL), u => u.COPYNOBILLL == input.COPYNOBILLL) .WhereIF(!string.IsNullOrWhiteSpace(input.ISSUETYPE), u => u.ISSUETYPE == input.ISSUETYPE) - .WhereIF(!string.IsNullOrWhiteSpace(input.ISSUEPLACE), u => u.ISSUEPLACE == input.ISSUEPLACE) + .WhereIF(!string.IsNullOrWhiteSpace(input.ISSUEPLACE), u => u.ISSUEPLACE.Contains(input.ISSUEPLACE)) + .WhereIF(!string.IsNullOrWhiteSpace(input.ISSUEPLACEID), u => u.ISSUEPLACEID == input.ISSUEPLACEID) .WhereIF(!string.IsNullOrWhiteSpace(input.BLFRT), u => u.BLFRT == input.BLFRT) + .WhereIF(!string.IsNullOrWhiteSpace(input.PREPARDATID), u => u.PREPARDATID == input.PREPARDATID) .WhereIF(!string.IsNullOrWhiteSpace(input.PREPARDAT), u => u.PREPARDAT == input.PREPARDAT) - .WhereIF(!string.IsNullOrWhiteSpace(input.PAYABLEAT), u => u.PAYABLEAT == input.PAYABLEAT) - .WhereIF(!string.IsNullOrWhiteSpace(input.SERVICE), u => u.SERVICE == input.SERVICE) - .WhereIF(!string.IsNullOrWhiteSpace(input.MARKS), u => u.MARKS == input.MARKS) - .WhereIF(!string.IsNullOrWhiteSpace(input.HSCODE), u => u.HSCODE == input.HSCODE) - .WhereIF(!string.IsNullOrWhiteSpace(input.DESCRIPTION), u => u.DESCRIPTION == input.DESCRIPTION) + .WhereIF(!string.IsNullOrWhiteSpace(input.PAYABLEAT), u => u.PAYABLEAT.Contains(input.PAYABLEAT)) + .WhereIF(!string.IsNullOrWhiteSpace(input.PAYABLEATID), u => u.PAYABLEATID == input.PAYABLEATID) + .WhereIF(!string.IsNullOrWhiteSpace(input.SERVICE), u => u.SERVICE.Contains(input.SERVICE)) + .WhereIF(!string.IsNullOrWhiteSpace(input.MARKS), u => u.MARKS.Contains(input.MARKS)) + .WhereIF(!string.IsNullOrWhiteSpace(input.HSCODE), u => u.HSCODE.IndexOf(input.HSCODE) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.DESCRIPTION), u => u.DESCRIPTION.Contains(input.DESCRIPTION)) .WhereIF(!string.IsNullOrWhiteSpace(input.KINDPKGS), u => u.KINDPKGS == input.KINDPKGS) .WhereIF(!string.IsNullOrWhiteSpace(input.CNTRTOTAL), u => u.CNTRTOTAL == input.CNTRTOTAL) .WhereIF(!string.IsNullOrWhiteSpace(input.CARRIERID), u => u.CARRIERID == input.CARRIERID) - .WhereIF(!string.IsNullOrWhiteSpace(input.CARRIER), u => u.CARRIER == input.CARRIER) + .WhereIF(!string.IsNullOrWhiteSpace(input.CARRIER), u => u.CARRIER.Contains(input.CARRIER)) .WhereIF(!string.IsNullOrWhiteSpace(input.CARGOID), u => u.CARGOID == input.CARGOID) .WhereIF(!string.IsNullOrWhiteSpace(input.DCLASS), u => u.DCLASS == input.DCLASS) .WhereIF(!string.IsNullOrWhiteSpace(input.DUNNO), u => u.DUNNO == input.DUNNO) @@ -93,41 +105,32 @@ namespace Myshipping.Application .WhereIF(!string.IsNullOrWhiteSpace(input.HUMIDITY), u => u.HUMIDITY == input.HUMIDITY) .WhereIF(!string.IsNullOrWhiteSpace(input.TEMPMIN), u => u.TEMPMIN == input.TEMPMIN) .WhereIF(!string.IsNullOrWhiteSpace(input.TEMPMAX), u => u.TEMPMAX == input.TEMPMAX) - //.WhereIF(!input.ISCONTAINERSOC, u => u.ISCONTAINERSOC == input.ISCONTAINERSOC) - .WhereIF(!string.IsNullOrWhiteSpace(input.SOREMARK), u => u.SOREMARK == input.SOREMARK) - .WhereIF(!string.IsNullOrWhiteSpace(input.SIREMARK), u => u.SIREMARK == input.SIREMARK) - .WhereIF(!string.IsNullOrWhiteSpace(input.YARDREMARK), u => u.YARDREMARK == input.YARDREMARK) + .WhereIF(!input.ISCONTAINERSOC, u => u.ISCONTAINERSOC == input.ISCONTAINERSOC) + .WhereIF(!string.IsNullOrWhiteSpace(input.SOREMARK), u => u.SOREMARK.Contains(input.SOREMARK)) + .WhereIF(!string.IsNullOrWhiteSpace(input.SIREMARK), u => u.SIREMARK.Contains(input.SIREMARK)) + .WhereIF(!string.IsNullOrWhiteSpace(input.YARDREMARK), u => u.YARDREMARK.Contains(input.YARDREMARK)) .WhereIF(!string.IsNullOrWhiteSpace(input.COMPID), u => u.COMPID == input.COMPID) - .WhereIF(!string.IsNullOrWhiteSpace(input.COMPNAME), u => u.COMPNAME == input.COMPNAME) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERNAME), u => u.SHIPPERNAME == input.SHIPPERNAME) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERADDR1), u => u.SHIPPERADDR1 == input.SHIPPERADDR1) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERADDR2), u => u.SHIPPERADDR2 == input.SHIPPERADDR2) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERADDR3), u => u.SHIPPERADDR3 == input.SHIPPERADDR3) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERCITY), u => u.SHIPPERCITY == input.SHIPPERCITY) + .WhereIF(!string.IsNullOrWhiteSpace(input.COMPNAME), u => u.COMPNAME.IndexOf(input.COMPNAME) > -1) + .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERNAME), u => u.SHIPPERNAME.Contains(input.SHIPPERNAME)) + .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERCITY), u => u.SHIPPERCITY.Contains(input.SHIPPERCITY)) .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERPROVINCE), u => u.SHIPPERPROVINCE == input.SHIPPERPROVINCE) .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERPOSTCODE), u => u.SHIPPERPOSTCODE == input.SHIPPERPOSTCODE) .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERCOUNTRY), u => u.SHIPPERCOUNTRY == input.SHIPPERCOUNTRY) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERATTN), u => u.SHIPPERATTN == input.SHIPPERATTN) + .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERATTN), u => u.SHIPPERATTN.Contains(input.SHIPPERATTN)) .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERTEL), u => u.SHIPPERTEL == input.SHIPPERTEL) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEENAME), u => u.CONSIGNEENAME == input.CONSIGNEENAME) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEADDR1), u => u.CONSIGNEEADDR1 == input.CONSIGNEEADDR1) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEADDR2), u => u.CONSIGNEEADDR2 == input.CONSIGNEEADDR2) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEADDR3), u => u.CONSIGNEEADDR3 == input.CONSIGNEEADDR3) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEECITY), u => u.CONSIGNEECITY == input.CONSIGNEECITY) + .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEENAME), u => u.CONSIGNEENAME.Contains(input.CONSIGNEENAME)) + .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEECITY), u => u.CONSIGNEECITY.Contains(input.CONSIGNEECITY)) .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEPROVINCE), u => u.CONSIGNEEPROVINCE == input.CONSIGNEEPROVINCE) .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEPOSTCODE), u => u.CONSIGNEEPOSTCODE == input.CONSIGNEEPOSTCODE) .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEERCOUNTRY), u => u.CONSIGNEERCOUNTRY == input.CONSIGNEERCOUNTRY) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEATTN), u => u.CONSIGNEEATTN == input.CONSIGNEEATTN) + .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEATTN), u => u.CONSIGNEEATTN.Contains(input.CONSIGNEEATTN)) .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEETEL), u => u.CONSIGNEETEL == input.CONSIGNEETEL) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYNAME), u => u.NOTIFYPARTYNAME == input.NOTIFYPARTYNAME) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYADDR1), u => u.NOTIFYPARTYADDR1 == input.NOTIFYPARTYADDR1) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYADDR2), u => u.NOTIFYPARTYADDR2 == input.NOTIFYPARTYADDR2) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYADDR3), u => u.NOTIFYPARTYADDR3 == input.NOTIFYPARTYADDR3) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYCITY), u => u.NOTIFYPARTYCITY == input.NOTIFYPARTYCITY) + .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYNAME), u => u.NOTIFYPARTYNAME.Contains(input.NOTIFYPARTYNAME)) + .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYCITY), u => u.NOTIFYPARTYCITY.Contains(input.NOTIFYPARTYCITY)) .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYPROVINCE), u => u.NOTIFYPARTYPROVINCE == input.NOTIFYPARTYPROVINCE) .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYPOSTCODE), u => u.NOTIFYPARTYPOSTCODE == input.NOTIFYPARTYPOSTCODE) .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYCOUNTRY), u => u.NOTIFYPARTYCOUNTRY == input.NOTIFYPARTYCOUNTRY) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYATTN), u => u.NOTIFYPARTYATTN == input.NOTIFYPARTYATTN) + .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYATTN), u => u.NOTIFYPARTYATTN.Contains(input.NOTIFYPARTYATTN)) .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYTEL), u => u.NOTIFYPARTYTEL == input.NOTIFYPARTYTEL) .WhereIF(!string.IsNullOrWhiteSpace(input.PONO), u => u.PONO == input.PONO) .WhereIF(!string.IsNullOrWhiteSpace(input.OPID), u => u.OPID == input.OPID) @@ -135,8 +138,12 @@ namespace Myshipping.Application .WhereIF(!string.IsNullOrWhiteSpace(input.OP), u => u.OP == input.OP) .WhereIF(!string.IsNullOrWhiteSpace(input.DOC), u => u.DOC == input.DOC) .WhereIF(!string.IsNullOrWhiteSpace(input.SALEID), u => u.SALEID == input.SALEID) - .WhereIF(!string.IsNullOrWhiteSpace(input.SALE), u => u.SALE == input.SALE) + .WhereIF(!string.IsNullOrWhiteSpace(input.SALE), u => u.SALE.Contains(input.SALE)) .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICEID), u => u.CUSTSERVICEID == input.CUSTSERVICEID) + .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICE), u => u.CUSTSERVICE.Contains(input.CUSTSERVICE)) + .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMERNAME), u => u.CUSTOMERNAME.Contains(input.CUSTOMERNAME)) + .WhereIF(input.CUSTOMERID != null, u => u.CUSTOMERID == input.CUSTOMERID) + .WhereIF(!string.IsNullOrWhiteSpace(input.FORWARDER), u => u.FORWARDER.Contains(input.FORWARDER)) .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICE), u => u.CUSTSERVICE == input.CUSTSERVICE) .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMERNAME), u => u.CUSTOMERNAME == input.CUSTOMERNAME) .WhereIF(!string.IsNullOrWhiteSpace(input.FORWARDER), u => u.FORWARDER == input.FORWARDER) @@ -145,64 +152,107 @@ namespace Myshipping.Application .WhereIF(!string.IsNullOrWhiteSpace(input.TRUCKER), u => u.TRUCKER == input.TRUCKER) .WhereIF(!string.IsNullOrWhiteSpace(input.AGENTID), u => u.AGENTID == input.AGENTID) .WhereIF(!string.IsNullOrWhiteSpace(input.FORWARDERID), u => u.FORWARDERID == input.FORWARDERID) + .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPAGENCY), u => u.SHIPAGENCY.Contains(input.SHIPAGENCY)) .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPAGENCYID), u => u.SHIPAGENCYID == input.SHIPAGENCYID) + .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMSER), u => u.CUSTOMSER.Contains(input.CUSTOMSER)) .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMSERID), u => u.CUSTOMSERID == input.CUSTOMSERID) + .WhereIF(!string.IsNullOrWhiteSpace(input.TRUCKER), u => u.TRUCKER.Contains(input.TRUCKER)) .WhereIF(!string.IsNullOrWhiteSpace(input.TRUCKERID), u => u.TRUCKERID == input.TRUCKERID) - .WhereIF(!string.IsNullOrWhiteSpace(input.AGENTNAME), u => u.AGENTNAME == input.AGENTNAME) - .WhereIF(!string.IsNullOrWhiteSpace(input.WEITUO), u => u.WEITUO == input.WEITUO) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEDOORADDR), u => u.CONSIGNEEDOORADDR == input.CONSIGNEEDOORADDR) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERDOORADDR), u => u.SHIPPERDOORADDR == input.SHIPPERDOORADDR) + .WhereIF(!string.IsNullOrWhiteSpace(input.AGENTNAME), u => u.AGENTNAME.Contains(input.AGENTNAME)) + .WhereIF(!string.IsNullOrWhiteSpace(input.AGENTID), u => u.AGENTID == input.AGENTID) + .WhereIF(!string.IsNullOrWhiteSpace(input.WEITUO), u => u.WEITUO.Contains(input.WEITUO)) .WhereIF(!string.IsNullOrWhiteSpace(input.SCACCODE), u => u.SCACCODE == input.SCACCODE) .WhereIF(!string.IsNullOrWhiteSpace(input.ITNCODE), u => u.ITNCODE == input.ITNCODE) - .WhereIF(!string.IsNullOrWhiteSpace(input.PREPARDATID), u => u.PREPARDATID == input.PREPARDATID) - .WhereIF(!string.IsNullOrWhiteSpace(input.PAYABLEATID), u => u.PAYABLEATID == input.PAYABLEATID) - .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTNO), u => u.CUSTNO == input.CUSTNO) + .WhereIF(!string.IsNullOrWhiteSpace(input.CUSTNO), u => u.CUSTNO.Contains(input.CUSTNO)) .WhereIF(!string.IsNullOrWhiteSpace(input.TRANSPORTID), u => u.TRANSPORTID == input.TRANSPORTID) - .WhereIF(!string.IsNullOrWhiteSpace(input.TRANSPORT), u => u.TRANSPORT == input.TRANSPORT) - .WhereIF(!string.IsNullOrWhiteSpace(input.THIRDPAYADDR), u => u.THIRDPAYADDR == input.THIRDPAYADDR) + .WhereIF(!string.IsNullOrWhiteSpace(input.TRANSPORT), u => u.TRANSPORT.Contains(input.TRANSPORT)) .WhereIF(!string.IsNullOrWhiteSpace(input.YARDCONTRACTTEL), u => u.YARDCONTRACTTEL == input.YARDCONTRACTTEL) .WhereIF(!string.IsNullOrWhiteSpace(input.YARDCONTRACTEMAIL), u => u.YARDCONTRACTEMAIL == input.YARDCONTRACTEMAIL) .WhereIF(!string.IsNullOrWhiteSpace(input.LANECODE), u => u.LANECODE == input.LANECODE) - .WhereIF(!string.IsNullOrWhiteSpace(input.LANENAME), u => u.LANENAME == input.LANENAME) - .WhereIF(!string.IsNullOrWhiteSpace(input.FREIGHTPAYER), u => u.FREIGHTPAYER == input.FREIGHTPAYER) + .WhereIF(!string.IsNullOrWhiteSpace(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME)) + .WhereIF(!string.IsNullOrWhiteSpace(input.FREIGHTPAYER), u => u.FREIGHTPAYER.Contains(input.FREIGHTPAYER)) .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// - /// 增加订舱主表 + /// 增加订舱 /// /// /// + [SqlSugarUnitOfWork] [HttpPost("/BookingOrder/add")] public async Task Add(AddBookingOrderInput input) { + JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail"); + JsonUtil.TrimFields(input); + var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}"); + input.CNTRTOTAL = string.Join(" / ", groupList); var entity = input.Adapt(); + entity.Create(); await _rep.InsertAsync(entity); + foreach (var item in input.ctnInputs) + { + var ctnentity=item.Adapt(); + ctnentity.BILLID = entity.Id; + await _repCtn.InsertAsync(ctnentity); + foreach (var it in item.ctnDetailInputs) + { + var ctndetail=it.Adapt(); + ctndetail.CTNID = ctnentity.Id; + await _ctndetailrep.InsertAsync(ctndetail); + } + } + } /// - /// 删除订舱主表 + /// 删除订舱 /// /// /// + [SqlSugarUnitOfWork] [HttpPost("/BookingOrder/delete")] - public async Task Delete(DeleteBookingOrderInput input) + public async Task Delete(QueryeBookingOrderInput input) { - var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); - await _rep.DeleteAsync(entity); + + await _rep.UpdateAsync(x=>x.Id==input.Id,x=> new BookingOrder { IsDeleted= true} ); + var ctnlist=await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync(); + + await _repCtn.UpdateAsync(x => x.BILLID == input.Id, x => new BookingCtn { IsDeleted = true }); + + await _ctndetailrep.UpdateAsync(x=>ctnlist.Contains((long)x.CTNID),x=>new BookingCtnDetail { IsDeleted=true}); + } /// - /// 更新订舱主表 + /// 更新订舱 /// /// /// + [SqlSugarUnitOfWork] [HttpPost("/BookingOrder/edit")] public async Task Update(UpdateBookingOrderInput input) { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync(); + + await _repCtn.DeleteAsync(x => x.BILLID == input.Id); + + await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID)); + foreach (var item in input.ctnInputs) + { + var ctnentity = item.Adapt(); + ctnentity.BILLID = entity.Id; + await _repCtn.InsertAsync(ctnentity); + foreach (var it in item.ctnDetailInputs) + { + var ctndetail = it.Adapt(); + ctndetail.CTNID = ctnentity.Id; + await _ctndetailrep.InsertAsync(ctndetail); + } + } } /// @@ -211,40 +261,20 @@ namespace Myshipping.Application /// /// [HttpGet("/BookingOrder/detail")] - public async Task Get([FromQuery] QueryeBookingOrderInput input) + public async Task Get([FromQuery] QueryeBookingOrderInput input) { - return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); - } + var main = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); + var list= main.Adapt(); - /// - /// - /// - /// - /// - [AllowAnonymous, ApiUser] - [HttpGet("/BookingOrder/updata")] - public async Task Updata() - { - return Task.Run(() => - { - return $"当前用户:{UserManager.Name} {UserManager.TENANT_ID} {UserManager.CLAINM_TENANT_NAME}"; - }); - } - [AllowAnonymous, SqlSugarUnitOfWork] - [HttpGet("/BookingOrder/test")] - public async Task Test() - { - var bo = new BookingOrder(); - await _rep.InsertAsync(bo); - Log.Information($"ins book id {bo.Id}"); - var ctn = new BookingCtn(); - ctn.BILLID = bo.Id; - await _repCtn.InsertAsync(ctn); - return await _rep.InsertAsync(new BookingOrder()); + return list; } + + + + } } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs index 2c2a2a26..51612c26 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Myshipping.Core; namespace Myshipping.Application @@ -737,6 +738,8 @@ namespace Myshipping.Application /// 付款方 /// public string FREIGHTPAYER { get; set; } - + + public List ctnInputs { get; set; } + } } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs index 9f28639f..1e2889f3 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs @@ -1,5 +1,6 @@ using Myshipping.Core; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace Myshipping.Application @@ -738,19 +739,19 @@ namespace Myshipping.Application public class AddBookingOrderInput : BookingOrderDto { + } - public class DeleteBookingOrderInput + public class QueryeBookingOrderInput { /// /// 主键 /// [Required(ErrorMessage = "主键不能为空")] public long Id { get; set; } - } - public class UpdateBookingOrderInput : BookingOrderInput + public class UpdateBookingOrderInput : BookingOrderDto { /// /// 主键 @@ -758,10 +759,8 @@ namespace Myshipping.Application [Required(ErrorMessage = "主键不能为空")] public long Id { get; set; } - } - - public class QueryeBookingOrderInput : DeleteBookingOrderInput - { } + + } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderOutput.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderOutput.cs index 6a1f26ad..c374dd3c 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderOutput.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderOutput.cs @@ -5,737 +5,9 @@ namespace Myshipping.Application /// /// 订舱主表输出参数 /// - public class BookingOrderOutput + public class BookingOrderOutput:BookingOrderDto { - /// - /// 主键 - /// - public long GID { get; set; } - - /// - /// 业务编号 - /// - public string BSNO { get; set; } - - /// - /// 业务状态 - /// - public string BSSTATUS { get; set; } - - /// - /// 业务状态名称 - /// - public string BSSTATUSNAME { get; set; } - - /// - /// 业务日期 - /// - public DateTime BSDATE { get; set; } - - /// - /// 主提单号 - /// - public string MBLNO { get; set; } - - /// - /// 分提单号 - /// - public string HBLNO { get; set; } - - /// - /// 订舱编号 - /// - public string BOOKINGNO { get; set; } - - /// - /// 合约号 - /// - public string CONTRACTNO { get; set; } - - /// - /// 客户合同号 - /// - public string SERVICECONTRACTNO { get; set; } - - /// - /// 发货人代码 - /// - public string SHIPPERID { get; set; } - - /// - /// 收货人代码 - /// - public string CONSIGNEEID { get; set; } - - /// - /// 通知人代码 - /// - public string NOTIFYPARTYID { get; set; } - - /// - /// 发货人 - /// - public string SHIPPER { get; set; } - - /// - /// 收货人 - /// - public string CONSIGNEE { get; set; } - - /// - /// 通知人 - /// - public string NOTIFYPARTY { get; set; } - - /// - /// 第二通知人 - /// - public string NOTIFYPARTY2 { get; set; } - - /// - /// 场站代码 - /// - public string YARDID { get; set; } - - /// - /// 场站 - /// - public string YARD { get; set; } - - /// - /// 船舶呼号 - /// - public string VESSELID { get; set; } - - /// - /// 船名 - /// - public string VESSEL { get; set; } - - /// - /// 海关航次 - /// - public string VOYNO { get; set; } - - /// - /// 内部航次 - /// - public string VOYNOINNER { get; set; } - - /// - /// 开船日期 - /// - public DateTime ETD { get; set; } - - /// - /// 实际开船日期 - /// - public DateTime ATD { get; set; } - - /// - /// 截港日期 - /// - public DateTime CLOSINGDATE { get; set; } - - /// - /// 截单日期 - /// - public DateTime CLOSEDOCDATE { get; set; } - - /// - /// 截VGM时间 - /// - public DateTime CLOSEVGMDATE { get; set; } - - /// - /// 预计到港日期 - /// - public DateTime ETA { get; set; } - - /// - /// 收货地代码 - /// - public string PLACERECEIPTID { get; set; } - - /// - /// 收货地 - /// - public string PLACERECEIPT { get; set; } - - /// - /// 起运港代码 - /// - public string PORTLOADID { get; set; } - - /// - /// 起运港 - /// - public string PORTLOAD { get; set; } - - /// - /// 卸货港代码 - /// - public string PORTDISCHARGEID { get; set; } - - /// - /// 卸货港 - /// - public string PORTDISCHARGE { get; set; } - - /// - /// 交货地代码 - /// - public string PLACEDELIVERYID { get; set; } - - /// - /// 交货地 - /// - public string PLACEDELIVERY { get; set; } - - /// - /// 目的地代码 - /// - public string DESTINATIONID { get; set; } - - /// - /// 目的地 - /// - public string DESTINATION { get; set; } - - /// - /// 提单份数 - /// - public string NOBILL { get; set; } - - /// - /// 副本提单份数 - /// - public string COPYNOBILLL { get; set; } - - /// - /// 签单方式 - /// - public string ISSUETYPE { get; set; } - - /// - /// 签单日期 - /// - public DateTime ISSUEDATE { get; set; } - - /// - /// 签单地点代码 - /// - public string ISSUEPLACEID { get; set; } - - /// - /// 签单地点 - /// - public string ISSUEPLACE { get; set; } - - /// - /// 付费方式 - /// - public string BLFRT { get; set; } - - /// - /// 预付地点 - /// - public string PREPARDAT { get; set; } - - /// - /// 到付地点 - /// - public string PAYABLEAT { get; set; } - - /// - /// 运输条款 - /// - public string SERVICE { get; set; } - - /// - /// 唛头 - /// - public string MARKS { get; set; } - - /// - /// HS代码 - /// - public string HSCODE { get; set; } - - /// - /// 货描 - /// - public string DESCRIPTION { get; set; } - - /// - /// 件数 - /// - public int PKGS { get; set; } - - /// - /// 包装 - /// - public string KINDPKGS { get; set; } - - /// - /// 毛重 - /// - public decimal KGS { get; set; } - - /// - /// 尺码 - /// - public decimal CBM { get; set; } - - /// - /// 件数大写 - /// - public string TOTALNO { get; set; } - - /// - /// 集装箱 - /// - public string CNTRTOTAL { get; set; } - - /// - /// 船公司代号 - /// - public string CARRIERID { get; set; } - - /// - /// 船公司 - /// - public string CARRIER { get; set; } - - /// - /// 货物标识 - /// - public string CARGOID { get; set; } - - /// - /// 危险品类别 - /// - public string DCLASS { get; set; } - - /// - /// 危险品编号 - /// - public string DUNNO { get; set; } - - /// - /// 危险品页号 - /// - public string DPAGE { get; set; } - - /// - /// 危险品标签 - /// - public string DLABEL { get; set; } - - /// - /// 危险品联系人 - /// - public string LINKMAN { get; set; } - - /// - /// 温度单位 - /// - public string TEMPID { get; set; } - - /// - /// 设置温度 - /// - public string TEMPSET { get; set; } - - /// - /// 通风度 - /// - public string REEFERF { get; set; } - - /// - /// 湿度 - /// - public string HUMIDITY { get; set; } - - /// - /// 最低温度 - /// - public string TEMPMIN { get; set; } - - /// - /// 最高温度 - /// - public string TEMPMAX { get; set; } - - /// - /// 是否SOC箱 - /// - public string ISCONTAINERSOC { get; set; } - - /// - /// SO备注 - /// - public string SOREMARK { get; set; } - - /// - /// SI备注 - /// - public string SIREMARK { get; set; } - - /// - /// 场站备注 - /// - public string YARDREMARK { get; set; } - - /// - /// 公司ID - /// - public string COMPID { get; set; } - - /// - /// 公司名称 - /// - public string COMPNAME { get; set; } - - /// - /// 发货人名称 - /// - public string SHIPPERNAME { get; set; } - - /// - /// 发货人地址1 - /// - public string SHIPPERADDR1 { get; set; } - - /// - /// 发货人地址2 - /// - public string SHIPPERADDR2 { get; set; } - - /// - /// 发货人地址3 - /// - public string SHIPPERADDR3 { get; set; } - - /// - /// 发货人城市 - /// - public string SHIPPERCITY { get; set; } - - /// - /// 发货人省份代码 - /// - public string SHIPPERPROVINCE { get; set; } - - /// - /// 发货人邮编 - /// - public string SHIPPERPOSTCODE { get; set; } - - /// - /// 发货人国家代码 - /// - public string SHIPPERCOUNTRY { get; set; } - - /// - /// 发货人联系人 - /// - public string SHIPPERATTN { get; set; } - - /// - /// 发货人电话 - /// - public string SHIPPERTEL { get; set; } - - /// - /// 发货人名称 - /// - public string CONSIGNEENAME { get; set; } - - /// - /// 发货人地址1 - /// - public string CONSIGNEEADDR1 { get; set; } - - /// - /// 发货人地址2 - /// - public string CONSIGNEEADDR2 { get; set; } - - /// - /// 发货人地址3 - /// - public string CONSIGNEEADDR3 { get; set; } - - /// - /// 发货人城市 - /// - public string CONSIGNEECITY { get; set; } - - /// - /// 发货人省份代码 - /// - public string CONSIGNEEPROVINCE { get; set; } - - /// - /// 发货人邮编 - /// - public string CONSIGNEEPOSTCODE { get; set; } - - /// - /// 发货人国家代码 - /// - public string CONSIGNEERCOUNTRY { get; set; } - - /// - /// 发货人联系人 - /// - public string CONSIGNEEATTN { get; set; } - - /// - /// 发货人电话 - /// - public string CONSIGNEETEL { get; set; } - - /// - /// 通知人名称 - /// - public string NOTIFYPARTYNAME { get; set; } - - /// - /// 通知人地址1 - /// - public string NOTIFYPARTYADDR1 { get; set; } - - /// - /// 通知人地址2 - /// - public string NOTIFYPARTYADDR2 { get; set; } - - /// - /// 通知人地址3 - /// - public string NOTIFYPARTYADDR3 { get; set; } - - /// - /// 通知人城市 - /// - public string NOTIFYPARTYCITY { get; set; } - - /// - /// 通知人省份代码 - /// - public string NOTIFYPARTYPROVINCE { get; set; } - - /// - /// 通知人邮编 - /// - public string NOTIFYPARTYPOSTCODE { get; set; } - - /// - /// 通知人国家代码 - /// - public string NOTIFYPARTYCOUNTRY { get; set; } - - /// - /// 通知人联系人 - /// - public string NOTIFYPARTYATTN { get; set; } - - /// - /// 通知人电话 - /// - public string NOTIFYPARTYTEL { get; set; } - - /// - /// PO号 - /// - public string PONO { get; set; } - - /// - /// 操作id - /// - public string OPID { get; set; } - - /// - /// 单证id - /// - public string DOCID { get; set; } - - /// - /// 操作 - /// - public string OP { get; set; } - - /// - /// 单证 - /// - public string DOC { get; set; } - - /// - /// 销售ID - /// - public string SALEID { get; set; } - - /// - /// 销售 - /// - public string SALE { get; set; } - - /// - /// 客服ID - /// - public string CUSTSERVICEID { get; set; } - - /// - /// 客服 - /// - public string CUSTSERVICE { get; set; } - - /// - /// 客户 - /// - public string CUSTOMERNAME { get; set; } - - /// - /// 订舱代理 - /// - public string FORWARDER { get; set; } - - /// - /// 船代 - /// - public string SHIPAGENCY { get; set; } - - /// - /// 报关行 - /// - public string CUSTOMSER { get; set; } - - /// - /// 车队 - /// - public string TRUCKER { get; set; } - - /// - /// 国外代理 - /// - public string AGENTID { get; set; } - - /// - /// 客户代号 - /// - public string CUSTOMERID { get; set; } - - /// - /// 订舱代理ID - /// - public string FORWARDERID { get; set; } - - /// - /// 船代ID - /// - public string SHIPAGENCYID { get; set; } - - /// - /// 报关行ID - /// - public string CUSTOMSERID { get; set; } - - /// - /// 车队ID - /// - public string TRUCKERID { get; set; } - - /// - /// 国外代理名称 - /// - public string AGENTNAME { get; set; } - - /// - /// 委托方 - /// - public string WEITUO { get; set; } - - /// - /// 收货人DOOR地址 - /// - public string CONSIGNEEDOORADDR { get; set; } - - /// - /// 发货人DOOR地址 - /// - public string SHIPPERDOORADDR { get; set; } - - /// - /// SCAC代码 - /// - public string SCACCODE { get; set; } - - /// - /// ITN编号 - /// - public string ITNCODE { get; set; } - - /// - /// 预付地点ID - /// - public string PREPARDATID { get; set; } - - /// - /// 到付地点ID - /// - public string PAYABLEATID { get; set; } - - /// - /// 客户系统编号 - /// - public string CUSTNO { get; set; } - - /// - /// 中转港代码 - /// - public string TRANSPORTID { get; set; } - - /// - /// 中转港 - /// - public string TRANSPORT { get; set; } - - /// - /// 第三付款地 - /// - public string THIRDPAYADDR { get; set; } - - /// - /// 场站联系人电话 - /// - public string YARDCONTRACTTEL { get; set; } - - /// - /// 场站联系人邮箱 - /// - public string YARDCONTRACTEMAIL { get; set; } - - /// - /// 费用自结 - /// - public bool FEESELF { get; set; } - - /// - /// 航线代码 - /// - public string LANECODE { get; set; } - - /// - /// 航线名称 - /// - public string LANENAME { get; set; } - - /// - /// 付款方 - /// - public string FREIGHTPAYER { get; set; } + } } diff --git a/Myshipping.Core/Entity/DBEntityTenant.cs b/Myshipping.Core/Entity/DBEntityTenant.cs index c2d04cdf..0a8b5778 100644 --- a/Myshipping.Core/Entity/DBEntityTenant.cs +++ b/Myshipping.Core/Entity/DBEntityTenant.cs @@ -1,5 +1,8 @@  +using Furion; using SqlSugar; +using System; +using Yitter.IdGenerator; namespace Myshipping.Core.Entity; @@ -14,24 +17,7 @@ public abstract class DBEntityTenant : DEntityBase [SugarColumn(ColumnDescription = "租户id")] public virtual long? TenantId { get; set; } - //public override void Create() { - // var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; - // var userName = App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; - // var tenantId = App.User.FindFirst(ClaimConst.TENANT_ID)?.Value; - // this.Id = YitIdHelper.NextId(); - // this.CreatedTime = DateTime.Now; - - // if (!string.IsNullOrEmpty(userId)) - // { - // this.CreatedUserId = long.Parse(userId); - // this.CreatedUserName = userName; - // } - // if (!string.IsNullOrWhiteSpace(tenantId)) { - // this.TenantId = long.Parse(tenantId); - // } - //} + - //public void CreateNotFillTenantInfo() { - // base.Create(); - //} + } diff --git a/Myshipping.Core/Entity/DEntityBase.cs b/Myshipping.Core/Entity/DEntityBase.cs index e8d31745..4dc6f791 100644 --- a/Myshipping.Core/Entity/DEntityBase.cs +++ b/Myshipping.Core/Entity/DEntityBase.cs @@ -1,6 +1,8 @@ -using SqlSugar; +using Furion; +using SqlSugar; using System; using System.ComponentModel.DataAnnotations; +using Yitter.IdGenerator; namespace Myshipping.Core.Entity; @@ -55,30 +57,30 @@ public abstract class DEntityBase : PrimaryKeyEntity public virtual bool IsDeleted { get; set; } = false; - //public virtual void Create() - //{ - // var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; - // var userName = App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; - // Id = YitIdHelper.NextId(); - // CreatedTime = DateTime.Now; - // if (!string.IsNullOrEmpty(userId)) - // { - // CreatedUserId = long.Parse(userId); - // CreatedUserName = userName; - // } - //} + public virtual void Create() + { + var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + var userName = App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; + Id = YitIdHelper.NextId(); + CreatedTime = DateTime.Now; + if (!string.IsNullOrEmpty(userId)) + { + CreatedUserId = long.Parse(userId); + CreatedUserName = userName; + } + } - //public void Modify() - //{ - // var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; - // var userName = App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; - // UpdatedTime = DateTime.Now; - // if (!string.IsNullOrEmpty(userId)) - // { - // UpdatedUserId = long.Parse(userId); - // UpdatedUserName = userName; - // } - //} + public void Modify() + { + var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + var userName = App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; + UpdatedTime = DateTime.Now; + if (!string.IsNullOrEmpty(userId)) + { + UpdatedUserId = long.Parse(userId); + UpdatedUserName = userName; + } + } /// /// 更新信息列 diff --git a/Myshipping.Core/Util/JsonUtil.cs b/Myshipping.Core/Util/JsonUtil.cs index ca98f0a7..2136a3ef 100644 --- a/Myshipping.Core/Util/JsonUtil.cs +++ b/Myshipping.Core/Util/JsonUtil.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; +using System.Reflection; using Furion.JsonSerialization; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -111,4 +113,92 @@ public static class JsonUtil } } + + + + /// + /// 处理输入的数据,变为大写,全角改为半角 + /// + /// 数据对象 + /// 不需要转大写的字段 + public static void PropToUpper(object model, params string[] excepProp) + { + var props = model.GetType().GetProperties(); + foreach (PropertyInfo prop in props) + { + var propName = prop.Name; + if (excepProp != null && excepProp.Length > 0) + { + if (!excepProp.Contains(propName)) + { + if (prop.PropertyType == typeof(string)) + { + object sourceVal = prop.GetValue(model); + if (sourceVal != null) + { + prop.SetValue(model, ToDBC(sourceVal.ToString().ToUpper())); + } + } + } + } + } + } + + public static string ToDBC(string input) + { + char[] c = input.ToCharArray(); + for (int i = 0; i < c.Length; i++) + { + if (c[i] == 12288) + { + c[i] = (char)32; + continue; + } + if (c[i] > 65280 && c[i] < 65375) + c[i] = (char)(c[i] - 65248); + } + return new string(c); + } + + + /// + /// 处理所有时间字段,将Datetime.Min设置为null + /// + /// + public static void MinDateToNull(object model) + { + var props = model.GetType().GetProperties(); + foreach (PropertyInfo prop in props) + { + if (prop.PropertyType == typeof(DateTime?)) + { + DateTime? sourceVal = (DateTime?)prop.GetValue(model); + if (sourceVal != null && sourceVal.HasValue && sourceVal.Value == DateTime.MinValue) + { + prop.SetValue(model, null); + } + } + } + } + + + /// + /// 去空格 + /// + public static void TrimFields(object model) + { + var props = model.GetType().GetProperties(); + foreach (PropertyInfo prop in props) + { + var propName = prop.Name; + if (prop.PropertyType == typeof(string)) + { + object sourceVal = prop.GetValue(model); + if (sourceVal != null) + { + prop.SetValue(model, ToDBC(sourceVal.ToString().Trim())); + } + } + } + } }