qiujinyang 2 лет назад
Родитель
Сommit
794f50b07a
22 измененных файлов: 423 добавлений и 348 удалений
  1. +0
    -14
      tuoheng-admin/src/main/java/com/tuoheng/admin/config/WebSocketConfig.java
  2. +2
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  3. +4
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/MissionController.java
  4. +9
    -7
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java
  5. +2
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ReportController.java
  6. +59
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/AIQuestionRequest.java
  7. +3
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/QuestionQuery.java
  8. +6
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/MissionVO.java
  9. +42
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AiAnalyseStatusEnum.java
  10. +10
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IDspService.java
  11. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IMissionService.java
  12. +3
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IQuestionService.java
  13. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IReportService.java
  14. +84
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/DspServiceImpl.java
  15. +75
    -22
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java
  16. +35
    -8
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java
  17. +81
    -284
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java
  18. +1
    -1
      tuoheng-admin/src/main/resources/application-airport.yml
  19. +1
    -1
      tuoheng-admin/src/main/resources/application-dev.yml
  20. +2
    -2
      tuoheng-admin/src/main/resources/application-local.yml
  21. +1
    -1
      tuoheng-admin/src/main/resources/application-prod.yml
  22. +1
    -1
      tuoheng-admin/src/main/resources/application-test.yml

+ 0
- 14
tuoheng-admin/src/main/java/com/tuoheng/admin/config/WebSocketConfig.java Просмотреть файл

@@ -1,14 +0,0 @@
package com.tuoheng.admin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}

}

+ 2
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java Просмотреть файл

