master
wet 3 years ago
parent a9efa64582
commit be499e7907

@ -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
{
/// <summary>
/// 主键
/// </summary>
[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; }
}
}

@ -49,6 +49,6 @@ namespace djy.Paas.IService
Response SendDE(string Gid, string userid);
void SendDE(string Gid, string userid);
}
}

@ -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; }
}
}

@ -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
/// </summary>
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<User>().Where(w => w.GID == userid).ToOne();
var dto = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().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<AMS_Master>().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<AMSDto>();
if (list != null)
var list = dto.Page(req.Page, req.Limit).ToList<AMSDto>();
if (list != null)
{
foreach (var item in list)
{
var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x =>( x.IsDel == false || x.IsDel == null) && x.PID == item.GID).ToList<AMS_HouseDto>();
var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == item.GID).ToList<AMS_HouseDto>();
item.HouseDto = hodto;
if (hodto!=null) {
if (hodto != null)
{
foreach (var it in hodto)
{
var cnt = DbBus.Get(DbList.AMSCenter).Select<AMS_Cntrno>().Where(x => (x.IsDel == false || x.IsDel == null )&& x.HID == it.GID).ToList();
it.CntrnoDto = cnt;
var cnt = DbBus.Get(DbList.AMSCenter).Select<AMS_Cntrno>().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<AMS_Master>().Set(w => w.IsDel,true).Where(w => w.GID ==oid).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => w.IsDel, true).Where(w => w.GID == oid).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => w.IsDel, true).Where(w => w.PID == oid).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<AMS_Cntrno>().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<User>().Where(w => w.GID == userid).ToOne();
DbBus.Get(DbList.AMSCenter).Transaction(() =>
{
AMS_Master master = dto.MapTo<AMS_Master>();
@ -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<AMS_House>();
house.GID = Guid.NewGuid().ToString("N");
house.PID = master.GID;
{
foreach (var item in dto.HouseDto)
{
AMS_House house = item.MapTo<AMS_House>();
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<AMS_Cntrno>();
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<AMS_Cntrno>();
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<AMS_Master>();
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().SetSource(master).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Delete<AMS_House>().Where(w => w.PID==master.GID).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Delete<AMS_House>().Where(w => w.PID == master.GID).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Delete<AMS_Cntrno>().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<AMS_House>();
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<CommonCodeValue> GetCountry()
public List<CommonCodeValue> GetCountry()
{
try
{
var List = DbBus.Get(DbList.AMSCenter).Select<AMS_SysCountry>().ToList<CommonCodeValue>();
return List;
var List = DbBus.Get(DbList.AMSCenter).Select<AMS_SysCountry>().ToList<CommonCodeValue>();
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<User>().Where(w => w.GID == userid).ToOne();
var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(x => (x.IsDel == false || x.IsDel == null) && x.CompID == user.CompId&&x.GID==oid).ToOne();
var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().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<ParamSet>().Where(x => x.PARAMNAME == "AMSAccount").ToOne();
var key = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AMSKEY").ToOne();
var url = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AMSURL").ToOne();
var method = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AMSMethod").ToOne();
//string stringSign = string.Format("format=json&method=cargoedi.demessage.msgrec.post&timestamp={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}&timestamp={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&timestamp={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();
}
}
}

@ -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)

@ -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",

@ -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",

@ -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"
}
]

Loading…
Cancel
Save