79 lines
3.0 KiB
Java
79 lines
3.0 KiB
Java
package com.jepsoninfo.service;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.jepsoninfo.entity.LogEntity;
|
|
import com.jepsoninfo.resp.DcsCallBackReg;
|
|
import com.jepsoninfo.util.*;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.util.List;
|
|
|
|
class ThreadOpenDoor extends Thread{
|
|
private final Logger logger = LoggerFactory.getLogger("ThreadReportDevice.class");
|
|
private HardService hardService;
|
|
private String prefix;
|
|
private String cmd;
|
|
private String jsonReq;
|
|
private String carNo;
|
|
private String devNo;
|
|
private String laneName;
|
|
private String optName = "车牌识别";
|
|
|
|
public ThreadOpenDoor(HardService hardService,String cmd, String prefix, String jsonReq, String optName, String carNo, String devNo, String laneName){
|
|
this.hardService = hardService;
|
|
this.optName = optName;
|
|
this.cmd = cmd;
|
|
this.prefix = prefix;
|
|
this.jsonReq = jsonReq;
|
|
this.carNo = carNo;
|
|
this.devNo = devNo;
|
|
this.laneName = laneName;
|
|
}
|
|
@Override
|
|
public void run() {
|
|
hardService.printDate(carNo,devNo,laneName,optName,"open door thread");
|
|
CmdUtil cmdUtil = new CmdUtil();
|
|
List<String> listRet = cmdUtil.exec(cmd);
|
|
String line;
|
|
|
|
for (int i = 0;i < listRet.size();i++) {
|
|
line = listRet.get(i);
|
|
hardService.printDate(carNo,devNo,laneName,optName,line);
|
|
int pos = line.indexOf(prefix);
|
|
if(pos >= 0){
|
|
String devRet = line.substring(prefix.length());
|
|
//printDate(carNo,devNo,laneName,optName,devRet);
|
|
try {
|
|
DcsCallBackReg openDoorRet = new DcsCallBackReg();
|
|
DeviceRet deviceRet = JSONObject.parseObject(devRet, DeviceRet.class);
|
|
ReturnCode returnCode = new ReturnCode();
|
|
|
|
if(deviceRet != null) {
|
|
if ((deviceRet.getState_code() != null && deviceRet.getState_code().compareTo("200") == 0)
|
|
|| (deviceRet.getCode() != null && deviceRet.getCode().compareTo("200") == 0)) {
|
|
//设置下发开闸指令状态为已下发
|
|
ConstUtil.DOOR_STATUS.put(devNo,ConstUtil.IS_SEND_OPEN_DOOR);
|
|
|
|
returnCode.setCode(ConstUtil.CODE_SUCCESS[0]);
|
|
returnCode.setMsg(ConstUtil.CODE_SUCCESS[1]);
|
|
}
|
|
|
|
String strReturnCode = JSONObject.toJSONString(returnCode);
|
|
openDoorRet.setParams(jsonReq);
|
|
openDoorRet.setResult(strReturnCode);
|
|
|
|
String strReport = JSONObject.toJSONString(openDoorRet);
|
|
|
|
String strRet = HttpClientUtil.postJson(ConstUtil.REPORT_SERVER + ConstUtil.DCS_CALLBACK, strReport);
|
|
}
|
|
}catch (Exception e){
|
|
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|