|
@@ -5,23 +5,31 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.gyee.impala.common.base.ExcludeQueryWrapper;
|
|
|
import com.gyee.impala.common.config.datasource.KuduDataSourceConfig;
|
|
|
import com.gyee.impala.common.exception.CustomException;
|
|
|
+import com.gyee.impala.common.feign.RemoteServiceBuilder;
|
|
|
import com.gyee.impala.common.result.ResultCode;
|
|
|
import com.gyee.impala.common.spring.InitialRunner;
|
|
|
import com.gyee.impala.common.util.DateUtil;
|
|
|
import com.gyee.impala.common.util.SnowFlakeUtil;
|
|
|
import com.gyee.impala.mapper.master.CasefaultalgMapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.gyee.impala.mapper.slave.Windturbinetestingpointai2Mapper;
|
|
|
+import com.gyee.impala.model.custom.TsDoubleData;
|
|
|
import com.gyee.impala.model.master.Casefault;
|
|
|
import com.gyee.impala.model.master.Casefaultalg;
|
|
|
+import com.gyee.impala.model.slave.Windturbinetestingpointai2;
|
|
|
import com.gyee.impala.service.master.CasefaultService;
|
|
|
import com.gyee.impala.service.master.CasefaultalgService;
|
|
|
import org.apache.kudu.client.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -38,7 +46,20 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
|
|
|
private KuduDataSourceConfig kuduConfig;
|
|
|
@Autowired
|
|
|
private CasefaultService casefaultService;
|
|
|
+ @Resource
|
|
|
+ private Windturbinetestingpointai2Mapper windturbinetestingpointai2Mapper;
|
|
|
+ @Autowired
|
|
|
+ private RemoteServiceBuilder remoteServiceBuilder;
|
|
|
+
|
|
|
+ private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
|
+ @Cacheable("aisAI022")
|
|
|
+ public Map<String, Windturbinetestingpointai2> getWindpointai2s() {
|
|
|
+ Map<String, Object> wrapper = new HashMap<>();
|
|
|
+ wrapper.put("uniformcode", "AI022");
|
|
|
+ List<Windturbinetestingpointai2> ai2s = windturbinetestingpointai2Mapper.selectByMap(wrapper);
|
|
|
+ return ai2s.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Function.identity()));
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void insertBatch(List<Casefaultalg> list) {
|
|
@@ -52,6 +73,23 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void insertBatchAddspeed(List<Casefaultalg> list) {
|
|
|
+ if (list == null || list.size() == 0)
|
|
|
+ return;
|
|
|
+ Map<String, Windturbinetestingpointai2> windpointai2s = getWindpointai2s();
|
|
|
+ try{
|
|
|
+ for (Casefaultalg casefaultalg : list) {
|
|
|
+ Map<String,TsDoubleData> historySection = remoteServiceBuilder.adapter().getHistorySection(windpointai2s.get(casefaultalg.getWindturbineid()).getId(), sdf.parse(casefaultalg.getStarttime()).getTime());
|
|
|
+ TsDoubleData value = historySection.entrySet().iterator().next().getValue();
|
|
|
+ casefaultalg.setSpeed(String.valueOf(value.getDoubleValue()));
|
|
|
+ }
|
|
|
+ insert(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<Casefaultalg> getAll(String station, String wtId, String[] id, Long[] faultid, String[] model, String[] faultcode,
|