Bläddra i källkod

'水质报警'

master
daixiantong 4 år sedan
förälder
incheckning
8269a34ce7
10 ändrade filer med 237 tillägg och 21 borttagningar
  1. +73
    -0
      src/main/java/com/taauav/admin/controller/TauvWaterAlarmController.java
  2. +6
    -6
      src/main/java/com/taauav/admin/controller/TauvWaterAlarmInfoController.java
  3. +1
    -1
      src/main/java/com/taauav/admin/controller/TauvWaterDataController.java
  4. +1
    -1
      src/main/java/com/taauav/admin/controller/TauvWaterStandardController.java
  5. +19
    -0
      src/main/java/com/taauav/admin/entity/TauvWaterAlarm.java
  6. +18
    -2
      src/main/java/com/taauav/admin/service/ITauvWaterAlarmService.java
  7. +82
    -2
      src/main/java/com/taauav/admin/service/impl/TauvWaterAlarmServiceImpl.java
  8. +17
    -9
      src/main/java/com/taauav/admin/service/impl/TauvWaterDataServiceImpl.java
  9. +20
    -0
      src/main/java/com/taauav/admin/vo/TauvWaterAlarmVo.java
  10. +0
    -0
      src/main/java/info/Menu.sql

+ 73
- 0
src/main/java/com/taauav/admin/controller/TauvWaterAlarmController.java Visa fil

@@ -0,0 +1,73 @@
package com.taauav.admin.controller;

import com.taauav.admin.entity.TauvWaterAlarm;
import com.taauav.admin.query.TauvWaterAlarmQuery;
import com.taauav.admin.service.ITauvWaterAlarmService;
import com.taauav.admin.vo.TauvWaterAlarmVo;
import com.taauav.common.bean.Response;
import com.taauav.common.constant.PermissionConstants;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* 水质超标信息 控制器
*
* @author daixiantong
* @date 2020-05-14
*/
@RestController
@RequestMapping("/admin/waterAlarm")
public class TauvWaterAlarmController extends BaseController{
private static final String controllerName = "admin:waterAlarm";
@Autowired
private ITauvWaterAlarmService waterAlarmService;
@Resource
private Response response;

/**
* 水质超标报警列表
* @param waterAlarmQuery
* @return
*/
@GetMapping("/index")
@RequiresPermissions(controllerName + ":" + PermissionConstants.LIST_PERMISSION)
public Response index(TauvWaterAlarmQuery waterAlarmQuery) {
return waterAlarmService.selectPageList(waterAlarmQuery);
}

/**
* 报警详情
* @param id
* @return
*/
@GetMapping("/detail")
@RequiresPermissions(controllerName + ":" + PermissionConstants.VIEW_PERMISSION)
public Response getDetail(Integer id) {
if (id == null || id <= 0) {
return response.failure("id不能为空");
}
TauvWaterAlarmVo waterAlarmVo = waterAlarmService.getDetail(id);
return response.success(waterAlarmVo);
}

/**
* 修改报警状态
* @param waterAlarm
* @return
*/
@PostMapping("/edit")
@RequiresPermissions(controllerName + ":" + PermissionConstants.EDIT_PERMISSION)
public Response changeStatus(TauvWaterAlarm waterAlarm) {
Boolean res = waterAlarmService.editData(waterAlarm);
if (!res) {
return response.failure("操作失败");
}
return response.success("操作成功");
}
}

+ 6
- 6
src/main/java/com/taauav/admin/controller/TauvWaterAlarmInfoController.java Visa fil

