|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zhiqiyun.open.annotation.Permission;
|
|
import com.zhiqiyun.open.annotation.Permission;
|
|
|
|
|
+import com.zhiqiyun.open.core.enmus.Gender;
|
|
|
import com.zhiqiyun.open.core.enmus.PassengerType;
|
|
import com.zhiqiyun.open.core.enmus.PassengerType;
|
|
|
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;
|
|
@@ -27,7 +28,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@RestController
|
|
@RestController
|
|
@@ -89,6 +93,73 @@ public class EquipmentPassengerController {
|
|
|
return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Permission(value = "equipment.passenger.find", tags = "查询人流采集设备详情")
|
|
|
|
|
+ @PostMapping("/findDetail")
|
|
|
|
|
+ public Result findDetail(Long id) {
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
+ QueryWrapper<EquipmentPassengerPeople> wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.eq("equipment_id", id);
|
|
|
|
|
+ wrapper.eq("passenger_type", PassengerType.IN);
|
|
|
|
|
+ Long inCount = this.equipmentPassengerPeopleService.count(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.eq("equipment_id", id);
|
|
|
|
|
+ wrapper.eq("passenger_type", PassengerType.OUT);
|
|
|
|
|
+ Long outCount = this.equipmentPassengerPeopleService.count(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.select("gender", "count(id) value");
|
|
|
|
|
+ wrapper.eq("equipment_id", id);
|
|
|
|
|
+ wrapper.groupBy("gender");
|
|
|
|
|
+ List<Map<String, Object>> listGenders = this.equipmentPassengerPeopleService.listMaps(wrapper);
|
|
|
|
|
+ for (Map<String, Object> genderMap : listGenders) {
|
|
|
|
|
+ int genderValue = Integer.parseInt(genderMap.get("gender").toString());
|
|
|
|
|
+ Gender gender = Gender.valueOf(genderValue);
|
|
|
|
|
+ if (gender != null) {
|
|
|
|
|
+ genderMap.put("name", gender.getText());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.select("from_source name", "count(id) value");
|
|
|
|
|
+ wrapper.eq("equipment_id", id);
|
|
|
|
|
+ wrapper.groupBy("from_source");
|
|
|
|
|
+ wrapper.orderByDesc("value");
|
|
|
|
|
+ wrapper.last("limit 8");
|
|
|
|
|
+ List<Map<String, Object>> listFromSource = this.equipmentPassengerPeopleService.listMaps(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.select("AVG(unix_timestamp(created_time)) t", "passenger_type");
|
|
|
|
|
+ wrapper.eq("equipment_id", id);
|
|
|
|
|
+ wrapper.groupBy("passenger_type");
|
|
|
|
|
+ List<Map<String, Object>> listPassenger = this.equipmentPassengerPeopleService.listMaps(wrapper);
|
|
|
|
|
+ int avgInTime = 0;
|
|
|
|
|
+ int avgOutTime = 0;
|
|
|
|
|
+ for (Map<String, Object> avgMap : listPassenger) {
|
|
|
|
|
+ int passengerTypeValue = Integer.parseInt(avgMap.get("passenger_type").toString());
|
|
|
|
|
+ BigDecimal t = new BigDecimal(avgMap.get("t").toString());
|
|
|
|
|
+ PassengerType passengerType = PassengerType.valueOf(passengerTypeValue);
|
|
|
|
|
+ if (PassengerType.IN.equals(passengerType)) {
|
|
|
|
|
+ avgInTime = t.intValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (PassengerType.OUT.equals(passengerType)) {
|
|
|
|
|
+ avgOutTime = t.intValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ dataMap.put("inCount", inCount);
|
|
|
|
|
+ dataMap.put("outCount", outCount);
|
|
|
|
|
+ dataMap.put("listGenders", listGenders);
|
|
|
|
|
+ dataMap.put("listFromSource", listFromSource);
|
|
|
|
|
+ dataMap.put("avgStayTime", avgOutTime - avgInTime);
|
|
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(dataMap);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Permission(value = "equipment.passenger.add", tags = "保存人流采集设备")
|
|
@Permission(value = "equipment.passenger.add", tags = "保存人流采集设备")
|
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
|
public Result save(@Valid @RequestBody SaveEquipmentPassengerParams params) {
|
|
public Result save(@Valid @RequestBody SaveEquipmentPassengerParams params) {
|