master
wet 2 years ago
parent 3ed55b8b2e
commit 5a3346568e

@ -3136,6 +3136,14 @@
</summary>
<returns></returns>
</member>
<member name="M:Common.Extensions.Json.SortJson(Newtonsoft.Json.Linq.JToken,Newtonsoft.Json.Linq.JToken)">
<summary>
JSON格式化重新排序
</summary>
<param name="jobj">原始JSON JToken.Parse(string json);</param>
<param name="obj">初始值Null</param>
<returns></returns>
</member>
<member name="M:Common.Extensions.LambdaExtensions.TakePage``1(System.Linq.IQueryable{``0},System.Int32,System.Int32)">
<summary>
分页查询

@ -1,5 +1,7 @@
using System;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Xml;
@ -84,9 +86,132 @@ namespace Common.Extensions
return null;
}
}
/// <summary>
/// JSON格式化重新排序
/// </summary>
/// <param name="jobj">原始JSON JToken.Parse(string json);</param>
/// <param name="obj">初始值Null</param>
/// <returns></returns>
public static string SortJson(JToken jobj, JToken obj)
{
if (obj == null)
{
obj = new JObject();
}
List<JToken> list = jobj.ToList<JToken>();
if (jobj.Type == JTokenType.Object)//非数组
{
List<string> listsort = new List<string>();
foreach (var item in list)
{
string name = JProperty.Load(item.CreateReader()).Name;
listsort.Add(name);
}
listsort.Sort();
List<JToken> listTemp = new List<JToken>();
foreach (var item in listsort)
{
listTemp.Add(list.Where(p => JProperty.Load(p.CreateReader()).Name == item).FirstOrDefault());
}
list = listTemp;
//list.Sort((p1, p2) => JProperty.Load(p1.CreateReader()).Name.GetAnsi() - JProperty.Load(p2.CreateReader()).Name.GetAnsi());
foreach (var item in list)
{
JProperty jp = JProperty.Load(item.CreateReader());
if (item.First.Type == JTokenType.Object)
{
JObject sub = new JObject();
(obj as JObject).Add(jp.Name, sub);
SortJson(item.First, sub);
}
else if (item.First.Type == JTokenType.Array)
{
JArray arr = new JArray();
if (obj.Type == JTokenType.Object)
{
(obj as JObject).Add(jp.Name, arr);
}
else if (obj.Type == JTokenType.Array)
{
(obj as JArray).Add(arr);
}
SortJson(item.First, arr);
}
else if (item.First.Type != JTokenType.Object && item.First.Type != JTokenType.Array)
{
(obj as JObject).Add(jp.Name, item.First);
}
}
}
else if (jobj.Type == JTokenType.Array)//数组
{
foreach (var item in list)
{
List<JToken> listToken = item.ToList<JToken>();
List<string> listsort = new List<string>();
foreach (var im in listToken)
{
string name = JProperty.Load(im.CreateReader()).Name;
listsort.Add(name);
}
listsort.Sort();
List<JToken> listTemp = new List<JToken>();
foreach (var im2 in listsort)
{
listTemp.Add(listToken.Where(p => JProperty.Load(p.CreateReader()).Name == im2).FirstOrDefault());
}
list = listTemp;
listToken = list;
// listToken.Sort((p1, p2) => JProperty.Load(p1.CreateReader()).Name.GetAnsi() - JProperty.Load(p2.CreateReader()).Name.GetAnsi());
JObject item_obj = new JObject();
foreach (var token in listToken)
{
JProperty jp = JProperty.Load(token.CreateReader());
if (token.First.Type == JTokenType.Object)
{
JObject sub = new JObject();
(obj as JObject).Add(jp.Name, sub);
SortJson(token.First, sub);
}
else if (token.First.Type == JTokenType.Array)
{
JArray arr = new JArray();
if (obj.Type == JTokenType.Object)
{
(obj as JObject).Add(jp.Name, arr);
}
else if (obj.Type == JTokenType.Array)
{
(obj as JArray).Add(arr);
}
SortJson(token.First, arr);
}
else if (item.First.Type != JTokenType.Object && item.First.Type != JTokenType.Array)
{
if (obj.Type == JTokenType.Object)
{
(obj as JObject).Add(jp.Name, token.First);
}
else if (obj.Type == JTokenType.Array)
{
item_obj.Add(jp.Name, token.First);
}
}
}
if (obj.Type == JTokenType.Array)
{
(obj as JArray).Add(item_obj);
}
}
}
string ret = obj.ToString();
return ret;
}
}
}

