|
@@ -1,7 +1,9 @@
|
|
|
package com.rtrh.projects.web.controller.subject.api;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.rtrh.common.util.StringUtil;
|
|
@@ -9,14 +11,20 @@ import com.rtrh.projects.modules.projects.dao.SubCompletedPicDao;
|
|
|
import com.rtrh.projects.modules.projects.dao.SubSourceDao;
|
|
|
import com.rtrh.projects.modules.projects.dto.SubFixCbSearch;
|
|
|
import com.rtrh.projects.modules.projects.po.SubCompletedPic;
|
|
|
+import com.rtrh.projects.modules.projects.po.SubIndu;
|
|
|
import com.rtrh.projects.modules.projects.po.SubSource;
|
|
|
import com.rtrh.projects.modules.projects.vo.StatisticsVO;
|
|
|
import com.rtrh.projects.modules.projects.vo.SubFixCbVo;
|
|
|
import com.rtrh.projects.modules.projects.vo.SubSourceVO;
|
|
|
import com.rtrh.projects.modules.system.enums.SysTableKind;
|
|
|
import com.rtrh.projects.modules.system.po.TSystable;
|
|
|
+import com.rtrh.projects.modules.system.service.ISubInduService;
|
|
|
import com.rtrh.projects.modules.system.service.TSysTableService;
|
|
|
+import com.rtrh.projects.vo.projects.SubFixBeginVo;
|
|
|
+import com.rtrh.projects.vo.projects.SubFixGetBeginRateVo;
|
|
|
+import com.rtrh.projects.vo.projects.SubFixTotalVo;
|
|
|
import com.rtrh.projects.web.log.Log;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -54,6 +62,9 @@ public class SubInfoQueryApiController extends BaseController {
|
|
|
@Autowired
|
|
|
private TSysTableService tSysTableService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISubInduService subInduService;
|
|
|
+
|
|
|
/**
|
|
|
* 项目台账
|
|
|
*
|
|
@@ -583,6 +594,214 @@ public class SubInfoQueryApiController extends BaseController {
|
|
|
return message;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 重点项目库获取行业分类,项目总数等数据
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("subFixGetBeginRate")
|
|
|
+ public Message subFixGetBeginRate(@RequestBody SubInfoQueryTzVO queryVO) {
|
|
|
+ Message message = new Message();
|
|
|
+
|
|
|
+ //查询出行业分类
|
|
|
+ List<SubIndu> subInduList = subInduService.queryTreeALl();
|
|
|
+ //保存行业code
|
|
|
+ List<String> indusKinds = new ArrayList<>();
|
|
|
+ //判断搜索条件中是否有行业分类条件
|
|
|
+ if (StringUtils.isNotBlank(queryVO.getIndusKinds())) {
|
|
|
+ //在subInduList中找到code=queryVO.getIndusKinds()的数据
|
|
|
+ SubIndu subIndu = subInduList.stream().filter(item -> item.getCode().equals(queryVO.getIndusKinds())).findFirst().orElse(null);
|
|
|
+
|
|
|
+ if (subIndu != null){
|
|
|
+ //判断这个行业是不是上级行业
|
|
|
+ if (StringUtils.isBlank(subIndu.getLastId())){
|
|
|
+ // 这个行业是上级行业,需要找到所有下级行业的code
|
|
|
+ indusKinds = subInduList.stream().filter(item -> item.getLastId().equals(subIndu.getId())).map(SubIndu::getCode).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ indusKinds.add(subIndu.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取项目地点
|
|
|
+ List<TSystable> jsddList = Optional.ofNullable(
|
|
|
+ tSysTableService.getByKind(SysTableKind.JSDD)
|
|
|
+ ).orElse(Collections.emptyList());
|
|
|
+ //将项目地点转换为map,key=code,value=title
|
|
|
+ Map<String, String> jsddMap = jsddList.stream().collect(Collectors.toMap(TSystable::getCode, TSystable::getTitle));
|
|
|
+
|
|
|
+ //查询出该库符合条件的数据
|
|
|
+ List<SubFixGetBeginRateVo> subFixGetBeginRateVoList = subInfoQueryService.subFixGetBeginRate(queryVO,indusKinds);
|
|
|
+
|
|
|
+ //最终需要返回的数据
|
|
|
+ SubFixBeginVo subFixBeginVo = new SubFixBeginVo();
|
|
|
+ if (subFixGetBeginRateVoList != null){
|
|
|
+
|
|
|
+ int aType = 0; //a类项目
|
|
|
+ int bType = 0; //b类项目
|
|
|
+ int cType = 0; //c类项目
|
|
|
+ int dType = 0; //d类项目
|
|
|
+ int kgTotal = 0; //开工数量
|
|
|
+ int xjNumber = 0; //新建数量
|
|
|
+ int zjNumber = 0; //在建数量
|
|
|
+ int tcNumber = 0; //投产数量
|
|
|
+ int rgNumber = 0; //入轨数量
|
|
|
+
|
|
|
+ for (SubFixGetBeginRateVo subFixGetBeginRateVo : subFixGetBeginRateVoList) {
|
|
|
+ if (StringUtils.isNotBlank(subFixGetBeginRateVo.getAbc())){
|
|
|
+ if (subFixGetBeginRateVo.getAbc().equals("a")){
|
|
|
+ aType++;
|
|
|
+ }else if (subFixGetBeginRateVo.getAbc().equals("b")){
|
|
|
+ bType++;
|
|
|
+ }else if (subFixGetBeginRateVo.getAbc().equals("c")){
|
|
|
+ cType++;
|
|
|
+ }else if (subFixGetBeginRateVo.getAbc().equals("d")){
|
|
|
+ dType++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(subFixGetBeginRateVo.getStatus())){
|
|
|
+ if (subFixGetBeginRateVo.getStatus().equals("3") || subFixGetBeginRateVo.getStatus().equals("9")){
|
|
|
+ kgTotal++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //2=新建
|
|
|
+ if (subFixGetBeginRateVo.getStatus().equals("2")){
|
|
|
+ xjNumber++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //3=在建
|
|
|
+ if (subFixGetBeginRateVo.getStatus().equals("3")){
|
|
|
+ zjNumber++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //9=投产
|
|
|
+ if (subFixGetBeginRateVo.getStatus().equals("9")){
|
|
|
+ tcNumber++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (subFixGetBeginRateVo.getIsRg() != null && subFixGetBeginRateVo.getIsRg() == 1){
|
|
|
+ rgNumber++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(subFixGetBeginRateVo.getSubjectId())){
|
|
|
+ subFixGetBeginRateVo.setSubjectId("未知地点");
|
|
|
+ }else {
|
|
|
+ if (StringUtils.isNotBlank(jsddMap.get(subFixGetBeginRateVo.getSubjectId()))){
|
|
|
+ subFixGetBeginRateVo.setSubjectId(jsddMap.get(subFixGetBeginRateVo.getSubjectId()));
|
|
|
+ }else {
|
|
|
+ subFixGetBeginRateVo.setSubjectId("未知地点");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(subFixGetBeginRateVo.getIndusKind())){
|
|
|
+ subFixGetBeginRateVo.setIndusKind("未知行业");
|
|
|
+ }else {
|
|
|
+ //找到对应的行业数据
|
|
|
+ SubIndu subIndu = subInduList.stream().filter(item -> item.getCode().equals(subFixGetBeginRateVo.getIndusKind())).findFirst().orElse(null);
|
|
|
+ if (subIndu != null){
|
|
|
+ if (StringUtils.isBlank(subIndu.getParentTitle())){
|
|
|
+ subFixGetBeginRateVo.setIndusKind(subIndu.getTitle());
|
|
|
+ }else {
|
|
|
+ subFixGetBeginRateVo.setIndusKind(subIndu.getParentTitle());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ subFixGetBeginRateVo.setIndusKind("未知行业");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ subFixBeginVo.setTotal(subFixGetBeginRateVoList.size());
|
|
|
+ subFixBeginVo.setATotal(aType);
|
|
|
+ subFixBeginVo.setBTotal(bType);
|
|
|
+ subFixBeginVo.setCTotal(cType);
|
|
|
+ subFixBeginVo.setDTotal(dType);
|
|
|
+ subFixBeginVo.setKgTotal(kgTotal);
|
|
|
+ subFixBeginVo.setRgTotal(rgNumber);
|
|
|
+
|
|
|
+ int number = xjNumber+zjNumber+tcNumber;
|
|
|
+ if (number != 0) {
|
|
|
+ subFixBeginVo.setZhl(new BigDecimal(xjNumber+zjNumber).divide(new BigDecimal(number), 2, RoundingMode.HALF_UP));
|
|
|
+ subFixBeginVo.setKfgl(subFixBeginVo.getZhl());
|
|
|
+ subFixBeginVo.setRgl(new BigDecimal(rgNumber).divide(new BigDecimal(number), 2, RoundingMode.HALF_UP));
|
|
|
+ subFixBeginVo.setTcl(new BigDecimal(tcNumber).divide(new BigDecimal(number), 2, RoundingMode.HALF_UP));
|
|
|
+ }else{
|
|
|
+ subFixBeginVo.setZhl(new BigDecimal(0));
|
|
|
+ subFixBeginVo.setKfgl(new BigDecimal(0));
|
|
|
+ subFixBeginVo.setRgl(new BigDecimal(0));
|
|
|
+ subFixBeginVo.setTcl(new BigDecimal(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ //对subFixGetBeginRateVoList按照项目地点进行分组
|
|
|
+ Map<String, List<SubFixGetBeginRateVo>> subjectIdDataMap = subFixGetBeginRateVoList.stream().collect(Collectors.groupingBy(SubFixGetBeginRateVo::getSubjectId));
|
|
|
+ List<SubFixTotalVo> subjectIdList = new ArrayList<>();
|
|
|
+ //遍历subFixGetBeginRateVoMap,将key和value的size放入subjectIdList
|
|
|
+ subjectIdDataMap.forEach((key, value) -> {
|
|
|
+ SubFixTotalVo subFixTotalVo = new SubFixTotalVo();
|
|
|
+ subFixTotalVo.setCode(key);
|
|
|
+ subFixTotalVo.setTitle(key);
|
|
|
+ subFixTotalVo.setTotal(value.size());
|
|
|
+ subjectIdList.add(subFixTotalVo);
|
|
|
+ });
|
|
|
+
|
|
|
+ //遍历subjectIdList,将对应code设置为对应的地点名称的code
|
|
|
+ subjectIdList.forEach(item -> {
|
|
|
+ //找到jsddList中与title匹配的title数据
|
|
|
+ Optional<TSystable> first = jsddList.stream().filter(item1 -> item1.getTitle().equals(item.getTitle())).findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ item.setCode(first.get().getCode());
|
|
|
+ }else {
|
|
|
+ item.setCode("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ //对subFixGetBeginRateVoList按照行业进行分组
|
|
|
+ Map<String, List<SubFixGetBeginRateVo>> industKindDataMap = subFixGetBeginRateVoList.stream().collect(Collectors.groupingBy(SubFixGetBeginRateVo::getIndusKind));
|
|
|
+ List<SubFixTotalVo> indusKindList = new ArrayList<>();
|
|
|
+ //遍历subFixGetBeginRateVoMap,将key和value的size放入industKindMap
|
|
|
+ industKindDataMap.forEach((key, value) -> {
|
|
|
+ SubFixTotalVo subFixTotalVo = new SubFixTotalVo();
|
|
|
+ subFixTotalVo.setCode(key);
|
|
|
+ subFixTotalVo.setTitle(key);
|
|
|
+ subFixTotalVo.setTotal(value.size());
|
|
|
+ indusKindList.add(subFixTotalVo);
|
|
|
+ });
|
|
|
+
|
|
|
+ //遍历indusKindList,将对应code设置为对应的地点名称的code
|
|
|
+ indusKindList.forEach(item -> {
|
|
|
+ //找到jsddList中与title匹配的title数据
|
|
|
+ Optional<SubIndu> first = subInduList.stream().filter(item1 -> item1.getTitle().equals(item.getCode())).findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ item.setCode(first.get().getCode());
|
|
|
+ }else {
|
|
|
+ item.setCode("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ subFixBeginVo.setSubjectIdList(subjectIdList);
|
|
|
+ subFixBeginVo.setIndusKindList(indusKindList);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ subFixBeginVo.setTotal(0);
|
|
|
+ subFixBeginVo.setATotal(0);
|
|
|
+ subFixBeginVo.setBTotal(0);
|
|
|
+ subFixBeginVo.setCTotal(0);
|
|
|
+ subFixBeginVo.setDTotal(0);
|
|
|
+ subFixBeginVo.setKgTotal(0);
|
|
|
+ subFixBeginVo.setZhl(new BigDecimal(0));
|
|
|
+ subFixBeginVo.setKfgl(new BigDecimal(0));
|
|
|
+ subFixBeginVo.setRgl(new BigDecimal(0));
|
|
|
+ subFixBeginVo.setTcl(new BigDecimal(0));
|
|
|
+ subFixBeginVo.setSubjectIdList(new ArrayList<>());
|
|
|
+ subFixBeginVo.setIndusKindList(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ message.setData(subFixBeginVo);
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 开工率
|
|
|
*
|