lighter hai 1 ano
pai
achega
17aea2b8e6

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>11.6</version>
+    <version>11.8</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 

+ 4 - 4
src/main/java/thyyxxk/wxservice_server/Test.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import org.apache.commons.codec.binary.Base64;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import thyyxxk.wxservice_server.utils.SnowFlakeId;
+import thyyxxk.wxservice_server.utils.TokenUtil;
 
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
@@ -14,10 +15,9 @@ import java.util.*;
 
 public class Test {
     public static void main(String[] args) {
-        String carts = "[12,19,49,86]";
-
-        List<Integer> list = JSONArray.parseObject(carts, List.class);
-        System.out.println(list);
+        String openid = "oao6f0y4oF7jd60QhzPzMD9C3bBU";
+        String token = TokenUtil.getInstance().createToken(openid);
+        System.out.println(token);
     }
 
     /**

+ 24 - 22
src/main/java/thyyxxk/wxservice_server/api/WxAppletApi.java

@@ -11,6 +11,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
+import thyyxxk.wxservice_server.config.auth.PassToken;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.constant.AppletOrderType;
 import thyyxxk.wxservice_server.dao.*;
@@ -19,7 +20,6 @@ import thyyxxk.wxservice_server.entity.ResultVo;
 import thyyxxk.wxservice_server.entity.analyzeidcard.IdCardAnalyzeResult;
 import thyyxxk.wxservice_server.entity.appointment.DoctorInfo;
 import thyyxxk.wxservice_server.entity.appointment.MzyReqrec;
-import thyyxxk.wxservice_server.entity.appointment.PatientBriefInfo;
 import thyyxxk.wxservice_server.entity.collections.CollectDoctorParam;
 import thyyxxk.wxservice_server.entity.electronichealthcard.ElectronicHealthCard;
 import thyyxxk.wxservice_server.entity.hrgresponse.HrgCommonResponse;
@@ -87,8 +87,9 @@ public class WxAppletApi {
         this.wxApiDao = wxApiDao;
     }
 
+    @PassToken
     @PostMapping("/getAppletUserInfo")
-    public ResultVo<JSONObject> getAppletUserInfo(@RequestBody AppletUserInquiry inquiry) {
+    public ResultVo<String> getAppletUserInfo(@RequestBody AppletUserInquiry inquiry) {
         AppletType appletType = inquiry.getAppletType();
         if (null == appletType) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "小程序类别不能为空。");
@@ -111,7 +112,12 @@ public class WxAppletApi {
                 .replace("JSCODE", jscode);
         String response = new RestTemplate().getForObject(url, String.class);
         log.info("小程序登录:{}\n参数:{}\n结果:{}", url, JSONObject.toJSON(inquiry), response);
-        return ResultVoUtil.success(JSONObject.parseObject(response));
+        JSONObject obj = JSONObject.parseObject(response);
+        String openid = obj.getString("openid");
+        if (null == openid) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, response);
+        }
+        return ResultVoUtil.success(TokenUtil.getInstance().createToken(openid));
     }
 
     @PostMapping("/createOrder")
@@ -409,13 +415,9 @@ public class WxAppletApi {
         return response;
     }
 
-    @PostMapping("/getBoundCards")
-    public ResultVo<List<PatientBriefInfo>> getBoundCards(@RequestBody CardInquiry inquiry) {
-        AppletType appletType = inquiry.getAppletType();
-        if (null == appletType) {
-            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "小程序类别不能为空。");
-        }
-        String openid = makeSpecialOpenid(appletType, inquiry.getOpenid());
+    @GetMapping("/getBoundCards")
+    public ResultVo<List<OutpatientCard>> getBoundCards(@RequestParam("appletType") AppletType appletType) {
+        String openid = makeSpecialOpenid(appletType);
         log.info("查询小程序绑卡:{}", openid);
         return ResultVoUtil.success(appletDao.getBindPatientCard(openid));
     }
@@ -429,7 +431,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(param.getOpenid())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "openid不能为空。");
         }
-        param.setOpenid(makeSpecialOpenid(appletType, param.getOpenid()));
+        param.setOpenid(makeSpecialOpenid(appletType));
         param.setSocialNo(param.getCardNo());
         log.info("绑定就诊卡:{}", JSONObject.toJSON(param));
         String column = param.getCardType() == 0 ? "patient_id" : "social_no";
@@ -476,7 +478,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(param.getOpenid())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "openid不能为空。");
         }
-        param.setOpenid(makeSpecialOpenid(appletType, param.getOpenid()));
+        param.setOpenid(makeSpecialOpenid(appletType));
         log.info("解除就诊卡绑定:{}", JSONObject.toJSON(param));
         cardsDao.frozenPatientCard(param.getPatientId(), param.getOpenid());
         return ResultVoUtil.success(cardsDao.getBindPatientCard(param.getOpenid()));
@@ -527,8 +529,8 @@ public class WxAppletApi {
         return ResultVoUtil.success(path);
     }
 
-    private String makeSpecialOpenid(AppletType appletType, String openid) {
-        return appletType + "@" + openid;
+    private String makeSpecialOpenid(AppletType appletType) {
+        return appletType + "@" + TokenUtil.getInstance().getUserOpenid();
     }
 
     @PostMapping("/linkHealthCard")
@@ -540,7 +542,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(inquiry.getOpenid())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "openid不能为空。");
         }
-        inquiry.setOpenid(makeSpecialOpenid(appletType, inquiry.getOpenid()));
+        inquiry.setOpenid(makeSpecialOpenid(appletType));
         log.info("小程序关联健康卡:{}", JSONObject.toJSON(inquiry));
         return electronicHealthCardService.linkHealthCard(inquiry.getHealthCode(), inquiry.getOpenid());
     }
@@ -557,7 +559,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(inquiry.getPatientId())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "patientId不能为空。");
         }
-        String openid = makeSpecialOpenid(appletType, inquiry.getOpenid());
+        String openid = makeSpecialOpenid(appletType);
         log.info("设置默认就诊卡:{}", JSONObject.toJSON(inquiry));
         appletDao.updateDefaultCard(inquiry.getPatientId(), openid);
         return ResultVoUtil.success();
@@ -618,7 +620,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(inquiry.getDoctorCode())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "医生编码不能为空。");
         }
-        String openid = makeSpecialOpenid(appletType, inquiry.getOpenid());
+        String openid = makeSpecialOpenid(appletType);
         DoctorInfo doctor = appointmentDao.selectDoctorInfo(inquiry.getDoctorCode(), openid);
         if (null == doctor) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "未找到医生信息!");
@@ -641,7 +643,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(param.getDeptCode())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "科室编码不能为空。");
         }
-        param.setOpenid(makeSpecialOpenid(appletType, param.getOpenid()));
+        param.setOpenid(makeSpecialOpenid(appletType));
         return collectionsService.collectDoctor(param);
     }
 
@@ -657,7 +659,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(param.getDoctorCode())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "医生编码不能为空。");
         }
-        param.setOpenid(makeSpecialOpenid(appletType, param.getOpenid()));
+        param.setOpenid(makeSpecialOpenid(appletType));
         return collectionsService.disCollectDoctor(param);
     }
 
@@ -670,7 +672,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(param.getOpenid())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "openid不能为空。");
         }
-        String openid = makeSpecialOpenid(appletType, param.getOpenid());
+        String openid = makeSpecialOpenid(appletType);
         return collectionsService.getMyCollections2(openid);
     }
 
@@ -683,7 +685,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(param.getOpenid())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "openid不能为空。");
         }
-        param.setOpenid(makeSpecialOpenid(appletType, param.getOpenid()));
+        param.setOpenid(makeSpecialOpenid(appletType));
         return inspectionsService.getExamIndex(param);
     }
 
@@ -696,7 +698,7 @@ public class WxAppletApi {
         if (StringUtil.isBlank(param.getOpenid())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "openid不能为空。");
         }
-        param.setOpenid(makeSpecialOpenid(appletType, param.getOpenid()));
+        param.setOpenid(makeSpecialOpenid(appletType));
         return inspectionsService.checkExamDetail(param);
     }
 

+ 8 - 5
src/main/java/thyyxxk/wxservice_server/dao/AppletDao.java

@@ -2,8 +2,7 @@ package thyyxxk.wxservice_server.dao;
 
 import com.wechat.pay.java.service.payments.model.Transaction;
 import org.apache.ibatis.annotations.*;
-import thyyxxk.wxservice_server.entity.PureCodeName;
-import thyyxxk.wxservice_server.entity.appointment.PatientBriefInfo;
+import thyyxxk.wxservice_server.entity.patientcards.OutpatientCard;
 import thyyxxk.wxservice_server.entity.wxapi.wxapplet.request.BaseInquiry;
 import thyyxxk.wxservice_server.entity.wxapi.wxapplet.response.AppletMallCart;
 import thyyxxk.wxservice_server.entity.wxapi.wxapplet.response.WxAppletOrder;
@@ -66,9 +65,13 @@ public interface AppletDao {
             "</script>")
     void deleteItemByIds(List<Integer> ids);
 
-    @Select("select name, patient_id, phone, social_no, is_default from " +
-            "t_wechat_patient_bind with(nolock) where openid=#{openid} and del_flag=0")
-    List<PatientBriefInfo> getBindPatientCard(String openid);
+    @Select("select a.name,a.patient_id,a.phone,a.social_no,a.is_default, " +
+            "cardType=isnull(b.visit_type,-1),convert(varchar(10), b.lv_date, 21) lvDate, " +
+            "rtrim(b.ic_card_no) as icCardNo from " +
+            "t_wechat_patient_bind a with(nolock),mz_patient_mi b with(nolock) " +
+            "where a.openid=#{openid} and a.del_flag=0 " +
+            "and a.patient_id=b.patient_id")
+    List<OutpatientCard> getBindPatientCard(String openid);
 
     @Update("update t_wechat_pay_order set query_state_times=(query_state_times+1)," +
             "last_query_state=getdate() where trade_no=#{tradeNo}")

+ 5 - 0
src/main/java/thyyxxk/wxservice_server/scheduled/GetWeChatAccessTokenTask.java

@@ -101,6 +101,11 @@ public class GetWeChatAccessTokenTask {
             ResultVo<String> res = new RestTemplate().getForObject(url, ResultVo.class);
             log.info("从服务器获取公众号ACCESS_TOKEN:{}", res.getData());
             PropertiesUtil.writeAccessToken("access_token", res.getData());
+
+            url = "http://192.168.200.3/wxserver/tokenSchedule/getToken?key=qywxToken";
+            res = new RestTemplate().getForObject(url, ResultVo.class);
+            log.info("从服务器获取企业微信ACCESS_TOKEN:{}", res.getData());
+            PropertiesUtil.writeAccessToken("qywxToken", res.getData());
         }
     }
 

+ 2 - 2
src/main/resources/application.yml

@@ -8,8 +8,8 @@ spring:
   thymeleaf:
     cache: false
   datasource:
-#    url: "jdbc:sqlserver://172.16.32.179:1433;databaseName=thxyhisdb"
-    url: "jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb"
+    url: "jdbc:sqlserver://172.16.32.179:1433;databaseName=thxyhisdb"
+#    url: "jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb"
     username: "sa"
     password:
     driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"