Browse Source

修复电子健康证绑卡的一些小问题。

lighter 2 years ago
parent
commit
d320087b16

+ 0 - 2
src/main/java/thyyxxk/wxservice_server/controller/ElectronicHealthCardController.java

@@ -9,8 +9,6 @@ import thyyxxk.wxservice_server.entity.analyzeidcard.UploadIdCardParam;
 import thyyxxk.wxservice_server.entity.electronichealthcard.ElectronicHealthCard;
 import thyyxxk.wxservice_server.entity.electronichealthcard.RegisterParams;
 import thyyxxk.wxservice_server.service.ElectronicHealthCardService;
-import thyyxxk.wxservice_server.utils.ElectronicHealthCardUtil;
-import thyyxxk.wxservice_server.utils.ResultVoUtil;
 
 import java.util.List;
 

+ 12 - 0
src/main/java/thyyxxk/wxservice_server/dao/ElectronicHealthCardDao.java

@@ -1,11 +1,13 @@
 package thyyxxk.wxservice_server.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import thyyxxk.wxservice_server.entity.electronichealthcard.BatchRegisterParams;
 import thyyxxk.wxservice_server.entity.electronichealthcard.ElectronicHealthCard;
+import thyyxxk.wxservice_server.entity.patientcards.WechatPatientBind;
 
 import java.util.List;
 
@@ -31,6 +33,16 @@ public interface ElectronicHealthCardDao extends BaseMapper<ElectronicHealthCard
     @Update("update t_wechat_patient_bind set electronic_health_card_registered=#{status} where social_no=#{idNumber}")
     void updateHealthCardBatchStatus(int status, String idNumber);
 
+    @Select("select * from t_wechat_patient_bind where patient_id=#{patId} and open_id=#{openId}")
+    WechatPatientBind selectWechatPatientBind(String patId, String openId);
+
+    @Update("update t_wechat_patient_bind set social_no=#{idNumber},del_flag=0,phone=#{phone} where id=#{id}")
+    void unfrozenWechatBind(String idNumber, String phone, int id);
+
+    @Insert("insert into t_wechat_patient_bind (name,patient_id,social_no,phone,open_id,del_flag,is_default) " +
+            "values (#{name},#{patId},#{idNumber},#{phone1},#{openId},0,#{isDefault})")
+    void insertWechatBind(ElectronicHealthCard card);
+
     @Select("select top 1 qr_code_text from t_tencent_electronic_health_card where pat_id=#{patId} ")
     String selectQrCodeText(String patId);
 }

+ 3 - 0
src/main/java/thyyxxk/wxservice_server/entity/electronichealthcard/ElectronicHealthCard.java

@@ -85,4 +85,7 @@ public class ElectronicHealthCard implements Serializable {
 
 	@TableField(exist = false)
 	private String blurIdNumber;
+
+	@TableField(exist = false)
+	private Integer isDefault;
 }

+ 0 - 1
src/main/java/thyyxxk/wxservice_server/entity/electronichealthcard/RegisterParams.java

@@ -25,7 +25,6 @@ public class RegisterParams {
     /**
      * 民族(汉族、满族等)
      * */
-    @NotBlank(message = "民族不能为空。")
     private String nation;
 
     /**

+ 107 - 0
src/main/java/thyyxxk/wxservice_server/entity/patientcards/WechatPatientBind.java

@@ -0,0 +1,107 @@
+package thyyxxk.wxservice_server.entity.patientcards;
+
+import java.io.Serializable;
+import lombok.Data;
+import java.util.Date;
+
+@Data
+public class WechatPatientBind  implements Serializable {
+
+	private static final long serialVersionUID =  1967003563687704271L;
+
+	/**
+	 * id
+	 */
+	private Integer id;
+
+	/**
+	 * name
+	 */
+	private String name;
+
+	/**
+	 * patientId
+	 */
+	private String patientId;
+
+	/**
+	 * socialNo
+	 */
+	private String socialNo;
+
+	/**
+	 * phone
+	 */
+	private String phone;
+
+	/**
+	 * province
+	 */
+	private Integer province;
+
+	/**
+	 * city
+	 */
+	private Integer city;
+
+	/**
+	 * district
+	 */
+	private Integer district;
+
+	/**
+	 * street
+	 */
+	private String street;
+
+	/**
+	 * openId
+	 */
+	private String openId;
+
+	/**
+	 * delFlag
+	 */
+	private Integer delFlag;
+
+	/**
+	 * isDefault
+	 */
+	private Integer isDefault;
+
+	/**
+	 * relation
+	 */
+	private Integer relation;
+
+	/**
+	 * icCardNo
+	 */
+	private String icCardNo;
+
+	/**
+	 * oldIcCardNo
+	 */
+	private String oldIcCardNo;
+
+	/**
+	 * bindDatetime
+	 */
+	private Date bindDatetime;
+
+	/**
+	 * guardName
+	 */
+	private String guardName;
+
+	/**
+	 * guardIdNo
+	 */
+	private String guardIdNo;
+
+	/**
+	 * electronicHealthCardRegistered
+	 */
+	private Integer electronicHealthCardRegistered;
+
+}

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/scheduled/GetWeChatAccessTokenTask.java

