Browse Source

20210602

recovery
zy_Java 4 years ago
parent
commit
e855203940
  1. 160
      recovery/src/main/java/com/ccsens/recovery/api/PatientController.java
  2. 104
      recovery/src/main/java/com/ccsens/recovery/api/RecipeController.java
  3. 2
      recovery/src/main/java/com/ccsens/recovery/bean/dto/PatientDto.java
  4. 66
      recovery/src/main/java/com/ccsens/recovery/bean/message/BaseMessageDto.java
  5. 34
      recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithStartRecipe.java
  6. 23
      recovery/src/main/java/com/ccsens/recovery/persist/dao/PatientDao.java
  7. 3
      recovery/src/main/java/com/ccsens/recovery/service/IPatientService.java
  8. 82
      recovery/src/main/java/com/ccsens/recovery/service/PatientService.java
  9. 7
      recovery/src/main/java/com/ccsens/recovery/service/RecipeService.java
  10. 6
      recovery/src/main/java/com/ccsens/recovery/util/Constant.java
  11. 4
      recovery/src/main/resources/application-test.yml
  12. 124
      recovery/src/main/resources/mapper_dao/PatientDao.xml
  13. 4
      tall/src/main/resources/application.yml
  14. 7
      util/src/main/java/com/ccsens/util/cron/NatureToDate.java

160
recovery/src/main/java/com/ccsens/recovery/api/PatientController.java

@ -28,86 +28,96 @@ import java.util.List;
@RequestMapping("/patient")
@Slf4j
public class PatientController {
// @Resource
// private IPatientService patientService;
//
// @MustLogin
// @ApiOperation(value = "主治医生查看患者列表", notes = "zy:")
// @RequestMapping(value = "/doctorId", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<PatientVo.Patient>> queryPatientByDoctorId(@ApiParam @Validated @RequestBody QueryDto<HospitalDto.DoctorId> params) {
// log.info("主治医生查看患者列表:{}",params);
// List<PatientVo.Patient> patientList = patientService.queryPatientByDoctorId(params.getParam(),params.getUserId());
// log.info("主治医生查看患者列表成功:{}",patientList);
// return JsonResponse.newInstance().ok(patientList);
// }
//
// @MustLogin
// @ApiOperation(value = "康复中心查看患者列表", notes = "zy:")
// @RequestMapping(value = "/recovery", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<PatientVo.Patient>> queryPatientByRecovery(@ApiParam @Validated @RequestBody QueryDto<HospitalDto.HospitalId> params) {
// log.info("康复中心查看患者列表:{}",params);
// List<PatientVo.Patient> patientList = patientService.queryPatientByRecovery(params.getParam(),params.getUserId());
// log.info("康复中心查看患者列表成功:{}",patientList);
// return JsonResponse.newInstance().ok(patientList);
// }
//
// @MustLogin
// @ApiOperation(value = "查看患者的详细信息", notes = "zy:")
// @RequestMapping(value = "/detail", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<PatientVo.Patient> getPatientById(@ApiParam @Validated @RequestBody QueryDto<PatientDto.PatientId> params) {
// log.info("查看患者的详细信息:{}",params);
// PatientVo.Patient patient = patientService.getPatientById(params.getParam(),params.getUserId());
// log.info("查看患者的详细信息成功:{}",patient);
// return JsonResponse.newInstance().ok(patient);
// }
//
// @MustLogin
// @ApiOperation(value = "添加患者", notes = "zy:")
// @RequestMapping(value = "/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse addPatient(@ApiParam @Validated @RequestBody QueryDto<PatientDto.PatientDetail> params) {
// log.info("添加患者:{}",params);
// patientService.addPatient(params.getParam(),params.getUserId());
// log.info("添加患者成功");
// return JsonResponse.newInstance().ok();
// }
//
// @MustLogin
// @ApiOperation(value = "康复医生选择需要做康复的患者", notes = "zy:")
// @RequestMapping(value = "/choose", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse choosePatient(@ApiParam @Validated @RequestBody QueryDto<PatientDto.ChoosePatient> params) {
// log.info("康复医生选择需要做康复的患者:{}",params);
// patientService.choosePatient(params.getParam(),params.getUserId());
// log.info("康复医生选择需要做康复的患者成功");
// return JsonResponse.newInstance().ok();
// }
//
// @MustLogin
// @ApiOperation(value = "开启训练", notes = "zy:")
// @RequestMapping(value = "/start", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<PatientVo.RecipeRecordId> startDrill(@ApiParam @Validated @RequestBody QueryDto<PatientDto.StartDrill> params) {
// log.info("开启训练:{}",params);
// PatientVo.RecipeRecordId recipeRecordId = patientService.startDrill(params.getParam(),params.getUserId());
// log.info("开启训练成功:{}",recipeRecordId);
// return JsonResponse.newInstance().ok(recipeRecordId);
// }
@Resource
private IPatientService patientService;
@MustLogin
@ApiOperation(value = "主治医生查看患者列表", notes = "zy:")
@RequestMapping(value = "/doctorId", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<PatientVo.Patient>> queryPatientByDoctorId(@ApiParam @Validated @RequestBody QueryDto<HospitalDto.DoctorId> params) {
log.info("主治医生查看患者列表:{}",params);
List<PatientVo.Patient> patientList = patientService.queryPatientByDoctorId(params.getParam(),params.getUserId());
log.info("主治医生查看患者列表成功:{}",patientList);
return JsonResponse.newInstance().ok(patientList);
}
@MustLogin
@ApiOperation(value = "康复中心查看患者列表", notes = "zy:")
@RequestMapping(value = "/recovery", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<PatientVo.Patient>> queryPatientByRecovery(@ApiParam @Validated @RequestBody QueryDto<HospitalDto.HospitalId> params) {
log.info("康复中心查看患者列表:{}",params);
List<PatientVo.Patient> patientList = patientService.queryPatientByRecovery(params.getParam(),params.getUserId());
log.info("康复中心查看患者列表成功:{}",patientList);
return JsonResponse.newInstance().ok(patientList);
}
@MustLogin
@ApiOperation(value = "查看患者的详细信息", notes = "zy:")
@RequestMapping(value = "/detail", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<PatientVo.Patient> getPatientById(@ApiParam @Validated @RequestBody QueryDto<PatientDto.PatientId> params) {
log.info("查看患者的详细信息:{}",params);
PatientVo.Patient patient = patientService.getPatientById(params.getParam(),params.getUserId());
log.info("查看患者的详细信息成功:{}",patient);
return JsonResponse.newInstance().ok(patient);
}
@MustLogin
@ApiOperation(value = "添加患者", notes = "zy:")
@RequestMapping(value = "/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse addPatient(@ApiParam @Validated @RequestBody QueryDto<PatientDto.PatientDetail> params) {
log.info("添加患者:{}",params);
patientService.addPatient(params.getParam(),params.getUserId());
log.info("添加患者成功");
return JsonResponse.newInstance().ok();
}
@MustLogin
@ApiOperation(value = "启动康复流程(康复师选择患者)", notes = "zy:")
@RequestMapping(value = "/choose", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse choosePatient(@ApiParam @Validated @RequestBody QueryDto<PatientDto.ChoosePatient> params) throws Exception {
log.info("启动康复流程:{}",params);
patientService.choosePatient(params.getParam(),params.getUserId());
log.info("启动康复流程成功");
return JsonResponse.newInstance().ok();
}
@MustLogin
@ApiOperation(value = "开启训练", notes = "zy:")
@RequestMapping(value = "/start", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<PatientVo.RecipeRecordId> startDrill(@ApiParam @Validated @RequestBody QueryDto<PatientDto.StartDrill> params) {
log.info("开启训练:{}",params);
PatientVo.RecipeRecordId recipeRecordId = patientService.startDrill(params.getParam(),params.getUserId());
log.info("开启训练成功:{}",recipeRecordId);
return JsonResponse.newInstance().ok(recipeRecordId);
}
@MustLogin
@ApiOperation(value = "结束训练", notes = "zy:")
@RequestMapping(value = "/end", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse endDrill(@ApiParam @Validated @RequestBody QueryDto<PatientDto.EndDrill> params) {
log.info("结束训练:{}",params);
patientService.endDrill(params.getParam(),params.getUserId());
log.info("结束训练成功");
return JsonResponse.newInstance().ok();
}
//
// @MustLogin
// @ApiOperation(value = "结束训练", notes = "zy:")
// @RequestMapping(value = "/start", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse endDrill(@ApiParam @Validated @RequestBody QueryDto<PatientDto.EndDrill> params) {
// @ApiOperation(value = "结束康复流程", notes = "zy:")
// @RequestMapping(value = "/finish", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse finishRecovery(@ApiParam @Validated @RequestBody QueryDto<PatientDto.EndDrill> params) {
// log.info("结束训练:{}",params);
// patientService.endDrill(params.getParam(),params.getUserId());
// log.info("结束训练成功");
// return JsonResponse.newInstance().ok();
// }
//
// @MustLogin
// @ApiOperation(value = "动作反馈", notes = "zy:")
// @RequestMapping(value = "/feedback", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse actionFeedback(@ApiParam @Validated @RequestBody QueryDto<PatientDto.ActionFeedback> params) {
// log.info("动作反馈:{}",params);
// patientService.actionFeedback(params.getParam(),params.getUserId());
// log.info("动作反馈成功");
// return JsonResponse.newInstance().ok();
// }
@MustLogin
@ApiOperation(value = "动作反馈", notes = "zy:")
@RequestMapping(value = "/feedback", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse actionFeedback(@ApiParam @Validated @RequestBody QueryDto<PatientDto.ActionFeedback> params) {
log.info("动作反馈:{}",params);
patientService.actionFeedback(params.getParam(),params.getUserId());
log.info("动作反馈成功");
return JsonResponse.newInstance().ok();
}
}

104
recovery/src/main/java/com/ccsens/recovery/api/RecipeController.java

@ -28,56 +28,56 @@ import java.util.List;
@RequestMapping("/recipe")
@Slf4j
public class RecipeController {
// @Resource
// private IRecipeService recipeService;
//
// @MustLogin
// @ApiOperation(value = "查看所有训练", notes = "zy:")
// @RequestMapping(value = "/queryDrill", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<RecipeVo.Drill>> queryDrill(@ApiParam @Validated @RequestBody QueryDto params) {
// log.info("查看所有训练:{}",params);
// List<RecipeVo.Drill> drillList = recipeService.queryDrill(params.getUserId());
// log.info("查看所有训练成功:{}",drillList);
// return JsonResponse.newInstance().ok(drillList);
// }
//
// @MustLogin
// @ApiOperation(value = "查看训练项目对应的游戏", notes = "zy:")
// @RequestMapping(value = "/game", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<RecipeVo.Game>> queryGameByDrill(@ApiParam @Validated @RequestBody QueryDto<RecipeDto.DrillId> params) {
// log.info("查看训练项目对应的游戏:{}",params);
// List<RecipeVo.Game> gameList = recipeService.queryGameByDrill(params.getParam(),params.getUserId());
// log.info("查看训练项目对应的游戏成功:{}",gameList);
// return JsonResponse.newInstance().ok(gameList);
// }
//
// @MustLogin
// @ApiOperation(value = "给患者添加处方", notes = "zy:")
// @RequestMapping(value = "/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse queryPatientByDoctorId(@ApiParam @Validated @RequestBody QueryDto<RecipeDto.AddRecipe> params) {
// log.info("主治医生查看患者列表:{}",params);
// recipeService.queryPatientByDoctorId(params.getParam(),params.getUserId());
// log.info("主治医生查看患者列表成功");
// return JsonResponse.newInstance().ok();
// }
//
// @MustLogin
// @ApiOperation(value = "查看患者的处方信息", notes = "zy:查找患者所有的处方信息,按倒叙排列")
// @RequestMapping(value = "/queryRecipe", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<RecipeVo.PatientRecipe>> queryRecipeByPatientId(@ApiParam @Validated @RequestBody QueryDto<PatientDto.PatientId> params) {
// log.info("查看患者的处方信息:{}",params);
// List<RecipeVo.PatientRecipe> patientRecipeList = recipeService.queryRecipeByPatientId(params.getParam(),params.getUserId());
// log.info("查看患者的处方信息成功:{}",patientRecipeList);
// return JsonResponse.newInstance().ok(patientRecipeList);
// }
//
// @MustLogin
// @ApiOperation(value = "查看患者处方项下的训练记录", notes = "zy:")
// @RequestMapping(value = "/queryRecipeRecord", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<RecipeVo.RecipeRecord>> queryRecipeRecord(@ApiParam @Validated @RequestBody QueryDto<RecipeDto.RecipeProjectId> params) {
// log.info("查看患者处方项下的训练记录:{}",params);
// List<RecipeVo.RecipeRecord> recipeRecords = recipeService.queryRecipeRecord(params.getParam(),params.getUserId());
// log.info("查看患者处方项下的训练记录成功:{}",recipeRecords);
// return JsonResponse.newInstance().ok(recipeRecords);
// }
@Resource
private IRecipeService recipeService;
@MustLogin
@ApiOperation(value = "查看所有训练", notes = "zy:")
@RequestMapping(value = "/queryDrill", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<RecipeVo.Drill>> queryDrill(@ApiParam @Validated @RequestBody QueryDto params) {
log.info("查看所有训练:{}",params);
List<RecipeVo.Drill> drillList = recipeService.queryDrill(params.getUserId());
log.info("查看所有训练成功:{}",drillList);
return JsonResponse.newInstance().ok(drillList);
}
@MustLogin
@ApiOperation(value = "查看训练项目对应的游戏", notes = "zy:")
@RequestMapping(value = "/game", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<RecipeVo.Game>> queryGameByDrill(@ApiParam @Validated @RequestBody QueryDto<RecipeDto.DrillId> params) {
log.info("查看训练项目对应的游戏:{}",params);
List<RecipeVo.Game> gameList = recipeService.queryGameByDrill(params.getParam(),params.getUserId());
log.info("查看训练项目对应的游戏成功:{}",gameList);
return JsonResponse.newInstance().ok(gameList);
}
@MustLogin
@ApiOperation(value = "给患者添加处方", notes = "zy:")
@RequestMapping(value = "/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse queryPatientByDoctorId(@ApiParam @Validated @RequestBody QueryDto<RecipeDto.AddRecipe> params) {
log.info("主治医生查看患者列表:{}",params);
recipeService.queryPatientByDoctorId(params.getParam(),params.getUserId());
log.info("主治医生查看患者列表成功");
return JsonResponse.newInstance().ok();
}
@MustLogin
@ApiOperation(value = "查看患者的处方信息", notes = "zy:查找患者所有的处方信息,按倒叙排列")
@RequestMapping(value = "/queryRecipe", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<RecipeVo.PatientRecipe>> queryRecipeByPatientId(@ApiParam @Validated @RequestBody QueryDto<PatientDto.PatientId> params) {
log.info("查看患者的处方信息:{}",params);
List<RecipeVo.PatientRecipe> patientRecipeList = recipeService.queryRecipeByPatientId(params.getParam(),params.getUserId());
log.info("查看患者的处方信息成功:{}",patientRecipeList);
return JsonResponse.newInstance().ok(patientRecipeList);
}
@MustLogin
@ApiOperation(value = "查看患者处方项下的训练记录", notes = "zy:")
@RequestMapping(value = "/queryRecipeRecord", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<RecipeVo.RecipeRecord>> queryRecipeRecord(@ApiParam @Validated @RequestBody QueryDto<RecipeDto.RecipeProjectId> params) {
log.info("查看患者处方项下的训练记录:{}",params);
List<RecipeVo.RecipeRecord> recipeRecords = recipeService.queryRecipeRecord(params.getParam(),params.getUserId());
log.info("查看患者处方项下的训练记录成功:{}",recipeRecords);
return JsonResponse.newInstance().ok(recipeRecords);
}
}

2
recovery/src/main/java/com/ccsens/recovery/bean/dto/PatientDto.java

@ -75,7 +75,7 @@ public class PatientDto {
@ApiModelProperty("康复中心医生id")
private Long sceneDoctorId;
@ApiModelProperty("是否有远程指导 0否 1是")
private Long remoteGuidance;
private byte remoteGuidance;
@ApiModelProperty("远程指导医生id")
private Long remoteDoctorId;
}

66
recovery/src/main/java/com/ccsens/recovery/bean/message/BaseMessageDto.java

@ -0,0 +1,66 @@
package com.ccsens.recovery.bean.message;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.util.bean.message.common.InMessage;
import lombok.Data;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Data
public class BaseMessageDto {
@Data
public static class MessageUser {
private Long id;
private Long userId; //本质上是authId //20190507 本质上是userId
private String nickname;
private String avatarUrl;
private boolean hasRead;
public MessageUser(){
hasRead = false;
}
public MessageUser(Long userId){
hasRead = false;
this.userId = userId;
}
public MessageUser(Long id,Long userId,String nickname,String avatarUrl){
this();
this.id = id;
this.userId = userId;
this.nickname = nickname;
this.avatarUrl = avatarUrl;
}
public static List<MessageUser> userIdToUsers(List<Long> userIds) {
List<MessageUser> users = new ArrayList<>();
userIds.forEach(userId ->{
users.add(new MessageUser(userId));
});
return users;
}
}
private Long time;
private String type;
private String event;
private Long projectId;
private MessageUser sender;
private List<MessageUser> receivers;
// private Object data;
public Set<String> receiversTransTos() {
Set<String> tos = new HashSet<>();
if (CollectionUtil.isEmpty(receivers)) {
return tos;
}
receivers.forEach(receiver -> {
InMessage.To to = new InMessage.To(receiver.getUserId());
tos.add(JSONObject.toJSONString(to));
});
return tos;
}
}

34
recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithStartRecipe.java

@ -0,0 +1,34 @@
package com.ccsens.recovery.bean.message;
import com.ccsens.recovery.util.Constant;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class RecoveryWithStartRecipe extends BaseMessageDto{
@lombok.Data
public static class Data{
private Long projectId;
}
private Data data;
public RecoveryWithStartRecipe(){
setType(Constant.Message.START_RECOVERY);
setEvent(Constant.Message.START_RECOVERY);
setTime(System.currentTimeMillis());
}
public RecoveryWithStartRecipe(Long projectId){
this();
Data d = new Data();
d.setProjectId(projectId);
setData(d);
}
}

23
recovery/src/main/java/com/ccsens/recovery/persist/dao/PatientDao.java

@ -0,0 +1,23 @@
package com.ccsens.recovery.persist.dao;
import com.ccsens.recovery.bean.vo.PatientVo;
import com.ccsens.recovery.bean.vo.RecipeVo;
import com.ccsens.recovery.persist.mapper.PatientMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author
*/
@Repository
public interface PatientDao extends PatientMapper {
List<PatientVo.Patient> queryPatientByDoctorId(@Param("doctorId") Long doctorId);
List<PatientVo.Patient> queryPatientByHospitalId(@Param("hospitalId") Long hospitalId);
PatientVo.Patient getPatientById(@Param("id")Long id);
List<RecipeVo.PatientRecipe> queryRecipeByPatientId(@Param("patientId")Long patientId);
}

3
recovery/src/main/java/com/ccsens/recovery/service/IPatientService.java

@ -3,6 +3,7 @@ package com.ccsens.recovery.service;
import com.ccsens.recovery.bean.dto.HospitalDto;
import com.ccsens.recovery.bean.dto.PatientDto;
import com.ccsens.recovery.bean.vo.PatientVo;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.List;
@ -45,7 +46,7 @@ public interface IPatientService {
* @param param 患者id和机器人id
* @param userId userId
*/
void choosePatient(PatientDto.ChoosePatient param, Long userId);
void choosePatient(PatientDto.ChoosePatient param, Long userId) throws Exception;
/**
* 开启训练

82
recovery/src/main/java/com/ccsens/recovery/service/PatientService.java

@ -1,14 +1,35 @@
package com.ccsens.recovery.service;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import com.ccsens.recovery.bean.dto.HospitalDto;
import com.ccsens.recovery.bean.dto.PatientDto;
import com.ccsens.recovery.bean.message.RecoveryWithStartRecipe;
import com.ccsens.recovery.bean.po.HospitalRobot;
import com.ccsens.recovery.bean.po.Patient;
import com.ccsens.recovery.bean.po.RecRecord;
import com.ccsens.recovery.bean.vo.PatientVo;
import com.ccsens.recovery.persist.dao.PatientDao;
import com.ccsens.recovery.persist.mapper.HospitalRobotMapper;
import com.ccsens.recovery.persist.mapper.RecRecordMapper;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.bean.message.common.InMessage;
import com.ccsens.util.bean.message.common.MessageConstant;
import com.ccsens.util.bean.message.common.MessageRule;
import com.ccsens.util.config.RabbitMQConfig;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author
*/
@ -16,19 +37,31 @@ import java.util.List;
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class PatientService implements IPatientService{
@Resource
private PatientDao patientDao;
@Resource
private HospitalRobotMapper hospitalRobotMapper;
@Resource
private AmqpTemplate rabbitTemplate;
@Resource
private Snowflake snowflake;
@Resource
private RecRecordMapper recRecordMapper;
@Override
public List<PatientVo.Patient> queryPatientByDoctorId(HospitalDto.DoctorId param, Long userId) {
return null;
//查找患者表
return patientDao.queryPatientByDoctorId(param.getId());
}
@Override
public List<PatientVo.Patient> queryPatientByRecovery(HospitalDto.HospitalId param, Long userId) {
return null;
return patientDao.queryPatientByHospitalId(param.getId());
}
@Override
public PatientVo.Patient getPatientById(PatientDto.PatientId param, Long userId) {
return null;
return patientDao.getPatientById(param.getId());
}
@Override
@ -37,12 +70,52 @@ public class PatientService implements IPatientService{
}
@Override
public void choosePatient(PatientDto.ChoosePatient param, Long userId) {
public void choosePatient(PatientDto.ChoosePatient param, Long userId) throws Exception {
//查找患者
Patient patient = patientDao.selectByPrimaryKey(param.getId());
if(ObjectUtil.isNull(patient)){
return;
}
//查找机器人
HospitalRobot robot = hospitalRobotMapper.selectByPrimaryKey(param.getRobotId());
if(ObjectUtil.isNull(robot)){
return;
}
//获取接收者id
Set<String> userIdSet = new HashSet<>();
userIdSet.add(robot.getUserid().toString());
//生成消息
RecoveryWithStartRecipe recoveryWithStartRecipe = new RecoveryWithStartRecipe(patient.getProjectId());
//封装成inMessage
MessageRule messageRule = MessageRule.defaultRule(MessageConstant.DomainType.User);
messageRule.setAckRule(MessageRule.AckRule.NONE);
messageRule.setOfflineDiscard((byte) 1);
InMessage inMessage = new InMessage();
inMessage.setToDomain(MessageConstant.DomainType.User);
inMessage.setTos(userIdSet);
inMessage.setData(JacksonUtil.beanToJson(recoveryWithStartRecipe));
inMessage.setRule(messageRule);
log.info("开启康复流程消息:{}",inMessage);
rabbitTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME,
JacksonUtil.beanToJson(inMessage));
}
@Override
public PatientVo.RecipeRecordId startDrill(PatientDto.StartDrill param, Long userId) {
//存储一条训练记录
RecRecord recRecord = new RecRecord();
recRecord.setId(snowflake.nextId());
recRecord.setStartTime(System.currentTimeMillis());
recRecord.setRecipeProjectId(param.getRecipeProjectId());
recRecord.setSceneDoctorId(param.getSceneDoctorId());
recRecord.setGameId(param.getGameId());
recRecord.setRemoteGuidance(param.getRemoteGuidance());
recRecord.setRemoteDoctorId(param.getRemoteDoctorId());
recRecord.setSubTaskId(param.getTaskId());
recRecordMapper.insertSelective(recRecord);
//给对应的康复机器人发消息、机器人切换至全屏游戏
return null;
}
@ -55,4 +128,5 @@ public class PatientService implements IPatientService{
public void actionFeedback(PatientDto.ActionFeedback param, Long userId) {
}
}

7
recovery/src/main/java/com/ccsens/recovery/service/RecipeService.java

@ -3,11 +3,13 @@ package com.ccsens.recovery.service;
import com.ccsens.recovery.bean.dto.PatientDto;
import com.ccsens.recovery.bean.dto.RecipeDto;
import com.ccsens.recovery.bean.vo.RecipeVo;
import com.ccsens.recovery.persist.dao.PatientDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* @author
@ -16,6 +18,9 @@ import java.util.List;
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class RecipeService implements IRecipeService{
@Resource
private PatientDao patientDao;
@Override
public void queryPatientByDoctorId(RecipeDto.AddRecipe param, Long userId) {
@ -28,7 +33,7 @@ public class RecipeService implements IRecipeService{
@Override
public List<RecipeVo.PatientRecipe> queryRecipeByPatientId(PatientDto.PatientId param, Long userId) {
return null;
return patientDao.queryRecipeByPatientId(param.getId());
}
@Override

6
recovery/src/main/java/com/ccsens/recovery/util/Constant.java

@ -6,5 +6,9 @@ package com.ccsens.recovery.util;
*/
public class Constant {
/**消息*/
public static final class Message {
/**启动康复流程*/
public static final String START_RECOVERY = "startRecovery";
}
}

4
recovery/src/main/resources/application-test.yml

@ -12,9 +12,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:
host: 127.0.0.1
password: 111111
password: guest
port: 5672
username: admin
username: guest
redis:
database: 0
host: 127.0.0.1

124
recovery/src/main/resources/mapper_dao/PatientDao.xml

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.recovery.persist.dao.PatientDao">
<select id="queryPatientByDoctorId" resultType="com.ccsens.recovery.bean.vo.PatientVo$Patient">
SELECT
p.id as id,
p.`name` as `name`,
p.sex as sex,
p.age as age,
p.id_card as idCord,
p.phone as phone,
p.address as address,
h.id as hospitalId,
h.`name` as hospitalName,
d.id as doctorId,
d.`name` as doctorName
FROM
t_patient p,
t_doctor d,
t_hospital h
WHERE
p.doctor_id = d.id
and p.hospital_id = h.id
and p.rec_status = 0
and d.rec_status = 0
and h.rec_status = 0
and d.id = #{doctorId}
</select>
<select id="queryPatientByHospitalId" resultType="com.ccsens.recovery.bean.vo.PatientVo$Patient">
SELECT
p.id as id,
p.`name` as `name`,
p.sex as sex,
p.age as age,
p.id_card as idCord,
p.phone as phone,
p.address as address,
h.id as hospitalId,
h.`name` as hospitalName,
d.id as doctorId,
d.`name` as doctorName
FROM
t_patient p,
t_doctor d,
t_hospital h
WHERE
p.doctor_id = d.id
and p.hospital_id = h.id
and p.rec_status = 0
and d.rec_status = 0
and h.rec_status = 0
and h.id = #{hospitalId}
</select>
<select id="getPatientById" resultType="com.ccsens.recovery.bean.vo.PatientVo$Patient">
SELECT
p.id as id,
p.`name` as `name`,
p.sex as sex,
p.age as age,
p.id_card as idCord,
p.phone as phone,
p.address as address,
h.id as hospitalId,
h.`name` as hospitalName,
d.id as doctorId,
d.`name` as doctorName
FROM
t_patient p,
t_doctor d,
t_hospital h
WHERE
p.doctor_id = d.id
and p.hospital_id = h.id
and p.rec_status = 0
and d.rec_status = 0
and h.rec_status = 0
and p.id = #{id}
</select>
<resultMap id="queryRecipe" type="com.ccsens.recovery.bean.vo.RecipeVo$PatientRecipe">
<id column="id" property="id"/>
<result column="startTime" property="startTime"/>
<result column="endTime" property="endTime"/>
<result column="type" property="type"/>
<result column="doctorId" property="doctorId"/>
<result column="doctorName" property="doctorName"/>
<collection property="recipeProjectList" ofType="com.ccsens.recovery.bean.vo.RecipeVo$RecipeProject">
<id column="recipeProjectId" property="recipeProjectId"/>
<result column="drillId" property="drillId"/>
<result column="drillName" property="drillName"/>
<result column="cycle" property="cycle"/>
<result column="timesDay" property="timesDay"/>
<result column="groupTimes" property="groupTimes"/>
<result column="severalGroup" property="severalGroup"/>
</collection>
</resultMap>
<select id="queryRecipeByPatientId" resultMap="queryRecipe">
SELECT
r.id as id,
r.start_time as startTime,
r.end_time as endTime,
r.type as type,
doc.id as doctorId,
doc.`name` as doctorName,
p.id as recipeProjectId,
d.id as drillId,
d.`name` as drillName,
p.cycle as cycle,
p.times_day as timesDay,
p.group_times as groupTimes,
p.several_group as severalGroup
FROM
t_recipe r
LEFT JOIN t_recipe_project p on r.id = p.recipe_id and p.rec_status = 0
LEFT JOIN t_rec_drill d on p.drill_id = d.id and d.rec_status = 0
LEFT JOIN t_doctor doc on r.doctor_id = doc.id and doc.rec_status = 0
WHERE
r.rec_status = 0
and r.patient_id = #{patientId}
</select>
</mapper>

4
tall/src/main/resources/application.yml

@ -1,6 +1,6 @@
spring:
profiles:
active: test
include: util-test,common
active: dev
include: util-dev,common

7
util/src/main/java/com/ccsens/util/cron/NatureToDate.java

@ -20,8 +20,8 @@ public class NatureToDate {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start = sdf.parse("2019-11-1 8:00:00");
Date end = sdf.parse("2020-11-30 8:00:00");
Date start = sdf.parse("2019-11-1 0:00:00");
Date end = sdf.parse("2019-11-2 0:00:00");
// System.out.println("每周一:" + generateDates("每周一", start, end));
// System.out.println("每周二:" + generateDates("每周二", start, end));
@ -42,7 +42,8 @@ public class NatureToDate {
// System.out.println("入职第一月:" + generateDates("入职第一月", start, end));
// System.out.println("入职第一年:" + generateDates("入职第一年", start, end));
// System.out.println("第八天:" + generateDates("第八天", start, end));
System.out.println("第1天:" + generateDates("第1天", start, end));
// System.out.println("第1天:" + generateDates("第1天", start, end));
System.out.println("每40分钟:" + generateDates("每40分钟", start, end));
// System.out.println("每月15号下午5点:" + generateDates("每月15号下午5点", start, end));
// log.info("周一到周五 8点-9点: " + generateDates("周一到周五 18点", start, end));

Loading…
Cancel
Save