|
@@ -1,11 +1,15 @@
|
|
|
package com.example.xiaoshiweixinback.service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.BatchNoUtil;
|
|
|
import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
|
import com.example.xiaoshiweixinback.domain.Person;
|
|
|
import com.example.xiaoshiweixinback.domain.Ticket;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.ticket.TicketAddDTO;
|
|
|
+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.mapper.TicketMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -27,14 +31,108 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer addorUpdateTicket(TicketAddDTO ticketAddDTO) {
|
|
|
Ticket ticket = new Ticket();
|
|
|
+ if (ticketAddDTO.getId() == null) {
|
|
|
+ BeanUtils.copyProperties(ticketAddDTO, ticket);
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
|
|
|
+ ticket.setCreateId(personnelVO.getUuid());
|
|
|
+ ticket.setTicketProgress(0);
|
|
|
+ String num = BatchNoUtil.getBatchNo();
|
|
|
+ ticket.setNum(num);
|
|
|
+ } else {
|
|
|
+ ticket = this.getById(ticket.getId());
|
|
|
+ ticket.setName(ticketAddDTO.getName());
|
|
|
+ ticket.setContentText(ticketAddDTO.getContentText());
|
|
|
+ }
|
|
|
+ ticket.insertOrUpdate();
|
|
|
+ return ticket.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Integer queryTickets(TicketAddDTO ticketAddDTO) {
|
|
|
+ Ticket ticket = new Ticket();
|
|
|
BeanUtils.copyProperties(ticketAddDTO, ticket);
|
|
|
if (ticket.getId() == null) {
|
|
|
- PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
|
|
|
ticket.setCreateId(personnelVO.getUuid());
|
|
|
|
|
|
+ } else {
|
|
|
+ Ticket oldTicket = this.getById(ticket.getId());
|
|
|
+ ticket.setCreateId(oldTicket.getCreateId());
|
|
|
+ ticket.setTicketType(oldTicket.getTicketType());
|
|
|
+ ticket.setTicketProgress(oldTicket.getTicketProgress());
|
|
|
+ }
|
|
|
+ ticket.insertOrUpdate();
|
|
|
+ return ticket.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新工单状态
|
|
|
+ *
|
|
|
+ * @param ticketProcessUpDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Integer updateProcess(TicketProcessUpDTO ticketProcessUpDTO) {
|
|
|
+ Integer id = ticketProcessUpDTO.getId();
|
|
|
+ Integer process = ticketProcessUpDTO.getProcess();
|
|
|
+ Ticket ticket = this.getById(id);
|
|
|
+
|
|
|
+ Boolean flag = this.ifHavePermission(ticket.getCreateId());
|
|
|
+ if (!flag) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ ticket.setTicketProgress(process);
|
|
|
+ ticket.updateById();
|
|
|
+ return ticket.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新价格
|
|
|
+ *
|
|
|
+ * @param ticketPriceUpDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Integer updatePrice(TicketPriceUpDTO ticketPriceUpDTO) {
|
|
|
+ Integer id = ticketPriceUpDTO.getId();
|
|
|
+ Double price = ticketPriceUpDTO.getPrice();
|
|
|
+ Ticket ticket = this.getById(id);
|
|
|
+
|
|
|
+ Boolean flag = this.ifHavePermission(null);
|
|
|
+ if (!flag) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ ticket.setPrice(price);
|
|
|
+ ticket.updateById();
|
|
|
+ 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();
|
|
|
+ if (personnelVO.getPersonType().equals(0) || (id!=null&&personnelVO.getId().equals(id))) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|