Selaa lähdekoodia

获取工单列表(分页)

tags/v1.1.0^2
wanghaoran 1 vuosi sitten
vanhempi
commit
8c2ae2f2b9
4 muutettua tiedostoa jossa 137 lisäystä ja 5 poistoa
  1. +7
    -5
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrder.java
  2. +10
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrderQuestion.java
  3. +67
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/WorkOrderInfoVO.java
  4. +53
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/WorkOrderServiceImpl.java

+ 7
- 5
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrder.java Näytä tiedosto

@@ -25,11 +25,6 @@ public class WorkOrder extends BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 分配人员
*/
private Integer distributionId;

/**
* 问题工单号
*/
@@ -57,4 +52,11 @@ public class WorkOrder extends BaseEntity implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date assignTime;

/**
* 完成时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date finishTime;

}

+ 10
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/WorkOrderQuestion.java Näytä tiedosto

@@ -32,4 +32,14 @@ public class WorkOrderQuestion extends BaseEntity implements Serializable {
*/
private Integer questionId;

/**
* 处理状态:0待处理 1已处理
*/
private Integer status;

/**
* 处理人员
*/
private Integer handleUser;

}

+ 67
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/WorkOrderInfoVO.java Näytä tiedosto

@@ -0,0 +1,67 @@
package com.tuoheng.admin.entity.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
public class WorkOrderInfoVO {

/**
* 问题工单号
*/
private String code;

/**
* 工单状态:5待分配 10处理中(已分配) 15已完成
*/
private Integer status;

/**
* 指派负责人,多个用,隔开
*/
private String assignUser;

/**
* 指派备注
*/
private String assignNote;

/**
* 指派时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date assignTime;

/**
* 完成时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date finishTime;

/**
* 问题总数
*/
private Integer questionTotal;

/**
* 未处理问题数
*/
private Integer unhandledTotal;

/**
* 指派负责人名称
*/
private String assignUserName;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

+ 53
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/WorkOrderServiceImpl.java Näytä tiedosto

@@ -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);

}

Loading…
Peruuta
Tallenna