后台功能调整

This commit is contained in:
zhangyue 2026-07-23 19:11:12 +08:00
parent 8f51445110
commit 94953eb330
6 changed files with 156 additions and 25 deletions

View File

@ -10,6 +10,8 @@ import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.PollutionConstants; import org.jeecg.common.constant.PollutionConstants;
import org.jeecg.common.constant.enums.DeviceDeployEnum; import org.jeecg.common.constant.enums.DeviceDeployEnum;
import org.jeecg.common.constant.enums.PollutionEnum;
import org.jeecg.common.entity.ScEquZhibiao;
import org.jeecg.common.entity.SurvDeviceDeploy; import org.jeecg.common.entity.SurvDeviceDeploy;
import org.jeecg.common.entity.SurvStationInfo; import org.jeecg.common.entity.SurvStationInfo;
import org.jeecg.common.vo.*; import org.jeecg.common.vo.*;
@ -21,9 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
@Api(tags="后台首页统计接口") @Api(tags="后台首页统计接口")
@RestController @RestController
@ -40,8 +40,6 @@ public class IndexAnalysisController {
@Autowired @Autowired
private IScEquZhibiaoService zhibiaoService; private IScEquZhibiaoService zhibiaoService;
@Autowired
private ISurvPestlightInfoService pestlightInfoService;
@Autowired @Autowired
private IUserInfoService userInfoService; private IUserInfoService userInfoService;
@ -210,11 +208,13 @@ public class IndexAnalysisController {
if(stationList!=null&&stationList.size()>0) { if(stationList!=null&&stationList.size()>0) {
// Map<String,List<String>> deviceMap = new HashMap<>(); // Map<String,List<String>> deviceMap = new HashMap<>();
for (SurvStationInfo survStationInfo : stationList) { for (SurvStationInfo survStationInfo : stationList) {
if (survStationInfo.getDeviceList() != null && survStationInfo.getDeviceList().size() > 0) { if (survStationInfo.getDeviceList() != null && !survStationInfo.getDeviceList().isEmpty()) {
List<String> airList = new ArrayList<>(); List<String> airList = new ArrayList<>();
List<String> soilList = new ArrayList<>(); List<String> soilList = new ArrayList<>();
List<String> orientList = new ArrayList<>(); List<String> orientList = new ArrayList<>();
List<String> orientIdList = new ArrayList<>();
List<String> liveList = new ArrayList<>(); List<String> liveList = new ArrayList<>();
List<String> liveIdList = new ArrayList<>();
for (SurvDeviceDeploy survDeviceDeploy : survStationInfo.getDeviceList()) { for (SurvDeviceDeploy survDeviceDeploy : survStationInfo.getDeviceList()) {
if(PollutionConstants.SOIL_SURV.equals(survDeviceDeploy.getDeployType())){//土壤设备 if(PollutionConstants.SOIL_SURV.equals(survDeviceDeploy.getDeployType())){//土壤设备
soilList.add(survDeviceDeploy.getDeployCode()); soilList.add(survDeviceDeploy.getDeployCode());
@ -222,12 +222,22 @@ public class IndexAnalysisController {
airList.add(survDeviceDeploy.getDeployCode()); airList.add(survDeviceDeploy.getDeployCode());
}else if(PollutionConstants.WATER_ORIENT.equals(survDeviceDeploy.getDeployType())) {//面源 }else if(PollutionConstants.WATER_ORIENT.equals(survDeviceDeploy.getDeployType())) {//面源
orientList.add(survDeviceDeploy.getDeployCode()); orientList.add(survDeviceDeploy.getDeployCode());
orientIdList.add(survDeviceDeploy.getId());
}else if(PollutionConstants.WATER_LIVE.equals(survDeviceDeploy.getDeployType())) {//畜禽 }else if(PollutionConstants.WATER_LIVE.equals(survDeviceDeploy.getDeployType())) {//畜禽
liveList.add(survDeviceDeploy.getDeployCode()); liveList.add(survDeviceDeploy.getDeployCode());
liveIdList.add(survDeviceDeploy.getId());
}else if(PollutionConstants.CAMERA.equals(survDeviceDeploy.getDeployType())) {//摄像头 }else if(PollutionConstants.CAMERA.equals(survDeviceDeploy.getDeployType())) {//摄像头
} }
} }
if(orientList.size()>0) { if(orientList.size()>0) {
List<ScEquZhibiao> zhibiaoList = zhibiaoService.getAllChemical(orientIdList);
Map<String,String> zhibiaoMap = new HashMap<>();
if(zhibiaoList!=null&& !zhibiaoList.isEmpty()){
for (ScEquZhibiao scEquZhibiao : zhibiaoList) {
zhibiaoMap.put(scEquZhibiao.getEntityField(),scEquZhibiao.getName());
}
}
List<OrientDataTrans> orientSummry = orientwaterService.getMonthSummry(orientList, chooseYear); List<OrientDataTrans> orientSummry = orientwaterService.getMonthSummry(orientList, chooseYear);
List<Double> avgTN = new ArrayList<>(); List<Double> avgTN = new ArrayList<>();
List<Double> avgTP = new ArrayList<>(); List<Double> avgTP = new ArrayList<>();
@ -241,21 +251,37 @@ public class IndexAnalysisController {
avgTP.add(orientDataTrans.getAvgTP()); avgTP.add(orientDataTrans.getAvgTP());
avgNO.add(orientDataTrans.getAvgNO()); avgNO.add(orientDataTrans.getAvgNO());
avgNH.add(0D); avgNH.add(orientDataTrans.getAvgNH());
avgCOD.add(0D); avgCOD.add(orientDataTrans.getAvgCod());
} }
} }
StationSummry stationSummry = new StationSummry(); StationSummry stationSummry = new StationSummry();
stationSummry.setTNSummry(avgTN); if(zhibiaoMap.get(PollutionEnum.dataWaterTpSy.getCode())!=null){
stationSummry.setTPSummry(avgTP); stationSummry.setTPSummry(avgTP);
stationSummry.setNOSummry(avgNO); }
if(zhibiaoMap.get(PollutionEnum.dataWaterTnSy.getCode())!=null){
stationSummry.setTNSummry(avgTN);
}
if(zhibiaoMap.get(PollutionEnum.dataWaterNoSy.getCode())!=null){
stationSummry.setNOSummry(avgNO);
}
if(zhibiaoMap.get(PollutionEnum.dataWaterCodSy.getCode())!=null){
stationSummry.setCODSummry(avgCOD);
}
if(zhibiaoMap.get(PollutionEnum.dataWaterNhSy.getCode())!=null){
stationSummry.setNHSummry(avgNH);
}
stationSummry.setCODSummry(avgNH); returnArrs.add(JSONObject.parseObject(JSONObject.toJSONString(stationSummry, SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty)));
stationSummry.setNHSummry(avgCOD);
returnArrs.add(JSONObject.parseObject(JSONObject.toJSONString(stationSummry, SerializerFeature.WriteNullStringAsEmpty)));
} }
if(liveList.size()>0){ if(liveList.size()>0){
List<ScEquZhibiao> zhibiaoList = zhibiaoService.getAllChemical(liveIdList);
Map<String,String> zhibiaoMap = new HashMap<>();
if(zhibiaoList!=null&& !zhibiaoList.isEmpty()){
for (ScEquZhibiao scEquZhibiao : zhibiaoList) {
zhibiaoMap.put(scEquZhibiao.getEntityField(),scEquZhibiao.getName());
}
}
List<LiveDataTrans> liveSummary = livestockwaterService.getMonthSummry(liveList,chooseYear); List<LiveDataTrans> liveSummary = livestockwaterService.getMonthSummry(liveList,chooseYear);
List<Double> avgTN = new ArrayList<>(); List<Double> avgTN = new ArrayList<>();
@ -271,17 +297,26 @@ public class IndexAnalysisController {
avgNH.add(liveDataTrans.getAvgNH()); avgNH.add(liveDataTrans.getAvgNH());
avgCOD.add(liveDataTrans.getAvgCOD()); avgCOD.add(liveDataTrans.getAvgCOD());
avgNO.add(0D); avgNO.add(liveDataTrans.getAvgNO());
} }
} }
StationSummry stationSummry = new StationSummry(); StationSummry stationSummry = new StationSummry();
stationSummry.setTNSummry(avgTN); if(zhibiaoMap.get(PollutionEnum.dataWaterTpSy.getCode())!=null){
stationSummry.setTPSummry(avgTP); stationSummry.setTPSummry(avgTP);
stationSummry.setNHSummry(avgNH); }
stationSummry.setCODSummry(avgCOD); if(zhibiaoMap.get(PollutionEnum.dataWaterTnSy.getCode())!=null){
stationSummry.setTNSummry(avgTN);
stationSummry.setNOSummry(avgNO); }
returnArrs.add(JSONObject.parseObject(JSONObject.toJSONString(stationSummry, SerializerFeature.WriteNullStringAsEmpty))); if(zhibiaoMap.get(PollutionEnum.dataWaterNoSy.getCode())!=null){
stationSummry.setNOSummry(avgNO);
}
if(zhibiaoMap.get(PollutionEnum.dataWaterCodSy.getCode())!=null){
stationSummry.setCODSummry(avgCOD);
}
if(zhibiaoMap.get(PollutionEnum.dataWaterNhSy.getCode())!=null){
stationSummry.setNHSummry(avgNH);
}
returnArrs.add(JSONObject.parseObject(JSONObject.toJSONString(stationSummry, SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty)));
} }
} }

