From 6d0964f325da79bf8b79a1599adb90a541514562 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Wed, 21 Dec 2022 14:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=88=B9=E6=9C=9F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 29 +-- Myshipping.Core/Entity/DJY/DjyVesselInfo.cs | 79 ++++++++ Myshipping.Core/Extension/NumberToUpper.cs | 183 ++++++++++++++++++ Myshipping.Core/Myshipping.Core.xml | 126 ++++++++++++ .../DjyVesselInfo/DjyVesselInfoService.cs | 67 +++++++ .../DjyVesselInfo/IDjyVesselInfoService.cs | 12 ++ 6 files changed, 482 insertions(+), 14 deletions(-) create mode 100644 Myshipping.Core/Entity/DJY/DjyVesselInfo.cs create mode 100644 Myshipping.Core/Extension/NumberToUpper.cs create mode 100644 Myshipping.Core/Service/DjyVesselInfo/DjyVesselInfoService.cs create mode 100644 Myshipping.Core/Service/DjyVesselInfo/IDjyVesselInfoService.cs diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 0ef63cc3..04b801b7 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -54,6 +54,7 @@ using Myshipping.Application.Helper; using System.Net; using Furion.DistributedIDGenerator; using System.Linq.Expressions; +using Myshipping.Core.Extension; namespace Myshipping.Application { @@ -366,7 +367,7 @@ namespace Myshipping.Application } var entity = input.Adapt(); - + entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS==null?0: entity.PKGS); await _rep.InsertAsync(entity); if (input.ctnInputs != null) { @@ -410,12 +411,11 @@ namespace Myshipping.Application CreatedUserName = UserManager.Name }); - ////分单不调用 - - if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) - { - await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO); - } + //////分单不调用 + //if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) + //{ + // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO); + //} return entity.Id; } @@ -474,6 +474,7 @@ namespace Myshipping.Application } var main = await _rep.AsQueryable().Where(x => x.Id == input.Id).FirstAsync(); var entity = input.Adapt(); + entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS); 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); @@ -574,13 +575,13 @@ namespace Myshipping.Application OldValue = _oldvalue, NewValue = _value, }); - if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO") - { - if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) - { - await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO); - } - } + //if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO") + //{ + // if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) + // { + // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO); + // } + //} } } } diff --git a/Myshipping.Core/Entity/DJY/DjyVesselInfo.cs b/Myshipping.Core/Entity/DJY/DjyVesselInfo.cs new file mode 100644 index 00000000..796c1ba7 --- /dev/null +++ b/Myshipping.Core/Entity/DJY/DjyVesselInfo.cs @@ -0,0 +1,79 @@ +using System; +using SqlSugar; +using System.ComponentModel; +using Myshipping.Core.Entity; +namespace Myshipping.Application.Entity +{ + /// + /// 船期信息 + /// + [SugarTable("vesselinfo")] + [Description("船期信息")] + public class DjyVesselInfo : PrimaryKeyEntity + { + /// + /// 租户Id + /// + public long? TenantId { get; set; } + /// + /// 船名 + /// + public string Vessel { get; set; } + /// + /// 航次 + /// + public string Voyno { get; set; } + /// + /// 装货港 + /// + public string PortLoading { get; set; } + /// + /// 中转港 + /// + public string PortTransit { get; set; } + /// + /// 卸货港 + /// + public string PortDischarge { get; set; } + /// + /// 装货港ID + /// + public string PortLoadingId { get; set; } + /// + /// 装货港ID + /// + public string PortTransitId { get; set; } + /// + /// 卸货港ID + /// + public string PortDischargeId { get; set; } + /// + /// 开船日期 + /// + public DateTime? ETD { get; set; } + /// + /// 截港日期 + /// + public DateTime? ClosingDate { get; set; } + /// + /// 预抵日期 + /// + public DateTime? ETA { get; set; } + /// + /// 默认码头 + /// + public string Wharf { get; set; } + /// + /// 船公司 + /// + public string CARRIER { get; set; } + /// + /// 船公司ID + /// + public string CARRIERID { get; set; } + /// + /// 内部航次 + /// + public string InsideVoyno { get; set; } + } +} \ No newline at end of file diff --git a/Myshipping.Core/Extension/NumberToUpper.cs b/Myshipping.Core/Extension/NumberToUpper.cs new file mode 100644 index 00000000..a12da532 --- /dev/null +++ b/Myshipping.Core/Extension/NumberToUpper.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Core.Extension +{ + public static class NumberToUpper + { + /// + /// 单个数字转为大写 + /// + /// 小写阿拉伯数字 0---9 + /// 大写数字 + private static string getint(char c) + { + string str = ""; + switch (c) + { + case '0': + str = "零"; + break; + case '1': + str = "壹"; + break; + case '2': + str = "贰"; + break; + case '3': + str = "叁"; + break; + case '4': + str = "肆"; + break; + case '5': + str = "伍"; + break; + case '6': + str = "陆"; + break; + case '7': + str = "柒"; + break; + case '8': + str = "拐"; + break; + case '9': + str = "玖"; + break; + } + return str; + } + + /// + /// 把一个单元转为大写,如亿单元,万单元,个单元 + /// + /// 这个单元的小写数字(4位长,若不足,则前面补零) + /// 亿,万,元 + /// 转换结果 + private static string getupper(string str, string strDW) + { + if (str == "0000") + return ""; + string ret = ""; + string tmp1 = getint(str[0]); + string tmp2 = getint(str[1]); + string tmp3 = getint(str[2]); + string tmp4 = getint(str[3]); + if (tmp1 != "零") + { + ret = ret + tmp1 + "仟"; + } + else + { + ret = ret + tmp1; + } + if (tmp2 != "零") + { + ret = ret + tmp2 + "佰"; + } + else + { + if (tmp1 != "零") //保证若有两个零'00',结果只有一个零,下同 + ret = ret + tmp2; + } + if (tmp3 != "零") + { + ret = ret + tmp3 + "拾"; + } + else + { + if (tmp2 != "零") + ret = ret + tmp3; + } + if (tmp4 != "零") + { + ret = ret + tmp4; + } + if (ret[0] == '零') //若第一个字符是'零',则去掉 + ret = ret.Substring(1); + if (ret[ret.Length - 1] == '零') //若最后一个字符是'零',则去掉 + ret = ret.Substring(0, ret.Length - 1); + return ret + strDW; //加上本单元的单位 + + } + + /// + /// 数字转换成大写 + /// + /// + /// + public static string ToUpper(dynamic d) + { + if (d == 0) + return "零"; + + string je = d.ToString("####.00"); + if (je.Length > 15) + return ""; + je = new String('0', 15 - je.Length) + je; //若小于15位长,前面补0 + + string stry = je.Substring(0, 4); //取得'亿'单元 + string strw = je.Substring(4, 4); //取得'万'单元 + string strg = je.Substring(8, 4); //取得'元'单元 + string strf = je.Substring(13, 2); //取得小数部分 + string str1 = "", str2 = "", str3 = ""; + str1 = getupper(stry, "亿"); //亿单元的大写 + str2 = getupper(strw, "万"); //万单元的大写 + str3 = getupper(strg, " "); //元单元的大写 + string str_y = "", str_w = ""; + if (je[3] == '0' || je[4] == '0') //亿和万之间是否有0 + str_y = "零"; + if (je[7] == '0' || je[8] == '0') //万和元之间是否有0 + str_w = "零"; + string ret = str1 + str_y + str2 + str_w + str3; //亿,万,元的三个大写合并 + for (int i = 0; i < ret.Length; i++) //去掉前面的"零" + { + if (ret[i] != '零') + { + ret = ret.Substring(i); + break; + } + } + for (int i = ret.Length - 1; i > -1; i--) //去掉最后的"零" + { + if (ret[i] != '零') + { + ret = ret.Substring(0, i + 1); + break; + } + } + if (ret[ret.Length - 1] != ' ') //若最后不位不是'元',则加一个'元'字 + ret = ret + ""; + if (ret == "零零") //若为零元,则去掉"元数",结果只要小数部分 + ret = ""; + if (strf == "00") //下面是小数部分的转换 + { + ret = ret + "整"; + } + else + { + string tmp = ""; + tmp = getint(strf[0]); + if (tmp == "零") + ret = ret + tmp; + else + ret = ret + tmp + "角"; + + tmp = getint(strf[1]); + if (tmp == "零") + ret = ret + "整"; + else + ret = ret + tmp + "分"; + } + if (ret[0] == '零') + { + ret = ret.Substring(1); //防止0.03转为"零叁分",而直接转为"叁分" + } + return ret; //完成,返回 + } + } +} diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 59a7c2dc..8b1cc1ff 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -5138,6 +5138,28 @@ + + + 单个数字转为大写 + + 小写阿拉伯数字 0---9 + 大写数字 + + + + 把一个单元转为大写,如亿单元,万单元,个单元 + + 这个单元的小写数字(4位长,若不足,则前面补零) + 亿,万,元 + 转换结果 + + + + 数字转换成大写 + + + + 分页拓展类 @@ -10532,6 +10554,25 @@ 发件SSL + + + 用户自定义配置服务 + + + + + 新增编辑 + + + + + + + 下拉列表 + + + + 网站账号维护服务 @@ -16423,5 +16464,90 @@ + + + 船期信息 + + + + + 租户Id + + + + + 船名 + + + + + 航次 + + + + + 装货港 + + + + + 中转港 + + + + + 卸货港 + + + + + 装货港ID + + + + + 装货港ID + + + + + 卸货港ID + + + + + 开船日期 + + + + + 截港日期 + + + + + 预抵日期 + + + + + 默认码头 + + + + + 船公司 + + + + + 船公司ID + + + + + 内部航次 + + diff --git a/Myshipping.Core/Service/DjyVesselInfo/DjyVesselInfoService.cs b/Myshipping.Core/Service/DjyVesselInfo/DjyVesselInfoService.cs new file mode 100644 index 00000000..7edfafd7 --- /dev/null +++ b/Myshipping.Core/Service/DjyVesselInfo/DjyVesselInfoService.cs @@ -0,0 +1,67 @@ +using Myshipping.Core; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using System.Linq; +using System.Threading.Tasks; +using Myshipping.Core.Entity; +using Myshipping.Application.Entity; +using Furion.FriendlyException; +using System.Collections.Generic; + +namespace Myshipping.Core.Service +{ + /// + /// 用户自定义配置服务 + /// + [ApiDescriptionSettings(Name = "DjyVesselInfo", Order = 1)] + public class DjyVesselInfoService : IDjyVesselInfoService, IDynamicApiController, ITransient + { + private readonly SqlSugarRepository _rep; + private readonly ISysCacheService _sysCacheService; + public DjyVesselInfoService(SqlSugarRepository rep, ISysCacheService sysCacheService) + { + _sysCacheService = sysCacheService; + _rep = rep; + } + /// + /// 新增编辑 + /// + /// + /// + public async Task AddOrUpdate(DjyVesselInfo dto) + { + if (dto == null) + { + throw Oops.Bah("请传入数据!"); + } + if (dto.Id == 0) + { + await _rep.InsertAsync(dto); + } + else + { + await _rep.AsUpdateable(dto).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + return dto.Id; + } + + /// + /// 下拉列表 + /// + /// + /// + public async Task GetList(string KeyWord) { + //获取船名 + List list = await _sysCacheService.GetAllCodeVessel(); + + var tlist= await _rep.AsQueryable().Where(x => x.TenantId == UserManager.TENANT_ID).ToListAsync(); + return null; + } + + + + } +} diff --git a/Myshipping.Core/Service/DjyVesselInfo/IDjyVesselInfoService.cs b/Myshipping.Core/Service/DjyVesselInfo/IDjyVesselInfoService.cs new file mode 100644 index 00000000..c944d239 --- /dev/null +++ b/Myshipping.Core/Service/DjyVesselInfo/IDjyVesselInfoService.cs @@ -0,0 +1,12 @@ +using Myshipping.Core; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Myshipping.Core.Entity; + +namespace Myshipping.Core.Service +{ + public interface IDjyVesselInfoService + { + + } +} \ No newline at end of file