From 86df207c37502cce1b2043e1c7c0486459eef1d6 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期四, 13 三月 2025 19:58:45 +0800
Subject: [PATCH] 党员、诉求评论基础代码

---
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java |   62 +++++++++++++++++++------------
 1 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
index 493c55b..e2233df 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
@@ -1,7 +1,6 @@
 package com.panzhihua.sangeshenbian.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -30,7 +29,6 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.panzhihua.sangeshenbian.model.vo.ComplaintVO;
 import com.panzhihua.sangeshenbian.service.ISystemUserService;
-import io.jsonwebtoken.lang.Collections;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Lazy;
@@ -92,7 +90,7 @@
 
         // 设置流水号
         complaint.setSerialNumber(serialNumber);
-        Optional<SystemUser> systemUserOpt = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
+        Optional<SystemUser> systemUserOpt = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone());
         Integer accountLevel = 5;
         Long superiorId = null;
         if (systemUserOpt.isPresent()) {
@@ -166,7 +164,7 @@
     public Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO loginUserInfoVO) {
         Page<ComplaintVO> page = new Page<>(query.getPageNum(), query.getPageSize());
         //判断当前登录用户级别,查询对应工单
-        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
+        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone());
         String targetId = "";
         int isSuperior = 0;
         Integer accountLevel = 5;
@@ -215,7 +213,7 @@
      */
     @Override
     public ComplaintVO detail(Long id, LoginUserInfoVO loginUserInfoVO) {
-        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
+        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone());
         String targetId = "";
         int isSuperior = 0;
         Integer accountLevel = 5;
@@ -371,6 +369,9 @@
         //complaint.setReportType(+);
         complaint.setSuperiorType(reportType);
         complaint.setSuperiorId(superiorId);
+        if (complaint.getStatus() != 0) {
+            complaint.setStatus(0);
+        }
         updateById(complaint);
 
         // 标记最新
@@ -441,9 +442,16 @@
         updateById(complaint);
         Long superiorOrgId = complaint.getSuperiorId();
         Integer superiorType = complaint.getSuperiorType();
-
+        //查询当前单位审核记录表数据
+        //查询上报审核记录
+        ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery()
+                .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())
+                .eq(ComplaintAuditRecord::getAuditType, 0)
+                .eq(ComplaintAuditRecord::getLatestFlag, true)
+                .eq(ComplaintAuditRecord::getReportType, adminUser.getAccountLevel())
+                .last("LIMIT 1").one();
         // 添加流转记录
-        complaintFlowService.createFlow(dto.getComplaintId(), superiorOrgId, superiorType, 1, loginUserInfoVO.getUserId());
+        complaintFlowService.createFlow(complaintAuditRecord, 1,loginUserInfoVO.getUserId());
 
         // 标记最新
         complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>()
@@ -469,7 +477,7 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void reportAudit(ComplaintReporAuditDTO complaintReporAuditDTO, LoginUserInfoVO loginUserInfoVO) {
-        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
+        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone());
         if (!systemUserByPhone.isPresent()) {
             throw new ServiceException("无权审核");
         }
@@ -499,6 +507,12 @@
                 .eq(ComplaintAuditRecord::getReportType, systemUser.getAccountLevel())
                 .eq(ComplaintAuditRecord::getSuperiorId, superiorId)
                 .last("LIMIT 1").one();
+        ComplaintAuditRecord lowLevelRecord = complaintAuditRecordService.lambdaQuery()
+                .eq(ComplaintAuditRecord::getComplaintId, complaintReporAuditDTO.getId())
+                .eq(ComplaintAuditRecord::getAuditType, 2)
+                .eq(ComplaintAuditRecord::getLatestFlag, true)
+                .eq(ComplaintAuditRecord::getReportType, systemUser.getAccountLevel()+1)
+                .last("LIMIT 1").one();
         if (Objects.isNull(complaintAuditRecord)) {
             throw new ServiceException("上报申请记录不存在");
         }
@@ -520,7 +534,7 @@
             record.setComplaintId(complaint.getId());
             record.setLatestFlag(true);
             record.setAuditorId(loginUserInfoVO.getUserId());
-            record.setAuditType(0);
+            record.setAuditType(2);
             record.setAuditStatus(1);
             record.setCreateBy(loginUserInfoVO.getUserId());
             record.setCreateTime(new Date());
@@ -531,14 +545,8 @@
             record.setSuperiorId(superiorId);
             record.setSort(count + 1);
             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());
