|
|
|
@ -10,6 +10,17 @@ using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpPrice;
|
|
|
|
|
using DSWeb.MvcContainer.Models.MsOpCtnr;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsChFee;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.Comm;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using System.Data.Entity.Migrations;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
{
|
|
|
|
@ -88,7 +99,7 @@ namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + condition;
|
|
|
|
|
}
|
|
|
|
|
var list=SetData(strSql);
|
|
|
|
|
var list = SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return list[0];
|
|
|
|
@ -121,6 +132,8 @@ namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
|
|
|
data.CARRIERSTATUS = Convert.ToString(reader["CARRIERSTATUS"]);
|
|
|
|
|
data.YGTSTATUS = Convert.ToString(reader["YGTSTATUS"]);
|
|
|
|
|
data.YARDSTATUS = Convert.ToString(reader["YARDSTATUS"]);
|
|
|
|
|
|
|
|
|
|
data.VGM_TIME = Convert.ToString(reader["VGM_TIME"]);
|
|
|
|
|
data.SENDERUSER = Convert.ToString(reader["SENDERUSER"]);
|
|
|
|
|
data.SENDERUSERREF = Convert.ToString(reader["SENDERUSERREF"]);
|
|
|
|
@ -134,7 +147,9 @@ namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
if (reader["SENDTIME"] != DBNull.Value)
|
|
|
|
|
data.SENDTIME = Convert.ToDateTime(reader["SENDTIME"]);
|
|
|
|
|
|
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
|
|
|
|
|
|
data.LINKURL = Convert.ToString(reader["LINKURL"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
@ -211,25 +226,6 @@ namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public string GetCustEDICode(string CUST, string EDINAME)
|
|
|
|
|
{
|
|
|
|
|
string EDICODE = "";
|
|
|
|
|
CUST = CUST.Replace("'", "''");
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select EDICODE from code_cust_edi where CUST='" + CUST + "' AND EDINAME='" + EDINAME + "'");
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
EDICODE = Convert.ToString(reader["EDICODE"]).Trim();
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EDICODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult SaveDetail(string LE_ID, List<MsOpVgmCtn> bodyList)
|
|
|
|
|
{
|
|
|
|
@ -275,20 +271,40 @@ namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
|
|
|
|
|
public static DsVgm CreateDjyVgm(MsOpVgmSend headData, List<MsOpVgmCtn> bodyList)
|
|
|
|
|
{
|
|
|
|
|
var OpSeaehead = MsOpSeaeDAL.MsOpSeaeDAL.GetData("BSNO='" + headData.BSNO + "'");
|
|
|
|
|
|
|
|
|
|
var DsVgm = new DsVgm();
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
DsVgm.mblno = headData.MBLNO;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DsVgm.carrier = BasicDataRefDAL.GetCustEdiCodeByName(OpSeaehead.CARRIER, "DJY");
|
|
|
|
|
//DsVgm.carrier = headData.CARRIER;
|
|
|
|
|
|
|
|
|
|
DsVgm.etd = OpSeaehead.ETD;
|
|
|
|
|
DsVgm.weiTuoFaSongFang = BasicDataRefDAL.GetCustEdiCodeByName(OpSeaehead.CUSTOMERNAME, "DJY");
|
|
|
|
|
|
|
|
|
|
DsVgm.chuanMing = headData.CARRIER;
|
|
|
|
|
DsVgm.vsid = OpSeaehead.VESSELID;
|
|
|
|
|
|
|
|
|
|
DsVgm.hangCi = headData.VOYNO;
|
|
|
|
|
|
|
|
|
|
DsVgm.beiZhu = headData.REMARK;
|
|
|
|
|
|
|
|
|
|
var 装货港 = OpSeaehead.PORTLOAD;
|
|
|
|
|
var 装货港代码 = OpSeaehead.PORTLOADID;
|
|
|
|
|
BasicDataRefDAL.GetPORTInfoByEDICODEAndEDIName("DJY", OpSeaehead.PORTLOADID, OpSeaehead.PORTLOAD, ref 装货港, ref 装货港代码);
|
|
|
|
|
DsVgm.zhuangHuoGang = 装货港;
|
|
|
|
|
DsVgm.zhuangHuoGangDaiMa = 装货港代码;
|
|
|
|
|
|
|
|
|
|
DsVgm.yard = BasicDataRefDAL.GetCustEdiCodeByName(OpSeaehead.YARD, "DJY");
|
|
|
|
|
|
|
|
|
|
DsVgm.orderno = headData.ORDERNO;
|
|
|
|
|
//DsVgm.yard = GetCustEDICode(headData.ya, "DJY");
|
|
|
|
|
DsVgm.carrier = headData.CARRIER;
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
DsVgm.mfno = headData.BSNO;
|
|
|
|
|
|
|
|
|
|
DsVgm.vgmclosetime = headData.VGM_TIME;
|
|
|
|
|
|
|
|
|
|
DsVgm.wharf = headData.MATOU;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cntrlist = new List<Ctn>();
|
|
|
|
|
foreach (var ctn in bodyList)
|
|
|
|
@ -308,13 +324,163 @@ namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
DsVgm.ctnList = cntrlist;
|
|
|
|
|
|
|
|
|
|
DsVgm.sendType = Convert.ToInt32(headData.SENDTYPE);
|
|
|
|
|
DsVgm.sendCarr = headData.ISCARRIER;
|
|
|
|
|
DsVgm.sendYGT = headData.ISYGT;
|
|
|
|
|
|
|
|
|
|
return DsVgm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public List<op_seae_vgm_history_md> GetVgmHistoryList(string BSNO)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new List<op_seae_vgm_history_md>();
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
result = cdc.op_seae_vgm_history
|
|
|
|
|
.Where(x => x.BSNO == BSNO)
|
|
|
|
|
.OrderByDescending(o=>o.SENDTIME).ToList();
|
|
|
|
|
|
|
|
|
|
if (result != null && result.Count > 0) {
|
|
|
|
|
var useridlist= result.Select(x => x.SENDERUSER).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
var userlist = cdc.VW_user.Where(x => useridlist.Contains(x.USERID)).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var item in result) {
|
|
|
|
|
item.SENDERNAME = userlist.FirstOrDefault(x => x.USERID == item.SENDERUSER).SHOWNAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
static public List<op_seae_vgm_state_md> GetStatusList(string BSNO,string type)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new List<op_seae_vgm_state_md>();
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
result = cdc.op_seae_vgm_state
|
|
|
|
|
.Where(x => x.mfno==BSNO&& x.Type==type)
|
|
|
|
|
.OrderByDescending(o => o.statustime).ToList();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 发送vgm至大简云
|
|
|
|
|
public static DBResult SendDjyVgm(MsOpVgmSend headData, List<MsOpVgmCtn> bodyList)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
result.OK();
|
|
|
|
|
|
|
|
|
|
var DsVgmUrl = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024URL'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
var headers = new NameValueCollection();
|
|
|
|
|
|
|
|
|
|
var key= MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_Key'").PARAMVALUE;
|
|
|
|
|
var secret = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_Secret'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
headers["USER_KEY"] = key;
|
|
|
|
|
headers["USER_SECRET"] = secret;
|
|
|
|
|
var sendinfo = CreateDjyVgm(headData, bodyList);
|
|
|
|
|
|
|
|
|
|
BasicDataRefDAL.SaveLog(JsonConvert.Serialize(DsVgmUrl) + "////" + key +"////"+ secret + "////"+JsonConvert.Serialize(sendinfo), "", "DJYVGM2024", "发送");
|
|
|
|
|
var rtn = WebRequestHelper.DoPost_JSON_Header(DsVgmUrl, JsonConvert.Serialize(sendinfo), 10000,headers);
|
|
|
|
|
BasicDataRefDAL.SaveLog(rtn, "", "DJYVGM2024", "返回");
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 从大简云获取VGM链接
|
|
|
|
|
|
|
|
|
|
public class getlinkparam {
|
|
|
|
|
public string mfno { get; set; }
|
|
|
|
|
public bool sendCarr { get; set; } = false;
|
|
|
|
|
public bool sendYGT { get; set; } = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult GetDjyVgmLink(getlinkparam sendparam)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
result.OK();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var _head = cdc.op_seae_vgm_send.Where(p => p.BSNO == sendparam.mfno).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
//var head = MsOpVgmSendDAL.GetData("BSNO='" + sendparam.mfno + "'");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(_head.LINKURL))
|
|
|
|
|
{
|
|
|
|
|
result.Data = _head.LINKURL;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
var DsVgmUrl = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024GetUrl'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
var headers = new NameValueCollection();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var key = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Key'").PARAMVALUE;
|
|
|
|
|
var secret = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Secret'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
//测试数据
|
|
|
|
|
//sendparam.mfno = "585399286181957";
|
|
|
|
|
|
|
|
|
|
headers["USER_KEY"] = key;// MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Key'").PARAMVALUE;
|
|
|
|
|
headers["USER_SECRET"] = secret;// MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Secret'").PARAMVALUE;
|
|
|
|
|
var sendstr= JsonConvert.Serialize(sendparam);
|
|
|
|
|
|
|
|
|
|
var dic = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "mfno", sendparam.mfno },
|
|
|
|
|
{ "sendCarr", sendparam.sendCarr.ToString().ToLower() },
|
|
|
|
|
{ "sendYGT", sendparam.sendYGT.ToString().ToLower() }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BasicDataRefDAL.SaveLog(JsonConvert.Serialize(DsVgmUrl) + "////" + key +"//"+ secret + "////" + JsonConvert.Serialize(sendstr), "", "DJYVGM2024GetUrl", "发送");
|
|
|
|
|
var rtn = WebRequestHelper.DoGet_Param_Header(DsVgmUrl, dic, 10000, headers);
|
|
|
|
|
BasicDataRefDAL.SaveLog(rtn, "", "DJYVGM2024GetUrl", "返回");
|
|
|
|
|
|
|
|
|
|
获取vgm链接Result rp = JsonConvert.Deserialize<获取vgm链接Result>(rtn);
|
|
|
|
|
if (rp.statusCode == 200)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_head.LINKURL = BasicDataRefDAL.Unicode2String(rp.data);
|
|
|
|
|
|
|
|
|
|
_head.ISCARRIER = sendparam.sendCarr;
|
|
|
|
|
_head.ISYGT = sendparam.sendYGT;
|
|
|
|
|
|
|
|
|
|
cdc.op_seae_vgm_send.AddOrUpdate(_head);
|
|
|
|
|
cdc.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
result.OK("获取成功");
|
|
|
|
|
|
|
|
|
|
result.Data = _head.LINKURL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
result.SetErrorInfo(BasicDataRefDAL.Unicode2String(rp.errors));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 判断编码是否有重复
|
|
|
|
|
static public int GetRdCount(string strCondition)
|
|
|
|
|