| | |
| | | private BigDecimal gxls; |
| | | |
| | | /** |
| | | * 峰谷占比 |
| | | * 峰时占比 |
| | | */ |
| | | private BigDecimal fgRatio; |
| | | private BigDecimal fsRatio; |
| | | |
| | | /** |
| | | * 谷时占比 |
| | | */ |
| | | private BigDecimal gsRatio; |
| | | |
| | | /** |
| | | * 平时占比 |
| | | */ |
| | | private BigDecimal psRatio; |
| | | } |
| | |
| | | private BigDecimal gxls; |
| | | |
| | | /** |
| | | * 峰谷占比 |
| | | * 峰时占比 |
| | | */ |
| | | private BigDecimal fgRatio; |
| | | private BigDecimal fsRatio; |
| | | |
| | | /** |
| | | * 谷时占比 |
| | | */ |
| | | private BigDecimal gsRatio; |
| | | |
| | | /** |
| | | * 平时占比 |
| | | */ |
| | | private BigDecimal psRatio; |
| | | } |
| | |
| | | |
| | | void save(List<CokingAnalyIndEntity> entityList); |
| | | |
| | | void delete(String analyType, String analyDate, String analyClass); |
| | | void delete(String analyType, String analyDate); |
| | | |
| | | void saveAnalyInd(String relId, String process, String analyDate, String analyContent); |
| | | } |
| | |
| | | package com.iailab.module.ansteel.coking.service; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceDeviationEntity; |
| | | |
| | | import java.util.List; |
| | |
| | | List<CokingTraceDeviationEntity> list(Map<String, Object> params); |
| | | |
| | | void save(List<CokingTraceDeviationEntity> entityList); |
| | | |
| | | void saveTraceDeviation(String relId, String process, String clock, JSONObject result, String chartcode, String row, String sugObj); |
| | | } |
| | |
| | | public interface CokingTraceReportService { |
| | | List<CokingTraceReportEntity> list(Map<String, Object> params); |
| | | |
| | | String save(String process, String reportName, String analyDate, String analyClass, String clock, String analyContent); |
| | | String save(String process, String reportName, String analyDate, String clock, String analyContent); |
| | | |
| | | String save(CokingTraceReportEntity reportEntity); |
| | | } |
| | |
| | | void insert(List<CokingTraceSuggestEntity> suggestEntitieList); |
| | | |
| | | List<CokingTraceSuggestEntity> getAbnormalData(Map<String, Object> params); |
| | | |
| | | void saveTraceSuggest(String relId, String process, String clock, String total, String sugObj); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String analyType, String analyDate, String analyClass) { |
| | | public void delete(String analyType, String analyDate) { |
| | | QueryWrapper<CokingAnalyIndEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("analy_type", analyType) |
| | | .eq("analy_date", analyDate) |
| | | .eq("analy_class", analyClass); |
| | | .eq("analy_date", analyDate); |
| | | cokingAnalyIndDao.delete(queryWrapper); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyContent) { |
| | | if (StringUtils.isBlank(analyContent)) { |
| | | return; |
| | | } |
| | | String[] analyContentArr = analyContent.split(";"); |
| | | List<CokingAnalyIndEntity> entityList = new ArrayList<>(); |
| | | for (int i = 0; i < analyContentArr.length; i++) { |
| | | CokingAnalyIndEntity analyIndEntity = new CokingAnalyIndEntity(); |
| | | analyIndEntity.setRelId(relId); |
| | | analyIndEntity.setAnalyType(process); |
| | | analyIndEntity.setAnalyDate(analyDate); |
| | | analyIndEntity.setAnalyContent(analyContentArr[i]); |
| | | analyIndEntity.setSort(i + 1); |
| | | entityList.add(analyIndEntity); |
| | | } |
| | | // 清理旧数据 |
| | | delete(process, analyDate); |
| | | cokingAnalyIndDao.insert(entityList); |
| | | } |
| | | } |
| | |
| | | QueryWrapper<CokingOverviewEntity> queryWrapperMonth = new QueryWrapper<>(); |
| | | queryWrapperMonth.eq("process_type", processType); |
| | | queryWrapperMonth.between("clock", monthStartClock,clock); |
| | | queryWrapperMonth.select("sub_process_type","SUM(steam_p) as steam_p","SUM(dj_steam_p) as dj_steam_p","SUM(steam_c) as steam_c","SUM(steam_only_c) as steam_only_c","SUM(steam_v) as steam_v","SUM(gas_p) as gas_p","SUM(gas_c) as gas_c","SUM(power_c) as power_c","SUM(power_only_c) as power_only_c","SUM(power_c_standard) as power_c_standard","SUM(idle_time) as idle_time","SUM(bfg_c) as bfg_c","SUM(cog_p) as cog_p","SUM(cog_c) as cog_c","SUM(bfg_only_c) as bfg_only_c","SUM(cog_only_c) as cog_only_c","SUM(gxls) as gxls","SUM(fg_ratio) as fg_ratio") |
| | | queryWrapperMonth.select("sub_process_type","SUM(steam_p) as steam_p","SUM(dj_steam_p) as dj_steam_p","SUM(steam_c) as steam_c","SUM(steam_only_c) as steam_only_c","SUM(steam_v) as steam_v","SUM(gas_p) as gas_p","SUM(gas_c) as gas_c","SUM(power_c) as power_c","SUM(power_only_c) as power_only_c","SUM(power_c_standard) as power_c_standard","SUM(idle_time) as idle_time","SUM(bfg_c) as bfg_c","SUM(cog_p) as cog_p","SUM(cog_c) as cog_c","SUM(bfg_only_c) as bfg_only_c","SUM(cog_only_c) as cog_only_c","SUM(gxls) as gxls","SUM(fs_ratio) as fs_ratio","SUM(gs_ratio) as gs_ratio","SUM(ps_ratio) as ps_ratio") |
| | | .groupBy("sub_process_type"); |
| | | |
| | | List<CokingOverviewEntity> monthList = cokingOverviewDao.selectList(queryWrapperMonth); |
| | |
| | | package com.iailab.module.ansteel.coking.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.module.ansteel.coking.dao.CokingTraceDeviationDao; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceDeviationEntity; |
| | | import com.iailab.module.ansteel.coking.service.CokingTraceDeviationService; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.ChartParamDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 焦化工序影响因数偏差值 |
| | |
| | | |
| | | @Autowired |
| | | private CokingTraceDeviationDao cokingTraceDeviationDao; |
| | | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | @Override |
| | | public List<CokingTraceDeviationEntity> list(Map<String, Object> params) { |
| | |
| | | public void save(List<CokingTraceDeviationEntity> entityList) { |
| | | cokingTraceDeviationDao.insert(entityList); |
| | | } |
| | | |
| | | @Override |
| | | public void saveTraceDeviation(String relId, String process, String clock, JSONObject result, String chartcode, String row, String sugObj) { |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(chartcode); |
| | | Map<String, String> indexMaps = list.stream().collect(Collectors.toMap(ChartParamDTO::getParamCode, e -> e.getParamName())); |
| | | |
| | | List<String> rowKeys = new ArrayList<>(); |
| | | result.forEach((key, value) -> { |
| | | if (StringUtils.isNotBlank(key) && key.contains(row)) { |
| | | rowKeys.add(key); |
| | | } |
| | | |
| | | }); |
| | | |
| | | List<CokingTraceDeviationEntity> entityList = new ArrayList<>(); |
| | | for (String key : rowKeys) { |
| | | JSONArray rowArr = JSON.parseArray(result.get(key).toString()); |
| | | if (CollectionUtils.isEmpty(rowArr)) { |
| | | continue; |
| | | } |
| | | CokingTraceDeviationEntity entity = new CokingTraceDeviationEntity(); |
| | | entity.setRelId(relId); |
| | | entity.setProcess(process); |
| | | entity.setClock(clock); |
| | | entity.setSugObj(sugObj); |
| | | |
| | | entity.setInd1Name(indexMaps.get(new BigDecimal(rowArr.getJSONArray(0).get(0).toString()).setScale(0, BigDecimal.ROUND_HALF_UP).toString())); |
| | | entity.setInd1Value(rowArr.getJSONArray(0).get(1).toString()); |
| | | entity.setInd1Unit(""); |
| | | |
| | | entity.setInd2Name(indexMaps.get(new BigDecimal(rowArr.getJSONArray(1).get(0).toString()).setScale(0, BigDecimal.ROUND_HALF_UP).toString())); |
| | | entity.setInd2Value(rowArr.getJSONArray(1).get(1).toString()); |
| | | entity.setInd2Unit(""); |
| | | |
| | | if (rowArr.size() > 2) { |
| | | entity.setFac1Name(indexMaps.get(new BigDecimal(rowArr.getJSONArray(2).get(0).toString()).setScale(0, BigDecimal.ROUND_HALF_UP).toString())); |
| | | entity.setFac1Value(rowArr.getJSONArray(2).get(1).toString()); |
| | | entity.setFac1Unit(""); |
| | | } |
| | | if (rowArr.size() > 3) { |
| | | entity.setFac2Name(indexMaps.get(new BigDecimal(rowArr.getJSONArray(3).get(0).toString()).setScale(0, BigDecimal.ROUND_HALF_UP).toString())); |
| | | entity.setFac2Value(rowArr.getJSONArray(3).get(1).toString()); |
| | | entity.setFac2Unit(""); |
| | | } |
| | | if (rowArr.size() > 4) { |
| | | entity.setFac3Name(indexMaps.get(new BigDecimal(rowArr.getJSONArray(4).get(0).toString()).setScale(0, BigDecimal.ROUND_HALF_UP).toString())); |
| | | entity.setFac3Value(rowArr.getJSONArray(4).get(1).toString()); |
| | | entity.setFac3Unit(""); |
| | | } |
| | | if (rowArr.size() > 5) { |
| | | entity.setFac4Name(indexMaps.get(new BigDecimal(rowArr.getJSONArray(5).get(0).toString()).setScale(0, BigDecimal.ROUND_HALF_UP).toString())); |
| | | entity.setFac4Value(rowArr.getJSONArray(5).get(1).toString()); |
| | | entity.setFac4Unit(""); |
| | | } |
| | | if (rowArr.size() > 6) { |
| | | entity.setFac5Name(indexMaps.get(new BigDecimal(rowArr.getJSONArray(6).get(0).toString()).setScale(0, BigDecimal.ROUND_HALF_UP).toString())); |
| | | entity.setFac5Value(rowArr.getJSONArray(6).get(1).toString()); |
| | | entity.setFac5Unit(""); |
| | | } |
| | | entityList.add(entity); |
| | | } |
| | | cokingTraceDeviationDao.insert(entityList); |
| | | } |
| | | } |
| | |
| | | if (StringUtils.isBlank(conf.getPointNo())) { |
| | | continue; |
| | | } |
| | | String value = ""; |
| | | String value = "0"; |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(conf.getDataType())) { |
| | | case DATAPOINT: |
| | | List<String> points = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String save(String process, String reportName, String analyDate, String analyClass, String clock, String analyContent) { |
| | | public String save(String process, String reportName, String analyDate, String clock, String analyContent) { |
| | | // 先删除,防止重复 |
| | | QueryWrapper<CokingTraceReportEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("process", process); |
| | |
| | | entity.setProcess(process); |
| | | entity.setReportName(process + "异常溯源报告"); |
| | | entity.setAnalyDate(analyDate); |
| | | entity.setAnalyClass(analyClass); |
| | | entity.setClock(clock); |
| | | entity.setAnalyContent(analyContent); |
| | | entity.setCreateDate(new Date()); |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | .orderByAsc("create_date"); |
| | | return cokingTraceSuggestDao.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void saveTraceSuggest(String relId, String process, String clock, String total, String sugObj) { |
| | | if (StringUtils.isBlank(total)) { |
| | | return; |
| | | } |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(relId); |
| | | suggestEntity.setProcess(process); |
| | | suggestEntity.setSugObj(sugObj); |
| | | suggestEntity.setClock(clock); |
| | | suggestEntity.setContent(total); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | cokingTraceSuggestDao.insert(suggestEntity); |
| | | } |
| | | } |
| | |
| | | processMainEntity.setAvgValue(BigDecimal.valueOf(avgValue)); |
| | | // 历史最优 |
| | | double baseValue = 0.0; |
| | | if (Double.valueOf(conf.getExt3()) > 0.0) { |
| | | if (conf.getExt3() == null || Double.valueOf(conf.getExt3()) > 0.0) { |
| | | baseValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).max().orElse(0.0); |
| | | }else { |
| | | baseValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).min().orElse(0.0); |
| | |
| | | // 干熄焦蒸汽产生 |
| | | BigDecimal mainGxjzqcs = resultCodeMap.get("main_gxjzqcs").getRealValue(); |
| | | e.setRealValue(mainGxjzqcs.divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | |
| | | |
| | | e.setRealValue(e.getAvgValue()); |
| | | e.setAvgValue(e.getAvgValue().divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | // 吨焦耗煤气 |
| | | if (e.getIndCode().equals("main_djhmq") && resultCodeMap.containsKey("main_glmqxh") && resultCodeMap.containsKey("main_jlmqxh")) { |
| | |
| | | break; |
| | | |
| | | } |
| | | if (value != null && StringUtils.isNotBlank(conf.getExt5())) { |
| | | value = value * Double.valueOf(conf.getExt5()); |
| | | } |
| | | return value; |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.ansteel.job.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.ansteel.coking.entity.CokingAnalyIndEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceDeviationEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceSuggestEntity; |
| | | import com.iailab.module.ansteel.coking.service.*; |
| | | import com.iailab.module.ansteel.common.constant.CommonConstant; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.ChartParamDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.iailab.module.model.api.mdk.MdkApi; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 备煤工序异常溯源 |
| | |
| | | private CokingTraceIndService cokingTraceIndService; |
| | | |
| | | @Autowired |
| | | private CokingTraceConfService cokingTraceConfService; |
| | | |
| | | @Autowired |
| | | private CokingTraceChartService cokingTraceChartService; |
| | | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | @Autowired |
| | | private MdkApi mdkApi; |
| | | |
| | | private final static String process = "备煤工序"; |
| | | |
| | |
| | | |
| | | private final static String indType = "备煤工序异常溯源"; |
| | | |
| | | private final static String coalRow = "coalRow"; |
| | | private final static String row = "coalRow"; |
| | | |
| | | private static final HashMap<String, Object> coalColoumMap = new HashMap<String, Object>() {{ |
| | | put("coalColoum0", "一级指标-偏差值"); |
| | | put("coalColoum1", "二级指标-偏差值"); |
| | | put("coalColoum2", "影响因素1-偏差值"); |
| | | }}; |
| | | |
| | | private static final HashMap<String, Object> historyPointMap = new HashMap<String, Object>() {{ |
| | | put("F0000101008", "备煤耗电"); |
| | | }}; |
| | | private final static String total = "coalPrepElecTotal1"; |
| | | |
| | | private static final String jsonStr = "{\n" + " " + |
| | | "\"result\": {\n" + |
| | | "\"coalPrepElec\":[1600.8,1613.5],\n" + |
| | | "\"coalPrepElecIndex\":[[0.8,0.73],[723,608],[1782,1782],[752,743],[729,783]],\n" + |
| | | "\"coalPrepElecTotal1\":\"1#粉碎机耗电因粉碎机偏高增加220KW/h,经模型计算,建建议调整单班用煤量,预计可使粉碎机耗电量指标降低170KW/h\",\n" + |
| | | "\"coalPrepElecTotal2\":\"1#粉碎机耗电量数据异常\",\n" + |
| | | "\"coalRow0\":[[0,450],[0,137],[0,342]],\n" + |
| | | "\"coalRow1\":[[0,450],[3,134],[1,142]],\n" + |
| | | "\"coalRow2\":[[4,142],[4,132],[4,349]],\n" + |
| | | "\"coalPrepElecHomePage\":[[50,42],[10,10]],\n" + |
| | | "\"coalHomeIndex\":[[90.4,90.2],[80.3,78],[103,100],[280,270]],\n" + |
| | | "\"coalIndexInfo\":\"4月25日甲班:备煤耗电异常\",\n" + |
| | | "\"coalErr\":\"4月25日粉碎机耗电数据异常(无数据)\"\n" + " }" + "}"; |
| | | "\"coalHomeIndexInfo\":\"备煤耗电偏高\"," + |
| | | "\"coalPrepElec\":[1600.8,1613.5]," + |
| | | "\"coalPrepElecTotal1\":\"备煤耗电量偏高,经模型计算,原因和调整建议如下:煤量异常,当前值2000, 建议调整煤量至区间[765.0,1020.0]\"," + |
| | | "\"coalPrepElecTime\":[[0.3,0.3],[1700.31,1900.2],[120.3]]," + |
| | | "\"coalPrepElecIndex\":[133527.2,283517.6,83451.5,233461.2,83564.4]," + |
| | | "\"coalRow0\":[[0.0,1000.3],[1.0,120.2],[7.0,1150.32]]," + |
| | | "\"coalRow1\":[[0.0,1000.5],[2.0,200.56],[7.0,120.2]]," + |
| | | "\"coalRow2\":[[0.0,1000.6],[3.0,261.7],[7.0,170.52]]," + |
| | | "\"coalPrepElecHomePage\":[503000.6,84.04]," + |
| | | "\"coalHomeIndex\":[30.0,4.6,523000.6]" + |
| | | " }" + |
| | | "}"; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | Date startDate = calendar.getTime(); |
| | | |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | Date endDate = calendar.getTime(); |
| | | String clock = ""; |
| | | String analyClass = ""; |
| | | if (hour >= 8 && hour < 16) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("A"); |
| | | analyClass = "甲班"; |
| | | } else if (hour >= 16 && hour < 24) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 8); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "乙班"; |
| | | } else if (hour >= 0 && hour < 8) { |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 16); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "丙班"; |
| | | } |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date startDate = calendar.getTime(); |
| | | String clock = DateUtils.format(startDate); |
| | | |
| | | // 调用模型 |
| | | /* 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(); |
| | | |
| | | JSONObject jsonObject = new JSONObject(result); |
| | | JSONObject result2 = (JSONObject) JSON.toJSON(jsonObject.get("result"));*/ |
| | | |
| | | JSONObject jsonObject = JSONObject.parseObject(jsonStr); |
| | | JSONObject result = (JSONObject) JSON.toJSON(jsonObject.get("result")); |
| | | |
| | |
| | | |
| | | // 保存报告 |
| | | String analyDate = DateUtils.format(startDate); |
| | | String analyContent = result.getString("coalIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, analyClass, clock, analyContent); |
| | | String analyContent = clock + " " + result.getString("coalHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, clock, analyContent); |
| | | |
| | | // 保存一级分析指标 |
| | | saveAnalyInd(relId, process, analyDate, analyClass, analyContent); |
| | | cokingAnalyIndService.saveAnalyInd(relId, process, analyDate, analyContent); |
| | | |
| | | // 保存优化建议 |
| | | saveTraceSuggest(relId, process, clock, result); |
| | | cokingTraceSuggestService.saveTraceSuggest(relId, process, clock, total, SugObj); |
| | | |
| | | // 保存偏差值 |
| | | saveTraceDeviation(relId, process, clock, result); |
| | | cokingTraceDeviationService.saveTraceDeviation(relId, process, clock, result, CommonConstant.COKE_INDEX_CHARTCODE, row, SugObj); |
| | | |
| | | // 保存溯源指标 |
| | | cokingTraceIndService.saveTraceInd(relId, indType, clock); |
| | |
| | | ex.printStackTrace(); |
| | | } |
| | | logger.info("RunCokingTraceModelBMTask运行完成"); |
| | | } |
| | | |
| | | |
| | | public void saveTraceSuggest(String relId, String process, String clock, JSONObject result) { |
| | | String coalTotal = result.get("coalPrepElecTotal1").toString(); |
| | | if (StringUtils.isBlank(coalTotal)) { |
| | | logger.info("coalPrepElecTotal1 is null"); |
| | | return; |
| | | } |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(relId); |
| | | suggestEntity.setProcess(process); |
| | | suggestEntity.setSugObj(SugObj); |
| | | suggestEntity.setClock(clock); |
| | | suggestEntity.setContent(coalTotal); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | cokingTraceSuggestService.save(suggestEntity); |
| | | } |
| | | |
| | | @Transactional |
| | | public void saveTraceDeviation(String relId, String process, String clock, JSONObject result) { |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(CommonConstant.COAL_INDEX_CHARTCODE); |
| | | Map<String, String> steamIndexMaps = list.stream().collect(Collectors.toMap(ChartParamDTO::getParamCode, e -> e.getParamName())); |
| | | |
| | | List<String> coalRowKeys = new ArrayList<>(); |
| | | result.forEach((key, value) -> { |
| | | if (StringUtils.isNotBlank(key) && key.contains(coalRow)) { |
| | | coalRowKeys.add(key); |
| | | } |
| | | |
| | | }); |
| | | |
| | | List<CokingTraceDeviationEntity> entityList = new ArrayList<>(); |
| | | for (String key : coalRowKeys) { |
| | | JSONArray rowArr = JSON.parseArray(result.get(key).toString()); |
| | | if (CollectionUtils.isEmpty(rowArr)) { |
| | | continue; |
| | | } |
| | | CokingTraceDeviationEntity entity = new CokingTraceDeviationEntity(); |
| | | entity.setRelId(relId); |
| | | entity.setProcess(process); |
| | | entity.setClock(clock); |
| | | entity.setSugObj(SugObj); |
| | | |
| | | entity.setInd1Name(steamIndexMaps.get(rowArr.getJSONArray(0).get(0).toString())); |
| | | entity.setInd1Value(rowArr.getJSONArray(0).get(1).toString()); |
| | | entity.setInd1Unit(""); |
| | | |
| | | entity.setInd2Name(steamIndexMaps.get(rowArr.getJSONArray(1).get(0).toString())); |
| | | entity.setInd2Value(rowArr.getJSONArray(1).get(1).toString()); |
| | | entity.setInd2Unit(""); |
| | | |
| | | if (rowArr.size() > 2) { |
| | | entity.setFac1Name(steamIndexMaps.get(rowArr.getJSONArray(2).get(0).toString())); |
| | | entity.setFac1Value(rowArr.getJSONArray(2).get(1).toString()); |
| | | entity.setFac1Unit(""); |
| | | } |
| | | if (rowArr.size() > 3) { |
| | | entity.setFac2Name(steamIndexMaps.get(rowArr.getJSONArray(3).get(0).toString())); |
| | | entity.setFac2Value(rowArr.getJSONArray(3).get(1).toString()); |
| | | entity.setFac2Unit(""); |
| | | } |
| | | if (rowArr.size() > 4) { |
| | | entity.setFac3Name(steamIndexMaps.get(rowArr.getJSONArray(4).get(0).toString())); |
| | | entity.setFac3Value(rowArr.getJSONArray(4).get(1).toString()); |
| | | entity.setFac3Unit(""); |
| | | } |
| | | if (rowArr.size() > 5) { |
| | | entity.setFac4Name(steamIndexMaps.get(rowArr.getJSONArray(5).get(0).toString())); |
| | | entity.setFac4Value(rowArr.getJSONArray(5).get(1).toString()); |
| | | entity.setFac4Unit(""); |
| | | } |
| | | if (rowArr.size() > 6) { |
| | | entity.setFac5Name(steamIndexMaps.get(rowArr.getJSONArray(6).get(0).toString())); |
| | | entity.setFac5Value(rowArr.getJSONArray(6).get(1).toString()); |
| | | entity.setFac5Unit(""); |
| | | } |
| | | entityList.add(entity); |
| | | } |
| | | |
| | | cokingTraceDeviationService.save(entityList); |
| | | } |
| | | |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyClass, String analyContent) { |
| | | if (StringUtils.isBlank(analyContent)) { |
| | | logger.info("analyContent is null"); |
| | | return; |
| | | } |
| | | String[] analyContentArr = analyContent.split(";"); |
| | | List<CokingAnalyIndEntity> entityList = new ArrayList<>(); |
| | | for (int i = 0; i < analyContentArr.length; i++) { |
| | | CokingAnalyIndEntity analyIndEntity = new CokingAnalyIndEntity(); |
| | | analyIndEntity.setRelId(relId); |
| | | analyIndEntity.setAnalyType(process); |
| | | analyIndEntity.setAnalyDate(analyDate); |
| | | analyIndEntity.setAnalyClass(analyClass); |
| | | analyIndEntity.setAnalyContent(analyContentArr[i]); |
| | | analyIndEntity.setSort(i + 1); |
| | | entityList.add(analyIndEntity); |
| | | } |
| | | // 清理旧数据 |
| | | cokingAnalyIndService.delete(process, analyDate, analyClass); |
| | | cokingAnalyIndService.save(entityList); |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.ansteel.job.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.ansteel.coking.entity.CokingAnalyIndEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceDeviationEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceSuggestEntity; |
| | | import com.iailab.module.ansteel.coking.service.*; |
| | | import com.iailab.module.ansteel.common.constant.CommonConstant; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.ChartParamDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.iailab.module.model.api.mdk.MdkApi; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 干熄焦工序-异常溯源 |
| | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | @Autowired |
| | | private MdkApi mdkApi; |
| | | |
| | | private final static String process = "干熄焦工序"; |
| | | |
| | | private final static String reportName = "干熄焦工序异常溯源"; |
| | | |
| | | private final static String indType = "干熄焦工序异常溯源"; |
| | | |
| | | private final static String steamRow = "steamRow"; |
| | | private final static String row = "steamRow"; |
| | | |
| | | private static final HashMap<String, Object> steamFirstColoumMap = new HashMap<String, Object>() {{ |
| | | put("steamFirstColoum0", "一级指标-偏差值"); |
| | | put("steamFirstColoum1", "二级指标-偏差值"); |
| | | put("steamFirstColoum2", "影响因素1-偏差值"); |
| | | put("steamFirstColoum3", "影响因素2-偏差值"); |
| | | put("steamFirstColoum4", "影响因素3-偏差值"); |
| | | put("steamFirstColoum5", "影响因素n-偏差值"); |
| | | }}; |
| | | private final static String total = "steamTotal1"; |
| | | |
| | | private static final HashMap<String, Object> steamSecondColoumMap = new HashMap<String, Object>() {{ |
| | | put("steamSecondColoum0", "一级指标-偏差值"); |
| | | put("steamSecondColoum1", "二级指标-偏差值"); |
| | | put("steamSecondColoum2", "影响因素1-偏差值"); |
| | | put("steamSecondColoum3", "影响因素2-偏差值"); |
| | | put("steamSecondColoum4", "影响因素3-偏差值"); |
| | | put("steamSecondColoum5", "影响因素n-偏差值"); |
| | | }}; |
| | | private final static String SugObj = "GXJ"; |
| | | |
| | | private static final String jsonStr="{\"result\":{" + |
| | | " \"steamTotal\":\"2#干熄焦蒸汽发生量因空气导入量偏高、锅炉入口温度偏低而减少13t,经模型计算,建议调整空气导入量,预计可使主蒸汽流量指标升高20m3/h\",\n" + |
| | | " \"steamRow0\":[[14,20],[14,30],[14,35]],\n" + |
| | | " \"steamRow1\":[[10,5],[11,15],[21,20]],\n" + |
| | | " \"steamRow2\":[[74,8],[36,18],[35,34]],\n" + |
| | | " \"steamRow3\":[[24,67],[6,12],[19,21]],\n" + |
| | | " \"steamRow4\":[[21,19],[22,31],[8,42]],\n" + |
| | | " \"steamRow5\":[[11,45],[9,62],[18,34]],\n" + |
| | | " \"steamSecondColoum0\":[[14,20],[14,50],[14,13]],\n" + |
| | | " \"steamSecondColoum1\":[[11,27],[10,35],[22,16]],\n" + |
| | | " \"steamSecondColoum2\":[[36,90],[35,34],[74,55]],\n" + |
| | | " \"steamSecondColoum3\":[[6,66],[19,73],[21,31]],\n" + |
| | | " \"steamSecondColoum4\":[[22,65],[8,22],[21,67]],\n" + |
| | | " \"steamSecondColoum5\":[[9,29],[11,56],[18,61]],\n" + |
| | | " \"steamHomePage\":[[663,617],[66.5,68.9]],\n" + |
| | | " \"steamHomeIndex\":[[90.4,90.2],[80.3,78],[103,100],[280,270]],\n" + |
| | | " \"steamHomeIndexInfo\":\"4月25日甲班:干熄焦产蒸汽量异常\",\n" + |
| | | " \"steamHomeErr\":\"4月25日循环风机转速数据异常(无数据)\"}}"; |
| | | private static final String jsonStr = "{\"result\":{" + |
| | | " \"steamProd\":[[0.76,0.76],[07,0.72],[0.74,0.68]]," + |
| | | "\"steamRow0\":[[14.0,20.7],[14.0,30.5],[14.0,35.2],[24.0,67.9],[6.0,12.3]]," + |
| | | "\"steamRow1\":[[10.0,5.5],[11.0,15.1],[21.0,20.6],[22.0,31.3],[8.0,42.5]]," + |
| | | "\"steamRow2\":[[74.0,8.2],[36.0,18.2],[35.0,34.6],[9.0,62.4],[18.0,34.7]]," + |
| | | "\"steamPressure\":[3.7,3.6,3.4]," + |
| | | "\"steamHomePage\":[[220.4,223.5],[0.5],[673214.3]]," + |
| | | "\"steamHomeIndexInfo\":\"干熄焦产蒸汽量异常\"," + |
| | | "\"steamTemperature\":[461.3,460.4,456.6]," + |
| | | "\"steamElec\":[233564.3,224571.7,246120.2,603157.7]," + |
| | | "\"steamIndex\":[[3.182,3.265,3.275],[1250.3,1293.1,1264.05],[890.3,886.32,901.21],[161495.2,171043.5,168533.6],[203667.2,238742.6,226731.7],[223548.3,223097.9,226733.3]]," + |
| | | "\"steamTotal1\":\"2#干熄焦蒸汽发生量因空气导入量偏高、锅炉入口温度偏低而减少13t,经模型计算,建议调整空气导入量,预计可使主蒸汽流量指标升高20m3/h\"," + |
| | | "\"steamHomeIndex\":[[63.2,61.7],[62.8,67.2],[66.1,65.7],[204.6,220.5]]" + |
| | | " }" + |
| | | "}"; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | Date startDate = calendar.getTime(); |
| | | |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | Date endDate = calendar.getTime(); |
| | | String clock = ""; |
| | | String analyClass = ""; |
| | | if (hour >= 8 && hour < 16) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("A"); |
| | | analyClass = "甲班"; |
| | | } else if (hour >= 16 && hour < 24) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 8); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "乙班"; |
| | | } else if (hour >= 0 && hour < 8) { |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 16); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "丙班"; |
| | | } |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date startDate = calendar.getTime(); |
| | | String clock = DateUtils.format(startDate); |
| | | |
| | | // 调用模型 |
| | | /* 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(); |
| | | |
| | | JSONObject jsonObject = new JSONObject(result); |
| | | JSONObject result2 = (JSONObject) JSON.toJSON(jsonObject.get("result"));*/ |
| | | |
| | | JSONObject jsonObject = JSONObject.parseObject(jsonStr); |
| | | JSONObject result = (JSONObject) JSON.toJSON(jsonObject.get("result")); |
| | | |
| | | if (Objects.isNull(result)) { |
| | | logger.info("模型结果为空"); |
| | | return; |
| | |
| | | |
| | | // 保存报告 |
| | | String analyDate = DateUtils.format(startDate); |
| | | String analyContent = result.getString("steamHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, analyClass, clock, analyContent); |
| | | String analyContent = clock + " " + result.getString("steamHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, clock, analyContent); |
| | | |
| | | // 保存一级分析指标 |
| | | saveAnalyInd(relId, process, analyDate, analyClass, analyContent); |
| | | cokingAnalyIndService.saveAnalyInd(relId, process, analyDate, analyContent); |
| | | |
| | | // 保存优化建议 |
| | | saveTraceSuggest(relId, process, clock, result); |
| | | cokingTraceSuggestService.saveTraceSuggest(relId, process, clock, total, SugObj); |
| | | |
| | | // 保存偏差值 |
| | | saveTraceDeviation(relId, process, clock, result); |
| | | cokingTraceDeviationService.saveTraceDeviation(relId, process, clock, result, CommonConstant.COKE_INDEX_CHARTCODE, row, SugObj); |
| | | |
| | | // 保存溯源指标 |
| | | cokingTraceIndService.saveTraceInd(relId, indType, clock); |
| | |
| | | |
| | | } |
| | | |
| | | public void saveTraceSuggest(String relId, String process, String clock, JSONObject result) { |
| | | List<CokingTraceSuggestEntity> entityList = new ArrayList<>(); |
| | | String steamTotal = result.get("steamTotal").toString(); |
| | | if(StringUtils.isNotBlank(steamTotal)){ |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(relId); |
| | | suggestEntity.setProcess(process); |
| | | suggestEntity.setSugObj("GXJ"); |
| | | suggestEntity.setClock(clock); |
| | | suggestEntity.setContent(steamTotal); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | entityList.add(suggestEntity); |
| | | } |
| | | cokingTraceSuggestService.insert(entityList); |
| | | } |
| | | |
| | | @Transactional |
| | | public void saveTraceDeviation(String relId, String process, String clock, JSONObject result) { |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(CommonConstant.STEAM_INDEX_CHARTCODE); |
| | | Map<String, String> steamIndexMaps = list.stream().collect(Collectors.toMap(ChartParamDTO::getParamCode, e -> e.getParamName())); |
| | | |
| | | List<String> coalRowKeys = new ArrayList<>(); |
| | | result.forEach((key, value) -> { |
| | | if (StringUtils.isNotBlank(key) && key.contains(steamRow)) { |
| | | coalRowKeys.add(key); |
| | | } |
| | | |
| | | }); |
| | | logger.info("coalRowKeys=" + coalRowKeys); |
| | | List<CokingTraceDeviationEntity> entityList = new ArrayList<>(); |
| | | for (String key : coalRowKeys) { |
| | | JSONArray rowArr = JSON.parseArray(result.get(key).toString()); |
| | | if (CollectionUtils.isEmpty(rowArr)) { |
| | | logger.info("rowArr is empty"); |
| | | continue; |
| | | } |
| | | CokingTraceDeviationEntity entity = new CokingTraceDeviationEntity(); |
| | | entity.setRelId(relId); |
| | | entity.setProcess(process); |
| | | entity.setClock(clock); |
| | | entity.setSugObj("GXJ"); |
| | | |
| | | entity.setInd1Name(steamIndexMaps.get(rowArr.getJSONArray(0).get(0).toString())); |
| | | entity.setInd1Value(rowArr.getJSONArray(0).get(1).toString()); |
| | | entity.setInd1Unit(""); |
| | | |
| | | entity.setInd2Name(steamIndexMaps.get(rowArr.getJSONArray(1).get(0).toString())); |
| | | entity.setInd2Value(rowArr.getJSONArray(1).get(1).toString()); |
| | | entity.setInd2Unit(""); |
| | | |
| | | if (rowArr.size() > 2) { |
| | | entity.setFac1Name(steamIndexMaps.get(rowArr.getJSONArray(2).get(0).toString())); |
| | | entity.setFac1Value(rowArr.getJSONArray(2).get(1).toString()); |
| | | entity.setFac1Unit(""); |
| | | } |
| | | if (rowArr.size() > 3) { |
| | | entity.setFac2Name(steamIndexMaps.get(rowArr.getJSONArray(3).get(0).toString())); |
| | | entity.setFac2Value(rowArr.getJSONArray(3).get(1).toString()); |
| | | entity.setFac2Unit(""); |
| | | } |
| | | if (rowArr.size() > 4) { |
| | | entity.setFac3Name(steamIndexMaps.get(rowArr.getJSONArray(4).get(0).toString())); |
| | | entity.setFac3Value(rowArr.getJSONArray(4).get(1).toString()); |
| | | entity.setFac3Unit(""); |
| | | } |
| | | if (rowArr.size() > 5) { |
| | | entity.setFac4Name(steamIndexMaps.get(rowArr.getJSONArray(5).get(0).toString())); |
| | | entity.setFac4Value(rowArr.getJSONArray(5).get(1).toString()); |
| | | entity.setFac4Unit(""); |
| | | } |
| | | if (rowArr.size() > 6) { |
| | | entity.setFac5Name(steamIndexMaps.get(rowArr.getJSONArray(6).get(0).toString())); |
| | | entity.setFac5Value(rowArr.getJSONArray(6).get(1).toString()); |
| | | entity.setFac5Unit(""); |
| | | } |
| | | entityList.add(entity); |
| | | } |
| | | |
| | | cokingTraceDeviationService.save(entityList); |
| | | } |
| | | |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyClass, String analyContent) { |
| | | if (StringUtils.isBlank(analyContent)) { |
| | | logger.info("analyContent is null"); |
| | | return; |
| | | } |
| | | String[] analyContentArr = analyContent.split(";"); |
| | | List<CokingAnalyIndEntity> entityList = new ArrayList<>(); |
| | | for(int i=0;i<analyContentArr.length;i++){ |
| | | CokingAnalyIndEntity analyIndEntity = new CokingAnalyIndEntity(); |
| | | analyIndEntity.setRelId(relId); |
| | | analyIndEntity.setAnalyType(process); |
| | | analyIndEntity.setAnalyDate(analyDate); |
| | | analyIndEntity.setAnalyClass(analyClass); |
| | | analyIndEntity.setAnalyContent(analyContentArr[i]); |
| | | analyIndEntity.setSort(i+1); |
| | | entityList.add(analyIndEntity); |
| | | } |
| | | // 清理旧数据 |
| | | cokingAnalyIndService.delete(process, analyDate, analyClass); |
| | | cokingAnalyIndService.save(entityList); |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.ansteel.job.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.ansteel.coking.entity.*; |
| | | import com.iailab.module.ansteel.coking.service.*; |
| | | import com.iailab.module.ansteel.common.constant.CommonConstant; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.ChartParamDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.iailab.module.model.api.mdk.MdkApi; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 化产工序异常溯源 |
| | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | @Autowired |
| | | private MdkApi mdkApi; |
| | | |
| | | private final static String process = "化产工序"; |
| | | |
| | | private final static String reportName = "化产工序异常溯源"; |
| | |
| | | |
| | | private final static String indType = "化产工序异常溯源"; |
| | | |
| | | private final static String chemProdRow = "chemProdRow"; |
| | | private final static String row = "chemProdRow"; |
| | | |
| | | private static final HashMap<String, Object> chemProdColoumMap = new HashMap<String, Object>() {{ |
| | | put("chemProdFirstColoum0", "一级指标-偏差值"); |
| | | put("chemProdFirstColoum1", "二级指标-偏差值"); |
| | | put("chemProdFirstColoum2", "影响因素1-偏差值"); |
| | | }}; |
| | | |
| | | private static final HashMap<String, Object> historyPointMap = new HashMap<String, Object>() {{ |
| | | put("F0000101006", "蒸汽消耗"); |
| | | put("F0000101006", "初冷器出口煤气温度"); |
| | | put("F0000101006", "洗苯塔后煤气含苯"); |
| | | put("F0000101006", "脱硫后H2S含量"); |
| | | }}; |
| | | private final static String total = "chemProdTotal"; |
| | | |
| | | private static final String jsonStr = "{\n" + |
| | | "\"result\":{\n" + |
| | | "\"chemProdSteam\":[[33836,33925]], \n" + |
| | | "\"chemProdIndex\":[[352,355],[68,66.3],[82.5,87.6],[50.7,56.5],[73.5,73.1]],\n" + |
| | | "\"chemProdTotal\":\"蒸汽消耗量异常,当前值1342,经模型计算,指标1异常,当前值1342,建议调整指标1至区间[90,110],指标2异常,当前值1342,建议调整指标2至区间[50,80]\",\n" + |
| | | "\"chemProdRow0\":[[0,42],[5,345],[2,41]],\n" + " " + |
| | | "\"chemProdRow1\":[[5,1342],[7,1342],[9,1342]],\n" + |
| | | "\"chemProdRow2\":[[5,1342],[5,1342],[7,1342]],\n" + |
| | | "\"chemProdHomePage\":[[9,1342],[9,1342]],\n" + |
| | | "\"chemProdHomeIndex\":[[90.4,90.2],[80.3,78],[103,100],[280,270]],\n" + |
| | | "\"chemProdHomeIndexInfo\":\"4月25日甲班:化产蒸汽消耗量异常\",\n" + |
| | | "\"chemProdHomeErr\":\"4月25日化产蒸汽消耗量数据异常(无数据)\"\n" + " }" + "}"; |
| | | "\"chemProdHomePage\":[1782.7,0.8]," + |
| | | "\"chemProdElec\":[794680.52]," + |
| | | "\"chemProdIndex\":[16.3,2.57,0.017,0.745,658731.5]," + |
| | | "\"chemProdRow0\":[[0.0,42.3],[5.0,1342.5],[10.0,122.5]]," + |
| | | "\"chemProdRow1\":[[0.0,42.3],[7.0,12.5],[9.0,17.45]]," + |
| | | "\"chemProdRow2\":[[0.0,42.3],[12.0,23.5],[35.0,54.33]]," + |
| | | "\"chemProdSteam\":[46.3]," + |
| | | "\"chemProdTotal\":\"蒸汽消耗量异常,经模型计算,原因和调整建议如下:电捕绝缘箱温度异常,当前值190,建议调整电捕绝缘箱温度至区间[80,110], 蒸氨塔塔顶温度异常,当前值190,建议调整蒸氨塔塔顶温度至区间[101,103]\"," + |
| | | "\"chemProdHomeIndexInfo\":\"化产蒸汽消耗量异常\""+ |
| | | " }" + |
| | | "}"; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | Date startDate = calendar.getTime(); |
| | | |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | Date endDate = calendar.getTime(); |
| | | String clock = ""; |
| | | String analyClass = ""; |
| | | if (hour >= 8 && hour < 16) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("A"); |
| | | analyClass = "甲班"; |
| | | } else if (hour >= 16 && hour < 24) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 8); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "乙班"; |
| | | } else if (hour >= 0 && hour < 8) { |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 16); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "丙班"; |
| | | } |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date startDate = calendar.getTime(); |
| | | String clock = DateUtils.format(startDate); |
| | | |
| | | // 调用模型 |
| | | JSONObject jsonObject = JSONObject.parseObject(jsonStr); |
| | |
| | | |
| | | // 保存报告 |
| | | String analyDate = DateUtils.format(startDate); |
| | | String analyContent = result.getString("chemProdHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, analyClass, clock, analyContent); |
| | | String analyContent = clock + " " + result.getString("chemProdHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, clock, analyContent); |
| | | |
| | | // 保存一级分析指标 |
| | | saveAnalyInd(relId, process, analyDate, analyClass, analyContent); |
| | | cokingAnalyIndService.saveAnalyInd(relId, process, analyDate, analyContent); |
| | | |
| | | // 保存优化建议 |
| | | saveTraceSuggest(relId, process, clock, result); |
| | | cokingTraceSuggestService.saveTraceSuggest(relId, process, clock, total, SugObj); |
| | | |
| | | // 保存偏差值 |
| | | saveTraceDeviation(relId, process, clock, result); |
| | | cokingTraceDeviationService.saveTraceDeviation(relId, process, clock, result, CommonConstant.COKE_INDEX_CHARTCODE, row, SugObj); |
| | | |
| | | // 保存溯源指标 |
| | | cokingTraceIndService.saveTraceInd(relId, indType, clock); |
| | |
| | | ex.printStackTrace(); |
| | | } |
| | | logger.info("RunCokingTraceModelHCTask运行完成"); |
| | | } |
| | | |
| | | public void saveTraceSuggest(String relId, String process, String clock, JSONObject result) { |
| | | String chemProdTotal = result.get("chemProdTotal").toString(); |
| | | if (StringUtils.isBlank(chemProdTotal)) { |
| | | logger.info("coalPrepElecTotal1 is null"); |
| | | return; |
| | | } |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(relId); |
| | | suggestEntity.setProcess(process); |
| | | suggestEntity.setSugObj(SugObj); |
| | | suggestEntity.setClock(clock); |
| | | suggestEntity.setContent(chemProdTotal); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | cokingTraceSuggestService.save(suggestEntity); |
| | | } |
| | | |
| | | @Transactional |
| | | public void saveTraceDeviation(String relId, String process, String clock, JSONObject result) { |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(CommonConstant.CHEMPROD_INDEX_CHARTCODE); |
| | | Map<String, String> steamIndexMaps = list.stream().collect(Collectors.toMap(ChartParamDTO::getParamCode, e -> e.getParamName())); |
| | | |
| | | List<String> coalRowKeys = new ArrayList<>(); |
| | | result.forEach((key, value) -> { |
| | | if (StringUtils.isNotBlank(key) && key.contains(chemProdRow)) { |
| | | coalRowKeys.add(key); |
| | | } |
| | | |
| | | }); |
| | | |
| | | List<CokingTraceDeviationEntity> entityList = new ArrayList<>(); |
| | | for (String key : coalRowKeys) { |
| | | JSONArray rowArr = JSON.parseArray(result.get(key).toString()); |
| | | if (CollectionUtils.isEmpty(rowArr)) { |
| | | continue; |
| | | } |
| | | CokingTraceDeviationEntity entity = new CokingTraceDeviationEntity(); |
| | | entity.setRelId(relId); |
| | | entity.setProcess(process); |
| | | entity.setClock(clock); |
| | | entity.setSugObj(SugObj); |
| | | |
| | | entity.setInd1Name(steamIndexMaps.get(rowArr.getJSONArray(0).get(0).toString())); |
| | | entity.setInd1Value(rowArr.getJSONArray(0).get(1).toString()); |
| | | entity.setInd1Unit(""); |
| | | |
| | | entity.setInd2Name(steamIndexMaps.get(rowArr.getJSONArray(1).get(0).toString())); |
| | | entity.setInd2Value(rowArr.getJSONArray(1).get(1).toString()); |
| | | entity.setInd2Unit(""); |
| | | |
| | | if (rowArr.size() > 2) { |
| | | entity.setFac1Name(steamIndexMaps.get(rowArr.getJSONArray(2).get(0).toString())); |
| | | entity.setFac1Value(rowArr.getJSONArray(2).get(1).toString()); |
| | | entity.setFac1Unit(""); |
| | | } |
| | | if (rowArr.size() > 3) { |
| | | entity.setFac2Name(steamIndexMaps.get(rowArr.getJSONArray(3).get(0).toString())); |
| | | entity.setFac2Value(rowArr.getJSONArray(3).get(1).toString()); |
| | | entity.setFac2Unit(""); |
| | | } |
| | | if (rowArr.size() > 4) { |
| | | entity.setFac3Name(steamIndexMaps.get(rowArr.getJSONArray(4).get(0).toString())); |
| | | entity.setFac3Value(rowArr.getJSONArray(4).get(1).toString()); |
| | | entity.setFac3Unit(""); |
| | | } |
| | | if (rowArr.size() > 5) { |
| | | entity.setFac4Name(steamIndexMaps.get(rowArr.getJSONArray(5).get(0).toString())); |
| | | entity.setFac4Value(rowArr.getJSONArray(5).get(1).toString()); |
| | | entity.setFac4Unit(""); |
| | | } |
| | | if (rowArr.size() > 6) { |
| | | entity.setFac5Name(steamIndexMaps.get(rowArr.getJSONArray(6).get(0).toString())); |
| | | entity.setFac5Value(rowArr.getJSONArray(6).get(1).toString()); |
| | | entity.setFac5Unit(""); |
| | | } |
| | | entityList.add(entity); |
| | | } |
| | | |
| | | cokingTraceDeviationService.save(entityList); |
| | | } |
| | | |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyClass, String analyContent) { |
| | | if (StringUtils.isBlank(analyContent)) { |
| | | logger.info("analyContent is null"); |
| | | return; |
| | | } |
| | | String[] analyContentArr = analyContent.split(";"); |
| | | List<CokingAnalyIndEntity> entityList = new ArrayList<>(); |
| | | for (int i = 0; i < analyContentArr.length; i++) { |
| | | CokingAnalyIndEntity analyIndEntity = new CokingAnalyIndEntity(); |
| | | analyIndEntity.setRelId(relId); |
| | | analyIndEntity.setAnalyType(process); |
| | | analyIndEntity.setAnalyDate(analyDate); |
| | | analyIndEntity.setAnalyClass(analyClass); |
| | | analyIndEntity.setAnalyContent(analyContentArr[i]); |
| | | analyIndEntity.setSort(i + 1); |
| | | entityList.add(analyIndEntity); |
| | | } |
| | | // 清理旧数据 |
| | | cokingAnalyIndService.delete(process, analyDate, analyClass); |
| | | cokingAnalyIndService.save(entityList); |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.ansteel.job.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.ansteel.coking.entity.CokingAnalyIndEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceDeviationEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceSuggestEntity; |
| | | import com.iailab.module.ansteel.coking.service.*; |
| | | import com.iailab.module.ansteel.common.constant.CommonConstant; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.ChartParamDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.iailab.module.model.api.mdk.MdkApi; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 炼焦工序-异常溯源 |
| | |
| | | private CokingTraceChartService cokingTraceChartService; |
| | | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | private MdkApi mdkApi; |
| | | |
| | | private final static String process = "炼焦工序"; |
| | | |
| | |
| | | |
| | | private final static String indType = "炼焦工序异常溯源"; |
| | | |
| | | private final static String cokeRow = "cokeRow"; |
| | | private final static String row = "cokeRow"; |
| | | |
| | | private static final HashMap<String, Object> cokeColoumMap = new HashMap<String, Object>() {{ |
| | | put("cokeColoum0", "一级指标-偏差值"); |
| | | put("cokeColoum1", "二级指标-偏差值"); |
| | | put("cokeColoum2", "影响因素1-偏差值"); |
| | | put("cokeColoum3", "影响因素2-偏差值"); |
| | | put("cokeColoum4", "影响因素3-偏差值"); |
| | | put("cokeColoum5", "影响因素n-偏差值"); |
| | | }}; |
| | | private final static String total = "cokeTotal"; |
| | | |
| | | private static final HashMap<String, Object> historyPointMap = new HashMap<String, Object>() {{ |
| | | put("F0000101009", "荒煤气发生"); |
| | | put("F0000101009", "耗热量"); |
| | | }}; |
| | | |
| | | private static final String jsonStr = "{\n" + " " + |
| | | "\"result\": {\n" + " " + |
| | | "\"cokeCOG\":[100.5,99.8],\n" + " " + |
| | | "\"cokeHeat\":[3.7,3.8],\n" + " " + |
| | | "\"cokeIndex\":[[0.8,0.7],[608,608],[1440,1460],[1346,1293],[0.8,0.7],[1372,1293]],\n" + " " + |
| | | "\"cokeTotal\":\"炼焦吨焦耗热量因煤气流量偏高、煤气水分偏低而增加23,经模型计算,延建议调整煤气流量,预计可使吨焦耗热量指标降低17\",\n" + " " + |
| | | "\"cokeRow0\":[[0,13],[0,42],[0,34]],\n" + " " + |
| | | "\"cokeRow1\":[[13,12],[12,34],[24,42]],\n" + " " + |
| | | "\"cokeRow2\":[[27,45],[58,42],[70,31]],\n" + " " + |
| | | "\"cokeRow3\":[[18,56],[10,89],[15,21]],\n" + " " + |
| | | "\"cokeRow4\":[[19,13],[20,51],[17,34]],\n" + " " + |
| | | "\"cokeRow5\":[[47,33],[31,12],[22,13]],\n" + " " + |
| | | "\"cokeHomePage\":[[202,42],[203,13],[204,45],[205,34],[206,17]],\n" + " " + |
| | | "\"cokeHomeIndex\":[[90.4,90.2],[80.3,78],[103,100],[280,270]],\n" + " " + |
| | | "\"cokeHomeIndexInfo\":\"4月25日甲班:吨焦耗热量异常\",\n" + " " + |
| | | "\"cokeHomeErr\":\"4月25日煤气预热器前数据异常(无数据)\"\n" + " " + "}\n" + "}"; |
| | | private static final String jsonStr = "{\n" + |
| | | "\"result\": {\n" + |
| | | "\"cokeElec\":[583562.4]," + |
| | | "\"cokeHeat1\":[130820.4,136710.3]," + |
| | | "\"cokeRow0\":[[0.0,13.6],[2.0,10.5],[69.0,34.6]]," + |
| | | "\"cokeIndex\":[[0.0149,0.0148],[23.6,24.5],[1350.2,1423.5],[1.21,1.25],[0.28],[103542.3,135238.5],[104668.63,137826.5],[155678.2]]," + |
| | | "\"cokeRow1\":[[0.0,12.51],[81.0,34.3],[69.0,42.3],[86.0,56.4],[92.0,89.4]]," + |
| | | "\"cokeRow2\":[[0.0,45.3],[9.0,42.5],[81.0,31.2],[88.0,16.3]]," + |
| | | "\"cokeHeat2\":[135220.3,134720.3]," + |
| | | "\"cokeCOG2\":[64525.8,64824.2]," + |
| | | "\"cokeHomeIndex\":[[90.4,90.2],[80.3,78.5],[103.6,100.3],[280.9,270.4]]," + |
| | | "\"cokeHomeIndexInfo\":\"吨焦耗热量异常\"," + |
| | | "\"cokeCOG1\":[64435.5,64532.6]," + |
| | | "\"cokeHomePage\":[[124439.4,124428.4],[320.6],[224.3],[248305.4],[124436.2],[3.96],[0.43]]," + |
| | | "\"cokeTotal\":\"炼焦吨焦耗热量因煤气流量偏高、煤气水分偏低而增加23,经模型计算,延建议调整煤气流量,预计可使吨焦耗热量指标降低17\"" + |
| | | " }" + |
| | | "}"; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | Date startDate = calendar.getTime(); |
| | | |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | Date endDate = calendar.getTime(); |
| | | String clock = ""; |
| | | String analyClass = ""; |
| | | if (hour >= 8 && hour < 16) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("A"); |
| | | analyClass = "甲班"; |
| | | } else if (hour >= 16 && hour < 24) { |
| | | calendar.set(Calendar.HOUR_OF_DAY, 8); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "乙班"; |
| | | } else if (hour >= 0 && hour < 8) { |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 16); |
| | | startDate = calendar.getTime(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 8); |
| | | endDate = calendar.getTime(); |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "丙班"; |
| | | } |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date startDate = calendar.getTime(); |
| | | String clock = DateUtils.format(startDate); |
| | | |
| | | // 调用模型 |
| | | JSONObject jsonObject = JSONObject.parseObject(jsonStr); |
| | |
| | | |
| | | // 保存报告 |
| | | String analyDate = DateUtils.format(startDate); |
| | | String analyContent = result.getString("cokeHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, analyClass, clock, analyContent); |
| | | String analyContent = clock + " " + result.getString("cokeHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, clock, analyContent); |
| | | |
| | | // 保存一级分析指标 |
| | | saveAnalyInd(relId, process, analyDate, analyClass, analyContent); |
| | | cokingAnalyIndService.saveAnalyInd(relId, process, analyDate, analyContent); |
| | | |
| | | // 保存优化建议 |
| | | saveTraceSuggest(relId, process, clock, result); |
| | | cokingTraceSuggestService.saveTraceSuggest(relId, process, clock, total, SugObj); |
| | | |
| | | // 保存偏差值 |
| | | saveTraceDeviation(relId, process, clock, result); |
| | | cokingTraceDeviationService.saveTraceDeviation(relId, process, clock, result, CommonConstant.COKE_INDEX_CHARTCODE, row, SugObj); |
| | | |
| | | // 保存溯源指标 |
| | | cokingTraceIndService.saveTraceInd(relId, indType, clock); |
| | |
| | | ex.printStackTrace(); |
| | | } |
| | | logger.info("RunCokingTraceModelLJTask运行完成"); |
| | | } |
| | | |
| | | public void saveTraceSuggest(String relId, String process, String clock, JSONObject result) { |
| | | String cokeTotal = result.get("cokeTotal").toString(); |
| | | if (StringUtils.isBlank(cokeTotal)) { |
| | | logger.info("cokeTotal is null"); |
| | | return; |
| | | } |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(relId); |
| | | suggestEntity.setProcess(process); |
| | | suggestEntity.setSugObj(SugObj); |
| | | suggestEntity.setClock(clock); |
| | | suggestEntity.setContent(cokeTotal); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | cokingTraceSuggestService.save(suggestEntity); |
| | | } |
| | | |
| | | @Transactional |
| | | public void saveTraceDeviation(String relId, String process, String clock, JSONObject result) { |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(CommonConstant.COKE_INDEX_CHARTCODE); |
| | | Map<String, String> steamIndexMaps = list.stream().collect(Collectors.toMap(ChartParamDTO::getParamCode, e -> e.getParamName())); |
| | | |
| | | List<String> coalRowKeys = new ArrayList<>(); |
| | | result.forEach((key, value) -> { |
| | | if (StringUtils.isNotBlank(key) && key.contains(cokeRow)) { |
| | | coalRowKeys.add(key); |
| | | } |
| | | |
| | | }); |
| | | |
| | | List<CokingTraceDeviationEntity> entityList = new ArrayList<>(); |
| | | for (String key : coalRowKeys) { |
| | | JSONArray rowArr = JSON.parseArray(result.get(key).toString()); |
| | | if (CollectionUtils.isEmpty(rowArr)) { |
| | | continue; |
| | | } |
| | | CokingTraceDeviationEntity entity = new CokingTraceDeviationEntity(); |
| | | entity.setRelId(relId); |
| | | entity.setProcess(process); |
| | | entity.setClock(clock); |
| | | entity.setSugObj(SugObj); |
| | | |
| | | entity.setInd1Name(steamIndexMaps.get(rowArr.getJSONArray(0).get(0).toString())); |
| | | entity.setInd1Value(rowArr.getJSONArray(0).get(1).toString()); |
| | | entity.setInd1Unit(""); |
| | | |
| | | entity.setInd2Name(steamIndexMaps.get(rowArr.getJSONArray(1).get(0).toString())); |
| | | entity.setInd2Value(rowArr.getJSONArray(1).get(1).toString()); |
| | | entity.setInd2Unit(""); |
| | | |
| | | if (rowArr.size() > 2) { |
| | | entity.setFac1Name(steamIndexMaps.get(rowArr.getJSONArray(2).get(0).toString())); |
| | | entity.setFac1Value(rowArr.getJSONArray(2).get(1).toString()); |
| | | entity.setFac1Unit(""); |
| | | } |
| | | if (rowArr.size() > 3) { |
| | | entity.setFac2Name(steamIndexMaps.get(rowArr.getJSONArray(3).get(0).toString())); |
| | | entity.setFac2Value(rowArr.getJSONArray(3).get(1).toString()); |
| | | entity.setFac2Unit(""); |
| | | } |
| | | if (rowArr.size() > 4) { |
| | | entity.setFac3Name(steamIndexMaps.get(rowArr.getJSONArray(4).get(0).toString())); |
| | | entity.setFac3Value(rowArr.getJSONArray(4).get(1).toString()); |
| | | entity.setFac3Unit(""); |
| | | } |
| | | if (rowArr.size() > 5) { |
| | | entity.setFac4Name(steamIndexMaps.get(rowArr.getJSONArray(5).get(0).toString())); |
| | | entity.setFac4Value(rowArr.getJSONArray(5).get(1).toString()); |
| | | entity.setFac4Unit(""); |
| | | } |
| | | if (rowArr.size() > 6) { |
| | | entity.setFac5Name(steamIndexMaps.get(rowArr.getJSONArray(6).get(0).toString())); |
| | | entity.setFac5Value(rowArr.getJSONArray(6).get(1).toString()); |
| | | entity.setFac5Unit(""); |
| | | } |
| | | entityList.add(entity); |
| | | } |
| | | |
| | | cokingTraceDeviationService.save(entityList); |
| | | } |
| | | |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyClass, String analyContent) { |
| | | if (StringUtils.isBlank(analyContent)) { |
| | | logger.info("analyContent is null"); |
| | | return; |
| | | } |
| | | String[] analyContentArr = analyContent.split(";"); |
| | | List<CokingAnalyIndEntity> entityList = new ArrayList<>(); |
| | | for (int i = 0; i < analyContentArr.length; i++) { |
| | | CokingAnalyIndEntity analyIndEntity = new CokingAnalyIndEntity(); |
| | | analyIndEntity.setRelId(relId); |
| | | analyIndEntity.setAnalyType(process); |
| | | analyIndEntity.setAnalyDate(analyDate); |
| | | analyIndEntity.setAnalyClass(analyClass); |
| | | analyIndEntity.setAnalyContent(analyContentArr[i]); |
| | | analyIndEntity.setSort(i + 1); |
| | | entityList.add(analyIndEntity); |
| | | } |
| | | // 清理旧数据 |
| | | cokingAnalyIndService.delete(process, analyDate, analyClass); |
| | | cokingAnalyIndService.save(entityList); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.ansteel.job.task; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.module.ansteel.power.dao.PeakValleyFlatDao; |
| | | import com.iailab.module.ansteel.power.entity.PeakValleyFlatEntity; |
| | | 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.ApiPointValueWriteDTO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 峰谷平累计量计算 |
| | | * |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2025年5月5日 |
| | | */ |
| | | @Component("runPeakValleyFlatTask") |
| | | public class RunPeakValleyFlatTask implements ITask { |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | @Autowired |
| | | private PeakValleyFlatDao peakValleyFlatDao; |
| | | |
| | | @Autowired |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | | try { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | |
| | | //查询峰谷平配置列表 |
| | | List<PeakValleyFlatEntity> list = peakValleyFlatDao.selectList(new QueryWrapper<>()); |
| | | |
| | | //根据测点分组 |
| | | Map<String, List<PeakValleyFlatEntity>> groupedByPointNo = list.stream() |
| | | .collect(Collectors.groupingBy(PeakValleyFlatEntity::getPowerNo)); |
| | | |
| | | groupedByPointNo.entrySet().stream().forEach(entry -> { |
| | | |
| | | //计算昨日的累积量 |
| | | double value = getSumValue(entry.getValue(), 1, calendar); |
| | | |
| | | //计算昨日总电耗 |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | Date endTime = calendar.getTime(); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date startTime = calendar.getTime(); |
| | | double totalValue = getSumValueTotal(entry.getValue().get(0).getPowerNo(), startTime,endTime); |
| | | |
| | | //下发昨日占比 |
| | | ApiPointValueWriteDTO dto = new ApiPointValueWriteDTO(); |
| | | dto.setPointNo(entry.getValue().get(0).getPointNo()); |
| | | dto.setValue(value/totalValue*100); |
| | | dataPointApi.writePointRealValue(dto); |
| | | |
| | | if(entry.getValue().get(0).getPointNoMonth()!=null){ |
| | | //计算前三十日累积量 |
| | | double value30 = 0; |
| | | for (int i = 1; i < 31; i++) { |
| | | //计算前三十日累积量 |
| | | value30 = value30 + getSumValue(entry.getValue(), i, calendar); |
| | | } |
| | | |
| | | //计算前三十日总电耗 |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -30); |
| | | Date startTimeMonth = calendar.getTime(); |
| | | double totalValueMonth = getSumValueTotal(entry.getValue().get(0).getPowerNo(), startTimeMonth,endTime); |
| | | |
| | | //下发前三十日占比 |
| | | ApiPointValueWriteDTO monthDto = new ApiPointValueWriteDTO(); |
| | | monthDto.setPointNo(entry.getValue().get(0).getPointNoMonth()); |
| | | monthDto.setValue(value30/totalValueMonth*100); |
| | | dataPointApi.writePointRealValue(monthDto); |
| | | } |
| | | }); |
| | | } catch (Exception ex) { |
| | | logger.error("runPeakValleyFlatTask运行异常"); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private Date getTime(String timeStr, int ago, Calendar calendar) { |
| | | String[] timeSplit = timeStr.split(":"); |
| | | if (timeSplit.length != 2) { |
| | | throw new IllegalArgumentException("时间配置格式不合法"); |
| | | } |
| | | //根据配置获取startTime、endTime |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timeSplit[0])); |
| | | calendar.set(Calendar.MINUTE, Integer.parseInt(timeSplit[1])); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -ago); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | private List<ApiPointValueDTO> fillMissingData(List<ApiPointValueDTO> valueList, |
| | | Date startTime, |
| | | Date endTime) { |
| | | if (valueList == null || valueList.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | // 过滤掉null元素 |
| | | valueList = valueList.stream().filter(Objects::nonNull).collect(Collectors.toList()); |
| | | if (valueList.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | List<ApiPointValueDTO> filledList = new ArrayList<>(); |
| | | ApiPointValueDTO lastValidData = null; |
| | | |
| | | long totalMinutes = (endTime.getTime() - startTime.getTime()) / (60 * 1000); |
| | | |
| | | for (int i = 0; i <= totalMinutes; i++) { |
| | | Date currentTime = new Date(startTime.getTime() + i * 60 * 1000); |
| | | ApiPointValueDTO currentData = findDataForTime(valueList, currentTime); |
| | | |
| | | if (currentData != null) { |
| | | filledList.add(currentData); |
| | | lastValidData = currentData; |
| | | } else if (lastValidData != null) { |
| | | filledList.add(new ApiPointValueDTO() |
| | | .setT(currentTime) |
| | | .setV(lastValidData.getV())); |
| | | } else { |
| | | // 使用第一个非null数据的值 |
| | | filledList.add(new ApiPointValueDTO() |
| | | .setT(currentTime) |
| | | .setV(valueList.get(0).getV())); |
| | | } |
| | | } |
| | | |
| | | return filledList; |
| | | } |
| | | |
| | | private ApiPointValueDTO findDataForTime(List<ApiPointValueDTO> valueList, Date time) { |
| | | long targetMinute = time.getTime() / (60 * 1000); |
| | | return valueList.stream() |
| | | .filter(Objects::nonNull) |
| | | .filter(d -> d.getT() != null) |
| | | .filter(d -> d.getT().getTime() / (60 * 1000) == targetMinute) |
| | | .findFirst() |
| | | .orElse(null); |
| | | } |
| | | |
| | | private double getSumValue(List<PeakValleyFlatEntity> list, int ago, Calendar calendar) { |
| | | double value = 0; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | |
| | | PeakValleyFlatEntity entity = list.get(i); |
| | | |
| | | ApiPointValueQueryDTO dto = new ApiPointValueQueryDTO(); |
| | | Date startTime = getTime(entity.getStartTime(), ago, calendar); |
| | | Date endTime = getTime(entity.getEndTime(), ago, calendar); |
| | | dto.setPointNo(entity.getPowerNo()); |
| | | dto.setStart(startTime); |
| | | dto.setEnd(endTime); |
| | | |
| | | //查找数据 |
| | | List<ApiPointValueDTO> valueList = dataPointApi.queryPointHistoryValue(dto); |
| | | //补全数据 |
| | | valueList = fillMissingData(valueList, startTime, endTime); |
| | | //累加 |
| | | double sum = valueList.stream().mapToDouble(ApiPointValueDTO::getV).sum(); |
| | | value = value + sum; |
| | | } |
| | | return value / 60; |
| | | } |
| | | |
| | | private double getSumValueTotal(String pointNo, Date startTime, Date endTime) { |
| | | ApiPointValueQueryDTO dto = new ApiPointValueQueryDTO(); |
| | | dto.setPointNo(pointNo); |
| | | dto.setStart(startTime); |
| | | dto.setEnd(endTime); |
| | | |
| | | //查找数据 |
| | | List<ApiPointValueDTO> valueList = dataPointApi.queryPointHistoryValue(dto); |
| | | //补全数据 |
| | | valueList = fillMissingData(valueList, startTime, endTime); |
| | | //累加 |
| | | return valueList.stream().mapToDouble(ApiPointValueDTO::getV).sum()/ 60; |
| | | } |
| | | } |
| | |
| | | suggestDto.setTitle("日平衡建议"); |
| | | suggestDto.setContent(entry.getValue().toString()); |
| | | suggestDto.setScheduleObj("GAS"); |
| | | suggestDto.setScheduleTime(dto.getScheduleTime()); |
| | | suggestDto.setCreateTime(calendar.getTime()); |
| | | if (mcsApi.createScheduleSuggest(suggestDto)) { |
| | | logger.info("日平衡建议{" + entry.getValue().toString() + "}保存成功"); |
| | |
| | | suggestDto.setTitle("转炉实时调度建议"); |
| | | suggestDto.setContent(LDG.toString()); |
| | | suggestDto.setScheduleObj("LDG"); |
| | | suggestDto.setScheduleTime(dto.getScheduleTime()); |
| | | suggestDto.setCreateTime(calendar.getTime()); |
| | | if (mcsApi.createScheduleSuggest(suggestDto)) { |
| | | logger.info("转炉实时调度建议{" + LDG + "}保存成功"); |
| | |
| | | suggestDto.setTitle("焦炉实时调度建议"); |
| | | suggestDto.setContent(COG.toString()); |
| | | suggestDto.setScheduleObj("COG"); |
| | | suggestDto.setScheduleTime(dto.getScheduleTime()); |
| | | suggestDto.setCreateTime(calendar.getTime()); |
| | | if (mcsApi.createScheduleSuggest(suggestDto)) { |
| | | logger.info("焦炉实时调度建议{" + COG + "}保存成功"); |
| | |
| | | suggestDto.setTitle("高炉实时调度建议"); |
| | | suggestDto.setContent(BFG.toString()); |
| | | suggestDto.setScheduleObj("BFG"); |
| | | suggestDto.setScheduleTime(dto.getScheduleTime()); |
| | | suggestDto.setCreateTime(calendar.getTime()); |
| | | if (mcsApi.createScheduleSuggest(suggestDto)) { |
| | | logger.info("高炉实时调度建议{" + BFG + "}保存成功"); |
对比新文件 |
| | |
| | | package com.iailab.module.ansteel.power.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.ansteel.power.entity.PeakValleyFlatEntity; |
| | | import com.iailab.module.ansteel.power.entity.PowerDemandEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author dyk |
| | | * @Description |
| | | * @createTime 2025年05月05日 |
| | | */ |
| | | @Mapper |
| | | public interface PeakValleyFlatDao extends BaseDao<PeakValleyFlatEntity> { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.ansteel.power.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 峰谷平累计量计算 |
| | | * |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2025年5月5日 |
| | | */ |
| | | @Data |
| | | @TableName("t_peak_valley_flat") |
| | | public class PeakValleyFlatEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId |
| | | private String id; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 类型(peak/vallay/flat) |
| | | */ |
| | | private String type; |
| | | /** |
| | | * 下发测点编码 |
| | | */ |
| | | private String pointNo; |
| | | /** |
| | | * 下发测点编码 |
| | | */ |
| | | private String pointNoMonth; |
| | | /** |
| | | * 功率测点编码 |
| | | */ |
| | | private String powerNo; |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | private String startTime; |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | private String endTime; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | } |
| | |
| | | url: jdbc:mysql://127.0.0.1:3306/iailab_fast_tenant_ansteel?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true |
| | | username: root |
| | | password: 123456 |
| | | redis: |
| | | host: 127.0.0.1 |
| | | port: 6379 |
| | | database: 0 |
| | | password: 123456 |
| | | cloud: |
| | | nacos: |
| | | server-addr: localhost:8848 # Nacos 服务器地址 |
| | |
| | | client-id: ansteel #租户OAuth2客户端id |
| | | client-secret: q3vY7K9PmFjW1xLbN6rTtZz2cV4B5sD0 #租户OAuth2客户端密钥 |
| | | username: ansteel |
| | | password: xY7^zW4.vU |
| | | password: 123456 |
| | | |
| | |
| | | - t_power_demand |
| | | - t_power_adjusted_factor |
| | | - t_power_net_dropdown |
| | | - t_peak_valley_flat |
| | | - t_coking_overview_ind |
| | | swagger: |
| | | title: 鞍钢鲅鱼圈能源管控系统 |