From cdbd21ea73eef5d7cf4024654e1f31ab7be1ed81 Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期四, 10 十月 2024 09:57:00 +0800 Subject: [PATCH] 代码初始化 --- server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java | 41 +++++++++++++++++++++++++++++++++-------- 1 files changed, 33 insertions(+), 8 deletions(-) diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java index a3e2a31..55c4e3a 100644 --- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java +++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformWaterGasServiceImpl.java @@ -15,6 +15,7 @@ import com.doumee.dao.openapi.request.GasByMonthRequest; import com.doumee.dao.openapi.request.WaterByMonthRequest; import com.doumee.dao.openapi.response.GasByMonthResponse; +import com.doumee.dao.openapi.response.PlatformLastMonthListResponse; import com.doumee.dao.openapi.response.WaterByMonthResponse; import com.doumee.service.business.PlatformWaterGasService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -29,10 +30,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.util.*; /** * 鏈堝彴_鐢ㄦ按鐢ㄦ皵淇℃伅璁板綍琛⊿ervice瀹炵幇 @@ -244,7 +242,7 @@ list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda() .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) .eq(PlatformWaterGas::getType,Constants.ZERO) - .like(PlatformWaterGas::getTimeInfo,beforMonth) + .like(PlatformWaterGas::getTimeInfo,DateUtil.getDate(beforMonth,"yyyy-MM")) ); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ waterByMonthResponse.setLastMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add)); @@ -253,7 +251,7 @@ list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda() .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) .eq(PlatformWaterGas::getType,Constants.ZERO) - .like(PlatformWaterGas::getTimeInfo,beforYearMonth) + .like(PlatformWaterGas::getTimeInfo,DateUtil.getDate(beforYearMonth,"yyyy-MM")) ); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ waterByMonthResponse.setLastYearMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add)); @@ -287,7 +285,7 @@ list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda() .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) .eq(PlatformWaterGas::getType,Constants.ONE) - .like(PlatformWaterGas::getTimeInfo,beforMonth) + .like(PlatformWaterGas::getTimeInfo,DateUtil.getDate(beforMonth,"yyyy-MM")) ); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ response.setLastMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add)); @@ -296,7 +294,7 @@ list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda() .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) .eq(PlatformWaterGas::getType,Constants.ONE) - .like(PlatformWaterGas::getTimeInfo,beforYearMonth) + .like(PlatformWaterGas::getTimeInfo,DateUtil.getDate(beforYearMonth,"yyyy-MM")) ); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ response.setLastYearMonth(list.stream().map(m->m.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add)); @@ -304,4 +302,31 @@ return response; } + + /** + * + * @param type 0鐢ㄦ按 1鐢ㄦ皵 + * @return + */ + @Override + public List<PlatformLastMonthListResponse> getPlatformLastMonthListResponse(Integer type){ + List<PlatformLastMonthListResponse> lastMonthListResponses = new ArrayList<>(); + + List<PlatformWaterGas> platformWaterGasList = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda() + .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) + .eq(PlatformWaterGas::getType,type) + ); + List<String> monthList = DateUtil.getBeforMonth(new Date(),12); + for (String str:monthList) { + PlatformLastMonthListResponse platformLastMonthListResponse = new PlatformLastMonthListResponse(); + platformLastMonthListResponse.setNum(platformWaterGasList.stream().filter(i->DateUtil.dateToString(i.getTimeInfo(),"yyyy-MM").equals(str)).map(i->i.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add)); + platformLastMonthListResponse.setTimeInfo(str); + lastMonthListResponses.add(platformLastMonthListResponse); + } + return lastMonthListResponses; + } + + + + } -- Gitblit v1.9.3