-            }
-
+            //创建流程
+            complaintFlowService.createFlow(lowLevelRecord ,0, loginUserInfoVO.getUserId());
         } else {
 
             switch (systemUser.getAccountLevel() + 1) {
@@ -582,13 +590,13 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void saveDelay(ComplaintDelayDTO dto, LoginUserInfoVO loginUserInfoVO) {
-        SystemUser systemUser = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()).orElse(null);
+        SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()).orElse(null);
         Long superiorId;
         Long currentId;
         int reportType;
         if (systemUser == null) {
             superiorId = loginUserInfoVO.getCommunityId();
-            currentId = loginUserInfoVO.getCommunityId();
+            currentId = loginUserInfoVO.getUserId();
             if (Objects.isNull(superiorId)) {
                 throw new ServiceException("上报失败,请绑定社区");
             }
@@ -610,6 +618,9 @@
             } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
                 superiorId = 510400L; // 攀枝花市
                 currentId = Long.parseLong(systemUser.getDistrictsCode());
+            } else if (accountLevel == ReportTypeEnum.PARTY.getCode()) {
+                superiorId = systemUser.getCommunityId();
+                currentId = loginUserInfoVO.getUserId();
             } else {
                 // 处理未预期的账号等级
                 throw new ServiceException("未知的账号等级");
@@ -641,6 +652,7 @@
         record1.setReportType(Objects.isNull(systemUser) ? 5 : systemUser.getAccountLevel());
         record1.setSuperiorId(currentId);
         record1.setSort(count + 1);
+        record1.setComment(dto.getComment());
         complaintAuditRecordService.save(record1);
 
         ComplaintAuditRecord record2 = new ComplaintAuditRecord();
@@ -656,6 +668,7 @@
         record2.setReportType(reportType);
         record2.setSuperiorId(superiorId);
         record2.setSort(count + 2);
+        record1.setComment(dto.getComment());
         complaintAuditRecordService.save(record2);
     }
 
@@ -663,7 +676,7 @@
     @Override
     public void delayAudit(ComplaintDelayAuditDTO dto, LoginUserInfoVO loginUserInfoVO) {
 
-        SystemUser systemUser = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()).orElse(null);
+        SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()).orElse(null);
 
         int accountLevel = systemUser.getAccountLevel(); // 改为基本类型
         Long cunrrentId;
@@ -696,7 +709,7 @@
         //complaintAuditRecordService.audit(complaintAuditRecord, loginUserInfoVO.getUserId(),
         //        dto.getAuditResult(), dto.getRejectReason());
         //审核通过后,设置诉求延期
-        if (complaintAuditRecord.getAuditType().equals(1) && complaintAuditRecord.getAuditStatus().equals(1)) {
+        if (complaintAuditRecord.getAuditType().equals(1) && complaintAuditRecord.getAuditStatus().equals(0) && dto.getAuditResult().equals(1)) {
             Complaint complaint = getById(complaintAuditRecord.getComplaintId());
             complaint.setStatus(1);
             updateById(complaint);
@@ -710,9 +723,9 @@
         ComplaintAuditRecord record1 = new ComplaintAuditRecord();
         record1.setComplaintId(dto.getComplaintId());
         record1.setLatestFlag(true);
-        record1.setAuditType(2);
+        record1.setAuditType(1);
         record1.setAuditorId(loginUserInfoVO.getUserId());
-        record1.setAuditStatus(2);
+        record1.setAuditStatus(dto.getAuditResult());
         record1.setCreateBy(loginUserInfoVO.getUserId());
         record1.setCreateTime(new Date(System.currentTimeMillis()));
         record1.setUpdateBy(loginUserInfoVO.getUserId());
@@ -721,6 +734,7 @@
         record1.setReportType(complaintAuditRecord.getReportType());
         record1.setSuperiorId(complaintAuditRecord.getSuperiorId());
         record1.setSort(count + 1);
+        record1.setRejectReason(dto.getRejectReason());
         complaintAuditRecordService.save(record1);
 
     }
@@ -788,7 +802,7 @@
      */
     @Override
     public Page<ComplaintTodoVO> getTodoList(BasePage basePage, LoginUserInfoVO loginUserInfo) {
-        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfo.getPhone());
+        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfo.getPhone());
         String targetId = "";
         int isSuperior = 0;
         //上级

--
Gitblit v1.7.1