Kaynağa Gözat

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

Trick 6 yıl önce
ebeveyn
işleme
9dda22d0b3
19 değiştirilmiş dosya ile 430 ekleme ve 66 silme
  1. 1 1
      business/base-service/src/main/java/com/yihu/jw/message/service/MessageService.java
  2. 0 3
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientMedicardCardService.java
  3. 121 0
      business/base-service/src/main/java/com/yihu/jw/utils/PinYinUtil.java
  4. 1 1
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatService.java
  5. 9 13
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  6. 8 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/patient/PatientRequestMapping.java
  7. 3 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  8. 3 3
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java
  9. 2 9
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  10. 1 1
      svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientApplyLogDao.java
  11. 9 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientFamilyMemberDao.java
  12. 34 3
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myFamily/MyFamilyEndpoint.java
  13. 65 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myMessage/MyMessageEndpoint.java
  14. 6 6
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/wechat/WechatEndPoint.java
  15. 58 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/message/MyDoctorListService.java
  16. 21 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/message/MyMessageService.java
  17. 78 23
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java
  18. 2 2
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientApplyLogService.java
  19. 8 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientFamilyMemberService.java

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/message/service/MessageService.java

@ -139,7 +139,7 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> {
                " AND b.platform = '"+platform+"' " +
                " AND b.receiver = '"+code+"' " +
                " AND b.del = 1 " +
                " AND m.read_state = "+readState;
                " AND b.read_state = "+readState;
        return jdbcTemplate.queryForList(sql);
    }

+ 0 - 3
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientMedicardCardService.java

@ -73,9 +73,6 @@ public class BasePatientMedicardCardService<T, R extends CrudRepository> extends
    public PatientMedicareCardDO findByTypeAndPatientCodeAndDel(String Type,String patientCode,String del)throws Exception{
        PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(Type,patientCode,del);
        if(patientMedicareCardDO==null){
            throw new Exception("no PatientMedicareCard entity");
        }
        return patientMedicareCardDO;
    }
}

+ 121 - 0
business/base-service/src/main/java/com/yihu/jw/utils/PinYinUtil.java

