mitao
2025-02-26 b7720b343c03f198ab3015a8ca5fdd1803dbe4e9
三个身边代码提交
11个文件已修改
589 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/ComplaintController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintMapper.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/enums/ReportTypeEnum.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/Complaint.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/ComplaintAuditRecord.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/ComplaintVO.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/DispatchVO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/IComplaintService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintFlowServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java 394 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintMapper.xml 150 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/ComplaintController.java
@@ -76,7 +76,7 @@
    @GetMapping("/detail")
    @ApiOperation("工单详情")
    public R<ComplaintVO> detail(@ApiParam(name = "id", value = "工单id", required = true) Long id) {
        return R.ok(complaintService.detail(id));
        return R.ok(complaintService.detail(id,getLoginUserInfo()));
    }
    @GetMapping("/progress/{complaintId}")
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintMapper.java
@@ -28,12 +28,25 @@
     */
    Page<ComplaintVO> selectComplaintPage(Page<ComplaintVO> page, @Param("query") ComplaintQuery query, @Param("targetId") String targetId, @Param("isSuperior") Integer isSuperior);
    /**
     * 工单列表
     * @param page
     * @param query
     * @param targetId
     * @param isSuperior
     * @return
     */
    Page<ComplaintVO> selectComplaintPage1(Page<ComplaintVO> page, @Param("query") ComplaintQuery query, @Param("accountLevel") Integer accountLevel, @Param("targetId") String targetId);
    /**
     *  工单详情
     * @param id
     * @return
     */
    ComplaintVO getDetail(Long id);
    ComplaintVO getDetail(@Param("id") Long id,@Param("targetId") String targetId, @Param("isSuperior") Integer isSuperior);
    /**
     * 获取待办诉求
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/enums/ReportTypeEnum.java
@@ -1,6 +1,7 @@
package com.panzhihua.sangeshenbian.enums;
public enum ReportTypeEnum {
    PARTY(5, "党员"),
    COMMUNITY(4, "社区"),
    STREET(3, "街道"),
    DISTRICT(2, "区县"),
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/Complaint.java
@@ -103,6 +103,10 @@
    @TableField("report_type")
    private Integer reportType;
    @ApiModelProperty(value = "上级类型 1=市级账号,2=区县账号,3=街道账号,4=社区账号")
    @TableField("superior_type")
    private Integer superiorType;
    @ApiModelProperty(value = "上级id")
    @TableField("superior_id")
    private Long superiorId;
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/ComplaintAuditRecord.java
@@ -49,11 +49,11 @@
    @TableField("auditor_id")
    private Long auditorId;
    @ApiModelProperty(value = "审核类型(1:延期申请, 2:上报申请)")
    @ApiModelProperty(value = "审核类型(0:录入1:延期申请, 2:上报申请,3=下派)")
    @TableField("audit_type")
    private Integer auditType;
    @ApiModelProperty(value = "审核状态 (0:待审核 1:审核通过 2:审核驳回)")
    @ApiModelProperty(value = "审核状态 (-1:未提交审核,0:待审核 1:审核通过 2:审核驳回)")
    @TableField("audit_status")
    private Integer auditStatus;
@@ -98,4 +98,12 @@
    @ApiModelProperty("部门id")
    private Integer departmentId;
    @ApiModelProperty(value = "上报类型 1=市级账号,2=区县账号,3=街道账号,4=社区账号 5=党员账号")
    @TableField("report_type")
    private Integer reportType;
    @ApiModelProperty(value = "上级id")
    @TableField("superior_id")
    private Long superiorId;
}
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/ComplaintVO.java
@@ -47,11 +47,14 @@
    private String rejectReason;
    @ApiModelProperty(value = "审核时间")
    private Date auditTime;
    private String auditTime;
    @ApiModelProperty(value = "诉求流转记录")
    List<ComplaintFlow> complaintFlows;
    @ApiModelProperty(value = "办理进度")
    List<ComplaintProgress> complaintProgresses;
    @ApiModelProperty(value = "审核按钮状态(0=显示,1=隐藏)")
    private Integer auditButtonStatus;
}
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/DispatchVO.java
@@ -8,7 +8,7 @@
@ApiModel("下派单位")
public class DispatchVO {
    @ApiModelProperty(value = "下派单位id")
    private Long id;
    private String id;
    @ApiModelProperty(value = "下派单位名称")
    private String name;
}
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/IComplaintService.java
@@ -42,7 +42,7 @@
     * @param id
     * @return
     */
    ComplaintVO detail(Long id);
    ComplaintVO detail(Long id, LoginUserInfoVO  loginUserInfoVO);
    /**
     * 保存办理进度
     *
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintFlowServiceImpl.java
@@ -68,7 +68,7 @@
            if (R.isOk(userR)) {
                throw new ServiceException("获取用户信息失败");
            }
            name =  userR.getData().getNickName();
            name =  null == userR.getData() ? "" : userR.getData().getNickName();
        }
        return name;
    }
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
@@ -88,10 +88,11 @@
        // 设置流水号
        complaint.setSerialNumber(serialNumber);
        Optional<SystemUser> systemUserOpt = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
        if (systemUserOpt.isPresent()){
        Integer accountLevel = 5;
            Long superiorId = null;
        if (systemUserOpt.isPresent()) {
            SystemUser systemUser = systemUserOpt.get();
            Integer accountLevel = systemUser.getAccountLevel();
            accountLevel = systemUser.getAccountLevel();
            switch (accountLevel) {
                case 1:
                    //市级
@@ -109,9 +110,17 @@
                    //社区
                    superiorId = systemUser.getCommunityId();
                    break;
                case 5:
                    //社区
                    superiorId = loginUserInfoVO.getUserId();
                    break;
            }
            complaint.setSuperiorType(accountLevel);
            complaint.setSuperiorId(superiorId);
        }else{
            superiorId = loginUserInfoVO.getUserId();
        }
        complaint.setReportType(accountLevel);
        // 设置其他字段
        complaint.setStatus(ProcessStatusEnum.PROCESSING.getCode());
        complaint.setCreateTime(new Date(System.currentTimeMillis()));
@@ -126,6 +135,19 @@
        complaint.setClosingTime(new Date(System.currentTimeMillis() + config.getDemandProcessingTime() * 24 * 60 * 60 * 1000));
        // 保存诉求记录
        save(complaint);
        //保存记录
        ComplaintAuditRecord complaintAuditRecord = new ComplaintAuditRecord();
        complaintAuditRecord.setComplaintId(complaint.getId());
        complaintAuditRecord.setLatestFlag(true);
        complaintAuditRecord.setAuditType(0);
        complaintAuditRecord.setAuditStatus(-1);
        complaintAuditRecord.setCreateBy(loginUserInfoVO.getUserId());
        complaintAuditRecord.setCreateTime(new Date(System.currentTimeMillis()));
        complaintAuditRecord.setUpdateBy(loginUserInfoVO.getUserId());
        complaintAuditRecord.setUpdateTime(new Date(System.currentTimeMillis()));
        complaintAuditRecord.setReportType(accountLevel);
        complaintAuditRecord.setSuperiorId(superiorId);
        complaintAuditRecordService.save(complaintAuditRecord);
    }
    /**
@@ -140,10 +162,11 @@
        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
        String targetId = "";
        int isSuperior = 0;
        Integer accountLevel = 5;
        //上级
        if (systemUserByPhone.isPresent()) {
            SystemUser systemUser = systemUserByPhone.get();
            Integer accountLevel = systemUser.getAccountLevel();
            accountLevel = systemUser.getAccountLevel();
            switch (accountLevel) {
                case 1:
                    //市级
@@ -161,6 +184,10 @@
                    //社区
                    targetId = systemUser.getCommunityId().toString();
                    break;
                case 5:
                    //党员
                    targetId = loginUserInfoVO.getUserId().toString();
                    break;
            }
            isSuperior = 1;
        } else {
@@ -168,19 +195,57 @@
            targetId = loginUserInfoVO.getUserId().toString();
        }
        //查询对应诉求
        query.setUserId(loginUserInfoVO.getUserId());//当前登录用户id
        page = baseMapper.selectComplaintPage(page, query, targetId,isSuperior);
        //page = baseMapper.selectComplaintPage(page, query, targetId, isSuperior);
        page = baseMapper.selectComplaintPage1(page, query, accountLevel, targetId);
        return page;
    }
    /**
     * 工单详情
     *
     * @param id
     * @return
     */
    @Override
    public ComplaintVO detail(Long id) {
        ComplaintVO detail = baseMapper.getDetail(id);
    public ComplaintVO detail(Long id, LoginUserInfoVO loginUserInfoVO) {
        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
        String targetId = "";
        int isSuperior = 0;
        Integer accountLevel = 5;
        //上级
        if (systemUserByPhone.isPresent()) {
            SystemUser systemUser = systemUserByPhone.get();
            accountLevel = systemUser.getAccountLevel();
            switch (accountLevel) {
                case 1:
                    //市级
                    targetId = "510400";
                    break;
                case 2:
                    //区县级
                    targetId = systemUser.getDistrictsCode();
                    break;
                case 3:
                    //街道
                    targetId = systemUser.getStreetId().toString();
                    break;
                case 4:
                    //社区
                    targetId = systemUser.getCommunityId().toString();
                    break;
                case 5:
                    //社区
                    targetId = loginUserInfoVO.getUserId().toString();
                    break;
            }
            isSuperior = 1;
        } else {
            //党员
            targetId = loginUserInfoVO.getUserId().toString();
        }
        ComplaintVO detail = baseMapper.getDetail(id,targetId, isSuperior);
        if (detail.getStatus().equals(0)) {
            List<ComplaintFlow> list = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByAsc(ComplaintFlow::getCreateTime).list();
            detail.setComplaintFlows(list);
@@ -189,6 +254,15 @@
        List<ComplaintProgress> list = complaintProgressService.lambdaQuery().eq(ComplaintProgress::getComplaintId, id)
                .orderByAsc(ComplaintProgress::getCreateTime).list();
        detail.setComplaintProgresses(list);
        detail.setAuditButtonStatus(1);
        Long superiorId = detail.getSuperiorId();
        Integer superiorType = detail.getSuperiorType();
        if(detail.getStatus() == 5 && systemUserByPhone.isPresent()){
            if(superiorType.equals(accountLevel) && superiorId.toString().equals(targetId)){
                detail.setAuditButtonStatus(0);
            }
        }
        return detail;
    }
@@ -223,8 +297,10 @@
        complaint.setCompletionTime(new Date());
        this.updateById(complaint);
    }
    /**
     * 办理进度列表
     *
     * @param complaintId
     * @return
     */
@@ -247,13 +323,16 @@
                .last("LIMIT 1"));
        Long superiorId;
        Long currentId;
        int reportType;
        if (adminUser == null) {
            superiorId = loginUserInfoVO.getCommunityId();
            currentId = 0L;
            if (Objects.isNull(superiorId)){
                throw new ServiceException("上报失败,请绑定社区");
            }
            reportType = ReportTypeEnum.COMMUNITY.getCode();
            currentId = loginUserInfoVO.getUserId();
        } else {
            int accountLevel = adminUser.getAccountLevel(); // 改为基本类型
            if (accountLevel == 1) {
@@ -264,10 +343,16 @@
            // 使用基本类型比较并补充默认分支
            if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) {
                superiorId = Long.parseLong(adminUser.getStreetId());
                currentId = adminUser.getCommunityId();
            } else if (accountLevel == ReportTypeEnum.STREET.getCode()) {
                superiorId = Long.parseLong(adminUser.getDistrictsCode());
                currentId = Long.valueOf(adminUser.getStreetId());
            } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
                superiorId = 510400L; // 攀枝花市
                currentId = Long.valueOf(adminUser.getDistrictsCode());
            } else if(accountLevel == ReportTypeEnum.PARTY.getCode()){
                superiorId = adminUser.getCommunityId();
                currentId = loginUserInfoVO.getUserId();
            } else {
                // 处理未预期的账号等级
                throw new ServiceException("未知的账号等级");
@@ -275,7 +360,8 @@
        }
        Complaint complaint = getById(dto.getComplaintId());
        complaint.setReportType(reportType);
        //complaint.setReportType(+);
        complaint.setSuperiorType(reportType);
        complaint.setSuperiorId(superiorId);
        updateById(complaint);
