|
@@ -1,16 +1,23 @@
|
|
|
package com.zhiqiyun.open.core.schedule;
|
|
package com.zhiqiyun.open.core.schedule;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.zhiqiyun.open.core.enmus.Gender;
|
|
import com.zhiqiyun.open.core.enmus.Gender;
|
|
|
|
|
+import com.zhiqiyun.open.core.enmus.PassengerType;
|
|
|
|
|
+import com.zhiqiyun.open.core.models.DictCity;
|
|
|
import com.zhiqiyun.open.core.models.equipment.EquipmentPassenger;
|
|
import com.zhiqiyun.open.core.models.equipment.EquipmentPassenger;
|
|
|
import com.zhiqiyun.open.core.models.equipment.EquipmentPassengerPeople;
|
|
import com.zhiqiyun.open.core.models.equipment.EquipmentPassengerPeople;
|
|
|
|
|
+import com.zhiqiyun.open.core.service.DictCityService;
|
|
|
import com.zhiqiyun.open.core.service.EquipmentPassengerPeopleService;
|
|
import com.zhiqiyun.open.core.service.EquipmentPassengerPeopleService;
|
|
|
import com.zhiqiyun.open.core.service.EquipmentPassengerService;
|
|
import com.zhiqiyun.open.core.service.EquipmentPassengerService;
|
|
|
import com.zhiqiyun.open.core.service.SequenceService;
|
|
import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
import com.zhiqiyun.open.utils.DateUtil;
|
|
import com.zhiqiyun.open.utils.DateUtil;
|
|
|
import com.zhiqiyun.open.utils.RandomUtil;
|
|
import com.zhiqiyun.open.utils.RandomUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.data.redis.core.BoundListOperations;
|
|
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
@@ -19,40 +26,59 @@ import java.util.List;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Component
|
|
@Component
|
|
|
public class EquipmentPeople {
|
|
public class EquipmentPeople {
|
|
|
- @Autowired
|
|
|
|
|
- private EquipmentPassengerService equipmentPassengerService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private EquipmentPassengerPeopleService equipmentPassengerPeopleService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private SequenceService sequenceService;
|
|
|
|
|
-
|
|
|
|
|
- @Scheduled(cron = "0/10 * * * * ?")
|
|
|
|
|
- public void createPeople() {
|
|
|
|
|
- List<EquipmentPassenger> listData = this.equipmentPassengerService.list();
|
|
|
|
|
- for (EquipmentPassenger equipment : listData) {
|
|
|
|
|
- int r = RandomUtil.getInt(0, 5);
|
|
|
|
|
- if (r == 0 || r == 1) {
|
|
|
|
|
-
|
|
|
|
|
- Long id = this.sequenceService.nextId();
|
|
|
|
|
- int retentionTime = RandomUtil.getInt(10, 10000);
|
|
|
|
|
-
|
|
|
|
|
- EquipmentPassengerPeople people = new EquipmentPassengerPeople();
|
|
|
|
|
- people.setId(id);
|
|
|
|
|
- people.setEquipmentId(equipment.getId());
|
|
|
|
|
- people.setFaceId(RandomUtil.getuuid());
|
|
|
|
|
- people.setGender(Gender.valueOf(r));
|
|
|
|
|
- people.setFromSource("南宁");
|
|
|
|
|
-
|
|
|
|
|
- people.setInTime(DateUtil.current());
|
|
|
|
|
- int r1 = RandomUtil.getInt(0, 2);
|
|
|
|
|
- if (r1 == 1) {
|
|
|
|
|
- people.setOutTime(DateUtils.addSeconds(people.getInTime(), retentionTime));
|
|
|
|
|
- }
|
|
|
|
|
- people.setRetentionTime(retentionTime);
|
|
|
|
|
- this.equipmentPassengerPeopleService.save(people);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private EquipmentPassengerService equipmentPassengerService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private EquipmentPassengerPeopleService equipmentPassengerPeopleService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DictCityService dictCityService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SequenceService sequenceService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
+
|
|
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
|
|
+ public void createPeople() {
|
|
|
|
|
+ QueryWrapper<DictCity> wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.eq("parent_id", "0");
|
|
|
|
|
+ List<DictCity> listDictCity = this.dictCityService.list(wrapper);
|
|
|
|
|
+ List<EquipmentPassenger> listData = this.equipmentPassengerService.list();
|
|
|
|
|
+ for (EquipmentPassenger equipment : listData) {
|
|
|
|
|
+
|
|
|
|
|
+ int r1 = RandomUtil.getInt(0, listDictCity.size() - 1);
|
|
|
|
|
+ int r2 = r1 % 2 + 1;
|
|
|
|
|
+ PassengerType type = PassengerType.valueOf(r2);
|
|
|
|
|
+
|
|
|
|
|
+ EquipmentPassengerPeople people = new EquipmentPassengerPeople();
|
|
|
|
|
+ people.setId(this.sequenceService.nextId());
|
|
|
|
|
+ people.setPlaceBaseInfoId(equipment.getPlaceBaseInfoId());
|
|
|
|
|
+ people.setEquipmentId(equipment.getId());
|
|
|
|
|
+ people.setPassengerType(type);
|
|
|
|
|
+ people.setCreatedTime(DateUtil.current());
|
|
|
|
|
+ people.setGender(Gender.valueOf(r2));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ people.setFromSource(listDictCity.get(r1).getFullName());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String redisKey = String.format("equipment%s", equipment.getId());
|
|
|
|
|
+ BoundListOperations<String, String> boundListOps = this.stringRedisTemplate.boundListOps(redisKey);
|
|
|
|
|
+ log.info("{}>>>>>{}", boundListOps.size(), JSON.toJSONString(boundListOps.range(0, 10000)));
|
|
|
|
|
+ String faceId;
|
|
|
|
|
+ if (PassengerType.IN.equals(type)) {
|
|
|
|
|
+ faceId = RandomUtil.getuuid();
|
|
|
|
|
+ boundListOps.leftPush(faceId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ faceId = boundListOps.rightPop();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNotBlank(faceId)) {
|
|
|
|
|
+ people.setFaceId(faceId);
|
|
|
|
|
+ this.equipmentPassengerPeopleService.save(people);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|