Kaynağa Gözat

总后台新增用户信息采集总览功能

cgp 1 hafta önce
ebeveyn
işleme
f50b4a1fe9

+ 76 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsUserInformationCollectionController.java

@@ -0,0 +1,76 @@
+package com.fs.hisStore.controller;
+
+import java.util.List;
+
+import com.fs.his.domain.FsPrescribe;
+import com.fs.his.service.IFsPrescribeService;
+import com.fs.hisStore.dto.FsUserInformationCollectionOverviewDTO;
+import com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.hisStore.service.IFsUserInformationCollectionService;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+/**
+ * 用户信息采集Controller
+ *
+ * @author fs
+ * @date 2026-04-03
+ */
+@Slf4j
+@RestController
+@RequestMapping("/hisStore/collection")
+public class FsUserInformationCollectionController extends BaseController {
+
+    @Autowired
+    private IFsUserInformationCollectionService fsUserInformationCollectionService;
+
+    @Autowired
+    IFsPrescribeService fsPrescribeService;
+
+    /**
+     * 查询用户信息采集信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('hisStore:collection:list')")
+    @GetMapping("/listOverview")
+    public TableDataInfo listOverview(FsUserInformationCollectionOverviewDTO queryDto) {
+        startPage();
+        List<FsUserInformationCollectionOverviewVo> list = fsUserInformationCollectionService.selectUserInformationCollectionOverviewByPage(queryDto);
+        return getDataTable(list);
+    }
+
+    /**
+     * 根据用户id查询用户处方列表
+     */
+    @GetMapping("/getPrescribeListByUserId")
+    public TableDataInfo getPrescribeListByUserId(FsPrescribe queryCondition) {
+        startPage();
+        List<FsPrescribe> list = fsPrescribeService.getPrescribeListByUserId(queryCondition);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出用户信息采集列表
+     */
+    @PreAuthorize("@ss.hasPermi('hisStore:collection:export')")
+    @Log(title = "用户信息采集", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsUserInformationCollectionOverviewDTO queryDto) {
+        try {
+            List<FsUserInformationCollectionOverviewVo> list = fsUserInformationCollectionService.selectExportUserInfoCollectionList(queryDto);
+            ExcelUtil<FsUserInformationCollectionOverviewVo> util = new ExcelUtil<>(FsUserInformationCollectionOverviewVo.class);
+            return util.exportExcel(list, "用户信息采集数据");
+        } catch (Exception e) {
+            log.error("导出用户信息采集数据失败", e);
+            return AjaxResult.error("导出失败:" + e.getMessage());
+        }
+    }
+
+}

+ 5 - 0
fs-service/src/main/java/com/fs/his/mapper/FsPrescribeMapper.java

@@ -318,4 +318,9 @@ public interface FsPrescribeMapper
      * 根据处方id更新推送到超拼网的处方状态
      **/
     int updateFsPrescribeListDataCPWByPrescribeIds(@Param("prescriptionIds") List<Long> prescriptionIds);
+
+    /**
+     * 根据用户id列表查询处方列表
+     **/
+    List<FsPrescribe> selectFsPrescribeListByUserIds(@Param("userIds") List<Long> userIds);
 }

+ 10 - 0
fs-service/src/main/java/com/fs/his/service/IFsPrescribeService.java

@@ -132,4 +132,14 @@ public interface IFsPrescribeService
     PageInfo<DoctorOperateStatVO> getDurationList(PrescribeStatParam  param);
 
     void handleReject(PrescribeRejectDTO rejectDTO);
+
+    /**
+     * 根据用户id获取用户处方列表(审核通过的处方)
+     * */
+    List<FsPrescribe> getPrescribeListByUserId(FsPrescribe queryCondition);
+
+    /**
+     * 根据用户id列表获取用户处方列表(审核通过的处方)
+     * */
+    List<FsPrescribe> selectFsPrescribeListByUserIds(List<Long> userIds);
 }

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

@@ -1488,4 +1488,23 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
 
     }
 