@ -85,6 +85,19 @@ namespace djy.Model.IsfDto
public bool? IsDel { get; set; }
/// <summary>
/// 申报状态
/// </summary>
public string ReportState { get; set; }
/// <summary>
/// 匹配状态
/// </summary>
public string MateState { get; set; }
/// <summary>
/// 最新通知
/// </summary>
public string NewNotice { get; set; }
public List<ISF_Company> companyList { get; set; }
public List<ISF_MasterHistory> HistoryDto { get; set; }

@ -48,11 +48,11 @@ namespace djy.Service.Ams
}
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)
.WhereIf(req.MBLNO != null, x => req.MBLNO.Contains(x.MBLNO))
.WhereIf(req.ReportState != null, x =>ReportStates.Contains(x.ReportState))
.WhereIf(req.PORTDISCHARGECode!=null,x=>x.PORTDISCHARGECode==req.PORTDISCHARGECode)
.WhereIf(req.LoadingPortCode != null, x => x.LoadingPortCode == req.LoadingPortCode)
.WhereIf(req.UserName!=null,x=>x.UserName==req.UserName)
.WhereIf(req.UserName!=null,x=> req.UserName.Contains(x.UserName) )
.WhereIf(req.CARRIERID != null, x =>req.CARRIERID==x.CARRIERID)
.WhereIf(req.BDate!=null,x=>x.CreateTime>=req.BDate)
.WhereIf(req.EDate!=null,x=>x.CreateTime<=req.EDate);
@ -252,31 +252,30 @@ namespace djy.Service.Ams
return req;
}
if (docType == "AMSAR" || docType == "AMSDOC")
{
var getfinrs = fin.Expend(new CustFee
{
SENDUSERID = userid,
LURURENID = userid,
CtnrCount = 1,
CtnrInfo = string.Empty,
BSTYPE = 15,
SENDTYPE = 0,
BSNO = oid.ToString(),
MBLNO = master.MBLNO.ToString(),
}
, 0);
if (!getfinrs.Status)
{
req.Code = 200;
req.Message = getfinrs.Message;
return req;
}
}
//if (docType == "AMSAR" || docType == "AMSDOC")
//{
// var getfinrs = fin.Expend(new CustFee
// {
// SENDUSERID = userid,
// LURURENID = userid,
// CtnrCount = 1,
// CtnrInfo = string.Empty,
// BSTYPE = 15,
// SENDTYPE = 0,
// BSNO = oid.ToString(),
// MBLNO = master.MBLNO.ToString(),
// }
// , 0);
// if (!getfinrs.Status)
// {
// req.Code = 200;
// req.Message = getfinrs.Message;
// return req;
// }
//}
var cARRIERIDList = DbBus.Get(DbList.Common).Select<MappingCarrier>().Where(map => map.Module == "AMS").ToList();
var portList = DbBus.Get(DbList.Common).Select<CodePort>().ToList();
var CodePortLoadList = DbBus.Get(DbList.Common).Select<CodePortLoad>().ToList();
var containerTypeList = DbBus.Get(DbList.Common).Select<MappingCtn>().Where(map => map.Module == "AMS").ToList();
var packageList = DbBus.Get(DbList.Common).Select<MappingPackage>().Where(map => map.Module == "AMS").ToList();
MasterBillInfoDto dto = new MasterBillInfoDto();
@ -408,14 +407,16 @@ namespace djy.Service.Ams
dic.Add("sign", sign);
dic.Add("docLength", docContent.ToString().Length.ToString());
#region 接口调用
_LogsAdd("SendDE", "post", $"AMS接口调用发送{dic}");
_LogsAdd("SendDE", "post", $"AMS接口调用地址{url.PARAMVALUE}");
_LogsAdd("SendDE", "post", $"timestamp{timestamp}");
_LogsAdd("SendDE", "post", $"AMS接口调用发送{oid}{ JsonConvert.SerializeObject(dic)}");
_LogsAdd("SendDE", "post", $"AMS接口调用地址{oid}{url.PARAMVALUE}");
string gethtml = await HttpHelp.Post(dic, url.PARAMVALUE, PsotType.Urlencoded);
_LogsAdd("SendDE", "post", $"AMS接口调用返回{gethtml}");
_LogsAdd("SendDE", "post", $"AMS接口调用返回{oid}{gethtml}");
if (gethtml != null)
{
JObject rlt = JObject.Parse(gethtml);
var code = rlt.GetValue("code").ToString();
var msg = rlt.GetValue("msg").ToString();
if (code == "F")
{
@ -445,8 +446,11 @@ namespace djy.Service.Ams
}
history.Operator = user.SHOWNAME;
history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "发送单据";
history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "发送单据失败,失败原因:"+ msg;
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
req.Code = 200;
req.Message = "操作失败,"+ msg;
return req;
}
if (code == "T")
{
@ -541,9 +545,6 @@ namespace djy.Service.Ams
}
public Response SaveReceipt(string msg)
{
Response req = new Response();
@ -615,8 +616,6 @@ namespace djy.Service.Ams
}
/// <summary>
/// 根据日期生成14位随机数
/// </summary>
@ -822,7 +821,9 @@ namespace djy.Service.Ams
{
Document document = new Document(PageSize.A4);
//指定字体文件IDENTITY_H支持中文
BaseFont customfont = BaseFont.CreateFont(@"C:\Windows\Fonts\MSYH.TTC,0", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
var path = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "msyh.ttc,0");
_LogsAdd("PDF", "Get", $"PDF字体路径{path }");
BaseFont customfont = BaseFont.CreateFont(path, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
var Fonttable = new Font(customfont, 12);
Font font = new Font(customfont, 14);
Font datefont = new Font(customfont, 9);
@ -845,7 +846,7 @@ namespace djy.Service.Ams
document.Add(new Paragraph("\r"));//换行
PdfPTable table = new PdfPTable(2); //生成只有2列的行数据
table.DefaultCell.Border = Rectangle.NO_BORDER; //无边框
table.DefaultCell.MinimumHeight = 40f; //高度
table.DefaultCell.MinimumHeight = 50f; //高度
float[] widths = new float[] { 100f,200f }; //宽度
table.SetWidths(widths);
@ -903,8 +904,8 @@ namespace djy.Service.Ams
document.Add(new Paragraph("\r"));//换行
Image image = Image.GetInstance(@"F:\DJY.Ams\djyweb_ams\ams\djy.WebApi\logo.png");
var imgpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logo.png");
Image image = Image.GetInstance(imgpath);
image.ScalePercent(10f);
//设置图片的宽高
image.ScaleAbsolute(180f, 66f);
@ -965,11 +966,11 @@ namespace djy.Service.Ams
{
try
{
var List = DbBus.Get(DbList.Common).Select<AMS_AddrTemplate>().
var List = DbBus.Get(DbList.AMSCenter).Select<AMS_AddrTemplate>().
Where(x => x.IsDel == false || x.IsDel == null).
WhereIf(companyid != "", x => x.CompID == companyid).
WhereIf(type != "", x => x.Type == type).
WhereIf(TemPlateName != "", x => TemPlateName.Contains(x.TemPlateName)).
WhereIf(companyid != null, x => x.CompID == companyid).
WhereIf(type != null, x => x.Type == type).
WhereIf(TemPlateName != null, x => TemPlateName.Contains(x.TemPlateName)).
ToList();
return List;
}

@ -28,8 +28,10 @@ namespace djy.Service.ISF
ReportStates = req.ReportState.Split(',');
}
var dto = DbBus.Get(DbList.AMSCenter).Select<ISF_Master>().Where(x => (x.IsDel == false || x.IsDel == null) && x.CompID == user.CompId)
.WhereIf(req.MBLNO != null, x => x.MBLNO == req.MBLNO).WhereIf(req.InFoType != null, x => x.InFoType==req.InFoType).
var dto = DbBus.Get(DbList.AMSCenter).Select<ISF_Master>().
Where(x => (x.IsDel == false || x.IsDel == null) && x.CompID == user.CompId).
WhereIf(req.MBLNO != null,x=> req.MBLNO.Contains(x.MBLNO)).
WhereIf(req.InFoType != null, x => x.InFoType==req.InFoType).
WhereIf(req.ReportState != null, x => ReportStates.Contains(x.ReportState)); ;
result.count = dto.ToList().Count();
var list = dto.Page(req.Page, req.Limit).ToList<ISFDto>();
@ -46,7 +48,6 @@ namespace djy.Service.ISF
result.data = list;
return result;
}
#endregion
#region 新增编辑
@ -171,12 +172,12 @@ namespace djy.Service.ISF
{
try
{
var List = DbBus.Get(DbList.Common).Select<ISF_CompanyTemplate>().
var List = DbBus.Get(DbList.AMSCenter).Select<ISF_CompanyTemplate>().
Where(x=> x.IsDel == false || x.IsDel == null).
WhereIf(companyid != "", x => x.CompID==companyid).
WhereIf(CompanyType != "", x => x.CompanyType == CompanyType).
WhereIf(InFoType != "", x => x.InFoType == InFoType).
WhereIf(TemPlateName != "", x => TemPlateName.Contains(x.TemPlateName)).
WhereIf(companyid !=null, x => x.CompID==companyid).
WhereIf(CompanyType != null, x => x.CompanyType == CompanyType).
WhereIf(InFoType != null, x => x.InFoType == InFoType).
WhereIf(TemPlateName != null, x => TemPlateName.Contains(x.TemPlateName)).
ToList();
return List;
}
@ -212,17 +213,83 @@ namespace djy.Service.ISF
return guid;
}
#endregion
#region 第三方接口
public Task<Response> SendDE(string Gid, string userid, string msgType)
public async Task<Response> SendDE(string Gid, string userid, string msgType)
{
throw new NotImplementedException();
}
Response req = new Response();
try
{
string[] id = Gid.Split(',');
var user = DbBus.Get(DbList.djydb).Select<User>().Where(w => w.GID == userid).ToOne();
foreach (string oid in id)
{
if (oid != "")
{
var fin = new FinanceService();
var master = DbBus.Get(DbList.AMSCenter).Select<ISF_Master>().Where(x => (x.IsDel == false || x.IsDel == null) && x.CompID == user.CompId && x.GID == oid).ToOne();
if (msgType != "3")
{
if (msgType == "4" && !(master.ReportState == "已删除" || master.MateState == "匹配失败"))
{
req.Code = 200;
req.Message = "当前状态不能重发!如有疑问,请联系相关客服!";
return req;
}
if (msgType == "1" || msgType == "4")
{
///扣费接口
var getfinrs = fin.Expend(new CustFee
{
SENDUSERID = userid,
LURURENID = userid,
CtnrCount = 1,
CtnrInfo = string.Empty,
BSTYPE = 16,
SENDTYPE = 0,
BSNO = oid.ToString(),
MBLNO = master.MBLNO.ToString(),
}
, 0);
if (!getfinrs.Status)
{
req.Code = 200;
req.Message = getfinrs.Message;
return req;
}
}
var portList = DbBus.Get(DbList.Common).Select<CodePort>().ToList();
var CodePortLoadList = DbBus.Get(DbList.Common).Select<CodePortLoad>().ToList();
Info info = new Info();
info.masterBillNo = master.MBLNO;
info.infoType = master.InFoType;
info.dischargeHarbourCode = portList.Where(x => x.Code == master.DischargeHarbourCode).Select(x => x.EdiCode).FirstOrDefault();
info.deliveryHarbourCode = portList.Where(x => x.Code == master.DeliveryHarbourCode).Select(x => x.EdiCode).FirstOrDefault();
}
}
}
return req;
}
catch (Exception ex)
{
req.Code = 500;
req.Message = ex.InnerException?.Message ?? ex.Message;
_LogsAdd("SendDE", "post", $"ISF_SendDE接口{req.Message }");
return req;
}
}
#endregion
}
}
}

