图片上传,总提交修改

master
Zangzhipeng 1 year ago
parent f90f8ad477
commit b1fc846f82
  1. 72
      hiatmp-base/src/main/java/com/hisense/hiatmp/server_api/controller/AuthController.java
  2. 381
      hiatmp-base/src/main/java/com/hisense/hiatmp/server_api/controller/HighDangerController.java
  3. 40
      hiatmp-base/src/main/java/com/hisense/hiatmp/server_api/controller/OperatorController.java
  4. 63
      hiatmp-base/src/main/java/com/hisense/hiatmp/server_api/mapper/HighDangerMapper.java
  5. 17
      hiatmp-base/src/main/java/com/hisense/hiatmp/server_api/mapper/OperatorMapper.java
  6. 68
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/controller/HighDangerController.java
  7. 14
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/mapper/HighDangerMapper.java
  8. 5
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/service/HighDangerService.java
  9. 117
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/service/impl/HighDangerBaseServiceImpl.java
  10. 8
      hiatmp-hidden-danger-server/src/main/resources/application.yml
  11. 10
      hiatmp-hidden-danger-server/src/main/resources/sql-mapper/HighDangerMapper.xml
  12. 2
      hiatmp-model/src/main/java/com/hisense/hiatmp/model/common/ManualInvestigation.java
  13. 19
      hiatmp-model/src/main/java/com/hisense/hiatmp/model/common/ThtHiddenDataCollectConfig.java

@ -1,72 +0,0 @@
package com.hisense.hiatmp.server_api.controller;
import com.hisense.hiatmp.server_api.mapper.OperatorMapper;
import com.hisense.hiatmp.server_api.model.OperatorDTO;
import com.hisense.hiatmp.server_api.service.AuthService;
import com.hisense.hiatmp.model.common.Operator;
import com.hisense.hiatmp.model.common.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/auth")
public class AuthController {
@Autowired
private AuthService authService;
@Autowired
private OperatorMapper operatorMapper;
static Map<Integer, Operator> userMap = new HashMap<>();
/**
* 用户登录
*/
@PostMapping("/login")
public ServerResponse<?> login(@RequestBody OperatorDTO operator) {
// 判断是否有该用户,取出该用户信息
Operator operatorById = operatorMapper.getOperatorById(operator.getCusername());
if(operatorById != null){
// 密码加密
String encrypt = authService.encrypt(operator.getCuserpwd()+ operator.getCusername());
if (operatorById.getCusername().equals(operator.getCusername()) && operatorById.getCuserpwd().equals(encrypt)) {
// String token = JwtUtil.createToken(operatorById);
return ServerResponse.ok(operatorById.getNuserid());
}
}else{
return ServerResponse.error("用户不存在");
}
return ServerResponse.error("用户名或密码错误");
}
/*
密码修改接口
*/
@PostMapping("/updatePwd")
public ServerResponse<?> updatePwd(@RequestParam String cusername,@RequestParam String nuserpwd){
// 获取要修改的用户信息
Operator operatorById = operatorMapper.getOperatorById(cusername);
if(operatorById!=null){
// 密码加密存储
String encrypt = authService.encrypt(nuserpwd + cusername);
operatorById.setCuserpwd(encrypt);
// 执行修改操作并返回结果,返回修改的,如果为null,表示修改失败
String rowsAffected = operatorMapper.updateByPrimaryKeySelective(operatorById.getCusername(), operatorById.getCuserpwd());
if(rowsAffected != null){
return ServerResponse.ok("<" + operatorById.getCusername() + ">用户密码修改成功");
}else{
return ServerResponse.error("修改失败");
}
// return ServerResponse.ok("修改成功");
}
return ServerResponse.error("无用户信息");
}
}