+    @Override
+    public List<FsPrescribe> getPrescribeListByUserId(FsPrescribe queryCondition) {
+        queryCondition.setStatus(1);//审核通过
+        List<FsPrescribe> resultList=fsPrescribeMapper.selectFsPrescribeList(queryCondition);
+        if (CollectionUtils.isEmpty(resultList)){
+            return Collections.emptyList();
+        }
+        return resultList;
+    }
+
+    @Override
+    public List<FsPrescribe> selectFsPrescribeListByUserIds(List<Long> userIds) {
+        List<FsPrescribe> resultList=fsPrescribeMapper.selectFsPrescribeListByUserIds(userIds);
+        if (CollectionUtils.isEmpty(resultList)){
+            return Collections.emptyList();
+        }
+        return resultList;
+    }
+
 }

+ 18 - 0
fs-service/src/main/java/com/fs/hisStore/dto/FsUserInformationCollectionOverviewDTO.java

@@ -0,0 +1,18 @@
+package com.fs.hisStore.dto;
+
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class FsUserInformationCollectionOverviewDTO  extends BaseEntity {
+    //用户姓名
+    private String userName;
+    //医生姓名
+    private String doctorName;
+    //销售人员姓名
+    private String companyUserName;
+    //问答模板id
+    private Long questionId;
+}

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

@@ -3,8 +3,10 @@ package com.fs.hisStore.mapper;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.hisStore.domain.FsUserInformationCollection;
+import com.fs.hisStore.dto.FsUserInformationCollectionOverviewDTO;
 import com.fs.hisStore.param.FsUserInformationCollectionListDParam;
 import com.fs.hisStore.vo.FsUserInformationCollectionListDVO;
+import com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -106,4 +108,9 @@ public interface FsUserInformationCollectionMapper extends BaseMapper<FsUserInfo
      * 根据第三方用户id和信息来源查询用户信息采集
      * */
     FsUserInformationCollection getCollectionByInfoSourceAndThirdPartyUserId(FsUserInformationCollection queryCondition);
+
+    /**
+     * 用户信息采集列表总览
+     * */
+    List<FsUserInformationCollectionOverviewVo> selectUserInformationCollectionOverviewByPage(FsUserInformationCollectionOverviewDTO queryDto);
 }

+ 18 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsUserInformationCollectionService.java

@@ -7,10 +7,12 @@ import com.fs.course.param.CollectionInfoConfirmParam;
 import com.fs.course.vo.FsUserInfoCollectionUVO;
 import com.fs.his.domain.FsUserInformationCollectionSchedule;
 import com.fs.hisStore.domain.FsUserInformationCollection;
+import com.fs.hisStore.dto.FsUserInformationCollectionOverviewDTO;
 import com.fs.hisStore.param.FsUserInformationCollectionListDParam;
 import com.fs.hisStore.param.FsUserInformationCollectionParam;
 import com.fs.hisStore.vo.FsUserInformationCollectionListDVO;
 import com.fs.hisStore.vo.FsUserInformationCollectionVO;
+import com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo;
 
 /**
  * 用户信息采集Service接口
@@ -111,4 +113,20 @@ public interface IFsUserInformationCollectionService extends IService<FsUserInfo
     void hasUserCollectionInfo(Long userId);
 
     R addUserCollection(FsUserInformationCollectionParam param);
+
+    /**
+     * 用户信息采集列表总览
+     *
+     * @param queryDto 用户信息采集
+     * @return 用户信息采集集合
+     */
+    List<FsUserInformationCollectionOverviewVo> selectUserInformationCollectionOverviewByPage(FsUserInformationCollectionOverviewDTO queryDto);
+
+    /**
+     * 导出用户信息采集列表
+     *
+     * @param queryDto 用户信息采集
+     * @return 用户信息采集集合
+     */
+    List<FsUserInformationCollectionOverviewVo> selectExportUserInfoCollectionList(FsUserInformationCollectionOverviewDTO queryDto);
 }