@@ -24,7 +24,7 @@ import com.taauav.admin.service.ITauvWaterAlarmInfoService;
* @date 20200514
*/
@RestController
@RequestMapping("/admin/info")
@RequestMapping("/admin/alarmInfo")
public class TauvWaterAlarmInfoController extends BaseController
{
@Autowired
@@ -35,7 +35,7 @@ public class TauvWaterAlarmInfoController extends BaseController
/**
* 查询水质报警附列表
*/
@RequiresPermissions("admin:info:list")
@RequiresPermissions("admin:alarmInfo:list")
@GetMapping("/list")
public Response list(TauvWaterAlarmInfo tauvWaterAlarmInfo, BaseQuery query)
{
@@ -47,7 +47,7 @@ public class TauvWaterAlarmInfoController extends BaseController
/**
* 获取水质报警附详细信息
*/
@RequiresPermissions("admin:info:query")
@RequiresPermissions("admin:alarmInfo:query")
@GetMapping(value = "/{id}")
public Response getInfo(@PathVariable("id") Integer id)
{
@@ -57,7 +57,7 @@ public class TauvWaterAlarmInfoController extends BaseController
/**
* 新增水质报警附
*/
@RequiresPermissions("admin:info:add")
@RequiresPermissions("admin:alarmInfo:add")
@PostMapping
public Response add(@RequestBody TauvWaterAlarmInfo tauvWaterAlarmInfo)
{
@@ -67,7 +67,7 @@ public class TauvWaterAlarmInfoController extends BaseController
/**
* 修改水质报警附
*/
@RequiresPermissions("admin:info:edit")
@RequiresPermissions("admin:alarmInfo:edit")
@PutMapping
public Response edit(@RequestBody TauvWaterAlarmInfo tauvWaterAlarmInfo)
{
@@ -77,7 +77,7 @@ public class TauvWaterAlarmInfoController extends BaseController
/**
* 删除水质报警附
*/
@RequiresPermissions("admin:info:remove")
@RequiresPermissions("admin:alarmInfo:remove")
@DeleteMapping("/{ids}")
public Response remove(@PathVariable Integer[] ids)
{

+ 1
- 1
src/main/java/com/taauav/admin/controller/TauvWaterDataController.java Visa fil

@@ -21,7 +21,7 @@ import javax.annotation.Resource;
@RestController
@RequestMapping("/admin/waterData")
public class TauvWaterDataController extends BaseController {
private static final String controllerName = "/admin/waterData";
private static final String controllerName = "admin:waterData";
@Autowired
private ITauvWaterDataService waterDataService;
@Resource

+ 1
- 1
src/main/java/com/taauav/admin/controller/TauvWaterStandardController.java Visa fil

@@ -25,7 +25,7 @@ public class TauvWaterStandardController {
private ITauvWaterStandardService waterStandardService;
@Autowired
private Response response;
private static final String controllerName = "/admin/waterStandard";
private static final String controllerName = "admin:waterStandard";

/**
* 标准列表

+ 19
- 0
src/main/java/com/taauav/admin/entity/TauvWaterAlarm.java Visa fil

@@ -1,5 +1,6 @@
package com.taauav.admin.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.taauav.common.domain.Entity;
import lombok.Data;
@@ -7,6 +8,8 @@ import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigInteger;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
* 水质报警 实体类
@@ -65,4 +68,20 @@ public class TauvWaterAlarm extends Entity {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date alarmTime;

/**
* 状态描述
*/
@TableField(exist = false)
private String statusText;

public Map<String, String> statusList() {
Map<String, String> map = new HashMap<>();
map.put("1", "未报警");
map.put("2", "已报警");
map.put("3", "已取消");
map.put("4", "处理中");
map.put("5", "处理完成");
return map;
}
}

+ 18
- 2
src/main/java/com/taauav/admin/service/ITauvWaterAlarmService.java Visa fil

@@ -1,13 +1,29 @@
package com.taauav.admin.service;

import com.taauav.admin.entity.TauvWaterAlarm;
import com.taauav.admin.query.TauvWaterAlarmQuery;
import com.taauav.admin.vo.TauvWaterAlarmVo;
import com.taauav.common.bean.Response;
import com.taauav.common.service.IBaseService;

/**
* 水质报警服务类
* 水质超标报警服务类
*
* @author daixiantong
* @date 2020-05-15
* @date 2020-05-14
*/
public interface ITauvWaterAlarmService extends IBaseService<TauvWaterAlarm> {
/**
* 自定义分页
* @param waterAlarmQuery
* @return
*/
Response selectPageList(TauvWaterAlarmQuery waterAlarmQuery);

/**
* 获取详情数据
* @param id
* @return
*/
TauvWaterAlarmVo getDetail(Integer id);
}

+ 82
- 2
src/main/java/com/taauav/admin/service/impl/TauvWaterAlarmServiceImpl.java Visa fil

@@ -1,17 +1,97 @@
package com.taauav.admin.service.impl;

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.taauav.admin.entity.TauvWaterAlarm;
import com.taauav.admin.entity.TauvWaterAlarmInfo;
import com.taauav.admin.mapper.TauvWaterAlarmInfoMapper;
import com.taauav.admin.mapper.TauvWaterAlarmMapper;
import com.taauav.admin.query.TauvWaterAlarmQuery;
import com.taauav.admin.service.ITauvWaterAlarmService;
import com.taauav.admin.vo.TauvWaterAlarmVo;
import com.taauav.common.bean.Response;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.List;

/**
* 水质报警服务类
* 水质超标报警服务类
*
* @author daixiantong
* @date 2020-05-15
* @date 2020-05-14
*/
@Service
public class TauvWaterAlarmServiceImpl extends BaseServiceImpl<TauvWaterAlarmMapper, TauvWaterAlarm> implements ITauvWaterAlarmService {
@Resource
private Response response;
@Autowired
private TauvWaterAlarmInfoMapper waterAlarmInfoMapper;

/**
* 自定义分页
* @param waterAlarmQuery
* @return
*/
@Override
public Response selectPageList(TauvWaterAlarmQuery waterAlarmQuery) {
IPage<TauvWaterAlarm> page = new Page<>(waterAlarmQuery.getPage(), waterAlarmQuery.getPageSize());
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("mark", 1);
if (StringUtils.isNotEmpty(waterAlarmQuery.getAlarmSn())) {
wrapper.like("alarm_sn", waterAlarmQuery.getAlarmSn());
}
if (StringUtils.isNotEmpty(waterAlarmQuery.getDriverName())) {
wrapper.like("driver_name", waterAlarmQuery.getDriverName());
}
if (StringUtils.isNotNull(waterAlarmQuery.getDriverArea()) && waterAlarmQuery.getDriverArea().compareTo(BigInteger.ZERO) > 0) {
wrapper.eq("driver_area", waterAlarmQuery.getDriverArea());
}
if (StringUtils.isNotNull(waterAlarmQuery.getStatus()) && waterAlarmQuery.getStatus() > 0) {
wrapper.eq("status", waterAlarmQuery.getStatus());
}
if (waterAlarmQuery.getStartTime() != null && waterAlarmQuery.getEndTime() != null) {
String beginTime = waterAlarmQuery.getStartTime().toString();
String endTime = waterAlarmQuery.getEndTime().toString();
if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {
wrapper.between("alarm_time", beginTime + " 00:00:00", endTime + " 23:59:59");
}
}
IPage<TauvWaterAlarm> list = baseMapper.selectPage(page, wrapper);
if (list.getRecords().size() > 0) {
for (TauvWaterAlarm data : list.getRecords()) {
data.setStatusText(FunctionUtils.getArrayText(data.getStatus().toString(), data.statusList()));
}
}
return response.success(list);
}

/**
* 获取详情数据
* @param id
* @return
*/
@Override
public TauvWaterAlarmVo getDetail(Integer id) {
TauvWaterAlarm waterAlarm = getInfo(id);
if (waterAlarm != null) {
waterAlarm.setStatusText(FunctionUtils.getArrayText(waterAlarm.getStatus().toString(), waterAlarm.statusList()));
}
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("mark", 1);
wrapper.eq("water_alarm_id", id);
wrapper.orderByAsc("id");
List<TauvWaterAlarmInfo> infoList = waterAlarmInfoMapper.selectList(wrapper);
TauvWaterAlarmVo waterAlarmVo = new TauvWaterAlarmVo();
BeanUtils.copyProperties(waterAlarm, waterAlarmVo, TauvWaterAlarmVo.class);
waterAlarmVo.setInfoList(infoList);
return waterAlarmVo;
}
}

+ 17
- 9
src/main/java/com/taauav/admin/service/impl/TauvWaterDataServiceImpl.java Visa fil

@@ -204,6 +204,7 @@ public class TauvWaterDataServiceImpl extends BaseServiceImpl<TauvWaterDataMappe
waterAlarm.setUpdateTime(DateUtil.now());
waterAlarm.setUpdateUser(ShiroUtils.getAdminId());
} else {
waterAlarm = new TauvWaterAlarm();
waterAlarm.setInspectDriverId(waterData.getInspectDriverId());
waterAlarm.setCreateTime(DateUtil.now());
waterAlarm.setCreateUser(ShiroUtils.getAdminId());
@@ -215,6 +216,7 @@ public class TauvWaterDataServiceImpl extends BaseServiceImpl<TauvWaterDataMappe
if (standardList.size() > 0) {
List<String> alarmInfo = new ArrayList<>();
List<TauvWaterAlarmInfo> waterAlarmInfoList = new ArrayList<>();
Boolean flag = false;
for (TauvWaterStandard item : standardList) {
// 实测值
BigDecimal value = BigDecimal.ZERO;
@@ -263,22 +265,23 @@ public class TauvWaterDataServiceImpl extends BaseServiceImpl<TauvWaterDataMappe
}
// 差值
BigDecimal exceed = value.subtract(standardValue);
TauvWaterAlarmInfo waterAlarmInfo = new TauvWaterAlarmInfo();
waterAlarmInfo.setName(item.getName());
waterAlarmInfo.setStandardValue(standardValue);
waterAlarmInfo.setMeasuredValue(value);
if (exceed.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal rate = exceed.divide(standardValue).multiply(new BigDecimal("0.01"));
flag = true;
BigDecimal rate = exceed.multiply(new BigDecimal("100")).divide(standardValue, 2, BigDecimal.ROUND_HALF_UP);
String exceedStandard = item.getName() + "超标" + rate + "%";
alarmInfo.add(exceedStandard);

TauvWaterAlarmInfo waterAlarmInfo = new TauvWaterAlarmInfo();
waterAlarmInfo.setName(item.getName());
waterAlarmInfo.setStandardValue(standardValue);
waterAlarmInfo.setMeasuredValue(value);
// 超标详情
waterAlarmInfo.setMeasuredStandard(checkCategory(item, value));
waterAlarmInfo.setExceedStandard(exceedStandard);
waterAlarmInfoList.add(waterAlarmInfo);
}
waterAlarmInfoList.add(waterAlarmInfo);
}
// 报警数据入库
if (waterAlarmInfoList.size() > 0) {
if (flag) {
TauvInspectDriver inspectDriver = inspectDriverMapper.selectById(waterData.getInspectDriverId());
waterAlarm.setAlarmSn(createAlarmSn());
waterAlarm.setDriverArea(inspectDriver.getDriverArea());
@@ -291,6 +294,8 @@ public class TauvWaterDataServiceImpl extends BaseServiceImpl<TauvWaterDataMappe
// 报警详情附表数据入库
for (TauvWaterAlarmInfo data : waterAlarmInfoList) {
data.setWaterAlarmId(waterAlarm.getId());
data.setCreateUser(ShiroUtils.getAdminId());
data.setCreateTime(DateUtil.now());
waterAlarmInfoService.save(data);
}
} else if (StringUtils.isNotNull(waterAlarm.getId())){
@@ -333,6 +338,9 @@ public class TauvWaterDataServiceImpl extends BaseServiceImpl<TauvWaterDataMappe
}
}
}
if (category.equals("")) {
category = "Ⅴ级";
}
return category;
}

@@ -343,7 +351,7 @@ public class TauvWaterDataServiceImpl extends BaseServiceImpl<TauvWaterDataMappe
*/
private String createAlarmSn() {
Calendar date = Calendar.getInstance();
String year = String.valueOf(date.get(Calendar.YEAR)).substring(-2);
String year = String.valueOf(date.get(Calendar.YEAR)).substring(2);
String month = String.valueOf(date.get(Calendar.MONTH) + 1);
String code = "20" + year + month + (Math.random() * 9 + 1) * 100000;
return code;

+ 20
- 0
src/main/java/com/taauav/admin/vo/TauvWaterAlarmVo.java Visa fil

@@ -0,0 +1,20 @@
package com.taauav.admin.vo;

import com.taauav.admin.entity.TauvWaterAlarm;
import com.taauav.admin.entity.TauvWaterAlarmInfo;
import lombok.Data;

import java.util.List;

/**
* @author daixiantong
* @date 2020-05-14
*/
@Data
public class TauvWaterAlarmVo extends TauvWaterAlarm {

/**
* 超标详情数组
*/
private List<TauvWaterAlarmInfo> infoList;
}

+ 0
- 0
src/main/java/info/Menu.sql Visa fil


Laddar…
Avbryt
Spara