|
|
|
|
@ -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<>(); |
|
|
|
|
|