Commit 3f4bcb82 authored by 鲁鸿波's avatar 鲁鸿波

安全风险分析阶段多条数据报错bug

parent 44e364a2
...@@ -11,12 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,12 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import com.tongtech.tfw.backend.core.helper.StringHelper; import com.tongtech.tfw.backend.core.helper.StringHelper;
import com.tongtech.tfw.backend.core.helper.ObjectHelper; import com.tongtech.tfw.backend.core.helper.ObjectHelper;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tongtech.tfw.backend.common.biz.constants.BizConstants; import com.tongtech.tfw.backend.common.biz.constants.BizConstants;
...@@ -61,9 +56,9 @@ public class THazardAssessmentController extends SuperController ...@@ -61,9 +56,9 @@ public class THazardAssessmentController extends SuperController
@ApiOperation(value = "获取 安全风险分析 ", notes = "Get THazardAssessment By Id") @ApiOperation(value = "获取 安全风险分析 ", notes = "Get THazardAssessment By Id")
@GetMapping(value = "/get") @GetMapping(value = "/get")
public BaseResponse<THazardAssessmentDTO> getById(String workTypeId,String planId){ public BaseResponse<THazardAssessmentDTO> getById(@RequestParam(value = "workTypeId",required = false) String workTypeId,@RequestParam(value = "planId",required = false) String planId,@RequestParam(value = "completeTime",required = false) String completeTime){
BaseResponse<THazardAssessmentDTO> baseResponse=new BaseResponse<>(); BaseResponse<THazardAssessmentDTO> baseResponse=new BaseResponse<>();
THazardAssessmentDTO data= tHazardAssessmentService.getDetailsById(workTypeId,planId); THazardAssessmentDTO data= tHazardAssessmentService.getDetailsById(workTypeId,planId,completeTime);
baseResponse.setData(data); baseResponse.setData(data);
return baseResponse; return baseResponse;
} }
......
...@@ -16,7 +16,7 @@ public interface THazardAssessmentService extends SuperService<THazardAssessment ...@@ -16,7 +16,7 @@ public interface THazardAssessmentService extends SuperService<THazardAssessment
THazardAssessment addEntity(THazardAssessmentDTO tHazardAssessmentDTO); THazardAssessment addEntity(THazardAssessmentDTO tHazardAssessmentDTO);
THazardAssessmentDTO getDetailsById(String typeId,String planId); THazardAssessmentDTO getDetailsById(String typeId,String planId,String completeTime);
void initData(String workTypes, THazardWorkPlan tHazardWorkPlan); void initData(String workTypes, THazardWorkPlan tHazardWorkPlan);
} }
...@@ -18,6 +18,8 @@ import com.tongtech.tfw.backend.common.models.supers.SuperServiceImpl; ...@@ -18,6 +18,8 @@ import com.tongtech.tfw.backend.common.models.supers.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
/** /**
...@@ -53,9 +55,30 @@ public class THazardAssessmentServiceImpl extends SuperServiceImpl<THazardAssess ...@@ -53,9 +55,30 @@ public class THazardAssessmentServiceImpl extends SuperServiceImpl<THazardAssess
} }
@Override @Override
public THazardAssessmentDTO getDetailsById(String typeId,String planId) { public THazardAssessmentDTO getDetailsById(String typeId,String planId,String completeTime) {
THazardAssessment tHazardAssessment = this.getOne(new LambdaQueryWrapper<THazardAssessment>().eq(THazardAssessment::getWorkTypeId, typeId).eq(THazardAssessment::getPlanId, planId)); THazardAssessment tHazardAssessment = null;
if(StringUtils.isEmpty(completeTime)){
tHazardAssessment = this.getOne(new LambdaQueryWrapper<THazardAssessment>().eq(THazardAssessment::getWorkTypeId, typeId).eq(THazardAssessment::getPlanId, planId));
}else{
tHazardAssessment = this.getOne(new LambdaQueryWrapper<THazardAssessment>().eq(THazardAssessment::getWorkTypeId, typeId).eq(THazardAssessment::getPlanId, planId).eq(THazardAssessment::getCreateDate,completeTime));
}
if (StringUtils.isNull(tHazardAssessment)) { if (StringUtils.isNull(tHazardAssessment)) {
if(!StringUtils.isEmpty(completeTime)){
//可能计算的时候会有时间上的差异,减1后继续查询一次
//completeTime: 2025-08-19 08:57:04
//实际值2025-08-19 08:57:03
// 定义时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 将字符串解析为LocalDateTime对象
LocalDateTime dateTime = LocalDateTime.parse(completeTime, formatter);
// 减去1秒
LocalDateTime newDateTime = dateTime.minusSeconds(1);
// 格式化为字符串
completeTime = newDateTime.format(formatter);
tHazardAssessment = this.getOne(new LambdaQueryWrapper<THazardAssessment>().eq(THazardAssessment::getWorkTypeId, typeId).eq(THazardAssessment::getPlanId, planId).eq(THazardAssessment::getCreateDate,completeTime));
}else{
return null;
}
return null; return null;
} }
THazardAssessmentDTO tHazardAssessmentDTO = BeanHelper.beanToBean(tHazardAssessment, THazardAssessmentDTO.class); THazardAssessmentDTO tHazardAssessmentDTO = BeanHelper.beanToBean(tHazardAssessment, THazardAssessmentDTO.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment