23 changed files with 842 additions and 81 deletions
@ -0,0 +1,66 @@ |
|||
package com.ccsens.util.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; |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.ccsens.util.message; |
|||
|
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* @author 逗 |
|||
*/ |
|||
|
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
public class RecoveryWithStartRecipe extends BaseMessageDto{ |
|||
/**切换项目*/ |
|||
public static final String SWITCHOVER_PROJECT = "switchoverProject"; |
|||
|
|||
@lombok.Data |
|||
public static class Data{ |
|||
private Long projectId; |
|||
} |
|||
|
|||
private Data data; |
|||
|
|||
public RecoveryWithStartRecipe(){ |
|||
setType(SWITCHOVER_PROJECT); |
|||
setEvent(SWITCHOVER_PROJECT); |
|||
setTime(System.currentTimeMillis()); |
|||
} |
|||
|
|||
public RecoveryWithStartRecipe(Long projectId){ |
|||
this(); |
|||
Data d = new Data(); |
|||
d.setProjectId(projectId); |
|||
setData(d); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
package com.ccsens.util.message; |
|||
|
|||
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.amqp.rabbit.core.RabbitTemplate; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import javax.annotation.Resource; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @author 逗 |
|||
*/ |
|||
@Component |
|||
@Slf4j |
|||
public class SwitchoverProjectUtil { |
|||
@Resource |
|||
private AmqpTemplate amqpTemplate; |
|||
private static SwitchoverProjectUtil util; |
|||
|
|||
@PostConstruct |
|||
public void init(){ |
|||
util = this; |
|||
util.amqpTemplate = this.amqpTemplate; |
|||
} |
|||
|
|||
public static void switchoverProject(Set<String> userIdSet,Long projectId) throws JsonProcessingException { |
|||
log.info("切换项目:{}--{}",projectId,userIdSet); |
|||
//设定发送规则
|
|||
MessageRule messageRule = MessageRule.defaultRule(MessageConstant.DomainType.User); |
|||
messageRule.setAckRule(MessageRule.AckRule.NONE); |
|||
messageRule.setOfflineDiscard((byte) 1); |
|||
//生成消息
|
|||
RecoveryWithStartRecipe recoveryWithStartRecipe = new RecoveryWithStartRecipe(projectId); |
|||
//封装成inMessage
|
|||
InMessage inMessage = new InMessage(); |
|||
inMessage.setToDomain(MessageConstant.DomainType.User); |
|||
inMessage.setTos(userIdSet); |
|||
inMessage.setData(JacksonUtil.beanToJson(recoveryWithStartRecipe)); |
|||
inMessage.setRule(messageRule); |
|||
log.info("发送切换项目信息:{}",inMessage); |
|||
util.amqpTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME, |
|||
JacksonUtil.beanToJson(inMessage)); |
|||
} |
|||
} |
|||
File diff suppressed because one or more lines are too long
@ -0,0 +1,46 @@ |
|||
package com.ccsens.wisdomcar.api; |
|||
|
|||
import com.ccsens.cloudutil.annotation.MustLogin; |
|||
import com.ccsens.util.JsonResponse; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import com.ccsens.wisdomcar.bean.dto.StepDto; |
|||
import com.ccsens.wisdomcar.bean.vo.PatientVo; |
|||
import com.ccsens.wisdomcar.bean.vo.StepVo; |
|||
import com.ccsens.wisdomcar.service.IStepService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author 马 |
|||
*/ |
|||
@Slf4j |
|||
@Api(tags = "环节(节点)相关接口" , description = "") |
|||
@RestController |
|||
@RequestMapping("/step") |
|||
public class StepController { |
|||
|
|||
@Resource |
|||
private IStepService stepService; |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "查看节点是否完成", notes = "mz") |
|||
@RequestMapping(value = "/findStepIsOver", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<StepVo.StepStatus> findStepIsOver(@ApiParam @Validated @RequestBody QueryDto<StepDto.FindStepStatus> params) { |
|||
log.info("查看节点是否完成:{}", params); |
|||
List<StepVo.StepStatus> stepStatuses = stepService.findStepIsOver(params.getParam()); |
|||
log.info("查看节点是否完成接口结束{}",stepStatuses); |
|||
return JsonResponse.newInstance().ok(stepStatuses); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.ccsens.wisdomcar.bean.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
@Data |
|||
public class StepDto { |
|||
|
|||
@Data |
|||
@ApiModel("查看环节完成状态") |
|||
public static class FindStepStatus{ |
|||
@ApiModelProperty("患者平车id") |
|||
private Long patientCarId; |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package com.ccsens.wisdomcar.bean.vo; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
@Data |
|||
public class PatientVo { |
|||
|
|||
@Data |
|||
@ApiModel("医生查看以前患者") |
|||
public static class PatientRecord { |
|||
@ApiModelProperty("患者姓名") |
|||
private String name; |
|||
@ApiModelProperty("患者性别(0-女,1-男)") |
|||
private Byte sex; |
|||
@ApiModelProperty("患者年龄") |
|||
private Integer age; |
|||
@ApiModelProperty("患者电话号") |
|||
private String phone; |
|||
@ApiModelProperty("患者身份证号") |
|||
private String idCard; |
|||
@ApiModelProperty("项目id") |
|||
private Long projectId; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.ccsens.wisdomcar.service; |
|||
|
|||
|
|||
import com.ccsens.wisdomcar.bean.dto.StepDto; |
|||
import com.ccsens.wisdomcar.bean.vo.StepVo; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
public interface IStepService { |
|||
/** |
|||
* 查看环节是否完成 |
|||
* @param param 患者平车id |
|||
* @return 环节状态 |
|||
*/ |
|||
List<StepVo.StepStatus> findStepIsOver(StepDto.FindStepStatus param); |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package com.ccsens.wisdomcar.service; |
|||
|
|||
import com.ccsens.wisdomcar.bean.dto.StepDto; |
|||
import com.ccsens.wisdomcar.bean.vo.StepVo; |
|||
|
|||
import com.ccsens.wisdomcar.persist.dao.StepDao; |
|||
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 马 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|||
public class StepService implements IStepService { |
|||
|
|||
@Resource |
|||
private StepDao stepDao; |
|||
|
|||
@Override |
|||
public List<StepVo.StepStatus> findStepIsOver(StepDto.FindStepStatus param) { |
|||
return stepDao.findStepIsOver(param.getPatientCarId()); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
<?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.wisdomcar.persist.dao.PatientDoctorDao"> |
|||
|
|||
|
|||
<select id="findPatientIdByDoctor" resultType="java.lang.Long"> |
|||
SELECT |
|||
patient_id |
|||
FROM |
|||
t_patient_doctor |
|||
WHERE |
|||
doctor_id = #{id} |
|||
AND rec_status = 0 |
|||
</select> |
|||
</mapper> |
|||
Loading…
Reference in new issue