Browse Source

信息采集消息,开方消息,审核消息

wjj 2 weeks ago
parent
commit
743e61f17f

+ 119 - 0
fs-doctor-app/src/main/java/com/fs/app/controller/DoctorMsgController.java

@@ -0,0 +1,119 @@
+package com.fs.app.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.fs.common.core.domain.R;
+import com.fs.crm.vo.CrmMsgTypeVO;
+import com.fs.his.domain.FsDoctor;
+import com.fs.his.service.IFsDoctorService;
+import com.fs.system.service.ISysDictDataService;
+import com.fs.system.vo.DictVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import com.fs.doctor.domain.DoctorMsg;
+import com.fs.doctor.service.IDoctorMsgService;
+
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * 医生消息Controller
+ * 
+ * @author fs
+ * @date 2025-11-04
+ */
+@RestController
+@RequestMapping("/doctor/msg")
+public class DoctorMsgController extends AppBaseController
+{
+    @Autowired
+    private IDoctorMsgService doctorMsgService;
+
+    @Autowired
+    private IFsDoctorService doctorService;
+
+    @Autowired
+    private ISysDictDataService dictDataService;
+
+
+    @GetMapping("/getMsgCount")
+    public R getMsgCount(HttpServletRequest request){
+        Long count= doctorMsgService.selectDoctorMsgCountsByDoctorId(Long.parseLong(getDoctorId()));
+        return R.ok().put("counts",count);
+    }
+
+    @GetMapping("/getMsg")
+    public R getMsg(HttpServletRequest request){
+        Long doctorId = Long.parseLong(getDoctorId());
+        FsDoctor doctor = doctorService.selectFsDoctorByDoctorId(doctorId);
+        //获取用户未读总数
+        //获取所有类型
+        List<DictVO> types;
+        if (doctor.getDoctorType() == 1) {
+            //医生返回 1-医生开方 3-信息采集
+            types = dictDataService.selectDictDataListByType("doctor_msg_type")
+                    .stream()
+                    .filter(v -> v.getDictValue().equals("1") || v.getDictValue().equals("3"))
+                    .collect(Collectors.toList());
+        } else {
+            //药师返回 2- 药师审核
+            types = dictDataService.selectDictDataListByType("doctor_msg_type")
+                    .stream()
+                    .filter(v -> v.getDictValue().equals("2"))
+                    .collect(Collectors.toList());
+        }
+        List<CrmMsgTypeVO> counts=new ArrayList<>();
+        for(DictVO v:types){
+            Long count= doctorMsgService.selectDoctorMsgCountsByDoctorIdAndType(doctorId,Integer.parseInt(v.getDictValue()));
+            CrmMsgTypeVO typeBO=new CrmMsgTypeVO();
+            typeBO.setMsgType(Integer.parseInt(v.getDictValue()));
+            typeBO.setTotal(count);
+            typeBO.setMsgTypeName(v.getDictLabel());
+            counts.add(typeBO);
+        }
+        return R.ok().put("counts",counts);
+    }
+
+    @GetMapping("/getMsgList")
+    public R getMsgList(
+            HttpServletRequest request,
+            @ApiParam(required = true, name = "type", value = "类型") @RequestParam(value = "type", required = false) Integer type
+    ){
+        int pageNum =1;
+        int pageSize = 10;
+
+        Long doctorId = Long.parseLong(getDoctorId());
+        DoctorMsg map = new DoctorMsg();
+        map.setType(type);
+        map.setDoctorId(doctorId);
+
+        PageHelper.startPage(pageNum, pageSize);
+        List<DoctorMsg> list = doctorMsgService.selectDoctorMsgList(map);
+        PageInfo<DoctorMsg> listPageInfo=new PageInfo<>(list);
+
+        return R.ok().put("data",listPageInfo);
+    }
+
+    @PostMapping("/setRead")
+    public R setRead(@RequestBody DoctorMsg msg)
+    {
+        doctorMsgService.updateDoctorMsg(msg);
+        return R.ok();
+    }
+
+    @PostMapping("/setAllRead")
+    public R setAllRead()
+    {
+        Long doctorId = Long.parseLong(getDoctorId());
+        doctorMsgService.setAllRead(doctorId);
+        return R.ok();
+    }
+
+}