@@ -91,7 +91,7 @@ public class InspectionController {
*/
@PutMapping("/status")
@ApiOperation(value = "被硬件调用,存任务状态", notes = "被硬件调用,存任务状态")
public JsonResult track(@RequestBody @Valid MissionStatusRequest missionStatusRequest) {
public JsonResult<Boolean> track(@RequestBody @Valid MissionStatusRequest missionStatusRequest) {
return JsonResult.success(missionService.updateStatus(missionStatusRequest));
}

@@ -101,7 +101,7 @@ public class InspectionController {
*/
@PostMapping("/track")
@ApiOperation(value = "被硬件调用,存飞行轨迹", notes = "被硬件调用,存飞行轨迹")
public JsonResult track(@RequestBody @Valid InspectionRequest inspectionRequest) {
public JsonResult<Integer> track(@RequestBody @Valid InspectionRequest inspectionRequest) {
return JsonResult.success(inspectionService.track(inspectionRequest));
}


+ 4
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/MissionController.java Просмотреть файл

@@ -1,9 +1,11 @@
package com.tuoheng.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.MissionQuery;
import com.tuoheng.admin.entity.request.MissionRequest;
import com.tuoheng.admin.entity.vo.MissionVO;
import com.tuoheng.admin.service.IMissionService;
import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.JsonResult;
@@ -64,7 +66,7 @@ public class MissionController {
*/
@DeleteMapping("/{idList}")
@ApiOperation(value = "删除巡检任务", notes = "传入巡检任务id")
public JsonResult deleteBatch(@PathVariable("idList") List<Integer> idList) {
public JsonResult<Boolean> deleteBatch(@PathVariable("idList") List<Integer> idList) {
return JsonResult.success(missionService.deleteBatch(idList));
}

@@ -75,7 +77,7 @@ public class MissionController {
*/
@GetMapping("/page")
@ApiOperation(value = "查询巡检任务列表", notes = "查询巡检任务分页")
public JsonResult findList(MissionQuery queryMissionRequest) {
public JsonResult<IPage<MissionVO>> findList(MissionQuery queryMissionRequest) {
return JsonResult.success(missionService.findList(queryMissionRequest));
}


+ 9
- 7
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java Просмотреть файл

@@ -1,16 +1,19 @@
package com.tuoheng.admin.controller;

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.request.*;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVo;
import com.tuoheng.admin.enums.UpdateOrCreateEnum;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.utils.ShiroUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@@ -40,15 +43,14 @@ public class QuestionController {


/**
* 添加巡检问题
* 被DSP调用,存问题
*
* @param entity 实体对象
* @return
*/
@PostMapping("")
public JsonResult create(@RequestBody Question entity) {
entity.setCreateUser(ShiroUtils.getUserId());
return questionService.edit(entity);
public JsonResult create(@RequestBody AIQuestionRequest request) {
return questionService.process(request);
}

/**

+ 2
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ReportController.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.tuoheng.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.admin.entity.domain.Report;
import com.tuoheng.admin.entity.request.ReportRequest;
import com.tuoheng.admin.entity.vo.ReportInfoVO;
import com.tuoheng.admin.entity.vo.ReportVO;
@@ -44,7 +45,7 @@ public class ReportController {
* @return
*/
@GetMapping("/page")
public JsonResult queryPage(ReportRequest request) {
public JsonResult<IPage<Report>> queryPage(ReportRequest request) {
return reportService.queryPage(request);
}


+ 59
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/AIQuestionRequest.java Просмотреть файл

@@ -0,0 +1,59 @@
package com.tuoheng.admin.entity.request;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.tuoheng.common.common.BaseQuery;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
* 巡检问题查询
*
* @author qiujinyang
* @since 2022-08-03
*/
@NoArgsConstructor
@Data
public class AIQuestionRequest extends BaseQuery implements Serializable {

private static final long serialVersionUID = 1L;


@JsonProperty("videoUrl")
private Object videoUrl;
@JsonProperty("aiVideoUrl")
private Object aiVideoUrl;
@JsonProperty("analyseStatus")
private Integer analyseStatus;
@JsonProperty("errorCode")
private String errorCode;
@JsonProperty("errorMsg")
private String errorMsg;
@JsonProperty("type")
private Integer type;
@JsonProperty("progress")
private Double progress;
@JsonProperty("questionFiles")
private List<QuestionFilesDTO> questionFiles;

@NoArgsConstructor
@Data
public static class QuestionFilesDTO {
@JsonProperty("fileCode")
private String fileCode;
@JsonProperty("fileName")
private String fileName;
@JsonProperty("fileOriginalUrl")
private String fileOriginalUrl;
@JsonProperty("fileMarkerUrl")
private String fileMarkerUrl;
@JsonProperty("analyseTime")
private String analyseTime;
@JsonProperty("questionName")
private String questionName;
@JsonProperty("questionDesc")
private String questionDesc;
}
}

+ 3
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/QuestionQuery.java Просмотреть файл

@@ -23,6 +23,9 @@ public class QuestionQuery extends BaseQuery implements Serializable {
@ApiModelProperty(value = "任务Id")
private Integer missionId;

@ApiModelProperty(value = "问题状态")
private Integer status;

@ApiModelProperty(value = "项目类型:病虫树、林斑、人员活动、火灾隐患")
private Integer type;


+ 6
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/MissionVO.java Просмотреть файл

@@ -81,9 +81,15 @@ public class MissionVO implements Serializable {
@ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成")
private Integer status;

@ApiModelProperty(value = "巡检报告是否生成 是否生成 0 未生成 1 需修改 2 已生成")
private Integer reportStatus;

@ApiModelProperty(value = "备注")
private String note;

@ApiModelProperty(value = "备注")
private String createUser;

@ApiModelProperty(value = "租户id",hidden = true)
private Integer tenantId;


+ 42
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AiAnalyseStatusEnum.java Просмотреть файл

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

import lombok.Getter;

/**
* Ai分析状态
*/
public enum AiAnalyseStatusEnum {
UPLOADED(1,"uploaded"),

WAITING(2,"waiting"),

RUNNING(3,"running"),

SUCCESS(4,"success"),

SUCCESS_TIMEOUT(5,"success_timeout"),

FAILED(6,"failed"),

DEFAULT(0,"default");

AiAnalyseStatusEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;

public static AiAnalyseStatusEnum getByDesc(String description){
for (AiAnalyseStatusEnum analyseStatusEnum : values()) {
if(analyseStatusEnum.getDescription().equals(description)){
return analyseStatusEnum;
}
}
return null;
}
}

+ 10
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IDspService.java Просмотреть файл

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

import com.alibaba.fastjson.JSONObject;

public interface IDspService {
JSONObject serviceInstApplication(JSONObject jsonObject);

JSONObject serviceStopApplication(JSONObject jsonObject);

}

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IMissionService.java Просмотреть файл

@@ -56,5 +56,5 @@ public interface IMissionService extends IBaseService<ThMission> {
* @author: zhu_zishuang
* @date: 2021/9/2
*/
OperationEnum deleteBatch(List<Integer> idList);
boolean deleteBatch(List<Integer> idList);
}

+ 3
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IQuestionService.java Просмотреть файл

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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.request.AIQuestionRequest;
import com.tuoheng.admin.entity.request.QuestionQuery;
import com.tuoheng.admin.entity.request.QuestionStatusRequest;
import com.tuoheng.admin.entity.request.QuestionTypeQuery;
@@ -38,4 +39,6 @@ public interface IQuestionService extends IBaseService<Question> {
JsonResult<Map<String, Integer>> analyzeController(Integer missionId);

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

JsonResult process(AIQuestionRequest request);
}

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IReportService.java Просмотреть файл

@@ -34,7 +34,7 @@ public interface IReportService extends IBaseService<Report> {
* @param request
* @return
*/
JsonResult queryPage(ReportRequest request);
JsonResult<IPage<Report>> queryPage(ReportRequest request);

/**
* 查看报告 详情

+ 84
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/DspServiceImpl.java Просмотреть файл

@@ -0,0 +1,84 @@
package com.tuoheng.admin.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.service.IDspService;
import com.tuoheng.common.utils.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Map;

@Slf4j
@Service
public class DspServiceImpl implements IDspService {
@Override
public JSONObject serviceInstApplication(JSONObject jsonObject) {
//TODO 替换成配置文件地址
String url = "http://192.168.11.241:1011/api/web/serviceInst/92cee2e917366746e5d2b0ac28799d02/application";
String result = doSend(url, jsonObject, null,"POST");
return JSONObject.parseObject(result);
}

@Override
public JSONObject serviceStopApplication(JSONObject jsonObject) {
//TODO 替换成配置文件地址
String url = "http://192.168.11.241:1011/api/web/serviceInst/92cee2e917366746e5d2b0ac28799d02/stop";
String result = doSend(url, jsonObject, null,"PUT");
return JSONObject.parseObject(result);
}

/**
* 处理post请求
* @param urlStr 请求url
* @param data 请求体数据
* @param properties 请求头参数
* @return
*/
public static String doSend(String urlStr, JSONObject data, Map<String, String> properties,String method){
try {
log.info("请求url={}", urlStr);
log.info("请求体数据data={}", data.toJSONString());
log.info("请求头参数properties={}", properties);
URL url = new URL(urlStr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

connection.setDoInput(true); // 设置可输入
connection.setDoOutput(true); // 设置该连接是可以输出的
//设置连接超时时间和读取超时时间
connection.setConnectTimeout(15000);
connection.setReadTimeout(60000);
//设置请求方式
connection.setRequestMethod(method);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
if(null != properties && !properties.isEmpty()){
for (String key:properties.keySet()){
connection.setRequestProperty(key, properties.get(key));
}
}

PrintWriter pw = new PrintWriter(new BufferedOutputStream(connection.getOutputStream()));
pw.write(data.toJSONString());
pw.flush();
pw.close();

BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
String line = null;
StringBuilder result = new StringBuilder();
while ((line = br.readLine()) != null) { // 读取数据
result.append(line).append("\n");
}
connection.disconnect();
return result.toString();
} catch (Exception e) {
log.error("post请求失败");
return "post请求失败!";
}
}
}

+ 75
- 22
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java Просмотреть файл

@@ -2,7 +2,10 @@ package com.tuoheng.admin.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
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.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.common.ServiceExceptionEnum;
@@ -13,6 +16,7 @@ import com.tuoheng.admin.entity.request.MissionStatusRequest;
import com.tuoheng.admin.entity.vo.MissionVO;
import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.service.IDspService;
import com.tuoheng.admin.service.IMissionService;
import com.tuoheng.admin.utils.CodeUtil;
import com.tuoheng.common.common.BaseServiceImpl;
@@ -49,6 +53,9 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
@Autowired
private RedisUtils redisUtils;

@Autowired
private IDspService dspService;


@Override
public Integer addMission(MissionRequest addThMissionRequest) throws ServiceException {
@@ -86,23 +93,13 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.WAIT.getCode());
Assert.notNull(thMission, "飞行任务不能为空!");
ThMission thMissionUpdate = setStatus(missionStatusRequest, thMission);
if(thMissionMapper.updateById(thMissionUpdate) > 0){
//任务调用完成之后,调用发送通道,请求DSP需要分析


}

return true;
JSONObject jsonObject = startAI(missionStatusRequest);
thMissionUpdate.setAipullUrl(jsonObject.getJSONObject("data").getString("aipullUrl"));
thMissionUpdate.setAipushUrl(jsonObject.getJSONObject("data").getString("aipushUrl"));
return thMissionMapper.updateById(thMissionUpdate) > 0;
}else if(AirPortTaskStatusEnum.WAIT.getCode()==missionStatusRequest.getStatus()){

ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.FLIGHT.getCode());
Assert.notNull(thMission, "飞行任务不能为空!");
ThMission thMissionUpdate = setStatus(missionStatusRequest, thMission);
if(thMissionMapper.updateById(thMissionUpdate) > 0){
//任务调用完成之后,调用发送通道,请求DSP关闭请求


}
stopAI(missionStatusRequest);

return true;
}else{
@@ -110,6 +107,64 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
}
}

private JSONObject startAI(MissionStatusRequest missionStatusRequest) throws ServiceException {
//任务调用完成之后,调用发送通道,请求DSP需要分析
//调用DSP接口
JSONObject request = new JSONObject();
JSONArray configList = new JSONArray();
JSONObject instConfigMode = new JSONObject();
instConfigMode.put("ename","service_mode");
instConfigMode.put("evalue","1");
configList.add(instConfigMode);
JSONObject instConfigUrl = new JSONObject();
instConfigUrl.put("ename","callback_url");
instConfigUrl.put("evalue","URL");//todo 替换成URL
configList.add(instConfigUrl);
request.put("serviceInstConfigList",configList);

JSONArray reqList = new JSONArray();

JSONObject instReqUrlPush = new JSONObject();
instReqUrlPush.put("ename","push_url");
instReqUrlPush.put("evalue", missionStatusRequest.getPushUrl());
reqList.add(instReqUrlPush);

JSONObject instReqUrlPull = new JSONObject();
instReqUrlPull.put("ename","pull_url");
instReqUrlPull.put("evalue", missionStatusRequest.getPullUrl());
reqList.add(instReqUrlPull);

request.put("serviceInstReqList", reqList);
JSONObject responseJson = dspService.serviceInstApplication(request);
if(responseJson.getIntValue("code") == 0){
String requestId = responseJson.getJSONObject("data").getString("requestId");
log.info("dsp实时调用响应requestId:{}",requestId);

}else {
log.error("dsp实时调用失败:{}", responseJson);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"任务失败!");
}
return responseJson;
}

private void stopAI(MissionStatusRequest missionStatusRequest) {
ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.FLIGHT.getCode());
Assert.notNull(thMission, "飞行任务不能为空!");
ThMission thMissionUpdate = setStatus(missionStatusRequest, thMission);
if(thMissionMapper.updateById(thMissionUpdate) > 0){
//任务调用完成之后,调用发送通道,请求DSP关闭请求
//调用DSP接口
JSONObject responseJson = dspService.serviceStopApplication(new JSONObject());
if(responseJson.getIntValue("code") == 0){
String requestId = responseJson.getJSONObject("data").getString("requestId");
log.info("dsp实时调用响应requestId:{}",requestId);

}else {
log.error("dsp实时调用失败:{}", responseJson);
}
}
}

private ThMission setStatus(MissionStatusRequest missionStatusRequest, ThMission thMission) {
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
thMissionUpdate.setId(thMission.getId());
@@ -117,8 +172,6 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
thMissionUpdate.setPullUrl(missionStatusRequest.getPullUrl());
if(missionStatusRequest.getStatus()==AirPortTaskStatusEnum.FLIGHT.getCode()){
thMissionUpdate.setStatus(TaskStatusEnum.FLIGHT.getCode());
}else{
thMissionUpdate.setStatus(TaskStatusEnum.COMPLETE.getCode());
}
return thMissionUpdate;
}
@@ -131,8 +184,7 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
lambdaQueryWrapper.eq(ThMission::getStatus,status);
lambdaQueryWrapper.eq(ThMission::getTenantId,ShiroUtils.getTenantId());
List<ThMission> thMissions = thMissionMapper.selectList(lambdaQueryWrapper);
ThMission thMission = thMissions.size()>0? thMissions.get(0) : null;
return thMission;
return thMissions.size()>0? thMissions.get(0) : null;
}

@Override
@@ -187,10 +239,11 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi


@Override
public OperationEnum deleteBatch(List<Integer> idList) {
public boolean deleteBatch(List<Integer> idList) {
Integer updateUser = ShiroUtils.getUserId();
thMissionMapper.deleteBatch(idList, updateUser, ShiroUtils.getTenantId());
return OperationEnum.DELETE_SUCCESS;
ThMission mission=new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
mission.setMark(MarkTypeEnum.NOTVALID.getCode());
return thMissionMapper.update(mission,new LambdaUpdateWrapper<ThMission>().in(ThMission::getId,idList))>0;
}

}

+ 35
- 8
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java Просмотреть файл

@@ -8,15 +8,13 @@ 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.ThMission;
import com.tuoheng.admin.entity.request.AIQuestionRequest;
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.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.enums.*;
import com.tuoheng.admin.mapper.QuestionMapper;
import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.admin.service.IQuestionService;
@@ -25,13 +23,11 @@ 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.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* 巡检问题表 服务实现类
@@ -60,6 +56,8 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
.like(ObjectUtil.isNotEmpty(query.getMissionName()), Question::getMissionName, query.getMissionName())
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())),Question::getCreateTime,query.getStartTime(),query.getEndTime())
.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));
return pageData;
}
@@ -80,6 +78,8 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
.like(ObjectUtil.isNotEmpty(query.getMissionName()), Question::getMissionName, query.getMissionName())
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())), Question::getCreateTime, query.getStartTime(), query.getEndTime())
.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));
return questionList;
}
@@ -150,4 +150,31 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
List<QuestionTypeCountVo> questionTypeCountList= questionMapper.analyzeType(missionId, ShiroUtils.getTenantId());
return JsonResult.success(questionTypeCountList);
}

