From d99aad4524f70b62401c135f946bda5696c702cb Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 29 五月 2025 21:36:25 +0800
Subject: [PATCH] 小程序接口修改

---
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/controller/ComplaintController.java    |   33 ++
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/api/SystemUserController.java          |   19 +
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintDispatch.java       |    2 
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/IComplaintService.java         |   16 +
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/SystemUser.java           |    6 
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/resources/mapper/ComplaintMapper.xml                                    |  322 ++++++++++++++++++++++++
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/dao/ComplaintMapper.java               |   15 +
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java |  278 +++++++++++++++------
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintReporAuditDTO.java  |    3 
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/Complaint.java            |   25 +
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/ComplaintVO.java              |    3 
 springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/SysUserVO.java                |   14 +
 12 files changed, 643 insertions(+), 93 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/api/SystemUserController.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/api/SystemUserController.java
index 46ca03d..0342827 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/api/SystemUserController.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/api/SystemUserController.java
@@ -1,6 +1,7 @@
 package com.panzhihua.westcommittee.api;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.panzhihua.common.controller.BaseController;
 import com.panzhihua.common.interfaces.OperLog;
@@ -19,6 +20,7 @@
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.BeanUtils;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.util.ObjectUtils;
@@ -304,6 +306,23 @@
 		return R.ok();
 	}
 
+	@PostMapping("/setDeptAdmin")
+	@ApiOperation(value = "设置单位管理员", tags = {"西区纪委后台-人员管理"})
+	@OperLog(operModul = "西区纪委后台",operType = 2,businessType = "设置单位管理员")
+	public R setDeptAdmin(@RequestParam(name = "id",value = "用户id",required = true) Integer id, @RequestParam(name = "deptId",value = "单位id",required = true) Integer deptId){
+		SystemUser systemUser = systemUserService.getById(id);
+		if(!systemUser.getOneDepartmentId().equals(deptId)){
+			return R.fail("不能设置非所属单位管理员为单位管理员");
+		}
+		boolean update = systemUserService.update(new LambdaUpdateWrapper<SystemUser>().eq(SystemUser::getIsDeptAdmin, deptId).set(SystemUser::getIsDeptAdmin, 0));
+		if(update){
+			systemUser.setIsDeptAdmin(1);
+			systemUserService.updateById(systemUser);
+			return R.ok();
+		}
+		return R.fail("设置失败");
+	}
+
 
 	@PutMapping("/unfreeze/{id}")
 	@ApiOperation(value = "解冻账号", tags = {"西区纪委后台-人员管理"})
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/controller/ComplaintController.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/controller/ComplaintController.java
index a0980ac..56238ce 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/controller/ComplaintController.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/controller/ComplaintController.java
@@ -8,15 +8,15 @@
 import com.panzhihua.westcommittee.annotation.DistributedLock;
 import com.panzhihua.westcommittee.model.dto.*;
 import com.panzhihua.westcommittee.model.entity.*;
+import com.panzhihua.westcommittee.model.query.BasePage;
 import com.panzhihua.westcommittee.model.query.ComplaintQuery;
 import com.panzhihua.westcommittee.model.vo.ComplaintVO;
 import com.panzhihua.westcommittee.model.vo.DispatchVO;
+import com.panzhihua.westcommittee.model.vo.SysUserVO;
 import com.panzhihua.westcommittee.service.IComplaintCommentService;
 import com.panzhihua.westcommittee.service.IComplaintService;
 import com.panzhihua.westcommittee.service.IProblemTypeService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.validation.annotation.Validated;
@@ -174,7 +174,7 @@
      * 上报审核
      */
     @PostMapping("/reportAudit")
