|
@@ -3,10 +3,8 @@ package com.platform.rest.controller.remote;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.constant.RedisKeyConstants;
|
|
|
-import com.platform.common.util.BeanConverterUtil;
|
|
|
-import com.platform.common.util.R;
|
|
|
-import com.platform.common.util.RedisUtils;
|
|
|
-import com.platform.common.util.StringUtils;
|
|
|
+import com.platform.common.constant.UpmsRedisKeyConstants;
|
|
|
+import com.platform.common.util.*;
|
|
|
import com.platform.common.validation.group.AddGroup;
|
|
|
import com.platform.common.validation.group.UpdateGroup;
|
|
|
import com.platform.dao.dto.remote.RemoteOpcDTO;
|
|
@@ -18,12 +16,14 @@ import com.platform.dao.vo.query.remote.RemoteOpcVO;
|
|
|
import com.platform.rest.log.annotation.SysLog;
|
|
|
import com.platform.service.remote.RemoteOpcService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -36,8 +36,9 @@ import java.util.List;
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
@RequestMapping("/remote/opcs")
|
|
|
+@Slf4j
|
|
|
public class RemoteOpcController {
|
|
|
- private final RemoteOpcService remoteMeasureService;
|
|
|
+ private final RemoteOpcService remoteOpcService;
|
|
|
|
|
|
/**
|
|
|
* 通过id查询单条记录
|
|
@@ -47,7 +48,7 @@ public class RemoteOpcController {
|
|
|
*/
|
|
|
@GetMapping("/{id}")
|
|
|
public R<RemoteOpc> getById(@PathVariable("id") String id) {
|
|
|
- return new R<>(remoteMeasureService.getModelById(id));
|
|
|
+ return new R<>(remoteOpcService.getModelById(id));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -58,7 +59,7 @@ public class RemoteOpcController {
|
|
|
*/
|
|
|
@GetMapping("/positionNum/{positionNum}/{line}")
|
|
|
public R<RemoteOpc> getByPositionNum(@PathVariable("positionNum") String positionNum, @PathVariable("line") String line) {
|
|
|
- return new R<>(remoteMeasureService.getModelByPositionNumAndLine(positionNum, line));
|
|
|
+ return new R<>(remoteOpcService.getModelByPositionNumAndLine(positionNum, line));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -71,7 +72,7 @@ public class RemoteOpcController {
|
|
|
@PostMapping
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-add')")
|
|
|
public R save(@Validated({AddGroup.class}) @RequestBody RemoteOpcDTO remoteMeasureDTO) {
|
|
|
- return new R<>(remoteMeasureService.saveModelByDTO(remoteMeasureDTO));
|
|
|
+ return new R<>(remoteOpcService.saveModelByDTO(remoteMeasureDTO));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -84,7 +85,7 @@ public class RemoteOpcController {
|
|
|
@PutMapping("/{id}")
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-edit')")
|
|
|
public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody RemoteOpcDTO remoteMeasureDTO) {
|
|
|
- remoteMeasureService.modModelByDTO(remoteMeasureDTO);
|
|
|
+ remoteOpcService.modModelByDTO(remoteMeasureDTO);
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
@@ -99,7 +100,7 @@ public class RemoteOpcController {
|
|
|
@PutMapping("/group/add/{positionNum}")
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-edit')")
|
|
|
public R addGroup(@PathVariable("positionNum") String positionNum) {
|
|
|
- remoteMeasureService.addToGroup(positionNum);
|
|
|
+ remoteOpcService.addToGroup(positionNum);
|
|
|
return new R<>("已加入待采集列表,10秒后自动采集");
|
|
|
}
|
|
|
|
|
@@ -112,7 +113,7 @@ public class RemoteOpcController {
|
|
|
@PutMapping("/group/addAll")
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-edit')")
|
|
|
public R addGroupAll(RemoteOpcDTO remoteMeasureDTO) {
|
|
|
- remoteMeasureService.addAllToGroup(remoteMeasureDTO);
|
|
|
+ remoteOpcService.addAllToGroup(remoteMeasureDTO);
|
|
|
return new R<>("已加入待采集列表,10秒后自动采集");
|
|
|
}
|
|
|
|
|
@@ -140,7 +141,7 @@ public class RemoteOpcController {
|
|
|
@PutMapping("/update/batch/{updateType}/{value}")
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-del')")
|
|
|
public R updateIds(@RequestBody List<String> ids, @PathVariable("updateType") Integer updateType, @PathVariable("value") Integer value) {
|
|
|
- remoteMeasureService.updateIds(ids, updateType, value);
|
|
|
+ remoteOpcService.updateIds(ids, updateType, value);
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
@@ -154,7 +155,7 @@ public class RemoteOpcController {
|
|
|
@DeleteMapping("/{id}")
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-del')")
|
|
|
public R removeById(@PathVariable String id) {
|
|
|
- remoteMeasureService.deleteByPrimaryKey(id);
|
|
|
+ remoteOpcService.deleteByPrimaryKey(id);
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
@@ -168,7 +169,7 @@ public class RemoteOpcController {
|
|
|
@DeleteMapping("")
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-del')")
|
|
|
public R removeIds(@RequestBody List<String> ids) {
|
|
|
- remoteMeasureService.batchDelete(ids);
|
|
|
+ remoteOpcService.batchDelete(ids);
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
@@ -182,7 +183,7 @@ public class RemoteOpcController {
|
|
|
*/
|
|
|
@GetMapping("/page")
|
|
|
public R<AbstractPageResultBean<RemoteOpcVO>> queryPage(RemoteOpcDTO remoteMeasureDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
|
|
|
- return new R<>(remoteMeasureService.selectPageList(remoteMeasureDTO, pageNum, pageSize));
|
|
|
+ return new R<>(remoteOpcService.selectPageList(remoteMeasureDTO, pageNum, pageSize));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -193,12 +194,13 @@ public class RemoteOpcController {
|
|
|
*/
|
|
|
@GetMapping("")
|
|
|
public R query(RemoteOpcDTO remoteMeasureDTO) {
|
|
|
- return new R<>(remoteMeasureService.selectList(remoteMeasureDTO));
|
|
|
+ return new R<>(remoteOpcService.selectList(remoteMeasureDTO));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取实时数据列表,从redis里面获取
|
|
|
+ * 同时处理判断超阈值的问题,超过最大预警值,就需要弹出消息:异步处理
|
|
|
*
|
|
|
* @param remoteMeasureDTO opc点位对应表DTO
|
|
|
* @return R
|
|
@@ -206,11 +208,17 @@ public class RemoteOpcController {
|
|
|
@GetMapping("/redis")
|
|
|
public R queryFromRedis(RemoteOpcDTO remoteMeasureDTO) {
|
|
|
String jsonStr = RedisUtils.getString(RedisKeyConstants.DCS_PREFIX + remoteMeasureDTO.getLine());
|
|
|
+ log.info("jsonStr: " + jsonStr);
|
|
|
+ List<RemoteOpcVO> resultList = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(jsonStr)) {
|
|
|
- List<RemoteOpcVO> resultList = JSON.parseArray(jsonStr, RemoteOpcVO.class);
|
|
|
- return new R<>(resultList);
|
|
|
+ resultList = JSON.parseArray(jsonStr, RemoteOpcVO.class);
|
|
|
+ } else {
|
|
|
+ resultList = remoteOpcService.selectList(remoteMeasureDTO);
|
|
|
}
|
|
|
- return new R<>(remoteMeasureService.selectList(remoteMeasureDTO));
|
|
|
+ if (BeanUtils.isDev() ) {
|
|
|
+ remoteOpcService.sendWarn(resultList);
|
|
|
+ }
|
|
|
+ return new R<>(resultList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -223,7 +231,7 @@ public class RemoteOpcController {
|
|
|
@SysLog("opc点位对应表导出")
|
|
|
@PreAuthorize("@pms.hasPermission('remote-opcs-export')")
|
|
|
public void export(HttpServletResponse response, RemoteOpcDTO remoteMeasureDTO) {
|
|
|
- List<RemoteOpcVO> list = remoteMeasureService.selectList(remoteMeasureDTO);
|
|
|
+ List<RemoteOpcVO> list = remoteOpcService.selectList(remoteMeasureDTO);
|
|
|
ExcelUtil.exportResponseDict(response, ExportRemoteOpcVO.class, BeanConverterUtil.copyListProperties(list, ExportRemoteOpcVO.class), "opc点位对应表");
|
|
|
}
|
|
|
|
|
@@ -236,7 +244,7 @@ public class RemoteOpcController {
|
|
|
@SysLog("新增opc点位数据导入")
|
|
|
@PostMapping("/import/{line}")
|
|
|
public R importExcel(@RequestParam("file") MultipartFile file, @PathVariable("line") String line) throws Exception {
|
|
|
- String result = remoteMeasureService.importListByAdd(file, line);
|
|
|
+ String result = remoteOpcService.importListByAdd(file, line);
|
|
|
return new R<>(result);
|
|
|
}
|
|
|
|