Quellcode durchsuchen

新增租户字段,变更查询和新增代码

tags/v1.2.0^2
douzhenjun vor 1 Jahr
Ursprung
Commit
b14b2f877c
19 geänderte Dateien mit 217 neuen und 126 gelöschten Zeilen
  1. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/MissionController.java
  2. +5
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/QuestionHandle.java
  3. +5
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrder.java
  4. +2
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/index/GetQuestionListDto.java
  5. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/QuestionMapper.java
  6. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/ThInspectionMapper.java
  7. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/WorkOrderMapper.java
  8. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/airport/drone/QueryDroneDataService.java
  9. +6
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/IndexServiceImpl.java
  10. +18
    -6
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java
  11. +118
    -94
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java
  12. +15
    -5
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java
  13. +12
    -7
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java
  14. +18
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/WorkOrderServiceImpl.java
  15. +5
    -4
      tuoheng-admin/src/main/resources/mapper/QuestionMapper.xml
  16. +1
    -1
      tuoheng-admin/src/main/resources/mapper/ThInspectionMapper.xml
  17. +2
    -1
      tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml
  18. +4
    -0
      tuoheng-common/pom.xml
  19. +1
    -0
      tuoheng-common/src/main/java/com/tuoheng/common/common/BaseServiceImpl.java

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/MissionController.java Datei anzeigen

