Commit b53c0e34 authored by caotao's avatar caotao

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

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