Commit fa9ea695c9d05899b4266eb8045153c2a9adccfa
1 parent
f7196ca4
对接文件系统和蓝斯设备日志上传
Showing
31 changed files
with
239 additions
and
273 deletions
Bsth-admin/pom.xml
Bsth-admin/src/main/java/com/ruoyi/controller/RefreshController.java
| ... | ... | @@ -275,7 +275,7 @@ public class RefreshController { |
| 275 | 275 | |
| 276 | 276 | @GetMapping(value = "/jar/class/path") |
| 277 | 277 | public ResponseResult<String> getJarClassPath() { |
| 278 | - String path = StringUtils.join(System.getProperty("user.dir"), File.separator, "images"); | |
| 278 | + String path = StringUtils.join(System.getProperty("user.dir"), "/images"); | |
| 279 | 279 | |
| 280 | 280 | ResponseResult<String> responseResult = ResponseResult.success(); |
| 281 | 281 | responseResult.setData(path); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/controller/dss/LansiAppLogController.java deleted
100644 → 0
| 1 | -package com.ruoyi.controller.dss; | |
| 2 | - | |
| 3 | -import com.ruoyi.common.core.controller.BaseController; | |
| 4 | -import com.ruoyi.common.core.domain.ResponseResult; | |
| 5 | -import com.ruoyi.domain.dss2.log.EquipmengLogDTO; | |
| 6 | -import com.ruoyi.equipment.domain.Equipment; | |
| 7 | -import com.ruoyi.equipment.service.IEquipmentService; | |
| 8 | -import io.swagger.annotations.Api; | |
| 9 | -import io.swagger.annotations.ApiOperation; | |
| 10 | -import lombok.extern.slf4j.Slf4j; | |
| 11 | -import org.apache.commons.collections4.CollectionUtils; | |
| 12 | -import org.apache.commons.lang3.StringUtils; | |
| 13 | -import org.slf4j.Logger; | |
| 14 | -import org.slf4j.LoggerFactory; | |
| 15 | -import org.springframework.web.bind.annotation.PostMapping; | |
| 16 | -import org.springframework.web.bind.annotation.RequestBody; | |
| 17 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | -import org.springframework.web.bind.annotation.RestController; | |
| 19 | - | |
| 20 | -import java.util.HashMap; | |
| 21 | -import java.util.List; | |
| 22 | -import java.util.Map; | |
| 23 | -import java.util.Objects; | |
| 24 | - | |
| 25 | -@RestController | |
| 26 | -@Slf4j | |
| 27 | -@RequestMapping("/dss") | |
| 28 | -@Api(tags = "【蓝斯二期】蓝斯设备日志") | |
| 29 | -public class LansiAppLogController extends BaseController { | |
| 30 | - | |
| 31 | - private final static Map<String, Logger> LOGGER_MAP = new HashMap<>(); | |
| 32 | - | |
| 33 | - public LansiAppLogController(IEquipmentService equipmentService) { | |
| 34 | - List<Equipment> equipmentList = equipmentService.list(); | |
| 35 | - int size = CollectionUtils.size(equipmentList); | |
| 36 | - for (int i = 0; i < size; i++) { | |
| 37 | - String name = StringUtils.join("lansi:", equipmentList.get(i).getDeviceId()); | |
| 38 | - LOGGER_MAP.put(equipmentList.get(i).getDeviceId(), LoggerFactory.getLogger(name)); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - | |
| 42 | - @ApiOperation(value = "设备日志") | |
| 43 | - @PostMapping("/equipment/log") | |
| 44 | - public ResponseResult<Boolean> createLog(@RequestBody EquipmengLogDTO equipmengLogDTO) { | |
| 45 | - | |
| 46 | - Logger logger = LOGGER_MAP.get(equipmengLogDTO.getDevice()); | |
| 47 | - if (Objects.isNull(logger)) { | |
| 48 | - String name = StringUtils.join("lansi:", equipmengLogDTO.getDevice()); | |
| 49 | - logger = LoggerFactory.getLogger(name); | |
| 50 | - LOGGER_MAP.put(equipmengLogDTO.getDevice(), logger); | |
| 51 | - | |
| 52 | - } | |
| 53 | - logger.info("[{}]", equipmengLogDTO); | |
| 54 | - return ResponseResult.success(Boolean.TRUE); | |
| 55 | - } | |
| 56 | -} |
Bsth-admin/src/main/java/com/ruoyi/controller/dss2/DssLogController.java
0 → 100644
| 1 | +package com.ruoyi.controller.dss2; | |
| 2 | + | |
| 3 | +import com.ruoyi.common.TipEnum; | |
| 4 | +import com.ruoyi.common.core.domain.AjaxResult; | |
| 5 | +import com.ruoyi.common.core.domain.ResponseResult; | |
| 6 | +import com.ruoyi.common.utils.file.MinioConfig; | |
| 7 | +import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; | |
| 8 | +import com.ruoyi.utils.DateUtil; | |
| 9 | +import io.swagger.annotations.Api; | |
| 10 | +import io.swagger.annotations.ApiOperation; | |
| 11 | +import lombok.extern.slf4j.Slf4j; | |
| 12 | +import org.apache.commons.lang3.StringUtils; | |
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | +import org.springframework.boot.autoconfigure.info.ProjectInfoProperties; | |
| 15 | +import org.springframework.web.bind.annotation.PathVariable; | |
| 16 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | +import org.springframework.web.bind.annotation.RestController; | |
| 19 | +import org.springframework.web.multipart.MultipartFile; | |
| 20 | + | |
| 21 | +@Slf4j | |
| 22 | +@RestController | |
| 23 | +@RequestMapping("/dss/log") | |
| 24 | +@Api(tags = "【蓝斯二期】日志信息") | |
| 25 | +public class DssLogController { | |
| 26 | + @Autowired | |
| 27 | + private MinioConfig minioConfig; | |
| 28 | + | |
| 29 | + @PostMapping("/upload/{device}") | |
| 30 | + @ApiOperation("客户端日志文件上传") | |
| 31 | + public ResponseResult<Boolean> uploadImage(MultipartFile file, @PathVariable("device") String device) { | |
| 32 | + String msg = JwtAuthenticationTokenFilter.validateDevice(device); | |
| 33 | + if (StringUtils.isNotEmpty(msg)) { | |
| 34 | + log.info(msg); | |
| 35 | + return ResponseResult.error(TipEnum.TIP_401.getCode(), TipEnum.TIP_401.getMsg()); | |
| 36 | + } | |
| 37 | + | |
| 38 | + try { | |
| 39 | + String fileName = StringUtils.join("logs/", DateUtil.shortNowStr(), "/", device, "/", file.getOriginalFilename()); | |
| 40 | + boolean flag = minioConfig.upload(file, fileName); | |
| 41 | + return flag?ResponseResult.success(Boolean.TRUE):ResponseResult.error("上传日志文件失败"); | |
| 42 | + } catch (Exception e) { | |
| 43 | + log.error("客户端日志文件上传异常:[{}]", device, e); | |
| 44 | + } | |
| 45 | + | |
| 46 | + | |
| 47 | + return ResponseResult.error("上传日志文件失败"); | |
| 48 | + } | |
| 49 | + | |
| 50 | +} | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| ... | ... | @@ -22,6 +22,7 @@ import com.ruoyi.common.utils.DateUtils; |
| 22 | 22 | import com.ruoyi.common.utils.file.FileUploadUtils; |
| 23 | 23 | import com.ruoyi.common.utils.file.FileUtils; |
| 24 | 24 | import com.ruoyi.common.utils.file.MimeTypeUtils; |
| 25 | +import com.ruoyi.common.utils.file.MinioConfig; | |
| 25 | 26 | import com.ruoyi.domain.DriverScheduling; |
| 26 | 27 | import com.ruoyi.domain.EquipmentDriverExpand; |
| 27 | 28 | import com.ruoyi.driver.domain.Driver; |
| ... | ... | @@ -136,6 +137,8 @@ public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> impleme |
| 136 | 137 | |
| 137 | 138 | @Autowired |
| 138 | 139 | private RuleAttendanceMainService attendanceMainService; |
| 140 | + @Autowired | |
| 141 | + private MinioConfig minioConfig; | |
| 139 | 142 | |
| 140 | 143 | /** |
| 141 | 144 | * 查询驾驶员信息 |
| ... | ... | @@ -408,13 +411,12 @@ public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> impleme |
| 408 | 411 | } else { |
| 409 | 412 | fileName = StringUtils.join("head/", RandomUtils.nextInt(1, 90000), "/", fileName); |
| 410 | 413 | } |
| 411 | - String urlFileName = fileName; | |
| 412 | - String absPath = FileUploadUtils.getAbsoluteFile(baseUrl, fileName).getAbsolutePath(); | |
| 413 | - fileName = FileUploadUtils.getPathFileName(baseUrl, fileName); | |
| 414 | - file.transferTo(Paths.get(absPath)); | |
| 414 | + | |
| 415 | + minioConfig.upload(file, fileName); | |
| 416 | + | |
| 415 | 417 | |
| 416 | 418 | SysDictData source = sysDictDataService.getResourceBaseUrl(); |
| 417 | - String url = sysDictDataService.combationValue(urlFileName, source); | |
| 419 | + String url = sysDictDataService.combationValue(fileName, source); | |
| 418 | 420 | |
| 419 | 421 | AjaxResult ajax = AjaxResult.success(); |
| 420 | 422 | ajax.put("url", url); |
| ... | ... | @@ -650,7 +652,7 @@ public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> impleme |
| 650 | 652 | driver.setPosts(vo.getPosts()); |
| 651 | 653 | String base64 = vo.getImage(); |
| 652 | 654 | String fileName = vo.getJobCode() + ".png"; |
| 653 | - String filePath = new File(RuoYiConfig.getUploadPath() + headImagePre + "/" + fileName + File.separator).getAbsolutePath(); | |
| 655 | + String filePath = new File(RuoYiConfig.getUploadPath() + headImagePre + "/" + fileName + "/").getAbsolutePath(); | |
| 654 | 656 | try { |
| 655 | 657 | fileName = FileUploadUtils.getPathFileName(RuoYiConfig.getUploadPath() + headImagePre, fileName); |
| 656 | 658 | } catch (IOException e) { |
| ... | ... | @@ -817,7 +819,7 @@ public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> impleme |
| 817 | 819 | private File getLocationFile(String jobCode) { |
| 818 | 820 | String image = driverMapper.getDriverImageByJobCode(jobCode); |
| 819 | 821 | |
| 820 | - return new File(RuoYiConfig.getProfile() + File.separator + image.replace("/profile", "")); | |
| 822 | + return new File(RuoYiConfig.getProfile() + "/" + image.replace("/profile", "")); | |
| 821 | 823 | } |
| 822 | 824 | |
| 823 | 825 | private String calimageContentFaceFeature(String imagePath) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
| ... | ... | @@ -819,7 +819,7 @@ public class SignInServiceImpl extends ServiceImpl<SignInMapper, SignIn> impleme |
| 819 | 819 | * @throws IOException |
| 820 | 820 | */ |
| 821 | 821 | public File getAbsoluteFile(String uploadDir, String fileName) throws IOException { |
| 822 | - File desc = new File(uploadDir + File.separator + fileName); | |
| 822 | + File desc = new File(uploadDir + "/" + fileName); | |
| 823 | 823 | |
| 824 | 824 | if (!desc.exists()) { |
| 825 | 825 | if (!desc.getParentFile().exists()) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceV1Impl.java
| ... | ... | @@ -42,6 +42,7 @@ import com.ruoyi.service.ThreadJobService; |
| 42 | 42 | import com.ruoyi.service.sign.in.exception.report.EquipmentExceptionReportService; |
| 43 | 43 | import com.ruoyi.service.sign.in.resource.LinggangSignInResourceService; |
| 44 | 44 | import com.ruoyi.utils.ConstDateUtil; |
| 45 | +import com.ruoyi.utils.DateUtil; | |
| 45 | 46 | import com.ruoyi.utils.UploadUtil; |
| 46 | 47 | import lombok.extern.slf4j.Slf4j; |
| 47 | 48 | import org.apache.commons.collections4.CollectionUtils; |
| ... | ... | @@ -277,14 +278,12 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 277 | 278 | } |
| 278 | 279 | if (org.apache.commons.lang3.StringUtils.isNotEmpty(videoContent) && Objects.equals(signIn.getResourceType(), 2)) { |
| 279 | 280 | StringBuilder builder = new StringBuilder(); |
| 280 | - builder.append("sign"); | |
| 281 | - builder.append(File.separator); | |
| 282 | - builder.append("images"); | |
| 283 | - builder.append(File.separator); | |
| 284 | - builder.append("offline"); | |
| 285 | - builder.append(File.separator); | |
| 281 | + builder.append("sign/video/offline/"); | |
| 282 | + builder.append(DateUtil.shortNowStr()); | |
| 283 | + builder.append("/"); | |
| 284 | + builder.append("/"); | |
| 286 | 285 | builder.append(signIn.getId()); |
| 287 | - builder.append(File.separator); | |
| 286 | + builder.append("/"); | |
| 288 | 287 | builder.append(java.util.UUID.randomUUID().toString().replace("-", "")); |
| 289 | 288 | builder.append(".mp4"); |
| 290 | 289 | |
| ... | ... | @@ -301,18 +300,15 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 301 | 300 | signInResourceService.save(signInResource); |
| 302 | 301 | } else if (org.apache.commons.lang3.StringUtils.isNotEmpty(videoContent)) { |
| 303 | 302 | StringBuilder builder = new StringBuilder(); |
| 304 | - builder.append("sign"); | |
| 305 | - builder.append(File.separator); | |
| 306 | - builder.append("images"); | |
| 307 | - builder.append(File.separator); | |
| 308 | - builder.append("offline"); | |
| 309 | - builder.append(File.separator); | |
| 303 | + builder.append("sign/images/offline/"); | |
| 304 | + builder.append(DateUtil.shortNowStr()); | |
| 305 | + builder.append("/"); | |
| 310 | 306 | builder.append(signIn.getId()); |
| 311 | - builder.append(File.separator); | |
| 307 | + builder.append("/"); | |
| 312 | 308 | builder.append(java.util.UUID.randomUUID().toString().replace("-", "")); |
| 313 | 309 | builder.append(".jpg"); |
| 314 | 310 | |
| 315 | - uploadUtil.uploadVideoOfBase64(videoContent, builder.toString()); | |
| 311 | + uploadUtil.uploadImageOfBase64(videoContent, builder.toString(),"jpg"); | |
| 316 | 312 | |
| 317 | 313 | LinggangSignInResource signInResource = new LinggangSignInResource(); |
| 318 | 314 | signInResource.setSignId(signIn.getId()); |
| ... | ... | @@ -626,7 +622,7 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 626 | 622 | * @throws IOException |
| 627 | 623 | */ |
| 628 | 624 | private File getAbsoluteFile(String uploadDir, String fileName) throws IOException { |
| 629 | - File desc = new File(uploadDir + File.separator + fileName); | |
| 625 | + File desc = new File(uploadDir + "/" + fileName); | |
| 630 | 626 | |
| 631 | 627 | if (!desc.exists()) { |
| 632 | 628 | if (!desc.getParentFile().exists()) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/pojo/converter/common/ImageConverter.java
| ... | ... | @@ -37,7 +37,7 @@ public class ImageConverter implements Converter<String> { |
| 37 | 37 | GlobalConfiguration globalConfiguration) throws IOException { |
| 38 | 38 | String path = RuoYiConfig.getProfile() + value.replace("/profile", ""); |
| 39 | 39 | System.out.println(path); |
| 40 | - File file = new File(path + File.separator); | |
| 40 | + File file = new File(path + "/"); | |
| 41 | 41 | if (file.exists()) { |
| 42 | 42 | if (file.isDirectory() || !file.canRead()) { |
| 43 | 43 | return new CellData("没有图片"); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/ReportService.java
| ... | ... | @@ -13,22 +13,27 @@ import com.ruoyi.common.global.ResultCode; |
| 13 | 13 | import com.ruoyi.common.utils.SecurityUtils; |
| 14 | 14 | import com.ruoyi.common.utils.poi.ExcelUtil; |
| 15 | 15 | import com.ruoyi.domain.DriverScheduling; |
| 16 | +import com.ruoyi.domain.scheduling.LinggangScheduling; | |
| 16 | 17 | import com.ruoyi.driver.domain.Driver; |
| 17 | 18 | import com.ruoyi.driver.mapper.DriverMapper; |
| 18 | 19 | import com.ruoyi.driver.mapper.DriverSchedulingMapper; |
| 19 | 20 | import com.ruoyi.eexception.mapper.EquipmentExceptionMapper; |
| 20 | 21 | import com.ruoyi.in.domain.SignIn; |
| 21 | 22 | import com.ruoyi.in.mapper.SignInMapper; |
| 23 | +import com.ruoyi.in.service.ISignInService; | |
| 22 | 24 | import com.ruoyi.pojo.request.ReportErrorRequestVo; |
| 23 | 25 | import com.ruoyi.pojo.request.ReportViewRequestVo; |
| 24 | 26 | import com.ruoyi.pojo.response.*; |
| 25 | 27 | import com.ruoyi.pojo.vo.PersonSignDataResponseVo; |
| 28 | +import com.ruoyi.service.scheduling.LinggangSchedulingService; | |
| 26 | 29 | import com.ruoyi.system.domain.SysNotice; |
| 30 | +import com.ruoyi.system.service.ISysDictDataService; | |
| 27 | 31 | import com.ruoyi.system.service.ISysNoticeService; |
| 28 | 32 | import com.ruoyi.utils.ConstDateUtil; |
| 29 | 33 | import com.ruoyi.utils.DateUtil; |
| 30 | 34 | import com.ruoyi.utils.ToolUtils; |
| 31 | 35 | import lombok.extern.slf4j.Slf4j; |
| 36 | +import org.apache.commons.collections4.CollectionUtils; | |
| 32 | 37 | import org.apache.commons.lang3.time.DateUtils; |
| 33 | 38 | import org.springframework.beans.BeanUtils; |
| 34 | 39 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -89,6 +94,10 @@ public class ReportService { |
| 89 | 94 | private RedisCache redisCache; |
| 90 | 95 | @Autowired |
| 91 | 96 | private NowSchedulingCache nowSchedulingCache; |
| 97 | + @Autowired | |
| 98 | + private ISignInService signInService; | |
| 99 | + @Autowired | |
| 100 | + private ISysDictDataService sysDictDataService; | |
| 92 | 101 | |
| 93 | 102 | /** |
| 94 | 103 | * 查询报表信息 |
| ... | ... | @@ -100,6 +109,15 @@ public class ReportService { |
| 100 | 109 | |
| 101 | 110 | public List<ReportErrorResponseVo> getErrorReportList(ReportErrorRequestVo request) { |
| 102 | 111 | List<EquipmentExceptionResponseVo> list = exceptionMapper.selectEquipmentExceptionListByVo(request); |
| 112 | + Set<Long> signIds = list.stream().map(EquipmentExceptionResponseVo::getSignId).collect(Collectors.toSet()); | |
| 113 | + List<SignIn> signInList = null; | |
| 114 | + | |
| 115 | + if (CollectionUtils.isNotEmpty(signIds)) { | |
| 116 | + signInList = signInService.listByIds(signIds); | |
| 117 | + } | |
| 118 | + int size = CollectionUtils.size(signInList); | |
| 119 | + List<SignIn> signInList1 = signInList; | |
| 120 | + | |
| 103 | 121 | return list.stream().map(item -> { |
| 104 | 122 | ReportErrorResponseVo vo = new ReportErrorResponseVo(); |
| 105 | 123 | vo.setRemark(item.getRemark()); |
| ... | ... | @@ -114,6 +132,12 @@ public class ReportService { |
| 114 | 132 | vo.setFleetName(item.getFleetName()); |
| 115 | 133 | vo.setLineName(item.getLineName()); |
| 116 | 134 | vo.setPlanTime(item.getPlanTime()); |
| 135 | + | |
| 136 | + if (size > 0) { | |
| 137 | + Optional<SignIn> optional = signInList1.stream().filter(ls -> Objects.equals(ls.getId(), item.getSignId())).findFirst(); | |
| 138 | + optional.ifPresent(signIn -> vo.setImage(sysDictDataService.combationValue(signIn.getImage()))); | |
| 139 | + } | |
| 140 | + | |
| 117 | 141 | return vo; |
| 118 | 142 | }).collect(Collectors.toList()); |
| 119 | 143 | } |
| ... | ... | @@ -269,11 +293,11 @@ public class ReportService { |
| 269 | 293 | private List<ExportReportViewResponseVo> getDayReportTableResponseVo(String date) { |
| 270 | 294 | String endDateStr = null; |
| 271 | 295 | try { |
| 272 | - endDateStr = DateUtil.YYYY_MM_DD_LINK.format(DateUtils.addDays(DateUtil.YYYY_MM_DD_LINK.parse(date),1)); | |
| 296 | + endDateStr = DateUtil.YYYY_MM_DD_LINK.format(DateUtils.addDays(DateUtil.YYYY_MM_DD_LINK.parse(date), 1)); | |
| 273 | 297 | } catch (ParseException e) { |
| 274 | 298 | throw new RuntimeException(e); |
| 275 | 299 | } |
| 276 | - List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date,endDateStr, null, null, null); | |
| 300 | + List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, endDateStr, null, null, null); | |
| 277 | 301 | Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800); |
| 278 | 302 | List<ExportReportViewResponseVo> signVo = new ArrayList<>(800); |
| 279 | 303 | handlerResultMap(date, resultMap, schedulingList); |
| ... | ... | @@ -368,11 +392,11 @@ public class ReportService { |
| 368 | 392 | List<ReportDetailResponseVo> responseVos = new ArrayList<>(); |
| 369 | 393 | String endDateStr = null; |
| 370 | 394 | try { |
| 371 | - endDateStr = DateUtil.YYYY_MM_DD_LINK.format(DateUtils.addDays(DateUtil.YYYY_MM_DD_LINK.parse(vo.getDate()),1)); | |
| 395 | + endDateStr = DateUtil.YYYY_MM_DD_LINK.format(DateUtils.addDays(DateUtil.YYYY_MM_DD_LINK.parse(vo.getDate()), 1)); | |
| 372 | 396 | } catch (ParseException e) { |
| 373 | 397 | throw new RuntimeException(e); |
| 374 | 398 | } |
| 375 | - List<DriverScheduling> toDay = schedulingMapper.queryToDay(vo.getDate(),endDateStr, vo.getName(), vo.getJobCode(), vo.getLineName()); | |
| 399 | + List<DriverScheduling> toDay = schedulingMapper.queryToDay(vo.getDate(), endDateStr, vo.getName(), vo.getJobCode(), vo.getLineName()); | |
| 376 | 400 | for (DriverScheduling scheduling : toDay) { |
| 377 | 401 | ToolUtils.updateReport(scheduling); |
| 378 | 402 | ReportDetailResponseVo reportDetailResponseVo = new ReportDetailResponseVo(); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| ... | ... | @@ -539,7 +539,7 @@ public class ThreadJobService { |
| 539 | 539 | if (Objects.isNull(is)) { |
| 540 | 540 | throw new IOException("图片数据不存在"); |
| 541 | 541 | } |
| 542 | - File file = new File(filePath + File.separator); | |
| 542 | + File file = new File(filePath + "/"); | |
| 543 | 543 | log.info("文件路径:{}", file.getPath()); |
| 544 | 544 | if (!file.exists()) { |
| 545 | 545 | if (!file.getParentFile().exists()) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/driver/NewDriverServiceImpl.java
| ... | ... | @@ -20,6 +20,7 @@ import com.ruoyi.domain.OrderEntity; |
| 20 | 20 | import com.ruoyi.domain.driver.NewDriver; |
| 21 | 21 | import com.ruoyi.mapper.driver.NewDriverMapper; |
| 22 | 22 | import com.ruoyi.service.driver.NewDriverService; |
| 23 | +import com.ruoyi.utils.DateUtil; | |
| 23 | 24 | import com.ruoyi.utils.UploadUtil; |
| 24 | 25 | import lombok.extern.slf4j.Slf4j; |
| 25 | 26 | import org.apache.commons.collections4.CollectionUtils; |
| ... | ... | @@ -341,7 +342,7 @@ public class NewDriverServiceImpl extends ServiceImpl<NewDriverMapper, NewDriver |
| 341 | 342 | String photo = Convert.toStr(obj.get("photo")); |
| 342 | 343 | if (StringUtils.isNotEmpty(photo)) { |
| 343 | 344 | StringBuilder builder = new StringBuilder(); |
| 344 | - builder.append(obj.get("personID")); | |
| 345 | + builder.append("head"); | |
| 345 | 346 | builder.append("/image/"); |
| 346 | 347 | builder.append(UUID.randomUUID().toString().replaceAll("-", "")); |
| 347 | 348 | builder.append(".png"); |
| ... | ... | @@ -409,20 +410,20 @@ public class NewDriverServiceImpl extends ServiceImpl<NewDriverMapper, NewDriver |
| 409 | 410 | return TipEnum.TIP_404; |
| 410 | 411 | } |
| 411 | 412 | LambdaUpdateWrapper<NewDriver> wrapper = new LambdaUpdateWrapper<NewDriver>(); |
| 412 | - StringBuilder builder = new StringBuilder(bsthSystemConfig.getImageBasePath()); | |
| 413 | - builder.append(File.separator); | |
| 413 | + StringBuilder builder = new StringBuilder(); | |
| 414 | + builder.append("head/face/"); | |
| 415 | + builder.append(DateUtil.shortNowStr()); | |
| 416 | + builder.append("/"); | |
| 414 | 417 | builder.append(source.getId()); |
| 415 | - builder.append(File.separator); | |
| 416 | - builder.append("image"); | |
| 418 | + builder.append("/image/"); | |
| 419 | + builder.append(UUID.randomUUID().toString().replaceAll("-", "")+".png"); | |
| 417 | 420 | |
| 418 | - ResponseResult<String> resultObj = FileUploadUtils.uploadBase64OfImage(builder.toString(), UUID.randomUUID().toString(). | |
| 419 | - replaceAll("-", ""), "png", entity.getImage()); | |
| 421 | + ResponseResult<String> resultObj = FileUploadUtils.uploadBase64OfImage(builder.toString(), "png", entity.getImage()); | |
| 420 | 422 | if (!resultObj.isSuccess()) { |
| 421 | 423 | return TipEnum.getObjByCode(resultObj.getCode()); |
| 422 | 424 | } |
| 423 | 425 | |
| 424 | - String result = StringUtils.substringAfter(resultObj.getData(), bsthSystemConfig.getImageBasePath() + File.separator); | |
| 425 | - entity.setImage(result); | |
| 426 | + entity.setImage(builder.toString()); | |
| 426 | 427 | |
| 427 | 428 | float imageVersion = 0.01f; |
| 428 | 429 | try { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/dss/FaceServiceImpl.java
| ... | ... | @@ -174,7 +174,7 @@ public class FaceServiceImpl implements FaceService { |
| 174 | 174 | } |
| 175 | 175 | StringBuilder builder = new StringBuilder(); |
| 176 | 176 | builder.append(bsthSystemConfig.getImageBasePath()); |
| 177 | - builder.append(File.separator); | |
| 177 | + builder.append("/"); | |
| 178 | 178 | builder.append(dr.getImage()); |
| 179 | 179 | |
| 180 | 180 | File targetFile = new File(builder.toString()); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/sign/in/resource/LinggangSignInResourceServiceImpl.java
| ... | ... | @@ -15,10 +15,12 @@ import com.ruoyi.in.service.ISignInService; |
| 15 | 15 | import com.ruoyi.in.service.SignInServiceV1; |
| 16 | 16 | import com.ruoyi.mapper.sign.in.resource.LinggangSignInResourceMapper; |
| 17 | 17 | import com.ruoyi.service.sign.in.resource.LinggangSignInResourceService; |
| 18 | +import com.ruoyi.utils.DateUtil; | |
| 18 | 19 | import com.ruoyi.utils.SpringApplicationUtil; |
| 19 | 20 | import com.ruoyi.utils.UploadUtil; |
| 20 | 21 | import lombok.extern.slf4j.Slf4j; |
| 21 | 22 | import org.apache.commons.collections4.CollectionUtils; |
| 23 | +import org.apache.commons.lang3.time.DateUtils; | |
| 22 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | 25 | import org.springframework.stereotype.Service; |
| 24 | 26 | import org.springframework.transaction.annotation.Transactional; |
| ... | ... | @@ -140,6 +142,8 @@ public class LinggangSignInResourceServiceImpl extends ServiceImpl<LinggangSignI |
| 140 | 142 | builder.append("/"); |
| 141 | 143 | builder.append(en.getDevice()); |
| 142 | 144 | builder.append("/"); |
| 145 | + builder.append(DateUtil.shortNowStr()); | |
| 146 | + builder.append("/"); | |
| 143 | 147 | builder.append(en.getSignId()); |
| 144 | 148 | builder.append("/"); |
| 145 | 149 | builder.append(UUID.randomUUID().toString().replace("-", "")); |
| ... | ... | @@ -177,13 +181,15 @@ public class LinggangSignInResourceServiceImpl extends ServiceImpl<LinggangSignI |
| 177 | 181 | public boolean insertVoide(LinggangSignInResource entity) { |
| 178 | 182 | StringBuilder builder = new StringBuilder(); |
| 179 | 183 | builder.append("sign"); |
| 180 | - builder.append(File.separator); | |
| 184 | + builder.append("/"); | |
| 181 | 185 | builder.append("video"); |
| 182 | - builder.append(File.separator); | |
| 186 | + builder.append("/"); | |
| 183 | 187 | builder.append(entity.getDevice()); |
| 184 | - builder.append(File.separator); | |
| 188 | + builder.append("/"); | |
| 189 | + builder.append(DateUtil.shortNowStr()); | |
| 190 | + builder.append("/"); | |
| 185 | 191 | builder.append(entity.getSignId()); |
| 186 | - builder.append(File.separator); | |
| 192 | + builder.append("/"); | |
| 187 | 193 | builder.append(UUID.randomUUID().toString().replace("-", "")); |
| 188 | 194 | builder.append(".mp4"); |
| 189 | 195 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/utils/DateUtil.java
Bsth-admin/src/main/java/com/ruoyi/utils/UploadUtil.java
| ... | ... | @@ -4,18 +4,14 @@ import cn.hutool.core.codec.Base64; |
| 4 | 4 | import com.ruoyi.common.core.domain.ResponseResult; |
| 5 | 5 | import com.ruoyi.common.utils.StringUtils; |
| 6 | 6 | import com.ruoyi.common.utils.file.FileUploadUtils; |
| 7 | +import com.ruoyi.common.utils.file.MinioConfig; | |
| 7 | 8 | import com.ruoyi.config.BsthSystemConfig; |
| 8 | -import com.ruoyi.config.MinioConfig; | |
| 9 | 9 | import lombok.extern.slf4j.Slf4j; |
| 10 | -import org.apache.commons.io.FileUtils; | |
| 11 | 10 | import org.apache.commons.io.IOUtils; |
| 12 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | 12 | import org.springframework.stereotype.Component; |
| 14 | 13 | |
| 15 | -import javax.imageio.ImageIO; | |
| 16 | -import java.awt.image.BufferedImage; | |
| 17 | 14 | import java.io.ByteArrayInputStream; |
| 18 | -import java.io.File; | |
| 19 | 15 | import java.io.FileOutputStream; |
| 20 | 16 | import java.util.Objects; |
| 21 | 17 | |
| ... | ... | @@ -48,13 +44,12 @@ public class UploadUtil { |
| 48 | 44 | } |
| 49 | 45 | |
| 50 | 46 | ByteArrayInputStream inputStream = null; |
| 51 | - BufferedImage bufferedImage = null; | |
| 52 | 47 | try { |
| 53 | 48 | content = FileUploadUtils.choosePrictureContent(content); |
| 54 | 49 | byte[] bytes = Base64.decode(content); |
| 55 | 50 | inputStream = new ByteArrayInputStream(bytes); |
| 56 | 51 | |
| 57 | - minioConfig.upload(inputStream,path,"application/png"); | |
| 52 | + minioConfig.upload(inputStream, path, "application/" + type); | |
| 58 | 53 | |
| 59 | 54 | return ResponseResult.success(Boolean.TRUE); |
| 60 | 55 | } catch (Exception e) { |
| ... | ... | @@ -82,22 +77,13 @@ public class UploadUtil { |
| 82 | 77 | } |
| 83 | 78 | |
| 84 | 79 | FileOutputStream outputStream = null; |
| 80 | + ByteArrayInputStream inputStream = null; | |
| 85 | 81 | try { |
| 86 | 82 | content = FileUploadUtils.choosePrictureContent(content); |
| 87 | 83 | byte[] bytes = Base64.decode(content); |
| 84 | + inputStream = new ByteArrayInputStream(bytes); | |
| 88 | 85 | |
| 89 | - StringBuilder filePath = new StringBuilder(); | |
| 90 | - filePath.append(bsthSystemConfig.getImageBasePath()); | |
| 91 | - filePath.append(File.separator); | |
| 92 | - filePath.append(path); | |
| 93 | - | |
| 94 | - File file = new File(filePath.toString()); | |
| 95 | - if(!file.exists() || !file.isDirectory()){ | |
| 96 | - FileUtils.forceMkdirParent(file); | |
| 97 | - } | |
| 98 | - outputStream = new FileOutputStream(file); | |
| 99 | - outputStream.write(bytes, 0, bytes.length); | |
| 100 | - outputStream.flush(); | |
| 86 | + minioConfig.upload(inputStream, path, "application/mp4"); | |
| 101 | 87 | |
| 102 | 88 | return ResponseResult.success(Boolean.TRUE); |
| 103 | 89 | } catch (Exception e) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
| ... | ... | @@ -26,13 +26,12 @@ import java.util.List; |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * 通用请求处理 |
| 29 | - * | |
| 29 | + * | |
| 30 | 30 | * @author ruoyi |
| 31 | 31 | */ |
| 32 | 32 | @RestController |
| 33 | 33 | @RequestMapping("/common") |
| 34 | -public class CommonController | |
| 35 | -{ | |
| 34 | +public class CommonController { | |
| 36 | 35 | private static final Logger log = LoggerFactory.getLogger(CommonController.class); |
| 37 | 36 | |
| 38 | 37 | @Autowired |
| ... | ... | @@ -46,17 +45,14 @@ public class CommonController |
| 46 | 45 | |
| 47 | 46 | /** |
| 48 | 47 | * 通用下载请求 |
| 49 | - * | |
| 48 | + * | |
| 50 | 49 | * @param fileName 文件名称 |
| 51 | - * @param delete 是否删除 | |
| 50 | + * @param delete 是否删除 | |
| 52 | 51 | */ |
| 53 | 52 | @GetMapping("/download") |
| 54 | - public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) | |
| 55 | - { | |
| 56 | - try | |
| 57 | - { | |
| 58 | - if (!FileUtils.checkAllowDownload(fileName)) | |
| 59 | - { | |
| 53 | + public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { | |
| 54 | + try { | |
| 55 | + if (!FileUtils.checkAllowDownload(fileName)) { | |
| 60 | 56 | throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); |
| 61 | 57 | } |
| 62 | 58 | String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
| ... | ... | @@ -65,13 +61,10 @@ public class CommonController |
| 65 | 61 | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| 66 | 62 | FileUtils.setAttachmentResponseHeader(response, realFileName); |
| 67 | 63 | FileUtils.writeBytes(filePath, response.getOutputStream()); |
| 68 | - if (delete) | |
| 69 | - { | |
| 64 | + if (delete) { | |
| 70 | 65 | FileUtils.deleteFile(filePath); |
| 71 | 66 | } |
| 72 | - } | |
| 73 | - catch (Exception e) | |
| 74 | - { | |
| 67 | + } catch (Exception e) { | |
| 75 | 68 | log.error("下载文件失败", e); |
| 76 | 69 | } |
| 77 | 70 | } |
| ... | ... | @@ -80,16 +73,13 @@ public class CommonController |
| 80 | 73 | * 通用上传请求(单个) |
| 81 | 74 | */ |
| 82 | 75 | @PostMapping("/upload") |
| 83 | - public AjaxResult uploadFile(MultipartFile file) throws Exception | |
| 84 | - { | |
| 85 | - try | |
| 86 | - { | |
| 76 | + public AjaxResult uploadFile(MultipartFile file) throws Exception { | |
| 77 | + try { | |
| 87 | 78 | // 上传文件路径 |
| 88 | - String filePath = org.apache.commons.lang3.StringUtils.join(RuoYiConfig.getUploadPath(),"/image"); | |
| 79 | + String filePath = org.apache.commons.lang3.StringUtils.join("usual/image"); | |
| 89 | 80 | |
| 90 | 81 | // 上传并返回新文件名称 |
| 91 | 82 | String fileName = FileUploadUtils.upload(filePath, file); |
| 92 | - fileName = org.apache.commons.lang3.StringUtils.substringAfter(fileName, "upload/image"); | |
| 93 | 83 | String url = getSysDictDataService().combationValue(fileName); |
| 94 | 84 | AjaxResult ajax = AjaxResult.success(); |
| 95 | 85 | |
| ... | ... | @@ -99,15 +89,13 @@ public class CommonController |
| 99 | 89 | ajax.put("newFileName", FileUtils.getName(fileName)); |
| 100 | 90 | ajax.put("originalFilename", file.getOriginalFilename()); |
| 101 | 91 | return ajax; |
| 102 | - } | |
| 103 | - catch (Exception e) | |
| 104 | - { | |
| 92 | + } catch (Exception e) { | |
| 105 | 93 | return AjaxResult.error(e.getMessage()); |
| 106 | 94 | } |
| 107 | 95 | } |
| 108 | 96 | |
| 109 | - public ISysDictDataService getSysDictDataService(){ | |
| 110 | - if(sysDictDataService == null){ | |
| 97 | + public ISysDictDataService getSysDictDataService() { | |
| 98 | + if (sysDictDataService == null) { | |
| 111 | 99 | sysDictDataService = SpringUtils.getBean(ISysDictDataService.class); |
| 112 | 100 | } |
| 113 | 101 | return sysDictDataService; |
| ... | ... | @@ -117,18 +105,15 @@ public class CommonController |
| 117 | 105 | * 通用上传请求(多个) |
| 118 | 106 | */ |
| 119 | 107 | @PostMapping("/uploads") |
| 120 | - public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception | |
| 121 | - { | |
| 122 | - try | |
| 123 | - { | |
| 108 | + public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception { | |
| 109 | + try { | |
| 124 | 110 | // 上传文件路径 |
| 125 | 111 | String filePath = RuoYiConfig.getUploadPath(); |
| 126 | 112 | List<String> urls = new ArrayList<String>(); |
| 127 | 113 | List<String> fileNames = new ArrayList<String>(); |
| 128 | 114 | List<String> newFileNames = new ArrayList<String>(); |
| 129 | 115 | List<String> originalFilenames = new ArrayList<String>(); |
| 130 | - for (MultipartFile file : files) | |
| 131 | - { | |
| 116 | + for (MultipartFile file : files) { | |
| 132 | 117 | // 上传并返回新文件名称 |
| 133 | 118 | String fileName = FileUploadUtils.upload(filePath, file); |
| 134 | 119 | String url = serverConfig.getUrl() + fileName; |
| ... | ... | @@ -143,9 +128,7 @@ public class CommonController |
| 143 | 128 | ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); |
| 144 | 129 | ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); |
| 145 | 130 | return ajax; |
| 146 | - } | |
| 147 | - catch (Exception e) | |
| 148 | - { | |
| 131 | + } catch (Exception e) { | |
| 149 | 132 | return AjaxResult.error(e.getMessage()); |
| 150 | 133 | } |
| 151 | 134 | } |
| ... | ... | @@ -155,12 +138,9 @@ public class CommonController |
| 155 | 138 | */ |
| 156 | 139 | @GetMapping("/download/resource") |
| 157 | 140 | public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) |
| 158 | - throws Exception | |
| 159 | - { | |
| 160 | - try | |
| 161 | - { | |
| 162 | - if (!FileUtils.checkAllowDownload(resource)) | |
| 163 | - { | |
| 141 | + throws Exception { | |
| 142 | + try { | |
| 143 | + if (!FileUtils.checkAllowDownload(resource)) { | |
| 164 | 144 | throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource)); |
| 165 | 145 | } |
| 166 | 146 | // 本地资源路径 |
| ... | ... | @@ -172,9 +152,7 @@ public class CommonController |
| 172 | 152 | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| 173 | 153 | FileUtils.setAttachmentResponseHeader(response, downloadName); |
| 174 | 154 | FileUtils.writeBytes(downloadPath, response.getOutputStream()); |
| 175 | - } | |
| 176 | - catch (Exception e) | |
| 177 | - { | |
| 155 | + } catch (Exception e) { | |
| 178 | 156 | log.error("下载文件失败", e); |
| 179 | 157 | } |
| 180 | 158 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
| ... | ... | @@ -11,6 +11,7 @@ import com.ruoyi.common.utils.ServletUtils; |
| 11 | 11 | import com.ruoyi.framework.web.service.SysLoginService; |
| 12 | 12 | import com.ruoyi.framework.web.service.SysPermissionService; |
| 13 | 13 | import com.ruoyi.framework.web.service.TokenService; |
| 14 | +import com.ruoyi.system.service.ISysDictDataService; | |
| 14 | 15 | import com.ruoyi.system.service.ISysMenuService; |
| 15 | 16 | import io.swagger.annotations.Api; |
| 16 | 17 | import io.swagger.annotations.ApiOperation; |
| ... | ... | @@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody; |
| 21 | 22 | import org.springframework.web.bind.annotation.RestController; |
| 22 | 23 | |
| 23 | 24 | import java.util.List; |
| 25 | +import java.util.Objects; | |
| 24 | 26 | import java.util.Set; |
| 25 | 27 | |
| 26 | 28 | /** |
| ... | ... | @@ -41,6 +43,8 @@ public class SysLoginController { |
| 41 | 43 | private SysPermissionService permissionService; |
| 42 | 44 | @Autowired |
| 43 | 45 | private TokenService tokenService; |
| 46 | + @Autowired | |
| 47 | + private ISysDictDataService sysDictDataService; | |
| 44 | 48 | |
| 45 | 49 | /** |
| 46 | 50 | * 登录方法 |
| ... | ... | @@ -103,6 +107,9 @@ public class SysLoginController { |
| 103 | 107 | public AjaxResult getInfo() { |
| 104 | 108 | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| 105 | 109 | SysUser user = loginUser.getUser(); |
| 110 | + if(Objects.nonNull(user)){ | |
| 111 | + user.setAvatar(sysDictDataService.combationValue(user.getAvatar())); | |
| 112 | + } | |
| 106 | 113 | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| 107 | 114 | // 角色集合 |
| 108 | 115 | Set<String> roles = permissionService.getRolePermission(user); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
| 1 | 1 | package com.ruoyi.web.controller.system; |
| 2 | 2 | |
| 3 | +import com.ruoyi.system.service.ISysDictDataService; | |
| 3 | 4 | import org.springframework.beans.factory.annotation.Autowired; |
| 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; |
| 5 | 6 | import org.springframework.web.bind.annotation.PostMapping; |
| ... | ... | @@ -23,6 +24,8 @@ import com.ruoyi.common.utils.file.MimeTypeUtils; |
| 23 | 24 | import com.ruoyi.framework.web.service.TokenService; |
| 24 | 25 | import com.ruoyi.system.service.ISysUserService; |
| 25 | 26 | |
| 27 | +import java.util.Objects; | |
| 28 | + | |
| 26 | 29 | /** |
| 27 | 30 | * 个人信息 业务处理 |
| 28 | 31 | * |
| ... | ... | @@ -37,6 +40,8 @@ public class SysProfileController extends BaseController |
| 37 | 40 | |
| 38 | 41 | @Autowired |
| 39 | 42 | private TokenService tokenService; |
| 43 | + @Autowired | |
| 44 | + private ISysDictDataService sysDictDataService; | |
| 40 | 45 | |
| 41 | 46 | /** |
| 42 | 47 | * 个人信息 |
| ... | ... | @@ -46,6 +51,9 @@ public class SysProfileController extends BaseController |
| 46 | 51 | { |
| 47 | 52 | LoginUser loginUser = getLoginUser(); |
| 48 | 53 | SysUser user = loginUser.getUser(); |
| 54 | + if(Objects.nonNull(user)){ | |
| 55 | + user.setAvatar(sysDictDataService.combationValue(user.getAvatar())); | |
| 56 | + } | |
| 49 | 57 | AjaxResult ajax = AjaxResult.success(user); |
| 50 | 58 | ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); |
| 51 | 59 | ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername())); |
| ... | ... | @@ -129,7 +137,8 @@ public class SysProfileController extends BaseController |
| 129 | 137 | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| 130 | 138 | { |
| 131 | 139 | AjaxResult ajax = AjaxResult.success(); |
| 132 | - ajax.put("imgUrl", avatar); | |
| 140 | + | |
| 141 | + ajax.put("imgUrl", sysDictDataService.combationValue(avatar)); | |
| 133 | 142 | // 更新缓存用户头像 |
| 134 | 143 | loginUser.getUser().setAvatar(avatar); |
| 135 | 144 | tokenService.setLoginUser(loginUser); | ... | ... |
Bsth-admin/src/main/resources/application-druid-dev.yml
Bsth-admin/src/main/resources/application-druid-devTest.yml
| ... | ... | @@ -89,9 +89,9 @@ spring: |
| 89 | 89 | servlet: |
| 90 | 90 | multipart: |
| 91 | 91 | # 单个文件大小 |
| 92 | - max-file-size: 100MB | |
| 92 | + max-file-size: 500MB | |
| 93 | 93 | # 设置总上传的文件大小 |
| 94 | - max-request-size: 100MB | |
| 94 | + max-request-size: 500MB | |
| 95 | 95 | # 服务模块 |
| 96 | 96 | devtools: |
| 97 | 97 | restart: |
| ... | ... | @@ -137,7 +137,7 @@ ruoyi: |
| 137 | 137 | # 实例演示开关 |
| 138 | 138 | demoEnabled: true |
| 139 | 139 | # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) |
| 140 | - profile: /home/test/lingang/apache-tomcat-8.5.61/webapps/uploadPath | |
| 140 | + profile: "usual" | |
| 141 | 141 | # 获取ip地址开关 |
| 142 | 142 | addressEnabled: false |
| 143 | 143 | # 验证码类型 math 数字计算 char 字符验证 |
| ... | ... | @@ -202,6 +202,13 @@ netty: |
| 202 | 202 | speech: device/speech |
| 203 | 203 | port: 8989 |
| 204 | 204 | |
| 205 | +minio: | |
| 206 | + host: http://192.168.168.167:9000 | |
| 207 | + url: ${minio.host}/${minio.bucket}/ | |
| 208 | + access-key: alcohol_0D2GVpdJ3 | |
| 209 | + secret-key: ZF4M3dFk1SjmKDuCphTRfh2MZ5T84r25w6YVDSsA | |
| 210 | + bucket: alchohol | |
| 211 | + | |
| 205 | 212 | |
| 206 | 213 | bsth: |
| 207 | 214 | face: |
| ... | ... | @@ -218,3 +225,4 @@ bsth: |
| 218 | 225 | process: |
| 219 | 226 | sign: |
| 220 | 227 | url: http://127.0.0.1:9103/commonOpenDataApi/sendAppAndSmsNotice |
| 228 | + audit-jobs: | |
| 221 | 229 | \ No newline at end of file | ... | ... |
Bsth-admin/src/main/resources/application-druid-lingangPrd.yml
Bsth-admin/src/main/resources/application-druid-lingangPrdAPI.yml
Bsth-admin/src/main/resources/application-druid-lingangTest.yml
Bsth-admin/src/main/resources/application-druid-prd.yml
Bsth-admin/src/main/resources/application.yml
Bsth-admin/src/main/resources/mapper/eexception/EquipmentExceptionMapper.xml
| ... | ... | @@ -105,11 +105,14 @@ |
| 105 | 105 | equipment_exception.nbbm, |
| 106 | 106 | equipment_exception.line_name, |
| 107 | 107 | equipment_exception.plan_time, |
| 108 | - equipment_exception.sign_type | |
| 108 | + equipment_exception.sign_type, | |
| 109 | + equipment_exception.sign_id, | |
| 110 | + venue_info.name siteName | |
| 109 | 111 | from |
| 110 | 112 | equipment_exception |
| 111 | 113 | join driver on driver.job_code = equipment_exception.job_code |
| 112 | 114 | join equipment on equipment.device_id = equipment_exception.device_id |
| 115 | + left join venue_info on equipment.yard_Id=venue_info.ID | |
| 113 | 116 | <where> |
| 114 | 117 | equipment_exception.`status` != 1 |
| 115 | 118 | <if test="fleetName != null and fleetName != ''">and equipment_exception.fleet_name like | ... | ... |
Bsth-common/pom.xml
| ... | ... | @@ -155,6 +155,13 @@ |
| 155 | 155 | <scope>compile</scope> |
| 156 | 156 | </dependency> |
| 157 | 157 | |
| 158 | + <dependency> | |
| 159 | + <groupId>io.minio</groupId> | |
| 160 | + <artifactId>minio</artifactId> | |
| 161 | + <version>8.2.1</version> | |
| 162 | + </dependency> | |
| 163 | + | |
| 164 | + | |
| 158 | 165 | </dependencies> |
| 159 | 166 | |
| 160 | 167 | </project> |
| 161 | 168 | \ No newline at end of file | ... | ... |
Bsth-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java
Bsth-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
| ... | ... | @@ -9,6 +9,7 @@ import com.ruoyi.common.exception.file.InvalidExtensionException; |
| 9 | 9 | import com.ruoyi.common.utils.DateUtils; |
| 10 | 10 | import com.ruoyi.common.utils.StringUtils; |
| 11 | 11 | import com.ruoyi.common.utils.sign.Base64; |
| 12 | +import com.ruoyi.common.utils.spring.SpringUtils; | |
| 12 | 13 | import com.ruoyi.common.utils.uuid.Seq; |
| 13 | 14 | import org.apache.commons.io.FileUtils; |
| 14 | 15 | import org.apache.commons.io.FilenameUtils; |
| ... | ... | @@ -57,20 +58,7 @@ public class FileUploadUtils { |
| 57 | 58 | return defaultBaseDir; |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | - /** | |
| 61 | - * 以默认配置进行文件上传 | |
| 62 | - * | |
| 63 | - * @param file 上传的文件 | |
| 64 | - * @return 文件名称 | |
| 65 | - * @throws Exception | |
| 66 | - */ | |
| 67 | - public static final String upload(MultipartFile file) throws IOException { | |
| 68 | - try { | |
| 69 | - return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); | |
| 70 | - } catch (Exception e) { | |
| 71 | - throw new IOException(e.getMessage(), e); | |
| 72 | - } | |
| 73 | - } | |
| 61 | + | |
| 74 | 62 | |
| 75 | 63 | /** |
| 76 | 64 | * 根据文件路径上传 |
| ... | ... | @@ -112,9 +100,13 @@ public class FileUploadUtils { |
| 112 | 100 | |
| 113 | 101 | String fileName = extractFilename(file); |
| 114 | 102 | |
| 115 | - String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); | |
| 116 | - file.transferTo(Paths.get(absPath)); | |
| 117 | - return getPathFileName(baseDir, fileName); | |
| 103 | + StringBuilder builder = new StringBuilder(); | |
| 104 | + builder.append(baseDir); | |
| 105 | + builder.append("/"); | |
| 106 | + builder.append(fileName); | |
| 107 | + SpringUtils.getBean(MinioConfig.class).upload(file, builder.toString()); | |
| 108 | + | |
| 109 | + return builder.toString(); | |
| 118 | 110 | } |
| 119 | 111 | |
| 120 | 112 | /*** |
| ... | ... | @@ -122,16 +114,14 @@ public class FileUploadUtils { |
| 122 | 114 | * @author liujun |
| 123 | 115 | * @date 2024/7/12 9:18 |
| 124 | 116 | * @param filePath 上传的路径 |
| 125 | - * @param fileName 上传文件名称 | |
| 126 | 117 | * @param type 文件类型 |
| 127 | 118 | * @param uploadContent 文件内容 |
| 128 | 119 | * |
| 129 | 120 | * @return ResponseResult 文件上传成功返回文件路径;上传异常返回500;文件超大返回1;不是图片返回2 |
| 130 | 121 | */ |
| 131 | - public static ResponseResult<String> uploadBase64OfImage(String filePath, String fileName, String type, String uploadContent) { | |
| 122 | + public static ResponseResult<String> uploadBase64OfImage(String filePath, String type, String uploadContent) { | |
| 132 | 123 | FileUploadUtils.uploadContent = uploadContent; |
| 133 | 124 | ByteArrayInputStream byteArrayInputStream = null; |
| 134 | - BufferedImage bufferedImage = null; | |
| 135 | 125 | try { |
| 136 | 126 | if (org.apache.commons.lang3.StringUtils.isEmpty(uploadContent)) { |
| 137 | 127 | return new ResponseResult<>(2, "请上传图片"); |
| ... | ... | @@ -145,28 +135,12 @@ public class FileUploadUtils { |
| 145 | 135 | |
| 146 | 136 | } |
| 147 | 137 | byteArrayInputStream = new ByteArrayInputStream(content); |
| 148 | - bufferedImage = ImageIO.read(byteArrayInputStream); | |
| 149 | - if (Objects.isNull(bufferedImage)) { | |
| 150 | - LOGGER.info("[{}]上传的不是图片", filePath); | |
| 151 | - return new ResponseResult<>(2); | |
| 152 | - } | |
| 153 | - | |
| 154 | 138 | |
| 155 | - StringBuilder path = new StringBuilder(); | |
| 156 | - path.append(filePath); | |
| 157 | - path.append(File.separator); | |
| 158 | - path.append(fileName); | |
| 159 | - path.append("."); | |
| 160 | - path.append(type); | |
| 139 | + SpringUtils.getBean(MinioConfig.class).upload(byteArrayInputStream,filePath, "application/"+type); | |
| 161 | 140 | |
| 162 | - boolean flag = ImageIO.write(bufferedImage, type, new File(path.toString())); | |
| 163 | - bufferedImage.flush(); | |
| 164 | 141 | |
| 165 | - if (Objects.equals(Boolean.FALSE, flag)) { | |
| 166 | - return new ResponseResult<>(500); | |
| 167 | - } | |
| 168 | 142 | ResponseResult<String> responseResult = ResponseResult.success(); |
| 169 | - responseResult.setData(path.toString()); | |
| 143 | + responseResult.setData(filePath); | |
| 170 | 144 | |
| 171 | 145 | return responseResult; |
| 172 | 146 | } catch (Exception e) { |
| ... | ... | @@ -178,7 +152,7 @@ public class FileUploadUtils { |
| 178 | 152 | } |
| 179 | 153 | |
| 180 | 154 | public static String choosePrictureContent(String uploadContent) { |
| 181 | - if (org.apache.commons.lang3.StringUtils.indexOf(uploadContent, ";base64,")>0) { | |
| 155 | + if (org.apache.commons.lang3.StringUtils.indexOf(uploadContent, ";base64,") > 0) { | |
| 182 | 156 | uploadContent = org.apache.commons.lang3.StringUtils.substringAfter(uploadContent, ";base64,"); |
| 183 | 157 | } |
| 184 | 158 | return uploadContent; |
| ... | ... | @@ -193,7 +167,7 @@ public class FileUploadUtils { |
| 193 | 167 | } |
| 194 | 168 | |
| 195 | 169 | public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { |
| 196 | - File desc = new File(uploadDir + File.separator + fileName); | |
| 170 | + File desc = new File(uploadDir + "/" + fileName); | |
| 197 | 171 | |
| 198 | 172 | if (!desc.exists()) { |
| 199 | 173 | if (!desc.getParentFile().exists()) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/config/MinioConfig.java renamed to Bsth-common/src/main/java/com/ruoyi/common/utils/file/MinioConfig.java
| 1 | -package com.ruoyi.config; | |
| 1 | +package com.ruoyi.common.utils.file; | |
| 2 | 2 | |
| 3 | -import io.minio.*; | |
| 3 | +import io.minio.MinioClient; | |
| 4 | +import io.minio.ObjectWriteResponse; | |
| 5 | +import io.minio.PutObjectArgs; | |
| 4 | 6 | import io.minio.errors.*; |
| 5 | -import io.minio.http.Method; | |
| 6 | 7 | import org.springframework.beans.factory.InitializingBean; |
| 8 | +import org.springframework.beans.factory.annotation.Value; | |
| 7 | 9 | import org.springframework.context.annotation.Bean; |
| 8 | 10 | import org.springframework.stereotype.Component; |
| 9 | -import org.springframework.beans.factory.annotation.Value; | |
| 10 | 11 | import org.springframework.web.multipart.MultipartFile; |
| 11 | -import org.springframework.web.util.UriUtils; | |
| 12 | 12 | |
| 13 | 13 | import java.io.IOException; |
| 14 | 14 | import java.io.InputStream; |
| 15 | -import java.nio.charset.StandardCharsets; | |
| 16 | 15 | import java.security.InvalidKeyException; |
| 17 | 16 | import java.security.NoSuchAlgorithmException; |
| 18 | 17 | |
| 19 | -import javax.annotation.Resource; | |
| 20 | - | |
| 21 | 18 | @Component |
| 22 | 19 | public class MinioConfig implements InitializingBean { |
| 23 | 20 | @Value(value = "${minio.bucket}") |
| ... | ... | @@ -55,18 +52,14 @@ public class MinioConfig implements InitializingBean { |
| 55 | 52 | * @param file 文件 |
| 56 | 53 | * @return Boolean |
| 57 | 54 | */ |
| 58 | - public Boolean upload(MultipartFile file) { | |
| 59 | - // 修饰过的文件名 非源文件名 | |
| 60 | - String fileName = "2021-07/21/"; | |
| 61 | - fileName = fileName + file.getOriginalFilename(); | |
| 55 | + public Boolean upload(MultipartFile file, String fileName) { | |
| 62 | 56 | try { |
| 63 | 57 | PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(bucket).object(fileName) |
| 64 | 58 | .stream(file.getInputStream(), file.getSize(), -1).contentType(file.getContentType()).build(); |
| 65 | 59 | //文件名称相同会覆盖 |
| 66 | 60 | minioClient.putObject(objectArgs); |
| 67 | 61 | } catch (Exception e) { |
| 68 | - e.printStackTrace(); | |
| 69 | - return false; | |
| 62 | + throw new RuntimeException(e); | |
| 70 | 63 | } |
| 71 | 64 | return true; |
| 72 | 65 | } |
| ... | ... | @@ -79,42 +72,17 @@ public class MinioConfig implements InitializingBean { |
| 79 | 72 | * @return Boolean |
| 80 | 73 | */ |
| 81 | 74 | public Boolean upload(InputStream inputStream, String fileName, String contentType) { |
| 82 | - // 修饰过的文件名 非源文件名 | |
| 83 | -// | |
| 84 | -// try { | |
| 85 | -// PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(bucket).object(fileName) | |
| 86 | -// .stream(inputStream, inputStream.available(), -1).contentType(contentType).build(); | |
| 87 | -// //文件名称相同会覆盖 | |
| 88 | -// minioClient.putObject(objectArgs); | |
| 89 | -// } catch (Exception e) { | |
| 90 | -// e.printStackTrace(); | |
| 91 | -// return false; | |
| 92 | -// } | |
| 93 | 75 | try { |
| 94 | - ObjectWriteResponse response= minioClient.putObject(PutObjectArgs.builder() | |
| 76 | + minioClient.putObject(PutObjectArgs.builder() | |
| 95 | 77 | .bucket(bucket) // 替换为你实际的存储桶名称 |
| 96 | 78 | .object(fileName) |
| 97 | 79 | .stream(inputStream, inputStream.available(), -1) |
| 98 | 80 | .contentType(contentType) |
| 99 | 81 | .build()); |
| 100 | 82 | return true; |
| 101 | - } catch (ErrorResponseException e) { | |
| 102 | - throw new RuntimeException(e); | |
| 103 | - } catch (InsufficientDataException e) { | |
| 104 | - throw new RuntimeException(e); | |
| 105 | - } catch (InternalException e) { | |
| 106 | - throw new RuntimeException(e); | |
| 107 | - } catch (InvalidKeyException e) { | |
| 108 | - throw new RuntimeException(e); | |
| 109 | - } catch (InvalidResponseException e) { | |
| 110 | - throw new RuntimeException(e); | |
| 111 | - } catch (IOException e) { | |
| 112 | - throw new RuntimeException(e); | |
| 113 | - } catch (NoSuchAlgorithmException e) { | |
| 114 | - throw new RuntimeException(e); | |
| 115 | - } catch (ServerException e) { | |
| 116 | - throw new RuntimeException(e); | |
| 117 | - } catch (XmlParserException e) { | |
| 83 | + } catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidKeyException | | |
| 84 | + InvalidResponseException | IOException | NoSuchAlgorithmException | ServerException | | |
| 85 | + XmlParserException e) { | |
| 118 | 86 | throw new RuntimeException(e); |
| 119 | 87 | } |
| 120 | 88 | } | ... | ... |
Bsth-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
| ... | ... | @@ -514,8 +514,8 @@ public class GenTableServiceImpl implements IGenTableService |
| 514 | 514 | String genPath = table.getGenPath(); |
| 515 | 515 | if (StringUtils.equals(genPath, "/")) |
| 516 | 516 | { |
| 517 | - return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); | |
| 517 | + return System.getProperty("user.dir") + "/" + "src" + "/" + VelocityUtils.getFileName(template, table); | |
| 518 | 518 | } |
| 519 | - return genPath + File.separator + VelocityUtils.getFileName(template, table); | |
| 519 | + return genPath + "/" + VelocityUtils.getFileName(template, table); | |
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | \ No newline at end of file | ... | ... |