@ -0,0 +1,121 @@
package com.yihu.jw.utils;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class PinYinUtil {
	/** 
     * 获取汉字串拼音首字母,英文字符不变 
     * @param chinese 汉字串 
     * @return 汉语拼音首字母 
     */ 
    public static String getFirstSpell(String chinese) { 
        StringBuffer pybf = new StringBuffer();
        char[] arr = chinese.toCharArray();
        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
            for (int i = 0; i < arr.length; i++) {
                    if (arr[i] > 128) {
                            try {
                                    String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat);
                                    if (temp != null) {
                                            pybf.append(temp[0].charAt(0));
                                    }
                            } catch (BadHanyuPinyinOutputFormatCombination e) {
                                    e.printStackTrace();
                            }
                    } else {
                            pybf.append(arr[i]);
                    }
            }
            return pybf.toString().replaceAll("\\W", "").trim();
    } 
    /** 
     * 获取汉字串拼音,英文字符不变 
     * @param chinese 汉字串 
     * @return 汉语拼音 
     */ 
    public static String getFullSpell(String chinese) { 
            StringBuffer pybf = new StringBuffer(); 
            char[] arr = chinese.toCharArray(); 
            HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); 
            defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); 
            defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); 
            for (int i = 0; i < arr.length; i++) { 
                    if (arr[i] > 128) { 
                            try { 
                                    pybf.append(PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat)[0]); 
                            } catch (BadHanyuPinyinOutputFormatCombination e) { 
                                    e.printStackTrace(); 
                            } 
                    } else { 
                            pybf.append(arr[i]); 
                    } 
            } 
            return pybf.toString(); 
    }
    /**
     * 字符串按拼音排序
     * @param list
     * @return
     */
    public static Map<String,List<Object>> pingYinSortByString(List<String> list){
            Map<String,List<Object>>  map =  new LinkedHashMap<>();
            String[] alphatables = {"a", "b", "c", "d", "e", "f", "g", "h", "i",
                    "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
            for (String alpha : alphatables){
                    for(String one:list){
                            String firstSpell = PinYinUtil.getFirstSpell(one).substring(0,1);
                            if (alpha.equals(firstSpell)){
                                    List<Object> resultList = null;
                                    if(map.get(alpha)==null){
                                            resultList = new ArrayList();
                                    }else{
                                            resultList = map.get(alpha);
                                    }
                                    resultList.add(one);
                                    map.put(alpha,resultList);
                            }
                    }
            }
            return map;
    }
    /**
    * 字符串按拼音排序
    * @param
    * @return
    */
    public static Map<String,Object> pingYinSort(List<Map<String,Object>> result){
            Map<String,Object>  map =  new LinkedHashMap <>();
            String[] alphatables = {"a", "b", "c", "d", "e", "f", "g", "h", "i",
                    "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
            if (result.size() > 0) {
                    for (String alpha : alphatables){
                            List<Map<String,Object>> resultList = new ArrayList<>();
                            for (Map<String,Object> one : result){
                                    String name = String.valueOf(one.get("name"));
                                    String firstSpell = PinYinUtil.getFirstSpell(name).substring(0,1);
                                    if (alpha.equals(firstSpell)){
                                            resultList.add(one);
                                            map.put(alpha,resultList);
                                    }
                            }
                    }
                    return map;
            } else {
                    return map;
            }
    }
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatService.java

@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class WechatService {
public class WechatInfoService {
    @Autowired
    private WechatDao wechatDao;

+ 9 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -2,14 +2,10 @@ package com.yihu.jw.entity.base.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
@ -229,17 +225,17 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    /**
     * 账号是否被锁定
     */
    private int locked;
    private Integer locked;
    /**
     * 是否可以登录
     */
    private int enabled;
    private Integer enabled;
    /**
     * 登录失败次数
     */
    private int loginFailureCount;
    private Integer loginFailureCount;
    /**
     * 锁定日期
@ -568,27 +564,27 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
        this.liveStreetName = liveStreetName;
    }
    public int getLocked() {
    public Integer getLocked() {
        return locked;
    }
    public void setLocked(int locked) {
    public void setLocked(Integer locked) {
        this.locked = locked;
    }
    public int getEnabled() {
    public Integer getEnabled() {
        return enabled;
    }
    public void setEnabled(int enabled) {
    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }
    public int getLoginFailureCount() {
    public Integer getLoginFailureCount() {
        return loginFailureCount;
    }
    public void setLoginFailureCount(int loginFailureCount) {
    public void setLoginFailureCount(Integer loginFailureCount) {
        this.loginFailureCount = loginFailureCount;
    }

+ 8 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/patient/PatientRequestMapping.java

@ -67,6 +67,14 @@ public class PatientRequestMapping {
        public static final String myFamilyBindList  = "/myFamilyBindList";
        public static final String scanQRcode  = "/scanQRcode";
        public static final String messageToBinding  = "/messageToBinding";
        public static final String cancelBindFamily  = "/cancelBindFamily";
        public static final String updateAuthorizeById  = "/updateAuthorizeById";
    }
    public static class MyMessage extends Basic {
        public static final String PREFIX  = "/myMessage";
        public static final String messageList  = "/messageList";
        public static final String myDoctorList  = "/myDoctorList";
    }

+ 3 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -264,7 +264,9 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        }else if("2".equals(loginType)){//2.为医生账号
        }else if("3".equals(loginType)){ //3.患者账号
            String key = "wlyy2:auth:token:"+token.getValue();
            redisTemplate.opsForValue().set(key,"/**");
            redisTemplate.expire(key,token.getExpiresIn(), TimeUnit.SECONDS);
        }else{
            return false;
        }

+ 3 - 3
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -314,10 +314,10 @@ public class WlyyTokenGranter implements TokenGranter {
            String client_id = parameters.get("client_id");
            String username = parameters.get("username");
            String captcha = parameters.get("captcha");
           /* if (!wlyyRedisVerifyCodeService.verification(client_id, username, captcha)){
                //todo cyx  部署应注释掉
           if (!wlyyRedisVerifyCodeService.verification(client_id, username, captcha)){
                throw new InvalidGrantException("Invalid captcha");
            }*/
            }
            SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(username);
            if (!userDetails.isEnabled()) {

+ 2 - 9
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -1,7 +1,5 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.yihu.jw.restmodel.base.wx.WxTemplateConfigVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.model.*;
@ -9,9 +7,6 @@ import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.utils.security.RSAUtils;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -40,14 +35,12 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.PostConstruct;
import javax.crypto.Cipher;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.text.SimpleDateFormat;
@ -410,9 +403,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            params.add("captcha", captcha);
            params.add("openid", parameters.get("openid"));
            HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, reqHeaders);
            Map<String, Object> result = restTemplate.postForObject("http://svr-patient-111:10021/basePatient/regist", httpEntity, HashMap.class);//svr-patient
            Map<String, Object> result = restTemplate.postForObject("http://svr-patient:10021/basePatient/regist", httpEntity, HashMap.class);//svr-patient
            Map<String,Object> obj = (Map<String, Object>) result.get("obj");
            if("1".equals(obj.get("code"))){
            if("1".equals(obj.get("code")+"")){
                registFlag = true;
                parameters.put("username",mobile);
                wlyyRedisVerifyCodeService.store(client_id, mobile, captcha, 120);

+ 1 - 1
svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientApplyLogDao.java

@ -23,6 +23,6 @@ public interface PatientApplyLogDao extends PagingAndSortingRepository<PatientAp
    @Query("update PatientApplyLog t set t.status = ?1 where t.id=?2 ")
    int updateStatusById(Integer status,Integer id);
    @Query("select l from PatientApplyLog l where l.createUser=?1 and l.familyMemberCode=?2 and l.del=1 and l.status in(1,2) and l.failureTime<?3 and l.familyBindRole=?4")
    @Query("select l from PatientApplyLog l where l.createUser=?1 and l.familyMemberCode=?2 and l.del=1 and l.status in(1,2) and l.failureTime>=?3 and l.familyBindRole=?4")
    PatientApplyLog findValidOne(String createUser,String familyMemberCode,Date failureTime,Integer familyBindRole);
}

+ 9 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientFamilyMemberDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.patient.dao.myFamily;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -29,4 +30,12 @@ public interface PatientFamilyMemberDao extends PagingAndSortingRepository<BaseP
    @Query("select m from BasePatientFamilyMemberDO m where m.del=1 and m.patient=?1")
    List<BasePatientFamilyMemberDO> getByPatientAndFamilyMember(String patient);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.isAuthorize = ?1 where m.id=?2 ")
    int updateAuthorizeById(Integer isAuthorize,String id);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.del = ?1 where m.id=?2 ")
    int updateDelById(Integer del,String id);
}

+ 34 - 3
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myFamily/MyFamilyEndpoint.java

@ -145,7 +145,7 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
    public Envelop scanQRcodeConfirmApply(
            @ApiParam(name = "applyPatient", value = "申请人code", required = true)
            @RequestParam(value = "applyPatient",required = true) String applyPatient,
            @ApiParam(name = "applyPatient", value = "家人code", required = false)
            @ApiParam(name = "familyPatient", value = "家人code", required = false)
            @RequestParam(value = "familyPatient",required = false) String familyPatient,
            @ApiParam(name = "familyBindRole", value = "家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女", required = true)
            @RequestParam(value = "familyBindRole",required = true) Integer familyBindRole,
@ -154,8 +154,8 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "status", value = "3、通过,4、拒绝", required = true)
            @RequestParam(value = "status",required = true) Integer status) throws Exception {
        try{
            myFamilyService.scanQRcodeConfirmApply(status,applyPatient,getUID(familyPatient),familyBindRole,isAuthorize);
            return success();
            Map<String,Object> resultMap = myFamilyService.scanQRcodeConfirmApply(status,applyPatient,getUID(familyPatient),familyBindRole,isAuthorize);
            return success(resultMap);
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
@ -175,6 +175,7 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
            return failed(e.getMessage());
        }
    }
    @GetMapping(value = PatientRequestMapping.MyFamily.myFamilyBindList)
    @ApiOperation(value = "我绑定的记录")
    public Envelop myFamilyBindList(
@ -221,4 +222,34 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
            return failed(e.getMessage());
        }
    }
    @PostMapping(value = PatientRequestMapping.MyFamily.cancelBindFamily)
    @ApiOperation(value = "解除绑定家人")
    public Envelop cancelBindFamily(
            @ApiParam(name = "familyMemberId", value = "familyMemberId", required = true)
            @RequestParam(value = "familyMemberId",required = true) String familyMemberId) throws Exception {
        try{
            myFamilyService.cancelBindFamily(familyMemberId);
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @PostMapping(value = PatientRequestMapping.MyFamily.updateAuthorizeById)
    @ApiOperation(value = "更新代管授权")
    public Envelop updateAuthorizeById(
            @ApiParam(name = "isAuthorize", value = "0:未授权,1:已授权", required = true)
            @RequestParam(value = "isAuthorize",required = true) Integer isAuthorize,
            @ApiParam(name = "familyMemberId", value = "familyMemberId", required = true)
            @RequestParam(value = "familyMemberId",required = true) String familyMemberId) throws Exception {
        try{
            myFamilyService.updateAuthorizeById(isAuthorize,familyMemberId);
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
}

+ 65 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myMessage/MyMessageEndpoint.java

@ -0,0 +1,65 @@
package com.yihu.jw.patient.endpoint.myMessage;
import com.yihu.jw.patient.service.message.MyDoctorListService;
import com.yihu.jw.patient.service.message.MyMessageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * @author liuwenbin on 2018/12/10.
 */
@RestController
@RequestMapping(PatientRequestMapping.MyMessage.PREFIX)
@Api(value = "居民的我的消息模块", description = "居民的我的消息模块", tags = {"居民端 - 我的消息"})
public class MyMessageEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private MyMessageService myMessageService;
    @Autowired
    private MyDoctorListService myDoctorListService;
    @GetMapping(value = PatientRequestMapping.MyMessage.messageList)
    @ApiOperation(value = "获取我的消息列表")
    public Envelop messageList(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient",required = false) String patient,
            @ApiParam(name = "page", value = "页码,从第一页开始", required = true)
            @RequestParam(value = "page",required = true) Integer page,
            @ApiParam(name = "pageSize", value = "每页总数", required = true)
            @RequestParam(value = "pageSize",required = true) Integer pageSize) throws Exception {
        try{
            List<Map<String,Object>> messageList = myMessageService.messageList(getUID(patient),page,pageSize);
            return success(messageList);
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @GetMapping(value = PatientRequestMapping.MyMessage.myDoctorList)
    @ApiOperation(value = "获取医生通讯录")
    public Envelop myDoctorList(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient",required = false) String patient,
            @ApiParam(name = "condition", value = "搜索条件,医生姓名/医院", required = false)
            @RequestParam(value = "condition",required = false) String condition) throws Exception {
        try{
            Map<String,Object> messageMap = myDoctorListService.myDoctorList(getUID(patient),condition);
            return success(messageMap);
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
}

+ 6 - 6
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/wechat/WechatEndPoint.java

@ -6,7 +6,7 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.service.WechatService;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import io.swagger.annotations.Api;
import org.json.JSONObject;
@ -29,15 +29,15 @@ import java.util.UUID;
 */
@Controller
@RequestMapping(value = PatientRequestMapping.Wechat.wxBase)
@Api(value = "微信相关操作", description = "微信相关操作", tags = {"居民端 - 微信相关操作"})
public class WechatEndPoint extends EnvelopRestEndpoint {
@Api(value = "获取微信基础信息等操作", description = "获取微信基础信息等操作", tags = {"居民端 - 获取微信基础信息等操作"})
public class WechatInfoEndPoint extends EnvelopRestEndpoint {
    private static Logger logger = LoggerFactory.getLogger(WechatEndPoint.class);
    private static Logger logger = LoggerFactory.getLogger(WechatInfoEndPoint.class);
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WechatService wechatService;
    private WechatInfoService wechatInfoService;
    @Value("${wechat.id}")
    private String wxId;
    /**
@ -79,7 +79,7 @@ public class WechatEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "getOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String getOpenidByCode(String code) {
        return wechatService.getOpenidByCode(code,wxId);
        return wechatInfoService.getOpenidByCode(code,wxId);
    }
    /**

+ 58 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/message/MyDoctorListService.java

@ -0,0 +1,58 @@
package com.yihu.jw.patient.service.message;
import com.yihu.jw.utils.PinYinUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
/**
 * @author liuwenbin on 2018/12/10.
 */
@Service
public class MyDoctorListService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public Map<String,Object> myDoctorList(String patient, String condition)throws Exception{
        String sql = myDoctorListSql(patient,condition);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Object> map = PinYinUtil.pingYinSort(list);
        return map;
    }
    public String myDoctorListSql(String patient, String condition){
        String sql ="SELECT " +
                " r.sign_doctor as doctor, " +
                " r.sign_doctor_name as name, " +
                " r.hospital as hospital, " +
                " r.hospital_name as hospitalName" +
                " FROM " +
                " base_service_package_sign_record r " +
                " WHERE " +
                " ( " +
                "  r.patient IN ( " +
                "   SELECT " +
                "    m.family_member  " +
                "   FROM " +
                "    base_patient_family_member m " +
                "   WHERE " +
                "    m.patient = '"+patient+"' " +
                "   AND m.del = 1 " +
                "   AND m.is_authorize = 1 " +
                "  ) " +
                "  OR r.patient = '"+patient+"' " +
                " ) " +
                " AND r. STATUS = 2 " ;
        if(!StringUtils.isEmpty(condition)){
            sql+=" AND r.sign_doctor_name like '%"+condition+"%' " +
                    " AND r.hospital_name like '%"+condition+"%'";
        }
        return sql;
    }
}

+ 21 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/message/MyMessageService.java

@ -0,0 +1,21 @@
package com.yihu.jw.patient.service.message;
import com.yihu.jw.message.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * @author liuwenbin on 2018/12/10.
 */
@Service
public class MyMessageService {
    @Autowired
    private MessageService messageService;
    public List<Map<String,Object>> messageList(String code,Integer page,Integer pageSize){//1微信端/患者端,2医生APP端
        return messageService.messageList(1,code,page,pageSize);
    }
}

+ 78 - 23
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java

@ -102,8 +102,15 @@ public class MyFamilyService {
        BasePatientDO patientDO = patientService.findByIdAndDel(patient);
        //1、检验手机号码是否有存在账号,
        BasePatientDO familyPatient = patientService.findByMobileAndDel(familyMobile);
        Long time = 1000*60*60*24*Long.valueOf(qrCodeFailurTime);
        if(familyPatient==null){
            //2、没有存在账号的,预注册一个账号,调用预注册接口
            Map<String,Object> map = patientService.bespeakRegist(familyMobile,time);
            if(Integer.valueOf(map.get("code")+"")==1){
                familyPatient = (BasePatientDO)map.get("patient");
            }else{
                throw new Exception(map.get("message")+"");
            }
        }
        //3、生成申请绑定的记录
@ -113,10 +120,14 @@ public class MyFamilyService {
            patientApplyLog.setFamilyMemberName(familyPatient.getName());
            patientApplyLog.setFamilyMemberCode(familyPatient.getId());
            patientApplyLog.setDel(1);
            patientApplyLog.setStatus(1);
            patientApplyLog.setCreateTime(new Date());
            patientApplyLog.setCreateUser(familyPatient.getId());
            patientApplyLog.setCreateUser(patientDO.getId());
            patientApplyLog.setCreateUserName(patientDO.getName());
            patientApplyLog.setFamilyBindRole(familyBindRole);
            Long failurTime = System.currentTimeMillis()+time;
            patientApplyLog.setFailureTime(new Date(failurTime));
            patientApplyLog = patientApplyLogService.save(patientApplyLog);
            //4、发送绑定家人的系统消息
            BaseMessageDO messageDO = new BaseMessageDO();
            messageDO.setReceiver(familyPatient.getId());
@ -134,12 +145,14 @@ public class MyFamilyService {
            messageDO.setReadonly(0);
            messageDO.setDel("1");
            messageDO.setCreateTime(new Date());
            messageDO.setRelationData(patientApplyLog.getId()+"");
            messageService.save(messageDO);
        }else{
            Long failurTime = System.currentTimeMillis()+time;
            patientApplyLog.setFailureTime(new Date(failurTime));
            patientApplyLog = patientApplyLogService.save(patientApplyLog);
        }
        Long time = 1000*60*60*Long.valueOf(qrCodeFailurTime);
        Long failurTime = System.currentTimeMillis()+time;
        patientApplyLog.setFailureTime(new Date(failurTime));
        patientApplyLog = patientApplyLogService.save(patientApplyLog);
//        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient,familyBindRole);
@ -234,15 +247,9 @@ public class MyFamilyService {
        PatientApplyLog patientApplyLog = patientApplyLogService.findById(patientApplyLogId);
        BasePatientDO apply = patientService.findByIdAndDel(patientApplyLog.getCreateUser());
        BasePatientDO family = patientService.findByIdAndDel(patientApplyLog.getFamilyMemberCode());
        Integer converRole = familyRelationTrans(patientApplyLog.getFamilyBindRole(),apply.getSex());
        if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()){
            map.put("key","0");
            map.put("keyName","绑定过期");
            map.put("applyPhoto",apply.getPhoto());
            map.put("familyPhoto",family.getPhoto());
            map.put("explain","您的"+role.get(converRole-1)+apply.getName()+"向您发起的绑定邀请已过期,您可以点下下方邀请绑定按钮,重新邀请绑定家人。");
            return map;
        }
        map.put("applyPhoto",apply.getPhoto());
        map.put("familyPhoto",family.getPhoto());
        patientApplyLog.setStatus(status);
        patientApplyLog.setConfirmTime(new Date());
        patientApplyLogService.save(patientApplyLog);
@ -264,8 +271,6 @@ public class MyFamilyService {
            patientFamilyMember2.setDel(1);
            patientFamilyMemberService.save(patientFamilyMember2);
        }
        map.put("key","1");
        map.put("keyName","绑定成功");
        return map;
    }
@ -278,7 +283,9 @@ public class MyFamilyService {
     * @param isAuthorize
     * @throws Exception
     */
    public void scanQRcodeConfirmApply(Integer status,String applyPatient,String familyPatient,Integer familyBindRole,Integer isAuthorize)throws Exception{
    @Transactional(rollbackFor = Exception.class)
    public Map<String,Object> scanQRcodeConfirmApply(Integer status,String applyPatient,String familyPatient,Integer familyBindRole,Integer isAuthorize)throws Exception{
        Map<String,Object> map = new HashedMap();
        if(status==3){
            BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO();
            patientFamilyMember.setPatient(applyPatient);
@ -296,6 +303,11 @@ public class MyFamilyService {
            patientFamilyMember2.setDel(1);
            patientFamilyMemberService.save(patientFamilyMember2);
        }
        BasePatientDO apply = patientService.findByIdAndDel(applyPatient);
        BasePatientDO family = patientService.findByIdAndDel(familyPatient);
        map.put("applyPhoto",apply.getPhoto());
        map.put("familyPhoto",family.getPhoto());
        return map;
    }
    /**
@ -326,6 +338,15 @@ public class MyFamilyService {
        BaseMessageDO messageDO = messageService.findById(messageId);
        PatientApplyLog patientApplyLog = patientApplyLogService.findById(Integer.valueOf(messageDO.getRelationData()+""));
        Map<String,Object> map = scanQRcode(patientApplyLog.getCreateUser(),patientApplyLog.getFamilyMemberCode(),patientApplyLog.getFamilyBindRole());
        BasePatientDO apply = patientService.findByIdAndDel(patientApplyLog.getCreateUser());
        Integer converRole = familyRelationTrans(patientApplyLog.getFamilyBindRole(),apply.getSex());
        if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()) {
            map.put("overdue", "1");//过期
            map.put("explain", "您的" + role.get(converRole - 1) + apply.getName() + "向您发起的绑定邀请已过期");
        }else {
            map.put("overdue", "0");
        }
        map.put("patientApplyLogId",patientApplyLog.getId());
        return map;
    }
@ -404,11 +425,12 @@ public class MyFamilyService {
            BasePatientDO familyMember = patientService.findByIdAndDel(one.getFamilyMember());
            map.put("photo",familyMember.getPhoto());//头像
            map.put("name",familyMember.getName());//姓名
            map.put("roleName",role.get(one.getFamilyRelation()+1));//角色名称
            map.put("roleName",role.get(one.getFamilyRelation()-1));//角色名称
            map.put("mobile",familyMember.getMobile());//手机号码
            map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权
            map.put("familyMemberId",one.getId());
            map.put("patientId",familyMember.getId());
            map.put("familyPatientId",familyMember.getId());
            map.put("patientId",patient);
            map.put("type",1);
            resultList.add(map);
        }
@ -419,15 +441,20 @@ public class MyFamilyService {
            BasePatientDO familyMember = patientService.findByIdAndDel(one.get("family_member_code")+"");
            map.put("photo",familyMember.getPhoto());//头像
            map.put("name",familyMember.getName());//姓名
            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")+1));//角色名称
            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")-1));//角色名称
            map.put("mobile",familyMember.getMobile());//手机号码
            //有效期
            Date failurTime = (Date)one.get("failure_time");
            Long l = failurTime.getTime()-System.currentTimeMillis();
            Long day24 = 1000*60*60*24L;
            map.put("day",l/day24);
            if(l%day24>0){
                map.put("day",(l/day24)+1);
            }else{
                map.put("day",l/day24);
            }
            map.put("patientApplyId",one.get("id"));
            map.put("patientId",familyMember.getId());
            map.put("familyPatientId",familyMember.getId());
            map.put("patientId",patient);
            map.put("type",2);
            resultList.add(map);
        }
@ -438,7 +465,7 @@ public class MyFamilyService {
            BasePatientDO familyMember = patientService.findByIdAndDel(one.get("family_member_code")+"");
            map.put("photo",familyMember.getPhoto());//头像
            map.put("name",familyMember.getName());//姓名
            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")+1));//角色名称
            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")-1));//角色名称
            map.put("mobile",familyMember.getMobile());//手机号码
            Integer status = null;
            if("1".equals(one.get("status")+"")||"2".equals(one.get("status")+"")){
@ -448,6 +475,8 @@ public class MyFamilyService {
            }
            map.put("status",one.get("status"));//状态
            map.put("statusName",getStatusName(status));//状态名称;
            map.put("familyPatientId",familyMember.getId());
            map.put("patientId",patient);
            map.put("type",3);
            resultList.add(map);
        }
@ -507,6 +536,32 @@ public class MyFamilyService {
        }
    }
    /**
     * 解除绑定
     * @param familyMemberId
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public void cancelBindFamily(String familyMemberId) throws Exception{
        int i = patientFamilyMemberService.cancelBindFamily(familyMemberId);
        if(i<0){
            throw new Exception("update data failur !");
        }
    }
    /**
     * 更新授权
     * @param familyMemberId
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public void updateAuthorizeById(Integer isAuthorize,String familyMemberId) throws Exception{
        int i = patientFamilyMemberService.updateAuthorizeById(isAuthorize,familyMemberId);
        if(i<0){
            throw new Exception("update data failur !");
        }
    }
    /**
     * 家庭关系转换

+ 2 - 2
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientApplyLogService.java

@ -48,13 +48,13 @@ public class PatientApplyLogService extends BaseJpaService<PatientApplyLog, Pati
    //valid 有效
    public List<Map<String, Object>> findValidByPatient(String patient){
        String sql = "select l.* from patient_apply_for_log l where l.create_user='"+patient+"' and l.del=1 and l.status in (1,2) and l.failure_time>="+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss");
        String sql = "select l.* from patient_apply_for_log l where l.create_user='"+patient+"' and l.del=1 and l.status in (1,2) and l.failure_time>='"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+"'";
        return jdbcTemplate.queryForList(sql);
    }
    //invalid 无效
    public List<Map<String, Object>> findInvalidByPatient(String patient){
        String sql = "select l.* from patient_apply_for_log l where l.create_user='"+patient+"' and l.del=1 and (l.status in (4,5) or (l.failure_time>='"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+"' and l.status in (1,2))) limit0,10";
        String sql = "select l.* from patient_apply_for_log l where l.create_user='"+patient+"' and l.del=1 and (l.status in (4,5) or (l.failure_time<='"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+"' and l.status in (1,2))) limit 0,10";
        return jdbcTemplate.queryForList(sql);
    }

+ 8 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientFamilyMemberService.java

@ -52,4 +52,12 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
        return patientFamilyMemberDao.getByPatientAndFamilyMember(patient);
    }
    public Integer cancelBindFamily(String id){
        return patientFamilyMemberDao.updateDelById(0,id);
    }
    public Integer updateAuthorizeById(Integer isAuthorize,String id){
        return patientFamilyMemberDao.updateAuthorizeById(isAuthorize,id);
    }
}