状态和绩效时间设置,修改值后清空缓存的key修正,修改位与collect一致
| | |
| | | public static void clearPerfCache(List<Long> workstationIds) { |
| | | List<String> keys = Lists.newArrayList(); |
| | | workstationIds.forEach(wId -> { |
| | | String redisKey = StringUtil.format(ExtCacheConstant.POSTING_WORKSTATION.concat("::").concat(WORK), new Object[]{wId}); |
| | | String redisKey = StringUtil.format(ExtCacheConstant.COLLECT_WORKSTATION.concat("::").concat(WORK), new Object[]{wId}); |
| | | keys.add(redisKey); |
| | | }); |
| | | BLADE_REDIS.del(keys); |
| | |
| | | package com.qianwen.smartman.common.constant; |
| | | |
| | | /** |
| | | * 图表名称常量 |
| | | */ |
| | | public interface ChartNameConstant { |
| | | public static final String DEVICE_RUN_DURATION = "设备运行时长前"; |
| | | /** |
| | | * 特指运行状态 |
| | | */ |
| | | public static final Integer DEVICE_RUN_STATUS = 2; |
| | | public static final Integer DEVICE_WAIT_STATUS = 3; |
| | | public static final String DEVICE_WAIT_DURATION = "设备等待时长前"; |
| | |
| | | package com.qianwen.smartman.common.constant; |
| | | |
| | | /** |
| | | * 缓存常量定义 |
| | | */ |
| | | public interface ExtCacheConstant { |
| | | public static final String CPS_CACHE = "blade:cps"; |
| | | public static final String I18N_CACHE = "blade:i18n"; |
| | | public static final String WORKSTATION_MACHINE = "blade:machine"; |
| | | public static final String POSTING_MACHINE = "posting:machine"; |
| | | public static final String CODE_RULE_CACHE = "blade:codeRule"; |
| | | public static final String POSTING_WORKSTATION = "posting:workstation"; |
| | | public static final String POSTING_CALENDAR = "posting:calendar"; |
| | | //public static final String POSTING_WORKSTATION = "posting:workstation"; |
| | | /** |
| | | * 与采集程序通信的rediskey前缀,必须与采集程序collect取数据定义的一致。改动该值需要两个程序一起改动 |
| | | */ |
| | | public static final String COLLECT_WORKSTATION = "collect:workstation"; |
| | | |
| | | public static final String EMPLOYEE = "blade:employee"; |
| | | public static final String GLOBAL_WCS = "blade:global:wcs"; |
| | | public static final String WORK_FEEDBACK = "blade:feedback"; |
| | |
| | | return R.data(this.statusRecordService.getTimeDistribution(statusRecordDetailSelectVO)); |
| | | } |
| | | |
| | | /** |
| | | * 工位数据,稼动率,报警率,运行率 |
| | | * @param statusRecordDetailSelectVO |
| | | * @return |
| | | */ |
| | | @ApiOperationSupport(order = 4) |
| | | @PostResource({"/equipment-efficiency"}) |
| | | @ApiOperation(value = "查询设备效率", notes = "传入statusRecordDetailSelectVO") |
| | |
| | | return R.data(this.statusRecordService.exportStatusRecord(vo)); |
| | | } |
| | | |
| | | /** |
| | | * 我们自己前端没有调用yys |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | /* |
| | | @ApiOperationSupport(order = 8) |
| | | @PostResource({"/cross-days"}) |
| | | @ApiOperation("分割状态数据跨天数据") |
| | | public R<List<List<SuperAggregateStateVO>>> crossDayState(@Valid @RequestBody CrossDayStateVO vo) { |
| | | return R.data(this.statusRecordService.crossDayState(vo)); |
| | | } |
| | | }*/ |
| | | |
| | | @ApiOperationSupport(order = 9) |
| | | @PostResource({"/status-record-by-dates"}) |
| | |
| | | @DS("iotdb") |
| | | @InterceptorIgnore(tenantLine = FmsConstant.AUTOMATIC) |
| | | public interface SuperAggregateStateMapper { |
| | | void createTable(@Param("workstationId") Long workstationId); |
| | | //void createTable(@Param("workstationId") Long workstationId); |
| | | |
| | | void insertData(@Param("workstationId") Long workstationId, @Param("sql") String sql); |
| | | |
| | |
| | | |
| | | List<SuperAggregateState> listCrossDay(@Param("startTime") String startTime, @Param("endTime") String endTime); |
| | | |
| | | void saveState(@Param("workstationId") Long workstationId, @Param("list") List<SuperAggregateState> list); |
| | | //void saveState(@Param("workstationId") Long workstationId, @Param("list") List<SuperAggregateState> list); |
| | | |
| | | List<SuperAggregateState> listInTime(@Param("workstationIds") List<Long> workstationIdList, @Param("startTime") String startTime, @Param("endTime") String endTime); |
| | | |
| | |
| | | |
| | | BladeFile exportStatusRecord(StatusRecordExcelVO vo); |
| | | |
| | | List<List<SuperAggregateStateVO>> crossDayState(CrossDayStateVO vo); |
| | | //分割状态数据跨天数据 |
| | | //List<List<SuperAggregateStateVO>> crossDayState(CrossDayStateVO vo); |
| | | |
| | | IPage<StatusRecordDateVO> getStatusRecordByDates(IPage<StatusRecordDateVO> page, StatusRecordDateTimeSelectVO statusRecordDateTimeSelectVO); |
| | | } |
| | |
| | | */ |
| | | List<SuperAggregateState> getStatusByTimeSection(List<Long> workstationIds, LocalDateTime startTime, LocalDateTime endTime); |
| | | |
| | | /** |
| | | * 根据状态,起止时间获取聚合状态数据列表 |
| | | * @param workstationIds |
| | | * @param startTime 开始时间 |
| | | * @param endTime 结束时间 |
| | | * @param status 状态值,查询wcs=status的数据 |
| | | * @param top top多少(统计后取出最高的top个数据) |
| | | * @return 数据列表 |
| | | */ |
| | | List<StatusTimeTopVO> getStatusTimeByWcs(List<Long> workstationIds, LocalDateTime startTime, LocalDateTime endTime, Integer status, Integer top); |
| | | |
| | | List<SuperAggregateState> getOeeAnalysis(List<Long> workStationIdList, LocalDateTime startTime, LocalDateTime endTime); |
| | |
| | | |
| | | List<SuperAggregateState> crossDay(LocalDateTime start, LocalDateTime end); |
| | | |
| | | void saveState(List<SuperAggregateState> collect); |
| | | //void saveState(List<SuperAggregateState> collect); |
| | | |
| | | List<SuperAggregateState> getStatusDataByTime(List<Long> workstationIdList, LocalDateTime startTime, LocalDateTime endTime); |
| | | |
| | |
| | | MultipartFile multipartFile = ExcelUtil.exportToMultipartFile(fileName, ExcelConstant.STATUS_RECORD, exportList, StatusRecordExport.class); |
| | | return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | | } |
| | | |
| | | /* |
| | | @Override |
| | | public List<List<SuperAggregateStateVO>> crossDayState(CrossDayStateVO vo) { |
| | | LocalDate date = vo.getDate(); |
| | |
| | | }).collect(Collectors.toList()); |
| | | this.superAggregateStateService.saveState(collect); |
| | | return list; |
| | | } |
| | | }*/ |
| | | |
| | | @Override |
| | | public IPage<StatusRecordDateVO> getStatusRecordByDates(IPage<StatusRecordDateVO> page, StatusRecordDateTimeSelectVO statusRecordDateTimeSelectVO) { |
| | |
| | | @Override |
| | | public List<StatusTimeTopVO> getStatusTimeByWcs(List<Long> workstationIds, LocalDateTime startTime, LocalDateTime endTime, Integer status, Integer top) { |
| | | List<StatusTimeTopVO> voList = new ArrayList<>(); |
| | | |
| | | //查询除所有状态时可用的工位,转换位 工位id -> 工位 的map |
| | | Map<Long, Workstation> workstationMap = this.workstationService.list(Wrappers.<Workstation>lambdaQuery() |
| | | .eq(Workstation::getStatus, CommonConstant.ENABLE)).stream().collect(Collectors.toMap(Workstation::getId, Function.identity())); |
| | | /* |
| | | Map<Long, Workstation> workstationMap = (Map) this.workstationService.list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getStatus(); |
| | | }, 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); |
| | | |
| | | // Date startTimeD = LocalDateUtil.localDateTimeToDate(startTime); |
| | | //startTimeD = new Date(124,8,2); |
| | | //Date endTimeD = LocalDateUtil.localDateTimeToDate(endTime); |
| | | //endTimeD = new Date(124,8,3); |
| | | |
| | | //查询出时间段内wcs=status的所有数据 |
| | | List<SuperAggregateState> equipmentStatusDuration = this.baseMapper.getEquipmentStatusDuration(workstationIds, DateTimeUtil.toDate(startTime), DateTimeUtil.toDate(endTime), status); |
| | | |
| | | List<SuperAggregateState> equipmentStatusDuration2 = FilterOffUtils.filterOffDay(equipmentStatusDuration, OpenTypeEnums.TIME_USED_ANALYSIS); |
| | | List<SuperAggregateState> equipmentStatusDuration2 = FilterOffUtils.filterOffDay(equipmentStatusDuration, OpenTypeEnums.TIME_USED_ANALYSIS);//过滤数据,TIME_USED_ANALYSIS open =1则过滤 |
| | | Map<Long, Long> timeMap = buildDuration(startTime, 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)); |
| | |
| | | List<SuperAggregateState> res = this.baseMapper.listCrossDay(startTime, endTime); |
| | | return buildDuration(res); |
| | | } |
| | | |
| | | /* |
| | | @Override |
| | | public void saveState(List<SuperAggregateState> collect) { |
| | | Map<Long, List<SuperAggregateState>> map = collect.stream().collect(Collectors.groupingBy(SuperAggregate::getWorkstationId)); |
| | | map.forEach(this.baseMapper::saveState); |
| | | /* |
| | | Map<Long, List<SuperAggregateState>> map = collect.stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getWorkstationId(); |
| | | })); |
| | | SuperAggregateStateMapper superAggregateStateMapper = this.baseMapper; |
| | | superAggregateStateMapper.getClass(); |
| | | map.forEach(this::saveState);*/ |
| | | } |
| | | |
| | | } |
| | | */ |
| | | @Override |
| | | public List<SuperAggregateState> getStatusDataByTime(List<Long> workstationIdList, LocalDateTime start, LocalDateTime end) { |
| | | List<SuperAggregateState> superAggregateStateList = new ArrayList<>(); |
| | |
| | | |
| | | public class FilterOffUtils { |
| | | /** |
| | | * 过滤休息日? |
| | | * 过滤数据 |
| | | * @param <R> |
| | | * @param data 聚合状态数据列表 |
| | | * @param openTypeEnums RUNNING/ALARM/OEE等 |
| | |
| | | if (Func.isEmpty(data)) { |
| | | return data; |
| | | } |
| | | boolean filterType = whetherToFilter(OpenTypeEnums.PARAM_KEY_TYPE, openTypeEnums);//mdc_open_type,是否过滤该类型 |
| | | boolean filterShift = whetherToFilter(OpenTypeEnums.PARAM_KEY_SHIFT, openTypeEnums);//mdc_open_shift,是否过滤班制 |
| | | //这里简化,不过滤了,数据在win服务器有,blade_boot_blade_param-0418bak.sql有,是个json数组 |
| | | //获取"分析设置"界面中的过滤配置,没有设置数据则返回false(不过滤) |
| | | boolean filterType = whetherToFilter(OpenTypeEnums.PARAM_KEY_TYPE, openTypeEnums);//mdc_open_type,是否过滤掉休息时段(shiftTimeType=2) |
| | | boolean filterShift = whetherToFilter(OpenTypeEnums.PARAM_KEY_SHIFT, openTypeEnums);//mdc_open_shift,是否过滤班制(shiftIndex>0的数据保留) |
| | | |
| | | if (!filterType && !filterShift) { |
| | | return data; |
| | |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * 是否过滤数据(根据系统参数中的json数据,open==1就过滤) |
| | | * @param typeEnums 过滤分类(班制/或类型) mdc_open_shift/mdc_open_type |
| | | * @param enums 过滤的项目TIME_USED_ANALYSIS/ALARM_ANALYSIS ... |
| | | * @return |
| | | */ |
| | | public static boolean whetherToFilter(OpenTypeEnums typeEnums, OpenTypeEnums enums) { |
| | | String value = ParamCache.getValue(typeEnums.getMsg()); |
| | | if (Func.isNull(value)) { |
| | |
| | | globalWcsOfRps.setRps(wcsAchievements.getRps()); |
| | | globalWcsOfRps.setIsPlan(wcsAchievements.getIsPlan()); |
| | | globalWcsOfRps.insertOrUpdate(); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | globalWcsOfRps.setRps(wcsAchievementsUpdateVO.getRps()); |
| | | globalWcsOfRps.setIsPlan(wcsAchievementsUpdateVO.getIsPlan()); |
| | | globalWcsOfRps.insertOrUpdate(); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE); |
| | | return save(globalWcs); |
| | | } |
| | | } |
| | |
| | | submitWorkstationWorkbench(workstationSubmitVO, workstation); |
| | | WorkstationCache.clearWorkstationCache(); |
| | | WorkstationCache.clearWorkstationRealTime(workstation.getId()); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_MACHINE, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.WORKSTATION_MACHINE, Boolean.FALSE); |
| | | String redisKey = ExtCacheConstant.CPS_CACHE.concat(":").concat(":").concat(WorkstationCache.CRC); |
| | |
| | | return v0.getItemId(); |
| | | }, workstationIds));*/ |
| | | WorkstationCache.clearWorkstationCache(); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_MACHINE, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.WORKSTATION_MACHINE, Boolean.FALSE); |
| | | CacheUtil.clear(redisKey, Boolean.FALSE); |
| | | } |
| | | changeStatus(workstationIds, CommonConstant.DEACTIVATE); |
| | | WorkstationCache.clearWorkstationCache(); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.POSTING_MACHINE, Boolean.FALSE); |
| | | CacheUtil.clear(ExtCacheConstant.WORKSTATION_MACHINE, Boolean.FALSE); |
| | | CacheUtil.clear(redisKey, Boolean.FALSE); |
| | |
| | | return R.data(this.visualStatusService.getVisualStatusRecord(visualBaseVO)); |
| | | } |
| | | |
| | | /** |
| | | * 首页卡片运行时长排名 |
| | | * @param timeStatusVO |
| | | * @return |
| | | */ |
| | | @ApiOperationSupport(order = 2) |
| | | @PostResource({"/running-top"}) |
| | | @ApiOperation(value = "设备运行时长TOP", notes = "传入timeStatusVO") |
| | |
| | | public interface IVisualStatusService { |
| | | ChartGanttStatusDataVO getVisualStatusRecord(VisualBaseVO visualBaseVO); |
| | | |
| | | /** |
| | | * 查询图表 |
| | | * @param timeStatusVO |
| | | * @param status 设备状态值 |
| | | * @return |
| | | */ |
| | | ChartSeriesDataVO getDeviceStatusDuration(TimeStatusVO timeStatusVO, Integer status); |
| | | |
| | | ChartNameValueDataVO getStatusDistribution(VisualBaseVO vo); |
| | |
| | | return new ChartSeriesDataVO(); |
| | | } |
| | | List<Long> workStationIdList = timeStatusVO.getWorkStationIdList(); |
| | | String timeLevel = timeStatusVO.getTimeLevel(); |
| | | Integer top = timeStatusVO.getTop(); |
| | | String timeLevel = timeStatusVO.getTimeLevel();//小时数,如24小时 |
| | | Integer top = timeStatusVO.getTop();//查询多少个 |
| | | VisualTimeDTO visualTimeDTO = VisualUtils.getTimeSectionByLevel(timeLevel); |
| | | List<StatusTimeTopVO> statusTimeByWcs = this.superAggregateStateService.getStatusTimeByWcs(workStationIdList, visualTimeDTO.getStartTime(), visualTimeDTO.getEndTime(), status, top); |
| | | return this.wrapper.deviceStatusDuration(statusTimeByWcs, status, top); |
| | |
| | | private static final IOssService ossService = (IOssService) SpringUtil.getBean(IOssService.class); |
| | | |
| | | |
| | | /** |
| | | * 根据level(小时数)获取起止时间 |
| | | * @param level 小时数 |
| | | * @return 包含起止时间对象 |
| | | */ |
| | | public static VisualTimeDTO getTimeSectionByLevel(String level) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime startTime = now.minusHours(Long.parseLong(level)); |
| | |
| | | |
| | | |
| | | public class TimeStatusVO extends VisualBaseVO { |
| | | /** |
| | | * top x,查询最高的几条 |
| | | */ |
| | | @ApiModelProperty("设备top数据") |
| | | private Integer top; |
| | | |
| | |
| | | @Size(min = 1, message = "工位ID不能为空") |
| | | private List<Long> workStationIdList; |
| | | @ApiModelProperty("时间等级") |
| | | private String timeLevel; |
| | | private String timeLevel;//running-top中是小时数 |
| | | |
| | | public void setWorkStationIdList(final List<Long> workStationIdList) { |
| | | this.workStationIdList = workStationIdList; |
| | |
| | | # redis |
| | | redis: |
| | | host: localhost |
| | | host: 120.46.212.231 |
| | | port: 6379 |
| | | password: root |
| | | database: 1 |
| | | database: 5 |
| | | ssl: false |
| | | # database config |
| | | datasource: |
| | | type: mysql |
| | | url: 120.46.212.231 |
| | | port: 3306 |
| | | database: smart_boot |
| | | database: smartman |
| | | username: qwmdc |
| | | password: Kknd_1234 |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | insert into iot_data.aggregate_state_${workstationId} |
| | | values ${sql} |
| | | </insert> |
| | | |
| | | <!-- |
| | | <insert id="saveState"> |
| | | insert into iot_data.aggregate_state_${workstationId} USING iot_data.super_aggregate_state |
| | | TAGS(${workstationId}) values |
| | |
| | | #{workstationId} |
| | | ) |
| | | </update> |
| | | |
| | | --> |
| | | <select id="countStatsShiftEndTimeNotNull" resultType="com.qianwen.smartman.modules.mdc.dto.CountResult"> |
| | | select sum(duration_collect) as nums, value_collect status |
| | | from iot_data.super_aggregate_state |
| | |
| | | </foreach> |
| | | align by device |
| | | </select> |
| | | |
| | | <!-- 这个有用吗 --> |
| | | <select id="listCrossDay" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState"> |
| | | select ts as startTime, |
| | | end_time as endTime, |