From f47a7ee9a230acbef83d09c762af830fff8f02a1 Mon Sep 17 00:00:00 2001 From: ddlucky Date: Fri, 10 Mar 2023 17:44:43 +0800 Subject: [PATCH] 20230310-2 --- DSWeb/Areas/CommMng/DAL/PublicPortHelper.cs | 697 ++++++++++++++++++ .../MvcShipping/DAL/MsOpSeae/MsOpSeaeDAL.cs | 289 ++++---- .../MsSysThirdParthAccountDAL.cs | 5 + .../SysThirdPartyAccount.cs | 11 + .../Viewsjs/MsOpSeae/MsOpSeaeIndex.js | 44 +- 5 files changed, 877 insertions(+), 169 deletions(-) create mode 100644 DSWeb/Areas/CommMng/DAL/PublicPortHelper.cs diff --git a/DSWeb/Areas/CommMng/DAL/PublicPortHelper.cs b/DSWeb/Areas/CommMng/DAL/PublicPortHelper.cs new file mode 100644 index 00000000..83fc5a76 --- /dev/null +++ b/DSWeb/Areas/CommMng/DAL/PublicPortHelper.cs @@ -0,0 +1,697 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Text; +using Microsoft.Practices.EnterpriseLibrary.Data; +using System.Globalization; +using System.Data; +using DSWeb.MvcShipping.DAL.MsCodeCtnEdi; +using DSWeb.MvcShipping.Models.MsOpSeae; +using DSWeb.MvcShipping.Models.MsChFee; +using DSWeb.MvcShipping.DAL.MsChFeeDAL; +using HcUtility.Comm; +using DSWeb.Areas.MvcShipping.Comm; +using DSWeb.MvcShipping.Helper; +using DSWeb.MvcShipping.DAL.MsSysThirdPartyAccount; +using DSWeb.Common.DB; + +namespace DSWeb.Areas.CommMng.DAL +{ + public class PortSendHelper { + + public string URL { get; set; } + public string logname { get; set; } + + public string userid { get; set; } + public string infoclient_carrier { get; set; }//该业务相关的船公司的info_client.shortname + + public object sendobj { get; set; } + + public void MakeMessage() + { + + } + public DBResult DoSend(int timeout= 5000) { + var result = new DBResult(); + try + { + var strSendObj = JsonConvert.Serialize(sendobj); + BasicDataRefDAL.SaveLog(strSendObj, "", logname, "发送"); + var rtn = WebRequestHelper.DoPost(URL, strSendObj, timeout: 50000); + BasicDataRefDAL.SaveLog(rtn, "", logname, "返回"); + result.OK("", rtn); + } + catch(Exception ex) + { + result.SetErrorInfo(ex.Message); + return result; + } + //"{\"status\":1,\"message\":\"ok\",\"data\":{\"message\":\"无效的参考号/没有运动可用:140201003313\",\"infos\":[]}}" + + /*"infos": [ + { + "bkgno": "ESLCHNQGA2044855", + "blno": "EPIRCHNQGA230635", + "eta": "", + "origin": "QINGDAO, CHINA", + "delivery": "PENANG, MALAYSIA", + "container": [ + { + "contno": "FCIU3466878", + "latestact": "EMPTY GATED IN AT DEPOT", + "actloc": "PENANG, MALAYSIA", + "conttype": "DV20", + "actdate": "19-Jan-2023" + } + ] + }, + { + "bkgno": "ESLCHNQGA2045659", + "blno": "EPIRCHNQGA230922", + "eta": "", + "origin": "QINGDAO, CHINA", + "delivery": "SOHAR, OMAN", + "container": [ + { + "contno": "CLHU8968063", + "latestact": "EMPTY GATED IN AT DEPOT", + "actloc": "SOHAR, OMAN", + "conttype": "HC40", + "actdate": "15-Feb-2023" + }, + { + "contno": "ESDU4074261", + "latestact": "EMPTY GATED IN AT DEPOT", + "actloc": "SOHAR, OMAN", + "conttype": "HC40", + "actdate": "15-Feb-2023" + } + ] + } + ]*/ + + result = DoDeal(result.Data.ToString()); + + return result; + } + + public virtual DBResult DoDeal(string rtn) { + var result = new DBResult(); + return result; + } + } + + #region 港联顺相关类和方法 + public class GLSFEEHead + { + public string key { get; set; } + public string mbl { get; set; } + public string vessel { get; set; } + public string voyage { get; set; } + public string placeStart { get; set; } + public string placeEnd { get; set; } + public string etd { get; set; } + public string cartonInfo { get; set; } + public string goodsName { get; set; } + public string number { get; set; } = "0"; + public string grossWeight { get; set; } = "0"; + public string volume { get; set; } = "0"; + public string remark { get; set; } + public List billInfoList { get; set; } = new List(); + + public GLSFEEHead() { } + public GLSFEEHead(MsOpSeae head, string userid, string username, string companyid) + { + var CUSTOMERNAME = ""; + var CUSTOMERNAMEInfo = MsCodeCtnEdiDAL.GetCustList($" EDINAME='GLSFEE'"); + if (CUSTOMERNAMEInfo != null && CUSTOMERNAMEInfo.Count > 0) + { + CUSTOMERNAME = CUSTOMERNAMEInfo[0].CTN; + } + + var chfeeCondition = $" CUSTOMERNAME='{CUSTOMERNAME}' and BSNO='{head.BSNO}' and not exists(select 1 from OP_LOGICINFO where BSNO=ch_fee.GID and PROPNAME='港联顺费用推送') "; + var 应收费用List = MsChFeeDAL.GetDataList(chfeeCondition + " and feetype=1 ", 1, "op_seae", userid, username, companyid); + var 应付费用List = MsChFeeDAL.GetDataList(chfeeCondition + " and feetype=2 ", 2, "op_seae", userid, username, companyid); + + var feenamedic = MsCodeCtnEdiDAL.GetFeeNameDicByName("GLSFEE"); + + mbl = head.MBLNO; + vessel = head.VESSEL; + voyage = head.VOYNO; + placeStart = head.PORTLOAD; + placeEnd = head.DESTINATION; + etd = head.ETD; + cartonInfo = head.CNTRTOTAL; + goodsName = head.GOODSNAME; + number = head.PKGS; + grossWeight = head.KGS; + volume = head.CBM; + billInfoList = new List(); + if (应收费用List != null && 应收费用List.Count > 0) + { + foreach (var item in 应收费用List) + { + var newfee = new GLSFEE(item, feenamedic); + billInfoList.Add(newfee); + } + } + if (应付费用List != null && 应付费用List.Count > 0) + { + foreach (var item in 应付费用List) + { + var newfee = new GLSFEE(item, feenamedic); + billInfoList.Add(newfee); + } + } + } + public List getFeeInfo() + { + var result = new List(); + if (billInfoList != null && billInfoList.Count > 0) + { + foreach (var item in billInfoList) + { + var newrec = new GLSFEEINFO(this); + //newrec.CUSTOMERNAME = CUSTOMERNAME; + newrec.GID = item.GID; + newrec.FEENAME = item.feeItem; + newrec.FEETYPEREF = item.feeType; + newrec.AMOUNT = item.totalPrice; + newrec.CURRENT = item.currency; + result.Add(newrec); + } + } + return result; + } + } + + public class GLSFEE + { + public string feeType { get; set; } + public string feeItem { get; set; } + public string FEENAME { get; set; } + public string GID { get; set; } + public string currency { get; set; } + public decimal? quantity { get; set; } + public string unit { get; set; } + public decimal? unitPrice { get; set; } + public decimal? totalPrice { get; set; } + public string remark { get; set; } + + public GLSFEE() { } + + public GLSFEE(MsChFee chfee, Dictionary feenamedic) + { + if (chfee.FeeType == 1) feeType = "R"; + if (chfee.FeeType == 2) feeType = "P"; + FEENAME = chfee.FeeName; + GID = chfee.GId; + if (feenamedic.ContainsKey(chfee.FeeName)) + { + feeItem = feenamedic[chfee.FeeName]; + } + else + { + //feeItem = ""; + //改为不强制要求设置费用名称 未设置的使用原名称 + feeItem = chfee.FeeName; + } + currency = chfee.Currency; + quantity = chfee.Quantity; + unit = chfee.Unit; + unitPrice = chfee.TaxUnitPrice; + totalPrice = chfee.Amount; + } + } + + public class GLSFEEINFO + { + public string GID { get; set; } + public string MBLNO { get; set; } + public string VESSEL { get; set; } + public string VOYNO { get; set; } + public string DESTINATION { get; set; } + public string ETD { get; set; } + public string FEENAME { get; set; } + public string FEETYPEREF { get; set; } + public decimal? AMOUNT { get; set; } + public string CURRENT { get; set; } + + public GLSFEEINFO() { } + + public GLSFEEINFO(GLSFEEHead feehead) + { + MBLNO = feehead.mbl; + VESSEL = feehead.vessel; + VOYNO = feehead.voyage; + ETD = feehead.etd; + DESTINATION = feehead.placeEnd; + } + } + + #endregion + + #region ESL相关类 + + public class ESLPortParam_Send + { + public string u { get; set; }//用户名 + public string p { get; set; }//密码 + + public object data { get; set; } + } + public class ESLPortParam + { + public string u { get; set; }//用户名 + public string p { get; set; }//密码 + + public string userid { get; set; } + public string carrier { get; set; } + + + public DBResult SetUserPassword(string _userid, string _carrier) { + userid = _userid; + carrier = _carrier; + var result = new DBResult(); + var thirdaccount= MsSysThirdPartyAccountDAL.GetDataByCustomername(userid, carrier); + if (!thirdaccount.HaveAccount()) + { + result.SetErrorInfo($"您没有在第三方账号密码管理中设置【{carrier}】的账号和密码"); + } + else { + u = thirdaccount.ACCOUNT; + p = thirdaccount.ACCOUNTPSW; + result.OK(); + } + return result; + } + + public virtual ESLPortParam_Send getSendParam() { + var result = new ESLPortParam_Send(); + result.u = u; + result.p = p; + return result; + } + } + public class ESLPortResult + { + public int? status { get; set; } + public string message { get; set; } + virtual public object data { get; set; } + } + public class ESLPortParam_ETA : ESLPortParam + { + public List data { get; set; } + + public ESLPortParam_Send getSendParam() { + var result = new ESLPortParam_Send(); + result.u = u; + result.p = p; + result.data = JsonConvert.Serialize(data); + return result; + } + } + public class ESLPortParam_GetMblnoBySO : ESLPortParam + { + public string so_no { get; set; } + } + public class ESLPortParam_GetEP : ESLPortParam + { + public string esl_code { get; set; } + } + public class ESLPortParam_Draft : ESLPortParam + { + public string ep_code { get; set; } + public string op_email { get; set; } + } + + public class ESLPortResult_ETA : ESLPortResult + { + public class etainfo + { + public string bkgno { get; set; } + public string blno { get; set; } + public string eta { get; set; } + public string origin { get; set; } + public string delivery { get; set; } + public List container { get; set; } + } + public class etacontainer + { + public string contno { get; set; } + public string latestact { get; set; } + public string actloc { get; set; } + public string conttype { get; set; } + public string actdate { get; set; } + } + public class etadata + { + public string message { get; set; } + public List infos { get; set; } + + } + public etadata data { get; set; } + } + public class ESLPortResult_GetMblnoBySO : ESLPortResult + { + public class draftdata + { + public string esl_no { get; set; } + public string ref_no { get; set; } + public string bk_no { get; set; } + public string pol { get; set; } + public string pod { get; set; } + public string pol_etd { get; set; } + public string bl_status { get; set; } + public string container_no { get; set; } + public string new_activity { get; set; } + public string teus { get; set; } + + } + public draftdata data { get; set; } + } + public class ESLPortResult_GetEP: ESLPortResult + { + public class draftdata + { + public string status { get; set; } + public string bk_no { get; set; } + public string bk_status { get; set; } + public string ep_code { get; set; } + } + public draftdata data { get; set; } + } + public class ESLPortResult_Draft: ESLPortResult + { + public class draftdata + { + public string abs_path { get; set; } + public string api_path { get; set; } + } + public draftdata data { get; set; } + } + + + + public class ESLPort_ETA : PortSendHelper { + private List headList { get; set; } + public ESLPortParam_ETA sendparam { get; set; } + public ESLPort_ETA(string userid,string CARRIER) { + URL = "http://118.190.106.151:10011/bill_track_search/"; + logname = "ESL货运追踪接口"; + infoclient_carrier= CARRIER; + sendparam = new ESLPortParam_ETA(); + this.userid = userid; + } + public DBResult MakeMessage(List _headList) { + var result = new DBResult(); + headList = _headList; + try { + result= sendparam.SetUserPassword(userid, infoclient_carrier); + + if (!result.Success) return result; + + //向data赋值 + var MBLNOList = headList.Select(s=>s.MBLNO).Distinct().ToList(); + sendparam.data = MBLNOList; + + sendobj = sendparam; + result.OK(); + } + catch(Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + override public DBResult DoDeal(string rtn) + { + var result = new DBResult(); + + var _r = JsonConvert.Deserialize(rtn); + try + { + if (_r.status == 1 && _r.data.infos.Count > 0) + { + //更新这些业务的ETA + + foreach (var item in _r.data.infos) { + + var eta = item.eta; + + if (string.IsNullOrWhiteSpace(eta)) { + continue; + } + + var bsnos = headList.Where(x => x.MBLNO.ToUpper() == item.bkgno.ToUpper()).Select(s => s.BSNO).ToList(); + + var bsnostr ="'"+ string.Join("','", bsnos)+"'"; + + var sqlstr = $" update op_seae set ETA='{eta}' where bsno in({bsnostr})"; + + BasicDataRefDAL.ExecSql(sqlstr); + } + + result.OK("获取成功!"); + } + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + } + + public class ESLPort_GetMblnoBySO : PortSendHelper + { + private MsOpSeae head { get; set; } + public ESLPortParam_GetMblnoBySO sendparam { get; set; } + public ESLPort_GetMblnoBySO(string userid, string CARRIER) + { + URL = "http://118.190.106.151:10011/so_search/"; + logname = "ESL货运追踪接口"; + infoclient_carrier = CARRIER; + sendparam = new ESLPortParam_GetMblnoBySO(); + this.userid = userid; + } + public DBResult MakeMessage(MsOpSeae _head) + { + var result = new DBResult(); + head = _head; + try + { + result = sendparam.SetUserPassword(userid, infoclient_carrier); + + if (!result.Success) return result; + + sendparam.so_no = head.MBLNO; + + sendobj = sendparam; + result.OK(); + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + override public DBResult DoDeal(string rtn) + { + var result = new DBResult(); + + var _r = JsonConvert.Deserialize(rtn); + try + { + if (_r.status == 1 && !string.IsNullOrWhiteSpace( _r.data.esl_no)) + { + //更新so号 + + //如ref_no=当前mblno, 将当前的mblno移动至申请放箱号APPLYNO,并将esl_no写入mblno; + + if(head.MBLNO== _r.data.ref_no) + + { + + var bsnostr = $"'{head.BSNO}'"; + + var sqlstr = $" update op_seae set MBLNO='{_r.data.esl_no}',APPLYNO='{_r.data.ref_no}' where bsno =({bsnostr})"; + + BasicDataRefDAL.ExecSql(sqlstr); + + } + + } + result.OK($"舱位号获取成功:[{_r.data.esl_no}]"); + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + } + public class ESLPort_GetEP : PortSendHelper + { + private MsOpSeae head { get; set; } + public ESLPortParam_GetEP sendparam { get; set; } + public ESLPort_GetEP(string userid, string CARRIER) + { + URL = "http://118.190.106.151:10011/ep_search/"; + logname = "ESL货运追踪接口"; + infoclient_carrier = CARRIER; + sendparam = new ESLPortParam_GetEP(); + this.userid = userid; + } + public DBResult MakeMessage(MsOpSeae _head) + { + var result = new DBResult(); + head = _head; + try + { + result = sendparam.SetUserPassword(userid, infoclient_carrier); + + if (!result.Success) return result; + + sendparam.esl_code = head.MBLNO; + + sendobj = sendparam; + result.OK(); + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + override public DBResult DoDeal(string rtn) + { + var result = new DBResult(); + + var _r = JsonConvert.Deserialize(rtn); + try + { + if (_r.status == 1 && !string.IsNullOrWhiteSpace(_r.data.ep_code)) + { + //更新so号 + + //如ref_no=当前mblno, 将当前的mblno移动至申请放箱号APPLYNO,并将esl_no写入mblno; + + if (head.MBLNO == _r.data.bk_no) + + { + var dic = new Dictionary + { + { "EPCODE", _r.data.ep_code } + }; + + BasicDataRefDAL.SaveLogicInfo(head.BSNO, "ESL", dic); + result.OK(_r.data.ep_code, _r.data.ep_code); + } + + } + else { + result.SetErrorInfo("还没有产生EP号"); + } + + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + } + public class ESLPort_Draft : PortSendHelper + { + private MsOpSeae head { get; set; } + public ESLPortParam_Draft sendparam { get; set; } + public ESLPort_Draft(string userid, string CARRIER) + { + URL = "http://118.190.106.151:10011/draft_download/"; + logname = "ESL货运追踪接口"; + infoclient_carrier = CARRIER; + sendparam = new ESLPortParam_Draft(); + this.userid = userid; + } + public DBResult MakeMessage(MsOpSeae _head) + { + var result = new DBResult(); + head = _head; + try + { + result = sendparam.SetUserPassword(userid, infoclient_carrier); + + if (!result.Success) return result; + + var esllogic = BasicDataRefDAL.GetLogicInfo(head.BSNO, "ESL"); + var epcode = ""; + if (esllogic.ContainsKey("EPCODE")) { + epcode = esllogic["EPCODE"]; + } + + sendparam.ep_code = epcode; + var cdc = new CommonDataContext(); + var userinfo = cdc.VW_user.First(x => x.USERID == userid); + sendparam.op_email= userinfo.EMAIL1; + + if (string.IsNullOrWhiteSpace(userinfo.EMAIL1)) { + result.SetErrorInfo("必须要设置自己的邮箱地址由于接受"); + return result; + } + + sendobj = sendparam; + result.OK(""); + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + override public DBResult DoDeal(string rtn) + { + var result = new DBResult(); + + var _r = JsonConvert.Deserialize(rtn); + try + { + if (_r.status == 1) + { + //更新so号 + + //如ref_no=当前mblno, 将当前的mblno移动至申请放箱号APPLYNO,并将esl_no写入mblno; + + if (!string.IsNullOrWhiteSpace(_r.data.api_path)) + + { + + var cdc = new CommonDataContext(); + + var oldrecList = cdc.Receipt_Doc.Where(x => x.BSNO == head.BSNO && x.Driect_URL == _r.data.api_path).ToList(); + + if (oldrecList == null || oldrecList.Count == 0) { + + var newreceipt = new Receipt_Doc_md(head.BSNO); + newreceipt.Driect_URL = _r.data.api_path; + newreceipt.URL = "DRAFT.pdf"; + newreceipt.RECEIPTTYPE = "DRAFT"; + cdc.Receipt_Doc.Add(newreceipt); + cdc.SaveChanges(); + } + } + + } + result.OK("发送成功"); + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + return result; + } + } + + #endregion +} \ No newline at end of file diff --git a/DSWeb/Areas/MvcShipping/DAL/MsOpSeae/MsOpSeaeDAL.cs b/DSWeb/Areas/MvcShipping/DAL/MsOpSeae/MsOpSeaeDAL.cs index a62620cb..2dfce743 100644 --- a/DSWeb/Areas/MvcShipping/DAL/MsOpSeae/MsOpSeaeDAL.cs +++ b/DSWeb/Areas/MvcShipping/DAL/MsOpSeae/MsOpSeaeDAL.cs @@ -7928,16 +7928,17 @@ namespace DSWeb.MvcShipping.DAL.MsOpSeaeDAL foreach (var item in GLSFeelist) { //清除掉未选中的费用; - for (var i = item.billInfoList.Count - 1; i < 0; i--) { - var fee = item.billInfoList[i]; - if (feeidList.Contains(fee.GID)) - { + //20230310 对方依据GID记录费用唯一代码,重发后更新,故不用记录是否已发送 + //for (var i = item.billInfoList.Count - 1; i < 0; i--) { + // var fee = item.billInfoList[i]; + // if (feeidList.Contains(fee.GID)) + // { - } - else { - item.billInfoList.RemoveAt(i); - } - } + // } + // else { + // item.billInfoList.RemoveAt(i); + // } + //} item.key = key; var strSendObj = JsonConvert.Serialize(item); @@ -7947,17 +7948,20 @@ namespace DSWeb.MvcShipping.DAL.MsOpSeaeDAL var rtn = WebRequestHelper.DoPost(url, strSendObj, timeout: 50000); BasicDataRefDAL.SaveLog(rtn, "", "港联顺费用推送", "返回"); //log.Debug($"发送vgm返回:{rtn}"); - var jobjRtn = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(rtn, new { code = "0", subCode = false, msg = string.Empty, ok = true, data = string.Empty }); + + //rtn = "{\"code\":\"200\",\"subCode\":\"0\",\"msg\":\"操作成功!\",\"ok\":true,\"returndata\":null}"; + + var jobjRtn = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(rtn, new { code = "0", subCode = "", msg = string.Empty, ok = true, data = string.Empty }); if (!jobjRtn.ok) { return result.SetErrorInfo($"港联顺费用推送错误:{jobjRtn.code + ":" + jobjRtn.msg}"); } else { //记录chfee发送结果 - foreach (var fee in item.billInfoList) { - BasicDataRefDAL.SaveLogicInfo(fee.GID, "港联顺费用推送"); - } - + //20230310 对方依据GID记录费用唯一代码,重发后更新,故不用记录是否已发送 + //foreach (var fee in item.billInfoList) { + // BasicDataRefDAL.SaveLogicInfo(fee.GID, "港联顺费用推送"); + //} } result.OK("发送完成"); @@ -7980,23 +7984,67 @@ namespace DSWeb.MvcShipping.DAL.MsOpSeaeDAL // result.SetErrorInfo($"未在第三方账号信息中配置船公司【{order.CARRIER}】的网站账号、密码(第三方账号每人维护各自信息,客户名称需选择船公司,第三方软件为【船公司账号】)"); //} + var headList = GetDataList($" BSNO in({BSNO})", userid, username, copmpanyid); + var carrier = ""; + var cando = ESL_CANDO(headList); + if (!cando.Success) + { + return cando; + } + else { + carrier = cando.Data.ToString(); + } + try { if (WORKTYPE == "ETA") - { - + { //查询到港时间 + + + + return ESL_ETA(headList, userid, carrier); } //舱位分配查询 if (WORKTYPE == "CWFPCX") { + return ESL_GetMblnoBySO(headList, userid, carrier); } //格式单批量接收 - if (WORKTYPE == "ETA") - { - + if (WORKTYPE == "DRAFT") + { + var eplist = new List(); + var draftlist = new List(); + foreach (var head in headList) { + //首先看logicinfo中有没有ep号 如果有 直接使用 如果没有 读取后使用返回值 + var epcode = ""; + var logicinfo = BasicDataRefDAL.GetLogicInfo(head.BSNO, "ESL"); + if (logicinfo.ContainsKey("EPCODE")) { + epcode = logicinfo["EPCODE"]; + } + if (string.IsNullOrWhiteSpace(epcode)) + { + eplist.Add(head); + } + else { + draftlist.Add(head); + } + } + if (eplist.Count > 0) + { + result = ESL_GetEP(eplist, userid, carrier); + if (!result.Success) return result; + result = ESL_GetDraft(eplist, userid, carrier); + if (!result.Success) return result; + } + if (draftlist.Count > 0) + { + result = ESL_GetDraft(draftlist, userid, carrier); + if (!result.Success) return result; + } + return result; } } catch (Exception e) @@ -8007,156 +8055,103 @@ namespace DSWeb.MvcShipping.DAL.MsOpSeaeDAL return result; } - private static DBResult ESL_CANDO(string WORKTYPE, string BSNO, string userid, string username, string copmpanyid) + private static DBResult ESL_CANDO(List headList) { var result = new DBResult(); - //看 + var cdc = new CommonDataContext(); + var ESL = cdc.info_client.Where(x => x.EDICODE == "ESL" ).ToList(); + if (ESL == null || ESL.Count == 0) { + result.SetErrorInfo("选择实际代表ESL(阿联酋航运)的往来单位,将其EDICODE改写为 ESL,然后再次尝试。"); + return result; + } + + var infoclient_ESL = ESL[0]; + + //看这些业务是否满足执行ESL相关接口的条件 + foreach (var item in headList) { + if (item.CARRIER != infoclient_ESL.SHORTNAME) + { + result.SetErrorInfo("只有船公司为ESL的业务可以执行该操作。"); + return result; + } + else { + result.OK("", item.CARRIER); + //result.Data = item.CARRIER; + } + } return result; } - } + public static DBResult ESL_ETA(List _headList, string userid,string carrier) { + var result = new DBResult(); + - public class GLSFEEHead - { - public string key { get; set; } - public string mbl { get; set; } - public string vessel { get; set; } - public string voyage { get; set; } - public string placeStart { get; set; } - public string placeEnd { get; set; } - public string etd { get; set; } - public string cartonInfo { get; set; } - public string goodsName { get; set; } - public string number { get; set; } = "0"; - public string grossWeight { get; set; } = "0"; - public string volume { get; set; } = "0"; - public string remark { get; set; } - public List billInfoList { get; set; } = new List(); - - public GLSFEEHead() { } - public GLSFEEHead(MsOpSeae head,string userid,string username,string companyid) + + ESLPort_ETA ETASender = new ESLPort_ETA(userid, carrier); + + result = ETASender.MakeMessage( _headList); + + if (!result.Success) return result; + result = ETASender.DoSend(120000); + + + return result; + } + + public static DBResult ESL_GetMblnoBySO(List _headList, string userid, string carrier) { - var CUSTOMERNAME = ""; - var CUSTOMERNAMEInfo= MsCodeCtnEdiDAL.GetCustList($" EDINAME='GLSFEE'"); - if (CUSTOMERNAMEInfo != null && CUSTOMERNAMEInfo.Count > 0) { - CUSTOMERNAME = CUSTOMERNAMEInfo[0].CTN; - } + var result = new DBResult(); - var chfeeCondition = $" CUSTOMERNAME='{CUSTOMERNAME}' and BSNO='{head.BSNO}' and not exists(select 1 from OP_LOGICINFO where BSNO=ch_fee.GID and PROPNAME='港联顺费用推送') "; - var 应收费用List = MsChFeeDAL.MsChFeeDAL.GetDataList(chfeeCondition + " and feetype=1 ", 1, "op_seae", userid, username, companyid); - var 应付费用List = MsChFeeDAL.MsChFeeDAL.GetDataList(chfeeCondition + " and feetype=2 ", 2, "op_seae", userid, username, companyid); + foreach (var head in _headList) { - var feenamedic = MsCodeCtnEdiDAL.GetFeeNameDicByName("GLSFEE"); + ESLPort_GetMblnoBySO SoNumSender = new ESLPort_GetMblnoBySO(userid, carrier); - mbl = head.MBLNO; - vessel = head.VESSEL; - voyage = head.VOYNO; - placeStart = head.PORTLOAD; - placeEnd = head.DESTINATION; - etd = head.ETD; - cartonInfo = head.CNTRTOTAL; - goodsName = head.GOODSNAME; - number = head.PKGS; - grossWeight = head.KGS; - volume = head.CBM; - billInfoList=new List(); - if (应收费用List != null && 应收费用List.Count > 0) - { - foreach (var item in 应收费用List) { - var newfee = new GLSFEE(item, feenamedic); - billInfoList.Add(newfee); - } - } - if (应付费用List != null && 应付费用List.Count > 0) - { - foreach (var item in 应付费用List) - { - var newfee = new GLSFEE(item, feenamedic); - billInfoList.Add(newfee); - } + result = SoNumSender.MakeMessage(head); + + if (!result.Success) return result; + result = SoNumSender.DoSend(120000); } + + return result; } - public List getFeeInfo() { - var result = new List(); - if (billInfoList!=null && billInfoList.Count>0) + + public static DBResult ESL_GetEP(List _headList, string userid, string carrier) + { + var result = new DBResult(); + + foreach (var head in _headList) { - foreach (var item in billInfoList) { - var newrec = new GLSFEEINFO(this); - //newrec.CUSTOMERNAME = CUSTOMERNAME; - newrec.GID = item.GID; - newrec.FEENAME = item.feeItem; - newrec.FEETYPEREF = item.feeType; - newrec.AMOUNT = item.totalPrice; - newrec.CURRENT = item.currency; - result.Add(newrec); - } + + ESLPort_GetEP SoNumSender = new ESLPort_GetEP(userid, carrier); + + result = SoNumSender.MakeMessage(head); + + if (!result.Success) return result; + result = SoNumSender.DoSend(120000); } - return result; + + return result; } - } - public class GLSFEE - { - public string feeType { get; set; } - public string feeItem { get; set; } - public string FEENAME { get; set; } - public string GID { get; set; } - public string currency { get; set; } - public decimal? quantity { get; set; } - public string unit { get; set; } - public decimal? unitPrice { get; set; } - public decimal? totalPrice { get; set; } - public string remark { get; set; } - - public GLSFEE() { } - - public GLSFEE(MsChFee chfee, Dictionary feenamedic) + public static DBResult ESL_GetDraft(List _headList, string userid, string carrier) { - if (chfee.FeeType == 1) feeType = "R"; - if (chfee.FeeType == 2) feeType = "P"; - FEENAME = chfee.FeeName; - GID = chfee.GId; - if (feenamedic.ContainsKey(chfee.FeeName)) + var result = new DBResult(); + + foreach (var head in _headList) { - feeItem = feenamedic[chfee.FeeName]; + + ESLPort_Draft Sender = new ESLPort_Draft(userid, carrier); + + result = Sender.MakeMessage(head); + + if (!result.Success) return result; + result = Sender.DoSend(120000); } - else { - //feeItem = ""; - //改为不强制要求设置费用名称 未设置的使用原名称 - feeItem = chfee.FeeName; - } - currency=chfee.Currency; - quantity = chfee.Quantity; - unit = chfee.Unit; - unitPrice = chfee.TaxUnitPrice; - totalPrice = chfee.Amount; - } - } - public class GLSFEEINFO - { - public string GID { get; set; } - public string MBLNO { get; set; } - public string VESSEL { get; set; } - public string VOYNO { get; set; } - public string DESTINATION { get; set; } - public string ETD { get; set; } - public string FEENAME { get; set; } - public string FEETYPEREF { get; set; } - public decimal? AMOUNT { get; set; } - public string CURRENT { get; set; } - - public GLSFEEINFO() { } - - public GLSFEEINFO(GLSFEEHead feehead) - { - MBLNO = feehead.mbl; - VESSEL = feehead.vessel; - VOYNO = feehead.voyage; - ETD = feehead.etd; - DESTINATION = feehead.placeEnd; + return result; } } + } diff --git a/DSWeb/Areas/MvcShipping/DAL/MsSysThirdPartyAccount/MsSysThirdParthAccountDAL.cs b/DSWeb/Areas/MvcShipping/DAL/MsSysThirdPartyAccount/MsSysThirdParthAccountDAL.cs index d4152654..0ecf38e3 100644 --- a/DSWeb/Areas/MvcShipping/DAL/MsSysThirdPartyAccount/MsSysThirdParthAccountDAL.cs +++ b/DSWeb/Areas/MvcShipping/DAL/MsSysThirdPartyAccount/MsSysThirdParthAccountDAL.cs @@ -55,6 +55,11 @@ namespace DSWeb.MvcShipping.DAL.MsSysThirdPartyAccount return data; } + static public SysThirdPartyAccount GetDataByCustomername(string USERID,string CUSTOMERNAME) + { + return GetData($" USERID='{USERID}' and CUSTOMERNAME='{CUSTOMERNAME}'"); + } + private static List SetData(StringBuilder strSql) { diff --git a/DSWeb/Areas/MvcShipping/Models/MsSysThirdPartyAccount/SysThirdPartyAccount.cs b/DSWeb/Areas/MvcShipping/Models/MsSysThirdPartyAccount/SysThirdPartyAccount.cs index fa055f86..8db67c7e 100644 --- a/DSWeb/Areas/MvcShipping/Models/MsSysThirdPartyAccount/SysThirdPartyAccount.cs +++ b/DSWeb/Areas/MvcShipping/Models/MsSysThirdPartyAccount/SysThirdPartyAccount.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.Generic; using HcUtility.Core; using Newtonsoft.Json; +using NPOI.SS.Formula.Functions; namespace DSWeb.MvcShipping.Models.MsSysThirdPartyAccount { @@ -95,6 +96,16 @@ namespace DSWeb.MvcShipping.Models.MsSysThirdPartyAccount public string CUSTOMERNAME { get; set; } #endregion + + public bool HaveAccount() { + if (string.IsNullOrWhiteSpace(_ACCOUNT)) + { + return false; + } + else { + return true; + } + } } diff --git a/DSWeb/Areas/MvcShipping/Viewsjs/MsOpSeae/MsOpSeaeIndex.js b/DSWeb/Areas/MvcShipping/Viewsjs/MsOpSeae/MsOpSeaeIndex.js index cfdf8e2e..71f9dc48 100644 --- a/DSWeb/Areas/MvcShipping/Viewsjs/MsOpSeae/MsOpSeaeIndex.js +++ b/DSWeb/Areas/MvcShipping/Viewsjs/MsOpSeae/MsOpSeaeIndex.js @@ -2927,28 +2927,28 @@ Ext.extend(Shipping.MsOpSeaeIndex, Ext.Panel, { _this.onSendToDJY('del'); } } - //, { - // text: Zi.LAN.ESL, //"ESL业务执行", - // menu: [ - // { - // text: Zi.LAN.ESL_ETA, //"ESL到港时间更新", - // handler: function (menu, event) { - // _this.ESLWork("ETA"); - // } - // }, - // { - // text: Zi.LAN.ESL_CWFPCX, //"ESL舱位分配查询", - // handler: function (menu, event) { - // _this.ESLWork("CWFPCX"); - // } - // }, { - // text: Zi.LAN.ESL_GSDXZ, //"ESL格式单批量接收", - // handler: function (menu, event) { - // _this.ESLWork("GSDXZ"); - // } - // } - // ] - //} + , { + text: Zi.LAN.ESL, //"ESL业务执行", + menu: [ + { + text: Zi.LAN.ESL_CWFPCX, //"ESL舱位分配查询", + handler: function (menu, event) { + _this.ESLWork("CWFPCX"); + } + }, { + text: Zi.LAN.ESL_ETA, //"ESL到港时间更新", + handler: function (menu, event) { + _this.ESLWork("ETA"); + } + }, + { + text: Zi.LAN.ESL_GSDXZ, //"ESL格式单批量接收", + handler: function (menu, event) { + _this.ESLWork("DRAFT"); + } + } + ] + } , { text: '推送港联顺费用', handler: function (menu, event) {