对比新文件 |
| | |
| | | package com.iailab.module.ansteel.job.task; |
| | | |
| | | 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.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; |
| | | import com.iailab.module.model.api.mdk.MdkApi; |
| | | import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; |
| | | import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 有功优化模型 |
| | | * 30 0/1 * * * ? |
| | | * <p> |
| | | * 实时检测望铁1#+望铁2#有功功率,当望铁1#+望铁2#连续5分钟上网(望铁1#+望铁2#有功功率>=0)触发模型 |
| | | * M0000101267+M0000101265 |
| | | * {'status_code': 100, 'result': {'reason': '135机组发电出力增加35.43%、CCPP发电出力增加12.10%、1#LF炉处于未生产状态:建议发电减少14MW'}} |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年06月11日 |
| | | */ |
| | | @Component("runOnPowerOptimTask") |
| | | public class RunOnPowerOptimTask implements ITask { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | @Autowired |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Autowired |
| | | private MdkApi mdkApi; |
| | | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | private final static String POINT_NO = "RunOnPowerOptimTask"; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | | logger.info("RunOnPowerOptimTask定时任务正在执行,参数为:{}", params); |
| | | try { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | Date endTime = calendar.getTime(); |
| | | calendar.add(Calendar.MINUTE, -5); |
| | | Date startTime = calendar.getTime(); |
| | | |
| | | ApiPointValueQueryDTO pointValueQueryDTO = new ApiPointValueQueryDTO(); |
| | | pointValueQueryDTO.setPointNo(POINT_NO); |
| | | pointValueQueryDTO.setStart(startTime); |
| | | pointValueQueryDTO.setEnd(endTime); |
| | | List<ApiPointValueDTO> valueList = dataPointApi.queryPointHistoryValue(pointValueQueryDTO); |
| | | boolean flag = true; |
| | | if (CollectionUtils.isEmpty(valueList)) { |
| | | flag = false; |
| | | } |
| | | for (ApiPointValueDTO apiPointValueDTO : valueList) { |
| | | if (apiPointValueDTO.getV() < 0) { |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if (flag) { |
| | | MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); |
| | | dto.setScheduleTime(calendar.getTime()); |
| | | dto.setScheduleCode(params); |
| | | MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
| | | logger.info(params + "调度方案执行完成," + mdkScheduleRespDTO); |
| | | Map<String, Object> result = mdkScheduleRespDTO.getResult(); |
| | | for (Map.Entry<String, Object> entry : result.entrySet()) { |
| | | String key = entry.getKey(); |
| | | this.saveScheduleSuggest("有功优化", entry.getValue(), "YGYH", calendar.getTime()); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception ex) { |
| | | logger.error("RunOnPowerOptimTask运行异常", ex); |
| | | } |
| | | logger.info("RunOnPowerOptimTask运行完成"); |
| | | } |
| | | |
| | | private void saveScheduleSuggest(String title, Object content, String scheduleObj, Date scheduleTime) { |
| | | if (content == null || StringUtils.isBlank(content.toString()) || "0".equals(content.toString())) { |
| | | logger.info(title + "content为空"); |
| | | return; |
| | | } |
| | | ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); |
| | | suggest.setTitle(title); |
| | | suggest.setContent(content.toString()); |
| | | suggest.setScheduleObj(scheduleObj); |
| | | suggest.setScheduleTime(scheduleTime); |
| | | suggest.setSort(0); |
| | | mcsApi.createScheduleSuggest(suggest); |
| | | } |
| | | } |