接口调整
This commit is contained in:
parent
2f493037e4
commit
1f1d2d8bf4
@ -5,7 +5,7 @@ import cn.xuyanwu.spring.file.storage.FileStorageService;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.file.FileUtil;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.camera.MonitorApi;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IFileDetailService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -37,18 +37,28 @@ public class FileController {
|
||||
private FileStorageService fileStorageService;
|
||||
|
||||
@Autowired
|
||||
private MonitorApi monitorApi;
|
||||
private IFileDetailService fileDetailService;
|
||||
|
||||
/**
|
||||
* 上传文件到指定存储平台,成功返回文件信息
|
||||
*/
|
||||
// @OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
// @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
// @PostMapping("/upload")
|
||||
// public Result<FileInfo> uploadPlatform(MultipartFile file) {
|
||||
// return Result.success(fileStorageService.of(file)
|
||||
// .setPlatform("minio-1") //使用指定的存储平台
|
||||
// .upload());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 上传文件到本地,成功返回文件信息
|
||||
*/
|
||||
@OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
@ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
@PostMapping("/upload")
|
||||
public Result<FileInfo> uploadPlatform(MultipartFile file) {
|
||||
return Result.success(fileStorageService.of(file)
|
||||
.setPlatform("minio-1") //使用指定的存储平台
|
||||
.upload());
|
||||
public Result<Map<String, Object>> upload(MultipartFile file) {
|
||||
return Result.success(fileDetailService.upload(file));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -19,8 +19,10 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Date;
|
||||
@ -68,8 +70,8 @@ public class HardWareCallbackController {
|
||||
@Autowired
|
||||
private ISystemDictDataService systemDictDataService;
|
||||
|
||||
@Autowired
|
||||
private KafkaTemplate<String, Object> kafkaTemplate;
|
||||
// @Autowired
|
||||
// private KafkaTemplate<String, Object> kafkaTemplate;
|
||||
|
||||
/**
|
||||
* 新增设备报警信息
|
||||
@ -106,10 +108,11 @@ public class HardWareCallbackController {
|
||||
dustNoiseDataService.save(dustNoiseData);
|
||||
LambdaUpdateWrapper<EnvironmentDev> updateWrapper = Wrappers.<EnvironmentDev>lambdaUpdate();
|
||||
// 修正设备状态
|
||||
if (environmentDev.getState() == 0) {
|
||||
updateWrapper.set(EnvironmentDev::getState, 1);
|
||||
updateWrapper.eq(EnvironmentDev::getState, 0);
|
||||
updateWrapper.eq(EnvironmentDev::getId, environmentDev.getId());
|
||||
environmentDevService.update(updateWrapper);
|
||||
}
|
||||
// 缓存
|
||||
redisRepository.set(CacheConstants.DUST_NOISE_DATA + environmentDev.getCode(), dustNoiseData);
|
||||
String param = dustNoiseData.getProjectSn();
|
||||
@ -117,7 +120,7 @@ public class HardWareCallbackController {
|
||||
param = dustNoiseData.getEngineeringSn();
|
||||
}
|
||||
redisRepository.set(CacheConstants.DUST_NOISE_DATA + param, dustNoiseData);
|
||||
sendMessage(ParamEnum.KafkaTopic.DUST_NOISE.getValue(), JSON.toJSONString(dustNoiseData));
|
||||
// sendMessage(ParamEnum.KafkaTopic.DUST_NOISE.getValue(), JSON.toJSONString(dustNoiseData));
|
||||
return Result.ok("操作成功!");
|
||||
}
|
||||
|
||||
@ -164,7 +167,7 @@ public class HardWareCallbackController {
|
||||
if (num1 > 10) {
|
||||
redisRepository.rightPop(CacheConstants.ENVIRONMENT_ALARM_LIST + param);
|
||||
}
|
||||
sendMessage(ParamEnum.KafkaTopic.ENVIRONMENT_ALARM.getValue(), JSON.toJSONString(environmentAlarm));
|
||||
// sendMessage(ParamEnum.KafkaTopic.ENVIRONMENT_ALARM.getValue(), JSON.toJSONString(environmentAlarm));
|
||||
return Result.success("添加成功!");
|
||||
}
|
||||
|
||||
@ -213,7 +216,7 @@ public class HardWareCallbackController {
|
||||
if (num > 10) {
|
||||
redisRepository.rightPop(CacheConstants.AI_MONITOR_ALARM_LIST + param);
|
||||
}
|
||||
sendMessage(ParamEnum.KafkaTopic.AI_MONITOR_ALARM.getValue(), JSON.toJSONString(aiMonitorAlarm));
|
||||
// sendMessage(ParamEnum.KafkaTopic.AI_MONITOR_ALARM.getValue(), JSON.toJSONString(aiMonitorAlarm));
|
||||
return Result.success("添加成功!");
|
||||
}
|
||||
|
||||
@ -233,12 +236,12 @@ public class HardWareCallbackController {
|
||||
return Result.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* (项目管理子系统)
|
||||
* @param topic
|
||||
* @param normalMessage
|
||||
*/
|
||||
public void sendMessage(@PathVariable("topic") String topic, @PathVariable("message") String normalMessage) {
|
||||
kafkaTemplate.send(topic, normalMessage);
|
||||
}
|
||||
// /**
|
||||
// * (项目管理子系统)
|
||||
// * @param topic
|
||||
// * @param normalMessage
|
||||
// */
|
||||
// public void sendMessage(@PathVariable("topic") String topic, @PathVariable("message") String normalMessage) {
|
||||
// kafkaTemplate.send(topic, normalMessage);
|
||||
// }
|
||||
}
|
||||
|
||||
@ -89,9 +89,12 @@ public class SystemDictDataController {
|
||||
if (StringUtils.isNotBlank(systemDictData.getDictType())) {
|
||||
wrapper.eq(SystemDictData::getDictType, systemDictData.getDictType());
|
||||
}
|
||||
if (SecurityUtil.getUser().getAccountType() != 1) {
|
||||
if (SecurityUtil.getUser() == null || SecurityUtil.getUser().getAccountType() != 1) {
|
||||
wrapper.eq(SystemDictData::getStatus, 1);
|
||||
}
|
||||
if (StringUtils.isNotBlank(systemDictData.getIsDefault())) {
|
||||
wrapper.eq(SystemDictData::getIsDefault, systemDictData.getIsDefault());
|
||||
}
|
||||
wrapper.orderByAsc(SystemDictData::getDictSort);
|
||||
List<SystemDictData> list = systemDictDataService.list(wrapper);
|
||||
result.setSuccess(true);
|
||||
|
||||
@ -134,6 +134,7 @@ public class GovMonitorDevController {
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
LambdaQueryWrapper<Project> wrapper = Wrappers.<Project>lambdaQuery();
|
||||
wrapper.eq(Project::getGovernmentSn, user.getSn());
|
||||
wrapper.eq(Project::getState, 1);
|
||||
if (StringUtils.isNotBlank(projectName)) {
|
||||
wrapper.like(Project::getProjectName, projectName);
|
||||
}
|
||||
|
||||
@ -34,6 +34,9 @@ public class FileDetailServiceImpl extends ServiceImpl<FileDetailMapper, FileDet
|
||||
@Value("${basePath}")
|
||||
private String basePath;
|
||||
|
||||
@Value("${imagePath}")
|
||||
private String imagePath;
|
||||
|
||||
/**
|
||||
* 保存文件信息到数据库
|
||||
*/
|
||||
@ -87,19 +90,22 @@ public class FileDetailServiceImpl extends ServiceImpl<FileDetailMapper, FileDet
|
||||
public Map<String, Object> upload(MultipartFile file) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
String rename = file.getOriginalFilename();
|
||||
String orgName = file.getOriginalFilename();
|
||||
String fileExtension = StringUtils.substringAfter(file.getOriginalFilename(), ".");
|
||||
String generateFileName = CommonUtil.getUUid();
|
||||
String rName = generateFileName + "." + fileExtension;
|
||||
//设置图片路径
|
||||
String completeUrl = basePath + generateFileName + "." + fileExtension;
|
||||
String completeUrl = basePath + rName;
|
||||
File folder = new File(basePath);
|
||||
// 判断路径是否存在,不存在则自动创建
|
||||
if(!folder.exists()){
|
||||
folder.mkdirs();
|
||||
}
|
||||
file.transferTo(new File(folder, generateFileName + "." + fileExtension));
|
||||
file.transferTo(new File(folder, rName));
|
||||
result.put("completeUrl", completeUrl);
|
||||
result.put("filename", rename);
|
||||
result.put("url", imagePath + rName);
|
||||
result.put("originalFilename", orgName);
|
||||
result.put("filename", rName);
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
|
||||
@ -24,5 +24,5 @@ public interface EnterpriseScoreMapper extends BaseMapper<EnterpriseScore> {
|
||||
|
||||
List<EnterpriseScoreDto> pageList(@Param(Constants.WRAPPER)Wrapper<EnterpriseScore> wrapper);
|
||||
|
||||
Integer enterpriseNum(Wrapper<EnterpriseScore> queryWrapper);
|
||||
Integer enterpriseNum(@Param(Constants.WRAPPER)Wrapper<EnterpriseScore> queryWrapper);
|
||||
}
|
||||
|
||||
@ -1,9 +1,15 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.camera.MonitorApi;
|
||||
import com.zhgd.xmgl.modules.wisdom.entity.DustNoiseData;
|
||||
import com.zhgd.xmgl.modules.wisdom.entity.EnvironmentDev;
|
||||
import com.zhgd.xmgl.modules.wisdom.entity.MonitorDev;
|
||||
import com.zhgd.xmgl.modules.wisdom.service.IDustNoiseDataService;
|
||||
import com.zhgd.xmgl.modules.wisdom.service.IEnvironmentDevService;
|
||||
import com.zhgd.xmgl.modules.wisdom.service.IMonitorDevService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -11,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -19,11 +27,17 @@ import java.util.stream.Collectors;
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MonitorTask {
|
||||
public class DevStateTask {
|
||||
|
||||
@Autowired
|
||||
private IMonitorDevService monitorDevService;
|
||||
|
||||
@Autowired
|
||||
private IEnvironmentDevService environmentDevService;
|
||||
|
||||
@Autowired
|
||||
private IDustNoiseDataService dustNoiseDataService;
|
||||
|
||||
@Autowired
|
||||
private MonitorApi monitorApi;
|
||||
/**
|
||||
@ -49,4 +63,25 @@ public class MonitorTask {
|
||||
monitorDevService.updateBatchById(list);
|
||||
log.info("=========定时修正监控点的状态任务执行成功========");
|
||||
}
|
||||
|
||||
/**
|
||||
* ,每十分钟修正扬尘设备的状态
|
||||
*/
|
||||
@Scheduled(cron = "0 0/10 * * * ?")
|
||||
private void environmentDevOnline() {
|
||||
List<EnvironmentDev> offline = new ArrayList<>();
|
||||
List<EnvironmentDev> list = environmentDevService.list();
|
||||
List<String> devList = dustNoiseDataService.list(Wrappers.<DustNoiseData>lambdaQuery().between(DustNoiseData::getCreateTime, DateUtil.offsetMinute(new Date(), -10), new Date()))
|
||||
.stream().map(d -> d.getDeviceCode()).collect(Collectors.toList());
|
||||
for (EnvironmentDev environmentDev : list) {
|
||||
if (!devList.contains(environmentDev.getCode()) && environmentDev.getState() == 1) {
|
||||
environmentDev.setState(0);
|
||||
offline.add(environmentDev);
|
||||
}
|
||||
}
|
||||
if (offline.size() > 0) {
|
||||
environmentDevService.updateBatchById(offline);
|
||||
}
|
||||
log.info("=========定时修正扬尘设备的状态任务执行成功========");
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,8 @@ spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
# 文件存储路径
|
||||
basePath=D:/itbgpImage/
|
||||
# 文件访问路径
|
||||
imagePath=http://192.168.34.155:6688/image/
|
||||
|
||||
# mqtt主题
|
||||
mqtt-scope=devTopic
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
"groupId" : "485e36d471af4f809398babc4abadafe",
|
||||
"name" : "查询工程分类统计",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1685354710938,
|
||||
"updateTime" : 1689313896719,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : "admin",
|
||||
@ -39,15 +39,15 @@ List list = db.select("SELECT d.dict_value, COUNT( a.id ) num FROM engineering a
|
||||
|
||||
Map totalMap = db.selectOne("SELECT COUNT(id) num FROM engineering WHERE #project")
|
||||
String total = totalMap.get("num")
|
||||
List dict = Arrays.asList("房屋建筑", "市政公用");
|
||||
List result = new ArrayList();
|
||||
Integer other = 0;
|
||||
Integer index = 0
|
||||
for (item in list) {
|
||||
Map map = item
|
||||
var dict_value = map.get("dict_value")
|
||||
var num = map.get("num")::int
|
||||
Map resultMap = new HashMap();
|
||||
if (dict.contains(dict_value)){
|
||||
if (index < 3){
|
||||
resultMap.put("dict_value" ,dict_value)
|
||||
resultMap.put("num" ,num)
|
||||
BigDecimal totalNum = new BigDecimal(total);
|
||||
@ -57,6 +57,7 @@ for (item in list) {
|
||||
} else {
|
||||
other = other + num;
|
||||
}
|
||||
index = index + 1
|
||||
}
|
||||
Map otherMap = new HashMap();
|
||||
otherMap.put("dict_value" , "其他")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user