Browse Source

Merge branch 'master' of https://172.16.32.165/lighter/web-server

xiaochan 2 years ago
parent
commit
cceb72c7ff

+ 30 - 0
src/main/java/thyyxxk/webserver/controller/outpatient/comments/CommentsController.java

@@ -0,0 +1,30 @@
+package thyyxxk.webserver.controller.outpatient.comments;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.outpatient.comments.request.CommentInquiry;
+import thyyxxk.webserver.entity.outpatient.comments.response.CommentsResponse;
+import thyyxxk.webserver.service.outpatient.comments.CommentsService;
+
+@RestController
+@RequestMapping("/comments")
+public class CommentsController {
+    private final CommentsService service;
+
+    @Autowired
+    public CommentsController(CommentsService service) {
+        this.service = service;
+    }
+
+    @PostMapping("/getComments")
+    public ResultVo<CommentsResponse> getComments(@RequestBody CommentInquiry inquiry) {
+        return service.getComments(inquiry);
+    }
+
+    @GetMapping("/updateCommentStatus")
+    public ResultVo<String> updateCommentStatus(@RequestParam("id") int id,
+                                                @RequestParam("deleted") int deleted) {
+        return service.updateCommentStatus(id, deleted);
+    }
+}

+ 0 - 1
src/main/java/thyyxxk/webserver/dao/his/inpatient/PatientDao.java

@@ -331,5 +331,4 @@ public interface PatientDao {
 
     @Update("update zy_actpatient set balance=#{balance} where inpatient_no=#{zyh}")
     void updateZyActPatientBalance(@Param("zyh") String zyh, @Param("balance") String balance);
-
 }

+ 30 - 0
src/main/java/thyyxxk/webserver/dao/his/outpatient/comments/CommentsDao.java

@@ -0,0 +1,30 @@
+package thyyxxk.webserver.dao.his.outpatient.comments;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.outpatient.comments.response.WechatPatientComment;
+
+import java.util.Date;
+import java.util.List;
+
+@Mapper
+public interface CommentsDao {
+    @Select("select * from " +
+            "(SELECT ROW_NUMBER() OVER(ORDER BY id) AS idx,*, " +
+            "department=(select rtrim(d.dept_code) from a_employee_mi d where d.code=doctor_code), " +
+            "patPhoneNo=(select top 1 d.phone from t_wechat_patient_bind d where d.patient_id=a.patient_id and d.phone is not null) " +
+            "from t_wechat_patient_comment a ${ew.customSqlSegment}) t " +
+            "where t.idx>(#{page}-1)*#{size} and t.idx<=#{page}*#{size}")
+    List<WechatPatientComment> selectComments(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper,
+                                              @Param("page") int page, @Param("size") int size);
+
+    @Select("select count(1) from t_wechat_patient_comment ${ew.customSqlSegment}")
+    int selectValidCount(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
+
+    @Update("update t_wechat_patient_comment set deleted=#{val},delete_staff=#{staff},delete_time=#{date} where id=#{id}")
+    int updateCommentStatus(int id, int val, String staff, Date date);
+}

+ 22 - 0
src/main/java/thyyxxk/webserver/entity/outpatient/comments/request/CommentInquiry.java

@@ -0,0 +1,22 @@
+package thyyxxk.webserver.entity.outpatient.comments.request;
+
+import lombok.Data;
+
+@Data
+public class CommentInquiry {
+    private String doctorName;
+    private Integer commentLevel;
+    private String startTime;
+    private String endTime;
+    private Integer pageNum;
+    private Integer pageSize;
+    private Integer deleted;
+
+    public Integer getPageNum() {
+        return null == pageNum ? 1 : pageNum;
+    }
+
+    public Integer getPageSize() {
+        return null == pageSize ? 20 : pageSize;
+    }
+}

+ 12 - 0
src/main/java/thyyxxk/webserver/entity/outpatient/comments/response/CommentsResponse.java

@@ -0,0 +1,12 @@
+package thyyxxk.webserver.entity.outpatient.comments.response;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CommentsResponse {
+    private Integer totalSize;
+    private Integer maxId;
+    private List<WechatPatientComment> list;
+}

+ 26 - 0
src/main/java/thyyxxk/webserver/entity/outpatient/comments/response/WechatPatientComment.java

@@ -0,0 +1,26 @@
+package thyyxxk.webserver.entity.outpatient.comments.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@Data
+public class WechatPatientComment {
+  private Integer id;
+  private String doctorCode;
+  private String doctorCodeRs;
+  private String doctorName;
+  private String department;
+  private String patientId;
+  private Integer times;
+  private String patientName;
+  @DateTimeFormat(pattern = "yyyy-MM-dd")
+  @JsonFormat(pattern = "yyyy-MM-dd")
+  private Date commentTime;
+  private Integer commentLevel;
+  private String commentContent;
+  private String patPhoneNo;
+  private Integer deleted;
+}

+ 70 - 0
src/main/java/thyyxxk/webserver/service/outpatient/comments/CommentsService.java

@@ -0,0 +1,70 @@
+package thyyxxk.webserver.service.outpatient.comments;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.outpatient.comments.CommentsDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.outpatient.comments.request.CommentInquiry;
+import thyyxxk.webserver.entity.outpatient.comments.response.CommentsResponse;
+import thyyxxk.webserver.entity.outpatient.comments.response.WechatPatientComment;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+import thyyxxk.webserver.utils.TokenUtil;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class CommentsService {
+    private final CommentsDao dao;
+    private final RedisLikeService redis;
+
+    @Autowired
+    public CommentsService(CommentsDao dao, RedisLikeService redis) {
+        this.dao = dao;
+        this.redis = redis;
+    }
+
+    public ResultVo<CommentsResponse> getComments(CommentInquiry inquiry) {
+        QueryWrapper<?> wrapper = new QueryWrapper<>();
+        if (null != inquiry.getDeleted()) {
+            wrapper.eq("deleted", inquiry.getDeleted());
+        }
+        if (null != inquiry.getCommentLevel()) {
+            wrapper.eq("comment_level", inquiry.getCommentLevel());
+        }
+        if (StringUtil.notBlank(inquiry.getDoctorName())) {
+            wrapper.eq("doctor_name", inquiry.getDoctorName());
+        }
+        if (StringUtil.notBlank(inquiry.getStartTime()) && StringUtil.notBlank(inquiry.getEndTime())) {
+            wrapper.ge("comment_time", inquiry.getStartTime())
+                    .le("comment_time", inquiry.getEndTime());
+        }
+        List<WechatPatientComment> list = dao.selectComments(wrapper, inquiry.getPageNum(), inquiry.getPageSize());
+        if (list.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        list.forEach(item -> item.setDepartment(redis.getDeptName(item.getDepartment())));
+        CommentsResponse response = new CommentsResponse();
+        response.setTotalSize(dao.selectValidCount(wrapper));
+        response.setList(list);
+        return ResultVoUtil.success(response);
+    }
+
+    public ResultVo<String> updateCommentStatus(int id, int deleted) {
+        String staff = null;
+        Date date = null;
+        if (deleted == 1) {
+            staff = TokenUtil.getTokenUserId();
+            date = new Date();
+        }
+        int count = dao.updateCommentStatus(id, deleted, staff, date);
+        if (count == 1) {
+            return ResultVoUtil.success("操作成功。");
+        }
+        return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+    }
+}