Browse Source

youhua

master
4670101279 2 years ago
parent
commit
0b2d805f73
  1. 43
      ruoyi-api/src/main/java/com/ruoyi/api/app/AlarmDataApiController.java
  2. 2
      ruoyi-api/src/main/java/com/ruoyi/api/app/StationDataApiController.java
  3. 2
      ruoyi-api/src/main/java/com/ruoyi/api/app/WaterDataApiController.java
  4. 7
      ruoyi-api/src/main/java/com/ruoyi/api/controller/AbstractApiController.java
  5. 16
      ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmDataParams.java
  6. 31
      ruoyi-api/src/main/java/com/ruoyi/api/service/AlarmDataApiService.java
  7. 5
      ruoyi-api/src/main/java/com/ruoyi/api/service/StationDataApiService.java
  8. 6
      ruoyi-api/src/main/java/com/ruoyi/api/service/WaterDataApiService.java
  9. 5
      ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/domain/ScWaterData.java
  10. 8
      ruoyi-code/src/main/java/com/ruoyi/code/warning/domain/WaAlarm.java
  11. 7
      ruoyi-code/src/main/java/com/ruoyi/code/warning/mapper/WaAlarmMapper.java
  12. 2
      ruoyi-code/src/main/java/com/ruoyi/code/warning/service/IWaAlarmService.java
  13. 5
      ruoyi-code/src/main/java/com/ruoyi/code/warning/service/impl/WaAlarmServiceImpl.java
  14. 20
      ruoyi-code/src/main/resources/mapper/warning/WaAlarmMapper.xml

43
ruoyi-api/src/main/java/com/ruoyi/api/app/AlarmDataApiController.java

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
package com.ruoyi.api.app;
import com.ruoyi.api.controller.AbstractApiController;
import com.ruoyi.api.params.AlarmDataParams;
import com.ruoyi.api.params.WaterDataParams;
import com.ruoyi.api.service.AlarmDataApiService;
import com.ruoyi.api.service.WaterDataApiService;
import com.ruoyi.code.warning.service.IWaAlarmService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.validator.ValidatorUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 系统对外接口-检测信息
*/
@RestController
@RequestMapping("/api")
@Slf4j
public class AlarmDataApiController extends AbstractApiController {
@Resource
private AlarmDataApiService alarmDataApiService;
/**
* 预警数据查询
*
* @param params
* @return
*/
@PostMapping("v1/alarm_data/query")
public R query(@RequestBody AlarmDataParams params) {
log.info("[预警数据查询接口查询参数为{}]", params);
ValidatorUtils.validateV2(params);
return alarmDataApiService.query(params);
}
}

2
ruoyi-api/src/main/java/com/ruoyi/api/app/StationDataApiController.java

