|
@@ -8,6 +8,7 @@ import com.platform.common.validation.group.UpdateGroup;
|
|
|
import com.platform.dao.dto.remote.RemoteOpcDTO;
|
|
|
import com.platform.dao.dto.remote.RemoteOpcLogDTO;
|
|
|
import com.platform.dao.entity.remote.RemoteOpc;
|
|
|
+import com.platform.dao.enums.RemoteOpcTypeEnum;
|
|
|
import com.platform.dao.influxdb.InfluxDBService;
|
|
|
import com.platform.dao.util.ExcelUtil;
|
|
|
import com.platform.dao.vo.export.remote.ExportRemoteOpcLogOneDayVO;
|
|
@@ -18,6 +19,7 @@ import com.platform.service.remote.RemoteOpcService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.math.RandomUtils;
|
|
|
+import org.apache.poi.util.SystemOutLogger;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -55,12 +57,23 @@ public class InfluxDBController {
|
|
|
@PutMapping("/{id}")
|
|
|
public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody RemoteOpcDTO remoteMeasureDTO) {
|
|
|
RemoteOpcVO vo = BeanConverterUtil.copyObjectProperties(remoteOpcService.getModelById(id), RemoteOpcVO.class);
|
|
|
- float value = RandomUtils.nextFloat();
|
|
|
- vo.setResult(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ if(vo.getType().equals(RemoteOpcTypeEnum.SHORT.getValue())){
|
|
|
+ float value = RandomUtils.nextFloat();
|
|
|
+ vo.setResult(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ }else{
|
|
|
+ boolean value = RandomUtils.nextBoolean();
|
|
|
+ vo.setResult(new BigDecimal(value?1:0));
|
|
|
+ }
|
|
|
+
|
|
|
influxDBService.writeOne(vo);
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ boolean value = RandomUtils.nextBoolean();
|
|
|
+ System.out.println(new BigDecimal(value?1:0));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增点位记录
|
|
|
* remoteMeasureDTO
|
|
@@ -73,8 +86,13 @@ public class InfluxDBController {
|
|
|
public R updateBatch(@RequestBody RemoteOpcDTO remoteOpcDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
|
|
|
List<RemoteOpcVO> voList = remoteOpcService.selectPageList(null, pageNum, pageSize).getRows();
|
|
|
for (RemoteOpcVO vo : voList) {
|
|
|
- float value = RandomUtils.nextFloat();
|
|
|
- vo.setResult(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ if(vo.getType().equals(RemoteOpcTypeEnum.SHORT.getValue())){
|
|
|
+ float value = RandomUtils.nextFloat();
|
|
|
+ vo.setResult(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ }else{
|
|
|
+ boolean value = RandomUtils.nextBoolean();
|
|
|
+ vo.setResult(new BigDecimal(value?1:0));
|
|
|
+ }
|
|
|
}
|
|
|
influxDBService.writeBatch(voList);
|
|
|
return new R<>("批量新增点位记录成功");
|