|
|
@@ -6,18 +6,30 @@ 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.WorkOrder; |
|
|
|
import com.tuoheng.admin.entity.domain.WorkOrderQuestion; |
|
|
|
import com.tuoheng.admin.entity.request.WorkOrderRequest; |
|
|
|
import com.tuoheng.admin.entity.vo.WorkOrderInfoVO; |
|
|
|
import com.tuoheng.admin.enums.MarkTypeEnum; |
|
|
|
import com.tuoheng.admin.mapper.WorkOrderMapper; |
|
|
|
import com.tuoheng.admin.mapper.WorkOrderQuestionMapper; |
|
|
|
import com.tuoheng.admin.service.IWorkOrderService; |
|
|
|
import com.tuoheng.common.common.BaseServiceImpl; |
|
|
|
import com.tuoheng.common.exception.ServiceException; |
|
|
|
import com.tuoheng.common.utils.DateUtils; |
|
|
|
import com.tuoheng.common.utils.JsonResult; |
|
|
|
import com.tuoheng.common.utils.StringUtils; |
|
|
|
import com.tuoheng.system.entity.User; |
|
|
|
import com.tuoheng.system.mapper.UserMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkOrder> implements IWorkOrderService { |
|
|
@@ -25,18 +37,59 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
@Autowired |
|
|
|
private WorkOrderMapper workOrderMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WorkOrderQuestionMapper workOrderQuestionMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public JsonResult queryPage(WorkOrderRequest request) { |
|
|
|
if(null == request.getPage() || null == request.getLimit()){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
Date startDate = null; |
|
|
|
Date endDate = null; |
|
|
|
if(StringUtils.isNotEmpty(request.getCreateStartTime()) && StringUtils.isNotEmpty(request.getCreateEndTime())){ |
|
|
|
String startTime = request.getCreateStartTime() + "00:00:00"; |
|
|
|
String endTime = request.getCreateEndTime() + "23:59:59"; |
|
|
|
startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD, startTime); |
|
|
|
endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD, endTime); |
|
|
|
} |
|
|
|
// 获取分页数据 |
|
|
|
IPage<WorkOrder> page = new Page<>(request.getPage(), request.getLimit()); |
|
|
|
IPage<WorkOrder> pageData = workOrderMapper.selectPage(page, new LambdaQueryWrapper<WorkOrder>() |
|
|
|
.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) |
|
|
|
.eq(WorkOrder::getMark, MarkTypeEnum.VALID.getCode()) |
|
|
|
.orderByDesc(WorkOrder::getCreateTime)); |
|
|
|
|
|
|
|
pageData.getRecords().stream().map(x ->{ |
|
|
|
WorkOrderInfoVO vo = new WorkOrderInfoVO(); |
|
|
|
BeanUtils.copyProperties(x, vo); |
|
|
|
|
|
|
|
//查询问题总数 |
|
|
|
Integer questionTotal = workOrderQuestionMapper.selectCount(new LambdaQueryWrapper<WorkOrderQuestion>() |
|
|
|
.eq(WorkOrderQuestion::getWorkOrderId, x.getId())); |
|
|
|
vo.setQuestionTotal(questionTotal); |
|
|
|
|
|
|
|
//查询未处理问题数 |
|
|
|
Integer unhandledTotal = workOrderQuestionMapper.selectCount(new LambdaQueryWrapper<WorkOrderQuestion>() |
|
|
|
.eq(WorkOrderQuestion::getWorkOrderId, x.getId()) |
|
|
|
.eq(WorkOrderQuestion::getStatus, 0)); |
|
|
|
vo.setUnhandledTotal(unhandledTotal); |
|
|
|
|
|
|
|
//处理人员名称 |
|
|
|
List<String> assignUser = Arrays.asList(x.getAssignUser().split(",")); |
|
|
|
List<Integer> assignUserInteger = assignUser.stream().map(Integer::parseInt).collect(Collectors.toList()); |
|
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().in(User::getId, assignUserInteger)); |
|
|
|
List<String> assignUserNameList = userList.stream().map(User::getRealname).collect(Collectors.toList()); |
|
|
|
vo.setAssignUserName(String.join(",",assignUserNameList)); |
|
|
|
|
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return JsonResult.success(pageData); |
|
|
|
|
|
|
|
} |