Commit fc89a99bfa4f2896a061233bf4a7aaefa4a00f9d
1 parent
2f206ef0
酒测未通过审核
Showing
8 changed files
with
92 additions
and
15 deletions
Bsth-admin/src/main/java/com/ruoyi/common/TipEnum.java
Bsth-admin/src/main/java/com/ruoyi/controller/RefreshController.java
| 1 | 1 | package com.ruoyi.controller; |
| 2 | 2 | |
| 3 | 3 | import com.ruoyi.common.core.domain.ResponseResult; |
| 4 | +import com.ruoyi.domain.scheduling.LinggangScheduling; | |
| 4 | 5 | import com.ruoyi.job.DriverJob; |
| 5 | 6 | import com.ruoyi.service.driver.NewDriverService; |
| 6 | 7 | import com.ruoyi.service.key.location.LinggangKeyWorkLocationService; |
| 8 | +import com.ruoyi.service.scheduling.LinggangSchedulingService; | |
| 9 | +import com.ruoyi.utils.DateUtil; | |
| 7 | 10 | import io.swagger.annotations.ApiOperation; |
| 8 | 11 | import org.apache.commons.lang3.time.DateUtils; |
| 9 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -12,7 +15,11 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 12 | 15 | import org.springframework.web.bind.annotation.RequestParam; |
| 13 | 16 | import org.springframework.web.bind.annotation.RestController; |
| 14 | 17 | |
| 18 | +import java.text.ParseException; | |
| 15 | 19 | import java.util.Date; |
| 20 | +import java.util.List; | |
| 21 | +import java.util.Set; | |
| 22 | +import java.util.stream.Collectors; | |
| 16 | 23 | |
| 17 | 24 | /** |
| 18 | 25 | * @author liujun |
| ... | ... | @@ -27,6 +34,8 @@ public class RefreshController { |
| 27 | 34 | private LinggangKeyWorkLocationService keyWorkLocationService; |
| 28 | 35 | @Autowired |
| 29 | 36 | private NewDriverService newDriverService; |
| 37 | + @Autowired | |
| 38 | + private LinggangSchedulingService linggangSchedulingService; | |
| 30 | 39 | |
| 31 | 40 | @GetMapping(value = "/scheduling") |
| 32 | 41 | @ApiOperation("scheduling") |
| ... | ... | @@ -41,8 +50,17 @@ public class RefreshController { |
| 41 | 50 | |
| 42 | 51 | @GetMapping(value = "/key/info/local") |
| 43 | 52 | @ApiOperation("/key/info/local") |
| 44 | - public ResponseResult<Boolean> testKeyInfoLocal(@RequestParam("dateStr") String dateStr) { | |
| 45 | - keyWorkLocationService.insertJob(dateStr); | |
| 53 | + public ResponseResult<Boolean> testKeyInfoLocal(@RequestParam("dateStr") String dateStr) throws ParseException { | |
| 54 | + Date date = DateUtil.YYYY_MM_DD_LINK.parse(dateStr); | |
| 55 | + | |
| 56 | + LinggangScheduling scheduling = new LinggangScheduling(); | |
| 57 | + scheduling.setStartScheduleDate(DateUtil.shortDate(date)); | |
| 58 | + scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1)); | |
| 59 | + scheduling.setType(100); | |
| 60 | + | |
| 61 | + List<LinggangScheduling> linggangSchedulings = linggangSchedulingService.list(scheduling); | |
| 62 | + Set<Long> idSets = linggangSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet()); | |
| 63 | + keyWorkLocationService.insertJob(dateStr, idSets); | |
| 46 | 64 | return ResponseResult.success(); |
| 47 | 65 | } |
| 48 | 66 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/domain/dss/driver/dto/GetBeforeWorkListDTO.java
| ... | ... | @@ -22,6 +22,8 @@ public class GetBeforeWorkListDTO implements java.io.Serializable { |
| 22 | 22 | |
| 23 | 23 | private static final long serialVersionUID = -19813580197166104L; |
| 24 | 24 | |
| 25 | + private String device; | |
| 26 | + | |
| 25 | 27 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| 26 | 28 | @ApiModelProperty(value = "酒测时间") |
| 27 | 29 | private Date checkTime; | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
| ... | ... | @@ -8,6 +8,7 @@ import com.ruoyi.common.cache.NowSchedulingCache; |
| 8 | 8 | import com.ruoyi.common.cache.SchedulingCache; |
| 9 | 9 | import com.ruoyi.common.core.redis.RedisCache; |
| 10 | 10 | import com.ruoyi.common.utils.StringUtils; |
| 11 | +import com.ruoyi.common.utils.spring.SpringUtils; | |
| 11 | 12 | import com.ruoyi.domain.scheduling.LinggangScheduling; |
| 12 | 13 | import com.ruoyi.driver.domain.Driver; |
| 13 | 14 | import com.ruoyi.driver.service.IDriverService; |
| ... | ... | @@ -15,6 +16,7 @@ import com.ruoyi.equipment.domain.Equipment; |
| 15 | 16 | import com.ruoyi.equipment.mapper.EquipmentMapper; |
| 16 | 17 | import com.ruoyi.expand.domain.DriverSchedulingExpand; |
| 17 | 18 | import com.ruoyi.expand.mapper.DriverSchedulingExpandMapper; |
| 19 | +import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; | |
| 18 | 20 | import com.ruoyi.pojo.request.PersonnelRequestVo; |
| 19 | 21 | import com.ruoyi.pojo.request.TokenRequestVo; |
| 20 | 22 | import com.ruoyi.pojo.response.ResponseSchedulingDto; |
| ... | ... | @@ -242,6 +244,7 @@ public class DriverJob implements InitializingBean { |
| 242 | 244 | @Transactional(rollbackFor = Exception.class) |
| 243 | 245 | public void getSchedulingInfo() { |
| 244 | 246 | Date date = new Date(); |
| 247 | + JwtAuthenticationTokenFilter.putMDC("job",JwtAuthenticationTokenFilter.getRequestIdOfMDCValue()); | |
| 245 | 248 | for (int i = 0; i < 2; i++) { |
| 246 | 249 | runScheduling(DateUtils.addDays(date, i).getTime()); |
| 247 | 250 | } |
| ... | ... | @@ -269,31 +272,35 @@ public class DriverJob implements InitializingBean { |
| 269 | 272 | scheduling.setStartScheduleDate(DateUtil.shortDate(date)); |
| 270 | 273 | scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1)); |
| 271 | 274 | scheduling.setType(type); |
| 275 | + if(Objects.isNull(schedulingService)){ | |
| 276 | + schedulingService = SpringUtils.getBean(LinggangSchedulingService.class); | |
| 277 | + } | |
| 272 | 278 | Integer count = schedulingService.countId(scheduling); |
| 273 | 279 | if (Objects.nonNull(count) && count > 0) { |
| 274 | 280 | log.info("[{}]排班数据已经存在", date); |
| 275 | 281 | return; |
| 276 | 282 | } |
| 277 | 283 | |
| 278 | - | |
| 284 | + Set<Long> idSets = null; | |
| 279 | 285 | if (isSameDay) { |
| 280 | 286 | scheduling.setType(100); |
| 281 | 287 | List<LinggangScheduling> linggangSchedulings = schedulingService.list(scheduling); |
| 282 | - Set<Long> IdSets = linggangSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet()); | |
| 283 | - if (CollectionUtils.isNotEmpty(IdSets)) { | |
| 284 | - schedulingService.removeByIds(IdSets); | |
| 288 | + idSets = linggangSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet()); | |
| 289 | + if (CollectionUtils.isNotEmpty(idSets)) { | |
| 290 | + schedulingService.removeByIds(idSets); | |
| 285 | 291 | } |
| 286 | 292 | } |
| 287 | 293 | |
| 288 | 294 | |
| 289 | 295 | // String url = getSchedulingInfoPlan; |
| 290 | 296 | try { |
| 297 | + log.info("url:[{}];formatDate:[{}];timestamp:[{}]",url,formatDate,timestamp); | |
| 291 | 298 | getSchedulingInfoUrl = String.format(url, "77", formatDate, timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); |
| 292 | 299 | } catch (Exception e) { |
| 293 | 300 | throw new RuntimeException(e); |
| 294 | 301 | } |
| 295 | 302 | // 获取排班信息并存入redis |
| 296 | - saveSchedulingToRedis(getSchedulingInfoUrl, formatDate, timeOut, date, type); | |
| 303 | + saveSchedulingToRedis(getSchedulingInfoUrl, formatDate, timeOut, date, type,idSets); | |
| 297 | 304 | // 删除两天前排班信息 |
| 298 | 305 | if (isSameDay) { |
| 299 | 306 | deleteScheduling(); |
| ... | ... | @@ -390,7 +397,7 @@ public class DriverJob implements InitializingBean { |
| 390 | 397 | } |
| 391 | 398 | |
| 392 | 399 | |
| 393 | - public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey, String timeOut, Date date, int type) { | |
| 400 | + public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey, String timeOut, Date date, int type,Set<Long> idSets) { | |
| 394 | 401 | log.info("开始拉取排班:{};[{}]", dateKey, getSchedulingInfoUrl); |
| 395 | 402 | List<ResponseSchedulingDto> originSchedulingList = RESTTEMPLATE.exchange( |
| 396 | 403 | getSchedulingInfoUrl, |
| ... | ... | @@ -436,7 +443,7 @@ public class DriverJob implements InitializingBean { |
| 436 | 443 | schedulingList.sort(Comparator.comparing(ResponseSchedulingDto::getFcsjT)); |
| 437 | 444 | } |
| 438 | 445 | // 存入签到报表 |
| 439 | - THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap, timeOut, date, type); | |
| 446 | + THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap, timeOut, date, type,idSets); | |
| 440 | 447 | // 实时排班直接存入缓存 |
| 441 | 448 | SCHEDULING_CACHE.setCacheScheduling(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap); |
| 442 | 449 | log.info("拉取排班完毕:{}", dateKey); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| ... | ... | @@ -416,7 +416,7 @@ public class ThreadJobService { |
| 416 | 416 | */ |
| 417 | 417 | @Async |
| 418 | 418 | @Transactional(rollbackFor = {Exception.class}) |
| 419 | - public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap, String timeOut, Date date, int type) { | |
| 419 | + public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap, String timeOut, Date date, int type,Set<Long> IdSets) { | |
| 420 | 420 | //查询当天是否保存过考情表 如果不存在则保存 |
| 421 | 421 | List<DriverScheduling> bcList = schedulingMapper.queryToDay(DateUtil.YYYY_MM_DD_LINK.format(date), DateUtil.YYYY_MM_DD_LINK.format(org.apache.commons.lang3.time.DateUtils.addDays(date, 1)), null, null, null); |
| 422 | 422 | Map<String, List<DriverScheduling>> dto = nowSchedulingCache.getCacheScheduling(ConstDateUtil.formatDate(date)); |
| ... | ... | @@ -519,7 +519,7 @@ public class ThreadJobService { |
| 519 | 519 | // 插入错误排班 |
| 520 | 520 | errorJobcodeService.insertBatchErrorJobcode(errorScheduling); |
| 521 | 521 | } |
| 522 | - keyWorkLocationService.insertJob(dateStr1); | |
| 522 | + keyWorkLocationService.insertJob(dateStr1,IdSets); | |
| 523 | 523 | log.info("当天排班数据获取完毕,共:{}条", bcList.size()); |
| 524 | 524 | } |
| 525 | 525 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/key/location/LinggangKeyWorkLocationServiceImpl.java
| ... | ... | @@ -125,6 +125,22 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | @Override |
| 128 | + public List<LinggangKeyWorkLocation> listRecent(LinggangKeyWorkLocation entity, Collection<Long> schedulingIds) { | |
| 129 | + LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper = null; | |
| 130 | + if(Objects.isNull(entity)){ | |
| 131 | + wrapper = new LambdaQueryWrapper<>(); | |
| 132 | + }else { | |
| 133 | + wrapper = new LambdaQueryWrapper<>(entity); | |
| 134 | + } | |
| 135 | + switchTime(entity, wrapper); | |
| 136 | + | |
| 137 | + if(CollectionUtils.isNotEmpty(schedulingIds)){ | |
| 138 | + wrapper.in(LinggangKeyWorkLocation::getSchedulingId,schedulingIds); | |
| 139 | + } | |
| 140 | + return list(wrapper); | |
| 141 | + } | |
| 142 | + | |
| 143 | + @Override | |
| 128 | 144 | public List<LinggangKeyWorkLocation> listRecent(Collection<Integer> keyIds, Date date) { |
| 129 | 145 | LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper = new LambdaQueryWrapper<>(); |
| 130 | 146 | if (CollectionUtils.isNotEmpty(keyIds)) { |
| ... | ... | @@ -235,11 +251,22 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 235 | 251 | |
| 236 | 252 | @Override |
| 237 | 253 | @Transactional(rollbackFor = Exception.class) |
| 238 | - public boolean insertJob(String timeStr) { | |
| 254 | + public boolean insertJob(String timeStr,Set<Long> schedulingIds) { | |
| 239 | 255 | try { |
| 256 | + if(CollectionUtils.isNotEmpty(schedulingIds)){ | |
| 257 | + List<LinggangKeyWorkLocation> workLocations = listRecent(null,schedulingIds); | |
| 258 | + if(CollectionUtils.isNotEmpty(workLocations)){ | |
| 259 | + Set<Long> ids = workLocations.stream().map(LinggangKeyWorkLocation::getId).collect(Collectors.toSet()); | |
| 260 | + if(CollectionUtils.isNotEmpty(ids)){ | |
| 261 | + removeByIds(ids); | |
| 262 | + } | |
| 263 | + } | |
| 264 | + } | |
| 265 | + | |
| 240 | 266 | Date date = DateUtil.YYYY_MM_DD_LINK.parse(timeStr); |
| 241 | 267 | LinggangKeyWorkLocation workLocation = new LinggangKeyWorkLocation(); |
| 242 | - workLocation.setScheduleDate(date); | |
| 268 | + workLocation.setStartScheduleDate(date); | |
| 269 | + workLocation.setEndScheduleDate(DateUtils.addDays(date,1)); | |
| 243 | 270 | Integer count = countId(workLocation); |
| 244 | 271 | if (Objects.nonNull(count) && count > 0) { |
| 245 | 272 | log.error("当天的数据已经存在:[{}];[{}]", timeStr, count); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/key/location/LinggangKeyWorkLocationService.java
| ... | ... | @@ -9,6 +9,7 @@ import com.ruoyi.domain.key.location.LinggangKeyWorkLocation; |
| 9 | 9 | import java.util.Collection; |
| 10 | 10 | import java.util.Date; |
| 11 | 11 | import java.util.List; |
| 12 | +import java.util.Set; | |
| 12 | 13 | |
| 13 | 14 | |
| 14 | 15 | /** |
| ... | ... | @@ -27,6 +28,8 @@ public interface LinggangKeyWorkLocationService extends IService<LinggangKeyWork |
| 27 | 28 | |
| 28 | 29 | List<LinggangKeyWorkLocation> listRecent(LinggangKeyWorkLocation entity, Date date); |
| 29 | 30 | |
| 31 | + List<LinggangKeyWorkLocation> listRecent(LinggangKeyWorkLocation entity, Collection<Long> schedulingIds); | |
| 32 | + | |
| 30 | 33 | List<LinggangKeyWorkLocation> listRecent(Collection<Integer> keyIds, Date date); |
| 31 | 34 | |
| 32 | 35 | List<LinggangKeyWorkLocation> listRecent(LinggangKeyWorkLocation entity,Collection<Integer> keyIds, Date date); |
| ... | ... | @@ -57,7 +60,7 @@ public interface LinggangKeyWorkLocationService extends IService<LinggangKeyWork |
| 57 | 60 | /***插入数据*/ |
| 58 | 61 | boolean insert(LinggangKeyWorkLocation entity); |
| 59 | 62 | |
| 60 | - boolean insertJob(String timeStr); | |
| 63 | + boolean insertJob(String timeStr, Set<Long> IdSets); | |
| 61 | 64 | |
| 62 | 65 | /** |
| 63 | 66 | * 根据主键修改数据 | ... | ... |
Bsth-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java
| ... | ... | @@ -11,6 +11,8 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio |
| 11 | 11 | import org.springframework.security.core.context.SecurityContextHolder; |
| 12 | 12 | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; |
| 13 | 13 | import org.springframework.stereotype.Component; |
| 14 | +import org.springframework.web.context.request.RequestContextHolder; | |
| 15 | +import org.springframework.web.context.request.ServletRequestAttributes; | |
| 14 | 16 | import org.springframework.web.filter.OncePerRequestFilter; |
| 15 | 17 | |
| 16 | 18 | import javax.servlet.FilterChain; |
| ... | ... | @@ -50,6 +52,24 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { |
| 50 | 52 | chain.doFilter(request, response); |
| 51 | 53 | } |
| 52 | 54 | |
| 55 | + public static String validateDevice(String device) { | |
| 56 | +// LoginUser loginUser = SecurityUtils.getLoginUser(); | |
| 57 | +// if(Objects.isNull(loginUser)){ | |
| 58 | +// return "没有登陆信息"; | |
| 59 | +// } | |
| 60 | +// | |
| 61 | +// if(org.apache.commons.lang3.StringUtils.equals(device,Convert.toStr(loginUser.getDeptId()))){ | |
| 62 | + return null; | |
| 63 | +// } | |
| 64 | +// | |
| 65 | +// return "登陆的设备和token不匹配"; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public static HttpServletRequest getRequest() { | |
| 69 | + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); | |
| 70 | + return Objects.isNull(servletRequestAttributes) ? (HttpServletRequest) servletRequestAttributes.getRequest() : null; | |
| 71 | + } | |
| 72 | + | |
| 53 | 73 | public static void putMDC(String userId, String requestId) { |
| 54 | 74 | if (org.apache.commons.lang3.StringUtils.isEmpty(userId)) { |
| 55 | 75 | userId = getRandomValue(); | ... | ... |