You've already forked FrameTour-BE
Merge branch 'refs/heads/master' into price_inquery
This commit is contained in:
@@ -92,7 +92,6 @@ public class DeviceV2Controller {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public ApiResponse<DeviceV2DTO> getDevice(@PathVariable Long id) {
|
||||
log.info("获取设备信息, id: {}", id);
|
||||
try {
|
||||
DeviceV2DTO device = deviceIntegrationService.getDevice(id);
|
||||
return ApiResponse.success(device);
|
||||
@@ -107,7 +106,6 @@ public class DeviceV2Controller {
|
||||
*/
|
||||
@GetMapping("/{id}/with-config")
|
||||
public ApiResponse<DeviceV2WithConfigDTO> getDeviceWithConfig(@PathVariable Long id) {
|
||||
log.info("获取设备配置信息, id: {}", id);
|
||||
try {
|
||||
DeviceV2WithConfigDTO device = deviceIntegrationService.getDeviceWithConfig(id);
|
||||
return ApiResponse.success(device);
|
||||
@@ -122,7 +120,6 @@ public class DeviceV2Controller {
|
||||
*/
|
||||
@GetMapping("/no/{no}")
|
||||
public ApiResponse<DeviceV2DTO> getDeviceByNo(@PathVariable String no) {
|
||||
log.info("根据设备编号获取设备信息, no: {}", no);
|
||||
try {
|
||||
DeviceV2DTO device = deviceIntegrationService.getDeviceByNo(no);
|
||||
return ApiResponse.success(device);
|
||||
@@ -137,7 +134,6 @@ public class DeviceV2Controller {
|
||||
*/
|
||||
@GetMapping("/no/{no}/with-config")
|
||||
public ApiResponse<DeviceV2WithConfigDTO> getDeviceWithConfigByNo(@PathVariable String no) {
|
||||
log.info("根据设备编号获取设备配置信息, no: {}", no);
|
||||
try {
|
||||
DeviceV2WithConfigDTO device = deviceIntegrationService.getDeviceWithConfigByNo(no);
|
||||
return ApiResponse.success(device);
|
||||
@@ -296,7 +292,6 @@ public class DeviceV2Controller {
|
||||
*/
|
||||
@GetMapping("/{id}/config")
|
||||
public ApiResponse<List<DeviceConfigV2DTO>> getDeviceConfigs(@PathVariable Long id) {
|
||||
log.info("获取设备配置列表, deviceId: {}", id);
|
||||
try {
|
||||
List<DeviceConfigV2DTO> configs = deviceConfigIntegrationService.getDeviceConfigs(id);
|
||||
return ApiResponse.success(configs);
|
||||
@@ -311,7 +306,6 @@ public class DeviceV2Controller {
|
||||
*/
|
||||
@GetMapping("/{id}/flat-config")
|
||||
public ApiResponse<Map<String, Object>> getDeviceFlatConfig(@PathVariable Long id) {
|
||||
log.info("获取设备扁平化配置, deviceId: {}", id);
|
||||
try {
|
||||
Map<String, Object> config = deviceConfigIntegrationService.getDeviceFlatConfig(id);
|
||||
return ApiResponse.success(config);
|
||||
@@ -327,7 +321,6 @@ public class DeviceV2Controller {
|
||||
@GetMapping("/{id}/config/{configKey}")
|
||||
public ApiResponse<DeviceConfigV2DTO> getDeviceConfigByKey(@PathVariable Long id,
|
||||
@PathVariable String configKey) {
|
||||
log.info("根据键获取设备配置, deviceId: {}, configKey: {}", id, configKey);
|
||||
try {
|
||||
DeviceConfigV2DTO config = deviceConfigIntegrationService.getDeviceConfigByKey(id, configKey);
|
||||
return ApiResponse.success(config);
|
||||
|
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class DeviceV2ListResponse {
|
||||
private List<DeviceV2DTO> list;
|
||||
private Long total;
|
||||
private Integer total;
|
||||
private Integer page;
|
||||
private Integer pageSize;
|
||||
}
|
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class DeviceV2WithConfigListResponse {
|
||||
private List<DeviceV2WithConfigDTO> list;
|
||||
private Long total;
|
||||
private Integer total;
|
||||
private Integer page;
|
||||
private Integer pageSize;
|
||||
}
|
@@ -24,7 +24,6 @@ public class DeviceConfigIntegrationService {
|
||||
private static final String SERVICE_NAME = "zt-device";
|
||||
|
||||
public List<DeviceConfigV2DTO> getDeviceConfigs(Long deviceId) {
|
||||
log.info("获取设备配置列表, deviceId: {}", deviceId);
|
||||
CommonResponse<List<DeviceConfigV2DTO>> response = deviceConfigV2Client.getDeviceConfigs(deviceId);
|
||||
return handleResponse(response, "获取设备配置列表失败");
|
||||
}
|
||||
@@ -36,13 +35,11 @@ public class DeviceConfigIntegrationService {
|
||||
}
|
||||
|
||||
public DeviceConfigV2DTO getDeviceConfigByKey(Long deviceId, String configKey) {
|
||||
log.info("根据键获取设备配置, deviceId: {}, configKey: {}", deviceId, configKey);
|
||||
CommonResponse<DeviceConfigV2DTO> response = deviceConfigV2Client.getDeviceConfigByKey(deviceId, configKey);
|
||||
return handleResponse(response, "根据键获取设备配置失败");
|
||||
}
|
||||
|
||||
public Map<String, Object> getDeviceFlatConfig(Long deviceId) {
|
||||
log.info("获取设备扁平化配置, deviceId: {}", deviceId);
|
||||
return fallbackService.executeWithFallback(
|
||||
SERVICE_NAME,
|
||||
"device:flat:config:" + deviceId,
|
||||
|
@@ -11,7 +11,7 @@ public class ScenicFilterPageResponse {
|
||||
private List<ScenicFilterItem> list;
|
||||
|
||||
@JsonProperty("total")
|
||||
private Long total;
|
||||
private Integer total;
|
||||
|
||||
@JsonProperty("page")
|
||||
private Integer page;
|
||||
|
@@ -70,9 +70,9 @@ public class DeviceRepository {
|
||||
}
|
||||
|
||||
public DeviceConfigEntity getDeviceConfig(Long deviceId) {
|
||||
List<DeviceConfigV2DTO> configList = deviceConfigIntegrationService.getDeviceConfigs(deviceId);
|
||||
if (configList != null && !configList.isEmpty()) {
|
||||
return convertToDeviceConfigEntity(configList, deviceId);
|
||||
DeviceConfigManager configManager = getDeviceConfigManager(deviceId);
|
||||
if (configManager != null) {
|
||||
return convertToDeviceConfigEntity(configManager, deviceId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -96,13 +96,26 @@ public class DeviceRepository {
|
||||
/**
|
||||
* 将DeviceConfigV2DTO列表转换为DeviceConfigEntity(为了兼容性)
|
||||
*/
|
||||
private DeviceConfigEntity convertToDeviceConfigEntity(List<DeviceConfigV2DTO> configList, Long deviceId) {
|
||||
private DeviceConfigEntity convertToDeviceConfigEntity(DeviceConfigManager configManager, Long deviceId) {
|
||||
DeviceConfigEntity entity = new DeviceConfigEntity();
|
||||
entity.setId(SnowFlakeUtil.getLongId());
|
||||
entity.setDeviceId(deviceId);
|
||||
|
||||
// 由于DeviceConfigEntity没有通用的configJson字段,这里只设置基本信息
|
||||
// 具体的配置项需要通过DeviceConfigManager来访问
|
||||
// 通过configManager获取对应的字段写入到deviceConfigEntity中
|
||||
entity.setViidType(configManager.getInteger("viid_type"));
|
||||
entity.setStoreType(configManager.getInteger("store_type"));
|
||||
entity.setStoreConfigJson(configManager.getString("store_config_json"));
|
||||
entity.setStoreExpireDay(configManager.getInteger("store_expire_day"));
|
||||
entity.setOnlineCheck(configManager.getInteger("online_check"));
|
||||
entity.setOnlineMaxInterval(configManager.getInteger("online_max_interval"));
|
||||
entity.setCutPre(configManager.getBigDecimal("cut_pre"));
|
||||
entity.setCutPost(configManager.getBigDecimal("cut_post"));
|
||||
entity.setEnablePreBook(configManager.getInteger("enable_pre_book"));
|
||||
entity.setImageFree(configManager.getInteger("image_free"));
|
||||
entity.setVideoFree(configManager.getInteger("video_free"));
|
||||
entity.setPairDevice(configManager.getLong("pair_device"));
|
||||
entity.setVideoCrop(configManager.getString("video_crop"));
|
||||
entity.setCropConfig(configManager.getString("crop_config"));
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
@@ -65,6 +65,9 @@ public class ScenicRepository {
|
||||
|
||||
// 基础配置
|
||||
config.setScenicId(scenicId);
|
||||
if (scenicConfigManager == null) {
|
||||
return config;
|
||||
}
|
||||
|
||||
// 业务流程配置
|
||||
config.setBookRoutine(scenicConfigManager.getInteger("book_routine"));
|
||||
|
@@ -73,6 +73,7 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
|
||||
ScenicReqQuery query = new ScenicReqQuery();
|
||||
query.setPageSize(1000);
|
||||
query.setStatus("1");
|
||||
List<ScenicV2DTO> scenicList = scenicRepository.list(query);
|
||||
List<ScenicEntity> list = scenicList.stream().map(scenic -> {
|
||||
return scenicRepository.getScenic(Long.valueOf(scenic.getId()));
|
||||
|
@@ -2,8 +2,12 @@ package com.ycwl.basic.service.pc.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ycwl.basic.mapper.ScenicDeviceStatsMapper;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
||||
import com.ycwl.basic.model.pc.scenicDeviceStats.resp.ScenicDeviceStatsListResp;
|
||||
import com.ycwl.basic.model.pc.scenicDeviceStats.resp.ScenicDeviceStatsResp;
|
||||
import com.ycwl.basic.repository.DeviceRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.service.pc.DeviceStatsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -17,6 +21,10 @@ import java.util.List;
|
||||
public class DeviceStatsServiceImpl implements DeviceStatsService {
|
||||
@Autowired
|
||||
private ScenicDeviceStatsMapper mapper;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private DeviceRepository deviceRepository;
|
||||
|
||||
@Override
|
||||
public ScenicDeviceStatsListResp queryByScenicId(Long scenicId, Date start, Date end) {
|
||||
@@ -30,10 +38,30 @@ public class DeviceStatsServiceImpl implements DeviceStatsService {
|
||||
if (DateUtil.isIn(start, DateUtil.tomorrow(), DateUtil.yesterday()) && DateUtil.isIn(end, DateUtil.tomorrow(), DateUtil.yesterday())) {
|
||||
resp.setRealtime(true);
|
||||
List<ScenicDeviceStatsResp> data = mapper.countRealtimeStatsByScenicId(scenicId, start, end);
|
||||
data.forEach(item -> {
|
||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||
if (scenic != null) {
|
||||
item.setScenicName(scenic.getName());
|
||||
}
|
||||
DeviceEntity device = deviceRepository.getDevice(item.getDeviceId());
|
||||
if (device != null) {
|
||||
item.setDeviceName(device.getName());
|
||||
}
|
||||
});
|
||||
resp.setData(data);
|
||||
} else {
|
||||
resp.setRealtime(false);
|
||||
List<ScenicDeviceStatsResp> data = mapper.countCachedStatsByScenicId(scenicId, start, end);
|
||||
data.forEach(item -> {
|
||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||
if (scenic != null) {
|
||||
item.setScenicName(scenic.getName());
|
||||
}
|
||||
DeviceEntity device = deviceRepository.getDevice(item.getDeviceId());
|
||||
if (device != null) {
|
||||
item.setDeviceName(device.getName());
|
||||
}
|
||||
});
|
||||
resp.setData(data);
|
||||
}
|
||||
resp.getData().stream()
|
||||
|
@@ -3,9 +3,13 @@ package com.ycwl.basic.service.pc.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
||||
import com.ycwl.basic.model.pc.faceSample.req.FaceSampleReqQuery;
|
||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
||||
import com.ycwl.basic.repository.DeviceRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.service.pc.FaceSampleService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
@@ -22,11 +26,25 @@ import java.util.List;
|
||||
public class FaceSampleServiceImpl implements FaceSampleService {
|
||||
@Autowired
|
||||
private FaceSampleMapper faceSampleMapper;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private DeviceRepository deviceRepository;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<FaceSampleRespVO>> pageQuery(FaceSampleReqQuery faceSampleReqQuery) {
|
||||
PageHelper.startPage(faceSampleReqQuery.getPageNum(),faceSampleReqQuery.getPageSize());
|
||||
List<FaceSampleRespVO> list = faceSampleMapper.list(faceSampleReqQuery);
|
||||
list.forEach(item -> {
|
||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||
if (scenic != null) {
|
||||
item.setScenicName(scenic.getName());
|
||||
}
|
||||
DeviceEntity device = deviceRepository.getDevice(item.getDeviceId());
|
||||
if (device != null) {
|
||||
item.setDeviceName(device.getName());
|
||||
}
|
||||
});
|
||||
PageInfo<FaceSampleRespVO> pageInfo = new PageInfo<>(list);
|
||||
return ApiResponse.success(pageInfo);
|
||||
}
|
||||
|
@@ -4,9 +4,13 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.exception.BaseException;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.repository.DeviceRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.SourceRepository;
|
||||
import com.ycwl.basic.service.pc.ScenicService;
|
||||
import com.ycwl.basic.service.pc.SourceService;
|
||||
@@ -39,12 +43,24 @@ public class SourceServiceImpl implements SourceService {
|
||||
private SourceRepository sourceRepository;
|
||||
@Autowired
|
||||
private ScenicService scenicService;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private DeviceRepository deviceRepository;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<SourceRespVO>> pageQuery(SourceReqQuery sourceReqQuery) {
|
||||
PageHelper.startPage(sourceReqQuery.getPageNum(), sourceReqQuery.getPageSize());
|
||||
List<SourceRespVO> list = sourceMapper.list(sourceReqQuery);
|
||||
list.forEach(sourceRespVO -> {
|
||||
ScenicEntity scenic = scenicRepository.getScenic(sourceRespVO.getScenicId());
|
||||
if (scenic != null) {
|
||||
sourceRespVO.setScenicName(scenic.getName());
|
||||
}
|
||||
DeviceEntity device = deviceRepository.getDevice(sourceRespVO.getDeviceId());
|
||||
if (device != null) {
|
||||
sourceRespVO.setDeviceName(device.getName());
|
||||
}
|
||||
if (sourceRespVO.getVideoUrl() != null) {
|
||||
try {
|
||||
URL url = new URL(sourceRespVO.getVideoUrl());
|
||||
|
@@ -54,10 +54,8 @@
|
||||
</if>
|
||||
</delete>
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO">
|
||||
select f.id, f.scenic_id, s.name scenicName, device_id, d.name deviceName, face_url, f.score, match_sample_ids, first_match_rate, match_result, f.`status`, f.create_at
|
||||
select f.id, f.scenic_id, device_id, face_url, f.score, match_sample_ids, first_match_rate, match_result, f.`status`, f.create_at
|
||||
from face_sample f
|
||||
left join scenic s on s.id = f.scenic_id
|
||||
left join device d on d.id = f.device_id
|
||||
<where>
|
||||
<if test="scenicId!= null and scenicId!= ''">
|
||||
and f.scenic_id = #{scenicId}
|
||||
|
@@ -33,14 +33,10 @@
|
||||
resultType="com.ycwl.basic.model.pc.scenicDeviceStats.resp.ScenicDeviceStatsResp">
|
||||
select
|
||||
ds.scenic_id as scenicId,
|
||||
s.name as scenicName,
|
||||
ds.device_id as deviceId,
|
||||
d.name as deviceName,
|
||||
IFNULL(sum(ds.count), 0) as count
|
||||
from scenic_device_stats ds
|
||||
left join scenic s on ds.scenic_id = s.id
|
||||
left join device d on ds.device_id = d.id
|
||||
where s.id = #{scenicId}
|
||||
where ds.device_id = #{scenicId}
|
||||
and ds.date >= #{start}
|
||||
and ds.date <= #{end}
|
||||
group by ds.scenic_id, ds.device_id
|
||||
@@ -49,9 +45,7 @@
|
||||
resultType="com.ycwl.basic.model.pc.scenicDeviceStats.resp.ScenicDeviceStatsResp">
|
||||
select
|
||||
ds.scenic_id as scenicId,
|
||||
s.name as scenicName,
|
||||
ds.device_id as deviceId,
|
||||
d.name as deviceName,
|
||||
ds.count
|
||||
from (
|
||||
select scenic_id, device_id, count(1) as count
|
||||
@@ -66,8 +60,6 @@
|
||||
)a
|
||||
group by scenic_id, device_id
|
||||
) ds
|
||||
left join scenic s on ds.scenic_id = s.id
|
||||
left join device d on ds.device_id = d.id
|
||||
where s.id = #{scenicId}
|
||||
where ds.scenic_id = #{scenicId}
|
||||
</select>
|
||||
</mapper>
|
@@ -72,10 +72,8 @@
|
||||
</delete>
|
||||
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
|
||||
select so.id, so.scenic_id, de.name as deviceName, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName, so.video_url, so.`type`, so.face_sample_id
|
||||
select so.id, so.scenic_id, device_id, url, so.create_time, so.update_time,so.video_url, so.`type`, so.face_sample_id
|
||||
from source so
|
||||
left join scenic sc on sc.id = so.scenic_id
|
||||
left join device de on de.id = so.device_id
|
||||
<where>
|
||||
<if test="scenicId!= null">and so.scenic_id = #{scenicId} </if>
|
||||
<if test="deviceId!= null">and device_id = #{deviceId} </if>
|
||||
|
Reference in New Issue
Block a user