@@ -116,7 +116,7 @@ public class GetWeChatAccessTokenTask {
                 }
             }
         } else {
-            PropertiesUtil.writeAccessToken("appToken", "A77DA33ED64E91AB25D7E22AF1C41C82");
+            PropertiesUtil.writeAccessToken("appToken", "4AD891E605DBEAABB9FEFAC2A12BA7F9");
         }
     }
 }

+ 29 - 11
src/main/java/thyyxxk/wxservice_server/service/ElectronicHealthCardService.java

@@ -16,10 +16,14 @@ import thyyxxk.wxservice_server.entity.analyzeidcard.UploadIdCardParam;
 import thyyxxk.wxservice_server.entity.electronichealthcard.BatchRegisterParams;
 import thyyxxk.wxservice_server.entity.electronichealthcard.ElectronicHealthCard;
 import thyyxxk.wxservice_server.entity.electronichealthcard.RegisterParams;
+import thyyxxk.wxservice_server.entity.patientcards.WechatPatientBind;
 import thyyxxk.wxservice_server.utils.*;
 
 import java.util.*;
 
+/**
+ * 电子健康卡卡面规范及素材 <a href="https://open.tengmed.com/openAccess/docs/access#28">...</a>
+ * */
 @Slf4j
 @Service
 public class ElectronicHealthCardService {
@@ -122,21 +126,34 @@ public class ElectronicHealthCardService {
         if (existCount == 0) {
             dao.insert(card);
         }
-        if (StringUtil.isBlank(card.getPatId())) {
-            String patientId = dao.selectLatestBindPatientId(card.getIdNumber());
-            if (null == patientId) {
-                createHisCard(card);
-                patientId = dao.selectLatestBindPatientId(card.getIdNumber());
-            }
-            if (null != patientId) {
-                card.setPatId(patientId);
-                dao.updateHealthCardBatchStatus(Constants.HealthCardBatchRegister.SUCCESS, card.getIdNumber());
-                bindCardRelation(card.getHealthCardId(), card.getQrCodeText(), patientId);
-            }
+        if (StringUtil.notBlank(card.getPatId())) {
+            bindPatIdAndOpenId(card);
+            return ResultVoUtil.success(card);
+        }
+        String patientId = dao.selectLatestBindPatientId(card.getIdNumber());
+        if (null == patientId) {
+            createHisCard(card);
+            patientId = dao.selectLatestBindPatientId(card.getIdNumber());
+        }
+        if (null != patientId) {
+            card.setPatId(patientId);
+            bindPatIdAndOpenId(card);
+            dao.updateHealthCardBatchStatus(Constants.HealthCardBatchRegister.SUCCESS, card.getIdNumber());
+            bindCardRelation(card.getHealthCardId(), card.getQrCodeText(), patientId);
         }
         return ResultVoUtil.success(card);
     }
 
+    private void bindPatIdAndOpenId(ElectronicHealthCard card) {
+        WechatPatientBind bind = dao.selectWechatPatientBind(card.getPatId(), card.getOpenId());
+        if (null == bind) {
+            card.setIsDefault(Objects.equals(card.getRelation(), "0") ? 1 : 0);
+            dao.insertWechatBind(card);
+        } else {
+            dao.unfrozenWechatBind(card.getIdNumber(), card.getPhone1(), bind.getId());
+        }
+    }
+
     public ResultVo<ElectronicHealthCard> register(RegisterParams req) {
         if (!IdCardUtil.isValidatedIdCard(req.getIdNumber())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请输入正确的身份证号码。");
@@ -195,6 +212,7 @@ public class ElectronicHealthCardService {
         }
         if (null != patientId) {
             card.setPatId(patientId);
+            bindPatIdAndOpenId(card);
             dao.updateHealthCardBatchStatus(Constants.HealthCardBatchRegister.SUCCESS, card.getIdNumber());
             bindCardRelation(card.getHealthCardId(), card.getQrCodeText(), patientId);
         }