|  | @@ -2,6 +2,7 @@ package com.rtrh.projects.modules.projects.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.math.RoundingMode;
 | 
	
		
			
				|  |  | +import java.text.DecimalFormat;
 | 
	
		
			
				|  |  |  import java.text.ParseException;
 | 
	
		
			
				|  |  |  import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  |  import java.time.LocalDate;
 | 
	
	
		
			
				|  | @@ -10,6 +11,7 @@ import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.rtrh.core.vo.Message;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.modules.projects.dao.*;
 | 
	
		
			
				|  |  | +import com.rtrh.projects.modules.projects.dto.QTDTO;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.modules.projects.enums.*;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.modules.projects.mapper.SubInfoMapper;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.modules.projects.po.*;
 | 
	
	
		
			
				|  | @@ -21,6 +23,7 @@ import com.rtrh.projects.modules.system.dao.TSystableDao;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.modules.system.po.*;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.modules.system.service.ISubInduService;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.modules.utils.DateUtils;
 | 
	
		
			
				|  |  | +import com.rtrh.projects.outapi.vo.StaticsVO;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.util.TargetDataSource;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.vo.SubIdVO;
 | 
	
		
			
				|  |  |  import com.rtrh.projects.vo.subject.MoveDbParamVo;
 | 
	
	
		
			
				|  | @@ -690,6 +693,10 @@ public class SubInfoServiceImpl implements SubInfoService {
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Map<String, Object> getSubInfoById(String id, String queryYear) {
 | 
	
		
			
				|  |  |          Map<String, Object> data = subInfoDao.getSubInfoById(id, queryYear);
 | 
	
		
			
				|  |  | +        if(data == null){
 | 
	
		
			
				|  |  | +            System.out.println("查询到数据为空的ID:"+id);
 | 
	
		
			
				|  |  | +            return null;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          String kindName = "";
 | 
	
		
			
				|  |  |          if (data.get("kind") != null) {
 | 
	
		
			
				|  |  |              String[] kind = data.get("kind").toString().split(",");
 | 
	
	
		
			
				|  | @@ -5952,4 +5959,67 @@ public class SubInfoServiceImpl implements SubInfoService {
 | 
	
		
			
				|  |  |          return labelList;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public StaticsVO statics(QTDTO qtdto){
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        StaticsVO vo =new StaticsVO();
 | 
	
		
			
				|  |  | +        List<SubInfo> subInfoList = subInfoDao.findByIndusKindAndAddress(qtdto.getVarhy(), qtdto.getVarqx());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<SubInfo> cbList = subInfoList.stream().filter(f -> "1".equals(f.getStatus())).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        vo.setReserveCount(cbList.size());
 | 
	
		
			
				|  |  | +        Map<String,Object> map = new HashMap<>();
 | 
	
		
			
				|  |  | +        //计算正在谋划,正在洽谈,已签约,已备案,已核准
 | 
	
		
			
				|  |  | +        long planningCount = cbList.stream().filter(f -> "1".equals(f.getCbStatus())).count();
 | 
	
		
			
				|  |  | +        map.put("planning",planningCount);
 | 
	
		
			
				|  |  | +        vo.setPlanning(planningCount);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        long negotiateCount = cbList.stream().filter(f -> "2".equals(f.getCbStatus())).count();
 | 
	
		
			
				|  |  | +        map.put("negotiate",negotiateCount);
 | 
	
		
			
				|  |  | +        vo.setNegotiate(negotiateCount);
 | 
	
		
			
				|  |  | +        long signedCount = cbList.stream().filter(f -> "3".equals(f.getCbStatus())).count();
 | 
	
		
			
				|  |  | +        map.put("signed",signedCount);
 | 
	
		
			
				|  |  | +        vo.setSigned(signedCount);
 | 
	
		
			
				|  |  | +        long filedCount = cbList.stream().filter(f -> "4".equals(f.getCbStatus())).count();
 | 
	
		
			
				|  |  | +        map.put("filed",filedCount);
 | 
	
		
			
				|  |  | +        vo.setFiled(filedCount);
 | 
	
		
			
				|  |  | +        long newBuildCount = subInfoList.stream().filter(f -> "2".equals(f.getStatus())).count();
 | 
	
		
			
				|  |  | +        vo.setNewBuildCount(newBuildCount);
 | 
	
		
			
				|  |  | +        long buildingCount = subInfoList.stream().filter(f -> "3".equals(f.getStatus())).count();
 | 
	
		
			
				|  |  | +        vo.setBuildingCount(buildingCount);
 | 
	
		
			
				|  |  | +        long commissioningCount = subInfoList.stream().filter(f -> "9".equals(f.getStatus())).count();
 | 
	
		
			
				|  |  | +        vo.setCommissioningCount(commissioningCount);
 | 
	
		
			
				|  |  | +        long startWorkCount = buildingCount + commissioningCount;
 | 
	
		
			
				|  |  | +        map.put("startWorkCount",startWorkCount);
 | 
	
		
			
				|  |  | +        vo.setStartWorkCount(startWorkCount);
 | 
	
		
			
				|  |  | +        long stopWorkCount = subInfoList.stream().filter(f -> f.getBoolLockout() !=null && 1 == f.getBoolLockout()).count();
 | 
	
		
			
				|  |  | +        map.put("stopWorkCount",stopWorkCount);
 | 
	
		
			
				|  |  | +        vo.setStopWorkCount(stopWorkCount);
 | 
	
		
			
				|  |  | +        long all = newBuildCount + startWorkCount;
 | 
	
		
			
				|  |  | +        vo.setStartRate(calculateRate(startWorkCount,all));
 | 
	
		
			
				|  |  | +        long rgCount = subInfoList.stream().filter(f -> f.getIsRg()!=null && 1 == f.getIsRg()).count();
 | 
	
		
			
				|  |  | +        map.put("rgCount",rgCount);
 | 
	
		
			
				|  |  | +        vo.setRgCount(rgCount);
 | 
	
		
			
				|  |  | +        long unRgCount = all - rgCount;
 | 
	
		
			
				|  |  | +        map.put("unRgCount",unRgCount);
 | 
	
		
			
				|  |  | +        vo.setUnRgCount(unRgCount);
 | 
	
		
			
				|  |  | +        vo.setRgRate(calculateRate(rgCount,all));
 | 
	
		
			
				|  |  | +        vo.setCommissioningRare(calculateRate(commissioningCount,all));
 | 
	
		
			
				|  |  | +        return vo;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 计算比率并保留一位小数
 | 
	
		
			
				|  |  | +     * @param numerator 分子
 | 
	
		
			
				|  |  | +     * @param denominator 分母
 | 
	
		
			
				|  |  | +     * @return 计算后的比率
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private static BigDecimal calculateRate(long numerator, long denominator) {
 | 
	
		
			
				|  |  | +        if (denominator == 0) {
 | 
	
		
			
				|  |  | +            return BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        BigDecimal num = BigDecimal.valueOf(numerator);
 | 
	
		
			
				|  |  | +        BigDecimal den = BigDecimal.valueOf(denominator);
 | 
	
		
			
				|  |  | +        return num.divide(den, 3, RoundingMode.HALF_UP) // 先保留三位小数进行计算
 | 
	
		
			
				|  |  | +                .multiply(BigDecimal.valueOf(100))
 | 
	
		
			
				|  |  | +                .setScale(1, RoundingMode.HALF_UP); // 最终结果保留一位小数
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |