guoshilong
2024-03-22 4ff6d97866376703a4349df9566a062a500444ea
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbResGeneralInvestigationServiceImpl.java
@@ -8,6 +8,7 @@
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsBar;
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsParams;
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsPie;
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsTable;
import cn.gistack.sm.sjztmd.util.CalculateUtils;
import cn.gistack.sm.sjztmd.vo.TbResGeneralInvestigationParam;
import com.baomidou.dynamic.datasource.annotation.DS;
@@ -44,8 +45,8 @@
   public R saveOrUpdateBy(TbResGeneralInvestigation entity) {
      QueryWrapper queryWrapper = new QueryWrapper();
      queryWrapper.eq("\"res_guid\"",entity.getResGuid());
      queryWrapper.eq("\"tb_year\"",entity.getTbYear());
      queryWrapper.eq("\"res_guid\"", entity.getResGuid());
      queryWrapper.eq("\"tb_year\"", entity.getTbYear());
//      queryWrapper.eq("\"tb_quarter\"",entity.getTbQuarter());
      TbResGeneralInvestigationState state = tbResGeneralInvestigationStateService.getOne(queryWrapper);
      if (null == state) {
@@ -64,7 +65,7 @@
      // 是否普查完成 1是 0否
      if (entity.getCheckState() != 0) {
         state.setCheckState(entity.getIsInvCom());
      }else{
      } else {
         state.setCheckState(0);
      }
@@ -82,8 +83,8 @@
      //查询该水库本年度是否有填报状态记录
      QueryWrapper queryWrapper = new QueryWrapper();
      queryWrapper.eq("\"res_guid\"",entity.getResGuid());
      queryWrapper.eq("\"tb_year\"",entity.getTbYear());
      queryWrapper.eq("\"res_guid\"", entity.getResGuid());
      queryWrapper.eq("\"tb_year\"", entity.getTbYear());
      TbResGeneralInvestigationState state = tbResGeneralInvestigationStateService.getOne(queryWrapper);
      if (null == state) {
         //无填报状态记录则新建
@@ -116,11 +117,11 @@
         //id清空方便批量新增
//         tbResGeneralInvestigation.setGuid("");
         if (tbResGeneralInvestigation.getCreateTime() == null){
         if (tbResGeneralInvestigation.getCreateTime() == null) {
            tbResGeneralInvestigation.setCreateTime(DateUtil.now());
         }
         if (tbResGeneralInvestigation.getCreateUser() == null){
         if (tbResGeneralInvestigation.getCreateUser() == null) {
            tbResGeneralInvestigation.setCreateUser(AuthUtil.getUserId().toString());
         }
@@ -136,56 +137,21 @@
   }
   @Override
   public List<StatisticsBar> statisticsBar(StatisticsParams statisticsParams) {
      String adCode = statisticsParams.getAdCode();
      //默认省
      String adGrad = "1";
      List<StatisticsBar> list = baseMapper.getStatisticsBar(statisticsParams);
      return list;
   }
      //若行政区划不为空
      if (StringUtil.isNotBlank(adCode)){
         if (adCode.substring(0,4).indexOf("00") > -1) {
            //前四位包含00说明是湖北省      4200/00000000
            adGrad = "1";
         } else if (adCode.substring(0,6).indexOf("00") > -1) {
            //前六位包含00说明是市级    420100/000000
            adGrad = "2";
         }else if (adCode.substring(0,8).indexOf("00") > -1){
            //前8位包含00 说明是区级     42011700/0000
            adGrad = "3";
         }
      }
      List<StatisticsBar> list = new ArrayList<>();
   @Override
   public List<StatisticsTable> statisticsTable(StatisticsParams statisticsParams) {
      if (adGrad.equals("3")){
         //区级需要展示水库
         list =  baseMapper.getCountyStatisticsBar(statisticsParams);
      }else if (adGrad.equals("2")){
         list =  baseMapper.getCityStatisticsBar(statisticsParams);
      }else  if (adGrad.equals("1")){
         statisticsParams.setAdCode("420000000000");
         list =  baseMapper.getProvinceStatisticsBar(statisticsParams);
      }
      List<StatisticsTable> list = baseMapper.getStatisticsTable(statisticsParams);
//      if (!adGrad.equals("3")){
//         //计算有蚁率
//         DecimalFormat df = new DecimalFormat("0.00");
//         list.forEach(statisticsBar -> {
//
//            //有蚁率 = 危害座数/水库总数   =》dangerRate = dangerNum / resNum
//            if (statisticsBar.getResNum() == 0){
//               //如果水库数量为0,有蚁率为0
//               statisticsBar.setDangerRate("0");
//            }else{
//               String percent = CalculateUtils.calculatePercent(statisticsBar.getDangerNum(), statisticsBar.getResNum());
//
//               statisticsBar.setDangerRate(percent);
//
//            }
//         });
//      }
      list.forEach(statisticsTable -> {
         statisticsTable.setUnInvestigationResNum(statisticsTable.getResNum() - statisticsTable.getInvestigationResNum());
         statisticsTable.setUnInvestigationDykeNum(statisticsTable.getDykeNum() - statisticsTable.getInvestigationDykeNum());
      });
      return list;
   }