无关风月
7 天以前 53d014edd19f57125c355abe71ec5b478500e610
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java
@@ -51,8 +51,6 @@
    private TTaskCleanService taskCleanService;
    @Resource
    private TLocationTypeService locationTypeService;
    @Resource
@@ -72,6 +70,11 @@
    @Resource
    private TAppealService appealService;
    @Resource
    private TInspectorService inspectorService;
    @Resource
    private TInspectorDetailService inspectorDetailService;
    @ApiOperation(value = "申诉记录分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<AppealListVO>> pageList(@RequestBody InsepectorListQuery query) {
@@ -162,6 +165,7 @@
        }
        return R.ok(appealService.pageList(query));
    }
    @Log(title = "批量删除申诉记录", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除申诉记录")
    @DeleteMapping(value = "/deleteByIds")
@@ -170,6 +174,7 @@
        appealService.removeBatchByIds(Arrays.asList(split));
        return R.ok();
    }
    @Log(title = "删除申诉记录", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除申诉记录")
    @DeleteMapping(value = "/deleteById")
@@ -177,12 +182,32 @@
        appealService.removeById(id);
        return R.ok();
    }
    @ApiOperation(value = "详情申诉记录")
    @GetMapping(value = "/detail")
    public R<AppealDetailVO> detail(@RequestParam String id) {
        AppealDetailVO appealDetailVO = new AppealDetailVO();
        TAppeal appeal = appealService.getById(id);
        BeanUtils.copyProperties(appeal,appealDetailVO);
        if (appeal.getInspectorId() != null) {
            TInspector inspector = inspectorService.getById(appeal.getInspectorId());
            TLocation location = locationService.getById(inspector.getLocationId());
            TLocationType byId2 = locationTypeService.getById(location.getLocationType());
            appealDetailVO.setLocationAddress(location.getLocationAddress());
            appealDetailVO.setLocationIcon(byId2.getLocationIcon());
            appealDetailVO.setLocationName(location.getLocationName());
            appealDetailVO.setLocationTypeName(byId2.getLocationName());
            appealDetailVO.setTaskId(inspector.getId());
            if (appeal.getAuditPerson() != null) {
                SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson()));
                if (sysUser != null) {
                    appealDetailVO.setAuditPersonName(sysUser.getUserName());
                }
            }
            appealDetailVO.setTaskName(location.getLocationName());
            return R.ok(appealDetailVO);
        } else {
        TTask byId = taskCleanService.getById(appeal.getTaskId());
        TLocation byId1 = locationService.getById(byId.getLocationId());
        TLocationType byId2 = locationTypeService.getById(byId1.getLocationType());
@@ -197,10 +222,14 @@
                appealDetailVO.setAuditPersonName(sysUser.getUserName());
            }
        }
        appealDetailVO.setTaskName(byId.getTaskName());
            appealDetailVO.setTaskName(byId1.getLocationName());
        appealDetailVO.setTaskCode(byId.getTaskCode());
        return R.ok(appealDetailVO);
    }
    }
    @Resource
    private TNoticeService noticeService;
    @Resource
