@@ -0,0 +1,4 @@ | |||
2020-08-13 10:49:31.830 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,275] - Validating all active sessions... | |||
2020-08-13 10:49:31.902 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,308] - Finished session validation. No sessions were stopped. | |||
2020-08-13 11:08:25.709 [SpringContextShutdownHook] INFO o.s.s.c.ThreadPoolTaskScheduler - [shutdown,208] - Shutting down ExecutorService 'taskScheduler' | |||
2020-08-13 11:08:26.086 [SpringContextShutdownHook] INFO c.a.d.p.DruidDataSource - [close,1825] - {dataSource-1} closed |
@@ -1,4 +1,2 @@ | |||
2020-08-13 10:49:31.830 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,275] - Validating all active sessions... | |||
2020-08-13 10:49:31.902 [SessionValidationThread-1] INFO o.a.s.s.m.AbstractValidatingSessionManager - [validateSessions,308] - Finished session validation. No sessions were stopped. | |||
2020-08-13 11:08:25.709 [SpringContextShutdownHook] INFO o.s.s.c.ThreadPoolTaskScheduler - [shutdown,208] - Shutting down ExecutorService 'taskScheduler' | |||
2020-08-13 11:08:26.086 [SpringContextShutdownHook] INFO c.a.d.p.DruidDataSource - [close,1825] - {dataSource-1} closed | |||
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 |
@@ -37,7 +37,7 @@ public class HomeController { | |||
// 获取顶部广告 | |||
List<CtAd> adList = adService.getAdList(); | |||
// 获取通知公告 | |||
List<UserNotice> noticeList = noticeService.getNoticeList(3); | |||
List<UserNotice> noticeList = noticeService.getRecommNoticeList(3); | |||
// 返回结果 | |||
Map<String, Object> result = new HashMap<>(); | |||
result.put("adList", adList); |
@@ -0,0 +1,45 @@ | |||
package com.taauav.api.controller; | |||
import com.taauav.api.service.IInspectFileService; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.constant.PermissionConstants; | |||
import org.apache.shiro.authz.annotation.RequiresPermissions; | |||
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; | |||
import java.io.IOException; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author zongjl | |||
* @since 2020-08-14 | |||
*/ | |||
@RestController | |||
@RequestMapping("/user/inspectfile") | |||
public class InspectFileController extends ApiBaseController { | |||
@Autowired | |||
private IInspectFileService inspectFileService; | |||
/** | |||
* 图片上传 | |||
* | |||
* @param map | |||
* @return | |||
*/ | |||
@PostMapping("uploadPic") | |||
public Response uploadPic(@RequestBody Map<String, Object> map) throws IOException { | |||
return inspectFileService.uploadPic(map); | |||
} | |||
} |
@@ -2,12 +2,13 @@ package com.taauav.api.controller; | |||
import com.taauav.api.dto.InspectQuestionDto; | |||
import com.taauav.api.query.InspectQuestionQuery; | |||
import com.taauav.api.service.IInspectQuestionService; | |||
import com.taauav.common.bean.Response; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import com.taauav.api.controller.ApiBaseController; | |||
import java.io.IOException; | |||
/** | |||
* <p> | |||
@@ -34,7 +35,7 @@ public class InspectQuestionController extends ApiBaseController { | |||
* @return | |||
*/ | |||
@GetMapping("/getQuestionList") | |||
public Response getQuestionList(@RequestBody InspectQuestionDto inspectQuestionDto) { | |||
public Response getQuestionList(@RequestBody InspectQuestionQuery inspectQuestionDto) { | |||
return response.success(inspectQuestionService.getQuestionList(inspectQuestionDto)); | |||
} | |||
@@ -49,4 +50,15 @@ public class InspectQuestionController extends ApiBaseController { | |||
return inspectQuestionService.getQuestionInfo(id); | |||
} | |||
/** | |||
* 问题上报 | |||
* | |||
* @param inspectQuestionDto 参数 | |||
* @return | |||
*/ | |||
@PostMapping("/createQuestion") | |||
public Response createQuestion(@RequestBody InspectQuestionDto inspectQuestionDto) throws IOException { | |||
return inspectQuestionService.createQuestion(inspectQuestionDto); | |||
} | |||
} |
@@ -1,9 +1,12 @@ | |||
package com.taauav.api.controller; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import com.taauav.api.dto.NoticeQuery; | |||
import com.taauav.api.service.INoticeService; | |||
import com.taauav.common.bean.Response; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import com.taauav.api.controller.ApiBaseController; | |||
/** | |||
@@ -18,4 +21,29 @@ import com.taauav.api.controller.ApiBaseController; | |||
@RequestMapping("/user/notice") | |||
public class NoticeController extends ApiBaseController { | |||
@Autowired | |||
private INoticeService noticeService; | |||
/** | |||
* 获取通知列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/getNoticeList") | |||
public Response getNoticeList(@RequestBody NoticeQuery query) { | |||
return noticeService.getNoticeList(query); | |||
} | |||
/** | |||
* 获取通知公告详情 | |||
* | |||
* @param id 通知ID | |||
* @return | |||
*/ | |||
@GetMapping("/getNoticeInfo/{id}") | |||
public Response getNoticeInfo(@PathVariable("id") Integer id) { | |||
return noticeService.getNoticeInfo(id); | |||
} | |||
} |
@@ -1,14 +1,46 @@ | |||
package com.taauav.api.dto; | |||
import com.taauav.common.core.mps.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 巡检问题上报 | |||
*/ | |||
@Data | |||
public class InspectQuestionDto extends BaseQuery { | |||
public class InspectQuestionDto { | |||
/** | |||
* 状态 | |||
* 巡检河道ID | |||
*/ | |||
private Integer status; | |||
private Integer inspectDriverId; | |||
/** | |||
* 问题选项ID | |||
*/ | |||
private Integer questionId; | |||
/** | |||
* 问题图片 | |||
*/ | |||
private String questionSrc; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String questionNote; | |||
/** | |||
* 经度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 问题位置 | |||
*/ | |||
private String address; | |||
} |
@@ -0,0 +1,8 @@ | |||
package com.taauav.api.dto; | |||
import com.taauav.common.core.mps.BaseQuery; | |||
import lombok.Data; | |||
@Data | |||
public class NoticeQuery extends BaseQuery { | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.taauav.api.mapper; | |||
import com.taauav.admin.entity.TauvInspectFile; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
/** | |||
* <p> | |||
* Mapper 接口 | |||
* </p> | |||
* | |||
* @author zongjl | |||
* @since 2020-08-14 | |||
*/ | |||
public interface InspectFileMapper extends BaseMapper<TauvInspectFile> { | |||
} |
@@ -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.InspectFileMapper"> | |||
</mapper> |
@@ -3,7 +3,7 @@ package com.taauav.api.mapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.taauav.admin.entity.TauvInspectQuestion; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.taauav.api.dto.InspectQuestionDto; | |||
import com.taauav.api.query.InspectQuestionQuery; | |||
import com.taauav.api.vo.InspectQuestionListVo; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
@@ -26,7 +26,7 @@ public interface InspectQuestionMapper extends BaseMapper<TauvInspectQuestion> { | |||
* @param param 参数 | |||
* @return | |||
*/ | |||
List<InspectQuestionListVo> getQuestionList(IPage<TauvInspectQuestion> page, @RequestParam("param") InspectQuestionDto param); | |||
List<InspectQuestionListVo> getQuestionList(IPage<TauvInspectQuestion> page, @RequestParam("param") InspectQuestionQuery param); | |||
/** | |||
* 获取问题详情 |
@@ -0,0 +1,14 @@ | |||
package com.taauav.api.query; | |||
import com.taauav.common.core.mps.BaseQuery; | |||
import lombok.Data; | |||
@Data | |||
public class InspectQuestionQuery extends BaseQuery { | |||
/** | |||
* 状态 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.taauav.api.service; | |||
import com.taauav.admin.entity.TauvInspectFile; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.taauav.common.bean.Response; | |||
import java.io.IOException; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* 服务类 | |||
* </p> | |||
* | |||
* @author zongjl | |||
* @since 2020-08-14 | |||
*/ | |||
public interface IInspectFileService extends IService<TauvInspectFile> { | |||
/** | |||
* 上传图片 | |||
* | |||
* @param map | |||
* @return | |||
* @throws IOException | |||
*/ | |||
Response uploadPic(Map<String, Object> map) throws IOException; | |||
} |
@@ -3,9 +3,11 @@ package com.taauav.api.service; | |||
import com.taauav.admin.entity.TauvInspectQuestion; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.taauav.api.dto.InspectQuestionDto; | |||
import com.taauav.api.query.InspectQuestionQuery; | |||
import com.taauav.api.vo.InspectQuestionListVo; | |||
import com.taauav.common.bean.Response; | |||
import java.io.IOException; | |||
import java.util.List; | |||
/** | |||
@@ -24,7 +26,7 @@ public interface IInspectQuestionService extends IService<TauvInspectQuestion> { | |||
* @param inspectQuestionDto 参数 | |||
* @return | |||
*/ | |||
List<InspectQuestionListVo> getQuestionList(InspectQuestionDto inspectQuestionDto); | |||
List<InspectQuestionListVo> getQuestionList(InspectQuestionQuery inspectQuestionDto); | |||
/** | |||
* 获取问题详情 | |||
@@ -34,4 +36,12 @@ public interface IInspectQuestionService extends IService<TauvInspectQuestion> { | |||
*/ | |||
Response getQuestionInfo(Integer id); | |||
/** | |||
* 上报问题 | |||
* | |||
* @param inspectQuestionDto 参数 | |||
* @return | |||
*/ | |||
Response createQuestion(InspectQuestionDto inspectQuestionDto) throws IOException; | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.taauav.api.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.taauav.api.dto.NoticeQuery; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.front.entity.UserNotice; | |||
import java.util.List; | |||
@@ -21,6 +23,22 @@ public interface INoticeService extends IService<UserNotice> { | |||
* @param num 获取条数 | |||
* @return | |||
*/ | |||
List<UserNotice> getNoticeList(Integer num); | |||
List<UserNotice> getRecommNoticeList(Integer num); | |||
/** | |||
* 获取通知列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
Response getNoticeList(NoticeQuery query); | |||
/** | |||
* 获取通知详情 | |||
* | |||
* @param id 通知ID | |||
* @return | |||
*/ | |||
Response getNoticeInfo(Integer id); | |||
} |
@@ -0,0 +1,189 @@ | |||
package com.taauav.api.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.taauav.admin.entity.TauvInspectDriver; | |||
import com.taauav.admin.entity.TauvInspectFile; | |||
import com.taauav.admin.mapper.TauvInspectDriverMapper; | |||
import com.taauav.api.mapper.InspectFileMapper; | |||
import com.taauav.api.service.IInspectFileService; | |||
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.ShiroUtils; | |||
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 org.springframework.util.StringUtils; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.util.*; | |||
/** | |||
* <p> | |||
* 服务实现类 | |||
* </p> | |||
* | |||
* @author zongjl | |||
* @since 2020-08-14 | |||
*/ | |||
@Service | |||
public class InspectFileServiceImpl extends ServiceImpl<InspectFileMapper, TauvInspectFile> implements IInspectFileService { | |||
@Autowired | |||
private TauvInspectDriverMapper inspectDriverMapper; | |||
@Autowired | |||
private InspectFileMapper inspectFileMapper; | |||
@Autowired | |||
private Response response; | |||
@Value("${file.uploadFolder}") | |||
private String uploadFolder; | |||
@Value("${server.UPLOAD_URL}") | |||
private String uploadUrl; | |||
/** | |||
* 上传图片 | |||
* | |||
* @param map | |||
* @return | |||
* @throws IOException | |||
*/ | |||
@Override | |||
public Response uploadPic(Map<String, Object> map) throws IOException { | |||
if (StringUtils.isEmpty(map)) { | |||
return response.failure("参数不全"); | |||
} | |||
if (StringUtils.isEmpty(map.get("fileList"))) { | |||
return response.failure("请选择要上传的文件"); | |||
} | |||
String inspectDriverIdStr = map.get("inspectDriverId").toString(); | |||
String fileDocument = map.get("fileDocument").toString(); | |||
List<String> fileList = (List<String>) map.get("fileList"); | |||
if (StringUtils.isEmpty(inspectDriverIdStr)) { | |||
return response.failure("任务编号不能为空"); | |||
} | |||
if (StringUtils.isEmpty(fileDocument)) { | |||
return response.failure("图片类型不能为空"); | |||
} | |||
Integer inspectDriverId = Integer.valueOf(inspectDriverIdStr); | |||
TauvInspectDriver driverInfo = inspectDriverMapper.selectById(inspectDriverId); | |||
Integer inspectId = StringUtils.isEmpty(driverInfo) ? 0 : driverInfo.getInspectId(); | |||
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(); | |||
} | |||
List<Map<String, String>> list = new ArrayList<>(); | |||
//判断同一任务、同一图片分类下是否已存在待上传的图片 | |||
Integer num = 1; | |||
String numStr = ""; | |||
for (String fileSrc : fileList) { | |||
fileSrc = fileSrc.replace("-thumbnail", ""); | |||
fileSrc = fileSrc.replace(uploadUrl, uploadFolder); | |||
String md5 = DigestUtils.md5Hex(new FileInputStream(fileSrc)); | |||
QueryWrapper wrapper = new QueryWrapper(); | |||
wrapper.eq("mark", 1); | |||
wrapper.eq("inspect_driver_id", inspectDriverId); | |||
wrapper.eq("file_document", fileDocument); | |||
wrapper.eq("md5", md5); | |||
List<TauvInspectFile> fileExists = inspectFileMapper.selectList(wrapper); | |||
if (fileExists.size() > 0) { | |||
numStr += "【" + num + "】"; | |||
} | |||
num++; | |||
} | |||
if (!"".equals(numStr)) { | |||
return response.failure("第" + numStr + "张图片已存在"); | |||
} | |||
for (String fileSrc : fileList) { | |||
fileSrc = fileSrc.replace("-thumbnail", ""); | |||
fileSrc = fileSrc.replace(uploadUrl, uploadFolder); | |||
File file = new File(fileSrc); | |||
Map<String, String> mapReturn = new HashMap<>(3); | |||
TauvInspectFile inspectFile = new TauvInspectFile(); | |||
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; | |||
inspectFile.setInspectId(inspectId); | |||
inspectFile.setDate(year + month + day); | |||
inspectFile.setInspectDriverId(inspectDriverId); | |||
inspectFile.setFileDocument(fileDocument); | |||
inspectFile.setExtension(extension); | |||
inspectFile.setName(originName); | |||
inspectFile.setFileType(Integer.valueOf("1")); | |||
inspectFile.setSize(size.intValue()); | |||
inspectFile.setFileName(originName); | |||
inspectFile.setType(extension); | |||
inspectFile.setMd5(DigestUtils.md5Hex(new FileInputStream(fileSrc))); | |||
mapReturn.put("code", "ok"); | |||
FileUtil.cutGeneralFile(fileSrc, destPath); | |||
File destFile = new File(destFileUrl); | |||
File destNewFile = new File(destNewFileUrl); | |||
destFile.renameTo(destNewFile); | |||
if (ImageUtil.isImage(extension)) { | |||
List<Map<String, Integer>> sizeList = getCutImgSize(); | |||
String[] scalImgArr = new String[2]; | |||
int i = 0; | |||
for (Map<String, Integer> sizeL : sizeList) { | |||
String scalImg = uploadFolder + nname + "_" + sizeL.get("extension") + "." + extension; | |||
int width = sizeL.get("width"); | |||
int height = sizeL.get("height"); | |||
ImageUtil.thumbnailImage(destNewFile, width, height, scalImg, false); | |||
scalImgArr[i] = scalImg; | |||
i++; | |||
} | |||
String thumbImg = scalImgArr[0].replace(uploadFolder, ""); | |||
String filePath = destNewFileUrl.replace(uploadFolder, ""); | |||
inspectFile.setSrc(filePath); | |||
inspectFile.setOriginalImg(filePath); | |||
inspectFile.setCreateUser(ShiroUtils.getAdminId()); | |||
inspectFile.setCreateTime(DateUtil.now()); | |||
inspectFile.setThumbImg(thumbImg); | |||
inspectFileMapper.insert(inspectFile); | |||
mapReturn.put("msg", "success"); | |||
mapReturn.put("fileUrl", uploadUrl + thumbImg); | |||
} else { | |||
mapReturn.put("code", "error"); | |||
mapReturn.put("msg", "上传图片格式不正确"); | |||
mapReturn.put("fileUrl", ""); | |||
log.warn("上传图片格式不正确"); | |||
} | |||
list.add(mapReturn); | |||
} | |||
return response.success(list); | |||
} | |||
/** | |||
* 切图尺寸 | |||
* | |||
* @return | |||
*/ | |||
private List<Map<String, Integer>> getCutImgSize() { | |||
List<Map<String, Integer>> list = new ArrayList<>(); | |||
Map<String, Integer> map = new HashMap<>(3); | |||
map.put("width", 100); | |||
map.put("height", 100); | |||
map.put("extension", 1); | |||
list.add(map); | |||
map = new HashMap<>(3); | |||
map.put("width", 650); | |||
map.put("height", 365); | |||
map.put("extension", 2); | |||
list.add(map); | |||
return list; | |||
} | |||
} |
@@ -2,22 +2,30 @@ package com.taauav.api.service.impl; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.taauav.admin.entity.TauvDriver; | |||
import com.taauav.admin.entity.TauvInspectQuestion; | |||
import com.taauav.admin.entity.*; | |||
import com.taauav.admin.mapper.TauvDriverMapper; | |||
import com.taauav.admin.mapper.TauvInspectDriverMapper; | |||
import com.taauav.admin.mapper.TauvInspectFileMapper; | |||
import com.taauav.admin.mapper.TauvQuestionOptionsMapper; | |||
import com.taauav.api.dto.InspectQuestionDto; | |||
import com.taauav.api.query.InspectQuestionQuery; | |||
import com.taauav.api.mapper.InspectQuestionMapper; | |||
import com.taauav.api.service.IInspectQuestionService; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.taauav.api.vo.InspectQuestionListVo; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.util.*; | |||
import com.taauav.front.entity.UserAdmin; | |||
import com.taauav.front.mapper.UserAdminMapper; | |||
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.util.List; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.util.*; | |||
/** | |||
* <p> | |||
@@ -32,16 +40,21 @@ public class InspectQuestionServiceImpl extends ServiceImpl<InspectQuestionMappe | |||
@Autowired | |||
private InspectQuestionMapper inspectQuestionMapper; | |||
@Autowired | |||
private TauvDriverMapper driverMapper; | |||
@Autowired | |||
private UserAdminMapper userAdminMapper; | |||
@Autowired | |||
private TauvInspectFileMapper inspectFileMapper; | |||
@Autowired | |||
private TauvInspectDriverMapper inspectDriverMapper; | |||
@Autowired | |||
private TauvQuestionOptionsMapper questionOptionsMapper; | |||
@Autowired | |||
private Response response; | |||
@Value("${file.uploadFolder}") | |||
private String uploadFolder; | |||
@Value("${server.IMAGE_URL}") | |||
private String uploadUrl; | |||
@@ -52,7 +65,7 @@ public class InspectQuestionServiceImpl extends ServiceImpl<InspectQuestionMappe | |||
* @return | |||
*/ | |||
@Override | |||
public List<InspectQuestionListVo> getQuestionList(InspectQuestionDto inspectQuestionDto) { | |||
public List<InspectQuestionListVo> getQuestionList(InspectQuestionQuery inspectQuestionDto) { | |||
IPage<TauvInspectQuestion> page = new Page<>(inspectQuestionDto.getPage(), inspectQuestionDto.getPageSize()); | |||
return inspectQuestionMapper.getQuestionList(page, inspectQuestionDto); | |||
} | |||
@@ -83,4 +96,144 @@ public class InspectQuestionServiceImpl extends ServiceImpl<InspectQuestionMappe | |||
} | |||
return response.success(inspectQuestionListVo); | |||
} | |||
/** | |||
* 上报问题 | |||
* | |||
* @param inspectQuestionDto 参数 | |||
* @return | |||
*/ | |||
@Override | |||
public Response createQuestion(InspectQuestionDto inspectQuestionDto) throws IOException { | |||
// 巡检河流ID | |||
if (inspectQuestionDto.getInspectDriverId() == null || inspectQuestionDto.getInspectDriverId() <= 0) { | |||
return response.failure("巡检河流ID不能为空"); | |||
} | |||
// 问题类型 | |||
if (inspectQuestionDto.getQuestionId() == null || inspectQuestionDto.getQuestionId() <= 0) { | |||
return response.failure("问题类型不能为空"); | |||
} | |||
// 问题图片 | |||
if (StringUtils.isEmpty(inspectQuestionDto.getQuestionSrc())) { | |||
return response.failure("问题图片不能为空"); | |||
} | |||
// 获取巡检河道信息 | |||
TauvInspectDriver inspectDriver = inspectDriverMapper.selectById(inspectQuestionDto.getInspectDriverId()); | |||
if (inspectDriver == null) { | |||
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 = inspectQuestionDto.getQuestionSrc().replace("-thumbnail", ""); | |||
fileSrc = fileSrc.replace(uploadUrl, uploadFolder); | |||
File file = new File(fileSrc); | |||
TauvInspectFile inspectFile = new TauvInspectFile(); | |||
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; | |||
inspectFile.setInspectId(inspectDriver.getInspectId()); | |||
inspectFile.setDate(year + month + day); | |||
inspectFile.setInspectDriverId(inspectQuestionDto.getInspectDriverId()); | |||
inspectFile.setFileDocument(""); | |||
inspectFile.setExtension(extension); | |||
inspectFile.setName(originName); | |||
inspectFile.setFileType(1); | |||
inspectFile.setSize(size.intValue()); | |||
inspectFile.setFileName(originName); | |||
inspectFile.setType(extension); | |||
inspectFile.setQuestionId(inspectQuestionDto.getQuestionId()); | |||
inspectFile.setDescription(inspectQuestionDto.getQuestionNote()); | |||
inspectFile.setMd5(DigestUtils.md5Hex(new FileInputStream(fileSrc))); | |||
FileUtil.cutGeneralFile(fileSrc, destPath); | |||
File destFile = new File(destFileUrl); | |||
File destNewFile = new File(destNewFileUrl); | |||
destFile.renameTo(destNewFile); | |||
if (ImageUtil.isImage(extension)) { | |||
List<Map<String, Integer>> sizeList = getCutImgSize(); | |||
String[] scalImgArr = new String[2]; | |||
int i = 0; | |||
for (Map<String, Integer> sizeL : sizeList) { | |||
String scalImg = uploadFolder + nname + "_" + sizeL.get("extension") + "." + extension; | |||
int width = sizeL.get("width"); | |||
int height = sizeL.get("height"); | |||
ImageUtil.thumbnailImage(destNewFile, width, height, scalImg, false); | |||
scalImgArr[i] = scalImg; | |||
i++; | |||
} | |||
String thumbImg = scalImgArr[0].replace(uploadFolder, ""); | |||
String filePath = destNewFileUrl.replace(uploadFolder, ""); | |||
inspectFile.setSrc(filePath); | |||
inspectFile.setOriginalImg(filePath); | |||
inspectFile.setCreateUser(1); | |||
inspectFile.setCreateTime(DateUtil.now()); | |||
inspectFile.setThumbImg(thumbImg); | |||
Integer result = inspectFileMapper.insert(inspectFile); | |||
if (result == 0) { | |||
return response.failure("问题图片创建失败"); | |||
} | |||
// 创建问题 | |||
TauvInspectQuestion inspectQuestion = new TauvInspectQuestion(); | |||
inspectQuestion.setInspectDriverId(inspectQuestionDto.getInspectDriverId()); | |||
inspectQuestion.setInspectFileId(inspectFile.getId()); | |||
inspectQuestion.setQuestionId(inspectQuestionDto.getQuestionId()); | |||
inspectQuestion.setQuestionNo(createQuestionNo()); | |||
inspectQuestion.setNote(inspectQuestionDto.getQuestionNote()); | |||
inspectQuestion.setCreateUser(1); | |||
inspectQuestion.setCreateTime(DateUtil.now()); | |||
Integer result2 = inspectQuestionMapper.insert(inspectQuestion); | |||
if (result2 == 0) { | |||
return response.failure("上报失败"); | |||
} | |||
} | |||
return response.success("上报成功"); | |||
} | |||
/** | |||
* 创建问题编号 | |||
* | |||
* @return | |||
*/ | |||
private String createQuestionNo() { | |||
Calendar date = Calendar.getInstance(); | |||
String year = String.valueOf(date.get(Calendar.YEAR)).substring(2); | |||
String month = String.format("%02d", date.get(Calendar.MONTH) + 1); | |||
String code = "10" + year + month + (int) ((Math.random() * 9 + 1) * 100000); | |||
return code; | |||
} | |||
/** | |||
* 切图尺寸 | |||
* | |||
* @return | |||
*/ | |||
private List<Map<String, Integer>> getCutImgSize() { | |||
List<Map<String, Integer>> list = new ArrayList<>(); | |||
Map<String, Integer> map = new HashMap<>(3); | |||
map.put("width", 100); | |||
map.put("height", 100); | |||
map.put("extension", 1); | |||
list.add(map); | |||
map = new HashMap<>(3); | |||
map.put("width", 650); | |||
map.put("height", 365); | |||
map.put("extension", 2); | |||
list.add(map); | |||
return list; | |||
} | |||
} |
@@ -1,14 +1,27 @@ | |||
package com.taauav.api.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.taauav.api.dto.NoticeQuery; | |||
import com.taauav.api.mapper.NoticeMapper; | |||
import com.taauav.api.service.INoticeService; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.util.FunctionUtils; | |||
import com.taauav.common.util.StringUtils; | |||
import com.taauav.front.constant.UserNoticeConstant; | |||
import com.taauav.front.entity.UserAdmin; | |||
import com.taauav.front.entity.UserNotice; | |||
import com.taauav.front.vo.usernotice.UserNoticeListVo; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
@@ -24,6 +37,9 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, UserNotice> imp | |||
@Autowired | |||
private NoticeMapper noticeMapper; | |||
@Autowired | |||
private Response response; | |||
/** | |||
* 获取工作台通知公告 | |||
* | |||
@@ -31,7 +47,7 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, UserNotice> imp | |||
* @return | |||
*/ | |||
@Override | |||
public List<UserNotice> getNoticeList(Integer num) { | |||
public List<UserNotice> getRecommNoticeList(Integer num) { | |||
QueryWrapper<UserNotice> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("status", 1); | |||
queryWrapper.eq("mark", 1); | |||
@@ -40,4 +56,61 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, UserNotice> imp | |||
List<UserNotice> noticeList = noticeMapper.selectList(queryWrapper); | |||
return noticeList; | |||
} | |||
/** | |||
* 获取通知列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
@Override | |||
public Response getNoticeList(NoticeQuery query) { | |||
// 查询条件 | |||
QueryWrapper<UserNotice> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("status", 1); | |||
queryWrapper.eq("mark", 1); | |||
queryWrapper.orderByDesc("id"); | |||
IPage<UserNotice> page = new Page<>(query.getPage(), query.getPageSize()); | |||
IPage<UserNotice> data = noticeMapper.selectPage(page, queryWrapper); | |||
List<UserNotice> noticeList = data.getRecords(); | |||
List<UserNoticeListVo> userNoticeListVoList = new ArrayList<>(); | |||
if (!noticeList.isEmpty()) { | |||
noticeList.forEach(item -> { | |||
UserNoticeListVo userNoticeListVo = new UserNoticeListVo(); | |||
// 拷贝属性 | |||
BeanUtils.copyProperties(item, userNoticeListVo); | |||
// 发布时间 | |||
userNoticeListVo.setPublishTime(item.getCreateTime()); | |||
// 通知类型 | |||
userNoticeListVo.setTypeName(UserNoticeConstant.USER_NOTICE_TYPE_LIST.get(item.getType())); | |||
// 通知内容 | |||
userNoticeListVo.setContent(FunctionUtils.delHTMLTag(userNoticeListVo.getContent())); | |||
userNoticeListVoList.add(userNoticeListVo); | |||
}); | |||
} | |||
// 返回结果 | |||
Map<String, Object> result = new HashMap<>(); | |||
result.put("total", data.getTotal()); | |||
result.put("size", data.getSize()); | |||
result.put("current", data.getCurrent()); | |||
result.put("pages", data.getPages()); | |||
result.put("records", userNoticeListVoList); | |||
return response.success(result); | |||
} | |||
/** | |||
* 获取通知公告详情 | |||
* | |||
* @param id 通知ID | |||
* @return | |||
*/ | |||
@Override | |||
public Response getNoticeInfo(Integer id) { | |||
UserNotice userNotice = noticeMapper.selectById(id); | |||
if (userNotice == null) { | |||
return response.failure("通知公告信息不存在"); | |||
} | |||
return response.success(userNotice); | |||
} | |||
} |
@@ -26,6 +26,8 @@ import java.security.MessageDigest; | |||
import java.text.ParseException; | |||
import java.util.*; | |||
import java.text.SimpleDateFormat; | |||
import java.util.regex.Matcher; | |||
import java.util.regex.Pattern; | |||
/** | |||
* 常用方法 | |||
@@ -526,4 +528,30 @@ public class FunctionUtils { | |||
return firstDayOfMonth; | |||
} | |||
/** | |||
* 删除HTML标签 | |||
* | |||
* @param htmlStr | |||
* @return | |||
*/ | |||
public static String delHTMLTag(String htmlStr) { | |||
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式 | |||
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式 | |||
String regEx_html = "<[^>]+>"; //定义HTML标签的正则表达式 | |||
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE); | |||
Matcher m_script = p_script.matcher(htmlStr); | |||
htmlStr = m_script.replaceAll(""); //过滤script标签 | |||
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE); | |||
Matcher m_style = p_style.matcher(htmlStr); | |||
htmlStr = m_style.replaceAll(""); //过滤style标签 | |||
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); | |||
Matcher m_html = p_html.matcher(htmlStr); | |||
htmlStr = m_html.replaceAll(""); //过滤html标签 | |||
return htmlStr.trim(); //返回文本字符串 | |||
} | |||
} |