@@ -285,7 +371,38 @@
                .set(ComplaintAuditRecord::getLatestFlag,false));
        // 添加审核记录
        complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 2, dto.getComment(), loginUserInfoVO,adminUser);
        //complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 2, dto.getComment(), loginUserInfoVO,adminUser);
        ComplaintAuditRecord complaintAuditRecord = new ComplaintAuditRecord();
        complaintAuditRecord.setComplaintId(complaint.getId());
        complaintAuditRecord.setLatestFlag(true);
        complaintAuditRecord.setAuditType(2);
        complaintAuditRecord.setAuditStatus(0);
        complaintAuditRecord.setCreateBy(loginUserInfoVO.getUserId());
        complaintAuditRecord.setCreateTime(new Date(System.currentTimeMillis()));
        complaintAuditRecord.setUpdateBy(loginUserInfoVO.getUserId());
        complaintAuditRecord.setUpdateTime(new Date(System.currentTimeMillis()));
        complaintAuditRecord.setReporter(loginUserInfoVO.getNickName());
        complaintAuditRecord.setReportType(Objects.isNull(adminUser) ? 5 : adminUser.getAccountLevel());
        complaintAuditRecord.setSuperiorId(currentId);
        complaintAuditRecord.setComment(dto.getComment());
        complaintAuditRecordService.save(complaintAuditRecord);
        ComplaintAuditRecord complaintAuditRecord2 = new ComplaintAuditRecord();
        complaintAuditRecord2.setComplaintId(complaint.getId());
        complaintAuditRecord2.setLatestFlag(true);
        complaintAuditRecord2.setAuditType(2);
        complaintAuditRecord2.setAuditStatus(0);
        complaintAuditRecord2.setCreateBy(loginUserInfoVO.getUserId());
        complaintAuditRecord2.setCreateTime(new Date(System.currentTimeMillis()));
        complaintAuditRecord2.setUpdateBy(loginUserInfoVO.getUserId());
        complaintAuditRecord2.setUpdateTime(new Date(System.currentTimeMillis()));
        complaintAuditRecord2.setReporter(loginUserInfoVO.getNickName());
        complaintAuditRecord2.setReportType(reportType);
        complaintAuditRecord2.setSuperiorId(superiorId);
        complaintAuditRecord2.setComment(dto.getComment());
        complaintAuditRecordService.save(complaintAuditRecord2);
    }
    @Override
