package com.iailab.module.feign;
|
|
import com.iailab.api.IFeignModelApi;
|
import com.iailab.module.device.service.DeviceAbnormalHistoryService;
|
import com.iailab.module.device.service.DeviceAccountService;
|
import com.iailab.module.device.service.DeviceHealthStateService;
|
import com.iailab.module.device.service.DeviceRunStateService;
|
import com.iailab.module.model.handler.ModelHandler;
|
import org.apache.commons.lang3.StringUtils;
|
import javax.annotation.Resource;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.Calendar;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author lirm
|
* @Description
|
* @createTime 2024年05月22日
|
*/
|
@RestController
|
public class FeignModelImpl implements IFeignModelApi {
|
|
@Resource
|
private DeviceRunStateService deviceRunStateService;
|
|
@Resource
|
private DeviceHealthStateService deviceHealthStateService;
|
|
@Resource
|
private DeviceAbnormalHistoryService deviceAbnormalHistoryService;
|
|
@Resource
|
private DeviceAccountService deviceAccountService;
|
|
@Resource
|
private ModelHandler modelHandler;
|
|
@Override
|
public void insertRunState(Map<String, Integer> tMap) {
|
deviceRunStateService.insertRunState(tMap);
|
}
|
|
@Override
|
public void insertHealthState(Map<String, Object> tMap) {
|
deviceHealthStateService.insertHealthState(tMap);
|
deviceAbnormalHistoryService.insertHistory(tMap);
|
}
|
|
@Override
|
public void insertDeviceList(Map<String, String> tMap) {
|
deviceAccountService.insertDeviceList(tMap);
|
}
|
|
@Override
|
public Map<String, Object> runModel(Map<String, Object> params, List<double[][]> sampleDataList) {
|
Map<String, Object> result = new HashMap<>();
|
try {
|
String modelCode = (String) params.get("modelCode");
|
if (StringUtils.isBlank(modelCode)) {
|
return result;
|
}
|
if (CollectionUtils.isEmpty(sampleDataList)) {
|
return result;
|
}
|
Calendar calendar = Calendar.getInstance();
|
calendar.set(Calendar.MILLISECOND, 0);
|
result = modelHandler.run(modelCode, sampleDataList);
|
} catch (Exception ex) {
|
ex.printStackTrace();
|
}
|
return result;
|
}
|
|
@Override
|
public List<String> getDeviceIdList() {
|
return deviceAccountService.getDeviceIdList();
|
}
|
}
|