代码扫描问题修改

master
Zangzhipeng 1 year ago
parent fcae07375a
commit 93a3ca8567
  1. 23
      hiatmp-base/src/main/java/com/hisense/hiatmp/server_api/jwt/JwtUtil.java
  2. 7
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/controller/AuthController.java
  3. 70
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/controller/FtpController.java
  4. 2
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/controller/GovernmentController.java
  5. 153
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/controller/HighDangerController.java
  6. 79
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/jwt/JwtUtil.java
  7. 2
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/mapper/HighDangerMapper.java
  8. 11
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/mapper/ThtTricycleInfoBaseMapper.java
  9. 12
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/service/impl/ConfigServiceImpl.java
  10. 343
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/service/impl/HighDangerBaseServiceImpl.java
  11. 36
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/service/impl/TricycleServiceImpl.java
  12. 23
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/utils/FTPUtils.java
  13. 14
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/utils/HiddenDangerUtils.java
  14. 15
      hiatmp-hidden-danger-server/src/main/resources/sql-mapper/HighDangerMapper.xml

@ -32,8 +32,9 @@ public class JwtUtil {
* 过期时间
**/
// private static final long EXPIRATION = 1800L;//单位为秒
//单位为秒
@Value("${expiration.time}")
private static final long EXPIRATION = 60 * 60 * 24; //单位为秒
private static final long EXPIRATION = 60L * 60L * 24L;
/**
* 生成用户token,设置token超时时间
@ -44,16 +45,16 @@ public class JwtUtil {
Map<String, Object> map = new HashMap<>();
map.put("alg", "HS256");
map.put("typ", "JWT");
String token = JWT.create()
.withHeader(map)// 添加头部
//可以将基本信息放到claims中
.withClaim("Nuserid", operator.getNuserid()) //userName
.withClaim("Cuserpwd", operator.getCuserpwd()) //password
.withClaim("Cusername", operator.getCusername()) //name
.withExpiresAt(expireDate) //超时设置,设置过期的日期
.withIssuedAt(new Date()) //签发时间
.sign(Algorithm.HMAC256(SECRET)); //SECRET加密
return token;
//SECRET加密
com.auth0.jwt.JWTCreator.Builder builder = JWT.create();
builder.withHeader(map);
builder.withClaim("Nuserid", operator.getNuserid());
builder.withClaim("Cuserpwd", operator.getCuserpwd());
builder.withClaim("Cusername", operator.getCusername());
builder.withExpiresAt(expireDate);
builder.withIssuedAt(new Date());
return builder.sign(Algorithm.HMAC256(SECRET));
}
/**

@ -36,13 +36,15 @@ public class AuthController {
@PostMapping("/login")
public ServerResponse<?> login(@RequestBody OperatorDTO operator) {
log.info("登录接口调用,登录参数:{}",operator);
HashMap<String, Object> authMap = new HashMap<>();
// 判断是否有该用户,取出该用户信息
Operator operatorById = operatorMapper.getOperatorById(operator.getNuserid());
if(operatorById != null){
// 密码加密(sha512)
String encrypt = authService.encrypt(operator.getCuserpwd() + operator.getNuserid());
// String encrypt = authService.encrypt(operator.getCuserpwd() + operator.getNuserid());
// LocalDate currentDate = LocalDate.now();
// long timestamp = currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
@ -53,7 +55,8 @@ public class AuthController {
// String sessionId = operatorById.getNuserid() + "-" + System.currentTimeMillis();
// String encrypt1 = authService.encrypt(sessionId);
if (operatorById.getNuserid().equals(operator.getNuserid()) && operatorById.getCuserpwd().equals(encrypt)
// 现在改为前端进行sha512加密,后端直接判断是否与数据库存储的密码相等
if (operatorById.getNuserid().equals(operator.getNuserid()) && operatorById.getCuserpwd().equals(operator.getCuserpwd())
) {
authMap.put("nuserid", operator.getNuserid());
List<String> roleById = operatorMapper.getRoleById(operator.getNuserid());

@ -3,44 +3,22 @@ package com.hisense.hiatmp.server_api.controller;
import cn.hutool.core.io.FileUtil;
import com.hisense.hiatmp.model.common.ServerResponse;
import com.hisense.hiatmp.server_api.utils.FTPUtils;
import com.hisense.hiatmp.server_api.utils.WatermarkUtil;
import com.vividsolutions.jts.io.ByteArrayInStream;
import io.swagger.annotations.*;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.net.ftp.FTPClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.imageio.ImageIO;
import javax.imageio.spi.IIORegistry;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@Api(tags="FTP操作")
@RequestMapping(value = "/ftp")
@ -48,23 +26,24 @@ import java.util.concurrent.locks.ReentrantLock;
public class FtpController {
private static final Logger log = LoggerFactory.getLogger(FtpController.class);
/*@Autowired
private RedisUtil redisUtil;*/
@Autowired
private FTPUtils ftpUtils;
@Value("${spring.ftp.username}") //用户名
//用户名
@Value("${spring.ftp.username}")
private String userName;
@Value("${spring.ftp.password}") //密码
//密码
@Value("${spring.ftp.password}")
private String passWord;
@Value("${spring.ftp.port}") //端口号
//端口号
@Value("${spring.ftp.port}")
private int port;
// 文件存放的目录
@Value("${spring.ftp.currentdir}")
private String CURRENT_DIR; // 文件存放的目录
private String currentDir;
@Value("${spring.ftp-http.url}")
private String ftpHttpUrl;
@ -77,9 +56,7 @@ public class FtpController {
@RequestMapping(value = "/uploadToFtp",method = RequestMethod.POST)
public ServerResponse uploadToFtp(@RequestBody String path) {
File file = new File(path);
//File file = new File("D:\\upload\\1.txt");
String url = "";
System.out.println(path+"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
InputStream inputStream = FileUtil.getInputStream(file);
try {
String fileName = path.substring(path.lastIndexOf("/")+1);
@ -112,21 +89,6 @@ public class FtpController {
});
}
/*public static File multipartFileToFile(MultipartFile file) throws Exception {
File toFile = null;
if (file.equals("") || file.getSize() <= 0) {
file = null;
} else {
InputStream ins = null;
ins = file.getInputStream();
toFile = new File(file.getOriginalFilename());
inputStreamToFile(ins, toFile);
ins.close();
}
return toFile;
}*/
public static File multipartFileToFile(MultipartFile multipartFile) throws IOException {
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
@ -137,20 +99,6 @@ public class FtpController {
multipartFile.transferTo(tempFile);
return tempFile;
}
public static void inputStreamToFile(InputStream ins,File file) {
try {
OutputStream os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
ins.close();
} catch (Exception e) {
e.printStackTrace();
}
}
@GetMapping(value = "/downloadFile")
public void downloadFileOld(HttpServletResponse response,@ApiParam("下载后的文件名,带后缀") String fileName
@ -159,7 +107,7 @@ public class FtpController {
try {
if(StringUtils.hasText(fileName)){
//此处可以重命名
response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(fileName,"UTF-8").replaceAll("\\+", "%20"));
response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(fileName,"UTF-8").replace("\\+", "%20"));
} else {
response.setHeader("Content-Disposition", "attachment");
}

@ -210,7 +210,7 @@ public class GovernmentController {
GovernmentProgrammeDTO governmentProgramme = governmentService.getGovernmentProgramme(businessId);
if(governmentProgramme != null){
log.info("/saveManualInvestigation(保存 & 暂存人工排查)接口返回, 返回数据:{},{}", governmentProgramme);
log.info("/getGovernmentProgramme(治理方案详情展示)接口返回, 返回数据:{},{}", governmentProgramme);
return ServerResponse.ok(governmentProgramme);
}else{
return ServerResponse.ok(null);

@ -144,17 +144,6 @@ public class HighDangerController {
if(operatorById == null){
return ServerResponse.ok("未找到当前用户",null);
}
// if (operatorById != null) {
// cdepartmentid = operatorById.getCdepartmentid();
// } else {
//
// }
// if (!Objects.equals(operatorById.getNlevel(), "2")) {
// // 取部门的前六位
// departmentid = cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
// }
cdepartmentid = configService.getDepartmentJurisdiction(nuserid);
// 获取用户权限
@ -828,7 +817,6 @@ public class HighDangerController {
HttpServletRequest request
) {
log.info("/getUserHiddenDangerList(排查第三页--存在隐患列表(用户数据回显))接口被调用,调用ip: {}, 入参:{}, pcType: {}", request.getRemoteAddr(), businessId, pcType);
List<HiddenDangerDTO> userHiddenDangerList = highDangerMapper.getUserHiddenDangerList(businessId, pcType, hdTerm);
for (HiddenDangerDTO hiddenDangerDTO : userHiddenDangerList) {
// 判断是否存在隐患照片,没有的话去attach表里去找
@ -886,7 +874,6 @@ public class HighDangerController {
public ServerResponse<?> saveManualInvestigation(@RequestBody ManualInvestigation manualInvestigation, HttpServletRequest request) throws MyCustomException {
log.info("/saveManualInvestigation(排查暂存、提交操作)接口被调用, 调用ip: {}, 入参: manualInvestigation={}", request.getRemoteAddr(), manualInvestigation);
return highDangerService.saveHiddenDanger(manualInvestigation);
}
// 智能排查 & 人工排查保存状态
@ -963,42 +950,42 @@ public class HighDangerController {
flag++;
continue;
}
if ("1".equals(thtApprove.getOperateContent())) {
// if ("1".equals(thtApprove.getOperateContent())) {
if ("-1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("级审批驳回");
thtApprove.setApprovalInfo(username + "级审批驳回");
thtApprove.setApprovalStatus(thtApprove.getOperateContent() + "级审批驳回");
thtApprove.setApprovalInfo(username + " " + thtApprove.getOperateContent() + "级审批驳回");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
if ("1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("一级审批通过");
thtApprove.setApprovalInfo(username + "一级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
}
if ("2".equals(thtApprove.getOperateContent())) {
if ("-1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("二级审批驳回");
thtApprove.setApprovalInfo(username + "二级审批驳回");
thtApprove.setApprovalStatus(thtApprove.getOperateContent() + "级审批通过");
thtApprove.setApprovalInfo(username + " " + thtApprove.getOperateContent() + "级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
if ("1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("二级审批通过");
thtApprove.setApprovalInfo(username + "二级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
}
// }
// if ("2".equals(thtApprove.getOperateContent())) {
// if ("-1".equals(thtApprove.getApproveResult())) {
// thtApprove.setApprovalOperator(username);
// thtApprove.setApprovalStatus(thtApprove.getOperateContent() + "级审批驳回");
// thtApprove.setApprovalInfo(username + "二级审批驳回");
// processMap.put(flag.toString(), thtApprove);
// flag++;
// continue;
// }
// if ("1".equals(thtApprove.getApproveResult())) {
// thtApprove.setApprovalOperator(username);
// thtApprove.setApprovalStatus("二级审批通过");
// thtApprove.setApprovalInfo(username + "二级审批通过");
// processMap.put(flag.toString(), thtApprove);
// flag++;
// continue;
// }
// }
}
if ("20".equals(thtApprove.getStatus())) {
@ -1010,41 +997,41 @@ public class HighDangerController {
flag++;
continue;
}
if ("1".equals(thtApprove.getOperateContent())) {
// if ("1".equals(thtApprove.getOperateContent())) {
if ("-1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("级审批驳回");
thtApprove.setApprovalInfo(username + "级审批驳回");
thtApprove.setApprovalStatus(thtApprove.getOperateContent() + "级审批驳回");
thtApprove.setApprovalInfo(username + " " + thtApprove.getOperateContent() + "级审批驳回");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
if ("1".equals(thtApprove.getOperateContent())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("一级审批通过");
thtApprove.setApprovalInfo(username + "一级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
}
if ("2".equals(thtApprove.getOperateContent())) {
if ("-1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("二级审批驳回");
thtApprove.setApprovalInfo(username + "二级审批驳回");
thtApprove.setApprovalStatus(thtApprove.getOperateContent() + "级审批通过");
thtApprove.setApprovalInfo(username + " " + thtApprove.getOperateContent() + "级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
if ("1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("二级审批通过");
thtApprove.setApprovalInfo(username + "二级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
}
}
// }
// if ("2".equals(thtApprove.getOperateContent())) {
// if ("-1".equals(thtApprove.getApproveResult())) {
// thtApprove.setApprovalOperator(username);
// thtApprove.setApprovalStatus("二级审批驳回");
// thtApprove.setApprovalInfo(username + "二级审批驳回");
// processMap.put(flag.toString(), thtApprove);
// flag++;
// continue;
// }
// if ("1".equals(thtApprove.getApproveResult())) {
// thtApprove.setApprovalOperator(username);
// thtApprove.setApprovalStatus("二级审批通过");
// thtApprove.setApprovalInfo(username + "二级审批通过");
// processMap.put(flag.toString(), thtApprove);
// flag++;
// }
// }
}
if ("60".equals(thtApprove.getStatus())) {
@ -1056,41 +1043,41 @@ public class HighDangerController {
flag++;
continue;
}
if ("1".equals(thtApprove.getOperateContent())) {
// if ("1".equals(thtApprove.getOperateContent())) {
if ("-1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("级审批驳回");
thtApprove.setApprovalInfo(username + "级审批驳回");
thtApprove.setApprovalStatus(thtApprove.getOperateContent() + "级审批驳回");
thtApprove.setApprovalInfo(username + " " + thtApprove.getOperateContent() + "级审批驳回");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
if ("1".equals(thtApprove.getOperateContent())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("级审批通过");
thtApprove.setApprovalInfo(username + "级审批通过");
thtApprove.setApprovalStatus(thtApprove.getOperateContent() + "级审批通过");
thtApprove.setApprovalInfo(username + " " + thtApprove.getOperateContent() + "级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
}
if ("2".equals(thtApprove.getOperateContent())) {
if ("-1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("二级审批驳回");
thtApprove.setApprovalInfo(username + "二级审批驳回");
processMap.put(flag.toString(), thtApprove);
flag++;
continue;
}
if ("1".equals(thtApprove.getApproveResult())) {
thtApprove.setApprovalOperator(username);
thtApprove.setApprovalStatus("二级审批通过");
thtApprove.setApprovalInfo(username + "二级审批通过");
processMap.put(flag.toString(), thtApprove);
flag++;
}
}
// }
// if ("2".equals(thtApprove.getOperateContent())) {
// if ("-1".equals(thtApprove.getApproveResult())) {
// thtApprove.setApprovalOperator(username);
// thtApprove.setApprovalStatus("二级审批驳回");
// thtApprove.setApprovalInfo(username + "二级审批驳回");
// processMap.put(flag.toString(), thtApprove);
// flag++;
// continue;
// }
// if ("1".equals(thtApprove.getApproveResult())) {
// thtApprove.setApprovalOperator(username);
// thtApprove.setApprovalStatus("二级审批通过");
// thtApprove.setApprovalInfo(username + "二级审批通过");
// processMap.put(flag.toString(), thtApprove);
// flag++;
// }
// }
}
}
return ServerResponse.ok(processMap);

@ -1,79 +0,0 @@
package com.hisense.hiatmp.server_api.jwt;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.hisense.hiatmp.model.common.Operator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @description: Jwt工具类生成JWT和认证
* @author: heshi
*/
@Component
public class JwtUtil {
private static final Logger logger = LoggerFactory.getLogger(JwtUtil.class);
/**
* 密钥
*/
private static final String SECRET = "my_secret";
/**
* 过期时间
**/
// private static final long EXPIRATION = 1800L;//单位为秒
@Value("${expiration.time}")
private static final long EXPIRATION = 60 * 60 * 24; //单位为秒
/**
* 生成用户token,设置token超时时间
*/
public static String createToken(Operator operator) {
//过期时间
Date expireDate = new Date(System.currentTimeMillis() + EXPIRATION * 1000);
Map<String, Object> map = new HashMap<>();
map.put("alg", "HS256");
map.put("typ", "JWT");
String token = JWT.create()
.withHeader(map)// 添加头部
//可以将基本信息放到claims中
.withClaim("Nuserid", operator.getNuserid()) //userName
.withClaim("Cuserpwd", operator.getCuserpwd()) //password
.withClaim("Cusername", operator.getCusername()) //name
.withExpiresAt(expireDate) //超时设置,设置过期的日期
.withIssuedAt(new Date()) //签发时间
.sign(Algorithm.HMAC256(SECRET)); //SECRET加密
return token;
}
/**
* 校验token并解析token
*/
public static Map<String, Claim> verifyToken(String token) {
DecodedJWT jwt = null;
try {
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(SECRET)).build();
jwt = verifier.verify(token);
//decodedJWT.getClaim("属性").asString() 获取负载中的属性值
} catch (Exception e) {
logger.error(e.getMessage());
logger.error("token解码异常");
//解码异常则抛出异常
return null;
}
return jwt.getClaims();
}
}

@ -99,7 +99,7 @@ public interface HighDangerMapper{
void saveHiddenDataCollectConfig(ThtHiddenDataCollectConfig config);
void saveDangerExtra(HiddenDangerDTO describe);
void saveRoadInfo(HiddenDangerDTO describe);
List<HiddenDangerDTO> isExtraExistence(String businessId);

@ -3,23 +3,18 @@ package com.hisense.hiatmp.server_api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.hiatmp.model.common.DTO.ThtTricycleInfoBaseDTO;
import com.hisense.hiatmp.model.common.VO.TricycleListVO;
import com.hisense.hiatmp.model.common.VO.TricycleWarningListVO;
import com.hisense.hiatmp.model.dmr.LineInfo;
import com.hisense.hiatmp.server_api.model.ModuleCustomConfig;
import com.hisense.hiatmp.server_api.model.StreetCommunity;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author Zangzhipeng
*/
@Repository
public interface ThtTricycleInfoBaseMapper extends BaseMapper<ThtTricycleInfoBaseDTO> {
List<TricycleListVO> getTricycleList(@Param("roleFlag") int roleFlag,@Param("cdepartmentid") String cdepartmentid,@Param("status") String status,@Param("search") String search);
// List<TricycleWarningListVO> getTricycleWarningList(@Param("roleFlag") int roleFlag, @Param("distributionStatus") String distributionStatus, @Param("completeStatus") String completeStatus);
// int saveTricycleInfo(ThtTricycleInfoBaseDTO infoBaseDTO);
ThtTricycleInfoBaseDTO getTricycleInfoBaseById(String vehicleId);
}

@ -84,31 +84,27 @@ public class ConfigServiceImpl implements IConfigService {
if (operatorById != null) {
// 是否有上级部门
if("1".equals(operatorById.getDepartmentflag())){
// cdepartmentid = operatorById.getParentdepartment();
QueryWrapper<Department> departmentQueryWrapper = new QueryWrapper<>();
departmentQueryWrapper.eq("cdepartmentid",operatorById.getParentdepartment());
// 查询上级部门权限
Department department = departmentMapper.selectOne(departmentQueryWrapper);
if(!(Integer.parseInt(department.getNlevel()) == 2)){
if(Integer.parseInt(department.getNlevel()) != 2){
// 取部门的前六位
cdepartmentid = department.getCdepartmentid();
String substring = cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
return substring;
return cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
}else{
return "";
}
}
// 没有上级部门,权限不是大于2
else if (!(Integer.parseInt(operatorById.getNlevel()) == 2)) {
else if (Integer.parseInt(operatorById.getNlevel()) != 2) {
// 取部门的前六位
cdepartmentid = operatorById.getCdepartmentid();
String substring = cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
return substring;
return cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
}
else{ // 没有上级部门
return "";
}
// cdepartmentid = operatorById.getCdepartmentid();
}else{
return null;
}

@ -2,8 +2,8 @@ package com.hisense.hiatmp.server_api.service.impl;
import com.alibaba.nacos.client.utils.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.hisense.hiatmp.model.common.*;
import com.hisense.hiatmp.model.common.DTO.SectionDTO;
import com.hisense.hiatmp.model.common.DTO.ThtTimeLineDTO;
@ -22,39 +22,40 @@ import org.springframework.beans.factory.annotation.Autowired;
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.File;
import java.io.IOException;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@Slf4j
@Service
public class HighDangerBaseServiceImpl implements HighDangerService {
@Value("${spring.ftp.username}") //用户名
//用户名
@Value("${spring.ftp.username}")
private String userName;
@Value("${spring.ftp.password}") //密码
//密码
@Value("${spring.ftp.password}")
private String passWord;
@Value("${spring.ftp.host}") //ip地址
//ip地址
@Value("${spring.ftp.host}")
private String ip;
@Value("${spring.ftp.port}") //端口号
//端口号
@Value("${spring.ftp.port}")
private int port;
// 文件存放的目录
@Value("${spring.ftp.currentdir}")
private String CURRENT_DIR; // 文件存放的目录
private String currentDir;
@Autowired
private HiddenDangerUtils hiddenDangerUtils;
@ -74,10 +75,13 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
@Autowired
private IConfigService configService;
private static final String ONE_HOURS = "剩余不到一小时";
/**
* 椭球参数
*/
private static double pi = 3.14159265358979324;
private static final double PI = 3.14159265358979324;
/**
* 卫星椭球坐标投影到平面地图坐标系的投影因子
*/
@ -91,9 +95,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
/*@Value("${file.path.local}")
private String fileLocalPath;*/
private static SimpleDateFormat sfFile = new SimpleDateFormat("yyyyMMddHHmmss");
@Autowired
private HighDangerMapper highDangerMapper;
@ -172,81 +174,16 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
}
private List<ThtDangerItems> getChildrenData(ThtDangerItems root, List<ThtDangerItems> all) {
List<ThtDangerItems> children = all.stream().filter(items ->
return all.stream().filter(items ->
root.getId().equals(items.getParentid())
).map(item -> {
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 String saveMultipartFiles(MultipartFile file) throws IOException {
Image img = null;
File saveFile = null;
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);
} catch (Exception e) {
e.printStackTrace();
} finally {
img = null;
}
if (saveFile == null) {
throw new RuntimeException("图片保存失败");
}
return saveFile.toPath().toString();
// 判断文件是否是图片类型
// Path path = saveFile.toPath();
// String type = Files.probeContentType(path);
// if (Files.probeContentType(saveFile.toPath()) != null) {
// return new FileSaveDTO(name, saveName, Files.probeContentType(saveFile.toPath()).startsWith("image/"));
// } else {
// return new FileSaveDTO(name, saveName, false);
// }
}*/
public Boolean isPicture(MultipartFile file) {
Image img = null;
File saveFile = null;
try {
img = ImageIO.read(file.getInputStream());
@ -278,12 +215,12 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
double dLat = transformLat(wgLon - 105.0, wgLat - 35.0);
double dLon = transformLon(wgLon - 105.0, wgLat - 35.0);
double radLat = wgLat / 180.0 * pi;
double radLat = wgLat / 180.0 * PI;
double magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * PI);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * PI);
double transLat = wgLat + dLat;
double transLon = wgLon + dLon;
return new CoordinateConverter.AMap((float) transLon, (float) transLat);
@ -313,9 +250,9 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
*/
private static double transformLat(double x, double y) {
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(y * PI) + 40.0 * Math.sin(y / 3.0 * PI)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(y / 12.0 * PI) + 320 * Math.sin(y * PI / 30.0)) * 2.0 / 3.0;
return ret;
}
@ -328,9 +265,9 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
*/
private static double transformLon(double x, double y) {
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(x * PI) + 40.0 * Math.sin(x / 3.0 * PI)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(x / 12.0 * PI) + 300.0 * Math.sin(x / 30.0 * PI)) * 2.0 / 3.0;
return ret;
}
@ -366,9 +303,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = sdf.format(date);
// 隐患名称
highDangerBase.setName(highDangerBase.getName());
// 隐患类型
@ -382,7 +316,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
highDangerBase.setPcStartTime(date);
highDangerBase.setDelayCount("0");
// highDangerBase.setDelayDay("0");
highDangerBase.setPcCount("1");
highDangerMapper.insertDanger(highDangerBase);
@ -469,47 +402,20 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
@Override
public ServerResponse<?> saveHiddenDanger(ManualInvestigation manualInvestigation) throws MyCustomException {
// 入参格式判断
if(manualInvestigation.getTemporary() == null || manualInvestigation.getOperator() == null || manualInvestigation.getIfCross() == null){
return ServerResponse.error("关键入参不合规(Temporary、Operator或if_cross)");
}
/*
加锁的意义
互斥访问
锁能够防止多个线程同时访问共享资源确保任何时刻只有一个线程能够进入临界区从而避免数据竞争和不一致状态
原子操作保证
通过锁可以确保某些关键操作如修改共享变量在执行时不会被其他线程中断保证了这些操作的原子性
线程同步
锁可以用于实现线程间的同步例如一个线程等待另一个线程完成某个任务后继续执行这有助于协调多线程程序中的复杂流程
避免死锁和活锁
虽然锁本身可能导致死锁和活锁问题但合理使用锁机制可以避免这些问题的发生确保程序的稳定运行
提高并发性能
虽然锁会带来一定的性能开销但在适当的地方使用锁可以提高并发性能尤其是在多处理器系统中合理的锁策略能够有效利用硬件资源
读写锁优化
Java提供了读写锁ReentrantReadWriteLock允许多个读取线程同时访问共享资源但写入操作是排他的这种机制在读操作远多于写操作的场景下可以显著提升并发性能
公平性和非公平性
Java中的锁还可以设置为公平锁或非公平锁公平锁按照线程请求锁的顺序分配锁而非公平锁则可能让后来的线程先获得锁提高了锁的获取速度但牺牲了一定的公平性
*/
// 加锁
Lock lock = new ReentrantLock();
lock.lock();
// 生成排查主键nid
UUID uuid = UUID.fromString(UUID.randomUUID().toString());
String nid = uuid.toString().replaceAll("-", "");
String nid = uuid.toString().replace("-", "");
// 当前时间
Date date = new Date();
// ftp文件保存格式封装
String ftpUrl = "ftp://" + userName + ":" + passWord + "@" + ip + ":" + port + CURRENT_DIR;
String ftpUrl = "ftp://" + userName + ":" + passWord + "@" + ip + ":" + port + currentDir;
// 当前时间为最后修改时间
manualInvestigation.setLastModeDate(date);
// 提交的businessId赋值
String hidden_businessId = manualInvestigation.getBusinessId();
String hiddenBusinessId = manualInvestigation.getBusinessId();
/*
获取当前角色对应部门
@ -535,7 +441,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
String formattedDate = currentDate.format(formatter);
// 生成businessId
hidden_businessId = "RG" + formattedDate + hiddenDangerUtils.randomNumber(5);
hiddenBusinessId = "RG" + formattedDate + hiddenDangerUtils.randomNumber(5);
/*
保存base表数据
@ -544,7 +450,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// base主键
highDangerBase.setNid(nid);
// 隐患id
highDangerBase.setBusinessId(hidden_businessId);
highDangerBase.setBusinessId(hiddenBusinessId);
// 隐患名称
highDangerBase.setName(manualInvestigation.getName());
// 操作用户
@ -634,7 +540,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 道路NID
highDangerRoad.setNid(nid);
// 隐患主键
highDangerRoad.setBusinessId(hidden_businessId);
highDangerRoad.setBusinessId(hiddenBusinessId);
// 绑定路段
highDangerRoad.setSectionCode(manualInvestigation.getSectionCode());
// 设置road表的ifCross
@ -654,7 +560,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 插入时间
thtTimeLineDTO.setInsertTime(date);
// 隐患id
thtTimeLineDTO.setBusinessId(hidden_businessId);
thtTimeLineDTO.setBusinessId(hiddenBusinessId);
// 隐患状态
thtTimeLineDTO.setStatus("0");
// 隐患状态(中文)
@ -667,7 +573,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
thtTimeLineDTO.setOperator(manualInvestigation.getOperator());
// 将生成的business_id存入manualInvestigation对象中
manualInvestigation.setBusinessId(hidden_businessId);
manualInvestigation.setBusinessId(hiddenBusinessId);
/*
分别插入三张表
@ -680,17 +586,17 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
insertTimeLine(thtTimeLineDTO);
}
// manualInvestigation.setBusinessId(hidden_businessId);
// manualInvestigation.setBusinessId(hiddenBusinessId);
// 更新隐患名称(暂存/保存)
highDangerMapper.updateHiddenDangerBaseName(hidden_businessId,manualInvestigation.getName());
highDangerMapper.updateHiddenDangerBaseName(hiddenBusinessId,manualInvestigation.getName());
// 保存辖区和街道
highDangerMapper.updateSectionCommunity(hidden_businessId, manualInvestigation.getXqcode(), manualInvestigation.getJdcode());
highDangerMapper.updateSectionCommunity(hiddenBusinessId, manualInvestigation.getXqcode(), manualInvestigation.getJdcode());
// 第一页:基础数据
// 先删除,后添加
// highDangerMapper.delSectionInfo(hidden_businessId);
highDangerMapper.delSectionInfo(hiddenBusinessId);
// 保存基础数据(步骤1)
// tht_section_info
@ -700,13 +606,13 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
if (manualInvestigation.getIfCross() != null && "1".equals(manualInvestigation.getIfCross())) {
basicInfoVO.setRoadCode(manualInvestigation.getSectionCode());
}
basicInfoVO.setBusinessId(hidden_businessId);
basicInfoVO.setBusinessId(hiddenBusinessId);
// 更新列表
highDangerMapper.updateSectionInfo(basicInfoVO);
highDangerMapper.insertSectionInfo(basicInfoVO);
}
// // 判断数据库是否存在统计数据
// ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(hidden_businessId);
// ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(hiddenBusinessId);
//
// if (sectionTraffic != null) {
// // 更新统计数据(步骤2)
@ -717,19 +623,19 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// }
// 查询base表的pcCount值
HighDangerBase higDangerDetail = highDangerMapper.getHigDangerDetail(hidden_businessId);
HighDangerBase higDangerDetail = highDangerMapper.getHigDangerDetail(hiddenBusinessId);
String pcCount = higDangerDetail.getPcCount();
manualInvestigation.setPcCount(pcCount);
/*
保存 Extra
*/
// 先删除二级页面数据
highDangerMapper.deleteThtHiddenDataCollectConfigExtra(hidden_businessId);
highDangerMapper.deleteThtHiddenDataCollectConfigExtra(hiddenBusinessId);
// 保存重点排查关联隐患项问题详情
for (ThtHiddenDataCollectConfigExtra extra : manualInvestigation.getExtraConfigs()) {
extra.setPcCount(pcCount);
extra.setBusinessId(hidden_businessId);
extra.setBusinessId(hiddenBusinessId);
highDangerMapper.saveThtHiddenDataCollectConfigExtra(extra);
}
@ -737,7 +643,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
保存 Describe
*/
// 隐患排查表--先删除,后更新(2024/10/29 -- 改为软删除)
highDangerMapper.updateRoadInfo(hidden_businessId);
highDangerMapper.updateRoadInfo(hiddenBusinessId);
for (HiddenDangerDTO details : manualInvestigation.getDescribe()) {
// 是否为重点隐患(1)
if("1".equals(details.getPcType())) {
@ -762,11 +668,11 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 随机生成UUID
String uuidString = UUID.randomUUID().toString().replace("-", "");
details.setNid(uuidString);
details.setBusinessId(hidden_businessId);
details.setBusinessId(hiddenBusinessId);
details.setPcCount(manualInvestigation.getPcCount());
// 保存重点排查数据(保存到 tht_hidden_danger_road_info)
highDangerMapper.saveDangerExtra(details);
highDangerMapper.saveRoadInfo(details);
// 删除提交过的隐患图片
governmentService.deleteAttache3(manualInvestigation.getBusinessId());
@ -791,7 +697,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 文件名
thtAttachs.setAttachName(accachName);
// 隐患id
thtAttachs.setBusinessId(hidden_businessId);
thtAttachs.setBusinessId(hiddenBusinessId);
// 排查次数
thtAttachs.setPcCount(pcCount);
// 最后修改时间
@ -809,7 +715,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// ThtTimeLineDTO thtTimeLineDTO = new ThtTimeLineDTO();
// thtTimeLineDTO.setNid(String.valueOf(uuid));
// thtTimeLineDTO.setInsertTime(date);
// thtTimeLineDTO.setBusinessId(hidden_businessId);
// thtTimeLineDTO.setBusinessId(hiddenBusinessId);
// thtTimeLineDTO.setStatus("10");
// thtTimeLineDTO.setTitle("隐患排查");
// thtTimeLineDTO.setLastModDate(date);
@ -823,7 +729,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 暂存数据
if (manualInvestigation.getTemporary() == 0) {
lock.unlock();
// highDangerMapper.updateTemporary(manualInvestigation.getBusinessId(), "99");
log.info("/saveManualInvestigation(保存 & 暂存人工排查)接口返回, 返回数据:{},{}", "数据已暂存", manualInvestigation);
return ServerResponse.ok("数据已暂存", manualInvestigation);
@ -832,19 +737,19 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
else if (manualInvestigation.getTemporary() == 1) {
// 提交时清空当前操作人
highDangerMapper.updateCurOperator(null,null, hidden_businessId);
highDangerMapper.updateCurOperator(null,null, hiddenBusinessId);
log.info("/saveManualInvestigation(保存 & 暂存人工排查)接口返回, 返回数据:{},{}", "数据已保存", manualInvestigation);
highDangerMapper.updateTemporaryStatus(hidden_businessId,"1");
highDangerMapper.updateTemporaryStatus(hiddenBusinessId,"1");
//隐患项不为空时,修改tht_hidden_danger_road
String hdFlag = "0";
if (CollectionUtils.isNotEmpty(manualInvestigation.getDescribe())) {
hdFlag = "1";
}
highDangerMapper.updateDangerRoad(hdFlag, hidden_businessId, pcCount, manualInvestigation.getOperator());
highDangerMapper.updateDangerRoad(hdFlag, hiddenBusinessId, pcCount, manualInvestigation.getOperator());
ThtApprove thtAApprove = new ThtApprove();
thtAApprove.setNid(nid);
thtAApprove.setBusinessId(hidden_businessId);
thtAApprove.setBusinessId(hiddenBusinessId);
thtAApprove.setOperator(manualInvestigation.getLastModeUser());
thtAApprove.setStatus("0");
thtAApprove.setOperateTime(date);
@ -852,8 +757,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
thtAApprove.setLastModDate(date);
thtApproveService.save(thtAApprove);
// 琐释放
lock.unlock();
return ServerResponse.ok("数据已保存", manualInvestigation);
}
// 新增
@ -861,7 +764,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
ThtApprove thtAApprove = new ThtApprove();
// String uuidString = uuid.toString().replace("-", "");
thtAApprove.setNid(nid);
thtAApprove.setBusinessId(hidden_businessId);
thtAApprove.setBusinessId(hiddenBusinessId);
thtAApprove.setOperator(manualInvestigation.getLastModeUser());
thtAApprove.setStatus("0");
thtAApprove.setOperateTime(date);
@ -879,17 +782,18 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
@Override
public List<HighDangerBase> selectProcessingList(String nuserId) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 获取待办数据中当前操作人不为空,且时间最近的两条数据
List<HighDangerBase> highDangerBase = highDangerMapper.ProcessingDangerList(nuserId);
for (HighDangerBase dangerBase : highDangerBase) {
int delayHour = dangerBase.getDelayHour();
// 查询列表的超期时间、临期时间
int delayHour = dangerBase.getDelayHour() - 1;
int delayDay = dangerBase.getDelayDay();
int nearDay = dangerBase.getNearDay();
int nearHour = dangerBase.getNearHour();
int nearHour = dangerBase.getNearHour() - 1;
// 时间规范
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String lastModDate = dateFormat.format(dangerBase.getLastModDate());
String curOperDate = dateFormat.format(dangerBase.getCurOperDate());
// dangerBase.setLastModDateStr(lastModDate);
@ -899,61 +803,58 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
dangerBase.setEnumname("排查中");
}
// 获取单条查询数据的当前操作人id
String nuserId1 = dangerBase.getCurOperUser();
// 根据操作人id获取操作人用户名
if(nuserId1.isEmpty()){
continue;
}
Operator operatorById = operatorMapper.getOperatorById(nuserId1);
dangerBase.setCuserName(operatorById.getCusername());
// 正常
String deadlineStatus = "剩余" + Math.abs(nearDay) + "天" + (Math.abs(nearHour) == 24 ? 23 : Math.abs(nearHour) == 0 ? 1 : Math.abs(nearHour)) + "小时";
if (dangerBase.getTimeStatus() == null || dangerBase.getTimeStatus().equals("9")) {
if(Math.abs(nearDay) == 0){
dangerBase.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时");
// 判断如果剩余天数和剩余小时数都是0,输出剩余不到一小时
if(nearHour == 0){
dangerBase.setDeadlineStatus(ONE_HOURS);
}
}else{
// 等于24变成23,等于0变为1
dangerBase.setDeadlineStatus("剩余"+ Math.abs(nearDay) +"天" + (Math.abs(nearHour) == 24 ? 23 : Math.abs(nearHour) == 0 ? 1 : Math.abs(nearHour)) +"小时");
dangerBase.setDeadlineStatus(deadlineStatus);
dangerBase.setDeadlineType("3");
}
// base.setDeadlineStatus("正常");
// base.setDeadlineType("3");
}
// 临期
if(Objects.equals(dangerBase.getTimeStatus(), "2")){
// 判断如果剩余天数和剩余小时数都是0,输出剩余不到一小时
if(Math.abs(nearDay) == 0){
dangerBase.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时");
if(nearHour == 0){
dangerBase.setDeadlineStatus(ONE_HOURS);
}
} else {
// 等于24变成23,等于0变为1
dangerBase.setDeadlineStatus(deadlineStatus);
}
dangerBase.setDeadlineType("3");
dangerBase.setDeadlineType("2");
}
// 超期
if (Objects.equals(dangerBase.getTimeStatus(), "1")) {
if (delayDay == 0) {
dangerBase.setDeadlineStatus("超期" + delayHour + "小时");
dangerBase.setDeadlineStatus("超期" + Math.abs(delayHour) + "小时");
if(delayHour == 0){
dangerBase.setDeadlineStatus("超期不足一小时");
}
} else if (delayHour == 0) {
dangerBase.setDeadlineStatus("超期" + delayDay + "天");
dangerBase.setDeadlineStatus("超期" + Math.abs(delayDay) + "天");
} else {
dangerBase.setDeadlineStatus("超期" + delayDay + "天" + delayHour + "小时");
dangerBase.setDeadlineStatus("超期" + Math.abs(delayDay) + "天" + Math.abs(delayHour) + "小时");
}
dangerBase.setDeadlineType("1");
}
if (Objects.equals(dangerBase.getTimeStatus(), "2")) {
if (nearDay == 0) {
dangerBase.setDeadlineStatus("临期" + nearHour + "小时");
if(delayHour == 0){
dangerBase.setDeadlineStatus("临期不足一小时");
}
} else if (nearHour == 0) {
dangerBase.setDeadlineStatus("临期" + nearDay + "天");
} else {
dangerBase.setDeadlineStatus("临期" + nearDay + "天" + nearHour + "小时");
}
dangerBase.setDeadlineType("2");
}
// 展示条件
dangerBase.setEnumname(dangerBase.getEnumname());
// dangerBase.setDeadlineStatus("正常");
}
return highDangerBase;
}
@ -964,30 +865,13 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
endTime = formatter.format(new Date());
}
String cdepartmentid = null;
String departmentid = null;
// 去掉两侧的空格
search = search.trim();
departmentid = configService.getDepartmentJurisdiction(highDangerBaseVO.getNuserid());
// search = search.replaceAll(" ","");
// 获取当前操作的对象,用于查找对应的部
// Operator operatorById = operatorMapper.getOperatorById(highDangerBaseVO.getNuserid());
// if (operatorById != null) {
// cdepartmentid = operatorById.getCdepartmentid();
// } else {
// return ServerResponse.error("未找到当前用户");
// }
//
// if (!Objects.equals(operatorById.getNlevel(), "2")) {
// // 取部门的前六位
// departmentid = cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
// }
// int termTime = Integer.parseInt(configureMapper.getTermTime());
//Page<HighDangerBase> page = new Page<>(pageNum, pageSize);
if(!("1".equals(approve) && "3".equals(classification))){
PageHelper.startPage(pageNum, pageSize);
PageMethod.startPage(pageNum, pageSize);
}
// 将要查询的状态和部门id查询数据库,获得隐患排查表
List<HighDangerBase> statusCounts = highDangerMapper.getHigDangerDealt(highDangerBaseVO.getStatus(), departmentid, search, highDangerBaseVO.getNuserid(), classification, approve, startTime, endTime);
@ -1000,9 +884,8 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
base.setEnumname("排查中");
}
// 格式化排查开始时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if(base.getPcStartTime() != null){
base.setPcStartTimeStr(sdf.format(base.getPcStartTime()));
base.setPcStartTimeStr(dateFormat.format(base.getPcStartTime()));
}
// 查询列表的超期时间、临期时间
@ -1050,7 +933,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
}
// 当前状态
if (Objects.equals(base.getStatus(), "0") || Objects.equals(thtApprove.getStatus(), "10")) {
if (Objects.equals(base.getStatus(), "0") || Objects.equals(base.getStatus(), "10")) {
base.setEnumname("排查中");
} else if (Objects.equals(base.getStatus(), "20")) {
base.setEnumname("治理中");
@ -1070,27 +953,42 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
} else {
base.setEnumname(base.getEnumname() + " " + format);
}
// if (Objects.equals(base.getApproveStatus(), "1")) {
// approveTime = "一次审批";
// base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + format);
// }
// else if (Objects.equals(base.getApproveStatus(), "2")) {
// approveTime = "二次审批";
// base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + format);
// } else {
// base.setEnumname(base.getEnumname() + " " + format);
// }
}
}
// 正常
String deadlineStatus = "剩余" + Math.abs(nearDay) + "天" + (Math.abs(nearHour) == 24 ? 23 : Math.abs(nearHour) == 0 ? 1 : Math.abs(nearHour)) + "小时";
if (base.getTimeStatus() == null || base.getTimeStatus().equals("9")) {
if (base.getTimeStatus() == null || "9".equals(base.getTimeStatus())) {
if(Math.abs(nearDay) == 0){
base.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时");
if(nearHour == 0){
base.setDeadlineStatus(ONE_HOURS);
}
}else{
// 等于24变成23,等于0变为1
base.setDeadlineStatus(deadlineStatus);
base.setDeadlineType("3");
}
// base.setDeadlineStatus("正常");
// base.setDeadlineType("3");
}
// 临期
if(Objects.equals(base.getTimeStatus(), "2")){
if(Math.abs(nearDay) == 0){
base.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时");
if(nearHour == 0){
base.setDeadlineStatus(ONE_HOURS);
}
} else {
// 等于24变成23,等于0变为1
base.setDeadlineStatus(deadlineStatus);
@ -1100,15 +998,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 超期
if (Objects.equals(base.getTimeStatus(), "1")) {
// // 获取相差的时间戳
// double timeDiffSeconds = Double.parseDouble(base.getTimeDiffEnd());
// // 计算天数
// int days = (int)Math.floor(timeDiffSeconds / (24 * 3600));
// // 计算秒数
// double remainingSeconds = timeDiffSeconds % (24 * 3600);
// // 计算小时数
// int hours = (int)Math.ceil(remainingSeconds / 3600);
if (delayDay == 0) {
base.setDeadlineStatus("超期" + Math.abs(delayHour) + "小时");
if(delayHour == 0){
@ -1121,20 +1010,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
}
base.setDeadlineType("1");
}
// if (Objects.equals(base.getTimeStatus(), "2")) {
//
// if (nearDay == 0) {
// base.setDeadlineStatus("临期" + Math.abs(nearHour) + "小时");
// if(delayHour == 0){
// base.setDeadlineStatus("临期不足一小时");
// }
// } else if (nearHour == 0) {
// base.setDeadlineStatus("临期" + Math.abs(nearDay) + "天");
// } else {
// base.setDeadlineStatus("临期" + Math.abs(nearDay) + "天" + Math.abs(nearHour) + "小时");
// }
// base.setDeadlineType("2");
// }
if("1".equals(approve) && "3".equals(classification)){
LinkedList<Map<String, Double>> pointList = new LinkedList<>();

@ -1,6 +1,5 @@
package com.hisense.hiatmp.server_api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.hisense.hiatmp.model.common.DTO.ThtTricycleInfoBaseDTO;
import com.hisense.hiatmp.model.common.VO.TricycleListVO;
@ -16,7 +15,8 @@ import com.hisense.hiatmp.server_api.model.StreetCommunity;
import com.hisense.hiatmp.server_api.service.TricycleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
@ -44,6 +44,16 @@ public class TricycleServiceImpl implements TricycleService {
@Autowired
ThtTricycleWarningBaseMapper tricycleWarningBaseMapper;
private static final Random RANDOM;
static {
try {
RANDOM = SecureRandom.getInstanceStrong();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public List<TricycleListVO> getTricycleList(int roleFlag,String cdepartmentid,String stauts,String search) {
List<TricycleListVO> tricycleList = tricycleInfoBaseMapper.getTricycleList(roleFlag, cdepartmentid,stauts,search);
@ -64,18 +74,6 @@ public class TricycleServiceImpl implements TricycleService {
@Override
public List<TricycleWarningListVO> getTricycleWarningList(String cdepartmentid, int roleFlag, String status,String search) {
// List<TricycleListVO> tricycleList = tricycleInfoBaseMapper.getTricycleList(roleFlag, cdepartmentid,stauts);
//
// for (int i = 0; i < tricycleList.size(); i++) {
// String villageCommunity = tricycleList.get(i).getVillageCommunity();
// StreetCommunity streetCommunityBySq = configMapper.getStreetCommunityBySq(villageCommunity);
// if(streetCommunityBySq == null){
// continue;
// }
// tricycleList.get(i).setVillageCommunity(streetCommunityBySq.getSqname());
// tricycleList.get(i).setStreetCommunity(streetCommunityBySq.getJdname());
// }
return tricycleWarningBaseMapper.getTricycleWarningList(cdepartmentid, roleFlag, status,search);
}
@ -87,18 +85,15 @@ public class TricycleServiceImpl implements TricycleService {
infoBaseDTO.setStatus("1");
UpdateWrapper<ThtTricycleInfoBaseDTO> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("vehicle_id", infoBaseDTO.getVehicleId());
// ThtTricycleInfoBaseDTO thtTricycleInfoBaseDTO = tricycleInfoBaseMapper.selectOne(new QueryWrapper<ThtTricycleInfoBaseDTO>().lambda().eq(ThtTricycleInfoBaseDTO::getVehicleId,infoBaseDTO.getVehicleId()));
return tricycleInfoBaseMapper.update(infoBaseDTO,updateWrapper);
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
Random random = new Random();
int i = random.nextInt(90000) + 10000;
int i = RANDOM.nextInt(90000) + 10000;
String vehicleId = "DJ" + LocalDate.now().format(formatter) + i;
infoBaseDTO.setVehicleId(vehicleId);
// if(infoBaseDTO.getVehicleLicense())
UUID uuid = UUID.fromString(UUID.randomUUID().toString());
String id = uuid.toString().replaceAll("-", "");
String id = uuid.toString().replace("-", "");
infoBaseDTO.setId(id);
infoBaseDTO.setStatus("1");
return tricycleInfoBaseMapper.insert(infoBaseDTO);
@ -137,6 +132,7 @@ public class TricycleServiceImpl implements TricycleService {
return tricycleWarningBaseMapper.saveTricycleWarningHandle(resultsVO);
}
@Override
public List<TricycleWarningDetailVO> getWarningDetails(String warningId){
return tricycleWarningBaseMapper.getWarningDetails(warningId);
}
@ -144,12 +140,10 @@ public class TricycleServiceImpl implements TricycleService {
@Override
public int updateWarningStatus(String handleStatus,String warningId) {
return tricycleWarningBaseMapper.updateWarningStatus(handleStatus,warningId);
// return 0;
}
@Override
public int updateWarningDistributionStatus(String distributionStatus,String warningId) {
return tricycleWarningBaseMapper.updateWarningDistributionStatus(distributionStatus,warningId);
// return 0;
}
}

@ -23,6 +23,7 @@ import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
@ -31,14 +32,14 @@ import java.util.UUID;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static cn.hutool.core.util.CharsetUtil.UTF_8;
@Component
@Data
@Slf4j
@Service
public class FTPUtils {
public static final int imageCutSize = 300;
@Value("${spring.ftp.username}") //用户名
private String userName;
@ -78,7 +79,6 @@ public class FTPUtils {
log.info("FTP断开链接。。。。");
throw new IOException("failed to connect to the FTP Server:" + ip);
}
//ftpClient.changeWorkingDirectory(CURRENT_DIR);
String date = DateUtil.format(new Date(),"yyyyMMdd");
//ftpClient.makeDirectory(CURRENT_DIR + "/" + date);
//进入文件目录
@ -87,7 +87,6 @@ public class FTPUtils {
ftpClient.setBufferSize(1024 * 1024 * 10);
ftpClient.enterLocalPassiveMode();
// 上传文件到ftp
returnValue = ftpClient.storeFile(fileName, buffIn);
@ -238,7 +237,7 @@ public class FTPUtils {
int reply;
try {
ftpClient = new FTPClient();
ftpClient.setControlEncoding("UTF-8");
ftpClient.setControlEncoding(UTF_8);
ftpClient.enterLocalPassiveMode();
// ftpClient.setFileTransferMode(FTP.STREAM_TRANSFER_MODE);
ftpClient.connect(ip, port);
@ -308,7 +307,7 @@ public class FTPUtils {
public FTPClient getConnect() throws IOException {
FTPClient ftp = new FTPClient();
ftp.setControlEncoding("UTF-8");
ftp.setControlEncoding(UTF_8);
// 连接FTP服务器
ftp.connect(ip, port);
// 登录
@ -337,7 +336,7 @@ public class FTPUtils {
try {
ftp = getConnect();
ftp.enterLocalPassiveMode();
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.changeWorkingDirectory(CURRENT_DIR);
ftp.retrieveFile(fileName,outputStream);
} catch (Exception e) {
@ -367,7 +366,7 @@ public class FTPUtils {
/*
文件上传逻辑
*/
public ServerResponse<?> ftpUpload(MultipartFile mfile,String position,String longitude,String latitude){
public ServerResponse ftpUpload(MultipartFile mfile,String position,String longitude,String latitude){
Lock lock = new ReentrantLock();
@ -390,7 +389,7 @@ public class FTPUtils {
String dFileName = UUID.randomUUID() + substring;
String url = "";
try {
try{
Date currentDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDate = sdf.format(currentDate);
@ -401,7 +400,6 @@ public class FTPUtils {
log.info("-----------------------图片文件类型,开始压缩图片上传。。。");
// 图片压缩,缩小文件尺寸
byte[] bytes = mfile.getBytes();
BufferedImage read = ImageIO.read(new ByteArrayInputStream(bytes));
BufferedImage bufferedImage = Thumbnails.of(new ByteArrayInputStream(bytes))
.size(800, 800)
.outputQuality(0.8)
@ -429,7 +427,7 @@ public class FTPUtils {
log.info("Unicode转中文String:{}",pos);
// 水印文字内容
String watermarkText = new String((pos + "\n" + formattedDate + "\n经度: " + longitude + " 纬度: " + latitude).getBytes("UTF-8"), "UTF-8");
String watermarkText = new String((pos + "\n" + formattedDate + "\n经度: " + longitude + " 纬度: " + latitude).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
log.info("水印信息String:{}",watermarkText);
String[] lines = watermarkText.split("\n");
// 将水印文字按换行符分割成多行
@ -457,13 +455,10 @@ public class FTPUtils {
url = uploadToFtp(mfile.getInputStream(), originalFilename, false);
}
} catch (Exception e) {
// 默认图片
// url = "https://ts1.cn.mm.bing.net/th/id/R-C.987f582c510be58755c4933cda68d525?rik=C0D21hJDYvXosw&riu=http%3a%2f%2fimg.pconline.com.cn%2fimages%2fupload%2fupc%2ftx%2fwallpaper%2f1305%2f16%2fc4%2f20990657_1368686545122.jpg&ehk=netN2qzcCVS4ALUQfDOwxAwFcy41oxC%2b0xTFvOYy5ds%3d&risl=&pid=ImgRaw&r=0";
e.printStackTrace();
return ServerResponse.error("文件上传失败");
}finally {
stopWatch.stop();
// System.out.println("代码执行时间为:" + stopWatch.getTime() + " 毫秒");
log.info("------------------上传文件用时:{} 毫秒",stopWatch.getTotalTimeMillis());
lock.unlock();
log.info("------------------文件上传锁释放");

@ -2,18 +2,28 @@ package com.hisense.hiatmp.server_api.utils;
import org.springframework.stereotype.Component;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
/**
* @Author: ZangZhipeng
* @Description: TODO
* @DateTime: 2024/11/8 16:53
**/
@Component
public class HiddenDangerUtils {
private static Random random;
static {
try {
random = SecureRandom.getInstanceStrong();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
public String randomNumber(int number){
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < number; i++) {
sb.append(random.nextInt(10));

@ -75,9 +75,7 @@
</insert>
<select id="getStatusCounts" resultType="com.hisense.hiatmp.model.common.HighDangerBaseNum">
SELECT
'Approve' AS status,
COUNT ( 0 )
SELECT 'Approve' AS status,COUNT( 0 )
FROM
(
SELECT
@ -114,12 +112,11 @@
WHERE
1 = 1
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid},'%'))
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
</if>
AND hdr.nid IS NOT NULL
AND hdb.status IN ( '0', '10', '20', '60' )
AND hdb.approve_status IN ( '1', '2' )
AND hdb.business_id IN ( SELECT ta.business_id FROM tht_approve ta )
) t1
UNION ALL
@ -579,10 +576,10 @@
<if test="status == 60 and approve == 2">
and hdb.business_id in(
select ta.business_id from tht_approve ta
-- 过滤驳回的数据
WHERE ta.operate_content in ('-1','1','2')
and ta.OPERATOR = #{nuserid}
and ta.status in ('10','0','20','30','40',
'50','60') -- order by ta.operate_time desc
and ta.status in ('10','0','20','30','40','50','60')
)
</if>
@ -939,7 +936,7 @@
VALUES (nextval('test_id_seq2'), #{itemid}, #{order}, #{type}, #{name}, #{standar}, #{unit}, #{businessId})
</insert>
<insert id="saveDangerExtra">
<insert id="saveRoadInfo">
INSERT INTO tht_hidden_danger_road_info (nid, business_id, big_category, small_category, hd_term, hd_desc,
pc_count, hd_pic, hd_info, pc_type,scenes_id, last_mod_date)
VALUES (#{nid}, #{businessId}, #{bigCategory}, #{smallCategory}, #{hdTerm},
@ -992,7 +989,7 @@
FROM tht_hidden_danger_road_info e
INNER JOIN tht_hidden_scenes s ON e.scenes_id = s.nid
where e.business_id = #{businessId}
and if_delete in ('0',null)
and e.if_delete in ('0',null)
</select>
<select id="getImportDangerItems" resultType="com.hisense.hiatmp.model.common.ThtDangerItems">

Loading…
Cancel
Save