-    @ApiOperation(value = "问题上报审核")
+    @ApiOperation(value = "问题上报审核并指派")
     public R<?> reportAudit(@RequestBody ComplaintReporAuditDTO dto) {
         complaintService.reportAudit(dto, getLoginUserInfo());
         return R.ok();
@@ -188,8 +188,29 @@
     public R<List<DispatchVO>> getDispatchList() {
         return R.ok(complaintService.getDispatchList(getLoginUserInfo()));
     }
-    
-    
+
+
+
+    @GetMapping("/getDeptUserList")
+    @ApiOperation(value = "获取当前单位用户列表")
+    public R<Page<SysUserVO>> getDeptUserList(BasePage page) {
+        return R.ok(complaintService.getDeptUserList(getLoginUserInfo(),page));
+    }
+
+
+
+    @PostMapping("/assignComplain")
+    @ApiOperation(value = "分配诉求")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "complainId", value = "诉求id", required = true),
+            @ApiImplicitParam(name = "userId", value = "单位id", required = true)
+    })
+    public R<?> assignComplain(@RequestParam Long complainId,@RequestParam Integer deptId) {
+        complaintService.assignComplain(getLoginUserInfo(),complainId,deptId);
+        return R.ok();
+    }
+
+
     /**
      * 评价诉求
      * @param complaintComment
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/dao/ComplaintMapper.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/dao/ComplaintMapper.java
index 2c361a7..09d2b03 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/dao/ComplaintMapper.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/dao/ComplaintMapper.java
@@ -46,6 +46,10 @@
 
 
 
+    Page<ComplaintVO> selectComplaintPage2(@Param("page") Page<ComplaintVO> page, @Param("query") ComplaintQuery query, @Param("accountLevel") Integer accountLevel, @Param("targetId") Long targetId);
+
+
+
     /**
      *  工单详情
      * @param id
@@ -110,4 +114,15 @@
     List<Complaint> getStatusForList(@Param("ids") List<Long> ids);
 
 
+    Page<ComplaintVO> selectComplaintPage3(@Param("page") Page<ComplaintVO> page, @Param("query") ComplaintQuery query, @Param("accountLevel") Integer accountLevel, @Param("targetId") Long targetId);
+
+
+    Page<ComplaintVO> selectComplaintPage4(@Param("page") Page<ComplaintVO> page, @Param("query") ComplaintQuery query, @Param("oneDepartmentId") Integer oneDepartmentId);
+
+
+    Page<ComplaintVO> selectComplaintPage5(@Param("page") Page<ComplaintVO> page, @Param("query") ComplaintQuery query,  @Param("streetId") String streetId,@Param("ids") List<Integer> ids);
+
+
+    Page<ComplaintVO> selectComplaintPage6(@Param("page") Page<ComplaintVO> page, @Param("query") ComplaintQuery query, @Param("communityId") Long communityId, @Param("ids") List<Integer> ids);
+
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintDispatch.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintDispatch.java
index 3902e07..93ba5ca 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintDispatch.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintDispatch.java
@@ -11,7 +11,7 @@
     private Long complaintId;
 
     @ApiModelProperty(value = "单位id")
-    private Long dispatchId; // TODO 待实现
+    private Long dispatchId;
 
     @ApiModelProperty(value = "内容")
     private String comment;
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintReporAuditDTO.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintReporAuditDTO.java
index a371b96..47626a5 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintReporAuditDTO.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/dto/ComplaintReporAuditDTO.java
@@ -13,4 +13,7 @@
 
     @ApiModelProperty(value = "驳回原因")
     private String rejectReason;
+
+    @ApiModelProperty(value = "通过需要指派单位")
+    private Integer deptId;
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/Complaint.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/Complaint.java
index bc6df59..78afb28 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/Complaint.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/Complaint.java
@@ -90,7 +90,7 @@
     @TableField("videos")
     private String videos;
 
-    @ApiModelProperty(value = "流转状态:0-正在办理 1-延期办理 2-超时办理 3-已办结 4-群众撤销 5-上报待审核 6-上级驳回 7-延期待审核 8-已评价 9-延期驳回")
+    @ApiModelProperty(value = "流转状态: -2待审核 -1待分配 0-正在办理 1-延期办理 2-超时办理 3-已办结 4-群众撤销 5-上报待审核 6-上级驳回 7-延期待审核 8-已评价 9-延期驳回")
     @TableField("status")
     private Integer status;
 
@@ -211,4 +211,27 @@
     @ApiModelProperty(value = "评价")
     @TableField("comment_rate")
     private Integer commentRate;
+
+    @ApiModelProperty(value = "处理人id")
+    @TableField("handle_user_id")
+    private Integer handleUserId;
+
+    @ApiModelProperty(value = "分配人id")
+    @TableField("assign_person_id")
+    private Integer assignPersonId;
+
+    @ApiModelProperty(value = "分配状态 0待分配 1已分配")
+    @TableField("assign_status")
+    private Integer assignStatus;
+
+    /**
+     * 用于用户提交后续是否处理
+     */
+    @TableField("first_status")
+    @ApiModelProperty(value = "0未处理 1已处理")
+    private Integer firstStatus;
+
+    @TableField("now_level")
+    @ApiModelProperty(value = "当前层级")
+    private Integer nowLevel;
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/SystemUser.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/SystemUser.java
index dfdae04..edecf12 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/SystemUser.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/entity/SystemUser.java
@@ -141,6 +141,12 @@
 	@TableField("create_time")
 	private LocalDateTime createTime;
 
+	/**
+	 * 是否是单位理员(0=否,1=是)
+	 */
+	@TableField("is_dept_admin")
+	private Integer isDeptAdmin;
+
 
 	@TableField(exist = false)
 	private Integer levelId;
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/ComplaintVO.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/ComplaintVO.java
index 6b9abb1..61dde92 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/ComplaintVO.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/ComplaintVO.java
@@ -100,5 +100,8 @@
     @ApiModelProperty(value = "已上报次数")
     private Integer reportCount;
 
+    @ApiModelProperty(value = "0待分配 1已分配")
+    private Integer assignStatus;
+
 
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/SysUserVO.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/SysUserVO.java
new file mode 100644
index 0000000..f4cf93c
--- /dev/null
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/model/vo/SysUserVO.java
@@ -0,0 +1,14 @@
+package com.panzhihua.westcommittee.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel("单位分配用户")
+public class SysUserVO {
+    @ApiModelProperty(value = "用户id")
+    private Integer id;
+    @ApiModelProperty(value = "用户名称")
+    private String name;
+}
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/IComplaintService.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/IComplaintService.java
index 887cbc2..4810525 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/IComplaintService.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/IComplaintService.java
@@ -220,4 +220,20 @@
      * @return
      */
     List<Complaint> queryCompliantList(AppStaticsQuery query, LoginUserInfoVO loginUserInfo);
