wangxy 2 дней назад
Родитель
Сommit
819a969e4a

+ 18 - 1
fs-admin/src/main/java/com/fs/web/controller/common/CommonController.java

@@ -4,9 +4,10 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.fs.common.core.domain.R;
+import com.fs.his.service.IFsFourDiagnosisRecordService;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.file.OssException;
-import com.fs.course.dto.BatchSendCourseAllDTO;;
+import com.fs.course.dto.BatchSendCourseAllDTO;
 import com.fs.course.service.ITencentCloudCosService;
 import com.fs.framework.config.ServerConfig;
 import com.fs.his.domain.FsExportTask;
@@ -74,6 +75,9 @@ public class CommonController
     @Autowired
     private IQwUserService qwUserService;
 
+    @Autowired
+    private IFsFourDiagnosisRecordService fourDiagnosisRecordService;
+
     org.slf4j.Logger logger= LoggerFactory.getLogger(getClass());
     @GetMapping(value = "common/getTask/{taskId}")
     public R getTask(@PathVariable("taskId") Long taskId)
@@ -313,4 +317,17 @@ public class CommonController
         return qwUserService.unbindQwUserByServerIds(serverIds);
     }
 
+    @PostMapping("/common/pushFourDiagnosis")
+    public R pushFourDiagnosis(@RequestBody String json) {
+        if (json == null || json.isEmpty()) {
+            return R.error("请求数据不能为空");
+        }
+        try {
+            fourDiagnosisRecordService.receivePush(json);
+            return R.ok("接收成功");
+        } catch (Exception e) {
+            log.error("四诊仪推送记录失败", e);
+            return R.error("系统异常");
+        }
+    }
 }

+ 1 - 0
fs-framework/src/main/java/com/fs/framework/config/SecurityConfig.java

@@ -138,6 +138,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/common/download**").anonymous()
                 .antMatchers("/common/download/resource**").anonymous()
                 .antMatchers("/common/unbindQwUserByServerIds").anonymous()
+                .antMatchers("/common/pushFourDiagnosis").anonymous()
                 .antMatchers("/swagger-ui.html").anonymous()
                 .antMatchers("/swagger-resources/**").anonymous()
                 .antMatchers("/webjars/**").anonymous()

+ 18 - 18
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1861,26 +1861,26 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
                 return R.error("奖励发送失败,请联系客服");
             }
         } else {
-            FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
-            // 添加红包记录
-            redPacketLog.setCourseId(param.getCourseId());
-//            redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
-            redPacketLog.setCompanyId(companyUser.getCompanyId());
-            redPacketLog.setUserId(param.getUserId());
-            redPacketLog.setVideoId(param.getVideoId());
-            redPacketLog.setStatus(1);
-            redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
-            redPacketLog.setCompanyUserId(param.getCompanyUserId());
-            redPacketLog.setCreateTime(new Date());
-            redPacketLog.setAmount(BigDecimal.ZERO);
-            redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
-            redPacketLog.setPeriodId(param.getPeriodId());
-            redPacketLog.setAppId(param.getAppId());
-            redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
+//            FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
+//            // 添加红包记录
+//            redPacketLog.setCourseId(param.getCourseId());
+////            redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
+//            redPacketLog.setCompanyId(companyUser.getCompanyId());
+//            redPacketLog.setUserId(param.getUserId());
+//            redPacketLog.setVideoId(param.getVideoId());
+//            redPacketLog.setStatus(1);
+//            redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
+//            redPacketLog.setCompanyUserId(param.getCompanyUserId());
+//            redPacketLog.setCreateTime(new Date());
+//            redPacketLog.setAmount(BigDecimal.ZERO);
+//            redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
+//            redPacketLog.setPeriodId(param.getPeriodId());
+//            redPacketLog.setAppId(param.getAppId());
+//            redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
 
             // 更新观看记录的奖励类
-            log.setRewardType(config.getRewardType());
-            courseWatchLogMapper.updateFsCourseWatchLog(log);
+//            log.setRewardType(config.getRewardType());
+//            courseWatchLogMapper.updateFsCourseWatchLog(log);
             return R.ok("答题成功,请联系群主");
         }
 