+ 74 - 11
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -3,9 +3,7 @@ package com.fs.hisStore.service.impl;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.function.Function;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.hutool.core.date.DateTime;
@@ -14,9 +12,6 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fs.common.BeanCopyUtils;
-import com.fs.common.OrderUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
@@ -30,13 +25,10 @@ import com.fs.company.service.ICompanyService;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 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.erp.dto.ErpRefundUpdateRequest;
-import com.fs.erp.service.IErpOrderService;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.enums.CollectionTaskStatusEnum;
@@ -44,15 +36,16 @@ import com.fs.his.enums.FsStoreOrderLogEnum;
 import com.fs.his.enums.FsStoreOrderStatusEnum;
 import com.fs.his.enums.PrescriptionTaskStepEnum;
 import com.fs.his.mapper.*;
-import com.fs.his.param.FsPrescribeParam;
 import com.fs.his.service.*;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.AnswerVO;
 import com.fs.his.vo.FsQuestionAndAnswerVO;
+import com.fs.hisStore.dto.FsUserInformationCollectionOverviewDTO;
 import com.fs.hisStore.param.FsUserInformationCollectionListDParam;
 import com.fs.hisStore.param.FsUserInformationCollectionParam;
 import com.fs.hisStore.vo.FsUserInformationCollectionListDVO;
 import com.fs.hisStore.vo.FsUserInformationCollectionVO;
+import com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.domain.HuifuConfirmrefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentDelaytransConfirmrefundRequest;
@@ -83,12 +76,10 @@ import com.google.common.collect.Lists;
 import com.google.gson.Gson;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
-import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import com.fs.hisStore.mapper.FsUserInformationCollectionMapper;
 import com.fs.hisStore.domain.FsUserInformationCollection;
@@ -1189,6 +1180,78 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         return R.error("添加信息采集失败");
     }
 
