Browse Source

待确认问题接口

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
736859fca0
9 changed files with 316 additions and 7 deletions
  1. +18
    -1
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/InspectionFileController.java
  2. +11
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/RoadInformationMapper.java
  3. +70
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/RoadInformation.java
  4. +23
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/query/InspectionFileQuery.java
  5. +4
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IInspectionFileService.java
  6. +100
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileServiceImpl.java
  7. +20
    -6
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java
  8. +63
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionFileInfoVo.java
  9. +7
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/RoadInformationMapper.xml

+ 18
- 1
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/InspectionFileController.java View File

@@ -1,11 +1,17 @@
package com.tuoheng.miniprogram.controller;

import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.miniprogram.entity.query.InspectionFileQuery;
import com.tuoheng.miniprogram.service.IInspectionFileService;
import com.tuoheng.miniprogram.service.IInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 问题管理 前端控制器
*
* @Author ChengWang
* @Date 2022/11/23
*/
@@ -14,7 +20,18 @@ import org.springframework.web.bind.annotation.RestController;
public class InspectionFileController {

@Autowired
private IInspectionService iInspectionService;
private IInspectionFileService iInspectionFileService;

/**
* 待确认问题
* @param query
* @return
*/
@GetMapping("/confirmedQuestion")
public JsonResult confirmedQuestion(InspectionFileQuery query){
return iInspectionFileService.confirmedQuestion(query);

}




+ 11
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/RoadInformationMapper.java View File

@@ -0,0 +1,11 @@
package com.tuoheng.miniprogram.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.miniprogram.entity.RoadInformation;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
public interface RoadInformationMapper extends BaseMapper<RoadInformation> {
}

+ 70
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/RoadInformation.java View File

@@ -0,0 +1,70 @@
package com.tuoheng.miniprogram.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.core.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
* @Author ChengWang
* @Date 2022/11/16
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("th_road")
public class RoadInformation extends BaseEntity {
private static final long serialVersionUID = 1L;

/**
* 租户id
*/
private String tenantId;

/**
* 公路名称
*/
private String name;

/**
* 公路代号
*/
private String code;

/**
* 起点经度
*/
private String startLongitude;

/**
* 起点纬度
*/
private String startLatitude;

/**
* 终点经度
*/
private String endLongitude;

/**
* 终点纬度
*/
private String endLatitude;

/**
* 备注
*/
private String remark;

/**
* 是否关联路段 true:关联 false:未关联
*/
@TableField(exist = false)
private boolean relation;




}

+ 23
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/query/InspectionFileQuery.java View File

@@ -0,0 +1,23 @@
package com.tuoheng.miniprogram.entity.query;

import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
@Data
public class InspectionFileQuery extends BaseQuery {

/**
* 任务id
*/
private String inspectionId;

/**
*租户id
*/
private String tenantId;

}

+ 4
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IInspectionFileService.java View File

@@ -1,8 +1,12 @@
package com.tuoheng.miniprogram.service;

import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.miniprogram.entity.query.InspectionFileQuery;

/**
* @Author ChengWang
* @Date 2022/11/23
*/
public interface IInspectionFileService {
JsonResult confirmedQuestion(InspectionFileQuery query);
}

+ 100
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileServiceImpl.java View File

@@ -1,9 +1,32 @@
package com.tuoheng.miniprogram.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.SecurityUserUtils;
import com.tuoheng.common.core.utils.StringUtils;
import com.tuoheng.miniprogram.dao.InspectionFileMapper;
import com.tuoheng.miniprogram.dao.InspectionMapper;
import com.tuoheng.miniprogram.dao.RoadInformationMapper;
import com.tuoheng.miniprogram.dao.UserMapper;
import com.tuoheng.miniprogram.entity.Inspection;
import com.tuoheng.miniprogram.entity.InspectionFile;
import com.tuoheng.miniprogram.entity.RoadInformation;
import com.tuoheng.miniprogram.entity.User;
import com.tuoheng.miniprogram.entity.query.InspectionFileQuery;
import com.tuoheng.miniprogram.service.IInspectionFileService;
import com.tuoheng.miniprogram.vo.InspectionFileInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
* @Author ChengWang
* @Date 2022/11/23
@@ -11,4 +34,81 @@ import org.springframework.stereotype.Service;
@Service
@Slf4j
public class InspectionFileServiceImpl implements IInspectionFileService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private UserMapper userMapper;

@Autowired
private RoadInformationMapper roadInformationMapper;




/**
*待确认问题 status状态为5
* @param query
* @return
*/
@Override
public JsonResult confirmedQuestion(InspectionFileQuery query) {
if(null==query.getLimit() && null == query.getPage()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
if(StringUtils.isEmpty(query.getInspectionId())){
return JsonResult.error("任务id为空");
}
//获取当前登录人
// String username = SecurityUserUtils.username();
// User user = userMapper.selectOne(Wrappers.<User>lambdaQuery()
// .eq(User::getUsername, username)
// .eq(User::getMark,1));
//查询当前对应的任务
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getId, query.getInspectionId())
.eq(Inspection::getMark, 1));
if(ObjectUtil.isNull(inspection)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//设置分页
IPage<InspectionFile> page = new Page<>(query.getPage(),query.getLimit());
//获取分页数据
IPage<InspectionFile> result = inspectionFileMapper.selectPage(page, Wrappers.<InspectionFile>lambdaQuery()
.eq(InspectionFile::getInspectionId, query.getInspectionId())
.eq(InspectionFile::getMark, 1)
.eq(InspectionFile::getStatus, 5));
//数据转换
IPage<InspectionFileInfoVo> pageData = result.convert(t -> {
InspectionFileInfoVo vo = Convert.convert(InspectionFileInfoVo.class, t);
//查询其他属性
//公路代号
RoadInformation roadInformation = roadInformationMapper.selectOne(Wrappers.<RoadInformation>lambdaQuery()
.eq(RoadInformation::getId, inspection.getRoadId()));
if(ObjectUtil.isNotNull(roadInformation)){
vo.setCode(roadInformation.getCode());
}
//任务名称
if (StringUtils.isNotEmpty(inspection.getName())) {
vo.setName(inspection.getName());
}
//任务时间
if (null != inspection.getExecutionStartTime()){
vo.setExecutionStartTime(inspection.getExecutionStartTime());
}
//缩略图
if (StringUtils.isNotEmpty(t.getFileThumbnail())) {
vo.setFileThumbnail(CommonConfig.imageURL + t.getFileThumbnail());
}

return vo;
});


return JsonResult.success(pageData);
}
}

