Sfoglia il codice sorgente

新增创建巡检日志功能

master
鲲鹏 4 anni fa
parent
commit
1718edb1ff
22 ha cambiato i file con 289 aggiunte e 3 eliminazioni
  1. +0
    -0
      log.path_IS_UNDEFINED/error/log-error-2020-08-13.0.log
  2. +3
    -0
      log.path_IS_UNDEFINED/info/log-info-2020-08-14.0.log
  3. +2
    -0
      log.path_IS_UNDEFINED/log_error.log
  4. +6
    -3
      log.path_IS_UNDEFINED/log_info.log
  5. +41
    -0
      src/main/java/com/taauav/api/controller/InspectLogsController.java
  6. +31
    -0
      src/main/java/com/taauav/api/dto/InspectLogsDto.java
  7. +45
    -0
      src/main/java/com/taauav/api/entity/TauvInspectLogs.java
  8. +16
    -0
      src/main/java/com/taauav/api/mapper/InspectLogsMapper.java
  9. +5
    -0
      src/main/java/com/taauav/api/mapper/InspectLogsMapper.xml
  10. +26
    -0
      src/main/java/com/taauav/api/service/IInspectLogsService.java
  11. +114
    -0
      src/main/java/com/taauav/api/service/impl/InspectLogsServiceImpl.java
  12. BIN
      upload/6620e6c3bf694c7aae1131a30ed8903e_1.png
  13. BIN
      upload/6620e6c3bf694c7aae1131a30ed8903e_2.png
  14. BIN
      upload/be55705430594ae6badf4668308d8234_1.png
  15. BIN
      upload/be55705430594ae6badf4668308d8234_2.png
  16. BIN
      upload/da089dd3bb8f4822ac129b82ddc3ec30_1.png
  17. BIN
      upload/da089dd3bb8f4822ac129b82ddc3ec30_2.png
  18. BIN
      upload/dd41e1c2adcc4193a129b6d5f82132a2_1.png
  19. BIN
      upload/dd41e1c2adcc4193a129b6d5f82132a2_2.png
  20. BIN
      upload/file/file/2020818/f8578c6ae32842e2a6fa841c3a889765.jpeg
  21. BIN
      upload/temp/2020/8/18/287681cdc4-thumbnail.png
  22. BIN
      upload/temp/2020/8/18/6450a5be02-thumbnail.jpeg

+ 0
- 0
log.path_IS_UNDEFINED/error/log-error-2020-08-13.0.log Vedi File


+ 3
- 0
log.path_IS_UNDEFINED/info/log-info-2020-08-14.0.log Vedi File

@@ -0,0 +1,3 @@
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...

+ 2
- 0
log.path_IS_UNDEFINED/log_error.log Vedi File

@@ -0,0 +1,2 @@
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.

+ 6
- 3
log.path_IS_UNDEFINED/log_info.log Vedi File

@@ -1,3 +1,6 @@
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

+ 41
- 0
src/main/java/com/taauav/api/controller/InspectLogsController.java Vedi File

@@ -0,0 +1,41 @@
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);
}

}

+ 31
- 0
src/main/java/com/taauav/api/dto/InspectLogsDto.java Vedi File

@@ -0,0 +1,31 @@
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;

}

+ 45
- 0
src/main/java/com/taauav/api/entity/TauvInspectLogs.java Vedi File

@@ -0,0 +1,45 @@
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;


}

+ 16
- 0
src/main/java/com/taauav/api/mapper/InspectLogsMapper.java Vedi File

@@ -0,0 +1,16 @@
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> {

}

+ 5
- 0
src/main/java/com/taauav/api/mapper/InspectLogsMapper.xml Vedi File

@@ -0,0 +1,5 @@
<?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>

+ 26
- 0
src/main/java/com/taauav/api/service/IInspectLogsService.java Vedi File

@@ -0,0 +1,26 @@
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);

}

+ 114
- 0
src/main/java/com/taauav/api/service/impl/InspectLogsServiceImpl.java Vedi File

@@ -0,0 +1,114 @@
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("巡检日志创建成功");

}
}

BIN
upload/6620e6c3bf694c7aae1131a30ed8903e_1.png Vedi File

Before After
Width: 100  |  Height: 100  |  Size: 2.1KB

BIN
upload/6620e6c3bf694c7aae1131a30ed8903e_2.png Vedi File

Before After
Width: 650  |  Height: 365  |  Size: 6.2KB

BIN
upload/be55705430594ae6badf4668308d8234_1.png Vedi File

Before After
Width: 100  |  Height: 100  |  Size: 2.1KB

BIN
upload/be55705430594ae6badf4668308d8234_2.png Vedi File

Before After
Width: 650  |  Height: 365  |  Size: 6.2KB

BIN
upload/da089dd3bb8f4822ac129b82ddc3ec30_1.png Vedi File

Before After
Width: 100  |  Height: 100  |  Size: 2.1KB

BIN
upload/da089dd3bb8f4822ac129b82ddc3ec30_2.png Vedi File

Before After
Width: 650  |  Height: 365  |  Size: 6.2KB

BIN
upload/dd41e1c2adcc4193a129b6d5f82132a2_1.png Vedi File

Before After
Width: 100  |  Height: 100  |  Size: 2.1KB

BIN
upload/dd41e1c2adcc4193a129b6d5f82132a2_2.png Vedi File

Before After
Width: 650  |  Height: 365  |  Size: 6.2KB

BIN
upload/file/file/2020818/f8578c6ae32842e2a6fa841c3a889765.jpeg Vedi File

Before After
Width: 562  |  Height: 422  |  Size: 74KB

BIN
upload/temp/2020/8/18/287681cdc4-thumbnail.png Vedi File

Before After
Width: 102  |  Height: 102  |  Size: 3.5KB

BIN
upload/temp/2020/8/18/6450a5be02-thumbnail.jpeg Vedi File

Before After
Width: 450  |  Height: 338  |  Size: 43KB

Loading…
Annulla
Salva