diff --git a/ds-wms-service/DS.Module.Core/Enums/WebCodeEnum.cs b/ds-wms-service/DS.Module.Core/Enums/WebCodeEnum.cs
new file mode 100644
index 00000000..ffde8714
--- /dev/null
+++ b/ds-wms-service/DS.Module.Core/Enums/WebCodeEnum.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.Module.Core.Enums
+{
+ ///
+ /// 调用爬虫网站时的WebCode参数类型
+ ///
+ public enum WebCodeEnum
+ {
+ [Description("场站编码")]
+ YARD = 11,
+
+
+ [Description("互联网+(定时任务)")]
+ HLW_CD = 21,
+
+ //[Description("互联网主单回执")]
+ //HLW_ZH = 22,
+
+ //[Description("互联网分单回执")]
+ //HLW_FD = 23,
+
+
+ [Description("单船单票(可查页面)")]
+ YGT = 31,
+ //[Description("云港通运综(定时任务上传该代号)")]
+ //YGT_YZ = 32,
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/WebDataReq.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/WebDataReq.cs
new file mode 100644
index 00000000..18e6458e
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/WebDataReq.cs
@@ -0,0 +1,33 @@
+using DS.Module.Core.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.WMS.Core.Op.Dtos
+{
+ ///
+ ///
+ ///
+ public class WebDataReq
+ {
+ ///
+ /// 提单号
+ ///
+ public string MBLNO { get; set; }
+
+ /////
+ ///// 场站代码
+ /////
+ //public string YardCode { get; set; }
+
+
+ ///
+ /// 场站Id
+ ///
+ public long YardId { get; set; }
+
+ public WebCodeEnum WebCode { get; set; }
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs
index 7d24828c..1c02ef89 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs
@@ -226,4 +226,12 @@ public interface ISeaExportService
/// 业务Id
///
public Task>> GetSeaExportLogList(string id);
+
+ ///
+ /// 获取订舱记录在指定网站的HTML数据
+ ///
+ /// 业务Id
+ /// 网站编码;值为YARD或HLW_CD或YGT;YARD:获取订舱记录所属场站的网页数据;HLW_CD:获取互联网+的网页数据;YGT:获取云港通的网页数据
+ ///
+ public Task> GetWebData(string id, string webCode);
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportYardService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportYardService.cs
index f5d73f36..c181460b 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportYardService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportYardService.cs
@@ -1,4 +1,5 @@
using DS.Module.Core;
+using DS.Module.Core.Enums;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.WMS.Core.Code.Entity;
@@ -9,6 +10,7 @@ using DS.WMS.Core.Sys.Entity;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.OpenXmlFormats;
+using SqlSugar;
namespace DS.WMS.Core.Op.Method
{
@@ -46,6 +48,48 @@ namespace DS.WMS.Core.Op.Method
}
return await Task.FromResult(DataResult.Success(JsonConvert.SerializeObject(data.Data)));
}
+
+ ///
+ /// 获取订舱记录在指定网站的HTML数据
+ ///
+ /// 业务Id
+ /// 网站编码;值为YARD或HLW_CD或YGT;YARD:获取订舱记录所属场站的网页数据;HLW_CD:获取互联网+的网页数据;YGT:获取云港通的网页数据
+ ///
+ public async Task> GetWebData(string id, string webCode)
+ {
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+ var order = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First();
+
+ if (order.IsNull())
+ {
+ return await Task.FromResult(DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist));
+ }
+ if (string.IsNullOrEmpty(order.Yard) || order.YardId == 0 || order.YardId.IsNull())
+ {
+ return await Task.FromResult(DataResult.Failed("请先选择场站!", MultiLanguageConst.SeaExportNotExist));
+ }
+ WebCodeEnum codeEnum = webCode switch
+ {
+ "YARD" => WebCodeEnum.YARD,
+ "HLW_CD" => WebCodeEnum.HLW_CD,
+ "YGT" => WebCodeEnum.YGT,
+ _ => throw new Exception("webCode参数错误!")
+ };
+
+ var data = await GetWebData(new WebDataReq() {
+ MBLNO = order.MBLNO,
+ YardId = order.YardId,
+ WebCode = codeEnum,
+ });
+
+ if (!data.Succeeded)
+ {
+ return await Task.FromResult(DataResult.Failed(data.Message));
+
+ }
+ return await Task.FromResult(DataResult.Success(JsonConvert.SerializeObject(data.Data)));
+ }
+
///
/// 从爬虫获取场站数据,并映射为系统中的箱型
///
@@ -164,6 +208,127 @@ namespace DS.WMS.Core.Op.Method
return await Task.FromResult(DataResult.Success(rtnData));
}
}
+
+ ///
+ /// 异步调取网站HTML数据
+ ///
+ ///
+ ///
+ public async Task> GetWebData(WebDataReq req)
+ {
+
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+ //var account = seaComService.GetCodeThirdParty("BillTrace", user.UserId, tenantDb, req.YardId);
+ //tenantDb.Queryable().Where(x => x.CustomerId == req.YardId && x.AccountType == "BillTrace").First();
+
+ var userKey = db.Queryable().Filter(null, true).Where(x => x.Code == "spiderUserKeyBilltrace" && x.TenantId == 1288018625843826688).First().Value;
+ var userSecret = db.Queryable().Filter(null, true).Where(x => x.Code == "spiderUserSecretBilltrace" && x.TenantId == 1288018625843826688).First().Value;
+ var spiderServerUrl = db.Queryable().Filter(null, true).Where(x => x.Code == "spiderServerUrlBillTraceNew" && x.TenantId == 1288018625843826688).First().Value;
+ var tenantName = db.Queryable().Filter(null, true).Where(x => x.Id == long.Parse(user.TenantId)).First().Name;
+ //if (account.IsNull())
+ //{
+ // return await Task.FromResult(DataResult.Failed("未配置出口运踪场站第三方账号信息!"));
+ //}
+ var webAcc = "";
+ var webPwd = "";
+ var newWebCode = "";
+ if (req.WebCode == WebCodeEnum.YARD)
+ {
+ var yardCode = seaComService.GetClientCode(req.YardId, tenantDb);
+
+ var needYgtAccountList = db.Queryable().InnerJoin((a, b) => a.TypeId == b.Id)
+ .Where((a, b) => b.Code == "YardListNeedYgtAccount").OrderBy((a, b) => a.OrderNo)
+ .Select().ToList();
+
+ var needLhtAccountList = db.Queryable().InnerJoin((a, b) => a.TypeId == b.Id)
+ .Where((a, b) => b.Code == "YardListNeedLhtAccount").OrderBy((a, b) => a.OrderNo)
+ .Select().ToList();
+
+ if (needYgtAccountList.Count(x => x.Value == yardCode) > 0)
+ {
+ var ygtAcc = seaComService.GetCodeThirdParty("YunGangTong", user.UserId, tenantDb);
+
+ if (ygtAcc == null || string.IsNullOrEmpty(ygtAcc.AppKey) || string.IsNullOrEmpty(ygtAcc.AppSecret))
+ {
+ return await Task.FromResult(DataResult.Failed("未找到云港通账号、密码配置,请到第三方账号中添加!"));
+ }
+
+ webAcc = ygtAcc.AppKey;
+ webPwd = ygtAcc.AppSecret;
+ }
+ else if (needLhtAccountList.Count(x => x.Value == yardCode) > 0)
+ {
+ var lhtAcc = seaComService.GetCodeThirdParty("LuHaiTong", user.UserId, tenantDb);
+
+ if (lhtAcc == null || string.IsNullOrEmpty(lhtAcc.AppKey) || string.IsNullOrEmpty(lhtAcc.AppSecret))
+ {
+ return await Task.FromResult(DataResult.Failed("未找到陆海通账号、密码配置,请到第三方账号中添加!"));
+ }
+
+ webAcc = lhtAcc.AppKey;
+ webPwd = lhtAcc.AppSecret;
+ }
+ else {
+ var account = seaComService.GetCodeThirdParty("BillTrace", user.UserId, tenantDb);
+ if (account.IsNull())
+ {
+ return await Task.FromResult(DataResult.Failed("未配置出口运踪场站第三方账号信息!"));
+ }
+ webAcc = account.AppKey;
+ webAcc = account.AppSecret;
+ }
+
+ var yardMap = tenantDb.Queryable().Where(x => x.LinkId == req.YardId && x.Module == "BillTrace").First();
+ if (yardMap.IsNull())
+ {
+ return await Task.FromResult(DataResult.Failed($"场站代号配置未找到:{yardCode}"));
+ }
+ newWebCode = yardMap.MapCode;
+ }
+ else
+ {
+ newWebCode = req.WebCode.ToString();
+ }
+
+
+ var objSend = new
+ {
+ user_key = userKey,
+ user_secret = userSecret,
+ customer_id = user.TenantId,
+ customer_name = tenantName,
+ web_code = newWebCode,
+ bno = req.MBLNO,
+ req_type = "1" ,
+ web_user = webAcc,
+ web_psw = webPwd,
+ };
+ var urlYard = spiderServerUrl;
+ if (!urlYard.EndsWith("/"))
+ {
+ urlYard += "/";
+ }
+
+ urlYard += "real/query";
+
+ var res = RequestHelper.Post(JsonConvert.SerializeObject(objSend), urlYard);
+ var rtnObj = JObject.Parse(res);
+ if (rtnObj.GetIntValue("code") != 200)
+ {
+ return await Task.FromResult(DataResult.Failed("获取场站数据失败:" + rtnObj.GetStringValue("msg")));
+ }
+ else
+ {
+ var rtnData = rtnObj.GetStringValue("data");
+
+ var viewstatehtml = GetDataHtmlList(rtnData, "__VIEWSTATE", "/>");
+ if (viewstatehtml != "")
+ {
+ rtnData = rtnData.Replace(viewstatehtml, "");
+ }
+ return await Task.FromResult(DataResult.Success(rtnData));
+ }
+ }
public static string GetDataHtmlList(string html, string startstr, string endstr)
{
var subhtml = html;
diff --git a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs
index 6ac60537..c66c1f37 100644
--- a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs
+++ b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs
@@ -164,7 +164,18 @@ public class SeaExportController : ApiController
return await _invokeService.GetYardData(id, isWeb);
}
-
+ ///
+ /// 获取订舱记录在指定网站的HTML数据
+ ///
+ /// 业务Id
+ /// 网站编码;值为YARD或HLW_CD或YGT;YARD:获取订舱记录所属场站的网页数据;HLW_CD:获取互联网+的网页数据;YGT:获取云港通的网页数据
+ ///
+ [HttpGet]
+ [Route("GetWebData")]
+ public async Task> GetWebData([FromQuery] string id, string webCode)
+ {
+ return await _invokeService.GetWebData(id, webCode);
+ }
///
/// 发起运踪订阅或者更新提单号
///