hyy-alt 4 years ago
parent
commit
6125d726f6
  1. 2
      cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TaskDto.java
  2. 6
      recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithActionFeedBack.java
  3. 8
      recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithEndDrill.java
  4. 1
      recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithScore.java
  5. 2
      recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithStartDrill.java
  6. 28
      recovery/src/main/java/com/ccsens/recovery/service/MessageService.java
  7. 85
      recovery/src/main/java/com/ccsens/recovery/service/PatientService.java
  8. 2
      recovery/src/main/java/com/ccsens/recovery/util/Constant.java
  9. 2
      tall/src/main/java/com/ccsens/tall/bean/dto/TaskDto.java
  10. 33
      tall/src/main/java/com/ccsens/tall/service/TaskSubTimeService.java
  11. 4
      tall/src/main/resources/application.yml
  12. 2
      util/src/main/java/com/ccsens/util/bean/message/common/MessageConstant.java
  13. 1
      wisdomcar/src/main/java/com/ccsens/wisdomcar/service/AsyncService.java
  14. 13
      wisdomcar/src/main/java/com/ccsens/wisdomcar/service/WisdomCarService.java
  15. 3
      wisdomcar/src/main/resources/application-test.yml
  16. 1
      wisdomcar/src/main/resources/application.yml

2
cloudutil/src/main/java/com/ccsens/cloudutil/bean/tall/dto/TaskDto.java

@ -26,6 +26,8 @@ public class TaskDto {
private Long taskId;
@ApiModelProperty("开始任务的时间 如果为空则为当前时间")
private Long startTime;
@ApiModelProperty("是否修改后续任务的时间(0否,1是)")
private Byte isUpdateTime = 0;
}
@ApiModel

6
recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithActionFeedBack.java

@ -18,8 +18,12 @@ public class RecoveryWithActionFeedBack extends BaseMessageDto{
//本次训练记录id
private Long recordId;
//动作是否正确 0否 1是
private int result;
private int result = 0;
private List<Info> infoList;
//训练分数
private int score;
//次数
private int times;
}
@lombok.Data

8
recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithEndDrill.java

@ -19,18 +19,22 @@ public class RecoveryWithEndDrill extends BaseMessageDto{
private int score;
//次数
private int times;
//状态
private int status;
}
private RecoveryWithEndDrill.Data data;
public RecoveryWithEndDrill(){
setType(Constant.Message.SCORE);
setEvent(Constant.Message.SCORE);
setType(Constant.Message.END_DRILL);
setEvent(Constant.Message.END_DRILL);
setTime(System.currentTimeMillis());
}
public RecoveryWithEndDrill(Data data) {
this();
this.data = data;
}
}

1
recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithScore.java

@ -31,6 +31,7 @@ public class RecoveryWithScore extends BaseMessageDto{
}
public RecoveryWithScore(Data data) {
this();
this.data = data;
}
}

2
recovery/src/main/java/com/ccsens/recovery/bean/message/RecoveryWithStartDrill.java

@ -18,6 +18,8 @@ public class RecoveryWithStartDrill extends BaseMessageDto{
private Long patientId;
//本次训练记录id
private Long recordId;
//"训练状态 0未开始 1进行中 2已结束")
private int status;
//"开始时间"
private Long startTime;
//"时长")

28
recovery/src/main/java/com/ccsens/recovery/service/MessageService.java

@ -91,25 +91,25 @@ public class MessageService implements IMessageService {
}
}
}
//将消息转发给机器人
ChannelManager.sendTo(robotUserId, OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(feedBack))));
//处理分数
RecoveryWithActionFeedBack.Data data = feedBack.getData();
if(ObjectUtil.isNotNull(data)){
if(data.getResult() == 1){
//处理分数
redisUtil.incr(Constant.Redis.RECORD_SCORE + data.getRecordId(),5);
redisUtil.incr(Constant.Redis.RECORD_TIMES + data.getRecordId(),5);
//给机器人和患者发送分数消息
RecoveryWithScore.Data data1 = new RecoveryWithScore.Data();
data1.setScore((Integer) redisUtil.get(Constant.Redis.RECORD_SCORE + data.getRecordId()));
data1.setTimes((Integer) redisUtil.get(Constant.Redis.RECORD_TIMES + data.getRecordId()));
RecoveryWithScore recoveryWithScore = new RecoveryWithScore(data1);
//机器人
ChannelManager.sendTo(robotUserId, OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithScore))));
//患者
ChannelManager.sendTo(userId, OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithScore))));
redisUtil.incr(Constant.Redis.RECORD_TIMES + data.getRecordId(),1);
//查询分数
Object redisScore = redisUtil.get(Constant.Redis.RECORD_SCORE + data.getRecordId());
Object redisTimes = redisUtil.get(Constant.Redis.RECORD_TIMES + data.getRecordId());
int score = redisScore == null ? 0 : (int) redisScore;
int times = redisTimes == null ? 0 : (int) redisTimes;
data.setScore(score);
data.setTimes(times);
log.info("训练的分数及次数 score--:{}--time--:{}",score,times);
}
}
//将消息转发给机器人
ChannelManager.sendTo(robotUserId, OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(feedBack))));
//发送给患者
ChannelManager.sendTo(userId, OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(feedBack))));
}
}

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

@ -158,6 +158,8 @@ public class PatientService implements IPatientService{
Object o = redisUtil.get(Constant.Redis.RECORD_SCORE + recRecord.getId());
data.setScore(o == null ? 0 : (Integer) o);
data.setSubTaskId(projectDecompose.getTaskId());
data.setStatus(1);
recoveryWithStartDrill.setData(data);
//用pt的WS发送消息
//查询接收者
@ -176,6 +178,8 @@ public class PatientService implements IPatientService{
log.info("开始训练消息:{}",inMessage);
rabbitTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME,
JacksonUtil.beanToJson(inMessage));
//用新ws给患者再发一条消息
ChannelManager.sendTo(patient.getUserId().toString(), OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithStartDrill))));
//给机器人发送消息,用新的WS
RecoveryRobot recoveryRobot = patientDao.getRobotByPatientId(param.getPatientId());
if(ObjectUtil.isNotNull(recoveryRobot)){
@ -203,17 +207,21 @@ public class PatientService implements IPatientService{
RecoveryWithEndDrill.Data data = new RecoveryWithEndDrill.Data();
data.setRecordId(param.getId());
data.setScore(score);
data.setStatus(2);
RecoveryWithEndDrill recoveryWithEndDrill = new RecoveryWithEndDrill(data);
//查找患者信息
Patient patient = patientDao.selectByPrimaryKey(param.getId());
Patient patient = patientDao.selectByPrimaryKey(param.getPatientId());
if(ObjectUtil.isNotNull(patient)) {
ChannelManager.sendTo(patient.getUserId().toString(), OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithEndDrill))));
//查找患者关联的机器人信息
RecoveryRobot recoveryRobot = patientDao.getRobotByPatientId(patient.getId());
if(ObjectUtil.isNotNull(recipeRecord)){
ChannelManager.sendTo(recoveryRobot.getUserid().toString(), OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithEndDrill))));
}
}
//查找患者关联的机器人信息
RecoveryRobot recoveryRobot = patientDao.getRobotByPatientId(patient.getId());
if(ObjectUtil.isNotNull(recipeRecord)){
ChannelManager.sendTo(recoveryRobot.getUserid().toString(), OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithEndDrill))));
}
//删除redis内的分数
redisUtil.del(Constant.Redis.RECORD_SCORE + recipeRecord.getId());
redisUtil.del(Constant.Redis.RECORD_TIMES + recipeRecord.getId());
}
}
@ -285,7 +293,9 @@ public class PatientService implements IPatientService{
if(ObjectUtil.isNotNull(patient)){
//查询患者当前关联的机器人
RecoveryRobot recoveryRobot = patientDao.getRobotByPatientId(patient.getId());
userIdSet.add(recoveryRobot.getUserid().toString());
if(ObjectUtil.isNotNull(recoveryRobot)){
userIdSet.add(recoveryRobot.getUserid().toString());
}
//查询患者所属的康复中心关联的项目
RecoveryCentre recoveryCentre = recoveryCentreMapper.selectByPrimaryKey(patient.getCentreId());
if(ObjectUtil.isNotNull(recoveryCentre)){
@ -305,27 +315,46 @@ public class PatientService implements IPatientService{
@Override
public PatientVo.RecordStatus getDrillStatus(PatientDto.SubTimeTaskId param, Long userId) {
PatientVo.RecordStatus recordStatus = new PatientVo.RecordStatus();
RecipeRecordExample recipeRecordExample = new RecipeRecordExample();
recipeRecordExample.createCriteria().andSubTaskIdEqualTo(param.getSubTaskId());
List<RecipeRecord> recipeRecordList = recipeRecordMapper.selectByExample(recipeRecordExample);
if(CollectionUtil.isNotEmpty(recipeRecordList)){
RecipeRecord recipeRecord = recipeRecordList.get(0);
recordStatus.setId(recipeRecord.getId());
if(ObjectUtil.isNotNull(recipeRecord.getStartTime()) && ObjectUtil.isNotNull(recipeRecord.getEndTime())){
if(recipeRecord.getStartTime() != 0 && recipeRecord.getEndTime() == 0){
recordStatus.setStatus(1);
recordStatus.setStartTime(recipeRecord.getStartTime());
return recordStatus;
}
if(recipeRecord.getEndTime() != 0){
recordStatus.setStatus(2);
recordStatus.setStartTime(recipeRecord.getStartTime());
return recordStatus;
//查询分解的处方项信息
Long decomposeId = null;
RecipeProjectDecomposeExample decomposeExample = new RecipeProjectDecomposeExample();
decomposeExample.createCriteria().andTaskIdEqualTo(param.getSubTaskId());
List<RecipeProjectDecompose> decomposeList = projectDecomposeMapper.selectByExample(decomposeExample);
if(CollectionUtil.isEmpty(decomposeList)){
RecipeProjectDecomposeExample decomposeExample1 = new RecipeProjectDecomposeExample();
decomposeExample1.createCriteria().andRobotTaskIdEqualTo(param.getSubTaskId());
List<RecipeProjectDecompose> decomposeList1 = projectDecomposeMapper.selectByExample(decomposeExample);
if(CollectionUtil.isNotEmpty(decomposeList1)){
decomposeId = decomposeList1.get(0).getId();
}
}else {
decomposeId = decomposeList.get(0).getId();
}
if(ObjectUtil.isNotNull(decomposeId)){
RecipeRecordExample recipeRecordExample = new RecipeRecordExample();
recipeRecordExample.createCriteria().andDecomposeIdEqualTo(decomposeId);
List<RecipeRecord> recipeRecordList = recipeRecordMapper.selectByExample(recipeRecordExample);
if(CollectionUtil.isNotEmpty(recipeRecordList)){
RecipeRecord recipeRecord = recipeRecordList.get(0);
recordStatus.setId(recipeRecord.getId());
if(ObjectUtil.isNotNull(recipeRecord.getStartTime()) && ObjectUtil.isNotNull(recipeRecord.getEndTime())){
if(recipeRecord.getStartTime() != 0 && recipeRecord.getEndTime() == 0){
recordStatus.setStatus(1);
recordStatus.setStartTime(recipeRecord.getStartTime());
Object o = redisUtil.get(Constant.Redis.RECORD_SCORE + recipeRecord.getId());
recordStatus.setScore(o == null ? 0 : (int)o);
return recordStatus;
}
if(recipeRecord.getEndTime() != 0){
recordStatus.setStatus(2);
recordStatus.setStartTime(recipeRecord.getStartTime());
recordStatus.setScore(recipeRecord.getScore());
return recordStatus;
}
}
}
recordStatus.setStatus(0);
}
recordStatus.setStatus(0);
return recordStatus;
}
@ -341,7 +370,13 @@ public class PatientService implements IPatientService{
//生成消息
RecoveryWithCountdown recoveryWithCountdown = new RecoveryWithCountdown();
log.info("倒计时结束消息:{}",recoveryWithCountdown);
//给患者发送消息
ChannelManager.sendTo(patientUserId, OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithCountdown))));
//给机器人发送新消息
RecoveryRobot recoveryRobot = patientDao.getRobotByPatientId(patient.getId());
if(ObjectUtil.isNotNull(recoveryRobot)){
ChannelManager.sendTo(recoveryRobot.getUserid().toString(), OutMessageSet.newInstance().ackId(null).add(new OutMessage(JacksonUtil.beanToJson(recoveryWithCountdown))));
}
// Set<String> userIdSet = new HashSet<>();

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

@ -18,6 +18,8 @@ public class Constant {
public static final String COUNTDOWN = "countdown";
/**训练分数消息*/
public static final String SCORE = "score";
/**结束训练*/
public static final String END_DRILL = "endDrill";
}
/**消息*/

2
tall/src/main/java/com/ccsens/tall/bean/dto/TaskDto.java

@ -168,6 +168,8 @@ public class TaskDto {
private Long taskId;
@ApiModelProperty("开始任务的时间 如果为空则为当前时间")
private Long startTime;
@ApiModelProperty("是否修改后续任务的时间(0否,1是)")
private Byte isUpdateTime = 0;
}
@Data

33
tall/src/main/java/com/ccsens/tall/service/TaskSubTimeService.java

@ -263,7 +263,14 @@ public class TaskSubTimeService implements ITaskSubTimeService {
}
taskSubTime.setComplatedStatus(1);
taskSubTimeDao.updateByPrimaryKeySelective(taskSubTime);
if (1 == startTaskDto.getIsUpdateTime()){
ProTaskDetail taskDetail = taskDetailDao.selectByPrimaryKey(taskSubTime.getTaskDetailId());
if (ObjectUtil.isNotNull(taskDetail)){
Long timeDifference = taskSubTime.getBeginTime()-now;
//寻找下到工序并修改时间
updateTimeDifference(timeDifference,taskDetail.getId());
}
}
//查找任务的负责人名
String player = null;
@ -336,6 +343,30 @@ public class TaskSubTimeService implements ITaskSubTimeService {
}
}
/**
* 修改分解任务预计时间
* @param timeDifference 时间差
* @param taskDetailId 任务详情id
*/
public void updateTimeDifference(Long timeDifference,Long taskDetailId){
Long currentTime = System.currentTimeMillis();
ProTaskDetailExample taskDetailExample = new ProTaskDetailExample();
taskDetailExample.createCriteria().andLastTaskDetailIdEqualTo(taskDetailId);
List<ProTaskDetail> proTaskDetails = taskDetailDao.selectByExample(taskDetailExample);
if (CollectionUtil.isNotEmpty(proTaskDetails)){
for (ProTaskDetail proTaskDetail : proTaskDetails) {
ProTaskSubTimeExample subTimeExample = new ProTaskSubTimeExample();
subTimeExample.createCriteria().andBeginTimeGreaterThan(currentTime).andTaskDetailIdEqualTo(proTaskDetail.getId());
List<ProTaskSubTime> taskSubTimes = taskSubTimeDao.selectByExample(subTimeExample);
if (CollectionUtil.isNotEmpty(taskSubTimes)){
taskSubTimes.get(0).setBeginTime(taskSubTimes.get(0).getBeginTime()+timeDifference);
taskSubTimeDao.updateByPrimaryKeySelective(taskSubTimes.get(0));
}
updateTimeDifference(timeDifference,proTaskDetail.getId());
}
}
}
/**
* 结束其他进行中的任务
*

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

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

2
util/src/main/java/com/ccsens/util/bean/message/common/MessageConstant.java

@ -57,9 +57,9 @@ public class MessageConstant {
Ping(0x00),
//客户端认证
Auth(0x01),
feedback(0x01),
//客户端收到消息ACK
Ack(0x02),
//客户端收到消息ACK

1
wisdomcar/src/main/java/com/ccsens/wisdomcar/service/AsyncService.java

@ -55,6 +55,7 @@ public class AsyncService implements IAsyncService {
startTask.setRoleId(0L);
startTask.setProjectId(patient.getProjectId());
startTask.setStartTime(data.getStartTime());
startTask.setIsUpdateTime((byte)1);
updateData.setPushStatus(Constant.PUSH_STATUS_FAIL);
try {
JsonResponse response = tallFeignClient.startNode(startTask);

13
wisdomcar/src/main/java/com/ccsens/wisdomcar/service/WisdomCarService.java

@ -310,10 +310,10 @@ public class WisdomCarService implements IWisdomCarService {
throw new BaseException(CodeEnum.TASK_IS_EXIST);
}
//查询任务是否是分诊环节的任务ID
Integer taskIsTriageTask = stepTaskDao.findTaskIsTriageTask(param.getTaskSubId());
if (0 == taskIsTriageTask){
throw new BaseException(CodeEnum.PARAM_ERROR);
}
// Integer taskIsTriageTask = stepTaskDao.findTaskIsTriageTask(param.getTaskSubId());
// if (0 == taskIsTriageTask){
// throw new BaseException(CodeEnum.PARAM_ERROR);
// }
//查询患者是否存在
Integer patientIsExist = patientProjectDao.findPatientIsExist(param.getProjectId());
if (0 == patientIsExist){
@ -381,8 +381,9 @@ public class WisdomCarService implements IWisdomCarService {
public List<WisdomCarVo.BindingCarInfo> queryBindingCar(WisdomCarDto.QueryInfo param) {
List<WisdomCarVo.BindingCarInfo> bindingCarList = patientWisdomCarDao.queryBindingCarList(param.getTaskSubId());
if(CollectionUtil.isEmpty(bindingCarList)){
log.info("未找到对应的任务");
throw new BaseException(CodeEnum.PARAM_ERROR);
// log.info("未找到对应的任务");
// throw new BaseException(CodeEnum.PARAM_ERROR);
return bindingCarList;
}
for (WisdomCarVo.BindingCarInfo bindingCar : bindingCarList) {
//拿到患者id把 患者的信息存入

3
wisdomcar/src/main/resources/application-test.yml

@ -4,7 +4,8 @@ server:
context-path:
spring:
application:
name: wisdomcar
# name: wisdomcar
name: wisdomcar2
datasource:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:

1
wisdomcar/src/main/resources/application.yml

@ -4,3 +4,4 @@ spring:
include: common, util-dev

Loading…
Cancel
Save