|  | @ -1,13 +1,18 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.doctor.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.DoctorSpecialDiseaseDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorVo;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.DoctorSpecialDiseaseDo;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.Envelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.utils.security.MD5;
 | 
	
	
		
			
				|  | @ -18,12 +23,15 @@ import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.data.redis.core.StringRedisTemplate;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | import java.util.Random;
 | 
	
		
			
				|  |  | import java.util.concurrent.TimeUnit;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDao> {
 | 
	
	
		
			
				|  | @ -39,6 +47,10 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTemplate;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HibenateUtils hibenateUtils;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private StringRedisTemplate redisTemplate;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -287,14 +299,23 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         baseDoctorDao.updateStatus(doctorId,status);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Boolean updateDoctorPw(String id,String pw){
 | 
	
		
			
				|  |  |     public Boolean updateDoctorPw(String id,String pw,String orgPw){
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findOne(id);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String orgPwMd5 = MD5.md5Hex(orgPw + "{" + doctorDO.getSalt() + "}");
 | 
	
		
			
				|  |  |         if(!orgPwMd5.equals(doctorDO.getPassword())){
 | 
	
		
			
				|  |  |             return false;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //认证信息设置
 | 
	
		
			
				|  |  |         String salt = randomString(5);
 | 
	
		
			
				|  |  |         doctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
 | 
	
		
			
				|  |  |         doctorDO.setSalt(salt);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         baseDoctorDao.save(doctorDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //设置更新时间
 | 
	
		
			
				|  |  |         saveDoctorPwlimitDate(id);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return true;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -311,6 +332,53 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         return buffer.toString();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public com.alibaba.fastjson.JSONObject findDoctorPwlimitDate(String doctor){
 | 
	
		
			
				|  |  |         String key = "hlwyy:authPw:doctor:" + doctor;
 | 
	
		
			
				|  |  |         String authPw = redisTemplate.opsForValue().get(key);
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject valueJson = null;
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(authPw)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("pwOverDue");
 | 
	
		
			
				|  |  |             String code[] = wlyyHospitalSysDictDO.getDictCode().split(",");
 | 
	
		
			
				|  |  |             Integer maxDateInt = Integer.parseInt(code[0]);
 | 
	
		
			
				|  |  |             Integer remainDateInt = Integer.parseInt(code[1]);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             valueJson = JSON.parseObject(authPw);
 | 
	
		
			
				|  |  |             Long updateTimeLong = valueJson.getLong("updateTime");
 | 
	
		
			
				|  |  |             Date updateTime = new Date();
 | 
	
		
			
				|  |  |             updateTime.setTime(updateTimeLong);
 | 
	
		
			
				|  |  |             Date maxDate = DateUtil.getPreDays(updateTime,maxDateInt);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Long betweenDate = (maxDate.getTime() - new Date().getTime())/(60*60*24*1000);
 | 
	
		
			
				|  |  |             valueJson.put("betweenDate",betweenDate);
 | 
	
		
			
				|  |  |             if(betweenDate<remainDateInt){
 | 
	
		
			
				|  |  |                 valueJson.put("remaind",true);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 valueJson.put("remaind",false);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             valueJson = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |             valueJson.put("isChanged",false);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return valueJson;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public boolean saveDoctorPwlimitDate(String doctor){
 | 
	
		
			
				|  |  |         String key = "hlwyy:authPw:doctor:" + doctor;
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject valueJson = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |         valueJson.put("updateTime",new Date().getTime());
 | 
	
		
			
				|  |  |         valueJson.put("isChanged",true);
 | 
	
		
			
				|  |  |         redisTemplate.opsForValue().set(key,valueJson.toJSONString());
 | 
	
		
			
				|  |  |         return true;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //    public static void main(String ag[]){
 | 
	
		
			
				|  |  | //        long betweenDate = (DateUtil.strToDate("2020-04-11","yyyy-MM-dd").getTime() - new Date().getTime())/(60*60*24*1000);
 | 
	
		
			
				|  |  | //        System.out.println(betweenDate);
 | 
	
		
			
				|  |  | //    }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //    public static void main(String ag[]){
 | 
	
		
			
				|  |  | //        String str = "[ " +
 | 
	
		
			
				|  |  | //                "{ " +
 |