@Override
public JsonResult process(AIQuestionRequest request) {

//todo 获取正在直播的任务,这个任务肯定是当前正在运行的任务,可以根据通道来确定

List<AIQuestionRequest.QuestionFilesDTO> questionFiles = request.getQuestionFiles();
List<Question> questionList=new ArrayList<>();
for (AIQuestionRequest.QuestionFilesDTO questionFile : questionFiles) {
Question question=new Question(UpdateOrCreateEnum.CREATE.getCode());
BeanUtils.copyProperties(questionFile,question);
questionList.add(question);
}



boolean batch=saveBatch(questionList);

ThMission thMissionUpdate=new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
if(request.getAnalyseStatus()== AiAnalyseStatusEnum.SUCCESS.getCode()){
thMissionUpdate.setStatus(TaskStatusEnum.COMPLETE.getCode());
//missionMapper.up
}


return null;
}
}

+ 81
- 284
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java Просмотреть файл

@@ -52,6 +52,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;

@@ -125,7 +126,7 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
}

@Override
public JsonResult queryPage(ReportRequest request) {
public JsonResult<IPage<Report>> queryPage(ReportRequest request) {
if(null == request.getPage() || null == request.getLimit()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
@@ -144,39 +145,44 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp

@Override
public ReportInfoVO detail(Integer reportId) {
ReportInfoVO reportInfoVo = new ReportInfoVO();
ReportInfoVO reportInfoVO = new ReportInfoVO();
//查询报告
Report report = reportMapper.selectById(reportId);
Integer missionId = report.getMissionId();
reportInfoVo.setMissionId(missionId);
reportInfoVo.setCompany("汤山林场");
reportInfoVo.setLcName("汤山林场");
reportInfoVO.setReportNo(report.getReportNo());
reportInfoVO.setMissionId(missionId);
reportInfoVO.setCompany("汤山林场");
reportInfoVO.setLcName("汤山林场");
//任务信息
setMission(reportInfoVo, missionId);
setMission(reportInfoVO, missionId);
//添加巡检天气
reportInfoVo.setAirWeather(inspectionService.getWeather(Integer.valueOf(report.getAirportId())));
setWeather(reportInfoVO, report);
//查询巡检结果
setQueestionCount(reportInfoVo, missionId);
setQueestionCount(reportInfoVO, missionId);
//问题类型
setQuestionType(reportInfoVo, missionId);
setQuestionType(reportInfoVO, missionId);
//查询问题清单
setQuestonList(reportInfoVo, missionId);
return reportInfoVo;
setQuestonList(reportInfoVO, missionId);
return reportInfoVO;
}

private void setMission(ReportInfoVO reportInfoVo, Integer missionId) {
private void setWeather(ReportInfoVO reportInfoVO, Report report) {
reportInfoVO.setAirWeather(inspectionService.getWeather(Integer.valueOf(report.getAirportId())));
}

private void setMission(ReportInfoVO reportInfoVO, Integer missionId) {
ThMission thMission = missionMapper.selectById(missionId);
MissionVO missionVO=new MissionVO();
BeanUtils.copyProperties(thMission,missionVO);
reportInfoVo.setMission(missionVO);
reportInfoVO.setMission(missionVO);
}

private void setQuestionType(ReportInfoVO reportInfoVo, Integer missionId) {
private void setQuestionType(ReportInfoVO reportInfoVO, Integer missionId) {
JsonResult<List<QuestionTypeCountVo>> analyzeType = questionService.analyzeType(missionId);
reportInfoVo.setQuestionTypeInfo(analyzeType.getData());
reportInfoVO.setQuestionTypeInfo(analyzeType.getData());
}

private void setQueestionCount(ReportInfoVO reportInfoVo, Integer missionId) {
private void setQueestionCount(ReportInfoVO reportInfoVO, Integer missionId) {
JsonResult<List<QuestionCountVo>> analyze = questionService.analyze(missionId);
Iterator<QuestionCountVo> iterator = analyze.getData().stream().iterator();
int questionCount=0;
@@ -187,12 +193,13 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
questionCount+=questionCountVo.getQuantity();
}
}
reportInfoVo.setQuestionCount(questionCount);
reportInfoVO.setQuestionCount(questionCount);
}

private void setQuestonList(ReportInfoVO reportInfoVo, Integer missionId) {
private void setQuestonList(ReportInfoVO reportInfoVO, Integer missionId) {
List<Question> questionList = questionService.list(new LambdaQueryWrapper<Question>().eq(Question::getTenantId, ShiroUtils.getTenantId())
.eq(Question::getMissionId, missionId)
.eq(Question::getStatus, QuestionStatusEnum.CONFIRM.getCode())
);

List<QuestionReportVO> questionReportVOList=new ArrayList<>();
@@ -202,33 +209,16 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
questionReportVOList.add(questionReportVO);
}
//问题列表
reportInfoVo.setQuestionReportList(questionReportVOList);
reportInfoVO.setQuestionReportList(questionReportVOList);
}

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



/*ReportVO reportInfoVo = detail(reportId);
//查询报告
Report report = reportMapper.selectOne(new LambdaQueryWrapper<Report>()
.eq(Report::getId, reportId)
.eq(Report::getTenantId, ShiroUtils.getTenantId()));
BeanUtils.copyProperties(report, reportInfoVo);

//查询巡检结果
List<QuestionCountVo> questionCountVoList = questionMapper.queryCountByInspectionId(report.getInspectionId(), ShiroUtils.getTenantId());
reportInfoVo.setInspectionResult(questionCountVoList);

//查询问题清单
List<QuestionReportVO> imageList = inspectionFileMapper.queryPictureByInspectionId(report.getInspectionId(), ShiroUtils.getTenantId());
reportInfoVo.setImageList(imageList);
reportInfoVo.setQuestionCount(imageList.size());
String[] inspectionPeople = report.getFlightHand().split(",");
reportInfoVo.setInspectionPeopleCount(inspectionPeople.length);
/*
ReportInfoVO reportInfoVO = detail(reportId);
//创建word
String fileName = report.getReportNo()+".doc";
String fileName = reportInfoVO.getReportNo()+".doc";
String filePath = UploadFileConfig.uploadFolder+"/doc/"+fileName;
File fd = new File(UploadFileConfig.uploadFolder+"/doc");
File f = new File(filePath);
@@ -236,6 +226,8 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
fd.mkdirs();
}
WordUtilsOld wordUtils = new WordUtilsOld();

SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
if(!f.exists()||f.length()<1000) {
f.delete();
@@ -244,17 +236,17 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
wordUtils.getDocument().setPageSize(PageSize.A4);
wordUtils.getDocument().setMargins(71f, 71f, 72f, 72f);
//标题
wordUtils.insertTitlePattern("南京市河道无人机巡检报告", wordUtils.rtfGsBt1);
wordUtils.insertContext("报告编号:"+reportInfoVo.getReportNo(),10,Font.NORMAL,Element.ALIGN_RIGHT,20,0,0);
wordUtils.insertTitlePatternThird("一:河湖信息", wordUtils.rtfGsBt3);
Table table = new Table(6);//生成一表格
wordUtils.insertTitlePattern("汤山林场无人机巡检报告", wordUtils.rtfGsBt1);
wordUtils.insertContext("报告编号:"+reportInfoVO.getReportNo(),10,Font.NORMAL,Element.ALIGN_RIGHT,20,0,0);
wordUtils.insertTitlePatternThird("一:林场信息", wordUtils.rtfGsBt3);
Table table = new Table(2);//生成一表格
table.setOffset(1f);
int width[] = {1, 1, 1, 1, 1,1};
int width[] = {1, 1};
table.setWidths(width);//设置系列所占比例
table.setWidth(100);
table.setWidth(300);
table.setAutoFillEmptyCells(true);
table.setAlignment(Element.ALIGN_LEFT);//居中显示
for (int i = 0; i < 11; i++) {
for (int i = 0; i < 6; i++) {
Cell cell = new Cell();
String str = null;
cell.setVerticalAlignment(Element.ALIGN_RIGHT);
@@ -263,32 +255,19 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
font.setSize(10.5f);
font.setStyle(Font.BOLD);
if (i == 0) {
str = "河道基本信息";cell.setColspan(6);
str = "责任单位";cell.setColspan(6);
} else if (i == 1) {
str = "责任单位";
str = reportInfoVO.getCompany();
} else if (i == 2) {
str = reportInfoVo.getStreamArea();
str = "林场名称";
font.setStyle(Font.NORMAL);
} else if (i == 3) {
str = "河流名称";
str = reportInfoVO.getLcName();
} else if (i == 4) {
str = reportInfoVo.getStreamName();
font.setStyle(Font.NORMAL);
} else if (i == 5) {
str = "河段长度";
} else if (i == 6) {
str = reportInfoVo.getStreamLength();
font.setStyle(Font.NORMAL);
} else if (i == 7) {
str = "起讫位置";
} else if (i == 8) {
str = reportInfoVo.getStreamLocation();
font.setStyle(Font.NORMAL);cell.setColspan(3);
} else if (i == 9) {
str = "巡查里程";
} else if (i == 10) {
str = reportInfoVo.getStreamLength();
font.setStyle(Font.NORMAL);
} else if (i == 5) {
str = reportInfoVO.getMission().getMileage();
}
Paragraph p = new Paragraph(str, font);
cell.add(p);
@@ -297,7 +276,7 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
wordUtils.getDocument().add(table);

wordUtils.insertTitlePatternThird("二:巡检信息", wordUtils.rtfGsBt3);
Table table2 = new Table(6);//生成一表格
Table table2 = new Table(2);//生成一表格
table2.setOffset(1f);
int width2[] = {1, 1, 1, 1, 1, 1};
table2.setWidths(width2);//设置系列所占比例
@@ -305,7 +284,9 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
table2.setAutoFillEmptyCells(true);
table2.setAlignment(Element.ALIGN_CENTER);//居中显示
table2.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示
for (int i = 0; i < 18; i++) {


for (int i = 0; i < 11; i++) {
Cell cell = new Cell();
String str = null;
cell.setVerticalAlignment(Element.ALIGN_LEFT);
@@ -314,59 +295,48 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
font.setSize(10.5f);
font.setStyle(Font.BOLD);
if (i == 0) {
str = "天气情况";
str = "气象信息";
} else if (i == 1) {
str = reportInfoVo.getWeather();font.setStyle(Font.NORMAL);
str = "气温:"+reportInfoVO.getAirWeather().getWth().getParm().getTmp()
+";湿度:"+reportInfoVO.getAirWeather().getWth().getParm().getHum()
+";风速:"+reportInfoVO.getAirWeather().getWth().getParm().getWspd()
+";风向:"+reportInfoVO.getAirWeather().getWth().getParm().getWdir();
font.setStyle(Font.NORMAL);
} else if (i == 2) {
str = "巡查人数";
str = "巡检方式";
} else if (i == 3) {
str = reportInfoVo.getInspectionPeopleCount()==null?"":reportInfoVo.getInspectionPeopleCount().toString();font.setStyle(Font.NORMAL);
//巡检方式 1 机场服务,2 人工巡检
str = reportInfoVO.getMission().getInspectionType().equals(1)?"无人机":"人工巡检";
font.setStyle(Font.NORMAL);
} else if (i == 4) {
str = "巡查人员";
str = "巡检设备";
} else if (i == 5) {
str = reportInfoVo.getFlightHandName();font.setStyle(Font.NORMAL);
str = reportInfoVO.getMission().getDroneName();
font.setStyle(Font.NORMAL);
} else if (i == 6) {
str = "巡查方式";
str = "巡检开始时间";
} else if (i == 7) {
if(reportInfoVo.getInspectionWay() == 1){
str = "无人机";
}else if(reportInfoVo.getInspectionWay() == 2){
str = "无人船";
}else if(reportInfoVo.getInspectionWay() == 3){
str = "人工";
}
str = simpleDateFormat.format(reportInfoVO.getMission().getExecutionStartTime());
font.setStyle(Font.NORMAL);
} else if (i == 8) {
str = "巡查设备";
str = "巡检结束时间";
}else if (i == 9) {
str = reportInfoVo.getInspectionDevice();font.setStyle(Font.NORMAL);
str = simpleDateFormat.format(reportInfoVO.getMission().getExecutionEndTime());
} else if (i == 10) {
str = "巡查日期";
str = "问题数量";
} else if (i == 11) {
str = reportInfoVo.getInspectionTime()==null?"":DateUtils.dateTime(reportInfoVo.getInspectionTime());font.setStyle(Font.NORMAL);
} else if (i == 12) {
str = "飞行高度";
} else if (i == 13) {
str = reportInfoVo.getFlightHeight();font.setStyle(Font.NORMAL);
} else if (i == 14) {
str = "巡查类型";
} else if (i == 15) {
if(reportInfoVo.getInspectionType() == 1){
str = "常规巡河";font.setStyle(Font.NORMAL);
}else if(reportInfoVo.getInspectionType() == 2){
str = "其他";font.setStyle(Font.NORMAL);
}
} else if (i == 16) {
str = "问题点数量";
} else if (i == 17) { str = reportInfoVo.getQuestionCount()==null?"":reportInfoVo.getQuestionCount().toString();font.setStyle(Font.NORMAL);
Integer questionCount = reportInfoVO.getQuestionCount();
str = ObjectUtil.isNotEmpty(questionCount)?questionCount.toString():"0";
font.setStyle(Font.NORMAL);
}

Paragraph p = new Paragraph(str, font);
cell.add(p);
table2.addCell(cell);
}
wordUtils.getDocument().add(table2);

Map<String, Object> params = getInsCount(reportInfoVo);

wordUtils.insertTitlePatternThird("三:巡检结果", wordUtils.rtfGsBt3);
Table table3 = new Table(5);//生成一表格
table3.setOffset(1f);
@@ -376,7 +346,8 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
table3.setAutoFillEmptyCells(true);
// table3.setAlignment(Element.ALIGN_CENTER);//居中显示
// table3.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示
for (int i = 0; i < 44; i++) {
int cellSize = reportInfoVO.getQuestionTypeInfo().size() * 2 + 2;
for (int i = 0; i < cellSize; i++) {
Cell cell = new Cell();
String str = null;
cell.setVerticalAlignment(Element.ALIGN_CENTER);
@@ -384,201 +355,30 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
Font font = new Font();
font.setSize(10.5f);
font.setStyle(Font.BOLD);
if (i == 0) {str = "序号";
} else if (i == 1) {str = "项目";cell.setColspan(2);
if (i == 0) {str = "巡检内容";
} else if (i == 1) {str = "巡检监测结果";cell.setColspan(2);
} else if (i == 2) { str = "巡检内容";
} else if (i == 3) { str = "巡检监测结果";
} else if (i == 4) { str = "一";cell.setRowspan(7);
} else if (i == 5) { str = "水面";cell.setRowspan(7);
} else if (i == 6) { str = "日常监测";cell.setRowspan(4);
} else if (i == 7) { str = "有大面积漂浮物";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 8) { str = params.get("${totalCount1}").toString();font.setStyle(Font.NORMAL);
} else if (i == 9) { str = "水生植物死亡";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 10) { str = params.get("${totalCount2}").toString();font.setStyle(Font.NORMAL);
} else if (i == 11) { str = "水面有明显鱼类翻肚现象";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 12) { str = params.get("${totalCount3}").toString();font.setStyle(Font.NORMAL);
} else if (i == 13) { str = "河道内存在水生植被";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 14) { str = params.get("${totalCount13}").toString();font.setStyle(Font.NORMAL);
} else if (i == 15) { str = "重点核查";cell.setRowspan(3);
} else if (i == 16) { str = "河道内无大面积蓝藻爆发";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 17) { str = params.get("${totalCount4}").toString();font.setStyle(Font.NORMAL);
} else if (i == 18) { str = "水生动、植物大面积死亡";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 19) { str = params.get("${totalCount5}").toString();font.setStyle(Font.NORMAL);
} else if (i == 20) { str = "河道无违规阻水物";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 21) { str = params.get("${totalCount6}").toString();font.setStyle(Font.NORMAL);
} else if (i == 22) { str = "二";cell.setRowspan(4);
} else if (i == 23) { str = "岸线";cell.setRowspan(4);
} else if (i == 24) { str = "日常监测";cell.setRowspan(3);
} else if (i == 25) { str = "河道养护范围内大面积毁绿、种菜";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 26) { str = params.get("${totalCount7}").toString();font.setStyle(Font.NORMAL);
} else if (i == 27) { str = "河堤、栏杆等设施有损坏";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 28) { str = params.get("${totalCount8}").toString();font.setStyle(Font.NORMAL);
} else if (i == 29) { str = "岸坡有大面积垃圾";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 30) { str = params.get("${totalCount9}").toString();font.setStyle(Font.NORMAL);
} else if (i == 31) { str = "重点核查";
} else if (i == 32) { str = "河道蓝线内(岸上)新增违法建筑或构造物";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 33) { str = params.get("${totalCount10}").toString();font.setStyle(Font.NORMAL);
} else if (i == 34) { str = "三";
} else if (i == 35) { str = "排口";
} else if (i == 36) { str = "日常监测";
} else if (i == 37) { str = "发现未备案入河排口";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 38) { str = params.get("${totalCount11}").toString();font.setStyle(Font.NORMAL);
} else if (i ==39) { str = "四";
} else if (i == 40) { str = "水质";
} else if (i == 41) { str = "日常监测";
} else if (i == 42) { str = "按照相关水体标准,监测段面水质不达标";cell.setHorizontalAlignment(Element.ALIGN_LEFT);font.setStyle(Font.NORMAL);
} else if (i == 43) { str = params.get("${totalCount12}").toString();font.setStyle(Font.NORMAL);
}
Paragraph p = new Paragraph(str, font);
cell.add(p);
table3.addCell(cell);
}*/
/* wordUtils.getDocument().add(table3);
if(reportInfoVo.getImageList().size()>0) {
wordUtils.insertTitlePatternThird("四:问题清单", wordUtils.rtfGsBt3);
for (int i = 0; i < reportInfoVo.getImageList().size(); i++) {
QuestionReportVO inspectionFileInfoVo = reportInfoVo.getImageList().get(i);
InspectionQuestionItem item = inspectionQuestionItemService.getOne(new LambdaQueryWrapper<InspectionQuestionItem>()
.eq(inspectionFileInfoVo.getId() != null, InspectionQuestionItem::getInspectionFileId, inspectionFileInfoVo.getId())
.eq(InspectionQuestionItem::getTenantId, ShiroUtils.getTenantId()));
if (item != null) {
inspectionFileInfoVo.setHandImg(item.getHandlerImage());
inspectionFileInfoVo.setHandContent(item.getHandlerResult());
inspectionFileInfoVo.setHandTime(DateUtils.dateTime(item.getHandlerTime()));
User user = userService.getOne(new LambdaQueryWrapper<User>()
.eq(User::getId, item.getHandlerUser())
.eq(User::getTenantId, ShiroUtils.getTenantId()));
inspectionFileInfoVo.setHanderName(user.getRealname());
}

Table table4 = new Table(2);//生成一表格
table4.setOffset(1f);
int width4[] = {1, 2};
table4.setWidths(width4);//设置系列所占比例
table4.setWidth(100);
table4.setAutoFillEmptyCells(true);
//table4.setAlignment(Element.ALIGN_LEFT);//居中显示
// table4.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示
for (int j = 0; j < 15; j++) {
Cell cell = new Cell();
//cell.setVerticalAlignment(Element.ALIGN_LEFT);
//cell.setHorizontalAlignment(Element.ALIGN_CENTER);
String str = "";
Font font = new Font();
font.setSize(10.5f);
cell.setVerticalAlignment(Element.ALIGN_CENTER);
if (j == 0) {
font.setSize(12);
str = " 问题" + (i + 1);
cell.add(new Paragraph(str, font));
cell.setColspan(2);
font.setStyle(Font.BOLD);
//cell.setVerticalAlignment(Element.ALIGN_LEFT);
} else if (j == 1) {
str = " 坐标";
cell.add(new Paragraph(str, font));
} else if (j == 2) {
str = reportInfoVo.getImageList().get(i).getLongitude() + "," + reportInfoVo.getImageList().get(i).getLatitude();
cell.add(new Paragraph(str, font));
} else if (j == 3) {
str = " 问题描述";
cell.add(new Paragraph(str, font));
} else if (j == 4) {
str = reportInfoVo.getImageList().get(i).getContent();
cell.add(new Paragraph(str, font));
} else if (j == 5) {
str = " 问题图片";
cell.add(new Paragraph(str, font));
} else if (j == 6) {
Image image = null;
String url = CommonConfig.imageURL + reportInfoVo.getImageList().get(i).getFileImage();
if (new UrlResource(url).exists()) {
image = Image.getInstance(url);
image.setAlignment(Image.ALIGN_CENTER);
image.scalePercent(100); //依照比例缩放
image.setAbsolutePosition(400, 600);
image.scaleToFit(300, 300);//自定义大
} else {
log.error("图片不存在!" + url);
}
if (new UrlResource(url).exists()) {
cell.add(image);
} else {
cell.add(new Paragraph(""));
}
} else if (j == 7) {
str = " 处理结果";
cell.add(new Paragraph(str, font));
cell.setColspan(2);
font.setStyle(Font.BOLD);
} else if (j == 8) {
str = " 处理人";
cell.add(new Paragraph(str, font));
} else if (j == 9) {
str = inspectionFileInfoVo.getHanderName();
cell.add(new Paragraph(str, font));
} else if (j == 10) {
str = " 处理时间";
cell.add(new Paragraph(str, font));
} else if (j == 11) {
str = inspectionFileInfoVo.getHandTime();
cell.add(new Paragraph(str, font));
} else if (j == 12) {
str = " 备注";
cell.add(new Paragraph(str, font));
} else if (j == 13) {
str = inspectionFileInfoVo.getHandContent();
cell.add(new Paragraph(str, font));
} else if (j == 14) {
String[] handUrls = inspectionFileInfoVo.getHandImg().split(",");
for (int k = 0; k < handUrls.length; k++) {
cell = new Cell();
cell.setVerticalAlignment(Element.ALIGN_CENTER);
if (handUrls.length == 1) {
cell.add(new Paragraph(" 结果图片", font));
} else {
cell.add(new Paragraph(" 结果图片" + (k + 1), font));
}
table4.addCell(cell);
cell = new Cell();
Image image = null;
String url = CommonConfig.imageURL + handUrls[k];
if (new UrlResource(url).exists()) {
image = Image.getInstance(url);
image.setAlignment(Image.ALIGN_CENTER);
image.scalePercent(100); //依照比例缩放
image.setAbsolutePosition(400, 600);
image.scaleToFit(300, 300);//自定义大
} else {
System.out.println("图片不存在!" + url);
}
if (new UrlResource(url).exists()) {
cell.add(image);
} else {
cell.add(new Paragraph(""));
}
table4.addCell(cell);
}
}
if (j != 14) {
table4.addCell(cell);
}
}
wordUtils.getDocument().add(table4);
}
}
wordUtils.closeDocument();
wordUtils.getDocument().add(table3);
wordUtils.closeDocument();
}
//清空缓存
response.reset();
// 定义浏览器响应表头,并定义下载名
String fileName = URLEncoder.encode("南京市河道无人机巡检报告【"+ report.getReportNo() + "】.doc", "UTF-8");
String urlFileName = URLEncoder.encode("南京市河道无人机巡检报告【"+ reportInfoVO.getReportNo() + "】.doc", "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
response.setCharacterEncoding("utf-8");
//定义下载的类型
response.setContentType("application/msword;charset=UTF-8");
OutputStream out;
File files = new File(UploadFileConfig.uploadFolder +"doc/",filename);
File files = new File(UploadFileConfig.uploadFolder +"doc/",urlFileName);

FileInputStream inputStream = new FileInputStream(files);
//3.通过response获取ServletOutputStream对象(out)
@@ -599,18 +399,15 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
}finally {
wordUtils.closeDocument();
}*/

}

/**
* 生成报告编号,R+年月日+随机四位数
* @return
* @return 返回报告编号
*/
public String createReportNo(){
String Date = DateUtils.dateTimeNow(DateUtils.YYYYMMDD);
int randomNum = new Random().nextInt(9999) % (9999 - 1000 + 1) + 1000;
String reportNo = "R" + Date + randomNum;

return reportNo;
return "R" + Date + randomNum;
}
}

+ 1
- 1
tuoheng-admin/src/main/resources/application-airport.yml Просмотреть файл

@@ -199,7 +199,7 @@ generate:
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix: sys_
xxl:
enable: true
enable: false
job:
admin:
addresses: http://172.16.1.31:8110/xxl-job-admin

+ 1
- 1
tuoheng-admin/src/main/resources/application-dev.yml Просмотреть файл

@@ -205,7 +205,7 @@ logging:
config: classpath:logback.xml

xxl:
enable: true
enable: false
job:
admin:
addresses: http://192.168.11.11:8110/xxl-job-admin

+ 2
- 2
tuoheng-admin/src/main/resources/application-local.yml Просмотреть файл

@@ -152,7 +152,7 @@ file:
#静态资源对外暴露的访问路径
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: E:\Gitea仓库源码\tuoheng_lc\uploads\
uploadFolder: d:\file\tuoheng_lc\uploads\

# Shiro
shiro:
@@ -199,7 +199,7 @@ generate:
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix: sys_
xxl:
enable: true
enable: false
job:
admin:
addresses: http://192.168.11.11:8110/xxl-job-admin

+ 1
- 1
tuoheng-admin/src/main/resources/application-prod.yml Просмотреть файл

@@ -199,7 +199,7 @@ generate:
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix: sys_
xxl:
enable: true
enable: false
job:
admin:
addresses: http://172.16.1.31:8110/xxl-job-admin

+ 1
- 1
tuoheng-admin/src/main/resources/application-test.yml Просмотреть файл

@@ -199,7 +199,7 @@ generate:
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix: sys_
xxl:
enable: true
enable: false
job:
admin:
addresses: http://192.168.11.241:8110/xxl-job-admin

Загрузка…
Отмена
Сохранить