@@ -302,34 +419,40 @@
            throw new ServiceException("无权下派");
        }
        long superiorId;
        int accountLevel = adminUser.getAccountLevel(); // 改为基本类型
        if (accountLevel == 4) {
            throw new ServiceException("社区账号,无法下派!");
        }
        accountLevel++;
        // 使用基本类型比较并补充默认分支
        if (accountLevel == ReportTypeEnum.STREET.getCode()) {
            superiorId = adminUser.getCommunityId().longValue();
        } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
            superiorId = Long.parseLong(adminUser.getStreetId());
        } else if (accountLevel == ReportTypeEnum.CITY.getCode()) {
            superiorId = Long.parseLong(adminUser.getDistrictsCode());
        } else {
            // 处理未预期的账号等级
            throw new ServiceException("未知的账号等级");
        }
        Long superiorOrgId;
        Complaint complaint = getById(dto.getComplaintId());
        superiorOrgId = complaint.getSuperiorId();
        complaint.setReportType(accountLevel + 1);
        complaint.setSuperiorId(superiorId);
        complaint.setSuperiorType(accountLevel);
        complaint.setSuperiorId(dto.getDispatchId());
        updateById(complaint);
        Long superiorOrgId = complaint.getSuperiorId();
        Integer superiorType = complaint.getSuperiorType();
        // 添加流转记录
        complaintFlowService.createFlow(dto.getComplaintId(), superiorOrgId, accountLevel, 1, loginUserInfoVO.getUserId());
        complaintFlowService.createFlow(dto.getComplaintId(), superiorOrgId, superiorType, 1, loginUserInfoVO.getUserId());
        // 标记最新
        complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>()
                .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())
                .set(ComplaintAuditRecord::getLatestFlag, false));
        ComplaintAuditRecord record = new ComplaintAuditRecord();
        record.setComplaintId(complaint.getId());
        record.setLatestFlag(true);
        record.setAuditType(0);
        record.setAuditStatus(1);
        record.setCreateBy(loginUserInfoVO.getUserId());
        record.setCreateTime(new Date(System.currentTimeMillis()));
        record.setUpdateBy(loginUserInfoVO.getUserId());
        record.setUpdateTime(new Date(System.currentTimeMillis()));
        record.setReporter(loginUserInfoVO.getNickName());
        record.setReportType(accountLevel);
        record.setSuperiorId(dto.getDispatchId());
        complaintAuditRecordService.save(record);
    }
    @Override