@ -1,381 +0,0 @@
package com.hisense.hiatmp.server_api.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.hisense.hiatmp.server_api.mapper.HighDangerMapper;
import com.hisense.hiatmp.server_api.mapper.OperatorMapper;
import com.hisense.hiatmp.server_api.model.BisRoadVO;
import com.hisense.hiatmp.server_api.service.HighDangerService;
import com.hisense.hiatmp.model.common.*;
import com.hisense.hiatmp.model.dmr.Point;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.*;
@Slf4j
@RestController
@RequestMapping(value = "/highDanger")
public class HighDangerController {
@Autowired
OperatorMapper operatorMapper;
@Autowired
HighDangerMapper highDangerMapper;
@Autowired
HighDangerService highDangerService;
// 查询各个状态的数据情况
@GetMapping("/getHighDangerStatusNum")
public ServerResponse<?> getHighStatusNum(@RequestParam String cusername){
String cdepartmentid = null;
Operator operatorById = operatorMapper.getOperatorById(cusername);
if(operatorById != null){
cdepartmentid = operatorById.getCdepartmentid();
}else{
return ServerResponse.error("未找到当前用户");
}
List<HighDangerBaseNum> statusCounts = highDangerMapper.getStatusCounts(cdepartmentid);
return ServerResponse.ok(statusCounts);
}
// 查询各状态列表
@PostMapping("/getHigDangerDealt")
public ServerResponse<?> getHighDealt(@RequestBody HighDangerBaseVO highDangerBaseVO,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize){
String cdepartmentid = null;
// 获取当前操作的对象,用于查找对应的部门
Operator operatorById = operatorMapper.getOperatorById(highDangerBaseVO.getCusername());
if(operatorById != null){
cdepartmentid = operatorById.getCdepartmentid();
}else{
return ServerResponse.error("未找到当前用户");
}
Page<HighDangerBase> page = new Page<>(pageNum, pageSize);
// 将要查询的状态和部门id查询数据库,获得隐患排查表
List<HighDangerBase> statusCounts = highDangerMapper.getHigDangerDealt(highDangerBaseVO.getStatus(),cdepartmentid,page);
for (HighDangerBase base : statusCounts) {
Date nowDate = new Date();
Date pcEndTime = base.getPcEndTime();
if(pcEndTime != null){
long diff = nowDate.getTime() - pcEndTime.getTime();
// 时间差
long diffDays = diff / (24 * 60 * 60 * 1000);
diffDays = Math.abs(diffDays);
int comparison = nowDate.compareTo(pcEndTime);
if(comparison < 0) { // 超期
base.setDeadline(diffDays);
base.setDeadlineStatus("超期" + diffDays + "天");
} else if(comparison > 0 && diffDays <= 3) { // 临期
base.setDeadline(diffDays);
base.setDeadlineStatus("临期" + diffDays + "天");
} else { // 正常
base.setDeadline(diffDays);
base.setDeadlineStatus("正常");
}
}else{
base.setDeadlineStatus("无排查结束时间");
}
}
PageInfo<HighDangerBase> pageInfo = new PageInfo<>(statusCounts);
return ServerResponse.ok(pageInfo);
}
// 查询临期 & 超期任务
@PostMapping("/getHigDangerDying")
public ServerResponse<?> getHighDying(@RequestBody HighDangerBaseVO highDangerBaseVO){
String departmentId = null;
// 查询当前登录用户的部门
Operator operatorById = operatorMapper.getOperatorById(highDangerBaseVO.getNuserid());
if(operatorById != null){
departmentId = operatorById.getCdepartmentid();
}else{
return ServerResponse.error("未找到当前用户");
}
// 查询该部门的指定状态的任务
List<HighDangerBase> statusCounts = highDangerMapper.getHigDangerDying(highDangerBaseVO.getStatus(),departmentId);
if(statusCounts != null){
return ServerResponse.ok(statusCounts);
}else{
return ServerResponse.error("未查询到任务");
}
}
// 查询指定任务详情任务
@GetMapping("/getHigDangerDetail")
public ServerResponse<?> getHighDetail(@RequestParam String businessId){
HighDangerBase highDangerBase = highDangerMapper.getHigDangerDetail(businessId);
return ServerResponse.ok(highDangerBase);
}
/*
* 模糊查询隐患排查项
*/
@GetMapping("/getHigDangerSearch")
public ServerResponse<?> getHighSearch(@RequestParam String search){
List<HighDangerBase> highDangerBase = highDangerMapper.getHigDangerSearch("%" + search + "%");
if(highDangerBase != null){
return ServerResponse.ok(highDangerBase);
}else{
return ServerResponse.error("未查询到隐患排查项");
}
}
// 获取全部道路
@GetMapping("/getAllRoadInfo")
public ServerResponse<?> getAllRoad(){
List<BisRoadDTO> allRoadInfo = highDangerMapper.getAllRoadInfo();
return ServerResponse.ok(allRoadInfo);
}
// 获取最近道路
@PostMapping("/getNearRoadInfo")
public ServerResponse<?> getNearRoad(@RequestBody Point point){
// 获取全部路段数据
List<BisRoadDTO> allRoadInfo = highDangerMapper.getAllRoadInfo();
HashMap<String, Double> pointMap = new HashMap<>();
// 遍历所有路段
for(BisRoadDTO dto : allRoadInfo){
// 临时存储最短距离
Double minDistance = null;
// 将单条路段的坐标点依次取出进行对比
String[] split = dto.getPosition().split(",");
for(int i = 0; i < split.length; i += 2){
float x = Float.parseFloat(split[i]);
float y = Float.parseFloat(split[i + 1]);
Point Dpoint = new Point();
Dpoint.setX(x);
Dpoint.setY(y);
// 计算两点间的距离
Double pointDistance = highDangerService.getPointDistance(Dpoint, point);
// 最短距离为空,初次存入第一个值
if(minDistance == null){
minDistance = pointDistance;
continue;
}else{
if(pointDistance < minDistance){
minDistance = pointDistance;
}
}
}
// 将路段和最短路线
pointMap.put(dto.getRoadName(), minDistance);
minDistance = null;
}
// 将路段根据计算的值进行排序
Map<String, Double> sortedMap = highDangerService.sortByValue(pointMap);
if(sortedMap != null){
return ServerResponse.ok(sortedMap);
}else{
return ServerResponse.error("未查询到最近道路");
}
// return ServerResponse.ok(sortedMap);
}
// 查询当前排查所在路段
@GetMapping("/getDangerRoad")
public ServerResponse<?> getDangerRoad(@RequestParam String businessId){
List<BisRoadVO> roadInfo = highDangerMapper.getRoadInfo(businessId);
if(roadInfo != null){
return ServerResponse.ok(roadInfo);
}else {
return ServerResponse.error("无对应路口信息");
}
}
// 查询重点排查选项
@GetMapping("/getImportDangers")
public ServerResponse<?> getImportDangers(){
List<ImportDangerDTO> importDanger = highDangerMapper.getImportDanger();
if(importDanger != null){
return ServerResponse.ok(importDanger);
}else {
return ServerResponse.error("无对应路口信息");
}
}
// 新增路段
@PostMapping("/saveRoad")
public ServerResponse<?> saveRoad(@RequestBody SectionDTO sectionDTO){
// 随机生成一个16位的数作为路段id
Random random = new Random();
long randomNumber = (long) (random.nextDouble() * 9000000000000000L) + 1000000000000000L;
String section = highDangerMapper.saveRoad(String.valueOf(randomNumber), sectionDTO.getSectionName(), sectionDTO.getUpCrossingCode(), sectionDTO.getDownCrossingCode());
if(section != null && !section.isEmpty()){
return ServerResponse.ok(section);
}else {
return ServerResponse.error("新增路段失败");
}
}
// 新增路口
@PostMapping("/saveCrossing")
public ServerResponse<?> saveCrossing(@RequestBody CrossingDTO crossingDTO){
Random random = new Random();
long randomNumber = (long) (random.nextDouble() * 9000000000000000L) + 1000000000000000L;
String crossing = highDangerMapper.saveCrossing(String.valueOf(randomNumber), crossingDTO.getCrossingName(), crossingDTO.getLongitude(), crossingDTO.getLatitude());
if(crossing != null && crossing != ""){
return ServerResponse.ok(crossing);
}else {
return ServerResponse.error("新增路口失败");
}
}
// 重点排查二级页面信息
@GetMapping("/getImportDangerInfo")
public ServerResponse<?> getImportDangerInfo(@RequestParam String sid){
List<ImportDangerInfoDTO> importDangerInfo = highDangerMapper.getImportDangerInfo(sid);
if(importDangerInfo != null){
return ServerResponse.ok(importDangerInfo);
}else {
return ServerResponse.error("获取二级页面信息失败");
}
}
// 排查审批
@PostMapping("/approval")
public ServerResponse<?> approval(@RequestParam String businessId){
String approvalId = highDangerMapper.setApproval(businessId);
if(approvalId != null){
return ServerResponse.ok(approvalId);
}else {
return ServerResponse.error("审批失败");
}
}
// 获取基础数据(第一页)
@GetMapping("/getSectionInfo")
public ServerResponse<?> getSectionInfo(@RequestParam String businessId){
ThtSectionInfoDTO sectionInfo = highDangerMapper.getSectionInfo(businessId);
if(sectionInfo != null){
return ServerResponse.ok(sectionInfo);
}else {
return ServerResponse.error("无基本信息内容");
}
}
// 获取统计数据(第二页)
@GetMapping("/getSectionTraffic")
public ServerResponse<?> getSectionTraffic(@RequestParam String businessId){
ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(businessId);
if(sectionTraffic != null){
return ServerResponse.ok(sectionTraffic);
}else {
return ServerResponse.error("无基本信息内容");
}
}
// 获取存在隐患的存在问题,多级列表
@GetMapping("/getDangerItems")
public ServerResponse<?> getDangerItems(){
List<ThtDangerItems> thtDangerItems = highDangerService.listWithTree();
if(thtDangerItems != null){
return ServerResponse.ok(thtDangerItems);
}else {
return ServerResponse.error("无存在问题数据");
}
}
// 保存人工排查
@Transactional
@PostMapping("/saveManualInvestigation")
public ServerResponse<?> saveManualInvestigation(@RequestBody ManualInvestigation manualInvestigation){
Date lastModDate = new Date();
manualInvestigation.setLastModeDate(lastModDate);
ThtSectionInfoDTO sectionInfo = highDangerMapper.getSectionInfo(manualInvestigation.getBusinessId());
if(sectionInfo != null){
// 更新基础数据(步骤1)
highDangerMapper.updateSectionInfo(manualInvestigation);
}else{
// 保存基础数据(步骤1)
highDangerMapper.insertSectionInfo(manualInvestigation);
}
// 判断数据库是否存在统计数据
ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(manualInvestigation.getBusinessId());
if(sectionTraffic != null){
// 更新统计数据(步骤1)
highDangerMapper.updateSectionTraffic(manualInvestigation);
}else{
// 保存统计数据(步骤2)
highDangerMapper.insertSectionTraffic(manualInvestigation);
}
Set<String> keys;
// 保存隐患排查二级页面数据
for (Map<String,List<ThtHiddenDataCollectConfig>> map: manualInvestigation.getKeyInvestigation()){
keys = map.keySet();
for (Map.Entry<String, List<ThtHiddenDataCollectConfig>> entry : map.entrySet()) {
String key = entry.getKey();
List<ThtHiddenDataCollectConfig> value = entry.getValue();
// 对key和value进行操作
for (ThtHiddenDataCollectConfig config : value) {
// 保存图片
List<MultipartFile> multipartFiles1 = config.getMultipartFiles1();
// 图片路径集合(来车方向1)
String path1 = highDangerService.saveMultipartFiles(multipartFiles1).toString();
List<MultipartFile> multipartFiles2 = config.getMultipartFiles1();
// 图片路径集合(来车方向2)
String path2 = highDangerService.saveMultipartFiles(multipartFiles2).toString();
config.setPic1Address(path1);
config.setPic2Address(path2);
// 插入重点排查二级页面数据
highDangerMapper.saveHiddenDataCollectConfig(config);
}
}
}
// 保存重点排查数据
highDangerMapper.saveDangerExtra(manualInvestigation);
// 暂存数据
if(manualInvestigation.getTemporary() == Boolean.FALSE){
highDangerMapper.updateTemporary(manualInvestigation.getBusinessId());
return ServerResponse.ok("数据已暂存");
}
return ServerResponse.ok(manualInvestigation);
}
}

