| | |
| | | import com.zy.acs.manager.common.config.UplinkProperties; |
| | | import com.zy.acs.manager.common.utils.HttpGo; |
| | | import com.zy.acs.manager.core.integrate.dto.HttpResult; |
| | | import com.zy.acs.manager.core.integrate.dto.TaskUplinkParam; |
| | | import com.zy.acs.manager.core.service.ThreadPoolRegulator; |
| | | import com.zy.acs.manager.manager.entity.Bus; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.enums.TaskUplinkStateType; |
| | | import com.zy.acs.manager.manager.service.BusService; |
| | | import com.zy.acs.manager.manager.service.TaskService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private ThreadPoolRegulator threadPoolRegulator; |
| | | @Autowired |
| | | private BusService busService; |
| | | |
| | | private HttpGo http; |
| | | |
| | |
| | | return false; |
| | | } |
| | | TaskUplinkStateType uplinkStateType = TaskUplinkStateType.of(task.getUplinkSts()); |
| | | if (!uplinkStateType.equals(TaskUplinkStateType.PENDING) && !uplinkStateType.equals(TaskUplinkStateType.FAILED)) { |
| | | if (!uplinkStateType.equals(TaskUplinkStateType.PENDING) |
| | | && !uplinkStateType.equals(TaskUplinkStateType.SENDING) |
| | | && !uplinkStateType.equals(TaskUplinkStateType.FAILED) |
| | | ) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | }, threadPoolRegulator.getInstance()); |
| | | |
| | | // url |
| | | String url = this.http.buildUrl(uplinkProperties.getHost(), uplinkProperties.getPort(), "/cv/station/query"); |
| | | String url = this.http.buildUrl(uplinkProperties.getHost(), uplinkProperties.getPort(), uplinkProperties.getUrl()); |
| | | // headers |
| | | Map<String, String> headers = new HashMap<>(); |
| | | // params |
| | | Map<String, Object> params = new HashMap<>(); |
| | | TaskUplinkParam param = new TaskUplinkParam(); |
| | | if (null != task.getBusId()) { |
| | | Bus bus = busService.getById(task); |
| | | param.setBatchNo(bus.getBusNo()); |
| | | } |
| | | param.setTaskNo(task.getSeqNum()); |
| | | param.setTimestamp(null == task.getEndTime() ? System.currentTimeMillis() : task.getEndTime().getTime()); |
| | | |
| | | HttpResult<?> result; |
| | | try { |
| | | result = postForResult(url, headers, params); |
| | | result = postForResult(url, headers, param); |
| | | Integer code = result.getCode(); |
| | | if (null == code || 200 != code) { |
| | | return false; |
| | | } |
| | | Object data = result.getData(); |
| | | if (Cools.isEmpty(data)) { |
| | | return false; |
| | | } |
| | | // Object data = result.getData(); |
| | | // if (Cools.isEmpty(data)) { |
| | | // return false; |
| | | // } |
| | | } catch (Exception e) { |
| | | log.error("Uplink report failed, taskId={}", |
| | | JSON.toJSONString(task), |
| | |
| | | return true; |
| | | } |
| | | |
| | | private HttpResult<?> postForResult(String url, Map<String, String> headers, Map<String, Object> params) throws Exception { |
| | | String json = JSON.toJSONString(params); |
| | | private HttpResult<?> postForResult(String url, Map<String, String> headers, TaskUplinkParam param) throws Exception { |
| | | String json = JSON.toJSONString(param); |
| | | HttpGo.HttpResponse response = this.http.postJson(url, headers, json); |
| | | |
| | | int status = response.statusCode(); |