1113审批已完成数量修改

master
zhangqun 1 year ago
parent 773d3b4c27
commit fcae07375a
  1. 2
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/controller/FtpController.java
  2. 297
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/controller/HighDangerController.java
  3. 14
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/service/HighDangerService.java
  4. 360
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/service/impl/HighDangerBaseServiceImpl.java
  5. 16
      hiatmp-hidden-danger-server/src/main/java/com/hisense/hiatmp/server_api/utils/FTPUtils.java
  6. 56
      hiatmp-hidden-danger-server/src/main/resources/sql-mapper/HighDangerMapper.xml

@ -103,7 +103,7 @@ public class FtpController {
@RequestParam(defaultValue = "") String position,
@RequestParam(defaultValue = "") String longitude,
@RequestParam(defaultValue = "") String latitude,
HttpServletRequest request) throws Exception {
HttpServletRequest request) {
// 异步多线程实现
return CompletableFuture.supplyAsync(() -> {
log.info("/uploadFileToFtp(上传文件-通过file上传到ftp)接口被调用,调用ip: {}, 入参:{},{},{},{}", request.getRemoteAddr(),mfile,position,longitude,latitude);

@ -52,27 +52,21 @@ public class HighDangerController {
@Autowired
OperatorMapper operatorMapper;
@Autowired
HighDangerMapper highDangerMapper;
@Autowired
HighDangerService highDangerService;
@Autowired
ThtAttachsService thtAttachsService;
@Autowired
ThtApproveService thtApproveService;
@Autowired
ConfigureMapper configureMapper;
@Autowired
HiddenDangerUtils hiddenDangerUtils;
@Autowired
FTPUtils ftpUtils;
@Value("${spring.ftp.username}") //用户名
private String userName;
@ -161,7 +155,7 @@ public class HighDangerController {
// departmentid = cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
// }
departmentid = configService.getDepartmentJurisdiction(nuserid);
cdepartmentid = configService.getDepartmentJurisdiction(nuserid);
// 获取用户权限
List<String> roleById = operatorMapper.getRoleById(nuserid);
@ -175,7 +169,7 @@ public class HighDangerController {
role = 4;
}
List<HighDangerBaseNum> statusCounts = highDangerMapper.getStatusCounts(departmentid, nuserid, role);
List<HighDangerBaseNum> statusCounts = highDangerMapper.getStatusCounts(cdepartmentid, nuserid, role);
log.info("/getHighDangerStatusNum(查询各个状态的数据情况)接口数据返回,调用ip: {}, 出参:{}", request.getRemoteAddr(), statusCounts);
return ServerResponse.ok(statusCounts);
@ -198,287 +192,14 @@ public class HighDangerController {
HttpServletRequest request
) {
log.info("/getHigDangerDealt(查询首页各个状态的数据列表)接口被调用,调用ip: {}, 入参:{},{},{},{},{}", request.getRemoteAddr(), highDangerBaseVO, pageNum, pageSize, search,classification);
if (endTime == null) {
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);
}
// 将要查询的状态和部门id查询数据库,获得隐患排查表
List<HighDangerBase> statusCounts = highDangerMapper.getHigDangerDealt(highDangerBaseVO.getStatus(), departmentid, search, highDangerBaseVO.getNuserid(), classification, approve, startTime, endTime);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 遍历排查数据
for (HighDangerBase base : statusCounts) {
if("10".equals(base.getStatus()) || "0".equals(base.getStatus())){
base.setEnumname("排查中");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if(base.getPcStartTime() != null){
base.setPcStartTimeStr(sdf.format(base.getPcStartTime()));
}
String planEndTime = base.getPlanEndTime();
int delayHour = base.getDelayHour() - 1;
int delayDay = base.getDelayDay();
int nearDay = base.getNearDay();
int nearHour = base.getNearHour() - 1;
// 获取审批流程列表
List<ThtApprove> processRecord = highDangerService.getProcessRecord(base.getBusinessId());
// 待办状态数据
if (Objects.equals(approve, "1")) {
if (!processRecord.isEmpty()) {
// 取审批流程最后一条流程
ThtApprove thtApprove = processRecord.get(processRecord.size() - 1);
// 状态不是驳回
if (!Objects.equals(thtApprove.getApproveResult(), "-1")) {
String format = "";
String approveTime = "";
String approveStatus = "";
if(thtApprove.getOperateTime() != null){
format = dateFormat.format(thtApprove.getOperateTime());
}
if (Objects.equals(base.getApproveStatus(), "1")) {
approveTime = "一次审批";
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + approveStatus + " " + format);
}
if (Objects.equals(base.getApproveStatus(), "2")) {
approveTime = "二次审批";
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + approveStatus + " " + format);
}
}
}
} else if(Objects.equals(approve, "2")){ // 已完成
// 获取审批状态流程表
ThtApprove thtApprove = highDangerMapper.getProcessRecordByNid(base.getBusinessId(),highDangerBaseVO.getNuserid(),highDangerBaseVO.getStatus());
if (thtApprove != null) {
String approveTime = "";
String approveStatus = "";
String format = "";
if (thtApprove.getOperateTime() != null) {
format = dateFormat.format(thtApprove.getOperateTime());
}
// 当前状态
if (Objects.equals(base.getStatus(), "0") || Objects.equals(thtApprove.getStatus(), "10")) {
base.setEnumname("排查中");
} else if (Objects.equals(base.getStatus(), "20")) {
base.setEnumname("治理中");
} else if (Objects.equals(base.getStatus(), "60")) {
base.setEnumname("治理方案中");
} else if (Objects.equals(base.getStatus(), "50")) {
base.setEnumname("跟踪中");
}
// if (Objects.equals(approve, "2")) {
// if ("1".equals(thtApprove.getApproveResult())) {
// approveStatus = "通过";
// } else if ("-1".equals(thtApprove.getApproveResult())) {
// approveStatus = "驳回";
// }
// }
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);
}
}
}
// 正常
if (base.getTimeStatus() == null || base.getTimeStatus().equals("9")) {
if(Math.abs(nearDay) == 0){
base.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时");
}else{
// 等于24变成23,等于0变为1
base.setDeadlineStatus("剩余"+ Math.abs(nearDay) +"天" + (Math.abs(nearHour) == 24 ? 23 : Math.abs(nearHour) == 0 ? 1 : Math.abs(nearHour)) +"小时");
base.setDeadlineType("3");
}
// base.setDeadlineStatus("正常");
// base.setDeadlineType("3");
}
// 临期
if(Objects.equals(base.getTimeStatus(), "2")){
if(Math.abs(nearDay) == 0){
base.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时");
}else {
// 等于24变成23,等于0变为1
base.setDeadlineStatus("剩余" + Math.abs(nearDay) + "天" + (Math.abs(nearHour) == 24 ? 23 : Math.abs(nearHour) == 0 ? 1 : Math.abs(nearHour)) + "小时");
}
base.setDeadlineType("2");
}
// 超期
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){
base.setDeadlineStatus("超期不足一小时");
}
} else if (delayHour == 0) {
base.setDeadlineStatus("超期" + Math.abs(delayDay) + "天");
} else {
base.setDeadlineStatus("超期" + Math.abs(delayDay) + "天" + Math.abs(delayHour) + "小时");
}
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<>();
SectionDTO sectionDTO = new SectionDTO();
// 路口
if("1".equals(base.getIfCross())){
sectionDTO = highDangerMapper.getCrossingByCode(base.getCrossCode());
}
// 路段
if("2".equals(base.getIfCross())){
sectionDTO = highDangerMapper.getSectionByCode(base.getSectionCode());
}
if (sectionDTO == null) {
sectionDTO = new SectionDTO();
HighDangerRoad highDangerRoadByBusinessId = highDangerMapper.getHighDangerRoadByBusinessId(base.getBusinessId());
if(highDangerRoadByBusinessId != null){
String coordinate = highDangerRoadByBusinessId.getCoordinate();
String result = "";
String[] split = coordinate.split(",");
// 保存的坐标是奇数
if(split.length % 2 == 1){
int lastCommaIndex = coordinate.lastIndexOf(",");
result = coordinate.substring(0, lastCommaIndex);
}else{
result = coordinate;
}
sectionDTO.setPosition(result);
}else{
continue;
}
}
if(sectionDTO.getPosition() == null){
log.info("--------------最近距离问题businessId:{}",base.getBusinessId());
continue;
}
// 将单条路段的坐标点依次取出进行对比
String[] split = sectionDTO.getPosition().split(",");
Point Dpoint = new Point();
Double minDistance = 0.0;
Point point = new Point();
point.setX(longitude);
point.setY(latitude);
if(split.length % 2 == 1){
log.info("---------------------【列表查询】排查的路段坐标有误:{}",base);
}
/*
遍历坐标字符串
字符串格式: 119.996321,36.800453,119.996309,36.800294,119.996205,36.798752
*/
for (int i = 0; i < split.length; i += 2) {
double xPoint = Double.parseDouble(split[i]);
double yPoint = Double.parseDouble(split[i + 1]);
Map<String, Double> pointMap = new LinkedHashMap<>();
CoordinateConverter.AMap aMap = CoordinateConverter.transform(xPoint, yPoint);
// pointMap.put("longitude", aMap.getLongitude());
// pointMap.put("latitude", aMap.getLatitude());
//
// pointList.add(pointMap);
Dpoint.setX(aMap.getLongitude());
Dpoint.setY(aMap.getLatitude());
// 计算两点间的距离
Double pointDistance = highDangerService.getPointDistance(Dpoint, point);
if (minDistance == null || minDistance == 0) {
minDistance = pointDistance;
continue;
} else {
if (pointDistance < minDistance) {
minDistance = pointDistance;
}
}
}
// 设置距离
base.setDistance((int) Math.ceil(minDistance));
}
}
if("1".equals(approve) && "3".equals(classification)) {
// 根据距离排序
statusCounts.sort(new Comparator<HighDangerBase>() {
@Override
public int compare(HighDangerBase o1, HighDangerBase o2) {
return o1.getDistance() - o2.getDistance();
}
});
// 优先判断入参不合理的位置
if(highDangerBaseVO.getNuserid() == null){
return ServerResponse.error("入参用户名为空");
}
// 分页
PageInfo<HighDangerBase> pageInfo = new PageInfo<>(statusCounts);
log.info("/getHigDangerDealt(查询各个状态的数据列表)接口数据返回,调用ip: {}, 出参:{}", request.getRemoteAddr(), statusCounts);
return ServerResponse.ok(pageInfo);
PageInfo<HighDangerBase> highDealt = highDangerService.getHighDealt(highDangerBaseVO, pageNum, pageSize, search, approve, classification, longitude, latitude, startTime, endTime);
log.info("/getHigDangerDealt(查询各个状态的数据列表)接口数据返回,调用ip: {}, 出参:{}", request.getRemoteAddr(), highDealt);
return ServerResponse.ok(highDealt);
}
// 查询临期 & 超期任务
@ -1222,6 +943,7 @@ public class HighDangerController {
@GetMapping("/getProcessRecord")
public ServerResponse<?> getProcessRecord(@RequestParam String businessId) {
Integer flag = 1;
List<ThtApprove> processRecord = highDangerService.getProcessRecord(businessId);
LinkedHashMap<String, Object> processMap = new LinkedHashMap<>();
@ -1381,7 +1103,6 @@ public class HighDangerController {
LinkedList<ThtApprove> governmentFx = new LinkedList();
LinkedList<ThtApprove> governmentZL = new LinkedList();
Integer flag = 1;
List<ThtApprove> processRecord = highDangerService.getProcessRecord(businessId);
LinkedHashMap<String, Object> processMap = new LinkedHashMap<>();

@ -1,5 +1,6 @@
package com.hisense.hiatmp.server_api.service;
import com.github.pagehelper.PageInfo;
import com.hisense.hiatmp.model.common.*;
import com.hisense.hiatmp.model.common.DTO.SectionDTO;
import com.hisense.hiatmp.model.common.DTO.ThtTimeLineDTO;
@ -8,6 +9,8 @@ import com.hisense.hiatmp.model.dmr.Point;
import com.hisense.hiatmp.server_api.exception.MyCustomException;
import com.hisense.hiatmp.server_api.utils.CoordinateConverter;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -65,4 +68,15 @@ public interface HighDangerService {
ServerResponse<?> saveHiddenDanger(ManualInvestigation manualInvestigation) throws MyCustomException;
List<HighDangerBase> selectProcessingList(String nuserId);
PageInfo<HighDangerBase> getHighDealt(HighDangerBaseVO highDangerBaseVO,
Integer pageNum,
Integer pageSize,
String search,
String approve,
String classification, // 1 已完成 2 个人上报 3 系统下发
Float longitude,
Float latitude,
String startTime,
String endTime);
}

@ -2,6 +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.hisense.hiatmp.model.common.*;
import com.hisense.hiatmp.model.common.DTO.SectionDTO;
import com.hisense.hiatmp.model.common.DTO.ThtTimeLineDTO;
@ -10,11 +12,8 @@ import com.hisense.hiatmp.model.common.VO.SectionVO;
import com.hisense.hiatmp.server_api.exception.MyCustomException;
import com.hisense.hiatmp.server_api.mapper.HighDangerMapper;
import com.hisense.hiatmp.server_api.mapper.OperatorMapper;
import com.hisense.hiatmp.server_api.service.GovernmentService;
import com.hisense.hiatmp.server_api.service.HighDangerService;
import com.hisense.hiatmp.server_api.service.*;
import com.hisense.hiatmp.model.dmr.Point;
import com.hisense.hiatmp.server_api.service.ThtApproveService;
import com.hisense.hiatmp.server_api.service.ThtAttachsService;
import com.hisense.hiatmp.server_api.utils.CoordinateConverter;
import com.hisense.hiatmp.server_api.utils.HiddenDangerUtils;
import lombok.extern.slf4j.Slf4j;
@ -72,6 +71,9 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
@Autowired
private ThtApproveService thtApproveService;
@Autowired
private IConfigService configService;
/**
* 椭球参数
*/
@ -433,16 +435,13 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
@Override
public List<ThtApprove> getProcessRecord(String businessId) {
List<ThtApprove> processRecord = highDangerMapper.getProcessRecord(businessId);
return processRecord;
return highDangerMapper.getProcessRecord(businessId);
}
@Override
public HighDangerBase getCurOperator(String businessId) {
HighDangerBase curOperator = highDangerMapper.getCurOperator(businessId);
return curOperator;
return highDangerMapper.getCurOperator(businessId);
}
public ThtSectionInfoDTO getNewRoadInfo(String businessId) {
@ -471,6 +470,28 @@ 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();
@ -548,7 +569,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
--------------------------------------------------------------
*/
// 路段信息查询临时对象
SectionDTO sectionByCode = new SectionDTO();
SectionDTO sectionByCode;
// 判断是否是路口(ifCross:1路口,2路段)
if (Objects.equals(manualInvestigation.getIfCross(), "1")) {
// 路口数据将保存的SectionCode赋值给CrossCode
@ -645,6 +666,8 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 操作人
thtTimeLineDTO.setOperator(manualInvestigation.getOperator());
// 将生成的business_id存入manualInvestigation对象中
manualInvestigation.setBusinessId(hidden_businessId);
/*
分别插入三张表
@ -657,9 +680,10 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
insertTimeLine(thtTimeLineDTO);
}
// manualInvestigation.setBusinessId(hidden_businessId);
// 更新隐患名称(暂存/保存)
highDangerMapper.updateHiddenDangerBaseName(hidden_businessId,manualInvestigation.getName());
manualInvestigation.setBusinessId(hidden_businessId);
// 保存辖区和街道
highDangerMapper.updateSectionCommunity(hidden_businessId, manualInvestigation.getXqcode(), manualInvestigation.getJdcode());
@ -681,16 +705,16 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
highDangerMapper.updateSectionInfo(basicInfoVO);
}
// 判断数据库是否存在统计数据
ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(hidden_businessId);
if (sectionTraffic != null) {
// 更新统计数据(步骤2)
highDangerMapper.updateSectionTraffic(manualInvestigation);
} else {
// 保存统计数据(步骤2)
highDangerMapper.insertSectionTraffic(manualInvestigation);
}
// // 判断数据库是否存在统计数据
// ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(hidden_businessId);
//
// if (sectionTraffic != null) {
// // 更新统计数据(步骤2)
// highDangerMapper.updateSectionTraffic(manualInvestigation);
// } else {
// // 保存统计数据(步骤2)
// highDangerMapper.insertSectionTraffic(manualInvestigation);
// }
// 查询base表的pcCount值
HighDangerBase higDangerDetail = highDangerMapper.getHigDangerDetail(hidden_businessId);
@ -896,14 +920,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
// 超期
if (Objects.equals(dangerBase.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) {
dangerBase.setDeadlineStatus("超期" + delayHour + "小时");
@ -918,14 +934,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
dangerBase.setDeadlineType("1");
}
if (Objects.equals(dangerBase.getTimeStatus(), "2")) {
// // 获取相差的时间戳
// double timeDiffSeconds = Double.parseDouble(base.getTimeDiffStart());
// // 计算天数
// int days= (int)Math.floor(timeDiffSeconds / (24 * 3600));
// // 计算秒数
// double remainingSeconds = timeDiffSeconds % (24 * 3600);
// // 计算小时数
// int hours = (int)Math.ceil(remainingSeconds / 3600);
if (nearDay == 0) {
dangerBase.setDeadlineStatus("临期" + nearHour + "小时");
@ -948,4 +956,282 @@ public class HighDangerBaseServiceImpl implements HighDangerService {
return highDangerBase;
}
@Override
public PageInfo<HighDangerBase> getHighDealt(HighDangerBaseVO highDangerBaseVO, Integer pageNum, Integer pageSize, String search, String approve, String classification, Float longitude, Float latitude, String startTime, String endTime) {
if (endTime == null) {
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);
}
// 将要查询的状态和部门id查询数据库,获得隐患排查表
List<HighDangerBase> statusCounts = highDangerMapper.getHigDangerDealt(highDangerBaseVO.getStatus(), departmentid, search, highDangerBaseVO.getNuserid(), classification, approve, startTime, endTime);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 遍历排查数据
for (HighDangerBase base : statusCounts) {
// status是否是0或10,统一修改状态为“排查中”
if("10".equals(base.getStatus()) || "0".equals(base.getStatus())){
base.setEnumname("排查中");
}
// 格式化排查开始时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if(base.getPcStartTime() != null){
base.setPcStartTimeStr(sdf.format(base.getPcStartTime()));
}
// 查询列表的超期时间、临期时间
int delayHour = base.getDelayHour() - 1;
int delayDay = base.getDelayDay();
int nearDay = base.getNearDay();
int nearHour = base.getNearHour() - 1;
// 获取审批流程列表
List<ThtApprove> processRecord = getProcessRecord(base.getBusinessId());
// 待办状态数据
if (Objects.equals(approve, "1")) {
if (!processRecord.isEmpty()) {
// 取审批流程最后一条流程
ThtApprove thtApprove = processRecord.get(processRecord.size() - 1);
// 状态不是驳回
if (!Objects.equals(thtApprove.getApproveResult(), "-1")) {
String format = "";
String approveTime = "";
String approveStatus = "";
if(thtApprove.getOperateTime() != null){
format = dateFormat.format(thtApprove.getOperateTime());
}
if (Objects.equals(base.getApproveStatus(), "1")) {
approveTime = "一次审批";
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + approveStatus + " " + format);
}
if (Objects.equals(base.getApproveStatus(), "2")) {
approveTime = "二次审批";
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + approveStatus + " " + format);
}
}
}
} else if(Objects.equals(approve, "2")){ // 已完成
// 获取审批状态流程表
ThtApprove thtApprove = highDangerMapper.getProcessRecordByNid(base.getBusinessId(),highDangerBaseVO.getNuserid(),highDangerBaseVO.getStatus());
if (thtApprove != null) {
String approveTime = "";
String approveStatus = "";
String format = "";
if (thtApprove.getOperateTime() != null) {
format = dateFormat.format(thtApprove.getOperateTime());
}
// 当前状态
if (Objects.equals(base.getStatus(), "0") || Objects.equals(thtApprove.getStatus(), "10")) {
base.setEnumname("排查中");
} else if (Objects.equals(base.getStatus(), "20")) {
base.setEnumname("治理中");
} else if (Objects.equals(base.getStatus(), "60")) {
base.setEnumname("治理方案中");
} else if (Objects.equals(base.getStatus(), "50")) {
base.setEnumname("跟踪中");
}
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(Math.abs(nearDay) == 0){
base.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时");
}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)+"小时");
} else {
// 等于24变成23,等于0变为1
base.setDeadlineStatus(deadlineStatus);
}
base.setDeadlineType("2");
}
// 超期
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){
base.setDeadlineStatus("超期不足一小时");
}
} else if (delayHour == 0) {
base.setDeadlineStatus("超期" + Math.abs(delayDay) + "天");
} else {
base.setDeadlineStatus("超期" + Math.abs(delayDay) + "天" + Math.abs(delayHour) + "小时");
}
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<>();
SectionDTO sectionDTO = new SectionDTO();
// 路口
if("1".equals(base.getIfCross())){
sectionDTO = highDangerMapper.getCrossingByCode(base.getCrossCode());
}
// 路段
if("2".equals(base.getIfCross())){
sectionDTO = highDangerMapper.getSectionByCode(base.getSectionCode());
}
if (sectionDTO == null) {
sectionDTO = new SectionDTO();
HighDangerRoad highDangerRoadByBusinessId = highDangerMapper.getHighDangerRoadByBusinessId(base.getBusinessId());
if(highDangerRoadByBusinessId != null){
String coordinate = highDangerRoadByBusinessId.getCoordinate();
String result = "";
String[] split = coordinate.split(",");
// 保存的坐标是奇数
if(split.length % 2 == 1){
int lastCommaIndex = coordinate.lastIndexOf(",");
result = coordinate.substring(0, lastCommaIndex);
}else{
result = coordinate;
}
sectionDTO.setPosition(result);
}else{
continue;
}
}
if(sectionDTO.getPosition() == null){
log.info("--------------最近距离问题businessId:{}",base.getBusinessId());
continue;
}
// 将单条路段的坐标点依次取出进行对比
String[] split = sectionDTO.getPosition().split(",");
Point Dpoint = new Point();
Double minDistance = 0.0;
Point point = new Point();
point.setX(longitude);
point.setY(latitude);
if(split.length % 2 == 1){
log.info("---------------------【列表查询】排查的路段坐标有误:{}",base);
}
/*
遍历坐标字符串
字符串格式: 119.996321,36.800453,119.996309,36.800294,119.996205,36.798752
*/
for (int i = 0; i < split.length; i += 2) {
double xPoint = Double.parseDouble(split[i]);
double yPoint = Double.parseDouble(split[i + 1]);
Map<String, Double> pointMap = new LinkedHashMap<>();
CoordinateConverter.AMap aMap = CoordinateConverter.transform(xPoint, yPoint);
// pointMap.put("longitude", aMap.getLongitude());
// pointMap.put("latitude", aMap.getLatitude());
//
// pointList.add(pointMap);
Dpoint.setX(aMap.getLongitude());
Dpoint.setY(aMap.getLatitude());
// 计算两点间的距离
Double pointDistance = getPointDistance(Dpoint, point);
if (minDistance == null || minDistance == 0) {
minDistance = pointDistance;
continue;
} else {
if (pointDistance < minDistance) {
minDistance = pointDistance;
}
}
}
// 设置距离
base.setDistance((int) Math.ceil(minDistance));
}
}
if("1".equals(approve) && "3".equals(classification)) {
// 根据距离排序
statusCounts.sort(new Comparator<HighDangerBase>() {
@Override
public int compare(HighDangerBase o1, HighDangerBase o2) {
return o1.getDistance() - o2.getDistance();
}
});
}
// 分页
PageInfo<HighDangerBase> pageInfo = new PageInfo<>(statusCounts);
return pageInfo;
}
}

@ -348,7 +348,6 @@ public class FTPUtils {
}
}
public String ftpToHttp(String url){
String urlResult = "";
@ -429,15 +428,18 @@ public class FTPUtils {
String pos = StringEscapeUtils.unescapeJava(position);
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("UTF-8"), "UTF-8");
log.info("水印信息String:{}",watermarkText);
String[] lines = watermarkText.split("\n");
// 将水印文字按换行符分割成多行
int x = 10; // 水印在左边的位置
int y = 30; // 水印在顶部的位置
int lineHeight = g.getFontMetrics().getHeight(); // 获取文字行高
// 水印在左边的位置
int x = 10;
// 水印在顶部的位置
int y = 30;
// 获取文字行高
int lineHeight = g.getFontMetrics().getHeight();
for (String line : lines) {
g.drawString(line, x, y);
@ -457,6 +459,7 @@ public class FTPUtils {
} 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();
@ -468,7 +471,6 @@ public class FTPUtils {
return ServerResponse.ok(url);
}
public MultipartFile convertHeicToJpeg(MultipartFile heicFile) throws Exception {
File tempFile = File.createTempFile("temp", ".heic", new File("C:/Temp"));
heicFile.transferTo(tempFile);

@ -75,7 +75,9 @@
</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
@ -112,16 +114,17 @@
WHERE
1 = 1
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
AND hdr.belong_xq like concat(concat(#{cdepartmentid},'%'))
</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
SELECT 'Investigated' AS status, COUNT( 0 )
SELECT 'Investigated' AS status,COUNT ( 0 )
FROM
(
SELECT
@ -133,7 +136,7 @@
WHEN now( ) AT TIME ZONE'Asia/Shanghai' >= t1.nearEndTime
AND now( ) AT TIME ZONE'Asia/Shanghai' <= t1.planEndTime THEN
2
WHEN now( ) AT TIME ZONE'Asia/Shanghai' >= t1.planEndTime THEN
WHEN now( ) AT TIME ZONE'Asia/Shanghai' >= t1.nearEndTime THEN
1
END AS time_status,
FLOOR ( EXTRACT ( EPOCH FROM ( now( ) AT TIME ZONE'Asia/Shanghai' - planEndTime ) ) / ( 1440 * 60 ) ) delayDay,
@ -144,7 +147,7 @@
CEIL (
MOD ( CEIL ( EXTRACT ( EPOCH FROM ( planEndTime - now( ) AT TIME ZONE'Asia/Shanghai' ) ) ) :: INTEGER, 1440 * 60 ) :: FLOAT / 3600
) nearHour,
]]>
]]>
t1.*
FROM
(
@ -187,14 +190,18 @@
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
</if>
and hdb.pc_start_time is not null
AND hdr.nid IS NOT NULL
AND hdb.status IN ( '0', '10' )
AND COALESCE ( hdb.approve_status, '0' ) IN ( '0', '-1' ) Order by hdb.pc_start_time ASC ) t1 ) tmp_count
AND COALESCE ( hdb.approve_status, '0' ) IN ( '0', '-1' )
ORDER BY
hdb.pc_start_time ASC
) t1
) tmp_count
UNION ALL
SELECT 'Government' AS status, COUNT
( 0 )
SELECT 'Government' AS status, COUNT ( 0 )
FROM
(
SELECT
@ -217,7 +224,7 @@
CEIL (
MOD ( CEIL ( EXTRACT ( EPOCH FROM ( planEndTime - now( ) AT TIME ZONE'Asia/Shanghai' ) ) ) :: INTEGER, 1440 * 60 ) :: FLOAT / 3600
) nearHour,
]]>
]]>
t1.*
FROM
(
@ -243,7 +250,7 @@
hdr.cross_code,
COALESCE ( hdb.last_mod_date, hdb.insert_time ) AS hdb_last_mode_date,
COALESCE ( hdb.zl_end_time, hdb.zl_start_time + INTERVAL '1 day' * hdr.zl_day :: INTEGER ) AS planEndTime,
COALESCE ( hdb.zl_end_time, hdb.zl_start_time + INTERVAL '1 day' * hdr.zl_day :: INTEGER :: INTEGER ) - INTERVAL '3 day' AS nearEndTime,
COALESCE ( hdb.zl_end_time, hdb.zl_start_time + INTERVAL '1 day' * hdr.zl_day :: INTEGER ) - INTERVAL '3 day' AS nearEndTime,
bs.section_name,
bs.section_code
FROM
@ -260,10 +267,14 @@
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
</if>
and hdb.zl_start_time is not null
AND hdr.nid IS NOT NULL
AND hdb.status IN ( '20' )
AND COALESCE ( hdb.approve_status, '0' ) IN ( '0', '-1' )
Order by hdb.zl_start_time ASC ) t1 ) tmp_count
ORDER BY
hdb.zl_start_time ASC
) t1
) tmp_count
UNION ALL
@ -280,6 +291,7 @@
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
</if>
and hdb.pc_start_time is not null
<![CDATA[
AND NOW() >= COALESCE(hdb.pc_end_time, hdb.pc_start_time + INTERVAL '1 day' * tpc.param_value::INTEGER) - INTERVAL '3 day'
AND NOW() <= COALESCE ( hdb.pc_end_time, hdb.pc_start_time + INTERVAL '1 day' * tpc.param_value :: INTEGER )
@ -303,6 +315,7 @@
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
</if>
and hdb.pc_start_time is not null
<![CDATA[
AND NOW() >= COALESCE ( hdb.pc_end_time, hdb.pc_start_time + INTERVAL '1 day' * tpc.param_value :: INTEGER )
AND hdb.status in ('0','10')
@ -326,6 +339,7 @@
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
</if>
and hdb.zl_start_time is not null
<![CDATA[
AND NOW() >= COALESCE ( hdb.zl_end_time, hdb.zl_start_time + INTERVAL '1 day' * hdr.zl_day :: INTEGER ) - INTERVAL '3 day'
AND NOW() <= COALESCE ( hdb.zl_end_time, hdb.zl_start_time + INTERVAL '1 day' * hdr.zl_day :: INTEGER )
@ -349,6 +363,7 @@
<if test="cdepartmentid != null and cdepartmentid != ''">
AND hdr.belong_xq like concat(concat(#{cdepartmentid}::text,'%'))
</if>
and hdb.zl_start_time is not null
<![CDATA[
AND NOW() >= COALESCE ( hdb.zl_end_time, hdb.zl_start_time + INTERVAL '1 day' * hdr.zl_day :: INTEGER )
AND hdb.status = '20'
@ -482,25 +497,6 @@
group by (business_id)
) apr on hdb.business_id = apr.business_id
</if>
<!--<if test="status == 10 and approve == 2">
inner JOIN tht_approve ta ON ta.business_id = hdb.business_id
and ta.operator=#{nuserId}
and ta.operate_content='0'
and ta.status in ('10','0')
</if>
<if test="status == 20 and approve == 2">
inner JOIN tht_approve ta ON ta.business_id = hdb.business_id
and ta.operator=#{nuserId}
and ta.operate_content='0'
and ta.status ='20'
</if>
<if test="status == 60 and approve == 2">
inner JOIN tht_approve ta ON ta.business_id = hdb.business_id
and ta.operator=#{nuserId}
and ta.operate_content in ('-1','1','2')
and ta.status in ('10','0','20','30','40','50','60')
</if>-->
WHERE
1 = 1
AND hdr.nid is not null

Loading…
Cancel
Save