布置图-渗压监测数据
parent
e328b32b1a
commit
f0b98f3e8a
|
|
@ -5,6 +5,7 @@ import com.gunshi.core.result.R;
|
|||
import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo;
|
||||
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo;
|
||||
import com.gunshi.project.xyt.entity.vo.OsmoticChartVo;
|
||||
import com.gunshi.project.xyt.entity.vo.OsmoticPressVo;
|
||||
import com.gunshi.project.xyt.entity.vo.OsmoticStationVo;
|
||||
import com.gunshi.project.xyt.model.OsmoticPressR;
|
||||
import com.gunshi.project.xyt.service.OsmoticPressRService;
|
||||
|
|
@ -67,6 +68,12 @@ public class OsmoticPressRController {
|
|||
return R.ok(service.queryPage(osmoticQueryPageSo));
|
||||
}
|
||||
|
||||
@Operation(summary = "布置图-渗压监测")
|
||||
@GetMapping("/list/value")
|
||||
public R<List<OsmoticPressVo>> listValue() {
|
||||
return R.ok(service.listValue());
|
||||
}
|
||||
|
||||
@Operation(summary = "测值查询(数据表)")
|
||||
@PostMapping("/query/value")
|
||||
public R<List<OsmoticStationVo>> queryValue(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.entity.so.WarnRulePageSo;
|
||||
|
|
@ -33,11 +35,25 @@ public class OsmoticWarnRuleController {
|
|||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<OsmoticWarnRule> insert(@Validated(Insert.class) @RequestBody OsmoticWarnRule dto) {
|
||||
checkParam(dto);
|
||||
dto.setId(IdWorker.getId());
|
||||
boolean result = service.save(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
private void checkParam(OsmoticWarnRule dto) {
|
||||
Long id = dto.getId();
|
||||
LambdaQueryWrapper<OsmoticWarnRule> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(OsmoticWarnRule::getStationCode,dto.getStationCode())
|
||||
.eq(OsmoticWarnRule::getType,dto.getType());
|
||||
if(id != null){
|
||||
queryWrapper.ne(OsmoticWarnRule::getId,id);
|
||||
}
|
||||
if(service.count(queryWrapper ) > 0){
|
||||
throw new IllegalArgumentException("该站点已存在该类型的告警");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<OsmoticWarnRule> update(@Validated(Update.class) @RequestBody OsmoticWarnRule dto) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import com.gunshi.project.xyt.model.OsmoticPressR;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Created by wanyan on 2024/7/9
|
||||
*
|
||||
* @author wanyan
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class OsmoticPressVo extends OsmoticPressR {
|
||||
|
||||
@Schema(description = "监测时间是否离当前时间超过2天(0否 1是)")
|
||||
private Integer flag = 0;
|
||||
|
||||
@Schema(description = "是否超过预警(0否 1是)")
|
||||
private Integer status = 0;
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo;
|
||||
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo;
|
||||
import com.gunshi.project.xyt.entity.vo.OsmoticPressVo;
|
||||
import com.gunshi.project.xyt.entity.vo.OsmoticValueVo;
|
||||
import com.gunshi.project.xyt.entity.vo.StRzVo;
|
||||
import com.gunshi.project.xyt.model.OsmoticPressR;
|
||||
|
|
@ -150,4 +151,15 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
|
|||
</script>
|
||||
""")
|
||||
List<StRzVo> queryDrp(@Param("year") Integer year);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT st.station_code,r.value,r.tm,m.profile_name FROM osmotic_press_device st
|
||||
LEFT JOIN (SELECT station_code,MAX(tm) tm FROM osmotic_press_r GROUP BY station_code) maxr ON st.station_code = maxr.station_code
|
||||
LEFT JOIN osmotic_press_r r ON maxr.station_code = r.station_code AND maxr.tm = r.tm
|
||||
LEFT JOIN att_dam_profile m ON st.profile_code = m.profile_code
|
||||
ORDER BY st.profile_code,st.station_code
|
||||
</script>
|
||||
""")
|
||||
List<OsmoticPressVo> listValue();
|
||||
}
|
||||
|
|
@ -375,6 +375,30 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
ExcelUtil.exportExcel(headList, DataHandleUtil.tableData(list),2,new int[]{0},fileName,response,sheetName);
|
||||
}
|
||||
|
||||
public List<OsmoticPressVo> listValue() {
|
||||
List<OsmoticPressVo> list = mapper.listValue();
|
||||
OsmoticQuerySo so = new OsmoticQuerySo();
|
||||
List<String> stationCodes = list.stream().map(OsmoticPressR::getStationCode).collect(Collectors.toList());
|
||||
Date maxTm = list.stream().filter(o->o.getTm() != null).max(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm();
|
||||
Date minTm = list.stream().filter(o->o.getTm() != null).min(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm();
|
||||
so.setStationCodes(stationCodes);
|
||||
DateTimeRangeSo dateTimeRangeSo = new DateTimeRangeSo();
|
||||
dateTimeRangeSo.setStart(minTm);
|
||||
dateTimeRangeSo.setEnd(maxTm);
|
||||
so.setDateTimeRangeSo(dateTimeRangeSo);
|
||||
List<OsmoticValueVo> warnList = mapper.queryWarn(so);
|
||||
list.stream().map(o->{
|
||||
if(o.getTm() != null && DateUtil.hoursBetweenDate(o.getTm(), new Date()) > 48){
|
||||
o.setFlag(1);
|
||||
}
|
||||
Boolean b = warnList.stream().filter(t->t.getStationCode().equals(o.getStationCode()) && t.getTm().equals(DateUtil.convertDateToMDSString(o.getTm()))).findAny().isPresent();
|
||||
if(b){
|
||||
o.setStatus(1);
|
||||
}
|
||||
return o;
|
||||
}).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import java.time.LocalDateTime;
|
|||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
|
|
@ -49,6 +50,13 @@ public class DateUtil {
|
|||
return df.format(date);
|
||||
}
|
||||
|
||||
public static long hoursBetweenDate(Date start,Date end){
|
||||
long startTime = start.getTime();
|
||||
long endTime = end.getTime();
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(endTime - startTime);
|
||||
return Math.round(hours);
|
||||
}
|
||||
|
||||
/**
|
||||
* 年初
|
||||
* @param year
|
||||
|
|
|
|||
Loading…
Reference in New Issue