| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | 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.dto.*; |
| | | import com.panzhihua.sangeshenbian.model.entity.*; |
| | | import com.panzhihua.sangeshenbian.enums.ProcessStatusEnum; |
| | | import com.panzhihua.sangeshenbian.dao.ComplaintMapper; |
| | | import com.panzhihua.sangeshenbian.model.query.ComplaintQuery; |
| | | 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 lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import static cn.hutool.core.util.ObjectUtil.isNull; |
| | | |
| | |
| | | * @since 2025-02-22 |
| | | */ |
| | | @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 IBcRegionService bcRegionService; |
| | | private final IComStreetService comStreetService; |
| | | private final IComActService comActService; |
| | | |
| | | @Override |
| | | public void saveComplaint(Complaint complaint,Long userId) { |
| | | public void saveComplaint(Complaint complaint, Long userId) { |
| | | // 获取当前日期(年月日) |
| | | String datePrefix = new SimpleDateFormat("yyyyMMdd").format(new Date()); |
| | | |
| | |
| | | |
| | | // 设置其他字段 |
| | | complaint.setStatus(ProcessStatusEnum.PROCESSING.getCode()); |
| | | complaint.setCreateTime(DateUtils.getCurrentDate()); |
| | | complaint.setCreateTime(new Date(System.currentTimeMillis())); |
| | | complaint.setCreateBy(userId); |
| | | complaint.setUpdateBy(userId); |
| | | complaint.setUpdateTime(DateUtils.getCurrentDate()); |
| | | complaint.setUpdateTime(new Date(System.currentTimeMillis())); |
| | | |
| | | // 保存诉求记录 |
| | | save(complaint); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | *办理进度录入 |
| | | * 办理进度录入 |
| | | * |
| | | * @param dto |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 办理结果录入 |
| | | * |
| | | * @param dto |
| | | */ |
| | | @Override |
| | | public void saveResult(ComplaintCompletionDTO dto) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void saveReport(ComplaintReportDTO dto, LoginUserInfoVO loginUserInfoVO) { |
| | | String phone = loginUserInfoVO.getPhone(); |
| | | |
| | | SystemUser adminUser = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>() |
| | | .eq(SystemUser::getPhone, phone) |
| | | .eq(SystemUser::getIsAdmin, 1) |
| | | .eq(SystemUser::getStatus, 3) |
| | | .last("LIMIT 1")); |
| | | |
| | | Long superiorId; |
| | | int reportType; |
| | | if (adminUser == null) { |
| | | superiorId = loginUserInfoVO.getCommunityId(); |
| | | reportType = ReportTypeEnum.COMMUNITY.getCode(); |
| | | } else { |
| | | int accountLevel = adminUser.getAccountLevel(); // 改为基本类型 |
| | | if (accountLevel == 1) { |
| | | throw new ServiceException("市级账号,无法上报!"); |
| | | } |
| | | reportType = accountLevel + 1; |
| | | |
| | | // 使用基本类型比较并补充默认分支 |
| | | if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) { |
| | | superiorId = Long.parseLong(adminUser.getStreetCode()); |
| | | } else if (accountLevel == ReportTypeEnum.STREET.getCode()) { |
| | | superiorId = Long.parseLong(adminUser.getDistrictsCode()); |
| | | } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { |
| | | superiorId = 510400L; // 攀枝花市 |
| | | } else { |
| | | // 处理未预期的账号等级 |
| | | throw new ServiceException("未知的账号等级"); |
| | | } |
| | | } |
| | | |
| | | Complaint complaint = getById(dto.getComplaintId()); |
| | | complaint.setReportType(reportType); |
| | | complaint.setSuperiorId(superiorId); |
| | | updateById(complaint); |
| | | |
| | | // 添加审核记录 |
| | | complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 2, dto.getComment(), loginUserInfoVO.getUserId()); |
| | | } |
| | | |
| | | @Override |
| | | public void saveDispatch(ComplaintDispatch dto, LoginUserInfoVO loginUserInfoVO) { |
| | | String phone = loginUserInfoVO.getPhone(); |
| | | SystemUser adminUser = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>() |
| | | .eq(SystemUser::getPhone, phone) |
| | | .eq(SystemUser::getIsAdmin, 1) |
| | | .eq(SystemUser::getStatus, 3) |
| | | .last("LIMIT 1")); |
| | | |
| | | if (adminUser == null) { |
| | | throw new ServiceException("无权下派"); |
| | | } |
| | | |
| | | long superiorId; |
| | | int reportType; |
| | | int accountLevel = adminUser.getAccountLevel(); // 改为基本类型 |
| | | if (accountLevel == 1) { |
| | | throw new ServiceException("市级账号,无法上报!"); |
| | | } |
| | | reportType = accountLevel - 1; |
| | | |
| | | // 使用基本类型比较并补充默认分支 |
| | | if (accountLevel == ReportTypeEnum.STREET.getCode()) { |
| | | superiorId = Long.parseLong(adminUser.getCommunityCode()); |
| | | } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { |
| | | superiorId = Long.parseLong(adminUser.getStreetCode()); |
| | | } else if (accountLevel == ReportTypeEnum.CITY.getCode()) { |
| | | superiorId = Long.parseLong(adminUser.getDistrictsCode()); |
| | | } else { |
| | | // 处理未预期的账号等级 |
| | | throw new ServiceException("未知的账号等级"); |
| | | } |
| | | |
| | | Complaint complaint = getById(dto.getComplaintId()); |
| | | complaint.setReportType(reportType); |
| | | complaint.setSuperiorId(superiorId); |
| | | updateById(complaint); |
| | | |
| | | // 添加流转记录 |
| | | complaintFlowService.createFlow(dto.getComplaintId(), 1, loginUserInfoVO.getUserId()); |
| | | } |
| | | |
| | | @Override |
| | | public void reportAudit(ComplaintReporAuditDTO complaintReporAuditDTO, LoginUserInfoVO loginUserInfoVO) { |
| | | complaintAuditRecordService.audit(complaintReporAuditDTO.getId(), loginUserInfoVO.getUserId(), |
| | | complaintReporAuditDTO.getAuditResult(), complaintReporAuditDTO.getRejectReason()); |
| | | |
| | | // 添加流转记录 |
| | | ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.getById(complaintReporAuditDTO.getId()); |
| | | complaintFlowService.createFlow(complaintAuditRecord.getComplaintId(), 0, loginUserInfoVO.getUserId()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveDelay(ComplaintDelayDTO dto, LoginUserInfoVO loginUserInfoVO) { |
| | | // 添加审核记录 |
| | | complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 1, dto.getComment(), loginUserInfoVO.getUserId()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void delayAudit(ComplaintDelayAuditDTO complaintDelayAuditDTO, LoginUserInfoVO loginUserInfoVO) { |
| | | complaintAuditRecordService.audit(complaintDelayAuditDTO.getId(), loginUserInfoVO.getUserId(), |
| | | complaintDelayAuditDTO.getAuditResult(), complaintDelayAuditDTO.getRejectReason()); |
| | | } |
| | | |
| | | @Override |
| | | public List<DispatchVO> getDispatchList(LoginUserInfoVO loginUserInfoVO) { |
| | | |
| | | String phone = loginUserInfoVO.getPhone(); |
| | | SystemUser adminUser = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>() |
| | | .eq(SystemUser::getPhone, phone) |
| | | .eq(SystemUser::getIsAdmin, 1) |
| | | .eq(SystemUser::getStatus, 3) |
| | | .last("LIMIT 1")); |
| | | |
| | | if (adminUser == null) { |
| | | throw new ServiceException("无权下派"); |
| | | } |
| | | int accountLevel = adminUser.getAccountLevel(); // 改为基本类型 |
| | | if (accountLevel == 1) { |
| | | throw new ServiceException("市级账号,无法上报!"); |
| | | } |
| | | |
| | | // 使用基本类型比较并补充默认分支 |
| | | List<DispatchVO> dispatchVOList = new ArrayList<>(); |
| | | if (accountLevel == ReportTypeEnum.STREET.getCode()) { |
| | | List<ComAct> list = comActService.list(); |
| | | for (ComAct comAct : list) { |
| | | DispatchVO dispatchVO = new DispatchVO(); |
| | | dispatchVO.setId(comAct.getCommunityId()); |
| | | dispatchVO.setName(comAct.getName()); |
| | | dispatchVOList.add(dispatchVO); |
| | | } |
| | | } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { |
| | | List<ComStreet> list = comStreetService.list(); |
| | | for (ComStreet street : list) { |
| | | DispatchVO dispatchVO = new DispatchVO(); |
| | | dispatchVO.setId(Long.valueOf(street.getStreetId())); |
| | | dispatchVO.setName(street.getName()); |
| | | dispatchVOList.add(dispatchVO); |
| | | } |
| | | } else if (accountLevel == ReportTypeEnum.CITY.getCode()) { |
| | | List<BcRegion> list = bcRegionService.list(new LambdaQueryWrapper<BcRegion>() |
| | | .eq(BcRegion::getHierarchyOrder, 3)); |
| | | for (BcRegion region : list) { |
| | | DispatchVO dispatchVO = new DispatchVO(); |
| | | dispatchVO.setId(Long.valueOf(region.getRegionCode())); |
| | | dispatchVO.setName(region.getRegionName()); |
| | | dispatchVOList.add(dispatchVO); |
| | | } |
| | | } else { |
| | | // 处理未预期的账号等级 |
| | | throw new ServiceException("未知的账号等级"); |
| | | } |
| | | return dispatchVOList; |
| | | } |
| | | } |
| | | |