Browse Source

问题状态接口返回值修改

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
d25b4fd37c
6 changed files with 57 additions and 38 deletions
  1. +7
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java
  2. +2
    -13
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ReportController.java
  3. +4
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IQuestionService.java
  4. +1
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IReportService.java
  5. +29
    -6
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java
  6. +14
    -12
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java

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

@@ -4,12 +4,16 @@ import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.request.QuestionQuery;
import com.tuoheng.admin.entity.request.QuestionStatusRequest;
import com.tuoheng.admin.entity.request.QuestionTypeQuery;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVo;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
* 巡检问题
*
@@ -75,8 +79,8 @@ public class QuestionController {
*
*/
@GetMapping("/analyze/{missionId}")
public JsonResult analyze(@PathVariable("missionId") Integer missionId) {
return questionService.analyze(missionId);
public JsonResult<Map<String, Integer>> analyze(@PathVariable("missionId") Integer missionId) {
return questionService.analyzeController(missionId);
}

/**
@@ -84,7 +88,7 @@ public class QuestionController {
*
*/
@GetMapping("/analyze/type/{missionId}")
public JsonResult analyzeType(@PathVariable("missionId") Integer missionId) {
public JsonResult<List<QuestionTypeCountVo>> analyzeType(@PathVariable("missionId") Integer missionId) {
return questionService.analyzeType(missionId);
}


+ 2
- 13
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ReportController.java View File

@@ -26,17 +26,6 @@ public class ReportController {
@Autowired
private IReportService reportService;

/**
* 弹框,已经核实的条数和未核实的条数
*
* @param missionId 任务ID
* @return
*/
@GetMapping("/analyze/{missionId}")
public JsonResult analyze(@PathVariable("missionId") Integer missionId) {
return reportService.analyze(missionId);
}

/**
* 提交并生成报告
*
@@ -77,8 +66,8 @@ public class ReportController {
* @param reportId 报告ID
* @return
*/
@GetMapping(value = "/exportReportWord")
public void exportReportWord(String reportId, HttpServletRequest request, HttpServletResponse response) throws Exception{
@GetMapping(value = "{reportId}/word")
public void exportReportWord(@PathVariable("reportId") Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception{
reportService.exportReportWord(reportId, request, response);
}


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

@@ -5,6 +5,7 @@ import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.request.QuestionQuery;
import com.tuoheng.admin.entity.request.QuestionStatusRequest;
import com.tuoheng.admin.entity.request.QuestionTypeQuery;
import com.tuoheng.admin.entity.vo.QuestionCountVo;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVo;
import com.tuoheng.common.common.IBaseService;
import com.tuoheng.common.utils.JsonResult;
@@ -32,7 +33,9 @@ public interface IQuestionService extends IBaseService<Question> {

JsonResult check(QuestionStatusRequest entity);

JsonResult<Map<Integer,Integer>> analyze(Integer missionId);
JsonResult<List<QuestionCountVo>> analyze(Integer missionId);

JsonResult<Map<String, Integer>> analyzeController(Integer missionId);

JsonResult<List<QuestionTypeCountVo>> analyzeType(Integer missionId);
}

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

@@ -51,7 +51,5 @@ public interface IReportService extends IBaseService<Report> {
* @param reportId 报告ID
* @return
*/
void exportReportWord(String reportId, HttpServletRequest request, HttpServletResponse response) throws Exception;

JsonResult analyze(Integer missionId);
void exportReportWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception;
}

+ 29
- 6
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java View File

@@ -14,6 +14,7 @@ import com.tuoheng.admin.entity.request.QuestionTypeQuery;
import com.tuoheng.admin.entity.vo.QuestionCountVo;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVo;
import com.tuoheng.admin.enums.MarkTypeEnum;
import com.tuoheng.admin.enums.QuestionStatusEnum;
import com.tuoheng.admin.enums.ReportStatusEnum;
import com.tuoheng.admin.enums.UpdateOrCreateEnum;
import com.tuoheng.admin.mapper.QuestionMapper;
@@ -23,6 +24,7 @@ import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.utils.ShiroUtils;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@@ -112,14 +114,35 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
}

@Override
public JsonResult<Map<Integer,Integer>> analyze(Integer missionId) {

public JsonResult<List<QuestionCountVo>> analyze(Integer missionId) {
List<QuestionCountVo> resultMap= questionMapper.analyze(missionId, ShiroUtils.getTenantId());
Map<Integer,Integer> result=new HashMap<>();
for (QuestionCountVo questionCountVo : resultMap) {
result.put(questionCountVo.getStatus(),questionCountVo.getQuantity());
return JsonResult.success(resultMap);
}

@Override
public JsonResult<Map<String, Integer>> analyzeController(Integer missionId) {
List<QuestionCountVo> questionCountVoList= questionMapper.analyze(missionId, ShiroUtils.getTenantId());
Map<String,Integer> resultMap=new HashMap<>();
for (QuestionCountVo questionCountVo : questionCountVoList) {
setInfo(resultMap, questionCountVo,QuestionStatusEnum.CONFIRM.getCode(),QuestionStatusEnum.CONFIRM.name().toLowerCase());
setInfo(resultMap, questionCountVo,QuestionStatusEnum.NOTREVIEWED.getCode(),QuestionStatusEnum.NOTREVIEWED.name().toLowerCase());
}

return JsonResult.success(resultMap);
}

private static void setInfo(Map<String, Integer> resultMap, QuestionCountVo questionCountVo,Integer code,String name) {
if(questionCountVo.getStatus().equals(code)){
if(resultMap.containsKey(name)){
Integer current = resultMap.get(name);
current=current+questionCountVo.getQuantity();
resultMap.put(name,current);
}else{
resultMap.put(name, questionCountVo.getQuantity());
}
}else{
resultMap.put(name, 0);
}
return JsonResult.success(result);
}

@Override

+ 14
- 12
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java View File

@@ -14,6 +14,7 @@ import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.ReportRequest;
import com.tuoheng.admin.entity.vo.*;
import com.tuoheng.admin.enums.MarkTypeEnum;
import com.tuoheng.admin.enums.QuestionStatusEnum;
import com.tuoheng.admin.enums.ReportStatusEnum;
import com.tuoheng.admin.enums.UpdateOrCreateEnum;
import com.tuoheng.admin.mapper.QuestionMapper;
@@ -176,10 +177,16 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
}

private void setQueestionCount(ReportInfoVO reportInfoVo, Integer missionId) {
JsonResult<Map<Integer,Integer>> analyze = questionService.analyze(missionId);
Iterator<Integer> iterator = analyze.getData().values().stream().iterator();
JsonResult<List<QuestionCountVo>> analyze = questionService.analyze(missionId);
Iterator<QuestionCountVo> iterator = analyze.getData().stream().iterator();
int questionCount=0;
while (iterator.hasNext()){questionCount+=iterator.next();}
while (iterator.hasNext()){
QuestionCountVo questionCountVo = iterator.next();
//只统计已经确认的问题
if(QuestionStatusEnum.CONFIRM.getCode()==questionCountVo.getStatus()){
questionCount+=questionCountVo.getQuantity();
}
}
reportInfoVo.setQuestionCount(questionCount);
}

@@ -199,9 +206,11 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
}

@Override
public void exportReportWord(String reportId, HttpServletRequest request, HttpServletResponse response) throws Exception {
public void exportReportWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception {



/*ReportVO reportInfoVo = new ReportVO();
/*ReportVO reportInfoVo = detail(reportId);
//查询报告
Report report = reportMapper.selectOne(new LambdaQueryWrapper<Report>()
.eq(Report::getId, reportId)
@@ -593,13 +602,6 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp

}

@Override
public JsonResult analyze(Integer missionId) {
JsonResult jsonResult=questionService.analyze(missionId);

return null;
}

/**
* 生成报告编号,R+年月日+随机四位数
* @return

Loading…
Cancel
Save