@ -22,42 +22,46 @@ namespace djy_AmsApi.Controllers
{
AmsService ser =new AmsService();
#region 查询接口
[HttpGet("Load")]
public object Load([FromQuery] AMSQuery request)
{
if (GetLoginId == null)
{
var result = new Response();
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
return ser.Load(request, GetLoginId.ToString());
}
#endregion
#region 新增/编辑
[HttpPost("AddOrUpdate")]
public Response AddOrUpdate(AMSDto Dto)
{
var result = new Response();
//if (GetLoginId == null)
//{
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
//}
if (GetLoginId == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
}
if (Dto == null)
{
result.Code = 500;
result.Message = "无效数据!";
}
result.data=ser.SaveInfo(Dto, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
return result;
}
#endregion
#region 查询接口
[HttpGet("Load")]
public object Load([FromQuery] AMSQuery request)
{
//if (GetLoginId == null)
//{
// var result = new Response();
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
// return result;
//}
return ser.Load(request, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
result.data = ser.SaveInfo(Dto, GetLoginId.ToString());
return result;
}
#endregion
#region 删除
/// <summary>
/// 删除接口
@ -94,14 +98,14 @@ namespace djy_AmsApi.Controllers
public async Task<Response> Send(string ids, string docType)
{
Response req = new Response();
//if (GetLoginId == null)
//{
// var result = new Response();
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
// return result;
//}
var result = ser.SendDE(ids, "d85fd590-d9f6-4410-93a1-f6fac77b606e", docType);
if (GetLoginId == null)
{
req.Code = 401;
req.Message = "登录过期,请重新登录!";
return req;
}
var result = ser.SendDE(ids, GetLoginId.ToString(), docType);
req.Code = result.Result.Code;
req.Message = result.Result.Message;
return req;
@ -352,33 +356,33 @@ namespace djy_AmsApi.Controllers
result.Message = "登录过期,请重新登录!";
return result;
}
result.Result = ser.GetTemplate("9f3b3526-4dd4-4997-b974-1f2adb2793c7", type, TemPlateName);
result.Result = ser.GetTemplate(GetLoginCompId, type, TemPlateName);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
#endregion
#region 保存模板
[HttpPost("SaveTemplate")]
public Response SaveTemplate(AMS_AddrTemplate Dto)
{
var result = new Response();
//if (GetLoginId == null)
//{
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
//}
if (GetLoginId == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
}
if (Dto == null)
{
result.Code = 500;
result.Message = "无效数据!";
}
result.data = ser.SaveTemplate(Dto, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
result.data = ser.SaveTemplate(Dto, GetLoginId.ToString());
return result;
}

@ -20,14 +20,15 @@ namespace djy_AmsApi.Controllers.ISF
[HttpGet("Load")]
public object Load([FromQuery] ISFQuery request)
{
//if (GetLoginId == null)
//{
// var result = new Response();
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
// return result;
//}
return ser.Load(request, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
if (GetLoginId == null)
{
var result = new Response();
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
return ser.Load(request, GetLoginId.ToString());
}
#endregion
@ -36,17 +37,18 @@ namespace djy_AmsApi.Controllers.ISF
public Response AddOrUpdate(ISFDto Dto)
{
var result = new Response();
//if (GetLoginId == null)
//{
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
//}
if (GetLoginId == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
}
if (Dto == null)
{
result.Code = 500;
result.Message = "无效数据!";
}
result.data = ser.SaveInfo(Dto, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
result.data = ser.SaveInfo(Dto, GetLoginId.ToString());
return result;
}
@ -70,6 +72,7 @@ namespace djy_AmsApi.Controllers.ISF
result.Message = "登录过期,请重新登录!";
return result;
}
ser.Delete(ids, GetLoginId.ToString());
}
@ -96,7 +99,7 @@ namespace djy_AmsApi.Controllers.ISF
result.Message = "登录过期,请重新登录!";
return result;
}
result.Result = ser.GetTemplate("9f3b3526-4dd4-4997-b974-1f2adb2793c7", CompanyType, InFoType, TemPlateName);
result.Result = ser.GetTemplate(GetLoginCompId, CompanyType, InFoType, TemPlateName);
}
catch (Exception ex)
{
@ -118,17 +121,18 @@ namespace djy_AmsApi.Controllers.ISF
public Response SaveTemplate(ISF_CompanyTemplate Dto)
{
var result = new Response();
//if (GetLoginId == null)
//{
// result.Code = 401;
// result.Message = "登录过期,请重新登录!";
//}
if (GetLoginId == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
}
if (Dto == null)
{
result.Code = 500;
result.Message = "无效数据!";
}
result.data = ser.SaveTemplate(Dto, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
result.data = ser.SaveTemplate(Dto, GetLoginId.ToString());
return result;
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save