+
+    /**
+     * 获取单位用户列表
+     * @param loginUserInfo
+     * @return
+     */
+    Page<SysUserVO> getDeptUserList(LoginUserInfoVO loginUserInfo,BasePage page);
+
+    /**
+     * 分配诉求
+     * @param loginUserInfo
+     * @param complainId
+     * @param userId
+     */
+    void assignComplain(LoginUserInfoVO loginUserInfo, Long complainId, Integer userId);
+
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java
index 2e3f188..93d7a21 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java
@@ -4,6 +4,7 @@
 import cn.hutool.core.collection.CollUtil;
 import cn.idev.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -77,6 +78,7 @@
     private final HttpServletResponse response;
     private final IPartyMemberService partyMemberService;
     private final IdentityInformationService identityInformationService;
+    private final IDepartmentService departmentService;
     private final RedisUtils redisUtils;
 
     @Override
@@ -110,8 +112,7 @@
         SystemUser systemUser = identityInformationVO.getSystemUser();
         Integer identity = identityInformationVO.getIdentity();
         if (identity == 2) {
-            SystemUserLevel systemUserLevel = identityInformationVO.getSystemUserLevel();
-            accountLevel = systemUserLevel.getLevel();
+            accountLevel = systemUser.getAccountLevel();
             switch (accountLevel) {
                 case 1:
                     //市级
@@ -122,39 +123,57 @@
                 case 2:
                     //区县级
                     complaint.setCityCode(510400);
-                    complaint.setDistrictsCode(Integer.valueOf(systemUserLevel.getDistrictsCode()));
+                    complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode()));
                     complaint.setReportUserName(systemUser.getName());
                     complaint.setReportUserPhone(systemUser.getPhone());
+
+
+                    complaint.setSuperiorId(Long.valueOf(systemUser.getDistrictsCode()));
                     break;
                 case 3:
                     //街道
                     complaint.setCityCode(510400);
-                    complaint.setDistrictsCode(Integer.valueOf(systemUserLevel.getDistrictsCode()));
-                    complaint.setStreetId(Long.valueOf(systemUserLevel.getStreetId()));
+                    complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode()));
+                    complaint.setStreetId(Long.valueOf(systemUser.getStreetId()));
                     complaint.setReportUserName(systemUser.getName());
                     complaint.setReportUserPhone(systemUser.getPhone());
+
+                    complaint.setSuperiorId(Long.valueOf(systemUser.getStreetId()));
                     break;
                 case 4:
                     //社区
                     complaint.setCityCode(510400);
-                    complaint.setDistrictsCode(Integer.valueOf(systemUserLevel.getDistrictsCode()));
-                    complaint.setStreetId(Long.valueOf(systemUserLevel.getStreetId()));
-                    complaint.setCommunityId(systemUserLevel.getCommunityId());
+                    complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode()));
+                    complaint.setStreetId(Long.valueOf(systemUser.getStreetId()));
+                    complaint.setCommunityId(systemUser.getCommunityId());
                     complaint.setReportUserName(systemUser.getName());
                     complaint.setReportUserPhone(systemUser.getPhone());
+
+                    complaint.setSuperiorId(systemUser.getCommunityId());
                     break;
                 case 5:
                     //党员
                     complaint.setCityCode(510400);
-                    complaint.setDistrictsCode(Integer.valueOf(systemUserLevel.getDistrictsCode()));
-                    complaint.setStreetId(Long.valueOf(systemUserLevel.getStreetId()));
-                    complaint.setCommunityId(systemUserLevel.getCommunityId());
+                    complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode()));
+                    complaint.setStreetId(Long.valueOf(systemUser.getStreetId()));
+                    complaint.setCommunityId(systemUser.getCommunityId());
                     PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone());
                     complaint.setPartyMemberId(partyMember.getId());
                     complaint.setReportUserName(partyMember.getName());
                     complaint.setReportUserPhone(partyMember.getPhone());
+
+                    accountLevel=4;
+                    complaint.setSuperiorId(systemUser.getCommunityId());
                     break;
             }
+
+            // 判断该单位的管理员 添加处理人
+//            Integer oneDepartmentId = systemUser.getOneDepartmentId();
+//            SystemUser oneDepartmentSystemUser = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getOneDepartmentId,oneDepartmentId).eq(SystemUser::getIsDeptAdmin,1).ne(SystemUser::getStatus,3));
+//            if(null != oneDepartmentSystemUser){
+//                complaint.setAssignPersonId(oneDepartmentSystemUser.getId());
+//                complaint.setHandleUserId(oneDepartmentSystemUser.getId());
+//            }
         } else {
             PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone());
             //党员
