| | |
| | | import java.sql.Timestamp; |
| | | |
| | | public class SuperAggregateState extends SuperAggregate { |
| | | private Timestamp time; |
| | | private Timestamp startTime; |
| | | private Timestamp endTime; |
| | | /** |
| | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | public Timestamp getStartTime() { |
| | | return this.startTime; |
| | | return this.time; |
| | | } |
| | | |
| | | public Timestamp getEndTime() { |
| | |
| | | |
| | | 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; |
| | |
| | | List<SuperAggregateState> getStatusData(@Param("workstationIds") List<Long> workstationIds, @Param("startDate") String startDate, @Param("endDate") String endDate); |
| | | |
| | | /** |
| | | * 根据工位id列表和时间节点获取状态数据yys |
| | | * 根据工位id列表和时间节点获取状态数据yys,首页稼动率时使用的 |
| | | * @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); |
| | | |
| | |
| | | List<AllShiftTimeDetail> getAllShiftTime(WorkstationShiftSearchVO vo); |
| | | |
| | | /** |
| | | * 查询工位最新的参数值 |
| | | * 查询工位最新的参数值(由collect保存的) |
| | | * @param workstationId 工位id |
| | | * @return 参数值列表(n,v) |
| | | */ |
| | |
| | | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | |
| | | @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); |
| | | } |
| | | |
| | |
| | | }, 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(); |
| | |
| | | }, 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; |
| | |
| | | |
| | | @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)); |
| | | } |
| | | |
| | |
| | | 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; |
| | | } |
| | |
| | | }).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为wcs的code值,value是设备数量(该状态的) |
| | | Map<String, Long> deviceMap = wIds.stream().map(wId -> { |
| | | Map<String, Object> realTimeData = WorkstationCache.getWorkstationAllCollect(wId); |
| | |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 实体转换为首页VO |
| | | * @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(); |
| | |
| | | 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"> |
| | |
| | | </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, |
| | |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | |
| | | <!-- 调整的sql开始 --> |
| | | <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> |
| | | <!-- 原来是union2个sql,现在合并未一个 --> |
| | | <!-- |
| | | 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> |
| | | |