View File

@ -14,24 +14,31 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.enums.PollutionEnum; import org.jeecg.common.constant.enums.PollutionEnum;
import org.jeecg.common.entity.ScEquZhibiao; import org.jeecg.common.entity.ScEquZhibiao;
import org.jeecg.common.entity.SurvDeviceDeploy;
import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.tenant.TenantContextHolder;
import org.jeecg.common.vo.PolutionVo; import org.jeecg.common.vo.PolutionVo;
import org.jeecg.modules.appmana.service.IScEquZhibiaoService; import org.jeecg.modules.appmana.service.IScEquZhibiaoService;
import org.jeecg.modules.appmana.service.ISurvDeviceDeployService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Description: sc_equ_zhibiao * @Description: sc_equ_zhibiao
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-07-11 * @Date: 2023-07-11
@ -44,7 +51,8 @@ import java.util.Date;
public class ScEquZhibiaoController extends JeecgController<ScEquZhibiao, IScEquZhibiaoService> { public class ScEquZhibiaoController extends JeecgController<ScEquZhibiao, IScEquZhibiaoService> {
@Autowired @Autowired
private IScEquZhibiaoService scEquZhibiaoService; private IScEquZhibiaoService scEquZhibiaoService;
@Autowired
private ISurvDeviceDeployService deviceDeployService;
/** /**
* 分页列表查询 * 分页列表查询
* *
@ -61,9 +69,39 @@ public class ScEquZhibiaoController extends JeecgController<ScEquZhibiao, IScEqu
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) { HttpServletRequest req) {
String tenantId = TenantContext.getTenant();
List<String> deploys = new ArrayList<>();
if(!"0".equals(tenantId)){
List<SurvDeviceDeploy> deployList = deviceDeployService.lambdaQuery()
.eq(SurvDeviceDeploy::getTenantId, tenantId)
.list()
;
if(!deployList.isEmpty()){
deploys = deployList.stream().map(SurvDeviceDeploy::getId).collect(Collectors.toList());
}else{
deploys.add("x");
}
}
QueryWrapper<ScEquZhibiao> queryWrapper = QueryGenerator.initQueryWrapper(scEquZhibiao, req.getParameterMap()); QueryWrapper<ScEquZhibiao> queryWrapper = QueryGenerator.initQueryWrapper(scEquZhibiao, req.getParameterMap());
if(StringUtils.isNotBlank(scEquZhibiao.getStationCode())){
List<SurvDeviceDeploy> deployList2 = deviceDeployService.lambdaQuery()
.eq(SurvDeviceDeploy::getStationCode, scEquZhibiao.getStationCode())
.list()
;
if(!deployList2.isEmpty()){
deploys = deployList2.stream().map(SurvDeviceDeploy::getId).collect(Collectors.toList());
}else{
deploys.add("y");
}
}
queryWrapper.in("equ_id", deploys);
Page<ScEquZhibiao> page = new Page<ScEquZhibiao>(pageNo, pageSize); Page<ScEquZhibiao> page = new Page<ScEquZhibiao>(pageNo, pageSize);
IPage<ScEquZhibiao> pageList = scEquZhibiaoService.page(page, queryWrapper.orderByAsc("sort_no").orderByDesc("create_time")); IPage<ScEquZhibiao> pageList = scEquZhibiaoService.page(page, queryWrapper.orderByAsc("sort_no").orderByDesc("create_time"));
scEquZhibiaoService.fills(pageList.getRecords());
return Result.OK(pageList); return Result.OK(pageList);
} }

View File

@ -18,4 +18,6 @@ public interface IScEquZhibiaoService extends IService<ScEquZhibiao> {
Integer getALlZhiBiaoCount(); Integer getALlZhiBiaoCount();
List<ScEquZhibiao> getListByEquid(String deployId); List<ScEquZhibiao> getListByEquid(String deployId);
void fills(List<ScEquZhibiao> records);
} }

View File

@ -4,11 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.entity.ScEquZhibiao; import org.jeecg.common.entity.ScEquZhibiao;
import org.jeecg.common.entity.SurvDeviceDeploy; import org.jeecg.common.entity.SurvDeviceDeploy;
import org.jeecg.common.entity.SurvStationInfo;
import org.jeecg.modules.appmana.mapper.ScEquZhibiaoMapper; import org.jeecg.modules.appmana.mapper.ScEquZhibiaoMapper;
import org.jeecg.modules.appmana.service.IScEquZhibiaoService; import org.jeecg.modules.appmana.service.IScEquZhibiaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @Description: sc_equ_zhibiao * @Description: sc_equ_zhibiao
@ -18,6 +24,12 @@ import java.util.List;
*/ */
@Service @Service
public class ScEquZhibiaoServiceImpl extends ServiceImpl<ScEquZhibiaoMapper, ScEquZhibiao> implements IScEquZhibiaoService { public class ScEquZhibiaoServiceImpl extends ServiceImpl<ScEquZhibiaoMapper, ScEquZhibiao> implements IScEquZhibiaoService {
@Lazy
@Autowired
private SurvDeviceDeployServiceImpl deviceDeployService;
@Lazy
@Autowired
private SurvStationInfoServiceImpl survStationInfoService;
@Override @Override
public List<ScEquZhibiao> getAllChemical(List<String> deviceList) { public List<ScEquZhibiao> getAllChemical(List<String> deviceList) {
@ -45,5 +57,39 @@ public class ScEquZhibiaoServiceImpl extends ServiceImpl<ScEquZhibiaoMapper, ScE
return this.list(queryWrapper); return this.list(queryWrapper);
} }
@Override
public void fills(List<ScEquZhibiao> records) {
if(records!=null && !records.isEmpty()){
List<String> equIds = records.stream().map(ScEquZhibiao::getEquId).collect(Collectors.toList());
Map<String,SurvStationInfo> stationMap = new HashMap<>();
Map<String,SurvDeviceDeploy> deployMap = new HashMap<>();
if(!equIds.isEmpty()){
List<SurvDeviceDeploy> deploys = deviceDeployService.listByIds(equIds);
if(deploys!=null && !deploys.isEmpty()){
List<String> stations = deploys.stream().map(SurvDeviceDeploy::getStationCode).collect(Collectors.toList());
List<SurvStationInfo> stationInfos = survStationInfoService.getStationByCode(stations);
if(stationInfos!=null && !stationInfos.isEmpty()){
for (SurvStationInfo stationInfo : stationInfos) {
stationMap.put(stationInfo.getStationCode(),stationInfo);
}
}
for (SurvDeviceDeploy deploy : deploys) {
deployMap.put(deploy.getId(),deploy);
}
}
}
for (ScEquZhibiao record : records) {
SurvDeviceDeploy deploy = deployMap.get(record.getEquId());
record.setDeployName(deploy!=null?deploy.getDeployDes():"");
if(deploy!=null){
SurvStationInfo stationInfo = stationMap.get(deploy.getStationCode());
record.setStationName(stationInfo!=null?stationInfo.getStationName():"");
}
}
}
}
} }

View File

@ -93,4 +93,12 @@ public class ScEquZhibiao implements Serializable {
@ApiModelProperty(value = "字典key") @ApiModelProperty(value = "字典key")
private String eleKey; private String eleKey;
@TableField(exist = false)
private String deployName;
@TableField(exist = false)
private String stationName;
@TableField(exist = false)
private String stationCode;
} }

View File

@ -18,5 +18,7 @@ public class LiveDataTrans {
private double avgNH; private double avgNH;
private double avgCOD; private double avgCOD;
private double avgNO;
} }