| | |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.ansteel.api.dto.*; |
| | | import com.iailab.module.ansteel.common.utils.DecimalUtil; |
| | | import com.iailab.module.ansteel.power.entity.*; |
| | | import com.iailab.module.ansteel.power.service.*; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointsValueQueryDTO; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.PredictLastValueReqVO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private PowerCapacitorDetService powerCapacitorDetService; |
| | | |
| | | @Autowired |
| | | private PowerNetDropdownService powerNetDropdownService; |
| | | |
| | | @GetMapping("/net-factor/list") |
| | | @Operation(summary = "功率因数-电网拓扑") |
| | |
| | | |
| | | @GetMapping("/net-factor-dropdown/list") |
| | | @Operation(summary = "功率因数-电网拓扑下拉列表") |
| | | public CommonResult<List<PowerNetFactorDropdownDTO>> getPowerNetFactorDropdownList(@RequestParam String nodeCode) { |
| | | public CommonResult<List<PowerNetDropdownDTO>> getPowerNetFactorDropdownList(@RequestParam String nodeCode) { |
| | | log.info("nodeCode=" + nodeCode); |
| | | List<PowerNetFactorEntity> list = powerNetFactorService.listDropdown(nodeCode); |
| | | return success(ConvertUtils.sourceToTarget(list, PowerNetFactorDropdownDTO.class)); |
| | | List<PowerNetDropdownDTO> result = new ArrayList<>(); |
| | | PowerNetFactorEntity entity = powerNetFactorService.getByNodeCode(nodeCode); |
| | | if (entity == null) { |
| | | return success(result); |
| | | } |
| | | List<PowerNetDropdownEntity> list = new ArrayList<>(); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | if ("望铁关口".equals(entity.getGroupName())) { |
| | | params.put("groupName", entity.getGroupName()); |
| | | params.put("neNodeName", entity.getNodeName()); |
| | | } else { |
| | | params.put("groupName", entity.getNodeName()); |
| | | } |
| | | list = powerNetDropdownService.list(params); |
| | | List<String> points = list.stream().map(item -> { |
| | | return item.getCurCos(); |
| | | }).collect(Collectors.toList()); |
| | | Map<String, Object> pointsRealValue = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(points)) { |
| | | pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | } |
| | | for (PowerNetDropdownEntity netDropdown : list) { |
| | | PowerNetDropdownDTO dto = ConvertUtils.sourceToTarget(netDropdown, PowerNetDropdownDTO.class); |
| | | BigDecimal curCos = BigDecimal.ZERO; |
| | | if (pointsRealValue.get(netDropdown.getCurCos()) != null) { |
| | | curCos = new BigDecimal(pointsRealValue.get(netDropdown.getCurCos()).toString()); |
| | | } |
| | | dto.setCurCos(curCos); |
| | | result.add(dto); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Operation(summary = "功率因数-电容器投退指示灯") |
| | | public CommonResult<List<PowerCapacitorDetDTO>> getPowerCapacitorDetList(@RequestParam Map<String, Object> params) { |
| | | List<PowerCapacitorDetEntity> list = powerCapacitorDetService.list(params); |
| | | log.info("list.size=" + list.size()); |
| | | log.info("list.size=" + list.size()); |
| | | List<String> points = list.stream().map(item -> { |
| | | return item.getPointNo(); |
| | | }).collect(Collectors.toList()); |
| | |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/demand-dropdown/list") |
| | | @Operation(summary = "负荷移植-电网拓扑下拉列表") |
| | | public CommonResult<List<PowerNetDropdownDTO>> getDemandDropdownList(@RequestParam String code) { |
| | | if (StringUtils.isBlank(code)) { |
| | | log.info("code isBlank"); |
| | | return CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | | } |
| | | log.info("code=" + code); |
| | | |
| | | List<PowerNetDropdownDTO> result = new ArrayList<>(); |
| | | PowerDemandEntity entity = powerDemandService.getByCode(code); |
| | | if (entity == null) { |
| | | return success(result); |
| | | } |
| | | List<PowerNetDropdownEntity> list = new ArrayList<>(); |
| | | Map<String, Object> params0 = new HashMap<>(); |
| | | params0.put("groupName", entity.getName()); |
| | | list = powerNetDropdownService.list(params0); |
| | | List<String> points = list.stream().map(item -> { |
| | | return item.getCurCos(); |
| | | }).collect(Collectors.toList()); |
| | | Map<String, Object> pointsRealValue = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(points)) { |
| | | pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | } |
| | | for (PowerNetDropdownEntity netDropdown : list) { |
| | | PowerNetDropdownDTO dto = ConvertUtils.sourceToTarget(netDropdown, PowerNetDropdownDTO.class); |
| | | BigDecimal curCos = BigDecimal.ZERO; |
| | | if (pointsRealValue.get(netDropdown.getCurCos()) != null) { |
| | | curCos = new BigDecimal(pointsRealValue.get(netDropdown.getCurCos()).toString()); |
| | | } |
| | | dto.setCurCos(curCos); |
| | | result.add(dto); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | @PostMapping("/net-factor/history") |
| | | @Operation(summary = "功率因数-根据nodeName获取最近1440min历史数据,月最大,最小值") |
| | | public CommonResult<PowerHistoryDTO> getPowerHistoryData(@RequestBody PowerNetFactorHisReqDTO dto) { |
| | | log.info("PowerNetFactorHisReqDTO=" + JSONObject.toJSONString(dto)); |
| | | PowerHistoryDTO result = new PowerHistoryDTO(); |
| | | String nodeCode = dto.getNodeCode(); |
| | | if (StringUtils.isBlank(nodeCode)) { |
| | | return CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | |
| | | if (StringUtils.isBlank(queryType)) { |
| | | return CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | | } |
| | | PowerNetFactorEntity powerNetFactor = powerNetFactorService.getByNodeCode(nodeCode); |
| | | PowerHistoryDTO result = new PowerHistoryDTO(); |
| | | if (powerNetFactor == null) { |
| | | PowerNetFactorQuery powerNetFactorQuery = null; |
| | | PowerNetFactorEntity powerNetFactorEntity = powerNetFactorService.getByNodeCode(nodeCode); |
| | | PowerNetDropdownEntity powerNetDropdownEntity = powerNetDropdownService.getByNodeCode(nodeCode); |
| | | if (powerNetFactorEntity != null) { |
| | | powerNetFactorQuery = ConvertUtils.sourceToTarget(powerNetFactorEntity, PowerNetFactorQuery.class); |
| | | } else if (powerNetDropdownEntity != null) { |
| | | powerNetFactorQuery = ConvertUtils.sourceToTarget(powerNetDropdownEntity, PowerNetFactorQuery.class); |
| | | } |
| | | if (powerNetFactorQuery == null) { |
| | | log.info("powerNetFactor is null"); |
| | | return success(result); |
| | | } |
| | | log.info("开始查询,"); |
| | | |
| | | ApiPointValueQueryDTO apiPointValueQueryDTO = new ApiPointValueQueryDTO(); |
| | | String pointNo = ""; |
| | | switch (queryType.toUpperCase()) { |
| | | case "P": |
| | | pointNo = powerNetFactor.getCurP(); |
| | | pointNo = powerNetFactorQuery.getCurP(); |
| | | break; |
| | | case "Q": |
| | | pointNo = powerNetFactor.getCurQ(); |
| | | pointNo = powerNetFactorQuery.getCurQ(); |
| | | break; |
| | | case "COS": |
| | | pointNo = powerNetFactor.getCurCos(); |
| | | pointNo = powerNetFactorQuery.getCurCos(); |
| | | break; |
| | | default: |
| | | break; |