|
|
|
|
using log4net;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Quartz;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace JobCreateFee
|
|
|
|
|
{
|
|
|
|
|
public class JobHaireBooking : IJob
|
|
|
|
|
{
|
|
|
|
|
private ILog log = LogManager.GetLogger(typeof(JobHaireBooking));
|
|
|
|
|
private const string CfgFileName = "hairebookingstarttime.cfg";
|
|
|
|
|
private static string CfgFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CfgFileName);
|
|
|
|
|
|
|
|
|
|
public void Execute(IJobExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
log.Debug($"Execute开始");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
|
|
|
|
|
string reqUrl = context.JobDetail.JobDataMap.GetString("ReqUrl");
|
|
|
|
|
string CustomerName = context.JobDetail.JobDataMap.GetString("CustomerName");
|
|
|
|
|
string TaskEmployee = context.JobDetail.JobDataMap.GetString("TaskEmployee");
|
|
|
|
|
|
|
|
|
|
int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
|
|
|
|
|
if (reqTimeout == 0) reqTimeout = 3;
|
|
|
|
|
long ts = DataTableToJsonHelper.ConvertDateTimeToInt(DateTime.Now);
|
|
|
|
|
JObject reqObj = new JObject();
|
|
|
|
|
var starttimestr = File.ReadAllText(CfgFilePath);
|
|
|
|
|
long startts = 0;
|
|
|
|
|
if (!string.IsNullOrEmpty(starttimestr))
|
|
|
|
|
{
|
|
|
|
|
startts = DataTableToJsonHelper.ConvertDateTimeToInt(Convert.ToDateTime(starttimestr));
|
|
|
|
|
reqObj.Add("assignBeginTime", new JValue(startts*1000));
|
|
|
|
|
}
|
|
|
|
|
var endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
long endts = DataTableToJsonHelper.ConvertDateTimeToInt(Convert.ToDateTime(endtime));
|
|
|
|
|
reqObj.Add("assignEndTime", new JValue(endts*1000));
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
|
|
dic.Add("notifyid", endts.ToString());
|
|
|
|
|
dic.Add("notifytime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
dic.Add("butype","Json");
|
|
|
|
|
dic.Add("source", "JF");
|
|
|
|
|
dic.Add("content", reqObj.ToString().Replace("\r\n",""));
|
|
|
|
|
log.Debug($"数据上传:{dic.ToList()}");
|
|
|
|
|
//发送请求数据
|
|
|
|
|
string rtn = WebRequestHelper.DoPost(reqUrl, dic, reqTimeout * 1000);
|
|
|
|
|
//var objRtn = JsonConvert.DeserializeAnonymousType(rtn, new { status = "", message = "" });
|
|
|
|
|
|
|
|
|
|
log.Debug($"数据返回:{rtn}");
|
|
|
|
|
|
|
|
|
|
var parseJsonObj = JsonConvert.DeserializeObject<JsonHBData>(rtn);
|
|
|
|
|
if (parseJsonObj.flag&& parseJsonObj.data!= null)
|
|
|
|
|
{
|
|
|
|
|
//var returnlist = JsonConvert.DeserializeObject<List<JsonBook>>(parseJsonObj.data);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (SqlConnection dbcon = new SqlConnection(connStr))
|
|
|
|
|
{
|
|
|
|
|
dbcon.Open();
|
|
|
|
|
foreach (var returndata in parseJsonObj.data)
|
|
|
|
|
{
|
|
|
|
|
var BSNO = Guid.NewGuid().ToString();
|
|
|
|
|
var ctnlist = returndata.contains;
|
|
|
|
|
if (ctnlist == null) ctnlist = returndata.containerDTOS;
|
|
|
|
|
var REEFERF = "";
|
|
|
|
|
var temperature = "";
|
|
|
|
|
var temperatureUnit = "";
|
|
|
|
|
var humidity = "";
|
|
|
|
|
foreach (var ctn in ctnlist) {
|
|
|
|
|
var insertctnstr = "insert into op_seaeorderctn (CTN_ID,ORDNO,CTNALL,CTNNUM,REMARK,KINDPKGS,PKGS,KGS,CBM,GOODSNAME,HSCODE,CNTRNO,SEALNO)";
|
|
|
|
|
var valuectnstr = $" values ('{Guid.NewGuid().ToString().Replace("'", "''")}'," +//
|
|
|
|
|
$"'{BSNO.Replace("'", "''")}'," + //ORDNO
|
|
|
|
|
$"'{ctn.boxType.Replace("'", "''")}'," + //CTNALL
|
|
|
|
|
$"'{ctn.boxQuantity.Replace("'", "''")}'," + //CTNNUM
|
|
|
|
|
$"''," + //REMARK
|
|
|
|
|
$"''," + //KINDPKGS
|
|
|
|
|
$"0," + //PKGS
|
|
|
|
|
$"'{ctn.grossWeight.Replace("'", "''")}'," + //KGS
|
|
|
|
|
$"0," + //CBM
|
|
|
|
|
$"''," + //GOODSNAME
|
|
|
|
|
$"''," + //HSCODE
|
|
|
|
|
$"''," + //CNTRNO
|
|
|
|
|
$"''" + //SEALNO
|
|
|
|
|
$")";
|
|
|
|
|
var headctnStr = insertctnstr + valuectnstr;
|
|
|
|
|
SqlCommand cmdctn = new SqlCommand(headctnStr, dbcon);
|
|
|
|
|
cmdctn.ExecuteNonQuery();
|
|
|
|
|
REEFERF = ctn.ventilate;
|
|
|
|
|
if (string.IsNullOrEmpty(REEFERF)) REEFERF = "";
|
|
|
|
|
temperature = ctn.temperature;
|
|
|
|
|
if (string.IsNullOrEmpty(temperature)) temperature = "";
|
|
|
|
|
|
|
|
|
|
if (ctn.temperatureUnit== "CEL")
|
|
|
|
|
temperatureUnit ="C";
|
|
|
|
|
if (ctn.temperatureUnit == "FAH")
|
|
|
|
|
temperatureUnit = "F";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var insertstr = "insert into op_seaeorder (BSNO,ORSTATUS,BSDATE,MBLNO,CUSTOMERNAME,SHIPPER,CONSIGNEE,NOTIFYPARTY,CARRIER,VESSEL,VOYNO,ETD,PlACERECEIPT,PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,PLACEDELIVERYID,PLACEDELIVERY,DESTINATIONID,DESTINATION,NOBILL,ISSUETYPE,ISSUEDATE,ISSUEPLACE,BLFRT,PREPARDAT,PAYABLEAT,SERVICE,MARKS,NOPKGS,DESCRIPTION,GOODSNAME,GROSSWEIGHT,MEASUREMENT,PKGS,KINDPKGS,KGS,CBM,TOTALNO,CNTRTOTAL,INPUTBY,INVNO,CARGOID,DCLASS,DUNNO,REEFERF,TEMPID,TEMPSET,TEMPMAX,TEMPMIN,CUSTOMSNUM,REMARK,DPAGE,DLABEL,LANE,SERVICECONTRACTNO,CUSTNO,CUSTATTN,CUSTTEL,BLTYPE)";
|
|
|
|
|
|
|
|
|
|
var CARGOID = "S";
|
|
|
|
|
if (returndata.goodsType == "01") CARGOID = "R";
|
|
|
|
|
if (returndata.goodsType == "02") CARGOID = "D";
|
|
|
|
|
var ETD = "";
|
|
|
|
|
if (!string.IsNullOrEmpty(returndata.reqShipmentDate)) {
|
|
|
|
|
|
|
|
|
|
ETD = DataTableToJsonHelper.GetDateTime(long.Parse(returndata.reqShipmentDate)).ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
var BSDATE = "";
|
|
|
|
|
if (!string.IsNullOrEmpty(returndata.trustDate))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
BSDATE = DataTableToJsonHelper.GetDateTime(long.Parse(returndata.trustDate)).ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var valuestr = $" values ('{BSNO.Replace("'", "''")}'," +//BSNO
|
|
|
|
|
$"'{returndata.scope.Replace("'", "''")}'," + //ORSTATUS
|
|
|
|
|
$"'{BSDATE.Replace("'", "''")}'," + //BSDATE
|
|
|
|
|
$"''," + //MBLNO
|
|
|
|
|
$"'{CustomerName.Replace("'", "''")}'," + //CUSTOMERNAME
|
|
|
|
|
$"'{returndata.senderName + Environment.NewLine + returndata.senderDesc}'," + //SHIPPER
|
|
|
|
|
$"'{returndata.receiverName + Environment.NewLine + returndata.receiverDesc}'," + //CONSIGNEE
|
|
|
|
|
$"'{returndata.notifierName + Environment.NewLine + returndata.notifierDesc}'," + //NOTIFYPARTY
|
|
|
|
|
//$"'{returndata.secondnotifierName.Replace("'", "''") + Environment.NewLine + returndata.secondnotifierDesc.Replace("'", "''")}'," + //NOTIFYPARTY
|
|
|
|
|
$"'{returndata.shipCompany}'," + //CARRIER
|
|
|
|
|
$"'{returndata.shipName}'," + //VESSEL
|
|
|
|
|
$"'{returndata.voyageNum}'," + //VOYNO
|
|
|
|
|
$"'{ETD.Replace("'", "''")}'," + //ETD
|
|
|
|
|
$"'{returndata.loadPlace}'," + //PlACERECEIPT
|
|
|
|
|
$"'{returndata.loadingPortCode}'," + //PORTLOADID
|
|
|
|
|
$"'{returndata.loadingPort}'," + //PORTLOAD
|
|
|
|
|
$"'{returndata.dischargePortCode}'," + //PORTDISCHARGEID
|
|
|
|
|
$"'{returndata.dischargePort}'," + //PORTDISCHARGE
|
|
|
|
|
$"''," + //PLACEDELIVERYID
|
|
|
|
|
$"'{returndata.deliveryPlace.Replace("'", "''")}'," + //PLACEDELIVERY
|
|
|
|
|
$"'{returndata.dischargePortCode.Replace("'", "''")}'," + //DESTINATIONID
|
|
|
|
|
$"'{returndata.dischargePort.Replace("'", "''")}'," + //DESTINATION
|
|
|
|
|
$"''," + //NOBILL
|
|
|
|
|
$"''," + //ISSUETYPE
|
|
|
|
|
$"''," + //ISSUEDATE
|
|
|
|
|
$"''," + //ISSUEPLACE
|
|
|
|
|
$"'{returndata.freightClause.Replace("'", "''")}'," + //BLFRT
|
|
|
|
|
$"''," + //PREPARDAT
|
|
|
|
|
$"''," + //PAYABLEAT
|
|
|
|
|
$"'{returndata.transClause}'," + //SERVICE
|
|
|
|
|
$"'{returndata.shipMarks.Replace("'", "''")}'," + //MARKS
|
|
|
|
|
$"'{returndata.goodsNum+ returndata.goodUnit}'," + //NOPKGS
|
|
|
|
|
$"'{returndata.goodsDesc}'," + //DESCRIPTION
|
|
|
|
|
$"'{returndata.productName}'," + //GOODSNAME
|
|
|
|
|
$"'{returndata.grossWeight}KGS'," + //GROSSWEIGHT
|
|
|
|
|
$"'{returndata.volume.Replace("'", "''")}CBM'," + //MEASUREMENT
|
|
|
|
|
$"'{returndata.goodsNum.Replace("'", "''")}'," + //PKGS
|
|
|
|
|
$"'{returndata.goodUnit.Replace("'", "''")}'," + //KINDPKGS
|
|
|
|
|
$"'{returndata.grossWeight.Replace("'", "''")}'," + //KGS
|
|
|
|
|
$"'{returndata.volume.Replace("'", "''")}'," + //CBM
|
|
|
|
|
$"''," + //TOTALNO
|
|
|
|
|
$"''," + //CNTRTOTAL
|
|
|
|
|
$"''," + //INPUTBY
|
|
|
|
|
$"''," + //INVNO
|
|
|
|
|
$"'{CARGOID}'," + //CARGOID
|
|
|
|
|
$"''," + //DCLASS
|
|
|
|
|
$"''," + //DUNNO
|
|
|
|
|
$"'{REEFERF.Replace("'", "''")}'," + //REEFERF
|
|
|
|
|
$"'{temperatureUnit.Replace("'", "''")}'," + //TEMPID
|
|
|
|
|
$"'{temperature.Replace("'", "''")}'," + //TEMPSET
|
|
|
|
|
$"''," + //TEMPMAX
|
|
|
|
|
$"''," + //TEMPMIN
|
|
|
|
|
$"0," + //CUSTOMSNUM
|
|
|
|
|
$"'{returndata.bookingComment.Replace("'", "''")}'," + //REMARK
|
|
|
|
|
$"''," + //DPAGE
|
|
|
|
|
$"''," + //DLABEL
|
|
|
|
|
$"'{returndata.airLine}'," + //LANE
|
|
|
|
|
$"'{returndata.protocol}'," + //SERVICECONTRACTNO
|
|
|
|
|
$"'{returndata.orderNo}'," + //CUSTNO
|
|
|
|
|
$"'{returndata.@operator}'," + //CUSTATTN
|
|
|
|
|
$"'{returndata.operatorPhone}'," + //CUSTTEL
|
|
|
|
|
$"''" + //CUSTTEL
|
|
|
|
|
$")";
|
|
|
|
|
|
|
|
|
|
var headStr = insertstr + valuestr;
|
|
|
|
|
|
|
|
|
|
SqlCommand cmd = new SqlCommand(headStr, dbcon);
|
|
|
|
|
cmd.ExecuteNonQuery();
|
|
|
|
|
|
|
|
|
|
var tastStr = $" INSERT INTO [t_op_task] ([任务编号],[上级任务号],[任务类型],[任务来源],[任务状态],[任务说明],[发起人],[录入日期],[任务开始时间],[完成方式],[完成时间],[KPI值],[提单号],[文件编号],[邮件编号],[电子档案路径],[是否公共],[任务相关人员],[SEA编号]) select newid(),null,'EDI订舱','FTP','未开始','海尔订舱:{returndata.dischargePort}','DEMO-SA',GETDATE(),GETDATE(),'手动',NULL,0,'',null,null,null,0,'{TaskEmployee}','{BSNO}' ";
|
|
|
|
|
|
|
|
|
|
SqlCommand cmdtast = new SqlCommand(tastStr, dbcon);
|
|
|
|
|
cmdtast.ExecuteNonQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
dbcon.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
log.Debug($"记录插入错误:{e.Message}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
log.Debug($"数据返回信息:{parseJsonObj.msg}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
File.WriteAllText(CfgFilePath, endtime);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error(ex.Message);
|
|
|
|
|
log.Error(ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class JsonBook
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public string scope { get; set; }
|
|
|
|
|
public string orderNo { get; set; }
|
|
|
|
|
public string trustDate { get; set; }
|
|
|
|
|
public string @operator { get; set; }
|
|
|
|
|
public string operatorPhone { get; set; }
|
|
|
|
|
public string saleMan { get; set; }
|
|
|
|
|
public string businessType { get; set; }
|
|
|
|
|
public string trustType { get; set; }
|
|
|
|
|
public string reqShipmentDate { get; set; }
|
|
|
|
|
public string reqArrivalDate { get; set; }
|
|
|
|
|
public string goodDeliveryDate { get; set; }
|
|
|
|
|
public string protocol { get; set; }
|
|
|
|
|
public string senderCode { get; set; }
|
|
|
|
|
public string senderName { get; set; }
|
|
|
|
|
public string senderDesc { get; set; }
|
|
|
|
|
public string receiverCode { get; set; }
|
|
|
|
|
public string receiverName { get; set; }
|
|
|
|
|
public string receiverDesc { get; set; }
|
|
|
|
|
public string notifierCode { get; set; }
|
|
|
|
|
public string notifierName { get; set; }
|
|
|
|
|
public string notifierDesc { get; set; }
|
|
|
|
|
public string secondnotifierCode { get; set; }
|
|
|
|
|
public string secondnotifierName { get; set; }
|
|
|
|
|
public string secondnotifierDesc { get; set; }
|
|
|
|
|
public string secondNotifierCode { get; set; }
|
|
|
|
|
public string secondNotifierName { get; set; }
|
|
|
|
|
public string secondNotifierDesc { get; set; }
|
|
|
|
|
public string loadingPortCode { get; set; }
|
|
|
|
|
public string loadingPort { get; set; }
|
|
|
|
|
public string dischargePortCode { get; set; }
|
|
|
|
|
public string dischargePort { get; set; }
|
|
|
|
|
public string transPortCode { get; set; }
|
|
|
|
|
public string transPort { get; set; }
|
|
|
|
|
public string loadPlace { get; set; }
|
|
|
|
|
public string deliveryPlace { get; set; }
|
|
|
|
|
public string country { get; set; }
|
|
|
|
|
public string airLine { get; set; }
|
|
|
|
|
public string shipCompanyCode { get; set; }
|
|
|
|
|
public string shipCompany { get; set; }
|
|
|
|
|
public string shipName { get; set; }
|
|
|
|
|
public string voyageNum { get; set; }
|
|
|
|
|
public string transClause { get; set; }
|
|
|
|
|
public string freightClause { get; set; }
|
|
|
|
|
public string priceClause { get; set; }
|
|
|
|
|
public string signType { get; set; }
|
|
|
|
|
public string goodsNum { get; set; }
|
|
|
|
|
public string goodUnit { get; set; }
|
|
|
|
|
public string grossWeight { get; set; }
|
|
|
|
|
public string volume { get; set; }
|
|
|
|
|
public string productName { get; set; }
|
|
|
|
|
public string goodsType { get; set; }
|
|
|
|
|
public string shipMarks { get; set; }
|
|
|
|
|
public string goodsDesc { get; set; }
|
|
|
|
|
public string bookingComment { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<JsonCtn> contains { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<JsonCtn> containerDTOS { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class JsonCtn
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public string itemNo { get; set; }
|
|
|
|
|
public string boxType { get; set; }
|
|
|
|
|
public string boxQuantity { get; set; }
|
|
|
|
|
public string grossWeight { get; set; }
|
|
|
|
|
public string grossWeightUnit { get; set; }
|
|
|
|
|
public string temperature { get; set; }
|
|
|
|
|
public string temperatureUnit { get; set; }
|
|
|
|
|
public string ventilate { get; set; }
|
|
|
|
|
public string ventilateUnit { get; set; }
|
|
|
|
|
public string humidity { get; set; }
|
|
|
|
|
public string humidityUnit { get; set; }
|
|
|
|
|
}
|
|
|
|
|
public class JsonHBData
|
|
|
|
|
{
|
|
|
|
|
public bool flag { get; set; }
|
|
|
|
|
public List<JsonBook> data { get; set; }
|
|
|
|
|
public string msg { get; set; }
|
|
|
|
|
public string code { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|