diff --git a/ams/Djy.Common/DJYModel/ParamSet.cs b/ams/Djy.Common/DJYModel/ParamSet.cs new file mode 100644 index 0000000..01acb87 --- /dev/null +++ b/ams/Djy.Common/DJYModel/ParamSet.cs @@ -0,0 +1,27 @@ +using FreeSql.DataAnnotations; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Common.DJYModel +{ + [JsonObject(MemberSerialization.OptIn), Table(Name = "sys_param_set", DisableSyncStructure = true)] + public class ParamSet + { + /// + /// 主键 + /// + [JsonProperty, Column(IsPrimary = true, IsNullable = false)] + public string GID { get; set; } + public string PARAMNAME { get; set; } + public string PARAMDESCRIPTION { get; set; } + public string PARAMVALUE { get; set; } + public string MODIFIEDUSER { get; set; } + public DateTime? MODIFIEDTIME { get; set; } + public string PARAMTYPE { get; set; } + public string FIELDTYPE { get; set; } + } +} diff --git a/ams/djy.IService/Ams/IAmsService.cs b/ams/djy.IService/Ams/IAmsService.cs index 6db9063..6b9aa53 100644 --- a/ams/djy.IService/Ams/IAmsService.cs +++ b/ams/djy.IService/Ams/IAmsService.cs @@ -49,6 +49,6 @@ namespace djy.Paas.IService - Response SendDE(string Gid, string userid); + void SendDE(string Gid, string userid); } } diff --git a/ams/djy.Model/AmsDto/AMSDocContent.cs b/ams/djy.Model/AmsDto/AMSDocContent.cs new file mode 100644 index 0000000..3b4adff --- /dev/null +++ b/ams/djy.Model/AmsDto/AMSDocContent.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace djy.Model.AmsDto +{ + public class AMSDocContent + { + public string fromdea { get; set; } + + public string todea { get; set; } + + public string editype { get; set; } + public string port { get; set; } + + public MasterBillInfoDto masterBillInfo { get; set; } + } +} diff --git a/ams/djy.Service/Ams/AmsService.cs b/ams/djy.Service/Ams/AmsService.cs index 6d74fde..ddd2365 100644 --- a/ams/djy.Service/Ams/AmsService.cs +++ b/ams/djy.Service/Ams/AmsService.cs @@ -17,6 +17,10 @@ using System.Transactions; using Dapper.Contrib.Extensions; using Common.Utilities; using Newtonsoft.Json; +using System.Security.Cryptography; +using System.Text.Encodings.Web; +using Common.Tools; +using System.Web; namespace djy.Service.Ams { @@ -25,24 +29,25 @@ namespace djy.Service.Ams /// public class AmsService : ServBase, IAmsService { - public TableData Load(AMSQuery req, string userid) + public TableData Load(AMSQuery req, string userid) { var result = new TableData(); var user = DbBus.Get(DbList.djydb).Select().Where(w => w.GID == userid).ToOne(); - var dto = DbBus.Get(DbList.AMSCenter).Select().Where(x => (x.IsDel == false || x.IsDel == null)&&x.CompID==user.CompId).WhereIf(req.MBLNO != null, x => x.MBLNO == req.MBLNO); + var dto = DbBus.Get(DbList.AMSCenter).Select().Where(x => (x.IsDel == false || x.IsDel == null) && x.CompID == user.CompId).WhereIf(req.MBLNO != null, x => x.MBLNO == req.MBLNO); result.count = dto.ToList().Count(); - var list= dto.Page(req.Page,req.Limit).ToList(); - if (list != null) + var list = dto.Page(req.Page, req.Limit).ToList(); + if (list != null) { foreach (var item in list) { - var hodto = DbBus.Get(DbList.AMSCenter).Select().Where(x =>( x.IsDel == false || x.IsDel == null) && x.PID == item.GID).ToList(); + var hodto = DbBus.Get(DbList.AMSCenter).Select().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == item.GID).ToList(); item.HouseDto = hodto; - if (hodto!=null) { + if (hodto != null) + { foreach (var it in hodto) { - var cnt = DbBus.Get(DbList.AMSCenter).Select().Where(x => (x.IsDel == false || x.IsDel == null )&& x.HID == it.GID).ToList(); - it.CntrnoDto = cnt; + var cnt = DbBus.Get(DbList.AMSCenter).Select().Where(x => (x.IsDel == false || x.IsDel == null) && x.HID == it.GID).ToList(); + it.CntrnoDto = cnt; } } } @@ -54,25 +59,26 @@ namespace djy.Service.Ams public void Delete(string ids) { string[] id = ids.Split(','); - DbBus.Get(DbList.AMSCenter).Transaction(() => { + DbBus.Get(DbList.AMSCenter).Transaction(() => + { foreach (string oid in id) { if (oid != "") { - DbBus.Get(DbList.AMSCenter).Update().Set(w => w.IsDel,true).Where(w => w.GID ==oid).ExecuteAffrows(); + DbBus.Get(DbList.AMSCenter).Update().Set(w => w.IsDel, true).Where(w => w.GID == oid).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update().Set(w => w.IsDel, true).Where(w => w.PID == oid).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update().Set(w => w.IsDel, true).Where(w => w.PID == oid).ExecuteAffrows(); - } + } } }); } - public void SaveInfo(AMSDto dto, string userid) + public void SaveInfo(AMSDto dto, string userid) { if (dto.GID.IsNull()) { var user = DbBus.Get(DbList.djydb).Select().Where(w => w.GID == userid).ToOne(); - + DbBus.Get(DbList.AMSCenter).Transaction(() => { AMS_Master master = dto.MapTo(); @@ -87,36 +93,37 @@ namespace djy.Service.Ams DbBus.Get(DbList.AMSCenter).Insert(master).ExecuteAffrows(); if (dto.HouseDto != null && dto.HouseDto.Count() > 0) - { - foreach (var item in dto.HouseDto) - { - AMS_House house = item.MapTo(); - house.GID = Guid.NewGuid().ToString("N"); - house.PID = master.GID; + { + foreach (var item in dto.HouseDto) + { + AMS_House house = item.MapTo(); + house.GID = Guid.NewGuid().ToString("N"); + house.PID = master.GID; house.IsDel = false; DbBus.Get(DbList.AMSCenter).Insert(house).ExecuteAffrows(); - if (item.CntrnoDto!=null&&item.CntrnoDto.Count()>0) { - foreach (var it in item.CntrnoDto) - { - AMS_Cntrno cntrno = it.MapTo(); - cntrno.GID = Guid.NewGuid().ToString("N"); - cntrno.PID = master.GID; - cntrno.HID = house.GID; - cntrno.IsDel = false; + if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0) + { + foreach (var it in item.CntrnoDto) + { + AMS_Cntrno cntrno = it.MapTo(); + cntrno.GID = Guid.NewGuid().ToString("N"); + cntrno.PID = master.GID; + cntrno.HID = house.GID; + cntrno.IsDel = false; DbBus.Get(DbList.AMSCenter).Insert(cntrno).ExecuteAffrows(); } - } - } - } + } + } + } }); - } + } else { DbBus.Get(DbList.AMSCenter).Transaction(() => { AMS_Master master = dto.MapTo(); DbBus.Get(DbList.AMSCenter).Update().SetSource(master).ExecuteAffrows(); - DbBus.Get(DbList.AMSCenter).Delete().Where(w => w.PID==master.GID).ExecuteAffrows(); + DbBus.Get(DbList.AMSCenter).Delete().Where(w => w.PID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Delete().Where(w => w.PID == master.GID).ExecuteAffrows(); if (dto.HouseDto != null && dto.HouseDto.Count() > 0) @@ -126,7 +133,7 @@ namespace djy.Service.Ams AMS_House house = item.MapTo(); house.GID = Guid.NewGuid().ToString("N"); house.PID = master.GID; - house.IsDel=false; + house.IsDel = false; DbBus.Get(DbList.AMSCenter).Insert(house).ExecuteAffrows(); if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0) { @@ -136,7 +143,7 @@ namespace djy.Service.Ams cntrno.GID = Guid.NewGuid().ToString("N"); cntrno.PID = master.GID; cntrno.HID = house.GID; - cntrno.IsDel=false; + cntrno.IsDel = false; DbBus.Get(DbList.AMSCenter).Insert(cntrno).ExecuteAffrows(); } } @@ -146,12 +153,12 @@ namespace djy.Service.Ams } } - public List GetCountry() + public List GetCountry() { try { - var List = DbBus.Get(DbList.AMSCenter).Select().ToList(); - return List; + var List = DbBus.Get(DbList.AMSCenter).Select().ToList(); + return List; } catch (Exception e) { @@ -212,15 +219,11 @@ namespace djy.Service.Ams } } - public Response SendDE(string Gid,string userid) + public async void SendDE(string Gid, string userid) { var result = new Response(); - try { - if (Gid.IsNull()) { - result.Code = 500; - result.Message = "请传入相关业务id!"; - return result; - } + try + { string[] id = Gid.Split(','); foreach (string oid in id) { @@ -229,8 +232,8 @@ namespace djy.Service.Ams MasterBillInfoDto dto = new MasterBillInfoDto(); masterBillInfo masterBillInfo = new masterBillInfo(); var user = DbBus.Get(DbList.djydb).Select().Where(w => w.GID == userid).ToOne(); - var master = DbBus.Get(DbList.AMSCenter).Select().Where(x => (x.IsDel == false || x.IsDel == null) && x.CompID == user.CompId&&x.GID==oid).ToOne(); - + var master = DbBus.Get(DbList.AMSCenter).Select().Where(x => (x.IsDel == false || x.IsDel == null) && x.CompID == user.CompId && x.GID == oid).ToOne(); + masterBillInfo.masterBillNo = master.MBLNO; masterBillInfo.shipCompany = master.CARRIERID; masterBillInfo.vessel = master.VESSEL; @@ -287,22 +290,64 @@ namespace djy.Service.Ams insertList.unCode = it.DUNNO; insertList.dangerGrade = it.DangerGrade; list.Add(insertList); + + + + CtnInfo.insertList = list; + houseinfo.ctnInfo = CtnInfo; + houseBillInfoListItems.Add(houseinfo); } - CtnInfo.insertList = list; - houseinfo.ctnInfo = CtnInfo; - houseBillInfoListItems.Add(houseinfo); } dto.houseBillInfoList = houseBillInfoListItems; - var data = JsonConvert.SerializeObject(dto).ToBase64(); + var data = JsonConvert.SerializeObject(dto); + var AMSAccount = DbBus.Get(DbList.djydb).Select().Where(x => x.PARAMNAME == "AMSAccount").ToOne(); + var key = DbBus.Get(DbList.djydb).Select().Where(x => x.PARAMNAME == "AMSKEY").ToOne(); + var url = DbBus.Get(DbList.djydb).Select().Where(x => x.PARAMNAME == "AMSURL").ToOne(); + var method = DbBus.Get(DbList.djydb).Select().Where(x => x.PARAMNAME == "AMSMethod").ToOne(); + //string stringSign = string.Format("format=json&method=cargoedi.demessage.msgrec.post×tamp={0}&user_id={1}&version=2.0&key={2}", + // DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss").ToUrlEncodeString(), AMSAccount.PARAMVALUE, key.PARAMVALUE); + + + //string sign = stringSign.ToMd5().ToUpper(); + AMSDocContent aMSDoc = new AMSDocContent(); + aMSDoc.fromdea = "n"; + aMSDoc.todea = "n"; + aMSDoc.editype = "AMSDOC"; + aMSDoc.port = "Ningbo"; + aMSDoc.masterBillInfo = dto; + var jobj = JsonConvert.SerializeObject(aMSDoc); + + string stringSign = string.Format("channel=WSTOM&deaId=n&destDeaId=n&docContent={0}&docLength={1}&docName={2}&format=json&method={3}×tamp={4}&user_id={5}&version=2.0&key={6}", + jobj.ToString(), jobj.ToString().Length, DateTime.Now.ToString("yyyyMMdd") + GenerateRandomNo(), method.PARAMVALUE, + HttpUtility.UrlEncode(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Encoding.UTF8), + AMSAccount.PARAMVALUE, key.PARAMVALUE); + + string sign = stringSign.ToMd5().ToUpper(); + + string json = string.Format("port=Ningbo&docContent={0}&method={1}&channel=WSTOM&docName={2}&user_id={3}&docType=AMSDOC×tamp={4}" + + "&format=json&destDeaId=n&deaId=n&sign={5}&docLength={6}", + jobj.ToString().ToBase64(), method.PARAMVALUE, DateTime.Now.ToString("yyyyMMdd") + GenerateRandomNo(), + AMSAccount.PARAMVALUE, HttpUtility.UrlEncode(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Encoding.UTF8), + sign, jobj.ToString().Length); + await HttpHelp.Post(json, url.PARAMVALUE, PsotType.Urlencoded); } + } } - catch (Exception e) { + catch (Exception e) + { - result.Code = 500; - result.Message = e.InnerException?.Message ?? e.Message; + throw; } - return result; + + } + + public string GenerateRandomNo() + { + int _min = 000000; + int _max = 999999; + Random _rdm = new Random(); + return _rdm.Next(_min, _max).ToString(); } } } diff --git a/ams/djy.WebApi/Controllers/AMS/AmsController.cs b/ams/djy.WebApi/Controllers/AMS/AmsController.cs index 7e2c6b3..0a6bd4e 100644 --- a/ams/djy.WebApi/Controllers/AMS/AmsController.cs +++ b/ams/djy.WebApi/Controllers/AMS/AmsController.cs @@ -188,7 +188,7 @@ namespace djy_AmsApi.Controllers try { - ser.SendDE(ids, "d85fd590-d9f6-4410-93a1-f6fac77b606e"); + ser.SendDE(ids, "d85fd590-d9f6-4410-93a1-f6fac77b606e"); } catch (Exception ex) diff --git a/ams/djy.WebApi/appsettings.Development.json b/ams/djy.WebApi/appsettings.Development.json index d40bc08..9102512 100644 --- a/ams/djy.WebApi/appsettings.Development.json +++ b/ams/djy.WebApi/appsettings.Development.json @@ -28,7 +28,7 @@ "Rbmq_UserName": "djy_paas", "Rbmq_Password": "123qwe", "Rbmq_Sqlhost": "Data Source =192.168.1.205,1433; Initial Catalog=TestDjyLogs; Persist Security Info=True; User ID =test; Password=test123;pooling=true", - "DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;max pool size=2", + "DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;", "DataConnList": [ @@ -38,7 +38,7 @@ "Index": 100, "DataType": 1, "Status": 0, - "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;max pool size=2" + "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;" }, { "SysKey": "djydb", diff --git a/ams/djy.WebApi/appsettings.Prod.json b/ams/djy.WebApi/appsettings.Prod.json index 9f5e41c..3ce1cf7 100644 --- a/ams/djy.WebApi/appsettings.Prod.json +++ b/ams/djy.WebApi/appsettings.Prod.json @@ -27,7 +27,7 @@ "Rbmq_UserName": "admin", "Rbmq_Password": "admin", "Rbmq_Sqlhost": "Data Source =172.31.85.154; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true", - "DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;max pool size=2", + "DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;", "DataConnList": [ { @@ -36,7 +36,7 @@ "Index": 100, "DataType": 1, "Status": 0, - "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;max pool size=2" + "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;" }, { "SysKey": "djydb", diff --git a/ams/djy.WebApi/appsettings.json b/ams/djy.WebApi/appsettings.json index 2ca92b8..b1f43dd 100644 --- a/ams/djy.WebApi/appsettings.json +++ b/ams/djy.WebApi/appsettings.json @@ -27,7 +27,8 @@ "Rbmq_UserName": "admin", "Rbmq_Password": "admin", "Rbmq_Sqlhost": "Data Source =172.31.85.154; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true", - "DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;max pool size=2", + "DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;", + "requesterDea": "nbforwarder", "DataConnList": [ { @@ -36,7 +37,7 @@ "Index": 100, "DataType": 1, "Status": 0, - "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;max pool size=2" + "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;" }, { "SysKey": "djydb", @@ -56,7 +57,7 @@ "ConnString": "Data Source =172.31.85.154,1433; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true" } - + ]