@@ -165,8 +184,19 @@
             complaint.setPartyMemberId(partyMember.getId());
             complaint.setReportUserName(partyMember.getName());
             complaint.setReportUserPhone(partyMember.getPhone());
+
+            // 添加处理人
+//            SystemUser one = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getAccountLevel, 4).eq(SystemUser::getIsDeptAdmin, 1).eq(SystemUser::getCommunityId, partyMember.getCommunityId()).ne(SystemUser::getStatus, 3));
+//            if (null != one) {
+//                complaint.setAssignPersonId(one.getId());
+//                complaint.setHandleUserId(one.getId());
+//            }
+
+
         }
         complaint.setReportType(accountLevel);
+        complaint.setNowLevel(accountLevel);
+
         // 设置其他字段
         complaint.setStatus(ProcessStatusEnum.PROCESSING.getCode());
         complaint.setCreateTime(new Date(System.currentTimeMillis()));
@@ -211,7 +241,7 @@
     @Override
     public Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO loginUserInfoVO) {
 
-
+        // 已分派了的
         Page<ComplaintVO> page = new Page<>(query.getPageNum(), query.getPageSize());
         //判断当前登录用户级别,查询对应工单
         Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone());
@@ -221,53 +251,79 @@
         IdentityInformation identityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfoVO);
         Integer identity = identityInformation.getIdentity();
         query.setUserId(loginUserInfoVO.getUserId());
+
+        SystemUser systemUser = null;
         //上级
         if (systemUserByPhone.isPresent() && null != identity && identity == 2) {
-            SystemUser systemUser = systemUserByPhone.get();
-            SystemUserLevel systemUserLevel = identityInformation.getSystemUserLevel();
-            accountLevel = systemUserLevel.getLevel();
+          systemUserByPhone.get();
+            accountLevel = systemUser.getAccountLevel();
             switch (accountLevel) {
-                case 1:
-                    //市级
-                    targetId = 510400L;
-                    break;
                 case 2:
                     //区县级
-                    targetId = Long.valueOf(systemUserLevel.getDistrictsCode());
+                    targetId = Long.valueOf(systemUser.getDistrictsCode());
                     break;
                 case 3:
                     //街道
-                    targetId = Long.valueOf(systemUserLevel.getStreetId());
+                    targetId = Long.valueOf(systemUser.getStreetId());
                     break;
                 case 4:
                     //社区
-                    targetId = systemUserLevel.getCommunityId();
+                    targetId = systemUser.getCommunityId();
                     break;
                 case 5:
                     //党员
                     PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone());
-                    targetId = partyMember.getId();
+                    targetId = partyMember.getCommunityId();
                     break;
             }
         } else {
             //党员
             PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone());
-            targetId = partyMember.getId();
+            targetId = partyMember.getCommunityId();
         }
         //查询对应诉求
         //page = baseMapper.selectComplaintPage(page, query, targetId, isSuperior);
-        page = baseMapper.selectComplaintPage1(page, query, accountLevel, targetId);
-
-     /*   for (ComplaintVO s : page.getRecords()) {
-            buttonPermission(s, systemUserByPhone, loginUserInfoVO);
-            Integer auditButtonStatus = s.getAuditButtonStatus();
-
-            Long reporterId = s.getReporterId();
-            Long superiorId = s.getSuperiorId2();
-            if (!targetId.equals(reporterId) && !targetId.equals(superiorId) && (s.getStatus() == 5)) {
-                s.setStatus(0);
+        // 党员只看自己上报的
+        if(accountLevel==5){
+            page =  baseMapper.selectComplaintPage2(page, query, accountLevel, targetId);
+        }else if(accountLevel==2){
+            // 西区单位  如果是西区单位,则只看自己上报的
+            if(systemUser.getSystemRoleId()==1){
+                // 是管理员 看所有的
+                page =  baseMapper.selectComplaintPage3(page, query, accountLevel, targetId);
+            }else {
+                // 不是管理员 看到指派给我的单位的诉求
+                page =  baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId());
             }
-        }*/
+        }else if(accountLevel==3){
+            // 街道 1
+            if(systemUser.getSystemRoleId()==1){
+                // 获取街道的所有单位
+                List<Department> list = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getTier, 3).eq(Department::getStreetId, systemUser.getStreetId()));
+                if(list.isEmpty()){
+                    return page;
+                }
+                // 是管理员 可以看到下派来的  也可以看到上派待审核的
+                page =  baseMapper.selectComplaintPage5(page, query,systemUser.getStreetId(),list.stream().map(Department::getId).collect(Collectors.toList()));
+            }else {
+                // 不是管理员 看指派给我的
+                page =  baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId());
+            }
+        }else if(accountLevel==4){
+            // 社区
+            if(systemUser.getSystemRoleId()==1){
+                List<Department> list = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getTier, 4).eq(Department::getCommunityId, systemUser.getCommunityId()));
+                if(list.isEmpty()){
+                    return page;
+                }
+                // 是管理员
+                page =  baseMapper.selectComplaintPage6(page, query,systemUser.getCommunityId(),list.stream().map(Department::getId).collect(Collectors.toList()));
+            }else {
+                // 不是管理员 看到负责社区的所有诉求  和 上级下派来的诉求
+                page =  baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId());
+
+            }
+        }
         return page;
     }
 
@@ -682,7 +738,6 @@
         String phone = loginUserInfoVO.getPhone();
         IdentityInformation identityInformationVO = identityInformationService.getCurrentIdentityInformation(loginUserInfoVO);
         SystemUser adminUser = identityInformationVO.getSystemUser();
-        SystemUserLevel systemUserLevel = identityInformationVO.getSystemUserLevel();
 
         Long superiorId;
         int reportType;
@@ -690,6 +745,7 @@
         Long reporterId = null;
         String departmentName = "";
         String reporter = "";
+        int nowLevel=0;
         if (identityInformationVO.getIdentity() == 1) {
             PartyMember partyMember = partyMemberService.getPartyMemberByPhone(phone);
             superiorId = partyMember.getCommunityId();
@@ -698,10 +754,13 @@
             reporterLevel = 5;
             departmentName = partyMember.getDistricts() + "-" + partyMember.getStreet() + "-" + partyMember.getCommunity();
             reporter = partyMember.getName();
+            // 找到当前社区上一级人
+            nowLevel = 3;
+
         } else if (identityInformationVO.getIdentity() == 2) {
-            int accountLevel = systemUserLevel.getLevel(); // 改为基本类型
-            if (accountLevel == 1) {
-                throw new ServiceException("市级账号,无法上报!");
+            int accountLevel = adminUser.getAccountLevel(); // 改为基本类型
+            if (accountLevel == 2) {
+                throw new ServiceException("区级账号,无法上报!");
             }
             reportType = accountLevel - 1;
             reporterLevel = accountLevel;
@@ -709,16 +768,14 @@
 
             // 使用基本类型比较并补充默认分支
             if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) {
-                superiorId = Long.parseLong(systemUserLevel.getStreetId());
-                reporterId = systemUserLevel.getCommunityId();
+                superiorId = Long.parseLong(adminUser.getStreetId());
+                reporterId = adminUser.getCommunityId();
+                nowLevel = 3;
+
             } else if (accountLevel == ReportTypeEnum.STREET.getCode()) {
-                superiorId = Long.parseLong(systemUserLevel.getDistrictsCode());
-                reporterId = Long.parseLong(systemUserLevel.getStreetId());
-            } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
-                superiorId = 510400L; // 攀枝花市
-                reporterId = Long.parseLong(systemUserLevel.getDistrictsCode());
-            } else if (accountLevel == ReportTypeEnum.PARTY.getCode()) {
-                superiorId = systemUserLevel.getCommunityId();
+                superiorId = Long.parseLong(adminUser.getDistrictsCode());
+                reporterId = Long.parseLong(adminUser.getStreetId());
+                nowLevel = 2;
             } else {
                 // 处理未预期的账号等级
                 throw new ServiceException("未知的账号等级");
@@ -726,20 +783,20 @@
             //查询社区信息
             switch (accountLevel) {
                 case 2:
-                    BcRegion region = bcRegionService.getDistrictByCode(systemUserLevel.getDistrictsCode().toString());
+                    BcRegion region = bcRegionService.getDistrictByCode(adminUser.getDistrictsCode().toString());
                     if (Objects.nonNull(region)) {
                         departmentName = region.getRegionName();
                     }
                     break;
                 case 3:
-                    ComStreet street = comStreetService.getById(systemUserLevel.getStreetId().toString());
+                    ComStreet street = comStreetService.getById(adminUser.getStreetId().toString());
                     if (Objects.nonNull(street)) {
                         BcRegion district = bcRegionService.getDistrictByCode(street.getAreaCode().toString());
                         departmentName = Objects.nonNull(district) ? district.getRegionName() + "-" + street.getName() : street.getName();
                     }
                     break;
                 case 4:
-                    ComAct act = comActService.getById(systemUserLevel.getCommunityId());
+                    ComAct act = comActService.getById(adminUser.getCommunityId());
                     if (Objects.nonNull(act)) {
                         ComStreet street2 = comStreetService.getById(adminUser.getStreetId().toString());
                         BcRegion district = bcRegionService.getDistrictByCode(act.getAreaCode());
@@ -756,6 +813,9 @@
         if (complaint.getStatus() != 0) {
             complaint.setStatus(0);
         }
+        complaint.setSuperiorId(superiorId);
+        complaint.setNowLevel(nowLevel);
+        complaint.setAssignStatus(0);
         updateById(complaint);
 
         // 标记最新
@@ -829,13 +889,12 @@
         if (identityInformation.getIdentity() != 2) {
             throw new ServiceException("无权下派");
         }
+        SystemUser systemUser = identityInformation.getSystemUser();
 
-        SystemUserLevel systemUserLevel = identityInformation.getSystemUserLevel();
-        int accountLevel = systemUserLevel.getLevel(); // 改为基本类型
+        int accountLevel = systemUser.getAccountLevel(); // 改为基本类型
         if (accountLevel == 4) {
             throw new ServiceException("社区账号,无法下派!");
         }
-        accountLevel++;
 
         Complaint complaint = getById(dto.getComplaintId());
         //查询当前单位审核记录表数据
@@ -869,22 +928,31 @@
         complaintAuditRecordService.save(record);
         ComplaintAuditRecord complaintAuditRecord = new ComplaintAuditRecord();
         complaintAuditRecord.setComplaintId(complaint.getId());
-        complaintAuditRecord.setReportType(systemUserLevel.getLevel());
+        complaintAuditRecord.setReportType(systemUser.getAccountLevel());
         Long superiorId = null;
-        switch (systemUserLevel.getLevel()) {
+        int nowLevel=0;
+
+        switch (systemUser.getAccountLevel()) {
             case 1:
                 superiorId = 510400L;//默认市级
                 break;
             case 2:
-                superiorId = Long.parseLong(systemUserLevel.getDistrictsCode());
+                superiorId = Long.parseLong(systemUser.getStreetId());
+                nowLevel=3;
                 break;
             case 3:
-                superiorId = Long.parseLong(systemUserLevel.getStreetId());
+                superiorId = systemUser.getCommunityId();
+                nowLevel=4;
                 break;
             case 4:
-                superiorId = systemUserLevel.getCommunityId();
+                superiorId = systemUser.getCommunityId();
                 break;
         }
+        complaint.setSuperiorId(superiorId);
+        complaint.setAssignStatus(0);
+        complaint.setNowLevel(nowLevel);
+        this.updateById(complaint);
+
         complaintAuditRecord.setSuperiorId(superiorId);
         complaintFlowService.createFlow(complaintAuditRecord, 1, loginUserInfoVO.getUserId());
     }
@@ -917,6 +985,8 @@
                 break;
         }
 
+
+
         //查询上报审核记录
         ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery()
                 .eq(ComplaintAuditRecord::getComplaintId, complaintReporAuditDTO.getId())
@@ -931,6 +1001,7 @@
         complaintAuditRecord.setAuditorName(systemUser.getName());
         complaintAuditRecord.setAuditorPhone(systemUser.getPhone());
         complaintAuditRecord.setAuditTime(new Date());
+
         if (complaintReporAuditDTO.getAuditResult().equals(1)) {
             complaintAuditRecord.setAuditStatus(1);
             complaintAuditRecord.setAuditorId(loginUserInfoVO.getUserId());
@@ -941,6 +1012,14 @@
             complaintAuditRecord2.setSuperiorId(complaintAuditRecord.getReporterId());
             complaintAuditRecord2.setReportType(complaintAuditRecord.getReporterLevel());
             complaintFlowService.createFlow(complaintAuditRecord2, 0, loginUserInfoVO.getUserId());
+
+            // 通过修改状态
+            Complaint complaint = this.getById(complaintReporAuditDTO.getId());
+            complaint.setAssignPersonId(complaintReporAuditDTO.getDeptId());
+            complaint.setAssignStatus(1);
+            this.updateById(complaint);
+
+
         } else {
             complaintAuditRecord.setRejectReason(complaintReporAuditDTO.getRejectReason());
             complaintAuditRecord.setAuditStatus(2);
@@ -972,8 +1051,8 @@
             reporter = partyMember.getName();
         } else if (identityInformation.getIdentity() == 2) {
             int accountLevel = systemUserLevel.getLevel(); // 改为基本类型
-            if (accountLevel == 1) {
-                throw new ServiceException("市级账号,无法延期申请!");
+            if (accountLevel == 2) {
+                throw new ServiceException("区级账号,无法延期申请!");
             }
             reportType = accountLevel - 1;
             reporter = systemUser.getName();
@@ -1119,12 +1198,11 @@
         IdentityInformation identityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfoVO);
 
         SystemUser adminUser = identityInformation.getSystemUser();
-        SystemUserLevel systemUserLevel = identityInformation.getSystemUserLevel();
 
         if (identityInformation.getIdentity() != 2) {
             throw new ServiceException("无权下派");
         }
-        int accountLevel = systemUserLevel.getLevel(); // 改为基本类型
+        int accountLevel = adminUser.getAccountLevel(); // 改为基本类型
       /*  if (accountLevel == 1) {
             throw new ServiceException("市级账号,无法上报!");
         }*/
@@ -1132,30 +1210,20 @@
         // 使用基本类型比较并补充默认分支
         List<DispatchVO> dispatchVOList = new ArrayList<>();
         if (accountLevel == ReportTypeEnum.STREET.getCode()) {
-            String streetId = systemUserLevel.getStreetId();
-            List<ComAct> list = comActService.list(new LambdaQueryWrapper<ComAct>().eq(ComAct::getStreetId, streetId));
-            for (ComAct comAct : list) {
+            // 社区的单位
+            List<Department> list1 = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getTier, 4));
+            for (Department department : list1) {
                 DispatchVO dispatchVO = new DispatchVO();
-                dispatchVO.setId(comAct.getCommunityId().toString());
-                dispatchVO.setName(comAct.getName());
+                dispatchVO.setId(department.getCommunityId().toString());
+                dispatchVO.setName(department.getName());
                 dispatchVOList.add(dispatchVO);
             }
         } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
-            String districtsCode = systemUserLevel.getDistrictsCode();
-            List<ComStreet> list = comStreetService.list(new LambdaQueryWrapper<ComStreet>().eq(ComStreet::getAreaCode, districtsCode));
-            for (ComStreet street : list) {
+            List<Department> list1 = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getTier, 3));
+            for (Department department : list1) {
                 DispatchVO dispatchVO = new DispatchVO();
-                dispatchVO.setId(street.getStreetId().toString());
-                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).eq(BcRegion::getParentId, 510400));//获取攀枝花市下的区县
-            for (BcRegion region : list) {
-                DispatchVO dispatchVO = new DispatchVO();
-                dispatchVO.setId(region.getRegionCode());
-                dispatchVO.setName(region.getRegionName());
+                dispatchVO.setId(department.getCommunityId().toString());
+                dispatchVO.setName(department.getName());
                 dispatchVOList.add(dispatchVO);
             }
         } else {
@@ -1727,5 +1795,51 @@
         }
         return baseMapper.queryCompliantList(targetId, accountLevel, loginUserInfo, query);
     }