@ -32,7 +32,7 @@ public class StationDataApiController extends AbstractApiController { @@ -32,7 +32,7 @@ public class StationDataApiController extends AbstractApiController {
public R query(@RequestBody StationDataParams params) {
log.info("[测站数据查询接口查询参数为{}]", params);
ValidatorUtils.validateV2(params);
return stationDataApiService.query(params,getMarketAuthDto());
return stationDataApiService.query(params);
}
}

2
ruoyi-api/src/main/java/com/ruoyi/api/app/WaterDataApiController.java

@ -34,7 +34,7 @@ public class WaterDataApiController extends AbstractApiController { @@ -34,7 +34,7 @@ public class WaterDataApiController extends AbstractApiController {
public R query(@RequestBody WaterDataParams params) {
log.info("[水位数据查询接口查询参数为{}]", params);
ValidatorUtils.validateV2(params);
return waterDataApiService.query(params,getMarketAuthDto());
return waterDataApiService.query(params);
}
}

7
ruoyi-api/src/main/java/com/ruoyi/api/controller/AbstractApiController.java

@ -33,11 +33,12 @@ public abstract class AbstractApiController { @@ -33,11 +33,12 @@ public abstract class AbstractApiController {
ValidatorUtils.validateV2(signParams);
YhAppInfoEntity appInfo = commonService.checkDigest(signParams);
HttpServletUtil.setAppInfo(appInfo);
//验证接口权限
commonService.authPermission(appInfo);
}
protected MarketAuthDto getMarketAuthDto() {
return commonService.getMarketAuthDto(HttpServletUtil.getAppInfo());
}
// protected MarketAuthDto getMarketAuthDto() {
// return commonService.getMarketAuthDto(HttpServletUtil.getAppInfo());
// }
}

16
ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmDataParams.java

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
package com.ruoyi.api.params;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
public class AlarmDataParams {
private Long stnmId;
private String startTime;
private String endTime;
}

31
ruoyi-api/src/main/java/com/ruoyi/api/service/AlarmDataApiService.java

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
package com.ruoyi.api.service;
import com.ruoyi.api.params.AlarmDataParams;
import com.ruoyi.api.params.WaterDataParams;
import com.ruoyi.code.warning.domain.WaAlarm;
import com.ruoyi.code.warning.service.IWaAlarmService;
import com.ruoyi.common.core.page.R;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class AlarmDataApiService {
@Resource
private IWaAlarmService waAlarmService;
public R query(AlarmDataParams params) {
Map<String,Object> map = new HashMap<>();
map.put("stnmId",params.getStnmId());
map.put("startTime",params.getStartTime());
map.put("endTime",params.getEndTime());
List<WaAlarm> list = waAlarmService.queryAlarm(map);
return R.ok().put("data", list);
}
}

5
ruoyi-api/src/main/java/com/ruoyi/api/service/StationDataApiService.java

@ -21,13 +21,14 @@ public class StationDataApiService { @@ -21,13 +21,14 @@ public class StationDataApiService {
@Resource
private IScStationInfoService scStationInfoService;
public R query(StationDataParams params, MarketAuthDto marketAuthDto) {
// public R query(StationDataParams params, MarketAuthDto marketAuthDto) {
public R query(StationDataParams params) {
Long id = params.getId();
String stnm = params.getStnm();
List<ScStationInfo> list = scStationInfoService.list(
new QueryWrapper<ScStationInfo>()
.in("id", marketAuthDto.getQueryList())
// .in("id", marketAuthDto.getQueryList())
.eq(id != null, "id", id)
.like(StringUtils.isNotBlank(stnm),"stnm", stnm)
);

6
ruoyi-api/src/main/java/com/ruoyi/api/service/WaterDataApiService.java

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
package com.ruoyi.api.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.api.dto.MarketAuthDto;
import com.ruoyi.api.dto.StationData;
import com.ruoyi.api.params.StationDataParams;
import com.ruoyi.api.params.WaterDataParams;
@ -27,15 +26,14 @@ public class WaterDataApiService { @@ -27,15 +26,14 @@ public class WaterDataApiService {
@Resource
private IScWaterDataService scWaterDataService;
public R query(WaterDataParams params, MarketAuthDto marketAuthDto) {
public R query(WaterDataParams params) {
Long stnmId = params.getStnmId();
String startTime = params.getStartTime();
String endTime = params.getEndTime();
List<ScWaterData> list = scWaterDataService.list(
new QueryWrapper<ScWaterData>()
.in("stnm_id", marketAuthDto.getQueryList())
.eq("stnm_id", stnmId)
.eq(stnmId != null,"stnm_id", stnmId)
.between("tm",startTime,endTime)
);

5
ruoyi-code/src/main/java/com/ruoyi/code/scwaterdata/domain/ScWaterData.java

@ -8,7 +8,10 @@ import com.baomidou.mybatisplus.annotation.TableName; @@ -8,7 +8,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
@ -31,6 +34,8 @@ public class ScWaterData implements Serializable @@ -31,6 +34,8 @@ public class ScWaterData implements Serializable
private Long stnmId;
/** 时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date tm;
/** 水位值 */

8
ruoyi-code/src/main/java/com/ruoyi/code/warning/domain/WaAlarm.java

@ -1,9 +1,12 @@ @@ -1,9 +1,12 @@
package com.ruoyi.code.warning.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@ -32,10 +35,15 @@ public class WaAlarm implements Serializable @@ -32,10 +35,15 @@ public class WaAlarm implements Serializable
private String alarmContent;
/** 预警时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date alarmTime;
/** 0 未删除 1 删除 */
// @TableLogic
private Long deleted;
@TableField(exist = false)
private String stnm;
}

7
ruoyi-code/src/main/java/com/ruoyi/code/warning/mapper/WaAlarmMapper.java

@ -1,8 +1,12 @@ @@ -1,8 +1,12 @@
package com.ruoyi.code.warning.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.ruoyi.code.warning.domain.WaAlarm;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Mapper接口
@ -14,4 +18,5 @@ import com.ruoyi.code.warning.domain.WaAlarm; @@ -14,4 +18,5 @@ import com.ruoyi.code.warning.domain.WaAlarm;
public interface WaAlarmMapper extends BaseMapper<WaAlarm>
{
List<WaAlarm> queryAlarm(@Param("params") Map<String, Object> params);
}

2
ruoyi-code/src/main/java/com/ruoyi/code/warning/service/IWaAlarmService.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.code.warning.domain.WaAlarm;
import com.ruoyi.common.core.page.R;
import java.util.List;
import java.util.Map;
/**
@ -19,4 +20,5 @@ public interface IWaAlarmService extends IService<WaAlarm> @@ -19,4 +20,5 @@ public interface IWaAlarmService extends IService<WaAlarm>
*/
R queryPage(Map<String, Object> params);
List<WaAlarm> queryAlarm(Map<String, Object> params);
}

5
ruoyi-code/src/main/java/com/ruoyi/code/warning/service/impl/WaAlarmServiceImpl.java

@ -11,6 +11,7 @@ import com.ruoyi.common.utils.Query; @@ -11,6 +11,7 @@ import com.ruoyi.common.utils.Query;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
@ -36,4 +37,8 @@ public class WaAlarmServiceImpl extends ServiceImpl<WaAlarmMapper, WaAlarm> impl @@ -36,4 +37,8 @@ public class WaAlarmServiceImpl extends ServiceImpl<WaAlarmMapper, WaAlarm> impl
return R.ok().put("count", page.getTotal()).put("data", page.getRecords());
}
@Override
public List<WaAlarm> queryAlarm(Map<String, Object> params){
return baseMapper.queryAlarm(params);
}
}

20
ruoyi-code/src/main/resources/mapper/warning/WaAlarmMapper.xml

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.code.warning.mapper.WaAlarmMapper">
<select id="queryAlarm" resultType="com.ruoyi.code.warning.domain.WaAlarm">
select a.*,b.stnm from wa_alarm a
left join sc_station_info b on a.stnm_id=b.id
where a.deleted=0
<if test="params.stnmId != null and params.stnmId !=''">
and a.stnm_id = #{stnmId}
</if>
<if test="params.startTime != null and params.startTime !=''">
and a.alarm_time &gt;= #{params.startTime }
</if>
<if test="params.endTime != null and params.endTime !=''">
and a.alarm_time &lt;= #{params.endTime}
</if>
order by alarm_time desc
</select>
</mapper>
Loading…
Cancel
Save