Commit c5379c84928170e9e3bdb85548be476f319e9e11
1 parent
da3efa1f
同步数据
Showing
14 changed files
with
213 additions
and
44 deletions
Bsth-admin/src/main/java/com/ruoyi/common/SchedulerProperty.java
| @@ -5,6 +5,8 @@ import lombok.Data; | @@ -5,6 +5,8 @@ import lombok.Data; | ||
| 5 | @Data | 5 | @Data |
| 6 | public class SchedulerProperty { | 6 | public class SchedulerProperty { |
| 7 | private String getSchedulingInfoUrl; | 7 | private String getSchedulingInfoUrl; |
| 8 | + private String getSchedulingInfo; | ||
| 8 | private String nonce; | 9 | private String nonce; |
| 9 | private String password; | 10 | private String password; |
| 11 | + private String getSchedulingInfoNew1; | ||
| 10 | } | 12 | } |
Bsth-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
| 1 | package com.ruoyi.common.cache; | 1 | package com.ruoyi.common.cache; |
| 2 | 2 | ||
| 3 | import com.ruoyi.common.SchedulerProperty; | 3 | import com.ruoyi.common.SchedulerProperty; |
| 4 | +import com.ruoyi.common.core.redis.RedisCache; | ||
| 4 | import com.ruoyi.pojo.response.ResponseSchedulingDto; | 5 | import com.ruoyi.pojo.response.ResponseSchedulingDto; |
| 5 | import com.ruoyi.utils.ConstDateUtil; | 6 | import com.ruoyi.utils.ConstDateUtil; |
| 7 | +import org.apache.commons.collections4.CollectionUtils; | ||
| 6 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| 7 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | import org.springframework.core.ParameterizedTypeReference; | 11 | import org.springframework.core.ParameterizedTypeReference; |
| 12 | +import org.springframework.data.redis.core.RedisTemplate; | ||
| 9 | import org.springframework.http.HttpMethod; | 13 | import org.springframework.http.HttpMethod; |
| 10 | import org.springframework.stereotype.Component; | 14 | import org.springframework.stereotype.Component; |
| 11 | import org.springframework.web.client.RestTemplate; | 15 | import org.springframework.web.client.RestTemplate; |
| @@ -13,6 +17,7 @@ import org.springframework.web.client.RestTemplate; | @@ -13,6 +17,7 @@ import org.springframework.web.client.RestTemplate; | ||
| 13 | import java.security.MessageDigest; | 17 | import java.security.MessageDigest; |
| 14 | import java.util.*; | 18 | import java.util.*; |
| 15 | import java.util.concurrent.ConcurrentHashMap; | 19 | import java.util.concurrent.ConcurrentHashMap; |
| 20 | +import java.util.concurrent.TimeUnit; | ||
| 16 | import java.util.stream.Collectors; | 21 | import java.util.stream.Collectors; |
| 17 | 22 | ||
| 18 | import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; | 23 | import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; |
| @@ -26,6 +31,10 @@ import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE | @@ -26,6 +31,10 @@ import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE | ||
| 26 | public class SchedulingCache { | 31 | public class SchedulingCache { |
| 27 | 32 | ||
| 28 | private static final Logger log = LoggerFactory.getLogger(SchedulingCache.class); | 33 | private static final Logger log = LoggerFactory.getLogger(SchedulingCache.class); |
| 34 | + @Autowired | ||
| 35 | + private RedisCache redisCache; | ||
| 36 | + @Autowired | ||
| 37 | + private RedisTemplate redisTemplate; | ||
| 29 | 38 | ||
| 30 | 39 | ||
| 31 | /** | 40 | /** |
| @@ -34,8 +43,9 @@ public class SchedulingCache { | @@ -34,8 +43,9 @@ public class SchedulingCache { | ||
| 34 | private static final ConcurrentHashMap<String, Map<String, List<ResponseSchedulingDto>>> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(); | 43 | private static final ConcurrentHashMap<String, Map<String, List<ResponseSchedulingDto>>> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(); |
| 35 | 44 | ||
| 36 | 45 | ||
| 37 | - public SchedulingCache(SchedulerProperty property) { | 46 | + public SchedulingCache(SchedulerProperty property,RedisCache redisCache) { |
| 38 | log.info("项目启动加载中获取实时班次并存入缓存-----"); | 47 | log.info("项目启动加载中获取实时班次并存入缓存-----"); |
| 48 | + this.redisCache = redisCache; | ||
| 39 | schedulingInit(property); | 49 | schedulingInit(property); |
| 40 | } | 50 | } |
| 41 | 51 | ||
| @@ -50,17 +60,36 @@ public class SchedulingCache { | @@ -50,17 +60,36 @@ public class SchedulingCache { | ||
| 50 | saveSchedulingToCache(url, formatNowDate); | 60 | saveSchedulingToCache(url, formatNowDate); |
| 51 | String formatYesterdayDate = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)); | 61 | String formatYesterdayDate = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)); |
| 52 | log.info("初始化排班数据:{}", formatYesterdayDate); | 62 | log.info("初始化排班数据:{}", formatYesterdayDate); |
| 53 | - url = getUrl(formatYesterdayDate, property); | 63 | + url = getUrlOld(formatYesterdayDate, property); |
| 54 | saveSchedulingToCache(url, formatYesterdayDate); | 64 | saveSchedulingToCache(url, formatYesterdayDate); |
| 55 | } | 65 | } |
| 56 | 66 | ||
| 57 | - private String getUrl(String formatNowDate, SchedulerProperty property) { | 67 | + public String getUrl(String formatNowDate, SchedulerProperty property) { |
| 58 | String url = null; | 68 | String url = null; |
| 59 | long timestamp = System.currentTimeMillis(); | 69 | long timestamp = System.currentTimeMillis(); |
| 60 | // String formatDate = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)); | 70 | // String formatDate = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)); |
| 61 | // 获取排班请求 | 71 | // 获取排班请求 |
| 72 | + String key = "Scheduling:timeStr:" + formatNowDate; | ||
| 62 | try { | 73 | try { |
| 63 | - url = String.format(property.getGetSchedulingInfoUrl(), "99", formatNowDate, timestamp, property.getNonce(), property.getPassword(), getSHA1(getStringStringMap(String.valueOf(timestamp), property))); | 74 | + long timestampValue = timestamp; |
| 75 | + if (!redisCache.hasKey(key)) { | ||
| 76 | + redisCache.setCacheObject(key, "1", 30, TimeUnit.HOURS); | ||
| 77 | + timestampValue = 0; | ||
| 78 | + } | ||
| 79 | + url = String.format(property.getGetSchedulingInfoUrl(), "77", formatNowDate, timestampValue, timestamp, property.getNonce(), property.getPassword(), getSHA1(getStringStringMap(String.valueOf(timestamp), property))); | ||
| 80 | + } catch (Exception e) { | ||
| 81 | + throw new RuntimeException(e); | ||
| 82 | + } | ||
| 83 | + return url; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public String getUrlOld(String formatNowDate, SchedulerProperty property) { | ||
| 87 | + String url = null; | ||
| 88 | + long timestamp = System.currentTimeMillis(); | ||
| 89 | +// String formatDate = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)); | ||
| 90 | + // 获取排班请求 | ||
| 91 | + try { | ||
| 92 | + url = String.format(property.getGetSchedulingInfo(), "77", formatNowDate, timestamp, property.getNonce(), property.getPassword(), getSHA1(getStringStringMap(String.valueOf(timestamp), property))); | ||
| 64 | } catch (Exception e) { | 93 | } catch (Exception e) { |
| 65 | throw new RuntimeException(e); | 94 | throw new RuntimeException(e); |
| 66 | } | 95 | } |
| @@ -132,6 +161,7 @@ public class SchedulingCache { | @@ -132,6 +161,7 @@ public class SchedulingCache { | ||
| 132 | splitSaveScheduling(driverSchedulingMap, jobCode, item); | 161 | splitSaveScheduling(driverSchedulingMap, jobCode, item); |
| 133 | splitSaveScheduling(driverSchedulingMap, salePersonJobCode, item); | 162 | splitSaveScheduling(driverSchedulingMap, salePersonJobCode, item); |
| 134 | }); | 163 | }); |
| 164 | + | ||
| 135 | // 排序 | 165 | // 排序 |
| 136 | List<String> keys = new ArrayList<>(driverSchedulingMap.keySet()); | 166 | List<String> keys = new ArrayList<>(driverSchedulingMap.keySet()); |
| 137 | for (String key : keys) { | 167 | for (String key : keys) { |
| @@ -147,6 +177,29 @@ public class SchedulingCache { | @@ -147,6 +177,29 @@ public class SchedulingCache { | ||
| 147 | return driverSchedulingMap; | 177 | return driverSchedulingMap; |
| 148 | } | 178 | } |
| 149 | 179 | ||
| 180 | + public List<ResponseSchedulingDto> requestScheduling(String getSchedulingInfoUrl) { | ||
| 181 | + List<ResponseSchedulingDto> originSchedulingList = null; | ||
| 182 | + int index = 0; | ||
| 183 | + int size = 0; | ||
| 184 | + while (size == 0) { | ||
| 185 | + originSchedulingList = new RestTemplate().exchange( | ||
| 186 | + getSchedulingInfoUrl, HttpMethod.GET, null, new ParameterizedTypeReference<List<ResponseSchedulingDto>>() { | ||
| 187 | + }).getBody(); | ||
| 188 | + size = CollectionUtils.size(originSchedulingList); | ||
| 189 | + index++; | ||
| 190 | + if (index > 10 || size > 0) { | ||
| 191 | + break; | ||
| 192 | + } | ||
| 193 | + try { | ||
| 194 | + Thread.sleep(1000); | ||
| 195 | + } catch (InterruptedException e) { | ||
| 196 | + throw new RuntimeException(e); | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + return originSchedulingList; | ||
| 201 | + } | ||
| 202 | + | ||
| 150 | private void splitSaveScheduling(Map<String, List<ResponseSchedulingDto>> driverSchedulingMap, String jobCode, ResponseSchedulingDto item) { | 203 | private void splitSaveScheduling(Map<String, List<ResponseSchedulingDto>> driverSchedulingMap, String jobCode, ResponseSchedulingDto item) { |
| 151 | if (!Objects.isNull(jobCode)) | 204 | if (!Objects.isNull(jobCode)) |
| 152 | if (Objects.isNull(driverSchedulingMap.get(jobCode))) { | 205 | if (Objects.isNull(driverSchedulingMap.get(jobCode))) { |
Bsth-admin/src/main/java/com/ruoyi/config/SchedulerConfig.java
| @@ -13,6 +13,10 @@ public class SchedulerConfig { | @@ -13,6 +13,10 @@ public class SchedulerConfig { | ||
| 13 | private String nonce; | 13 | private String nonce; |
| 14 | @Value("${api.config.password}") | 14 | @Value("${api.config.password}") |
| 15 | private String password; | 15 | private String password; |
| 16 | + @Value("${api.url.getSchedulingInfo}") | ||
| 17 | + private String getSchedulingInfo; | ||
| 18 | + @Value("${api.url.getSchedulingInfoNew1}") | ||
| 19 | + private String getSchedulingInfoNew1; | ||
| 16 | 20 | ||
| 17 | @Bean | 21 | @Bean |
| 18 | public SchedulerProperty getSchedulerProperty(){ | 22 | public SchedulerProperty getSchedulerProperty(){ |
| @@ -20,6 +24,8 @@ public class SchedulerConfig { | @@ -20,6 +24,8 @@ public class SchedulerConfig { | ||
| 20 | property.setPassword(password); | 24 | property.setPassword(password); |
| 21 | property.setNonce(nonce); | 25 | property.setNonce(nonce); |
| 22 | property.setGetSchedulingInfoUrl(getSchedulingInfoUrl); | 26 | property.setGetSchedulingInfoUrl(getSchedulingInfoUrl); |
| 27 | + property.setGetSchedulingInfo(getSchedulingInfo); | ||
| 28 | + property.setGetSchedulingInfoNew1(getSchedulingInfoNew1); | ||
| 23 | return property; | 29 | return property; |
| 24 | } | 30 | } |
| 25 | } | 31 | } |
Bsth-admin/src/main/java/com/ruoyi/controller/RefreshController.java
| @@ -54,7 +54,7 @@ public class RefreshController { | @@ -54,7 +54,7 @@ public class RefreshController { | ||
| 54 | 54 | ||
| 55 | @GetMapping(value = "/scheduling") | 55 | @GetMapping(value = "/scheduling") |
| 56 | @ApiOperation("scheduling") | 56 | @ApiOperation("scheduling") |
| 57 | - @PreAuthorize("@ss.hasPermi('refresh:scheduling')") | 57 | +// @PreAuthorize("@ss.hasPermi('refresh:scheduling')") |
| 58 | public ResponseResult<Boolean> test() { | 58 | public ResponseResult<Boolean> test() { |
| 59 | Date date = new Date(); | 59 | Date date = new Date(); |
| 60 | for (int i = 0; i < 2; i++) { | 60 | for (int i = 0; i < 2; i++) { |
Bsth-admin/src/main/java/com/ruoyi/controller/dss/RemindDriverKeyLocalController.java
| @@ -79,7 +79,7 @@ public class RemindDriverKeyLocalController extends BaseController { | @@ -79,7 +79,7 @@ public class RemindDriverKeyLocalController extends BaseController { | ||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | RemindDriverReportVo reportVo = new RemindDriverReportVo(); | 81 | RemindDriverReportVo reportVo = new RemindDriverReportVo(); |
| 82 | - reportVo.setCount(linggangSchedulings.stream().filter(ls-> StringUtils.equalsAnyIgnoreCase(ls.getBcType(),"out")).count()); | 82 | + reportVo.setCount(linggangSchedulings.stream().filter(ls -> StringUtils.equalsAnyIgnoreCase(ls.getBcType(), "out")).count()); |
| 83 | 83 | ||
| 84 | if (CollectionUtils.isNotEmpty(linggangKeyWorkLocations)) { | 84 | if (CollectionUtils.isNotEmpty(linggangKeyWorkLocations)) { |
| 85 | List<RemindKeyInfoLocalVo> remindKeyInfoLocalVoList = new ArrayList<>(); | 85 | List<RemindKeyInfoLocalVo> remindKeyInfoLocalVoList = new ArrayList<>(); |
| @@ -97,7 +97,7 @@ public class RemindDriverKeyLocalController extends BaseController { | @@ -97,7 +97,7 @@ public class RemindDriverKeyLocalController extends BaseController { | ||
| 97 | Optional<LinggangKeyWorkLocation> finalOptional = optional; | 97 | Optional<LinggangKeyWorkLocation> finalOptional = optional; |
| 98 | Optional<Equipment> equipmentOptional = equipments.stream().filter(e -> Objects.equals(e.getDeviceId(), finalOptional.get().getDevice())).findFirst(); | 98 | Optional<Equipment> equipmentOptional = equipments.stream().filter(e -> Objects.equals(e.getDeviceId(), finalOptional.get().getDevice())).findFirst(); |
| 99 | equipmentOptional.ifPresent(equipment -> localVo.setEquipmentName(equipment.getName())); | 99 | equipmentOptional.ifPresent(equipment -> localVo.setEquipmentName(equipment.getName())); |
| 100 | - if(i == 0){ | 100 | + if (i == 0) { |
| 101 | 101 | ||
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| @@ -114,11 +114,23 @@ public class RemindDriverKeyLocalController extends BaseController { | @@ -114,11 +114,23 @@ public class RemindDriverKeyLocalController extends BaseController { | ||
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | - if(i == 0){ | ||
| 118 | - reportVo.setCurrentKeyLocaltion(localVo.getEquipmentName()); | ||
| 119 | - } | ||
| 120 | remindKeyInfoLocalVoList.add(localVo); | 117 | remindKeyInfoLocalVoList.add(localVo); |
| 121 | } | 118 | } |
| 119 | + Optional<LinggangScheduling> opt = linggangSchedulings.stream().filter(f -> Objects.nonNull(f.getSignInId())).max(Comparator.comparing(LinggangScheduling::getFcsjT)); | ||
| 120 | + if (opt.isPresent()) { | ||
| 121 | + Optional<LinggangKeyWorkLocation> optional = linggangKeyWorkLocations.stream().filter(kl -> Objects.equals(kl.getSchedulingId(), opt.get().getId())).findFirst(); | ||
| 122 | + if (optional.isPresent()) { | ||
| 123 | + Optional<Equipment> equipmentOptional = equipments.stream().filter(e -> Objects.equals(e.getDeviceId(), optional.get().getDevice())).findFirst(); | ||
| 124 | + equipmentOptional.ifPresent(equipment -> reportVo.setCurrentKeyLocaltion(equipment.getName())); | ||
| 125 | + } | ||
| 126 | + } else { | ||
| 127 | + Optional<LinggangKeyWorkLocation> optional = linggangKeyWorkLocations.stream().filter(kl -> Objects.equals(kl.getSchedulingId(), linggangSchedulings.get(0).getId())).findFirst(); | ||
| 128 | + if (optional.isPresent()) { | ||
| 129 | + Optional<Equipment> equipmentOptional = equipments.stream().filter(e -> Objects.equals(e.getDeviceId(), optional.get().getDevice())).findFirst(); | ||
| 130 | + equipmentOptional.ifPresent(equipment -> reportVo.setCurrentKeyLocaltion(equipment.getName())); | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + | ||
| 122 | reportVo.setRemindKeyInfoLocalVoList(remindKeyInfoLocalVoList); | 134 | reportVo.setRemindKeyInfoLocalVoList(remindKeyInfoLocalVoList); |
| 123 | } | 135 | } |
| 124 | 136 |
Bsth-admin/src/main/java/com/ruoyi/domain/key/location/LinggangKeyWorkLocation.java
| @@ -101,6 +101,8 @@ public class LinggangKeyWorkLocation { | @@ -101,6 +101,8 @@ public class LinggangKeyWorkLocation { | ||
| 101 | @Excel(name = "状态:1 是归还;0是借出;2是初始状态") | 101 | @Excel(name = "状态:1 是归还;0是借出;2是初始状态") |
| 102 | private java.lang.Integer type; | 102 | private java.lang.Integer type; |
| 103 | 103 | ||
| 104 | + private Integer type1; | ||
| 105 | + | ||
| 104 | @TableField(exist = false) | 106 | @TableField(exist = false) |
| 105 | private Long scheduleDateTimeDiff; | 107 | private Long scheduleDateTimeDiff; |
| 106 | 108 |
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
| @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; | @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; | ||
| 4 | import cn.hutool.http.HttpUtil; | 4 | import cn.hutool.http.HttpUtil; |
| 5 | import com.alibaba.fastjson2.JSON; | 5 | import com.alibaba.fastjson2.JSON; |
| 6 | import com.alibaba.fastjson2.JSONArray; | 6 | import com.alibaba.fastjson2.JSONArray; |
| 7 | +import com.ruoyi.common.SchedulerProperty; | ||
| 7 | import com.ruoyi.common.cache.NowSchedulingCache; | 8 | import com.ruoyi.common.cache.NowSchedulingCache; |
| 8 | import com.ruoyi.common.cache.SchedulingCache; | 9 | import com.ruoyi.common.cache.SchedulingCache; |
| 9 | import com.ruoyi.common.core.redis.RedisCache; | 10 | import com.ruoyi.common.core.redis.RedisCache; |
| @@ -37,8 +38,10 @@ import org.springframework.beans.BeanUtils; | @@ -37,8 +38,10 @@ import org.springframework.beans.BeanUtils; | ||
| 37 | import org.springframework.beans.factory.InitializingBean; | 38 | import org.springframework.beans.factory.InitializingBean; |
| 38 | import org.springframework.beans.factory.annotation.Autowired; | 39 | import org.springframework.beans.factory.annotation.Autowired; |
| 39 | import org.springframework.beans.factory.annotation.Value; | 40 | import org.springframework.beans.factory.annotation.Value; |
| 40 | -import org.springframework.core.ParameterizedTypeReference; | ||
| 41 | -import org.springframework.http.*; | 41 | +import org.springframework.http.HttpEntity; |
| 42 | +import org.springframework.http.HttpHeaders; | ||
| 43 | +import org.springframework.http.MediaType; | ||
| 44 | +import org.springframework.http.ResponseEntity; | ||
| 42 | import org.springframework.stereotype.Component; | 45 | import org.springframework.stereotype.Component; |
| 43 | import org.springframework.transaction.annotation.Transactional; | 46 | import org.springframework.transaction.annotation.Transactional; |
| 44 | import org.springframework.web.client.RestTemplate; | 47 | import org.springframework.web.client.RestTemplate; |
| @@ -131,6 +134,9 @@ public class DriverJob implements InitializingBean { | @@ -131,6 +134,9 @@ public class DriverJob implements InitializingBean { | ||
| 131 | @Value("${api.config.nonce}") | 134 | @Value("${api.config.nonce}") |
| 132 | private String nonce; | 135 | private String nonce; |
| 133 | 136 | ||
| 137 | + @Autowired | ||
| 138 | + private SchedulerProperty property; | ||
| 139 | + | ||
| 134 | 140 | ||
| 135 | private static DriverSchedulingExpandMapper EXPAND_MAPPER; | 141 | private static DriverSchedulingExpandMapper EXPAND_MAPPER; |
| 136 | private static DriverSchedulingExpandSmartService EXPAND_SMART_SERVICE; | 142 | private static DriverSchedulingExpandSmartService EXPAND_SMART_SERVICE; |
| @@ -248,7 +254,7 @@ public class DriverJob implements InitializingBean { | @@ -248,7 +254,7 @@ public class DriverJob implements InitializingBean { | ||
| 248 | Date date = new Date(); | 254 | Date date = new Date(); |
| 249 | 255 | ||
| 250 | for (int i = 0; i < 2; i++) { | 256 | for (int i = 0; i < 2; i++) { |
| 251 | - JwtAuthenticationTokenFilter.putMDC("job",JwtAuthenticationTokenFilter.getRandomValue()); | 257 | + JwtAuthenticationTokenFilter.putMDC("job", JwtAuthenticationTokenFilter.getRandomValue()); |
| 252 | runScheduling(DateUtils.addDays(date, i).getTime()); | 258 | runScheduling(DateUtils.addDays(date, i).getTime()); |
| 253 | } | 259 | } |
| 254 | 260 | ||
| @@ -276,26 +282,38 @@ public class DriverJob implements InitializingBean { | @@ -276,26 +282,38 @@ public class DriverJob implements InitializingBean { | ||
| 276 | 282 | ||
| 277 | Set<Long> idSets = null; | 283 | Set<Long> idSets = null; |
| 278 | if (isSameDay) { | 284 | if (isSameDay) { |
| 285 | + String key = "Scheduling:timeStr:" + formatDate; | ||
| 286 | + long timestampValu = timestamp; | ||
| 287 | + if (!redisCache.hasKey(key)) { | ||
| 288 | + redisCache.setCacheObject(key, "1", 30, TimeUnit.HOURS); | ||
| 289 | + timestampValu = 0; | ||
| 290 | + } | ||
| 279 | scheduling.setType(100); | 291 | scheduling.setType(100); |
| 280 | List<LinggangScheduling> linggangSchedulings = schedulingService.list(scheduling); | 292 | List<LinggangScheduling> linggangSchedulings = schedulingService.list(scheduling); |
| 281 | idSets = linggangSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet()); | 293 | idSets = linggangSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet()); |
| 282 | - } | ||
| 283 | - | ||
| 284 | - | ||
| 285 | 294 | ||
| 295 | + try { | ||
| 296 | + log.info("url:[{}];formatDate:[{}];timestamp:[{}]", url, formatDate, timestamp); | ||
| 297 | + getSchedulingInfoUrl = String.format(url, "77", formatDate, timestampValu, timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); | ||
| 298 | + } catch (Exception e) { | ||
| 299 | + throw new RuntimeException(e); | ||
| 300 | + } | ||
| 286 | 301 | ||
| 302 | + } else { | ||
| 303 | + try { | ||
| 304 | + log.info("url:[{}];formatDate:[{}];timestamp:[{}]", url, formatDate, timestamp); | ||
| 305 | + getSchedulingInfoUrl = String.format(url, "77", formatDate, timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); | ||
| 306 | + } catch (Exception e) { | ||
| 307 | + throw new RuntimeException(e); | ||
| 308 | + } | ||
| 309 | + } | ||
| 287 | 310 | ||
| 288 | 311 | ||
| 289 | // String url = getSchedulingInfoPlan; | 312 | // String url = getSchedulingInfoPlan; |
| 290 | - try { | ||
| 291 | - log.info("url:[{}];formatDate:[{}];timestamp:[{}]",url,formatDate,timestamp); | ||
| 292 | - getSchedulingInfoUrl = String.format(url, "77", formatDate, timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); | ||
| 293 | - } catch (Exception e) { | ||
| 294 | - throw new RuntimeException(e); | ||
| 295 | - } | 313 | + |
| 296 | String requestId = JwtAuthenticationTokenFilter.getRequestIdOfMDCValue(); | 314 | String requestId = JwtAuthenticationTokenFilter.getRequestIdOfMDCValue(); |
| 297 | // 获取排班信息并存入redis | 315 | // 获取排班信息并存入redis |
| 298 | - saveSchedulingToRedis(getSchedulingInfoUrl, formatDate, timeOut, date, type,idSets,requestId); | 316 | + saveSchedulingToRedis(getSchedulingInfoUrl, formatDate, timeOut, date, type, idSets, requestId); |
| 299 | // 删除两天前排班信息 | 317 | // 删除两天前排班信息 |
| 300 | if (isSameDay) { | 318 | if (isSameDay) { |
| 301 | deleteScheduling(); | 319 | deleteScheduling(); |
| @@ -392,19 +410,11 @@ public class DriverJob implements InitializingBean { | @@ -392,19 +410,11 @@ public class DriverJob implements InitializingBean { | ||
| 392 | } | 410 | } |
| 393 | 411 | ||
| 394 | 412 | ||
| 395 | - public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey, String timeOut, Date date, int type,Set<Long> idSets,String requestId) { | ||
| 396 | - JwtAuthenticationTokenFilter.putMDC("job",requestId); | 413 | + public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey, String timeOut, Date date, int type, Set<Long> idSets, String requestId) { |
| 414 | + JwtAuthenticationTokenFilter.putMDC("job", requestId); | ||
| 397 | log.info("开始拉取排班:{};[{}]", dateKey, getSchedulingInfoUrl); | 415 | log.info("开始拉取排班:{};[{}]", dateKey, getSchedulingInfoUrl); |
| 398 | - List<ResponseSchedulingDto> originSchedulingList = RESTTEMPLATE.exchange( | ||
| 399 | - getSchedulingInfoUrl, | ||
| 400 | - HttpMethod.GET, | ||
| 401 | - null, | ||
| 402 | - new ParameterizedTypeReference<List<ResponseSchedulingDto>>() { | ||
| 403 | - }).getBody(); | ||
| 404 | - | ||
| 405 | - if (CollectionUtils.isEmpty(originSchedulingList)) { | ||
| 406 | - return null; | ||
| 407 | - } | 416 | + List<ResponseSchedulingDto> originSchedulingList = schedulingCache.requestScheduling(getSchedulingInfoUrl); |
| 417 | + log.info("originSchedulingList:[{}]", JSON.toJSONString(originSchedulingList)); | ||
| 408 | Map<String, List<ResponseSchedulingDto>> driverSchedulingMap = new HashMap<>(200); | 418 | Map<String, List<ResponseSchedulingDto>> driverSchedulingMap = new HashMap<>(200); |
| 409 | // 以员工号为key存入排班集合 | 419 | // 以员工号为key存入排班集合 |
| 410 | originSchedulingList.stream().forEach(item -> { | 420 | originSchedulingList.stream().forEach(item -> { |
| @@ -423,13 +433,13 @@ public class DriverJob implements InitializingBean { | @@ -423,13 +433,13 @@ public class DriverJob implements InitializingBean { | ||
| 423 | List<String> keys = new ArrayList<>(driverSchedulingMap.keySet()); | 433 | List<String> keys = new ArrayList<>(driverSchedulingMap.keySet()); |
| 424 | for (String key : keys) { | 434 | for (String key : keys) { |
| 425 | List<ResponseSchedulingDto> schedulingList = driverSchedulingMap.get(key); | 435 | List<ResponseSchedulingDto> schedulingList = driverSchedulingMap.get(key); |
| 426 | - if(CollectionUtils.isNotEmpty(schedulingList)){ | ||
| 427 | - schedulingList = schedulingList.stream().map(s->{ | ||
| 428 | - if(Objects.isNull(s.getFcsjT())){ | 436 | + if (CollectionUtils.isNotEmpty(schedulingList)) { |
| 437 | + schedulingList = schedulingList.stream().map(s -> { | ||
| 438 | + if (Objects.isNull(s.getFcsjT())) { | ||
| 429 | s.setFcsjT(0L); | 439 | s.setFcsjT(0L); |
| 430 | } | 440 | } |
| 431 | 441 | ||
| 432 | - if(Objects.isNull(s.getZdsjT())){ | 442 | + if (Objects.isNull(s.getZdsjT())) { |
| 433 | s.setZdsjT(0L); | 443 | s.setZdsjT(0L); |
| 434 | } | 444 | } |
| 435 | 445 | ||
| @@ -440,7 +450,7 @@ public class DriverJob implements InitializingBean { | @@ -440,7 +450,7 @@ public class DriverJob implements InitializingBean { | ||
| 440 | } | 450 | } |
| 441 | 451 | ||
| 442 | // 存入签到报表 | 452 | // 存入签到报表 |
| 443 | - THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap, timeOut, date, type,idSets,requestId); | 453 | + THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap, timeOut, date, type, idSets, requestId); |
| 444 | // 实时排班直接存入缓存 | 454 | // 实时排班直接存入缓存 |
| 445 | SCHEDULING_CACHE.setCacheScheduling(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap); | 455 | SCHEDULING_CACHE.setCacheScheduling(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap); |
| 446 | 456 |
Bsth-admin/src/main/java/com/ruoyi/job/NewDriverJob.java
0 → 100644
| 1 | +package com.ruoyi.job; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; | ||
| 4 | +import com.ruoyi.service.driver.NewDriverService; | ||
| 5 | +import lombok.extern.slf4j.Slf4j; | ||
| 6 | +import org.springframework.beans.factory.InitializingBean; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | +import org.springframework.transaction.annotation.Transactional; | ||
| 10 | + | ||
| 11 | +import java.util.Date; | ||
| 12 | + | ||
| 13 | +@Component("newDriverJob") | ||
| 14 | +@Slf4j | ||
| 15 | +public class NewDriverJob implements InitializingBean { | ||
| 16 | + @Autowired | ||
| 17 | + private NewDriverService newDriverService; | ||
| 18 | + @Transactional(rollbackFor = Exception.class) | ||
| 19 | + public void syDriver() { | ||
| 20 | + Date date = new Date(); | ||
| 21 | + | ||
| 22 | + for (int i = 0; i < 2; i++) { | ||
| 23 | + JwtAuthenticationTokenFilter.putMDC("job",JwtAuthenticationTokenFilter.getRandomValue()); | ||
| 24 | + newDriverService.insertJob(); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public void afterPropertiesSet() throws Exception { | ||
| 32 | + | ||
| 33 | + } | ||
| 34 | +} |
Bsth-admin/src/main/java/com/ruoyi/pojo/response/ResponseSchedulingDto.java
| @@ -59,6 +59,7 @@ public class ResponseSchedulingDto implements Serializable { | @@ -59,6 +59,7 @@ public class ResponseSchedulingDto implements Serializable { | ||
| 59 | private Integer dfsj; | 59 | private Integer dfsj; |
| 60 | private String scheduleDateStr; | 60 | private String scheduleDateStr; |
| 61 | 61 | ||
| 62 | + | ||
| 62 | public void setScheduleDateStr(Object scheduleDateStr) { | 63 | public void setScheduleDateStr(Object scheduleDateStr) { |
| 63 | if (Objects.nonNull(scheduleDateStr)) { | 64 | if (Objects.nonNull(scheduleDateStr)) { |
| 64 | this.scheduleDateStr = scheduleDateStr.toString(); | 65 | this.scheduleDateStr = scheduleDateStr.toString(); |
| @@ -103,6 +104,21 @@ public class ResponseSchedulingDto implements Serializable { | @@ -103,6 +104,21 @@ public class ResponseSchedulingDto implements Serializable { | ||
| 103 | return null; | 104 | return null; |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 107 | +// public String getJobCode(){ | ||
| 108 | +// if(StringUtils.isEmpty(this.jobCode) && StringUtils.isNotEmpty(this.jsy)){ | ||
| 109 | +// this.jobCode = StringUtils.substringBeforeLast(this.jsy,"/"); | ||
| 110 | +// } | ||
| 111 | +// return this.jobCode; | ||
| 112 | +// } | ||
| 113 | +// | ||
| 114 | +// public String getName(){ | ||
| 115 | +// if(StringUtils.isEmpty(this.name) && StringUtils.isNotEmpty(this.jsy)){ | ||
| 116 | +// this.name = StringUtils.substringAfterLast(this.jsy,"/"); | ||
| 117 | +// } | ||
| 118 | +// return this.name; | ||
| 119 | +// } | ||
| 120 | + | ||
| 121 | + | ||
| 106 | public void setUpDowm(String upDowm){ | 122 | public void setUpDowm(String upDowm){ |
| 107 | this.upDown = upDowm; | 123 | this.upDown = upDowm; |
| 108 | } | 124 | } |
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| @@ -546,7 +546,7 @@ public class ThreadJobService { | @@ -546,7 +546,7 @@ public class ThreadJobService { | ||
| 546 | scheduling.setType(b.getType()); | 546 | scheduling.setType(b.getType()); |
| 547 | 547 | ||
| 548 | return scheduling; | 548 | return scheduling; |
| 549 | - }).filter(s->StringUtils.isBlank(s.getJobCode()) && StringUtils.isBlank(s.getName()) && !StringUtils.equalsAnyIgnoreCase(s.getJobCode(),"null") | 549 | + }).filter(s->!StringUtils.isBlank(s.getJobCode()) && !StringUtils.isBlank(s.getName()) && !StringUtils.equalsAnyIgnoreCase(s.getJobCode(),"null") |
| 550 | && !StringUtils.equalsAnyIgnoreCase(s.getName(),"null")).collect(Collectors.toList()); | 550 | && !StringUtils.equalsAnyIgnoreCase(s.getName(),"null")).collect(Collectors.toList()); |
| 551 | if (CollectionUtils.isNotEmpty(schedulings)) { | 551 | if (CollectionUtils.isNotEmpty(schedulings)) { |
| 552 | Map<String, List<LinggangScheduling>> distinctMap = new HashMap<>(); | 552 | Map<String, List<LinggangScheduling>> distinctMap = new HashMap<>(); |
| @@ -599,6 +599,10 @@ public class ThreadJobService { | @@ -599,6 +599,10 @@ public class ThreadJobService { | ||
| 599 | if(CollectionUtils.isNotEmpty(removeSchedulings)){ | 599 | if(CollectionUtils.isNotEmpty(removeSchedulings)){ |
| 600 | Set<Long> ids = removeSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet()); | 600 | Set<Long> ids = removeSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet()); |
| 601 | schedulingService.removeByIds(ids); | 601 | schedulingService.removeByIds(ids); |
| 602 | + schedulings = schedulings1.stream().filter(s->{ | ||
| 603 | + Optional<LinggangScheduling> opt = removeSchedulings.stream().filter(s1 -> s1.importEqus(s)).findFirst(); | ||
| 604 | + return !opt.isPresent(); | ||
| 605 | + }).collect(Collectors.toList()); | ||
| 602 | } | 606 | } |
| 603 | 607 | ||
| 604 | schedulings = schedulings.stream().filter(s -> { | 608 | schedulings = schedulings.stream().filter(s -> { |
Bsth-admin/src/main/java/com/ruoyi/utils/HttpClientUtil.java
| @@ -3,12 +3,18 @@ package com.ruoyi.utils; | @@ -3,12 +3,18 @@ package com.ruoyi.utils; | ||
| 3 | import com.alibaba.fastjson2.JSON; | 3 | import com.alibaba.fastjson2.JSON; |
| 4 | import lombok.extern.slf4j.Slf4j; | 4 | import lombok.extern.slf4j.Slf4j; |
| 5 | import org.apache.commons.collections4.MapUtils; | 5 | import org.apache.commons.collections4.MapUtils; |
| 6 | +import org.apache.commons.lang3.StringUtils; | ||
| 7 | +import org.apache.http.HttpEntity; | ||
| 6 | import org.apache.http.HttpResponse; | 8 | import org.apache.http.HttpResponse; |
| 9 | +import org.apache.http.ParseException; | ||
| 7 | import org.apache.http.client.ClientProtocolException; | 10 | import org.apache.http.client.ClientProtocolException; |
| 8 | import org.apache.http.client.HttpClient; | 11 | import org.apache.http.client.HttpClient; |
| 12 | +import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 13 | +import org.apache.http.client.methods.HttpGet; | ||
| 9 | import org.apache.http.client.methods.HttpPost; | 14 | import org.apache.http.client.methods.HttpPost; |
| 10 | import org.apache.http.entity.ContentType; | 15 | import org.apache.http.entity.ContentType; |
| 11 | import org.apache.http.entity.StringEntity; | 16 | import org.apache.http.entity.StringEntity; |
| 17 | +import org.apache.http.impl.client.CloseableHttpClient; | ||
| 12 | import org.apache.http.impl.client.HttpClients; | 18 | import org.apache.http.impl.client.HttpClients; |
| 13 | import org.apache.http.util.EntityUtils; | 19 | import org.apache.http.util.EntityUtils; |
| 14 | import org.springframework.stereotype.Component; | 20 | import org.springframework.stereotype.Component; |
| @@ -16,6 +22,7 @@ import org.springframework.stereotype.Component; | @@ -16,6 +22,7 @@ import org.springframework.stereotype.Component; | ||
| 16 | import java.io.IOException; | 22 | import java.io.IOException; |
| 17 | import java.net.URI; | 23 | import java.net.URI; |
| 18 | import java.net.URISyntaxException; | 24 | import java.net.URISyntaxException; |
| 25 | +import java.nio.charset.StandardCharsets; | ||
| 19 | import java.util.Map; | 26 | import java.util.Map; |
| 20 | import java.util.Objects; | 27 | import java.util.Objects; |
| 21 | 28 | ||
| @@ -69,4 +76,24 @@ public class HttpClientUtil { | @@ -69,4 +76,24 @@ public class HttpClientUtil { | ||
| 69 | } | 76 | } |
| 70 | return null; | 77 | return null; |
| 71 | } | 78 | } |
| 79 | + | ||
| 80 | + | ||
| 81 | + public static String get(String url) { | ||
| 82 | + String resultContent = null; | ||
| 83 | + HttpGet httpGet = new HttpGet(url); | ||
| 84 | + try (CloseableHttpClient httpclient = HttpClients.createDefault()) { | ||
| 85 | + try (CloseableHttpResponse response = httpclient.execute(httpGet)) { | ||
| 86 | + | ||
| 87 | + HttpEntity entity = response.getEntity(); | ||
| 88 | + // 获取响应信息 | ||
| 89 | + resultContent = EntityUtils.toString(entity); | ||
| 90 | + if(StringUtils.isNotEmpty(resultContent)){ | ||
| 91 | + resultContent = new String(resultContent.getBytes(),StandardCharsets.UTF_8); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + } catch (IOException | ParseException e) { | ||
| 95 | + e.printStackTrace(); | ||
| 96 | + } | ||
| 97 | + return resultContent; | ||
| 98 | + } | ||
| 72 | } | 99 | } |
Bsth-admin/src/main/resources/application-druid-dev.yml
| @@ -165,7 +165,8 @@ api: | @@ -165,7 +165,8 @@ api: | ||
| 165 | getCompanyInfo: | 165 | getCompanyInfo: |
| 166 | # 获取排班信息 | 166 | # 获取排班信息 |
| 167 | getSchedulingInfo: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 167 | getSchedulingInfo: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 168 | - getSchedulingInfoNew: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 168 | + getSchedulingInfoNew: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk4modify/%s/%s/%d?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 169 | + getSchedulingInfoNew1: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | ||
| 169 | getSchedulingInfoPlan: http://58.34.47.74:9089/webservice/rest/schedule/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 170 | getSchedulingInfoPlan: http://58.34.47.74:9089/webservice/rest/schedule/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 170 | config: | 171 | config: |
| 171 | password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 | 172 | password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 |
Bsth-admin/src/main/resources/application-druid-lingangTest.yml
| @@ -165,7 +165,8 @@ api: | @@ -165,7 +165,8 @@ api: | ||
| 165 | getCompanyInfo: | 165 | getCompanyInfo: |
| 166 | # 获取排班信息 | 166 | # 获取排班信息 |
| 167 | getSchedulingInfo: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 167 | getSchedulingInfo: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 168 | - getSchedulingInfoNew: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 168 | + getSchedulingInfoNew: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk4modify/%s/%s/%d?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 169 | + getSchedulingInfoNew1: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | ||
| 169 | getSchedulingInfoPlan: http://58.34.47.74:9089/webservice/rest/schedule/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 170 | getSchedulingInfoPlan: http://58.34.47.74:9089/webservice/rest/schedule/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 170 | config: | 171 | config: |
| 171 | password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 | 172 | password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 |
Bsth-admin/src/main/resources/application-druid-prd.yml
| @@ -185,7 +185,8 @@ api: | @@ -185,7 +185,8 @@ api: | ||
| 185 | getCompanyInfo: | 185 | getCompanyInfo: |
| 186 | # 获取排班信息 | 186 | # 获取排班信息 |
| 187 | getSchedulingInfo: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 187 | getSchedulingInfo: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 188 | - getSchedulingInfoNew: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 188 | + getSchedulingInfoNew: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk4modify/%s/%s/%d?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 189 | + getSchedulingInfoNew1: http://58.34.47.74:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | ||
| 189 | getSchedulingInfoPlan: http://58.34.47.74:9089/webservice/rest/schedule/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s | 190 | getSchedulingInfoPlan: http://58.34.47.74:9089/webservice/rest/schedule/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s |
| 190 | config: | 191 | config: |
| 191 | password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 | 192 | password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 |