+
+
+    @Override
+    public Page<SysUserVO> getDeptUserList(LoginUserInfoVO loginUserInfo,BasePage page) {
+        IdentityInformation currentIdentityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo);
+        if (currentIdentityInformation.getIdentity().equals(2)) {
+            SystemUser systemUser = currentIdentityInformation.getSystemUser();
+            if(systemUser.getIsDeptAdmin()==0){
+                throw new ServiceException("你没有分配权限");
+            }
+
+            Page<SysUserVO> sysUserVOPage = new Page<>();
+            ArrayList<SysUserVO> sysUserVOS = new ArrayList<>();
+
+            Page<SystemUser> page1 = systemUserService.page(new Page<>(page.getPageNum(), page.getPageSize()), new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getOneDepartmentId, systemUser.getOneDepartmentId()).ne(SystemUser::getId,systemUser.getId()).ne(SystemUser::getStatus, 3));
+            for (SystemUser record : page1.getRecords()) {
+                SysUserVO sysUserVO = new SysUserVO();
+                sysUserVO.setId(record.getId());
+                sysUserVO.setName(record.getName());
+                sysUserVOS.add(sysUserVO);
+            }
+            sysUserVOPage.setRecords(sysUserVOS);
+            BeanUtils.copyProperties(page1,sysUserVOPage);
+            return sysUserVOPage;
+        }else {
+            throw new ServiceException("你没有分配权限");
+        }
+    }
+
+
+    @Override
+    public void assignComplain(LoginUserInfoVO loginUserInfo, Long complainId, Integer userId) {
+        IdentityInformation currentIdentityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo);
+        if (currentIdentityInformation.getIdentity().equals(2)) {
+            SystemUser systemUser = currentIdentityInformation.getSystemUser();
+            Complaint complaint = baseMapper.selectById(complainId);
+            // 已分配状态
+            complaint.setAssignPersonId(userId);
+            complaint.setFirstStatus(1);
+            complaint.setAssignStatus(1);
+        }else {
+            throw new ServiceException("你没有分配权限");
+        }
+
+    }
+
 }
 
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/resources/mapper/ComplaintMapper.xml b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/resources/mapper/ComplaintMapper.xml
index 6dd0cde..3cda500 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/resources/mapper/ComplaintMapper.xml
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/resources/mapper/ComplaintMapper.xml
@@ -136,9 +136,6 @@
         FROM west_complaint sc
         LEFT JOIN west_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1
         <where>