+ 43 - 0
fs-service/src/main/java/com/fs/doctor/domain/DoctorMsg.java

@@ -0,0 +1,43 @@
+package com.fs.doctor.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 医生消息对象 doctor_msg
+ *
+ * @author fs
+ * @date 2025-11-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DoctorMsg extends BaseEntity{
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** 类型:1医生开方 2药师处方审核 3信息采集建议 */
+    @Excel(name = "类型:1医生开方 2药师处方审核 3信息采集建议")
+    private Integer type;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String title;
+
+    /** 内容 */
+    @Excel(name = "内容")
+    private String content;
+
+    /** 0未读 1已读 */
+    @Excel(name = "0未读 1已读")
+    private Integer isRead;
+
+    /** 医生id */
+    @Excel(name = "医生id")
+    private Long doctorId;
+
+
+}

+ 74 - 0
fs-service/src/main/java/com/fs/doctor/mapper/DoctorMsgMapper.java

@@ -0,0 +1,74 @@
+package com.fs.doctor.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.doctor.domain.DoctorMsg;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+/**
+ * 医生消息Mapper接口
+ * 
+ * @author fs
+ * @date 2025-11-04
+ */
+public interface DoctorMsgMapper extends BaseMapper<DoctorMsg>{
+    /**
+     * 查询医生消息
+     * 
+     * @param id 医生消息主键
+     * @return 医生消息
+     */
+    DoctorMsg selectDoctorMsgById(Long id);
+
+    /**
+     * 查询医生消息列表
+     * 
+     * @param doctorMsg 医生消息
+     * @return 医生消息集合
+     */
+    List<DoctorMsg> selectDoctorMsgList(DoctorMsg doctorMsg);
+
+    /**
+     * 新增医生消息
+     * 
+     * @param doctorMsg 医生消息
+     * @return 结果
+     */
+    int insertDoctorMsg(DoctorMsg doctorMsg);
+
+    /**
+     * 修改医生消息
+     * 
+     * @param doctorMsg 医生消息
+     * @return 结果
+     */
+    int updateDoctorMsg(DoctorMsg doctorMsg);
+
+    /**
+     * 删除医生消息
+     * 
+     * @param id 医生消息主键
+     * @return 结果
+     */
+    int deleteDoctorMsgById(Long id);
+
+    /**
+     * 批量删除医生消息
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteDoctorMsgByIds(Long[] ids);
+
+    //获取医生未读消息总数
+    @Select("select IFNULL(count( 0),0) from doctor_msg where doctor_id = #{doctorId} and is_read = 0 ")
+    Long selectDoctorMsgCountsByDoctorId(Long doctorId);
+
+    @Select("select IFNULL(count( type),0) from doctor_msg where doctor_id = #{doctorId} and is_read = 0 and type = #{type}")
+    Long selectDoctorMsgCountsByDoctorIdAndType(@Param("doctorId") Long doctorId, @Param("type") int type);
+
+    @Update("update  doctor_msg set is_read=1 where doctor_id = #{doctorId} ")
+    int setAllRead(Long doctorId);
+}

+ 67 - 0
fs-service/src/main/java/com/fs/doctor/service/IDoctorMsgService.java

@@ -0,0 +1,67 @@
+package com.fs.doctor.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.doctor.domain.DoctorMsg;
+
+/**
+ * 医生消息Service接口
+ * 
+ * @author fs
+ * @date 2025-11-04
+ */
+public interface IDoctorMsgService extends IService<DoctorMsg>{
+    /**
+     * 查询医生消息
+     * 
+     * @param id 医生消息主键
+     * @return 医生消息
+     */
+    DoctorMsg selectDoctorMsgById(Long id);
+
+    /**
+     * 查询医生消息列表
+     * 
+     * @param doctorMsg 医生消息
+     * @return 医生消息集合
+     */
+    List<DoctorMsg> selectDoctorMsgList(DoctorMsg doctorMsg);
+
+    /**
+     * 新增医生消息
+     * 
+     * @param doctorMsg 医生消息
+     * @return 结果
+     */
+    int insertDoctorMsg(DoctorMsg doctorMsg);
+
+    /**
+     * 修改医生消息
+     * 
+     * @param doctorMsg 医生消息
+     * @return 结果
+     */
+    int updateDoctorMsg(DoctorMsg doctorMsg);
+
+    /**
+     * 批量删除医生消息
+     * 
+     * @param ids 需要删除的医生消息主键集合
+     * @return 结果
+     */
+    int deleteDoctorMsgByIds(Long[] ids);
+
+    /**
+     * 删除医生消息信息
+     * 
+     * @param id 医生消息主键
+     * @return 结果
+     */
+    int deleteDoctorMsgById(Long id);
+
+    Long selectDoctorMsgCountsByDoctorId(Long doctorId);
+
+    Long selectDoctorMsgCountsByDoctorIdAndType(Long doctorId, int type);
+
+    int setAllRead(Long doctorId);
+}

+ 112 - 0
fs-service/src/main/java/com/fs/doctor/service/impl/DoctorMsgServiceImpl.java

@@ -0,0 +1,112 @@
+package com.fs.doctor.service.impl;
+
+import java.util.List;
+import com.fs.common.utils.DateUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.fs.doctor.mapper.DoctorMsgMapper;
+import com.fs.doctor.domain.DoctorMsg;
+import com.fs.doctor.service.IDoctorMsgService;
+
+/**
+ * 医生消息Service业务层处理
+ * 
+ * @author fs
+ * @date 2025-11-04
+ */
+@Service
+public class DoctorMsgServiceImpl extends ServiceImpl<DoctorMsgMapper, DoctorMsg> implements IDoctorMsgService {
+
+    @Autowired
+    private DoctorMsgMapper doctorMsgMapper;
+
+    /**
+     * 查询医生消息
+     * 
+     * @param id 医生消息主键
+     * @return 医生消息
+     */
+    @Override
+    public DoctorMsg selectDoctorMsgById(Long id)
+    {
+        return doctorMsgMapper.selectDoctorMsgById(id);
+    }
+
+    /**
+     * 查询医生消息列表
+     * 
+     * @param doctorMsg 医生消息
+     * @return 医生消息
+     */
+    @Override
+    public List<DoctorMsg> selectDoctorMsgList(DoctorMsg doctorMsg)
+    {
+        return doctorMsgMapper.selectDoctorMsgList(doctorMsg);
+    }
+
+    /**
+     * 新增医生消息
+     * 
+     * @param doctorMsg 医生消息
+     * @return 结果
+     */
+    @Override
+    public int insertDoctorMsg(DoctorMsg doctorMsg)
+    {
+        doctorMsg.setCreateTime(DateUtils.getNowDate());
+        return doctorMsgMapper.insertDoctorMsg(doctorMsg);
+    }
+
+    /**
+     * 修改医生消息
+     * 
+     * @param doctorMsg 医生消息
+     * @return 结果
+     */
+    @Override
+    public int updateDoctorMsg(DoctorMsg doctorMsg)
+    {
+        doctorMsg.setUpdateTime(DateUtils.getNowDate());
+        return doctorMsgMapper.updateDoctorMsg(doctorMsg);
+    }
+
+    /**
+     * 批量删除医生消息
+     * 
+     * @param ids 需要删除的医生消息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDoctorMsgByIds(Long[] ids)
+    {
+        return doctorMsgMapper.deleteDoctorMsgByIds(ids);
+    }
+
+    /**
+     * 删除医生消息信息
+     * 
+     * @param id 医生消息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDoctorMsgById(Long id)
+    {
+        return doctorMsgMapper.deleteDoctorMsgById(id);
+    }
+
+    @Override
+    public Long selectDoctorMsgCountsByDoctorId(Long doctorId) {
+        return doctorMsgMapper.selectDoctorMsgCountsByDoctorId(doctorId);
+    }
+
+    @Override
+    public Long selectDoctorMsgCountsByDoctorIdAndType(Long doctorId, int type) {
+        return doctorMsgMapper.selectDoctorMsgCountsByDoctorIdAndType(doctorId,type);
+    }
+
+    @Override
+    public int setAllRead(Long doctorId) {
+        return doctorMsgMapper.setAllRead(doctorId);
+    }
+}

+ 24 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -12,6 +12,8 @@ import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.doctor.domain.DoctorMsg;
+import com.fs.doctor.mapper.DoctorMsgMapper;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.dto.FsPackagePatientDTO;
@@ -108,6 +110,9 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     @Autowired
     private IFsPrescribeRecordService prescribeRecordService;
 
+    @Autowired
+    private DoctorMsgMapper doctorMsgMapper;
+
     /**
      * 查询处方
      *
@@ -1036,6 +1041,16 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
             map.setAuditReason("");
             fsExportTaskService.updateFsExportTaskByPrescribeId(param.getPrescribeId());
         }
+        if (param.getStatus() == 2) {
+            //生成拒方开方消息
+            DoctorMsg msg = new DoctorMsg();
+            msg.setDoctorId(prescribe.getDoctorId());
+            msg.setType(1);
+            msg.setTitle("药师拒方,处方编号:"+prescribe.getPrescribeCode());
+            msg.setContent("拒方原因:"+param.getAuditReason()+",请重新开方");
+            msg.setCreateTime(DateUtils.getNowDate());
+            doctorMsgMapper.insertDoctorMsg(msg);
+        }
         delUrl(param.getPrescribeId());
         if (this.updateFsPrescribe(map) > 0){
             return R.ok("审核成功");
@@ -1128,6 +1143,15 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         record.setExecuteStatus(0);
         record.setRetryCount(0);
         prescriptionTaskRecordMapper.insert(record);
+
+        //生成药师审核消息
+        DoctorMsg msg = new DoctorMsg();
+        msg.setType(2);
+        msg.setDoctorId(fsPrescribe.getDrugDoctorId());
+        msg.setTitle("处方审核");
+        msg.setContent("处方编号:"+fsPrescribe.getPrescribeCode()+"待审核");
+        msg.setCreateTime(DateUtils.getNowDate());
+        doctorMsgMapper.insertDoctorMsg(msg);
     }
 
     @Override

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserInformationCollectionMapper.java

@@ -72,7 +72,7 @@ public interface FsUserInformationCollectionMapper extends BaseMapper<FsUserInfo
 
     @Select({"<script> " +
             " SELECT uic.*,u.nickname userName FROM fs_user_information_collection uic LEFT JOIN fs_user u ON uic.user_id = u.user_id " +
-            "WHERE doctor_id = #{maps.doctorId} and is_package = 0  " +
+            "WHERE doctor_id = #{maps.doctorId} and is_package = 0  and user_confirm = 1 " +
             "<if test='maps.doctorConfirm != null' > and uic.doctor_confirm = #{maps.doctorConfirm}  </if>" +
             "<if test='maps.userConfirm != null' > and uic.user_confirm = #{maps.userConfirm}  </if>" +
             "<if test='maps.userName != null ' > and u.nickname like concat('%',#{maps.userName},'%')</if>" +

+ 29 - 2
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -31,6 +31,8 @@ import com.fs.core.utils.OrderCodeUtils;
 import com.fs.course.mapper.FsUserCompanyUserMapper;
 import com.fs.course.param.CollectionInfoConfirmParam;
 import com.fs.course.vo.FsUserInfoCollectionUVO;
+import com.fs.doctor.domain.DoctorMsg;
+import com.fs.doctor.mapper.DoctorMsgMapper;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.enums.FsStoreOrderStatusEnum;
@@ -72,6 +74,7 @@ import com.github.binarywang.wxpay.service.WxPayService;
 import com.google.common.collect.Lists;
 import com.google.gson.Gson;
 import me.chanjar.weixin.common.error.WxErrorException;
+import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -160,6 +163,8 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
 
     @Autowired
     private FsStoreOrderLogsMapper fsStoreOrderLogsMapper;
+    @Autowired
+    private DoctorMsgMapper doctorMsgMapper;
     /**
      * 查询用户信息采集
      *
@@ -585,9 +590,11 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         map.setId(param.getId());
         map.setUserConfirm(1);
         map.setUserAdvice(param.getUserAdvice());
-
-
         if (collection.getStatus() == 1) {
+            //用户第一次确认添加医生消息
+            DoctorMsg msg = getDoctorMsg(collection);
+            //插入医生消息
+            doctorMsgMapper.insertDoctorMsg(msg);
             //第一次确认
             map.setStatus(2);
         } else if (collection.getStatus() == 2) {
@@ -619,6 +626,26 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         return R.error("用户确认失败");
     }
 
+    private static @NotNull DoctorMsg getDoctorMsg(FsUserInformationCollection collection) {
+        DoctorMsg msg = new DoctorMsg();
+        String name = collection.getUserName() != null ? collection.getUserName() : "-";
+        if (collection.getIsPackage() == 0) {
+            //没套餐包的添加医生信息采集建议消息
+            msg.setTitle("用户采集信息建议");
+            msg.setType(3);
+            msg.setContent("患者:" + name + "的信息采集,前往建议");
+            msg.setDoctorId(collection.getDoctorId());
+            msg.setCreateTime(DateUtils.getNowDate());
+        } else if (collection.getIsPackage() == 1) {
+            msg.setTitle("用户信息采集开方");
+            msg.setType(1);
+            msg.setContent("患者:" + name + "的信息采集,前往开方");
+            msg.setDoctorId(collection.getDoctorId());
+            msg.setCreateTime(DateUtils.getNowDate());
+        }
+        return msg;
+    }
+
     @Override
     @Transactional
     public void autoRefund(FsUserInformationCollection collection) {

+ 84 - 0
fs-service/src/main/resources/mapper/doctor/DoctorMsgMapper.xml

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.doctor.mapper.DoctorMsgMapper">
+    
+    <resultMap type="DoctorMsg" id="DoctorMsgResult">
+        <result property="id"    column="id"    />
+        <result property="type"    column="type"    />
+        <result property="title"    column="title"    />
+        <result property="content"    column="content"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="isRead"    column="is_read"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="doctorId"    column="doctor_id"    />
+    </resultMap>
+
+    <sql id="selectDoctorMsgVo">
+        select id, type, title, content, create_time, is_read, update_time, doctor_id from doctor_msg
+    </sql>
+
+    <select id="selectDoctorMsgList" parameterType="DoctorMsg" resultMap="DoctorMsgResult">
+        <include refid="selectDoctorMsgVo"/>
+        <where>  
+            <if test="type != null "> and type = #{type}</if>
+            <if test="title != null  and title != ''"> and title = #{title}</if>
+            <if test="content != null  and content != ''"> and content = #{content}</if>
+            <if test="isRead != null "> and is_read = #{isRead}</if>
+            <if test="doctorId != null "> and doctor_id = #{doctorId}</if>
+        </where>
+    </select>
+    
+    <select id="selectDoctorMsgById" parameterType="Long" resultMap="DoctorMsgResult">
+        <include refid="selectDoctorMsgVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertDoctorMsg" parameterType="DoctorMsg" useGeneratedKeys="true" keyProperty="id">
+        insert into doctor_msg
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="type != null">type,</if>
+            <if test="title != null">title,</if>
+            <if test="content != null">content,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="isRead != null">is_read,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="doctorId != null">doctor_id,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="type != null">#{type},</if>
+            <if test="title != null">#{title},</if>
+            <if test="content != null">#{content},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="isRead != null">#{isRead},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="doctorId != null">#{doctorId},</if>
+         </trim>
+    </insert>
+
+    <update id="updateDoctorMsg" parameterType="DoctorMsg">
+        update doctor_msg
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="type != null">type = #{type},</if>
+            <if test="title != null">title = #{title},</if>
+            <if test="content != null">content = #{content},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="isRead != null">is_read = #{isRead},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="doctorId != null">doctor_id = #{doctorId},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteDoctorMsgById" parameterType="Long">
+        delete from doctor_msg where id = #{id}
+    </delete>
+
+    <delete id="deleteDoctorMsgByIds" parameterType="String">
+        delete from doctor_msg where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>