| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.model.Bikes; |
| | | import com.doumee.jtt808.web.service.Jtt808Service; |
| | | import com.doumee.service.business.BikesService; |
| | | import io.github.yezhihao.netmc.core.annotation.Async; |
| | | import io.github.yezhihao.netmc.core.annotation.AsyncBatch; |
| | |
| | | public class JT808Endpoint { |
| | | |
| | | @Autowired |
| | | private BikesService bikesService; |
| | | private Jtt808Service jtt808Service; |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(JT808Endpoint.class); |
| | | |
| | |
| | | @AsyncBatch(poolSize = 2, maxElements = 4000, maxWait = 1000) |
| | | @Mapping(types = 位置信息汇报, desc = "位置信息汇报") |
| | | public void T0200(List<T0200> list) { |
| | | for(T0200 m : list){ |
| | | Bikes bike = new Bikes(); |
| | | bike.setDeviceSn(m.getClientId()); |
| | | if(m.getLatitude()!=0){ |
| | | bike.setLatitude(new BigDecimal(m.getLatitude()).divide(new BigDecimal(1000000),8,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if(m.getLongitude()!=0){ |
| | | bike.setLongitude(new BigDecimal(m.getLongitude()).divide(new BigDecimal(1000000),8,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | bike.setHeartDate(DateUtil.getDateFromLocalDateTime(m.getDeviceTime())); |
| | | if(m.getAttributes()!=null ){ |
| | | Battery battery= (Battery) m.getAttributes().get(AttributeKey.Battery); |
| | | if(battery !=null && battery.getVoltage()!=null){ |
| | | bike.setVoltage(new BigDecimal(battery.getVoltage())); |
| | | } |
| | | } |
| | | bikesService.updateByJtt(bike); |
| | | } |
| | | jtt808Service.updateBikesInfo(list); |
| | | System.out.println(JSONObject.toJSONString(list) |
| | | ); |
| | | } |