Merge remote-tracking branch 'origin/master'

master
zhaoxiaolin 2 months ago
commit 366520b042

@ -1,129 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="op-api-system" />
<orderEntry type="module" module-name="op-common-security" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.3.24" level="project" />
<orderEntry type="library" name="Maven: com.op:op-api-system:0.0.1" level="project" />
<orderEntry type="module" module-name="op-common-core" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-openfeign:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-openfeign-core:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.7" level="project" />
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form-spring:3.8.0" level="project" />
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form:3.8.0" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.4" level="project" />
<orderEntry type="library" name="Maven: io.github.openfeign:feign-core:11.10" level="project" />
<orderEntry type="library" name="Maven: io.github.openfeign:feign-slf4j:11.10" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-loadbalancer:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-loadbalancer:3.1.5" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor.addons:reactor-extra:3.4.9" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:2.7.7" level="project" />
<orderEntry type="library" name="Maven: com.stoyanr:evictor:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.3.24" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:transmittable-thread-local:2.14.2" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.4.6" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.7.7" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.4.6" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.3.2" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.70" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.2.5.Final" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.3.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.13.4.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.13.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.13.4" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.25" level="project" />
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.06" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.6.2" level="project" />
<orderEntry type="module" module-name="op-common-redis" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.7.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.7.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.7.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" />
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:6.1.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.86.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.86.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.86.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.86.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.86.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.86.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.86.Final" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.4.26" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-bootstrap:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.7.7" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.11" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.36" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.30" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.7.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcutil-jdk15on:1.69" level="project" />
</component>
</module>

@ -18,6 +18,8 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* Service * Service
@ -133,29 +135,21 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
if (StringUtils.isEmpty(recordDnbInstant.getMonitorSubset())) { if (StringUtils.isEmpty(recordDnbInstant.getMonitorSubset())) {
return recordDnbInstantMapper.instantList(new RecordDnbInstant()); return recordDnbInstantMapper.instantList(new RecordDnbInstant());
} }
List<RecordDnbInstant> dnbInstantList = new ArrayList<>();
BaseMonitorInfo monitorInfo = new BaseMonitorInfo(); BaseMonitorInfo monitorInfo = new BaseMonitorInfo();
monitorInfo.setParentId(Long.valueOf(recordDnbInstant.getMonitorSubset())); monitorInfo.setParentId(Long.valueOf(recordDnbInstant.getMonitorSubset()));
monitorInfo.setParams(null); monitorInfo.setParams(null);
recordDnbInstant.setParams(null); recordDnbInstant.setParams(null);
List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoService.selectBaseMonitorInfoList(monitorInfo); List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoService.selectBaseMonitorInfoList(monitorInfo);
for (BaseMonitorInfo baseMonitorInfo : baseMonitorInfos) { List<String> monitorIdList = baseMonitorInfos.stream().map(BaseMonitorInfo::getMonitorId).collect(Collectors.toList());
RecordDnbInstant dnbInstant = new RecordDnbInstant(); if (monitorIdList.size() > 0){
dnbInstant.setMonitorId(baseMonitorInfo.getMonitorId()); RecordDnbInstant instant = new RecordDnbInstant();
dnbInstant.setMonitorName(baseMonitorInfo.getMonitorName()); Map<String, Object> params = instant.getParams();
RecordDnbInstant baseDnbInstant = new RecordDnbInstant(); params.put("monitorIdList", monitorIdList);
baseDnbInstant.setMonitorSubset(baseMonitorInfo.getMonitorId()); List<RecordDnbInstant> dnbInstantList = recordDnbInstantMapper.instantList(instant);
List<RecordDnbInstant> dnbInstantListOld = recordDnbInstantMapper.instantList(baseDnbInstant);
if (dnbInstantListOld.size() > 0) {
BigDecimal zxyg = dnbInstantListOld.stream().map(RecordDnbInstant::getZxyg).reduce(BigDecimal.ZERO, BigDecimal::add);
Date collectTime = dnbInstantListOld.stream().map(RecordDnbInstant::getCollectTime).max(Date::compareTo).orElse(null);
dnbInstant.setZxyg(zxyg);
dnbInstant.setCollectTime(collectTime);
}
dnbInstantList.add(dnbInstant);
}
return dnbInstantList; return dnbInstantList;
} }
return null;
}
/** /**
* *
@ -176,7 +170,9 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
baseDnbInstant.setParams(null); baseDnbInstant.setParams(null);
List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoService.selectBaseMonitorInfoList(monitorInfo); List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoService.selectBaseMonitorInfoList(monitorInfo);
if (baseMonitorInfos.size() > 0) { if (baseMonitorInfos.size() > 0) {
List<RecordDnbInstant> dnbInstantListOld = recordDnbInstantMapper.instantList(baseDnbInstant); RecordDnbInstant instant = new RecordDnbInstant();
instant.setMonitorId(baseDnbInstant.getMonitorSubset());
List<RecordDnbInstant> dnbInstantListOld = recordDnbInstantMapper.instantList(instant);
dnbInstant.setMonitorId(baseMonitorInfos.get(0).getMonitorId()); dnbInstant.setMonitorId(baseMonitorInfos.get(0).getMonitorId());
dnbInstant.setMonitorName(baseMonitorInfos.get(0).getMonitorName()); dnbInstant.setMonitorName(baseMonitorInfos.get(0).getMonitorName());
if (dnbInstantListOld.size() > 0) { if (dnbInstantListOld.size() > 0) {

@ -1,7 +1,9 @@
package com.op.energy.report.controller; package com.op.energy.report.controller;
import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.web.page.TableDataInfo; import com.op.common.core.web.page.TableDataInfo;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.service.IEnergyPreviewService; import com.op.energy.report.service.IEnergyPreviewService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -25,7 +27,6 @@ public class energyPreviewController extends BaseController {
@Autowired @Autowired
private IEnergyPreviewService energyPreviewService; private IEnergyPreviewService energyPreviewService;
/** /**
* *
* *
@ -63,5 +64,52 @@ public class energyPreviewController extends BaseController {
return prefix + "/waterIndex"; return prefix + "/waterIndex";
} }
/**
* 线
* @param paramMap
* @return
*/
@ResponseBody
@GetMapping("/productionLineEnergyConsumption")
public AjaxResult productionLineEnergyConsumption(@RequestParam(required = false) Map paramMap) {
Map<String, Object> result = energyPreviewService.productionLineEnergyConsumption(paramMap);
return AjaxResult.success(result);
}
/**
*
* @param paramMap
* @return
*/
@ResponseBody
@GetMapping("/energyConsumptionTrendAnalysis")
public AjaxResult energyConsumptionTrendAnalysis(@RequestParam(required = false) Map paramMap) {
Map<String, Object> result = energyPreviewService.energyConsumptionTrendAnalysis(paramMap);
return AjaxResult.success(result);
}
/**
* 线
* @param energyDTO
* @return
*/
@ResponseBody
@GetMapping("/linesConsumptionComparison")
public AjaxResult linesConsumptionComparison(ReportOrderEnergyDTO energyDTO) {
Map<String, Object> result = energyPreviewService.linesConsumptionComparison(energyDTO);
return AjaxResult.success(result);
}
/**
*
* @param energyDTO
* @return
*/
@ResponseBody
@GetMapping("/productConsumptionComparison")
public AjaxResult productLinesConsumptionComparison(ReportOrderEnergyDTO energyDTO) {
Map<String, Object> result = energyPreviewService.productConsumptionComparison(energyDTO);
return AjaxResult.success(result);
}
} }

@ -80,4 +80,10 @@ public interface ReportPointDnbMapper {
List<Map<String, String>> energyStatisticsData(Map map); List<Map<String, String>> energyStatisticsData(Map map);
public List<ReportOrderEnergyDTO> OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO); public List<ReportOrderEnergyDTO> OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO);
List<Map<String, String>> productionLineEnergyConsumption(Map paramMap);
List<ReportOrderEnergyDTO> linesConsumptionComparison(ReportOrderEnergyDTO energyDTO);
List<ReportOrderEnergyDTO> productConsumptionComparison(ReportOrderEnergyDTO energyDTO);
} }

@ -1,5 +1,7 @@
package com.op.energy.report.service; package com.op.energy.report.service;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -77,4 +79,32 @@ public interface IEnergyPreviewService {
* @return * @return
*/ */
public List<Map<String, String>> energyConsumptionByTime(Map paramMap); public List<Map<String, String>> energyConsumptionByTime(Map paramMap);
/**
* 线
* @param paramMap
* @return
*/
Map<String, Object> productionLineEnergyConsumption(Map paramMap);
/**
*
* @param paramMap
* @return
*/
Map<String, Object> energyConsumptionTrendAnalysis(Map paramMap);
/**
* 线
* @param energyDTO
* @return
*/
Map<String, Object> linesConsumptionComparison(ReportOrderEnergyDTO energyDTO);
/**
*
* @param energyDTO
* @return
*/
Map<String, Object> productConsumptionComparison(ReportOrderEnergyDTO energyDTO);
} }

@ -10,15 +10,25 @@ import com.op.energy.base.mapper.BaseTypeRelationMapper;
import com.op.energy.base.service.IBaseMonitorInfoService; import com.op.energy.base.service.IBaseMonitorInfoService;
import com.op.energy.base.utils.DateUtils; import com.op.energy.base.utils.DateUtils;
import com.op.energy.base.utils.sortReportUitls; import com.op.energy.base.utils.sortReportUitls;
import com.op.energy.record.domain.RecordDnbInstant;
import com.op.energy.record.mapper.RecordDnbInstantMapper;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.domain.ReportPointDnb;
import com.op.energy.report.domain.ReportPointWater;
import com.op.energy.report.mapper.ReportPointDnbMapper; import com.op.energy.report.mapper.ReportPointDnbMapper;
import com.op.energy.report.mapper.ReportPointWaterMapper; import com.op.energy.report.mapper.ReportPointWaterMapper;
import com.op.energy.report.service.IDataAnalysisService;
import com.op.energy.report.service.IEnergyPreviewService; import com.op.energy.report.service.IEnergyPreviewService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static com.op.energy.base.utils.DateUtils.YYYY_MM_DD_HH_MM_SS;
/** /**
* Service * Service
@ -43,6 +53,9 @@ public class EnergyPreviewServiceImpl implements IEnergyPreviewService {
@Autowired @Autowired
private BaseBuildInfoMapper baseBuildInfoMapper; private BaseBuildInfoMapper baseBuildInfoMapper;
@Autowired
private RecordDnbInstantMapper recordDnbInstantMapper;
/** /**
* *
* *
@ -615,4 +628,217 @@ public class EnergyPreviewServiceImpl implements IEnergyPreviewService {
result.put("valueList", valueList); result.put("valueList", valueList);
return result; return result;
} }
/**
* 线
*
* @param paramMap
* @return
*/
@Override
@DS("#header.poolName")
public Map<String, Object> productionLineEnergyConsumption(Map paramMap) {
HashMap<String, Object> result = new HashMap<>();
List<Map<String, String>> energyList = reportPointDnbMapper.productionLineEnergyConsumption(paramMap);
result.put("energyList", energyList);
return result;
}
/**
*
*
* @param paramMap
* @return
*/
@Override
@DS("#header.poolName")
public Map<String, Object> energyConsumptionTrendAnalysis(Map paramMap) {
HashMap<String, Object> result = new HashMap<>();
List<Map<String, String>> energyList = new ArrayList<>();
List<String> timeList = new ArrayList<>();
List<Long> monitorIdLists = new ArrayList<>();
LinkedHashMap<String, List<Float>> monitorInfoMap = new LinkedHashMap<>();
if (!paramMap.containsKey("type") || !paramMap.containsKey("energyType") ||
String.valueOf(paramMap.get("startTime")).equals("") || String.valueOf(paramMap.get("endTime")).equals("")) {
return result;
}
String energyType = String.valueOf(paramMap.get("energyType"));
//小时 天 月 年
String type = String.valueOf(paramMap.get("type"));
BaseBuildInfo baseBuildInfo = new BaseBuildInfo();
List<BaseBuildInfo> buildInfoList = baseBuildInfoMapper.selectBaseBuildInfoList(baseBuildInfo);
if (paramMap.containsKey("monitorIds")) {
String monitorIds = String.valueOf(paramMap.get("monitorIds"));
if (monitorIds.contains(",")) {
monitorIdLists = Arrays.stream(monitorIds.split(","))
.map(String::trim)
.map(Long::valueOf)
.collect(Collectors.toList());
} else {
if (!monitorIds.isEmpty()) {
monitorIdLists.add(Long.parseLong(monitorIds));
}
}
}
switch (type) {
case "month":
timeList = DateUtils.getSortedMonthList(DateUtils.getDatesBetween(String.valueOf(paramMap.get("startTime")), String.valueOf(paramMap.get("endTime"))), type);
break;
case "year":
timeList = DateUtils.getSortedMonthList(DateUtils.getDatesBetween(String.valueOf(paramMap.get("startTime")), String.valueOf(paramMap.get("endTime"))), type);
break;
case "hour":
timeList = DateUtils.getHourlyIntervals(String.valueOf(paramMap.get("startTime")), String.valueOf(paramMap.get("endTime")));
break;
case "day":
timeList = DateUtils.getDatesBetween(String.valueOf(paramMap.get("startTime")), String.valueOf(paramMap.get("endTime")));
break;
}
List<List<Float>> lists = new ArrayList<>();
for (Long buildOId : monitorIdLists) {
List<Float> monitorValueList = new ArrayList<>();
List<String> monitorNameList = buildInfoList.stream().filter(e -> e.getObjid().equals(buildOId))
.map(BaseBuildInfo::getBuildName).collect(Collectors.toList());
BaseTypeRelation relation = new BaseTypeRelation();
relation.setType(0L);
relation.setRelationId(buildOId);
List<BaseTypeRelation> baseTypeRelations = baseTypeRelationMapper.selectBaseTypeRelationList(relation);
List<String> collect = baseTypeRelations.stream().map(BaseTypeRelation::getMonitorId).collect(Collectors.toList());
paramMap.put("monitorIdList", collect);
if (energyType.equals("2")) {
ReportPointDnb pointDnb = new ReportPointDnb();
pointDnb.setParams(paramMap);
List<ReportPointDnb> pointDnbList = reportPointDnbMapper.selectReportPointDnbList(pointDnb);
for (ReportPointDnb reportPointDnb : pointDnbList) {
Map<String, String> map = new HashMap<>();
map.put("recordTime", DateUtils.parseDateToStr("yyyy-MM-dd HH", reportPointDnb.getBeginTime()));
map.put("expend", reportPointDnb.getExpend().toString());
energyList.add(map);
}
} else if (energyType.equals("3")) {
ReportPointWater reportPointWater = new ReportPointWater();
reportPointWater.setParams(paramMap);
List<ReportPointWater> reportPointWaters = reportPointWaterMapper.selectReportPointWaterList(reportPointWater);
for (ReportPointWater pointWater : reportPointWaters) {
Map<String, String> map = new HashMap<>();
map.put("recordTime", DateUtils.parseDateToStr("yyyy-MM-dd HH", pointWater.getBeginTime()));
map.put("expend", pointWater.getExpend().toString());
energyList.add(map);
}
}
timeList.forEach(date -> {
float expend = 0.00f;
for (Map<String, String> map : energyList) {
String recordTime = String.valueOf(map.get("recordTime"));
if (type.equals("month")) {
recordTime = recordTime.substring(0, 7);
} else if (type.equals("year")) {
recordTime = recordTime.substring(0, 4);
} else if (type.equals("hour")) {
date = date.substring(0, 13);
} else if (type.equals("day")) {
recordTime = recordTime.substring(0, 10);
}
if (date.equals(recordTime)) {
expend += Float.parseFloat(String.valueOf(map.get("expend")));
}
}
BigDecimal decimal = new BigDecimal(Float.toString(expend));
decimal = decimal.setScale(2, RoundingMode.HALF_UP);
monitorValueList.add(decimal.floatValue());
});
if (monitorNameList.size() != 0) {
monitorInfoMap.put(monitorNameList.get(0), monitorValueList);
}
lists.add(monitorValueList);
}
if (lists.size() != 0) {
List<Float> sumLineList = IntStream.range(0, lists.get(0).size())
.mapToObj(i -> lists.stream()
.map(list -> list.get(i))
.reduce(0f, Float::sum))
.map(f -> Math.round(f * 100.0) / 100.0f)
.collect(Collectors.toList());
result.put("sumLineList", sumLineList);
}
List<String> monitorNameList = new ArrayList<>();
for (String monitorName : monitorInfoMap.keySet()) {
monitorNameList.add(monitorName);
}
result.put("monitorNameList", monitorNameList);
result.put("timeList", timeList);
result.put("monitorInfoMap", monitorInfoMap);
return result;
}
/**
* 线
*
* @param energyDTO
* @return
*/
@Override
@DS("#header.poolName")
public Map<String, Object> linesConsumptionComparison(ReportOrderEnergyDTO energyDTO) {
HashMap<String, Object> result = new HashMap<>();
LinkedHashMap<String, BigDecimal> dataMap = new LinkedHashMap<>();
List<ReportOrderEnergyDTO> reportOrderEnergyDTOList = reportPointDnbMapper.linesConsumptionComparison(energyDTO);
if (reportOrderEnergyDTOList != null && reportOrderEnergyDTOList.size() > 0) {
for (ReportOrderEnergyDTO orderEnergyDTO : reportOrderEnergyDTOList) {
RecordDnbInstant recordDnbInstant = new RecordDnbInstant();
String startWorkTime = DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, orderEnergyDTO.getStartWorkTime());
String endWorkTime = DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, orderEnergyDTO.getEndWorkTime());
String electricityNo = orderEnergyDTO.getElectricityNo();
Map<String, Object> map = new HashMap<>();
recordDnbInstant.setMonitorId(electricityNo);
map.put("beginCollectTime", startWorkTime);
map.put("endCollectTime", endWorkTime);
recordDnbInstant.setParams(map);
List<RecordDnbInstant> recordDnbInstantList = recordDnbInstantMapper.selectRecordDnbInstantByTime(recordDnbInstant);
if (recordDnbInstantList.size() == 2) {
BigDecimal kw = recordDnbInstantList.get(0).getKw().subtract(recordDnbInstantList.get(1).getKw()).abs();
BigDecimal decimal = kw.divide(new BigDecimal(orderEnergyDTO.getTotalQuantityFeedback()), 2, RoundingMode.HALF_UP);
dataMap.put(orderEnergyDTO.getEquipmentName(), decimal);
}
}
}
result.put("data", dataMap);
return result;
}
/**
*
* @param energyDTO
* @return
*/
@Override
@DS("#header.poolName")
public Map<String, Object> productConsumptionComparison(ReportOrderEnergyDTO energyDTO) {
HashMap<String, Object> result = new HashMap<>();
LinkedHashMap<String, BigDecimal> dataMap = new LinkedHashMap<>();
List<ReportOrderEnergyDTO> reportOrderEnergyDTOList = reportPointDnbMapper.productConsumptionComparison(energyDTO);
if (reportOrderEnergyDTOList != null && reportOrderEnergyDTOList.size() > 0) {
for (ReportOrderEnergyDTO orderEnergyDTO : reportOrderEnergyDTOList) {
RecordDnbInstant recordDnbInstant = new RecordDnbInstant();
String startWorkTime = DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, orderEnergyDTO.getStartWorkTime());
String endWorkTime = DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, orderEnergyDTO.getEndWorkTime());
String electricityNo = orderEnergyDTO.getElectricityNo();
Map<String, Object> map = new HashMap<>();
recordDnbInstant.setMonitorId(electricityNo);
map.put("beginCollectTime", startWorkTime);
map.put("endCollectTime", endWorkTime);
recordDnbInstant.setParams(map);
List<RecordDnbInstant> recordDnbInstantList = recordDnbInstantMapper.selectRecordDnbInstantByTime(recordDnbInstant);
if (recordDnbInstantList.size() == 2) {
BigDecimal kw = recordDnbInstantList.get(0).getKw().subtract(recordDnbInstantList.get(1).getKw()).abs();
BigDecimal decimal = kw.divide(new BigDecimal(orderEnergyDTO.getTotalQuantityFeedback()), 2, RoundingMode.HALF_UP);
dataMap.put(orderEnergyDTO.getProductName(), decimal);
}
}
}
result.put("data", dataMap);
return result;
}
} }

