|
@@ -1,6 +1,10 @@
|
|
|
package com.example.xiaoshiweixinback.service;
|
|
|
|
|
|
+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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
|
import com.example.xiaoshiweixinback.business.utils.BatchNoUtil;
|
|
|
import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
@@ -11,12 +15,16 @@ import com.example.xiaoshiweixinback.entity.dto.ticket.TicketPriceUpDTO;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.ticket.TicketProcessUpDTO;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.ticket.TicketQueryDTO;
|
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
|
+import com.example.xiaoshiweixinback.entity.vo.TicketVO;
|
|
|
import com.example.xiaoshiweixinback.mapper.TicketMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author admin
|
|
|
* @description 针对表【ticket(工单)】的数据库操作Service实现
|
|
@@ -48,21 +56,55 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Integer queryTickets(TicketAddDTO ticketAddDTO) {
|
|
|
- Ticket ticket = new Ticket();
|
|
|
- BeanUtils.copyProperties(ticketAddDTO, ticket);
|
|
|
- if (ticket.getId() == null) {
|
|
|
+ public Records queryTickets(TicketQueryDTO ticketQueryDTO) {
|
|
|
+ String name = ticketQueryDTO.getName();
|
|
|
+ Integer ticketType = ticketQueryDTO.getTicketType();
|
|
|
+ Boolean isAdmin = ticketQueryDTO.getIsAdmin();
|
|
|
+ Integer pageNum = ticketQueryDTO.getCurrent();
|
|
|
+ Integer pageSize = ticketQueryDTO.getSize();
|
|
|
+ Page<Ticket> page = new Page<>(pageNum, pageSize);
|
|
|
+ QueryWrapper<Ticket> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (name != null && !name.equals("")) {
|
|
|
+ queryWrapper.lambda().like(Ticket::getName, name);
|
|
|
+ }
|
|
|
+ if (ticketType != null) {
|
|
|
+ queryWrapper.lambda().eq(Ticket::getTicketType, ticketType);
|
|
|
+ }
|
|
|
+ if (!isAdmin.equals(true)) {
|
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
|
|
|
- ticket.setCreateId(personnelVO.getUuid());
|
|
|
+ Integer personType = personnelVO.getPersonType();
|
|
|
+ if (personType != null && personType.equals(0)) {
|
|
|
+ queryWrapper.lambda().eq(Ticket::getCreateId, personnelVO.getUuid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryWrapper.orderBy(true, false, "create_time");
|
|
|
+ IPage<Ticket> ticketPage = this.page(page, queryWrapper);
|
|
|
+ List<Ticket> tickets = ticketPage.getRecords();
|
|
|
+ List<TicketVO> ticketVOS = this.loadTicketVO(tickets);
|
|
|
+ Records records = new Records();
|
|
|
+ records.setData(ticketVOS);
|
|
|
+ records.setCurrent((long)pageNum);
|
|
|
+ records.setSize((long)pageSize);
|
|
|
+ records.setTotal(ticketPage.getTotal());
|
|
|
+ return records;
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- Ticket oldTicket = this.getById(ticket.getId());
|
|
|
- ticket.setCreateId(oldTicket.getCreateId());
|
|
|
- ticket.setTicketType(oldTicket.getTicketType());
|
|
|
- ticket.setTicketProgress(oldTicket.getTicketProgress());
|
|
|
+ public List<TicketVO> loadTicketVO(List<Ticket> tickets){
|
|
|
+ List<TicketVO> ticketVOS = new ArrayList<>();
|
|
|
+ if (!tickets.isEmpty()) {
|
|
|
+ List<String> createIds = new ArrayList<>();
|
|
|
+ tickets.forEach(item -> {
|
|
|
+ if (item.getCreateId() != null) {
|
|
|
+ createIds.add(item.getCreateId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ for (Ticket ticket : tickets) {
|
|
|
+ TicketVO ticketVO = new TicketVO();
|
|
|
+ BeanUtils.copyProperties(ticket, ticketVO);
|
|
|
+ ticketVOS.add(ticketVO);
|
|
|
+ }
|
|
|
}
|
|
|
- ticket.insertOrUpdate();
|
|
|
- return ticket.getId();
|
|
|
+ return ticketVOS;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -108,22 +150,6 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
|
|
|
return ticket.getId();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询我的工单
|
|
|
- *
|
|
|
- * @param ticketQueryDTO
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public Integer queryTickets(TicketQueryDTO ticketQueryDTO) {
|
|
|
- PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
|
|
|
- Integer personType = personnelVO.getPersonType();
|
|
|
- if (personType != null && personType.equals(0)) {
|
|
|
-
|
|
|
- }
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
private Boolean ifHavePermission(String id) {
|
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
|
|
|
personnelVO.getPersonType();
|