yingsl
3 years ago
6 changed files with 364 additions and 4 deletions
-
3src/main/java/com/example/modular/energyconsumption/service/impl/ToiletElectricityConsumptionServiceImpl.java
-
110src/main/java/com/example/modular/shangyudata/controller/IntelligenceCityController.java
-
6src/main/java/com/example/modular/shangyudata/controller/ShangyuToiletDataController.java
-
46src/main/java/com/example/modular/shangyudata/service/IntelligenceCityService.java
-
172src/main/java/com/example/modular/shangyudata/service/impl/IntelligenceCityServiceImpl.java
-
31src/main/java/com/example/modular/shangyudata/vo/GetToiletStatusVO.java
@ -0,0 +1,110 @@ |
|||
package com.example.modular.shangyudata.controller; |
|||
|
|||
import com.example.common.controller.BaseSupport; |
|||
import com.example.common.excepiton.BusinessException; |
|||
import com.example.modular.shangyudata.service.IntelligenceCityService; |
|||
import com.example.modular.shangyudata.vo.GetToiletStatusVO; |
|||
import com.haidapu.core.common.msg.R; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 上虞公厕数据对接 controller |
|||
* @Author ysl |
|||
* @date :Created in 2022/04/12 18:09 |
|||
*/ |
|||
@RestController |
|||
public class IntelligenceCityController extends BaseSupport { |
|||
|
|||
@Autowired |
|||
private IntelligenceCityService intelligenceCityService; |
|||
|
|||
/** |
|||
* 获取公厕厕位状态数据接口 |
|||
* @return |
|||
* @Author ysl |
|||
*/ |
|||
@PostMapping("getToiletStatus") |
|||
public R getToiletStatus() { |
|||
GetToiletStatusVO getToiletStatusVO = getInputObject(GetToiletStatusVO.class); |
|||
R r; |
|||
try { |
|||
r = intelligenceCityService.getToiletStatus(getToiletStatusVO); |
|||
} catch (Exception e) { |
|||
throw new BusinessException("系统错误",500); |
|||
} |
|||
return r; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取公厕人流量数据接口 |
|||
* @return |
|||
* @Author ysl |
|||
*/ |
|||
@PostMapping("getToiletPedeVolume") |
|||
public R getToiletPedeVolume() { |
|||
GetToiletStatusVO getToiletStatusVO = getInputObject(GetToiletStatusVO.class); |
|||
R r; |
|||
try { |
|||
r = intelligenceCityService.getToiletPedeVolume(getToiletStatusVO); |
|||
} catch (Exception e) { |
|||
throw new BusinessException("系统错误",500); |
|||
} |
|||
return r; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取公厕空气质量数据接口 |
|||
* @return |
|||
* @Author ysl |
|||
*/ |
|||
@PostMapping("getToiletAir") |
|||
public R getToiletAir() { |
|||
GetToiletStatusVO getToiletStatusVO = getInputObject(GetToiletStatusVO.class); |
|||
R r; |
|||
try { |
|||
r = intelligenceCityService.getToiletAir(getToiletStatusVO); |
|||
} catch (Exception e) { |
|||
throw new BusinessException("系统错误",500); |
|||
} |
|||
return r; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取公厕用电量数据接口 |
|||
* @return |
|||
* @Author ysl |
|||
*/ |
|||
@PostMapping("getToiletElectricity") |
|||
public R getToiletElectricity() { |
|||
GetToiletStatusVO getToiletStatusVO = getInputObject(GetToiletStatusVO.class); |
|||
R r; |
|||
try { |
|||
r = intelligenceCityService.getToiletElectricity(getToiletStatusVO); |
|||
} catch (Exception e) { |
|||
throw new BusinessException("系统错误",500); |
|||
} |
|||
return r; |
|||
} |
|||
|
|||
/** |
|||
* 获取公厕用水量数据接口 |
|||
* @return |
|||
* @Author ysl |
|||
*/ |
|||
@PostMapping("getToiletWater") |
|||
public R getToiletWater() { |
|||
GetToiletStatusVO getToiletStatusVO = getInputObject(GetToiletStatusVO.class); |
|||
R r; |
|||
try { |
|||
r = intelligenceCityService.getToiletWater(getToiletStatusVO); |
|||
} catch (Exception e) { |
|||
throw new BusinessException("系统错误",500); |
|||
} |
|||
return r; |
|||
} |
|||
} |
@ -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); |
|||
} |
@ -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<Toilet> toiletQueryWrapper = new QueryWrapper<>(); |
|||
toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); |
|||
toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); |
|||
List<Toilet> toiletList = toiletService.list(toiletQueryWrapper); |
|||
if (CollectionUtils.isEmpty(toiletList)) { |
|||
throw new BusinessException("公厕信息不存在!",202); |
|||
} |
|||
Long toiletId = toiletList.get(0).getId(); |
|||
//查询公厕厕位状态数据 |
|||
QueryWrapper<ToiletNearInfo> 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<ToiletNearInfo> 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<Toilet> toiletQueryWrapper = new QueryWrapper<>(); |
|||
toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); |
|||
toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); |
|||
List<Toilet> toiletList = toiletService.list(toiletQueryWrapper); |
|||
if (CollectionUtils.isEmpty(toiletList)) { |
|||
throw new BusinessException("公厕信息不存在!",202); |
|||
} |
|||
Long toiletId = toiletList.get(0).getId(); |
|||
//查询公厕厕位状态数据 |
|||
QueryWrapper<ToiletPassengerFlow> 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<ToiletPassengerFlow> 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<Toilet> toiletQueryWrapper = new QueryWrapper<>(); |
|||
toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); |
|||
toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); |
|||
List<Toilet> toiletList = toiletService.list(toiletQueryWrapper); |
|||
if (CollectionUtils.isEmpty(toiletList)) { |
|||
throw new BusinessException("公厕信息不存在!",202); |
|||
} |
|||
Long toiletId = toiletList.get(0).getId(); |
|||
//查询公厕厕位状态数据 |
|||
QueryWrapper<ToiletAirIndexAverage> 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<ToiletAirIndexAverage> 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<Toilet> toiletQueryWrapper = new QueryWrapper<>(); |
|||
toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); |
|||
toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); |
|||
List<Toilet> toiletList = toiletService.list(toiletQueryWrapper); |
|||
if (CollectionUtils.isEmpty(toiletList)) { |
|||
throw new BusinessException("公厕信息不存在!",202); |
|||
} |
|||
Long toiletId = toiletList.get(0).getId(); |
|||
//查询公厕厕位状态数据 |
|||
QueryWrapper<ToiletElectricityConsumption> toiletElectricityConsumptionQueryWrapper = new QueryWrapper<>(); |
|||
toiletElectricityConsumptionQueryWrapper.eq("toilet_id",toiletId); |
|||
toiletElectricityConsumptionQueryWrapper.ge("create_time",getToiletStatusVO.getStartTime()); |
|||
toiletElectricityConsumptionQueryWrapper.le("create_time",getToiletStatusVO.getEndTime()); |
|||
List<ToiletElectricityConsumption> 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<Toilet> toiletQueryWrapper = new QueryWrapper<>(); |
|||
toiletQueryWrapper.eq("toilet_code",getToiletStatusVO.getToiletCode()); |
|||
toiletQueryWrapper.eq("delete_status", Constant.TOILET_DEL_STATUS_NO); |
|||
List<Toilet> toiletList = toiletService.list(toiletQueryWrapper); |
|||
if (CollectionUtils.isEmpty(toiletList)) { |
|||
throw new BusinessException("公厕信息不存在!",202); |
|||
} |
|||
Long toiletId = toiletList.get(0).getId(); |
|||
//查询公厕厕位状态数据 |
|||
QueryWrapper<ToiletWaterConsumption> toiletWaterConsumptionQueryWrapper = new QueryWrapper<>(); |
|||
toiletWaterConsumptionQueryWrapper.eq("toilet_id",toiletId); |
|||
toiletWaterConsumptionQueryWrapper.ge("create_time",getToiletStatusVO.getStartTime()); |
|||
toiletWaterConsumptionQueryWrapper.le("create_time",getToiletStatusVO.getEndTime()); |
|||
List<ToiletWaterConsumption> toiletWaterConsumptionList = toiletWaterConsumptionService.list(toiletWaterConsumptionQueryWrapper); |
|||
return R.ok().put("data",toiletWaterConsumptionList); |
|||
} |
|||
|
|||
} |
@ -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; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue