From b2bf1b7afaab2c4c0858be22f6aae0402435dd18 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期三, 04 九月 2024 20:24:01 +0800
Subject: [PATCH] 首页稼动率排名,在线时长排名
---
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/IProcessParameterService.java | 2
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/entity/SuperAggregateState.java | 15 ++
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.java | 18 +++
smart-man-boot/src/main/resources/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.xml | 127 ++++++++++++-------------
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/SuperAggregateStateServiceImpl.java | 58 +++++++++--
smart-man-boot/src/main/java/com/qianwen/smartman/modules/visual/wrapper/StatusWrapper.java | 9 +
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/WorkstationAnalysisServiceImpl.java | 7 -
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/ISuperAggregateStateService.java | 7 +
8 files changed, 155 insertions(+), 88 deletions(-)
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/entity/SuperAggregateState.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/entity/SuperAggregateState.java
index 5a639e8..a16ed34 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/entity/SuperAggregateState.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/entity/SuperAggregateState.java
@@ -3,6 +3,7 @@
import java.sql.Timestamp;
public class SuperAggregateState extends SuperAggregate {
+ private Timestamp time;
private Timestamp startTime;
private Timestamp endTime;
/**
@@ -151,8 +152,16 @@
return (result10 * 59) + ($endTime == null ? 43 : $endTime.hashCode());
}
- public void setStartTime(final Timestamp startTime) {
- this.startTime = startTime;
+ public Timestamp getTime() {
+ return time;
+ }
+
+ public void setTime(Timestamp time) {
+ this.time = time;
+ }
+
+ public void setStartTime(final Timestamp startTime) {
+ this.time = startTime;
}
public void setEndTime(final Timestamp endTime) {
@@ -213,7 +222,7 @@
}
public Timestamp getStartTime() {
- return this.startTime;
+ return this.time;
}
public Timestamp getEndTime() {
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.java
index bf52183..4982ee5 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.java
@@ -2,6 +2,9 @@
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+
+import java.time.LocalDateTime;
+import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.qianwen.smartman.common.constant.FmsConstant;
@@ -51,19 +54,28 @@
List<SuperAggregateState> getStatusData(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
/**
- * 鏍规嵁宸ヤ綅id鍒楄〃鍜屾椂闂磋妭鐐硅幏鍙栫姸鎬佹暟鎹畒ys
+ * 鏍规嵁宸ヤ綅id鍒楄〃鍜屾椂闂磋妭鐐硅幏鍙栫姸鎬佹暟鎹畒ys,棣栭〉绋煎姩鐜囨椂浣跨敤鐨�
* @param workstationIds
* @param startDate
* @param endDate
* @return
*/
- List<SuperAggregateState> getStatusDataByTimeSection(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
+ List<SuperAggregateState> getStatusDataByTimeSection(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate);
List<SuperAggregateState> getStatusDataByFactoryDate(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
List<SuperAggregateState> getStatusDataByFactoryDateAndWorkstationId(@Param("workstationId") Long workstationId, @Param("startDate") String startDate, @Param("endDate") String endDate);
- List<SuperAggregateState> getEquipmentStatusDuration(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("status") Integer status);
+ /**
+ * 鑾峰彇璁惧杩愯鏃堕暱鎵�闇�鍏ㄩ儴鐘舵�佹暟鎹紝娆㈣繋椤甸潰灏忛儴浠惰皟鐢�.yys 锛屾棩鏈熷弬鏁扮敱string鏀逛负localdatetime
+ * @param workstationIds
+ * @param startDate 寮�濮嬫椂闂�
+ * @param endDate 鎴嚦鏃堕棿
+ * @param status 鎸囧畾鐨勭姸鎬�
+ * @return
+ */
+ //List<SuperAggregateState> getEquipmentStatusDuration(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("status") Integer status);
+ List<SuperAggregateState> getEquipmentStatusDuration(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate, @Param("status") Integer status);
List<SuperAggregateState> getEquipmentStatusRecord(@Param("workstationIds") List<Long> workstationIds, @Param("shiftIndex") Integer shiftIndex, @Param("factoryDate") Integer factoryDate);
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/IProcessParameterService.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/IProcessParameterService.java
index 8a74230..f2a4d34 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/IProcessParameterService.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/IProcessParameterService.java
@@ -39,7 +39,7 @@
List<AllShiftTimeDetail> getAllShiftTime(WorkstationShiftSearchVO vo);
/**
- * 鏌ヨ宸ヤ綅鏈�鏂扮殑鍙傛暟鍊�
+ * 鏌ヨ宸ヤ綅鏈�鏂扮殑鍙傛暟鍊硷紙鐢眂ollect淇濆瓨鐨勶級
* @param workstationId 宸ヤ綅id
* @return 鍙傛暟鍊煎垪琛紙n,v锛�
*/
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/ISuperAggregateStateService.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/ISuperAggregateStateService.java
index a8bb827..6e3166a 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/ISuperAggregateStateService.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/ISuperAggregateStateService.java
@@ -14,6 +14,13 @@
List<SuperAggregateState> getStatusByCondition(List<Long> workstationIds, LocalDateTime startTime, LocalDateTime endTime);
+ /**
+ * 缁熻棣栭〉绋煎姩鐜囨帓鍚嶆椂浣跨敤鐨勬煡璇�
+ * @param workstationIds
+ * @param startTime
+ * @param endTime
+ * @return
+ */
List<SuperAggregateState> getStatusByTimeSection(List<Long> workstationIds, LocalDateTime startTime, LocalDateTime endTime);
List<StatusTimeTopVO> getStatusTimeByWcs(List<Long> workstationIds, LocalDateTime startTime, LocalDateTime endTime, Integer status, Integer top);
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/SuperAggregateStateServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/SuperAggregateStateServiceImpl.java
index 5e7142f..dba1f4a 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/SuperAggregateStateServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/SuperAggregateStateServiceImpl.java
@@ -24,6 +24,7 @@
import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.smartman.common.constant.DateConstant;
import com.qianwen.smartman.common.utils.LocalDateTimeUtils;
+import com.qianwen.smartman.common.utils.LocalDateUtil;
import com.qianwen.smartman.modules.cps.entity.Workstation;
import com.qianwen.smartman.modules.cps.service.IWorkstationService;
import com.qianwen.smartman.modules.mdc.entity.SuperAggregate;
@@ -82,7 +83,8 @@
@Override
public List<SuperAggregateState> getStatusByTimeSection(List<Long> workstationIds, LocalDateTime startTime, LocalDateTime endTime) {
- List<SuperAggregateState> statusDataList = this.baseMapper.getStatusDataByTimeSection(workstationIds, LocalDateTimeUtil.format(startTime, DateConstant.PATTERN_DATE_TIME), LocalDateTimeUtil.format(endTime, DateConstant.PATTERN_DATE_TIME));
+ //List<SuperAggregateState> statusDataList = this.baseMapper.getStatusDataByTimeSection(workstationIds, LocalDateTimeUtil.format(startTime, DateConstant.PATTERN_DATE_TIME), LocalDateTimeUtil.format(endTime, DateConstant.PATTERN_DATE_TIME));
+ List<SuperAggregateState> statusDataList = this.baseMapper.getStatusDataByTimeSection(workstationIds, startTime, endTime);
return buildDuration(startTime, statusDataList);
}
@@ -97,8 +99,21 @@
}, CommonConstant.ENABLE)).stream().collect(Collectors.toMap((v0) -> {
return v0.getId();
}, Function.identity()));*/
- List<SuperAggregateState> equipmentStatusDuration = this.baseMapper.getEquipmentStatusDuration(workstationIds, LocalDateTimeUtil.format(startTime, DateConstant.PATTERN_DATE_TIME), LocalDateTimeUtil.format(endTime, DateConstant.PATTERN_DATE_TIME), status);
- Map<Long, Long> timeMap = buildDuration(startTime, equipmentStatusDuration).stream().collect(Collectors.groupingBy(SuperAggregate::getWorkstationId, Collectors.summingLong(SuperAggregateState::getDurationCollect))).entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).limit(top.intValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, java.util.LinkedHashMap::new));
+ //List<SuperAggregateState> equipmentStatusDuration = this.baseMapper.getEquipmentStatusDuration(workstationIds, LocalDateTimeUtil.format(startTime, DateConstant.PATTERN_DATE_TIME), LocalDateTimeUtil.format(endTime, DateConstant.PATTERN_DATE_TIME), status);
+
+ Date startTimeD = LocalDateUtil.localDateTimeToDate(startTime);
+ startTimeD = new Date(124,8,2);
+ Date endTimeD = LocalDateUtil.localDateTimeToDate(endTime);
+ endTimeD = new Date(124,8,3);
+
+ LocalDateTime startTime2 = LocalDateTime.of(2024, 9, 2, 1, 0);
+ LocalDateTime endTime2 = LocalDateTime.of(2024, 9, 3, 1, 0);
+ List<SuperAggregateState> equipmentStatusDuration = this.baseMapper.getEquipmentStatusDuration(workstationIds, startTime2, endTime2, status);
+
+ List<SuperAggregateState> equipmentStatusDuration2 = FilterOffUtils.filterOffDay(equipmentStatusDuration, OpenTypeEnums.TIME_USED_ANALYSIS);
+ Map<Long, Long> timeMap = buildDuration(startTime2, equipmentStatusDuration2).stream().collect(Collectors.groupingBy(SuperAggregate::getWorkstationId, Collectors.summingLong(SuperAggregateState::getDurationCollect))).entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).limit(top.intValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, java.util.LinkedHashMap::new));
+ //yangys鏀逛簡buildDuration锛屽幓鎺変簡startTime鍙傛暟
+ //Map<Long, Long> timeMap = buildDuration(equipmentStatusDuration2,ChronoUnit.SECONDS).stream().collect(Collectors.groupingBy(SuperAggregate::getWorkstationId, Collectors.summingLong(SuperAggregateState::getDurationCollect))).entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).limit(top.intValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, java.util.LinkedHashMap::new));
/*
Map<Long, Long> timeMap = (buildDuration(startTime, FilterOffUtils.filterOffDay(equipmentStatusDuration, OpenTypeEnums.TIME_USED_ANALYSIS)).stream().collect(Collectors.groupingBy((v0) -> {
return v0.getWorkstationId();
@@ -113,8 +128,8 @@
}, LinkedHashMap::new));*/
timeMap.forEach((k, v) -> {
StatusTimeTopVO statusTimeTopVO = new StatusTimeTopVO();
- statusTimeTopVO.setValue(Double.valueOf(secondToHour(v)));
- statusTimeTopVO.setWorkstation((Workstation) workstationMap.get(k));
+ statusTimeTopVO.setValue(secondToHour(v));//
+ statusTimeTopVO.setWorkstation(workstationMap.get(k));
voList.add(statusTimeTopVO);
});
return voList;
@@ -122,7 +137,10 @@
@Override
public List<SuperAggregateState> getOeeAnalysis(List<Long> workStationIdList, LocalDateTime startTime, LocalDateTime endTime) {
- List<SuperAggregateState> statusDataList = this.baseMapper.getEquipmentStatusDuration(workStationIdList, LocalDateTimeUtil.format(startTime, DateConstant.PATTERN_DATE_TIME), LocalDateTimeUtil.format(endTime, DateConstant.PATTERN_DATE_TIME), null);
+ Date startTimeD = LocalDateUtil.localDateTimeToDate(startTime);
+ Date endTimeD = LocalDateUtil.localDateTimeToDate(endTime);
+ //List<SuperAggregateState> statusDataList = this.baseMapper.getEquipmentStatusDuration(workStationIdList, LocalDateTimeUtil.format(startTime, DateConstant.PATTERN_DATE_TIME), LocalDateTimeUtil.format(endTime, DateConstant.PATTERN_DATE_TIME), null);
+ List<SuperAggregateState> statusDataList = this.baseMapper.getEquipmentStatusDuration(workStationIdList, startTime, endTime, null);
return buildDuration(startTime, FilterOffUtils.filterOffDay(statusDataList, OpenTypeEnums.OEE));
}
@@ -288,24 +306,44 @@
private List<SuperAggregateState> buildDuration(List<SuperAggregateState> statusDataShift) {
Date now = DateUtil.now();
statusDataShift.forEach(x -> {
- if (Func.isEmpty(x.getEndTime())) {
+ if (Func.isEmpty(x.getEndTime()) || x.getEndTime().toLocalDateTime().getYear()==1970) {
x.setEndTime(new Timestamp(now.getTime()));
}
- x.setDurationCollect(Long.valueOf(LocalDateTimeUtils.betweenTwoTime(x.getStartTime().toLocalDateTime(), x.getEndTime().toLocalDateTime(), ChronoUnit.MILLIS)));
+ x.setDurationCollect(LocalDateTimeUtils.betweenTwoTime(x.getStartTime().toLocalDateTime(), x.getEndTime().toLocalDateTime(), ChronoUnit.MILLIS));
+ System.out.println(x);
});
return statusDataShift;
}
+ /**
+ * 璁剧疆鏃堕棿宸�
+ * @param statusDataShift
+ * @param chUnit
+ * @return
+ */
+ private List<SuperAggregateState> buildDuration(List<SuperAggregateState> statusDataShift, ChronoUnit chUnit) {
+ Date now = DateUtil.now();
+ statusDataShift.forEach(x -> {
+ if (Func.isEmpty(x.getEndTime()) || x.getEndTime().toLocalDateTime().getYear()==1970) {
+ x.setEndTime(new Timestamp(now.getTime()));
+ }
+ x.setDurationCollect(LocalDateTimeUtils.betweenTwoTime(x.getStartTime().toLocalDateTime(), x.getEndTime().toLocalDateTime(), chUnit));
+ System.out.println("s="+x);
+ });
+ return statusDataShift;
+ }
+
private List<SuperAggregateState> buildDuration(LocalDateTime startTime, List<SuperAggregateState> statusDataShift) {
Date now = DateUtil.now();
statusDataShift.forEach(x -> {
- if (Func.isEmpty(x.getEndTime())) {
+ if (Func.isEmpty(x.getEndTime()) || x.getEndTime().toLocalDateTime().getYear()==1970) {
x.setEndTime(new Timestamp(now.getTime()));
}
if (x.getStartTime().toLocalDateTime().isBefore(startTime)) {
x.setStartTime(Timestamp.valueOf(startTime));
}
- x.setDurationCollect(Long.valueOf(LocalDateTimeUtils.betweenTwoTime(x.getStartTime().toLocalDateTime(), x.getEndTime().toLocalDateTime(), ChronoUnit.MILLIS)));
+ x.setDurationCollect(LocalDateTimeUtils.betweenTwoTime(x.getStartTime().toLocalDateTime(), x.getEndTime().toLocalDateTime(), ChronoUnit.MILLIS));
+ System.out.println(x);
});
return statusDataShift;
}
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/WorkstationAnalysisServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/WorkstationAnalysisServiceImpl.java
index d0338f1..6b9b0fe 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/WorkstationAnalysisServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/WorkstationAnalysisServiceImpl.java
@@ -190,13 +190,8 @@
}).collect(Collectors.toList());
}
- Set<String> wIds = workstationList.stream().map((v0) -> {
- return v0.getId();
- }).map((v0) -> {
- return String.valueOf(v0);
- }).collect(Collectors.toSet());
+ Set<String> wIds = workstationList.stream().map(Workstation::getId).map(String::valueOf).collect(Collectors.toSet());
- //Set<String> wIds1 = workstationList.stream().map(Workstation::getId).map(String::valueOf).collect(Collectors.toSet());
//deviceMap key涓簑cs鐨刢ode鍊硷紝value鏄澶囨暟閲忥紙璇ョ姸鎬佺殑锛�
Map<String, Long> deviceMap = wIds.stream().map(wId -> {
Map<String, Object> realTimeData = WorkstationCache.getWorkstationAllCollect(wId);
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/visual/wrapper/StatusWrapper.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/visual/wrapper/StatusWrapper.java
index d396552..e716a43 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/visual/wrapper/StatusWrapper.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/visual/wrapper/StatusWrapper.java
@@ -158,6 +158,15 @@
return vo;
}
+ /**
+ * 瀹炰綋杞崲涓洪椤礦O
+ * @param statusByCondition
+ * @param productivityTypeEnum
+ * @param top
+ * @param workstations
+ * @param name
+ * @return
+ */
public ChartSeriesDataVO entityToEfficiencyTopVo(List<SuperAggregateState> statusByCondition, ProductivityTypeEnum productivityTypeEnum, Integer top, List<Workstation> workstations, String name) {
Map<Long, Workstation> workstationMap = workstations.stream().collect(Collectors.toMap((v0) -> {
return v0.getId();
diff --git a/smart-man-boot/src/main/resources/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.xml b/smart-man-boot/src/main/resources/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.xml
index af876a4..1fac162 100644
--- a/smart-man-boot/src/main/resources/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.xml
+++ b/smart-man-boot/src/main/resources/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateStateMapper.xml
@@ -428,34 +428,7 @@
is_plan as isPlan
</sql>
- <select id="getStatusDataByTimeSection"
- resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
- select
- <include refid="superAggregateStateColumnSql"/>
- from iot_data.super_aggregate_state
- where is_deleted = 0
- and wcs > 0
- and ts <![CDATA[<]]> #{startDate} and #{startDate} <![CDATA[<=]]> end_time
- <if test="workstationIds != null and workstationIds.size() > 0">
- AND workstation_id IN
- <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- union all
- select
- <include refid="superAggregateStateColumnSql"/>
- from iot_data.super_aggregate_state
- where is_deleted = 0
- and wcs > 0
- and ts <![CDATA[>=]]> #{startDate} and ts <![CDATA[<=]]> #{endDate}
- <if test="workstationIds != null and workstationIds.size() > 0">
- AND workstation_id IN
- <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </select>
+
<select id="getStatusDataByFactoryDate"
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
@@ -487,42 +460,7 @@
</if>
</select>
- <select id="getEquipmentStatusDuration"
- resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
- select
- <include refid="superAggregateStateColumnSql"/>
- from iot_data.super_aggregate_state
- where ts <![CDATA[<]]> #{startDate} and #{startDate} <![CDATA[<=]]> end_time
- and is_deleted = 0
- and rps > 0
- and wcs > 0
- <if test="workstationIds != null and workstationIds.size() > 0">
- AND workstation_id IN
- <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="status != null and status !=''">
- and wcs =#{status}
- </if>
- union all
- select
- <include refid="superAggregateStateColumnSql"/>
- from iot_data.super_aggregate_state
- where ts <![CDATA[>=]]> #{startDate} and ts <![CDATA[<=]]> #{endDate}
- and is_deleted = 0
- and rps > 0
- and wcs > 0
- <if test="workstationIds != null and workstationIds.size() > 0">
- AND workstation_id IN
- <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="status != null and status !=''">
- and wcs =#{status}
- </if>
- </select>
+
<select id="getEquipmentStatusRecord" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
select ts as startTime,
@@ -1124,6 +1062,65 @@
and is_deleted = 0
</select>
-
+ <!-- 璋冩暣鐨剆ql寮�濮� -->
+ <sql id="aggregateStateColumnSql">
+
+ end_time as endTime,
+ duration_collect as durationCollect,
+ value_collect as valueCollect,
+ calendar_code as calendarCode,
+ factory_year as factoryYear,
+ factory_month as factoryMonth,
+ factory_week as factoryWeek,
+ factory_date as factoryDate,
+ shift_index as shiftIndex,
+ shift_time_type as shiftTimeType,
+ wcs,
+ rps,
+ is_deleted as isDeleted,
+ workstation_id as workstationId,
+ is_plan as isPlan
+ </sql>
+ <!-- 鍘熸潵鏄痷nion2涓猻ql锛岀幇鍦ㄥ悎骞舵湭涓�涓� -->
+ <!--
+ OK: where ((time <![CDATA[<]]> #{startDate} and end_time <![CDATA[>=]]> #{startDate.time}) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate.time}))
+ where ((time <![CDATA[<]]> #{startDate} and #{startDate.time} <![CDATA[<=]]> end_time) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate.time})) -->
+ <select id="getEquipmentStatusDuration"
+ resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
+ select
+ <include refid="aggregateStateColumnSql"/>
+ from root.f2.aggregate_state_*
+ where ((time <![CDATA[<]]> #{startDate} and end_time <![CDATA[>=]]> #{startDate}) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate}))
+ and is_deleted=false
+ and rps > 0
+ and wcs > 0
+ <if test="workstationIds != null and workstationIds.size() > 0">
+ AND workstation_id IN
+ <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
+ #{id}
+ </foreach>
+ </if>
+ <if test="status != null and status !=''">
+ and wcs =#{status}
+ </if>
+ align by device
+ </select>
+
+ <select id="getStatusDataByTimeSection"
+ resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
+ select
+ <include refid="aggregateStateColumnSql"/>
+ from root.f2.aggregate_state_*
+ where is_deleted = false
+ and wcs > 0
+ and ((time <![CDATA[<]]> #{startDate} and end_time <![CDATA[>=]]> #{startDate}) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate}))
+ <if test="workstationIds != null and workstationIds.size() > 0">
+ AND workstation_id IN
+ <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
+ #{id}
+ </foreach>
+ </if>
+ align by device
+ </select>
</mapper>
--
Gitblit v1.9.3