From 7658b1364caa5df10d232117d7728a8a96f57b75 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期日, 23 二月 2025 22:56:29 +0800
Subject: [PATCH] 工单列表、详情、办理进度添加、办理结果录入接口

---
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintCompletionDTO.java   |    7 
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/ComplaintController.java     |   24 ++
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/config/MyMetaObjectHandler.java         |   12 
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/ISystemUserService.java         |    7 +
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java |   18 ++
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/ComplaintProgress.java     |    4 
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintMapper.xml                                     |  123 +++++++++++++++++
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/Complaint.java             |    4 
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java  |   92 +++++++++++-
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/IComplaintService.java          |   20 ++
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintProcessDTO.java      |    6 
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/query/ComplaintQuery.java         |    8 
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintMapper.java                |   21 ++
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/ComplaintVO.java               |   20 ++
 14 files changed, 325 insertions(+), 41 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/config/MyMetaObjectHandler.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/config/MyMetaObjectHandler.java
index 853be50..ea4d7d2 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/config/MyMetaObjectHandler.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/config/MyMetaObjectHandler.java
@@ -21,12 +21,12 @@
         log.info("start insert fill ....");
         // this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); // 起始版本 3.3.0(推荐使用)
         // 或者
-        this.strictInsertFill(metaObject, "createAt", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
-        this.strictInsertFill(metaObject, "updateAt", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
+        this.strictInsertFill(metaObject, "createTime", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
+        this.strictInsertFill(metaObject, "updateTime", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
         // 或者
         // this.fillStrategy(metaObject, "createTime", LocalDateTime.now()); // 也可以使用(3.3.0 该方法有bug)
-        this.strictInsertFill(metaObject, "createdAt", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
-        this.strictInsertFill(metaObject, "updatedAt", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
+        this.strictInsertFill(metaObject, "createTime", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
+        this.strictInsertFill(metaObject, "updateTime", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
     }
 
     @Override
@@ -34,8 +34,8 @@
         log.info("start update fill ....");
         // this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); // 起始版本 3.3.0(推荐)
         // 或者
-        this.strictUpdateFill(metaObject, "updateAt", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
-        this.strictUpdateFill(metaObject, "updatedAt", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
+        this.strictUpdateFill(metaObject, "createTime", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
+        this.strictUpdateFill(metaObject, "updateTime", () -> new Date(), Date.class); // 起始版本 3.3.3(推荐)
         // 或者
         // this.fillStrategy(metaObject, "updateTime", LocalDateTime.now()); // 也可以使用(3.3.0 该方法有bug)
     }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/ComplaintController.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/ComplaintController.java
index 3613723..9d304d9 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/ComplaintController.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/ComplaintController.java
@@ -3,6 +3,7 @@
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.panzhihua.common.controller.BaseController;
+import com.panzhihua.common.model.vos.LoginUserInfoVO;
 import com.panzhihua.common.model.vos.R;
 import com.panzhihua.sangeshenbian.annotation.DistributedLock;
 import com.panzhihua.sangeshenbian.model.dto.ComplaintCompletionDTO;
@@ -14,12 +15,17 @@
 import com.panzhihua.sangeshenbian.model.vo.ComplaintVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
 
 /**
  * <p>
@@ -29,6 +35,7 @@
  * @author
  * @since 2025-02-22
  */
+@Validated
 @RestController
 @RequestMapping("/applet/complaint")
 @RequiredArgsConstructor
@@ -51,18 +58,23 @@
     @PostMapping("/list")
     @ApiOperation("工单列表")
     public R<Page<ComplaintVO>> complaintList(@RequestBody ComplaintQuery query) {
-        return R.ok(complaintService.complaintList(query));
+        return R.ok(complaintService.complaintList(query,getLoginUserInfo()));
     }
-    @ApiOperation("办理进度录入")
+    @GetMapping("/detail")
+    @ApiOperation("工单详情")
+    public R<ComplaintVO> detail(@ApiParam(name = "id", value = "工单id", required = true) Long id) {
+        return R.ok(complaintService.detail(id));
+    }
     @PostMapping("/saveProcess")
-    public R<?> saveProcess(@RequestBody ComplaintProcessDTO dto){
-        complaintService.saveProcess(dto);
+    @ApiOperation("办理进度录入")
+    public R<?> saveProcess(@Valid @RequestBody ComplaintProcessDTO dto){
+        complaintService.saveProcess(dto,getUserId());
         return R.ok();
     }
-    @ApiOperation("办理结果录入")
     @PostMapping("/saveResult")
+    @ApiOperation("办理结果录入")
     public R<?> saveResult(@RequestBody ComplaintCompletionDTO dto){
-        complaintService.saveResult(dto);
+        complaintService.saveResult(dto,getLoginUserInfo());
         return R.ok();
     }
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintMapper.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintMapper.java
index 774ca31..0875b6a 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintMapper.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintMapper.java
@@ -1,16 +1,35 @@
 package com.panzhihua.sangeshenbian.dao;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.panzhihua.sangeshenbian.model.entity.Complaint;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.panzhihua.sangeshenbian.model.query.ComplaintQuery;
+import com.panzhihua.sangeshenbian.model.vo.ComplaintVO;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
  * 问题报告表 Mapper 接口
  * </p>
  *
- * @author 
+ * @author
  * @since 2025-02-22
  */
 public interface ComplaintMapper extends BaseMapper<Complaint> {
+    /**
+     * 工单列表
+     * @param page
+     * @param query
+     * @param targetId
+     * @param isSuperior
+     * @return
+     */
+    Page<ComplaintVO> selectComplaintPage(Page<ComplaintVO> page, @Param("query") ComplaintQuery query, @Param("targetId") String targetId, @Param("isSuperior") Integer isSuperior);
 
+    /**
+     *  工单详情
+     * @param id
+     * @return
+     */
+    ComplaintVO getDetail(Long id);
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintCompletionDTO.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintCompletionDTO.java
index 5953d39..17a1220 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintCompletionDTO.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintCompletionDTO.java
@@ -15,6 +15,9 @@
 @ApiModel("办理结果录入数据传输对象")
 public class ComplaintCompletionDTO {
 
+    @ApiModelProperty(value = "诉求id")
+    private Long id;
+
     @ApiModelProperty(value = "办理结果描述")
     private String completionDescription;
 
@@ -26,9 +29,5 @@
 
     @ApiModelProperty(value = "办理结果其他说明")
     private String completionOtherDescription;
-
-    @ApiModelProperty(value = "办结人员id")
-    private Long completionUserId;
-
 
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintProcessDTO.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintProcessDTO.java
index da0ca2b..b94461c 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintProcessDTO.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintProcessDTO.java
@@ -6,6 +6,8 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.util.Date;
 
 /**
@@ -17,9 +19,11 @@
 public class ComplaintProcessDTO {
 
     @ApiModelProperty(value = "诉求id")
-    private Long issueReportId;
+    @NotNull(message = "诉求id不能为空")
+    private Long complaintId;
 
     @ApiModelProperty(value = "办理进度描述")
+    @NotBlank(message = "办理进度描述不能为空")
     private String describe;
 
     @ApiModelProperty(value = "图片url")
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/Complaint.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/Complaint.java
index 9feb910..3c9af9f 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/Complaint.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/Complaint.java
@@ -84,7 +84,7 @@
     @TableField("audit_status")
     private Integer auditStatus;
 
-    @ApiModelProperty(value = "流转状态:0-正在办理 1-延期办理 2-超时办理 3-已办结")
+    @ApiModelProperty(value = "流转状态:0-正在办理 1-延期办理 2-超时办理 3-已办结 4-群众撤销 5-上报待审核 6-上级驳回")
     @TableField("status")
     private Integer status;
 
@@ -134,7 +134,7 @@
 
     @ApiModelProperty(value = "办结人员id")
     @TableField("completion_user_id")
-    private Integer completionUserId;
+    private Long completionUserId;
 
     @ApiModelProperty(value = "办结人员")
     @TableField("completion_username")
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/ComplaintProgress.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/ComplaintProgress.java
index a905ea2..fe85266 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/ComplaintProgress.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/ComplaintProgress.java
@@ -36,8 +36,8 @@
     private Long id;
 
     @ApiModelProperty(value = "诉求id")
-    @TableField("issue_report_id")
-    private Long issueReportId;
+    @TableField("complaint_id")
+    private Long complaintId;
 
     @ApiModelProperty(value = "办理进度描述")
     @TableField("describe")
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/query/ComplaintQuery.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/query/ComplaintQuery.java
index 97791c0..228d3e2 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/query/ComplaintQuery.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/query/ComplaintQuery.java
@@ -11,12 +11,8 @@
 @Data
 @ApiModel("工单查询数据传输对象")
 public class ComplaintQuery extends BasePage{
-    @ApiModelProperty("1:上报待审核,2:正在办理, 3:办结, 不传为全部")
+
+    @ApiModelProperty("全部:不传,上报待审核:0,正在办理:1, 办结:2")
     private Integer type;
 
-    @ApiModelProperty(value = "当前页数", example = "1")
-    private Long pageNum = 1L;
-
-    @ApiModelProperty(value = "每页记录数", example = "10")
-    private Long pageSize = 10L;
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/ComplaintVO.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/ComplaintVO.java
index 0c2afa7..45a7c66 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/ComplaintVO.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/vo/ComplaintVO.java
@@ -1,8 +1,14 @@
 package com.panzhihua.sangeshenbian.model.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.panzhihua.sangeshenbian.model.entity.Complaint;
+import com.panzhihua.sangeshenbian.model.entity.ComplaintFlow;
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
 
 /**
  * @author mitao
@@ -12,4 +18,18 @@
 @ApiModel("工单视图对象")
 public class ComplaintVO extends Complaint {
 
+    @ApiModelProperty(value = "上报人")
+    private String reportName;
+
+    @ApiModelProperty(value = "所属部门")
+    private String departmentName;
+
+    @ApiModelProperty(value = "上报提交时间")
+    private Date reportTime;
+
+    @ApiModelProperty(value = "上报说明")
+    private String comment;
+
+    @ApiModelProperty(value = "诉求流转记录")
+    List<ComplaintFlow> complaintFlows;
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/IComplaintService.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/IComplaintService.java
index 769c2a9..932372e 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/IComplaintService.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/IComplaintService.java
@@ -1,6 +1,7 @@
 package com.panzhihua.sangeshenbian.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.panzhihua.common.model.vos.LoginUserInfoVO;
 import com.panzhihua.sangeshenbian.model.dto.ComplaintCompletionDTO;
 import com.panzhihua.sangeshenbian.model.dto.ComplaintProcessDTO;
 import com.panzhihua.sangeshenbian.model.entity.Complaint;
@@ -21,20 +22,33 @@
 
     /**
      * 诉求列表
+     *
      * @param query
+     * @param loginUserInfoVO
      * @return
      */
-    Page<ComplaintVO> complaintList(ComplaintQuery query);
+    Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO  loginUserInfoVO);
 
+    /**
+     * 工单详情
+     * @param id
+     * @return
+     */
+    ComplaintVO detail(Long id);
     /**
      * 保存办理进度
      * @param dto
+     * @param userId
      */
-    void saveProcess(ComplaintProcessDTO dto);
+    void saveProcess(ComplaintProcessDTO dto, Long userId);
 
     /**
      * 办理结果录入
+     *
      * @param dto
+     * @param loginUserInfoVO
      */
-    void saveResult(ComplaintCompletionDTO dto);
+    void saveResult(ComplaintCompletionDTO dto, LoginUserInfoVO loginUserInfoVO);
+
+
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/ISystemUserService.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/ISystemUserService.java
index 2d04728..cf7ad50 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/ISystemUserService.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/ISystemUserService.java
@@ -6,6 +6,8 @@
 import com.panzhihua.sangeshenbian.warpper.SystemUserList;
 import com.panzhihua.sangeshenbian.warpper.SystemUserListVo;
 
+import java.util.Optional;
+
 /**
  * @author zhibing.pu
  * @Date 2025/2/18 22:30
@@ -18,4 +20,9 @@
 	 * @return
 	 */
 	IPage<SystemUserListVo> list(Integer accountLevel, SystemUserList query);
+
+	/**
+	 * 根据手机号码查询小程序用户在三个身边的上级角色用户
+	 */
+	Optional<SystemUser> getSystemUserByPhone(String phone);
 }
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 1bf936b..a2cf0c1 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,21 +1,31 @@
 package com.panzhihua.sangeshenbian.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.panzhihua.common.utlis.DateUtils;
+import com.panzhihua.common.model.vos.LoginUserInfoVO;
 import com.panzhihua.sangeshenbian.model.dto.ComplaintCompletionDTO;
 import com.panzhihua.sangeshenbian.model.dto.ComplaintProcessDTO;
 import com.panzhihua.sangeshenbian.model.entity.Complaint;
 import com.panzhihua.sangeshenbian.enums.ProcessStatusEnum;
 import com.panzhihua.sangeshenbian.dao.ComplaintMapper;
+import com.panzhihua.sangeshenbian.model.entity.ComplaintFlow;
+import com.panzhihua.sangeshenbian.model.entity.ComplaintProgress;
+import com.panzhihua.sangeshenbian.model.entity.SystemUser;
 import com.panzhihua.sangeshenbian.model.query.ComplaintQuery;
+import com.panzhihua.sangeshenbian.service.IComplaintFlowService;
+import com.panzhihua.sangeshenbian.service.IComplaintProgressService;
 import com.panzhihua.sangeshenbian.service.IComplaintService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.panzhihua.sangeshenbian.model.vo.ComplaintVO;
+import com.panzhihua.sangeshenbian.service.ISystemUserService;
+import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
+import java.util.Optional;
 
 import static cn.hutool.core.util.ObjectUtil.isNull;
 
@@ -28,7 +38,11 @@
  * @since 2025-02-22
  */
 @Service
+@RequiredArgsConstructor
 public class ComplaintServiceImpl extends ServiceImpl<ComplaintMapper, Complaint> implements IComplaintService {
+    private final ISystemUserService systemUserService;
+    private final IComplaintFlowService complaintFlowService;
+    private final IComplaintProgressService complaintProgressService;
 
     @Override
     public void saveComplaint(Complaint complaint,Long userId) {
@@ -57,43 +71,101 @@
 
         // 设置其他字段
         complaint.setStatus(ProcessStatusEnum.PROCESSING.getCode());
-        complaint.setCreateTime(DateUtils.getCurrentDate());
+        complaint.setCreateTime(new Date());
         complaint.setCreateBy(userId);
         complaint.setUpdateBy(userId);
-        complaint.setUpdateTime(DateUtils.getCurrentDate());
+        complaint.setUpdateTime(new Date());
 
         // 保存诉求记录
         save(complaint);
     }
 
     /**
-     *
      * @param query
+     * @param loginUserInfoVO
      * @return
      */
     @Override
-    public Page<ComplaintVO> complaintList(ComplaintQuery query) {
-        //判断当前登录用户级别,查询对应工单
+    public Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO loginUserInfoVO) {
         Page<ComplaintVO> page = new Page<>(query.getPageNum(), query.getPageSize());
+        //判断当前登录用户级别,查询对应工单
+        Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
+        String targetId = "";
+        int isSuperior = 0;
+        //上级
+        if (systemUserByPhone.isPresent()) {
+            SystemUser systemUser = systemUserByPhone.get();
+            Integer accountLevel = systemUser.getAccountLevel();
+            switch (accountLevel) {
+                case 1:
+                    //市级
+                    targetId = "510400";
+                    break;
+                case 2:
+                    //区县级
+                    targetId = systemUser.getDistrictsCode();
+                    break;
+                case 3:
+                    //街道
+                    targetId = systemUser.getStreetCode();
+                    break;
+                case 4:
+                    //社区
+                    targetId = systemUser.getCommunityCode();
+                    break;
+            }
+            isSuperior = 1;
+        } else {
+        //党员
+            targetId = loginUserInfoVO.getUserId().toString();
+        }
+        //查询对应诉求
+        page = baseMapper.selectComplaintPage(page, query, targetId,isSuperior);
         return page;
+    }
+
+    /**
+     * 工单详情
+     * @param id
+     * @return
+     */
+    @Override
+    public ComplaintVO detail(Long id) {
+        ComplaintVO detail = baseMapper.getDetail(id);
+        if (detail.getStatus().equals(0)) {
+            List<ComplaintFlow> list = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByAsc(ComplaintFlow::getCreateTime).list();
+            detail.setComplaintFlows(list);
+        }
+        return detail;
     }
 
     /**
      *办理进度录入
      * @param dto
+     * @param userId
      */
     @Override
-    public void saveProcess(ComplaintProcessDTO dto) {
-
+    public void saveProcess(ComplaintProcessDTO dto,Long userId) {
+        ComplaintProgress complaintProgress = BeanUtil.copyProperties(dto, ComplaintProgress.class);
+        complaintProgress.setCreateTime(new Date());
+        complaintProgress.setCreateBy(userId);
+        complaintProgressService.save(complaintProgress);
     }
 
     /**
      * 办理结果录入
+     *
      * @param dto
+     * @param loginUserInfoVO
      */
     @Override
-    public void saveResult(ComplaintCompletionDTO dto) {
-
+    public void saveResult(ComplaintCompletionDTO dto, LoginUserInfoVO loginUserInfoVO) {
+        Complaint complaint = BeanUtil.copyProperties(dto, Complaint.class);
+        complaint.setUpdateTime(new Date());
+        complaint.setCompletionUserId(loginUserInfoVO.getUserId());
+        complaint.setCompletionUsername(loginUserInfoVO.getName());
+        complaint.setCompletionTime(new Date());
+        this.updateById(complaint);
     }
 }
 
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java
index 734c5ad..ddfbdfa 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java
@@ -3,12 +3,15 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.utlis.StringUtils;
 import com.panzhihua.sangeshenbian.dao.SystemUserMapper;
 import com.panzhihua.sangeshenbian.model.entity.SystemUser;
 import com.panzhihua.sangeshenbian.service.ISystemUserService;
 import com.panzhihua.sangeshenbian.warpper.SystemUserList;
 import com.panzhihua.sangeshenbian.warpper.SystemUserListVo;
 import org.springframework.stereotype.Service;
+
+import java.util.Optional;
 
 /**
  * @author zhibing.pu
@@ -30,4 +33,19 @@
 		IPage<SystemUserListVo> list = this.baseMapper.list(page, accountLevel, query);
 		return list;
 	}
+
+	/**
+	 * 根据手机号码查询小程序用户在三个身边的上级角色用户
+	 * @param phone
+	 * @return
+	 */
+	@Override
+	public Optional<SystemUser> getSystemUserByPhone(String phone) {
+		if (StringUtils.isBlank(phone)) {
+			return Optional.empty();
+		}
+		return this.lambdaQuery()
+				.eq(SystemUser::getPhone, phone).ne(SystemUser::getStatus, 3)
+				.eq(SystemUser::getIsAdmin, 1).last("LIMIT 1").oneOpt();
+	}
 }
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintMapper.xml b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintMapper.xml
index 9dbbee7..d13f60b 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintMapper.xml
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintMapper.xml
@@ -2,4 +2,127 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.panzhihua.sangeshenbian.dao.ComplaintMapper">
 
+    <select id="selectComplaintPage" 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 = 1 THEN 5
+                   WHEN scar.audit_type = 2 AND scar.audit_status = 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.latitude,
+               sc.longitude,
+               scar.audit_type,
+               scar.audit_status,
+               scar.comment,
+               scar.images,
+               scar.videos,
+               scar.create_time AS reportTime,
+               scar.system_user_id,
+               scar.name        AS reportName,
+               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>
+            <if test="query.type ==null">
+                (scar.audit_type = 1 AND scar.audit_status = 1)
+                OR (scar.audit_type = 2 AND scar.audit_status = 2)
+            </if>
+            <if test="isSuperior == 1 and targetId != null">
+                AND sc.superior_id = #{targetId}
+            </if>
+            <if test="isSuperior == 0 and targetId != null">
+                AND sc.create_by = #{targetId}
+            </if>
+            <if test="query.type!=null and query.type == 0">
+                AND scar.audit_type = 2 AND scar.audit_status = 2
+            </if>
+            <if test="query.type!=null and query.type == 1">
+                AND sc.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 = 1 THEN 5
+                   WHEN scar.audit_type = 2 AND scar.audit_status = 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.latitude,
+               sc.longitude,
+               scar.audit_type,
+               scar.audit_status,
+               scar.comment,
+               scar.images,
+               scar.videos,
+               scar.create_time AS reportTime,
+               scar.system_user_id,
+               scar.name        AS reportName,
+               scar.department_name,
+               scar.department_id,
+               scar.comment
+        FROM sgsb_complaint sc
+                 LEFT JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id AND scar.latest_flag = 1
+        WHERE sc.id = #{id}
+        <where>
+            sc.id = #{id}
+        </where>
+    </select>
 </mapper>

--
Gitblit v1.7.1