package com.iailab.module.job.task; import com.iailab.module.any.dto.AnyProcCardDTO; import com.iailab.module.any.service.AnyProcCardService; import com.iailab.module.any.service.AnyProcReportService; import com.iailab.module.model.handler.ModelHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.Resource; import org.springframework.stereotype.Component; import java.util.Calendar; import java.util.Date; import java.util.Map; /** * 旋流器分选3319控制诊断 * 10 0 0/2 * * ? * * @author PanZhibao * @Description * @createTime 2024年06月26日 */ @Component("anyProc4Task") public class AnyProc4Task implements ITask { private Logger logger = LoggerFactory.getLogger(getClass()); private final String MODEL_CODE = "separation_diagnosis_3319"; private final String CARD_CODE = "C04"; private final String REPORT_NAME = "旋流器分选3319控制诊断"; @Resource private ModelHandler modelHandler; @Resource private AnyProcCardService anyProcCardService; @Resource private AnyProcReportService anyProcReportService; @Override public void run(String params) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); try { Map modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); StringBuilder sb = new StringBuilder(); sb.append(modelCommonResult.get("hl_str") + ";"); sb.append(modelCommonResult.get("hj_str") + ";"); sb.append(modelCommonResult.get("xj_str") + ";"); sb.append(modelCommonResult.get("mn_str") + ";"); sb.append(modelCommonResult.get("yl_str") + ";"); sb.append(modelCommonResult.get("cxw_str") + ";"); sb.append(modelCommonResult.get("hj_md_str") + ";"); sb.append(modelCommonResult.get("hf_str") + ";"); // 更新状态 this.updateCard(sb.toString(), calendar.getTime()); // 生成报告 anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); } catch (Exception ex) { logger.error("AnyProc1Task运行异常"); ex.printStackTrace(); } logger.info("AnyProc1Task运行完成"); } private void updateCard(String content, Date runTime) { AnyProcCardDTO dto = new AnyProcCardDTO(); dto.setCode(CARD_CODE); dto.setAlarmInfo(content); dto.setAnyTime(runTime); anyProcCardService.updateByCode(dto); } }