@ -7643,7 +7643,6 @@ namespace DSWeb.MvcShipping.DAL.MsOpSeaeDAL
}
}
}
}
public static DBResult SendVGM ( string BSNO , string userid , string companyid , string CarrierEDICode )
public static DBResult SendVGM ( string BSNO , string userid , string companyid , string CarrierEDICode )
{
{
@ -7654,6 +7653,188 @@ namespace DSWeb.MvcShipping.DAL.MsOpSeaeDAL
var order = MsOpSeaeDAL . GetData ( $" B.BSNO='{BSNO}'" , userid ) ;
var order = MsOpSeaeDAL . GetData ( $" B.BSNO='{BSNO}'" , userid ) ;
var ctns = MsOpSeaeDAL . GetBodyList ( $" BSNO='{BSNO}'" ) ;
var ctns = MsOpSeaeDAL . GetBodyList ( $" BSNO='{BSNO}'" ) ;
var paraVgmSendService = MsSysParamSetDAL . GetDataByName ( "bookingSendVgmServiceUrl" ) ;
// var paraMyshippingUrlService = MsSysParamSetDAL.GetDataByName("DJYURL");
#region 检测能否发出
if ( string . IsNullOrEmpty ( paraVgmSendService . PARAMVALUE )
)
{
result . SetErrorInfo ( "请正确配置vgm发送服务及大简云url地址" ) ;
}
if ( string . IsNullOrEmpty ( order . MBLNO ) )
{
result . SetErrorInfo ( "提单号不能为空" ) ;
}
if ( string . IsNullOrEmpty ( order . CARRIER ) | | string . IsNullOrEmpty ( CarrierEDICode ) )
{
result . SetErrorInfo ( "船公司不能为空" ) ;
}
//var accType = AccountConfigType.CmaWeb.ToString();
var accCfg = MsSysThirdPartyAccount . MsSysThirdPartyAccountDAL . GetData ( $" CUSTOMERNAME='{order.CARRIER}' and THIRDPARTY='船公司账号' and USERID='" + userid + "' " ) ;
if ( accCfg = = null | | string . IsNullOrWhiteSpace ( accCfg . ACCOUNT ) | | string . IsNullOrWhiteSpace ( accCfg . ACCOUNTPSW ) )
{
accCfg = MsSysThirdPartyAccount . MsSysThirdPartyAccountDAL . GetData ( $" CUSTOMERNAME='{order.CARRIER}' and THIRDPARTY='船公司账号'" ) ;
if ( accCfg = = null | | string . IsNullOrWhiteSpace ( accCfg . ACCOUNT ) | | string . IsNullOrWhiteSpace ( accCfg . ACCOUNTPSW ) )
{
result . SetErrorInfo ( $"未在第三方账号信息中配置船公司【{order.CARRIER}】的网站账号、密码(第三方账号每人维护各自信息,客户名称需选择船公司,第三方软件为【船公司账号】)" ) ;
}
}
//var yardset = MsCodeYardDataSetDAL.GetDataList($" YARD='{order.YARD}'", companyid);
//if (yardset == null || yardset.Count == 0)
//{
// result.SetErrorInfo("场站代号未找到");
//}
var userbaseinfo = BasicDataRefDAL . GetUserLinkRef ( "u.GID='" + userid + "'" ) ;
if ( userbaseinfo = = null | | string . IsNullOrWhiteSpace ( userbaseinfo . Tel ) | | string . IsNullOrWhiteSpace ( userbaseinfo . Email ) )
{
result . SetErrorInfo ( "请维护用户基础信息中的电话和邮箱" ) ;
}
CtnCanSend ( CarrierEDICode , ctns , ref result ) ;
if ( ! result . Success ) return result ;
# endregion
var cdc = new CommonDataContext ( ) ;
var vwuser = cdc . VW_user . FirstOrDefault ( x = > x . USERID = = userid ) ;
//var company = MsCompanysDAL.MsCompanysDAL.GetNoPicData("GID='" + companyid + "'");
int idx = 1 ;
var Etdstr = GetDateStr ( order . ETD ) ;
var VgmEndTimeStr = DateTime . Now . AddDays ( 1 ) . ToString ( "yyyy-MM-dd" ) ;
string GetDateStr ( string datestr )
{
return ! string . IsNullOrWhiteSpace ( datestr ) ? Convert . ToDateTime ( datestr ) . ToString ( "yyyy-MM-dd" ) : string . Empty ;
}
var strSendObj = "" ;
if ( CarrierEDICode . ToLower ( ) = = "cma" )
{
List < List < string > > data_list = new List < List < string > > ( ) ;
foreach ( var ctn in ctns )
{
var newctnlist = new List < string > ( ) ;
newctnlist . Add ( order . MBLNO ) ;
newctnlist . Add ( ctn . CNTRNO ) ;
if ( order . ISCONTAINERSOC )
newctnlist . Add ( "Y" ) ;
else
newctnlist . Add ( "N" ) ;
newctnlist . Add ( ctn . KGS . ToString ( ) ) ;
newctnlist . Add ( ctn . WEIGHKGS . ToString ( ) ) ;
newctnlist . Add ( "KGM" ) ;
newctnlist . Add ( ctn . WEIGHSIGN ) ;
newctnlist . Add ( ctn . WEIGHTYPE = = "累加" ? "SM2" : "SM1" ) ;
data_list . Add ( newctnlist ) ;
}
var SENDGID = Guid . NewGuid ( ) . ToString ( ) ;
var customername = MsSysParamSetDAL . GetData ( "PARAMNAME='DSVGMID'" ) . PARAMVALUE ;
var password = MsSysParamSetDAL . GetData ( "PARAMNAME='DSVGMKEY'" ) . PARAMVALUE ;
//调用接口
var sendObj = new
{
gid = SENDGID ,
User = customername ,
Secret = password ,
web_code = CarrierEDICode . ToLower ( ) ,
web_user = accCfg . ACCOUNT ,
web_pwd = accCfg . ACCOUNTPSW ,
data_list = data_list
} ;
strSendObj = JsonConvert . Serialize ( sendObj ) ;
}
else {
List < VgmData_list > data_list = new List < VgmData_list > ( ) ;
foreach ( var ctn in ctns )
{
var newctnlist = new VgmData_list ( ) ;
newctnlist . booking_no = order . MBLNO ;
newctnlist . container_no = ctn . CNTRNO ;
newctnlist . weight_type = ( ctn . WEIGHTYPE = = "累加" ? "SM2" : "SM1" ) ;
newctnlist . unit = ctn . KINDPKGS ;
newctnlist . weight = ctn . KGS . ToString ( ) ;
newctnlist . signatory = ctn . WEIGHSIGN ;
newctnlist . reference_id = ctn . WEIGHSIGN ;
newctnlist . e_mail_notification = userbaseinfo . Email ;
data_list . Add ( newctnlist ) ;
}
var SENDGID = Guid . NewGuid ( ) . ToString ( ) ;
var customername = MsSysParamSetDAL . GetData ( "PARAMNAME='DSVGMID'" ) . PARAMVALUE ;
var password = MsSysParamSetDAL . GetData ( "PARAMNAME='DSVGMKEY'" ) . PARAMVALUE ;
//调用接口
var sendObj = new
{
gid = SENDGID ,
User = customername ,
Secret = password ,
web_code = CarrierEDICode . ToLower ( ) ,
web_user = accCfg . ACCOUNT ,
web_pwd = accCfg . ACCOUNTPSW ,
data_list = data_list
} ;
strSendObj = JsonConvert . Serialize ( sendObj ) ;
}
strSendObj = strSendObj . Replace ( "\r\n" , "" ) ;
//log.Debug($"准备发送vgm: {strSendObj}");
try
{
BasicDataRefDAL . SaveLog ( strSendObj , "" , "VGM直发" , "发送" ) ;
var rtn = WebRequestHelper . DoPost ( paraVgmSendService . PARAMVALUE , strSendObj , timeout : 5000 ) ;
BasicDataRefDAL . SaveLog ( rtn , "" , "VGM直发" , "返回" ) ;
//log.Debug($"发送vgm返回: {rtn}");
var jobjRtn = Newtonsoft . Json . JsonConvert . DeserializeAnonymousType ( rtn , new { status = 0 , message = string . Empty , data = string . Empty } ) ;
if ( ! ( jobjRtn . status = = 1 ) )
{
return result . SetErrorInfo ( $"直发VGM错误: {jobjRtn.message}" ) ;
}
else
{
T_ALL_DA T_ALL_DA = new T_ALL_DA ( ) ;
var blUpSQL = " insert into sys_vgm_log(GID,MBLNO,STATUS,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + order . MBLNO + "','发送','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) + "','" + order . BSNO + "','" + userid + "')" ;
bool bl = T_ALL_DA . GetExecuteSqlCommand ( blUpSQL ) ;
result . OK ( $"发送完成" ) ; //:[{ jobjRtn.message}]
}
}
catch ( Exception ex )
{
result . SetErrorInfo ( ex . Message ) ;
}
return result ;
}
public static DBResult SendVGM2 ( string BSNO , string userid , string companyid , string CarrierEDICode )
{
RespCommonData resp = new RespCommonData ( ) ;
var result = new DBResult ( true , "" ) ;
var order = MsOpSeaeDAL . GetData ( $" B.BSNO='{BSNO}'" , userid ) ;
var ctns = MsOpSeaeDAL . GetBodyList ( $" BSNO='{BSNO}'" ) ;
var paraVgmSendService = MsSysParamSetDAL . GetDataByName ( "bookingSendVgmServiceUrl" ) ;
var paraVgmSendService = MsSysParamSetDAL . GetDataByName ( "bookingSendVgmServiceUrl" ) ;
var paraMyshippingUrlService = MsSysParamSetDAL . GetDataByName ( "DJYURL" ) ;
var paraMyshippingUrlService = MsSysParamSetDAL . GetDataByName ( "DJYURL" ) ;
@ -7850,53 +8031,56 @@ namespace DSWeb.MvcShipping.DAL.MsOpSeaeDAL
}
}
* /
* /
if ( CarrierEDICode . ToUpper ( ) = = " ESL ")
if ( CarrierEDICode . ToUpper ( ) = = " CMA ")
{
{
//船公司ESL只需要指定 提单号 箱号 毛重kgs ,
//船公司ESL只需要指定 提单号 箱号 毛重kgs ,
//故做如下限制
//故做如下限制
foreach ( var ctn in ctns )
foreach ( var ctn in ctns )
{
{
if ( string . IsNullOrWhiteSpace ( ctn . CTNALL ) ) result . SetErrorInfo ( "必须选择箱型" ) ;
//if (string.IsNullOrWhiteSpace(ctn.CTNALL)) result.SetErrorInfo("必须选择箱型") ;
if ( ctn . CTNNUM < = 0 ) result . SetErrorInfo ( "箱量不能为零" ) ;
//if (ctn.CTNNUM <= 0) result.SetErrorInfo("箱量不能为零") ;
if ( string . IsNullOrWhiteSpace ( ctn . CNTRNO ) ) result . SetErrorInfo ( "箱号不能为空" ) ;
if ( string . IsNullOrWhiteSpace ( ctn . CNTRNO ) ) result . SetErrorInfo ( "箱号不能为空" ) ;
//if (string.IsNullOrWhiteSpace(ctn.SEALNO)) result.SetErrorInfo("封号不能为空");
if ( ctn . KGS < = 0 ) result . SetErrorInfo ( "毛重不能为零" ) ;
if ( ctn . KGS < = 0 ) result . SetErrorInfo ( "毛重不能为零" ) ;
//if (ctn.TAREWEIGHT <= 0) result.SetErrorInfo("皮重不能为零");
if ( ctn . WEIGHKGS < = 0 ) result . SetErrorInfo ( "称重重量不能为零" ) ;
//if (string.IsNullOrWhiteSpace(ctn.SEALNO)) result.SetErrorInfo("封号不能为空");
//if (string.IsNullOrWhiteSpace(ctn.SEALNO)) result.SetErrorInfo("封号不能为空");
//if (ctn.TAREWEIGHT <= 0) result.SetErrorInfo("皮重不能为零");
//if (ctn.TAREWEIGHT <= 0) result.SetErrorInfo("皮重不能为零");
//if (ctn.WEIGHKGS <= 0) result.SetErrorInfo("称重重量不能为零");
//if (ctn.WEIGHKGS <= 0) result.SetErrorInfo("称重重量不能为零");
}
}
}
}
else
// else
if ( CarrierEDICode . ToUpper ( ) = = "ONE" )
//if (CarrierEDICode.ToUpper() == "ONE" )
{
// {
//船公司ONE只需要指定 提单号 箱号 毛重kgs ,
// //船公司ONE只需要指定 提单号 箱号 毛重kgs ,
//故做如下限制
// //故做如下限制
foreach ( var ctn in ctns )
// foreach (var ctn in ctns)
{
// {
if ( string . IsNullOrWhiteSpace ( ctn . CTNALL ) ) result . SetErrorInfo ( "必须选择箱型" ) ;
// //if (string.IsNullOrWhiteSpace(ctn.CTNALL)) result.SetErrorInfo("必须选择箱型") ;
if ( ctn . CTNNUM < = 0 ) result . SetErrorInfo ( "箱量不能为零" ) ;
// //if (ctn.CTNNUM <= 0) result.SetErrorInfo("箱量不能为零") ;
if ( string . IsNullOrWhiteSpace ( ctn . CNTRNO ) ) result . SetErrorInfo ( "箱号不能为空" ) ;
// if (string.IsNullOrWhiteSpace(ctn.CNTRNO)) result.SetErrorInfo("箱号不能为空");
if ( ctn . KGS < = 0 ) result . SetErrorInfo ( "毛重不能为零" ) ;
// if (ctn.KGS <= 0) result.SetErrorInfo("毛重不能为零");
//if (string.IsNullOrWhiteSpace(ctn.SEALNO)) result.SetErrorInfo("封号不能为空");
// //if (string.IsNullOrWhiteSpace(ctn.SEALNO)) result.SetErrorInfo("封号不能为空");
//if (ctn.TAREWEIGHT <= 0) result.SetErrorInfo("皮重不能为零");
// //if (ctn.TAREWEIGHT <= 0) result.SetErrorInfo("皮重不能为零");
//if (ctn.WEIGHKGS <= 0) result.SetErrorInfo("称重重量不能为零");
// //if (ctn.WEIGHKGS <= 0) result.SetErrorInfo("称重重量不能为零");
}
// }
}
// }
else
else
{
{
//对所有未指定的其他船公司而言:
//对所有未指定的其他船公司而言:
foreach ( var ctn in ctns )
foreach ( var ctn in ctns )
{
{
if ( string . IsNullOrWhiteSpace ( ctn . CTNALL ) ) result . SetErrorInfo ( "必须选择箱型" ) ;
//if (string.IsNullOrWhiteSpace(ctn.CTNALL)) result.SetErrorInfo("必须选择箱型") ;
if ( ctn . CTNNUM < = 0 ) result . SetErrorInfo ( "箱量不能为零" ) ;
//if (ctn.CTNNUM <= 0) result.SetErrorInfo("箱量不能为零") ;
if ( string . IsNullOrWhiteSpace ( ctn . CNTRNO ) ) result . SetErrorInfo ( "箱号不能为空" ) ;
if ( string . IsNullOrWhiteSpace ( ctn . CNTRNO ) ) result . SetErrorInfo ( "箱号不能为空" ) ;
if ( string . IsNullOrWhiteSpace ( ctn . SEALNO ) ) result . SetErrorInfo ( "封号不能为空" ) ;
//if (string.IsNullOrWhiteSpace(ctn.SEALNO)) result.SetErrorInfo("封号不能为空") ;
if ( ctn . KGS < = 0 ) result . SetErrorInfo ( "毛重不能为零" ) ;
if ( ctn . KGS < = 0 ) result . SetErrorInfo ( "毛重不能为零" ) ;
if ( ctn . TAREWEIGHT < = 0 ) result . SetErrorInfo ( "皮重不能为零" ) ;
//if (ctn.TAREWEIGHT <= 0) result.SetErrorInfo("皮重不能为零") ;
if ( ctn . WEIGHKGS < = 0 ) result . SetErrorInfo ( "称重重量不能为零" ) ;
//if (ctn.WEIGHKGS <= 0) result.SetErrorInfo("称重重量不能为零") ;
}
}
}
}
}
}