@@ -70,7 +70,7 @@ public class MissionController {
LambdaQueryWrapper<ThMission> lambdaQueryTimeWrapper= new LambdaQueryWrapper<>();
lambdaQueryTimeWrapper.eq(ThMission::getInspectionLine, request.getInspectionLine());
lambdaQueryTimeWrapper.between(ThMission::getExecutionStartTime, startTime,endTime);
//lambdaQueryTimeWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId());
lambdaQueryTimeWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId());
List<ThMission> missionListTime = missionService.getList(lambdaQueryTimeWrapper);
if(!ObjectUtils.isEmpty(missionListTime) || missionListTime.size() >0 ){
throw new ServiceException(HttpStatus.SC_BAD_REQUEST,"同一个航线已存在相同的巡检时间!");

+ 5
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/QuestionHandle.java Datei anzeigen

@@ -26,6 +26,11 @@ public class QuestionHandle extends BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;

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

/**
* 巡检问题文件ID
*/

+ 5
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrder.java Datei anzeigen

@@ -46,6 +46,11 @@ public class WorkOrder extends BaseEntity implements Serializable {
*/
private String assignNote;

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

/**
* 指派时间
*/

+ 2
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/index/GetQuestionListDto.java Datei anzeigen

@@ -15,6 +15,8 @@ import javax.validation.constraints.NotEmpty;
@Data
public class GetQuestionListDto {

private Integer tenantId;//新增

@NotEmpty(message = "startTime can not be empty!")
private String startTime;


+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/QuestionMapper.java Datei anzeigen

@@ -17,7 +17,7 @@ import java.util.List;
*/
public interface QuestionMapper extends BaseMapper<Question> {

List<QuestionCountVO> analyze(Integer missionId);
List<QuestionCountVO> analyze(Integer missionId, Integer tenantId);

List<QuestionTypeCountVO> analyzeType(Integer missionId, Integer tenantId);


+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/ThInspectionMapper.java Datei anzeigen

@@ -8,6 +8,6 @@ import java.util.List;

public interface ThInspectionMapper extends BaseMapper<ThInspection> {

List<ThInspection> selectListByMissionId(Integer missionId);
List<ThInspection> selectListByMissionId(Integer missionId, Integer tenantId);

}

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/WorkOrderMapper.java Datei anzeigen

@@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Param;


public interface WorkOrderMapper extends BaseMapper<WorkOrder> {
IPage<WorkOrderQuestionVO> questionPage(@Param("page") IPage page, @Param("request") WorkOrderQuestionRequest request);
IPage<WorkOrderQuestionVO> questionPage(@Param("page") IPage page, @Param("request") WorkOrderQuestionRequest request, int tenantId);
}

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/airport/drone/QueryDroneDataService.java Datei anzeigen

@@ -54,7 +54,7 @@ public class QueryDroneDataService {
throw new ServiceException("没有正在飞行的任务");
}

List<ThInspection> inspectionList = inspectionMapper.selectListByMissionId(mission.getId());
List<ThInspection> inspectionList = inspectionMapper.selectListByMissionId(mission.getId(), ShiroUtils.getTenantId());
if (CollectionUtil.isEmpty(inspectionList)) {
JsonResult.success("无人机数据为空");
}

+ 6
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/IndexServiceImpl.java Datei anzeigen

@@ -25,6 +25,7 @@ import com.tuoheng.common.utils.HttpUtils;
import com.tuoheng.common.utils.JacksonUtil;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.StringUtils;
import com.tuoheng.system.entity.User;
import com.tuoheng.system.utils.ShiroUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
@@ -64,7 +65,9 @@ public class IndexServiceImpl implements IndexService {
page.setSize(baseQuery.getLimit() != null ? baseQuery.getLimit() : 10);
page.setCurrent(baseQuery.getPage() != null ? baseQuery.getPage() : 0);
LambdaQueryWrapper<ThMission> queryMission=new LambdaQueryWrapper<>();
queryMission.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode()).orderByDesc(ThMission::getCreateTime);
queryMission.eq(ThMission::getTenantId,ShiroUtils.getTenantId())//xz
.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode())
.orderByDesc(ThMission::getCreateTime);
queryMission.in(ThMission::getStatus, Arrays.asList(TaskStatusEnum.FLIGHT.getCode(),TaskStatusEnum.WAIT.getCode()));
IPage<ThMission> thMissionIPage = thMissionMapper.selectPage(page, queryMission);
List<ThMission> records = thMissionIPage.getRecords();
@@ -134,10 +137,12 @@ public class IndexServiceImpl implements IndexService {
@Override
@Transactional(readOnly = true)
public List<QuestionListDto> getQuestionList(GetQuestionListDto getQuestionListDto){
getQuestionListDto.setTenantId(ShiroUtils.getTenantId());//新增
if(ObjectUtil.isNotEmpty(getQuestionListDto.getStartTime()) && ObjectUtil.isNotEmpty(getQuestionListDto.getEndTime())){
getQuestionListDto.setStartTime(getQuestionListDto.getStartTime() + " 00:00:00");
getQuestionListDto.setEndTime(getQuestionListDto.getEndTime() + " 23:59:59");
}

List<QuestionListDto> questionListDtoList = questionMapper.getIndexQuestion(getQuestionListDto);
for(QuestionListDto questionListDto : questionListDtoList){
if(questionListDto.getHandlerImage() != null){

+ 18
- 6
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java Datei anzeigen

@@ -4,6 +4,7 @@ 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.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -95,11 +96,14 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
ThMission tm=new ThMission(UpdateOrCreateEnum.CREATE.getCode());
tm.setCreateUser(ShiroUtils.getUserId());
tm.setUpdateUser(ShiroUtils.getUserId());
tm.setTenantId(ShiroUtils.getTenantId());//xz
BeanUtils.copyProperties(addThMissionRequest,tm);

//任务名称不能重复
List<ThMission> thMissions = thMissionMapper.selectList(new LambdaQueryWrapper<ThMission>().eq(ThMission::getName, addThMissionRequest.getName())
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()));
List<ThMission> thMissions = thMissionMapper.selectList(new LambdaQueryWrapper<ThMission>()
.eq(ThMission::getTenantId, ShiroUtils.getTenantId())//xz
.eq(ThMission::getName, addThMissionRequest.getName())
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()));

if(thMissions.size()>0){
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"任务名称不能重复!");
@@ -187,6 +191,7 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
//开始分析
try {
JSONObject jsonObject = startAI(missionStatusRequest);
thMissionUpdate.setTenantId(ShiroUtils.getTenantId());//xz
thMissionUpdate.setRequestId(jsonObject.getJSONObject("data").getString("requestId"));
thMissionUpdate.setAipullUrl(jsonObject.getJSONObject("data").getString("aipullUrl"));
thMissionUpdate.setAipushUrl(jsonObject.getJSONObject("data").getString("aipushUrl"));
@@ -324,10 +329,11 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
Page<ThMission> page = new Page<>();
page.setSize(queryInspectionRequest.getLimit());
page.setCurrent(queryInspectionRequest.getPage());
queryInspectionRequest.setTenantId(ShiroUtils.getTenantId());
LambdaQueryWrapper<ThMission> queryMission=new LambdaQueryWrapper<>();
queryParam(queryInspectionRequest, queryMission);
queryMission.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode()).orderByDesc(ThMission::getCreateTime);
queryMission.eq(ThMission::getTenantId, ShiroUtils.getTenantId())//xz
.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode())
.orderByDesc(ThMission::getCreateTime);

IPage<ThMission> thMissionIPage = thMissionMapper.selectPage(page, queryMission);
List<ThMission> records = thMissionIPage.getRecords();
@@ -403,7 +409,9 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
@Override
public MissionVO findById(Integer id) {
MissionVO missionVO=new MissionVO();
BeanUtils.copyProperties(thMissionMapper.selectById(id),missionVO);
LambdaQueryWrapper<ThMission> queryWrapper = new LambdaQueryWrapper<>();//xz
queryWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId()).eq(ThMission::getId, id);//xz
BeanUtils.copyProperties(thMissionMapper.selectOne(queryWrapper),missionVO);//xz
return missionVO;
}

@@ -414,6 +422,7 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
ThMission mission=new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
mission.setMark(MarkTypeEnum.NOTVALID.getCode());
boolean result=false;
//如果成功更新
if(thMissionMapper.update(mission,new LambdaUpdateWrapper<ThMission>().in(ThMission::getId,idList))>0){
Integer missionId = mission.getId();
questionMapper.delete(new LambdaQueryWrapper<Question>().eq(Question::getMissionId,missionId));
@@ -428,6 +437,7 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
public MissionLiveVO live(Integer id) {
//根据机场的Id查询出来直播的对象
LambdaQueryWrapper<ThMission> lambdaQueryWrapper=new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ThMission::getTenantId,ShiroUtils.getTenantId());//xz
lambdaQueryWrapper.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode());
lambdaQueryWrapper.eq(ThMission::getAirportId,id);
lambdaQueryWrapper.eq(ThMission::getStatus,TaskStatusEnum.FLIGHT.getCode()).orderByDesc(ThMission::getExecutionStartTime);
@@ -447,7 +457,9 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryVideoServiceEnum.MISSION_ID_IS_NULL.getCode(), QueryVideoServiceEnum.MISSION_ID_IS_NULL.getMsg());
}
ThMission thMission = thMissionMapper.selectById(id);
LambdaQueryWrapper<ThMission> queryWrapper = new LambdaQueryWrapper<>();//xz
queryWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId()).eq(ThMission::getId, id);//xz
ThMission thMission = thMissionMapper.selectOne(queryWrapper);//xz
if (ObjectUtil.isNull(thMission)) {
return JsonResult.error(QueryVideoServiceEnum.MISSION_IS_NOT_EXIST.getCode(), QueryVideoServiceEnum.MISSION_IS_NOT_EXIST.getMsg());


+ 118
- 94
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java Datei anzeigen

@@ -3,6 +3,7 @@ package com.tuoheng.admin.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.common.ServiceExceptionEnum;
@@ -72,46 +73,64 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio

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

@Override
public JsonResult deleteByIds(Integer[] ids) {
if (org.springframework.util.StringUtils.isEmpty(ids)) {
return JsonResult.error("记录ID不能为空");
}
// String[] item = ids.split(",");
// 设置Mark=0
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.set("mark", 0);
updateWrapper.in("id", ids);
boolean result = update(updateWrapper);
if (!result) {
return JsonResult.error();
}
return JsonResult.success("删除成功");
}

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

LambdaQueryWrapper<Question> questionLambdaQueryWrapper = new LambdaQueryWrapper<Question>()
.eq(Question::getTenantId, ShiroUtils.getTenantId())//xz
.eq(ObjectUtil.isNotEmpty(query.getMissionId()), Question::getMissionId, query.getMissionId())
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName())
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType())
.eq(ObjectUtil.isNotEmpty(query.getStatus()), Question::getStatus, query.getStatus())
//.eq(Question::getTenantId, ShiroUtils.getTenantId())
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime);
if(ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())){
query.setStartTime(query.getStartTime()+" 00:00:00");
query.setEndTime(query.getEndTime()+" 23:59:59");
if (ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())) {
query.setStartTime(query.getStartTime() + " 00:00:00");
query.setEndTime(query.getEndTime() + " 23:59:59");
questionLambdaQueryWrapper.between(Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime()));
}
IPage<Question> pageData = questionMapper.selectPage(page, questionLambdaQueryWrapper);
List<Question> questions = pageData.getRecords();
List<QuestionVO> questionVOList = new ArrayList<>();
questions.forEach(question->{
questions.forEach(question -> {
QuestionVO questionVO = new QuestionVO();
BeanUtils.copyProperties(question,questionVO);
BeanUtils.copyProperties(question, questionVO);
LambdaQueryWrapper<WorkOrderQuestion> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(WorkOrderQuestion::getQuestionId, question.getId());
lambdaQueryWrapper.eq(WorkOrderQuestion::getTenantId, question.getTenantId())//xz
.eq(WorkOrderQuestion::getQuestionId, question.getId());
WorkOrderQuestion workOrderQuestion = workOrderQuestionMapper.selectOne(lambdaQueryWrapper);
if(workOrderQuestion != null){
if (workOrderQuestion != null) {
questionVO.setWordOrderStatus(1);
questionVO.setHandleStatus(workOrderQuestion.getStatus());
}else {
} else {
questionVO.setWordOrderStatus(0);
questionVO.setHandleStatus(0);
}
questionVOList.add(questionVO);
});
IPage<QuestionVO> resultPage=new Page<>();
IPage<QuestionVO> resultPage = new Page<>();
resultPage.setCurrent(pageData.getCurrent());
resultPage.setPages(pageData.getPages());
resultPage.setSize(pageData.getSize());
@@ -124,38 +143,39 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
@Override
public List<Question> distributed(QuestionQuery query) {
List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>()
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode())
.in(ThMission::getStatus, Arrays.asList(TaskStatusEnum.FLIGHT.getCode(),TaskStatusEnum.FAIL.getCode(),TaskStatusEnum.COMPLETE.getCode()))
.orderByDesc(ThMission::getUpdateTime));
.eq(ThMission::getTenantId, ShiroUtils.getTenantId())//xz
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode())
.in(ThMission::getStatus, Arrays.asList(TaskStatusEnum.FLIGHT.getCode(), TaskStatusEnum.FAIL.getCode(), TaskStatusEnum.COMPLETE.getCode()))
.orderByDesc(ThMission::getUpdateTime));
return getQuestions(query, thMissions);
}

private List<Question> getQuestions(QuestionQuery query, List<ThMission> thMissions) {
if(thMissions.size()==0){
if (thMissions.size() == 0) {
return new ArrayList<>();
}
try {
LambdaQueryWrapper<Question> questionLambdaQueryWrapper = new LambdaQueryWrapper<Question>()
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType())
.eq(Question::getStatus, QuestionStatusEnum.CONFIRM.getCode())
//.eq(Question::getTenantId, ShiroUtils.getTenantId())
.eq(Question::getTenantId, ShiroUtils.getTenantId())//xz
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime);

if(ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())){
query.setStartTime(query.getStartTime()+" 00:00:00");
query.setEndTime(query.getEndTime()+" 23:59:59");
if (ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())) {
query.setStartTime(query.getStartTime() + " 00:00:00");
query.setEndTime(query.getEndTime() + " 23:59:59");
questionLambdaQueryWrapper.between(Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime()));
}

if((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime()))
|| StringUtils.isNotEmpty(query.getMissionName())){
if ((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime()))
|| StringUtils.isNotEmpty(query.getMissionName())) {
questionLambdaQueryWrapper.like(StringUtils.isNotEmpty(query.getMissionName()), Question::getMissionName, query.getMissionName());
}else {
} else {
//只需要取最上面的那一条
questionLambdaQueryWrapper.eq(Question::getMissionId, thMissions.get(0).getId());
}
return questionMapper.selectList(questionLambdaQueryWrapper);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
log.error("查询出错!");
return null;
@@ -167,91 +187,92 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
//已经生成工单的问题无法修改
for (Integer id : entity.getId()) {
List<WorkOrderQuestion> workOrderQuestions = workOrderQuestionMapper.selectList(new LambdaQueryWrapper<WorkOrderQuestion>()
.eq(WorkOrderQuestion::getQuestionId, id));
if(StringUtils.isNotEmpty(workOrderQuestions)){
.eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.eq(WorkOrderQuestion::getQuestionId, id));
if (StringUtils.isNotEmpty(workOrderQuestions)) {
return JsonResult.error("问题已生成工单,无法修改!");
}
}


//根据ID的数量来判断是否是批量确认和忽略
Question question=new Question(UpdateOrCreateEnum.UPDATE.getCode());
Question question = new Question(UpdateOrCreateEnum.UPDATE.getCode());
question.setStatus(entity.getStatus());
int update;
Integer qId;
if(entity.getId().length>1){
qId= entity.getId()[0];
if (entity.getId().length > 1) {
qId = entity.getId()[0];
//批量
update= questionMapper.update(question, new LambdaUpdateWrapper<Question>().in(Question::getId, Arrays.asList(entity.getId())));
}else{
update = questionMapper.update(question, new LambdaUpdateWrapper<Question>().in(Question::getId, Arrays.asList(entity.getId())));
} else {
//查询巡检问题分类
List<QuestionType> questionTypeList = questionTypeMapper.selectList(new LambdaQueryWrapper<QuestionType>()
.eq(QuestionType::getCode, entity.getType())
.eq(QuestionType::getMark, 1));
if(StringUtils.isNotEmpty(questionTypeList)){
if (StringUtils.isNotEmpty(questionTypeList)) {
question.setQuestionName(questionTypeList.get(0).getContent());
question.setQuestionDesc(questionTypeList.get(0).getContent());
}
//单个
qId= entity.getId()[0];
qId = entity.getId()[0];
question.setId(qId);
question.setType(entity.getType());
update = questionMapper.updateById(question);
}

Integer missionId = questionMapper.selectById(qId).getMissionId();
ThMission thMission=new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
ThMission thMission = new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
thMission.setReportStatus(ReportStatusEnum.UPDATE.getCode());
thMission.setId(missionId);
missionMapper.updateById(thMission);


return JsonResult.success(update>0);
return JsonResult.success(update > 0);
}

@Override
public JsonResult<List<QuestionCountVO>> analyze(Integer missionId) {
List<QuestionCountVO> resultMap= questionMapper.analyze(missionId);
List<QuestionCountVO> resultMap = questionMapper.analyze(missionId, ShiroUtils.getTenantId());
return JsonResult.success(resultMap);
}

@Override
public JsonResult<Map<String, Integer>> analyzeController(Integer missionId) {
List<QuestionCountVO> questionCountVoList= questionMapper.analyze(missionId);
Map<String,Integer> resultMap=new HashMap<>();
List<QuestionCountVO> questionCountVoList = questionMapper.analyze(missionId, ShiroUtils.getTenantId());
Map<String, Integer> resultMap = new HashMap<>();
for (QuestionCountVO questionCountVo : questionCountVoList) {
setInfo(resultMap, questionCountVo,QuestionStatusEnum.CONFIRM.getCode(),QuestionStatusEnum.CONFIRM.name().toLowerCase());
setInfo(resultMap, questionCountVo,QuestionStatusEnum.NEGLECT.getCode(),QuestionStatusEnum.NEGLECT.name().toLowerCase());
setInfo(resultMap, questionCountVo,QuestionStatusEnum.NOTREVIEWED.getCode(),QuestionStatusEnum.NOTREVIEWED.name().toLowerCase());
setInfo(resultMap, questionCountVo, QuestionStatusEnum.CONFIRM.getCode(), QuestionStatusEnum.CONFIRM.name().toLowerCase());
setInfo(resultMap, questionCountVo, QuestionStatusEnum.NEGLECT.getCode(), QuestionStatusEnum.NEGLECT.name().toLowerCase());
setInfo(resultMap, questionCountVo, QuestionStatusEnum.NOTREVIEWED.getCode(), QuestionStatusEnum.NOTREVIEWED.name().toLowerCase());
}
int sum=0;
if(!resultMap.containsKey(QuestionStatusEnum.CONFIRM.name().toLowerCase())){
resultMap.put(QuestionStatusEnum.CONFIRM.name().toLowerCase(),0);
}else{
sum+=resultMap.get(QuestionStatusEnum.CONFIRM.name().toLowerCase());
int sum = 0;
if (!resultMap.containsKey(QuestionStatusEnum.CONFIRM.name().toLowerCase())) {
resultMap.put(QuestionStatusEnum.CONFIRM.name().toLowerCase(), 0);
} else {
sum += resultMap.get(QuestionStatusEnum.CONFIRM.name().toLowerCase());
}

if(!resultMap.containsKey(QuestionStatusEnum.NEGLECT.name().toLowerCase())){
resultMap.put(QuestionStatusEnum.NEGLECT.name().toLowerCase(),0);
}else{
sum+=resultMap.get(QuestionStatusEnum.NEGLECT.name().toLowerCase());
if (!resultMap.containsKey(QuestionStatusEnum.NEGLECT.name().toLowerCase())) {
resultMap.put(QuestionStatusEnum.NEGLECT.name().toLowerCase(), 0);
} else {
sum += resultMap.get(QuestionStatusEnum.NEGLECT.name().toLowerCase());
}
resultMap.remove(QuestionStatusEnum.NEGLECT.name().toLowerCase());
resultMap.put(QuestionStatusEnum.CONFIRM.name().toLowerCase(),sum);
resultMap.put(QuestionStatusEnum.CONFIRM.name().toLowerCase(), sum);

if(!resultMap.containsKey(QuestionStatusEnum.NOTREVIEWED.name().toLowerCase())){
resultMap.put(QuestionStatusEnum.NOTREVIEWED.name().toLowerCase(),0);
if (!resultMap.containsKey(QuestionStatusEnum.NOTREVIEWED.name().toLowerCase())) {
resultMap.put(QuestionStatusEnum.NOTREVIEWED.name().toLowerCase(), 0);
}
return JsonResult.success(resultMap);
}

private static void setInfo(Map<String, Integer> resultMap, QuestionCountVO questionCountVo, Integer code, String name) {
if(questionCountVo.getStatus().equals(code)){
if(resultMap.containsKey(name)){
if (questionCountVo.getStatus().equals(code)) {
if (resultMap.containsKey(name)) {
Integer current = resultMap.get(name);
current=current+questionCountVo.getQuantity();
resultMap.put(name,current);
}else{
current = current + questionCountVo.getQuantity();
resultMap.put(name, current);
} else {
resultMap.put(name, questionCountVo.getQuantity());
}
}
@@ -259,7 +280,8 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio

@Override
public JsonResult<List<QuestionTypeCountVO>> analyzeType(Integer missionId) {
List<QuestionTypeCountVO> questionTypeCountList= questionMapper.analyzeType(missionId, ShiroUtils.getTenantId());
List<QuestionTypeCountVO> questionTypeCountList = questionMapper.analyzeType
(missionId, ShiroUtils.getTenantId());

//id
//name
@@ -268,15 +290,15 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
//content

//添加问题的分类
List<QuestionType> questionTypeList=new ArrayList<>();
List<QuestionType> questionTypeList = new ArrayList<>();
try {
questionTypeList = questionTypeService.getQuestionType();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
Map<String,String> codeMap=new HashMap<>();
Map<String, String> codeMap = new HashMap<>();
for (QuestionType questionType : questionTypeList) {
codeMap.put(questionType.getCode(),questionType.getContent());
codeMap.put(questionType.getCode(), questionType.getContent());
}
for (QuestionTypeCountVO questionTypeCountVO : questionTypeCountList) {
questionTypeCountVO.setContent(codeMap.get(questionTypeCountVO.getType()));
@@ -290,12 +312,12 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
ThMission mission = getThMission(requestId);
Boolean aBoolean = saveQuestion(callbackRequest, mission);
//如果任务已经完成就修改任务状态
ThMission thMissionUpdate=new ThMission(UpdateOrCreateEnum.UPDATE.getCode());
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode());

thMissionUpdate.setProgressbar(callbackRequest.getProgress());
if(aBoolean){
if (aBoolean) {
setComplate(callbackRequest, mission, thMissionUpdate);
}else{
} else {
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission);
}
return JsonResult.success();
@@ -309,21 +331,21 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
}

private void setComplate(CallbackRequest callbackRequest, ThMission mission, ThMission thMissionUpdate) {
if(callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.SUCCESS.getCode() || callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode()){
if (callbackRequest.getAnalyseStatus() == AiAnalyseStatusEnum.SUCCESS.getCode() || callbackRequest.getAnalyseStatus() == AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode()) {
//这边存回放的视频地址
thMissionUpdate.setVideoUrl(callbackRequest.getVideoUrl());
thMissionUpdate.setAiVideoUrl(callbackRequest.getAiVideoUrl());

if(callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode()){
if (callbackRequest.getAnalyseStatus() == AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode()) {
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode());
}else{
} else {
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.SUCCESS.getCode());
}

setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission);
}else if(callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.FAILED.getCode()){
} else if (callbackRequest.getAnalyseStatus() == AiAnalyseStatusEnum.FAILED.getCode()) {
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission);
}else{
} else {
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.RUNNING.getCode());
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FLIGHT, mission);
}
@@ -337,8 +359,8 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
List<Question> questionList = getQuestionList(mission, questionFiles, flightDataList);
//保存问题数据时调用saveWarningData方法保存预警数据入库
Boolean aBoolean = saveWarningData(mission, questionFiles, flightDataList);
log.info("预警表数据入库结束, {}",aBoolean);
if(questionList.size()==0){
log.info("预警表数据入库结束, {}", aBoolean);
if (questionList.size() == 0) {
return true;
}
return saveBatch(questionList);
@@ -352,19 +374,19 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
}

private List<Question> getQuestionList(ThMission mission, List<CallbackRequest.QuestionFilesDTO> questionFiles, List<ThInspection> flightDataList) {
List<Question> questionList=new ArrayList<>();
if(ObjectUtil.isEmpty(questionFiles)){
List<Question> questionList = new ArrayList<>();
if (ObjectUtil.isEmpty(questionFiles)) {
return questionList;
}

List<QuestionType> questionType = questionTypeService.getQuestionType();
Map<String,QuestionType> typeMap=new HashMap<>();
Map<String, QuestionType> typeMap = new HashMap<>();
for (QuestionType type : questionType) {
typeMap.put(type.getCode(),type);
typeMap.put(type.getCode(), type);
}
for (CallbackRequest.QuestionFilesDTO questionFile : questionFiles) {
Question question=new Question(UpdateOrCreateEnum.CREATE.getCode());
BeanUtils.copyProperties(questionFile,question);
Question question = new Question(UpdateOrCreateEnum.CREATE.getCode());
BeanUtils.copyProperties(questionFile, question);
ThInspection flightDataByTime = getFlightDataByTime(flightDataList, questionFile.getAnalyseTime().getTime());
question.setMissionId(mission.getId());
question.setMissionName(mission.getName());
@@ -374,29 +396,29 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
question.setStatus(QuestionStatusEnum.NOTREVIEWED.getCode());
//问题类型
QuestionType questionTypeInfo = typeMap.get(questionFile.getQuestionCode());
question.setType(ObjectUtil.isNotEmpty(questionTypeInfo)? questionTypeInfo.getCode():"");
question.setQuestionName(ObjectUtil.isNotEmpty(questionTypeInfo)? questionTypeInfo.getContent():"");
question.setQuestionDesc(ObjectUtil.isNotEmpty(questionTypeInfo)? questionTypeInfo.getDescription():"");
question.setType(ObjectUtil.isNotEmpty(questionTypeInfo) ? questionTypeInfo.getCode() : "");
question.setQuestionName(ObjectUtil.isNotEmpty(questionTypeInfo) ? questionTypeInfo.getContent() : "");
question.setQuestionDesc(ObjectUtil.isNotEmpty(questionTypeInfo) ? questionTypeInfo.getDescription() : "");
questionList.add(question);
}
return questionList;
}

//根据获取的问题列表问题类型code为002004,添加数据入库到预警表
private Boolean saveWarningData(ThMission mission, List<CallbackRequest.QuestionFilesDTO> questionFiles, List<ThInspection> flightDataList){
log.info("预警表数据入库开始...");
private Boolean saveWarningData(ThMission mission, List<CallbackRequest.QuestionFilesDTO> questionFiles, List<ThInspection> flightDataList) {
log.info("预警表数据入库开始...");
List<Warning> warningList = new ArrayList<>();
List<QuestionType> questionType = questionTypeService.getQuestionType();
Map<String,QuestionType> typeMap=new HashMap<>();
Map<String, QuestionType> typeMap = new HashMap<>();
for (QuestionType type : questionType) {
typeMap.put(type.getCode(),type);
typeMap.put(type.getCode(), type);
}
//调用添加问题列表接口
List<Question> questionList = this.getQuestionList(mission, questionFiles, flightDataList);
for (Question question : questionList) {
Warning warning = new Warning();
//问题类型为火灾隐患时添加数据
if(question.getType().equals(QuestionTypeEnum.Q4.getCode())){
if (question.getType().equals(QuestionTypeEnum.Q4.getCode())) {
warning.setTenantId(question.getTenantId());
warning.setDiscoveryWay(DiscoveryWayEnum.UAV_PATROL.getCode());
warning.setLocation("");
@@ -412,13 +434,15 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
}

private ThMission getThMission(String requestId) {
LambdaQueryWrapper<ThMission> lambdaQueryWrapper=new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode())
.eq(ThMission::getRequestId, requestId)
.eq(ThMission::getStatus,TaskStatusEnum.FLIGHT.getCode()).orderByDesc(ThMission::getExecutionStartTime);
LambdaQueryWrapper<ThMission> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper
.eq(ThMission::getTenantId, ShiroUtils.getTenantId())//xz
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode())
.eq(ThMission::getRequestId, requestId)
.eq(ThMission::getStatus, TaskStatusEnum.FLIGHT.getCode()).orderByDesc(ThMission::getExecutionStartTime);
List<ThMission> thMissions = missionMapper.selectList(lambdaQueryWrapper);
if(ObjectUtil.isEmpty(thMissions) || thMissions.size()==0){
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"正在执行的任务不存在!");
if (ObjectUtil.isEmpty(thMissions) || thMissions.size() == 0) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "正在执行的任务不存在!");
}
return thMissions.get(0);
}
@@ -435,9 +459,9 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
if (CollectionUtils.isEmpty(inspectionList)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!");
}
List<ThInspection> inspectionData =new ArrayList<>();
List<ThInspection> inspectionData = new ArrayList<>();
for (ThInspection thInspection : inspectionList) {
if(thInspection.getUpdateTime().getTime() <= time){
if (thInspection.getUpdateTime().getTime() <= time) {
inspectionData.add(thInspection);
}
}

+ 15
- 5
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java Datei anzeigen

@@ -3,6 +3,7 @@ package com.tuoheng.admin.service.impl;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lowagie.text.*;
@@ -28,6 +29,7 @@ import com.tuoheng.common.utils.DateUtils;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.StringUtils;
import com.tuoheng.system.service.impl.UserServiceImpl;
import com.tuoheng.system.utils.ShiroUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -81,7 +83,9 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
Assert.notNull(missionId,"任务ID为空");
String reportNo = createReportNo();
//查询巡检信息
ThMission mission = missionMapper.selectById(missionId);
LambdaQueryWrapper<ThMission> queryWrapper = new LambdaQueryWrapper<>();//xz
queryWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId()).eq(ThMission::getId, missionId);//xz
ThMission mission = missionMapper.selectOne(queryWrapper);//xz
Assert.notNull(mission,"任务不能为空!");

//如果报告已经生成,就修改,如果未生成就创建
@@ -90,7 +94,8 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
Report report = setInfo(missionId, reportNo, mission);
reportMapper.insert(report);
}else if(mission.getReportStatus() == ReportStatusEnum.UPDATE.getCode()){
Report update = reportMapper.selectOne(new LambdaQueryWrapper<Report>().eq(Report::getMissionId, missionId));
Report update = reportMapper.selectOne(new LambdaQueryWrapper<Report>().eq(Report::getMissionId, missionId).
eq(Report::getTenantId, ShiroUtils.getTenantId()));//xz

if(ObjectUtil.isEmpty(update)){
//生成报告
@@ -113,6 +118,7 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp

private Report setInfo(Integer missionId, String reportNo, ThMission mission) {
Report report = new Report(UpdateOrCreateEnum.CREATE.getCode());
report.setTenantId(ShiroUtils.getTenantId());//xz
report.setReportNo(reportNo);
report.setMissionId(missionId);
report.setMissionName(mission.getName());
@@ -135,12 +141,12 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
// 获取分页数据
IPage<Report> page = new Page<>(request.getPage(), request.getLimit());
IPage<Report> pageData = reportMapper.selectPage(page, new LambdaQueryWrapper<Report>()
.eq(Report::getTenantId, ShiroUtils.getTenantId())//xz
.like(StringUtils.isNotEmpty(request.getReportNo()), Report::getReportNo, request.getReportNo())
.like(StringUtils.isNotEmpty(request.getName()), Report::getMissionName, request.getName())
.eq(StringUtils.isNotEmpty(request.getAirportId()), Report::getAirportId, request.getAirportId())
.eq(ObjectUtil.isNotEmpty(request.getType()), Report::getType, request.getType())
.eq(Report::getMark, MarkTypeEnum.VALID.getCode())
//.eq(Report::getTenantId, ShiroUtils.getTenantId())
.orderByDesc(Report::getCreateTime));
return JsonResult.success(pageData);
}
@@ -149,7 +155,9 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
public ReportInfoVO detail(Integer reportId) {
ReportInfoVO reportInfoVO = new ReportInfoVO();
//查询报告
Report report = reportMapper.selectById(reportId);
LambdaQueryWrapper<Report> queryWrapper = new LambdaQueryWrapper<>();//xz
queryWrapper.eq(Report::getTenantId,ShiroUtils.getTenantId()).eq(Report::getId, reportId);//xz
Report report = reportMapper.selectOne(queryWrapper);//xz
Integer missionId = report.getMissionId();
reportInfoVO.setReportNo(report.getReportNo());
reportInfoVO.setMissionId(missionId);
@@ -174,7 +182,9 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
// }

private void setMission(ReportInfoVO reportInfoVO, Integer missionId) {
ThMission thMission = missionMapper.selectById(missionId);
LambdaQueryWrapper<ThMission> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ThMission::getTenantId, ShiroUtils.getTenantId()).eq(ThMission::getId, missionId);
ThMission thMission = missionMapper.selectOne(lambdaQueryWrapper);
if(ObjectUtil.isEmpty(thMission)){
thMission=new ThMission(UpdateOrCreateEnum.CREATE.getCode());
}

+ 12
- 7
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java Datei anzeigen

@@ -70,8 +70,12 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,
public List<InspectionVO> track(Integer id) {

LambdaQueryWrapper<ThInspection> lambdaQueryWrapper=new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ThInspection::getMissionId,id).orderByAsc(ThInspection::getCreateTime);
//lambdaQueryWrapper.eq(ThInspection::getTenantId, ShiroUtils.getTenantId());
User user = ShiroUtils.getUserInfo();//xz
Integer tenantId = user.getTenantId();//xz

lambdaQueryWrapper.eq(ThInspection::getTenantId, tenantId)
.eq(ThInspection::getMissionId,id)
.orderByAsc(ThInspection::getCreateTime);//xz
List<InspectionVO> result=new ArrayList<>();
List<ThInspection> thInspections = inspectionMapper.selectList(lambdaQueryWrapper);

@@ -90,15 +94,16 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,
BeanUtils.copyProperties(inspectionRequest,inspection);
//获取当前巡检正在执行的任务
List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>()
.eq(ThMission::getInspectionLine, inspectionRequest.getInspectionId())
.eq(ThMission::getStatus, TaskStatusEnum.FLIGHT.getCode())
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()).orderByAsc(ThMission::getExecutionStartTime));
.eq(ThMission::getTenantId, ShiroUtils.getTenantId())//xz
.eq(ThMission::getInspectionLine, inspectionRequest.getInspectionId())
.eq(ThMission::getStatus, TaskStatusEnum.FLIGHT.getCode())
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()).orderByAsc(ThMission::getExecutionStartTime));
if(ObjectUtil.isEmpty(thMissions) || thMissions.size()==0){
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"没有正在飞行的任务!");
}
ThMission mission = thMissions.get(0);
inspection.setMissionId(mission.getId());
inspection.setTenantId(mission.getTenantId());
inspection.setTenantId(mission.getTenantId());//xz
inspectionMapper.insert(inspection);
return inspection.getId();
}
@@ -231,7 +236,7 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//根据任务id查询对应的遥测数据
List<ThInspection> listData = inspectionMapper.selectListByMissionId(id);
List<ThInspection> listData = inspectionMapper.selectListByMissionId(id, ShiroUtils.getTenantId());//xz

return JsonResult.success(listData);
}

+ 18
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/WorkOrderServiceImpl.java Datei anzeigen

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

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.common.ServiceExceptionEnum;
@@ -77,6 +78,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
// 获取分页数据
IPage<WorkOrder> page = new Page<>(request.getPage(), request.getLimit());
IPage<WorkOrder> pageData = workOrderMapper.selectPage(page, new LambdaQueryWrapper<WorkOrder>()
.eq(WorkOrder::getTenantId, ShiroUtils.getTenantId())//xz
.like(StringUtils.isNotEmpty(request.getCode()), WorkOrder::getCode, request.getCode())
.eq(ObjectUtil.isNotEmpty(request.getStatus()), WorkOrder::getStatus, request.getStatus())
.between(ObjectUtil.isNotNull(startDate),WorkOrder::getCreateTime, startDate, endDate)
@@ -88,11 +90,13 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO

//查询问题总数
Integer questionTotal = workOrderQuestionMapper.selectCount(new LambdaQueryWrapper<WorkOrderQuestion>()
.eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.eq(WorkOrderQuestion::getWorkOrderId, vo.getId()));
vo.setQuestionTotal(questionTotal);

//查询未处理问题数
Integer unhandledTotal = workOrderQuestionMapper.selectCount(new LambdaQueryWrapper<WorkOrderQuestion>()
.eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.eq(WorkOrderQuestion::getWorkOrderId, vo.getId())
.eq(WorkOrderQuestion::getStatus, 0));
vo.setUnhandledTotal(unhandledTotal);
@@ -117,6 +121,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
public JsonResult generate(Integer[] ids) {
//校验,已生成工单的问题,无法生成工单
Integer count = workOrderQuestionMapper.selectCount(new LambdaQueryWrapper<WorkOrderQuestion>()
.eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.in(WorkOrderQuestion::getQuestionId, ids));
if(count > 0){
return JsonResult.error("有问题已生成工单");
@@ -126,6 +131,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO

WorkOrder workOrder = new WorkOrder();
workOrder.setCode(code);
workOrder.setTenantId(ShiroUtils.getTenantId());//xz
workOrderMapper.insert(workOrder);

for (Integer id : ids) {
@@ -133,6 +139,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
WorkOrderQuestion workOrderQuestion = new WorkOrderQuestion();
workOrderQuestion.setWorkOrderId(workOrder.getId());
workOrderQuestion.setQuestionId(id);
workOrderQuestion.setTenantId(ShiroUtils.getTenantId());//xz
workOrderQuestionMapper.insert(workOrderQuestion);
}
return JsonResult.success();
@@ -154,6 +161,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
public JsonResult handle(WorkOrderHandleRequest request) {
//校验,已处理的问题,无法再处理
Integer handleCount = workOrderQuestionMapper.selectCount(new LambdaQueryWrapper<WorkOrderQuestion>()
.eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.eq(WorkOrderQuestion::getQuestionId, request.getQuestionId())
.eq(WorkOrderQuestion::getStatus, 1)
.eq(WorkOrderQuestion::getMark, MarkTypeEnum.VALID.getCode()));
@@ -166,6 +174,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
BeanUtils.copyProperties(request, workOrderQuestion);
workOrderQuestion.setStatus(1);
workOrderQuestionMapper.update(workOrderQuestion, new LambdaQueryWrapper<WorkOrderQuestion>()
// .eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.eq(WorkOrderQuestion::getWorkOrderId, request.getWorkOrderId())
.eq(WorkOrderQuestion::getQuestionId, request.getQuestionId()));

@@ -174,10 +183,12 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
BeanUtils.copyProperties(request, questionHandle);
questionHandle.setHandlerUser(ShiroUtils.getUserId());
questionHandle.setHandlerTime(new Date());
questionHandle.setTenantId(ShiroUtils.getTenantId());//xz
questionHandleMapper.insert(questionHandle);

//查询工单下待处理的问题,如全部处理完,将工单状态修改为已完成
Integer count = workOrderQuestionMapper.selectCount(new LambdaQueryWrapper<WorkOrderQuestion>()
.eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.eq(WorkOrderQuestion::getWorkOrderId, request.getWorkOrderId())
.eq(WorkOrderQuestion::getStatus, 0));
if(count == 0){
@@ -196,7 +207,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
// 设置分页参数
IPage<WorkOrderQuestionVO> page = new Page<>(request.getPage(), request.getLimit());
// 查询结果
IPage<WorkOrderQuestionVO> pageInfo = workOrderMapper.questionPage(page, request);
int tenantId = ShiroUtils.getTenantId();
IPage<WorkOrderQuestionVO> pageInfo = workOrderMapper.questionPage(page, request, tenantId);
for (WorkOrderQuestionVO record : pageInfo.getRecords()) {
if(StringUtils.isNotEmpty(record.getHandlerImage())){
String[] imgHanders = record.getHandlerImage().split(",");
@@ -214,11 +226,14 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
public JsonResult questionDetail(Integer questionId) {
QuestionDetailVO questionDetailVO = new QuestionDetailVO();
//查询问题详情
Question question = questionMapper.selectById(questionId);
QueryWrapper<Question> queryWrapper = new QueryWrapper<>();//xz
queryWrapper.lambda().eq(Question::getTenantId, ShiroUtils.getTenantId()).eq(Question::getId, questionId);//xz
Question question = questionMapper.selectOne(queryWrapper);//xz
questionDetailVO.setQuestion(question);

//查询问题处理详情
QuestionHandle questionHandle = questionHandleMapper.selectOne(new LambdaQueryWrapper<QuestionHandle>()
.eq(QuestionHandle::getTenantId, ShiroUtils.getTenantId())//xz
.eq(QuestionHandle::getQuestionId, questionId)
.eq(QuestionHandle::getMark, MarkTypeEnum.VALID.getCode()));
//拼接图片域名
@@ -239,6 +254,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO

//查询问题处理状态
WorkOrderQuestion workOrderQuestion = workOrderQuestionMapper.selectOne(new LambdaQueryWrapper<WorkOrderQuestion>()
.eq(WorkOrderQuestion::getTenantId, ShiroUtils.getTenantId())//xz
.eq(WorkOrderQuestion::getQuestionId, questionId));
questionDetailVO.setQuestionHandle(questionHandle);
questionHandle.setStatus(workOrderQuestion.getStatus());

+ 5
- 4
tuoheng-admin/src/main/resources/mapper/QuestionMapper.xml Datei anzeigen

@@ -4,19 +4,19 @@
<select id="analyze" resultType="com.tuoheng.admin.entity.vo.QuestionCountVO">
select q.status,count(q.id) as quantity
from th_question q
where q.mission_id=#{missionId}
where q.mission_id=#{missionId} and tenant_id = #{tenantId}
group by q.status;
</select>

<select id="analyzeType" resultType="com.tuoheng.admin.entity.vo.QuestionTypeCountVO">
select q.type,count(q.id) as quantity
from th_question q
where q.mission_id=#{missionId} and q.status=1
where q.mission_id=#{missionId} and tenant_id = ${tenantId} and q.status=1
group by q.type;
</select>

<select id="getIndexQuestion" parameterType="com.tuoheng.admin.entity.request.index.GetQuestionListDto" resultType="com.tuoheng.admin.entity.dto.index.QuestionListDto">
select a.create_time,a.id as questionId, a.mission_id as missionId, a.type, b.content as typeName,
select a.create_time,a.id as questionId, a.tenant_id as tenantId, a.mission_id as missionId, a.type, b.content as typeName,
a.mission_name as missionName, c.execution_start_time as inspectionTime,
a.file_marker_url as fileMarkerUrl, d.handler_result as handlerResult,
d.handler_image as handlerImage, d.handler_user as handlerUserId, e.realname as handlerUserName,
@@ -26,7 +26,8 @@
inner join th_mission c on c.id = a.mission_id and c.mark = 1
left join th_question_handle d on d.question_id = a.id
left join sys_user e on e.id = d.handler_user
where a.mark = 1 and a.status = 1 and a.create_time BETWEEN #{startTime} AND #{endTime}
where a.tenant_id = #{tenantId}
and a.mark = 1 and a.status = 1 and a.create_time BETWEEN #{startTime} AND #{endTime}
order by a.create_time desc limit 200
</select>


+ 1
- 1
tuoheng-admin/src/main/resources/mapper/ThInspectionMapper.xml Datei anzeigen

@@ -31,7 +31,7 @@
select
<include refid="Base_Column_List"/>
from th_inspection
where mission_id = #{id}
where mission_id = #{id} and tenant_id = #{tenantId}
and mark = 1
order by create_time asc
</select>

+ 2
- 1
tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml Datei anzeigen

@@ -25,7 +25,8 @@
LEFT JOIN th_question_handle qh on q.id = qh.question_id
LEFT JOIN sys_user u on qh.handler_user = u.id
WHERE
wo.mark = 1
wo.tenant_id = #{tenantId}
AND wo.mark = 1
AND wo.id = #{request.workOrderId}
<if test="request.questionType != '' and request.questionType != null">
AND q.type = #{request.questionType}

+ 4
- 0
tuoheng-common/pom.xml Datei anzeigen

@@ -179,6 +179,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>com.tuoheng</groupId>
<artifactId>tuoheng-system</artifactId>
</dependency>
</dependencies>

</project>

+ 1
- 0
tuoheng-common/src/main/java/com/tuoheng/common/common/BaseServiceImpl.java Datei anzeigen

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.common.utils.DateUtils;
import com.tuoheng.common.utils.JsonResult;
import org.springframework.util.StringUtils;
import com.tuoheng.system.utils.ShiroUtils;

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

Laden…
Abbrechen
Speichern