From f73dbcd6c21d28ab1e98840eee73c6d09bd0f929 Mon Sep 17 00:00:00 2001
From: ke <893754509@qq.com>
Date: Tue, 27 Aug 2024 17:31:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jtdev' into jtdev
---
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java | 204 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 159 insertions(+), 45 deletions(-)
diff --git a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
index be99689..400d558 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
+++ b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
@@ -18,11 +18,13 @@
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jetbrains.annotations.NotNull;
+import org.springblade.core.secure.utils.AuthUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StopWatch;
+import javax.security.auth.login.LoginContext;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
@@ -53,17 +55,31 @@
@Override
public IPage<SgProjectInfoDO> queryPageList(IPage<SgProjectInfoDO> page, ProjectSearchDTO searchDTO) {
+ List<String> sgCodeS = getSgCodeByUser();
+ searchDTO.setSgCodeS(sgCodeS);
List<SgProjectInfoDO> sgProjectInfoDOS = baseMapper.queryPageList(page,searchDTO);
- /*List<SgProjectInfoDO> projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject(searchDTO));
+ List<SgProjectInfoDO> projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject(searchDTO));
if (CollectionUtils.isNotEmpty(projectProgress)){
Map<Long, String> progressMap = projectProgress.stream().filter(s->s.getProjectProgress()!=null).collect(Collectors.toMap(SgProjectInfoDO::getId, SgProjectInfoDO::getProjectProgress));
sgProjectInfoDOS.forEach(s->{
s.setProjectProgress(progressMap.get(s.getId()));
});
- }*/
+ }
return page.setRecords(sgProjectInfoDOS);
}
+ /**
+ * 获取当前用户的工程编码
+ */
+ public List<String> getSgCodeByUser(){
+ Long userId = AuthUtil.getUserId();
+ String sgCode = sgProjectInfoMapper.getSgCodeByUser(userId.toString());
+ if (StringUtils.isNotBlank(sgCode)){
+ List<String> list = List.of(sgCode.split(","));
+ return list;
+ }
+ return null;
+ }
/**
* 获取项目及项目下设备及设备下工序进度
* @param searchDTO
@@ -103,54 +119,72 @@
}
SgProjectInfoVO sgProjectInfoVO = value.get(0);
SgProjectInfoDO sgProjectInfoDO = SgProjectInfoDO.builder().id(porId).lonLat(sgProjectInfoVO.getLonLat()).status(sgProjectInfoVO.getProjectStatus()).projectName(sgProjectInfoVO.getProjectName()).build();
- List<SgTypeVO> sgGxDOS = new ArrayList<>();
- //类型分组
- Map<String, List<SgProjectInfoVO>> GxMap = value.stream().filter(s->s.getDeviceType()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getDeviceType));
- for (Map.Entry<String, List<SgProjectInfoVO>> ty : GxMap.entrySet()) {
- String type = ty.getKey();
- List<SgProjectInfoVO> gxList = ty.getValue();
- if (CollectionUtils.isEmpty(gxList)){
+ //父类型分组
+ List<PtypeVO> pTypes = new ArrayList();
+ Map<String, List<SgProjectInfoVO>> pTypeMap = value.stream().filter(s->s.getPtype()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getPtype));
+ for (Map.Entry<String, List<SgProjectInfoVO>> pty : pTypeMap.entrySet()) {
+ List<SgProjectInfoVO> ptyValue = pty.getValue();
+ if (CollectionUtils.isEmpty(ptyValue)){
continue;
}
- SgTypeVO typeVO = SgTypeVO.builder().typeName(gxList.get(0).getTypeName()).build();
- List<SgDeviceDO> deviceDOS = new ArrayList<>();
- //设备分组
- Map<Long, List<SgProjectInfoVO>> dMap = gxList.stream().collect(Collectors.groupingBy(SgProjectInfoVO::getDId));
- for (Map.Entry<Long, List<SgProjectInfoVO>> device : dMap.entrySet()) {
- Long dId = device.getKey();
- List<SgProjectInfoVO> deList = device.getValue();
- SgDeviceDO sgDeviceDO = new SgDeviceDO();
- sgDeviceDO.setId(dId);
- sgDeviceDO.setDeviceName(deList.get(0).getDeviceName());
- List<SgGxStepDO> stepDOS = deList.stream().filter(s->s.getReportStatus()==null || s.getReportStatus()!=4).map(s -> SgGxStepDO.builder().id(s.getStepId()).gxStepNum(s.getGxStepNum()).gxStepName(s.getGxStepName()).deviceId(s.getDId()).approvalStatus(s.getReportStatus()).build()).collect(Collectors.toList());
- List<SgGxStepDO> stepOver = stepDOS.stream().filter(s -> s.getApprovalStatus() != null && s.getApprovalStatus() == 2).collect(Collectors.toList());
- BigDecimal stepSize = BigDecimal.valueOf(stepDOS.size());
- BigDecimal stepOverSize = BigDecimal.ZERO;
- if (!stepOver.isEmpty()){
- stepOverSize = BigDecimal.valueOf(stepOver.size());
+ PtypeVO ptypeVO = PtypeVO.builder().pTypeName(ptyValue.get(0).getPtypeName()).build();
+ List<SgTypeVO> sgGxDOS = new ArrayList<>();
+ //类型分组
+ Map<String, List<SgProjectInfoVO>> GxMap = ptyValue.stream().filter(s->s.getDeviceType()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getDeviceType));
+ for (Map.Entry<String, List<SgProjectInfoVO>> ty : GxMap.entrySet()) {
+ String type = ty.getKey();
+ List<SgProjectInfoVO> gxList = ty.getValue();
+ if (CollectionUtils.isEmpty(gxList)){
+ continue;
}
- BigDecimal divide = stepOverSize.divide(stepSize, 2, RoundingMode.HALF_UP);
- sgDeviceDO.setStatus(divide.compareTo(new BigDecimal(1)) == 0?2:deList.get(0).getDeviceStatus());
- sgDeviceDO.setProgress(divide.toString());
- sgDeviceDO.setDeviceProgress(getBigDecimalPercent(divide));
- sgDeviceDO.setStepDOList(stepDOS);
- deviceDOS.add(sgDeviceDO);
- allDevice.add(sgDeviceDO);
+ SgTypeVO typeVO = SgTypeVO.builder().typeName(gxList.get(0).getTypeName()).build();
+ List<SgDeviceDO> deviceDOS = new ArrayList<>();
+ //设备分组
+ Map<Long, List<SgProjectInfoVO>> dMap = gxList.stream().collect(Collectors.groupingBy(SgProjectInfoVO::getDId));
+ for (Map.Entry<Long, List<SgProjectInfoVO>> device : dMap.entrySet()) {
+ Long dId = device.getKey();
+ List<SgProjectInfoVO> deList = device.getValue();
+ SgDeviceDO sgDeviceDO = new SgDeviceDO();
+ sgDeviceDO.setId(dId);
+ sgDeviceDO.setDeviceName(deList.get(0).getDeviceName());
+ List<SgGxStepDO> stepDOS = deList.stream().filter(s -> s.getReportStatus() == null || (s.getReportStatus() != 4 && !(s.getReportStatus() == 3 && s.getResubmit() != 0))).map(s -> SgGxStepDO.builder().id(s.getStepId()).gxStepNum(s.getGxStepNum()).gxStepName(s.getGxStepName()).deviceId(s.getDId()).approvalStatus(s.getReportStatus()).build()).collect(Collectors.toList());
+ List<SgGxStepDO> stepOver = stepDOS.stream().filter(s -> s.getApprovalStatus() != null && s.getApprovalStatus() == 2).collect(Collectors.toList());
+ BigDecimal stepSize = BigDecimal.valueOf(stepDOS.size());
+ BigDecimal stepOverSize = BigDecimal.ZERO;
+ if (!stepOver.isEmpty()){
+ stepOverSize = BigDecimal.valueOf(stepOver.size());
+ }
+ BigDecimal divide = stepOverSize.divide(stepSize, 2, RoundingMode.HALF_UP);
+ sgDeviceDO.setStatus(divide.compareTo(new BigDecimal(1)) == 0?2:deList.get(0).getDeviceStatus());
+ sgDeviceDO.setProgress(divide.toString());
+ sgDeviceDO.setDeviceProgress(getBigDecimalPercent(divide));
+ sgDeviceDO.setStepDOList(stepDOS);
+ deviceDOS.add(sgDeviceDO);
+ allDevice.add(sgDeviceDO);
+ }
+ BigDecimal deviceSize = BigDecimal.valueOf(deviceDOS.size());
+ double sum = deviceDOS.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum();
+ BigDecimal deviceOver = BigDecimal.valueOf(sum);
+ BigDecimal divideDevice = deviceOver.divide(deviceSize, 2, RoundingMode.HALF_UP);
+ typeVO.setDeviceDOS(deviceDOS);
+ typeVO.setTypeProgress(getBigDecimalPercent(divideDevice));
+ typeVO.setProgress(divideDevice.toString());
+ sgGxDOS.add(typeVO);
}
- BigDecimal deviceSize = BigDecimal.valueOf(deviceDOS.size());
- double sum = deviceDOS.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum();
- BigDecimal deviceOver = BigDecimal.valueOf(sum);
- BigDecimal divideDevice = deviceOver.divide(deviceSize, 2, RoundingMode.HALF_UP);
- typeVO.setDeviceDOS(deviceDOS);
- typeVO.setTypeProgress(getBigDecimalPercent(divideDevice));
- sgGxDOS.add(typeVO);
+ BigDecimal sgGxSize = BigDecimal.valueOf(sgGxDOS.size());
+ double sum = sgGxDOS.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum();
+ BigDecimal sgGxOver = BigDecimal.valueOf(sum);
+ BigDecimal divideSgGx = sgGxOver.divide(sgGxSize, 2, RoundingMode.HALF_UP);
+ ptypeVO.setPTypeProgress(getBigDecimalPercent(divideSgGx));
+ ptypeVO.setSgTypeVOS(sgGxDOS);
+ pTypes.add(ptypeVO);
}
BigDecimal allDeviceSize = BigDecimal.valueOf(allDevice.size());
if (!allDeviceSize.equals(BigDecimal.ZERO)){
double sum = allDevice.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum();
BigDecimal allDeviceOver = BigDecimal.valueOf(sum);
BigDecimal allDivideDevice = allDeviceOver.divide(allDeviceSize, 2, RoundingMode.HALF_UP);
- sgProjectInfoDO.setSgGxDOS(sgGxDOS);
+ sgProjectInfoDO.setPtypeVOS(pTypes);
sgProjectInfoDO.setProjectProgress( getBigDecimalPercent(allDivideDevice));
sgProjectInfoDO.setProjectProgressNum(allDivideDevice);
}
@@ -251,17 +285,90 @@
//片区
if (ywxtAdDetail == null) {
sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsZero(code);
+ getDeviceTypes(sgStatisProVOS);
// String getname = sgProjectInfoMapper.getname(code);
String getname = code;
updateProjectProgress(sgStatisProVOS, code, getname, "2");
} else if (ywxtAdDetail.getAdGrad().equals("1")) {//默认
sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsOne(code);
+ getDeviceTypes(sgStatisProVOS);
updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getPAdCode(), ywxtAdDetail.getPAdName(), "0");
} else {//区县
sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsList(code);
+ getDeviceTypes(sgStatisProVOS);
updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getAdCode(), ywxtAdDetail.getAdName(), "3");
}
return sgStatisProVOS;
+ }
+
+ /**
+ * 统计设备类型开工率
+ * @param sgStatisProVOS
+ */
+ private void getDeviceTypes(List<SgStatisProVO> sgStatisProVOS) {
+ if (CollectionUtils.isNotEmpty(sgStatisProVOS)){
+ for (SgStatisProVO vo : sgStatisProVOS) {
+ String proIds = vo.getProIds();
+ if (StringUtils.isNotBlank(proIds)){
+ List<SgStatisDeviceVO> deviceVOS = sgProjectInfoMapper.getDeviceTypes("("+proIds+")");
+ if(CollectionUtils.isNotEmpty(deviceVOS)){
+ Map<String, SgStatisDeviceVO> map = deviceVOS.stream().collect(Collectors.toMap(SgStatisDeviceVO::getPType, Function.identity()));
+ //表面变形
+ SgStatisDeviceVO sg108 = map.get("sg108");
+ if (Objects.nonNull(sg108)){
+ Integer deviceCount = sg108.getDeviceCount();
+ Integer deviceStart = sg108.getDeviceStart();
+ vo.setSurfaceNum(deviceCount);
+ if (deviceCount != 0){
+ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP);
+ vo.setSeepageProgress(getBigDecimalPercent(divide));
+ }else {
+ vo.setSeepageProgress("0%");
+ }
+ }
+ //视频
+ SgStatisDeviceVO sg104 = map.get("sg104");
+ if (Objects.nonNull(sg104)){
+ Integer deviceCount = sg104.getDeviceCount();
+ Integer deviceStart = sg104.getDeviceStart();
+ vo.setVideoNum(deviceCount);
+ if (deviceCount != 0){
+ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP);
+ vo.setVideoProgress(getBigDecimalPercent(divide));
+ }else {
+ vo.setVideoProgress("0%");
+ }
+ }
+ //渗压
+ SgStatisDeviceVO sg101 = map.get("sg101");
+ if (Objects.nonNull(sg101)){
+ Integer deviceCount = sg101.getDeviceCount();
+ Integer deviceStart = sg101.getDeviceStart();
+ vo.setTransNum(deviceCount);
+ if (deviceCount != 0){
+ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP);
+ vo.setTransProgress(getBigDecimalPercent(divide));
+ }else {
+ vo.setTransProgress("0%");
+ }
+ }
+ //渗流
+ SgStatisDeviceVO sg102 = map.get("sg102");
+ if (Objects.nonNull(sg102)){
+ Integer deviceCount = sg102.getDeviceCount();
+ Integer deviceStart = sg102.getDeviceStart();
+ vo.setSeepageNum(deviceCount);
+ if (deviceCount != 0){
+ BigDecimal divide = BigDecimal.valueOf(deviceStart).divide(BigDecimal.valueOf(deviceCount), 2, BigDecimal.ROUND_UP);
+ vo.setSeepageProgress(getBigDecimalPercent(divide));
+ }else {
+ vo.setSeepageProgress("0%");
+ }
+ }
+ }
+ }
+ }
+ }
}
private void updateProjectProgress(List<SgStatisProVO> sgStatisProVOS, String pcode, String pname, String adGrad) {
@@ -314,11 +421,11 @@
List<SgProjectInfoDO> projectProgress = getProjectProgress(list);
projectProgress.forEach(p -> {
- List<SgTypeVO> sgGxDOS = p.getSgGxDOS();
- sgGxDOS.forEach(sgTypeVO -> {
- String typeProgress = sgTypeVO.getTypeProgress().replace("%", "");
+ List<PtypeVO> ptypeVOS = p.getPtypeVOS();
+ ptypeVOS.forEach(sgTypeVO -> {
+ String typeProgress = sgTypeVO.getPTypeProgress().replace("%", "");
BigDecimal percentageBigDecimal = new BigDecimal(typeProgress).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
- bigDecimals.merge(sgTypeVO.getTypeName(), percentageBigDecimal, BigDecimal::add);
+ bigDecimals.merge(sgTypeVO.getPTypeName(), percentageBigDecimal, BigDecimal::add);
});
});
@@ -384,8 +491,15 @@
QueryWrapper<SgProgressReportDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("gx_step_id", stepIdForNull)
.eq("profram_id", programId);
- SgProgressReportDO sgProgressReportDO = sgProgressReportMapper.selectOne(queryWrapper);
+ SgProgressReportDO sgProgressReportDO = null;
+ List<SgProgressReportDO> sgProgressReportDOS = sgProgressReportMapper.selectList(queryWrapper);
+ if (CollectionUtils.isNotEmpty(sgProgressReportDOS)) {
+ List<SgProgressReportDO> collect = sgProgressReportDOS.stream().filter(s -> s.getStatus() == null || (s.getStatus() != 4 && !(s.getStatus() == 3 && s.getResubmit() != 0))).collect(Collectors.toList());
+ if (!collect.isEmpty()){
+ sgProgressReportDO = collect.get(0);
+ }
+ }
PreAcceVO preAcceVO = new PreAcceVO();
if (sgProgressReportDO!= null) {
preAcceVO.setId(sgProgressReportDO.getId().toString());
--
Gitblit v1.9.3