wet 2 years ago
parent 63ac82c327
commit fb71cf143f

@ -1,4 +1,6 @@
using Common.Entity; using Common.Entity;
using System;
namespace djy.Model.IsfDto namespace djy.Model.IsfDto
{ {
public class ISFQuery : PageEntity public class ISFQuery : PageEntity
@ -15,5 +17,12 @@ namespace djy.Model.IsfDto
/// 申报状态 /// 申报状态
/// </summary> /// </summary>
public string ReportState { get; set; } public string ReportState { get; set; }
public DateTime? BDate { get; set; }
public DateTime? EDate { get; set; }
/// <summary>
/// 操作人
/// </summary>
public string UserName { get; set; }
} }
} }

@ -48,7 +48,6 @@ namespace djy.Model.IsfDto
/// </summary> /// </summary>
public string shipmentTypeCode { get; set; } public string shipmentTypeCode { get; set; }
} }
public class CompanyList public class CompanyList
{ {
/// <summary> /// <summary>
@ -110,8 +109,8 @@ namespace djy.Model.IsfDto
public class IsfInfo public class IsfInfo
{ {
public List<CompanyList> companyList { get; set; } //public List<CompanyList> companyList { get; set; }
public object companyList { get; set; }
public string format { get; set; } public string format { get; set; }
public Info info { get; set; } public Info info { get; set; }

@ -234,9 +234,9 @@ namespace djy.Service.DjyService
/// </summary> /// </summary>
public void _LogsClear() public void _LogsClear()
{ //删除10天前的并收缩logs日志数据库文件 { //删除10天前的并收缩logs日志数据库文件
var delcount = DbBus.Get(DbList.Logsdb).Delete<tb_sys_Logs>().Where(w => w.AddTime < DateTime.Now.AddDays(-7).ToTimeStamp()).ExecuteAffrows(); //var delcount = DbBus.Get(DbList.Logsdb).Delete<tb_sys_Logs>().Where(w => w.AddTime < DateTime.Now.AddDays(-7).ToTimeStamp()).ExecuteAffrows();
var dbcc = DbBus.Get(DbList.Logsdb).Ado.ExecuteNonQuery("DBCC SHRINKFILE (N'djy_logs_log' , 1, TRUNCATEONLY)"); //var dbcc = DbBus.Get(DbList.Logsdb).Ado.ExecuteNonQuery("DBCC SHRINKFILE (N'djy_logs_log' , 1, TRUNCATEONLY)");
_LogsAdd("del Logs :" + delcount + "行", "logs", new { delcount, dbcc }, null); //_LogsAdd("del Logs :" + delcount + "行", "logs", new { delcount, dbcc }, null);
} }

@ -36,7 +36,10 @@ namespace djy.Service.Isf
WhereIf(req.InFoType != null, x => x.InFoType == req.InFoType). WhereIf(req.InFoType != null, x => x.InFoType == req.InFoType).
WhereIf(req.ReportState != null && req.ReportState != "0" && req.ReportState != "1", x => ReportStates.Contains(x.ReportState)). WhereIf(req.ReportState != null && req.ReportState != "0" && req.ReportState != "1", x => ReportStates.Contains(x.ReportState)).
WhereIf(req.ReportState == "0", x => x.ReportState == "未申报" || x.ReportState == "删单成功" || x.ReportState == "接收失败"). WhereIf(req.ReportState == "0", x => x.ReportState == "未申报" || x.ReportState == "删单成功" || x.ReportState == "接收失败").
WhereIf(req.ReportState == "1", x => !(x.ReportState == "未申报" || x.ReportState == "删单成功" || x.ReportState == "接收失败")); WhereIf(req.ReportState == "1", x => !(x.ReportState == "未申报" || x.ReportState == "删单成功" || x.ReportState == "接收失败"))
.WhereIf(req.UserName != null, x => x.UserName.Contains(req.UserName.Trim()))
.WhereIf(req.BDate != null, x => x.CreateTime >= req.BDate)
.WhereIf(req.EDate != null, x => x.CreateTime <= req.EDate).OrderByDescending(x => x.CreateTime); ;
result.count = dto.ToList().Count(); result.count = dto.ToList().Count();
var list = dto.Page(req.Page, req.Limit).ToList<ISFDto>(); var list = dto.Page(req.Page, req.Limit).ToList<ISFDto>();
if (list != null) if (list != null)
@ -59,7 +62,7 @@ namespace djy.Service.Isf
public string SaveInfo(ISFDto dto, User user) public string SaveInfo(ISFDto dto, User user)
{ {
string guid = ""; string guid = "";
var mlist = DbBus.Get(DbList.AMSCenter).Select<ISF_Master>().Where(x => x.IsDel != true && x.MBLNO == dto.MBLNO && x.GID != dto.GID&&x.MBLNO!="").ToOne(); var mlist = DbBus.Get(DbList.AMSCenter).Select<ISF_Master>().Where(x => x.IsDel != true && x.MBLNO == dto.MBLNO && x.GID != dto.GID && x.MBLNO != "").ToOne();
if (mlist != null) if (mlist != null)
{ {
return "-1"; return "-1";
@ -218,7 +221,7 @@ namespace djy.Service.Isf
{ {
string guid = ""; string guid = "";
var list = DbBus.Get(DbList.AMSCenter).Select<ISF_CompanyTemplate>().Where(w => w.UserID == user.GID && w.TemPlateName == dto.TemPlateName && w.CompanyType == dto.CompanyType && w.InFoType == dto.InFoType && w.GID != dto.GID).ToOne(); var list = DbBus.Get(DbList.AMSCenter).Select<ISF_CompanyTemplate>().Where(w => w.UserID == user.GID && w.TemPlateName == dto.TemPlateName && w.CompanyType == dto.CompanyType && w.InFoType == dto.InFoType && w.GID != dto.GID).ToOne();
if (list!=null) if (list != null)
{ {
return "-1"; return "-1";
} }
@ -267,8 +270,12 @@ namespace djy.Service.Isf
var fin = new FinanceService(); 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(); 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();
var comlist = DbBus.Get(DbList.AMSCenter).Select<ISF_Company>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == oid).ToList(); var comlist = DbBus.Get(DbList.AMSCenter).Select<ISF_Company>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == oid).ToList();
if (msgType != "3") if (msgType == "3"&& master.ReportState == "删单成功")
{ {
req.Code = 201;
req.Message = "已删除单据不可以再次删除";
return req;
}
if (msgType == "4" && !(master.ReportState == "已删除" || master.MateState == "匹配失败")) if (msgType == "4" && !(master.ReportState == "已删除" || master.MateState == "匹配失败"))
{ {
@ -276,28 +283,28 @@ namespace djy.Service.Isf
req.Message = "当前状态不能重发!如有疑问,请联系相关客服!"; req.Message = "当前状态不能重发!如有疑问,请联系相关客服!";
return req; return req;
} }
if (msgType == "1" || msgType == "4") //if (msgType == "1" || msgType == "4")
{ //{
///扣费接口 // ///扣费接口
var getfinrs = fin.Expend(new CustFee // var getfinrs = fin.Expend(new CustFee
{ // {
SENDUSERID = user.GID, // SENDUSERID = user.GID,
LURURENID = user.GID, // LURURENID = user.GID,
CtnrCount = 1, // CtnrCount = 1,
CtnrInfo = string.Empty, // CtnrInfo = string.Empty,
BSTYPE = 16, // BSTYPE = 16,
SENDTYPE = 0, // SENDTYPE = 0,
BSNO = oid.ToString(), // BSNO = oid.ToString(),
MBLNO = master.MBLNO.ToString(), // MBLNO = master.MBLNO.ToString(),
} // }
, 0); // , 0);
if (!getfinrs.Status) // if (!getfinrs.Status)
{ // {
req.Code = 201; // req.Code = 201;
req.Message = getfinrs.Message; // req.Message = getfinrs.Message;
return req; // return req;
} // }
} //}
var portList = DbBus.Get(DbList.Common).Select<CodePort>().ToList(); var portList = DbBus.Get(DbList.Common).Select<CodePort>().ToList();
var CodePortLoadList = DbBus.Get(DbList.Common).Select<CodePortLoad>().ToList(); var CodePortLoadList = DbBus.Get(DbList.Common).Select<CodePortLoad>().ToList();
Info info = new Info(); Info info = new Info();
@ -307,41 +314,74 @@ namespace djy.Service.Isf
info.deliveryHarbourCode = portList.Where(x => x.Code == master.DeliveryHarbourCode).Select(x => x.EdiCode).FirstOrDefault(); info.deliveryHarbourCode = portList.Where(x => x.Code == master.DeliveryHarbourCode).Select(x => x.EdiCode).FirstOrDefault();
info.shipmentTypeCode = master.ShipmentTypeCode; info.shipmentTypeCode = master.ShipmentTypeCode;
info.hstCode = master.HstCode; info.hstCode = master.HstCode;
info.blTypeCode = master.BlTypeCode; info.blTypeCode = master.BlTypeCode;
info.refId = master.GID; info.refId = master.GID;
List<CompanyList> companyList = new List<CompanyList>();
//List<CompanyList> companyList = new List<CompanyList>();
JArray arr = new JArray();
foreach (var item in comlist) foreach (var item in comlist)
{ {
companyList.Add(new CompanyList JObject obj = new JObject();
{
companyType = item.CompanyType, if (!item.Address.IsNullOrEmpty())
companyName = item.CompanyName, obj.Add("address", new JValue($"{item.Address}"));
idTypeCode = item.IdTypeCode, if (!item.City.IsNullOrEmpty())
companyId=item.CompanyId, obj.Add("city", new JValue($"{item.City}"));
address = item.Address, if (!item.CompanyId.IsNullOrEmpty())
city = item.City, obj.Add("companyId", new JValue($"{item.CompanyId}"));
province = item.Province, if (!item.CompanyName.IsNullOrEmpty())
provinceCode = item.ProvinceCode, obj.Add("companyName", new JValue($"{item.CompanyName}"));
countryCode = item.ProvinceCode, if (!item.CompanyType.IsNullOrEmpty())
postcode = item.PostCode, obj.Add("companyType", new JValue($"{item.CompanyType}"));
hstCode = item.HstCode, if (!item.CountryCode.IsNullOrEmpty())
obj.Add("countryCode", new JValue($"{item.CountryCode}"));
}); if (!item.HstCode.IsNullOrEmpty())
obj.Add("hstCode", new JValue($"{item.HstCode}"));
if (!item.IdTypeCode.IsNullOrEmpty())
obj.Add("idTypeCode", new JValue($"{item.IdTypeCode}"));
if (!item.PostCode.IsNullOrEmpty())
obj.Add("postCode", new JValue($"{item.PostCode}"));
if (!item.Province.IsNullOrEmpty())
obj.Add("province", new JValue($"{item.Province}"));
if (!item.ProvinceCode.IsNullOrEmpty())
obj.Add("provinceCode", new JValue($"{item.ProvinceCode}"));
arr.Add(obj);
//companyList.Add(new CompanyList
//{
// companyType = item.CompanyType,
// companyName = item.CompanyName,
// idTypeCode = item.IdTypeCode,
// companyId = item.CompanyId,
// address = item.Address,
// city = item.City,
// province = item.Province,
// provinceCode = item.ProvinceCode,
// countryCode = item.CountryCode,
// postcode = item.PostCode,
// hstCode = item.HstCode,
//});
} }
var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var AMSAccount = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AMSAccount").ToOne(); var AMSAccount = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AMSAccount").ToOne();
var method = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "ISFMethod").ToOne(); var method = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "ISFMethod").ToOne();
var key = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AMSKEY").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 url = DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AMSURL").ToOne();
///////MD5加密
//string stringSign = string.Format("companyList={0}&format=json&info={1}&method={2}&msgType={3}&timestamp={4}&user_id={5}&version=2.0&key={6}",
//JsonConvert.SerializeObject(arr), JsonConvert.SerializeObject(info), method.PARAMVALUE, Convert.ToInt32(msgType), timestamp, AMSAccount.PARAMVALUE, key.PARAMVALUE);
//string sign = stringSign.ToMd5().ToUpper();
/////MD5加密 /////MD5加密
string stringSign = string.Format("companyList={0}&format=json&info={1}&method={2}&msgType={3}&timestamp={4}&user_id={5}&version=2.0&key={6}", string stringSign = string.Format("{0}{1}{2}", AMSAccount.PARAMVALUE, key.PARAMVALUE, timestamp);
JsonConvert.SerializeObject(companyList), JsonConvert.SerializeObject(info), method.PARAMVALUE, Convert.ToInt32(msgType), timestamp, AMSAccount.PARAMVALUE, key.PARAMVALUE); string sign = stringSign.ToMd5();
string sign = stringSign.ToMd5().ToUpper();
///post参数 ///post参数
IsfInfo isfinfo = new IsfInfo(); IsfInfo isfinfo = new IsfInfo();
isfinfo.companyList = companyList; isfinfo.companyList = arr;
isfinfo.format = "json"; isfinfo.format = "json";
isfinfo.info = info; isfinfo.info = info;
isfinfo.method = method.PARAMVALUE; isfinfo.method = method.PARAMVALUE;
@ -349,7 +389,7 @@ namespace djy.Service.Isf
isfinfo.user_id = AMSAccount.PARAMVALUE; isfinfo.user_id = AMSAccount.PARAMVALUE;
isfinfo.sign = sign; isfinfo.sign = sign;
isfinfo.timestamp = timestamp; isfinfo.timestamp = timestamp;
isfinfo.version = "2.0"; isfinfo.version = "1.0";
isfinfo.format = "json"; isfinfo.format = "json";
string json = JsonConvert.SerializeObject(isfinfo); string json = JsonConvert.SerializeObject(isfinfo);
_LogsAdd("SendDE", "post", $"ISF接口调用发送{oid}{json}"); _LogsAdd("SendDE", "post", $"ISF接口调用发送{oid}{json}");
@ -360,11 +400,8 @@ namespace djy.Service.Isf
JObject rlt = JObject.Parse(gethtml); JObject rlt = JObject.Parse(gethtml);
var code = rlt.GetValue("code").ToString(); var code = rlt.GetValue("code").ToString();
var msg = rlt.GetValue("msg").ToString(); var msg = rlt.GetValue("msg").ToString();
var data = rlt.GetValue("data").ToString();
JObject drlt = JObject.Parse(data); if (code == "F")
var result = drlt.GetValue("code").ToString();
var errorInfo = drlt.GetValue("msg").ToString();
if (code == "F" || result != "1")
{ {
ISF_MasterHistory history = new ISF_MasterHistory(); ISF_MasterHistory history = new ISF_MasterHistory();
@ -396,12 +433,52 @@ namespace djy.Service.Isf
history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "发送单据失败,失败原因:" + msg; history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "发送单据失败,失败原因:" + msg;
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
req.Code = 201; req.Code = 201;
req.Message = "操作失败," + msg + errorInfo; req.Message = "操作失败," + msg ;
return req; return req;
} }
if (code == "T" && result == "1") if (code == "T")
{ {
ISF_MasterHistory history = new ISF_MasterHistory(); ISF_MasterHistory history = new ISF_MasterHistory();
var data = rlt.GetValue("data").ToString();
JObject drlt = JObject.Parse(data);
var result = drlt.GetValue("code").ToString();
var errorInfo = drlt.GetValue("msg").ToString();
if (result!="1") {
history.GID = Guid.NewGuid().ToString("N");
history.ISF_ID = oid;
history.SendTime = DateTime.Now;
if (msgType == "1")
{
history.State = "新增发送失败";
history.Type = "接收失败";
}
else if (msgType == "4")
{
history.State = "重发失败";
history.Type = "接收失败";
}
else if (msgType == "2")
{
history.State = "修改发送失败";
history.Type = "修改失败";
}
else
{
history.State = "删除发送失败";
history.Type = "删单失败";
}
history.Operator = user.SHOWNAME;
history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "发送单据失败,失败原因:" + msg;
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
req.Code = 201;
req.Message = "操作失败," + msg+errorInfo;
return req;
}
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.ISF_ID = oid; history.ISF_ID = oid;
history.SendTime = DateTime.Now; history.SendTime = DateTime.Now;
@ -475,7 +552,7 @@ namespace djy.Service.Isf
} }
} }
} }
}
} }
return req; return req;
} }
@ -555,7 +632,7 @@ namespace djy.Service.Isf
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows();
} }
else if (retdto.status == "SB"|| retdto.status == "S2" || retdto.status == "S3" || retdto.status == "S4" || retdto.status == "S5" || retdto.status == "S6") else if (retdto.status == "SB" || retdto.status == "S2" || retdto.status == "S3" || retdto.status == "S4" || retdto.status == "S5" || retdto.status == "S6")
{ {
ISF_MasterHistory history = new ISF_MasterHistory(); ISF_MasterHistory history = new ISF_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");

@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<_PublishTargetUrl>F:\DJY.AMS\web\djy_IsfApi\bin\Release\net5.0\publish\</_PublishTargetUrl> <_PublishTargetUrl>F:\DJY.AMS\web\djy_IsfApi\bin\Release\net5.0\publish\</_PublishTargetUrl>
<History>True|2022-07-04T01:35:17.7702978Z;True|2022-07-01T17:41:17.1936764+08:00;True|2022-07-01T17:32:54.2967210+08:00;True|2022-07-01T16:13:16.7902814+08:00;True|2022-07-01T15:53:11.0569260+08:00;True|2022-07-01T09:54:42.5780181+08:00;True|2022-06-30T15:28:48.8212173+08:00;True|2022-06-30T15:07:27.8048719+08:00;True|2022-06-30T14:23:02.1357807+08:00;True|2022-06-30T14:07:07.8696769+08:00;True|2022-06-30T09:14:19.1360602+08:00;True|2022-06-29T16:34:08.2367476+08:00;</History> <History>True|2022-07-04T09:29:37.9437422Z;True|2022-07-04T11:51:52.2386090+08:00;True|2022-07-04T11:51:11.4558393+08:00;True|2022-07-04T09:35:17.7702978+08:00;True|2022-07-01T17:41:17.1936764+08:00;True|2022-07-01T17:32:54.2967210+08:00;True|2022-07-01T16:13:16.7902814+08:00;True|2022-07-01T15:53:11.0569260+08:00;True|2022-07-01T09:54:42.5780181+08:00;True|2022-06-30T15:28:48.8212173+08:00;True|2022-06-30T15:07:27.8048719+08:00;True|2022-06-30T14:23:02.1357807+08:00;True|2022-06-30T14:07:07.8696769+08:00;True|2022-06-30T09:14:19.1360602+08:00;True|2022-06-29T16:34:08.2367476+08:00;</History>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>

Loading…
Cancel
Save