Browse Source

问题列表修改

tags/v1.1.0^2
chenjiandong 1 year ago
parent
commit
6f11dde713
5 changed files with 208 additions and 33 deletions
  1. +3
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java
  2. +2
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrderQuestion.java
  3. +147
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/QuestionVO.java
  4. +3
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IQuestionService.java
  5. +53
    -31
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java

+ 3
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.request.*;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVO;
import com.tuoheng.admin.entity.vo.QuestionVO;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.common.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

@@ -38,7 +40,7 @@ public class QuestionController {
* @return
*/
@GetMapping("/page")
public JsonResult<IPage<Question>> page(QuestionQuery questionQuery) {
public JsonResult<IPage<QuestionVO>> page(QuestionQuery questionQuery) throws ParseException {
return JsonResult.success(questionService.queryPage(questionQuery));
}


+ 2
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrderQuestion.java View File

@@ -22,6 +22,8 @@ public class WorkOrderQuestion extends BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;

private Integer tenantId;

/**
* 巡检问题工单ID
*/

+ 147
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/QuestionVO.java View File

@@ -0,0 +1,147 @@
package com.tuoheng.admin.entity.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tuoheng.admin.entity.domain.Question;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* 巡检任务 新增或修改请求参数 2022/7/27
* @author : qiujinyang
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class QuestionVO {

private static final long serialVersionUID = 1L;

/**
* 工单生成状态
*/
private Integer wordOrderStatus;

/**
* 工单处理状态
*/
private Integer handleStatus;

/**
* 任务ID
*/
private Integer missionId;

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

/**
* 问题类型:病死树、林斑
*/
private String type;

/**
* 问题类型名称
*/
private String questionName;

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

/**
* 图片分析时间,可以通过这个时间来计算出坐标位置
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date analyseTime;

/**
* 文件编码
*/
private String fileCode;

/**
* 文件名称
*/
private String fileName;

/**
* 原图片位置
*/
private String fileOriginalUrl;

/**
* 分析后的图片位置
*/
private String fileMarkerUrl;

/**
* 经度
*/
private String lng;

/**
* 纬度
*/
private String lat;

/**
* 备注
*/
private String note;

/**
* 问题状态:1:确认,2:忽略,3:待确认
*/
private Integer status;


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

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;
}

+ 3
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IQuestionService.java View File

@@ -5,10 +5,12 @@ import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.request.*;
import com.tuoheng.admin.entity.vo.QuestionCountVO;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVO;
import com.tuoheng.admin.entity.vo.QuestionVO;
import com.tuoheng.common.common.IBaseService;
import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.JsonResult;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

@@ -26,7 +28,7 @@ public interface IQuestionService extends IBaseService<Question> {
* @param query
* @return
*/
IPage<Question> queryPage(QuestionQuery query);
IPage<QuestionVO> queryPage(QuestionQuery query) throws ParseException;

List<Question> distributed(QuestionQuery query);


+ 53
- 31
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java View File

@@ -6,20 +6,17 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.common.ServiceExceptionEnum;
import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.domain.QuestionType;
import com.tuoheng.admin.entity.domain.ThInspection;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.domain.*;
import com.tuoheng.admin.entity.request.*;
import com.tuoheng.admin.entity.vo.MissionVO;
import com.tuoheng.admin.entity.vo.QuestionCountVO;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVO;
import com.tuoheng.admin.entity.vo.QuestionVO;
import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.mapper.QuestionMapper;
import com.tuoheng.admin.mapper.QuestionTypeMapper;
import com.tuoheng.admin.mapper.ThInspectionMapper;
import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.admin.service.IQuestionTypeService;
import com.tuoheng.admin.utils.TimeUtil;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.JsonResult;
@@ -29,8 +26,10 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@@ -55,39 +54,61 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
@Autowired
private ThInspectionMapper inspectionMapper;

@Autowired
private WorkOrderQuestionMapper workOrderQuestionMapper;

@Autowired
private IQuestionTypeService questionTypeService;

private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

@Override
public IPage<Question> queryPage(QuestionQuery query) {
@Transactional(readOnly = true)
public IPage<QuestionVO> queryPage(QuestionQuery query) throws ParseException {
if(null == query.getPage() || null == query.getLimit()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
IPage<Question> pageData=null;
try {
// 获取分页数据
IPage<Question> page = new Page<>(query.getPage(), query.getLimit());

LambdaQueryWrapper<Question> questionLambdaQueryWrapper = new LambdaQueryWrapper<Question>()
.eq(ObjectUtil.isNotEmpty(query.getMissionId()), Question::getMissionId, query.getMissionId())
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName())
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType())
.eq(ObjectUtil.isNotEmpty(query.getStatus()), Question::getStatus, query.getStatus())
//.eq(Question::getTenantId, ShiroUtils.getTenantId())
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime);
if(ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())){
query.setStartTime(query.getStartTime()+" 00:00:00");
query.setEndTime(query.getEndTime()+" 23:59:59");
questionLambdaQueryWrapper.between(Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime()));
}
pageData = questionMapper.selectPage(page, questionLambdaQueryWrapper);
}catch (Exception e){
e.printStackTrace();
log.error("查询出错!");
// 获取分页数据
IPage<Question> page = new Page<>(query.getPage(), query.getLimit());

LambdaQueryWrapper<Question> questionLambdaQueryWrapper = new LambdaQueryWrapper<Question>()
.eq(ObjectUtil.isNotEmpty(query.getMissionId()), Question::getMissionId, query.getMissionId())
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName())
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType())
.eq(ObjectUtil.isNotEmpty(query.getStatus()), Question::getStatus, query.getStatus())
//.eq(Question::getTenantId, ShiroUtils.getTenantId())
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime);
if(ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())){
query.setStartTime(query.getStartTime()+" 00:00:00");
query.setEndTime(query.getEndTime()+" 23:59:59");
questionLambdaQueryWrapper.between(Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime()));
}
return pageData;
IPage<Question> pageData = questionMapper.selectPage(page, questionLambdaQueryWrapper);
List<Question> questions = pageData.getRecords();
List<QuestionVO> questionVOList = new ArrayList<>();
questions.forEach(question->{
QuestionVO questionVO = new QuestionVO();
BeanUtils.copyProperties(question,questionVO);
LambdaQueryWrapper<WorkOrderQuestion> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(WorkOrderQuestion::getQuestionId, question.getId());
WorkOrderQuestion workOrderQuestion = workOrderQuestionMapper.selectOne(lambdaQueryWrapper);
if(workOrderQuestion != null){
questionVO.setWordOrderStatus(1);
questionVO.setHandleStatus(workOrderQuestion.getStatus());
}else {
questionVO.setWordOrderStatus(0);
questionVO.setHandleStatus(0);
}
questionVOList.add(questionVO);
});
IPage<QuestionVO> resultPage=new Page<>();
resultPage.setCurrent(pageData.getCurrent());
resultPage.setPages(pageData.getPages());
resultPage.setSize(pageData.getSize());
resultPage.setTotal(pageData.getTotal());
resultPage.setRecords(questionVOList);
return resultPage;

}

@Override
@@ -373,4 +394,5 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
}
return inspectionData.get(0);
}

}

Loading…
Cancel
Save