| | |
| | | if (Func.isEmpty(members)) { |
| | | ProductionCalendar calendar = (ProductionCalendar)CALENDAR_SERVICE.getOne(Wrappers.<ProductionCalendar>lambdaQuery().eq(ProductionCalendar::getCode, calendarCode)); |
| | | |
| | | return (List) Optional.ofNullable(calendar).map(cal -> { |
| | | return Optional.ofNullable(calendar).map(cal -> { |
| | | ProductionCalendarDay calendarDay = CALENDAR_DAY_SERVICE.getOne((Wrappers.<ProductionCalendarDay>lambdaQuery().eq((v0) -> { |
| | | return v0.getCalendarId(); |
| | | }, cal.getId())).eq((v0) -> { |
| | |
| | | return (Map<String, CurrentShiftInfoDTO>)currentShiftInfoDTOList.stream().distinct().collect(Collectors.toMap(CurrentShiftInfoDTO::getCalendarCode, v -> v)); |
| | | } |
| | | |
| | | /** |
| | | * 构建生产日历切片缓存,从CalendarCacheXxlJob中定时调用 |
| | | * @param cacheBuildDTO |
| | | */ |
| | | public static void build(CacheBuildDTO cacheBuildDTO) { |
| | | String key = cacheBuildDTO.getTargetDate().format(DateTimeFormatter.ISO_LOCAL_DATE); |
| | | List<TimestampToProductionTimeCacheDto> data = CALENDAR_SERVICE.buildProductionTimeCache(cacheBuildDTO); |
| | | if (Func.isNotEmpty(data)) |
| | | data.forEach(t -> { |
| | | String redisKey = CommonUtil.getReallyCacheName("blade:cps::calendar", "calendars:code:".concat(t.getCalendarCode()).concat(":").concat("minute-point:"), key); |
| | | String redisKey = CommonUtil.getReallyCacheName("blade:cps::calendar", "calendars:code:".concat(t.getCalendarCode()).concat(":").concat("minute-point:"), key);//key格式:yyyy-MM-dd |
| | | Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDtoMap = t.getTimeSlicesDTOMap(); |
| | | BLADE_REDIS.getRedisTemplate().opsForHash().putAll(redisKey, timeSlicesDtoMap); |
| | | long oneDaySeconds = 86400L; |
| | | long oneDaySeconds = 86400L;//24小时的秒数 |
| | | BLADE_REDIS.expire(redisKey, oneDaySeconds * 40L); |
| | | }); |
| | | } |
| | |
| | | return (int) ((size / 0.75d) + 1.0d); |
| | | } |
| | | |
| | | /** |
| | | * 拼接redisKey,[cacheName]::[keyPrefix][key] |
| | | * @param cacheName 缓存名称 |
| | | * @param keyPrefix key前缀 |
| | | * @param key 最末端的key |
| | | * @return |
| | | */ |
| | | public static String getReallyCacheName(String cacheName, String keyPrefix, String key) { |
| | | return cacheName.concat("::").concat(keyPrefix).concat(key); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import com.qianwen.smartman.common.cache.cps.WorkstationCache; |
| | | import com.qianwen.core.tool.utils.Func; |
| | |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.modules.cps.dto.CacheBuildDTO; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 生产日历切片缓存任务 |
| | | */ |
| | | @Component |
| | | |
| | | public class CalendarCacheXxlJob { |
| | | private static final Logger log = LoggerFactory.getLogger(CalendarCacheXxlJob.class); |
| | | |
| | |
| | | targetDate = LocalDate.parse(param, DateTimeFormatter.ofPattern(DateConstant.PATTERN_DATE)); |
| | | } |
| | | XxlJobLogger.log("XXL-JOB, 定时构建生产日历切片缓存,构建开始.....", new Object[0]); |
| | | CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(targetDate).build(); |
| | | CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(targetDate).build();//没有calendarCode? |
| | | TimeSliceCache.build(cacheBuildDTO); |
| | | XxlJobLogger.log("XXL-JOB, 定时构建生产日历切片缓存,构建结束", new Object[0]); |
| | | return ReturnT.SUCCESS; |
| | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 采集的数据 |
| | | */ |
| | | public class TelemetryDataResponseDTO implements Serializable { |
| | | private String v; |
| | | private Long t; |
| | |
| | | |
| | | ProductionCalendar saveYearCalendar(CalendarSaveVO calendarSaveVO); |
| | | |
| | | /** |
| | | * 构建生产日历切片缓存对象 |
| | | * @param cacheBuildDTO |
| | | * @return |
| | | */ |
| | | List<TimestampToProductionTimeCacheDto> buildProductionTimeCache(CacheBuildDTO cacheBuildDTO); |
| | | |
| | | List<CalendarSimpleVO> getCalendarList(@RequestParam("tenantId") String tenantId); |
| | |
| | | package com.qianwen.smartman.modules.mdc.constant; |
| | | |
| | | public interface CollectConstant { |
| | | /** |
| | | * 采集数据的最大长度 |
| | | */ |
| | | public static final Integer MAX_VALUE = 256; |
| | | public static final Integer STRING_DATA_TYPE = 11; |
| | | public static final String ALARM = "ALARM"; |
| | |
| | | import com.qianwen.smartman.modules.mdc.service.ICollectDataService; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * xxljob任务,同步当前时间全量参数,从缓存到new_param_json_[工位id]表 |
| | | */ |
| | | @Component |
| | | public class CacheNewCollectXxlJob { |
| | | private static final Logger log = LoggerFactory.getLogger(CacheNewCollectXxlJob.class); |
| | |
| | | import java.util.Set; |
| | | |
| | | public interface ISuperNewCollectService { |
| | | /** |
| | | * 同步当前时间全量参数 |
| | | * @param workstationIds 工位id集合 |
| | | */ |
| | | void insertData(Set<String> workstationIds); |
| | | } |
| | |
| | | import com.qianwen.smartman.modules.mdc.service.ISuperNewCollectService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * super_collect_data_json表入库 |
| | | */ |
| | | @Service |
| | | public class CollectDataServiceImpl implements ICollectDataService { |
| | | private static final Logger log = LoggerFactory.getLogger(CollectDataServiceImpl.class); |
| | |
| | | public class SuperNewCollectServiceImpl implements ISuperNewCollectService { |
| | | private final SuperCollectJsonMapper collectJsonMapper; |
| | | private static final Logger log = LoggerFactory.getLogger(SuperNewCollectServiceImpl.class); |
| | | private static final Map<Integer, String> PROCESS_PARAM_MAP = new HashMap(); |
| | | private static final Map<Integer, String> PROCESS_PARAM_MAP = new HashMap<>(); |
| | | |
| | | static { |
| | | PROCESS_PARAM_MAP.put(1, "STATE"); |
| | |
| | | this.collectJsonMapper = collectJsonMapper; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void insertData(Set<String> workstationIds) { |
| | | List<NewParamSaveDTO> data = workstationIds.stream().map(workstationId -> { |
| | | Map<String, Object> realTimeData = WorkstationCache.getWorkstationAllCollect(workstationId); |
| | | Map<String, Object> realTimeData = WorkstationCache.getWorkstationAllCollect(workstationId);//实时数据, |
| | | if (Func.isNotEmpty(realTimeData)) { |
| | | int size = realTimeData.size(); |
| | | long time = DateUtil.now().getTime(); |
| | | Map<String, String> valuesMap = new HashMap<>(size); |
| | | realTimeData.forEach((n, telemetry) -> { |
| | | if (!n.toUpperCase().contains(CollectConstant.ALARM)) { |
| | | if (!n.toUpperCase().contains(CollectConstant.ALARM)) {//去除ALARM数据 |
| | | TelemetryDataResponseDTO dto = (TelemetryDataResponseDTO) telemetry; |
| | | String v = dto.getV(); |
| | | if (Func.isNotEmpty(v) && v.length() <= CollectConstant.MAX_VALUE.intValue() && !v.contains("timestamp")) { |
| | |
| | | @Resource |
| | | private IEmployeeService employeeService; |
| | | |
| | | /* JADX WARN: Type inference failed for: r0v11, types: [org.springblade.modules.mdc.service.impl.WorkstationFeedbackServiceImpl$1] */ |
| | | |
| | | @Override |
| | | public IPage<WorkstationFeedbackInfoVO> workstationPage(Query query, boolean excludeImmediate) { |
| | | final List<WorkstationFeedback> immediateFeedback = this.selfService.getImmediateFeedback(); |
| | |
| | | IPage<Workstation> page = this.workstationService.page(Condition.getPage(query), Lambda.notIn(excludeImmediate && Func.isNotEmpty(immediateFeedback), (v0) -> { |
| | | return v0.getId(); |
| | | }, workstationList)); |
| | | return new BaseEntityWrapper<Workstation, WorkstationFeedbackInfoVO>() { // from class: org.springblade.modules.mdc.service.impl.WorkstationFeedbackServiceImpl.1 |
| | | return new BaseEntityWrapper<Workstation, WorkstationFeedbackInfoVO>() { |
| | | public WorkstationFeedbackInfoVO entityVO(Workstation entity) { |
| | | WorkstationFeedbackInfoVO vo = new WorkstationFeedbackInfoVO(); |
| | | vo.setWorkstationId(entity.getId()); |
| | |
| | | # tdengine |
| | | tdengine: |
| | | driver: com.taosdata.jdbc.TSDBDriver |
| | | url: jdbc:TAOS://116.63.155.153:6030/iot_data?charset=UTF-8&locale=en_US.UTF-8&cfgdir=taos.cfg |
| | | url: jdbc:TAOS://localhost:6030/iot_data?charset=UTF-8&locale=en_US.UTF-8&cfgdir=taos.cfg |
| | | username: root |
| | | password: taosdata |
| | | |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.qianwen.smartman.modules.mdc.mapper.SuperCollectJsonMapper"> |
| | | |
| | | <!-- 插入采集的参数数据 --> |
| | | <insert id="insertValueJson"> |
| | | insert into |
| | | <foreach separator=" " collection="list" item="item" index="index" > |
| | |
| | | return this.redisTemplate.move(key, dbIndex); |
| | | } |
| | | |
| | | /** |
| | | * 设置指定key的超市时间 |
| | | * @param key redisKey |
| | | * @param seconds 秒数 |
| | | * @return |
| | | */ |
| | | public Boolean expire(String key, long seconds) { |
| | | return this.redisTemplate.expire(key, seconds, TimeUnit.SECONDS); |
| | | } |