|
@@ -13,6 +13,7 @@ import com.gyee.impala.model.master.diagnose.AlgorithmType;
|
|
|
import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
|
|
|
import com.gyee.impala.service.master.diagnose.DiagnosetrainhistoryService;
|
|
|
import org.apache.kudu.client.*;
|
|
|
+import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -21,6 +22,8 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<DiagnosetrainhistoryMapper, Diagnosetrainhistory> implements DiagnosetrainhistoryService {
|
|
|
|
|
|
+
|
|
|
+ private static Logger logger = Logger.getLogger(DiagnosetrainhistoryServiceImpl.class);
|
|
|
@Autowired
|
|
|
private KuduDataSourceConfig kuduConfig;
|
|
|
|
|
@@ -50,7 +53,14 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteById(String id) {
|
|
|
+ public void deleteById(String id) throws CustomException{
|
|
|
+
|
|
|
+ Diagnosetrainhistory oriHistory = getHistoryById(id);
|
|
|
+ if (null == oriHistory) {
|
|
|
+ logger.warn("没有查找到此模型[ id = " + id + " ]");
|
|
|
+ throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
+ }
|
|
|
+
|
|
|
QueryWrapper<Diagnosetrainhistory> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("id",id);
|
|
|
try {
|
|
@@ -62,11 +72,12 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Diagnosetrainhistory getHistoryByModel(String model) {
|
|
|
- QueryWrapper<Diagnosetrainhistory> wrapper = new QueryWrapper<>();
|
|
|
+ public List<Diagnosetrainhistory> getHistoryByModel(String id,String model) {
|
|
|
+ ExcludeQueryWrapper<Diagnosetrainhistory> wrapper = new ExcludeQueryWrapper<>();
|
|
|
+ wrapper.ne("id",id);
|
|
|
wrapper.eq("model",model);
|
|
|
try{
|
|
|
- return baseMapper.selectList(wrapper).get(0);
|
|
|
+ return baseMapper.selectList(wrapper);
|
|
|
} catch (Exception e){
|
|
|
log.error(e.getMessage());
|
|
|
throw new CustomException(ResultCode.ERROR_DATA);
|
|
@@ -75,9 +86,44 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
|
|
|
|
|
|
@Override
|
|
|
public void editDiagnosetrainhistory(Diagnosetrainhistory history) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
+ List<Diagnosetrainhistory> historyByModel = getHistoryByModel(history.getId(), history.getModel());
|
|
|
+ if (null != historyByModel && historyByModel.size() > 0 && history.isEnable()) {
|
|
|
+ for (Diagnosetrainhistory h : historyByModel) {
|
|
|
+ h.setEnable(false);
|
|
|
+ baseMapper.updateById(h);
|
|
|
+ }
|
|
|
+ }
|
|
|
baseMapper.updateById(history);
|
|
|
initialRunner.cacheKnowCategory();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Diagnosetrainhistory> getList(Boolean enable, String name, String code,String model) {
|
|
|
+ ExcludeQueryWrapper<Diagnosetrainhistory> wrapper = new ExcludeQueryWrapper<>();
|
|
|
+
|
|
|
+ wrapper.eq("enable", enable);
|
|
|
+ wrapper.eq("name", name);
|
|
|
+ wrapper.eq("code", code);
|
|
|
+ wrapper.eq("model",model);
|
|
|
+ try{
|
|
|
+ return baseMapper.selectList(wrapper);
|
|
|
+ } catch (Exception e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Diagnosetrainhistory getHistoryById(String historyId) {
|
|
|
+ ExcludeQueryWrapper<Diagnosetrainhistory> wrapper = new ExcludeQueryWrapper<>();
|
|
|
+ wrapper.eq("id",historyId);
|
|
|
+ try{
|
|
|
+ return baseMapper.selectById(historyId);
|
|
|
} catch (Exception e){
|
|
|
log.error(e.getMessage());
|
|
|
throw new CustomException(ResultCode.ERROR_DATA);
|
|
@@ -85,11 +131,11 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Diagnosetrainhistory> getList() {
|
|
|
+ public Diagnosetrainhistory getHistoryByCode(String code) {
|
|
|
QueryWrapper<Diagnosetrainhistory> wrapper = new QueryWrapper<>();
|
|
|
-// wrapper.eq("model",model);
|
|
|
+ wrapper.eq("code",code);
|
|
|
try{
|
|
|
- return baseMapper.selectList(wrapper);
|
|
|
+ return baseMapper.selectList(wrapper).get(0);
|
|
|
} catch (Exception e){
|
|
|
log.error(e.getMessage());
|
|
|
throw new CustomException(ResultCode.ERROR_DATA);
|