2020-08-14 09:59:01.928 [SpringContextShutdownHook] INFO o.s.s.c.ThreadPoolTaskScheduler - [shutdown,208] - Shutting down ExecutorService 'taskScheduler' | |||||
2020-08-14 09:59:02.172 [SpringContextShutdownHook] INFO c.a.d.p.DruidDataSource - [close,1825] - {dataSource-1} closed | |||||
2020-08-14 15:08:02.429 [http-nio-8012-exec-2] INFO o.a.s.s.m.AbstractValidatingSessionManager - [enableSessionValidation,233] - Enabling session validation scheduler... |
2020-08-18 09:46:33.995 [SessionValidationThread-1] ERROR o.c.s.RedisSessionDAO - [getActiveSessions,111] - get active sessions error. | |||||
2020-08-18 10:46:34.095 [SessionValidationThread-1] ERROR o.c.s.RedisSessionDAO - [getActiveSessions,111] - get active sessions error. |
2020-08-14 09:59:01.928 [SpringContextShutdownHook] INFO o.s.s.c.ThreadPoolTaskScheduler - [shutdown,208] - Shutting down ExecutorService 'taskScheduler' | |||||
2020-08-14 09:59:02.172 [SpringContextShutdownHook] INFO c.a.d.p.DruidDataSource - [close,1825] - {dataSource-1} closed | |||||
2020-08-14 15:08:02.429 [http-nio-8012-exec-2] INFO o.a.s.s.m.AbstractValidatingSessionManager - [enableSessionValidation,233] - Enabling session validation scheduler... | |||||
2020-08-18 09:46:33.957 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,275] - Validating all active sessions... | |||||
2020-08-18 09:46:34.000 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,308] - Finished session validation. No sessions were stopped. | |||||
2020-08-18 10:46:33.960 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,275] - Validating all active sessions... | |||||
2020-08-18 10:46:34.098 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,308] - Finished session validation. No sessions were stopped. | |||||
2020-08-18 10:50:37.500 [SpringContextShutdownHook] INFO o.s.s.c.ThreadPoolTaskScheduler - [shutdown,208] - Shutting down ExecutorService 'taskScheduler' | |||||
2020-08-18 10:50:37.809 [SpringContextShutdownHook] INFO c.a.d.p.DruidDataSource - [close,1825] - {dataSource-1} closed |
package com.taauav.api.controller; | |||||
import com.taauav.api.dto.InspectLogsDto; | |||||
import com.taauav.api.service.IInspectLogsService; | |||||
import com.taauav.common.bean.Response; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.PostMapping; | |||||
import org.springframework.web.bind.annotation.RequestBody; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import com.taauav.api.controller.ApiBaseController; | |||||
/** | |||||
* <p> | |||||
* 巡检日志表 前端控制器 | |||||
* </p> | |||||
* | |||||
* @author zongjl | |||||
* @since 2020-08-18 | |||||
*/ | |||||
@RestController | |||||
@RequestMapping("/user/inspectlogs") | |||||
public class InspectLogsController extends ApiBaseController { | |||||
@Autowired | |||||
private IInspectLogsService inspectLogsService; | |||||
/** | |||||
* 创建巡检日志 | |||||
* | |||||
* @param inspectLogsDto 巡检日志Dto | |||||
* @return | |||||
*/ | |||||
@PostMapping("/createLogs") | |||||
public Response createLogs(@RequestBody InspectLogsDto inspectLogsDto) { | |||||
return inspectLogsService.createLogs(inspectLogsDto); | |||||
} | |||||
} |
package com.taauav.api.dto; | |||||
import lombok.Data; | |||||
/** | |||||
* 巡检日志Dto | |||||
*/ | |||||
@Data | |||||
public class InspectLogsDto { | |||||
/** | |||||
* 巡检河道ID | |||||
*/ | |||||
private Integer inspectDriverId; | |||||
/** | |||||
* 问题选项ID | |||||
*/ | |||||
private Integer questionId; | |||||
/** | |||||
* 巡检结果 | |||||
*/ | |||||
private String inspectResult; | |||||
/** | |||||
* 巡检图片 | |||||
*/ | |||||
private String inspectImage; | |||||
} |
package com.taauav.api.entity; | |||||
import java.time.LocalDateTime; | |||||
import com.taauav.common.domain.Entity; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.experimental.Accessors; | |||||
/** | |||||
* <p> | |||||
* 巡检日志表 | |||||
* </p> | |||||
* | |||||
* @author zongjl | |||||
* @since 2020-08-18 | |||||
*/ | |||||
@Data | |||||
@EqualsAndHashCode(callSuper = true) | |||||
@Accessors(chain = true) | |||||
public class TauvInspectLogs extends Entity { | |||||
private static final long serialVersionUID = 1L; | |||||
/** | |||||
* 巡检河流ID | |||||
*/ | |||||
private Integer inspectDriverId; | |||||
/** | |||||
* 问题选项id | |||||
*/ | |||||
private Integer questionId; | |||||
/** | |||||
* 巡检结果 | |||||
*/ | |||||
private String inspectResult; | |||||
/** | |||||
* 巡检图片 | |||||
*/ | |||||
private String inspectImage; | |||||
} |
package com.taauav.api.mapper; | |||||
import com.taauav.api.entity.TauvInspectLogs; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
/** | |||||
* <p> | |||||
* 巡检日志表 Mapper 接口 | |||||
* </p> | |||||
* | |||||
* @author zongjl | |||||
* @since 2020-08-18 | |||||
*/ | |||||
public interface InspectLogsMapper extends BaseMapper<TauvInspectLogs> { | |||||
} |
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
<mapper namespace="com.taauav.api.mapper.InspectLogsMapper"> | |||||
</mapper> |
package com.taauav.api.service; | |||||
import com.taauav.api.dto.InspectLogsDto; | |||||
import com.taauav.api.entity.TauvInspectLogs; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | |||||
import com.taauav.common.bean.Response; | |||||
/** | |||||
* <p> | |||||
* 巡检日志表 服务类 | |||||
* </p> | |||||
* | |||||
* @author zongjl | |||||
* @since 2020-08-18 | |||||
*/ | |||||
public interface IInspectLogsService extends IService<TauvInspectLogs> { | |||||
/** | |||||
* 创建巡检日志 | |||||
* | |||||
* @param inspectLogsDto 参数Dto | |||||
* @return | |||||
*/ | |||||
Response createLogs(InspectLogsDto inspectLogsDto); | |||||
} |
package com.taauav.api.service.impl; | |||||
import com.taauav.admin.entity.TauvInspectFile; | |||||
import com.taauav.admin.entity.TauvInspectQuestion; | |||||
import com.taauav.api.dto.InspectLogsDto; | |||||
import com.taauav.api.entity.TauvInspectLogs; | |||||
import com.taauav.api.mapper.InspectLogsMapper; | |||||
import com.taauav.api.service.IInspectLogsService; | |||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.taauav.common.bean.Response; | |||||
import com.taauav.common.util.DateUtil; | |||||
import com.taauav.common.util.FileUtil; | |||||
import com.taauav.common.util.ImageUtil; | |||||
import com.taauav.common.util.StringUtils; | |||||
import org.apache.commons.codec.digest.DigestUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.stereotype.Service; | |||||
import java.io.File; | |||||
import java.io.FileInputStream; | |||||
import java.util.Calendar; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.UUID; | |||||
/** | |||||
* <p> | |||||
* 巡检日志表 服务实现类 | |||||
* </p> | |||||
* | |||||
* @author zongjl | |||||
* @since 2020-08-18 | |||||
*/ | |||||
@Service | |||||
public class InspectLogsServiceImpl extends ServiceImpl<InspectLogsMapper, TauvInspectLogs> implements IInspectLogsService { | |||||
@Autowired | |||||
private InspectLogsMapper inspectLogsMapper; | |||||
@Autowired | |||||
private Response response; | |||||
@Value("${file.uploadFolder}") | |||||
private String uploadFolder; | |||||
@Value("${server.IMAGE_URL}") | |||||
private String uploadUrl; | |||||
/** | |||||
* 创建巡检日志 | |||||
* | |||||
* @param inspectLogsDto 参数Dto | |||||
* @return | |||||
*/ | |||||
@Override | |||||
public Response createLogs(InspectLogsDto inspectLogsDto) { | |||||
// 巡检河流ID | |||||
if (inspectLogsDto.getInspectDriverId() == null || inspectLogsDto.getInspectDriverId() <= 0) { | |||||
return response.failure("巡检河流ID不能为空"); | |||||
} | |||||
// 问题选项ID | |||||
if (inspectLogsDto.getQuestionId() == null || inspectLogsDto.getQuestionId() <= 0) { | |||||
return response.failure("问题选项ID不能为空"); | |||||
} | |||||
// 巡检结果 | |||||
if (StringUtils.isEmpty(inspectLogsDto.getInspectResult())) { | |||||
return response.failure("巡检结果不能为空"); | |||||
} | |||||
// 巡检结果图片 | |||||
if (StringUtils.isEmpty(inspectLogsDto.getInspectImage())) { | |||||
return response.failure("新建结果图片不能为空"); | |||||
} | |||||
Calendar calendar = Calendar.getInstance(); | |||||
String year = calendar.get(Calendar.YEAR) + ""; | |||||
String month = (calendar.get(Calendar.MONTH) + 1) + ""; | |||||
String day = calendar.get(Calendar.DATE) + ""; | |||||
String destPath = uploadFolder + "/file/file/" + year + month + day + "/"; | |||||
File destPathFile = new File(destPath); | |||||
if (!destPathFile.isDirectory()) { | |||||
destPathFile.mkdirs(); | |||||
} | |||||
// 问题图片入库 | |||||
String fileSrc = inspectLogsDto.getInspectImage().replace("-thumbnail", ""); | |||||
fileSrc = fileSrc.replace(uploadUrl, uploadFolder); | |||||
File file = new File(fileSrc); | |||||
String originName = file.getName(); | |||||
Long size = file.length(); | |||||
String extension = originName.substring(originName.lastIndexOf(".") + 1); | |||||
String nname = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32); | |||||
String newName = nname + "." + extension; | |||||
String destFileUrl = destPath + originName; | |||||
String destNewFileUrl = destPath + newName; | |||||
FileUtil.cutGeneralFile(fileSrc, destPath); | |||||
File destFile = new File(destFileUrl); | |||||
File destNewFile = new File(destNewFileUrl); | |||||
destFile.renameTo(destNewFile); | |||||
String filePath = destNewFileUrl.replace(uploadFolder, ""); | |||||
// 创建日志数据 | |||||
TauvInspectLogs entity = new TauvInspectLogs(); | |||||
entity.setInspectDriverId(inspectLogsDto.getInspectDriverId()); | |||||
entity.setQuestionId(inspectLogsDto.getQuestionId()); | |||||
entity.setInspectResult(inspectLogsDto.getInspectResult()); | |||||
entity.setInspectImage(filePath); | |||||
entity.setCreateUser(1); | |||||
entity.setCreateTime(DateUtil.now()); | |||||
Integer result = inspectLogsMapper.insert(entity); | |||||
if (result == 0) { | |||||
return response.failure("巡检日志创建失败"); | |||||
} | |||||
return response.success("巡检日志创建成功"); | |||||
} | |||||
} |