@@ -339,31 +462,9 @@
        if (!systemUserByPhone.isPresent()) {
            throw new ServiceException("无权审核");
        }
        //查询上报审核记录
        ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery().eq(ComplaintAuditRecord::getComplaintId, complaintReporAuditDTO.getId())
                .eq(ComplaintAuditRecord::getAuditType, 2)
                .eq(ComplaintAuditRecord::getLatestFlag, true)
                .last("LIMIT 1").one();
        if (Objects.isNull(complaintAuditRecord)) {
            throw new ServiceException("上报申请记录不存在");
        }
        //查询待审核诉求
        complaintAuditRecordService.audit(complaintAuditRecord,  loginUserInfoVO.getUserId(),
                complaintReporAuditDTO.getAuditResult(), complaintReporAuditDTO.getRejectReason());
        // 添加流转记录
        Complaint complaint = getById(complaintAuditRecord.getComplaintId());
        Long superiorId = null;
        if (Objects.nonNull(complaint) && complaintReporAuditDTO.getAuditResult().equals(1)) {
            superiorId = complaint.getCreateBy();
            if (Objects.nonNull(complaint.getSuperiorId())) {
                superiorId = complaint.getSuperiorId();
            }
            complaintFlowService.createFlow(complaintAuditRecord.getComplaintId(), superiorId,complaint.getReportType(),0, loginUserInfoVO.getUserId());
            //审核通过后,将诉求转移给上级
            if (complaintAuditRecord.getAuditType().equals(2) && complaintAuditRecord.getAuditStatus().equals(1)){
                SystemUser systemUser = systemUserByPhone.get();
        Long superiorId = 0L;
                    switch (systemUser.getAccountLevel()) {
                        case 1:
                            superiorId = 510400L;//默认市级
@@ -378,9 +479,88 @@
                            superiorId = systemUser.getCommunityId();
                            break;
                    }
        //查询上报审核记录
        ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery()
                .eq(ComplaintAuditRecord::getComplaintId, complaintReporAuditDTO.getId())
                .eq(ComplaintAuditRecord::getAuditType, 2)
                .eq(ComplaintAuditRecord::getLatestFlag, true)
                .eq(ComplaintAuditRecord::getReportType, systemUser.getAccountLevel())
                .eq(ComplaintAuditRecord::getSuperiorId, superiorId)
                .last("LIMIT 1").one();
        if (Objects.isNull(complaintAuditRecord)) {
            throw new ServiceException("上报申请记录不存在");
                }
                complaint.setSuperiorId(superiorId);
                updateById(complaint );
        //查询待审核诉求
        //complaintAuditRecordService.audit(complaintAuditRecord,  loginUserInfoVO.getUserId(),
        //        complaintReporAuditDTO.getAuditResult(), complaintReporAuditDTO.getRejectReason());
        // 添加流转记录
        Complaint complaint = getById(complaintAuditRecord.getComplaintId());
        // 标记最新
        complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>()
                .eq(ComplaintAuditRecord::getComplaintId, complaintAuditRecord.getComplaintId())
                .set(ComplaintAuditRecord::getLatestFlag, false));
        if (complaintReporAuditDTO.getAuditResult().equals(1)) {
            ComplaintAuditRecord record = new ComplaintAuditRecord();
            record.setComplaintId(complaint.getId());
            record.setLatestFlag(true);
            record.setAuditorId(loginUserInfoVO.getUserId());
            record.setAuditType(0);
            record.setAuditStatus(1);
            record.setCreateBy(loginUserInfoVO.getUserId());
            record.setCreateTime(new Date(System.currentTimeMillis()));
            record.setUpdateBy(loginUserInfoVO.getUserId());
            record.setUpdateTime(new Date(System.currentTimeMillis()));
            record.setReporter(complaintAuditRecord.getReporter());
            record.setReportType(complaintAuditRecord.getReportType());
            record.setSuperiorId(superiorId);
            complaintAuditRecordService.save(record);
            if (Objects.nonNull(complaint.getSuperiorId())) {
                complaintFlowService.createFlow(complaintAuditRecord.getComplaintId(), complaint.getSuperiorId(), complaint.getSuperiorType(), 0, loginUserInfoVO.getUserId());
            } else {
                complaintFlowService.createFlow(complaintAuditRecord.getComplaintId(), complaint.getCreateBy(), complaint.getReportType(), 0, loginUserInfoVO.getUserId());
            }
        } else {
            switch (systemUser.getAccountLevel() + 1) {
                case 1:
                    superiorId = 510400L;//默认市级
                    break;
                case 2:
                    superiorId = Long.parseLong(systemUser.getDistrictsCode());
                    break;
                case 3:
                    superiorId = Long.parseLong(systemUser.getStreetId());
                    break;
                case 4:
                    superiorId = systemUser.getCommunityId();
                    break;
                case 5:
                    superiorId = complaint.getCreateBy();
                    break;
            }
            ComplaintAuditRecord record2 = new ComplaintAuditRecord();
            record2.setComplaintId(complaint.getId());
            record2.setLatestFlag(true);
            record2.setAuditType(2);
            record2.setAuditorId(loginUserInfoVO.getUserId());
            record2.setAuditStatus(2);
            record2.setCreateBy(loginUserInfoVO.getUserId());
            record2.setCreateTime(new Date(System.currentTimeMillis()));
            record2.setUpdateBy(loginUserInfoVO.getUserId());
            record2.setUpdateTime(new Date(System.currentTimeMillis()));
            record2.setReporter(complaintAuditRecord.getReporter());
            record2.setReportType(systemUser.getAccountLevel() + 1);
            record2.setSuperiorId(superiorId);
            record2.setRejectReason(complaintReporAuditDTO.getRejectReason());
            complaintAuditRecordService.save(record2);
        }
    }
