From ebf31fdde41e6b07faa11ebbf41beac61926235a Mon Sep 17 00:00:00 2001
From: shenyijian <1178253012@qq.com>
Date: Mon, 26 Aug 2024 20:53:02 +0800
Subject: [PATCH] 湖北水库:设备开工率统计
---
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java | 90 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 90 insertions(+), 0 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 f58232a..5405251 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,6 +55,8 @@
@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));
if (CollectionUtils.isNotEmpty(projectProgress)){
@@ -64,6 +68,18 @@
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
@@ -269,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) {
@@ -401,6 +490,7 @@
private PreAcceVO handleQuery( int stepIdForNull, Long programId) {
QueryWrapper<SgProgressReportDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("gx_step_id", stepIdForNull)
+ .ne("status",3)
.eq("profram_id", programId);
SgProgressReportDO sgProgressReportDO = sgProgressReportMapper.selectOne(queryWrapper);
--
Gitblit v1.9.3