| | |
| | | package com.panzhihua.sangeshenbian.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.sangeshenbian.model.dto.ComplaintCompletionDTO; |
| | | import com.panzhihua.sangeshenbian.model.dto.ComplaintProcessDTO; |
| | | import com.panzhihua.sangeshenbian.model.entity.Complaint; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.sangeshenbian.enums.ReportTypeEnum; |
| | |
| | | import com.panzhihua.sangeshenbian.model.entity.*; |
| | | import com.panzhihua.sangeshenbian.enums.ProcessStatusEnum; |
| | | import com.panzhihua.sangeshenbian.dao.ComplaintMapper; |
| | | import com.panzhihua.sangeshenbian.model.entity.ComplaintFlow; |
| | | import com.panzhihua.sangeshenbian.model.entity.ComplaintProgress; |
| | | import com.panzhihua.sangeshenbian.model.entity.SystemUser; |
| | | import com.panzhihua.sangeshenbian.model.query.BasePage; |
| | | import com.panzhihua.sangeshenbian.model.query.ComplaintQuery; |
| | | import com.panzhihua.sangeshenbian.model.vo.ComplaintTodoVO; |
| | | import com.panzhihua.sangeshenbian.service.IComplaintFlowService; |
| | | import com.panzhihua.sangeshenbian.service.IComplaintProgressService; |
| | | import com.panzhihua.sangeshenbian.service.IComplaintService; |
| | | import com.panzhihua.sangeshenbian.model.vo.DispatchVO; |
| | | import com.panzhihua.sangeshenbian.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.sangeshenbian.model.vo.ComplaintVO; |
| | | import com.panzhihua.sangeshenbian.service.ISystemUserService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.List; |
| | | |
| | | import static cn.hutool.core.util.ObjectUtil.isNull; |
| | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ComplaintServiceImpl extends ServiceImpl<ComplaintMapper, Complaint> implements IComplaintService { |
| | | |
| | | private final IComplaintAuditRecordService complaintAuditRecordService; |
| | | private final ISystemUserService systemUserService; |
| | | private final IComplaintFlowService complaintFlowService; |
| | | private final IComplaintProgressService complaintProgressService; |
| | | |
| | | private final IComplaintAuditRecordService complaintAuditRecordService; |
| | | private final IBcRegionService bcRegionService; |
| | | private final IComStreetService comStreetService; |
| | | private final IComActService comActService; |
| | |
| | | |
| | | /** |
| | | * @param query |
| | | * @param loginUserInfoVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Page<ComplaintVO> complaintList(ComplaintQuery query) { |
| | | //判断当前登录用户级别,查询对应工单 |
| | | public Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO loginUserInfoVO) { |
| | | Page<ComplaintVO> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | //判断当前登录用户级别,查询对应工单 |
| | | Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()); |
| | | String targetId = ""; |
| | | int isSuperior = 0; |
| | | //上级 |
| | | if (systemUserByPhone.isPresent()) { |
| | | SystemUser systemUser = systemUserByPhone.get(); |
| | | Integer accountLevel = systemUser.getAccountLevel(); |
| | | switch (accountLevel) { |
| | | case 1: |
| | | //市级 |
| | | targetId = "510400"; |
| | | break; |
| | | case 2: |
| | | //区县级 |
| | | targetId = systemUser.getDistrictsCode(); |
| | | break; |
| | | case 3: |
| | | //街道 |
| | | targetId = systemUser.getStreetCode(); |
| | | break; |
| | | case 4: |
| | | //社区 |
| | | targetId = systemUser.getCommunityCode(); |
| | | break; |
| | | } |
| | | isSuperior = 1; |
| | | } else { |
| | | //党员 |
| | | targetId = loginUserInfoVO.getUserId().toString(); |
| | | } |
| | | //查询对应诉求 |
| | | page = baseMapper.selectComplaintPage(page, query, targetId,isSuperior); |
| | | return page; |
| | | } |
| | | |
| | | /** |
| | | * 工单详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ComplaintVO detail(Long id) { |
| | | ComplaintVO detail = baseMapper.getDetail(id); |
| | | if (detail.getStatus().equals(0)) { |
| | | List<ComplaintFlow> list = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByAsc(ComplaintFlow::getCreateTime).list(); |
| | | detail.setComplaintFlows(list); |
| | | } |
| | | return detail; |
| | | } |
| | | |
| | | /** |
| | | * 办理进度录入 |
| | | * |
| | | * @param dto |
| | | * @param userId |
| | | */ |
| | | @Override |
| | | public void saveProcess(ComplaintProcessDTO dto) { |
| | | |
| | | public void saveProcess(ComplaintProcessDTO dto,Long userId) { |
| | | ComplaintProgress complaintProgress = BeanUtil.copyProperties(dto, ComplaintProgress.class); |
| | | complaintProgress.setCreateTime(new Date()); |
| | | complaintProgress.setCreateBy(userId); |
| | | complaintProgressService.save(complaintProgress); |
| | | } |
| | | |
| | | /** |
| | | * 办理结果录入 |
| | | * |
| | | * @param dto |
| | | * @param loginUserInfoVO |
| | | */ |
| | | @Override |
| | | public void saveResult(ComplaintCompletionDTO dto) { |
| | | |
| | | public void saveResult(ComplaintCompletionDTO dto, LoginUserInfoVO loginUserInfoVO) { |
| | | Complaint complaint = BeanUtil.copyProperties(dto, Complaint.class); |
| | | complaint.setUpdateTime(new Date()); |
| | | complaint.setCompletionUserId(loginUserInfoVO.getUserId()); |
| | | complaint.setCompletionUsername(loginUserInfoVO.getName()); |
| | | complaint.setCompletionTime(new Date()); |
| | | this.updateById(complaint); |
| | | } |
| | | |
| | | @Override |
| | |
| | | complaint.setReportType(reportType); |
| | | complaint.setSuperiorId(superiorId); |
| | | updateById(complaint); |
| | | |
| | | // 标记最新 |
| | | complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>() |
| | | .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) |
| | | .set(ComplaintAuditRecord::getLatestFlag,false)); |
| | | |
| | | // 添加审核记录 |
| | | complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 2, dto.getComment(), loginUserInfoVO.getUserId()); |
| | |
| | | |
| | | @Override |
| | | public void saveDelay(ComplaintDelayDTO dto, LoginUserInfoVO loginUserInfoVO) { |
| | | // 标记最新 |
| | | complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>() |
| | | .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) |
| | | .set(ComplaintAuditRecord::getLatestFlag,false)); |
| | | // 添加审核记录 |
| | | complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 1, dto.getComment(), loginUserInfoVO.getUserId()); |
| | | } |
| | |
| | | } |
| | | return dispatchVOList; |
| | | } |
| | | /** |
| | | * 获取待办诉求 |
| | | * @param basePage |
| | | * @param loginUserInfo |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Page<ComplaintTodoVO> getTodoList(BasePage basePage, LoginUserInfoVO loginUserInfo) { |
| | | Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfo.getPhone()); |
| | | String targetId = ""; |
| | | int isSuperior = 0; |
| | | //上级 |
| | | if (systemUserByPhone.isPresent()) { |
| | | SystemUser systemUser = systemUserByPhone.get(); |
| | | Integer accountLevel = systemUser.getAccountLevel(); |
| | | switch (accountLevel) { |
| | | case 1: |
| | | //市级 |
| | | targetId = "510400"; |
| | | break; |
| | | case 2: |
| | | //区县级 |
| | | targetId = systemUser.getDistrictsCode(); |
| | | break; |
| | | case 3: |
| | | //街道 |
| | | targetId = systemUser.getStreetCode(); |
| | | break; |
| | | case 4: |
| | | //社区 |
| | | targetId = systemUser.getCommunityCode(); |
| | | break; |
| | | } |
| | | isSuperior = 1; |
| | | } else { |
| | | //党员 |
| | | targetId = loginUserInfo.getUserId().toString(); |
| | | } |
| | | Page<ComplaintTodoVO> page = baseMapper.getTodoList(new Page<>(basePage.getPageNum(), basePage.getPageSize()), targetId,isSuperior); |
| | | return page; |
| | | } |
| | | |
| | | } |
| | | |