Browse Source

预警通知下发弹窗接口优化

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
6efa15777b
8 changed files with 153 additions and 9 deletions
  1. +20
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentReadController.java
  2. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/AccidentRead.java
  3. +48
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/QuestionCodeEnum.java
  4. +31
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java
  5. +40
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java
  6. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/IAccidentReadService.java
  7. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java
  8. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/QueryAccidentPageVO.java

+ 20
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentReadController.java View File

@@ -1,5 +1,10 @@
package com.tuoheng.admin.controller;

import com.tuoheng.admin.service.accidentread.IAccidentReadService;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@@ -9,6 +14,20 @@ import org.springframework.web.bind.annotation.RestController;
* @Date 2023/3/2
*/
@RestController
@RequestMapping("/accidentread")
@RequestMapping("/accidentRead")
public class AccidentReadController {

@Autowired
private IAccidentReadService accidentReadService;

/**
* 应急记录已读数据保存
* @return
*/
@PostMapping("/add/{accidentId}")
public JsonResult add(@PathVariable("accidentId") String accidentId){
return accidentReadService.add(accidentId);
}


}

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/AccidentRead.java View File

@@ -24,11 +24,11 @@ public class AccidentRead {
/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableId(value = "id", type = IdType.UUID)
private String id;

/**
* 应急时间ID
* 应急事件ID
*/
private String accidentId;


+ 48
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/QuestionCodeEnum.java View File

@@ -0,0 +1,48 @@
package com.tuoheng.admin.enums;

/**
* @Author ChengWang
* @Date 2023/3/14
*/
public enum QuestionCodeEnum {

LONGITUDINAL_CRACK("003000", "纵向裂缝"),
TRANSVERSE_CRACK("003002", "横向裂缝"),
RETICULAR_CRACK("003004", "网状裂纹"),
PIT_GROOVE("003001", "坑槽"),
BIOCKY_CRACK("003005", "块状裂纹"),
PONDING("003006", "积水"),
TURN_OVER("003007", "翻车"),
REAR_END_COLLISION("003008", "追尾");

/**
* 编号
*/
private String code;

/**
* 问题名称
*/
private String msg;

QuestionCodeEnum(String code, String msg){
this.code = code;
this.msg = msg;
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}
}

+ 31
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java View File

@@ -3,11 +3,12 @@ package com.tuoheng.admin.service.accident;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.AccidentRead;
import com.tuoheng.admin.enums.AccidentStatusEnum;
import com.tuoheng.admin.enums.FlagEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.mapper.AccidentReadMapper;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
@@ -15,7 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.sql.rowset.serial.SerialException;
import java.util.ArrayList;
import java.util.List;

/**
@@ -29,6 +30,9 @@ public class AccidentNoticeService {
@Autowired
private AccidentMapper accidentMapper;

@Autowired
private AccidentReadMapper accidentReadMapper;


/**
* 告警弹窗通知下发
@@ -36,7 +40,13 @@ public class AccidentNoticeService {
*/
public JsonResult notice() {
//当前登录用户
String tenantId = CurrentUserUtil.getTenantId();
//String tenantId = CurrentUserUtil.getTenantId();
String tenantId = "0";
//String userId = CurrentUserUtil.getUserId();
String userId = "e1df76387f28b93a523c97a3e0cf27f9";
if(StringUtils.isEmpty(userId)){
throw new ServiceException("当前用户id为空");
}
if(StringUtils.isEmpty(tenantId)){
throw new ServiceException("当前用户租户id为空");
}
@@ -49,6 +59,23 @@ public class AccidentNoticeService {
if(CollectionUtils.isEmpty(accidentList) || accidentList.size() == 0){
return JsonResult.success("巡检任务无应急记录产生");
}
return JsonResult.success(accidentList);
//当前用户对应的应急记为未读才出现弹窗
List<Accident> list = new ArrayList<>();
//获取当前用户下对应的应急已读数据
List<AccidentRead> accidentReadList = accidentReadMapper.selectList(new LambdaQueryWrapper<AccidentRead>()
.eq(AccidentRead::getUserId, userId).eq(AccidentRead::getStatus, 3));
if(CollectionUtils.isEmpty(accidentReadList) || accidentReadList.size()==0){
return JsonResult.success(accidentList);
}
//数据刷选
for (AccidentRead accidentRead : accidentReadList) {
for (Accident accident : accidentList) {
if (!accident.getId().equals(accidentRead.getAccidentId())){
list.add(accident);
}
}
}

return JsonResult.success(list);
}
}

+ 40
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java View File

@@ -1,10 +1,17 @@
package com.tuoheng.admin.service.accidentread;

import com.tuoheng.admin.entity.AccidentRead;
import com.tuoheng.admin.enums.AccidentEnum;
import com.tuoheng.admin.mapper.AccidentReadMapper;
import com.tuoheng.admin.service.accident.IAccidentService;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
@@ -15,5 +22,38 @@ import org.springframework.stereotype.Service;
@Slf4j
public class AccidentReadServiceImpl implements IAccidentReadService {

@Autowired
private AccidentReadMapper accidentReadMapper;

/**
* 应急记录已读数据保存
* @param accidentId
* @return
*/
@Override
public JsonResult add(String accidentId) {
//校验
if(StringUtils.isEmpty(accidentId)){
return JsonResult.error(AccidentEnum.DATA_IS_NULL.getCode(),AccidentEnum.DATA_IS_NULL.getMsg());
}
//当前用户信息
//String userId = CurrentUserUtil.getUserId();
String userId = "e1df76387f28b93a523c97a3e0cf27f9";
if(StringUtils.isEmpty(userId)){
throw new ServiceException("用户id为空");
}
AccidentRead accidentRead = new AccidentRead();
accidentRead.setAccidentId(accidentId);
accidentRead.setCreateTime(DateUtils.now());
accidentRead.setCreateUser(userId);
accidentRead.setUserId(userId);
accidentRead.setStatus(3);
int result = accidentReadMapper.insert(accidentRead);
if(result<=0){
return JsonResult.error();
}

return JsonResult.success();
}

}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/IAccidentReadService.java View File

@@ -2,10 +2,15 @@ package com.tuoheng.admin.service.accidentread;

import com.tuoheng.admin.entity.AccidentRead;
import com.tuoheng.common.core.common.IBaseService;
import com.tuoheng.common.core.utils.JsonResult;

/**
* @Author ChengWang
* @Date 2023/3/2
*/
public interface IAccidentReadService{


JsonResult add(String accidentId);

}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java View File

@@ -301,7 +301,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
for (InspectionFile inspectionFile : inspectionFileList) {
Accident accident = new Accident();
//问题类型为应急类型时添加数据
if(inspectionFile.getQuestionCode().equals(QuestionTypeEnum.PON_DING_NAME.getCode())){
if(inspectionFile.getQuestionCode().equals(QuestionCodeEnum.TURN_OVER.getCode()) || inspectionFile.getQuestionCode().equals(QuestionCodeEnum.REAR_END_COLLISION.getCode())){
accident.setTenantId(inspectionFile.getTenantId());
accident.setDeptId(deptId);
accident.setInspectionId(inspectionFile.getInspectionId());

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/QueryAccidentPageVO.java View File

@@ -12,6 +12,11 @@ import java.util.Date;
@Data
public class QueryAccidentPageVO {

/**
* 事故id
*/
private String id;

/**
* 公路代号
*/

Loading…
Cancel
Save