lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentStatisticalInfoMapper.xml
@@ -3,67 +3,69 @@ <mapper namespace="org.jeecg.modules.mdc.mapper.EquipmentStatisticalInfoMapper"> <select id="findDataRankingForBigScreen" resultType="org.jeecg.modules.mdc.subcontrol.vo.LastWeekDataVo"> SELECT EQUIPMENT, SUM( CLOSEDLONG ) CLOSEDLONG, SUM( ERRORINGLONG ) ERRORINGLONG, SUM( OPENINGLONG ) OPENINGLONG, SUM( PROCESSINGLONG ) PROCESSINGLONG, SUM( WAITINGLONG ) WAITINGLONG equipment_id equipment, SUM( open_long ) openlong, SUM( close_long ) closelong, SUM( wait_long ) waitlong, SUM( process_long ) processingLong, SUM( error_long ) errorlong FROM EQUIPMENTSTATISTICALINFO mdc_equipment_statistical_info <where> <if test="equipmentIdList != null and equipmentIdList.size() > 0"> AND EQUIPMENT IN AND equipment_id IN <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> #{ id } </foreach> </if> AND THEDATE >= #{ monday } AND THEDATE <= #{ saturday } AND the_date >= #{ monday } AND the_date <= #{ saturday } </where> GROUP BY EQUIPMENT; equipment_id; </select> <select id="findDataForBigScreen" resultType="org.jeecg.modules.mdc.subcontrol.vo.LastWeekDataVo"> SELECT THEDATE, SUM( OPENINGLONG ) OPENINGLONG, SUM(CLOSEDLONG) CLOSEDLONG, SUM(PROCESSINGLONG) PROCESSINGLONG, SUM(WAITINGLONG) WAITINGLONG equipment_id equipment, SUM( open_long ) openlong, SUM( close_long ) closelong, SUM( wait_long ) waitlong, SUM( process_long ) processingLong, SUM( error_long ) errorlong FROM EQUIPMENTSTATISTICALINFO mdc_equipment_statistical_info <where> <if test="equipmentIdList != null and equipmentIdList.size() > 0"> AND EQUIPMENT IN AND equipment_id IN <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> #{ id } </foreach> </if> AND THEDATE >= #{ monday } AND THEDATE <= #{ saturday } AND the_date >= #{ monday } AND the_date <= #{ saturday } </where> GROUP BY THEDATE the_date ORDER BY THEDATE ASC; the_date ASC; </select> <select id="findEquipmentId" resultType="java.lang.String"> SELECT DISTINCT EQUIPMENT equipment_id equipment FROM EQUIPMENTSTATISTICALINFO mdc_equipment_statistical_info <where> <if test="equipmentIdList != null and equipmentIdList.size() > 0"> AND EQUIPMENT IN AND equipment_id IN <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> #{ id } </foreach> </if> <if test="date != null and date != ''"> AND THEDATE = #{ date } AND the_date = #{ date } </if> </where> </select> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
@@ -17,4 +17,8 @@ * @param dateTime */ void runningAllEquipmentStatisticalProcess(String dateTime); Long selectSize(String equipmentId, String monday, String saturday); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentStatisticalInfoServiceImpl.java
@@ -36,6 +36,7 @@ @Override public Long selectSize(String equipmentId, String monday, String saturday) { return this.baseMapper.selectCount(new LambdaQueryWrapper<EquipmentStatisticalInfo>(). eq(EquipmentStatisticalInfo::getEquipment, equipmentId).ge(EquipmentStatisticalInfo::getTheDate, monday).le(EquipmentStatisticalInfo::getTheDate, saturday)); eq(EquipmentStatisticalInfo::getEquipment, equipmentId). ge(EquipmentStatisticalInfo::getTheDate, monday).le(EquipmentStatisticalInfo::getTheDate, saturday)); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
@@ -75,6 +75,13 @@ } } @Override public Long selectSize(String equipmentId, String monday, String saturday) { return this.baseMapper.selectCount(new LambdaQueryWrapper<MdcEquipmentStatisticalInfo>(). eq(MdcEquipmentStatisticalInfo::getEquipmentId, equipmentId). ge(MdcEquipmentStatisticalInfo::getTheDate, monday).le(MdcEquipmentStatisticalInfo::getTheDate, saturday)); } private List<EquipmentStatisticalInfo> dataHandle(List<MdcEquipmentStatisticalInfo> list) { List<EquipmentStatisticalInfo> result = new ArrayList<>(); list.forEach(item -> { lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/subcontrol/service/impl/MdcBigScreenServiceImpl.java
@@ -1,6 +1,7 @@ package org.jeecg.modules.mdc.subcontrol.service.impl; import org.apache.commons.lang.StringUtils; import org.checkerframework.checker.units.qual.A; import org.jeecg.modules.mdc.entity.EquipmentLog; import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.subcontrol.service.MdcBigScreenService; @@ -34,6 +35,8 @@ private IEquipmentStatisticalInfoService equipmentStatisticalInfoService; @Autowired private IMdcEquipmentStatisticalShiftInfoService mdcEquipmentStatisticalShiftInfoService; @Autowired private IMdcEquipmentStatisticalInfoService mdcEquipmentStatisticalInfoService; @Resource @@ -126,11 +129,17 @@ List<LastWeekDataVo> lastWeekDataVos = equipmentStatisticalInfoService.findDataRankingForBigScreen(equipmentIdList, monday, saturday); if (!lastWeekDataVos.isEmpty()) { for (LastWeekDataVo lastWeekDataVo : lastWeekDataVos) { Long size = equipmentStatisticalInfoService.selectSize(lastWeekDataVo.getEquipment(), monday, saturday); lastWeekDataVo.setUtilization(new BigDecimal(String.format("%.2f", (Float.parseFloat(lastWeekDataVo.getProcessingLong()) / (86400 * size) * 100)))); Long size = mdcEquipmentStatisticalInfoService.selectSize(lastWeekDataVo.getEquipment(), monday, saturday); if (StringUtils.isNotEmpty(lastWeekDataVo.getProcessingLong()) && Float.parseFloat(lastWeekDataVo.getProcessingLong()) >0) { lastWeekDataVo.setUtilization(new BigDecimal(String.format("%.2f", (Float.parseFloat(lastWeekDataVo.getProcessingLong()) / (86400 * size) * 100)))); } else { lastWeekDataVo.setUtilization(new BigDecimal(0)); } } List<LastWeekDataVo> collect = lastWeekDataVos.stream().sorted(Comparator.comparing(LastWeekDataVo::getUtilization).reversed()).collect(Collectors.toList()); if (collect.size() > 3) { if (collect.size() > 6) { List<LastWeekDataVo> topList = collect.subList(0, 6); for (LastWeekDataVo vo : topList) { LastWeekDataRankingVo rankingVo = new LastWeekDataRankingVo(); @@ -138,6 +147,13 @@ rankingVo.setTopRate(vo.getUtilization().toString()); voList.add(rankingVo); } } else { for (LastWeekDataVo vo : collect) { LastWeekDataRankingVo rankingVo = new LastWeekDataRankingVo(); rankingVo.setTopName(vo.getEquipment()); rankingVo.setTopRate(vo.getUtilization().toString()); voList.add(rankingVo); } } } lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml
@@ -126,7 +126,7 @@ connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: url: jdbc:sqlserver://192.168.124.118:1433;databasename=LXZN_TEST_COMMON url: jdbc:sqlserver://192.168.1.118:1433;databasename=LXZN_HX_MDC_COMMON username: sa password: 123 driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver @@ -135,7 +135,7 @@ database: 0 host: 127.0.0.1 port: 6379 password: 123456 password: #mybatis plus 设置 mybatis-plus: mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml