Selaa lähdekoodia

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

Conflicts:
	patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
8 vuotta sitten
vanhempi
commit
a40e178f33
33 muutettua tiedostoa jossa 1424 lisäystä ja 574 poistoa
  1. 26 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java
  2. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/data/DataHandlingController.java
  3. 0 17
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/FollowUpDataFilter.java
  4. 68 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  5. 19 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  6. 1 1
      patient-co-statistics/src/main/resources/application.yml
  7. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java
  8. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  9. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowupContentDao.java
  10. 20 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  11. 5 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/PopulationBaseDao.java
  12. 31 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  13. 158 21
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  14. 72 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  15. 124 104
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  16. 141 49
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  17. 38 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java
  18. 108 14
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java
  19. 65 47
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java
  20. 78 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  21. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  22. 2 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  23. 1 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java
  24. 24 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  25. 50 17
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  26. 22 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  27. 145 104
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  28. 50 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java
  29. 38 13
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  30. 41 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  31. 20 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  32. 64 129
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java
  33. 2 0
      patient-co-wlyy/src/main/resources/application.properties

+ 26 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java

@ -467,4 +467,30 @@ public class JobController extends BaseController {
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /******************************** 随访计划消息 ****************************************************/
    @ApiOperation(value = "启动随访计划消息任务")
    @RequestMapping(value = "startFollowupPlantJob", method = RequestMethod.GET)
    public String startFollowupPlantJob() {
        try {
            jobService.startFollowupPlantJob();
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    @ApiOperation(value = "停止随访计划消息任务")
    @RequestMapping(value = "stopFollowupPlantJob", method = RequestMethod.GET)
    public String stopFollowupPlantJob() {
        try {
            jobService.stopFollowupPlantJob();
            return success("停止成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/data/DataHandlingController.java

@ -21,7 +21,7 @@ public class DataHandlingController extends BaseController {
     * 生成医生和患者表中有身份的用户的密码
     * @return
     */
    @RequestMapping(value = "producePatientAndDoctorPassword")
    @RequestMapping(value = "/producePatientAndDoctorPassword")
    @ResponseBody
    public String producePatientAndDoctorPasswor() {
        try {

+ 0 - 17
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/FollowUpDataFilter.java

@ -165,21 +165,4 @@ public class FollowUpDataFilter {
        return FilterModel.getFiltrerMode(logModel,etlModels,isAll);
    }
    private String saveContent(Integer size, Long qkCount, Long orgCount, Long townCount, Long cityCount, boolean isAll, StringBuffer errorContent,Long errorCount,String sql,String filterDate) {
        if(StringUtils.isEmpty(filterDate)){
            filterDate= DateUtil.dateToStrLong(new Date());
        }
        StringBuffer string=new StringBuffer("统计"+filterDate+" 的数据完成 ,数据库查询到数目:"+size);
        string.append(",sql语句:"+sql);
        string.append(",过滤的脏数据数目:"+errorCount);
        string.append(",统计到市的数据总数:"+cityCount);
        string.append(",统计到区的数据总数:"+townCount);
        string.append(",统计到机构的数据总数:"+orgCount);
        string.append(",统计到团队的数据总数:"+qkCount);
        string.append(",是否统计成功:"+isAll);
        if(!isAll){
            string.append(",失败原因:"+errorContent);
        }
        return string.toString();
    }
}

+ 68 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java

@ -170,6 +170,8 @@ public class CurrentDayAllQuotaJob implements Job {
        computequota_15(sql,signFamilies,null);//统计今天的健康分布统计
        //computequota_16_0(sql,signFamilies,null);//统计今天的签约数的未扣费 0
        computequota_17(sql,signFamilies,null);//统计今天的年龄疾病
        computequota_20();//统计今天的已经签约患者绑定设备
        computequota_21();//统计今天的已经签约微信关注人数
        quartzJobLog.setJobContent(allContent.toString());
        quartzJobLog.setJobName("实时统计");
@ -192,6 +194,72 @@ public class CurrentDayAllQuotaJob implements Job {
        redisTemplate.opsForValue().set("quota:timeKey",RedisStorage.timeKey);
    }
    private void computequota_21() {
        try{
            //找出今天的签约信息 yesterday,now
            String sql=" SELECT " +
                    "  sf. CODE, " +
                    "  sf.idcard, " +
                    "  sf.hospital, " +
                    "  sf.admin_team_code " +
                    " FROM " +
                    "  wlyy_patient p, " +
                    "  wlyy_sign_family sf " +
                    " WHERE " +
                    "   p.idcard = sf.idcard " +
                    " AND sf.expenses_status = 1 " +
                    " AND sf.type = 2 " +
                    " AND sf. STATUS IN (1, 2) " +
                    " AND p.openid is not null  " +
                    " AND p.openid_time <'" +tomorrow+"' ";
            //抽取數據
            List<SignFamily> signFamilies= SpringUtil.getBean(DBExtract.class).extract(SignFamily.class,sql);
            //清洗數據
            FilterModel etlModels= SpringUtil.getBean(SignDataFilter.class).filter(signFamilies,sql,"now");
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel1(returnDatas,null,"21");
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        }catch (Exception e){
            e.printStackTrace();
            allContent.append("统计失败:"+e.getMessage());
        }
        allContent.append("-----------1----------");
    }
    private void computequota_20() {
        try{
            String sql=" SELECT " +
                    "  sf. CODE, " +
                    "  sf.idcard, " +
                    "  sf.hospital, " +
                    "  sf.admin_team_code " +
                    " FROM " +
                    "  wlyy_patient_device pd, " +
                    "  wlyy_sign_family sf " +
                    " WHERE " +
                    "  pd.user_idcard = sf.idcard " +
                    " AND sf.expenses_status = 1 " +
                    " AND sf.type = 2 " +
                    " AND sf. STATUS IN (1, 2) " +
                    " AND pd.czrq <' "+tomorrow+"' ";
            //抽取數據
            List<SignFamily> signFamilies=  SpringUtil.getBean(DBExtract.class).extract(SignFamily.class,sql);
            //清洗數據
            FilterModel etlModels= SpringUtil.getBean(SignDataFilter.class).filter(signFamilies,sql,"now");
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel1(returnDatas,null,"20");
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        }catch (Exception e){
            e.printStackTrace();
            allContent.append("统计失败:"+e.getMessage());
        }
        allContent.append("-----------1----------");
    }
    private void initCurrentExpire() {
        try{
            if(StringUtils.isEmpty(currentExpire)){

+ 19 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.statistics.job.business.QuartzHelper;
import com.yihu.wlyy.statistics.job.cache.CacheCleanJob;
import com.yihu.wlyy.statistics.job.check.CheckSignJob;
import com.yihu.wlyy.statistics.job.check.ReportAllLogJob;
import com.yihu.wlyy.statistics.job.message.FollowupPlanJob;
import com.yihu.wlyy.statistics.job.message.HealthMessageJob;
import com.yihu.wlyy.statistics.job.message.NoticeJob;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
@ -475,4 +476,22 @@ public class JobService {
            throw new Exception("已经停止");
        }
    }
    /******************************* 随访计划任务 *******************************************************/
    private String followupJob = "FOLLOWUP_PLAN_JOB";
    public void startFollowupPlantJob() throws Exception {
        if (!quartzHelper.isExistJob(followupJob)) {
            quartzHelper.addJob(FollowupPlanJob.class, FollowupPlanJob.cron, followupJob, new HashMap<>());
        } else {
            throw new Exception("已经启动");
        }
    }
    public void stopFollowupPlantJob() throws Exception {
        if (quartzHelper.isExistJob(followupJob)) {
            quartzHelper.removeJob(followupJob);
        } else {
            throw new Exception("已经停止");
        }
    }
}

+ 1 - 1
patient-co-statistics/src/main/resources/application.yml

@ -77,7 +77,7 @@ multipart:
security:
  basic:
    username: jkzl
    password: jkzlehr@402803a657d14f9f0157d1517f183d50
    password: jkzlehr

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -53,6 +53,9 @@ public interface DevicePatientHealthIndexDao
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate >= ?3 and a.recordDate <= ?4 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
	List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
	@Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 order by a.recordDate desc ")
	Iterable<DevicePatientHealthIndex> findRecentByPatient(String patient);

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -15,6 +15,7 @@ import com.yihu.wlyy.entity.followup.Followup;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>, JpaSpecificationExecutor<Followup> {
@ -24,6 +25,7 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.creater = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByCreater(String creater, Date begin, Date end, Pageable pageRequest) throws Exception;
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code = ?1 and a.patient_code = ?2 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String doctorCode,String patientCode) throws Exception;
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code in ?1 and a.patient_code = ?2 and a.followup_class=?3 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String[] doctors,String patientCode,String followClass) throws Exception;
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowupContentDao.java

@ -18,4 +18,6 @@ public interface FollowupContentDao extends PagingAndSortingRepository<FollowupC
    List<String> findProjectByFollowupId(Long followupId) throws Exception;
    List<FollowupContent> findByFollowupIdAndFollowupProject(Long followupId,String followupProject);
    List<FollowupContent> findByFollowupId(Long followupId);
}

+ 20 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -14,33 +14,43 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface MessageDao extends PagingAndSortingRepository<Message, Long>, JpaSpecificationExecutor<Message> {
    @Query("select count(a) from Message a where a.type =1 and a.read= 1 and a.receiver=?1 ")
    int amountUnreadByReceiver(String doctor);
    @Query("select count(1) from Message a where a.type =1 and a.read= 1 and a.receiver=?1 ")
    Integer amountUnreadByReceiver(String doctor);
    @Query("select a from Message a where a.type =1 and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    Page<Message> amountUnreadLastByReceiver(String doctor, Pageable pageRequest);
    @Query("select count(a) from Message a where a.type =2 and a.read= 1 and a.receiver=?1 ")
    int amountUnreadHealthByReceiver(String doctor);
    @Query("select count(1) from Message a where a.type =2 and a.read= 1 and a.receiver=?1 ")
    Integer amountUnreadHealthByReceiver(String doctor);
    @Query("select a from Message a where (a.type =2 ) and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    Page<Message> amountUnreadHealthLastByReceiver(String doctor,Pageable pageRequest);
    @Query("select a from Message a where a.type =2 and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    List<Message> amountUnreadHealthLastByReceiver(String doctor,Pageable pageRequest);
    @Modifying
    @Query("update Message a set a.read = 0,a.over='0' where a.id = ?1")
    int read(long msgid);
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 and a.signStatus = ?3 and a.read=1")
    Message findByParams(String sender, String receiver, String signStatus);
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 and a.signStatus = ?3 ")
    Message findAllByParams(String sender, String receiver, String signStatus);
    Message findUnreadSign(String sender, String receiver, String signStatus);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 and a.signStatus='1'")
    Message findByPatient(String patient,String doctor);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.sender=?2 and a.tzType=?3")
    List<Message> getHealthIndexMessageByPatient(String doctor,String patient,String type,Pageable pageRequest);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2) order by a.czrq desc")
    List<Message> getSystemMessageUnread(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2)")
    List<Message> getSystemMessage(String doctor,Pageable pageRequest);
    @Query("select count(a) from Message a where a.read = 0 and a.over ='0'  and a.receiver=?1 and a.type=?2 ")
    int findMessageNum(String doctor, Integer type);
}

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/PopulationBaseDao.java

@ -5,6 +5,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Iterator;
import java.util.List;
/**
 * Created by lyr on 2016/08/18.
 */
@ -14,4 +17,6 @@ public interface PopulationBaseDao extends PagingAndSortingRepository<Population
    int findPeopleNumByCode(String code);
    PopulationBase findByCodeAndYear(String code,Integer year);
    List<PopulationBase> findByYear(Integer year);
}

+ 31 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -872,15 +872,23 @@ public class DoctorInfoService extends BaseService {
    }
    @Transactional
    public void updateTeamHealthDoctors(String newDoctorCode, String oldDoctorCode, String patients, String loginUser) throws Exception {
    public Map<String, Integer> updateTeamHealthDoctors(String newDoctorCode, String oldDoctorCode, String patients, String loginUser) throws Exception {
        Map<String, Integer> returnMap = new HashMap();
        String[] patiensString = patients.split(",");
        Integer successs = 0;//转移成功
        Integer error = 0;//转移失败
        for (int i = 0; i < patiensString.length; i++) {
            updateTeamHealthDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
            try {
                updateTeamHealthDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
                successs++;
            } catch (Exception e) {
                error++;
            }
        }
        OperatorLog operatorLog = new OperatorLog();
        operatorLog.setCreateTime(new Date());
        operatorLog.setMethod("/doctor/updateTeamHealthDoctors");
        operatorLog.setMethodName("转换团队中的健康管理师");
        operatorLog.setMethodName("转换团队中的健康管理师:成功:" + successs + ",失败:" + error);
        operatorLog.setCreateUser(loginUser);
        JSONObject jo = new JSONObject();
        jo.put("newDoctorCode", newDoctorCode);
@ -888,6 +896,9 @@ public class DoctorInfoService extends BaseService {
        jo.put("patients", patients);
        operatorLog.setParams(jo.toString());
        operatorLogDao.save(operatorLog);
        returnMap.put("success", successs);
        returnMap.put("error", error);
        return returnMap;
    }
    @Transactional
@ -917,7 +928,7 @@ public class DoctorInfoService extends BaseService {
            return -1;
        }
        if(StringUtils.isNotEmpty(signFamily.getDoctorHealth())){
        if (StringUtils.isNotEmpty(signFamily.getDoctorHealth())) {
            return -2;
        }
@ -1063,10 +1074,20 @@ public class DoctorInfoService extends BaseService {
    }
    @Transactional
    public void updateTeamDoctors(String newDoctorCode, String oldDoctorCode, String patients, String loginUser) throws Exception {
    public Map<String, Integer> updateTeamDoctors(String newDoctorCode, String oldDoctorCode, String patients, String loginUser) throws Exception {
        Map<String, Integer> returnMap = new HashMap();
        String[] patiensString = patients.split(",");
        Integer successs = 0;//转移成功
        Integer error = 0;//转移失败
        for (int i = 0; i < patiensString.length; i++) {
            updateTeamDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
            try {
                updateTeamDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
                successs++;
            } catch (Exception e) {
                error++;
            }
        }
        OperatorLog operatorLog = new OperatorLog();
        operatorLog.setCreateTime(new Date());
@ -1079,6 +1100,10 @@ public class DoctorInfoService extends BaseService {
        jo.put("patients", patients);
        operatorLog.setParams(jo.toString());
        operatorLogDao.save(operatorLog);
        returnMap.put("success", successs);
        returnMap.put("error", error);
        return returnMap;
    }
    private void updateTeamDoctor(String newDoctorCode, String oldDoctorCode, String patient) throws Exception {

+ 158 - 21
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -8,19 +8,25 @@ import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupContent;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowupContentDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.yihu.wlyy.repository.followup.FollowUpDao;
@ -55,6 +61,18 @@ public class FollowUpService extends BaseService {
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private SignFamilyDao signFamilyDao;
	@Autowired
	private DrHealthTeamService drHealthTeamService;
	@Autowired
	private MessageDao messageDao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
	 * 转译随访信息
     */
@ -400,26 +418,6 @@ public class FollowUpService extends BaseService {
	}
	/**
	 * 获取上次随访项目数据
	 */
	public Map<String,String> getLastFollowupProjectData(String doctor,String patient,String followupProject) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		Followup lastFollowup = followupDao.findLastFollowup(doctor,patient);
		if(lastFollowup!=null)
		{
			List<FollowupContent> dataList =  followupContentDao.findByFollowupIdAndFollowupProject(lastFollowup.getId(),followupProject);
			for(FollowupContent item:dataList)
			{
				re.put(item.getFollowupKey(),item.getFollowupValue());
			}
		}
		return re;
	}
	/**
	 *保存面访项目数据
	 */
@ -484,4 +482,143 @@ public class FollowUpService extends BaseService {
	}
	/*************************************** 上次随访 ********************************************/
	/**
	 * 获取团队医生
     */
	private List<Doctor>  getTeamDoctors(String doctor,String patient) throws Exception
	{
		List<Doctor> doctors = new ArrayList<>();
		//获取医生团队成员
		SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
		// 查询家庭医生团队
		if (signFamily != null) {
			doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
		}
		// 查询三师团队医生
		if (doctors == null || doctors.size() == 0) {
			SignFamily sanshiSign = signFamilyDao.findBySanshiDoctorAndPatient(doctor, patient);
			if (sanshiSign != null) {
				doctors = drHealthTeamService.findTeamDoctors(patient, 1);
			} else {
				doctors = new ArrayList<>();
			}
		}
		return doctors;
	}
	/**
	 * 获取上次随访
	 */
	public Map<String,String> getLastFollowup(String doctor,String patient,String followClass) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//获取医生团队成员
		String[] doctors = new String[]{doctor};
		List<Doctor> doctorList = getTeamDoctors(doctor,patient);
		if(doctorList!=null&& doctorList.size()>1)
		{
			doctors = new String[doctorList.size()];
			for(int i=0;i<doctorList.size();i++)
			{
				doctors[i] = doctorList.get(i).getCode();
			}
		}
		//获取最新的随访记录
		Followup followup = followupDao.findLastFollowup(doctors,patient,followClass);
		if(followup!=null)
		{
			re.put("id",String.valueOf(followup.getId()));
			re.put("followupDate",DateUtil.dateToStrShort(followup.getFollowupDate()));
		}
		else{
			re = null;
		}
		return re;
	}
	/**
	 * 获取上次随访
	 */
	public void copyFollowup(Long id,Long fromId) throws Exception
	{
		List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
		if(list!=null && list.size()>0)
		{
			List<FollowupContent> copyList = new ArrayList<>();
			for (FollowupContent item :list)
			{
				FollowupContent copyItem = new FollowupContent();
				copyItem.setFollowupId(id);
				copyItem.setFollowupKey(item.getFollowupKey());
				copyItem.setFollowupValue(item.getFollowupValue());
				copyItem.setFollowupProject(item.getFollowupProject());
				copyItem.setCreateTime(new Date());
				copyList.add(copyItem);
			}
			followupContentDao.save(copyList);
		}
	}
	/**************************************** 随访计划消息 ******************************************/
	/**
	 * 每日发送随访计划提醒消息
     */
	@Transactional
	public void sendMessage(String date)
	{
	    try{
			String start = date +" 00:00:00";
			String end = date +" 23:59:59";
			String sql = "select doctor_code,count(1) count from wlyy_followup where status not in ('0','1') and followup_plan_date>='"+start+"' and followup_plan_date<='"+end+"' group by doctor_code";
			//获取所有未执行随访计划
			List<Map<String,Object>> followupToday = jdbcTemplate.queryForList(sql);
			if(followupToday!=null)
			{
				List<Message> list = new ArrayList<>();
				for(Map<String,Object> map:followupToday)
				{
					String doctor = String.valueOf(map.get("doctor_code"));
					String count = String.valueOf(map.get("count"));
					// 添加签约消息
					String title = "随访计划提醒";
					String content = "您今日有" +count+"个随访计划待处理";
					Message message = new Message();
					message.setCode(getCode());
					message.setCzrq(new Date());
					message.setContent(content);
					message.setRead(1);//设置未读
					message.setReceiver(doctor);//设置接受医生的code
					message.setSender("system");//设置发送的用户
					message.setTitle(title);
					message.setType(4);//随访计划提醒
					message.setReadonly(1);//是否只读消息
					list.add(message);
					// 推送消息给医生
					PushMsgTask.getInstance().put(doctor,"4",title,content,"");
				}
				messageDao.save(list);
			}
		}
		catch (Exception e)
		{
		   e.printStackTrace();
		}
	}
}

+ 72 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -383,11 +383,12 @@ public class PatientHealthIndexService extends BaseService {
            // 餐后
            if (index % 2 == 0) {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
                    msgContent += patient.getName() + "饭后血糖超标,血糖值" + value1 + ",参考范围:" + minValueAfter + " ~ " + maxValueAfter + ";\n";
                    msgContent += patient.getName() + "血糖异常("+value1+"mmol/L),请处理";
                }
            } else { //餐前
            }
            else { //餐前
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter)) {
                    msgContent += patient.getName() + "饭前血糖超标,血糖值" + value1 + ",参考范围:" + minValueBefore + " ~ " + maxValueBefore + ";\n";
                    msgContent += patient.getName() + "血糖异常("+value1+"mmol/L),请处理";
                }
            }
        }
@ -415,13 +416,9 @@ public class PatientHealthIndexService extends BaseService {
                    minValueSZY = standard.getMinValue2();
                }
            }
            // 收缩压校验
            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY)) {
                msgContent += "血压超标,收缩压" + value1 + ",参考范围:" + minValueSSY + " ~ " + maxValueSSY + ";\n";
            }
            // 舒张压
            if (!checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)) {
                msgContent += "血压超标,舒张压" + value2 + ",参考范围:" + minValueSZY + " ~ " + maxValueSZY + ";\n";
            // 收缩压/舒张压校验
            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY)||!checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)) {
                msgContent = patient.getName() +"血压异常(舒张压 "+value2+"mmHg、收缩压 "+value1+"mmHg),请处理";
            }
        }
@ -777,4 +774,69 @@ public class PatientHealthIndexService extends BaseService {
        }
    }
    /**
     * 获取患者健康指标历史记录
     * 1血糖,2血压,3体重,4腰围
     */
    public List<Map<String,String>> getHealthIndexHistory(String patientCode, int type,int page,int pagesize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Direction.DESC, "recordDate");
        PageRequest pageRequest = new PageRequest(page, pagesize, sort);
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatient(patientCode, type, pageRequest);
        if (list != null && list.size() > 0) {
            for (DevicePatientHealthIndex item : list) {
                Map<String, String> map = new HashMap<>();
                if (type == 1)    //血糖
                {
                    String gi = item.getValue1();
                    String giType = item.getValue2();
                    map.put("time", DateUtil.dateToStrLong(item.getRecordDate()));
                    map.put("gi", gi); //  血糖值
                    map.put("gi_type", giType); //  血糖值类型
                    String text = gi + " mmol/L";
                    if ("1".equals(giType)) {
                        text += "(早餐前)";
                    } else if ("2".equals(giType)) {
                        text += "(早餐后)";
                    } else if ("3".equals(giType)) {
                        text += "(午餐前)";
                    } else if ("4".equals(giType)) {
                        text += "(午餐后)";
                    } else if ("5".equals(giType)) {
                        text += "(晚饭前)";
                    } else if ("6".equals(giType)) {
                        text += "(晚饭后)";
                    } else if ("7".equals(giType)) {
                        text += "(睡前)";
                    }
                    map.put("text", text); //  展示
                    re.add(map);
                } else if (type == 2) //血压
                {
                    String sys = item.getValue1();   //收缩压
                    String dia = item.getValue2();    //舒张压
                    String pul = item.getValue3();    //脉搏
                    map.put("time", DateUtil.dateToStrLong(item.getRecordDate()));
                    map.put("sys", sys);
                    map.put("dia", dia);
                    map.put("pul", pul);
                    re.add(map);
                } else if (type == 3) //体重
                {
                    String weight = item.getValue1();   //体重
                    map.put("time", DateUtil.dateToStrShort(item.getRecordDate()));
                    map.put("weight", weight);
                    map.put("text", weight + " kg");
                    re.add(map);
                }
            }
        }
        return re;
    }
}

+ 124 - 104
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -161,29 +161,29 @@ public class SignPatientLabelInfoService extends BaseService {
        }
        if (json.has("expensesStatus") && (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0"))) {
            String epTime = "";
            boolean epTime = false;
            try {
                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (StringUtils.isEmpty(epTime)) {
            if (!epTime) {
                json.put("expensesRemindStatus", 0);
            } else {
                json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                json.put("expensesRemindStatus", 1);
            }
        }
        String epTime = "";
        boolean epTime = false;
        try {
            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (StringUtils.isEmpty(epTime)) {
        if (!epTime) {
            json.put("wechatFocusRemind", 0);
        } else {
            json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
            json.put("wechatFocusRemind", 1);
        }
        return json;
@ -303,28 +303,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set",  p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -369,32 +369,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                //json.put("labels", labels == null ? "" : labels);
@ -457,28 +457,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
@ -536,32 +536,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -700,6 +700,16 @@ public class SignPatientLabelInfoService extends BaseService {
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t1.openid,''))) > 0 ";
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
                    focusAmount = Integer.valueOf(String.valueOf(focusCount.get(0).get("count")));
                }
                json.put("focusAmount", focusAmount);
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                    continue;
                }
@ -857,6 +867,16 @@ public class SignPatientLabelInfoService extends BaseService {
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t1.openid,''))) > 0 ";
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
                    focusAmount = Integer.valueOf(String.valueOf(focusCount.get(0).get("count")));
                }
                json.put("focusAmount", focusAmount);
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                    continue;
                }
@ -1282,28 +1302,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -1371,32 +1391,32 @@ public class SignPatientLabelInfoService extends BaseService {
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -1746,28 +1766,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -1832,32 +1852,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -1924,29 +1944,29 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -1997,32 +2017,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -2142,29 +2162,29 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -2209,32 +2229,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                //json.put("labels", labels == null ? "" : labels);

+ 141 - 49
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -7,9 +7,11 @@ import javax.transaction.Transactional;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -17,6 +19,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
@ -46,6 +49,17 @@ public class MessageService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
    /**
     * IM消息数量
     */
    private String getImMsgAmount(String doctor) {
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "/api/v1/chats/msg/amount?user_id=" + doctor;
        return HttpClientUtil.get(url, "UTF-8");
    }
    /**
     * 汇总查询医生的消息总数
@ -73,11 +87,8 @@ public class MessageService extends BaseService {
    /**
     * 查询医生未读消息和最后消息
     *
     * @param doctor
     * @return
     */
    public JSONObject findDoctorAllMessage(String doctor) {
    public JSONObject findDoctorAllMessage(String doctor) throws Exception {
        // 签约未读消息总数
        int sign = messageDao.amountUnreadByReceiver(doctor);
@ -90,54 +101,62 @@ public class MessageService extends BaseService {
            if (msgs != null && msgs.getSize() > 0) {
                for (Message msg : msgs) {
                    JSONObject msgJson = new JSONObject();
                    msgJson.put("title", msg.getTitle());
                    msgJson.put("type", msg.getType());
                    if (msg.getSignStatus().equals("4")) {
                        msgJson.put("msg", msg.getSenderName() + "申请与您解除家庭签约");
                    } else {
                        msgJson.put("msg", msg.getSenderName() + "申请与您签约家庭医生");
                    }
                    msgJson.put("msgTime", msg.getCzrq() != null ? DateUtil.dateToStr(msg.getCzrq(), DateUtil.YYYY_MM_DD) : "");
                    msgJson.put("msgTime", DateUtil.dateToStrLong(msg.getCzrq()));
                    signJson.put("lastMessage", msgJson);
                }
            }
        }
        // 体征指标未读消息总数
        int healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
        Integer healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
        JSONObject indexJson = new JSONObject();
        indexJson.put("amount", healthIndex);
        if (sign > 0) {
        if (healthIndex > 0) {
            PageRequest pageRequest = new PageRequest(0, 1);
            Page<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
            List<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
            if (msgs != null && msgs.getSize() > 0) {
                for (Message msg : msgs) {
                    JSONObject msgJson = new JSONObject();
                    msgJson.put("msg", msg.getContent());
                    msgJson.put("msgTime", msg.getCzrq() != null ? DateUtil.dateToStr(msg.getCzrq(), DateUtil.YYYY_MM_DD) : "");
                    indexJson.put("lastMessage", msgJson);
                }
            if (msgs != null && msgs.size() > 0) {
                JSONObject msgJson = new JSONObject();
                msgJson.put("title", msgs.get(0).getTitle());
                msgJson.put("type", msgs.get(0).getType());
                msgJson.put("msg", msgs.get(0).getContent());
                msgJson.put("msgTime", DateUtil.dateToStrLong(msgs.get(0).getCzrq()));
                indexJson.put("lastMessage", msgJson);
            }
        }
        //获取系统消息总数
        int count= messageDao.findMessageNum(doctor,3);
        //获取未读系统消息
        List<Message> systemMessage = messageDao.getSystemMessageUnread(doctor);
        JSONObject systemJson = new JSONObject();
        systemJson.put("amount", count);
        JSONObject json = new JSONObject();
        getImMsgAmount(json,doctor);//IM消息数量
        if (systemMessage != null && systemMessage.size() > 0) {
            systemJson.put("amount", systemMessage.size());
            JSONObject msgJson = new JSONObject();
            msgJson.put("title", systemMessage.get(0).getTitle());
            msgJson.put("type", systemMessage.get(0).getType());
            msgJson.put("msg", systemMessage.get(0).getContent());
            msgJson.put("msgTime", DateUtil.dateToStrLong(systemMessage.get(0).getCzrq()));
            systemJson.put("lastMessage", msgJson);
        } else {
            systemJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
        json.put("sign", signJson);//签约数
        json.put("healthIndex", indexJson);//健康指标
        json.put("system", systemJson);//系统消息
        return json;
    }
    private void  getImMsgAmount(JSONObject obj,String doctor){
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "/api/v1/chats/msg/amount?user_id="+doctor;
        String response = HttpClientUtil.get(url, "UTF-8");
        obj.put("imMsgCount",response);
    }
    /**
     * 查询健康咨询列表
     *
@ -203,14 +222,11 @@ public class MessageService extends BaseService {
    }
    /**
     * 根据参数查询指定的消息
     *
     * @return
     * 未读签约信息
     */
    public Message findMessage(String sender, String receiver, String signStatus) {
    public Message findUnreadSign(String sender, String receiver, String signStatus) {
        return messageDao.findByParams(sender, receiver, signStatus);
        return messageDao.findUnreadSign(sender, receiver, signStatus);
    }
    public Page<Message> find(String doctor, String type, long id, int pagesize) {
@ -233,27 +249,103 @@ public class MessageService extends BaseService {
    }
    public JSONObject findMessageNum(String doctor, Integer type) {
        JSONObject jo=new JSONObject();
        JSONObject jo = new JSONObject();
        //得到消息总数
        int count= messageDao.findMessageNum(doctor,type);
        String DateString="";
        String message="";
        String sql="select w.* from wlyy_message w where w.type='"+type+"' and w.receiver='"+doctor+"' order by w.czrq desc limit 0,1";
        List<Message> returnList= jdbcTemplate.query(sql,new BeanPropertyRowMapper(Message.class));
        if(returnList!=null&&returnList.size()>0){
            Message m=returnList.get(0);
            DateString=DateUtil.dateToStrShort(m.getCzrq());
            message=m.getContent();
        int count = messageDao.findMessageNum(doctor, type);
        String DateString = "";
        String message = "";
        String sql = "select w.* from wlyy_message w where w.type='" + type + "' and w.receiver='" + doctor + "' order by w.czrq desc limit 0,1";
        List<Message> returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(Message.class));
        if (returnList != null && returnList.size() > 0) {
            Message m = returnList.get(0);
            DateString = DateUtil.dateToStrShort(m.getCzrq());
            message = m.getContent();
        }
        jo.put("count",count);
        jo.put("message",message);
        jo.put("date",DateString);
        jo.put("count", count);
        jo.put("message", message);
        jo.put("date", DateString);
        return jo;
    }
    public void changeMessageToRead(Long id) {
        Message message= messageDao.findOne(id);
        message.setRead(1);
    /**
     * 获取超标指标消息--根据患者分组
     */
    public List<Map<String, Object>> getHealthIndexMessage(String doctor) throws Exception {
        List<Map<String, Object>> re = new ArrayList<>();
        String sql = "select a.sender,a.tz_type,count(1) count,max(date_format(a.czrq,'%Y-%c-%d %h:%i:%s')) last_time from wlyy_Message a where a.receiver='" + doctor + "' and a.has_read='1' and a.type='2' group by a.sender,a.tz_type order by last_time desc";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> item : list) {
            Map<String, Object> obj = new HashMap<>();
            String patientCode = String.valueOf(item.get("sender"));
            //获取患者信息
            Patient patient = patientDao.findByCode(patientCode);
            if (patient != null) {
                String type = String.valueOf(item.get("tz_type")); //1血糖,2血压,3体重,4腰
                obj.put("patient", patientCode);
                obj.put("type", type);
                obj.put("time", item.get("last_time"));
                obj.put("name", patient.getName());
                obj.put("sex", patient.getSex());
                obj.put("birthday", DateUtil.dateToStrShort(patient.getBirthday()));
                obj.put("sex", patient.getSex());
                obj.put("photo", patient.getPhoto());
                if ("1".equals(type)) {
                    obj.put("message", "有" + item.get("count") + "条血糖异常未读消息");
                } else if ("2".equals(type)) {
                    obj.put("message", "有" + item.get("count") + "条血压异常未读消息");
                } else {
                    break;
                }
                re.add(obj);
            } else {
                System.out.print("not exit patient!code:" + patientCode);
            }
        }
        return re;
    }
    /**
     * 获取患者超标指标消息
     */
    public List<Map<String, String>> getHealthIndexMessageByPatient(String doctor, String patient, String type, Integer page, Integer pagesize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "czrq");
        Pageable pageRequest = new PageRequest(page - 1, pagesize, sort);
        List<Message> list = messageDao.getHealthIndexMessageByPatient(doctor, patient, type, pageRequest);
        if (list != null && list.size() > 0) {
            for (Message item : list) {
                Map<String, String> map = new HashMap<>();
                map.put("id", String.valueOf(item.getId()));
                map.put("sender", item.getSender());
                map.put("senderName", item.getSenderName());
                map.put("senderPhoto", item.getSenderPhoto());
                map.put("type", type);
                map.put("read", String.valueOf(item.getRead()));
                map.put("sex", String.valueOf(item.getSex()));
                map.put("value1", String.valueOf(item.getValue1()));
                map.put("value2", String.valueOf(item.getValue2()));
                map.put("czrq", DateUtil.dateToStrLong(item.getCzrq()));
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 获取系统消息
     */
    public List<Message> getSystemMessage(String doctor,Integer page,Integer pagesize) throws Exception
    {
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "czrq");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, pagesize,sort);
        return messageDao.getSystemMessage(doctor,pageRequest);
    }
}

+ 38 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java

@ -42,6 +42,25 @@ public class DoctorQuickReplyService extends BaseService {
        return quickReplyDao.save(reply);
    }
    /**
     * 修改快捷回复
     *
     * @param id      回复ID
     * @param content 快捷回复内容
     * @return
     */
    public DoctorQuickReply modifyReply(long id, String content) throws Exception {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        if (reply == null) {
            throw new Exception("reply not exist");
        }
        reply.setContent(content);
        return quickReplyDao.save(reply);
    }
    /**
     * 删除快捷回复
     *
@ -108,4 +127,23 @@ public class DoctorQuickReplyService extends BaseService {
        return 1;
    }
    /**
     * 排序回复
     *
     * @param id
     * @return
     */
    public int sortReplyList(String id) {
        String[] ids = id.split(",");
        for (int i = 0; i < ids.length; i++) {
            DoctorQuickReply reply = quickReplyDao.findOne(Long.valueOf(ids[i]));
            if (reply == null) {
                return -1;
            }
            reply.setSort(ids.length - i);
        }
        return 1;
    }
}

+ 108 - 14
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java

@ -1,12 +1,13 @@
package com.yihu.wlyy.service.app.reservation;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import javax.transaction.Transactional;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -39,21 +40,47 @@ public class PatientReservationService extends BaseService {
	private PatientReservationDao patientReservationDao;
	@Autowired
	private PatientReservationDoctorDao patientReservationDoctorDao;
	
	@Autowired
	private GuahaoXMService  guahaoXMService;
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private PatientDao patientDao;
	public PatientReservation findByCode(String code){
		return patientReservationDao.findByCode(code);
	}
	public PatientReservation findById(String id){
		return patientReservationDao.findById(Long.valueOf(id));
	public PatientReservation findById(Long id) throws Exception{
		PatientReservation re = patientReservationDao.findById(id);
		if(re==null)
		{
			throw new Exception("not exit result!id:"+id);
		}
		return re;
	}
	/**
	 * 实体转map
	 */
	private Map<String, String> entityToMap(PatientReservation obj) throws Exception {
		String mapString = objectMapper.writeValueAsString(obj);
		return objectMapper.readValue(mapString, Map.class);
	}
	/**
	 * 更新预约状态
     */
	public void updateStatus(String code,Integer status)
	@Transactional
	public void updateStatus(Long id,Integer status)
	{
		PatientReservation obj=  patientReservationDao.findByCode(code);
		PatientReservation obj=  patientReservationDao.findOne(id);
		if(!obj.getStatus().equals(status))
		{
			obj.setStatus(status);
@ -153,26 +180,93 @@ public class PatientReservationService extends BaseService {
	/**
	 * 分页获取患者预约记录,医生为空查患者所有
     */
	public List<PatientReservation> getReservationByPatient(String patient,String doctor, int page, int pagesize) {
	@Transactional
	public List<PatientReservation> getReservationByPatient(String patient,String doctor, int page, int pagesize) throws Exception
	{
		List<PatientReservation> list = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		if(StringUtils.isNotBlank(doctor)){//传入医生查询医生帮此患者的预约记录
			return patientReservationDao.findByPatientAndDoctor(patient, doctor, pageRequest);
			list = patientReservationDao.findByPatientAndDoctor(patient, doctor, pageRequest);
		}else{
			return patientReservationDao.findByPatient(patient, pageRequest);
			list = patientReservationDao.findByPatient(patient, pageRequest);
		}
		//更新当前状态
		if(list!=null)
		{
			//遍历更新预约状态
			for (PatientReservation item : list) {
				String type = item.getType();
				String code = item.getCode();
				if (type.equals("0")) {  //医护网接口
				}
				else if (type.equals("1"))   //厦门市民健康预约接口
				{
					Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
					//更新状态
					if (status != null && !status.equals(item.getStatus())) {
						item.setStatus(status);
					}
				}
			}
			patientReservationDao.save(list);
		}
		return list;
	}
	/**
	 * 分页获取患者预约记录(医生端)
	 */
	public List<PatientReservation> getReservationByDoctor(String doctor, int page, int pagesize) {
	public List<Map<String,String>> getReservationByDoctor(String doctor, int page, int pagesize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		return patientReservationDao.findByDoctor(doctor, pageRequest);
		List<PatientReservation> list = patientReservationDao.findByDoctor(doctor, pageRequest);
		//更新当前状态
		if(list!=null)
		{
			//遍历更新预约状态
			for (PatientReservation item : list) {
				String type = item.getType();
				String code = item.getCode();
				if (type.equals("0")) {  //医护网接口
				}
				else if (type.equals("1"))   //厦门市民健康预约接口
				{
					Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
					//更新状态
					if (status != null && !status.equals(item.getStatus())) {
						item.setStatus(status);
					}
				}
			}
			patientReservationDao.save(list);
		}
		//返回患者头像
		for (PatientReservation item : list) {
			Map<String,String> map = entityToMap(item);
			Patient patient = patientDao.findByCode(item.getPatient());
			if(patient!=null){
				map.put("photo",patient.getPhoto());
			}
			re.add(map);
		}
		return re;
	}
	public Long countReservationByDoctorForPatient(String doctor,String patient){

+ 65 - 47
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java

@ -25,10 +25,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -76,7 +73,11 @@ public class PatientRemindService extends BaseService {
            }
            RemindAll(doc, hos);
            redisTemplate.opsForValue().set("expenses:remind:doctor:" + doctor, "0");
            redisTemplate.expire("expenses:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
        } catch (Exception e) {
            redisTemplate.opsForValue().set("expenses:remind:doctor:" + doctor, "0");
            redisTemplate.expire("expenses:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
            e.printStackTrace();
        }
    }
@ -87,8 +88,7 @@ public class PatientRemindService extends BaseService {
     * @param doc
     * @param hos
     */
    public void RemindAll(Doctor doc, Hospital hos) {
        try {
    public void RemindAll(Doctor doc, Hospital hos) throws Exception {
            boolean flag = true;
            int page = 0;
            int start = 0;
@ -103,14 +103,13 @@ public class PatientRemindService extends BaseService {
                    "     limit ?,3000";
            while (flag) {
                List<Patient> result = jdbcTemplate.query(sql,new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper(Patient.class));
                List<Patient> result = jdbcTemplate.query(sql, new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper(Patient.class));
                if (result != null && result.size() > 0) {
                    for (Patient p : result) {
                        if (p != null) {
                            String epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            if (StringUtils.isNotEmpty(epTime) &&
                                    new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime)) {
                            Boolean epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            if (epTime) {
                                continue;
                            }
                            remindPatientExpenses(p, doc, hos, true);
@ -122,9 +121,6 @@ public class PatientRemindService extends BaseService {
                    flag = false;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
@ -172,6 +168,11 @@ public class PatientRemindService extends BaseService {
     */
    public JSONObject remindPatientExpenses(Patient p, Doctor doc, Hospital hos, boolean ignore) throws Exception {
        try {
            Calendar today = Calendar.getInstance();
            today.set(Calendar.HOUR,23);
            today.set(Calendar.MINUTE,59);
            today.set(Calendar.SECOND,59);
            today.set(Calendar.MILLISECOND,59);
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            JSONObject reObj = new JSONObject();
            String mDesc = "";
@ -211,14 +212,14 @@ public class PatientRemindService extends BaseService {
            SendP2PUtil.sendP2Pmsg(doc.getCode(), p.getCode(), "1", doc.getName() + "医生提醒您:为完成家庭医生签约," +
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
            if (ignore) {
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
                redisTemplate.expire("expenses:remind:" + p.getCode(), 1, TimeUnit.DAYS);
                redisTemplate.opsForSet().add("expenses:remind:set",p.getCode());
                redisTemplate.expireAt("expenses:remind:set", today.getTime());
            }
            if (wFlag || mFlag) {
                reObj.put("status", 200);
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
                redisTemplate.expire("expenses:remind:" + p.getCode(), 1, TimeUnit.DAYS);
                redisTemplate.opsForSet().add("expenses:remind:set",p.getCode());
                redisTemplate.expireAt("expenses:remind:set", today.getTime());
                if (wFlag && mFlag) {
                    reObj.put("msg", "提醒成功");
                } else if (mFlag && !wFlag) {
@ -294,36 +295,48 @@ public class PatientRemindService extends BaseService {
     */
    @Async
    public void remindPatientWechatFocusAll(String doctor) throws Exception {
        int page = 0;
        int start = 0;
        boolean flag = true;
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        String sql = "select p.code,p.name,p.mobile" +
                "     from " +
                "        wlyy_sign_family f join wlyy_patient p on f.patient = p.code" +
                "     where " +
                "        (f.doctor = ? or f.doctor_health = ?) " +
                "        and f.status > 0 " +
                "        and f.expenses_status = '1' " +
                "        and LENGTH(trim(ifnull(p.openid,''))) < 1 limit ?,3000";
        while (flag) {
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
            if (result != null && result.size() > 0) {
                for (Map<String, Object> map : result) {
                    remindWechatFocus(map, doc);
        try {
            int page = 0;
            int start = 0;
            boolean flag = true;
            Doctor doc = doctorDao.findByCode(doctor);
            if (doc == null) {
                throw new Exception("doctor info can not find");
            }
            String sql = "select p.code,p.name,p.mobile" +
                    "     from " +
                    "        wlyy_sign_family f join wlyy_patient p on f.patient = p.code" +
                    "     where " +
                    "        (f.doctor = ? or f.doctor_health = ?) " +
                    "        and f.status > 0 " +
                    "        and f.expenses_status = '1' " +
                    "        and LENGTH(trim(ifnull(p.openid,''))) < 1 limit ?,3000";
            while (flag) {
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
                if (result != null && result.size() > 0) {
                    for (Map<String, Object> map : result) {
                        boolean epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", map.get("code").toString());
                        if (epTime) {
                            continue;
                        }
                        remindWechatFocus(map, doc);
                    }
                    page = page + 1;
                    start = page * 3000;
                } else {
                    flag = false;
                }
                page = page + 1;
                start = page * 3000;
            } else {
                flag = false;
            }
        }
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + doctor, "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
        } catch (Exception e) {
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + doctor, "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
            e.printStackTrace();
        }
    }
@ -335,14 +348,19 @@ public class PatientRemindService extends BaseService {
     * @return
     */
    public JSONObject remindWechatFocus(Map<String, Object> p, Doctor doctor) {
        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR,23);
        today.set(Calendar.MINUTE,59);
        today.set(Calendar.SECOND,59);
        today.set(Calendar.MILLISECOND,59);
        JSONObject result = new JSONObject();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        redisTemplate.opsForSet().add("wechat:focus:remind:set",p.get("code").toString());
        redisTemplate.expireAt("wechat:focus:remind:set", today.getTime());
        if (p.get("mobile") == null || StringUtils.isEmpty(p.get("mobile").toString())) {
            result.put("status", -1);
            result.put("msg", "对不起,居民未绑定手机号,无法短信提醒");
            redisTemplate.opsForValue().set("wechat:focus:remind:" + p.get("code").toString(), df.format(new Date()));
            redisTemplate.expire("wechat:focus:remind:" + p.get("code").toString(), 1, TimeUnit.DAYS);
            return result;
        }
@ -352,7 +370,7 @@ public class PatientRemindService extends BaseService {
        JSONObject smsResult = smsService.sendMsg(p.get("mobile").toString(), msg);
        if (smsResult != null && smsResult.getInt("result") == 0) {
            result.put("status", 1);
            result.put("status", 200);
            result.put("msg", "提醒成功");
        } else {
            result.put("status", -1);

+ 78 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.sign;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
@ -10,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -33,6 +35,8 @@ public class SignWebService extends BaseService {
    private SignFamilyDao signFamilyDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -62,6 +66,7 @@ public class SignWebService extends BaseService {
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                (status == 3 ? " and expenses_status = '1'" : "") + " order by begin desc ) a " +
@ -86,6 +91,7 @@ public class SignWebService extends BaseService {
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
@ -109,6 +115,7 @@ public class SignWebService extends BaseService {
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,apply_unsign_date,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?) and ( status = ? or status = ? ) and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
@ -139,6 +146,77 @@ public class SignWebService extends BaseService {
        return patients;
    }
    /**
     * 查询家庭签约已缴费未关注人数
     *
     * @param doctor
     * @return
     */
    public int isRemindFocusAll(String doctor) {
        boolean isAll = true;
        // 查询语句
        String sql = "select distinct b.code" +
                " from " +
                "     wlyy_sign_family f" +
                "     ,wlyy_patient b " +
                " where " +
                "     f.patient = b.code " +
                "     and (f.doctor = ? or f.doctor_health = ?)" +
                "     and f.expenses_status = '1' " +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and LENGTH(trim(ifnull(b.openid,''))) < 1";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
        if (result != null && result.size() > 0) {
            Set<String> set = redisTemplate.opsForSet().members("wechat:focus:remind:set");
            if (set == null) {
                isAll = false;
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        } else {
            isAll = false;
        }
        return isAll ? 1 : 0;
    }
    /**
     * 查询家庭签约已缴费未关注人数
     *
     * @param doctor
     * @return
     */
    public int isRemindExpensesAll(String doctor) {
        boolean isAll = true;
        // 查询语句
        String sql = "select distinct f.patient" +
                " from " +
                "     wlyy_sign_family f" +
                " where " +
                "     (f.doctor = ? or f.doctor_health = ?)" +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and (f.expenses_status = 0 or LENGTH(trim(ifnull(f.expenses_status,''))) < 1)";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
        if (result != null && result.size() > 0) {
            Set<String> set = redisTemplate.opsForSet().members("expenses:remind:set");
            if (set == null) {
                isAll = false;
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        } else {
            isAll = false;
        }
        return isAll ? 1 : 0;
    }
    /**
     * 根据代码查找签约信息明细
     *

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -83,7 +83,7 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public boolean peopleNumToRedis() {
        Iterable<PopulationBase> peopleNums = peopleNumDao.findAll();
        List<PopulationBase> peopleNums = peopleNumDao.findByYear(Calendar.getInstance().get(Calendar.YEAR));
        for (PopulationBase peopleNum : peopleNums) {
            redisTemplate.opsForValue().set("people:num:" + peopleNum.getCode(), new JSONObject(peopleNum).toString());

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -614,6 +614,7 @@ public class GuahaoXMService implements IGuahaoService {
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        if (xml.toLowerCase().startsWith("ok")) {
            return true;
        } else {
            return false;
@ -953,7 +954,7 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        else if (StringUtils.startsWith(xml, "Error"))  {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }

+ 1 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java

@ -358,8 +358,7 @@ public class JwSmjkService {
            if (status == 200) {
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data) && (data.startsWith("error")||data.startsWith("System-Error"))) {
                    return "111111|aaaaaa|zzzz";
                    //throw new Exception(data);
                    throw new Exception(data);
                } else {
                    re = data;
                }

+ 24 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -15,6 +15,7 @@ import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.hospital.HospitalDeptService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.util.*;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -77,6 +78,8 @@ public class DoctorController extends BaseController {
    private DoctorWorkTimeService workTimeService;
    @Autowired
    StringRedisTemplate redisTemplate;
    @Autowired
    private RoleService roleService;
    /**
     * 社区医院下医生列表查询接口 没分页
@ -593,7 +596,9 @@ public class DoctorController extends BaseController {
                json.put("isFamous", temp.getIsFamous());
                //是否医生提示 提示过是1 其他都是0
                json.put("isPasswordPrompt", StringUtils.isEmpty(temp.getIsPasswordPrompt()) ? "0" : temp.getIsPasswordPrompt());
                //获取医生角色和区域权限
                List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(temp.getCode());
                json.put("userRole", roleMap);
                return write(200, "医生信息查询成功!", "data", json);
            } else {
                return error(-1, "医生信息查询失败!");
@ -1565,15 +1570,15 @@ public class DoctorController extends BaseController {
        try {
            String status = redisTemplate.opsForValue().get("jianguanshifenpei:" + getUID());
            status = StringUtils.isEmpty(status) ? "0" : status;
            if(!status.equals("1")){
                redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(),"1");
            if (!status.equals("1")) {
                redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "1");
                redisTemplate.expire("jianguanshifenpei:" + getUID(), 20, TimeUnit.MINUTES);
            } else {
                return error(-2,"正在分配,请勿重复操作");
                return error(-2, "正在分配,请勿重复操作");
            }
            if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                int result = doctorInfoService.updateTeamHealthDoctorsAll(newDoctorCode, getUID());
                redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(),"0");
                redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "0");
                redisTemplate.expire("jianguanshifenpei:" + getUID(), 10, TimeUnit.MINUTES);
                if (result == 1) {
                    return write(200, "分配健管师成功");
@ -1582,11 +1587,16 @@ public class DoctorController extends BaseController {
                }
            } else {
                if (StringUtils.isEmpty(patients)) {
                    redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "0");
                    redisTemplate.expire("jianguanshifenpei:" + getUID(), 10, TimeUnit.MINUTES);
                    return error(-1, "居民不能为空");
                }
                doctorInfoService.updateTeamHealthDoctors(newDoctorCode, oldDoctorCode, patients, getUID());
                Map<String, Integer> returnMap = doctorInfoService.updateTeamHealthDoctors(newDoctorCode, oldDoctorCode, patients, getUID());
                redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "0");
                redisTemplate.expire("jianguanshifenpei:" + getUID(), 10, TimeUnit.MINUTES);
                return write(200, "已成功处理" + returnMap.get("success") + "个居民," + returnMap.get("error") + "个居民因有未结束的咨询,无法处理");
            }
            redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(),"0");
            redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "0");
            redisTemplate.expire("jianguanshifenpei:" + getUID(), 10, TimeUnit.MINUTES);
            return write(200, "更新成功");
        } catch (Exception e) {
@ -1613,16 +1623,18 @@ public class DoctorController extends BaseController {
        try {
            String status = redisTemplate.opsForValue().get("quankeyishengfenpei:" + getUID());
            status = StringUtils.isEmpty(status) ? "0" : status;
            if(!status.equals("1")){
                redisTemplate.opsForValue().set("quankeyishengfenpei:" + getUID(),"1");
            if (!status.equals("1")) {
                redisTemplate.opsForValue().set("quankeyishengfenpei:" + getUID(), "1");
                redisTemplate.expire("quankeyishengfenpei:" + getUID(), 20, TimeUnit.MINUTES);
            } else {
                return error(-2,"正在分配,请勿重复操作");
                return error(-2, "正在分配,请勿重复操作");
            }
            doctorInfoService.updateTeamDoctors(newDoctorCode, oldDoctorCode, patients, getUID());
            Map<String, Integer> returnMap = doctorInfoService.updateTeamDoctors(newDoctorCode, oldDoctorCode, patients, getUID());
            redisTemplate.opsForValue().set("quankeyishengfenpei:" + getUID(), "0");
            redisTemplate.expire("quankeyishengfenpei:" + getUID(), 10, TimeUnit.MINUTES);
            return write(200, "更新成功");
            return write(200, "已成功处理" + returnMap.get("success") + "个居民," + returnMap.get("error") + "个居民因有未结束的咨询,无法处理");
        } catch (Exception e) {
            redisTemplate.opsForValue().set("quankeyishengfenpei:" + getUID(), "0");
            redisTemplate.expire("quankeyishengfenpei:" + getUID(), 10, TimeUnit.MINUTES);

+ 50 - 17
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -234,23 +234,6 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	@ApiOperation("获取上次随访项目数据")
	@RequestMapping(value = "/getLastFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowupProjectData(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
										 @RequestParam(value="patient",required = true) String patient,
										 @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
										 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowupProjectData("D20161008003",patient,followupProject);
			return write(200, "获取上次随访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访项目数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存随访项目数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
@ -302,4 +285,54 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	/*************************************** 上次随访 ********************************************/
	@ApiOperation("获取上次随访")
	@RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowup(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
								   @RequestParam(value="patient",required = true) String patient,
								   @ApiParam(name="followClass",value="随访类别",defaultValue = "1")
								   @RequestParam(value="followClass",required = true) String followClass)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowup(getUID(),patient,followClass);
			return write(200, "获取上次随访成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访失败!"+e.getMessage());
		}
	}
	@ApiOperation("复制上次随访数据")
	@RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String copyFollowup(@ApiParam(name="id",value="本地随访ID",defaultValue = "")
								  @RequestParam(value="id",required = true) Long id,
								  @ApiParam(name="fromId",value="拷贝随访记录ID",defaultValue = "")
								  @RequestParam(value="fromId",required = true) Long fromId)
	{
		try {
			followUpService.copyFollowup(id,fromId);
			return write(200, "复制上次随访成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "复制上次随访失败!"+e.getMessage());
		}
	}
	/*************************************** 发送随访计划消息 ********************************************/
	@ApiOperation("发送随访计划消息")
	@RequestMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String sendMessage(@ApiParam(name="date",value="日期",defaultValue = "2017-01-05")
								  @RequestParam(value="date",required = true) String date)
	{
		try {
			followUpService.sendMessage(date);
			return write(200, "发送随访计划消息成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "发送随访计划消息失败!"+e.getMessage());
		}
	}
}

+ 22 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -256,11 +256,6 @@ public class DoctorHealthController extends BaseController {
	}
	/**
	 * 根据患者标志获取健康指标
	 * @param patient 患者指标
	 * @return 操作结果
	 */
	@RequestMapping(value = "last",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("患者最新健康指标信息")
@ -285,4 +280,26 @@ public class DoctorHealthController extends BaseController {
		}
	}
	@RequestMapping(value = "getHealthIndexHistory",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取患者健康指标历史记录")
	public String getHealthIndexHistory(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
										 @RequestParam(value="patient",required = true) String patient,
										 @ApiParam(name="type",value="指标类型1血糖,2血压,3体重,4腰围",defaultValue = "1")
										 @RequestParam(value="type",required = true) int type,
										 @ApiParam(name="page",value="第几页",defaultValue = "0")
										 @RequestParam(value="page",required = true) int page,
										 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
										 @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
			List<Map<String,String>> list = healthIndexService.getHealthIndexHistory(patient, type, page, pagesize);
			return write(200, "获取患者健康指标历史记录成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
}

+ 145 - 104
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.web.doctor.message;
import com.yihu.wlyy.entity.message.Message;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +21,7 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/doctor/message", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ -28,35 +31,29 @@ public class DoctorMessageController extends BaseController {
	@Autowired
	private MessageService messageService;
	/**
	 * 医生消息总数统计接口
	 * @return
	 */
	@RequestMapping(value = "amount")
	@RequestMapping(value = "messages")
	@ResponseBody
	public String amount() {
	@ApiOperation("查询医生未读消息和最后消息")
	public String messages() {
		try {
			JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
			if (json == null) {
				return error(-1, "获取消息总数失败!");
			} else {
				return write(200, "获取消息总数成功!", "data", json);
			}
			JSONObject json = messageService.findDoctorAllMessage(getUID());
			return write(200, "获取消息总数成功!", "data", json);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息总数失败!");
			return error(-1, e.getMessage());
		}
	}
	/**
	 * 医生消息总数统计接口
	 * @return
	 */
	@RequestMapping(value = "messages")
	@RequestMapping(value = "amount")
	@ResponseBody
	public String messages() {
	public String amount() {
		try {
			JSONObject json = messageService.findDoctorAllMessage(getUID());
			JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
			if (json == null) {
				return error(-1, "获取消息总数失败!");
			} else {
@ -111,53 +108,6 @@ public class DoctorMessageController extends BaseController {
		}
	}
	/**
	 * 体征指标消息查询接口
	 * @param id
	 * @param pagesize
	 * @param isRead 1未读,0已读
	 * @return
	 */
	@RequestMapping(value = "health")
	@ResponseBody
	public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 消息类型:1血糖,2血压
				json.put("type", msg.getTzType());
				// 是否已读:1未读,0已读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 当前值/收缩压,正数为高,负数为低
				json.put("value1", msg.getValue1());
				// 上次值/舒张压,正数为高,负数为低
				json.put("value2", msg.getValue2());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取体征消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取体征消息失败!");
		}
	}
	/**
	 * 更新体征消息为已读
	 * @param msgid
@ -165,6 +115,7 @@ public class DoctorMessageController extends BaseController {
	 */
	@RequestMapping(value = "read_health")
	@ResponseBody
	@ApiOperation("消息设置成已读")
	public String readHealth(long msgid) {
		try {
			messageService.readHealth(msgid);
@ -175,16 +126,16 @@ public class DoctorMessageController extends BaseController {
		}
	}
	/**
	 * 根据参数查询发送给我的消息
	 * @return
	 */
	@RequestMapping(value = "find")
	@ResponseBody
	public String find(String sender, String signStatus) {
	@ApiOperation("查询发送给我的消息")
	public String findMyMessage(String sender, String signStatus) {
		try {
			Message msg = messageService.findMessage(sender, getUID(), signStatus);
			Message msg = messageService.findUnreadSign(sender, getUID(), signStatus);
			JSONObject json = null;
			if (msg != null) {
				json = new JSONObject();
@ -203,20 +154,98 @@ public class DoctorMessageController extends BaseController {
			return error(-1, "获取消息失败!");
		}
	}
	/**
	 * 系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "getSystemMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取系统消息")
	public String getSystemMessage(@ApiParam(value="第几页",defaultValue = "1")
							  @RequestParam Integer page,
							  @ApiParam(value="每页几行",defaultValue = "10")
							  @RequestParam Integer pagesize) {
		try {
			List<Message> list = messageService.getSystemMessage(getUID(),page,pagesize);
			return write(200, "获取消息成功!", "list", list);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
	@RequestMapping(value = "getHealthIndexMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取超标指标消息--根据患者分组")
	public String getHealthIndexMessage()throws Exception{
		try {
			List<Map<String,Object>> list = messageService.getHealthIndexMessage(getUID());     //"D20161008003"
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
	@RequestMapping(value = "getHealthIndexMessageByPatient",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取患者超标指标消息")
	public String getHealthIndexMessageByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
												 @RequestParam(value="patient",required = true) String patient,
												 @ApiParam(name="type",value="健康指标类型1血糖,2血压,3体重",defaultValue = "1")
												 @RequestParam(value="type",required = true) String type,
												 @ApiParam(name="page",value="第几页",defaultValue = "1")
												 @RequestParam(value="page",required = true) Integer page,
												 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
												 @RequestParam(value="pagesize",required = true) Integer pagesize)throws Exception{
		try {
			List<Map<String,String>> list = messageService.getHealthIndexMessageByPatient(getUID(),patient,type,page,pagesize);
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
	 * @param id  消息id
	 * @param pagesize  每頁顯示條數
	 * @return
	 */
	@RequestMapping(value = "findMessage")
	@RequestMapping(value = "findMessageNum")
	@ResponseBody
	public String findMessage(String type,
							   long id,
							   int pagesize) {
	@ApiOperation("获取未读消息数(1.2.8版本作废)")
	public String findMessageNum(@ApiParam(value="消息类型",defaultValue = "3")
								 @RequestParam Integer type) {
		try {
			JSONObject obj = messageService.findMessageNum(getUID(), type);
			return write(200, "获取消息成功!", "list", obj);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
	/**
	 * 体征指标消息查询接口
	 * @param isRead 1未读,0已读
	 */
	@RequestMapping(value = "health")
	@ResponseBody
	@ApiOperation("体征指标消息查询接口(1.2.8版本作废)")
	public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.find(getUID(), type,id,pagesize);
			Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
			for (Message msg : list) {
				if (msg == null) {
					continue;
@ -226,55 +255,67 @@ public class DoctorMessageController extends BaseController {
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 消息內容
				json.put("content", msg.getContent());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 是否已读:1已读,0未读
				// 消息类型:1血糖,2血压
				json.put("type", msg.getTzType());
				// 是否已读:1未读,0已读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 当前值/收缩压,正数为高,负数为低
				json.put("value1", msg.getValue1());
				// 上次值/舒张压,正数为高,负数为低
				json.put("value2", msg.getValue2());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
				json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取消息成功!", "list", array);
			return write(200, "获取体征消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
			return error(-1, "获取体征消息失败!");
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
	 * @return
	 */
	@RequestMapping(value = "findMessageNum")
	@ResponseBody
	public String findMessageNum(Integer type) {
		try {
			JSONObject obj = messageService.findMessageNum(getUID(), type);
			return write(200, "获取消息成功!", "list", obj);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
	/**
	 * @param id
	 * @return
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "changeMessageToRead")
	@RequestMapping(value = "findMessage")
	@ResponseBody
	public String changeMessageToRead(Long id) {
	@ApiOperation("获取某类消息(1.2.8版本作废)")
	public String findMessage(String type,
							  long id,
							  int pagesize) {
		try {
			 messageService.changeMessageToRead(id);
			return write(200, "修改成功!");
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.find(getUID(), type,id,pagesize);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 消息內容
				json.put("content", msg.getContent());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 是否已读:1已读,0未读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");

+ 50 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java

@ -47,6 +47,31 @@ public class DoctorQuickReplyController extends BaseController {
        }
    }
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "修改快捷回复")
    public String modifyReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id,
                              @RequestParam @ApiParam(value = "快捷回复内容") String content) {
        try {
            if (id == null || id < 1) {
                return error(-1, "快捷回复ID不能为空");
            }
            if (StringUtils.isEmpty(content)) {
                return error(-1, "快捷回复内容不能为空");
            }
            DoctorQuickReply reply = quickReplyService.modifyReply(id, content);
            if (reply != null) {
                return write(200, "添加成功", "data", reply);
            } else {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除快捷回复")
    public String delReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id) {
@ -99,6 +124,31 @@ public class DoctorQuickReplyController extends BaseController {
        }
    }
    @RequestMapping(value = "/sortList", method = RequestMethod.POST)
    @ApiOperation(value = "快捷回复排序")
    public String sortReplyList(@RequestParam @ApiParam(value = "快捷回复ID")String id) {
        try {
            if (StringUtils.isEmpty(id)) {
                return error(-1, "请输入排序后的回复ID");
            }
            int result = quickReplyService.sortReplyList(id);
            if (result == 1) {
                return write(200, "排序成功");
            } else if (result == -1) {
                return error(-1, "快捷回复不存在或已删除");
            }  else if (result == -2) {
                return error(-1, "快捷回复已在排序位置");
            } else {
                return error(-1, "排序失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "排序失败");
        }
    }
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "快捷回复列表")
    public String replyList() {

+ 38 - 13
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -925,8 +925,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return write(result.getInt("status"), result.getString("msg"));
            } else if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                patientRemindService.remindPatientExpensesAll(getUID());
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
                redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
                return error(200, "提醒操作成功");
            } else {
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
@ -955,12 +953,12 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "患者不能为空");
            }
            int result = 0;
            String epTime = redisTemplate.opsForValue().get("expenses:remind:" + patient);
            boolean epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", patient);
            if (StringUtils.isEmpty(epTime)) {
            if (!epTime) {
                result = 0;
            } else {
                result = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0;
                result = 1;
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -1064,7 +1062,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    public String wechatFocusRemind(@RequestParam(defaultValue = "") @ApiParam(value = "居民") String patient,
                                    @RequestParam(defaultValue = "") @ApiParam(value = "是否全部(1:全部  0:非全部)") String isAll) {
        try {
            int result = 1;
            int result = 200;
            String msg = "提醒成功";
            String status = redisTemplate.opsForValue().get("wechat:focus:remind:doctor:" + getUID());
            status = StringUtils.isEmpty(status) ? "0" : status;
@ -1082,15 +1080,14 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                if (StringUtils.isEmpty(patient)) {
                    result = -1;
                    msg = "请选择需提醒的居民";
                } else {
                    JSONObject json = patientRemindService.remindPatientFocusWechat(patient, getUID());
                    result = json.getInt("status");
                    msg = json.getString("msg");
                    redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
                    redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
                }
                JSONObject json = patientRemindService.remindPatientFocusWechat(patient, getUID());
                result = json.getInt("status");
                msg = json.getString("msg");
            }
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            return write(result, msg);
        } catch (Exception e) {
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
@ -1099,4 +1096,32 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return error(-1, "微信关注提醒失败");
        }
    }
    /**
     * 是否已提醒关注
     *
     * @param patient
     * @return
     */
    @RequestMapping(value = "/is_patient_remind_focus")
    @ResponseBody
    public String isPatientRemindFocusToday(String patient){
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
            }
            int result = 0;
            boolean epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", patient);
            if (!epTime) {
                result = 0;
            } else {
                result = 1;
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 41 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -5,6 +5,7 @@ import java.util.*;
import com.yihu.wlyy.util.IdCardUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -233,6 +234,7 @@ public class DoctorSignController extends BaseController {
                    json.put("address", temp.get("address"));
                    json.put("photo", temp.get("photo"));
                    json.put("status", temp.get("status"));
                    json.put("openid", temp.get("openid"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
@ -256,29 +258,29 @@ public class DoctorSignController extends BaseController {
                    json.put("streetName", temp.get("streetName"));
                    json.put("sex", temp.get("sex"));
                    if (status == 5) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + temp.get("patient"));
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", temp.get("patient"));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", df.format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                    if (status == 3) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + temp.get("patient"));
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", temp.get("patient"));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("wechatFocusRemind", 0);
                        } else {
                            json.put("wechatFocusRemind", df.format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("wechatFocusRemind", 1);
                        }
                    }
                    jsonArray.add(json);
@ -312,4 +314,35 @@ public class DoctorSignController extends BaseController {
        }
    }
    /**
     * 查询今天是否全部提醒关注
     *
     * @return
     */
    @RequestMapping(value = "/is_remind_focus_all")
    @ApiOperation(value = "今天是否已全部提醒关注")
    public String isRemindFocusAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindFocusAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    /**
     * 查询今天是否全部提醒关注
     *
     * @return
     */
    @RequestMapping(value = "/is_remind_expenses_all")
    @ApiOperation(value = "今天是否已全部提醒缴费")
    public String isRemindFExpensesAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindExpensesAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}

+ 20 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.quota;
import com.yihu.wlyy.job.FollowupPlanJob;
import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.consult.ConsultCleanerJob;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
@ -322,4 +323,23 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /******************************************** 随访计划任务 **********************************************************************/
    @RequestMapping(value = "/followup/planJob", method = RequestMethod.POST)
    @ApiOperation("随访计划消息发送任务")
    public String addFollowPlanJob() {
        try {
            String jobKey = "followup-plan";
            if (!quartzHelper.isExistJob(jobKey)) {
                quartzHelper.addJob(FollowupPlanJob.class, "0 0/5 0 * * ?", jobKey, new HashMap<String, Object>());
                return write(200, "启动成功");
            } else {
                return write(200, "任务已存在");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "启动失败");
        }
    }
}

+ 64 - 129
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -307,6 +307,54 @@ public class BookingController extends WeixinBaseController {
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("取消挂号单")
    public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
                              @RequestParam(value = "orderId", required = true) Long orderId) {
        try {
            //获取订单信息
            PatientReservation obj = patientReservationService.findById(orderId);
            boolean re = false;
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                if (type.equals("0")) {  //医护网接口
                    re = guahaoYihu.CancelOrder(code);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    re = guahaoXM.CancelOrder(code, obj.getSsc());
                }
            }
            if (re) {
                //更新状态
                patientReservationService.updateStatus(orderId, 0);
                //微信消息
                Patient p = patientService.findByCode(obj.getPatient());
                if (StringUtils.isNotEmpty(p.getOpenid())) {
                    JSONObject json = new JSONObject();
                    json.put("first", "");
                    json.put("toUser", p.getCode());
                    json.put("name", obj.getName());
                    json.put("date", obj.getStartTime());
                    json.put("doctorName", obj.getDoctorName());
                    json.put("orgName", obj.getOrgName());
                    json.put("remark", obj.getName() + ",您好!\n您已取消了" + obj.getStartTime() + "的挂号!");
                    PushMsgTask.getInstance().putWxMsg(getAccessToken(), 7, p.getOpenid(), obj.getName(), json);
                }
                return write(200, "取消挂号单成功!");
            } else {
                return error(-1, "取消挂号单失败!");
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    /****************************************** 内网预约 ***************************************************************/
    @RequestMapping(value = "CreateOrderByDoctor", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("(内网)转诊预约挂号")
@ -390,12 +438,12 @@ public class BookingController extends WeixinBaseController {
    @ResponseBody
    @ApiOperation("(内网)获取医生排班接口")
    public String GetDoctorArrangeTenDay(
                                   @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
                                   @RequestParam(value = "hospitalId", required = true) String hospitalId,
                                   @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
                                   @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
                                   @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
                                   @RequestParam(value = "doctorId", required = true) String doctorId) {
            @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
            @RequestParam(value = "hospitalId", required = true) String hospitalId,
            @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
            @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
            @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
            @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            List<Map<String, Object>> list = guahaoXM.GetDoctorArrangeTenDay(hospitalId, hosDeptId, doctorId);
            return write(200, "获取医生排班成功!", "data", list);
@ -404,54 +452,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("取消挂号单")
    public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
                              @RequestParam(value = "orderId", required = true) String orderId) {
        try {
            //获取订单信息
            PatientReservation obj = patientReservationService.findById(orderId);
            boolean re = false;
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                if (type.equals("0")) {  //医护网接口
                    re = guahaoYihu.CancelOrder(code);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    re = guahaoXM.CancelOrder(code, obj.getSsc());
                }
            }
            if (re) {
                //更新状态
                patientReservationService.updateStatus(obj.getCode(), 0);
                //微信消息
                Patient p = patientService.findByCode(obj.getPatient());
                if (StringUtils.isNotEmpty(p.getOpenid())) {
                    JSONObject json = new JSONObject();
                    json.put("first", "");
                    json.put("toUser", p.getCode());
                    json.put("name", obj.getName());
                    json.put("date", obj.getStartTime());
                    json.put("doctorName", obj.getDoctorName());
                    json.put("orgName", obj.getOrgName());
                    json.put("remark", obj.getName() + ",您好!\n您已取消了" + obj.getStartTime() + "的挂号!");
                    PushMsgTask.getInstance().putWxMsg(getAccessToken(), 7, p.getOpenid(), obj.getName(), json);
                }
                return write(200, "取消挂号单成功!");
            } else {
                return error(-1, "取消挂号单失败!");
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    /********************************************* 医生端查询 **************************************************************************/
    @RequestMapping(value = "GetPatientReservationList", method = RequestMethod.POST)
    @ResponseBody
@ -460,29 +460,13 @@ public class BookingController extends WeixinBaseController {
                                        @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                        @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "10")
                                        @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                        @ApiParam(name = "patient", value = "患者编号", defaultValue = "10")
                                        @ApiParam(name = "patient", value = "患者编号", defaultValue = "4afdbce6194e412fbc770eb4dfbe7b00")
                                        @RequestParam(value = "patient", required = false) String patient,
                                        @ApiParam(name = "doctor", value = "医生编号", defaultValue = "10")
                                        @ApiParam(name = "doctor", value = "医生编号", defaultValue = "shiliuD20160926005")
                                        @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByPatient(patient, doctor, pageIndex, pageSize);
            //遍历更新预约状态
            for (PatientReservation item : list) {
                String type = item.getType();
                String code = item.getCode();
                if (type.equals("0")) {  //医护网接口
                }
                else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    Integer status = guahaoXM.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
                    //更新状态
                    if (status != null) {
                        patientReservationService.updateStatus(item.getCode(), 0);
                        item.setStatus(status);
                    }
                }
            }
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -497,39 +481,12 @@ public class BookingController extends WeixinBaseController {
                                       @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "10")
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                       @ApiParam(name = "doctor", value = "医生编号", defaultValue = "10")
                                       @ApiParam(name = "doctor", value = "医生编号", defaultValue = "shiliuD20160926005")
                                       @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByDoctor(doctor, pageIndex, pageSize);
            //遍历更新预约状态
            JSONArray array = new JSONArray();
            for (PatientReservation item : list) {
                String type = item.getType();
                String code = item.getCode();
                JSONObject object = new JSONObject();
                Class pClass = (Class) item.getClass();
                for(Field field  : pClass.getDeclaredFields()){
                    field.setAccessible(true);
                    object.put(field.getName(),field.get(item));
                }
                Patient patient = patientService.findByCode(item.getPatient());
                if(patient!=null){
                    object.put("photo",patient.getPhoto());
                }
                array.put(object);
                if (type.equals("0")) {  //医护网接口
            List<Map<String,String>> list = patientReservationService.getReservationByDoctor(doctor, pageIndex, pageSize);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    Integer status = guahaoXM.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
                    //更新状态
                    if (status != null) {
                        patientReservationService.updateStatus(item.getCode(), 0);
                        item.setStatus(status);
                    }
                }
            }
            return write(200, "获取患者预约信息列表成功!", "data", array);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
@ -540,35 +497,13 @@ public class BookingController extends WeixinBaseController {
    @ResponseBody
    @ApiOperation("获取患者预约信息单条-医生端")
    public String GetPatientReservation(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
                                        @RequestParam(value = "orderId", required = true) String orderId) {
                                        @RequestParam(value = "orderId", required = true) Long orderId) {
        try {
            PatientReservation obj = null;
            try {
                obj = patientReservationService.findById(orderId);
            } catch (Exception e) {
                obj = patientReservationService.findByCode(orderId);
            }
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                Integer status = null;
                if (type.equals("0")) {  //医护网接口
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    status = guahaoXM.GetOrderStatus(obj.getOrgCode(), code, obj.getSsc());
                }
                //更新状态
                if (status != null) {
                    patientReservationService.updateStatus(obj.getCode(), 0);
                    obj.setStatus(status);
                }
                return write(200, "获取患者预约信息成功!", "data", obj);
            } else {
                return error(-1, "不存在该条预约信息!");
            }
            PatientReservation obj = patientReservationService.findById(orderId);
        } catch (Exception e) {
            return write(200, "获取患者预约信息成功!", "data", obj);
        }
        catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }

+ 2 - 0
patient-co-wlyy/src/main/resources/application.properties

@ -73,6 +73,7 @@ fv.jdbc.password=123456
#### redis
redis.host=172.19.103.47
redis.port=6379
redis.password=
#---------------------------------测试环境数据库配置---------------------------------------#
###### mysql database setting
@ -96,6 +97,7 @@ redis.port=6379
###### redis
#redis.host=172.19.103.88
#redis.port=6379
#redis.password=
#-----------------------------------通用配置--------------------------------------------#
##### redis