|
@@ -2,13 +2,19 @@
|
|
|
|
|
|
package cn.vber.breeding.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.vber.breeding.domain.CoopBatchReport;
|
|
|
import cn.vber.breeding.domain.bo.statistic.QueryStaBo;
|
|
|
import cn.vber.breeding.domain.bo.statistic.QueryStaScopeParam;
|
|
|
+import cn.vber.breeding.domain.vo.CoopBatchReportVo;
|
|
|
import cn.vber.breeding.domain.vo.report.CoopBatchReportDetailResult;
|
|
|
import cn.vber.breeding.domain.vo.report.CoopBatchReportDetailView;
|
|
|
+import cn.vber.breeding.domain.vo.report.CoopBatchReportResultVo;
|
|
|
import cn.vber.breeding.domain.vo.statistic.StatisticTmpResultDto;
|
|
|
+import cn.vber.breeding.mapper.CoopBatchReportMapper;
|
|
|
+import cn.vber.breeding.service.ICommonService;
|
|
|
import cn.vber.breeding.service.IStatisticsHelperService;
|
|
|
+import cn.vber.common.core.domain.R;
|
|
|
+import cn.vber.common.core.exception.ServiceException;
|
|
|
import cn.vber.common.core.utils.ChickenCalcUtils;
|
|
|
import cn.vber.common.core.utils.DateUtils;
|
|
|
import cn.vber.common.core.utils.MapstructUtils;
|
|
@@ -18,9 +24,7 @@ import cn.vber.common.mybatis.core.page.PageQuery;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import cn.vber.breeding.domain.bo.CoopBatchReportDetailBo;
|
|
|
import cn.vber.breeding.domain.vo.CoopBatchReportDetailVo;
|
|
@@ -42,7 +46,9 @@ import java.util.stream.Collectors;
|
|
|
public class CoopBatchReportDetailServiceImpl implements ICoopBatchReportDetailService {
|
|
|
|
|
|
private final CoopBatchReportDetailMapper baseMapper;
|
|
|
+ private final CoopBatchReportMapper coopBatchReportMapper;
|
|
|
private final IStatisticsHelperService statisticsHelperService;
|
|
|
+ private final ICommonService commonService ;
|
|
|
|
|
|
/**
|
|
|
* 查询统计报表详情信息
|
|
@@ -70,12 +76,56 @@ public class CoopBatchReportDetailServiceImpl implements ICoopBatchReportDetailS
|
|
|
LambdaQueryWrapper<CoopBatchReportDetail> lqw = buildQueryWrapper(bo);
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public CoopBatchReportResultVo queryReport(QueryStaBo bo) {
|
|
|
+ CoopBatchReportVo coopBatchReportVo = queryByStaParam(bo);
|
|
|
+ if(coopBatchReportVo == null){
|
|
|
+ throw new ServiceException("未查询到数据");
|
|
|
+ }
|
|
|
+ QueryStaScopeParam param = commonService.convertQueryStaToParam(bo);
|
|
|
+ StatisticTmpResultDto totalTmp = new StatisticTmpResultDto();
|
|
|
+ List<CoopBatchReportDetailResult> views =
|
|
|
+ queryListViewByReportId(coopBatchReportVo.getId(), param,totalTmp);
|
|
|
+ statisticsHelperService.calcCommon(totalTmp);
|
|
|
+ CoopBatchReportResultVo vo= new CoopBatchReportResultVo();
|
|
|
+ vo.setData(views);
|
|
|
+ coopBatchReportVo.setLastSave1(totalTmp.getLastSave1());
|
|
|
+ coopBatchReportVo.setLastSave0(totalTmp.getLastSave0());
|
|
|
+ coopBatchReportVo.setSave1(totalTmp.getSave1());
|
|
|
+ coopBatchReportVo.setSave0(totalTmp.getSave0());
|
|
|
+ coopBatchReportVo.setCull1(totalTmp.getCull1());
|
|
|
+ coopBatchReportVo.setCull0(totalTmp.getCull0());
|
|
|
+ coopBatchReportVo.setIn1(totalTmp.getIn1());
|
|
|
+ coopBatchReportVo.setIn0(totalTmp.getIn0());
|
|
|
+ coopBatchReportVo.setOut1(totalTmp.getOut1());
|
|
|
+ coopBatchReportVo.setOut0(totalTmp.getOut0());
|
|
|
+ coopBatchReportVo.setQualifiedEgg(totalTmp.getQualifiedEgg());
|
|
|
+ coopBatchReportVo.setDeformedEgg(totalTmp.getDeformedEgg());
|
|
|
+ coopBatchReportVo.setBreakEgg(totalTmp.getBreakEgg());
|
|
|
+ coopBatchReportVo.setEggProductionRate(totalTmp.getEggProductionRate());
|
|
|
+ coopBatchReportVo.setEggPassRate(totalTmp.getEggPassRate());
|
|
|
+ coopBatchReportVo.setChicken0(totalTmp.getChicken0());
|
|
|
+ coopBatchReportVo.setChicken1(totalTmp.getChicken1());
|
|
|
+ coopBatchReportVo.setLifeRate(totalTmp.getLifeRate());
|
|
|
+ coopBatchReportVo.setCullRate(totalTmp.getCullRate());
|
|
|
+
|
|
|
+ vo.setTotalData(coopBatchReportVo);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private CoopBatchReportVo queryByStaParam(QueryStaBo bo) {
|
|
|
+ LambdaQueryWrapper<CoopBatchReport> lqw = commonService.getQueryWrapper(bo);
|
|
|
+ CoopBatchReport coopBatchReport = coopBatchReportMapper.selectOne(lqw);
|
|
|
+ if(coopBatchReport == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return MapstructUtils.convert(coopBatchReport, CoopBatchReportVo.class);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询统计报表详情信息列表
|
|
|
*/
|
|
|
- @Override
|
|
|
- public List<CoopBatchReportDetailResult> queryListViewByReportId(String reportId, QueryStaScopeParam param) {
|
|
|
+ private List<CoopBatchReportDetailResult> queryListViewByReportId(String reportId, QueryStaScopeParam param,StatisticTmpResultDto total) {
|
|
|
List<CoopBatchReportDetailView> coopBatchReportDetailViews =
|
|
|
baseMapper.selectCoopBatchReportDetail(reportId, param.getCoopType());
|
|
|
Date endDate = DateUtils.parseDate(param.getEndDate());
|
|
@@ -87,33 +137,58 @@ public class CoopBatchReportDetailServiceImpl implements ICoopBatchReportDetailS
|
|
|
// 根据coopId分组并统计各项数据总和
|
|
|
Map<Long, List<CoopBatchReportDetailView>> groupedByCoopId = listResult.stream()
|
|
|
.collect(Collectors.groupingBy(CoopBatchReportDetailView::getCoopId));
|
|
|
- StatisticTmpResultDto totalResult = new StatisticTmpResultDto();
|
|
|
+
|
|
|
groupedByCoopId.forEach((coopId, view) -> {
|
|
|
CoopBatchReportDetailResult result = new CoopBatchReportDetailResult();
|
|
|
result.setCoopId(coopId);
|
|
|
result.setCoopName(view.get(0).getCoopName());
|
|
|
result.setData(view);
|
|
|
- view.forEach((k)->{
|
|
|
- totalResult.setLastSave0(totalResult.getLastSave0()+k.getLastSave0());
|
|
|
- totalResult.setLastSave1(totalResult.getLastSave1()+k.getLastSave1());
|
|
|
- totalResult.setSave0(totalResult.getSave0()+k.getSave0());
|
|
|
- totalResult.setSave1(totalResult.getSave1()+k.getSave1());
|
|
|
- totalResult.setCull0(totalResult.getCull0()+k.getCull0());
|
|
|
- totalResult.setCull1(totalResult.getCull1()+k.getCull1());
|
|
|
- totalResult.setIn0(totalResult.getIn0()+k.getIn0());
|
|
|
- totalResult.setIn1(totalResult.getIn1()+k.getIn1());
|
|
|
- totalResult.setOut0(totalResult.getOut0()+k.getOut0());
|
|
|
- totalResult.setOut1(totalResult.getOut1()+k.getOut1());
|
|
|
- totalResult.setChicken0(totalResult.getChicken0()+k.getChicken0());
|
|
|
- totalResult.setChicken1(totalResult.getChicken1()+k.getChicken1());
|
|
|
- });
|
|
|
- statisticsHelperService.calcCommon(totalResult);
|
|
|
- result.setTotal(totalResult.convertDetailView());
|
|
|
+ result.setTotal(convertDetailView(view,total));
|
|
|
resultList.add(result);
|
|
|
});
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
+ private CoopBatchReportDetailView convertDetailView(List<CoopBatchReportDetailView> views,StatisticTmpResultDto total) {
|
|
|
+ StatisticTmpResultDto totalResult = new StatisticTmpResultDto();
|
|
|
+ views.forEach((k)->{
|
|
|
+
|
|
|
+ totalResult.setLastSave0(totalResult.getLastSave0()+k.getLastSave0());
|
|
|
+ totalResult.setLastSave1(totalResult.getLastSave1()+k.getLastSave1());
|
|
|
+ totalResult.setSave0(totalResult.getSave0()+k.getSave0());
|
|
|
+ totalResult.setSave1(totalResult.getSave1()+k.getSave1());
|
|
|
+ totalResult.setCull0(totalResult.getCull0()+k.getCull0());
|
|
|
+ totalResult.setCull1(totalResult.getCull1()+k.getCull1());
|
|
|
+ totalResult.setIn0(totalResult.getIn0()+k.getIn0());
|
|
|
+ totalResult.setIn1(totalResult.getIn1()+k.getIn1());
|
|
|
+ totalResult.setOut0(totalResult.getOut0()+k.getOut0());
|
|
|
+ totalResult.setOut1(totalResult.getOut1()+k.getOut1());
|
|
|
+ totalResult.setChicken0(totalResult.getChicken0()+k.getChicken0());
|
|
|
+ totalResult.setChicken1(totalResult.getChicken1()+k.getChicken1());
|
|
|
+ totalResult.setQualifiedEgg(totalResult.getQualifiedEgg()+k.getQualifiedEgg());
|
|
|
+ totalResult.setDeformedEgg(totalResult.getDeformedEgg()+k.getDeformedEgg());
|
|
|
+ totalResult.setBreakEgg(totalResult.getBreakEgg()+k.getBreakEgg());
|
|
|
+
|
|
|
+ total.setLastSave0(total.getLastSave0()+k.getLastSave0());
|
|
|
+ total.setLastSave1(total.getLastSave1()+k.getLastSave1());
|
|
|
+ total.setSave0(total.getSave0()+k.getSave0());
|
|
|
+ total.setSave1(total.getSave1()+k.getSave1());
|
|
|
+ total.setCull0(total.getCull0()+k.getCull0());
|
|
|
+ total.setCull1(total.getCull1()+k.getCull1());
|
|
|
+ total.setIn0(total.getIn0()+k.getIn0());
|
|
|
+ total.setIn1(total.getIn1()+k.getIn1());
|
|
|
+ total.setOut0(total.getOut0()+k.getOut0());
|
|
|
+ total.setOut1(total.getOut1()+k.getOut1());
|
|
|
+ total.setChicken0(total.getChicken0()+k.getChicken0());
|
|
|
+ total.setChicken1(total.getChicken1()+k.getChicken1());
|
|
|
+ total.setQualifiedEgg(total.getQualifiedEgg()+k.getQualifiedEgg());
|
|
|
+ total.setDeformedEgg(total.getDeformedEgg()+k.getDeformedEgg());
|
|
|
+ total.setBreakEgg(total.getBreakEgg()+k.getBreakEgg());
|
|
|
+ });
|
|
|
+ statisticsHelperService.calcCommon(totalResult);
|
|
|
+ return totalResult.convertDetailView();
|
|
|
+ }
|
|
|
+
|
|
|
private LambdaQueryWrapper<CoopBatchReportDetail> buildQueryWrapper(CoopBatchReportDetailBo bo) {
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
LambdaQueryWrapper<CoopBatchReportDetail> lqw = Wrappers.lambdaQuery();
|