+ 69 - 0
fs-service/src/main/java/com/fs/his/domain/FsFourDiagnosisRecord.java

@@ -0,0 +1,69 @@
+package com.fs.his.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 四诊仪检测档案对象 fs_four_diagnosis_record
+ *
+ * @author fs
+ * @date 2026-05-29
+ */
+@Data
+public class FsFourDiagnosisRecord extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    @Excel(name = "报告编号")
+    private String reportNo;
+
+    @Excel(name = "姓名")
+    private String userName;
+
+    @Excel(name = "手机号")
+    private String mobile;
+
+    @Excel(name = "性别", readConverterExp = "1=男,2=女")
+    private Integer gender;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date birthday;
+
+    private Integer age;
+
+    @Excel(name = "身高(cm)")
+    private BigDecimal height;
+
+    @Excel(name = "体重(kg)")
+    private BigDecimal weight;
+
+    @Excel(name = "职业")
+    private String occupation;
+
+    private String medicalHistory;
+
+    @Excel(name = "证型")
+    private String symptomType;
+
+    @Excel(name = "体质类型")
+    private String tizhiName;
+
+    private String origin;
+
+    @Excel(name = "PDF报告地址")
+    private String reportPdfUrl;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "检测时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date detectTime;
+
+    @Excel(name = "是否删除")
+    private Integer isDel;
+}

+ 23 - 0
fs-service/src/main/java/com/fs/his/domain/FsFourDiagnosisReport.java

@@ -0,0 +1,23 @@
+package com.fs.his.domain;
+
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 四诊仪原始报告数据对象 fs_four_diagnosis_report
+ *
+ * @author fs
+ * @date 2026-05-29
+ */
+@Data
+public class FsFourDiagnosisReport extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    private Long recordId;
+
+    private String reportNo;
+
+    private String reportJson;
+}

+ 21 - 0
fs-service/src/main/java/com/fs/his/mapper/FsFourDiagnosisRecordMapper.java

@@ -0,0 +1,21 @@
+package com.fs.his.mapper;
+
+import com.fs.his.domain.FsFourDiagnosisRecord;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface FsFourDiagnosisRecordMapper {
+
+    FsFourDiagnosisRecord selectFsFourDiagnosisRecordById(Long id);
+
+    FsFourDiagnosisRecord selectByReportNo(@Param("reportNo") String reportNo);
+
+    List<FsFourDiagnosisRecord> selectFsFourDiagnosisRecordList(FsFourDiagnosisRecord record);
+
+    int insertFsFourDiagnosisRecord(FsFourDiagnosisRecord record);
+
+    int updateFsFourDiagnosisRecord(FsFourDiagnosisRecord record);
+
+    int deleteFsFourDiagnosisRecordByIds(Long[] ids);
+}

+ 8 - 0
fs-service/src/main/java/com/fs/his/mapper/FsFourDiagnosisReportMapper.java

@@ -0,0 +1,8 @@
+package com.fs.his.mapper;
+
+import com.fs.his.domain.FsFourDiagnosisReport;
+
+public interface FsFourDiagnosisReportMapper {
+
+    int insertFsFourDiagnosisReport(FsFourDiagnosisReport report);
+}

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

@@ -0,0 +1,19 @@
+package com.fs.his.service;
+
+import com.fs.his.domain.FsFourDiagnosisRecord;
+import java.util.List;
+
+public interface IFsFourDiagnosisRecordService {
+
+    FsFourDiagnosisRecord selectFsFourDiagnosisRecordById(Long id);
+
+    List<FsFourDiagnosisRecord> selectFsFourDiagnosisRecordList(FsFourDiagnosisRecord record);
+
+    int insertFsFourDiagnosisRecord(FsFourDiagnosisRecord record);
+
+    int updateFsFourDiagnosisRecord(FsFourDiagnosisRecord record);
+
+    int deleteFsFourDiagnosisRecordByIds(Long[] ids);
+
+    void receivePush(String json);
+}

+ 154 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsFourDiagnosisRecordServiceImpl.java

