| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.west.SystemUserVo; |
| | | import com.panzhihua.westcommittee.annotation.DistributedLock; |
| | | import com.panzhihua.westcommittee.annotation.SysLog; |
| | | import com.panzhihua.westcommittee.model.dto.AssignComplainDto; |
| | | import com.panzhihua.westcommittee.model.dto.ComplaintProcessUpdateDto; |
| | | import com.panzhihua.westcommittee.model.dto.*; |
| | | import com.panzhihua.westcommittee.model.entity.Complaint; |
| | | import com.panzhihua.westcommittee.model.entity.ComplaintComment; |
| | | import com.panzhihua.westcommittee.model.entity.Department; |
| | | import com.panzhihua.westcommittee.model.entity.SystemUser; |
| | | import com.panzhihua.westcommittee.model.vo.ComplaintVO; |
| | | import com.panzhihua.westcommittee.model.vo.DispatchVO; |
| | | import com.panzhihua.westcommittee.service.IComplaintCommentService; |
| | | import com.panzhihua.westcommittee.service.IComplaintService; |
| | | import com.panzhihua.westcommittee.service.IDepartmentService; |
| | | import com.panzhihua.westcommittee.service.ISystemUserService; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import static cn.hutool.core.util.ObjectUtil.isNull; |
| | | |
| | | /** |
| | | * @author mitao |
| | |
| | | private final IComplaintService complaintService; |
| | | private final ISystemUserService systemUserService; |
| | | private final IDepartmentService departmentService; |
| | | private final IComplaintCommentService complaintCommentService; |
| | | |
| | | @PostMapping("/save") |
| | | @ApiOperation(value = "录入诉求") |
| | |
| | | @PostMapping("/assignComplain") |
| | | @ApiOperation(value = "分配诉求") |
| | | public R<?> assignComplain(@Valid@RequestBody AssignComplainDto dto) { |
| | | complaintService.assignComplain(getLoginUserInfo(),dto.getComplainId(),dto.getDeptId(),dto.getRemark()); |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | complaintService.assignComplain(loginUserInfoVO,dto.getComplainId(),dto.getDeptId(),dto.getRemark(),dto.getProblemType()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | @ApiOperation("诉求详情") |
| | | @GetMapping("/detail/{id}") |
| | | public R<ComplaintVO> detail(@ApiParam(name = "id", value = "诉求id", required = true) @PathVariable("id") Long id) { |
| | | return R.ok(complaintService.getDetailMgt(id)); |
| | | } |
| | | // @ApiOperation("诉求详情") |
| | | // @GetMapping("/detail/{id}") |
| | | // public R<ComplaintVO> detail(@ApiParam(name = "id", value = "诉求id", required = true) @PathVariable("id") Long id) { |
| | | // return R.ok(complaintService.getDetailMgt(id)); |
| | | // } |
| | | @ApiOperation("导出") |
| | | @PostMapping("/export") |
| | | @SysLog(operatorCategory = "诉求导出",operId = 9) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("社区问题单、问题处理单、协调通知单 下载") |
| | | @GetMapping("/download-file/{id}/{type}") |
| | | @SysLog(operatorCategory = "单导出",operId = 10) |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ApiOperation("诉求详情") |
| | | @GetMapping("/detail/{id}") |
| | | public R<ComplaintVO> detail(Long id) { |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | return R.ok(complaintService.detail(id,loginUserInfoVO)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/save-process") |
| | | @ApiOperation("办理进度录入") |
| | | public R<?> saveProcess(@Valid @RequestBody ComplaintProcessDTO dto){ |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | complaintService.saveProcess(dto,loginUserInfoVO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/save-result") |
| | | @ApiOperation("办理结果录入") |
| | | public R<?> saveResult(@RequestBody ComplaintCompletionDTO dto){ |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | complaintService.saveResult(dto,loginUserInfoVO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 问题上报 |
| | | */ |
| | | @PostMapping("/report") |
| | | @ApiOperation(value = "问题上报") |
| | | public R<?> report(@RequestBody ComplaintReportDTO complaintReportDTO) { |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | complaintService.saveReport(complaintReportDTO, loginUserInfoVO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 延期申请 |
| | | */ |
| | | @PostMapping("/saveDelay") |
| | | @ApiOperation(value = "延期申请") |
| | | public R<?> saveDelay(@Valid @RequestBody ComplaintDelayDTO dto){ |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | complaintService.saveDelay(dto, loginUserInfoVO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 延期审核 |
| | | */ |
| | | @PostMapping("/delayAudit") |
| | | @ApiOperation(value = "延期审核") |
| | | public R<?> delayAudit(@RequestBody ComplaintDelayAuditDTO dto) { |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | complaintService.delayAudit(dto, loginUserInfoVO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 上报审核 |
| | | */ |
| | | @PostMapping("/reportAudit") |
| | | @ApiOperation(value = "问题上报审核并指派") |
| | | public R<?> reportAudit(@RequestBody ComplaintReporAuditDTO dto) { |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | complaintService.reportAudit(dto, loginUserInfoVO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/setProblemType") |
| | | @ApiOperation(value = "分配问题类型") |
| | | public R<?> assignComplain(@Valid @RequestBody SetProblemTypeDto dto) { |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | // 判断是否管理员 |
| | | complaintService.setProblemType(loginUserInfoVO,dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 评价诉求 |
| | | * @param complaintComment |
| | | * @return |
| | | */ |
| | | @PostMapping("/commentComplaint") |
| | | @ApiOperation(value = "评价诉求") |
| | | public R<?> commentComplaint(@RequestBody ComplaintComment complaintComment){ |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, complaintComment.getComplaintId()) |
| | | .eq(ComplaintComment::getDelFlag, 0)); |
| | | if(0 != count){ |
| | | return R.fail("不能重复评价"); |
| | | } |
| | | Long userId = loginUserInfoVO.getUserId(); |
| | | complaintComment.setUserId(userId); |
| | | complaintComment.setCreateTime(new Date()); |
| | | complaintComment.setCreateBy(userId); |
| | | complaintComment.setUpdateBy(userId); |
| | | complaintComment.setUpdateTime(new Date()); |
| | | complaintComment.setDelFlag(0); |
| | | complaintCommentService.save(complaintComment); |
| | | Complaint complaint = complaintService.getById(complaintComment.getComplaintId()); |
| | | complaint.setStatus(8); |
| | | complaint.setCommentRate(complaintComment.getRate()); |
| | | complaintService.updateById(complaint); |
| | | // 不满意 重新生成诉求 |
| | | if(complaintComment.getRate()==0){ |
| | | // 获取当前日期(年月日) |
| | | String datePrefix = new SimpleDateFormat("yyyyMMdd").format(new Date()); |
| | | |
| | | // 查询当前日期的最大流水号 |
| | | Complaint lastComplaint = complaintService.getOne(new LambdaQueryWrapper<Complaint>() |
| | | .likeRight(Complaint::getSerialNumber, datePrefix) // 查询以当前日期开头的流水号 |
| | | .orderByDesc(Complaint::getSerialNumber) |
| | | .last("limit 1")); |
| | | |
| | | String serialNumber; |
| | | if (isNull(lastComplaint)) { |
| | | // 如果当天没有记录,从 0001 开始 |
| | | serialNumber = datePrefix + "0001"; |
| | | } else { |
| | | // 获取当前日期的最大流水号,并递增 |
| | | String lastSerialNumber = lastComplaint.getSerialNumber(); |
| | | int num = Integer.parseInt(lastSerialNumber.substring(lastSerialNumber.length() - 4)); // 提取后4位数字 |
| | | serialNumber = datePrefix + String.format("%04d", num + 1); // 递增并格式化为4位 |
| | | } |
| | | Complaint complaint1 = new Complaint(); |
| | | BeanUtils.copyProperties(complaint,complaint1); |
| | | complaint1.setStatus(0); |
| | | complaint1.setSerialNumber(serialNumber); |
| | | complaint1.setAssignStatus(0); |
| | | complaint1.setCreateTime(new Date()); |
| | | complaint1.setId(null); |
| | | complaint1.setCompletionTime(null); |
| | | complaint1.setCompletionUserId(null); |
| | | complaint1.setCompletionUsername(null); |
| | | complaint1.setCompletionUserPhone(null); |
| | | complaint1.setCompletionImages(null); |
| | | complaint1.setCompletionUserLevel(null); |
| | | complaint1.setCompletionDescription(null); |
| | | complaint1.setCompletionVideos(null); |
| | | complaint1.setCompletionOtherDescription(null); |
| | | complaint1.setRemark(null); |
| | | complaint1.setNowLevelTime(new Date()); |
| | | complaint1.setNowLevelSms(0); |
| | | complaint1.setRedispatch(1); |
| | | complaintService.save(complaint1); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 上报撤回 |
| | | */ |
| | | @PostMapping("/revoke") |
| | | @ApiOperation(value = "诉求上报撤回") |
| | | public R<?> reportWithdraw(@RequestBody ComplaintReportWithdrawDTO dto) { |
| | | SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | loginUserInfoVO.setPhone(loginUserInfoWest.getPhone()); |
| | | loginUserInfoVO.setUserId(Long.valueOf(loginUserInfoWest.getId())); |
| | | complaintService.reportWithdraw(dto, loginUserInfoVO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |