|
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -55,7 +56,7 @@ public class InfluxDBController {
|
|
|
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));
|
|
|
+ vo.setResult(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
|
|
|
influxDBService.writeOne(vo);
|
|
|
return new R<>();
|
|
|
}
|
|
@@ -73,7 +74,7 @@ public class InfluxDBController {
|
|
|
List<RemoteOpcVO> voList = remoteOpcService.selectPageList(null, pageNum, pageSize).getRows();
|
|
|
for (RemoteOpcVO vo : voList) {
|
|
|
float value = RandomUtils.nextFloat();
|
|
|
- vo.setResult(new BigDecimal(value).setScale(2));
|
|
|
+ vo.setResult(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
influxDBService.writeBatch(voList);
|
|
|
return new R<>("批量新增点位记录成功");
|