@ -1,40 +0,0 @@
package com.hisense.hiatmp.server_api.controller;
import com.hisense.hiatmp.server_api.mapper.OperatorMapper;
import com.hisense.hiatmp.model.common.Operator;
import com.hisense.hiatmp.model.common.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/operator")
public class OperatorController {
@Autowired
OperatorMapper operatorMapper;
// 查询指定用户
@GetMapping("/getOperatorById")
public ServerResponse<?> getOperatorById(@RequestParam String nusername){
Operator operatorById = operatorMapper.getOperatorById(nusername);
if(operatorById != null){
return ServerResponse.ok(operatorById);
}else{
return ServerResponse.error("未查询到用户信息");
}
}
// 查询所有用户
@GetMapping("/getAllOperator")
public ServerResponse<?> getAllOperator(){
List<Operator> allOperator = operatorMapper.getAllOperator();
if(allOperator != null){
return ServerResponse.ok(allOperator);
}else{
return ServerResponse.error("未查询到用户信息");
}
}
}

@ -1,63 +0,0 @@
package com.hisense.hiatmp.server_api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hisense.hiatmp.server_api.model.BisRoadVO;
import com.hisense.hiatmp.model.common.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface HighDangerMapper extends BaseMapper<HighDangerBase>{
// String getHighDangerStatusNum(@Param("postId") String postId);
// 主页获取各类型数据
List<HighDangerBaseNum> getStatusCounts(String cdepartmentid);
//
List<HighDangerBase> getHigDangerDealt(String status, String cdepartmentid, Page<HighDangerBase> page);
List<HighDangerBase> getHigDangerDying(String status, String cdepartmentid);
HighDangerBase getHigDangerDetail(String businessId);
List<HighDangerBase> getHigDangerSearch(String search);
List<BisRoadDTO> getAllRoadInfo();
List<BisRoadVO> getRoadInfo(String businessId);
List<ImportDangerDTO> getImportDanger();
String saveRoad(String sectionCode, String sectionName, String upCrossingCode, String downCrossingCode);
String saveCrossing(String crossingCode, String crossingName,Float longitude, Float latitude);
List<ImportDangerInfoDTO> getImportDangerInfo(String sid);
String setApproval(String businessId);
ThtSectionInfoDTO getSectionInfo(String businessId);
ThtSectionTrafficDTO getSectionTraffic(String businessId);
String insertSectionInfo(ManualInvestigation sectionInfo);
String updateSectionInfo(ManualInvestigation sectionInfo);
String insertSectionTraffic(ManualInvestigation sectionTraffic);
String updateSectionTraffic(ManualInvestigation sectionTraffic);
List<ThtDangerItems> getDangerItems();
String updateTemporary(String temporary);
String saveHiddenDataCollectConfig(ThtHiddenDataCollectConfig config);
String saveDangerExtra(ManualInvestigation manualInvestigation);
}

@ -1,17 +0,0 @@
package com.hisense.hiatmp.server_api.mapper;
import com.hisense.hiatmp.model.common.Operator;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OperatorMapper {
List<Operator> getAllOperator();
Operator getOperatorById(@Param("cusername") String cusername);
String updateByPrimaryKeySelective(@Param("cusername") String cusername,@Param("cuserpwd") String cuserpwd);
}

@ -14,6 +14,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.file.Path;
import java.util.*;
@Slf4j
@ -338,27 +340,26 @@ public class HighDangerController {
// 保存统计数据(步骤2)
highDangerMapper.insertSectionTraffic(manualInvestigation);
}
Set<String> keys;
Set<String> keys = Collections.emptySet();
// 保存隐患排查二级页面数据
for (Map<String,List<ThtHiddenDataCollectConfig>> map: manualInvestigation.getKeyInvestigation()){
keys = map.keySet();
for (Map.Entry<String, List<ThtHiddenDataCollectConfig>> entry : map.entrySet()) {
String key = entry.getKey();
List<ThtHiddenDataCollectConfig> value = entry.getValue();
// 对key和value进行操作
for (ThtHiddenDataCollectConfig config : value) {
// 保存图片
List<MultipartFile> multipartFiles1 = config.getMultipartFiles1();
// 图片路径集合(来车方向1)
String path1 = highDangerService.saveMultipartFiles(multipartFiles1).toString();
List<MultipartFile> multipartFiles2 = config.getMultipartFiles1();
// 图片路径集合(来车方向2)
String path2 = highDangerService.saveMultipartFiles(multipartFiles2).toString();
config.setPic1Address(path1);
config.setPic2Address(path2);
for (ThtHiddenDataCollectConfig config : entry.getValue()) {
// // 保存图片
// List<MultipartFile> multipartFiles1 = config.getMultipartFiles1();
// // 图片路径集合(来车方向1)
// String path1 = highDangerService.saveMultipartFiles(multipartFiles1).toString();
//
// List<MultipartFile> multipartFiles2 = config.getMultipartFiles1();
// // 图片路径集合(来车方向2)
// String path2 = highDangerService.saveMultipartFiles(multipartFiles2).toString();
//
// config.setPic1Address(path1);
// config.setPic2Address(path2);
config.setBusinessId(manualInvestigation.getBusinessId());
// 插入重点排查二级页面数据
highDangerMapper.saveHiddenDataCollectConfig(config);
@ -366,6 +367,21 @@ public class HighDangerController {
}
}
// // 保存重点排查数据
// highDangerMapper.saveDangerExtra(manualInvestigation);
//
// // <EFBFBD><EFBFBD><EFBFBD>存数据
// if(manualInvestigation.getTemporary() == Boolean.FALSE){
// highDangerMapper.updateTemporary(manualInvestigation.getBusinessId());
// return ServerResponse.ok("数据已暂存");
// }
// return ServerResponse.ok(manualInvestigation);
// public ServerResponse<?> pushPicture(){
// // 图片上传
// return ServerResponse.ok();
// }
manualInvestigation.setKeySet(keys.toString());
// 保存重点排查数据
highDangerMapper.saveDangerExtra(manualInvestigation);
@ -378,4 +394,26 @@ public class HighDangerController {
return ServerResponse.ok(manualInvestigation);
}
// 图片上传接口
@PostMapping("/uploadImage")
public ServerResponse<?> uploadImage(@RequestBody MultipartFile multipartFile) throws IOException {
if(multipartFile.isEmpty()){
return ServerResponse.error("上传文件为空!");
}
Boolean picture = highDangerService.isPicture(multipartFile);
if(picture == Boolean.TRUE){
String path = highDangerService.saveMultipartFiles(multipartFile);
if(path!=null){
return ServerResponse.ok(path);
}else{
return ServerResponse.error("图片上传失败!");
}
}else{
return ServerResponse.error("上传的文件不是图片类型!");
}
}
}

@ -42,21 +42,21 @@ public interface HighDangerMapper extends BaseMapper<HighDangerBase>{
ThtSectionTrafficDTO getSectionTraffic(String businessId);
String insertSectionInfo(ManualInvestigation sectionInfo);
void insertSectionInfo(ManualInvestigation sectionInfo);
String updateSectionInfo(ManualInvestigation sectionInfo);
void updateSectionInfo(ManualInvestigation sectionInfo);
String insertSectionTraffic(ManualInvestigation sectionTraffic);
void insertSectionTraffic(ManualInvestigation sectionTraffic);
String updateSectionTraffic(ManualInvestigation sectionTraffic);
void updateSectionTraffic(ManualInvestigation sectionTraffic);
List<ThtDangerItems> getDangerItems();
String updateTemporary(String temporary);
void updateTemporary(String temporary);
String saveHiddenDataCollectConfig(ThtHiddenDataCollectConfig config);
void saveHiddenDataCollectConfig(ThtHiddenDataCollectConfig config);
String saveDangerExtra(ManualInvestigation manualInvestigation);
void saveDangerExtra(ManualInvestigation manualInvestigation);

@ -5,6 +5,7 @@ import com.hisense.hiatmp.model.dmr.Point;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
@ -20,5 +21,7 @@ public interface HighDangerService {
List<ThtDangerItems> listWithTree();
List<Path> saveMultipartFiles(List<MultipartFile> multipartFiles);
String saveMultipartFiles(MultipartFile multipartFiles) throws IOException;
Boolean isPicture(MultipartFile file);
}

@ -10,10 +10,16 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.*;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
@Service
@ -70,68 +76,88 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
递归查找
*/
@Override
public List<ThtDangerItems> listWithTree(){
public List<ThtDangerItems> listWithTree() {
List<ThtDangerItems> dangerItems = highDangerMapper.getDangerItems();
List<ThtDangerItems> dangerItemResult = dangerItems.stream().map(items -> {
List<ThtDangerItems> dangerItemResult = dangerItems.stream().map(items -> {
ThtDangerItems dangerItemVO = new ThtDangerItems();
BeanUtils.copyProperties(items, dangerItemVO);
return dangerItemVO;
}).collect(Collectors.toList());
List<ThtDangerItems> list = dangerItemResult.stream().filter(items ->
items.getParentid()==null || items.getParentid().isEmpty()
).map((menu)->{
menu.setChildren(getChildrenData(menu,dangerItemResult));
items.getParentid() == null || items.getParentid().isEmpty()
).map((menu) -> {
menu.setChildren(getChildrenData(menu, dangerItemResult));
return menu;
}).collect(Collectors.toList());
return list;
}
private List<ThtDangerItems> getChildrenData(ThtDangerItems root, List<ThtDangerItems> all) {
List<ThtDangerItems> children = all.stream().filter(items ->
root.getId().equals(items.getParentid())
).map(item -> {
item.setChildren(getChildrenData(item,all));
item.setChildren(getChildrenData(item, all));
return item;
}).collect(Collectors.toList());
return children;
}
// 保存图片
// // 保存图片
// @Override
// public Path>saveMultipartFiles(MultipartFile multipartFiles) {
//// ArrayList<Path> paths = new ArrayList<>();
// if(multipartFiles!= null &&!multipartFiles.isEmpty()){
// for (MultipartFile multipartFile : multipartFiles) {
// // 保存图片
// try {
// boolean add = paths.add(handleFileSave(fileLocalPath, multipartFile));
// if(add){
// continue;
// }else{
// throw new RuntimeException("图片保存失败");
// }
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
// }
// return paths;
// }
@Override
public List<Path> saveMultipartFiles(List<MultipartFile> multipartFiles) {
ArrayList<Path> paths = new ArrayList<>();
if(multipartFiles!= null &&!multipartFiles.isEmpty()){
for (MultipartFile multipartFile : multipartFiles) {
// 保存图片
try {
boolean add = paths.add(handleFileSave(fileLocalPath, multipartFile));
if(add){
continue;
}else{
throw new RuntimeException("图片保存失败");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return paths;
}
public String saveMultipartFiles(MultipartFile file) throws IOException {
Image img = null;
File saveFile = null;
public static Path handleFileSave(String localPath, MultipartFile file) throws Exception {
try {
img = ImageIO.read(file.getInputStream());
if (img == null || img.getWidth(null) <= 0 || img.getHeight(null) <= 0) {
return "上传的不是图片文件";
}
// 处理传来的文件
String name = file.getOriginalFilename();
String saveName = "file-" + sfFile.format(new Date()) + UUID.randomUUID().toString().substring(0, 4) + name.substring(name.lastIndexOf("."));
saveFile = new File(fileLocalPath + saveName);
if (!saveFile.getParentFile().exists()) {
saveFile.getParentFile().mkdirs();
}
file.transferTo(saveFile);
// 处理传来的文件
String name = file.getOriginalFilename();
String saveName = "file-" + sfFile.format(new Date()) + UUID.randomUUID().toString().substring(0, 4) + name.substring(name.lastIndexOf("."));
File saveFile = new File(localPath + saveName);
file.transferTo(saveFile);
} catch (Exception e) {
e.printStackTrace();
} finally {
img = null;
}
return saveFile.toPath();
if (saveFile == null) {
throw new RuntimeException("图片保存失败");
}
return saveFile.toPath().toString();
// 判断文件是否是图片类型
// Path path = saveFile.toPath();
// String type = Files.probeContentType(path);
@ -141,4 +167,27 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// return new FileSaveDTO(name, saveName, false);
// }
}
public Boolean isPicture(MultipartFile file) {
Image img = null;
File saveFile = null;
try {
img = ImageIO.read(file.getInputStream());
if (img == null || img.getWidth(null) <= 0 || img.getHeight(null) <= 0) {
return Boolean.FALSE;
}
return Boolean.TRUE;
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
img = null;
}
// @Override
// public Path saveMultipartFiles(MultipartFile multipartFiles) {
// return null;
// }
}
}

@ -7,6 +7,10 @@ run-mode: dev
spring:
application:
name: urbantraffic-hiatmp-base
servlet:
multipart:
max-file-size: 100MB
max-request-size: 200MB
cloud:
nacos:
discovery:
@ -45,6 +49,7 @@ pagehelper:
default-page-size: 10
params: count=countSql
# 登录过期时间
expiration:
time: 60 * 60 * 24
@ -52,7 +57,8 @@ expiration:
file:
path:
local:
/www/wwwroot/hiatmp/pic
# /www/wwwroot/hiatmp/pic
D:\DEV\Code\highDanger\pic\
ssoUrl: http://10.16.3.178:801
# 下面部分为mybatis及log配置,一般不需修改
mybatis:

@ -304,17 +304,15 @@
</update>
<insert id="saveHiddenDataCollectConfig">
INSERT INTO tht_hidden_data_collect_config_copy2 (nid, itemid, order, type, name, standar, unit, pic1_address,
pic2_address)
VALUES (nextval('test_id_seq2'), , #{itemid}, #{order}, #{type}, #{name}, #{standar}, #{unit}, #{pic1Address},
#{pic2Address})
INSERT INTO tht_hidden_data_collect_config_copy2 (nid, itemid, "order", type, name, standar, unit, business_id)
VALUES (nextval('test_id_seq2'), #{itemid}, #{order}, #{type}, #{name}, #{standar}, #{unit},#{businessId})
</insert>
<insert id="saveDangerExtra">
INSERT INTO tht_hidden_danger_extra (nid, key_investigation, danger_item, danger_desc, image_list, information,
business_id)
VALUES (nextval('test_id_seq3'), , #{key_investigation}, #{danger_item}, #{danger_desc}, #{image_list},
#{information}, #{business_id})
VALUES (nextval('test_id_seq3'), #{keySet}, #{dangerItem}, #{dangerDesc}, #{imageList},
#{information}, #{businessId})
</insert>
</mapper>

@ -5,7 +5,6 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -41,6 +40,7 @@ public class ManualInvestigation implements Serializable {
// 第三页,重点排查 & 存在隐患
List<Map<String, List<ThtHiddenDataCollectConfig>>> keyInvestigation;
String keySet;
String dangerItem;
String dangerDesc;
List<MultipartFile> imageList;

@ -24,6 +24,11 @@ public class ThtHiddenDataCollectConfig implements Serializable {
*/
private String nid;
/**
* business_id
*/
private String businessId;
/**
* itemid
*/
@ -32,7 +37,7 @@ public class ThtHiddenDataCollectConfig implements Serializable {
/**
* order
*/
private String order;
private Integer order;
/**
* type
@ -54,13 +59,13 @@ public class ThtHiddenDataCollectConfig implements Serializable {
*/
private String unit;
private String pic1Address;
private String pic2Address;
// 图片地址
List<MultipartFile> multipartFiles1;
// private String pic1Address;
// private String pic2Address;
List<MultipartFile> multipartFiles2;
// // 图片地址
// List<MultipartFile> multipartFiles1;
//
// List<MultipartFile> multipartFiles2;
public ThtHiddenDataCollectConfig() {}
}
Loading…
Cancel
Save