-            <if test="1 == accountLevel">
-                and sc.city_code = #{targetId}
-            </if>
             <if test="2 == accountLevel">
                 and (sc.districts_code = #{targetId} OR sc.id in (select complaint_id from west_complaint_audit_record where audit_type = 3 and audit_status = 1 and report_type = #{accountLevel} and superior_id = #{targetId}))
             </if>
@@ -798,4 +795,323 @@
         </foreach>
 
     </select>
+
+
+    <select id="selectComplaintPage2" resultType="com.panzhihua.westcommittee.model.vo.ComplaintVO">
+        select * from (
+        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 sc.first_status = 1 and sc.status != 3 and sc.status != 8 and sc.first_status=1 THEN 0
+        WHEN sc.first_status = 1 and sc.status = 8 THEN 3
+        WHEN sc.first_status = 0 THEN -2
+        ELSE sc.status
+        END AS status,
+        CASE
+        WHEN sc.status = 8  THEN 1
+        ELSE 0
+        END AS evaluateButtonStatus,
+        sc.report_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.reporter_level,
+        scar.comment,
+        scar.create_time AS reportTime,
+        scar.system_user_id,
+        scar.create_by as auditCreateBy,
+        scar.reporter,
+        scar.reporter_id,
+        scar.superior_id superiorId2,
+        scar.department_name,
+        scar.department_id
+        FROM west_complaint sc
+        LEFT JOIN west_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1
+        WHERE sc.create_by =#{query.userId}
+        ) as t1
+        <if test="query.status !=null">
+            and t1.status = #{query.status}
+        </if>
+        ORDER BY t1.create_time DESC
+    </select>
+    <select id="selectComplaintPage3" resultType="com.panzhihua.westcommittee.model.vo.ComplaintVO">
+select * from (
+        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 sc.assign_status = 0 THEN -1
+            WHEN sc.status = 0 and scar.audit_type = 1 AND scar.audit_status = 0 THEN 7
+            WHEN sc.status = 0 and scar.audit_type = 2 AND scar.audit_status = 0 THEN 5
+            WHEN sc.status = 0 and scar.audit_status = 2 and scar.audit_type = 2 THEN 6
+            ELSE sc.status
+            END AS status,
+        sc.report_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.reporter_level,
+        scar.comment,
+        scar.create_time AS reportTime,
+        scar.system_user_id,
+        scar.create_by as auditCreateBy,
+        scar.reporter,
+        scar.reporter_id,
+        scar.superior_id superiorId2,
+        scar.department_name,
+        scar.department_id,
+        sc.assign_status AS assignStatus
+        FROM west_complaint sc
+        LEFT JOIN west_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1
+              ) as t1
+        <if test="query.status !=null">
+            and t1.status = #{query.status}
+        </if>
+        ORDER BY t1.create_time DESC
+    </select>
+    <select id="selectComplaintPage5" resultType="com.panzhihua.westcommittee.model.vo.ComplaintVO">
+        select * from (
+        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 sc.assign_status = 0  THEN -1
+            WHEN sc.status = 0 and scar.audit_type = 1 AND scar.audit_status = 0 THEN 7
+            WHEN sc.status = 0 and scar.audit_type = 2 AND scar.audit_status = 0 THEN 5
+            WHEN sc.status = 0 and scar.audit_status = 2 and scar.audit_type = 2 THEN 6
+            ELSE sc.status
+        END AS status,
+        sc.report_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.reporter_level,
+        scar.comment,
+        scar.create_time AS reportTime,
+        scar.system_user_id,
+        scar.create_by as auditCreateBy,
+        scar.reporter,
+        scar.reporter_id,
+        scar.superior_id superiorId2,
+        scar.department_name,
+        scar.department_id,
+        sc.assign_status AS assignStatus
+        FROM west_complaint sc
+        LEFT JOIN west_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1
+        where (
+            sc.assign_person_id in
+            <foreach collection="ids"  item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            ) or (superior_id =#{streetId} and sc.now_level=3)
+        ) as t1
+        <if test="query.status !=null">
+            and t1.status = #{query.status}
+        </if>
+        ORDER BY t1.create_time DESC
+    </select>
+    <select id="selectComplaintPage4" resultType="com.panzhihua.westcommittee.model.vo.ComplaintVO">
+select * from  (
+        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  sc.status!=3 and sc.status !=8 THEN 0
+                ELSE 3
+                END AS status,
+            sc.report_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.reporter_level,
+            scar.comment,
+            scar.create_time AS reportTime,
+            scar.system_user_id,
+            scar.create_by as auditCreateBy,
+            scar.reporter,
+            scar.reporter_id,
+            scar.superior_id superiorId2,
+            scar.department_name,
+            scar.department_id,
+            sc.assign_status AS assignStatus
+        FROM west_complaint sc
+                 LEFT JOIN west_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1
+        WHERE assign_person_id =#{oneDepartmentId}
+            ) as t1
+        <if test="query.status !=null">
+            and t1.status = #{query.status}
+        </if>
+        ORDER BY t1.create_time DESC
+    </select>
+    <select id="selectComplaintPage6" resultType="com.panzhihua.westcommittee.model.vo.ComplaintVO">
+        select * from (
+        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 sc.assign_status = 0  THEN -1
+        WHEN sc.status = 0 and scar.audit_type = 1 AND scar.audit_status = 0 THEN 7
+        WHEN sc.status = 0 and scar.audit_type = 2 AND scar.audit_status = 0 THEN 5
+        WHEN sc.status = 0 and scar.audit_status = 2 and scar.audit_type = 2 THEN 6
+        ELSE sc.status
+        END AS status,
+        sc.report_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.reporter_level,
+        scar.comment,
+        scar.create_time AS reportTime,
+        scar.system_user_id,
+        scar.create_by as auditCreateBy,
+        scar.reporter,
+        scar.reporter_id,
+        scar.superior_id superiorId2,
+        scar.department_name,
+        scar.department_id,
+        sc.assign_status AS assignStatus
+        FROM west_complaint sc
+        LEFT JOIN west_complaint_audit_record scar ON scar.complaint_id = sc.id and scar.latest_flag = 1
+        where (
+        sc.assign_person_id in
+        <foreach collection="ids"  item="item" index="index" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        ) or (superior_id =#{communityId} and sc.now_level=4)
+        ) as t1
+        <if test="query.status !=null">
+            and t1.status = #{query.status}
+        </if>
+        ORDER BY t1.create_time DESC
+    </select>
 </mapper>

--
Gitblit v1.7.1