Commit 7b49ec2ff6521c748f004f04c15497a646d2c3d9
1 parent
001d2d5b
fix: 导出逻辑修改提供图片导出
Showing
9 changed files
with
114 additions
and
20 deletions
ruoyi-admin/src/main/java/com/ruoyi/driver/controller/DriverController.java
| @@ -39,8 +39,6 @@ public class DriverController extends BaseController { | @@ -39,8 +39,6 @@ public class DriverController extends BaseController { | ||
| 39 | @Autowired | 39 | @Autowired |
| 40 | private IDriverService driverService; | 40 | private IDriverService driverService; |
| 41 | 41 | ||
| 42 | - @Autowired | ||
| 43 | - private ServerConfig serverConfig; | ||
| 44 | 42 | ||
| 45 | /** | 43 | /** |
| 46 | * 获取驾驶员排班信息 | 44 | * 获取驾驶员排班信息 |
| @@ -145,21 +143,7 @@ public class DriverController extends BaseController { | @@ -145,21 +143,7 @@ public class DriverController extends BaseController { | ||
| 145 | public AjaxResult uploadImage(MultipartFile file) { | 143 | public AjaxResult uploadImage(MultipartFile file) { |
| 146 | try | 144 | try |
| 147 | { | 145 | { |
| 148 | - // 上传文件路径 | ||
| 149 | - String baseUrl = RuoYiConfig.getUploadPath() + "/head/image"; | ||
| 150 | - // 上传并返回新文件名称 | ||
| 151 | - FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); | ||
| 152 | - String fileName = file.getOriginalFilename(); | ||
| 153 | - String absPath = FileUploadUtils.getAbsoluteFile(baseUrl, fileName).getAbsolutePath(); | ||
| 154 | - fileName = FileUploadUtils.getPathFileName(baseUrl, fileName); | ||
| 155 | - file.transferTo(Paths.get(absPath)); | ||
| 156 | - String url = serverConfig.getUrl() + fileName; | ||
| 157 | - AjaxResult ajax = AjaxResult.success(); | ||
| 158 | - ajax.put("url", url); | ||
| 159 | - ajax.put("fileName", fileName); | ||
| 160 | - ajax.put("newFileName", FileUtils.getName(fileName)); | ||
| 161 | - ajax.put("originalFilename", file.getOriginalFilename()); | ||
| 162 | - return ajax; | 146 | + return driverService.uploadImage(file); |
| 163 | } | 147 | } |
| 164 | catch (Exception e) | 148 | catch (Exception e) |
| 165 | { | 149 | { |
| @@ -167,6 +151,4 @@ public class DriverController extends BaseController { | @@ -167,6 +151,4 @@ public class DriverController extends BaseController { | ||
| 167 | } | 151 | } |
| 168 | } | 152 | } |
| 169 | 153 | ||
| 170 | - | ||
| 171 | -// @ApiOperation("保存员工大头像") | ||
| 172 | } | 154 | } |
ruoyi-admin/src/main/java/com/ruoyi/driver/service/IDriverService.java
| 1 | package com.ruoyi.driver.service; | 1 | package com.ruoyi.driver.service; |
| 2 | 2 | ||
| 3 | +import java.io.IOException; | ||
| 3 | import java.util.List; | 4 | import java.util.List; |
| 4 | import java.util.Map; | 5 | import java.util.Map; |
| 5 | 6 | ||
| 6 | import com.ruoyi.common.core.domain.AjaxResult; | 7 | import com.ruoyi.common.core.domain.AjaxResult; |
| 8 | +import com.ruoyi.common.exception.file.InvalidExtensionException; | ||
| 7 | import com.ruoyi.driver.domain.Driver; | 9 | import com.ruoyi.driver.domain.Driver; |
| 8 | import com.ruoyi.pojo.response.ResponseScheduling; | 10 | import com.ruoyi.pojo.response.ResponseScheduling; |
| 11 | +import org.springframework.web.multipart.MultipartFile; | ||
| 9 | 12 | ||
| 10 | /** | 13 | /** |
| 11 | * 驾驶员信息Service接口 | 14 | * 驾驶员信息Service接口 |
| @@ -76,4 +79,6 @@ public interface IDriverService | @@ -76,4 +79,6 @@ public interface IDriverService | ||
| 76 | AjaxResult getDriverSchedulingAll(); | 79 | AjaxResult getDriverSchedulingAll(); |
| 77 | 80 | ||
| 78 | AjaxResult checkJobCode(Driver jobCode); | 81 | AjaxResult checkJobCode(Driver jobCode); |
| 82 | + | ||
| 83 | + AjaxResult uploadImage(MultipartFile file) throws InvalidExtensionException, IOException; | ||
| 79 | } | 84 | } |
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| 1 | package com.ruoyi.driver.service.impl; | 1 | package com.ruoyi.driver.service.impl; |
| 2 | 2 | ||
| 3 | +import java.io.IOException; | ||
| 4 | +import java.nio.file.Paths; | ||
| 3 | import java.util.*; | 5 | import java.util.*; |
| 4 | 6 | ||
| 7 | +import com.ruoyi.common.config.RuoYiConfig; | ||
| 5 | import com.ruoyi.common.core.domain.AjaxResult; | 8 | import com.ruoyi.common.core.domain.AjaxResult; |
| 6 | import com.ruoyi.common.core.redis.RedisCache; | 9 | import com.ruoyi.common.core.redis.RedisCache; |
| 10 | +import com.ruoyi.common.exception.file.InvalidExtensionException; | ||
| 7 | import com.ruoyi.common.utils.SecurityUtils; | 11 | import com.ruoyi.common.utils.SecurityUtils; |
| 12 | +import com.ruoyi.common.utils.file.FileUploadUtils; | ||
| 13 | +import com.ruoyi.common.utils.file.FileUtils; | ||
| 14 | +import com.ruoyi.common.utils.file.MimeTypeUtils; | ||
| 15 | +import com.ruoyi.framework.config.ServerConfig; | ||
| 8 | import com.ruoyi.pojo.response.ResponseScheduling; | 16 | import com.ruoyi.pojo.response.ResponseScheduling; |
| 9 | import com.ruoyi.utils.ConstDateUtil; | 17 | import com.ruoyi.utils.ConstDateUtil; |
| 10 | import com.ruoyi.utils.ListUtils; | 18 | import com.ruoyi.utils.ListUtils; |
| @@ -13,6 +21,7 @@ import org.springframework.stereotype.Service; | @@ -13,6 +21,7 @@ import org.springframework.stereotype.Service; | ||
| 13 | import com.ruoyi.driver.mapper.DriverMapper; | 21 | import com.ruoyi.driver.mapper.DriverMapper; |
| 14 | import com.ruoyi.driver.domain.Driver; | 22 | import com.ruoyi.driver.domain.Driver; |
| 15 | import com.ruoyi.driver.service.IDriverService; | 23 | import com.ruoyi.driver.service.IDriverService; |
| 24 | +import org.springframework.web.multipart.MultipartFile; | ||
| 16 | 25 | ||
| 17 | import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; | 26 | import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; |
| 18 | 27 | ||
| @@ -24,6 +33,10 @@ import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; | @@ -24,6 +33,10 @@ import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; | ||
| 24 | */ | 33 | */ |
| 25 | @Service | 34 | @Service |
| 26 | public class DriverServiceImpl implements IDriverService { | 35 | public class DriverServiceImpl implements IDriverService { |
| 36 | + | ||
| 37 | + | ||
| 38 | + @Autowired | ||
| 39 | + private ServerConfig serverConfig; | ||
| 27 | @Autowired | 40 | @Autowired |
| 28 | private DriverMapper driverMapper; | 41 | private DriverMapper driverMapper; |
| 29 | 42 | ||
| @@ -143,4 +156,24 @@ public class DriverServiceImpl implements IDriverService { | @@ -143,4 +156,24 @@ public class DriverServiceImpl implements IDriverService { | ||
| 143 | } | 156 | } |
| 144 | return AjaxResult.success(resultMap); | 157 | return AjaxResult.success(resultMap); |
| 145 | } | 158 | } |
| 159 | + | ||
| 160 | + @Override | ||
| 161 | + public AjaxResult uploadImage(MultipartFile file) throws InvalidExtensionException, IOException { | ||
| 162 | + | ||
| 163 | + // 上传文件路径 | ||
| 164 | + String baseUrl = RuoYiConfig.getUploadPath() + "/head/image"; | ||
| 165 | + // 上传并返回新文件名称 | ||
| 166 | + FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); | ||
| 167 | + String fileName = file.getOriginalFilename(); | ||
| 168 | + String absPath = FileUploadUtils.getAbsoluteFile(baseUrl, fileName).getAbsolutePath(); | ||
| 169 | + fileName = FileUploadUtils.getPathFileName(baseUrl, fileName); | ||
| 170 | + file.transferTo(Paths.get(absPath)); | ||
| 171 | + String url = serverConfig.getUrl() + fileName; | ||
| 172 | + AjaxResult ajax = AjaxResult.success(); | ||
| 173 | + ajax.put("url", url); | ||
| 174 | + ajax.put("fileName", fileName); | ||
| 175 | + ajax.put("newFileName", FileUtils.getName(fileName)); | ||
| 176 | + ajax.put("originalFilename", file.getOriginalFilename()); | ||
| 177 | + return ajax; | ||
| 178 | + } | ||
| 146 | } | 179 | } |
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
| @@ -90,6 +90,14 @@ public class DriverJob implements InitializingBean { | @@ -90,6 +90,14 @@ public class DriverJob implements InitializingBean { | ||
| 90 | System.out.println("执行结束"); | 90 | System.out.println("执行结束"); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | + /** | ||
| 94 | + * 导入图片任务 | ||
| 95 | + */ | ||
| 96 | + public void importImages(){ | ||
| 97 | + // TODO 获取用户列表 通过用户列表的jobCode来匹配对应的用户图像信息并保存到服务器 | ||
| 98 | + | ||
| 99 | + } | ||
| 100 | + | ||
| 93 | private static void saveSchedulingToRedis(String getSchedulingInfoUrl, List<Driver> drivers) { | 101 | private static void saveSchedulingToRedis(String getSchedulingInfoUrl, List<Driver> drivers) { |
| 94 | List<ResponseScheduling> originSchedulingList = RESTTEMPLATE.exchange( | 102 | List<ResponseScheduling> originSchedulingList = RESTTEMPLATE.exchange( |
| 95 | getSchedulingInfoUrl, | 103 | getSchedulingInfoUrl, |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/common/ImageConverter.java
0 → 100644
| 1 | +package com.ruoyi.pojo.converter.common; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.converters.Converter; | ||
| 4 | +import com.alibaba.excel.enums.CellDataTypeEnum; | ||
| 5 | +import com.alibaba.excel.metadata.CellData; | ||
| 6 | +import com.alibaba.excel.metadata.GlobalConfiguration; | ||
| 7 | +import com.alibaba.excel.metadata.property.ExcelContentProperty; | ||
| 8 | +import com.alibaba.excel.util.FileUtils; | ||
| 9 | +import com.ruoyi.common.config.RuoYiConfig; | ||
| 10 | +import com.ruoyi.common.utils.file.FileUploadUtils; | ||
| 11 | + | ||
| 12 | +import java.io.File; | ||
| 13 | +import java.io.IOException; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * @author 20412 | ||
| 17 | + */ | ||
| 18 | +public class ImageConverter implements Converter<String> { | ||
| 19 | + @Override | ||
| 20 | + public Class supportJavaTypeKey() { | ||
| 21 | + return String.class; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public CellDataTypeEnum supportExcelTypeKey() { | ||
| 26 | + return CellDataTypeEnum.IMAGE; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, | ||
| 31 | + GlobalConfiguration globalConfiguration) { | ||
| 32 | + throw new UnsupportedOperationException("Cannot convert images to string"); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, | ||
| 37 | + GlobalConfiguration globalConfiguration) throws IOException { | ||
| 38 | + String path = RuoYiConfig.getProfile() + value.replace("/profile",""); | ||
| 39 | + System.out.println(path); | ||
| 40 | + File file = new File(path + File.separator); | ||
| 41 | + if (!file.exists()){ | ||
| 42 | + return new CellData("没有图片"); | ||
| 43 | + } | ||
| 44 | + return new CellData(FileUtils.readFileToByteArray(file)); | ||
| 45 | + } | ||
| 46 | +} |
ruoyi-admin/src/main/java/com/ruoyi/pojo/request/ReportErrorRequestVo.java
| @@ -18,6 +18,11 @@ import java.util.List; | @@ -18,6 +18,11 @@ import java.util.List; | ||
| 18 | @Data | 18 | @Data |
| 19 | public class ReportErrorRequestVo { | 19 | public class ReportErrorRequestVo { |
| 20 | /** | 20 | /** |
| 21 | + * 工号 | ||
| 22 | + */ | ||
| 23 | + @ApiModelProperty("工号") | ||
| 24 | + private String jobCode; | ||
| 25 | + /** | ||
| 21 | * 错误类型 | 26 | * 错误类型 |
| 22 | */ | 27 | */ |
| 23 | @ApiModelProperty("错误类型") | 28 | @ApiModelProperty("错误类型") |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ReportViewResponseVo.java
| @@ -2,17 +2,22 @@ package com.ruoyi.pojo.response; | @@ -2,17 +2,22 @@ package com.ruoyi.pojo.response; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.excel.annotation.ExcelIgnore; | 3 | import com.alibaba.excel.annotation.ExcelIgnore; |
| 4 | import com.alibaba.excel.annotation.ExcelProperty; | 4 | import com.alibaba.excel.annotation.ExcelProperty; |
| 5 | +import com.alibaba.excel.annotation.write.style.ColumnWidth; | ||
| 6 | +import com.alibaba.excel.annotation.write.style.ContentRowHeight; | ||
| 7 | +import com.alibaba.excel.converters.string.StringImageConverter; | ||
| 5 | import com.fasterxml.jackson.annotation.JsonFormat; | 8 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 6 | import com.ruoyi.pojo.converter.AlcoholFlagConverter; | 9 | import com.ruoyi.pojo.converter.AlcoholFlagConverter; |
| 7 | import com.ruoyi.pojo.converter.SignInConvert; | 10 | import com.ruoyi.pojo.converter.SignInConvert; |
| 8 | import com.ruoyi.pojo.converter.SignInStatusConverter; | 11 | import com.ruoyi.pojo.converter.SignInStatusConverter; |
| 9 | import com.ruoyi.pojo.converter.SignInTypeConverter; | 12 | import com.ruoyi.pojo.converter.SignInTypeConverter; |
| 13 | +import com.ruoyi.pojo.converter.common.ImageConverter; | ||
| 10 | import io.swagger.annotations.ApiModel; | 14 | import io.swagger.annotations.ApiModel; |
| 11 | import io.swagger.annotations.ApiModelProperty; | 15 | import io.swagger.annotations.ApiModelProperty; |
| 12 | import lombok.Data; | 16 | import lombok.Data; |
| 13 | import org.springframework.format.annotation.DateTimeFormat; | 17 | import org.springframework.format.annotation.DateTimeFormat; |
| 14 | 18 | ||
| 15 | import java.math.BigDecimal; | 19 | import java.math.BigDecimal; |
| 20 | +import java.net.URL; | ||
| 16 | import java.util.Date; | 21 | import java.util.Date; |
| 17 | 22 | ||
| 18 | /** | 23 | /** |
| @@ -20,6 +25,8 @@ import java.util.Date; | @@ -20,6 +25,8 @@ import java.util.Date; | ||
| 20 | */ | 25 | */ |
| 21 | @ApiModel("滚动大屏响应体数据") | 26 | @ApiModel("滚动大屏响应体数据") |
| 22 | @Data | 27 | @Data |
| 28 | +@ContentRowHeight(100) | ||
| 29 | +@ColumnWidth(100 / 8) | ||
| 23 | public class ReportViewResponseVo { | 30 | public class ReportViewResponseVo { |
| 24 | @ApiModelProperty("id") | 31 | @ApiModelProperty("id") |
| 25 | @ExcelIgnore | 32 | @ExcelIgnore |
| @@ -65,10 +72,12 @@ public class ReportViewResponseVo { | @@ -65,10 +72,12 @@ public class ReportViewResponseVo { | ||
| 65 | @ApiModelProperty("酒精含量") | 72 | @ApiModelProperty("酒精含量") |
| 66 | private BigDecimal alcoholIntake; | 73 | private BigDecimal alcoholIntake; |
| 67 | 74 | ||
| 68 | - @ExcelProperty(value = "头像") | 75 | + @ExcelProperty(value = "头像",converter = ImageConverter.class) |
| 69 | @ApiModelProperty("头像") | 76 | @ApiModelProperty("头像") |
| 70 | private String image; | 77 | private String image; |
| 71 | 78 | ||
| 79 | +// private URL url; | ||
| 80 | + | ||
| 72 | @ExcelProperty(value = "备注") | 81 | @ExcelProperty(value = "备注") |
| 73 | @ApiModelProperty("备注") | 82 | @ApiModelProperty("备注") |
| 74 | private String remark; | 83 | private String remark; |
ruoyi-admin/src/main/resources/mapper/eexception/EquipmentExceptionMapper.xml
| @@ -42,6 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -42,6 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 42 | and DATE_FORMAT(create_time,'%Y-%m-%d') >= #{startTime} | 42 | and DATE_FORMAT(create_time,'%Y-%m-%d') >= #{startTime} |
| 43 | and DATE_FORMAT(create_time,'%Y-%m-%d') <= #{endTime} | 43 | and DATE_FORMAT(create_time,'%Y-%m-%d') <= #{endTime} |
| 44 | </if> | 44 | </if> |
| 45 | + <if test="jobCode != '' and jobCode != null"> | ||
| 46 | + and job_code = #{jobCode} | ||
| 47 | + </if> | ||
| 45 | </select> | 48 | </select> |
| 46 | 49 | ||
| 47 | <insert id="insertEquipmentException" parameterType="EquipmentException" useGeneratedKeys="true" keyProperty="id"> | 50 | <insert id="insertEquipmentException" parameterType="EquipmentException" useGeneratedKeys="true" keyProperty="id"> |
ruoyi-admin/src/main/resources/mapper/in/SignInMapper.xml
| @@ -90,6 +90,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -90,6 +90,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 90 | and DATE_FORMAT(create_time,'%Y-%m-%d') >= #{startTime} | 90 | and DATE_FORMAT(create_time,'%Y-%m-%d') >= #{startTime} |
| 91 | and DATE_FORMAT(create_time,'%Y-%m-%d') <= #{endTime} | 91 | and DATE_FORMAT(create_time,'%Y-%m-%d') <= #{endTime} |
| 92 | </if> | 92 | </if> |
| 93 | + <if test="jobCode != '' and jobCode != null"> | ||
| 94 | + and jobCode = #{jobCode} | ||
| 95 | + </if> | ||
| 93 | 96 | ||
| 94 | </select> | 97 | </select> |
| 95 | 98 |