package com.iailab.module.job.task;
|
|
import com.alibaba.fastjson.JSON;
|
import com.iailab.common.utils.DateUtils;
|
import com.iailab.module.mcs.dto.StModelDTO;
|
import com.iailab.module.mcs.service.StModelService;
|
import com.iailab.module.mcs.service.StModelResultService;
|
import com.iailab.module.model.handler.ModelHandler;
|
import javax.annotation.Resource;
|
import org.springframework.stereotype.Component;
|
|
import java.util.*;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年07月08日
|
*/
|
@Component("fakeDataTask")
|
public class FakeDataTask implements ITask {
|
|
@Resource
|
private StModelService stModelService;
|
|
@Resource
|
private ModelHandler modelHandler;
|
|
@Resource
|
private StModelResultService stModelCommonResultService;
|
|
// private final String MODEL_CODE = "shallow_groove_separation_control307";
|
|
// private final String MODEL_CODE = "shallow_groove_separation_control308";
|
|
// private final String MODEL_CODE = "separation_control3318";
|
|
// private final String MODEL_CODE = "separation_control3319";
|
|
// private final String MODEL_CODE = "thickener_control_qc";
|
|
// private final String MODEL_CODE = "thickener_control_xl";
|
|
// private final String MODEL_CODE = "filter";
|
|
private final String MODEL_CODE = "warehouse_allocation";
|
|
private Date startDate = DateUtils.stringToDate("2024-05-15 12:00:00", DateUtils.DATE_TIME_PATTERN);
|
|
private Date endDate = DateUtils.stringToDate("2024-07-01 12:00:00", DateUtils.DATE_TIME_PATTERN);
|
|
private int sc = 60;
|
|
private List<Integer> inHours = new ArrayList<>();
|
|
FakeDataTask() {
|
inHours.add(18);
|
}
|
|
@Override
|
public void run(String params) {
|
Calendar calendar = Calendar.getInstance();
|
calendar.setTime(startDate);
|
do {
|
calendar.add(Calendar.SECOND, sc);
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
System.out.println("hour=" + hour);
|
System.out.println(DateUtils.format(calendar.getTime(), DateUtils.DATE_TIME_PATTERN));
|
if (!inHours.contains(hour) || calendar.get(Calendar.MINUTE) > 10) {
|
continue;
|
}
|
StModelDTO stModel = stModelService.getByCode(MODEL_CODE);
|
|
// 307
|
// String jsonString = "{\"mv_fl_kd_307\":14,\"mv_hj_water_valve_main_307\":0,\"mv_xj_water_valve_307\":51,\"mv_hj_water_valve_small_307\":0,\"mv_mn_water_valve_307\":0,\"status\":200,\"tips\":\"OK\"}";
|
|
// 308
|
// String jsonString = "{\"mv_fl_kd_308\":14,\"mv_hj_water_valve_main_308\":0,\"mv_xj_water_valve_308\":51,\"mv_hj_water_valve_small_308\":0,\"mv_mn_water_valve_308\":0,\"status\":200,\"tips\":\"OK\"}";
|
|
// 3318
|
//String jsonString = "{\"mv_pump_hl_3318\":9,\"mv_valve_fl_3318\":0,\"mv_pump_hj_3318\":11,\"mv_pump_xj_3318\":12,\"mv_value_hj_water_3318\":0,\"mv_value_xj_water_3318\":10,\"mv_valve_jj_3318\":0,\"mv_pump_mn_3318\":0,\"mv_valve_mn_water_3318\":30,\"target_md_3318\":15,\"status\":200,\"tips\":\"OK\"}";
|
|
// 3319
|
// String jsonString = "{\"mv_pump_hl_3319\":9,\"mv_valve_fl_3319\":0,\"mv_pump_hj_3319\":11,\"mv_pump_xj_3319\":12,\"mv_value_hj_water_3319\":0,\"mv_value_xj_water_3319\":10,\"mv_valve_jj_3319\":0,\"mv_pump_mn_3319\":0,\"mv_valve_mn_water_3319\":30,\"target_md_3319\":15,\"status\":200,\"tips\":\"OK\"}";
|
|
// 浅槽浓缩
|
// String jsonString = "{\"Dos_yang_det_QC\":35.5,\"Dos_yin_det_QC\":28.0,\"status\":200}";
|
|
// 旋流浓缩
|
// String jsonString = "{\"Dos_yang_det1_XL\":38.0,\"Dos_yang_det2_XL\":0,\"Dos_yin_det1_XL\":31.0,\"Dos_yin_det2_XL\":0,\"status\":200}";
|
|
// 智能压滤
|
// String jsonString = "{\"zt4429_res\":0,\"UF_pumb2\":0.0,\"zt4430_res\":-1,\"zt4422_res\":-1,\"zt4428_res\":1,\"zt4431_res\":1,\"zt4432_res\":-1,\"zt4419_res\":1,\"UF_pumb1\":1.0,\"zt4420_res\":-1,\"zt4418_res\":-1,\"zt4421_res\":-1,\"status\":200}";
|
|
// 智能配仓
|
String jsonString = "{\"status\":200,\"tips\":\"OK\",\"unloader_state1\":0,\"unloader_state2\":0,\"unloader_state3\":0,\"unloader_state4\":0,\"unloader_state5\":0,\"unloader_state6\":0,\"unloader_state7\":0,\"unloader_state8\":0,\"unloader_state9\":0,\"unloader_state10\":1,\"bunker_ash\":7.74,\"bunker_water\":6.78,\"bunker_heat_val\":4617,\"bunker_number\":[4,12]}";
|
|
Map<String, Object> result = JSON.parseObject(jsonString);
|
stModelCommonResultService.addML(stModel.getId(), result, calendar.getTime());
|
modelHandler.addLog(stModel.getId(), MODEL_CODE, calendar.getTime(), modelHandler.dealResult(result));
|
} while (calendar.getTime().getTime() <= endDate.getTime());
|
|
}
|
}
|