@@ -211,12 +240,114 @@
    private TNoticeSetService noticeSetService;
    @Resource
    private TDictDataService dictDataService;
    @Log(title = "审核申诉记录", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "审核申诉记录")
    @PostMapping(value = "/audit")
    public R<Boolean> audit(@RequestBody @Valid TAppealAuditDTO dto) throws Exception {
        List<SysUser> sysUsers = sysUserService.selectAllList();
        TAppeal appeal = appealService.getById(dto.getId());
        if (appeal.getInspectorId() != null) {
            SysUser sysUser1 = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(appeal.getAppealPerson())))
                    .findFirst().orElse(null);
            dto.setStatus(dto.getStatus());
            dto.setAuditPerson(tokenService.getLoginUser().getUserId() + "");
            dto.setAuditTime(LocalDateTime.now());
            TInspector inspector = inspectorService.getById(appeal.getInspectorId());
            TLocation location1 = locationService.getById(inspector.getLocationId());
            TNotice tNotice1 = new TNotice();
            tNotice1.setUserId(appeal.getAppealPerson());
            tNotice1.setStatus(1);
            tNotice1.setDataId(dto.getId());
            dto.setAuditTime(LocalDateTime.now());
            TInspectorDetail inspectorDetail = new TInspectorDetail();
            inspectorDetail.setInspectorId(appeal.getInspectorId());
            Long count1 = inspectorDetailService.lambdaQuery().eq(TInspectorDetail::getInspectorId, appeal.getInspectorId())
                    .eq(TInspectorDetail::getHandleType, 1).count();
            TNoticeSet noticeSet1 = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1")
                    .one();
            // 邮箱
            TDictData email1 = dictDataService.lambdaQuery().eq(TDictData::getDataType, 4).one();
            // 授权码
            TDictData code1 = dictDataService.lambdaQuery().eq(TDictData::getDataType, 5).one();
            if (dto.getStatus() == 2) {
                inspectorDetail.setClearStatus(1);
                inspectorDetail.setAuditTime(LocalDateTime.now());
                inspectorDetail.setAuditPerson(tokenService.getLoginUser().getUserId() + "");
                inspectorDetail.setAuditStatus(1);
                inspectorDetail.setAuditRemark(dto.getAuditRemark());
                inspectorDetail.setHandleType(5);
                inspectorDetail.setAppealId(dto.getId());
                // 通过
                TInspector byId = inspectorService.getById(dto.getInspectorId());
                if (count1 > 1) {
                    byId.setStatus(5);
                } else {
                    byId.setStatus(6);
                }
                inspectorService.updateById(byId);
                tNotice1.setNoticeType(5);
                tNotice1.setNoticeContent("【" + location1.getLocationName() + "】任务申诉通过");
                if (sysUser1 != null) {
                    switch (noticeSet1.getNoticeType()) {
                        case 1:
                            msgUtils.sendMsg3(sysUser1.getPhonenumber(), location1.getLocationName(), "通过");
                            break;
                        case 2:
                            if (StringUtils.hasLength(email1.getDataContent()) && StringUtils.hasLength(code1.getDataContent())
                            &&StringUtils.hasLength(sysUser1.getEmail())
                            ) {
                                EmailUtils.sendEmail(sysUser1.getEmail(), email1.getDataContent(), code1.getDataContent(), "【" + location1.getLocationName() + "】任务申诉通过");
                            }
                            break;
                        case 3:
                            if (StringUtils.hasLength(sysUser1.getOpenId())) {
                                Date date = new Date();
                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                String format = simpleDateFormat.format(date);
                                templateMessageSendUtil.wxTemplateAppealResultRequest(sysUser1.getOpenId(),
                                        location1.getLocationName(), "通过", format, dto.getAuditRemark());
                            }
                            break;
                    }
                }
            } else {
                inspectorDetail.setClearStatus(2);
                inspectorDetail.setAuditTime(LocalDateTime.now());
                inspectorDetail.setAuditPerson(tokenService.getLoginUser().getUserId() + "");
                inspectorDetail.setAuditStatus(2);
                inspectorDetail.setAuditRemark(dto.getAuditRemark());
                inspectorDetail.setHandleType(6);
                inspectorDetail.setAppealId(dto.getId());
                tNotice1.setNoticeType(4);
                tNotice1.setNoticeContent("【" + location1.getLocationName() + "】任务申诉驳回");
                if (sysUser1 != null) {
                    switch (noticeSet1.getNoticeType()) {
                        case 1:
                            msgUtils.sendMsg3(sysUser1.getPhonenumber(), location1.getLocationName(), "通过");
                            break;
                        case 2:
                            if (StringUtils.hasLength(email1.getDataContent()) && StringUtils.hasLength(code1.getDataContent())
                                    &&StringUtils.hasLength(sysUser1.getEmail())) {
                                EmailUtils.sendEmail(sysUser1.getEmail(), email1.getDataContent(), code1.getDataContent(), "【" + location1.getLocationName() + "】任务申诉驳回");
                            }
                            break;
                        case 3:
                            if (StringUtils.hasLength(sysUser1.getOpenId())) {
                                Date date = new Date();
                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                String format = simpleDateFormat.format(date);
                                templateMessageSendUtil.wxTemplateAppealResultRequest(sysUser1.getOpenId(),
                                        location1.getLocationName(), "驳回", format, dto.getAuditRemark());
                            }
                            break;
                    }
                }
            }
        } else {
        SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(appeal.getAppealPerson())))
                .findFirst().orElse(null);
        dto.setStatus(dto.getStatus());
@@ -265,7 +396,9 @@
                        msgUtils.sendMsg3(sysUser.getPhonenumber(),location.getLocationName(),"通过");
                        break;
                    case 2:
                        if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){
                            if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent())
                                    &&StringUtils.hasLength(sysUser.getEmail())) {
                            EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【"+location.getLocationName()+"】任务申诉通过");
                        }
                        break;
@@ -297,7 +430,8 @@
                        msgUtils.sendMsg3(sysUser.getPhonenumber(),location.getLocationName(),"通过");
                        break;
                    case 2:
                        if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){
                            if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent())
                                    &&StringUtils.hasLength(sysUser.getEmail())) {
                            EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【"+location.getLocationName()+"】任务申诉驳回");
                        }
                        break;
@@ -318,7 +452,9 @@
        dto.setAuditPerson(tokenService.getLoginUser().getUserId()+"");
        appealService.updateById(dto);
        tTaskDetailService.save(taskDetail);
        }
        return R.ok();
    }
}