+    @Override
+    public List<FsUserInformationCollectionOverviewVo> selectUserInformationCollectionOverviewByPage(FsUserInformationCollectionOverviewDTO queryDto) {
+        queryDto.setQuestionId(10L); // 问答模板为信息采集表类型
+        List<FsUserInformationCollectionOverviewVo> resultList = fsUserInformationCollectionMapper.selectUserInformationCollectionOverviewByPage(queryDto);
+        if (CollectionUtils.isEmpty(resultList)) {
+            return Collections.emptyList();
+        }
+        return resultList;
+    }
+
+    @Override
+    public List<FsUserInformationCollectionOverviewVo> selectExportUserInfoCollectionList(FsUserInformationCollectionOverviewDTO queryDto) {
+        try {
+            List<FsUserInformationCollectionOverviewVo> resultList = this.selectUserInformationCollectionOverviewByPage(queryDto);
+            if (CollectionUtils.isEmpty(resultList)) {
+                return Collections.emptyList();
+            }
+
+            // 收集用户id查询用户处方列表
+            List<Long> userIds = resultList.stream()
+                    .filter(vo -> vo.getUserId() != null)
+                    .map(FsUserInformationCollectionOverviewVo::getUserId)
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            if (userIds.isEmpty()) {
+                return resultList;
+            }
+
+            List<FsPrescribe> fsPrescribes = prescribeService.selectFsPrescribeListByUserIds(userIds);
+
+            if (CollectionUtils.isEmpty(fsPrescribes)) {
+                for (FsUserInformationCollectionOverviewVo vo : resultList) {
+                    vo.setPrescribeImgUrl(Collections.emptyList());
+                }
+                return resultList;
+            }
+
+            // 转成map<userId,List<FsPrescribe>>
+            Map<Long, List<FsPrescribe>> userIdPrescribeMap = fsPrescribes.stream()
+                    .filter(prescribe -> prescribe.getUserId() != null)
+                    .collect(Collectors.groupingBy(FsPrescribe::getUserId));
+
+            // 遍历resultList赋值处方图片列表
+            for (FsUserInformationCollectionOverviewVo vo : resultList) {
+                if (vo.getUserId() != null) {
+                    List<FsPrescribe> userPrescribes = userIdPrescribeMap.get(vo.getUserId());
+                    if (userPrescribes != null && !userPrescribes.isEmpty()) {
+                        List<String> imgUrlList = userPrescribes.stream()
+                                .filter(prescribe -> prescribe.getPrescribeImgUrl() != null)
+                                .map(FsPrescribe::getPrescribeImgUrl)
+                                .filter(url -> !url.trim().isEmpty())
+                                .collect(Collectors.toList());
+
+                        // 使用setPrescribeImgUrl方法,会自动设置prescribeImgUrlString
+                        vo.setPrescribeImgUrl(imgUrlList);
+                    } else {
+                        vo.setPrescribeImgUrl(Collections.emptyList());
+                    }
+                } else {
+                    vo.setPrescribeImgUrl(Collections.emptyList());
+                }
+            }
+
+            return resultList;
+        } catch (Exception e) {
+            log.error("导出用户信息采集列表时发生错误", e);
+            // 返回基本数据,不包含处方图片信息
+            return this.selectUserInformationCollectionOverviewByPage(queryDto);
+        }
+    }
+
     private List<AnswerVO> getAnswerVOs(List<AnswerVO> target,List<AnswerVO> source) {
         target.addAll(source);
         return target.stream()

+ 107 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsUserInformationCollectionOverviewVo.java

@@ -0,0 +1,107 @@
+package com.fs.hisStore.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 用户信息采集视图对象 - 用于连表查询结果
+ *
+ * @author fs
+ * @date 2026-04-03
+ */
+@Data
+public class FsUserInformationCollectionOverviewVo {
+    /** 主键ID */
+    private Long id;
+
+    /** 用户id */
+    private Long userId;
+
+    /** 信息采集json数据 */
+    private String jsonInfo;
+
+    /** 医生id */
+    private Long doctorId;
+
+    /** 销售id */
+    private Long companyUserId;
+
+    /** 用户姓名 */
+    @Excel(name = "用户姓名")
+    private String userName;
+
+    /** 用户性别 0女 1男 */
+    @Excel(name = "用户性别", readConverterExp = "0=女,1=男")
+    private Long sex;
+
+    /** 用户年龄 */
+    @Excel(name = "用户年龄")
+    private Integer age;
+
+    /** 用户电话后四位 */
+    @Excel(name = "电话尾号")
+    private String userPhoneFour;
+
+    /** 是否过敏 */
+    @Excel(name = "是否过敏")
+    private String allergy;
+
+    /** 备注 */
+    @Excel(name = "备注")
+    private String remark;
+
+    // ======== 关联表字段 ========
+    /** 医生姓名 */
+    @Excel(name = "医生姓名")
+    private String doctorName;
+
+    /** 销售人员姓名 */
+    @Excel(name = "销售人员姓名")
+    private String companyUserName;
+
+    /** 创建时间 */
+    @Excel(name = "创建时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /** 处方图片 - 用于导出显示 */
+    @Excel(name = "处方图片URL")
+    private String prescribeImgUrlString;
+
+    // 原始的List字段,用于内部处理
+    private List<String> prescribeImgUrlList;
+
+    /**
+     * 获取处方图片URL字符串(用于Excel导出)
+     */
+    public String getPrescribeImgUrlString() {
+        if (prescribeImgUrlList != null && !prescribeImgUrlList.isEmpty()) {
+            return String.join(",", prescribeImgUrlList);
+        }
+        return prescribeImgUrlString != null ? prescribeImgUrlString : "";
+    }
+
+    /**
+     * 设置处方图片URL列表(同时设置字符串形式)
+     */
+    public void setPrescribeImgUrl(List<String> prescribeImgUrlList) {
+        this.prescribeImgUrlList = prescribeImgUrlList;
+        // 同时更新字符串形式
+        if (prescribeImgUrlList != null && !prescribeImgUrlList.isEmpty()) {
+            this.prescribeImgUrlString = String.join(",", prescribeImgUrlList);
+        } else {
+            this.prescribeImgUrlString = "";
+        }
+    }
+
+    /**
+     * 获取处方图片URL列表(内部使用)
+     */
+    public List<String> getPrescribeImgUrlList() {
+        return prescribeImgUrlList;
+    }
+}

+ 2 - 1
fs-service/src/main/java/com/fs/hisStore/vo/FsUserInformationCollectionVO.java

@@ -1,6 +1,5 @@
 package com.fs.hisStore.vo;
 
-import com.fs.his.domain.FsPatient;
 import com.fs.his.vo.AnswerVO;
 import lombok.Data;
 
@@ -33,8 +32,10 @@ public class FsUserInformationCollectionVO {
 
     //用户性别 0女 1男
     private Long sex;
+
     //用户姓名
     private String userName;
+
     //用户电话后四位
     private String userPhoneFour;
 

+ 9 - 0
fs-service/src/main/resources/mapper/his/FsPrescribeMapper.xml

@@ -448,6 +448,15 @@
         limit 10
     </select>
 
+    <select id="selectFsPrescribeListByUserIds" resultMap="FsPrescribeResult">
+        <include refid="selectFsPrescribeVo"/>
+        where user_id in
+        <foreach collection="userIds" item="userId" open="(" separator="," close=")">
+            #{userId}
+        </foreach>
+        order by prescribe_id desc
+    </select>
+
     <update id="updateFsPrescribeListDataCPWByPrescribeIds" parameterType="java.util.List">
         update fs_prescribe
         set

+ 56 - 0
fs-service/src/main/resources/mapper/hisStore/FsUserInformationCollectionMapper.xml

@@ -35,6 +35,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="thirdPartyUserId"    column="third_party_user_id"    />
     </resultMap>
 
+    <!-- 用户信息采集视图对象类的ResultMap -->
+    <resultMap type="com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo" id="FsUserInformationCollectionVoResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="jsonInfo"    column="json_info"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="doctorId"    column="doctor_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
+        <result property="age"    column="age"    />
+        <result property="userName"    column="user_name"    />
+        <result property="sex"    column="sex"    />
+        <result property="userPhoneFour"    column="user_phone_four"    />
+        <result property="allergy"    column="allergy"    />
+        <result property="remark"    column="remark"    />
+        <result property="companyUserName"    column="nick_name"    />
+        <result property="doctorName"    column="doctor_name"    />
+    </resultMap>
+
     <sql id="selectFsUserInformationCollectionVo">
         select id, question_id, user_id, json_info, user_confirm
              , doctor_confirm, create_time, update_time,doctor_id,company_user_id
@@ -91,6 +109,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where info_source = #{infoSource} and third_party_user_id = #{thirdPartyUserId}
     </select>
 
+    <select id="selectUserInformationCollectionOverviewByPage"
+            parameterType="com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo"
+            resultMap="FsUserInformationCollectionVoResult">
+        SELECT
+        infocollect.id,
+        infocollect.user_id,
+        infocollect.json_info,
+        infocollect.create_time,
+        infocollect.doctor_id,
+        infocollect.company_user_id,
+        infocollect.age,
+        infocollect.user_name,
+        infocollect.sex,
+        infocollect.user_phone_four,
+        infocollect.allergy,
+        infocollect.remark,
+        cu.nick_name,
+        fd.doctor_name
+        FROM fs_user_information_collection infocollect
+        LEFT JOIN company_user cu ON infocollect.company_user_id = cu.user_id
+        LEFT JOIN fs_doctor fd ON infocollect.doctor_id = fd.doctor_id
+        <where>
+            <if test="userName != null and userName != ''">
+                AND infocollect.user_name LIKE CONCAT('%', #{userName}, '%')
+            </if>
+            <if test="questionId != null and questionId != ''">
+                AND infocollect.question_id LIKE CONCAT('%', #{questionId}, '%')
+            </if>
+            <if test="companyUserName != null and companyUserName != ''">
+                AND cu.nick_name LIKE CONCAT('%', #{companyUserName}, '%')
+            </if>
+            <if test="doctorName != null and doctorName != ''">
+                AND fd.doctor_name LIKE CONCAT('%', #{doctorName}, '%')
+            </if>
+
+        </where>
+        ORDER BY infocollect.create_time DESC
+    </select>
     <insert id="insertFsUserInformationCollection" parameterType="FsUserInformationCollection" useGeneratedKeys="true" keyProperty="id">
         insert into fs_user_information_collection
         <trim prefix="(" suffix=")" suffixOverrides=",">