+ 20
- 6
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java View File

@@ -2,6 +2,7 @@ package com.tuoheng.miniprogram.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -111,17 +112,18 @@ public class InspectionServiceImpl implements IInspectionService {
int problemsVerifiedNum = 0;
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery()
.eq(StringUtils.isNotEmpty(x.getId()), InspectionFile::getInspectionId, x.getId())
.eq(InspectionFile::getTenantId, 0));
.eq(InspectionFile::getTenantId, 0)
.eq(InspectionFile::getMark,1));
if(StringUtils.isEmpty(inspectionFileList)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
problemsVerifiedNum = inspectionFileList.size();
for (InspectionFile inspectionFile : inspectionFileList) {
if (5 == inspectionFile.getStatus()) {
problemsFoundNum += 1;
}
if (15 == inspectionFile.getStatus()) {
problemsVerifiedNum += 1;
}
}
//获取任务deptId1:1为部门任务 0为子部门任务
String deptId1 = query.getDeptId();
if(deptIdInt.equals(deptId)){
x.setFlag(1);
}else {
@@ -213,8 +215,20 @@ public class InspectionServiceImpl implements IInspectionService {
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getId, id));
inspection.setMark(0);
//判断当前任务下的问题是否存在,存在则删除
List<InspectionFile> inspectionFiles = inspectionFileMapper.selectList(new LambdaQueryWrapper<InspectionFile>()
.eq(InspectionFile::getInspectionId, id));
if(StringUtils.isEmpty(inspectionFiles)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
Integer num = 0;
for (InspectionFile inspectionFile : inspectionFiles) {
inspectionFile.setMark(0);
int i = inspectionFileMapper.updateById(inspectionFile);
num += i;
}
int count = inspectionMapper.updateById(inspection);
if(count<=0){
if(count<=0 && num !=inspectionFiles.size()){
return JsonResult.error();
}


+ 63
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionFileInfoVo.java View File

@@ -0,0 +1,63 @@
package com.tuoheng.miniprogram.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* @Author ChengWang
* @Date 2022/11/24
*/
@Data
public class InspectionFileInfoVo {

/**
* 主键id
*/
private String id;

/**
* 任务名称
*/
private String name;

/**
* 问题描述
*/
private String questionDesc;

/**
* 位置(公路代号)
*/
private String code;

/**
* 任务时间(巡检执行时间)
*/
@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm")
@JsonFormat(pattern = "yyyy/MM/dd HH:mm", timezone = "GMT+8")
private Date executionStartTime;

/**
* 状态:5待确认 10已忽略 15已确认 20已生成工单 25问题已处理
*/
private Integer status;

/**
* 缩略图
*/
private String fileThumbnail;

/**
* 原图
*/
private String fileOriginal;

/**
* 标记图
*/
private String fileImage;

}

+ 7
- 0
tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/RoadInformationMapper.xml View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.miniprogram.dao.RoadInformationMapper">

</mapper>

Loading…
Cancel
Save