| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.data.GatewayDeviceProtocol; |
| | | import com.fzzy.api.entity.ApiConfs; |
| | | import com.fzzy.api.service.*; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.api.utils.RedisUtil; |
| | | import com.fzzy.gateway.api.GatewayRemoteManager; |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.gateway.data.WeatherWebDto; |
| | | import com.fzzy.gateway.entity.GatewayConf; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.gateway.service.GatewayConfService; |
| | | import com.fzzy.gateway.util.GatewayHttpUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private GatewayConfService confService; |
| | | |
| | | @Resource |
| | | private GatewayRemoteManager gatewayRemoteManager; |
| | | |
| | |
| | | doHeartbeat(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * 每间隔3秒执行一次事件 |
| | | */ |
| | | @Scheduled(cron = "0/3 * * * * ?") |
| | | public void scheduled3() { |
| | | |
| | | //执行HTTP地磅请求 |
| | | exeHttpWeightReq(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 每间隔30分钟执行一次 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 执行地磅HTTP请求协议 |
| | | */ |
| | | private void exeHttpWeightReq() { |
| | | //获取设备 |
| | | Collection<GatewayDevice> list = GatewayUtils.listDeviceWeight(); |
| | | |
| | | if (null == list || list.isEmpty()) return; |
| | | |
| | | BaseReqData reqData; |
| | | for (GatewayDevice device : list) { |
| | | |
| | | if (!GatewayDeviceProtocol.DEVICE_WEIGHT_HTTP.getCode().equals(device.getSyncProtocol())) { |
| | | continue; |
| | | } |
| | | |
| | | reqData = new BaseReqData(); |
| | | reqData.setDevice(device); |
| | | reqData.setDeviceName(device.getDeviceName()); |
| | | reqData.setProductId(device.getProductId()); |
| | | reqData.setDeviceId(device.getDeviceId()); |
| | | |
| | | gatewayRemoteManager.getSyncWeightService(device.getSyncProtocol()).syncWeightInfo(reqData); |
| | | } |
| | | } |
| | | } |