Commit 241ef25319dc527e4fc4e63aa8636ef7b14cf529
1 parent
08088c35
上传不显示图片问题
Showing
8 changed files
with
46 additions
and
25 deletions
Bsth-admin/src/main/java/com/ruoyi/controller/dss/DssDriverController.java
| ... | ... | @@ -99,9 +99,9 @@ public class DssDriverController extends BaseController { |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | String msg = JwtAuthenticationTokenFilter.validateDevice(loginDriverDTO.getDevice()); |
| 102 | - if(StringUtils.isNotEmpty(msg)){ | |
| 102 | + if (StringUtils.isNotEmpty(msg)) { | |
| 103 | 103 | log.info(msg); |
| 104 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 104 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | NewDriver driver = null; |
| ... | ... | @@ -127,9 +127,9 @@ public class DssDriverController extends BaseController { |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | String msg = JwtAuthenticationTokenFilter.validateDevice(dto.getDevice()); |
| 130 | - if(StringUtils.isNotEmpty(msg)){ | |
| 130 | + if (StringUtils.isNotEmpty(msg)) { | |
| 131 | 131 | log.info(msg); |
| 132 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 132 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | SignIn signIn = convertSignIn(dto); |
| ... | ... | @@ -170,9 +170,9 @@ public class DssDriverController extends BaseController { |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | String msg = JwtAuthenticationTokenFilter.validateDevice(dto.getDevice()); |
| 173 | - if(StringUtils.isNotEmpty(msg)){ | |
| 173 | + if (StringUtils.isNotEmpty(msg)) { | |
| 174 | 174 | log.info(msg); |
| 175 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 175 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | SignIn signIn = convertSignIn(dto); |
| ... | ... | @@ -202,9 +202,9 @@ public class DssDriverController extends BaseController { |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | String msg = JwtAuthenticationTokenFilter.validateDevice(dto.getDevice()); |
| 205 | - if(StringUtils.isNotEmpty(msg)){ | |
| 205 | + if (StringUtils.isNotEmpty(msg)) { | |
| 206 | 206 | log.info(msg); |
| 207 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 207 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | SignIn signIn = convertSignIn(dto); |
| ... | ... | @@ -220,9 +220,9 @@ public class DssDriverController extends BaseController { |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | String msg = JwtAuthenticationTokenFilter.validateDevice(dto.getDevice()); |
| 223 | - if(StringUtils.isNotEmpty(msg)){ | |
| 223 | + if (StringUtils.isNotEmpty(msg)) { | |
| 224 | 224 | log.info(msg); |
| 225 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 225 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | LinggangScheduling scheduling = convertScheduling(dto); |
| ... | ... | @@ -250,9 +250,9 @@ public class DssDriverController extends BaseController { |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | String msg = JwtAuthenticationTokenFilter.validateDevice(dto.getDevice()); |
| 253 | - if(StringUtils.isNotEmpty(msg)){ | |
| 253 | + if (StringUtils.isNotEmpty(msg)) { | |
| 254 | 254 | log.info(msg); |
| 255 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 255 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | NewDriver newDriver = convertGetBeforeWorkListDTO(dto); |
| ... | ... | @@ -295,9 +295,9 @@ public class DssDriverController extends BaseController { |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | String msg = JwtAuthenticationTokenFilter.validateDevice(dto.getDevice()); |
| 298 | - if(StringUtils.isNotEmpty(msg)){ | |
| 298 | + if (StringUtils.isNotEmpty(msg)) { | |
| 299 | 299 | log.info(msg); |
| 300 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 300 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | List<LinggangSignInResource> convertLinggangSignInResources = convertLinggangSignInResource(dto); |
| ... | ... | @@ -319,9 +319,9 @@ public class DssDriverController extends BaseController { |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | String msg = JwtAuthenticationTokenFilter.validateDevice(dto.getDevice()); |
| 322 | - if(StringUtils.isNotEmpty(msg)){ | |
| 322 | + if (StringUtils.isNotEmpty(msg)) { | |
| 323 | 323 | log.info(msg); |
| 324 | - return ResponseResult.error(TipEnum.TIP_401.getCode(),TipEnum.TIP_401.getMsg()); | |
| 324 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | LinggangSignInResource resource = cconvertLinggangSignInResource(dto); |
| ... | ... | @@ -536,6 +536,10 @@ public class DssDriverController extends BaseController { |
| 536 | 536 | resource.setCreateTime(new Date()); |
| 537 | 537 | resource.setDevice(dto.getDevice()); |
| 538 | 538 | resource.setContent(pic.getPic()); |
| 539 | + resource.setPicType(pic.getPicType()); | |
| 540 | + if (StringUtils.isEmpty(resource.getPicType())) { | |
| 541 | + resource.setPicType("png"); | |
| 542 | + } | |
| 539 | 543 | |
| 540 | 544 | resources.add(resource); |
| 541 | 545 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/domain/dss/sign/resource/UpLoadPicturePicDataDTO.java
| ... | ... | @@ -36,6 +36,8 @@ public class UpLoadPicturePicDataDTO implements java.io.Serializable { |
| 36 | 36 | @NotEmpty(message = "照片内容不能为空") |
| 37 | 37 | @ApiModelProperty(value = "照片;格式:BASE64", required = true) |
| 38 | 38 | private String pic; |
| 39 | + @ApiModelProperty(value = "照片类型", required = true) | |
| 40 | + private String picType; | |
| 39 | 41 | |
| 40 | 42 | @Override |
| 41 | 43 | public String toString() { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/domain/sign/in/resource/LinggangSignInResource.java
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
| ... | ... | @@ -244,7 +244,7 @@ public class DriverJob implements InitializingBean { |
| 244 | 244 | @Transactional(rollbackFor = Exception.class) |
| 245 | 245 | public void getSchedulingInfo() { |
| 246 | 246 | Date date = new Date(); |
| 247 | - JwtAuthenticationTokenFilter.putMDC("job",JwtAuthenticationTokenFilter.getRequestIdOfMDCValue()); | |
| 247 | + JwtAuthenticationTokenFilter.putMDC("job",JwtAuthenticationTokenFilter.getRandomValue()); | |
| 248 | 248 | for (int i = 0; i < 2; i++) { |
| 249 | 249 | runScheduling(DateUtils.addDays(date, i).getTime()); |
| 250 | 250 | } |
| ... | ... | @@ -288,7 +288,7 @@ public class DriverJob implements InitializingBean { |
| 288 | 288 | } |
| 289 | 289 | Integer count = schedulingService.countId(scheduling); |
| 290 | 290 | if (Objects.nonNull(count) && count > 0) { |
| 291 | - log.info("[{}]排班数据已经存在", date); | |
| 291 | + log.info("[{}]排班数据已经存在:[{}]", date,count); | |
| 292 | 292 | return; |
| 293 | 293 | } |
| 294 | 294 | |
| ... | ... | @@ -302,8 +302,9 @@ public class DriverJob implements InitializingBean { |
| 302 | 302 | } catch (Exception e) { |
| 303 | 303 | throw new RuntimeException(e); |
| 304 | 304 | } |
| 305 | + String requestId = JwtAuthenticationTokenFilter.getRequestIdOfMDCValue(); | |
| 305 | 306 | // 获取排班信息并存入redis |
| 306 | - saveSchedulingToRedis(getSchedulingInfoUrl, formatDate, timeOut, date, type,idSets); | |
| 307 | + saveSchedulingToRedis(getSchedulingInfoUrl, formatDate, timeOut, date, type,idSets,requestId); | |
| 307 | 308 | // 删除两天前排班信息 |
| 308 | 309 | if (isSameDay) { |
| 309 | 310 | deleteScheduling(); |
| ... | ... | @@ -400,7 +401,8 @@ public class DriverJob implements InitializingBean { |
| 400 | 401 | } |
| 401 | 402 | |
| 402 | 403 | |
| 403 | - public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey, String timeOut, Date date, int type,Set<Long> idSets) { | |
| 404 | + public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey, String timeOut, Date date, int type,Set<Long> idSets,String requestId) { | |
| 405 | + JwtAuthenticationTokenFilter.putMDC("job",requestId); | |
| 404 | 406 | log.info("开始拉取排班:{};[{}]", dateKey, getSchedulingInfoUrl); |
| 405 | 407 | List<ResponseSchedulingDto> originSchedulingList = RESTTEMPLATE.exchange( |
| 406 | 408 | getSchedulingInfoUrl, |
| ... | ... | @@ -445,8 +447,9 @@ public class DriverJob implements InitializingBean { |
| 445 | 447 | } |
| 446 | 448 | schedulingList.sort(Comparator.comparing(ResponseSchedulingDto::getFcsjT)); |
| 447 | 449 | } |
| 450 | + | |
| 448 | 451 | // 存入签到报表 |
| 449 | - THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap, timeOut, date, type,idSets); | |
| 452 | + THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap, timeOut, date, type,idSets,requestId); | |
| 450 | 453 | // 实时排班直接存入缓存 |
| 451 | 454 | SCHEDULING_CACHE.setCacheScheduling(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap); |
| 452 | 455 | log.info("拉取排班完毕:{}", dateKey); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| ... | ... | @@ -28,6 +28,7 @@ import com.ruoyi.equipment.domain.EquipmentLog; |
| 28 | 28 | import com.ruoyi.equipment.mapper.EquipmentMapper; |
| 29 | 29 | import com.ruoyi.errorScheduling.domain.ErrorJobcode; |
| 30 | 30 | import com.ruoyi.errorScheduling.service.IErrorJobcodeService; |
| 31 | +import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; | |
| 31 | 32 | import com.ruoyi.in.domain.SignIn; |
| 32 | 33 | import com.ruoyi.job.DriverJob; |
| 33 | 34 | import com.ruoyi.pojo.GlobalIndex; |
| ... | ... | @@ -416,7 +417,8 @@ public class ThreadJobService { |
| 416 | 417 | */ |
| 417 | 418 | @Async |
| 418 | 419 | @Transactional(rollbackFor = {Exception.class}) |
| 419 | - public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap, String timeOut, Date date, int type,Set<Long> IdSets) { | |
| 420 | + public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap, String timeOut, Date date, int type,Set<Long> IdSets,String requestId) { | |
| 421 | + JwtAuthenticationTokenFilter.putMDC("job",requestId); | |
| 420 | 422 | //查询当天是否保存过考情表 如果不存在则保存 |
| 421 | 423 | 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 | 424 | Map<String, List<DriverScheduling>> dto = nowSchedulingCache.getCacheScheduling(ConstDateUtil.formatDate(date)); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/key/location/LinggangKeyWorkLocationServiceImpl.java
| ... | ... | @@ -101,6 +101,9 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | private static void switchTime(LinggangKeyWorkLocation entity, LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper) { |
| 104 | + if(Objects.isNull(entity) || Objects.isNull(wrapper)){ | |
| 105 | + return; | |
| 106 | + } | |
| 104 | 107 | if (Objects.nonNull(entity.getStartScheduleDate()) && Objects.nonNull(entity.getEndScheduleDate())) { |
| 105 | 108 | wrapper.between(LinggangKeyWorkLocation::getScheduleDate, entity.getStartScheduleDate(), entity.getEndScheduleDate()); |
| 106 | 109 | } else if (Objects.nonNull(entity.getStartScheduleDate())) { |
| ... | ... | @@ -111,6 +114,10 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 111 | 114 | } |
| 112 | 115 | |
| 113 | 116 | private static void switchTypes(LinggangKeyWorkLocation entity, LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper) { |
| 117 | + if(Objects.isNull(entity) || Objects.isNull(wrapper)){ | |
| 118 | + return; | |
| 119 | + } | |
| 120 | + | |
| 114 | 121 | if (CollectionUtils.isNotEmpty(entity.getTypes())) { |
| 115 | 122 | wrapper.in(LinggangKeyWorkLocation::getType, entity.getTypes()); |
| 116 | 123 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/sign/in/resource/LinggangSignInResourceServiceImpl.java
| ... | ... | @@ -130,7 +130,8 @@ public class LinggangSignInResourceServiceImpl extends ServiceImpl<LinggangSignI |
| 130 | 130 | builder.append(en.getSignId()); |
| 131 | 131 | builder.append(File.separator); |
| 132 | 132 | builder.append(UUID.randomUUID().toString().replace("-", "")); |
| 133 | - builder.append(".jpg"); | |
| 133 | + builder.append("."); | |
| 134 | + builder.append(en.getPicType()); | |
| 134 | 135 | |
| 135 | 136 | en.setPath(builder.toString()); |
| 136 | 137 | en.setResourceType(1); |
| ... | ... | @@ -141,7 +142,7 @@ public class LinggangSignInResourceServiceImpl extends ServiceImpl<LinggangSignI |
| 141 | 142 | boolean flag = saveBatch(entities); |
| 142 | 143 | if (flag) { |
| 143 | 144 | entities.stream().forEach(en -> { |
| 144 | - ResponseResult<Boolean> result = uploadUtil.uploadImageOfBase64(en.getContent(), en.getPath(), "jpg"); | |
| 145 | + ResponseResult<Boolean> result = uploadUtil.uploadImageOfBase64(en.getContent(), en.getPath(), en.getPicType()); | |
| 145 | 146 | if (!result.isSuccess() && Objects.equals(result.getData(), Boolean.FALSE)) { |
| 146 | 147 | throw new InterruptException("图片上传失败,请检查服务器"); |
| 147 | 148 | } | ... | ... |
Bsth-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java
| ... | ... | @@ -86,7 +86,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { |
| 86 | 86 | return MDC.get(REQUEST_ID_KEY); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - private static String getRandomValue() { | |
| 89 | + public static String getRandomValue() { | |
| 90 | 90 | return UUID.randomUUID().toString().replaceAll("-", ""); |
| 91 | 91 | } |
| 92 | 92 | } | ... | ... |