| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @GetMapping("/control-det/list") |
| | | @Operation(summary = "功率因数-管控功率因数") |
| | | public CommonResult<List<PowerControlDetDTO>> getPowerControlDetList(@RequestParam Map<String, Object> params) { |
| | | List<PowerControlDetDTO> result = new ArrayList<>(); |
| | | String name = (String)params.get("name"); |
| | | if (StringUtils.isBlank(name)) { |
| | | return CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | |
| | | return CommonResult.error(GlobalErrorCodeConstants.NOT_FOUND); |
| | | } |
| | | List<PowerControlDetEntity> list = powerControlDetService.list(main.getId()); |
| | | return success(ConvertUtils.sourceToTarget(list, PowerControlDetDTO.class)); |
| | | result = ConvertUtils.sourceToTarget(list, PowerControlDetDTO.class); |
| | | |
| | | result.forEach(item -> { |
| | | // 设置随机数据,0.8左右 |
| | | double randomDouble = Math.random(); |
| | | double min = 0.7; |
| | | double max = 0.9; |
| | | double randomNumber = (randomDouble * (max - min + 1)) + min; |
| | | BigDecimal rv = new BigDecimal(randomNumber).setScale(4, BigDecimal.ROUND_HALF_UP); |
| | | item.setValue(rv); |
| | | if (item.getLimitL() != null && rv.compareTo(item.getLimitL()) < 0) { |
| | | item.setStatus(1); |
| | | } |
| | | }); |
| | | return success(result); |
| | | } |
| | | } |