protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case WM_COPYDATA: COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); string[] messColl = mystr.lpData.Split(new char[] { '=' }); if (messColl[0] == "D00") { //MessageBox.Show(mystr.lpData); FileWorker.LogHelper.WriteLog("接受车底信息记录D00:" + mystr.lpData); MessCommand messComm = Utils.ParseCarScanMess(messColl); string jsonMess = messComm.toJson(); KafkaWorker.sendCarRecordMessage(jsonMess); Task.Run(() => { //在上传图片之前先进行压缩,保存到本地上,然后拿到压缩后的路径,进行FTP的上传 //string path = string.Format("/{0}/{1}", DateTime.Now.ToString("yyyy.MM.dd"), Path.GetFileName(messComm.body.vechicleInUvssPicpath)); FtpStatus ftpStatus = FtpHelper.upload(messColl[4], messComm.body.vechicleInUvssPicpath); if (ftpStatus == FtpStatus.Success) { FileWorker.LogHelper.WriteLog("上传文件" + messColl[4] + "成功"); } else if (ftpStatus == FtpStatus.Skipped) { FileWorker.LogHelper.WriteLog("上传文件" + messColl[4] + "在服务端已存在,跳过传输"); } else { FileWorker.LogHelper.WriteLog("上传文件" + messColl[4] + "失败"); string txtPath = Application.StartupPath + "\\imageErrorMess.txt"; string txt = string.Format("{0}|{1}", messColl[4], messComm.body.vechicleInUvssPicpath); WriteLogFile(txtPath, txt); } //string txtPath = Application.StartupPath + "\\imageErrorMess.txt"; //string txt = string.Format("{0}|{1}", messComm.body.vechicleInUvssPicpath, path); //WriteLogFile(txtPath, txt); }); } else if (messColl[0] == "D01") { //FileWorker.LogHelper.WriteLog("基本工作状态D01:" + mystr.lpData); //WorkingState work = Utils.ParseWorkMess(messColl); //string jsonMess = work.toJson(); //KafkaTest.SendMessCommand(jsonMess); } else if (messColl[0] == "D02") { FileWorker.LogHelper.WriteLog("第3方自定义功能D02:" + mystr.lpData); if (messColl[1] == "0") { this.Close(); } else if (messColl[1] == "1") { this.TopMost = true; } else if (messColl[1] == "2") //D02 = 2 = N = EOF { //N 最大接入许可数量 //MessageOrder work = Utils.ParseMessOrder(messColl); //上行,发送"U02=2=EOF" SendResponOrder(); } else { } } else { FileWorker.LogHelper.WriteLog("未知命令:" + mystr.lpData); //MessageBox.Show(mystr.lpData); } break; default: base.DefWndProc(ref m); break; } }
public static MessCommand ParseCarScanMess(string[] inforColl) { MessCommand messCommand = null; try { //FileWorker.LogHelper.WriteLog("解析汽车记录失败," + ex.Message); messCommand = new MessCommand(); #region meta messCommand.meta.eventType = "CROSSING_CAR_PASS_INFO"; messCommand.meta.msgType = "CROSSING_DATA"; messCommand.meta.receiver = ""; messCommand.meta.recvSequence = ""; messCommand.meta.recvTime = ""; messCommand.meta.sender = "CROSSING"; messCommand.meta.sendTime = DateTime.Now.ToString("yyyyMMddHHmmss"); messCommand.meta.sequence = ""; #endregion #region body #region //messCommand.body.cardNo = ""; //messCommand.body.carTypeCode = ""; //messCommand.body.carType = ""; //messCommand.body.capPlace = ""; //messCommand.body.imgName = ""; //messCommand.body.capRemark = ""; //messCommand.body.vechicleShape = ""; //messCommand.body.vechicleShapeName = ""; //messCommand.body.vechicleColour = ""; //messCommand.body.vechicleColourName = ""; //messCommand.body.vechicleInUvssImg = ""; //messCommand.body.vechicleInAnprImg = ""; //messCommand.body.vechicleInTopImg = ""; //messCommand.body.vechicleInTopPicpath = ""; //messCommand.body.vechicleOutTime = ""; //messCommand.body.vechicleInState = ""; //messCommand.body.vechicleInStateName = ""; //messCommand.body.driverName = ""; //messCommand.body.driverCard = ""; //messCommand.body.driverLicense = ""; //messCommand.body.vechicleDept = ""; //messCommand.body.createDate = ""; //messCommand.body.updateDate = ""; //messCommand.body.airportIata = ""; //messCommand.body.airportIame = ""; #endregion messCommand.body.capTime = inforColl[1]; messCommand.body.parkCode = inforColl[3]; //string test = "https://img-blog.csdnimg.cn/2020091110132619.jpg"; //test = "https://img-blog.csdnimg.cn/20191016215757571.png"; messCommand.body.vechicleInAnprPicpath = BaseHelper.ImgToBase64String(inforColl[5]); messCommand.body.vechicleInUvssPicpath = inforColl[4]; messCommand.body.vechicleInUvssPicpath = string.Format("/photo/sodb/{0}/{1}", DateTime.Now.ToString("yyyyMMdd"), Path.GetFileName(messCommand.body.vechicleInUvssPicpath)); messCommand.body.plateNo = inforColl[6]; if (inforColl[7] == "0") { messCommand.body.capFlag = "1"; } else { messCommand.body.capFlag = "0"; } messCommand.body.driverJobNo = inforColl[11]; #endregion } catch (Exception ex) { FileWorker.LogHelper.WriteLog("解析D00记录失败," + ex.Message); } return(messCommand); }