Commit b53c0e34 authored by caotao's avatar caotao

17826:【小程序端-电站监控】报警信息>电站报警列表,未处理报警列表没有一条数据

parent a9365470
......@@ -44,269 +44,271 @@ import java.util.stream.Collectors;
@RequestMapping(value = "/td-hygf-jp-inverter-warn")
public class TdHygfJpInverterWarnController extends BaseController {
@Autowired
TdHygfJpInverterWarnServiceImpl tdHygfJpInverterWarnServiceImpl;
@Autowired
JpPersonStationMapper pPersonStationMapper;
@Autowired
TdHygfJpInverterWarnMapper tdHygfJpInverterWarnMapper;
@Autowired
JpStationMapper jpStationMapper;
@Autowired
HYGFMaintenanceTicketsMapper hygfMaintenanceTicketsMapper;
@Autowired
TdHygfJpInverterWarnServiceImpl tdHygfJpInverterWarnServiceImpl;
@Autowired
JpPersonStationMapper pPersonStationMapper;
@Autowired
TdHygfJpInverterWarnMapper tdHygfJpInverterWarnMapper;
@Autowired
JpStationMapper jpStationMapper;
@Autowired
HYGFMaintenanceTicketsMapper hygfMaintenanceTicketsMapper;
/**
* 新增户用光伏监盘逆变器报警表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增户用光伏监盘逆变器报警表", notes = "新增户用光伏监盘逆变器报警表")
public ResponseModel<TdHygfJpInverterWarnDto> save(@RequestBody TdHygfJpInverterWarnDto model) {
model = tdHygfJpInverterWarnServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 新增户用光伏监盘逆变器报警表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增户用光伏监盘逆变器报警表", notes = "新增户用光伏监盘逆变器报警表")
public ResponseModel<TdHygfJpInverterWarnDto> save(@RequestBody TdHygfJpInverterWarnDto model) {
model = tdHygfJpInverterWarnServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新户用光伏监盘逆变器报警表", notes = "根据sequenceNbr更新户用光伏监盘逆变器报警表")
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新户用光伏监盘逆变器报警表", notes = "根据sequenceNbr更新户用光伏监盘逆变器报警表")
public ResponseModel<TdHygfJpInverterWarnDto> updateBySequenceNbrTdHygfJpInverterWarn(
@RequestBody TdHygfJpInverterWarnDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.updateWithModel(model));
public ResponseModel<TdHygfJpInverterWarnDto> updateBySequenceNbrTdHygfJpInverterWarn(
@RequestBody TdHygfJpInverterWarnDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.updateWithModel(model));
}
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除户用光伏监盘逆变器报警表", notes = "根据sequenceNbr删除户用光伏监盘逆变器报警表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除户用光伏监盘逆变器报警表", notes = "根据sequenceNbr删除户用光伏监盘逆变器报警表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表")
public ResponseModel<TdHygfJpInverterWarnDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "time/{createdTime}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表")
public ResponseModel<TdHygfJpInverterWarnDto> selectCreatedTime(@PathVariable Long createdTime) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.queryByCreatedTime(createdTime));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表")
public ResponseModel<TdHygfJpInverterWarnDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器报警表分页查询", notes = "户用光伏监盘逆变器报警表分页查询")
public ResponseModel<Page<TdHygfJpInverterWarnDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, TdHygfJpInverterWarnDto tdHygfJpInverterWarnDto) {
List<JpPersonStation> pPersonStation =null;
if(tdHygfJpInverterWarnDto.getName()!=null&&!"".equals(tdHygfJpInverterWarnDto.getName())){
LambdaQueryWrapper<JpPersonStation> qug1=new LambdaQueryWrapper<>();
qug1.like(JpPersonStation::getStationName,tdHygfJpInverterWarnDto.getName());
pPersonStation=pPersonStationMapper.selectList(qug1);
}else{
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "time/{createdTime}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器报警表")
public ResponseModel<TdHygfJpInverterWarnDto> selectCreatedTime(@PathVariable Long createdTime) {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.queryByCreatedTime(createdTime));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器报警表分页查询", notes = "户用光伏监盘逆变器报警表分页查询")
public ResponseModel<Page<TdHygfJpInverterWarnDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, TdHygfJpInverterWarnDto tdHygfJpInverterWarnDto) {
List<JpPersonStation> pPersonStation = null;
if (tdHygfJpInverterWarnDto.getName() != null && !"".equals(tdHygfJpInverterWarnDto.getName())) {
LambdaQueryWrapper<JpPersonStation> qug1 = new LambdaQueryWrapper<>();
qug1.like(JpPersonStation::getStationName, tdHygfJpInverterWarnDto.getName());
pPersonStation = pPersonStationMapper.selectList(qug1);
} else {
LambdaQueryWrapper<JpPersonStation> qug = new LambdaQueryWrapper<>();
qug.eq(JpPersonStation::getPersonId, getUserInfo().getUserId());
pPersonStation = pPersonStationMapper.selectList(qug);
pPersonStation = pPersonStationMapper.selectList(qug);
}
if (!pPersonStation.isEmpty()) {
Page<TdHygfJpInverterWarnDto> page = new Page<TdHygfJpInverterWarnDto>();
page.setCurrent(current);
page.setSize(size);
List<String> ids = pPersonStation.stream().map(i -> i.getStationId()).collect(Collectors.toList());
tdHygfJpInverterWarnDto.setStationIds(ids);
return ResponseHelper.buildResponse(
tdHygfJpInverterWarnServiceImpl.queryForTdHygfJpInverterWarnPage(page, tdHygfJpInverterWarnDto));
} else {
return ResponseHelper.buildResponse(new Page<TdHygfJpInverterWarnDto>());
}
if (!pPersonStation.isEmpty()) {
Page<TdHygfJpInverterWarnDto> page = new Page<TdHygfJpInverterWarnDto>();
page.setCurrent(current);
page.setSize(size);
List<String> ids = pPersonStation.stream().map(i -> i.getStationId()).collect(Collectors.toList());
tdHygfJpInverterWarnDto.setStationIds(ids);
return ResponseHelper.buildResponse(
tdHygfJpInverterWarnServiceImpl.queryForTdHygfJpInverterWarnPage(page, tdHygfJpInverterWarnDto));
} else {
return ResponseHelper.buildResponse(new Page<TdHygfJpInverterWarnDto>());
}
}
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器报警表列表全部数据查询", notes = "户用光伏监盘逆变器报警表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<TdHygfJpInverterWarnDto>> selectForList() {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.queryForTdHygfJpInverterWarnList());
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器报警表列表全部数据查询", notes = "户用光伏监盘逆变器报警表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<TdHygfJpInverterWarnDto>> selectForList() {
return ResponseHelper.buildResponse(tdHygfJpInverterWarnServiceImpl.queryForTdHygfJpInverterWarnList());
}
/**
* 获取告警统计
* **/
/**
* 获取告警统计
**/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器报警表列表全部数据查询", notes = "户用光伏监盘逆变器报警表列表全部数据查询")
@GetMapping(value = "/selectcount")
public ResponseModel< Map<String,Object> > selectcount(JpStationDto reviewDto) {
LambdaQueryWrapper<JpStation> qugda=new LambdaQueryWrapper<>();
public ResponseModel<Map<String, Object>> selectcount(JpStationDto reviewDto) {
LambdaQueryWrapper<JpStation> qugda = new LambdaQueryWrapper<>();
//获取当前人管理场站
if(reviewDto.getThirdStationId()==null){
if (reviewDto.getThirdStationId() == null) {
//获取当前人管理场站
LambdaQueryWrapper<JpPersonStation> qug=new LambdaQueryWrapper<>();
qug.eq(JpPersonStation::getPersonId,getUserInfo().getUserId());
List<JpPersonStation> pPersonStation=pPersonStationMapper.selectList(qug);
LambdaQueryWrapper<JpPersonStation> qug = new LambdaQueryWrapper<>();
qug.eq(JpPersonStation::getPersonId, getUserInfo().getUserId());
List<JpPersonStation> pPersonStation = pPersonStationMapper.selectList(qug);
if(pPersonStation==null||pPersonStation.isEmpty()){
return ResponseHelper.buildResponse(null);
if (pPersonStation == null || pPersonStation.isEmpty()) {
return ResponseHelper.buildResponse(null);
}
List ids=null;
if(pPersonStation!=null&&!pPersonStation.isEmpty()){
ids=new ArrayList();
List ids = null;
if (pPersonStation != null && !pPersonStation.isEmpty()) {
ids = new ArrayList();
for (JpPersonStation jpPersonStation : pPersonStation) {
ids.add(jpPersonStation.getStationId());
}
qugda.in(ids!=null,JpStation::getThirdStationId,ids);
qugda.in(ids != null, JpStation::getThirdStationId, ids);
}
}else{
qugda.eq(JpStation::getThirdStationId,reviewDto.getThirdStationId());
} else {
qugda.eq(JpStation::getThirdStationId, reviewDto.getThirdStationId());
}
qugda.like(reviewDto.getName()!=null,JpStation::getName,reviewDto.getName());
qugda.like(reviewDto.getArea()!=null,JpStation::getArea,reviewDto.getArea());
List<JpStation> pPersonStation=jpStationMapper.selectList(qugda);
List<Map<String,Object>> datalist= tdHygfJpInverterWarnMapper.getCountTdHygfJpInverterWarn(pPersonStation!=null&&!pPersonStation.isEmpty()?pPersonStation:null);
Map<String,Object> collector =new HashMap<>();
collector.put("wcl",0);
collector.put("ycl",0);
qugda.like(reviewDto.getName() != null, JpStation::getName, reviewDto.getName());
qugda.like(reviewDto.getArea() != null, JpStation::getArea, reviewDto.getArea());
List<JpStation> pPersonStation = jpStationMapper.selectList(qugda);
List<Map<String, Object>> datalist = tdHygfJpInverterWarnMapper.getCountTdHygfJpInverterWarn(pPersonStation != null && !pPersonStation.isEmpty() ? pPersonStation : null);
Map<String, Object> collector = new HashMap<>();
collector.put("wcl", 0);
collector.put("ycl", 0);
if(datalist!=null&&!datalist.isEmpty()){
for (Map<String, Object> map : datalist) {
if("未处理".equals(map.get("state").toString())){
collector.put("wcl",Integer.valueOf(map.get("num").toString()));
}else if("已处理".equals(map.get("state").toString())||"已恢复".equals(map.get("state").toString())){
collector.put("ycl",Integer.valueOf(map.get("num").toString()));
if (datalist != null && !datalist.isEmpty()) {
for (Map<String, Object> map : datalist) {
if ("未处理".equals(map.get("state").toString())) {
collector.put("wcl", Integer.valueOf(map.get("num").toString()));
} else if ("已处理".equals(map.get("state").toString()) || "已恢复".equals(map.get("state").toString())) {
collector.put("ycl", Integer.valueOf(map.get("num").toString()));
}
}
}
return ResponseHelper.buildResponse(collector);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器报警表列表全部数据查询", notes = "户用光伏监盘逆变器报警表列表全部数据查询")
@GetMapping(value = "/selectWarnList")
@UserLimits
public ResponseModel<Page<TdHygfJpInverterWarnDto>> selectWarnList(@RequestParam(required = false) String state,
@RequestParam(required = false) String handlerStatus,
@RequestParam(required = false) String level,
@RequestParam(required = false) String stationName,
@RequestParam(required = false) String minvalue,
@RequestParam(required = false) String maxValue,
@RequestParam(required = false) String snCode,
@RequestParam(required = false) List<String> stationId,
@RequestParam(required = false) String[] time,
@RequestParam(required = false) Integer current,
@RequestParam(required = false) Integer size,
@RequestParam(required = false) String content) {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器报警表列表全部数据查询", notes = "户用光伏监盘逆变器报警表列表全部数据查询")
@GetMapping(value = "/selectWarnList")
@UserLimits
public ResponseModel<Page<TdHygfJpInverterWarnDto>> selectWarnList(@RequestParam(required = false) String state,
@RequestParam(required = false) String handlerStatus,
@RequestParam(required = false) String level,
@RequestParam(required = false) String stationName,
@RequestParam(required = false) String minvalue,
@RequestParam(required = false) String maxValue,
@RequestParam(required = false) String snCode,
@RequestParam(required = false) List<String> stationId,
@RequestParam(required = false) String[] time,
@RequestParam(required = false) Integer current,
@RequestParam(required = false) Integer size,
@RequestParam(required = false) String content) {
Page<TdHygfJpInverterWarnDto> result = new Page<>();
result.setCurrent(current);
result.setSize(size);
JpStationDto reviewDto = new JpStationDto();
Map<String, String> nameMaps = new HashMap<>();
if (null != stationName && stationName != ""){
reviewDto.setName(stationName);
}
List<JpStation> jpStation = jpStationMapper.getJpStation(reviewDto);
if (CollectionUtil.isEmpty(jpStation)){
result.setTotal(0);
List<TdHygfJpInverterWarnDto> list = new ArrayList<>();
result.setRecords(list);
return ResponseHelper.buildResponse(result);
Page<TdHygfJpInverterWarnDto> result = new Page<>();
result.setCurrent(current);
result.setSize(size);
JpStationDto reviewDto = new JpStationDto();
Map<String, String> nameMaps = new HashMap<>();
if (null != stationName && stationName != "") {
reviewDto.setName(stationName);
}
List<JpStation> jpStation = jpStationMapper.getJpStation(reviewDto);
if (CollectionUtil.isEmpty(jpStation)) {
result.setTotal(0);
List<TdHygfJpInverterWarnDto> list = new ArrayList<>();
result.setRecords(list);
return ResponseHelper.buildResponse(result);
}
nameMaps = jpStation.stream().collect(Collectors.toMap(JpStation::getThirdStationId, JpStation::getName));
}
nameMaps = jpStation.stream().collect(Collectors.toMap(JpStation::getThirdStationId, JpStation::getName));
if (null == stationId ){
stationId = jpStation.stream().map(JpStation::getThirdStationId).collect(Collectors.toList());
}
String startTime ="";
String endTime = "";
if (null != time){
if (null == stationId) {
stationId = jpStation.stream().map(JpStation::getThirdStationId).collect(Collectors.toList());
}
String startTime = "";
String endTime = "";
if (null != time) {
try {
startTime = String.valueOf( DateUtils.dateParse(time[0].replace("[",""), null).getTime());
Date date = DateUtils.dateParse(time[1].replace("]", ""), null);
endTime = String.valueOf(DateUtils.dateAddDays(date,1).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
if (StringUtils.isNotEmpty(snCode)){
snCode = '%'+snCode+'%';
}
if (StringUtils.isNotEmpty(content)){
content = '%'+content+'%';
}
List<TdHygfJpInverterWarnDto> maps = tdHygfJpInverterWarnServiceImpl.selectWarnList(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content,current,size,handlerStatus);
for (TdHygfJpInverterWarnDto map : maps) {
if (nameMaps.containsKey(map.getThirdStationId())){
map.setStationName(nameMaps.get(map.getThirdStationId()));
}
String te= map.getTimeLong()!=null?TimeUtil.longFormat(map.getTimeLong()):"";
map.setTimeLongFormat(te);
}
try {
startTime = String.valueOf(DateUtils.dateParse(time[0].replace("[", ""), null).getTime());
Date date = DateUtils.dateParse(time[1].replace("]", ""), null);
endTime = String.valueOf(DateUtils.dateAddDays(date, 1).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
if (StringUtils.isNotEmpty(snCode)) {
snCode = '%' + snCode + '%';
}
if (StringUtils.isNotEmpty(content)) {
content = '%' + content + '%';
}
List<TdHygfJpInverterWarnDto> maps = tdHygfJpInverterWarnServiceImpl.selectWarnList(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, current, size, handlerStatus);
for (TdHygfJpInverterWarnDto map : maps) {
if (nameMaps.containsKey(map.getThirdStationId())) {
map.setStationName(nameMaps.get(map.getThirdStationId()));
}
String te = map.getTimeLong() != null ? TimeUtil.longFormat(map.getTimeLong()) : "";
map.setTimeLongFormat(te);
}
result.setTotal(tdHygfJpInverterWarnServiceImpl.selectWarnListTotal(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content,handlerStatus));
List<Long> waringIds = maps.stream().map(tdHygfJpInverterWarnDto -> tdHygfJpInverterWarnDto.getCreatedTime()).collect(Collectors.toList());
if(waringIds.size()==0){
waringIds =Arrays.asList(0L);
}
List<HYGFMaintenanceTickets> hygfMaintenanceTicketsList = hygfMaintenanceTicketsMapper.selectList(new QueryWrapper<HYGFMaintenanceTickets>().in("warning_id",waringIds));
maps.forEach(tdHygfJpInverterWarnDto -> {
Set<String> status = hygfMaintenanceTicketsList.stream().filter(hygfmaintenanceTickets -> tdHygfJpInverterWarnDto.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if(status.contains("未处理")){
tdHygfJpInverterWarnDto.setTicketStatus("处理中");
}
if(status.contains("已处理")&&status.size()==1){
tdHygfJpInverterWarnDto.setTicketStatus("已处理");
}
});
result.setRecords(maps);
return ResponseHelper.buildResponse(result);
}
result.setTotal(tdHygfJpInverterWarnServiceImpl.selectWarnListTotal(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, handlerStatus));
List<Long> waringIds = maps.stream().map(tdHygfJpInverterWarnDto -> tdHygfJpInverterWarnDto.getCreatedTime()).collect(Collectors.toList());
if (waringIds.size() == 0) {
waringIds = Arrays.asList(0L);
}
List<HYGFMaintenanceTickets> hygfMaintenanceTicketsList = hygfMaintenanceTicketsMapper.selectList(new QueryWrapper<HYGFMaintenanceTickets>().in("warning_id", waringIds));
if (hygfMaintenanceTicketsList.size() > 0) {
maps.forEach(tdHygfJpInverterWarnDto -> {
Set<String> status = hygfMaintenanceTicketsList.stream().filter(hygfmaintenanceTickets -> tdHygfJpInverterWarnDto.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if (status.contains("未处理")) {
tdHygfJpInverterWarnDto.setTicketStatus("处理中");
}
if (status.contains("已处理") && status.size() == 1) {
tdHygfJpInverterWarnDto.setTicketStatus("已处理");
}
});
}
result.setRecords(maps);
return ResponseHelper.buildResponse(result);
}
}
......@@ -32,145 +32,153 @@ import java.util.stream.Collectors;
*/
@Service
public class TdHygfJpInverterWarnServiceImpl
extends BaseService<TdHygfJpInverterWarnDto, TdHygfJpInverterWarn, TdHygfJpInverterWarnMapper>
implements ITdHygfJpInverterWarnService {
extends BaseService<TdHygfJpInverterWarnDto, TdHygfJpInverterWarn, TdHygfJpInverterWarnMapper>
implements ITdHygfJpInverterWarnService {
@Autowired
JpStationServiceImpl jpStationServiceImpl;
@Autowired
JpStationServiceImpl jpStationServiceImpl;
@Autowired
HYGFMaintenanceTicketsMapper hygfMaintenanceTicketsMapper;
@Autowired
HYGFMaintenanceTicketsMapper hygfMaintenanceTicketsMapper;
/**
* 分页查询
*/
public Page<TdHygfJpInverterWarnDto> queryForTdHygfJpInverterWarnPage(Page<TdHygfJpInverterWarnDto> pageParam,
TdHygfJpInverterWarnDto tdHygfJpInverterWarnDto) {
int pageNum = (int) pageParam.getCurrent();
int pageSize = (int) pageParam.getSize();
PageHelper.startPage(pageNum, pageSize);
if (tdHygfJpInverterWarnDto.getState() != null) {
String[] s = tdHygfJpInverterWarnDto.getState().split(",");
tdHygfJpInverterWarnDto.setStates(Arrays.asList(s));
}
if (tdHygfJpInverterWarnDto.getStationName() != null) {
LambdaQueryWrapper<JpStation> wapper = new LambdaQueryWrapper<JpStation>().like(JpStation::getName,
tdHygfJpInverterWarnDto.getStationName());
if (!tdHygfJpInverterWarnDto.getStationIds().isEmpty()) {
wapper.in(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getStationIds());
}
List<JpStation> sList = jpStationServiceImpl.list(wapper);
List<String> ids = sList.stream().map(i -> i.getThirdStationId()).collect(Collectors.toList());
tdHygfJpInverterWarnDto.setStationIds(ids);
}
/**
* 分页查询
*/
public Page<TdHygfJpInverterWarnDto> queryForTdHygfJpInverterWarnPage(Page<TdHygfJpInverterWarnDto> pageParam,
TdHygfJpInverterWarnDto tdHygfJpInverterWarnDto) {
int pageNum = (int) pageParam.getCurrent();
int pageSize = (int) pageParam.getSize();
PageHelper.startPage(pageNum, pageSize);
if (tdHygfJpInverterWarnDto.getState() != null) {
String[] s = tdHygfJpInverterWarnDto.getState().split(",");
tdHygfJpInverterWarnDto.setStates(Arrays.asList(s));
}
if (tdHygfJpInverterWarnDto.getStationName() != null) {
LambdaQueryWrapper<JpStation> wapper = new LambdaQueryWrapper<JpStation>().like(JpStation::getName,
tdHygfJpInverterWarnDto.getStationName());
if (!tdHygfJpInverterWarnDto.getStationIds().isEmpty()) {
wapper.in(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getStationIds());
}
List<JpStation> sList = jpStationServiceImpl.list(wapper);
List<String> ids = sList.stream().map(i -> i.getThirdStationId()).collect(Collectors.toList());
tdHygfJpInverterWarnDto.setStationIds(ids);
}
// if (tdHygfJpInverterWarnDto.getHandlerStatus() != null) {
// String[] s = tdHygfJpInverterWarnDto.getHandlerStatus().split(",");
// tdHygfJpInverterWarnDto.setListHandlerStatus(Arrays.asList(s));
// }
List<TdHygfJpInverterWarnDto> list = new ArrayList<>();
if (tdHygfJpInverterWarnDto.getStationIds().isEmpty()) {
list = this.baseMapper.list(tdHygfJpInverterWarnDto);
} else {
List<TdHygfJpInverterWarnDto> list = new ArrayList<>();
if (tdHygfJpInverterWarnDto.getStationIds().isEmpty()) {
list = this.baseMapper.list(tdHygfJpInverterWarnDto);
} else {
if (!list.isEmpty()) {
list.forEach(i -> {
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, i.getThirdStationId()));
if (jpStation != null) {
i.setAddress(jpStation.getAddress());
i.setStationName(jpStation.getName());
i.setArea(jpStation.getArea());
}
if (i.getStartTime() != null) {
i.setStartTimeFormat(TimeUtil.dateFormat(i.getStartTime()));
}
});
}
}
List<Long> waringIds = list.stream().map(tdHygfJpInverterWarnDto1 -> tdHygfJpInverterWarnDto1.getCreatedTime()).collect(Collectors.toList());
if(waringIds.size()==0){
waringIds =Arrays.asList(0L);
}
List<HYGFMaintenanceTickets> hygfMaintenanceTicketsList = hygfMaintenanceTicketsMapper.selectList(new QueryWrapper<HYGFMaintenanceTickets>().in("warning_id",waringIds));
Set<String> status = hygfMaintenanceTicketsList.stream().filter(hygfmaintenanceTickets -> tdHygfJpInverterWarnDto.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if(status.contains("未处理")){
tdHygfJpInverterWarnDto.setTicketStatus("处理中");
}
if(status.contains("已处理")&&status.size()==1){
tdHygfJpInverterWarnDto.setTicketStatus("已处理");
}
PageInfo<TdHygfJpInverterWarnDto> page = new PageInfo(list);
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto> pagenew = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto>();
pagenew.setCurrent(pageNum);
pagenew.setTotal(page.getTotal());
pagenew.setSize(pageSize);
pagenew.setRecords(page.getList());
return pagenew;
}
list = this.baseMapper.list(tdHygfJpInverterWarnDto);
/**
* 列表查询 示例
*/
public List<TdHygfJpInverterWarnDto> queryForTdHygfJpInverterWarnList() {
return this.getBaseMapper().listAll();
}
if (!list.isEmpty()) {
list.forEach(i -> {
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, i.getThirdStationId()));
if (jpStation != null) {
i.setAddress(jpStation.getAddress());
i.setStationName(jpStation.getName());
i.setArea(jpStation.getArea());
}
if (i.getStartTime() != null) {
i.setStartTimeFormat(TimeUtil.dateFormat(i.getStartTime()));
}
});
}
}
List<Long> waringIds = list.stream().map(tdHygfJpInverterWarnDto1 -> tdHygfJpInverterWarnDto1.getCreatedTime()).collect(Collectors.toList());
if (waringIds.size() == 0) {
waringIds = Arrays.asList(0L);
}
List<HYGFMaintenanceTickets> hygfMaintenanceTicketsList = hygfMaintenanceTicketsMapper.selectList(new QueryWrapper<HYGFMaintenanceTickets>().in("warning_id", waringIds));
if (hygfMaintenanceTicketsList.size() > 0) {
list.forEach(i -> {
List<HYGFMaintenanceTickets> ticketsList = hygfMaintenanceTicketsList.stream().filter(hygfmaintenanceTickets -> i.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(ticketsList)) {
Set<String> status = ticketsList.stream().map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if (status.contains("未处理")) {
i.setTicketStatus("处理中");
}
if (status.contains("已处理") && status.size() == 1) {
i.setTicketStatus("已处理");
}
}
});
}
PageInfo<TdHygfJpInverterWarnDto> page = new PageInfo(list);
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto> pagenew = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto>();
pagenew.setCurrent(pageNum);
pagenew.setTotal(page.getTotal());
pagenew.setSize(pageSize);
pagenew.setRecords(page.getList());
return pagenew;
}
public TdHygfJpInverterWarnDto queryByCreatedTime(long createdTime) {
Map map = new HashMap<>();
map.put("created_time", createdTime);
TdHygfJpInverterWarnDto tdHygfJpInverterWarnDto = this.baseMapper.getByTime(createdTime);
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getThirdStationId()));
List<HYGFMaintenanceTickets> hygfMaintenanceTickets = hygfMaintenanceTicketsMapper.
selectList(new QueryWrapper<HYGFMaintenanceTickets>()
.eq("warning_id",String.valueOf(tdHygfJpInverterWarnDto.getCreatedTime()))
.eq("inverter_sn",String.valueOf(tdHygfJpInverterWarnDto.getSnCode())));
if (jpStation != null) {
tdHygfJpInverterWarnDto.setStationName(jpStation.getName());
tdHygfJpInverterWarnDto.setStationContact(jpStation.getStationContact());
tdHygfJpInverterWarnDto.setUserName(jpStation.getUserName());
tdHygfJpInverterWarnDto.setUserPhone(jpStation.getUserPhone());
tdHygfJpInverterWarnDto.setEmail(jpStation.getEmail());
tdHygfJpInverterWarnDto.setAddress(jpStation.getAddress());
tdHygfJpInverterWarnDto.setArea(jpStation.getArea());
if (tdHygfJpInverterWarnDto.getRecoverTime() != null) {
tdHygfJpInverterWarnDto
.setRecoverTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getRecoverTime()));
tdHygfJpInverterWarnDto.setTimeLongFormat(TimeUtil
.longFormat(tdHygfJpInverterWarnDto.getRecoverTime() - tdHygfJpInverterWarnDto.getStartTime()));
}
if (tdHygfJpInverterWarnDto.getStartTime() != null) {
tdHygfJpInverterWarnDto.setStartTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getStartTime()));
}
}
if(hygfMaintenanceTickets.size()>0){
Set<String> status = hygfMaintenanceTickets.stream().filter(hygfmaintenanceTickets -> tdHygfJpInverterWarnDto.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if(status.contains("未处理")){
tdHygfJpInverterWarnDto.setTicketStatus("处理中");
}
if(status.contains("已处理")&&status.size()==1){
tdHygfJpInverterWarnDto.setTicketStatus("已处理");
}
tdHygfJpInverterWarnDto.setListTickets(hygfMaintenanceTickets);
}
return tdHygfJpInverterWarnDto;
}
/**
* 列表查询 示例
*/
public List<TdHygfJpInverterWarnDto> queryForTdHygfJpInverterWarnList() {
return this.getBaseMapper().listAll();
}
public List<TdHygfJpInverterWarnDto> selectWarnList(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, Integer current, Integer size,String handlerStatus){
List<TdHygfJpInverterWarnDto> list = this.getBaseMapper().selectWarnList(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content,(current-1)*size,size,handlerStatus);
list.forEach(i -> {
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, i.getThirdStationId()));
if(ObjectUtil.isNotNull(jpStation)){
i.setAddress(jpStation.getAddress());
i.setArea(jpStation.getArea());
}
});
return list;
}
public int selectWarnListTotal(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content,String handlerStatus){
return this.getBaseMapper().selectWarnListTotal(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content,handlerStatus);
}
public TdHygfJpInverterWarnDto queryByCreatedTime(long createdTime) {
Map map = new HashMap<>();
map.put("created_time", createdTime);
TdHygfJpInverterWarnDto tdHygfJpInverterWarnDto = this.baseMapper.getByTime(createdTime);
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getThirdStationId()));
List<HYGFMaintenanceTickets> hygfMaintenanceTickets = hygfMaintenanceTicketsMapper.
selectList(new QueryWrapper<HYGFMaintenanceTickets>()
.eq("warning_id", String.valueOf(tdHygfJpInverterWarnDto.getCreatedTime()))
.eq("inverter_sn", String.valueOf(tdHygfJpInverterWarnDto.getSnCode())));
if (jpStation != null) {
tdHygfJpInverterWarnDto.setStationName(jpStation.getName());
tdHygfJpInverterWarnDto.setStationContact(jpStation.getStationContact());
tdHygfJpInverterWarnDto.setUserName(jpStation.getUserName());
tdHygfJpInverterWarnDto.setUserPhone(jpStation.getUserPhone());
tdHygfJpInverterWarnDto.setEmail(jpStation.getEmail());
tdHygfJpInverterWarnDto.setAddress(jpStation.getAddress());
tdHygfJpInverterWarnDto.setArea(jpStation.getArea());
if (tdHygfJpInverterWarnDto.getRecoverTime() != null) {
tdHygfJpInverterWarnDto
.setRecoverTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getRecoverTime()));
tdHygfJpInverterWarnDto.setTimeLongFormat(TimeUtil
.longFormat(tdHygfJpInverterWarnDto.getRecoverTime() - tdHygfJpInverterWarnDto.getStartTime()));
}
if (tdHygfJpInverterWarnDto.getStartTime() != null) {
tdHygfJpInverterWarnDto.setStartTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getStartTime()));
}
}
if (hygfMaintenanceTickets.size() > 0) {
Set<String> status = hygfMaintenanceTickets.stream().filter(hygfmaintenanceTickets -> tdHygfJpInverterWarnDto.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if (status.contains("未处理")) {
tdHygfJpInverterWarnDto.setTicketStatus("处理中");
}
if (status.contains("已处理") && status.size() == 1) {
tdHygfJpInverterWarnDto.setTicketStatus("已处理");
}
tdHygfJpInverterWarnDto.setListTickets(hygfMaintenanceTickets);
}
return tdHygfJpInverterWarnDto;
}
public List<TdHygfJpInverterWarnDto> selectWarnList(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, Integer current, Integer size, String handlerStatus) {
List<TdHygfJpInverterWarnDto> list = this.getBaseMapper().selectWarnList(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, (current - 1) * size, size, handlerStatus);
list.forEach(i -> {
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, i.getThirdStationId()));
if (ObjectUtil.isNotNull(jpStation)) {
i.setAddress(jpStation.getAddress());
i.setArea(jpStation.getArea());
}
});
return list;
}
public int selectWarnListTotal(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, String handlerStatus) {
return this.getBaseMapper().selectWarnListTotal(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, handlerStatus);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment