|
|
@@ -6,20 +6,17 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.tuoheng.admin.common.ServiceExceptionEnum; |
|
|
|
import com.tuoheng.admin.entity.domain.Question; |
|
|
|
import com.tuoheng.admin.entity.domain.QuestionType; |
|
|
|
import com.tuoheng.admin.entity.domain.ThInspection; |
|
|
|
import com.tuoheng.admin.entity.domain.ThMission; |
|
|
|
import com.tuoheng.admin.entity.domain.*; |
|
|
|
import com.tuoheng.admin.entity.request.*; |
|
|
|
import com.tuoheng.admin.entity.vo.MissionVO; |
|
|
|
import com.tuoheng.admin.entity.vo.QuestionCountVO; |
|
|
|
import com.tuoheng.admin.entity.vo.QuestionTypeCountVO; |
|
|
|
import com.tuoheng.admin.entity.vo.QuestionVO; |
|
|
|
import com.tuoheng.admin.enums.*; |
|
|
|
import com.tuoheng.admin.mapper.QuestionMapper; |
|
|
|
import com.tuoheng.admin.mapper.QuestionTypeMapper; |
|
|
|
import com.tuoheng.admin.mapper.ThInspectionMapper; |
|
|
|
import com.tuoheng.admin.mapper.ThMissionMapper; |
|
|
|
import com.tuoheng.admin.mapper.*; |
|
|
|
import com.tuoheng.admin.service.IQuestionService; |
|
|
|
import com.tuoheng.admin.service.IQuestionTypeService; |
|
|
|
import com.tuoheng.admin.utils.TimeUtil; |
|
|
|
import com.tuoheng.common.common.BaseServiceImpl; |
|
|
|
import com.tuoheng.common.exception.ServiceException; |
|
|
|
import com.tuoheng.common.utils.JsonResult; |
|
|
@@ -29,8 +26,10 @@ import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
@@ -55,39 +54,61 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
@Autowired |
|
|
|
private ThInspectionMapper inspectionMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WorkOrderQuestionMapper workOrderQuestionMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IQuestionTypeService questionTypeService; |
|
|
|
|
|
|
|
private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
@Override |
|
|
|
public IPage<Question> queryPage(QuestionQuery query) { |
|
|
|
@Transactional(readOnly = true) |
|
|
|
public IPage<QuestionVO> queryPage(QuestionQuery query) throws ParseException { |
|
|
|
if(null == query.getPage() || null == query.getLimit()){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
IPage<Question> pageData=null; |
|
|
|
try { |
|
|
|
// 获取分页数据 |
|
|
|
IPage<Question> page = new Page<>(query.getPage(), query.getLimit()); |
|
|
|
|
|
|
|
LambdaQueryWrapper<Question> questionLambdaQueryWrapper = new LambdaQueryWrapper<Question>() |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getMissionId()), Question::getMissionId, query.getMissionId()) |
|
|
|
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getStatus()), Question::getStatus, query.getStatus()) |
|
|
|
//.eq(Question::getTenantId, ShiroUtils.getTenantId()) |
|
|
|
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime); |
|
|
|
if(ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())){ |
|
|
|
query.setStartTime(query.getStartTime()+" 00:00:00"); |
|
|
|
query.setEndTime(query.getEndTime()+" 23:59:59"); |
|
|
|
questionLambdaQueryWrapper.between(Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime())); |
|
|
|
} |
|
|
|
pageData = questionMapper.selectPage(page, questionLambdaQueryWrapper); |
|
|
|
}catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("查询出错!"); |
|
|
|
// 获取分页数据 |
|
|
|
IPage<Question> page = new Page<>(query.getPage(), query.getLimit()); |
|
|
|
|
|
|
|
LambdaQueryWrapper<Question> questionLambdaQueryWrapper = new LambdaQueryWrapper<Question>() |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getMissionId()), Question::getMissionId, query.getMissionId()) |
|
|
|
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getStatus()), Question::getStatus, query.getStatus()) |
|
|
|
//.eq(Question::getTenantId, ShiroUtils.getTenantId()) |
|
|
|
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime); |
|
|
|
if(ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())){ |
|
|
|
query.setStartTime(query.getStartTime()+" 00:00:00"); |
|
|
|
query.setEndTime(query.getEndTime()+" 23:59:59"); |
|
|
|
questionLambdaQueryWrapper.between(Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime())); |
|
|
|
} |
|
|
|
return pageData; |
|
|
|
IPage<Question> pageData = questionMapper.selectPage(page, questionLambdaQueryWrapper); |
|
|
|
List<Question> questions = pageData.getRecords(); |
|
|
|
List<QuestionVO> questionVOList = new ArrayList<>(); |
|
|
|
questions.forEach(question->{ |
|
|
|
QuestionVO questionVO = new QuestionVO(); |
|
|
|
BeanUtils.copyProperties(question,questionVO); |
|
|
|
LambdaQueryWrapper<WorkOrderQuestion> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
lambdaQueryWrapper.eq(WorkOrderQuestion::getQuestionId, question.getId()); |
|
|
|
WorkOrderQuestion workOrderQuestion = workOrderQuestionMapper.selectOne(lambdaQueryWrapper); |
|
|
|
if(workOrderQuestion != null){ |
|
|
|
questionVO.setWordOrderStatus(1); |
|
|
|
questionVO.setHandleStatus(workOrderQuestion.getStatus()); |
|
|
|
}else { |
|
|
|
questionVO.setWordOrderStatus(0); |
|
|
|
questionVO.setHandleStatus(0); |
|
|
|
} |
|
|
|
questionVOList.add(questionVO); |
|
|
|
}); |
|
|
|
IPage<QuestionVO> resultPage=new Page<>(); |
|
|
|
resultPage.setCurrent(pageData.getCurrent()); |
|
|
|
resultPage.setPages(pageData.getPages()); |
|
|
|
resultPage.setSize(pageData.getSize()); |
|
|
|
resultPage.setTotal(pageData.getTotal()); |
|
|
|
resultPage.setRecords(questionVOList); |
|
|
|
return resultPage; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@@ -373,4 +394,5 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
} |
|
|
|
return inspectionData.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
} |