| | |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| | | <java.version>1.8</java.version> |
| | | <!-- |
| | | <druid.version>1.1.18</druid.version> |
| | | --> |
| | | <druid.version>1.2.8</druid.version> |
| | | <fastjson.version>1.2.58</fastjson.version> |
| | | <commons-io.version>2.10.0</commons-io.version> |
| | | <commons-codec.version>1.10</commons-codec.version> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.cache; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | import com.qianwen.core.tool.utils.SpringUtil; |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftTimeSlicesDTO; |
| | | import com.qianwen.mdc.collect.dto.TimestampToProductionTimeCacheDto; |
| | | import com.qianwen.mdc.collect.service.CalendarService; |
| | | import com.qianwen.mdc.collect.utils.CommonUtil; |
| | | import com.qianwen.mdc.collect.utils.redis.RedisUtil; |
| | | |
| | | /* |
| | | |
| | | import com.qianwen.posting.dto.CacheBuildDTO; |
| | | import com.qianwen.posting.dto.CalendarShiftTimeSlicesDTO; |
| | | import com.qianwen.posting.dto.TimestampToProductionTimeCacheDto; |
| | | import com.qianwen.posting.service.ICalendarService; |
| | | import com.qianwen.posting.utils.CommonUtil; |
| | | */ |
| | | @Component |
| | | public class TimeSliceCache { |
| | | public static final String CALENDAR = "calendar"; |
| | | public static final String CALENDARS_CODE = "calendar:code:"; |
| | | public static final String MINUTE_POINT = "minute-point:"; |
| | | private static final Logger log = LoggerFactory.getLogger(TimeSliceCache.class); |
| | | //private static final BladeRedis bladeRedis = (BladeRedis) SpringUtil.getBean(BladeRedis.class); |
| | | //private static final ICalendarService calendarService = (ICalendarService) SpringUtil.getBean(ICalendarService.class); |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private CalendarService calendarService; |
| | | |
| | | |
| | | public CalendarShiftTimeSlicesDTO getTimeSliceShift(String calendarCode, Date date) { |
| | | int minutes = (DateTime.of(date).hour(true) * 60) + DateTime.of(date).minute();//æ¥æè½¬å为åéæ°ï¼ä½ä¸ºhash keyä»redisååçæ°æ®æ°æ® |
| | | String redisKey = CommonUtil.getReallyCacheName("posting:calendar", CALENDARS_CODE.concat(calendarCode).concat(":").concat(MINUTE_POINT), DateTime.of(date).toDateStr()); |
| | | //return (CalendarShiftTimeSlicesDTO) bladeRedis.hGet(redisKey, Integer.valueOf(minutes)); |
| | | |
| | | return (CalendarShiftTimeSlicesDTO) redisUtil.hget(redisKey, minutes+""); |
| | | } |
| | | |
| | | //æå»ºå¹¶ä¿åæ¶é´åçï¼ä¿åå°redis |
| | | |
| | | public void build(CacheBuildDTO cacheBuildDTO) { |
| | | String key = cacheBuildDTO.getTargetDate().format(DateTimeFormatter.ISO_LOCAL_DATE); |
| | | List<TimestampToProductionTimeCacheDto> data = calendarService.buildProductionTimeCache(cacheBuildDTO);//æ¥è¯¢ç产æ¥åï¼å¹¶è®¡ç®åºæ¶é´åç |
| | | data.forEach(t -> { |
| | | String redisKey = CommonUtil.getReallyCacheName("posting:calendar", CALENDARS_CODE.concat(t.getCalendarCode()).concat(":").concat(MINUTE_POINT), key); |
| | | Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDtoMap = t.getTimeSlicesDTOMap(); |
| | | //bladeRedis.getRedisTemplate().opsForHash().putAll(redisKey, timeSlicesDtoMap); |
| | | //bladeRedis.expire(redisKey, 259200L); |
| | | redisUtil.hmset(redisKey, timeSlicesDtoMap, 259200L); |
| | | }); |
| | | } |
| | | } |
| | |
| | | @Autowired |
| | | private GlobalWcsOfRpsMapper globalWcsOfRpsMapper; |
| | | @Autowired |
| | | private WorkstationService workStationService; |
| | | private WorkstationService workstationService; |
| | | //private static final EmployeeOnOffWorkMapper employeeOnOffWorkMapper = (EmployeeOnOffWorkMapper) SpringUtil.getBean(EmployeeOnOffWorkMapper.class); |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | private Map<Long, WorkstationDTO> setWorkStations() { |
| | | List<Workstation> list = workStationService.list(); |
| | | List<Workstation> list = workstationService.list(); |
| | | String redisKey = "posting:workstation".concat("::").concat(WORKSTATION_ALL); |
| | | |
| | | list.forEach(ws -> { |
| | |
| | | String redisKey = "posting:workstation".concat("::").concat(WORKSTATION_ALL); |
| | | return bladeRedis.del(redisKey); |
| | | } |
| | | |
| | | public static String getWorkstationCalendarCodeForDate(Long workstationId, String date) { |
| | | */ |
| | | /** |
| | | * è·åæå®æ¥æçæ¥å代ç |
| | | * @param workstationId |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public String getWorkstationCalendarCodeForDate(Long workstationId, String date) { |
| | | String redisKey = "posting:workstation".concat("::").concat(WORKSTATION_ID).concat(workstationId.toString().concat(CALENDAR_DATE)).concat(date); |
| | | String calendarCode = (String) bladeRedis.get(redisKey); |
| | | if (Func.isEmpty(calendarCode)) { |
| | | log.warn("è·åå·¥ä½{}æå®æ¥æ{}æ¥åç¼åä¸åå¨", workstationId, date); |
| | | Optional.ofNullable(workStationService.getById(workstationId)).ifPresent(workStation -> { |
| | | bladeRedis.setEx(redisKey, workStation.getCalendarCode(), 259200L); |
| | | //String calendarCode = (String) bladeRedis.get(redisKey); |
| | | String calendarCode = (String) redisUtil.get(redisKey); |
| | | if (ObjectUtil.isEmpty(calendarCode)) { |
| | | log.warn("è·åå·¥ä½{}æå®æ¥æ{}æ¥åç¼åä¸åå¨,仿°æ®åºå
è·åå¹¶çæç¼å", workstationId, date); |
| | | Optional.ofNullable(workstationService.getById(workstationId)).ifPresent(workStation -> { |
| | | //bladeRedis.setEx(redisKey, workStation.getCalendarCode(), 259200L); |
| | | redisUtil.set(redisKey, workStation.getCalendarCode(), 259200L); |
| | | }); |
| | | } |
| | | return (String) bladeRedis.get(redisKey); |
| | | |
| | | //return (String) bladeRedis.get(redisKey); |
| | | return calendarCode; |
| | | } |
| | | */ |
| | | |
| | | public GlobalWcsOfRps getWorkstationWcsSetting(Long workstationId, String code) { |
| | | String redisKey = "posting:workstation".concat("::").concat(WORKSTATION_ID).concat(workstationId.toString() |
| | | .concat(WCS_SETTING)); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.controller; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.google.common.collect.Sets; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.mdc.collect.cache.TimeSliceCache; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftInfoDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.Output; |
| | | import com.qianwen.mdc.collect.entity.iotdb.ProcessParam; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.OutputMapper; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.ProcessParamMapper; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper; |
| | | import com.qianwen.mdc.collect.mqtt.MqttMessageSender; |
| | | import com.qianwen.mdc.collect.service.DeviceStateAggregateService; |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | import com.qianwen.mdc.collect.service.IOTMqttReceiveService; |
| | | import com.qianwen.mdc.collect.service.IotDBCommonService; |
| | | import com.qianwen.mdc.collect.service.OutputAggregateService; |
| | | import com.qianwen.mdc.collect.utils.redis.RedisUtil; |
| | | import com.xxl.job.core.log.XxlJobLogger; |
| | | |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | |
| | | @RestController |
| | | public class JobTestController { |
| | | private final Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | @Autowired |
| | | private TimeSliceCache timeSliceCache; |
| | | |
| | | |
| | | @GetMapping("/timecache") |
| | | public Object stateagg(Long workstationId) { |
| | | |
| | | LocalDate targetDate = LocalDate.now();//.plusDays(1L); |
| | | CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(targetDate).build(); |
| | | if (Func.isNotEmpty(cacheBuildDTO)) { |
| | | timeSliceCache.build(cacheBuildDTO); |
| | | } else { |
| | | log.error("[ç产æ¥ååçç¼åæå»ºå¤±è´¥...],æå»ºæ¶é´{},æå»ºç§æ·ï¼{}", targetDate, "000000"); |
| | | } |
| | | |
| | | return "1"; |
| | | } |
| | | |
| | | } |
| | |
| | | public void testRec2() { |
| | | //æ°æ®æ ¼å¼ï¼{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174æ¯åºç¨id |
| | | //夿¡æ ¼å¼ï¼{"174":[{"values":{"DeviceStatus":2},"ts":"1722478128278"},{"values":{"spindleSpeed":22},"ts":"1722478128281"}]} |
| | | String payload = "{\"174\":[{\"values\":{\"DeviceStatus\":2,\"Output\":34},\"ts\":\"1723709061525\"}]}"; |
| | | String payload = "{\"174\":[{\"values\":{\"DeviceStatus\":2,\"Output\":34},\"ts\":\"1725247557768\"}]}"; |
| | | //payload = "{\"174\":[{\"values\":{\"Output\":11},\"ts\":\"1722478128278\"},{\"values\":{\"SpindleSpeed\":22},\"ts\":\"1722478128281\"}]}"; |
| | | recService.handle(payload); |
| | | } |
| | | @GetMapping("/rec") |
| | | public void testRec() { |
| | | ////æ°æ®æ ¼å¼ï¼{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174æ¯åºç¨id |
| | | //夿¡æ ¼å¼ï¼{"174":[{"values":{"output":11},"ts":"1722478128278"},{"values":{"spindleSpeed":22},"ts":"1722478128281"}]} |
| | | String payload = "{\"174\":[{\"values\":{\"output\":12},\"ts\":\"1721978780449\"}]}"; |
| | | |
| | | JSONObject jsonObj = JSONObject.parseObject(payload); |
| | | //æ°æ®æ ¼å¼ï¼{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174æ¯åºç¨id |
| | | Set<String> keys = jsonObj.keySet(); |
| | | String appId = keys.toArray(new String[] {})[0]; |
| | | JSONArray dtArr = jsonObj.getJSONArray(appId); |
| | | JSONObject data = dtArr.getJSONObject(0); |
| | | long time = data.getLong("ts"); |
| | | String output = data.getJSONObject("values").getString("output"); |
| | | //AggrgateData ad = recService.fillFactoryData(payload); |
| | | |
| | | List<String> fields = new ArrayList<>(); |
| | | List<String> values = new ArrayList<>(); |
| | | //long time = System.currentTimeMillis(); |
| | | fields.add("output"); |
| | | fields.add("factory_year"); |
| | | fields.add("factory_month"); |
| | | fields.add("factory_date");//INT64, INT64,factory_date INT64,factory_week |
| | | values.add(output); |
| | | |
| | | |
| | | //iotdbCfg.insertRecord("root.qa.myoutput_"+ad.getWorkstationId(), time, fields, values); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/tpl") |
| | | public Object tpl(String tplname) throws StatementExecutionException, IoTDBConnectionException { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.controller; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftInfoDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.Output; |
| | | import com.qianwen.mdc.collect.entity.iotdb.ProcessParam; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.OutputMapper; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.ProcessParamMapper; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper; |
| | | import com.qianwen.mdc.collect.mqtt.MqttMessageSender; |
| | | import com.qianwen.mdc.collect.service.DeviceStateAggregateService; |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | import com.qianwen.mdc.collect.service.IOTMqttReceiveService; |
| | | import com.qianwen.mdc.collect.service.IotDBCommonService; |
| | | import com.qianwen.mdc.collect.service.OutputAggregateService; |
| | | import com.qianwen.mdc.collect.utils.redis.RedisUtil; |
| | | |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | |
| | | @RestController |
| | | public class StateController { |
| | | |
| | | @Autowired |
| | | private DeviceStateAggregateService stateAggregateService; |
| | | |
| | | |
| | | @GetMapping("/stateagg") |
| | | public Object stateagg(Long workstationId) { |
| | | stateAggregateService.stateAggregate(workstationId); |
| | | |
| | | return "1"; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.dto; |
| | | |
| | | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; |
| | | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDate; |
| | | import java.util.Set; |
| | | |
| | | @ApiModel(value = "ç产æ¥åæ ¡éªå
¥å", description = "ç产æ¥åæ ¡éªå
¥å") |
| | | public class CacheBuildDTO implements Serializable { |
| | | private static final long serialVersionUID = 1; |
| | | private Set<String> tenantIds; |
| | | private String calendarCode; |
| | | @JsonSerialize(using = LocalDateSerializer.class) |
| | | @JsonDeserialize(using = LocalDateDeserializer.class) |
| | | private LocalDate targetDate; |
| | | |
| | | public static class CacheBuildDTOBuilder { |
| | | private Set<String> tenantIds; |
| | | private String calendarCode; |
| | | private LocalDate targetDate; |
| | | |
| | | CacheBuildDTOBuilder() { |
| | | } |
| | | |
| | | public CacheBuildDTOBuilder tenantIds(final Set<String> tenantIds) { |
| | | this.tenantIds = tenantIds; |
| | | return this; |
| | | } |
| | | |
| | | public CacheBuildDTOBuilder calendarCode(final String calendarCode) { |
| | | this.calendarCode = calendarCode; |
| | | return this; |
| | | } |
| | | |
| | | @JsonDeserialize(using = LocalDateDeserializer.class) |
| | | public CacheBuildDTOBuilder targetDate(final LocalDate targetDate) { |
| | | this.targetDate = targetDate; |
| | | return this; |
| | | } |
| | | |
| | | public CacheBuildDTO build() { |
| | | return new CacheBuildDTO(this.tenantIds, this.calendarCode, this.targetDate); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "CacheBuildDTO.CacheBuildDTOBuilder(tenantIds=" + this.tenantIds + ", calendarCode=" + this.calendarCode + ", targetDate=" + this.targetDate + ")"; |
| | | } |
| | | } |
| | | |
| | | public void setTenantIds(final Set<String> tenantIds) { |
| | | this.tenantIds = tenantIds; |
| | | } |
| | | |
| | | public void setCalendarCode(final String calendarCode) { |
| | | this.calendarCode = calendarCode; |
| | | } |
| | | |
| | | @JsonDeserialize(using = LocalDateDeserializer.class) |
| | | public void setTargetDate(final LocalDate targetDate) { |
| | | this.targetDate = targetDate; |
| | | } |
| | | |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | | return true; |
| | | } |
| | | if (o instanceof CacheBuildDTO) { |
| | | CacheBuildDTO other = (CacheBuildDTO) o; |
| | | if (other.canEqual(this)) { |
| | | Object this$tenantIds = getTenantIds(); |
| | | Object other$tenantIds = other.getTenantIds(); |
| | | if (this$tenantIds == null) { |
| | | if (other$tenantIds != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$tenantIds.equals(other$tenantIds)) { |
| | | return false; |
| | | } |
| | | Object this$calendarCode = getCalendarCode(); |
| | | Object other$calendarCode = other.getCalendarCode(); |
| | | if (this$calendarCode == null) { |
| | | if (other$calendarCode != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$calendarCode.equals(other$calendarCode)) { |
| | | return false; |
| | | } |
| | | Object this$targetDate = getTargetDate(); |
| | | Object other$targetDate = other.getTargetDate(); |
| | | return this$targetDate == null ? other$targetDate == null : this$targetDate.equals(other$targetDate); |
| | | } |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | protected boolean canEqual(final Object other) { |
| | | return other instanceof CacheBuildDTO; |
| | | } |
| | | |
| | | public int hashCode() { |
| | | Object $tenantIds = getTenantIds(); |
| | | int result = (1 * 59) + ($tenantIds == null ? 43 : $tenantIds.hashCode()); |
| | | Object $calendarCode = getCalendarCode(); |
| | | int result2 = (result * 59) + ($calendarCode == null ? 43 : $calendarCode.hashCode()); |
| | | Object $targetDate = getTargetDate(); |
| | | return (result2 * 59) + ($targetDate == null ? 43 : $targetDate.hashCode()); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "CacheBuildDTO(tenantIds=" + getTenantIds() + ", calendarCode=" + getCalendarCode() + ", targetDate=" + getTargetDate() + ")"; |
| | | } |
| | | |
| | | public static CacheBuildDTOBuilder builder() { |
| | | return new CacheBuildDTOBuilder(); |
| | | } |
| | | |
| | | public CacheBuildDTO() { |
| | | } |
| | | |
| | | public CacheBuildDTO(final Set<String> tenantIds, final String calendarCode, final LocalDate targetDate) { |
| | | this.tenantIds = tenantIds; |
| | | this.calendarCode = calendarCode; |
| | | this.targetDate = targetDate; |
| | | } |
| | | |
| | | public Set<String> getTenantIds() { |
| | | return this.tenantIds; |
| | | } |
| | | |
| | | public String getCalendarCode() { |
| | | return this.calendarCode; |
| | | } |
| | | |
| | | public LocalDate getTargetDate() { |
| | | return this.targetDate; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.dto; |
| | | |
| | | import java.util.Date; |
| | | |
| | | public class CalendarShiftTimeSlicesDTO { |
| | | private String factoryDate; |
| | | private Integer shiftIndex; |
| | | private String shiftTimeType; |
| | | private Integer factoryWeek; |
| | | private Integer factoryMonth; |
| | | private Integer factoryYear; |
| | | private Date startTime; |
| | | private Date endTime; |
| | | |
| | | public CalendarShiftTimeSlicesDTO setFactoryDate(final String factoryDate) { |
| | | this.factoryDate = factoryDate; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO setShiftIndex(final Integer shiftIndex) { |
| | | this.shiftIndex = shiftIndex; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO setShiftTimeType(final String shiftTimeType) { |
| | | this.shiftTimeType = shiftTimeType; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO setFactoryWeek(final Integer factoryWeek) { |
| | | this.factoryWeek = factoryWeek; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO setFactoryMonth(final Integer factoryMonth) { |
| | | this.factoryMonth = factoryMonth; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO setFactoryYear(final Integer factoryYear) { |
| | | this.factoryYear = factoryYear; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO setStartTime(final Date startTime) { |
| | | this.startTime = startTime; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO setEndTime(final Date endTime) { |
| | | this.endTime = endTime; |
| | | return this; |
| | | } |
| | | |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | | return true; |
| | | } |
| | | if (o instanceof CalendarShiftTimeSlicesDTO) { |
| | | CalendarShiftTimeSlicesDTO other = (CalendarShiftTimeSlicesDTO) o; |
| | | if (other.canEqual(this)) { |
| | | Object this$shiftIndex = getShiftIndex(); |
| | | Object other$shiftIndex = other.getShiftIndex(); |
| | | if (this$shiftIndex == null) { |
| | | if (other$shiftIndex != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$shiftIndex.equals(other$shiftIndex)) { |
| | | return false; |
| | | } |
| | | Object this$factoryWeek = getFactoryWeek(); |
| | | Object other$factoryWeek = other.getFactoryWeek(); |
| | | if (this$factoryWeek == null) { |
| | | if (other$factoryWeek != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$factoryWeek.equals(other$factoryWeek)) { |
| | | return false; |
| | | } |
| | | Object this$factoryMonth = getFactoryMonth(); |
| | | Object other$factoryMonth = other.getFactoryMonth(); |
| | | if (this$factoryMonth == null) { |
| | | if (other$factoryMonth != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$factoryMonth.equals(other$factoryMonth)) { |
| | | return false; |
| | | } |
| | | Object this$factoryYear = getFactoryYear(); |
| | | Object other$factoryYear = other.getFactoryYear(); |
| | | if (this$factoryYear == null) { |
| | | if (other$factoryYear != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$factoryYear.equals(other$factoryYear)) { |
| | | return false; |
| | | } |
| | | Object this$factoryDate = getFactoryDate(); |
| | | Object other$factoryDate = other.getFactoryDate(); |
| | | if (this$factoryDate == null) { |
| | | if (other$factoryDate != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$factoryDate.equals(other$factoryDate)) { |
| | | return false; |
| | | } |
| | | Object this$shiftTimeType = getShiftTimeType(); |
| | | Object other$shiftTimeType = other.getShiftTimeType(); |
| | | if (this$shiftTimeType == null) { |
| | | if (other$shiftTimeType != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$shiftTimeType.equals(other$shiftTimeType)) { |
| | | return false; |
| | | } |
| | | Object this$startTime = getStartTime(); |
| | | Object other$startTime = other.getStartTime(); |
| | | if (this$startTime == null) { |
| | | if (other$startTime != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$startTime.equals(other$startTime)) { |
| | | return false; |
| | | } |
| | | Object this$endTime = getEndTime(); |
| | | Object other$endTime = other.getEndTime(); |
| | | return this$endTime == null ? other$endTime == null : this$endTime.equals(other$endTime); |
| | | } |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | protected boolean canEqual(final Object other) { |
| | | return other instanceof CalendarShiftTimeSlicesDTO; |
| | | } |
| | | |
| | | public int hashCode() { |
| | | Object $shiftIndex = getShiftIndex(); |
| | | int result = (1 * 59) + ($shiftIndex == null ? 43 : $shiftIndex.hashCode()); |
| | | Object $factoryWeek = getFactoryWeek(); |
| | | int result2 = (result * 59) + ($factoryWeek == null ? 43 : $factoryWeek.hashCode()); |
| | | Object $factoryMonth = getFactoryMonth(); |
| | | int result3 = (result2 * 59) + ($factoryMonth == null ? 43 : $factoryMonth.hashCode()); |
| | | Object $factoryYear = getFactoryYear(); |
| | | int result4 = (result3 * 59) + ($factoryYear == null ? 43 : $factoryYear.hashCode()); |
| | | Object $factoryDate = getFactoryDate(); |
| | | int result5 = (result4 * 59) + ($factoryDate == null ? 43 : $factoryDate.hashCode()); |
| | | Object $shiftTimeType = getShiftTimeType(); |
| | | int result6 = (result5 * 59) + ($shiftTimeType == null ? 43 : $shiftTimeType.hashCode()); |
| | | Object $startTime = getStartTime(); |
| | | int result7 = (result6 * 59) + ($startTime == null ? 43 : $startTime.hashCode()); |
| | | Object $endTime = getEndTime(); |
| | | return (result7 * 59) + ($endTime == null ? 43 : $endTime.hashCode()); |
| | | } |
| | | |
| | | public static class CalendarShiftTimeSlicesDTOBuilder { |
| | | private String factoryDate; |
| | | private Integer shiftIndex; |
| | | private String shiftTimeType; |
| | | private Integer factoryWeek; |
| | | private Integer factoryMonth; |
| | | private Integer factoryYear; |
| | | private Date startTime; |
| | | private Date endTime; |
| | | |
| | | CalendarShiftTimeSlicesDTOBuilder() { |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder factoryDate(final String factoryDate) { |
| | | this.factoryDate = factoryDate; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder shiftIndex(final Integer shiftIndex) { |
| | | this.shiftIndex = shiftIndex; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder shiftTimeType(final String shiftTimeType) { |
| | | this.shiftTimeType = shiftTimeType; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder factoryWeek(final Integer factoryWeek) { |
| | | this.factoryWeek = factoryWeek; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder factoryMonth(final Integer factoryMonth) { |
| | | this.factoryMonth = factoryMonth; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder factoryYear(final Integer factoryYear) { |
| | | this.factoryYear = factoryYear; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder startTime(final Date startTime) { |
| | | this.startTime = startTime; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTOBuilder endTime(final Date endTime) { |
| | | this.endTime = endTime; |
| | | return this; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO build() { |
| | | return new CalendarShiftTimeSlicesDTO(this.factoryDate, this.shiftIndex, this.shiftTimeType, this.factoryWeek, this.factoryMonth, this.factoryYear, this.startTime, this.endTime); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "CalendarShiftTimeSlicesDTO.CalendarShiftTimeSlicesDTOBuilder(factoryDate=" + this.factoryDate + ", shiftIndex=" + this.shiftIndex + ", shiftTimeType=" + this.shiftTimeType + ", factoryWeek=" + this.factoryWeek + ", factoryMonth=" + this.factoryMonth + ", factoryYear=" + this.factoryYear + ", startTime=" + this.startTime + ", endTime=" + this.endTime + ")"; |
| | | } |
| | | } |
| | | |
| | | public static CalendarShiftTimeSlicesDTOBuilder builder() { |
| | | return new CalendarShiftTimeSlicesDTOBuilder(); |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO(final String factoryDate, final Integer shiftIndex, final String shiftTimeType, final Integer factoryWeek, final Integer factoryMonth, final Integer factoryYear, final Date startTime, final Date endTime) { |
| | | this.factoryDate = factoryDate; |
| | | this.shiftIndex = shiftIndex; |
| | | this.shiftTimeType = shiftTimeType; |
| | | this.factoryWeek = factoryWeek; |
| | | this.factoryMonth = factoryMonth; |
| | | this.factoryYear = factoryYear; |
| | | this.startTime = startTime; |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | public CalendarShiftTimeSlicesDTO() { |
| | | } |
| | | |
| | | public String toString() { |
| | | return "CalendarShiftTimeSlicesDTO(factoryDate=" + getFactoryDate() + ", shiftIndex=" + getShiftIndex() + ", shiftTimeType=" + getShiftTimeType() + ", factoryWeek=" + getFactoryWeek() + ", factoryMonth=" + getFactoryMonth() + ", factoryYear=" + getFactoryYear() + ", startTime=" + getStartTime() + ", endTime=" + getEndTime() + ")"; |
| | | } |
| | | |
| | | public String getFactoryDate() { |
| | | return this.factoryDate; |
| | | } |
| | | |
| | | public Integer getShiftIndex() { |
| | | return this.shiftIndex; |
| | | } |
| | | |
| | | public String getShiftTimeType() { |
| | | return this.shiftTimeType; |
| | | } |
| | | |
| | | public Integer getFactoryWeek() { |
| | | return this.factoryWeek; |
| | | } |
| | | |
| | | public Integer getFactoryMonth() { |
| | | return this.factoryMonth; |
| | | } |
| | | |
| | | public Integer getFactoryYear() { |
| | | return this.factoryYear; |
| | | } |
| | | |
| | | public Date getStartTime() { |
| | | return this.startTime; |
| | | } |
| | | |
| | | public Date getEndTime() { |
| | | return this.endTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.dto; |
| | | |
| | | public class StateAggregateTimeDTO { |
| | | private Long startTime; |
| | | private Long endTime; |
| | | private Boolean noFeedbackTime; |
| | | |
| | | public void setStartTime(final Long startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public void setEndTime(final Long endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | public void setNoFeedbackTime(final Boolean noFeedbackTime) { |
| | | this.noFeedbackTime = noFeedbackTime; |
| | | } |
| | | |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | | return true; |
| | | } |
| | | if (o instanceof StateAggregateTimeDTO) { |
| | | StateAggregateTimeDTO other = (StateAggregateTimeDTO) o; |
| | | if (other.canEqual(this)) { |
| | | Object this$startTime = getStartTime(); |
| | | Object other$startTime = other.getStartTime(); |
| | | if (this$startTime == null) { |
| | | if (other$startTime != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$startTime.equals(other$startTime)) { |
| | | return false; |
| | | } |
| | | Object this$endTime = getEndTime(); |
| | | Object other$endTime = other.getEndTime(); |
| | | if (this$endTime == null) { |
| | | if (other$endTime != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$endTime.equals(other$endTime)) { |
| | | return false; |
| | | } |
| | | Object this$noFeedbackTime = getNoFeedbackTime(); |
| | | Object other$noFeedbackTime = other.getNoFeedbackTime(); |
| | | return this$noFeedbackTime == null ? other$noFeedbackTime == null : this$noFeedbackTime.equals(other$noFeedbackTime); |
| | | } |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | protected boolean canEqual(final Object other) { |
| | | return other instanceof StateAggregateTimeDTO; |
| | | } |
| | | |
| | | public int hashCode() { |
| | | Object $startTime = getStartTime(); |
| | | int result = (1 * 59) + ($startTime == null ? 43 : $startTime.hashCode()); |
| | | Object $endTime = getEndTime(); |
| | | int result2 = (result * 59) + ($endTime == null ? 43 : $endTime.hashCode()); |
| | | Object $noFeedbackTime = getNoFeedbackTime(); |
| | | return (result2 * 59) + ($noFeedbackTime == null ? 43 : $noFeedbackTime.hashCode()); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "WorkstationStateAggregateTimeDTO(startTime=" + getStartTime() + ", endTime=" + getEndTime() + ", noFeedbackTime=" + getNoFeedbackTime() + ")"; |
| | | } |
| | | |
| | | public Long getStartTime() { |
| | | return this.startTime; |
| | | } |
| | | |
| | | public Long getEndTime() { |
| | | return this.endTime; |
| | | } |
| | | |
| | | public Boolean getNoFeedbackTime() { |
| | | return this.noFeedbackTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.dto; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.Map; |
| | | |
| | | public class TimestampToProductionTimeCacheDto { |
| | | private String TenantId; |
| | | private String CalendarCode; |
| | | private LocalDate NaturalDay; |
| | | private Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDTOMap; |
| | | |
| | | public static class TimestampToProductionTimeCacheDtoBuilder { |
| | | private String TenantId; |
| | | private String CalendarCode; |
| | | private LocalDate NaturalDay; |
| | | private Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDTOMap; |
| | | |
| | | TimestampToProductionTimeCacheDtoBuilder() { |
| | | } |
| | | |
| | | public TimestampToProductionTimeCacheDtoBuilder TenantId(final String TenantId) { |
| | | this.TenantId = TenantId; |
| | | return this; |
| | | } |
| | | |
| | | public TimestampToProductionTimeCacheDtoBuilder CalendarCode(final String CalendarCode) { |
| | | this.CalendarCode = CalendarCode; |
| | | return this; |
| | | } |
| | | |
| | | public TimestampToProductionTimeCacheDtoBuilder NaturalDay(final LocalDate NaturalDay) { |
| | | this.NaturalDay = NaturalDay; |
| | | return this; |
| | | } |
| | | |
| | | public TimestampToProductionTimeCacheDtoBuilder timeSlicesDTOMap(final Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDTOMap) { |
| | | this.timeSlicesDTOMap = timeSlicesDTOMap; |
| | | return this; |
| | | } |
| | | |
| | | public TimestampToProductionTimeCacheDto build() { |
| | | return new TimestampToProductionTimeCacheDto(this.TenantId, this.CalendarCode, this.NaturalDay, this.timeSlicesDTOMap); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "TimestampToProductionTimeCacheDto.TimestampToProductionTimeCacheDtoBuilder(TenantId=" + this.TenantId + ", CalendarCode=" + this.CalendarCode + ", NaturalDay=" + this.NaturalDay + ", timeSlicesDTOMap=" + this.timeSlicesDTOMap + ")"; |
| | | } |
| | | } |
| | | |
| | | public void setTenantId(final String TenantId) { |
| | | this.TenantId = TenantId; |
| | | } |
| | | |
| | | public void setCalendarCode(final String CalendarCode) { |
| | | this.CalendarCode = CalendarCode; |
| | | } |
| | | |
| | | public void setNaturalDay(final LocalDate NaturalDay) { |
| | | this.NaturalDay = NaturalDay; |
| | | } |
| | | |
| | | public void setTimeSlicesDTOMap(final Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDTOMap) { |
| | | this.timeSlicesDTOMap = timeSlicesDTOMap; |
| | | } |
| | | |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | | return true; |
| | | } |
| | | if (o instanceof TimestampToProductionTimeCacheDto) { |
| | | TimestampToProductionTimeCacheDto other = (TimestampToProductionTimeCacheDto) o; |
| | | if (other.canEqual(this)) { |
| | | Object this$TenantId = getTenantId(); |
| | | Object other$TenantId = other.getTenantId(); |
| | | if (this$TenantId == null) { |
| | | if (other$TenantId != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$TenantId.equals(other$TenantId)) { |
| | | return false; |
| | | } |
| | | Object this$CalendarCode = getCalendarCode(); |
| | | Object other$CalendarCode = other.getCalendarCode(); |
| | | if (this$CalendarCode == null) { |
| | | if (other$CalendarCode != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$CalendarCode.equals(other$CalendarCode)) { |
| | | return false; |
| | | } |
| | | Object this$NaturalDay = getNaturalDay(); |
| | | Object other$NaturalDay = other.getNaturalDay(); |
| | | if (this$NaturalDay == null) { |
| | | if (other$NaturalDay != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$NaturalDay.equals(other$NaturalDay)) { |
| | | return false; |
| | | } |
| | | Object this$timeSlicesDTOMap = getTimeSlicesDTOMap(); |
| | | Object other$timeSlicesDTOMap = other.getTimeSlicesDTOMap(); |
| | | return this$timeSlicesDTOMap == null ? other$timeSlicesDTOMap == null : this$timeSlicesDTOMap.equals(other$timeSlicesDTOMap); |
| | | } |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | protected boolean canEqual(final Object other) { |
| | | return other instanceof TimestampToProductionTimeCacheDto; |
| | | } |
| | | |
| | | public int hashCode() { |
| | | Object $TenantId = getTenantId(); |
| | | int result = (1 * 59) + ($TenantId == null ? 43 : $TenantId.hashCode()); |
| | | Object $CalendarCode = getCalendarCode(); |
| | | int result2 = (result * 59) + ($CalendarCode == null ? 43 : $CalendarCode.hashCode()); |
| | | Object $NaturalDay = getNaturalDay(); |
| | | int result3 = (result2 * 59) + ($NaturalDay == null ? 43 : $NaturalDay.hashCode()); |
| | | Object $timeSlicesDTOMap = getTimeSlicesDTOMap(); |
| | | return (result3 * 59) + ($timeSlicesDTOMap == null ? 43 : $timeSlicesDTOMap.hashCode()); |
| | | } |
| | | |
| | | public static TimestampToProductionTimeCacheDtoBuilder builder() { |
| | | return new TimestampToProductionTimeCacheDtoBuilder(); |
| | | } |
| | | |
| | | public TimestampToProductionTimeCacheDto() { |
| | | } |
| | | |
| | | public TimestampToProductionTimeCacheDto(final String TenantId, final String CalendarCode, final LocalDate NaturalDay, final Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDTOMap) { |
| | | this.TenantId = TenantId; |
| | | this.CalendarCode = CalendarCode; |
| | | this.NaturalDay = NaturalDay; |
| | | this.timeSlicesDTOMap = timeSlicesDTOMap; |
| | | } |
| | | |
| | | public String toString() { |
| | | return "TimestampToProductionTimeCacheDto(TenantId=" + getTenantId() + ", CalendarCode=" + getCalendarCode() + ", NaturalDay=" + getNaturalDay() + ", timeSlicesDTOMap=" + getTimeSlicesDTOMap() + ")"; |
| | | } |
| | | |
| | | public String getTenantId() { |
| | | return this.TenantId; |
| | | } |
| | | |
| | | public String getCalendarCode() { |
| | | return this.CalendarCode; |
| | | } |
| | | |
| | | public LocalDate getNaturalDay() { |
| | | return this.NaturalDay; |
| | | } |
| | | |
| | | public Map<Integer, CalendarShiftTimeSlicesDTO> getTimeSlicesDTOMap() { |
| | | return this.timeSlicesDTOMap; |
| | | } |
| | | } |
| | |
| | | private Long time; |
| | | private Long workstationId; |
| | | private Integer valueCollect; |
| | | |
| | | private Long durationCollect; |
| | | private Long endTime; |
| | | private String calendarCode; |
| | | private Integer factoryYear; |
| | | private Integer factoryMonth; |
| | |
| | | public void setFeedbackId(Long feedbackId) { |
| | | this.feedbackId = feedbackId; |
| | | } |
| | | |
| | | public Long getDurationCollect() { |
| | | return durationCollect; |
| | | } |
| | | |
| | | public void setDurationCollect(Long durationCollect) { |
| | | this.durationCollect = durationCollect; |
| | | } |
| | | |
| | | public Long getEndTime() { |
| | | return endTime; |
| | | } |
| | | |
| | | public void setEndTime(Long endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.entity.mgr; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @ApiModel(value = "çæ¬¡æ¥entity", description = "çæ¬¡æ¥entity") |
| | | @TableName("blade_production_calendar_day") |
| | | public class ProductionCalendarDay implements Serializable { |
| | | private static final long serialVersionUID = 6935830020987594867L; |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty("主é®") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | @ApiModelProperty("ç产æ¥åid") |
| | | private Long calendarId; |
| | | @ApiModelProperty("ç产æ¥åæ¥æ") |
| | | private LocalDate calendarDate; |
| | | @ApiModelProperty("çæ¬¡æ¥å¼å§æ¶é´") |
| | | private LocalDateTime startTime; |
| | | @ApiModelProperty("çæ¬¡æ¥ç»ææ¶é´") |
| | | private LocalDateTime endTime; |
| | | @ApiModelProperty("å±äºç¬¬å å¨") |
| | | private Integer week; |
| | | @ApiModelProperty("å±äºç¬¬å æ") |
| | | private Integer month; |
| | | @ApiModelProperty("å±äºç¬¬å å¹´") |
| | | private Integer year; |
| | | @ApiModelProperty("çæ¬¡æ¨¡åId") |
| | | private Long modelId; |
| | | @ApiModelProperty("æ¯å¦é«ä¼å
级") |
| | | private Integer isHighPriority; |
| | | @TableLogic |
| | | @TableField(value = "is_deleted", fill = FieldFill.INSERT) |
| | | private boolean isDeleted; |
| | | |
| | | public static class ProductionCalendarDayBuilder { |
| | | private Long id; |
| | | private Long calendarId; |
| | | private LocalDate calendarDate; |
| | | private LocalDateTime startTime; |
| | | private LocalDateTime endTime; |
| | | private Integer week; |
| | | private Integer month; |
| | | private Integer year; |
| | | private Long modelId; |
| | | private Integer isHighPriority; |
| | | private boolean isDeleted; |
| | | |
| | | ProductionCalendarDayBuilder() { |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder id(final Long id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder calendarId(final Long calendarId) { |
| | | this.calendarId = calendarId; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder calendarDate(final LocalDate calendarDate) { |
| | | this.calendarDate = calendarDate; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder startTime(final LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder endTime(final LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder week(final Integer week) { |
| | | this.week = week; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder month(final Integer month) { |
| | | this.month = month; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder year(final Integer year) { |
| | | this.year = year; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder modelId(final Long modelId) { |
| | | this.modelId = modelId; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder isHighPriority(final Integer isHighPriority) { |
| | | this.isHighPriority = isHighPriority; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDayBuilder isDeleted(final boolean isDeleted) { |
| | | this.isDeleted = isDeleted; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDay build() { |
| | | return new ProductionCalendarDay(this.id, this.calendarId, this.calendarDate, this.startTime, this.endTime, this.week, this.month, this.year, this.modelId, this.isHighPriority, this.isDeleted); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "ProductionCalendarDay.ProductionCalendarDayBuilder(id=" + this.id + ", calendarId=" + this.calendarId + ", calendarDate=" + this.calendarDate + ", startTime=" + this.startTime + ", endTime=" + this.endTime + ", week=" + this.week + ", month=" + this.month + ", year=" + this.year + ", modelId=" + this.modelId + ", isHighPriority=" + this.isHighPriority + ", isDeleted=" + this.isDeleted + ")"; |
| | | } |
| | | } |
| | | |
| | | public void setId(final Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public void setCalendarId(final Long calendarId) { |
| | | this.calendarId = calendarId; |
| | | } |
| | | |
| | | public void setCalendarDate(final LocalDate calendarDate) { |
| | | this.calendarDate = calendarDate; |
| | | } |
| | | |
| | | public void setStartTime(final LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public void setEndTime(final LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | public void setWeek(final Integer week) { |
| | | this.week = week; |
| | | } |
| | | |
| | | public void setMonth(final Integer month) { |
| | | this.month = month; |
| | | } |
| | | |
| | | public void setYear(final Integer year) { |
| | | this.year = year; |
| | | } |
| | | |
| | | public void setModelId(final Long modelId) { |
| | | this.modelId = modelId; |
| | | } |
| | | |
| | | public void setIsHighPriority(final Integer isHighPriority) { |
| | | this.isHighPriority = isHighPriority; |
| | | } |
| | | |
| | | public void setDeleted(final boolean isDeleted) { |
| | | this.isDeleted = isDeleted; |
| | | } |
| | | |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | | return true; |
| | | } |
| | | if (o instanceof ProductionCalendarDay) { |
| | | ProductionCalendarDay other = (ProductionCalendarDay) o; |
| | | if (other.canEqual(this) && isDeleted() == other.isDeleted()) { |
| | | Object this$id = getId(); |
| | | Object other$id = other.getId(); |
| | | if (this$id == null) { |
| | | if (other$id != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$id.equals(other$id)) { |
| | | return false; |
| | | } |
| | | Object this$calendarId = getCalendarId(); |
| | | Object other$calendarId = other.getCalendarId(); |
| | | if (this$calendarId == null) { |
| | | if (other$calendarId != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$calendarId.equals(other$calendarId)) { |
| | | return false; |
| | | } |
| | | Object this$week = getWeek(); |
| | | Object other$week = other.getWeek(); |
| | | if (this$week == null) { |
| | | if (other$week != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$week.equals(other$week)) { |
| | | return false; |
| | | } |
| | | Object this$month = getMonth(); |
| | | Object other$month = other.getMonth(); |
| | | if (this$month == null) { |
| | | if (other$month != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$month.equals(other$month)) { |
| | | return false; |
| | | } |
| | | Object this$year = getYear(); |
| | | Object other$year = other.getYear(); |
| | | if (this$year == null) { |
| | | if (other$year != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$year.equals(other$year)) { |
| | | return false; |
| | | } |
| | | Object this$modelId = getModelId(); |
| | | Object other$modelId = other.getModelId(); |
| | | if (this$modelId == null) { |
| | | if (other$modelId != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$modelId.equals(other$modelId)) { |
| | | return false; |
| | | } |
| | | Object this$isHighPriority = getIsHighPriority(); |
| | | Object other$isHighPriority = other.getIsHighPriority(); |
| | | if (this$isHighPriority == null) { |
| | | if (other$isHighPriority != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$isHighPriority.equals(other$isHighPriority)) { |
| | | return false; |
| | | } |
| | | Object this$calendarDate = getCalendarDate(); |
| | | Object other$calendarDate = other.getCalendarDate(); |
| | | if (this$calendarDate == null) { |
| | | if (other$calendarDate != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$calendarDate.equals(other$calendarDate)) { |
| | | return false; |
| | | } |
| | | Object this$startTime = getStartTime(); |
| | | Object other$startTime = other.getStartTime(); |
| | | if (this$startTime == null) { |
| | | if (other$startTime != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$startTime.equals(other$startTime)) { |
| | | return false; |
| | | } |
| | | Object this$endTime = getEndTime(); |
| | | Object other$endTime = other.getEndTime(); |
| | | return this$endTime == null ? other$endTime == null : this$endTime.equals(other$endTime); |
| | | } |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | protected boolean canEqual(final Object other) { |
| | | return other instanceof ProductionCalendarDay; |
| | | } |
| | | |
| | | public int hashCode() { |
| | | int result = (1 * 59) + (isDeleted() ? 79 : 97); |
| | | Object $id = getId(); |
| | | int result2 = (result * 59) + ($id == null ? 43 : $id.hashCode()); |
| | | Object $calendarId = getCalendarId(); |
| | | int result3 = (result2 * 59) + ($calendarId == null ? 43 : $calendarId.hashCode()); |
| | | Object $week = getWeek(); |
| | | int result4 = (result3 * 59) + ($week == null ? 43 : $week.hashCode()); |
| | | Object $month = getMonth(); |
| | | int result5 = (result4 * 59) + ($month == null ? 43 : $month.hashCode()); |
| | | Object $year = getYear(); |
| | | int result6 = (result5 * 59) + ($year == null ? 43 : $year.hashCode()); |
| | | Object $modelId = getModelId(); |
| | | int result7 = (result6 * 59) + ($modelId == null ? 43 : $modelId.hashCode()); |
| | | Object $isHighPriority = getIsHighPriority(); |
| | | int result8 = (result7 * 59) + ($isHighPriority == null ? 43 : $isHighPriority.hashCode()); |
| | | Object $calendarDate = getCalendarDate(); |
| | | int result9 = (result8 * 59) + ($calendarDate == null ? 43 : $calendarDate.hashCode()); |
| | | Object $startTime = getStartTime(); |
| | | int result10 = (result9 * 59) + ($startTime == null ? 43 : $startTime.hashCode()); |
| | | Object $endTime = getEndTime(); |
| | | return (result10 * 59) + ($endTime == null ? 43 : $endTime.hashCode()); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "ProductionCalendarDay(id=" + getId() + ", calendarId=" + getCalendarId() + ", calendarDate=" + getCalendarDate() + ", startTime=" + getStartTime() + ", endTime=" + getEndTime() + ", week=" + getWeek() + ", month=" + getMonth() + ", year=" + getYear() + ", modelId=" + getModelId() + ", isHighPriority=" + getIsHighPriority() + ", isDeleted=" + isDeleted() + ")"; |
| | | } |
| | | |
| | | public static ProductionCalendarDayBuilder builder() { |
| | | return new ProductionCalendarDayBuilder(); |
| | | } |
| | | |
| | | public ProductionCalendarDay() { |
| | | } |
| | | |
| | | public ProductionCalendarDay(final Long id, final Long calendarId, final LocalDate calendarDate, final LocalDateTime startTime, final LocalDateTime endTime, final Integer week, final Integer month, final Integer year, final Long modelId, final Integer isHighPriority, final boolean isDeleted) { |
| | | this.id = id; |
| | | this.calendarId = calendarId; |
| | | this.calendarDate = calendarDate; |
| | | this.startTime = startTime; |
| | | this.endTime = endTime; |
| | | this.week = week; |
| | | this.month = month; |
| | | this.year = year; |
| | | this.modelId = modelId; |
| | | this.isHighPriority = isHighPriority; |
| | | this.isDeleted = isDeleted; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return this.id; |
| | | } |
| | | |
| | | public Long getCalendarId() { |
| | | return this.calendarId; |
| | | } |
| | | |
| | | public LocalDate getCalendarDate() { |
| | | return this.calendarDate; |
| | | } |
| | | |
| | | public LocalDateTime getStartTime() { |
| | | return this.startTime; |
| | | } |
| | | |
| | | public LocalDateTime getEndTime() { |
| | | return this.endTime; |
| | | } |
| | | |
| | | public Integer getWeek() { |
| | | return this.week; |
| | | } |
| | | |
| | | public Integer getMonth() { |
| | | return this.month; |
| | | } |
| | | |
| | | public Integer getYear() { |
| | | return this.year; |
| | | } |
| | | |
| | | public Long getModelId() { |
| | | return this.modelId; |
| | | } |
| | | |
| | | public Integer getIsHighPriority() { |
| | | return this.isHighPriority; |
| | | } |
| | | |
| | | public boolean isDeleted() { |
| | | return this.isDeleted; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.entity.mgr; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | @ApiModel(value = "çæ¬¡æ¥åçentity", description = "çæ¬¡æ¥åçentity") |
| | | @TableName("blade_production_calendar_daytime") |
| | | public class ProductionCalendarDaytime implements Serializable { |
| | | private static final long serialVersionUID = 2597571287144588437L; |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty("主é®") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | @ApiModelProperty("ç产æ¥åid") |
| | | private Long calendarId; |
| | | @ApiModelProperty("çæ¬¡æ¥id") |
| | | private Long calendarDayId; |
| | | @ApiModelProperty("çæ¬¡æ¥æ") |
| | | private LocalDate calendarDate; |
| | | @ApiModelProperty("çæ¬¡å¼å§æ¶é´") |
| | | private LocalDateTime startTime; |
| | | @ApiModelProperty("çæ¬¡ç»ææ¶é´") |
| | | private LocalDateTime endTime; |
| | | @ApiModelProperty("çæ¬¡åºå·") |
| | | private Integer shiftIndex; |
| | | @ApiModelProperty("çæ¬¡ç±»å(1-工使¶æ®µ,2-伿¯æ¶æ®µ)") |
| | | private Integer shiftType; |
| | | @ApiModelProperty("å±äºç¬¬å å¨") |
| | | private Integer week; |
| | | @ApiModelProperty("å±äºç¬¬å æ") |
| | | private Integer month; |
| | | @ApiModelProperty("å±äºç¬¬å å¹´") |
| | | private Integer year; |
| | | @ApiModelProperty("æ¯å¦æ¯æªå®ä¹å·¥åæ¥") |
| | | private Integer isUndefined; |
| | | @ApiModelProperty("æ¯å¦é«ä¼å
级") |
| | | private Integer isHighPriority; |
| | | @TableField(value = "create_user", fill = FieldFill.INSERT) |
| | | @ApiModelProperty("å建人") |
| | | private Long createUser; |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | @ApiModelProperty("å建æ¶é´") |
| | | private Date createTime; |
| | | |
| | | public static class ProductionCalendarDaytimeBuilder { |
| | | private Long id; |
| | | private Long calendarId; |
| | | private Long calendarDayId; |
| | | private LocalDate calendarDate; |
| | | private LocalDateTime startTime; |
| | | private LocalDateTime endTime; |
| | | private Integer shiftIndex; |
| | | private Integer shiftType; |
| | | private Integer week; |
| | | private Integer month; |
| | | private Integer year; |
| | | private Integer isUndefined; |
| | | private Integer isHighPriority; |
| | | private Long createUser; |
| | | private Date createTime; |
| | | |
| | | ProductionCalendarDaytimeBuilder() { |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder id(final Long id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder calendarId(final Long calendarId) { |
| | | this.calendarId = calendarId; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder calendarDayId(final Long calendarDayId) { |
| | | this.calendarDayId = calendarDayId; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder calendarDate(final LocalDate calendarDate) { |
| | | this.calendarDate = calendarDate; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder startTime(final LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder endTime(final LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder shiftIndex(final Integer shiftIndex) { |
| | | this.shiftIndex = shiftIndex; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder shiftType(final Integer shiftType) { |
| | | this.shiftType = shiftType; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder week(final Integer week) { |
| | | this.week = week; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder month(final Integer month) { |
| | | this.month = month; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder year(final Integer year) { |
| | | this.year = year; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder isUndefined(final Integer isUndefined) { |
| | | this.isUndefined = isUndefined; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder isHighPriority(final Integer isHighPriority) { |
| | | this.isHighPriority = isHighPriority; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder createUser(final Long createUser) { |
| | | this.createUser = createUser; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytimeBuilder createTime(final Date createTime) { |
| | | this.createTime = createTime; |
| | | return this; |
| | | } |
| | | |
| | | public ProductionCalendarDaytime build() { |
| | | return new ProductionCalendarDaytime(this.id, this.calendarId, this.calendarDayId, this.calendarDate, this.startTime, this.endTime, this.shiftIndex, this.shiftType, this.week, this.month, this.year, this.isUndefined, this.isHighPriority, this.createUser, this.createTime); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "ProductionCalendarDaytime.ProductionCalendarDaytimeBuilder(id=" + this.id + ", calendarId=" + this.calendarId + ", calendarDayId=" + this.calendarDayId + ", calendarDate=" + this.calendarDate + ", startTime=" + this.startTime + ", endTime=" + this.endTime + ", shiftIndex=" + this.shiftIndex + ", shiftType=" + this.shiftType + ", week=" + this.week + ", month=" + this.month + ", year=" + this.year + ", isUndefined=" + this.isUndefined + ", isHighPriority=" + this.isHighPriority + ", createUser=" + this.createUser + ", createTime=" + this.createTime + ")"; |
| | | } |
| | | } |
| | | |
| | | public void setId(final Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public void setCalendarId(final Long calendarId) { |
| | | this.calendarId = calendarId; |
| | | } |
| | | |
| | | public void setCalendarDayId(final Long calendarDayId) { |
| | | this.calendarDayId = calendarDayId; |
| | | } |
| | | |
| | | public void setCalendarDate(final LocalDate calendarDate) { |
| | | this.calendarDate = calendarDate; |
| | | } |
| | | |
| | | public void setStartTime(final LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public void setEndTime(final LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | public void setShiftIndex(final Integer shiftIndex) { |
| | | this.shiftIndex = shiftIndex; |
| | | } |
| | | |
| | | public void setShiftType(final Integer shiftType) { |
| | | this.shiftType = shiftType; |
| | | } |
| | | |
| | | public void setWeek(final Integer week) { |
| | | this.week = week; |
| | | } |
| | | |
| | | public void setMonth(final Integer month) { |
| | | this.month = month; |
| | | } |
| | | |
| | | public void setYear(final Integer year) { |
| | | this.year = year; |
| | | } |
| | | |
| | | public void setIsUndefined(final Integer isUndefined) { |
| | | this.isUndefined = isUndefined; |
| | | } |
| | | |
| | | public void setIsHighPriority(final Integer isHighPriority) { |
| | | this.isHighPriority = isHighPriority; |
| | | } |
| | | |
| | | public void setCreateUser(final Long createUser) { |
| | | this.createUser = createUser; |
| | | } |
| | | |
| | | public void setCreateTime(final Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | | return true; |
| | | } |
| | | if (o instanceof ProductionCalendarDaytime) { |
| | | ProductionCalendarDaytime other = (ProductionCalendarDaytime) o; |
| | | if (other.canEqual(this)) { |
| | | Object this$id = getId(); |
| | | Object other$id = other.getId(); |
| | | if (this$id == null) { |
| | | if (other$id != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$id.equals(other$id)) { |
| | | return false; |
| | | } |
| | | Object this$calendarId = getCalendarId(); |
| | | Object other$calendarId = other.getCalendarId(); |
| | | if (this$calendarId == null) { |
| | | if (other$calendarId != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$calendarId.equals(other$calendarId)) { |
| | | return false; |
| | | } |
| | | Object this$calendarDayId = getCalendarDayId(); |
| | | Object other$calendarDayId = other.getCalendarDayId(); |
| | | if (this$calendarDayId == null) { |
| | | if (other$calendarDayId != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$calendarDayId.equals(other$calendarDayId)) { |
| | | return false; |
| | | } |
| | | Object this$shiftIndex = getShiftIndex(); |
| | | Object other$shiftIndex = other.getShiftIndex(); |
| | | if (this$shiftIndex == null) { |
| | | if (other$shiftIndex != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$shiftIndex.equals(other$shiftIndex)) { |
| | | return false; |
| | | } |
| | | Object this$shiftType = getShiftType(); |
| | | Object other$shiftType = other.getShiftType(); |
| | | if (this$shiftType == null) { |
| | | if (other$shiftType != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$shiftType.equals(other$shiftType)) { |
| | | return false; |
| | | } |
| | | Object this$week = getWeek(); |
| | | Object other$week = other.getWeek(); |
| | | if (this$week == null) { |
| | | if (other$week != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$week.equals(other$week)) { |
| | | return false; |
| | | } |
| | | Object this$month = getMonth(); |
| | | Object other$month = other.getMonth(); |
| | | if (this$month == null) { |
| | | if (other$month != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$month.equals(other$month)) { |
| | | return false; |
| | | } |
| | | Object this$year = getYear(); |
| | | Object other$year = other.getYear(); |
| | | if (this$year == null) { |
| | | if (other$year != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$year.equals(other$year)) { |
| | | return false; |
| | | } |
| | | Object this$isUndefined = getIsUndefined(); |
| | | Object other$isUndefined = other.getIsUndefined(); |
| | | if (this$isUndefined == null) { |
| | | if (other$isUndefined != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$isUndefined.equals(other$isUndefined)) { |
| | | return false; |
| | | } |
| | | Object this$isHighPriority = getIsHighPriority(); |
| | | Object other$isHighPriority = other.getIsHighPriority(); |
| | | if (this$isHighPriority == null) { |
| | | if (other$isHighPriority != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$isHighPriority.equals(other$isHighPriority)) { |
| | | return false; |
| | | } |
| | | Object this$createUser = getCreateUser(); |
| | | Object other$createUser = other.getCreateUser(); |
| | | if (this$createUser == null) { |
| | | if (other$createUser != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$createUser.equals(other$createUser)) { |
| | | return false; |
| | | } |
| | | Object this$calendarDate = getCalendarDate(); |
| | | Object other$calendarDate = other.getCalendarDate(); |
| | | if (this$calendarDate == null) { |
| | | if (other$calendarDate != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$calendarDate.equals(other$calendarDate)) { |
| | | return false; |
| | | } |
| | | Object this$startTime = getStartTime(); |
| | | Object other$startTime = other.getStartTime(); |
| | | if (this$startTime == null) { |
| | | if (other$startTime != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$startTime.equals(other$startTime)) { |
| | | return false; |
| | | } |
| | | Object this$endTime = getEndTime(); |
| | | Object other$endTime = other.getEndTime(); |
| | | if (this$endTime == null) { |
| | | if (other$endTime != null) { |
| | | return false; |
| | | } |
| | | } else if (!this$endTime.equals(other$endTime)) { |
| | | return false; |
| | | } |
| | | Object this$createTime = getCreateTime(); |
| | | Object other$createTime = other.getCreateTime(); |
| | | return this$createTime == null ? other$createTime == null : this$createTime.equals(other$createTime); |
| | | } |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | protected boolean canEqual(final Object other) { |
| | | return other instanceof ProductionCalendarDaytime; |
| | | } |
| | | |
| | | public int hashCode() { |
| | | Object $id = getId(); |
| | | int result = (1 * 59) + ($id == null ? 43 : $id.hashCode()); |
| | | Object $calendarId = getCalendarId(); |
| | | int result2 = (result * 59) + ($calendarId == null ? 43 : $calendarId.hashCode()); |
| | | Object $calendarDayId = getCalendarDayId(); |
| | | int result3 = (result2 * 59) + ($calendarDayId == null ? 43 : $calendarDayId.hashCode()); |
| | | Object $shiftIndex = getShiftIndex(); |
| | | int result4 = (result3 * 59) + ($shiftIndex == null ? 43 : $shiftIndex.hashCode()); |
| | | Object $shiftType = getShiftType(); |
| | | int result5 = (result4 * 59) + ($shiftType == null ? 43 : $shiftType.hashCode()); |
| | | Object $week = getWeek(); |
| | | int result6 = (result5 * 59) + ($week == null ? 43 : $week.hashCode()); |
| | | Object $month = getMonth(); |
| | | int result7 = (result6 * 59) + ($month == null ? 43 : $month.hashCode()); |
| | | Object $year = getYear(); |
| | | int result8 = (result7 * 59) + ($year == null ? 43 : $year.hashCode()); |
| | | Object $isUndefined = getIsUndefined(); |
| | | int result9 = (result8 * 59) + ($isUndefined == null ? 43 : $isUndefined.hashCode()); |
| | | Object $isHighPriority = getIsHighPriority(); |
| | | int result10 = (result9 * 59) + ($isHighPriority == null ? 43 : $isHighPriority.hashCode()); |
| | | Object $createUser = getCreateUser(); |
| | | int result11 = (result10 * 59) + ($createUser == null ? 43 : $createUser.hashCode()); |
| | | Object $calendarDate = getCalendarDate(); |
| | | int result12 = (result11 * 59) + ($calendarDate == null ? 43 : $calendarDate.hashCode()); |
| | | Object $startTime = getStartTime(); |
| | | int result13 = (result12 * 59) + ($startTime == null ? 43 : $startTime.hashCode()); |
| | | Object $endTime = getEndTime(); |
| | | int result14 = (result13 * 59) + ($endTime == null ? 43 : $endTime.hashCode()); |
| | | Object $createTime = getCreateTime(); |
| | | return (result14 * 59) + ($createTime == null ? 43 : $createTime.hashCode()); |
| | | } |
| | | |
| | | public String toString() { |
| | | return "ProductionCalendarDaytime(id=" + getId() + ", calendarId=" + getCalendarId() + ", calendarDayId=" + getCalendarDayId() + ", calendarDate=" + getCalendarDate() + ", startTime=" + getStartTime() + ", endTime=" + getEndTime() + ", shiftIndex=" + getShiftIndex() + ", shiftType=" + getShiftType() + ", week=" + getWeek() + ", month=" + getMonth() + ", year=" + getYear() + ", isUndefined=" + getIsUndefined() + ", isHighPriority=" + getIsHighPriority() + ", createUser=" + getCreateUser() + ", createTime=" + getCreateTime() + ")"; |
| | | } |
| | | |
| | | public static ProductionCalendarDaytimeBuilder builder() { |
| | | return new ProductionCalendarDaytimeBuilder(); |
| | | } |
| | | |
| | | public ProductionCalendarDaytime() { |
| | | } |
| | | |
| | | public ProductionCalendarDaytime(final Long id, final Long calendarId, final Long calendarDayId, final LocalDate calendarDate, final LocalDateTime startTime, final LocalDateTime endTime, final Integer shiftIndex, final Integer shiftType, final Integer week, final Integer month, final Integer year, final Integer isUndefined, final Integer isHighPriority, final Long createUser, final Date createTime) { |
| | | this.id = id; |
| | | this.calendarId = calendarId; |
| | | this.calendarDayId = calendarDayId; |
| | | this.calendarDate = calendarDate; |
| | | this.startTime = startTime; |
| | | this.endTime = endTime; |
| | | this.shiftIndex = shiftIndex; |
| | | this.shiftType = shiftType; |
| | | this.week = week; |
| | | this.month = month; |
| | | this.year = year; |
| | | this.isUndefined = isUndefined; |
| | | this.isHighPriority = isHighPriority; |
| | | this.createUser = createUser; |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return this.id; |
| | | } |
| | | |
| | | public Long getCalendarId() { |
| | | return this.calendarId; |
| | | } |
| | | |
| | | public Long getCalendarDayId() { |
| | | return this.calendarDayId; |
| | | } |
| | | |
| | | public LocalDate getCalendarDate() { |
| | | return this.calendarDate; |
| | | } |
| | | |
| | | public LocalDateTime getStartTime() { |
| | | return this.startTime; |
| | | } |
| | | |
| | | public LocalDateTime getEndTime() { |
| | | return this.endTime; |
| | | } |
| | | |
| | | public Integer getShiftIndex() { |
| | | return this.shiftIndex; |
| | | } |
| | | |
| | | public Integer getShiftType() { |
| | | return this.shiftType; |
| | | } |
| | | |
| | | public Integer getWeek() { |
| | | return this.week; |
| | | } |
| | | |
| | | public Integer getMonth() { |
| | | return this.month; |
| | | } |
| | | |
| | | public Integer getYear() { |
| | | return this.year; |
| | | } |
| | | |
| | | public Integer getIsUndefined() { |
| | | return this.isUndefined; |
| | | } |
| | | |
| | | public Integer getIsHighPriority() { |
| | | return this.isHighPriority; |
| | | } |
| | | |
| | | public Long getCreateUser() { |
| | | return this.createUser; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return this.createTime; |
| | | } |
| | | } |
| | |
| | | package com.qianwen.mdc.collect.handler; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; |
| | |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | import com.qianwen.mdc.collect.entity.mgr.GlobalWcsOfRps; |
| | | import com.qianwen.mdc.collect.enums.FeedbackTimePointEnum; |
| | | import com.qianwen.mdc.collect.service.DeviceStateService; |
| | | import com.qianwen.mdc.collect.service.IotDBCommonService; |
| | | |
| | | @Component |
| | |
| | | private IotDBSessionConfig iotdbCfg; |
| | | @Autowired |
| | | private IotDBCommonService iotDBCommonService; |
| | | @Autowired |
| | | private DeviceStateService deviceStateService; |
| | | @Override |
| | | public void handleData(PackedTelemetryData data) { |
| | | DeviceState state = new DeviceState(); |
| | |
| | | state.setValueCollect(Integer.valueOf(data.getValue())); |
| | | state.setWcs(state.getValueCollect()); |
| | | state.setWorkstationId(data.getWorkstationId()); |
| | | |
| | | state.setShiftIndex(data.getShiftIndex()); |
| | | state.setShiftTimeType(data.getShiftTimeType()); |
| | | fillWorkStationCondition(data, state); |
| | | |
| | | insertState(state); |
| | | //insertState(state); |
| | | deviceStateService.saveDeviceStates(Arrays.asList(state)); |
| | | |
| | | log.info("ç¶æèåèå宿:æ°æ®"); |
| | | } |
| | |
| | | //log.info("è·åå
è£
å·¥åµä»¥å绩æä¿¡æ¯" + JsonUtil.toJson(workstationState)); |
| | | |
| | | } |
| | | |
| | | /* |
| | | void insertState(DeviceState state){ |
| | | String deviceId = IOTDBConstant.DB_PREFIX+IOTDBConstant.TEMPLATE_STATE+"_"+state.getWorkstationId(); |
| | | try { |
| | |
| | | schemas.add(new MeasurementSchema("shift_time_type", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("wcs", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("rps", TSDataType.INT32)); |
| | | |
| | | schemas.add(new MeasurementSchema("is_fix_point", TSDataType.BOOLEAN)); |
| | | schemas.add(new MeasurementSchema("is_sync", TSDataType.BOOLEAN)); |
| | | |
| | | schemas.add(new MeasurementSchema("is_plan", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("feedback_point_type", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("feedback_id", TSDataType.INT64)); |
| | |
| | | tablet.addValue("factory_month", rowIndex, state.getFactoryMonth()); |
| | | tablet.addValue("factory_week", rowIndex, state.getFactoryWeek()); |
| | | tablet.addValue("factory_date", rowIndex, state.getFactoryDate()); |
| | | tablet.addValue("shift_index", rowIndex, state.getShiftIndex()); |
| | | tablet.addValue("shift_time_type", rowIndex, state.getShiftTimeType()); |
| | | tablet.addValue("shift_index", rowIndex, state.getShiftIndex());//TODO null |
| | | tablet.addValue("shift_time_type", rowIndex, state.getShiftTimeType());//TODO null |
| | | tablet.addValue("wcs", rowIndex, state.getWcs()); |
| | | tablet.addValue("rps", rowIndex, state.getRps()); |
| | | |
| | | tablet.addValue("is_fix_point", rowIndex,state.getIsFixPoint()); |
| | | tablet.addValue("is_sync", rowIndex, state.getIsSync()); |
| | | |
| | | tablet.addValue("is_plan", rowIndex, state.getIsPlan()); |
| | | tablet.addValue("feedback_point_type", rowIndex, state.getFeedbackPointType()); |
| | | tablet.addValue("feedback_id", rowIndex, state.getFeedbackId()); |
| | |
| | | } catch (Exception e) { |
| | | log.error("èå产éIODDBå
¥åºå¤±è´¥", e); |
| | | } |
| | | } |
| | | }*/ |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.job; |
| | | |
| | | import com.google.common.collect.Sets; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.xxl.job.core.log.XxlJobLogger; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.mdc.collect.cache.TimeSliceCache; |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | public class ProductionTimeCacheXxlJob { |
| | | private static final Logger log = LoggerFactory.getLogger(ProductionTimeCacheXxlJob.class); |
| | | |
| | | @Autowired |
| | | private TimeSliceCache timeSliceCache; |
| | | |
| | | @XxlJob("productionTimeCacheJobHandler") |
| | | public ReturnT<String> productionTimeCacheJobHandler(String param) throws Exception { |
| | | LocalDate targetDate = LocalDate.now().plusDays(1L); |
| | | if (Func.isNotEmpty(param)) { |
| | | targetDate = LocalDate.parse(param, DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | XxlJobLogger.log("XXL-JOB, 宿¶æå»ºç产æ¥ååçç¼å,æå»ºå¼å§.....", new Object[0]); |
| | | CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(targetDate).build(); |
| | | if (Func.isNotEmpty(cacheBuildDTO)) { |
| | | timeSliceCache.build(cacheBuildDTO); |
| | | } else { |
| | | log.error("[ç产æ¥ååçç¼åæå»ºå¤±è´¥...],æå»ºæ¶é´{},æå»ºç§æ·ï¼{}", targetDate, "000000"); |
| | | } |
| | | XxlJobLogger.log("XXL-JOB, 宿¶æå»ºç产æ¥ååçç¼å,æå»ºç»æ", new Object[0]); |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.mapper.iotdb; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.qianwen.mdc.collect.entity.iotdb.AggregateState; |
| | | |
| | | @DS("iotdb") |
| | | @InterceptorIgnore(tenantLine = "true") |
| | | public interface AggregateStateMapper extends BaseMapper<AggregateState> { |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.qianwen.mdc.collect.dto.StateAggregateTimeDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | DeviceState getLastIsSyncNoFixPointState(@Param("workstationId") Long workstationId); |
| | | |
| | | DeviceState getLastWorkstationState(@Param("ew") Wrapper query); |
| | | //DeviceState getLastWorkstationState(@Param("ew") Wrapper query); |
| | | /** |
| | | * è·åææ°ç已忥çéåé¦ç¹ç¶æ |
| | | * @param workstationId |
| | | * @return |
| | | */ |
| | | DeviceState lastSyncedNoFeedbackPointState(Long workstationId); |
| | | |
| | | //DeviceState getFirstWorkstationState(@Param("ew") Wrapper query); |
| | | /** |
| | | * è·å第ä¸ä¸ªçæªåæ¥çéåé¦ç¹ç¶æ |
| | | * @param workstationId |
| | | * @return |
| | | */ |
| | | DeviceState firstNotSyncedNofeedbackPointState(Long workstationId); |
| | | |
| | | DeviceState getFirstWorkstationState(@Param("ew") Wrapper query); |
| | | /** |
| | | * è·åæ¶é´åºé´å
çç¶ææ°æ® |
| | | * @param workstationId |
| | | * @param timeRange |
| | | * @return |
| | | */ |
| | | List<DeviceState> statesInTimeRange(@Param("workstationId")Long workstationId,@Param("timeRange") StateAggregateTimeDTO timeRange); |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.mapper.mgr; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.qianwen.mdc.collect.entity.mgr.ProductionCalendarDay; |
| | | |
| | | public interface CalendarDayMapper extends BaseMapper<ProductionCalendarDay> { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.mapper.mgr; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.qianwen.mdc.collect.entity.mgr.ProductionCalendarDaytime; |
| | | |
| | | public interface CalendarDaytimeMapper extends BaseMapper<ProductionCalendarDaytime> { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.qianwen.mdc.collect.entity.mgr.ProductionCalendarDay; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarDayMapper; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class CalendarDayService extends ServiceImpl<CalendarDayMapper, ProductionCalendarDay> { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.qianwen.mdc.collect.entity.mgr.ProductionCalendarDaytime; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarDaytimeMapper; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class CalendarDaytimeService extends ServiceImpl<CalendarDaytimeMapper, ProductionCalendarDaytime>{ |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.qianwen.mdc.collect.constants.CommonConstant; |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftTimeSlicesDTO; |
| | | import com.qianwen.mdc.collect.dto.TimestampToProductionTimeCacheDto; |
| | | import com.qianwen.mdc.collect.entity.mgr.ProductionCalendar; |
| | | import com.qianwen.mdc.collect.entity.mgr.ProductionCalendarDaytime; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper; |
| | | import com.qianwen.mdc.collect.utils.LocalDateTimeUtils; |
| | | import com.qianwen.core.secure.utils.AuthUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | /* |
| | | import com.qianwen.core.redis.cache.BladeRedis; |
| | | |
| | | import com.qianwen.posting.constant.CommonConstant; |
| | | import com.qianwen.posting.dto.CacheBuildDTO; |
| | | import com.qianwen.posting.dto.CalendarShiftTimeSlicesDTO; |
| | | import com.qianwen.posting.dto.TimestampToProductionTimeCacheDto; |
| | | import com.qianwen.posting.entity.mysql.ProductionCalendar; |
| | | import com.qianwen.posting.entity.mysql.ProductionCalendarDaytime; |
| | | |
| | | import com.qianwen.posting.service.ICalendarDayService; |
| | | import com.qianwen.posting.service.ICalendarDaytimeService; |
| | | import com.qianwen.posting.service.ICalendarService; |
| | | import com.qianwen.posting.utils.LocalDateTimeUtils; |
| | | */ |
| | | @Service |
| | | public class CalendarService extends ServiceImpl<CalendarMapper, ProductionCalendar>{ |
| | | private static final Logger log = LoggerFactory.getLogger(CalendarService.class); |
| | | @Autowired |
| | | private CalendarDayService calendarDayService; |
| | | @Autowired |
| | | private CalendarDaytimeService calendarDaytimeService; |
| | | //private final BladeRedis bladeRedis; |
| | | |
| | | /* |
| | | @Override |
| | | public String getShiftIndexNameByCodeAndYear(String calendarCode, Integer year, Integer shiftIndex) { |
| | | return ((CalendarMapper) this.baseMapper).getShiftIndexNameByCodeAndYear(calendarCode, year, shiftIndex, AuthUtil.getTenantId()); |
| | | }*/ |
| | | |
| | | //æå»ºç产æ¥ååçï¼blade_production_calendarï¼ |
| | | public List<TimestampToProductionTimeCacheDto> buildProductionTimeCache(CacheBuildDTO cacheBuildDTO) { |
| | | LocalDate targetDate = cacheBuildDTO.getTargetDate(); |
| | | Set<String> tenantIds = cacheBuildDTO.getTenantIds(); |
| | | String code = cacheBuildDTO.getCalendarCode(); |
| | | List<TimestampToProductionTimeCacheDto> timestampToProductionTimeCacheDtos = new ArrayList<>(); |
| | | List<ProductionCalendar> list = list((new QueryWrapper<ProductionCalendar>()).lambda() |
| | | .in(ProductionCalendar::getTenantId, tenantIds) |
| | | .eq(ProductionCalendar::getStatus, CommonConstant.ENABLE) |
| | | .eq(StringUtils.isNotBlank(code), ProductionCalendar::getCode, code) |
| | | .eq(ProductionCalendar::getYear, Integer.valueOf(targetDate.getYear()))); |
| | | |
| | | LocalDateTime startTime = LocalDateTime.of(targetDate, LocalTime.MIN);//0å0ç§å¼å§ |
| | | LocalDateTime endTime = LocalDateTime.of(targetDate.plusDays(1L), LocalTime.of(0, 0));//第äºå¤©0ç¹ |
| | | if (Func.isNotEmpty(list)) { |
| | | Map<String, List<ProductionCalendar>> collect = (Map<String, List<ProductionCalendar>>)list.stream().collect(Collectors.groupingBy(ProductionCalendar::getTenantId)); |
| | | collect.forEach((tenantId, productionList) -> { |
| | | productionList.forEach(productionCalendar -> { |
| | | TimestampToProductionTimeCacheDto timestampToProductionTimeCacheDto = TimestampToProductionTimeCacheDto.builder().TenantId(productionCalendar.getTenantId()).CalendarCode(productionCalendar.getCode()).NaturalDay(targetDate).build(); |
| | | |
| | | List<ProductionCalendarDaytime> dayTimeList = this.calendarDaytimeService.list(new QueryWrapper<ProductionCalendarDaytime>().lambda() |
| | | .eq(ProductionCalendarDaytime::getCalendarId, productionCalendar.getId()).or().and(i -> { |
| | | LambdaQueryWrapper lambdaQueryWrapper = i.between(ProductionCalendarDaytime::getStartTime, startTime, endTime).or() |
| | | .between(ProductionCalendarDaytime::getEndTime, startTime, endTime); |
| | | }).orderByAsc(ProductionCalendarDaytime::getStartTime)); |
| | | |
| | | List<ProductionCalendarDaytime> dayTimeList2 = dayTimeList.stream().filter(productionCalendarDaytime -> { |
| | | return (productionCalendarDaytime.getEndTime().equals(startTime) || productionCalendarDaytime.getStartTime().equals(endTime)) ? false : true; |
| | | }).collect(Collectors.toList()); |
| | | Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesMap = new HashMap<>(1919); |
| | | for (int i2 = 0; i2 <= CommonConstant.MINUTE_STOP.intValue(); i2++) {//MINUTE_STOP=1439,å·®ä¸åé23å°æ¶59åçåéæ° |
| | | buildTimeSlicesMap(startTime, endTime, dayTimeList2, timeSlicesMap, i2, targetDate); |
| | | } |
| | | timestampToProductionTimeCacheDto.setTimeSlicesDTOMap(timeSlicesMap); |
| | | timestampToProductionTimeCacheDtos.add(timestampToProductionTimeCacheDto); |
| | | }); |
| | | }); |
| | | } |
| | | return timestampToProductionTimeCacheDtos; |
| | | } |
| | | |
| | | private void buildTimeSlicesMap(LocalDateTime startTime, LocalDateTime endTime, List<ProductionCalendarDaytime> dayTimeList, Map<Integer, CalendarShiftTimeSlicesDTO> timeSlicesDTOMap, int i, LocalDate targetDate) { |
| | | LocalDateTime localDateTime = LocalDateTime.of(targetDate, LocalTime.MIN).plusMinutes(i).plusSeconds(1L); |
| | | |
| | | //å¨dayTimeListä¸è¿æ»¤åºå¨starttimeï¼endtimeä¹é´çæ¥æ |
| | | ProductionCalendarDaytime productionCalendarDaytime = dayTimeList.stream().filter(dayTime -> { |
| | | return (localDateTime.isAfter(dayTime.getStartTime()) || localDateTime.equals(dayTime.getStartTime())) && (localDateTime.isBefore(dayTime.getEndTime()) || localDateTime.equals(dayTime.getEndTime())); |
| | | }).findFirst().orElse(null); |
| | | if (Func.isEmpty(productionCalendarDaytime)) { |
| | | return; |
| | | } |
| | | LocalDateTime shiftStartTime = productionCalendarDaytime.getStartTime(); |
| | | LocalDateTime shiftEndTime = productionCalendarDaytime.getEndTime(); |
| | | if (shiftStartTime.isBefore(startTime)) { |
| | | shiftStartTime = startTime; |
| | | } |
| | | if (shiftEndTime.isAfter(endTime)) { |
| | | shiftEndTime = endTime; |
| | | } |
| | | CalendarShiftTimeSlicesDTO calendarShiftTimeSlicesDTO = CalendarShiftTimeSlicesDTO.builder().shiftTimeType(productionCalendarDaytime.getShiftType().toString()).endTime(LocalDateTimeUtils.LocalDateTimeToDate(shiftEndTime)).startTime(LocalDateTimeUtils.LocalDateTimeToDate(shiftStartTime)).shiftIndex(productionCalendarDaytime.getShiftIndex()).shiftTimeType(productionCalendarDaytime.getShiftType().toString()).factoryDate(LocalDateTimeUtils.formatTimeLocalDate(productionCalendarDaytime.getCalendarDate(), "yyyy-MM-dd")).factoryMonth(productionCalendarDaytime.getMonth()).factoryWeek(productionCalendarDaytime.getWeek()).factoryYear(productionCalendarDaytime.getYear()).build(); |
| | | timeSlicesDTOMap.put(Integer.valueOf(i), calendarShiftTimeSlicesDTO); |
| | | } |
| | | } |
| | |
| | | private IotDBSessionConfig iotdbConfig; |
| | | @Autowired |
| | | private IotDBCommonService iotDBCommonService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | private static String TEMPLATE_NAME = "process_param"; |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map.Entry; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; |
| | | import org.apache.iotdb.tsfile.write.record.Tablet; |
| | | import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.constants.IOTDBConstant; |
| | | import com.qianwen.mdc.collect.dto.StateAggregateTimeDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.AggregateState; |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.AggregateStateMapper; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.DeviceStateMapper; |
| | | import com.qianwen.mdc.collect.utils.WorkstationStateAggregateNoFeedbackUtils; |
| | | |
| | | /** |
| | | * éåé¦ç¹ ç¶æèåæå¡ |
| | | */ |
| | | @Service |
| | | public class DeviceStateAggregateNoFeedbackService { |
| | | private static final Logger log = LoggerFactory.getLogger(DeviceStateAggregateNoFeedbackService.class); |
| | | @Autowired |
| | | private DeviceStateMapper stateMapper; |
| | | @Autowired |
| | | private AggregateStateMapper workstationAggregateStateMapper; |
| | | @Autowired |
| | | private IotDBSessionConfig iotdbConfig; |
| | | |
| | | |
| | | public List<AggregateState> stateAggregateForSpecialTimeRange(Long workstationId, StateAggregateTimeDTO timeRange, List<DeviceState> effectiveStateList) { |
| | | //ætimeRangeæ¥è¯¢æ¶é´åºé´å
çç¶ææ°æ®ï¼é¤äºå·²å é¤çï¼å
¶ä»æ°æ®é½æ¥åºæ¥äº |
| | | /* |
| | | List<DeviceState> notSyncWorkstationStates = this.stateMapper.selectList(Wrappers.<DeviceState>lambdaQuery() |
| | | .eq(DeviceState::getWorkstationId, workstationId).and(wrapper -> { |
| | | LambdaQueryWrapper lambdaQueryWrapper = wrapper.eq(DeviceState::getIsDeleted, Boolean.FALSE).or().isNull(DeviceState::getIsDeleted); |
| | | }).ge(Func.isNotEmpty(timeRange.getStartTime()), DeviceState::getTime, timeRange.getStartTime()) |
| | | .le(DeviceState::getTime, timeRange.getEndTime()).orderByAsc(DeviceState::getTime)); |
| | | */ |
| | | List<DeviceState> notSyncWorkstationStates = stateMapper.statesInTimeRange(workstationId,timeRange); |
| | | effectiveStateList.addAll(notSyncWorkstationStates);//å¹²åçï¼è¿åç»è°ç¨è
äºï¼ |
| | | List<AggregateState> result = WorkstationStateAggregateNoFeedbackUtils.buildAggregateList(notSyncWorkstationStates); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * è¿æ»¤åºææèåç¶ææ°æ®å¹¶ä¿å |
| | | * @param result |
| | | * @param workstationId |
| | | * @param effectTimeRangeList |
| | | */ |
| | | public void handlerAggregateState(List<AggregateState> result, Long workstationId, StateAggregateTimeDTO timeRange) { |
| | | /* |
| | | if (Func.isNotEmpty(result)) { |
| | | Map<String, List> stringListMap = CommonUtil.groupList(getFinallyAggregateStateList(result, workstationId, effectTimeRangeList), CommonConstant.MAX_RECORDS_FOR_SQL_LENGTH.intValue()); |
| | | stringListMap.forEach(k, v -> { |
| | | this.workstationAggregateStateMapper.batchSave(workstationId, v); |
| | | }); |
| | | }*/ |
| | | |
| | | if(result.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | List<AggregateState> aggStates = getFinallyAggregateStateList(result, workstationId, timeRange); |
| | | |
| | | List<MeasurementSchema> schemas = new ArrayList<>(); |
| | | schemas.add(new MeasurementSchema("workstation_id", TSDataType.INT64)); |
| | | schemas.add(new MeasurementSchema("value_collect", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("end_time", TSDataType.INT64)); |
| | | schemas.add(new MeasurementSchema("duration_collect", TSDataType.INT64)); |
| | | |
| | | schemas.add(new MeasurementSchema("calendar_code", TSDataType.TEXT)); |
| | | schemas.add(new MeasurementSchema("factory_year", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_month", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_week", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_date", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("shift_index", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("shift_time_type", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("wcs", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("rps", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("is_sync", TSDataType.BOOLEAN)); |
| | | schemas.add(new MeasurementSchema("is_plan", TSDataType.INT32));//TODO è¿ä¸ªå±æ§åºè¯¥æ¯GlobalWcsOfRpsä¸çå¼ï¼å¦ä½å¡«åï¼ |
| | | schemas.add(new MeasurementSchema("feedback_id", TSDataType.INT64)); |
| | | schemas.add(new MeasurementSchema("is_deleted", TSDataType.BOOLEAN)); |
| | | schemas.add(new MeasurementSchema("employee_id", TSDataType.INT64)); |
| | | |
| | | //å½åï¼aggregate_state_{workstation_id} |
| | | String deviceId = IOTDBConstant.DB_PREFIX+"aggregate_state_"+workstationId; |
| | | Tablet tablet = new Tablet(deviceId, schemas); |
| | | //tablet.rowSize = aggStates.size(); |
| | | |
| | | AggregateState aggState; |
| | | for(int i=0;i<aggStates.size();i++) { |
| | | aggState = aggStates.get(i); |
| | | tablet.addTimestamp(i, aggState.getTime()); |
| | | tablet.addValue("workstation_id", i, aggState.getWorkstationId()); |
| | | tablet.addValue("value_collect", i, aggState.getValueCollect()); |
| | | tablet.addValue("end_time", i, aggState.getEndTime()); |
| | | tablet.addValue("duration_collect", i, aggState.getDurationCollect()); |
| | | tablet.addValue("calendar_code", i, aggState.getCalendarCode()); |
| | | tablet.addValue("factory_year", i, aggState.getFactoryYear()); |
| | | tablet.addValue("factory_month", i, aggState.getFactoryMonth()); |
| | | tablet.addValue("factory_week", i, aggState.getFactoryWeek()); |
| | | tablet.addValue("factory_date", i, aggState.getFactoryDate()); |
| | | tablet.addValue("shift_index", i, aggState.getShiftIndex()); |
| | | tablet.addValue("shift_time_type", i, aggState.getShiftTimeType()); |
| | | tablet.addValue("wcs", i, aggState.getWcs()); |
| | | tablet.addValue("rps", i, aggState.getRps()); |
| | | tablet.addValue("is_sync", i, aggState.getIsSync()); |
| | | tablet.addValue("is_plan", i, aggState.getIsPlan()); |
| | | tablet.addValue("feedback_id", i, aggState.getFeedbackId()); |
| | | tablet.addValue("is_deleted", i, aggState.getIsDeleted()); |
| | | tablet.addValue("employee_id", i, aggState.getEmployeeId()); |
| | | |
| | | } |
| | | try { |
| | | this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | } catch (Exception e) { |
| | | log.error("ä¿åèåç¶ææ°æ®å¼å¸¸",e); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private List<AggregateState> getFinallyAggregateStateList(List<AggregateState> result, Long workstationId, StateAggregateTimeDTO timeRange) { |
| | | /* |
| | | List<StateAggregateTimeDTO> effectTimeRangeList2 = effectTimeRangeList.stream().filter(x -> { |
| | | return Boolean.TRUE.equals(x.getNoFeedbackTime()); |
| | | }).collect(Collectors.toList()); |
| | | */ |
| | | List<AggregateState> finallyResult = new ArrayList<>(); |
| | | //for (StateAggregateTimeDTO item : effectTimeRangeList2) { |
| | | List<AggregateState> temp = this.workstationAggregateStateMapper.selectList(Wrappers.<AggregateState>lambdaQuery() |
| | | .eq(AggregateState::getWorkstationId, workstationId).and(wrapper -> { |
| | | LambdaQueryWrapper lambdaQueryWrapper = wrapper.eq(AggregateState::getIsDeleted, Boolean.FALSE).or().isNull(AggregateState::getIsDeleted); |
| | | }). |
| | | ge(Func.isNotEmpty(timeRange.getStartTime()), AggregateState::getTime, timeRange.getStartTime()).le(AggregateState::getTime, timeRange.getEndTime()).orderByAsc(AggregateState::getTime)); |
| | | if (Func.isNotEmpty(temp)) { |
| | | finallyResult.addAll(temp); |
| | | } |
| | | //} |
| | | |
| | | List<AggregateState> deleteData = finallyResult.stream().map(x2 -> { |
| | | x2.setIsDeleted(Boolean.TRUE); |
| | | return x2; |
| | | }).collect(Collectors.toList()); |
| | | return WorkstationStateAggregateNoFeedbackUtils.getReallyEffectWorkstationStateAggregateNoFeedbackList(result, deleteData); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Map.Entry; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; |
| | | import org.apache.iotdb.tsfile.write.record.Tablet; |
| | | import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.core.tool.utils.SpringUtil; |
| | | import com.qianwen.mdc.collect.cache.WorkstationCache; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.constants.CommonConstant; |
| | | import com.qianwen.mdc.collect.constants.IOTDBConstant; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftInfoDTO; |
| | | import com.qianwen.mdc.collect.dto.StateAggregateTimeDTO; |
| | | import com.qianwen.mdc.collect.dto.WorkstationDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.AggregateState; |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | import com.qianwen.mdc.collect.enums.FeedbackTimePointEnum; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.DeviceStateMapper; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper; |
| | | import com.qianwen.mdc.collect.utils.FeedbackAnalyseUtils; |
| | | import com.qianwen.mdc.collect.utils.LocalDateTimeUtils; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | /** |
| | | * 设å¤ç¶æèåæå¡ |
| | | */ |
| | | @Service |
| | | public class DeviceStateAggregateService{ |
| | | private static final Logger log = LoggerFactory.getLogger(DeviceStateAggregateService.class); |
| | | |
| | | @Autowired |
| | | private CalendarMapper calendarMapper; |
| | | @Autowired |
| | | private DeviceStateMapper stateMapper; |
| | | @Autowired |
| | | private WorkstationCache workstationCache; |
| | | @Autowired |
| | | private IotDBCommonService iotDBCommonService; |
| | | @Autowired |
| | | private IotDBSessionConfig iotdbConfig; |
| | | @Autowired |
| | | private DeviceStateService deviceStateService; |
| | | @Autowired |
| | | private DeviceStateAggregateNoFeedbackService stateAggregateNoFeedbackService; |
| | | |
| | | public void stateAggregate(Long workstationId) { |
| | | ////è·åæ¶é´é¶æ®µå表(2个),ä¸ä¸ªnoFeedbackTime=trueï¼ä¸ä¸ªnoFeedbackTime=false,æä»¬èªå·±è¿åä¸ä¸ªstartTimeï¼endTimeå³å¯ï¼noFeedbackTime=trueçå³å¯ |
| | | //List<StateAggregateTimeDTO> effective = getCurrentStateAggregateTimeRange(workstationId); |
| | | StateAggregateTimeDTO timeRange = getAggregateTimeRange(workstationId); |
| | | List<AggregateState> noFeedbackAggregateList = new ArrayList<>(); |
| | | |
| | | //List<WorkstationAggregateStateWithFeedback> feedbackAggregateList = new ArrayList<>();//ææ¶ä¸éè¦ï¼æ²¡äººå¡«ååé¦ |
| | | List<DeviceState> noFeedbackStateList = new ArrayList<>();//åå¡«çå表 |
| | | noFeedbackAggregateList.addAll(this.stateAggregateNoFeedbackService.stateAggregateForSpecialTimeRange(workstationId, timeRange, noFeedbackStateList)); |
| | | |
| | | /* |
| | | Collection<DeviceState> effectiveState = getReallyEffectWorkstationStateList(noFeedbackStateList, feedbackStateList); |
| | | List<DeviceState> effectiveStateList = effectiveState.stream().map(x -> { |
| | | x.setIsSync(Boolean.TRUE); |
| | | return x; |
| | | }).collect(Collectors.toList());*/ |
| | | noFeedbackStateList.forEach(state -> {state.setIsSync(true);});//TODO æ¯å¦éè¦çææ°å表ï¼é¿å
è¢«ä¿®æ¹æ°æ® |
| | | |
| | | //this.stateAggregateWithFeedbackService.handlerAggregateState(feedbackAggregateList, workstationId, effective); |
| | | this.stateAggregateNoFeedbackService.handlerAggregateState(noFeedbackAggregateList, workstationId, timeRange);//è¿æ»¤åºææç¶ææ°æ®å¹¶ä¿å |
| | | //æ´æ°isSyncå¾ç¶æ |
| | | /* |
| | | if (Func.isNotEmpty(effectiveStateList)) { |
| | | Map<String, List> stringListMap = CommonUtil.groupList(effectiveStateList, CommonConstant.MAX_RECORDS_FOR_SQL_LENGTH.intValue()); |
| | | stringListMap.forEach((k, v) -> { |
| | | this.workstationStateMapper.batchSave(workstationId, v); |
| | | }); |
| | | }*/ |
| | | deviceStateService.saveDeviceStates(noFeedbackStateList);//æ´æ°isSync=true |
| | | ////使ç¨workstationWcsFeedbackMapperæ´æ°åé¦å¾ç¶æ,æä»¬ä¸éè¦ |
| | | //IWorkstationFeedbackService workstationFeedbackService = SpringUtil.getBean(IWorkstationFeedbackService.class); |
| | | //workstationFeedbackService.handlerFeedbackComplete(workstationId); |
| | | } |
| | | |
| | | |
| | | private StateAggregateTimeDTO getAggregateTimeRange(Long workstationId) { |
| | | Long normalStartTime = FeedbackAnalyseUtils.getNormalStartTimePoint(workstationId, stateMapper);//æåä¸ä¸ªå·²åæ¥çisFixPoint=falseæ¶é´ï¼æè
ææ°ä¸ä¸ªæªåæ¥çãæ»ä¹å°±æ¯æ¥æ¾èåå¼å§æ¶é´ç¹ã |
| | | //è¿ä¸ª |
| | | StateAggregateTimeDTO nofeedBackTimeRange2 = new StateAggregateTimeDTO(); |
| | | nofeedBackTimeRange2.setStartTime(normalStartTime); |
| | | nofeedBackTimeRange2.setEndTime(System.currentTimeMillis()); |
| | | nofeedBackTimeRange2.setNoFeedbackTime(Boolean.FALSE); |
| | | |
| | | return nofeedBackTimeRange2; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¶é´èå´ï¼ï¼ï¼ |
| | | */ |
| | | /* |
| | | private List<StateAggregateTimeDTO> getCurrentStateAggregateTimeRange(Long workstationId) { |
| | | Long currentTime = Long.valueOf(System.currentTimeMillis()); |
| | | List<StateAggregateTimeDTO> effectiveTimeRangeList = new ArrayList<>(); |
| | | //WorkstationStateMapper stateMapper = SpringUtil.getBean(WorkstationStateMapper.class); |
| | | //List<DeviceState> processingStateList = stateMapper.getProcessingFeedbackState(workstationId); // is_sync = false AND feedback_point_type != 0 |
| | | List<DeviceState> processingStateList = Collections.emptyList();//æä»¬æ²¡æfeedback_point_type != 0çæ°æ®ï¼å°±æ¯æ²¡æåé¦ç¹æ°æ® |
| | | Long normalStartTime = FeedbackAnalyseUtils.getNormalStartTimePoint(workstationId, stateMapper);//æåä¸ä¸ªå·²åæ¥çisFixPoint=falseæ¶é´ï¼æè
ææ°ä¸ä¸ªæªåæ¥çãæ»ä¹å°±æ¯æ¥æ¾èåå¼å§æ¶é´ç¹ã |
| | | if (Func.isNotEmpty(processingStateList)) {//é空(ææªåæ¥çåé¦ç¹) |
| | | //!!!è¿ä¸ªIFéæ°æ®æ²¡ç¨ |
| | | //æ¥æ¾starttimeï¼endtime (sync=true,IsFixPoint=false) : startTime< processingStateList < endTime |
| | | //Long startTime = FeedbackAnalyseUtils.getStartFeedbackTimePoint(workstationId, stateMapper, processingStateList); |
| | | //Long endTime = FeedbackAnalyseUtils.getEndFeedbackTimePoint(workstationId, stateMapper, processingStateList); |
| | | Long startTime = 0L;//ä¸´æ¶æ°æ®ï¼æ²¡ç¨ |
| | | Long endTime =0L; |
| | | |
| | | StateAggregateTimeDTO feedbackTimeRange = new StateAggregateTimeDTO(); |
| | | feedbackTimeRange.setNoFeedbackTime(Boolean.FALSE); |
| | | feedbackTimeRange.setStartTime(startTime); |
| | | if (Func.isNotEmpty(endTime)) { |
| | | feedbackTimeRange.setEndTime(endTime); |
| | | } else { |
| | | endTime = currentTime; |
| | | feedbackTimeRange.setEndTime(currentTime); |
| | | } |
| | | if (Func.isNotEmpty(normalStartTime)) { |
| | | if (normalStartTime.longValue() <= startTime.longValue()) { |
| | | feedbackTimeRange.setStartTime(startTime); |
| | | } |
| | | if (startTime.longValue() >= normalStartTime.longValue() && endTime.longValue() >= normalStartTime.longValue()) { |
| | | feedbackTimeRange.setEndTime(currentTime); |
| | | } |
| | | if (normalStartTime.longValue() > endTime.longValue()) { |
| | | StateAggregateTimeDTO nofeedBackTimeRange = new StateAggregateTimeDTO(); |
| | | nofeedBackTimeRange.setStartTime(normalStartTime); |
| | | nofeedBackTimeRange.setNoFeedbackTime(Boolean.FALSE); |
| | | nofeedBackTimeRange.setEndTime(currentTime); |
| | | effectiveTimeRangeList.add(nofeedBackTimeRange); |
| | | } |
| | | } else { |
| | | feedbackTimeRange.setStartTime(null); |
| | | feedbackTimeRange.setEndTime(currentTime); |
| | | } |
| | | effectiveTimeRangeList.add(feedbackTimeRange); |
| | | } else { |
| | | //è¿ä¸ª |
| | | StateAggregateTimeDTO nofeedBackTimeRange2 = new StateAggregateTimeDTO(); |
| | | nofeedBackTimeRange2.setStartTime(normalStartTime); |
| | | nofeedBackTimeRange2.setEndTime(currentTime); |
| | | nofeedBackTimeRange2.setNoFeedbackTime(Boolean.FALSE); |
| | | effectiveTimeRangeList.add(nofeedBackTimeRange2); |
| | | } |
| | | StateAggregateTimeDTO nofeedBackTimeRange3 = new StateAggregateTimeDTO(); |
| | | nofeedBackTimeRange3.setStartTime(normalStartTime); |
| | | nofeedBackTimeRange3.setEndTime(currentTime); |
| | | nofeedBackTimeRange3.setNoFeedbackTime(Boolean.TRUE); |
| | | |
| | | effectiveTimeRangeList.add(nofeedBackTimeRange3); |
| | | return effectiveTimeRangeList; |
| | | } |
| | | */ |
| | | /** |
| | | * å»éçä½ç¨ï¼å°ææç¶ææ°æ®å»éæ¾å°ä¸ä¸ªå表 |
| | | * @param noFeedbackStateList |
| | | * @param feedbackStateList |
| | | * @return |
| | | */ |
| | | /* |
| | | private Collection<DeviceState> getReallyEffectWorkstationStateList(List<DeviceState> noFeedbackStateList, List<DeviceState> feedbackStateList) { |
| | | HashMap<Long, DeviceState> workstationStateMap = new HashMap<>(); |
| | | if (Func.isNotEmpty(noFeedbackStateList)) { |
| | | noFeedbackStateList.forEach(item -> { |
| | | workstationStateMap.put(item.getTime(), item); |
| | | }); |
| | | } |
| | | if (Func.isNotEmpty(feedbackStateList)) { |
| | | for (DeviceState state : feedbackStateList) { |
| | | if (!workstationStateMap.containsKey(state.getTime())) { |
| | | workstationStateMap.put(state.getTime(), state); |
| | | } |
| | | } |
| | | } |
| | | return workstationStateMap.values(); |
| | | }*/ |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | private List<DeviceState> getDefaultShift24HourPointDTOS(Long workStationId, String calendarCode, CalendarShiftInfoDTO shift) { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Map.Entry; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; |
| | | import org.apache.iotdb.tsfile.write.record.Tablet; |
| | | import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.core.tool.utils.SpringUtil; |
| | | import com.qianwen.mdc.collect.cache.WorkstationCache; |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.qianwen.mdc.collect.constants.CommonConstant; |
| | | import com.qianwen.mdc.collect.constants.IOTDBConstant; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftInfoDTO; |
| | | import com.qianwen.mdc.collect.dto.WorkstationDTO; |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | import com.qianwen.mdc.collect.enums.FeedbackTimePointEnum; |
| | | import com.qianwen.mdc.collect.mapper.mgr.CalendarMapper; |
| | | import com.qianwen.mdc.collect.utils.LocalDateTimeUtils; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | /** |
| | | * 设å¤ç¶ææ®éæå¡ |
| | | */ |
| | | @Service |
| | | public class DeviceStateService{ |
| | | private static final Logger log = LoggerFactory.getLogger(DeviceStateService.class); |
| | | |
| | | @Autowired |
| | | private IotDBCommonService iotDBCommonService; |
| | | @Autowired |
| | | private IotDBSessionConfig iotdbConfig; |
| | | |
| | | static final List<MeasurementSchema> schemas; |
| | | |
| | | static { |
| | | schemas = new ArrayList<>(); |
| | | |
| | | schemas.add(new MeasurementSchema("workstation_id", TSDataType.INT64)); |
| | | schemas.add(new MeasurementSchema("value_collect", TSDataType.INT32)); |
| | | |
| | | schemas.add(new MeasurementSchema("calendar_code", TSDataType.TEXT)); |
| | | schemas.add(new MeasurementSchema("factory_year", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_month", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_week", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("factory_date", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("shift_index", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("shift_time_type", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("wcs", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("rps", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("is_fix_point", TSDataType.BOOLEAN)); |
| | | schemas.add(new MeasurementSchema("is_sync", TSDataType.BOOLEAN)); |
| | | schemas.add(new MeasurementSchema("is_plan", TSDataType.INT32));//TODO è¿ä¸ªå±æ§åºè¯¥æ¯GlobalWcsOfRpsä¸çå¼ï¼å¦ä½å¡«åï¼ |
| | | schemas.add(new MeasurementSchema("feedback_point_type", TSDataType.INT32)); |
| | | schemas.add(new MeasurementSchema("feedback_id", TSDataType.INT64)); |
| | | schemas.add(new MeasurementSchema("is_deleted", TSDataType.BOOLEAN)); |
| | | schemas.add(new MeasurementSchema("employee_id", TSDataType.INT64)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * ä¿åç¶æåºå®ç¹æ°æ®(state_{workstationId}) |
| | | * @param stateList |
| | | */ |
| | | public void saveDeviceStates(List<DeviceState> stateList) { |
| | | //å°æ°æ®æç
§å·¥ä½idåç» |
| | | Map<Long,List<DeviceState>> maps = stateList.stream().collect(Collectors.groupingBy(DeviceState::getWorkstationId)); |
| | | String deviceId; |
| | | Long wid; |
| | | |
| | | List<DeviceState> states; |
| | | for(Entry<Long, List<DeviceState>> entry: maps.entrySet()) { |
| | | wid = entry.getKey(); |
| | | |
| | | deviceId = IOTDBConstant.DB_PREFIX+"state_"+wid; |
| | | iotDBCommonService.setTemmplateIfNotSet(IOTDBConstant.TEMPLATE_STATE, deviceId);//æè½½æ¨¡æ¿ |
| | | |
| | | Tablet tablet = new Tablet(deviceId, schemas); |
| | | |
| | | states = entry.getValue(); |
| | | tablet.rowSize = states.size(); |
| | | DeviceState state; |
| | | for(int i=0;i<states.size();i++) { |
| | | state = states.get(i); |
| | | tablet.addTimestamp(i, state.getTime()); |
| | | tablet.addValue("workstation_id", i, state.getWorkstationId()); |
| | | tablet.addValue("value_collect", i, state.getValueCollect()); |
| | | |
| | | tablet.addValue("calendar_code", i, state.getCalendarCode()); |
| | | tablet.addValue("factory_year", i, state.getFactoryYear()); |
| | | tablet.addValue("factory_month", i, state.getFactoryMonth()); |
| | | tablet.addValue("factory_week", i, state.getFactoryWeek()); |
| | | tablet.addValue("factory_date", i, state.getFactoryDate()); |
| | | tablet.addValue("shift_index", i, state.getShiftIndex()); |
| | | tablet.addValue("shift_time_type", i, state.getShiftTimeType()); |
| | | tablet.addValue("wcs", i, state.getWcs()); |
| | | tablet.addValue("rps", i, state.getRps()); |
| | | tablet.addValue("is_fix_point", i, state.getIsFixPoint()); |
| | | tablet.addValue("is_sync", i, state.getIsSync()); |
| | | tablet.addValue("is_plan", i, state.getIsPlan()); |
| | | tablet.addValue("feedback_point_type", i, state.getFeedbackPointType()); |
| | | tablet.addValue("feedback_id", i, state.getFeedbackId()); |
| | | tablet.addValue("is_deleted", i, state.getIsDeleted()); |
| | | tablet.addValue("employee_id", i, state.getEmployeeId()); |
| | | |
| | | } |
| | | try { |
| | | //æ¯ä¸ªå·¥ä½æ¹éæå
¥ä¸æ¬¡æ°æ® |
| | | this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | } catch (Exception e) { |
| | | log.error("ä¿ååºå®ç¹æ°æ®å¼å¸¸",e); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | /** |
| | | * å¤çæ¶å°çæ¶æ¯ |
| | | * å¤çæ¶å°çæ¶æ¯,对åºTelemetryDataPostingConsumer |
| | | * @param payload |
| | | */ |
| | | public void handle(String payload) { |
| | | //System.out.println("Received message122: " + payload); |
| | | //è§£ææ¶æ¯æª |
| | | //è§£ææ¶æ¯ |
| | | List<TelemetryData> teleList = parsePayload(payload); |
| | | |
| | | collectDataService.handleCollectData(teleList); |
| | |
| | | return dtList; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å¯¹åºè¡¨ç¼åï¼è·åappId对åºçid |
| | | * @param appId |
| | | * @return |
| | | */ |
| | | public long getWorkstationIdByAppId(String appId) { |
| | | |
| | | Object wid = redisUtil.hget("workstation-appid-map", appId); |
| | | String workstationId = String.valueOf(Optional.ofNullable(wid).orElse("-1")); |
| | | String workstationId = String.valueOf(Optional.ofNullable(wid).orElse(appId)); |
| | | |
| | | return Long.parseLong(workstationId); |
| | | } |
| | |
| | | package com.qianwen.mdc.collect.service; |
| | | |
| | | import java.time.DayOfWeek; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneOffset; |
| | | import java.time.temporal.WeekFields; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.commons.lang3.time.FastDateFormat; |
| | | import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; |
| | | import org.apache.iotdb.tsfile.write.record.Tablet; |
| | | import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.qianwen.mdc.collect.config.IotDBSessionConfig; |
| | | import com.google.common.collect.Sets; |
| | | import com.qianwen.mdc.collect.cache.TimeSliceCache; |
| | | import com.qianwen.mdc.collect.cache.WorkstationCache; |
| | | import com.qianwen.mdc.collect.constants.CommonConstant; |
| | | import com.qianwen.mdc.collect.domain.TelemetryData; |
| | | import com.qianwen.mdc.collect.domain.TelemetryDataItem; |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | import com.qianwen.mdc.collect.dto.CalendarShiftTimeSlicesDTO; |
| | | import com.qianwen.mdc.collect.dto.PackedTelemetryData; |
| | | import com.qianwen.mdc.collect.handler.PackedTelemetryDataHandlerSelector; |
| | | import com.qianwen.mdc.collect.handler.TelemetryDataHandler; |
| | | import com.qianwen.mdc.collect.utils.LocalDateTimeUtils; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | |
| | | /** |
| | | * ééæ°æ®å¡«å
ï¼èååå
¥åº |
| | |
| | | public class PackedDataService { |
| | | private static final Logger log = LoggerFactory.getLogger(PackedDataService.class); |
| | | |
| | | private String DB_PREFIX = "root.f2."; |
| | | private static final Map<Integer, String> PROCESS_PARAM_MAP = new HashMap<>(); |
| | | @Autowired |
| | | private IotDBSessionConfig iotdbConfig; |
| | | @Autowired |
| | | private IotDBCommonService iotDBCommonService; |
| | | |
| | | @Autowired |
| | | private PackedTelemetryDataHandlerSelector handlerSelector; |
| | | |
| | | private static String TEMPLATE_NAME = "process_param"; |
| | | @Autowired |
| | | private WorkstationCache workstationCache; |
| | | @Autowired |
| | | private TimeSliceCache timeSliceCache; |
| | | //private static String TEMPLATE_NAME = "process_param"; |
| | | |
| | | static { |
| | | PROCESS_PARAM_MAP.put(1, "STATE"); |
| | |
| | | void fillByCalendar(PackedTelemetryData pdata) { |
| | | //忥å¨TelemetryPropertyWrapper.packWorkstationCalendarInfoä¸å®æ |
| | | //FIXME: å¡«åå®é
çæ°æ®è¿éè¦åç»å¤ç |
| | | pdata.setCalendarCode("1");//临æ¶ï¼ç®ååºå
齿¯1 |
| | | |
| | | Date collectTime = new Date(pdata.getTime()); |
| | | String calendarCode = workstationCache.getWorkstationCalendarCodeForDate(pdata.getWorkstationId(), DateUtil.formatDate(DateUtil.date(collectTime))); |
| | | if (ObjectUtil.isNotEmpty(calendarCode)) { |
| | | pdata.setCalendarCode(calendarCode); |
| | | //telemetryData.setCalendarCode(calendarCode); |
| | | } else { |
| | | //telemetryData.setCalendarCode("#default#"); |
| | | pdata.setCalendarCode("#default#"); |
| | | } |
| | | |
| | | pdata.setShiftIndex(1);//ä¸´æ¶ |
| | | pdata.setShiftTimeType(1);//ä¸´æ¶ |
| | | |
| | | // TelemetryPropertyWrapperä¸packWorkstationCalendarInfo |
| | | Date collectTime = new Date(pdata.getTime()); |
| | | //------------start |
| | | Boolean isDefaultCalendar = true; |
| | | if (!"#default#".equals(pdata.getCalendarCode())) { |
| | | CalendarShiftTimeSlicesDTO calendarShiftTimeSlicesDTO = timeSliceCache.getTimeSliceShift(pdata.getCalendarCode(), collectTime);//ä»redisä¸è·å¾æ¥åçæ¶é´åç |
| | | if (ObjectUtil.isEmpty(calendarShiftTimeSlicesDTO)) {//å¦ææ²¡ææ¶é´åçï¼å使ç¨TimeSliceCache.build(cacheBuildDTO);æå»º |
| | | LocalDate targetDate = Instant.ofEpochMilli(pdata.getTime()).atZone(ZoneOffset.systemDefault()).toLocalDate(); |
| | | CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).calendarCode(calendarCode).targetDate(targetDate).build(); |
| | | timeSliceCache.build(cacheBuildDTO); |
| | | calendarShiftTimeSlicesDTO = timeSliceCache.getTimeSliceShift(pdata.getCalendarCode(), collectTime); |
| | | } |
| | | if (ObjectUtil.isNotEmpty(calendarShiftTimeSlicesDTO)) { |
| | | pdata.setShiftIndex(calendarShiftTimeSlicesDTO.getShiftIndex()).setShiftTimeType(Integer.valueOf(calendarShiftTimeSlicesDTO.getShiftTimeType())).setFactoryDate(Integer.valueOf(calendarShiftTimeSlicesDTO.getFactoryDate().replaceAll("-", ""))).setFactoryWeek(calendarShiftTimeSlicesDTO.getFactoryWeek()).setFactoryMonth(calendarShiftTimeSlicesDTO.getFactoryMonth()).setFactoryYear(calendarShiftTimeSlicesDTO.getFactoryYear()); |
| | | isDefaultCalendar = false; |
| | | } |
| | | } |
| | | |
| | | //æ æ¥ååçï¼ä½¿ç¨ééæ¶é´å¡«å
factoryYearï¼monthï¼dateï¼weekå ä¸ªå±æ§ |
| | | if (isDefaultCalendar.booleanValue()) { |
| | | log.info("æ æ¥ååç"); |
| | | LocalDate localDate = Instant.ofEpochMilli(pdata.getTime().longValue()).atZone(ZoneOffset.systemDefault()).toLocalDate(); |
| | | pdata.setFactoryDate(Integer.valueOf(DatePattern.PURE_DATE_FORMAT.format(collectTime))) |
| | | .setFactoryYear(DateUtil.year(collectTime)) |
| | | .setFactoryWeek(LocalDateTimeUtils.getWeek(localDate)) |
| | | .setFactoryMonth(DateUtil.month(collectTime) + 1) |
| | | .setShiftIndex(CommonConstant.DEFAULT_SHIFT_INDEX) |
| | | .setShiftTimeType(CommonConstant.DEFAULT_SHIFT_TYPE); |
| | | } |
| | | |
| | | //----------------------end |
| | | /* |
| | | |
| | | LocalDate localDate = Instant.ofEpochMilli(pdata.getTime()).atZone(ZoneOffset.systemDefault()).toLocalDate(); |
| | | |
| | | String PURE_DATE_PATTERN = "yyyyMMdd"; |
| | | /** æ åæ¥ææ ¼å¼ {@link FastDateFormat}ï¼yyyyMMdd */ |
| | | |
| | | FastDateFormat PURE_DATE_FORMAT = FastDateFormat.getInstance(PURE_DATE_PATTERN); |
| | | |
| | | WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1); |
| | |
| | | pdata.setFactoryYear(localDate.getYear()).setFactoryMonth(localDate.getMonthValue()) |
| | | .setFactoryDate(Integer.valueOf(PURE_DATE_FORMAT.format(collectTime))) |
| | | .setFactoryWeek(localDate.get(weekFields.weekOfYear())); |
| | | */ |
| | | } |
| | | |
| | | void handleOneWorkstationXX(TelemetryData dt) { |
| | | String deviceId = DB_PREFIX + TEMPLATE_NAME + "_" + dt.getWorkstationId(); |
| | | |
| | | // æè½½æ¨¡æ¿ |
| | | iotDBCommonService.setTemmplateIfNotSet(TEMPLATE_NAME, deviceId); |
| | | |
| | | List<MeasurementSchema> schemas = new ArrayList<>(); |
| | | |
| | | schemas.add(new MeasurementSchema("workstation_id", TSDataType.INT64)); |
| | | schemas.add(new MeasurementSchema("n", TSDataType.TEXT)); |
| | | schemas.add(new MeasurementSchema("v", TSDataType.TEXT)); |
| | | |
| | | Tablet tablet = new Tablet(deviceId, schemas); |
| | | int rowIndex = 0; |
| | | for (TelemetryDataItem dataItem : dt.getDataItems()) { |
| | | |
| | | for (Map<String, String> point : dataItem.getDataPoints()) { |
| | | |
| | | String[] keys = point.keySet().toArray(new String[0]); |
| | | for (int i = 0; i < keys.length; i++) { |
| | | rowIndex = tablet.rowSize++; |
| | | tablet.addTimestamp(rowIndex, dataItem.getTime()); |
| | | tablet.addValue("workstation_id", rowIndex, new Long(dt.getWorkstationId())); |
| | | tablet.addValue("n", rowIndex, keys[i]); |
| | | tablet.addValue("v", rowIndex, point.get(keys[i])); |
| | | } |
| | | |
| | | } |
| | | |
| | | try { |
| | | iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | } catch (Exception e) { |
| | | log.error("IODDBå
¥åºå¤±è´¥", e); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.utils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | //import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; |
| | | //import org.apache.rocketmq.common.UtilAll; |
| | | import com.qianwen.core.tool.utils.StringUtil; |
| | | |
| | | public class CommonUtil { |
| | | /* |
| | | public static String changeInstanceNameToPID(DefaultMQPushConsumer consumer) { |
| | | String instanceName = consumer.getInstanceName(); |
| | | if (consumer.getInstanceName().equals("DEFAULT")) { |
| | | instanceName = UtilAll.getPid() + "#" + System.nanoTime(); |
| | | } |
| | | return instanceName; |
| | | } |
| | | */ |
| | | public static String getReallyCacheName(String cacheName, String keyPrefix, String key) { |
| | | return cacheName.concat("::").concat(keyPrefix).concat(key); |
| | | } |
| | | |
| | | public static String getReallyCacheName(String cacheName, String keyPrefix, String key, Object... args) { |
| | | return StringUtil.format(cacheName.concat("::").concat(keyPrefix).concat(key), args); |
| | | } |
| | | /* |
| | | public static Map<String, List> groupList(List list, int size) { |
| | | int listSize = list.size(); |
| | | int index = size; |
| | | int keyToken = 0; |
| | | Map map = new HashMap(); |
| | | int i = 0; |
| | | while (true) { |
| | | int i2 = i; |
| | | if (i2 < list.size()) { |
| | | if (i2 + size > listSize) { |
| | | index = listSize - i2; |
| | | } |
| | | List newList = list.subList(i2, i2 + index); |
| | | map.put("keyName" + keyToken, newList); |
| | | keyToken++; |
| | | i = i2 + size; |
| | | } else { |
| | | return map; |
| | | } |
| | | } |
| | | }*/ |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.qianwen.core.tool.utils.BeanUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | import com.qianwen.mdc.collect.enums.FeedbackTimePointEnum; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.DeviceStateMapper; |
| | | |
| | | public class FeedbackAnalyseUtils { |
| | | private static final Logger log = LoggerFactory.getLogger(FeedbackAnalyseUtils.class); |
| | | /* |
| | | public static List<WorkstationFeedbackTimeQuantumDTO> getRelatedFeedbackTimeQuantumInfo(List<WorkstationFeedbackViewDTO> workstationFeedbackViewList) { |
| | | List<WorkstationFeedbackTimeQuantumDTO> result = new ArrayList<>(); |
| | | if (Func.isNotEmpty(workstationFeedbackViewList)) { |
| | | workstationFeedbackViewList.forEach(item -> { |
| | | WorkstationFeedbackTimeQuantumDTO temp = new WorkstationFeedbackTimeQuantumDTO(); |
| | | temp.setFeedbackId(item.getWorkstationWcsFeedback().getId()); |
| | | temp.setFeedbackTime(item.getWorkstationWcsFeedback().getFeedbackTime()); |
| | | temp.setWcs(item.getWorkstationWcsFeedback().getWcs()); |
| | | if (Func.isNotEmpty(item.getWorkstationWcsFeedbackDetails())) { |
| | | item.getWorkstationWcsFeedbackDetails().forEach(detail -> { |
| | | WorkstationFeedbackTimeQuantumDTO tempTime = (WorkstationFeedbackTimeQuantumDTO) BeanUtil.copyProperties(temp, WorkstationFeedbackTimeQuantumDTO.class); |
| | | tempTime.setStartTime(detail.getStartTime()); |
| | | tempTime.setFeedbackDetailId(detail.getId()); |
| | | tempTime.setEndTime(detail.getEndTime()); |
| | | result.add(tempTime); |
| | | }); |
| | | } else if (!item.getIsDeleted().booleanValue()) { |
| | | temp.setStartTime(item.getWorkstationWcsFeedback().getStartTime()); |
| | | temp.setEndTime(item.getWorkstationWcsFeedback().getEndTime()); |
| | | result.add(temp); |
| | | } |
| | | }); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // JADX WARN: Multi-variable type inference failed |
| | | public static List<WorkstationFeedbackTimePointDTO> buildFeedbackTimePointInfo(List<WorkstationFeedbackTimeQuantumDTO> feedbackTimeQuantumDTOList) { |
| | | List<WorkstationFeedbackTimePointDTO> result = new ArrayList<>(); |
| | | List<WorkstationFeedbackTimePointDTO> remove = new ArrayList<>(); |
| | | if (Func.isNotEmpty(feedbackTimeQuantumDTOList)) { |
| | | for (int i = 0; i < feedbackTimeQuantumDTOList.size(); i++) { |
| | | WorkstationFeedbackTimeQuantumDTO x = feedbackTimeQuantumDTOList.get(i); |
| | | WorkstationFeedbackTimePointDTO startTimePoint = new WorkstationFeedbackTimePointDTO().setFeedbackId(x.getFeedbackId()).setReportTime(x.getFeedbackTime()).setFeedbackDetailId(x.getFeedbackDetailId()).setFeedbackTime(x.getStartTime()).setWcs(x.getWcs()); |
| | | WorkstationFeedbackTimePointDTO endTimePoint = new WorkstationFeedbackTimePointDTO().setFeedbackId(x.getFeedbackId()).setReportTime(x.getFeedbackTime()).setFeedbackTime(x.getEndTime()).setFeedbackDetailId(x.getFeedbackDetailId()).setWcs(x.getWcs()); |
| | | result.add(startTimePoint); |
| | | result.add(endTimePoint); |
| | | } |
| | | } |
| | | if (Func.isNotEmpty(result)) { |
| | | result = (List) result.stream().sorted(Comparator.comparing((v0) -> { |
| | | return v0.getReportTime(); |
| | | }).thenComparing((v0) -> { |
| | | return v0.getFeedbackTime(); |
| | | })).collect(Collectors.toList()); |
| | | } |
| | | for (int i2 = 0; i2 < result.size(); i2++) { |
| | | result.get(i2).setIndex(Integer.valueOf(i2)); |
| | | } |
| | | getCrossFeedbackTimePoints(result); |
| | | List<WorkstationFeedbackTimePointDTO> finalResult = getEffectFeedbackTimePoints(result, remove); |
| | | return fixFeedbackTimePointInfo(feedbackTimeQuantumDTOList, buildFeedbackTimePointsCompleteInfo(finalResult, remove)); |
| | | } |
| | | |
| | | private static List<WorkstationFeedbackTimePointDTO> fixFeedbackTimePointInfo(List<WorkstationFeedbackTimeQuantumDTO> feedbackTimeQuantumDTOList, List<WorkstationFeedbackTimePointDTO> finalResult) { |
| | | List<WorkstationFeedbackTimePointDTO> result = new ArrayList<>(); |
| | | List<WorkstationFeedbackTimePointDTO> finallyResult = new ArrayList<>(); |
| | | new ArrayList(); |
| | | List<WorkstationFeedbackTimeQuantumDTO> effectFeedbackTimeQuantumList = (List) feedbackTimeQuantumDTOList.stream().sorted(Comparator.comparing((v0) -> { |
| | | return v0.getFeedbackTime(); |
| | | }).thenComparing((v0) -> { |
| | | return v0.getStartTime(); |
| | | }).reversed()).collect(Collectors.toList()); |
| | | for (WorkstationFeedbackTimePointDTO item : finalResult) { |
| | | if (FeedbackTimePointEnum.CROSS_POINT.isEqual(item.getPointEnum().getValue())) { |
| | | WorkstationFeedbackTimeQuantumDTO matchDto = effectFeedbackTimeQuantumList.stream().filter(x -> { |
| | | return x.getStartTime().getTime() <= item.getFeedbackTime().getTime() && x.getEndTime().getTime() > item.getFeedbackTime().getTime(); |
| | | }).findFirst().orElse(null); |
| | | if (Func.isNotEmpty(matchDto)) { |
| | | WorkstationFeedbackTimePointDTO tempTime = (WorkstationFeedbackTimePointDTO) BeanUtil.copyProperties(item, WorkstationFeedbackTimePointDTO.class); |
| | | tempTime.setFeedbackId(matchDto.getFeedbackId()); |
| | | tempTime.setFeedbackDetailId(matchDto.getFeedbackDetailId()); |
| | | tempTime.setWcs(matchDto.getWcs()); |
| | | result.add(tempTime); |
| | | } |
| | | } else { |
| | | result.add(item); |
| | | } |
| | | } |
| | | for (int i = 0; i < result.size(); i++) { |
| | | WorkstationFeedbackTimePointDTO temp = result.get(i); |
| | | if (FeedbackTimePointEnum.CROSS_POINT.isEqual(temp.getPointEnum().getValue()) && FeedbackTimePointEnum.END_POINT.isEqual(result.get(i + 1).getPointEnum().getValue())) { |
| | | temp.setWcs(result.get(i + 1).getWcs()); |
| | | temp.setFeedbackId(result.get(i + 1).getFeedbackId()); |
| | | } |
| | | finallyResult.add(temp); |
| | | } |
| | | return finallyResult; |
| | | } |
| | | |
| | | private static void getCrossFeedbackTimePoints(List<WorkstationFeedbackTimePointDTO> timePointList) { |
| | | new ArrayList(); |
| | | if (Func.isNotEmpty(timePointList)) { |
| | | for (WorkstationFeedbackTimePointDTO item : timePointList) { |
| | | WorkstationFeedbackTimePointDTO start = timePointList.stream().filter(x -> { |
| | | return x.getFeedbackTime().getTime() < item.getFeedbackTime().getTime() && x.getIndex().intValue() < item.getIndex().intValue() && !x.getFeedbackId().equals(item.getFeedbackId()); |
| | | }).max(Comparator.comparing((v0) -> { |
| | | return v0.getIndex(); |
| | | })).orElse(null); |
| | | WorkstationFeedbackTimePointDTO end = timePointList.stream().filter(x2 -> { |
| | | return x2.getFeedbackTime().getTime() > item.getFeedbackTime().getTime() && x2.getIndex().intValue() < item.getIndex().intValue() && !x2.getFeedbackId().equals(item.getFeedbackId()); |
| | | }).min(Comparator.comparing((v0) -> { |
| | | return v0.getIndex(); |
| | | })).orElse(null); |
| | | if (Func.isNotEmpty(start) && Func.isNotEmpty(end) && start.getFeedbackId().equals(end.getFeedbackId())) { |
| | | item.setPointEnum(FeedbackTimePointEnum.CROSS_POINT); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static List<WorkstationFeedbackTimePointDTO> buildFeedbackTimePointsCompleteInfo(List<WorkstationFeedbackTimePointDTO> effectFeedbackList, List<WorkstationFeedbackTimePointDTO> removeList) { |
| | | new ArrayList(); |
| | | if (Func.isNotEmpty(effectFeedbackList)) { |
| | | effectFeedbackList = (List) effectFeedbackList.stream().sorted(Comparator.comparing((v0) -> { |
| | | return v0.getFeedbackTime(); |
| | | })).collect(Collectors.toList()); |
| | | for (int i = 0; i < effectFeedbackList.size(); i++) { |
| | | if (i == 0) { |
| | | effectFeedbackList.get(0).setPointEnum(FeedbackTimePointEnum.START_POINT); |
| | | } else if (i == effectFeedbackList.size() - 1) { |
| | | effectFeedbackList.get(i).setPointEnum(FeedbackTimePointEnum.END_POINT); |
| | | } else { |
| | | WorkstationFeedbackTimePointDTO prePoint = effectFeedbackList.get(i - 1); |
| | | WorkstationFeedbackTimePointDTO currentPoint = effectFeedbackList.get(i); |
| | | WorkstationFeedbackTimePointDTO start = effectFeedbackList.stream().filter(x -> { |
| | | return x.getFeedbackTime().getTime() < currentPoint.getFeedbackTime().getTime() && !x.getFeedbackId().equals(currentPoint.getFeedbackId()); |
| | | }).max(Comparator.comparing((v0) -> { |
| | | return v0.getFeedbackTime(); |
| | | })).orElse(null); |
| | | WorkstationFeedbackTimePointDTO end = effectFeedbackList.stream().filter(x2 -> { |
| | | return x2.getFeedbackTime().getTime() > currentPoint.getFeedbackTime().getTime() && !x2.getFeedbackId().equals(currentPoint.getFeedbackId()); |
| | | }).min(Comparator.comparing((v0) -> { |
| | | return v0.getFeedbackTime(); |
| | | })).orElse(null); |
| | | if (Func.isNotEmpty(start) && Func.isNotEmpty(end) && start.getFeedbackId().equals(end.getFeedbackId())) { |
| | | currentPoint.setPointEnum(FeedbackTimePointEnum.CROSS_POINT); |
| | | } |
| | | if (checkIsCrossFeedbackTimePoint(currentPoint, effectFeedbackList, removeList)) { |
| | | currentPoint.setPointEnum(FeedbackTimePointEnum.CROSS_POINT); |
| | | } |
| | | if (!Func.isNotEmpty(currentPoint.getPointEnum())) { |
| | | if (Func.isNotEmpty(prePoint.getPointEnum()) && FeedbackTimePointEnum.CROSS_POINT.isEqual(prePoint.getPointEnum().getValue())) { |
| | | effectFeedbackList.get(i).setPointEnum(FeedbackTimePointEnum.END_POINT); |
| | | } |
| | | if (prePoint.getFeedbackId().equals(currentPoint.getFeedbackId())) { |
| | | effectFeedbackList.get(i).setPointEnum(FeedbackTimePointEnum.END_POINT); |
| | | } else { |
| | | if (prePoint.getPointEnum().isEqual(FeedbackTimePointEnum.START_POINT.getValue())) { |
| | | effectFeedbackList.get(i).setPointEnum(FeedbackTimePointEnum.CROSS_POINT); |
| | | } |
| | | if (prePoint.getPointEnum().isEqual(FeedbackTimePointEnum.END_POINT.getValue())) { |
| | | effectFeedbackList.get(i).setPointEnum(FeedbackTimePointEnum.START_POINT); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return effectFeedbackList; |
| | | } |
| | | |
| | | private static List<WorkstationFeedbackTimePointDTO> getEffectFeedbackTimePoints(List<WorkstationFeedbackTimePointDTO> originalPointsList, List<WorkstationFeedbackTimePointDTO> removeList) { |
| | | List<WorkstationFeedbackTimePointDTO> result = new ArrayList<>(); |
| | | for (WorkstationFeedbackTimePointDTO item : originalPointsList) { |
| | | if (checkIsKeepFeedbackTimePoint(item, originalPointsList)) { |
| | | result.add(item); |
| | | } else { |
| | | removeList.add(item); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private static boolean checkIsKeepFeedbackTimePoint(WorkstationFeedbackTimePointDTO pointDTO, List<WorkstationFeedbackTimePointDTO> originalPointsList) { |
| | | long min = originalPointsList.stream().filter(x -> { |
| | | return x.getIndex().intValue() > pointDTO.getIndex().intValue() && x.getFeedbackTime().getTime() <= pointDTO.getFeedbackTime().getTime(); |
| | | }).count(); |
| | | if (min <= 0) { |
| | | return true; |
| | | } |
| | | long max = originalPointsList.stream().filter(x2 -> { |
| | | return x2.getIndex().intValue() > pointDTO.getIndex().intValue() && x2.getFeedbackTime().getTime() >= pointDTO.getFeedbackTime().getTime(); |
| | | }).count(); |
| | | if (max <= 0) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private static boolean checkIsCrossFeedbackTimePoint(WorkstationFeedbackTimePointDTO pointDTO, List<WorkstationFeedbackTimePointDTO> originalPointsList, List<WorkstationFeedbackTimePointDTO> removeList) { |
| | | WorkstationFeedbackTimePointDTO exits; |
| | | List<WorkstationFeedbackTimePointDTO> minList = (List) originalPointsList.stream().filter(x -> { |
| | | return x.getFeedbackTime().getTime() < pointDTO.getFeedbackTime().getTime(); |
| | | }).collect(Collectors.toList()); |
| | | if (Func.isEmpty(minList)) { |
| | | return false; |
| | | } |
| | | List<WorkstationFeedbackTimePointDTO> maxList = (List) originalPointsList.stream().filter(x2 -> { |
| | | return x2.getFeedbackTime().getTime() > pointDTO.getFeedbackTime().getTime(); |
| | | }).collect(Collectors.toList()); |
| | | if (Func.isEmpty(maxList)) { |
| | | return false; |
| | | } |
| | | for (WorkstationFeedbackTimePointDTO item : minList) { |
| | | WorkstationFeedbackTimePointDTO exits2 = maxList.stream().filter(x3 -> { |
| | | return x3.getFeedbackId().equals(item.getFeedbackId()); |
| | | }).findAny().orElse(null); |
| | | if (Func.isNotEmpty(exits2)) { |
| | | return true; |
| | | } |
| | | } |
| | | for (WorkstationFeedbackTimePointDTO item2 : maxList) { |
| | | if (Func.isNotEmpty(item2.getFeedbackDetailId())) { |
| | | exits = removeList.stream().filter(x4 -> { |
| | | return Func.isNotEmpty(x4.getFeedbackDetailId()) && x4.getFeedbackDetailId().equals(item2.getFeedbackDetailId()) && x4.getFeedbackTime().getTime() <= pointDTO.getFeedbackTime().getTime(); |
| | | }).findAny().orElse(null); |
| | | } else { |
| | | exits = removeList.stream().filter(x5 -> { |
| | | return x5.getFeedbackId().equals(item2.getFeedbackId()) && x5.getFeedbackTime().getTime() <= pointDTO.getFeedbackTime().getTime(); |
| | | }).findAny().orElse(null); |
| | | } |
| | | if (Func.isNotEmpty(exits)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static List<WorkstationFeedbackTimeQuantumDTO> buildFeedbackTimeQuantum(List<WorkstationFeedbackTimePointDTO> effectFeedbackList) { |
| | | List<WorkstationFeedbackTimeQuantumDTO> result = new ArrayList<>(); |
| | | List<WorkstationFeedbackTimePointDTO> effectFeedbackList2 = (List) effectFeedbackList.stream().sorted(Comparator.comparing((v0) -> { |
| | | return v0.getFeedbackTime(); |
| | | })).collect(Collectors.toList()); |
| | | for (int i = 0; i < effectFeedbackList2.size() - 1; i++) { |
| | | WorkstationFeedbackTimePointDTO currentFeedbackPoint = effectFeedbackList2.get(i); |
| | | if (FeedbackTimePointEnum.END_POINT.isEqual(currentFeedbackPoint.getPointEnum().getValue())) { |
| | | break; |
| | | } |
| | | WorkstationFeedbackTimePointDTO nextFeedbackPoint = effectFeedbackList2.get(i + 1); |
| | | WorkstationFeedbackTimeQuantumDTO tempFeedback = new WorkstationFeedbackTimeQuantumDTO(); |
| | | tempFeedback.setFeedbackId(currentFeedbackPoint.getFeedbackId()); |
| | | tempFeedback.setStartTime(currentFeedbackPoint.getFeedbackTime()); |
| | | tempFeedback.setEndTime(nextFeedbackPoint.getFeedbackTime()); |
| | | tempFeedback.setWcs(currentFeedbackPoint.getWcs()); |
| | | result.add(tempFeedback); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static Long getStartFeedbackTimePoint(Long workstationId, WorkstationStateMapper stateMapper, List<WorkstationState> processingStateList) { |
| | | if (Func.isNotEmpty(processingStateList)) { |
| | | //æªåæ¥åé¦ç¹çææ©ä¸æ¡æ°æ® |
| | | Long startTime = processingStateList.stream().sorted(Comparator.comparing(WorkstationState::getTs)).collect(Collectors.toList()).get(0).getTs();//ææ©ä¸æ¡çts |
| | | |
| | | //æ¥è¯¢å¨åé¦ç¹ä¹å䏿¡å·²åæ¥çæ°æ®(å°äºstartTimeçæå䏿¡ã已忥ï¼IsFixPoint=falseçæ°æ®) |
| | | WorkstationState startNoFixpoint = stateMapper.getLastWorkstationState(Wrappers.<WorkstationState>lambdaQuery() |
| | | .eq(WorkstationState::getWorkstationId, workstationId) |
| | | .lt(WorkstationState::getTs, startTime) |
| | | .eq(WorkstationState::getIsSync, Boolean.TRUE) |
| | | .eq(WorkstationState::getIsFixPoint, Boolean.FALSE) |
| | | |
| | | .ne(WorkstationState::getIsDeleted, Boolean.TRUE)); |
| | | |
| | | |
| | | if (Func.isNotEmpty(startNoFixpoint)) { |
| | | startTime = startNoFixpoint.getTs(); |
| | | } |
| | | return startTime; |
| | | } |
| | | return null; |
| | | } |
| | | */ |
| | | /** |
| | | * |
| | | * @param workstationId |
| | | * @param stateMapper |
| | | * @param processingStateList æªåæ¥åé¦ç¹éå |
| | | * @return |
| | | */ |
| | | /* |
| | | public static Long getEndFeedbackTimePoint(Long workstationId, WorkstationStateMapper stateMapper, List<WorkstationState> processingStateList) { |
| | | Long result = null; |
| | | if (Func.isNotEmpty(processingStateList)) { |
| | | List<WorkstationState> processingStateList2 = processingStateList.stream().sorted(Comparator.comparing(WorkstationState::getTs)).collect(Collectors.toList()); |
| | | WorkstationState endTimePoint = processingStateList2.get(processingStateList2.size() - 1);//ææç䏿¡æ¶é´ |
| | | |
| | | if (FeedbackTimePointEnum.END_POINT.isEqual(endTimePoint.getFeedbackPointType())) {//å¦æè¯¥åé¦ç¹æ¯ç»ææ¶é´ï¼åæ¥æ¾ 第ä¸ä¸ª æ¶é´æäºè¯¥åé¦ç¹çå·²åæ¥ç¶æç¹ |
| | | WorkstationState endNoFixPoint = stateMapper.getFirstWorkstationState(Wrappers.<WorkstationState>lambdaQuery() |
| | | .eq(WorkstationState::getWorkstationId, workstationId). |
| | | gt(WorkstationState::getTs, endTimePoint.getTs()) |
| | | .eq(WorkstationState::getIsSync, Boolean.TRUE) |
| | | .eq(WorkstationState::getIsFixPoint, Boolean.FALSE) |
| | | .ne(WorkstationState::getIsDeleted, Boolean.TRUE)); |
| | | if (Func.isNotEmpty(endNoFixPoint)) { |
| | | result = endNoFixPoint.getTs(); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | */ |
| | | /** |
| | | * è·å¾æåä¸ä¸ªå·²åæ¥éåé¦ç¹çæ¶é´ï¼æè
ææ©ä¸ä¸ªæªåæ¥éåé¦ç¹æ¶é´ |
| | | * @param workstationId |
| | | * @param stateMapper |
| | | * @return |
| | | */ |
| | | public static Long getNormalStartTimePoint(Long workstationId, DeviceStateMapper stateMapper) { |
| | | //isFixPoint å¿
é¡»æ¯false |
| | | //è·åisSync=trueï¼NO_FEED_BACK_POINTçç¶ææ°æ® |
| | | /* |
| | | DeviceState resultTimePoint = stateMapper.getLastWorkstationState( Wrappers.<DeviceState>lambdaQuery() |
| | | .eq(DeviceState::getWorkstationId, workstationId).eq(DeviceState::getIsSync, Boolean.TRUE).eq(DeviceState::getIsFixPoint, Boolean.FALSE) |
| | | .eq(DeviceState::getFeedbackPointType, FeedbackTimePointEnum.NO_FEED_BACK_POINT.getValue()).ne(DeviceState::getIsDeleted, Boolean.TRUE)); |
| | | */ |
| | | DeviceState resultTimePoint = stateMapper.lastSyncedNoFeedbackPointState(workstationId); |
| | | if (Func.isEmpty(resultTimePoint)) { |
| | | //è·åisSync=false,fixpoint=falseï¼NO_FEED_BACK_POINTçæ°æ® |
| | | /* |
| | | resultTimePoint = stateMapper.getFirstWorkstationState(Wrappers.<DeviceState>lambdaQuery().eq(DeviceState::getWorkstationId, workstationId) |
| | | .eq(DeviceState::getIsSync, Boolean.FALSE) |
| | | .eq(DeviceState::getIsFixPoint, Boolean.FALSE) |
| | | .eq(DeviceState::getFeedbackPointType, FeedbackTimePointEnum.NO_FEED_BACK_POINT.getValue()) |
| | | .ne(DeviceState::getIsDeleted, Boolean.TRUE)); |
| | | */ |
| | | resultTimePoint = stateMapper.firstNotSyncedNofeedbackPointState(workstationId); |
| | | } |
| | | if (Func.isNotEmpty(resultTimePoint)) { |
| | | return resultTimePoint.getTime(); |
| | | } |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.mdc.collect.utils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.qianwen.core.tool.utils.BeanUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.mdc.collect.entity.iotdb.AggregateState; |
| | | import com.qianwen.mdc.collect.entity.iotdb.DeviceState; |
| | | import com.qianwen.mdc.collect.enums.FeedbackTimePointEnum; |
| | | |
| | | /** |
| | | * æ åé¦å¾ç¶æèå util |
| | | * |
| | | */ |
| | | public class WorkstationStateAggregateNoFeedbackUtils { |
| | | private static final Logger log = LoggerFactory.getLogger(WorkstationStateAggregateNoFeedbackUtils.class); |
| | | |
| | | |
| | | |
| | | public static List<AggregateState> buildAggregateList(List<DeviceState> notSyncWorkstationStates) { |
| | | List<AggregateState> workstationAggregateStateList = new ArrayList<>(); |
| | | List<DeviceState> notSyncWorkstationStates2 = rebuildNotSyncWorkstationStates(notSyncWorkstationStates); |
| | | if (Func.isNotEmpty(notSyncWorkstationStates2)) { |
| | | int resultCount = notSyncWorkstationStates2.size(); |
| | | for (int i = 0; i < notSyncWorkstationStates2.size() - 1; i++) { |
| | | DeviceState current = notSyncWorkstationStates2.get(i); |
| | | DeviceState nextState = notSyncWorkstationStates2.get(i + 1); |
| | | //使ç¨tsçå·®ï¼æå»ºdurationCollectï¼å
¶ä½ä½¿ç¨currentç屿§ |
| | | AggregateState aggState =new AggregateState(); |
| | | //workstationAggregateStateList.add(AggregateState.builder().ts(current.getTs()).workstationId(current.getWorkstationId()).isDeleted(Boolean.FALSE).valueCollect(current.getValueCollect()).rps(current.getRps()).wcs(current.getWcs()).isPlan(current.getIsPlan()).shiftIndex(current.getShiftIndex()).shiftTimeType(current.getShiftTimeType()).calendarCode(current.getCalendarCode()).factoryDate(current.getFactoryDate()).factoryMonth(current.getFactoryMonth()).factoryWeek(current.getFactoryWeek()).factoryYear(current.getFactoryYear()).durationCollect(Long.valueOf(TimeUnit.MILLISECONDS.toSeconds(nextState.getTs().longValue() - current.getTs().longValue()))).employeeId(current.getEmployeeId()).endTime(nextState.getTs()).build()); |
| | | aggState.setTime(current.getTime()); |
| | | aggState.setWorkstationId(current.getWorkstationId()); |
| | | aggState.setIsDeleted(false); |
| | | aggState.setValueCollect(current.getValueCollect()); |
| | | aggState.setRps(current.getRps()); |
| | | aggState.setWcs(current.getWcs()); |
| | | aggState.setIsPlan(current.getIsPlan()); |
| | | aggState.setShiftIndex(current.getShiftIndex()); |
| | | aggState.setShiftTimeType(current.getShiftTimeType()); |
| | | aggState.setCalendarCode(current.getCalendarCode()); |
| | | aggState.setFactoryDate(current.getFactoryDate()); |
| | | aggState.setFactoryMonth(current.getFactoryMonth()); |
| | | aggState.setFactoryWeek(current.getFactoryWeek()); |
| | | aggState.setFactoryYear(current.getFactoryYear()); |
| | | aggState.setDurationCollect(Long.valueOf(TimeUnit.MILLISECONDS.toSeconds(nextState.getTime().longValue() - current.getTime().longValue()))); |
| | | aggState.setEmployeeId(current.getEmployeeId()); |
| | | aggState.setEndTime(nextState.getTime()); |
| | | |
| | | workstationAggregateStateList.add(aggState); |
| | | } |
| | | |
| | | //æå»ºæå䏿¡ï¼æ durationCollect |
| | | DeviceState lastNoSyncWorkstationState = notSyncWorkstationStates2.get(resultCount - 1); |
| | | |
| | | AggregateState lastAggState = new AggregateState(); |
| | | //workstationAggregateStateList.add(AggregateState.builder().ts(lastNoSyncWorkstationState.getTime()).workstationId(lastNoSyncWorkstationState.getWorkstationId()).isDeleted(Boolean.FALSE).valueCollect(lastNoSyncWorkstationState.getValueCollect()).rps(lastNoSyncWorkstationState.getRps()).wcs(lastNoSyncWorkstationState.getWcs()).isPlan(lastNoSyncWorkstationState.getIsPlan()).shiftIndex(lastNoSyncWorkstationState.getShiftIndex()).shiftTimeType(lastNoSyncWorkstationState.getShiftTimeType()).calendarCode(lastNoSyncWorkstationState.getCalendarCode()).factoryDate(lastNoSyncWorkstationState.getFactoryDate()).factoryMonth(lastNoSyncWorkstationState.getFactoryMonth()).factoryWeek(lastNoSyncWorkstationState.getFactoryWeek()).factoryYear(lastNoSyncWorkstationState.getFactoryYear()).employeeId(lastNoSyncWorkstationState.getEmployeeId()).build()); |
| | | lastAggState.setTime(lastNoSyncWorkstationState.getTime()); |
| | | lastAggState.setWorkstationId(lastNoSyncWorkstationState.getWorkstationId()); |
| | | lastAggState.setIsDeleted(false); |
| | | lastAggState.setValueCollect(lastNoSyncWorkstationState.getValueCollect()); |
| | | lastAggState.setRps(lastNoSyncWorkstationState.getRps()); |
| | | lastAggState.setWcs(lastNoSyncWorkstationState.getWcs()); |
| | | lastAggState.setIsPlan(lastNoSyncWorkstationState.getIsPlan()); |
| | | lastAggState.setShiftIndex(lastNoSyncWorkstationState.getShiftIndex()); |
| | | lastAggState.setShiftTimeType(lastNoSyncWorkstationState.getShiftTimeType()); |
| | | lastAggState.setCalendarCode(lastNoSyncWorkstationState.getCalendarCode()); |
| | | lastAggState.setFactoryDate(lastNoSyncWorkstationState.getFactoryDate()); |
| | | lastAggState.setFactoryMonth(lastNoSyncWorkstationState.getFactoryMonth()); |
| | | lastAggState.setFactoryWeek(lastNoSyncWorkstationState.getFactoryWeek()); |
| | | lastAggState.setFactoryYear(lastNoSyncWorkstationState.getFactoryYear()); |
| | | lastAggState.setEmployeeId(lastNoSyncWorkstationState.getEmployeeId()); |
| | | |
| | | |
| | | workstationAggregateStateList.add(lastAggState); |
| | | } |
| | | return workstationAggregateStateList; |
| | | } |
| | | |
| | | /** |
| | | * éæ°æå»ºæªåæ¥ç¶æåè¡¨æ°æ® |
| | | * @param originalDeviceStates |
| | | * @return |
| | | */ |
| | | private static List<DeviceState> rebuildNotSyncWorkstationStates(List<DeviceState> originalDeviceStates) { |
| | | List<DeviceState> stateList = new ArrayList<>(); |
| | | if (Func.isNotEmpty(originalDeviceStates)) { |
| | | List<DeviceState> notSyncWorkstationStates = originalDeviceStates.stream().filter(x -> { |
| | | //å«ä¹æªéåfixpoint æè
éåé¦ç¹ï¼å
¶ä»ç±»åçééæ°æ®ä¸å¤çäºï¼æä»¬èªå·±å°±ä¸ç¨è¿æ»¤äºï¼å ä¸ºé½æ¯NO_FEED_BACK_POINTï¼ä¸isFixPoint=false |
| | | return Boolean.TRUE.equals(x.getIsFixPoint()) || x.getFeedbackPointType() == null || x.getFeedbackPointType().equals(FeedbackTimePointEnum.NO_FEED_BACK_POINT.getValue()); |
| | | }).map(x2 -> { |
| | | //åºå®ç¹ï¼è®¾ç½®wcsï¼rps=0 |
| | | if (x2.getIsFixPoint().booleanValue()) { |
| | | x2.setWcs(0); |
| | | x2.setRps(0); |
| | | x2.setIsPlan(null); |
| | | } |
| | | return x2; |
| | | }).collect(Collectors.toList()).stream().sorted(Comparator.comparing(DeviceState::getTime)).collect(Collectors.toList()); |
| | | |
| | | notSyncWorkstationStates.forEach(x3 -> { |
| | | if (x3.getIsFixPoint().booleanValue()) { |
| | | //æ¯åºå®ç¹ï¼æ¾åºä¸æäºè¯¥åºå®ç¹çæåä¸ä¸ªç¹ï¼å å
¥stateList;å¦ææ²¡ææ¾å°ï¼åå°è¯¥åºå®ç¹å å
¥stateList |
| | | List<DeviceState> collect = notSyncWorkstationStates.stream().filter(y -> { |
| | | //å¨åè¡¨ä¸æ¾åºæ¶é´ä¸æäº(<=)该åºå®ç¹(x3)çéåºå®ç¹(为äºè·åæå䏿¡çæ°æ®) |
| | | return !y.getIsFixPoint().booleanValue() && y.getTime().longValue() <= x3.getTime().longValue(); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | if (Func.isNotEmpty(collect)) {//é¤éä¹å没æè¿æ°æ®ï¼å¦åè¿ä¸ªæ¡ä»¶(isNotEmpty)é½æç« |
| | | DeviceState temp = (DeviceState) BeanUtil.copy(x3, DeviceState.class); |
| | | temp.setValueCollect(collect.get(collect.size() - 1).getValueCollect()); |
| | | temp.setWcs(collect.get(collect.size() - 1).getWcs()); |
| | | temp.setRps(collect.get(collect.size() - 1).getRps()); |
| | | temp.setIsPlan(collect.get(collect.size() - 1).getIsPlan()); |
| | | stateList.add(temp); |
| | | return; |
| | | } |
| | | stateList.add(x3); |
| | | return; |
| | | } |
| | | //éåºå®ç¹ï¼ç´æ¥å å
¥å表 |
| | | stateList.add(x3); |
| | | }); |
| | | } |
| | | return stateList; |
| | | } |
| | | |
| | | public static List<AggregateState> getReallyEffectWorkstationStateAggregateNoFeedbackList(List<AggregateState> insertData, List<AggregateState> deleteData) { |
| | | HashMap<Long, AggregateState> workstationStateMap = new HashMap<>(); |
| | | if (Func.isNotEmpty(insertData)) { |
| | | insertData.forEach(item -> { |
| | | workstationStateMap.put(item.getTime(), item); |
| | | }); |
| | | } |
| | | if (Func.isNotEmpty(deleteData)) { |
| | | for (AggregateState state : deleteData) { |
| | | if (!workstationStateMap.containsKey(state.getTime())) { |
| | | workstationStateMap.put(state.getTime(), state); |
| | | } |
| | | } |
| | | } |
| | | return workstationStateMap.values().stream().collect(Collectors.toList()); |
| | | } |
| | | } |
| | |
| | | * @param time æ¶é´(ç§) |
| | | * @return trueæå false失败 |
| | | */ |
| | | public boolean hmset(String key, Map<String,Object> map, long time){ |
| | | public boolean hmsetold(String key, Map<String,Object> map, long time){ |
| | | try { |
| | | redisTemplate.opsForHash().putAll(key, map); |
| | | if (time > 0) { |
| | |
| | | return false; |
| | | } |
| | | } |
| | | public boolean hmset(String key, Map<? extends Object, ? extends Object> map, long time){ |
| | | try { |
| | | redisTemplate.opsForHash().putAll(key, map); |
| | | if (time > 0) { |
| | | expire(key, time); |
| | | } |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åä¸å¼ hashè¡¨ä¸æ¾å
¥æ°æ®,妿ä¸åå¨å°å建 |
| | |
| | | #iotdb 以åå
¶jdbcä¸èµ·é
ç½® |
| | | iotdb: |
| | | driver: org.apache.iotdb.jdbc.IoTDBDriver |
| | | host: localhost |
| | | host: 127.0.0.1 |
| | | port: 6667 |
| | | maxSize: 10 |
| | | maxSize: 300 |
| | | username: root |
| | | password: root |
| | | |
| | |
| | | type: com.zaxxer.hikari.HikariDataSource |
| | | hikari: |
| | | minimum-idle: 5 |
| | | maximum-pool-size: 15 |
| | | maximum-pool-size: 50 |
| | | auto-commit: true |
| | | idle-timeout: 30000 |
| | | pool-name: DatebookHikariCP |
| | | max-lifetime: 1800000 |
| | | connection-timeout: 30000 |
| | | connection-timeout: 10000 |
| | | connection-test-query: select count(*) from root.test |
| | | mybatis: |
| | | configuration: |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.mdc.collect.mapper.iotdb.DeviceStateMapper"> |
| | | <resultMap id="BaseResultMap" type="com.qianwen.mdc.collect.entity.iotdb.DeviceState"> |
| | | <result column="workstation_id" jdbcType="BIGINT" property="workstationId"/> |
| | | <result column="value_collect" jdbcType="BIGINT" property="valueCollect"/> |
| | | <result column="param_type" jdbcType="INTEGER" property="paramType"/> |
| | | <result column="calendar_code" jdbcType="VARCHAR" property="calendarCode"/> |
| | | <result column="factory_year" jdbcType="INTEGER" property="factoryYear"/> |
| | | <result column="factory_month" jdbcType="INTEGER" property="factoryMonth"/> |
| | | <result column="factory_week" jdbcType="INTEGER" property="factoryWeek"/> |
| | | <result column="factory_date" jdbcType="INTEGER" property="factoryDate"/> |
| | | <result column="shift_index" jdbcType="INTEGER" property="shiftIndex"/> |
| | | <result column="shift_time_type" jdbcType="INTEGER" property="shiftTimeType"/> |
| | | <result column="wcs" jdbcType="INTEGER" property="wcs"/> |
| | | <result column="rps" jdbcType="INTEGER" property="wcs"/> |
| | | <result column="is_sync" jdbcType="BOOLEAN" property="isSync"/> |
| | | <result column="feedback_id" jdbcType="BIGINT" property="feedbackId"/> |
| | | <result column="is_deleted" jdbcType="BOOLEAN" property="isDeleted"/> |
| | | <result column="employee_id" jdbcType="BIGINT" property="employeeId"/> |
| | | </resultMap> |
| | | <!-- |
| | | |
| | | <select id="getProcessingFeedbackState" resultType="org.springblade.posting.entity.tdengine.WorkstationState" |
| | | parameterType="java.lang.Long"> |
| | | select * FROM iot_data.super_state WHERE workstation_id = #{workstationId} AND is_deleted != true AND is_sync = false AND feedback_point_type != 0 |
| | | </select> |
| | | |
| | | <insert id="insert" parameterType="org.springblade.posting.entity.tdengine.WorkstationState"> |
| | | insert into iot_data.state_${workstationId} USING iot_data.super_state TAGS (${workstationId}) |
| | | values (#{ts}, #{valueCollect}, #{calendarCode}, #{factoryYear}, #{factoryMonth}, #{factoryWeek}, #{factoryDate}, |
| | | #{shiftIndex}, #{shiftTimeType}, #{wcs}, #{rps},#{isFixPoint},#{isSync}, #{isPlan},#{feedbackPointType},#{feedbackId},#{isDeleted}, #{employeeId}) |
| | | </insert> |
| | | |
| | | <insert id="batchInsert" > |
| | | insert into |
| | | <foreach separator=" " collection="list" item="item" index="index" > |
| | | iot_data.state_${item.workstationId} USING iot_data.super_state TAGS (${item.workstationId}) values |
| | | (#{item.ts}, #{item.valueCollect},#{item.calendarCode}, #{item.factoryYear}, #{item.factoryMonth}, #{item.factoryWeek}, #{item.factoryDate}, |
| | | #{item.shiftIndex}, #{item.shiftTimeType}, #{item.wcs}, #{item.rps},#{item.isFixPoint}, #{item.isSync}, #{item.isPlan},#{item.feedbackPointType},#{item.feedbackId},#{item.isDeleted}, #{item.employeeId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <insert id="batchSave"> |
| | | insert into iot_data.state_${workstationId} USING iot_data.super_state TAGS (${workstationId}) values |
| | | <foreach separator="," collection="list" item="item" index="index" > |
| | | (#{item.ts}, #{item.valueCollect},#{item.calendarCode}, #{item.factoryYear}, #{item.factoryMonth}, #{item.factoryWeek}, #{item.factoryDate}, |
| | | #{item.shiftIndex}, #{item.shiftTimeType}, #{item.wcs}, #{item.rps}, #{item.isFixPoint}, |
| | | #{item.isSync}, #{item.isPlan},#{item.feedbackPointType},#{item.feedbackId},#{item.isDeleted}, #{item.employeeId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | |
| | | <select id="getLastIsSyncNoFixPointState" |
| | | resultType="org.springblade.posting.entity.tdengine.WorkstationState"> |
| | | select LAST_ROW(*), workstation_Id FROM iot_data.super_state WHERE workstation_id = #{workstationId} AND is_deleted != true AND is_sync = true and is_fix_point=false |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="getFirstWorkstationState" resultType="org.springblade.posting.entity.tdengine.WorkstationState" |
| | | parameterType="com.baomidou.mybatisplus.core.conditions.Wrapper"> |
| | | select First(*) FROM iot_data.super_state |
| | | ${ew.customSqlSegment} |
| | | </select> |
| | | --> |
| | | <sql id="all_columns"> |
| | | workstation_id,value_collect,calendar_code,factory_year,factory_month,factory_date,factory_week,shift_index,shift_time_type,wcs,rps,is_fix_point,is_sync,is_plan,feedback_point_type,feedback_id,is_deleted,employee_id |
| | | </sql> |
| | | <!-- resultType="com.qianwen.mdc.collect.entity.iotdb.DeviceState" --> |
| | | <select id="lastSyncedNoFeedbackPointState" resultMap="BaseResultMap"> |
| | | select <include refid="all_columns" /> FROM root.f2.aggregate_state_${workstationId} |
| | | where is_sync=true and is_fix_point=false and feedback_point_type=0 and is_deleted=false |
| | | order by time desc limit 1 |
| | | </select> |
| | | |
| | | <select id="firstNotSyncedNofeedbackPointState" resultMap="BaseResultMap"> |
| | | select <include refid="all_columns" /> FROM root.f2.aggregate_state_${workstationId} |
| | | where is_sync=false and is_fix_point=false and feedback_point_type=0 and is_deleted=false |
| | | order by time asc limit 1 |
| | | </select> |
| | | |
| | | <select id="statesInTimeRange" resultMap="BaseResultMap"> |
| | | select <include refid="all_columns" /> FROM root.f2.aggregate_state_${workstationId} |
| | | <where> |
| | | is_deleted=false |
| | | <if test="timeRange.startTime != null"> |
| | | AND time >= #{timeRange.startTime} |
| | | </if> |
| | | AND time <= #{timeRange.endTime} |
| | | </where> |
| | | |
| | | order by time asc |
| | | </select> |
| | | |
| | | </mapper> |
| | | |