@@ -0,0 +1,154 @@
+package com.fs.his.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.utils.DateUtils;
+import com.fs.his.domain.FsFourDiagnosisRecord;
+import com.fs.his.domain.FsFourDiagnosisReport;
+import com.fs.his.mapper.FsFourDiagnosisRecordMapper;
+import com.fs.his.mapper.FsFourDiagnosisReportMapper;
+import com.fs.his.service.IFsFourDiagnosisRecordService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+@Service
+public class FsFourDiagnosisRecordServiceImpl implements IFsFourDiagnosisRecordService {
+
+    private static final Logger log = LoggerFactory.getLogger(FsFourDiagnosisRecordServiceImpl.class);
+
+    @Autowired
+    private FsFourDiagnosisRecordMapper mapper;
+
+    @Autowired
+    private FsFourDiagnosisReportMapper reportMapper;
+
+    @Override
+    public FsFourDiagnosisRecord selectFsFourDiagnosisRecordById(Long id) {
+        return mapper.selectFsFourDiagnosisRecordById(id);
+    }
+
+    @Override
+    public List<FsFourDiagnosisRecord> selectFsFourDiagnosisRecordList(FsFourDiagnosisRecord record) {
+        return mapper.selectFsFourDiagnosisRecordList(record);
+    }
+
+    @Override
+    public int insertFsFourDiagnosisRecord(FsFourDiagnosisRecord record) {
+        return mapper.insertFsFourDiagnosisRecord(record);
+    }
+
+    @Override
+    public int updateFsFourDiagnosisRecord(FsFourDiagnosisRecord record) {
+        return mapper.updateFsFourDiagnosisRecord(record);
+    }
+
+    @Override
+    public int deleteFsFourDiagnosisRecordByIds(Long[] ids) {
+        return mapper.deleteFsFourDiagnosisRecordByIds(ids);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void receivePush(String json) {
+        JSONObject root = JSON.parseObject(json);
+        JSONObject pdfData = extractPdfData(root);
+        String reportNo = getReportNo(pdfData);
+        Integer examStatus = root.getInteger("examStatus");
+
+        if (examStatus != null && examStatus != 66) {
+            log.info("四诊仪检测未完成,跳过处理,reportNo: {}, examStatus: {}", reportNo, examStatus);
+            return;
+        }
+
+        FsFourDiagnosisRecord exist = mapper.selectByReportNo(reportNo);
+        if (exist != null) {
+            log.info("四诊仪检测记录已存在,跳过推送,reportNo: {}", reportNo);
+            return;
+        }
+
+        FsFourDiagnosisRecord record = buildRecord(root, reportNo, pdfData);
+        mapper.insertFsFourDiagnosisRecord(record);
+
+        FsFourDiagnosisReport report = new FsFourDiagnosisReport();
+        report.setRecordId(record.getId());
+        report.setReportNo(reportNo);
+        report.setReportJson(json);
+        report.setCreateTime(DateUtils.getNowDate());
+        reportMapper.insertFsFourDiagnosisReport(report);
+
+        log.info("接收四诊仪检测记录成功,reportNo: {}", reportNo);
+    }
+
+    private JSONObject extractPdfData(JSONObject root) {
+        JSONObject pdfResult = root.getJSONObject("pdfResult");
+        if (pdfResult != null) {
+            return pdfResult.getJSONObject("data");
+        }
+        return null;
+    }
+
+    private String getReportNo(JSONObject pdfData) {
+        if (pdfData != null && pdfData.getLong("reportId") != null) {
+            return String.valueOf(pdfData.getLong("reportId"));
+        }
+        return String.valueOf(System.currentTimeMillis());
+    }
+
+    private FsFourDiagnosisRecord buildRecord(JSONObject root, String reportNo, JSONObject pdfData) {
+        JSONObject examUser = root.getJSONObject("examUser");
+
+        FsFourDiagnosisRecord record = new FsFourDiagnosisRecord();
+        record.setReportNo(reportNo);
+        record.setOrigin(root.getString("origin"));
+        record.setSymptomType(root.getString("symptomType"));
+        record.setTizhiName(root.getString("tizhiName"));
+
+        if (pdfData != null) {
+            record.setReportPdfUrl(pdfData.getString("wordUrl"));
+        }
+
+        if (examUser != null) {
+            record.setUserName(examUser.getString("name"));
+            record.setMobile(examUser.getString("number"));
+            String genderStr = examUser.getString("gender");
+            if ("男".equals(genderStr)) {
+                record.setGender(1);
+            } else if ("女".equals(genderStr)) {
+                record.setGender(2);
+            }
+            if (examUser.getInteger("age") != null) {
+                record.setAge(examUser.getInteger("age"));
+            }
+            if (examUser.getBigDecimal("height") != null) {
+                record.setHeight(examUser.getBigDecimal("height"));
+            }
+            if (examUser.getBigDecimal("weight") != null) {
+                record.setWeight(examUser.getBigDecimal("weight"));
+            }
+            record.setOccupation(examUser.getString("occupation"));
+            String medicalHistory = examUser.getString("medicalHistory");
+            if (medicalHistory != null && !medicalHistory.isEmpty()) {
+                record.setMedicalHistory(medicalHistory);
+            }
+        }
+
+        String examTime = root.getString("examTime");
+        if (examTime != null && !examTime.isEmpty()) {
+            try {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                record.setDetectTime(sdf.parse(examTime));
+            } catch (Exception e) {
+                log.warn("解析检测时间失败: {}", examTime, e);
+            }
+        }
+
+        record.setCreateTime(DateUtils.getNowDate());
+        return record;
+    }
+}

+ 135 - 0
fs-service/src/main/resources/mapper/his/FsFourDiagnosisRecordMapper.xml

@@ -0,0 +1,135 @@
+<?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.his.mapper.FsFourDiagnosisRecordMapper">
+
+    <resultMap type="FsFourDiagnosisRecord" id="FsFourDiagnosisRecordResult">
+        <id     property="id"              column="id"              />
+        <result property="reportNo"        column="report_no"        />
+        <result property="userName"        column="user_name"        />
+        <result property="mobile"          column="mobile"           />
+        <result property="gender"          column="gender"           />
+        <result property="birthday"        column="birthday"         />
+        <result property="height"          column="height"           />
+        <result property="weight"          column="weight"           />
+        <result property="occupation"      column="occupation"       />
+        <result property="medicalHistory"  column="medical_history"  />
+        <result property="symptomType"     column="symptom_type"     />
+        <result property="tizhiName"       column="tizhi_name"       />
+        <result property="origin"          column="origin"           />
+        <result property="reportPdfUrl"    column="report_pdf_url"   />
+        <result property="detectTime"      column="detect_time"      />
+        <result property="createTime"      column="create_time"      />
+        <result property="updateTime"      column="update_time"      />
+        <result property="isDel"           column="is_del"           />
+    </resultMap>
+
+    <sql id="selectFsFourDiagnosisRecordVo">
+        select id, report_no, user_name, mobile, gender, birthday, age, height, weight,
+               occupation, medical_history, symptom_type, tizhi_name, origin,
+               report_pdf_url, detect_time,
+               create_time, update_time, is_del
+        from fs_four_diagnosis_record
+    </sql>
+
+    <select id="selectFsFourDiagnosisRecordById" parameterType="Long" resultMap="FsFourDiagnosisRecordResult">
+        <include refid="selectFsFourDiagnosisRecordVo"/>
+        where id = #{id} and is_del = 0
+    </select>
+
+    <select id="selectByReportNo" parameterType="String" resultMap="FsFourDiagnosisRecordResult">
+        <include refid="selectFsFourDiagnosisRecordVo"/>
+        where report_no = #{reportNo} and is_del = 0
+    </select>
+
+    <select id="selectFsFourDiagnosisRecordList" parameterType="FsFourDiagnosisRecord" resultMap="FsFourDiagnosisRecordResult">
+        <include refid="selectFsFourDiagnosisRecordVo"/>
+        <where>
+            and is_del = 0
+            <if test="reportNo != null and reportNo != ''">and report_no = #{reportNo}</if>
+            <if test="userName != null and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
+            <if test="mobile != null and mobile != ''">and mobile = #{mobile}</if>
+            <if test="gender != null">and gender = #{gender}</if>
+            <if test="symptomType != null and symptomType != ''">and symptom_type = #{symptomType}</if>
+            <if test="tizhiName != null and tizhiName != ''">and tizhi_name = #{tizhiName}</if>
+            <if test="params.beginDetectTime != null and params.beginDetectTime != ''">
+                and detect_time &gt;= #{params.beginDetectTime}
+            </if>
+            <if test="params.endDetectTime != null and params.endDetectTime != ''">
+                and detect_time &lt;= #{params.endDetectTime}
+            </if>
+        </where>
+        order by detect_time desc
+    </select>
+
+    <insert id="insertFsFourDiagnosisRecord" parameterType="FsFourDiagnosisRecord" useGeneratedKeys="true" keyProperty="id">
+        insert into fs_four_diagnosis_record
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="reportNo != null">report_no,</if>
+            <if test="userName != null">user_name,</if>
+            <if test="mobile != null">mobile,</if>
+            <if test="gender != null">gender,</if>
+            <if test="birthday != null">birthday,</if>
+            <if test="age != null">age,</if>
+            <if test="height != null">height,</if>
+            <if test="weight != null">weight,</if>
+            <if test="occupation != null">occupation,</if>
+            <if test="medicalHistory != null">medical_history,</if>
+            <if test="symptomType != null">symptom_type,</if>
+            <if test="tizhiName != null">tizhi_name,</if>
+            <if test="origin != null">origin,</if>
+            <if test="reportPdfUrl != null">report_pdf_url,</if>
+            <if test="detectTime != null">detect_time,</if>
+            create_time
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="reportNo != null">#{reportNo},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="mobile != null">#{mobile},</if>
+            <if test="gender != null">#{gender},</if>
+            <if test="birthday != null">#{birthday},</if>
+            <if test="age != null">#{age},</if>
+            <if test="height != null">#{height},</if>
+            <if test="weight != null">#{weight},</if>
+            <if test="occupation != null">#{occupation},</if>
+            <if test="medicalHistory != null">#{medicalHistory},</if>
+            <if test="symptomType != null">#{symptomType},</if>
+            <if test="tizhiName != null">#{tizhiName},</if>
+            <if test="origin != null">#{origin},</if>
+            <if test="reportPdfUrl != null">#{reportPdfUrl},</if>
+            <if test="detectTime != null">#{detectTime},</if>
+            now()
+        </trim>
+    </insert>
+
+    <update id="updateFsFourDiagnosisRecord" parameterType="FsFourDiagnosisRecord">
+        update fs_four_diagnosis_record
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userName != null">user_name = #{userName},</if>
+            <if test="mobile != null">mobile = #{mobile},</if>
+            <if test="gender != null">gender = #{gender},</if>
+            <if test="birthday != null">birthday = #{birthday},</if>
+            <if test="age != null">age = #{age},</if>
+            <if test="height != null">height = #{height},</if>
+            <if test="weight != null">weight = #{weight},</if>
+            <if test="occupation != null">occupation = #{occupation},</if>
+            <if test="medicalHistory != null">medical_history = #{medicalHistory},</if>
+            <if test="symptomType != null">symptom_type = #{symptomType},</if>
+            <if test="tizhiName != null">tizhi_name = #{tizhiName},</if>
+            <if test="origin != null">origin = #{origin},</if>
+            <if test="reportPdfUrl != null">report_pdf_url = #{reportPdfUrl},</if>
+            <if test="detectTime != null">detect_time = #{detectTime},</if>
+            update_time = now()
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="deleteFsFourDiagnosisRecordByIds">
+        update fs_four_diagnosis_record set is_del = 1 where id in
+        <foreach collection="array" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+</mapper>

+ 23 - 0
fs-service/src/main/resources/mapper/his/FsFourDiagnosisReportMapper.xml

@@ -0,0 +1,23 @@
+<?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.his.mapper.FsFourDiagnosisReportMapper">
+
+    <insert id="insertFsFourDiagnosisReport" parameterType="FsFourDiagnosisReport" useGeneratedKeys="true" keyProperty="id">
+        insert into fs_four_diagnosis_report
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="recordId != null">record_id,</if>
+            <if test="reportNo != null">report_no,</if>
+            <if test="reportJson != null">report_json,</if>
+            create_time
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="recordId != null">#{recordId},</if>
+            <if test="reportNo != null">#{reportNo},</if>
+            <if test="reportJson != null">#{reportJson},</if>
+            now()
+        </trim>
+    </insert>
+
+</mapper>