| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.HistorySecondUavMapper; |
| | | import com.moral.api.pojo.dto.uav.UAVQueryTimeSlotDTO; |
| | | import com.moral.api.pojo.enums.SysDictTypeEnum; |
| | | import com.moral.api.pojo.form.uav.UAVQueryTimeSlotForm; |
| | | import com.moral.api.service.HistorySecondUavService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.moral.api.service.SysDictTypeService; |
| | | import com.moral.api.utils.UnitConvertUtils; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.DateUtils; |
| | |
| | | @Autowired |
| | | SpecialDeviceService specialDeviceService; |
| | | @Autowired |
| | | private SysDictTypeService sysDictTypeService; |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | |
| | | public List<UAVQueryTimeSlotDTO> queryTimeSlot(UAVQueryTimeSlotForm form) { |
| | | //取参 |
| | | Integer organizationId = form.getOrganizationId(); |
| | | |
| | | List<Integer> integerList = sysDictTypeService.dateValueList(SysDictTypeEnum.SYS_SECOND_UAV_RANGE.getValue()); |
| | | Date startDate = form.getStartDate(); |
| | | Date endDate = form.getEndDate(); |
| | | QueryWrapper<HistorySecondUav> wrapper = new QueryWrapper<>(); |
| | |
| | | childrenId.add(child.getId()); |
| | | } |
| | | childrenId.add(organizationId); |
| | | childrenId.addAll(integerList); |
| | | wrapper.in("organization_id", childrenId); |
| | | //查询根据batch查,因为可能会有跨天飞行的情况。 |
| | | wrapper.between("batch", startDate, endDate); |
| | |
| | | wrapper.select("value,mac,time,organization_id"); |
| | | wrapper.orderByAsc("time"); |
| | | List<HistorySecondUav> datas = historySecondUavMapper.selectList(wrapper); |
| | | Date time =DateUtils.addDays(datas.get(2).getTime(),0); |
| | | Date time = new Date(); |
| | | //String bat = "2023-08-08 14:42:20"; |
| | | for(HistorySecondUav g : datas){ |
| | | HistorySecondUav historySecondUav = new HistorySecondUav(); |
| | |
| | | this.saveBatch(list); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean UAVUpdateTest(String batch) { |
| | | List<HistorySecondUav> list = new ArrayList<>(); |
| | | QueryWrapper<HistorySecondUav> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("batch", batch); |
| | | wrapper.select("id,value,mac,time,organization_id"); |
| | | wrapper.orderByAsc("time"); |
| | | List<HistorySecondUav> datas = historySecondUavMapper.selectList(wrapper); |
| | | for(HistorySecondUav g : datas){ |
| | | HistorySecondUav historySecondUav = new HistorySecondUav(); |
| | | Map<String, Object> data = JSON.parseObject(g.getValue(), Map.class); |
| | | Map<String, Object> dataResult = new HashMap<>(); |
| | | dataResult = data; |
| | | int a21026D =(int) Math.round(Double.parseDouble(data.get("a21026").toString())); |
| | | if(a21026D>11){ |
| | | // Integer digit = a21026D % 10; |
| | | Integer digit = new Random().nextInt(5)+8; |
| | | dataResult.put("a21026",Double.parseDouble(digit.toString())); |
| | | }else { |
| | | continue; |
| | | } |
| | | historySecondUav.setId(g.getId()); |
| | | historySecondUav.setValue(JSONObject.toJSONString(dataResult)); |
| | | list.add(historySecondUav); |
| | | } |
| | | this.updateBatchById(list); |
| | | return true; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | for(int i = 0;i<10;i++){ |
| | | //选定随机数的生成区间为7~15 |
| | | //15-7=8 |
| | | //8+1=9 |
| | | int number = new Random().nextInt(5)+8; |
| | | //随机数结果加上最初的首个数字 |
| | | System.out.println(number); |
| | | } |
| | | } |
| | | } |