|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.gyee.alarm.init.CacheContext;
|
|
|
import com.gyee.alarm.mapper.auto.ProEconShutdownEvent2Mapper;
|
|
|
import com.gyee.alarm.model.auto.ProEconShutdownEvent2;
|
|
|
import com.gyee.alarm.model.vo.ShutdownEventVo;
|
|
@@ -16,8 +17,7 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -32,41 +32,108 @@ public class ProEconShutdownEvent2ServiceImpl extends ServiceImpl<ProEconShutdow
|
|
|
|
|
|
@Resource
|
|
|
private ProEconShutdownEvent2Mapper proEconShutdownEvent2Mapper;
|
|
|
- public IPage<ProEconShutdownEvent2> queryShutdownEvent2(String wpId, String wtId,String description, String begin,String end, Integer pageNum, Integer pageSize,String type) {
|
|
|
- QueryWrapper<ProEconShutdownEvent2> qw = new QueryWrapper<>();
|
|
|
-
|
|
|
- if (StringUtils.notEmp(wpId)) {
|
|
|
- qw.eq("winpowerstation_id", wpId);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.notEmp(wtId)) {
|
|
|
- qw.eq("windturbine_id", wtId);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.notEmp(description)) {
|
|
|
- qw.like("fault_view", "%"+description+"%");
|
|
|
- }
|
|
|
+// public IPage<ProEconShutdownEvent2> queryShutdownEvent2(String wpId, String wtId,String description, String begin,String end, Integer pageNum, Integer pageSize,String type,String modelId) {
|
|
|
+// QueryWrapper<ProEconShutdownEvent2> qw = new QueryWrapper<>();
|
|
|
+//
|
|
|
+// if (StringUtils.notEmp(wpId)) {
|
|
|
+// qw.eq("winpowerstation_id", wpId);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.notEmp(wtId)) {
|
|
|
+// qw.eq("windturbine_id", wtId);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.notEmp(modelId)) {
|
|
|
+// qw.eq("windturbine_id", modelId);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.notEmp(description)) {
|
|
|
+// qw.like("fault_view", "%"+description+"%");
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.notEmp(begin) && StringUtils.notEmp(end)) {
|
|
|
+// try {
|
|
|
+// Date beginDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(begin);
|
|
|
+// Date endDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(end);
|
|
|
+// qw.ge("stop_time", beginDate);
|
|
|
+// qw.le("stop_time", endDate);
|
|
|
+// } catch (ParseException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// qw.eq("stop_type_id", type);
|
|
|
+// qw.orderByDesc("stop_time");
|
|
|
+//
|
|
|
+//
|
|
|
+// Page<ProEconShutdownEvent2> page = new Page<>(pageNum, pageSize);
|
|
|
+// IPage<ProEconShutdownEvent2> InputPage = getBaseMapper().selectPage(page, qw);
|
|
|
+//
|
|
|
+// return InputPage;
|
|
|
+// }
|
|
|
+
|
|
|
+ public Map<String,Object> queryShutdownEvent2(String wpId, String wtId, String description, String begin, String end, Integer pageNum, Integer pageSize, String type, String modelId) {
|
|
|
+
|
|
|
+ Map<String,Object> map=new HashMap();
|
|
|
|
|
|
if (StringUtils.notEmp(begin) && StringUtils.notEmp(end)) {
|
|
|
try {
|
|
|
Date beginDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(begin);
|
|
|
Date endDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(end);
|
|
|
- qw.ge("stop_time", beginDate);
|
|
|
- qw.le("stop_time", endDate);
|
|
|
+ List<ProEconShutdownEvent2> ls=proEconShutdownEvent2Mapper.queryShutdownEvent( wpId, modelId, beginDate, endDate,type);
|
|
|
+
|
|
|
+ map.put("total",ls.size());
|
|
|
+ List<ProEconShutdownEvent2> vos = paginate(ls, pageNum, pageSize);
|
|
|
+
|
|
|
+
|
|
|
+ for(ProEconShutdownEvent2 vo:vos)
|
|
|
+ {
|
|
|
+ if(com.gyee.alarm.util.StringUtils.notEmp(vo.getWindturbineId()) && CacheContext.wtmap.containsKey(vo.getWindturbineId()))
|
|
|
+ {
|
|
|
+ vo.setCode(CacheContext.wtmap.get(vo.getWindturbineId()).getNemCode());
|
|
|
+
|
|
|
+ vo.setWindturbineName(CacheContext.wtmap.get(vo.getWindturbineId()).getName());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("result",vos);
|
|
|
+
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ map.put("total",0);
|
|
|
+ map.put("result",new ArrayList<ProEconShutdownEvent2>());
|
|
|
}
|
|
|
- qw.eq("stop_type_id", type);
|
|
|
- qw.orderByDesc("stop_time");
|
|
|
|
|
|
|
|
|
- Page<ProEconShutdownEvent2> page = new Page<>(pageNum, pageSize);
|
|
|
- IPage<ProEconShutdownEvent2> InputPage = getBaseMapper().selectPage(page, qw);
|
|
|
-
|
|
|
- return InputPage;
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 对集合进行分页
|
|
|
+ *
|
|
|
+ * @param <T> 集合中元素的类型
|
|
|
+ * @param list 要分页的集合
|
|
|
+ * @param pageNumber 页码,从1开始
|
|
|
+ * @param pageSize 每页显示的元素数量
|
|
|
+ * @return 返回指定页的数据
|
|
|
+ */
|
|
|
+ public static <T> List<T> paginate(List<T> list, int pageNumber, int pageSize) {
|
|
|
+ if (list == null || list.isEmpty() || pageNumber <= 0 || pageSize <= 0) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算开始和结束的索引
|
|
|
+ int fromIndex = (pageNumber - 1) * pageSize;
|
|
|
+ if (fromIndex >= list.size()) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ int toIndex = Math.min(fromIndex + pageSize, list.size());
|
|
|
+ return new ArrayList<>(list.subList(fromIndex, toIndex));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public List<ShutdownEventVo> queryShutdownEvent2ByType(String wpId, String modelId, Date begin, Date end)
|