|
@@ -0,0 +1,328 @@
|
|
|
+package com.persagy.apm.energy.report.monthly.detail.hotel.project.service.impl;
|
|
|
+
|
|
|
+import com.persagy.apm.common.context.AppContext;
|
|
|
+import com.persagy.apm.energy.report.monthly.detail.hotel.project.dao.ReportHotelProjectDetailMapper;
|
|
|
+import com.persagy.apm.energy.report.monthly.detail.hotel.project.model.vo.ResponseReportHotelProjectDetailItemVO;
|
|
|
+import com.persagy.apm.energy.report.monthly.detail.hotel.project.service.IReportHotelProjectDetailService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
|
|
|
+import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import com.persagy.apm.common.constant.enums.ValidEnum;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.persagy.apm.energy.report.monthly.detail.hotel.project.model.*;
|
|
|
+import com.persagy.apm.energy.report.monthly.detail.hotel.project.model.dto.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.google.common.base.CaseFormat;
|
|
|
+import com.persagy.apm.common.model.dto.Sort;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 商业报告详情(ReportHotelProjectDetail) service层
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ReportHotelProjectDetailServiceImpl extends ServiceImpl<ReportHotelProjectDetailMapper, ReportHotelProjectDetail>
|
|
|
+ implements IReportHotelProjectDetailService {
|
|
|
+ @Autowired
|
|
|
+ private IReportOutlineService reportOutlineService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建商业报告详情
|
|
|
+ *
|
|
|
+ * @return 商业报告详情主键
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String createReportHotelProjectDetail(AddReportHotelProjectDetailDTO addReportHotelProjectDetailDTO) {
|
|
|
+ ReportHotelProjectDetail reportHotelProjectDetail = ConvertReportHotelProjectDetailTool.INSTANCE.convertAddDto2Entity(addReportHotelProjectDetailDTO);
|
|
|
+ // 设置默认值
|
|
|
+ setDefaultValue(reportHotelProjectDetail);
|
|
|
+ save(reportHotelProjectDetail);
|
|
|
+ return reportHotelProjectDetail.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 如果某些字段没有赋值,使用默认的值
|
|
|
+ *
|
|
|
+ * @param reportHotelProjectDetail 商业报告详情实体
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/3/12 12:29 下午
|
|
|
+ */
|
|
|
+ private void setDefaultValue(ReportHotelProjectDetail reportHotelProjectDetail) {
|
|
|
+ reportHotelProjectDetail.setCreator(AppContext.getContext().getAccountId());
|
|
|
+ // todo 其他默认的属性
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商业报告详情详情
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 部门do类
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ReportHotelProjectDetail getReportHotelProjectDetail(String id) {
|
|
|
+ ReportHotelProjectDetail reportHotelProjectDetail = getById(id);
|
|
|
+ if (reportHotelProjectDetail == null) {
|
|
|
+ throw new IllegalArgumentException("查看ReportHotelProjectDetail详情时发生异常,找不到要查看的记录,id=" + id);
|
|
|
+ }
|
|
|
+ return reportHotelProjectDetail;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新商业报告详情
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateReportHotelProjectDetail(UpdateReportHotelProjectDetailDTO updateReportHotelProjectDetailDTO) {
|
|
|
+ ReportHotelProjectDetail reportHotelProjectDetail = getById(updateReportHotelProjectDetailDTO.getId());
|
|
|
+ reportHotelProjectDetail = ConvertReportHotelProjectDetailTool.INSTANCE.convertUpdateDto2Entity(reportHotelProjectDetail, updateReportHotelProjectDetailDTO);
|
|
|
+ reportHotelProjectDetail.setModifier(AppContext.getContext().getAccountId());
|
|
|
+ updateById(reportHotelProjectDetail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验商业报告详情是否可删除
|
|
|
+ *
|
|
|
+ * @param id 商业报告详情主键
|
|
|
+ * @return 商业报告详情do类
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+ public ReportHotelProjectDetail checkDeletable(String id) {
|
|
|
+ if (id == null) {
|
|
|
+ throw new IllegalArgumentException("删除ReportHotelProjectDetail时发生异常,主键为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ ReportHotelProjectDetail reportHotelProjectDetail = getById(id);
|
|
|
+
|
|
|
+ if (reportHotelProjectDetail == null) {
|
|
|
+ throw new IllegalArgumentException("删除ReportHotelProjectDetail时发生异常,找不到要删除的数据,id:" + id);
|
|
|
+ }
|
|
|
+
|
|
|
+ return reportHotelProjectDetail;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除商业报告详情
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void deleteReportHotelProjectDetail(String id) {
|
|
|
+ // 校验是否可删除
|
|
|
+ ReportHotelProjectDetail reportHotelProjectDetail = checkDeletable(id);
|
|
|
+
|
|
|
+ reportHotelProjectDetail.setValid(ValidEnum.FALSE.getType());
|
|
|
+ updateById(reportHotelProjectDetail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询商业报告详情
|
|
|
+ *
|
|
|
+ * @return List<ReportHotelProjectDetail>
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ReportHotelProjectDetail> queryReportHotelProjectDetailList(QueryReportHotelProjectDetailDTO queryReportHotelProjectDetailDTO) {
|
|
|
+ QueryWrapper<ReportHotelProjectDetail> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
+ // 默认按创建时间倒序排序
|
|
|
+ queryWrapper.orderBy(true, false, ReportHotelProjectDetail.PROP_CREATIONTIME);
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO != null) {
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getCostInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_COST_INFO, queryReportHotelProjectDetailDTO.getCostInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryReportHotelProjectDetailDTO.getCostDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_COST_DESCRIPTION, queryReportHotelProjectDetailDTO.getCostDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getPowerUsageOutline() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_POWER_USAGE_OUTLINE, queryReportHotelProjectDetailDTO.getPowerUsageOutline());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getPublicAreaPowerUsage() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_PUBLIC_AREA_POWER_USAGE, queryReportHotelProjectDetailDTO.getPublicAreaPowerUsage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryReportHotelProjectDetailDTO.getPowerUsageDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_POWER_USAGE_DESCRIPTION, queryReportHotelProjectDetailDTO.getPowerUsageDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getAirConditionerEfficiency() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_AIR_CONDITIONER_EFFICIENCY, queryReportHotelProjectDetailDTO.getAirConditionerEfficiency());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryReportHotelProjectDetailDTO.getAirConditionerEfficiencyExplain())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_AIR_CONDITIONER_EFFICIENCY_EXPLAIN, queryReportHotelProjectDetailDTO.getAirConditionerEfficiencyExplain());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getEnvInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_ENV_INFO, queryReportHotelProjectDetailDTO.getEnvInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryReportHotelProjectDetailDTO.getEnvDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_ENV_DESCRIPTION, queryReportHotelProjectDetailDTO.getEnvDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getEnergyWorkOrderInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_ENERGY_WORK_ORDER_INFO, queryReportHotelProjectDetailDTO.getEnergyWorkOrderInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryReportHotelProjectDetailDTO.getEnergyWorkOrderDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_ENERGY_WORK_ORDER_DESCRIPTION, queryReportHotelProjectDetailDTO.getEnergyWorkOrderDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getPlatformRuntimeInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_PLATFORM_RUNTIME_INFO, queryReportHotelProjectDetailDTO.getPlatformRuntimeInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryReportHotelProjectDetailDTO.getPlatformRuntimeDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_PLATFORM_RUNTIME_DESCRIPTION, queryReportHotelProjectDetailDTO.getPlatformRuntimeDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryReportHotelProjectDetailDTO.getAlarmDealInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_ALARM_DEAL_INFO, queryReportHotelProjectDetailDTO.getAlarmDealInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryReportHotelProjectDetailDTO.getAlarmDealDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_ALARM_DEAL_DESCRIPTION, queryReportHotelProjectDetailDTO.getAlarmDealDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return list(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询商业报告详情
|
|
|
+ *
|
|
|
+ * @return IPage<ReportHotelProjectDetail>
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-06-07 09:42:57
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<ReportHotelProjectDetail> pageQueryReportHotelProjectDetail(PageQueryReportHotelProjectDetailDTO pageQueryReportHotelProjectDetailDTO) {
|
|
|
+ QueryWrapper<ReportHotelProjectDetail> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
+ // 这里认为pageQueryDTO是经过校验的,肯定包含分页信息
|
|
|
+ IPage<ReportHotelProjectDetail> pageParam = new Page<>(pageQueryReportHotelProjectDetailDTO.getPage(), pageQueryReportHotelProjectDetailDTO.getSize(), true);
|
|
|
+ // 排序信息
|
|
|
+ if (CollectionUtils.isEmpty(pageQueryReportHotelProjectDetailDTO.getOrders())) {
|
|
|
+ // 默认按创建时间倒序排序
|
|
|
+ queryWrapper.orderBy(true, false, ReportHotelProjectDetail.PROP_CREATIONTIME);
|
|
|
+ } else {
|
|
|
+ List<Sort> orders = pageQueryReportHotelProjectDetailDTO.getOrders();
|
|
|
+ for (Sort sort : orders) {
|
|
|
+ // 将驼峰转换为下划线格式
|
|
|
+ sort.setColumn(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sort.getColumn()));
|
|
|
+ queryWrapper.orderBy(true, sort.isAsc(), sort.getColumn());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getCostInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_COST_INFO, pageQueryReportHotelProjectDetailDTO.getCostInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryReportHotelProjectDetailDTO.getCostDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_COST_DESCRIPTION, pageQueryReportHotelProjectDetailDTO.getCostDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getPowerUsageOutline() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_POWER_USAGE_OUTLINE, pageQueryReportHotelProjectDetailDTO.getPowerUsageOutline());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getPublicAreaPowerUsage() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_PUBLIC_AREA_POWER_USAGE, pageQueryReportHotelProjectDetailDTO.getPublicAreaPowerUsage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryReportHotelProjectDetailDTO.getPowerUsageDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_POWER_USAGE_DESCRIPTION, pageQueryReportHotelProjectDetailDTO.getPowerUsageDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getAirConditionerEfficiency() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_AIR_CONDITIONER_EFFICIENCY, pageQueryReportHotelProjectDetailDTO.getAirConditionerEfficiency());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryReportHotelProjectDetailDTO.getAirConditionerEfficiencyExplain())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_AIR_CONDITIONER_EFFICIENCY_EXPLAIN, pageQueryReportHotelProjectDetailDTO.getAirConditionerEfficiencyExplain());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getEnvInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_ENV_INFO, pageQueryReportHotelProjectDetailDTO.getEnvInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryReportHotelProjectDetailDTO.getEnvDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_ENV_DESCRIPTION, pageQueryReportHotelProjectDetailDTO.getEnvDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getEnergyWorkOrderInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_ENERGY_WORK_ORDER_INFO, pageQueryReportHotelProjectDetailDTO.getEnergyWorkOrderInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryReportHotelProjectDetailDTO.getEnergyWorkOrderDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_ENERGY_WORK_ORDER_DESCRIPTION, pageQueryReportHotelProjectDetailDTO.getEnergyWorkOrderDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getPlatformRuntimeInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_PLATFORM_RUNTIME_INFO, pageQueryReportHotelProjectDetailDTO.getPlatformRuntimeInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryReportHotelProjectDetailDTO.getPlatformRuntimeDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_PLATFORM_RUNTIME_DESCRIPTION, pageQueryReportHotelProjectDetailDTO.getPlatformRuntimeDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryReportHotelProjectDetailDTO.getAlarmDealInfo() != null) {
|
|
|
+ queryWrapper.eq(ReportHotelProjectDetail.PROP_ALARM_DEAL_INFO, pageQueryReportHotelProjectDetailDTO.getAlarmDealInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryReportHotelProjectDetailDTO.getAlarmDealDescription())) {
|
|
|
+ queryWrapper.like(ReportHotelProjectDetail.PROP_ALARM_DEAL_DESCRIPTION, pageQueryReportHotelProjectDetailDTO.getAlarmDealDescription());
|
|
|
+ }
|
|
|
+
|
|
|
+ return getBaseMapper().selectPage(pageParam, queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseReportHotelProjectDetailItemVO getReportHotelProjectDetailByReportOutline(String reportOutlineId) {
|
|
|
+ ReportOutline reportOutline = reportOutlineService.queryReportOutlineDetail(reportOutlineId);
|
|
|
+ String detailId = reportOutline.getDetailId();
|
|
|
+ ReportHotelProjectDetail reportHotelProjectDetail = getReportHotelProjectDetail(detailId);
|
|
|
+ return ConvertReportHotelProjectDetailTool.INSTANCE.
|
|
|
+ convert2ResponseItemDTO(reportHotelProjectDetail);
|
|
|
+ }
|
|
|
+}
|