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(); | |||||
} | |||||
} |
*/ | */ | ||||
@PutMapping("/status") | @PutMapping("/status") | ||||
@ApiOperation(value = "被硬件调用,存任务状态", notes = "被硬件调用,存任务状态") | @ApiOperation(value = "被硬件调用,存任务状态", notes = "被硬件调用,存任务状态") | ||||
public JsonResult track(@RequestBody @Valid MissionStatusRequest missionStatusRequest) { | |||||
public JsonResult<Boolean> track(@RequestBody @Valid MissionStatusRequest missionStatusRequest) { | |||||
return JsonResult.success(missionService.updateStatus(missionStatusRequest)); | return JsonResult.success(missionService.updateStatus(missionStatusRequest)); | ||||
} | } | ||||
*/ | */ | ||||
@PostMapping("/track") | @PostMapping("/track") | ||||
@ApiOperation(value = "被硬件调用,存飞行轨迹", notes = "被硬件调用,存飞行轨迹") | @ApiOperation(value = "被硬件调用,存飞行轨迹", notes = "被硬件调用,存飞行轨迹") | ||||
public JsonResult track(@RequestBody @Valid InspectionRequest inspectionRequest) { | |||||
public JsonResult<Integer> track(@RequestBody @Valid InspectionRequest inspectionRequest) { | |||||
return JsonResult.success(inspectionService.track(inspectionRequest)); | return JsonResult.success(inspectionService.track(inspectionRequest)); | ||||
} | } | ||||
package com.tuoheng.admin.controller; | package com.tuoheng.admin.controller; | ||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 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.domain.ThMission; | ||||
import com.tuoheng.admin.entity.request.MissionQuery; | import com.tuoheng.admin.entity.request.MissionQuery; | ||||
import com.tuoheng.admin.entity.request.MissionRequest; | import com.tuoheng.admin.entity.request.MissionRequest; | ||||
import com.tuoheng.admin.entity.vo.MissionVO; | |||||
import com.tuoheng.admin.service.IMissionService; | import com.tuoheng.admin.service.IMissionService; | ||||
import com.tuoheng.common.exception.ServiceException; | import com.tuoheng.common.exception.ServiceException; | ||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
*/ | */ | ||||
@DeleteMapping("/{idList}") | @DeleteMapping("/{idList}") | ||||
@ApiOperation(value = "删除巡检任务", notes = "传入巡检任务id") | @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)); | return JsonResult.success(missionService.deleteBatch(idList)); | ||||
} | } | ||||
*/ | */ | ||||
@GetMapping("/page") | @GetMapping("/page") | ||||
@ApiOperation(value = "查询巡检任务列表", notes = "查询巡检任务分页") | @ApiOperation(value = "查询巡检任务列表", notes = "查询巡检任务分页") | ||||
public JsonResult findList(MissionQuery queryMissionRequest) { | |||||
public JsonResult<IPage<MissionVO>> findList(MissionQuery queryMissionRequest) { | |||||
return JsonResult.success(missionService.findList(queryMissionRequest)); | return JsonResult.success(missionService.findList(queryMissionRequest)); | ||||
} | } | ||||
package com.tuoheng.admin.controller; | package com.tuoheng.admin.controller; | ||||
import com.tuoheng.admin.entity.domain.Question; | 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.entity.vo.QuestionTypeCountVo; | ||||
import com.tuoheng.admin.enums.UpdateOrCreateEnum; | |||||
import com.tuoheng.admin.service.IQuestionService; | import com.tuoheng.admin.service.IQuestionService; | ||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
import com.tuoheng.system.utils.ShiroUtils; | 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.beans.factory.annotation.Autowired; | ||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import javax.validation.Valid; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
/** | /** | ||||
* 添加巡检问题 | |||||
* 被DSP调用,存问题 | |||||
* | * | ||||
* @param entity 实体对象 | * @param entity 实体对象 | ||||
* @return | * @return | ||||
*/ | */ | ||||
@PostMapping("") | @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); | |||||
} | } | ||||
/** | /** |
package com.tuoheng.admin.controller; | package com.tuoheng.admin.controller; | ||||
import com.baomidou.mybatisplus.core.metadata.IPage; | 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.request.ReportRequest; | ||||
import com.tuoheng.admin.entity.vo.ReportInfoVO; | import com.tuoheng.admin.entity.vo.ReportInfoVO; | ||||
import com.tuoheng.admin.entity.vo.ReportVO; | import com.tuoheng.admin.entity.vo.ReportVO; | ||||
* @return | * @return | ||||
*/ | */ | ||||
@GetMapping("/page") | @GetMapping("/page") | ||||
public JsonResult queryPage(ReportRequest request) { | |||||
public JsonResult<IPage<Report>> queryPage(ReportRequest request) { | |||||
return reportService.queryPage(request); | return reportService.queryPage(request); | ||||
} | } | ||||
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; | |||||
} | |||||
} |
@ApiModelProperty(value = "任务Id") | @ApiModelProperty(value = "任务Id") | ||||
private Integer missionId; | private Integer missionId; | ||||
@ApiModelProperty(value = "问题状态") | |||||
private Integer status; | |||||
@ApiModelProperty(value = "项目类型:病虫树、林斑、人员活动、火灾隐患") | @ApiModelProperty(value = "项目类型:病虫树、林斑、人员活动、火灾隐患") | ||||
private Integer type; | private Integer type; | ||||
@ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | @ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | ||||
private Integer status; | private Integer status; | ||||
@ApiModelProperty(value = "巡检报告是否生成 是否生成 0 未生成 1 需修改 2 已生成") | |||||
private Integer reportStatus; | |||||
@ApiModelProperty(value = "备注") | @ApiModelProperty(value = "备注") | ||||
private String note; | private String note; | ||||
@ApiModelProperty(value = "备注") | |||||
private String createUser; | |||||
@ApiModelProperty(value = "租户id",hidden = true) | @ApiModelProperty(value = "租户id",hidden = true) | ||||
private Integer tenantId; | private Integer tenantId; | ||||
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; | |||||
} | |||||
} |
package com.tuoheng.admin.service; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
public interface IDspService { | |||||
JSONObject serviceInstApplication(JSONObject jsonObject); | |||||
JSONObject serviceStopApplication(JSONObject jsonObject); | |||||
} |
* @author: zhu_zishuang | * @author: zhu_zishuang | ||||
* @date: 2021/9/2 | * @date: 2021/9/2 | ||||
*/ | */ | ||||
OperationEnum deleteBatch(List<Integer> idList); | |||||
boolean deleteBatch(List<Integer> idList); | |||||
} | } |
import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
import com.tuoheng.admin.entity.domain.Question; | 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.QuestionQuery; | ||||
import com.tuoheng.admin.entity.request.QuestionStatusRequest; | import com.tuoheng.admin.entity.request.QuestionStatusRequest; | ||||
import com.tuoheng.admin.entity.request.QuestionTypeQuery; | import com.tuoheng.admin.entity.request.QuestionTypeQuery; | ||||
JsonResult<Map<String, Integer>> analyzeController(Integer missionId); | JsonResult<Map<String, Integer>> analyzeController(Integer missionId); | ||||
JsonResult<List<QuestionTypeCountVo>> analyzeType(Integer missionId); | JsonResult<List<QuestionTypeCountVo>> analyzeType(Integer missionId); | ||||
JsonResult process(AIQuestionRequest request); | |||||
} | } |
* @param request | * @param request | ||||
* @return | * @return | ||||
*/ | */ | ||||
JsonResult queryPage(ReportRequest request); | |||||
JsonResult<IPage<Report>> queryPage(ReportRequest request); | |||||
/** | /** | ||||
* 查看报告 详情 | * 查看报告 详情 |
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请求失败!"; | |||||
} | |||||
} | |||||
} |
import cn.hutool.core.collection.CollectionUtil; | import cn.hutool.core.collection.CollectionUtil; | ||||
import cn.hutool.core.util.ObjectUtil; | 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.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||||
import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.tuoheng.admin.common.ServiceExceptionEnum; | import com.tuoheng.admin.common.ServiceExceptionEnum; | ||||
import com.tuoheng.admin.entity.vo.MissionVO; | import com.tuoheng.admin.entity.vo.MissionVO; | ||||
import com.tuoheng.admin.enums.*; | import com.tuoheng.admin.enums.*; | ||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
import com.tuoheng.admin.service.IDspService; | |||||
import com.tuoheng.admin.service.IMissionService; | import com.tuoheng.admin.service.IMissionService; | ||||
import com.tuoheng.admin.utils.CodeUtil; | import com.tuoheng.admin.utils.CodeUtil; | ||||
import com.tuoheng.common.common.BaseServiceImpl; | import com.tuoheng.common.common.BaseServiceImpl; | ||||
@Autowired | @Autowired | ||||
private RedisUtils redisUtils; | private RedisUtils redisUtils; | ||||
@Autowired | |||||
private IDspService dspService; | |||||
@Override | @Override | ||||
public Integer addMission(MissionRequest addThMissionRequest) throws ServiceException { | public Integer addMission(MissionRequest addThMissionRequest) throws ServiceException { | ||||
ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.WAIT.getCode()); | ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.WAIT.getCode()); | ||||
Assert.notNull(thMission, "飞行任务不能为空!"); | Assert.notNull(thMission, "飞行任务不能为空!"); | ||||
ThMission thMissionUpdate = setStatus(missionStatusRequest, 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()){ | }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; | return true; | ||||
}else{ | }else{ | ||||
} | } | ||||
} | } | ||||
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) { | private ThMission setStatus(MissionStatusRequest missionStatusRequest, ThMission thMission) { | ||||
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); | ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); | ||||
thMissionUpdate.setId(thMission.getId()); | thMissionUpdate.setId(thMission.getId()); | ||||
thMissionUpdate.setPullUrl(missionStatusRequest.getPullUrl()); | thMissionUpdate.setPullUrl(missionStatusRequest.getPullUrl()); | ||||
if(missionStatusRequest.getStatus()==AirPortTaskStatusEnum.FLIGHT.getCode()){ | if(missionStatusRequest.getStatus()==AirPortTaskStatusEnum.FLIGHT.getCode()){ | ||||
thMissionUpdate.setStatus(TaskStatusEnum.FLIGHT.getCode()); | thMissionUpdate.setStatus(TaskStatusEnum.FLIGHT.getCode()); | ||||
}else{ | |||||
thMissionUpdate.setStatus(TaskStatusEnum.COMPLETE.getCode()); | |||||
} | } | ||||
return thMissionUpdate; | return thMissionUpdate; | ||||
} | } | ||||
lambdaQueryWrapper.eq(ThMission::getStatus,status); | lambdaQueryWrapper.eq(ThMission::getStatus,status); | ||||
lambdaQueryWrapper.eq(ThMission::getTenantId,ShiroUtils.getTenantId()); | lambdaQueryWrapper.eq(ThMission::getTenantId,ShiroUtils.getTenantId()); | ||||
List<ThMission> thMissions = thMissionMapper.selectList(lambdaQueryWrapper); | 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 | @Override | ||||
@Override | @Override | ||||
public OperationEnum deleteBatch(List<Integer> idList) { | |||||
public boolean deleteBatch(List<Integer> idList) { | |||||
Integer updateUser = ShiroUtils.getUserId(); | 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; | |||||
} | } | ||||
} | } |
import com.tuoheng.admin.common.ServiceExceptionEnum; | import com.tuoheng.admin.common.ServiceExceptionEnum; | ||||
import com.tuoheng.admin.entity.domain.Question; | import com.tuoheng.admin.entity.domain.Question; | ||||
import com.tuoheng.admin.entity.domain.ThMission; | 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.QuestionQuery; | ||||
import com.tuoheng.admin.entity.request.QuestionStatusRequest; | import com.tuoheng.admin.entity.request.QuestionStatusRequest; | ||||
import com.tuoheng.admin.entity.request.QuestionTypeQuery; | import com.tuoheng.admin.entity.request.QuestionTypeQuery; | ||||
import com.tuoheng.admin.entity.vo.QuestionCountVo; | import com.tuoheng.admin.entity.vo.QuestionCountVo; | ||||
import com.tuoheng.admin.entity.vo.QuestionTypeCountVo; | 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.QuestionMapper; | ||||
import com.tuoheng.admin.mapper.ThMissionMapper; | import com.tuoheng.admin.mapper.ThMissionMapper; | ||||
import com.tuoheng.admin.service.IQuestionService; | import com.tuoheng.admin.service.IQuestionService; | ||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
import com.tuoheng.system.utils.ShiroUtils; | import com.tuoheng.system.utils.ShiroUtils; | ||||
import io.swagger.models.auth.In; | import io.swagger.models.auth.In; | ||||
import org.springframework.beans.BeanUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.Arrays; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.*; | |||||
/** | /** | ||||
* 巡检问题表 服务实现类 | * 巡检问题表 服务实现类 | ||||
.like(ObjectUtil.isNotEmpty(query.getMissionName()), Question::getMissionName, query.getMissionName()) | .like(ObjectUtil.isNotEmpty(query.getMissionName()), Question::getMissionName, query.getMissionName()) | ||||
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())),Question::getCreateTime,query.getStartTime(),query.getEndTime()) | .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.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)); | .eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime)); | ||||
return pageData; | return pageData; | ||||
} | } | ||||
.like(ObjectUtil.isNotEmpty(query.getMissionName()), Question::getMissionName, query.getMissionName()) | .like(ObjectUtil.isNotEmpty(query.getMissionName()), Question::getMissionName, query.getMissionName()) | ||||
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())), Question::getCreateTime, query.getStartTime(), query.getEndTime()) | .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.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)); | .eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime)); | ||||
return questionList; | return questionList; | ||||
} | } | ||||
List<QuestionTypeCountVo> questionTypeCountList= questionMapper.analyzeType(missionId, ShiroUtils.getTenantId()); | List<QuestionTypeCountVo> questionTypeCountList= questionMapper.analyzeType(missionId, ShiroUtils.getTenantId()); | ||||
return JsonResult.success(questionTypeCountList); | 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; | |||||
} | |||||
} | } |
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.net.URLEncoder; | import java.net.URLEncoder; | ||||
import java.text.SimpleDateFormat; | |||||
import java.util.*; | import java.util.*; | ||||
import java.util.List; | import java.util.List; | ||||
} | } | ||||
@Override | @Override | ||||
public JsonResult queryPage(ReportRequest request) { | |||||
public JsonResult<IPage<Report>> queryPage(ReportRequest request) { | |||||
if(null == request.getPage() || null == request.getLimit()){ | if(null == request.getPage() || null == request.getLimit()){ | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
@Override | @Override | ||||
public ReportInfoVO detail(Integer reportId) { | public ReportInfoVO detail(Integer reportId) { | ||||
ReportInfoVO reportInfoVo = new ReportInfoVO(); | |||||
ReportInfoVO reportInfoVO = new ReportInfoVO(); | |||||
//查询报告 | //查询报告 | ||||
Report report = reportMapper.selectById(reportId); | Report report = reportMapper.selectById(reportId); | ||||
Integer missionId = report.getMissionId(); | 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); | ThMission thMission = missionMapper.selectById(missionId); | ||||
MissionVO missionVO=new MissionVO(); | MissionVO missionVO=new MissionVO(); | ||||
BeanUtils.copyProperties(thMission,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); | 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); | JsonResult<List<QuestionCountVo>> analyze = questionService.analyze(missionId); | ||||
Iterator<QuestionCountVo> iterator = analyze.getData().stream().iterator(); | Iterator<QuestionCountVo> iterator = analyze.getData().stream().iterator(); | ||||
int questionCount=0; | int questionCount=0; | ||||
questionCount+=questionCountVo.getQuantity(); | 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()) | List<Question> questionList = questionService.list(new LambdaQueryWrapper<Question>().eq(Question::getTenantId, ShiroUtils.getTenantId()) | ||||
.eq(Question::getMissionId, missionId) | .eq(Question::getMissionId, missionId) | ||||
.eq(Question::getStatus, QuestionStatusEnum.CONFIRM.getCode()) | |||||
); | ); | ||||
List<QuestionReportVO> questionReportVOList=new ArrayList<>(); | List<QuestionReportVO> questionReportVOList=new ArrayList<>(); | ||||
questionReportVOList.add(questionReportVO); | questionReportVOList.add(questionReportVO); | ||||
} | } | ||||
//问题列表 | //问题列表 | ||||
reportInfoVo.setQuestionReportList(questionReportVOList); | |||||
reportInfoVO.setQuestionReportList(questionReportVOList); | |||||
} | } | ||||
@Override | @Override | ||||
public void exportReportWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception { | 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 | //创建word | ||||
String fileName = report.getReportNo()+".doc"; | |||||
String fileName = reportInfoVO.getReportNo()+".doc"; | |||||
String filePath = UploadFileConfig.uploadFolder+"/doc/"+fileName; | String filePath = UploadFileConfig.uploadFolder+"/doc/"+fileName; | ||||
File fd = new File(UploadFileConfig.uploadFolder+"/doc"); | File fd = new File(UploadFileConfig.uploadFolder+"/doc"); | ||||
File f = new File(filePath); | File f = new File(filePath); | ||||
fd.mkdirs(); | fd.mkdirs(); | ||||
} | } | ||||
WordUtilsOld wordUtils = new WordUtilsOld(); | WordUtilsOld wordUtils = new WordUtilsOld(); | ||||
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
try { | try { | ||||
if(!f.exists()||f.length()<1000) { | if(!f.exists()||f.length()<1000) { | ||||
f.delete(); | f.delete(); | ||||
wordUtils.getDocument().setPageSize(PageSize.A4); | wordUtils.getDocument().setPageSize(PageSize.A4); | ||||
wordUtils.getDocument().setMargins(71f, 71f, 72f, 72f); | 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); | table.setOffset(1f); | ||||
int width[] = {1, 1, 1, 1, 1,1}; | |||||
int width[] = {1, 1}; | |||||
table.setWidths(width);//设置系列所占比例 | table.setWidths(width);//设置系列所占比例 | ||||
table.setWidth(100); | |||||
table.setWidth(300); | |||||
table.setAutoFillEmptyCells(true); | table.setAutoFillEmptyCells(true); | ||||
table.setAlignment(Element.ALIGN_LEFT);//居中显示 | table.setAlignment(Element.ALIGN_LEFT);//居中显示 | ||||
for (int i = 0; i < 11; i++) { | |||||
for (int i = 0; i < 6; i++) { | |||||
Cell cell = new Cell(); | Cell cell = new Cell(); | ||||
String str = null; | String str = null; | ||||
cell.setVerticalAlignment(Element.ALIGN_RIGHT); | cell.setVerticalAlignment(Element.ALIGN_RIGHT); | ||||
font.setSize(10.5f); | font.setSize(10.5f); | ||||
font.setStyle(Font.BOLD); | font.setStyle(Font.BOLD); | ||||
if (i == 0) { | if (i == 0) { | ||||
str = "河道基本信息";cell.setColspan(6); | |||||
str = "责任单位";cell.setColspan(6); | |||||
} else if (i == 1) { | } else if (i == 1) { | ||||
str = "责任单位"; | |||||
str = reportInfoVO.getCompany(); | |||||
} else if (i == 2) { | } else if (i == 2) { | ||||
str = reportInfoVo.getStreamArea(); | |||||
str = "林场名称"; | |||||
font.setStyle(Font.NORMAL); | font.setStyle(Font.NORMAL); | ||||
} else if (i == 3) { | } else if (i == 3) { | ||||
str = "河流名称"; | |||||
str = reportInfoVO.getLcName(); | |||||
} else if (i == 4) { | } 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 = "巡查里程"; | str = "巡查里程"; | ||||
} else if (i == 10) { | |||||
str = reportInfoVo.getStreamLength(); | |||||
font.setStyle(Font.NORMAL); | font.setStyle(Font.NORMAL); | ||||
} else if (i == 5) { | |||||
str = reportInfoVO.getMission().getMileage(); | |||||
} | } | ||||
Paragraph p = new Paragraph(str, font); | Paragraph p = new Paragraph(str, font); | ||||
cell.add(p); | cell.add(p); | ||||
wordUtils.getDocument().add(table); | wordUtils.getDocument().add(table); | ||||
wordUtils.insertTitlePatternThird("二:巡检信息", wordUtils.rtfGsBt3); | wordUtils.insertTitlePatternThird("二:巡检信息", wordUtils.rtfGsBt3); | ||||
Table table2 = new Table(6);//生成一表格 | |||||
Table table2 = new Table(2);//生成一表格 | |||||
table2.setOffset(1f); | table2.setOffset(1f); | ||||
int width2[] = {1, 1, 1, 1, 1, 1}; | int width2[] = {1, 1, 1, 1, 1, 1}; | ||||
table2.setWidths(width2);//设置系列所占比例 | table2.setWidths(width2);//设置系列所占比例 | ||||
table2.setAutoFillEmptyCells(true); | table2.setAutoFillEmptyCells(true); | ||||
table2.setAlignment(Element.ALIGN_CENTER);//居中显示 | table2.setAlignment(Element.ALIGN_CENTER);//居中显示 | ||||
table2.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示 | table2.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示 | ||||
for (int i = 0; i < 18; i++) { | |||||
for (int i = 0; i < 11; i++) { | |||||
Cell cell = new Cell(); | Cell cell = new Cell(); | ||||
String str = null; | String str = null; | ||||
cell.setVerticalAlignment(Element.ALIGN_LEFT); | cell.setVerticalAlignment(Element.ALIGN_LEFT); | ||||
font.setSize(10.5f); | font.setSize(10.5f); | ||||
font.setStyle(Font.BOLD); | font.setStyle(Font.BOLD); | ||||
if (i == 0) { | if (i == 0) { | ||||
str = "天气情况"; | |||||
str = "气象信息"; | |||||
} else if (i == 1) { | } 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) { | } else if (i == 2) { | ||||
str = "巡查人数"; | |||||
str = "巡检方式"; | |||||
} else if (i == 3) { | } 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) { | } else if (i == 4) { | ||||
str = "巡查人员"; | |||||
str = "巡检设备"; | |||||
} else if (i == 5) { | } else if (i == 5) { | ||||
str = reportInfoVo.getFlightHandName();font.setStyle(Font.NORMAL); | |||||
str = reportInfoVO.getMission().getDroneName(); | |||||
font.setStyle(Font.NORMAL); | |||||
} else if (i == 6) { | } else if (i == 6) { | ||||
str = "巡查方式"; | |||||
str = "巡检开始时间"; | |||||
} else if (i == 7) { | } 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); | font.setStyle(Font.NORMAL); | ||||
} else if (i == 8) { | } else if (i == 8) { | ||||
str = "巡查设备"; | |||||
str = "巡检结束时间"; | |||||
}else if (i == 9) { | }else if (i == 9) { | ||||
str = reportInfoVo.getInspectionDevice();font.setStyle(Font.NORMAL); | |||||
str = simpleDateFormat.format(reportInfoVO.getMission().getExecutionEndTime()); | |||||
} else if (i == 10) { | } else if (i == 10) { | ||||
str = "巡查日期"; | |||||
str = "问题数量"; | |||||
} else if (i == 11) { | } 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); | Paragraph p = new Paragraph(str, font); | ||||
cell.add(p); | cell.add(p); | ||||
table2.addCell(cell); | table2.addCell(cell); | ||||
} | } | ||||
wordUtils.getDocument().add(table2); | wordUtils.getDocument().add(table2); | ||||
Map<String, Object> params = getInsCount(reportInfoVo); | |||||
wordUtils.insertTitlePatternThird("三:巡检结果", wordUtils.rtfGsBt3); | wordUtils.insertTitlePatternThird("三:巡检结果", wordUtils.rtfGsBt3); | ||||
Table table3 = new Table(5);//生成一表格 | Table table3 = new Table(5);//生成一表格 | ||||
table3.setOffset(1f); | table3.setOffset(1f); | ||||
table3.setAutoFillEmptyCells(true); | table3.setAutoFillEmptyCells(true); | ||||
// table3.setAlignment(Element.ALIGN_CENTER);//居中显示 | // table3.setAlignment(Element.ALIGN_CENTER);//居中显示 | ||||
// table3.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示 | // 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(); | Cell cell = new Cell(); | ||||
String str = null; | String str = null; | ||||
cell.setVerticalAlignment(Element.ALIGN_CENTER); | cell.setVerticalAlignment(Element.ALIGN_CENTER); | ||||
Font font = new Font(); | Font font = new Font(); | ||||
font.setSize(10.5f); | font.setSize(10.5f); | ||||
font.setStyle(Font.BOLD); | 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 == 2) { str = "巡检内容"; | ||||
} else if (i == 3) { str = "巡检监测结果"; | } else if (i == 3) { str = "巡检监测结果"; | ||||
} else if (i == 4) { str = "一";cell.setRowspan(7); | } else if (i == 4) { str = "一";cell.setRowspan(7); | ||||
} else if (i == 5) { 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); | Paragraph p = new Paragraph(str, font); | ||||
cell.add(p); | cell.add(p); | ||||
table3.addCell(cell); | 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(); | 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.setHeader("Content-Disposition", "attachment;filename=" + fileName); | ||||
response.setCharacterEncoding("utf-8"); | response.setCharacterEncoding("utf-8"); | ||||
//定义下载的类型 | //定义下载的类型 | ||||
response.setContentType("application/msword;charset=UTF-8"); | response.setContentType("application/msword;charset=UTF-8"); | ||||
OutputStream out; | OutputStream out; | ||||
File files = new File(UploadFileConfig.uploadFolder +"doc/",filename); | |||||
File files = new File(UploadFileConfig.uploadFolder +"doc/",urlFileName); | |||||
FileInputStream inputStream = new FileInputStream(files); | FileInputStream inputStream = new FileInputStream(files); | ||||
//3.通过response获取ServletOutputStream对象(out) | //3.通过response获取ServletOutputStream对象(out) | ||||
}finally { | }finally { | ||||
wordUtils.closeDocument(); | wordUtils.closeDocument(); | ||||
}*/ | }*/ | ||||
} | } | ||||
/** | /** | ||||
* 生成报告编号,R+年月日+随机四位数 | * 生成报告编号,R+年月日+随机四位数 | ||||
* @return | |||||
* @return 返回报告编号 | |||||
*/ | */ | ||||
public String createReportNo(){ | public String createReportNo(){ | ||||
String Date = DateUtils.dateTimeNow(DateUtils.YYYYMMDD); | String Date = DateUtils.dateTimeNow(DateUtils.YYYYMMDD); | ||||
int randomNum = new Random().nextInt(9999) % (9999 - 1000 + 1) + 1000; | int randomNum = new Random().nextInt(9999) % (9999 - 1000 + 1) + 1000; | ||||
String reportNo = "R" + Date + randomNum; | |||||
return reportNo; | |||||
return "R" + Date + randomNum; | |||||
} | } | ||||
} | } |
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | ||||
tablePrefix: sys_ | tablePrefix: sys_ | ||||
xxl: | xxl: | ||||
enable: true | |||||
enable: false | |||||
job: | job: | ||||
admin: | admin: | ||||
addresses: http://172.16.1.31:8110/xxl-job-admin | addresses: http://172.16.1.31:8110/xxl-job-admin |
config: classpath:logback.xml | config: classpath:logback.xml | ||||
xxl: | xxl: | ||||
enable: true | |||||
enable: false | |||||
job: | job: | ||||
admin: | admin: | ||||
addresses: http://192.168.11.11:8110/xxl-job-admin | addresses: http://192.168.11.11:8110/xxl-job-admin |
#静态资源对外暴露的访问路径 | #静态资源对外暴露的访问路径 | ||||
staticAccessPath: /** | staticAccessPath: /** | ||||
#静态资源实际存储路径 | #静态资源实际存储路径 | ||||
uploadFolder: E:\Gitea仓库源码\tuoheng_lc\uploads\ | |||||
uploadFolder: d:\file\tuoheng_lc\uploads\ | |||||
# Shiro | # Shiro | ||||
shiro: | shiro: | ||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | ||||
tablePrefix: sys_ | tablePrefix: sys_ | ||||
xxl: | xxl: | ||||
enable: true | |||||
enable: false | |||||
job: | job: | ||||
admin: | admin: | ||||
addresses: http://192.168.11.11:8110/xxl-job-admin | addresses: http://192.168.11.11:8110/xxl-job-admin |
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | ||||
tablePrefix: sys_ | tablePrefix: sys_ | ||||
xxl: | xxl: | ||||
enable: true | |||||
enable: false | |||||
job: | job: | ||||
admin: | admin: | ||||
addresses: http://172.16.1.31:8110/xxl-job-admin | addresses: http://172.16.1.31:8110/xxl-job-admin |
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | ||||
tablePrefix: sys_ | tablePrefix: sys_ | ||||
xxl: | xxl: | ||||
enable: true | |||||
enable: false | |||||
job: | job: | ||||
admin: | admin: | ||||
addresses: http://192.168.11.241:8110/xxl-job-admin | addresses: http://192.168.11.241:8110/xxl-job-admin |