@@ -388,15 +568,17 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveDelay(ComplaintDelayDTO dto, LoginUserInfoVO loginUserInfoVO) {
        // 标记最新
        // 清除最新记录
        complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>()
                .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())
                .set(ComplaintAuditRecord::getLatestFlag,false));
        SystemUser systemUser = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()).orElse(null);
        Long superiorId;
        Long currentId;
        int reportType;
        if (systemUser == null) {
            superiorId = loginUserInfoVO.getCommunityId();
            currentId = loginUserInfoVO.getCommunityId();
            if (Objects.isNull(superiorId)){
                throw new ServiceException("上报失败,请绑定社区");
            }
@@ -411,10 +593,13 @@
            // 使用基本类型比较并补充默认分支
            if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) {
                superiorId = Long.parseLong(systemUser.getStreetId());
                currentId = systemUser.getCommunityId();
            } else if (accountLevel == ReportTypeEnum.STREET.getCode()) {
                superiorId = Long.parseLong(systemUser.getDistrictsCode());
                currentId = Long.parseLong(systemUser.getStreetId());
            } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
                superiorId = 510400L; // 攀枝花市
                currentId = Long.parseLong(systemUser.getDistrictsCode());
            } else {
                // 处理未预期的账号等级
                throw new ServiceException("未知的账号等级");
@@ -422,33 +607,108 @@
        }
        Complaint complaint = getById(dto.getComplaintId());
        complaint.setReportType(reportType);
        complaint.setSuperiorType(reportType);
        complaint.setSuperiorId(superiorId);
        updateById(complaint);
        // 添加审核记录
        complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 1, dto.getComment(), loginUserInfoVO, systemUser);
        //complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 1, dto.getComment(), loginUserInfoVO, systemUser);
        complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>()
                .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())
                .set(ComplaintAuditRecord::getLatestFlag, false));
        ComplaintAuditRecord record1 = new ComplaintAuditRecord();
        record1.setComplaintId(complaint.getId());
        record1.setLatestFlag(true);
        record1.setAuditType(2);
        record1.setAuditStatus(2);
        record1.setCreateBy(loginUserInfoVO.getUserId());
        record1.setCreateTime(new Date(System.currentTimeMillis()));
        record1.setUpdateBy(loginUserInfoVO.getUserId());
        record1.setUpdateTime(new Date(System.currentTimeMillis()));
        record1.setReporter(loginUserInfoVO.getNickName());
        record1.setReportType(systemUser.getAccountLevel());
        record1.setSuperiorId(currentId);
        complaintAuditRecordService.save(record1);
        ComplaintAuditRecord record2 = new ComplaintAuditRecord();
        record2.setComplaintId(complaint.getId());
        record2.setLatestFlag(true);
        record2.setAuditType(2);
        record2.setAuditStatus(2);
        record2.setCreateBy(loginUserInfoVO.getUserId());
        record2.setCreateTime(new Date(System.currentTimeMillis()));
        record2.setUpdateBy(loginUserInfoVO.getUserId());
        record2.setUpdateTime(new Date(System.currentTimeMillis()));
        record2.setReporter(loginUserInfoVO.getNickName());
        record2.setReportType(systemUser.getAccountLevel() - 1);
        record2.setSuperiorId(superiorId);
        complaintAuditRecordService.save(record2);
    }
    @Override
    public void delayAudit(ComplaintDelayAuditDTO complaintDelayAuditDTO, LoginUserInfoVO loginUserInfoVO) {
        //查询待审核诉求
        ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery().eq(ComplaintAuditRecord::getComplaintId, complaintDelayAuditDTO.getComplaintId())
    public void delayAudit(ComplaintDelayAuditDTO dto, LoginUserInfoVO loginUserInfoVO) {
        SystemUser systemUser = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()).orElse(null);
        int accountLevel = systemUser.getAccountLevel(); // 改为基本类型
        Long cunrrentId;
        // 使用基本类型比较并补充默认分支
        if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) {
            cunrrentId = systemUser.getCommunityId();
        } else if (accountLevel == ReportTypeEnum.STREET.getCode()) {
            cunrrentId = Long.parseLong(systemUser.getStreetId());
        } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
            cunrrentId = Long.parseLong(systemUser.getDistrictsCode());
        } else {
            // 处理未预期的账号等级
            throw new ServiceException("未知的账号等级");
        }
        ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>()
                .eq(ComplaintAuditRecord::getAuditType, 1)
                .eq(ComplaintAuditRecord::getLatestFlag, 1)
                .eq(ComplaintAuditRecord::getAuditStatus, 0)
                .eq(ComplaintAuditRecord::getLatestFlag, true)
                .last("LIMIT 1").one();
                .eq(ComplaintAuditRecord::getSuperiorId, cunrrentId)
                .eq(ComplaintAuditRecord::getReportType, accountLevel)
                .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())
                .last("LIMIT 1"));
        if (Objects.isNull(complaintAuditRecord)) {
            throw new ServiceException("诉求延期申请不存在");
        }
        complaintAuditRecordService.audit(complaintAuditRecord, loginUserInfoVO.getUserId(),
                complaintDelayAuditDTO.getAuditResult(), complaintDelayAuditDTO.getRejectReason());
                dto.getAuditResult(), dto.getRejectReason());
        //审核通过后,设置诉求延期
        if (complaintAuditRecord.getAuditType().equals(1) && complaintAuditRecord.getAuditStatus().equals(1)){
            Complaint complaint = getById(complaintAuditRecord.getComplaintId());
            complaint.setStatus(1);
            updateById(complaint);
        }
        complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>()
                .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())
                .set(ComplaintAuditRecord::getLatestFlag, false));
        ComplaintAuditRecord record1 = new ComplaintAuditRecord();
        record1.setComplaintId(dto.getComplaintId());
        record1.setLatestFlag(true);
        record1.setAuditType(2);
        record1.setAuditorId(loginUserInfoVO.getUserId());
        record1.setAuditStatus(2);
        record1.setCreateBy(loginUserInfoVO.getUserId());
        record1.setCreateTime(new Date(System.currentTimeMillis()));
        record1.setUpdateBy(loginUserInfoVO.getUserId());
        record1.setUpdateTime(new Date(System.currentTimeMillis()));
        record1.setReporter(complaintAuditRecord.getReporter());
        record1.setReportType(systemUser.getAccountLevel());
        record1.setSuperiorId(cunrrentId);
        complaintAuditRecordService.save(record1);
    }
    @Override
@@ -475,7 +735,7 @@
            List<ComAct> list = comActService.list();
            for (ComAct comAct : list) {
                DispatchVO dispatchVO = new DispatchVO();
                dispatchVO.setId(comAct.getCommunityId());
                dispatchVO.setId(comAct.getCommunityId().toString());
                dispatchVO.setName(comAct.getName());
                dispatchVOList.add(dispatchVO);
            }
@@ -483,7 +743,7 @@
            List<ComStreet> list = comStreetService.list();
            for (ComStreet street : list) {
                DispatchVO dispatchVO = new DispatchVO();
                dispatchVO.setId(Long.valueOf(street.getStreetId()));
                dispatchVO.setId(street.getStreetId().toString());
                dispatchVO.setName(street.getName());
                dispatchVOList.add(dispatchVO);
            }
@@ -492,7 +752,7 @@
                    .eq(BcRegion::getHierarchyOrder, 3).eq(BcRegion::getParentId, 510400));//获取攀枝花市下的区县
            for (BcRegion region : list) {
                DispatchVO dispatchVO = new DispatchVO();
                dispatchVO.setId(Long.valueOf(region.getRegionCode()));
                dispatchVO.setId(region.getRegionCode());
                dispatchVO.setName(region.getRegionName());
                dispatchVOList.add(dispatchVO);
            }
@@ -502,8 +762,10 @@
        }
        return dispatchVOList;
    }
    /**
     * 获取待办诉求
     *
     * @param basePage
     * @param loginUserInfo
     * @return
@@ -543,8 +805,10 @@
        Page<ComplaintTodoVO> page = baseMapper.getTodoList(new Page<>(basePage.getPageNum(), basePage.getPageSize()), targetId,isSuperior);
        return page;
    }
    /**
     * 延期情况说明
     *
     * @param complaintId
     * @return
     */
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintMapper.xml
@@ -3,7 +3,6 @@
<mapper namespace="com.panzhihua.sangeshenbian.dao.ComplaintMapper">
    <select id="selectComplaintPage" resultType="com.panzhihua.sangeshenbian.model.vo.ComplaintVO">
        SELECT * FROM (
        SELECT sc.id,
        sc.serial_number,
        sc.time,
@@ -49,31 +48,32 @@
        scar.department_name,
        scar.department_id
        FROM sgsb_complaint sc
        LEFT JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id AND scar.latest_flag = 1
        WHERE
        ((scar.audit_type = 2 AND scar.audit_status != 1) OR (scar.audit_type = 1) OR
        (scar.id IS NULL) OR (scar.audit_type = 2 AND scar.audit_status = 1 AND scar.auditor_id = #{query.userId}))
        ) AS t
        INNER JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id AND scar.latest_flag = 1
        <where>
            <if test="isSuperior == 1 and targetId != null">
                AND superior_id = #{targetId}
            <if test="isSuperior == 1">
                AND scar.superior_id = #{targetId}
            </if>
            <if test="isSuperior == 0 and targetId != null">
                AND create_by = #{targetId}
            <if test="isSuperior == 0">
                AND sc.create_by = #{targetId}
                AND scar.superior_id = 0
            </if>
            <if test="query.type!=null and query.type == 0">
                AND(audit_type = 1 AND audit_status = 0) OR (audit_type = 2 AND audit_status = 0)
                AND scar.audit_type != 0 AND scar.audit_status = 0
            </if>
            <if test="query.type!=null and query.type == 1">
                AND (status IN(0,1,2))
                AND sc.status IN(0,1,2) AND scar.audit_type = 0
            </if>
            <if test="query.type!=null and query.type == 2">
                AND status = 3
                AND sc.status = 3
            </if>
        </where>
        ORDER BY create_time DESC
        ORDER BY sc.create_time DESC
    </select>
    <select id="getDetail" resultType="com.panzhihua.sangeshenbian.model.vo.ComplaintVO">
    <select id="selectComplaintPage1" resultType="com.panzhihua.sangeshenbian.model.vo.ComplaintVO">
        SELECT sc.id,
        sc.serial_number,
        sc.time,
@@ -113,6 +113,116 @@
        scar.audit_type,
        scar.audit_status,
        scar.comment,
        scar.create_time AS reportTime,
        scar.system_user_id,
        scar.reporter,
        scar.department_name,
        scar.department_id
        FROM sgsb_complaint sc
        INNER JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1 and scar.superior_id = #{targetId}
        <where>
            scar.latest_flag = 1
            <if test="null != accountLevel and accountLevel == 5">
                and sc.report_type = 5 and sc.create_by = #{targetId}
                <if test="query.type == 0">
                    and scar.audit_type != 0 AND scar.audit_status = 0
                </if>
            </if>
            <if test="null != accountLevel and accountLevel == 4">
                <if test="query.type==null">
                    and (
                    (sc.report_type = 4 and sc.create_by = #{targetId}) or (sc.superior_type = 4 and sc.superior_id = #{targetId})
                    or ( scar.audit_type != 0 AND scar.audit_status != 1 and scar.report_type = 4 and scar.superior_id =  #{targetId})
                    )
                </if>
                <if test="query.type == 0">
                    and ( scar.audit_type != 0 AND scar.audit_status = 0 and scar.report_type = 4 and scar.superior_id =  #{targetId})
                </if>
            </if>
            <if test="null != accountLevel and accountLevel == 3">
                <if test="query.type==null">
                    and (
                    (sc.report_type = 3 and sc.create_by = #{targetId}) or (sc.superior_type = 3 and sc.superior_id = #{targetId})
                    or (scar.audit_type != 0 AND scar.audit_status != 1 and scar.report_type = 3 and scar.superior_id =  #{targetId})
                    )
                </if>
                <if test="query.type == 0">
                    and (scar.audit_type != 0 AND scar.audit_status = 0 and scar.report_type = 3 and scar.superior_id =  #{targetId})
                </if>
            </if>
            <if test="null != accountLevel and accountLevel == 2">
                <if test="query.type==null">
                    and ((sc.report_type = 2 and sc.create_by = #{targetId}) or (sc.superior_type = 2 and sc.superior_id = #{targetId})
                    or (scar.audit_type != 0 AND scar.audit_status != 1 and scar.report_type = 2 and scar.superior_id =  #{targetId})
                    )
                </if>
                <if test="query.type == 0">
                    and (scar.audit_type != 0 AND scar.audit_status = 0 and scar.report_type = 2 and scar.superior_id =  #{targetId})
                </if>
            </if>
            <if test="null != accountLevel and accountLevel == 1">
                <if test="query.type == null">
                    and ((sc.report_type = 1 and sc.create_by = #{targetId}) or (sc.superior_type = 1 and sc.superior_id = #{targetId})
                    or (scar.audit_type != 0 AND scar.audit_status != 1 and scar.report_type = 1 and scar.superior_id =  #{targetId}))
                </if>
                <if test="query.type == 0">
                    and (scar.audit_type != 0 AND scar.audit_status = 0 and scar.report_type = 1 and scar.superior_id =  #{targetId})
                </if>
            </if>
            <if test="query.type!=null and query.type == 1">
                AND sc.status IN(0,1,2) and scar.audit_status != 0
            </if>
            <if test="query.type!=null and query.type == 2">
                AND sc.status = 3
            </if>
        </where>
        ORDER BY sc.create_time DESC
    </select>
    <select id="getDetail" resultType="com.panzhihua.sangeshenbian.model.vo.ComplaintVO">
        SELECT sc.id,
        sc.serial_number,
        sc.time,
        sc.problem_type,
        sc.name,
        sc.contact_number,
        sc.location,
        sc.detailed_address,
        sc.description_title,
        sc.description_content,
        sc.images,
        sc.videos,
        CASE
        WHEN scar.audit_type = 1 AND scar.audit_status = 0 THEN 7
        WHEN scar.audit_type = 2 AND scar.audit_status = 0 THEN 5
        WHEN scar.audit_status = 2 THEN 6
        ELSE sc.status
        END          AS status,
        sc.report_type,
        sc.superior_type,
        sc.superior_id,
        sc.create_by,
        sc.create_time,
        sc.update_by,
        sc.update_time,
        sc.completion_description,
        sc.completion_images,
        sc.completion_videos,
        sc.completion_other_description,
        sc.completion_time,
        sc.completion_user_id,
        sc.completion_username,
        sc.completion_user_phone,
        sc.closing_time,
        sc.over_time_days,
        sc.latitude,
        sc.longitude,
        scar.audit_type,
        scar.audit_status,
        scar.comment,
        scar.images,
        scar.videos,
        scar.create_time AS reportTime,
@@ -121,15 +231,15 @@
        scar.department_name,
        scar.department_id,
        scar.comment,
        scar.create_time AS auditTime,
        scar.reject_reason,
        ifnull((select a.create_time from sgsb_complaint_audit_record a where a.audit_status != 0 and a.complaint_id = #{id} order by a.create_time desc limit 0, 1), "") AS auditTime,
        ifnull((select a.reject_reason from sgsb_complaint_audit_record a where a.audit_status != 0 and a.complaint_id = #{id} order by a.create_time desc limit 0, 1), "") as rejectReason,
        su.nick_name,
        su.phone,
        su2.nick_name AS auditorName,
        su2.phone AS auditorPhone
        ifnull((select b.nick_name from sgsb_complaint_audit_record a left join sys_user b on (a.create_by = b.user_id) where a.audit_status != 0 and a.complaint_id = #{id} order by a.create_time desc limit 0, 1), "") AS auditorName,
        ifnull((select b.phone from sgsb_complaint_audit_record a left join sys_user b on (a.create_by = b.user_id) where a.audit_status != 0 and a.complaint_id = #{id} order by a.create_time desc limit 0, 1), "") AS auditorPhone
        FROM sgsb_complaint sc
            LEFT JOIN sys_user su ON su.user_id = sc.create_by
                 LEFT JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id AND scar.latest_flag = 1
        LEFT JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1 and scar.superior_id = #{targetId}
        LEFT JOIN sys_user su2 ON su2.user_id = scar.auditor_id AND scar.audit_status != 0
        <where>
            sc.id = #{id}