From 749a8000333145e82c0fc88137601f685fd6d7eb Mon Sep 17 00:00:00 2001 From: yingsl Date: Mon, 18 Apr 2022 18:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=85=AC=E5=8E=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ToiletElectricityConsumptionServiceImpl.java | 3 +- .../controller/IntelligenceCityController.java | 110 +++++++++++++ .../controller/ShangyuToiletDataController.java | 6 +- .../service/IntelligenceCityService.java | 46 ++++++ .../service/impl/IntelligenceCityServiceImpl.java | 172 +++++++++++++++++++++ .../modular/shangyudata/vo/GetToiletStatusVO.java | 31 ++++ 6 files changed, 364 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/example/modular/shangyudata/controller/IntelligenceCityController.java create mode 100644 src/main/java/com/example/modular/shangyudata/service/IntelligenceCityService.java create mode 100644 src/main/java/com/example/modular/shangyudata/service/impl/IntelligenceCityServiceImpl.java create mode 100644 src/main/java/com/example/modular/shangyudata/vo/GetToiletStatusVO.java diff --git a/src/main/java/com/example/modular/energyconsumption/service/impl/ToiletElectricityConsumptionServiceImpl.java b/src/main/java/com/example/modular/energyconsumption/service/impl/ToiletElectricityConsumptionServiceImpl.java index 76276a6..b12fa14 100644 --- a/src/main/java/com/example/modular/energyconsumption/service/impl/ToiletElectricityConsumptionServiceImpl.java +++ b/src/main/java/com/example/modular/energyconsumption/service/impl/ToiletElectricityConsumptionServiceImpl.java @@ -351,7 +351,8 @@ public class ToiletElectricityConsumptionServiceImpl extends ServiceImpl map = new HashMap<>(); map.put("appid","f890e766810cc612dafbc1fe501f46fc"); - map.put("method","pushToiletPedeVolume"); + map.put("method","pushToiletAir"); map.put("timeStamp",System.currentTimeMillis()); Map dataMap = new HashMap<>(); dataMap.put("toiletCode","123"); @@ -93,6 +91,8 @@ public class ShangyuToiletDataController extends BaseSupport { dataMap.put("passengerNumToday",123); dataMap.put("passengerNumHour",13); dataMap.put("createTime","2021-12-29 12:12:12"); + + String dataJsonStr = JSON.toJSONString(dataMap); map.put("data",dataJsonStr); StringBuilder stringBuilder = new StringBuilder(); diff --git a/src/main/java/com/example/modular/shangyudata/service/IntelligenceCityService.java b/src/main/java/com/example/modular/shangyudata/service/IntelligenceCityService.java new file mode 100644 index 0000000..e55a1a7 --- /dev/null +++ b/src/main/java/com/example/modular/shangyudata/service/IntelligenceCityService.java @@ -0,0 +1,46 @@ +package com.example.modular.shangyudata.service; + +import com.example.modular.shangyudata.vo.GetToiletStatusVO; +import com.example.modular.shangyudata.vo.ToiletInfoVO; +import com.haidapu.core.common.msg.R; + +public interface IntelligenceCityService { + + /** + * 获取公厕厕位状态数据接口 + * @return + * @Author ysl + */ + R getToiletStatus(GetToiletStatusVO getToiletStatusVO); + + + /** + * 获取公厕人流量数据接口 + * @return + * @Author ysl + */ + R getToiletPedeVolume(GetToiletStatusVO getToiletStatusVO); + + + /** + * 获取公厕空气质量数据接口 + * @return + * @Author ysl + */ + R getToiletAir(GetToiletStatusVO getToiletStatusVO); + + + /** + * 获取公厕用电量数据接口 + * @return + * @Author ysl + */ + R getToiletElectricity(GetToiletStatusVO getToiletStatusVO); + + /** + * 获取公厕用水量数据接口 + * @return + * @Author ysl + */ + R getToiletWater(GetToiletStatusVO getToiletStatusVO); +} diff --git a/src/main/java/com/example/modular/shangyudata/service/impl/IntelligenceCityServiceImpl.java b/src/main/java/com/example/modular/shangyudata/service/impl/IntelligenceCityServiceImpl.java new file mode 100644 index 0000000..a1a5442 --- /dev/null +++ b/src/main/java/com/example/modular/shangyudata/service/impl/IntelligenceCityServiceImpl.java @@ -0,0 +1,172 @@ +package com.example.modular.shangyudata.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.example.common.Constant; +import com.example.common.excepiton.BusinessException; +import com.example.modular.energyconsumption.po.ToiletElectricityConsumption; +import com.example.modular.energyconsumption.po.ToiletWaterConsumption; +import com.example.modular.energyconsumption.service.IToiletElectricityConsumptionService; +import com.example.modular.energyconsumption.service.IToiletWaterConsumptionService; +import com.example.modular.monitoringdata.po.ToiletAirIndexAverage; +import com.example.modular.monitoringdata.po.ToiletNearInfo; +import com.example.modular.monitoringdata.po.ToiletPassengerFlow; +import com.example.modular.monitoringdata.service.IToiletAirIndexAverageService; +import com.example.modular.monitoringdata.service.IToiletNearInfoService; +import com.example.modular.monitoringdata.service.IToiletPassengerFlowService; +import com.example.modular.shangyudata.service.IntelligenceCityService; +import com.example.modular.shangyudata.vo.GetToiletStatusVO; +import com.example.modular.toilet.po.Toilet; +import com.example.modular.toilet.service.IToiletService; +import com.haidapu.core.common.msg.R; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +@Service +public class IntelligenceCityServiceImpl implements IntelligenceCityService { + + @Autowired + private IToiletService toiletService; + @Autowired + private IToiletNearInfoService toiletNearInfoService; + @Autowired + private IToiletPassengerFlowService toiletPassengerFlowService; + @Autowired + private IToiletAirIndexAverageService toiletAirIndexAverageService; + @Autowired + private IToiletElectricityConsumptionService toiletElectricityConsumptionService; + @Autowired + private IToiletWaterConsumptionService toiletWaterConsumptionService; + + @Override + public R getToiletStatus(GetToiletStatusVO getToiletStatusVO) { + //校验参数是否存在 + if (getToiletStatusVO == null || StringUtils.isBlank(getToiletStatusVO.getToiletCode()) || getToiletStatusVO.getToiletNearType() == null + || StringUtils.isBlank(getToiletStatusVO.getStartTime()) || StringUtils.isBlank(getToiletStatusVO.getEndTime())) { + throw new BusinessException("必填项不能为空!",201); + } + //校验公厕是否存在 + QueryWrapper toiletQueryWrapper = new QueryWrapper<>(); + toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); + toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); + List toiletList = toiletService.list(toiletQueryWrapper); + if (CollectionUtils.isEmpty(toiletList)) { + throw new BusinessException("公厕信息不存在!",202); + } + Long toiletId = toiletList.get(0).getId(); + //查询公厕厕位状态数据 + QueryWrapper toiletNearInfoQueryWrapper = new QueryWrapper<>(); + toiletNearInfoQueryWrapper.eq("toilet_id",toiletId); + toiletNearInfoQueryWrapper.eq("toilet_near_type",getToiletStatusVO.getToiletNearType()); + toiletNearInfoQueryWrapper.ge("create_time",getToiletStatusVO.getStartTime()); + toiletNearInfoQueryWrapper.le("create_time",getToiletStatusVO.getEndTime()); + List toiletNearInfoList = toiletNearInfoService.list(toiletNearInfoQueryWrapper); + return R.ok().put("data",toiletNearInfoList); + } + + @Override + public R getToiletPedeVolume(GetToiletStatusVO getToiletStatusVO) { + //校验参数是否存在 + if (getToiletStatusVO == null || StringUtils.isBlank(getToiletStatusVO.getToiletCode()) || getToiletStatusVO.getToiletNearType() == null + || StringUtils.isBlank(getToiletStatusVO.getStartTime()) || StringUtils.isBlank(getToiletStatusVO.getEndTime())) { + throw new BusinessException("必填项不能为空!",201); + } + //校验公厕是否存在 + QueryWrapper toiletQueryWrapper = new QueryWrapper<>(); + toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); + toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); + List toiletList = toiletService.list(toiletQueryWrapper); + if (CollectionUtils.isEmpty(toiletList)) { + throw new BusinessException("公厕信息不存在!",202); + } + Long toiletId = toiletList.get(0).getId(); + //查询公厕厕位状态数据 + QueryWrapper toiletPassengerFlowQueryWrapper = new QueryWrapper<>(); + toiletPassengerFlowQueryWrapper.eq("toilet_id",toiletId); + toiletPassengerFlowQueryWrapper.eq("toilet_near_type",getToiletStatusVO.getToiletNearType()); + toiletPassengerFlowQueryWrapper.ge("create_time",getToiletStatusVO.getStartTime()); + toiletPassengerFlowQueryWrapper.le("create_time",getToiletStatusVO.getEndTime()); + List toiletPassengerFlowList = toiletPassengerFlowService.list(toiletPassengerFlowQueryWrapper); + return R.ok().put("data",toiletPassengerFlowList); + } + + @Override + public R getToiletAir(GetToiletStatusVO getToiletStatusVO) { + //校验参数是否存在 + if (getToiletStatusVO == null || StringUtils.isBlank(getToiletStatusVO.getToiletCode()) || getToiletStatusVO.getToiletNearType() == null + || StringUtils.isBlank(getToiletStatusVO.getStartTime()) || StringUtils.isBlank(getToiletStatusVO.getEndTime())) { + throw new BusinessException("必填项不能为空!",201); + } + //校验公厕是否存在 + QueryWrapper toiletQueryWrapper = new QueryWrapper<>(); + toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); + toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); + List toiletList = toiletService.list(toiletQueryWrapper); + if (CollectionUtils.isEmpty(toiletList)) { + throw new BusinessException("公厕信息不存在!",202); + } + Long toiletId = toiletList.get(0).getId(); + //查询公厕厕位状态数据 + QueryWrapper toiletAirIndexAverageQueryWrapper = new QueryWrapper<>(); + toiletAirIndexAverageQueryWrapper.eq("toilet_id",toiletId); + toiletAirIndexAverageQueryWrapper.eq("toilet_near_type",getToiletStatusVO.getToiletNearType()); + toiletAirIndexAverageQueryWrapper.ge("create_time",getToiletStatusVO.getStartTime()); + toiletAirIndexAverageQueryWrapper.le("create_time",getToiletStatusVO.getEndTime()); + List toiletAirIndexAverageList = toiletAirIndexAverageService.list(toiletAirIndexAverageQueryWrapper); + return R.ok().put("data",toiletAirIndexAverageList); + } + + @Override + public R getToiletElectricity(GetToiletStatusVO getToiletStatusVO) { + //校验参数是否存在 + if (getToiletStatusVO == null || StringUtils.isBlank(getToiletStatusVO.getToiletCode()) + || StringUtils.isBlank(getToiletStatusVO.getStartTime()) || StringUtils.isBlank(getToiletStatusVO.getEndTime())) { + throw new BusinessException("必填项不能为空!",201); + } + //校验公厕是否存在 + QueryWrapper toiletQueryWrapper = new QueryWrapper<>(); + toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); + toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); + List toiletList = toiletService.list(toiletQueryWrapper); + if (CollectionUtils.isEmpty(toiletList)) { + throw new BusinessException("公厕信息不存在!",202); + } + Long toiletId = toiletList.get(0).getId(); + //查询公厕厕位状态数据 + QueryWrapper toiletElectricityConsumptionQueryWrapper = new QueryWrapper<>(); + toiletElectricityConsumptionQueryWrapper.eq("toilet_id",toiletId); + toiletElectricityConsumptionQueryWrapper.ge("create_time",getToiletStatusVO.getStartTime()); + toiletElectricityConsumptionQueryWrapper.le("create_time",getToiletStatusVO.getEndTime()); + List toiletElectricityConsumptionList = toiletElectricityConsumptionService.list(toiletElectricityConsumptionQueryWrapper); + return R.ok().put("data",toiletElectricityConsumptionList); + } + + @Override + public R getToiletWater(GetToiletStatusVO getToiletStatusVO) { + //校验参数是否存在 + if (getToiletStatusVO == null || StringUtils.isBlank(getToiletStatusVO.getToiletCode()) + || StringUtils.isBlank(getToiletStatusVO.getStartTime()) || StringUtils.isBlank(getToiletStatusVO.getEndTime())) { + throw new BusinessException("必填项不能为空!",201); + } + //校验公厕是否存在 + QueryWrapper toiletQueryWrapper = new QueryWrapper<>(); + toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); + toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); + List toiletList = toiletService.list(toiletQueryWrapper); + if (CollectionUtils.isEmpty(toiletList)) { + throw new BusinessException("公厕信息不存在!",202); + } + Long toiletId = toiletList.get(0).getId(); + //查询公厕厕位状态数据 + QueryWrapper toiletWaterConsumptionQueryWrapper = new QueryWrapper<>(); + toiletWaterConsumptionQueryWrapper.eq("toilet_id",toiletId); + toiletWaterConsumptionQueryWrapper.ge("create_time",getToiletStatusVO.getStartTime()); + toiletWaterConsumptionQueryWrapper.le("create_time",getToiletStatusVO.getEndTime()); + List toiletWaterConsumptionList = toiletWaterConsumptionService.list(toiletWaterConsumptionQueryWrapper); + return R.ok().put("data",toiletWaterConsumptionList); + } + +} diff --git a/src/main/java/com/example/modular/shangyudata/vo/GetToiletStatusVO.java b/src/main/java/com/example/modular/shangyudata/vo/GetToiletStatusVO.java new file mode 100644 index 0000000..790036b --- /dev/null +++ b/src/main/java/com/example/modular/shangyudata/vo/GetToiletStatusVO.java @@ -0,0 +1,31 @@ +package com.example.modular.shangyudata.vo; + +import lombok.Data; + +/** + * 获取公厕厕位状态数据参数类 + */ +@Data +public class GetToiletStatusVO { + + public GetToiletStatusVO () { + + } + + /** + * 公厕编码 + */ + private String toiletCode; + /** + * 公厕厕位 1:男厕 2:女厕 + */ + private Integer toiletNearType; + /** + * 开始时间,格式:yyyy-MM-dd HH:mm:ss + */ + private String startTime; + /** + * 结束时间,格式:yyyy-MM-dd HH:mm:ss + */ + private String endTime; +}