|
@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.huimv.common.exception.RRException;
|
|
import com.huimv.common.exception.RRException;
|
|
import com.huimv.management.entity.dto.WarningInfoDto;
|
|
import com.huimv.management.entity.dto.WarningInfoDto;
|
|
import com.huimv.management.entity.vo.WarningInfoVo;
|
|
import com.huimv.management.entity.vo.WarningInfoVo;
|
|
|
|
+import com.huimv.management.util.GetUserUtil;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -20,6 +22,8 @@ import com.huimv.management.dao.WarningInfoDao;
|
|
import com.huimv.management.entity.WarningInfoEntity;
|
|
import com.huimv.management.entity.WarningInfoEntity;
|
|
import com.huimv.management.service.WarningInfoService;
|
|
import com.huimv.management.service.WarningInfoService;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 报警信息ServiceImpl
|
|
* 报警信息ServiceImpl
|
|
@@ -34,15 +38,39 @@ public class WarningInfoServiceImpl extends ServiceImpl<WarningInfoDao, WarningI
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PageUtils queryPage(Map<String, Object> params) {
|
|
public PageUtils queryPage(Map<String, Object> params) {
|
|
|
|
+ QueryWrapper<WarningInfoVo> queryWrapper = buildQueryWrapper(params);
|
|
|
|
+ IPage<WarningInfoVo> page = baseMapper.page(new Query<>().getPage(params), queryWrapper);
|
|
|
|
+ return new PageUtils(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void verify(WarningInfoDto warningInfoDto, HttpServletRequest request) {
|
|
|
|
+
|
|
|
|
+ LambdaUpdateWrapper<WarningInfoEntity> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
+
|
|
|
|
+ String username = GetUserUtil.getUser(request).getUsername();
|
|
|
|
+
|
|
|
|
+ updateWrapper.set(WarningInfoEntity::getVerifyDescription, warningInfoDto.getVerifyDescription())
|
|
|
|
+ .set(WarningInfoEntity::getVerifyStatus, true)
|
|
|
|
+ .set(WarningInfoEntity::getVerifyUser,username)
|
|
|
|
+ .eq(WarningInfoEntity::getId, warningInfoDto.getId());
|
|
|
|
+ update(updateWrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<WarningInfoVo> queryByCondition(Map<String, Object> params) {
|
|
|
|
+ QueryWrapper<WarningInfoVo> queryWrapper = buildQueryWrapper(params);
|
|
|
|
+ return baseMapper.page(queryWrapper);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private QueryWrapper<WarningInfoVo> buildQueryWrapper(Map<String, Object> params) {
|
|
QueryWrapper<WarningInfoVo> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<WarningInfoVo> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
String belongTo = (String) params.get("belongTo");
|
|
String belongTo = (String) params.get("belongTo");
|
|
- if (StringUtils.isBlank(belongTo)) {
|
|
|
|
- throw new RRException("报警所属范围(室内,室外,耳标)不能为空!");
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(belongTo)) {
|
|
|
|
+ queryWrapper.eq("warn.belong_to", Short.parseShort(belongTo));
|
|
}
|
|
}
|
|
- queryWrapper.eq("warn.belong_to", Short.parseShort(belongTo));
|
|
|
|
-
|
|
|
|
//报警类型
|
|
//报警类型
|
|
String warningType = (String) params.get("warningType");
|
|
String warningType = (String) params.get("warningType");
|
|
if (StringUtils.isNotBlank(warningType)) {
|
|
if (StringUtils.isNotBlank(warningType)) {
|
|
@@ -58,7 +86,6 @@ public class WarningInfoServiceImpl extends ServiceImpl<WarningInfoDao, WarningI
|
|
if (StringUtils.isNotBlank(pigstyId)) {
|
|
if (StringUtils.isNotBlank(pigstyId)) {
|
|
queryWrapper.eq("warn.pigsty_id", Integer.parseInt(pigstyId));
|
|
queryWrapper.eq("warn.pigsty_id", Integer.parseInt(pigstyId));
|
|
}
|
|
}
|
|
-
|
|
|
|
String unitId = (String) params.get("unitId");
|
|
String unitId = (String) params.get("unitId");
|
|
if (StringUtils.isNotBlank(unitId)) {
|
|
if (StringUtils.isNotBlank(unitId)) {
|
|
queryWrapper.eq("warn.unit_id", Integer.parseInt(unitId));
|
|
queryWrapper.eq("warn.unit_id", Integer.parseInt(unitId));
|
|
@@ -66,7 +93,11 @@ public class WarningInfoServiceImpl extends ServiceImpl<WarningInfoDao, WarningI
|
|
//猪耳标号
|
|
//猪耳标号
|
|
String earTag = (String) params.get("earTag");
|
|
String earTag = (String) params.get("earTag");
|
|
if (StringUtils.isNotBlank(earTag)) {
|
|
if (StringUtils.isNotBlank(earTag)) {
|
|
- queryWrapper.eq("warn.ear_tag", earTag);
|
|
|
|
|
|
+ queryWrapper.like("warn.ear_tag", earTag);
|
|
|
|
+ }
|
|
|
|
+ String verifyStatus = (String) params.get("verifyStatus");
|
|
|
|
+ if (StringUtils.isNotBlank(verifyStatus)) {
|
|
|
|
+ queryWrapper.eq("warn.verify_status", Boolean.parseBoolean(verifyStatus));
|
|
}
|
|
}
|
|
//时间区间(前)
|
|
//时间区间(前)
|
|
String startTime = (String) params.get("startTime");
|
|
String startTime = (String) params.get("startTime");
|
|
@@ -76,23 +107,10 @@ public class WarningInfoServiceImpl extends ServiceImpl<WarningInfoDao, WarningI
|
|
queryWrapper
|
|
queryWrapper
|
|
.ge(StringUtils.isNotBlank(startTime), "warn.warning_time", startTime)
|
|
.ge(StringUtils.isNotBlank(startTime), "warn.warning_time", startTime)
|
|
.le(StringUtils.isNotBlank(endTime), "warn.warning_time", endTime)
|
|
.le(StringUtils.isNotBlank(endTime), "warn.warning_time", endTime)
|
|
- .apply("warn.verify_status = 0 AND farm.deleted = 0 AND IFNULL(pigsty.deleted,0) = 0 AND IFNULL(unit.deleted,0) = 0")
|
|
|
|
|
|
+ .apply("farm.deleted = 0 AND IFNULL(pigsty.deleted,0) = 0 AND IFNULL(unit.deleted,0) = 0")
|
|
.orderByDesc("warn.warning_time");
|
|
.orderByDesc("warn.warning_time");
|
|
-
|
|
|
|
- IPage<WarningInfoVo> page = baseMapper.page(new Query<>().getPage(params), queryWrapper);
|
|
|
|
- return new PageUtils(page);
|
|
|
|
-
|
|
|
|
|
|
+ return queryWrapper;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void verify(WarningInfoDto warningInfoDto) {
|
|
|
|
|
|
|
|
- LambdaUpdateWrapper<WarningInfoEntity> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
-
|
|
|
|
- updateWrapper.set(WarningInfoEntity::getVerifyDescription, warningInfoDto.getVerifyDescription())
|
|
|
|
- .set(WarningInfoEntity::getVerifyStatus, true)
|
|
|
|
- .eq(WarningInfoEntity::getId, warningInfoDto.getId());
|
|
|
|
-
|
|
|
|
- update(updateWrapper);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|