@ -41,7 +41,7 @@
WITH OrderedRecords AS ( WITH OrderedRecords AS (
SELECT SELECT
rdi.*, rdi.*,
rdi.zxyg * bmi.ct AS kw, rdi.zxyg * isnull(bmi.ct,1) AS kw,
bmi.ct, bmi.ct,
ROW_NUMBER() OVER (ORDER BY rdi.collect_time ASC) AS RowAsc, ROW_NUMBER() OVER (ORDER BY rdi.collect_time ASC) AS RowAsc,
ROW_NUMBER() OVER (ORDER BY rdi.collect_time DESC) AS RowDesc ROW_NUMBER() OVER (ORDER BY rdi.collect_time DESC) AS RowDesc

@ -380,4 +380,74 @@
</foreach> </foreach>
</delete> </delete>
<select id="productionLineEnergyConsumption" resultType="java.util.Map">
select bbi.build_name buildName, sum(rpd.expend) expend
from base_build_info bbi
left join base_type_relation btr on btr.relation_id = bbi.objid
left join base_monitor_info m on m.monitor_id = btr.monitor_id
left join report_point_dnb rpd on m.monitor_id = rpd.monitor_id
where m.monitor_id is not null
<if test="unitId != null and unitId != ''">and bbi.grade = #{unitId}</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and rpd.begin_time between #{beginTime} and #{endTime}
</if>
group by bbi.build_name
order by expend desc
</select>
<select id="linesConsumptionComparison" resultMap="ReportOrderEnergyDTOResult">
select be.equipment_name equipment_name,
SUM(mrw.total_quantity_feedback) total_quantity_feedback,
MIN(pow.start_work_time) start_work_time,
MAX(pow.end_work_time) end_work_time,
be.attr2 AS electricity_no
FROM pro_order_workorder pow
LEFT JOIN base_equipment be ON pow.workorder_name = be.equipment_code
LEFT JOIN (SELECT workorder_code,
SUM(quantity_feedback) AS total_quantity_feedback
FROM mes_report_work
GROUP BY workorder_code) mrw ON pow.workorder_code = mrw.workorder_code
WHERE pow.status = 'w3'
AND pow.parent_order = '0'
AND pow.del_flag = '0'
AND pow.end_work_time IS NOT NULL
AND be.equipment_name IS NOT NULL
AND be.attr2 IS NOT NULL
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
AND pow.product_date between #{params.beginTime} and #{params.endTime}
</if>
<if test="workorderCode != null and workorderCode != ''">and pow.workorder_code like concat('%', #{workorderCode}, '%')</if>
<if test="productCode != null and productCode != ''">and pow.product_code like concat('%', #{productCode}, '%')</if>
<if test="productName != null and productName != ''">and pow.product_name like concat('%', #{productName}, '%')</if>
GROUP BY be.equipment_name, be.attr2
ORDER BY be.equipment_name
</select>
<select id="productConsumptionComparison" resultMap="ReportOrderEnergyDTOResult">
select pow.product_name product_name,
SUM(mrw.total_quantity_feedback) total_quantity_feedback,
MIN(pow.start_work_time) start_work_time,
MAX(pow.end_work_time) end_work_time,
be.attr2 AS electricity_no
FROM pro_order_workorder pow
LEFT JOIN base_equipment be ON pow.workorder_name = be.equipment_code
LEFT JOIN (SELECT workorder_code,
SUM(quantity_feedback) AS total_quantity_feedback
FROM mes_report_work
GROUP BY workorder_code) mrw ON pow.workorder_code = mrw.workorder_code
WHERE pow.status = 'w3'
AND pow.parent_order = '0'
AND pow.del_flag = '0'
AND pow.end_work_time IS NOT NULL
AND be.equipment_name IS NOT NULL
AND be.attr2 IS NOT NULL
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
AND pow.product_date between #{params.beginTime} and #{params.endTime}
</if>
<if test="workorderCode != null and workorderCode != ''">and pow.workorder_code like concat('%', #{workorderCode}, '%')</if>
<if test="workorderName != null and workorderName != ''">and pow.workorder_name like concat('%', #{workorderName}, '%')</if>
<if test="equipmentName != null and equipmentName != ''">and be.equipment_name like concat('%', #{equipmentName}, '%')</if>
GROUP BY pow.product_name, be.attr2
ORDER BY pow.product_name
</select>
</mapper> </mapper>

@ -3,7 +3,10 @@ package com.op.mes.controller;
import com.op.mes.domain.EnergyExpend; import com.op.mes.domain.EnergyExpend;
import com.op.mes.domain.H5; import com.op.mes.domain.H5;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.vo.MesDailyReportVo;
import com.op.mes.service.H5ApiService; import com.op.mes.service.H5ApiService;
import com.op.mes.service.IMesReportWorkService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -14,6 +17,8 @@ import javax.validation.constraints.Max;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.op.common.core.utils.PageUtils.startPage;
/** /**
* H5 * H5
* *
@ -26,12 +31,13 @@ public class H5ApiController {
@Autowired @Autowired
private H5ApiService h5ApiService; private H5ApiService h5ApiService;
@Autowired
private IMesReportWorkService mesReportWorkService;
@GetMapping("/dailyProductDetil") @GetMapping("/dailyProductDetil")
public List<H5> list(H5 h5) public List<MesDailyReportVo> list(MesDailyReportVo mesDailyReportVo)
{ {
String workTime=h5.getFeedbackTime(); startPage();
List<H5> list = h5ApiService.dailyProductDetil(workTime); List<MesDailyReportVo> list = mesReportWorkService.getDailyReportNew(mesDailyReportVo);
return list; return list;
} }
//能源数据 //能源数据

@ -1,6 +1,10 @@
package com.op.mes.domain; package com.op.mes.domain;
public class H5 { import com.op.common.core.web.domain.BaseEntity;
import java.util.List;
public class H5 extends BaseEntity {
private String workOrderCode; private String workOrderCode;
private String lineName; private String lineName;
private String productName; private String productName;
@ -20,6 +24,16 @@ public class H5 {
private String reason; private String reason;
private String shift; private String shift;
private List<H5> children;
public List<H5> getChildren() {
return children;
}
public void setChildren(List<H5> children) {
this.children = children;
}
public String getShift() { public String getShift() {
return shift; return shift;
} }

@ -6,7 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface H5ApiService { public interface H5ApiService {
List<H5> dailyProductDetil(String workTime); // List<H5> dailyProductDetil(String workTime);
List EnergyExpend(); List EnergyExpend();
} }

@ -0,0 +1,61 @@
package com.op.mes.service;
import java.util.List;
import com.op.mes.domain.WcsPrintTask;
/**
* Service
*
* @author ruoyi
* @date 2025-04-24
*/
public interface IWcsPrintTaskService
{
/**
*
*
* @param id
* @return
*/
public WcsPrintTask selectWcsPrintTaskById(String id);
/**
*
*
* @param wcsPrintTask
* @return
*/
public List<WcsPrintTask> selectWcsPrintTaskList(WcsPrintTask wcsPrintTask);
/**
*
*
* @param wcsPrintTask
* @return
*/
public int insertWcsPrintTask(WcsPrintTask wcsPrintTask);
/**
*
*
* @param wcsPrintTask
* @return
*/
public int updateWcsPrintTask(WcsPrintTask wcsPrintTask);
/**
*
*
* @param ids
* @return
*/
public int deleteWcsPrintTaskByIds(String[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteWcsPrintTaskById(String id);
}

@ -4,11 +4,15 @@ package com.op.mes.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.mes.domain.EnergyExpend; import com.op.mes.domain.EnergyExpend;
import com.op.mes.domain.H5; import com.op.mes.domain.H5;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.mapper.H5ApiMapper; import com.op.mes.mapper.H5ApiMapper;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.mes.service.H5ApiService; import com.op.mes.service.H5ApiService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
@ -23,142 +27,155 @@ import java.util.stream.Collectors;
public class H5ApiServiceImpl implements H5ApiService { public class H5ApiServiceImpl implements H5ApiService {
@Autowired @Autowired
private H5ApiMapper h5ApiMapper; private H5ApiMapper h5ApiMapper;
@Autowired
private MesReportWorkMapper mesReportWorkMapper;
// @Override
// @DS("#header.poolName")
// public List<MesDailyReport> dailyProductDetil(String workTime) {
//
//
@Override
@DS("#header.poolName")
public List<H5> dailyProductDetil(String workTime) {
//查询当天的生产情况 //查询当天的生产情况
H5 h5=new H5(); // H5 h5=new H5();
h5.setFeedbackTime(workTime); // h5.setFeedbackTime(workTime);
//报工信息
List<H5> h5List=h5ApiMapper.selectMesLineProdceList(h5);
//报工信息处理
//母单报工数据
List<H5> filteredList = h5List.stream()
.filter(h5s -> "0".equals(h5s.getParentOrder()))
.collect(Collectors.toList());
//子单报工数据
List<H5> filteredLists = h5List.stream()
.filter(h5s -> !"0".equals(h5s.getParentOrder()))
.collect(Collectors.toList());
// 按照 workOrderCode 分组,并计算各个字段的统计值
List<H5> resultList = filteredList.stream()
.collect(Collectors.groupingBy(
H5::getWorkOrderCode, // 按 workOrderCode 分组
Collectors.collectingAndThen(
Collectors.toList(),
list -> {
double averageStandardStaffing = list.stream()
.collect(Collectors.averagingDouble(H5::getStandardStaffing));
double averageActualEmployment = list.stream()
.collect(Collectors.averagingDouble(H5::getActualEmployment));
double totalProductionDuration = list.stream()
.collect(Collectors.summingDouble(H5::getProductionDuration));
double totalPlanProduction = list.stream()
.collect(Collectors.summingDouble(H5::getPlanProduction));
double totalProduction = list.stream()
.collect(Collectors.summingDouble(H5::getProduction));
H5 resultH5 = new H5();
resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
resultH5.setLineName(list.get(0).getLineName());
resultH5.setProductName(list.get(0).getProductName());
resultH5.setCategory(list.get(0).getCategory());
resultH5.setSpecifications(list.get(0).getSpecifications());
resultH5.setStandardEfficiency(list.get(0).getStandardEfficiency());
resultH5.setActualEmployment(averageActualEmployment);
resultH5.setStandardStaffing((int) Math.round(averageStandardStaffing)); // 计算的平均值
resultH5.setProductionDuration(totalProductionDuration); // 总和
resultH5.setPlanProduction((int) Math.round(totalPlanProduction)); // 总和
resultH5.setProduction((int) Math.round(totalProduction)); // 总和
resultH5.setReason(list.get(0).getReason());
resultH5.setShift(list.get(0).getShift());
return resultH5;
}
)
))
.values()
.stream()
.collect(Collectors.toList());
List<H5> resultLists = filteredLists.stream()
.collect(Collectors.groupingBy(
H5::getWorkOrderCode, // 按 workOrderCode 分组
Collectors.collectingAndThen(
Collectors.toList(),
list -> {
double averageActualEmployment =Math.round(list.stream()
.collect(Collectors.averagingDouble(H5::getActualEmployment)));
H5 resultH5 = new H5();
resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
resultH5.setActualEmployment(averageActualEmployment);
resultH5.setParentOrder(list.get(0).getParentOrder());
return resultH5;
}
)
))
.values()
.stream()
.collect(Collectors.toList());
// 将 resultLists 转换为 Map以便快速查找
Map<String, H5> parentOrderToH5Map = resultLists.stream()
.collect(Collectors.toMap(
H5::getParentOrder,
h5s -> h5s
));
// 更新 resultList 中的 actualEmployment
// 更新 resultList 中的 actualEmployment
resultList.forEach(h51 -> {
H5 matchingH52 = parentOrderToH5Map.get(h51.getWorkOrderCode());
if (matchingH52 != null) {
h51.setActualEmployment(matchingH52.getActualEmployment());
}
});
// 更新 actualEfficiency 为百分比形式,保留一位小数
resultList.forEach(h5a -> {
double production = h5a.getProduction();
double productionDuration = h5a.getProductionDuration();
double actualEmployment = h5a.getActualEmployment();
double standardEfficiency=h5a.getStandardEfficiency();
// 避免除以零的情况
if (productionDuration != 0 && actualEmployment != 0) {
double actualEfficiency = production / productionDuration / actualEmployment;
actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
h5a.setActualEfficiency(actualEfficiency);
String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency/standardEfficiency)*100); // 格式化为百分比形式
h5a.setEfficiencyAcRate(efficiencyAcRate); // 设置百分比形式
} else {
h5a.setEfficiencyAcRate("0.0%"); // 或者设为其他默认值
}
});
resultList.stream()
.forEach(h5a -> {
double production = h5a.getProduction();
double productionDuration = h5a.getProductionDuration();
double actualEmployment = h5a.getActualEmployment();
double standardEfficiency = h5a.getStandardEfficiency();
// Avoid division by zero
if (productionDuration != 0 && actualEmployment != 0) {
double actualEfficiency = production / productionDuration / actualEmployment;
actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
h5a.setActualEfficiency(actualEfficiency);
// Format efficiency as a percentage
String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency / standardEfficiency) * 100);
h5a.setEfficiencyAcRate(efficiencyAcRate);
} else {
h5a.setEfficiencyAcRate("0.0%");
}
});
return resultList;
} // //报工信息
// List<H5> h5List=h5ApiMapper.selectMesLineProdceList(h5);
//// List<H5> resultList = new ArrayList<>();
//// if (h5List != null && h5List.size() >0){
//// resultList = filterParentWithChildren(h5List);
//// }
//
//
// //报工信息处理
// //母单报工数据
// List<H5> filteredList = h5List.stream()
// .filter(h5s -> "0".equals(h5s.getParentOrder()))
// .collect(Collectors.toList());
// //子单报工数据
// List<H5> filteredLists = h5List.stream()
// .filter(h5s -> !"0".equals(h5s.getParentOrder()))
// .collect(Collectors.toList());
// // 按照 workOrderCode 分组,并计算各个字段的统计值
// List<H5> resultList = filteredList.stream()
// .collect(Collectors.groupingBy(
// H5::getWorkOrderCode, // 按 workOrderCode 分组
// Collectors.collectingAndThen(
// Collectors.toList(),
// list -> {
// double averageStandardStaffing = list.stream()
// .collect(Collectors.averagingDouble(H5::getStandardStaffing));
// double averageActualEmployment = list.stream()
// .collect(Collectors.averagingDouble(H5::getActualEmployment));
// double totalProductionDuration = list.stream()
// .collect(Collectors.summingDouble(H5::getProductionDuration));
// double totalPlanProduction = list.stream()
// .collect(Collectors.summingDouble(H5::getPlanProduction));
// double totalProduction = list.stream()
// .collect(Collectors.summingDouble(H5::getProduction));
//
// H5 resultH5 = new H5();
// resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
// resultH5.setLineName(list.get(0).getLineName());
// resultH5.setProductName(list.get(0).getProductName());
// resultH5.setCategory(list.get(0).getCategory());
// resultH5.setSpecifications(list.get(0).getSpecifications());
// resultH5.setStandardEfficiency(list.get(0).getStandardEfficiency());
// resultH5.setActualEmployment(averageActualEmployment);
// resultH5.setStandardStaffing((int) Math.round(averageStandardStaffing)); // 计算的平均值
// resultH5.setProductionDuration(totalProductionDuration); // 总和
// resultH5.setPlanProduction((int) Math.round(totalPlanProduction)); // 总和
// resultH5.setProduction((int) Math.round(totalProduction)); // 总和
// resultH5.setReason(list.get(0).getReason());
// resultH5.setShift(list.get(0).getShift());
// return resultH5;
// }
// )
// ))
// .values()
// .stream()
// .collect(Collectors.toList());
//
// List<H5> resultLists = filteredLists.stream()
// .collect(Collectors.groupingBy(
// H5::getWorkOrderCode, // 按 workOrderCode 分组
// Collectors.collectingAndThen(
// Collectors.toList(),
// list -> {
// double averageActualEmployment =Math.round(list.stream()
// .collect(Collectors.averagingDouble(H5::getActualEmployment)));
// H5 resultH5 = new H5();
// resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
// resultH5.setActualEmployment(averageActualEmployment);
// resultH5.setParentOrder(list.get(0).getParentOrder());
// return resultH5;
// }
// )
// ))
// .values()
// .stream()
// .collect(Collectors.toList());
//
// // 将 resultLists 转换为 Map以便快速查找
// Map<String, H5> parentOrderToH5Map = resultLists.stream()
// .collect(Collectors.toMap(
// H5::getParentOrder,
// h5s -> h5s
// ));
//
// // 更新 resultList 中的 actualEmployment
// resultList.forEach(h51 -> {
// H5 matchingH52 = parentOrderToH5Map.get(h51.getWorkOrderCode());
// if (matchingH52 != null) {
// h51.setActualEmployment(matchingH52.getActualEmployment());
// }
// });
// // 更新 actualEfficiency 为百分比形式,保留一位小数
// resultList.forEach(h5a -> {
// double production = h5a.getProduction();
// double productionDuration = h5a.getProductionDuration();
// double actualEmployment = h5a.getActualEmployment();
// double standardEfficiency=h5a.getStandardEfficiency();
// // 避免除以零的情况
// if (productionDuration != 0 && actualEmployment != 0) {
// double actualEfficiency = production / productionDuration / actualEmployment;
// actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
// h5a.setActualEfficiency(actualEfficiency);
// String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency/standardEfficiency)*100); // 格式化为百分比形式
// h5a.setEfficiencyAcRate(efficiencyAcRate); // 设置百分比形式
// } else {
// h5a.setEfficiencyAcRate("0.0%"); // 或者设为其他默认值
// }
// });
//
// resultList.stream()
// .forEach(h5a -> {
// double production = h5a.getProduction();
// double productionDuration = h5a.getProductionDuration();
// double actualEmployment = h5a.getActualEmployment();
// double standardEfficiency = h5a.getStandardEfficiency();
//
// // Avoid division by zero
// if (productionDuration != 0 && actualEmployment != 0) {
// double actualEfficiency = production / productionDuration / actualEmployment;
// actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
// h5a.setActualEfficiency(actualEfficiency);
//
// // Format efficiency as a percentage
// String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency / standardEfficiency) * 100);
// h5a.setEfficiencyAcRate(efficiencyAcRate);
// } else {
// h5a.setEfficiencyAcRate("0.0%");
// }
// });
//
//
// return resultList;
// }
@Override @Override
@DS("#header.poolName") @DS("#header.poolName")

@ -172,32 +172,25 @@
<select id="getProductList" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport"> <select id="getProductList" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select select
mts.id, mts.id,
pow.workorder_id, mts.product_name,
pow.product_name, mts.product_code
pow.product_code
from mes_table_self mts from mes_table_self mts
left join pro_order_workorder pow on mts.line_code = pow.workorder_name
LEFT JOIN base_shifts_t bst ON pow.shift_id = bst.Shift_Id
where DATEDIFF(DAY, mts.check_date, #{checkDate}) = 0 where DATEDIFF(DAY, mts.check_date, #{checkDate}) = 0
and DATEDIFF(DAY, pow.product_date, #{checkDate}) = 0
and mts.del_flag = '0' and mts.del_flag = '0'
and pow.del_flag = '0'
and pow.parent_order = '0'
<choose> <choose>
<when test="shiftId != null"> <when test="shiftId != null">
AND mts.report_name = CONCAT(#{reportName}, bst.Shift_Desc) AND mts.report_name = CONCAT(#{reportName}, (SELECT Shift_Desc FROM base_shifts_t WHERE Shift_Id = #{shiftId}))
</when> </when>
<otherwise> <otherwise>
AND mts.report_name = #{reportName} AND mts.report_name = #{reportName}
</otherwise> </otherwise>
</choose> </choose>
and mts.line_code = #{lineCode} and mts.line_code = #{lineCode}
and pow.workorder_name = #{lineCode}
group by group by
mts.id, mts.id,
pow.workorder_id, mts.product_name,
pow.product_name, mts.product_code
pow.product_code
</select> </select>
<select id="getDataCodeList" resultType ="com.op.mes.domain.ProOrderWorkorder" parameterType="MesInspectionReport"> <select id="getDataCodeList" resultType ="com.op.mes.domain.ProOrderWorkorder" parameterType="MesInspectionReport">

Loading…
Cancel
Save