鞍钢鲅鱼圈能源管控系统后端代码
liriming
2025-06-17 b66bb9f7e496ac2c9295dbe759befd2e276441cf
动态修改备煤模型设置参数
已修改2个文件
已添加1个文件
80 ■■■■■ 文件已修改
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PowerPriceRespVO.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ansteel-biz/src/main/java/com/iailab/module/ansteel/common/constant/CommonConstant.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ansteel-biz/src/main/java/com/iailab/module/ansteel/power/service/impl/PowerPriceMainServiceImpl.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PowerPriceRespVO.java
对比新文件
@@ -0,0 +1,14 @@
package com.iailab.module.ansteel.api.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class PowerPriceRespVO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String type;
    private Object[] value;
}
ansteel-biz/src/main/java/com/iailab/module/ansteel/common/constant/CommonConstant.java
@@ -81,6 +81,9 @@
    String COAL_INDEX_CHARTCODE = "COAL_INDEX";
    String CHEMPROD_INDEX_CHARTCODE = "CHEMPROD_INDEX";
    String COAL_MODEL_CODE = "Coal0611";
    //电容器编码
    String POWER_CODE = "POWER_CODE";
}
ansteel-biz/src/main/java/com/iailab/module/ansteel/power/service/impl/PowerPriceMainServiceImpl.java
@@ -1,11 +1,13 @@
package com.iailab.module.ansteel.power.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.framework.common.util.date.DateUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.security.core.util.SecurityFrameworkUtils;
import com.iailab.module.ansteel.api.dto.PowerPriceDetDTO;
import com.iailab.module.ansteel.api.dto.PowerPriceMainDTO;
import com.iailab.module.ansteel.api.dto.PowerPriceRespVO;
import com.iailab.module.ansteel.common.constant.CommonConstant;
import com.iailab.module.ansteel.power.dao.PowerPriceDetDao;
import com.iailab.module.ansteel.power.dao.PowerPriceMainDao;
@@ -13,13 +15,16 @@
import com.iailab.module.ansteel.power.entity.PowerPriceMainEntity;
import com.iailab.module.ansteel.power.service.PowerPriceDetService;
import com.iailab.module.ansteel.power.service.PowerPriceMainService;
import com.iailab.module.model.api.mcs.McsApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -41,6 +46,12 @@
    @Resource
    private PowerPriceDetService powerPriceDetService;
    @Autowired
    private McsApi mcsApi;
    private String peakKey = "peak_periods_json";//峰
    private String valleyKey = "valley_periods_json";//谷
    private String flatKey = "flat_periods_json";//平
    @Override
    public List<PowerPriceMainDTO> list(Map<String, Object> params) {
@@ -64,7 +75,6 @@
        powerPriceMainDao.updateStatus();
        if (!CollectionUtils.isEmpty(mainDTO.getDetList())) {
            PowerPriceMainEntity powerPriceMainEntity = ConvertUtils.sourceToTarget(mainDTO, PowerPriceMainEntity.class);
            powerPriceMainEntity.setCode(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
            powerPriceMainEntity.setStatus(CommonConstant.IS_ENABLE);
@@ -72,12 +82,37 @@
            powerPriceMainEntity.setCreateDate(new Date());
            powerPriceMainDao.insert(powerPriceMainEntity);
            List<PowerPriceRespVO> list = new ArrayList<>();
            for (int i = 0; i < mainDTO.getDetList().size(); i++) {
                PowerPriceDetEntity powerPriceDetEntity = ConvertUtils.sourceToTarget(mainDTO.getDetList().get(i), PowerPriceDetEntity.class);
                powerPriceDetEntity.setMainId(powerPriceMainEntity.getId());
                powerPriceDetEntity.setSort(i + 1);
                powerPriceDetDao.insert(powerPriceDetEntity);
                ArrayList arrayList = new ArrayList();
                arrayList.add(powerPriceDetEntity.getStart());
                arrayList.add(powerPriceDetEntity.getEnd());
                PowerPriceRespVO powerPriceRespVO = new PowerPriceRespVO();
                if ("峰".equals(powerPriceDetEntity.getName())) {
                    powerPriceRespVO.setType("峰");
                } else if ("谷".equals(powerPriceDetEntity.getName())) {
                    powerPriceRespVO.setType("谷");
                } else if ("平".equals(powerPriceDetEntity.getName())) {
                    powerPriceRespVO.setType("平");
                }
                powerPriceRespVO.setValue(arrayList.stream().toArray(String[]::new));
                list.add(powerPriceRespVO);
            }
            Object[] peakArray = list.stream().filter(e -> e.getType().equals("峰")).collect(Collectors.toList()).stream().map(e -> e.getValue()).collect(Collectors.toList()).stream().toArray(Object[]::new);
            Object[] valleyArray = list.stream().filter(e -> e.getType().equals("谷")).collect(Collectors.toList()).stream().map(e -> e.getValue()).collect(Collectors.toList()).stream().toArray(Object[]::new);
            Object[] flatArray = list.stream().filter(e -> e.getType().equals("平")).collect(Collectors.toList()).stream().map(e -> e.getValue()).collect(Collectors.toList()).stream().toArray(Object[]::new);
            mcsApi.updateScheduleModelSetting(CommonConstant.COAL_MODEL_CODE,peakKey,JSONArray.toJSONString(peakArray));
            mcsApi.updateScheduleModelSetting(CommonConstant.COAL_MODEL_CODE,valleyKey,JSONArray.toJSONString(valleyArray));
            mcsApi.updateScheduleModelSetting(CommonConstant.COAL_MODEL_CODE,flatKey,JSONArray.toJSONString(flatArray));
        }
        return true;
    }
@@ -86,7 +121,6 @@
    @Transactional(rollbackFor = Exception.class)
    public Boolean update(PowerPriceMainDTO mainDTO) {
        if (!CollectionUtils.isEmpty(mainDTO.getDetList())) {
            PowerPriceMainEntity powerPriceMainEntity = powerPriceMainDao.selectById(mainDTO.getId());
            powerPriceMainEntity.setCreator(SecurityFrameworkUtils.getLoginUser().getId());
            powerPriceMainEntity.setCreateDate(new Date());
@@ -96,12 +130,37 @@
            queryWrapper.eq("main_id", powerPriceMainEntity.getId());
            powerPriceDetDao.delete(queryWrapper);
            List<PowerPriceRespVO> list = new ArrayList<>();
            for (int i = 0; i < mainDTO.getDetList().size(); i++) {
                PowerPriceDetEntity powerPriceDetEntity = ConvertUtils.sourceToTarget(mainDTO.getDetList().get(i), PowerPriceDetEntity.class);
                powerPriceDetEntity.setMainId(powerPriceMainEntity.getId());
                powerPriceDetEntity.setSort(i + 1);
                powerPriceDetDao.insert(powerPriceDetEntity);
                ArrayList arrayList = new ArrayList();
                arrayList.add(powerPriceDetEntity.getStart());
                arrayList.add(powerPriceDetEntity.getEnd());
                PowerPriceRespVO powerPriceRespVO = new PowerPriceRespVO();
                if ("峰".equals(powerPriceDetEntity.getName())) {
                    powerPriceRespVO.setType("峰");
                } else if ("谷".equals(powerPriceDetEntity.getName())) {
                    powerPriceRespVO.setType("谷");
                } else if ("平".equals(powerPriceDetEntity.getName())) {
                    powerPriceRespVO.setType("平");
                }
                powerPriceRespVO.setValue(arrayList.stream().toArray(String[]::new));
                list.add(powerPriceRespVO);
            }
            Object[] peakArray = list.stream().filter(e -> e.getType().equals("峰")).collect(Collectors.toList()).stream().map(e -> e.getValue()).collect(Collectors.toList()).stream().toArray(Object[]::new);
            Object[] valleyArray = list.stream().filter(e -> e.getType().equals("谷")).collect(Collectors.toList()).stream().map(e -> e.getValue()).collect(Collectors.toList()).stream().toArray(Object[]::new);
            Object[] flatArray = list.stream().filter(e -> e.getType().equals("平")).collect(Collectors.toList()).stream().map(e -> e.getValue()).collect(Collectors.toList()).stream().toArray(Object[]::new);
            mcsApi.updateScheduleModelSetting(CommonConstant.COAL_MODEL_CODE,peakKey,JSONArray.toJSONString(peakArray));
            mcsApi.updateScheduleModelSetting(CommonConstant.COAL_MODEL_CODE,valleyKey,JSONArray.toJSONString(valleyArray));
            mcsApi.updateScheduleModelSetting(CommonConstant.COAL_MODEL_CODE,flatKey,JSONArray.toJSONString(flatArray));
        }
        return true;
    }