| | |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | private EmployeeOnOffWorkMapper employeeOnOffWorkMapper; |
| | | |
| | | |
| | | public Map<Long, WorkstationDTO> getWorkstations() { |
| | | public Map<String, WorkstationDTO> getWorkstations() { |
| | | String redisKey = COLLECT_WORKSTATION.concat("::").concat(WORKSTATION_ALL); |
| | | /*Map<String, WorkstationDTO> map = bladeRedis.hGetAll(redisKey); |
| | | |
| | |
| | | } |
| | | return map; |
| | | */ |
| | | Map<Long, WorkstationDTO> map = convertMap(redisUtil.hmget(redisKey)); |
| | | Map<String, WorkstationDTO> map = convertMap(redisUtil.hmget(redisKey)); |
| | | |
| | | if (ObjectUtil.isEmpty(map)) { |
| | | map = setWorkstations(); |
| | |
| | | |
| | | } |
| | | |
| | | private Map<Long, WorkstationDTO> setWorkstations() { |
| | | private Map<String, WorkstationDTO> setWorkstations() { |
| | | List<Workstation> list = workstationService.list(); |
| | | String redisKey = COLLECT_WORKSTATION.concat("::").concat(WORKSTATION_ALL); |
| | | |
| | | /* |
| | | list.forEach(ws -> { |
| | | /* |
| | | WorkStationDTO workStationDTO = WorkstationConvert.INSTANCE.convertDTO(workStation); |
| | | bladeRedis.hSet(redisKey, workStation.getId(), workStationDTO); |
| | | */ |
| | | |
| | | //WorkStationDTO workStationDTO = WorkstationConvert.INSTANCE.convertDTO(workStation); |
| | | //bladeRedis.hSet(redisKey, workStation.getId(), workStationDTO); |
| | | |
| | | WorkstationDTO dto = new WorkstationDTO(); |
| | | dto.setCalendarCode(ws.getCalendarCode()); |
| | | dto.setCode(ws.getCode()); |
| | | dto.setId(ws.getId()); |
| | | dto.setName(ws.getName()); |
| | | redisUtil.hset(redisKey, ws.getId(), dto); |
| | | }); |
| | | |
| | | //bladeRedis.expire(redisKey, 259200L); |
| | | redisUtil.expire(redisKey, 259200L); |
| | | //return bladeRedis.hGetAll(redisKey); |
| | | });*/ |
| | | //Map<String, String> map = str.collect(Collectors.toMap(p -> p[0], p -> p[1])); |
| | | Map<String,WorkstationDTO> mp = list.stream().collect(Collectors.toMap(ws -> String.valueOf(ws.getId()), ws->{ |
| | | WorkstationDTO dto = new WorkstationDTO(); |
| | | dto.setCalendarCode(ws.getCalendarCode()); |
| | | dto.setCode(ws.getCode()); |
| | | dto.setId(ws.getId()); |
| | | dto.setName(ws.getName()); |
| | | return dto; |
| | | })); |
| | | redisUtil.hmset(redisKey, mp); |
| | | |
| | | return convertMap(redisUtil.hmget(redisKey)); |
| | | redisUtil.expire(redisKey, 259200L); |
| | | |
| | | |
| | | return (Map<String, WorkstationDTO>)redisUtil.hmget(redisKey); |
| | | } |
| | | |
| | | static <K,V> Map<K,V> convertMap(Map<?,?> map){ |
| | |
| | | } |
| | | return result; |
| | | } |
| | | /* |
| | | public static Boolean clearWorkStationCache() { |
| | | String redisKey = "posting:workstation".concat("::").concat(WORKSTATION_ALL); |
| | | return bladeRedis.del(redisKey); |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * 获取指定日期的日历代码 |
| | | * @param workstationId |
| | |
| | | return calendarCode; |
| | | } |
| | | |
| | | public GlobalWcsOfRps getWorkstationWcsSetting(Long workstationId, String code) { |
| | | public GlobalWcsOfRps getWorkstationWcsSetting(Long workstationId, String deviceStatusCode) { |
| | | String redisKey = COLLECT_WORKSTATION.concat("::").concat(WORKSTATION_ID).concat(workstationId.toString() |
| | | .concat(WCS_SETTING)); |
| | | |
| | | //GlobalWcsOfRps wcsSetting = (GlobalWcsOfRps)redisUtil.hGet(redisKey, code); |
| | | GlobalWcsOfRps wcsSetting = (GlobalWcsOfRps)redisUtil.hget(redisKey, code); |
| | | GlobalWcsOfRps wcsSetting = (GlobalWcsOfRps)redisUtil.hget(redisKey, deviceStatusCode); |
| | | if (wcsSetting == null) { |
| | | wcsSetting = globalWcsOfRpsMapper.selectOne(Wrappers.<GlobalWcsOfRps>lambdaQuery() |
| | | .eq(GlobalWcsOfRps::getCode, code) |
| | | .eq(GlobalWcsOfRps::getCode, deviceStatusCode) |
| | | .isNull(GlobalWcsOfRps::getPrecondition)); |
| | | if(wcsSetting == null) { |
| | | wcsSetting = new GlobalWcsOfRps(); |
| | |
| | | //wcsSetting = Func.isNotEmpty(wcsSetting) ? wcsSetting : GlobalWcsOfRps.builder().rps(0).isPlan(0).build(); |
| | | //bladeRedis.hSet(redisKey, code, wcsSetting); |
| | | //bladeRedis.expire(redisKey, Duration.ofDays(1L)); |
| | | redisUtil.hset(redisKey, code, wcsSetting, Duration.ofDays(1L).getSeconds()); |
| | | redisUtil.hset(redisKey, deviceStatusCode, wcsSetting, Duration.ofDays(1L).getSeconds()); |
| | | } |
| | | return wcsSetting; |
| | | } |