11 changed files with 333 additions and 0 deletions
@ -0,0 +1,47 @@ |
|||||
|
package com.ccsens.carbasics.api; |
||||
|
|
||||
|
import com.ccsens.carbasics.bean.dto.EquipmentDto; |
||||
|
import com.ccsens.carbasics.bean.vo.OrganizationMemberVo; |
||||
|
import com.ccsens.carbasics.service.IEquipmentService; |
||||
|
import com.ccsens.carbasics.service.IOrganizationMemberService; |
||||
|
import com.ccsens.carbasics.util.DefaultCodeError; |
||||
|
import com.ccsens.cloudutil.annotation.MustLogin; |
||||
|
import com.ccsens.util.CodeError; |
||||
|
import com.ccsens.util.JsonResponse; |
||||
|
import com.ccsens.util.bean.dto.QueryDto; |
||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: whj |
||||
|
* @time: 2021/10/19 15:36 |
||||
|
*/ |
||||
|
@Api(tags = "设备相关" ) |
||||
|
@RestController |
||||
|
@RequestMapping("/equipment") |
||||
|
@Slf4j |
||||
|
public class EquipmentController { |
||||
|
|
||||
|
@Resource |
||||
|
private IEquipmentService equipmentService; |
||||
|
|
||||
|
@MustLogin |
||||
|
@ApiOperation(value = "查询用户对应的医院信息", notes = "") |
||||
|
@RequestMapping(value = "/buttonStart", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
||||
|
public JsonResponse buttonStart(@ApiParam @Validated @RequestBody QueryDto<EquipmentDto.Start> params) throws Exception{ |
||||
|
log.info("一键启动请求:{},{}", params.getParam(), params.getUserId()); |
||||
|
CodeError.Code code = equipmentService.start(params.getParam(), params.getUserId()); |
||||
|
log.info("一键启动结果:{}", code); |
||||
|
return JsonResponse.newInstance().ok(code); |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.ccsens.carbasics.bean.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: whj |
||||
|
* @time: 2021/10/19 15:38 |
||||
|
*/ |
||||
|
public class EquipmentDto { |
||||
|
|
||||
|
|
||||
|
@ApiModel("一键启动") |
||||
|
@Data |
||||
|
public static class Start{ |
||||
|
@NotNull |
||||
|
@ApiModelProperty("急救ID") |
||||
|
private Long firstAidId; |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.ccsens.carbasics.bean.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: whj |
||||
|
* @time: 2021/10/19 15:39 |
||||
|
*/ |
||||
|
public class EquipmentVo { |
||||
|
|
||||
|
@ApiModel("未完成的设备信息") |
||||
|
@Data |
||||
|
public static class Unfinished{ |
||||
|
@ApiModelProperty("开始时间") |
||||
|
private Long time; |
||||
|
@ApiModelProperty("通知内容") |
||||
|
private String content; |
||||
|
@ApiModelProperty("总倒计时") |
||||
|
private Long totalCountdown; |
||||
|
} |
||||
|
} |
@ -1,9 +1,34 @@ |
|||||
package com.ccsens.carbasics.persist.dao; |
package com.ccsens.carbasics.persist.dao; |
||||
|
|
||||
|
import com.ccsens.carbasics.bean.vo.EquipmentVo; |
||||
import com.ccsens.carbasics.persist.mapper.EquipmentStatusMapper; |
import com.ccsens.carbasics.persist.mapper.EquipmentStatusMapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
/** |
||||
|
* @author ma |
||||
|
*/ |
||||
@Repository |
@Repository |
||||
public interface EquipmentStatusDao extends EquipmentStatusMapper { |
public interface EquipmentStatusDao extends EquipmentStatusMapper { |
||||
|
|
||||
|
/** |
||||
|
* 统计病例一键启动的次数 |
||||
|
* @param firstAidId 急救ID |
||||
|
* @return 启动次数 |
||||
|
*/ |
||||
|
long countButtonStart(@Param("firstAidId") Long firstAidId); |
||||
|
|
||||
|
/** |
||||
|
* 查询虚拟设备的ID |
||||
|
* @param type 虚拟设备类型 |
||||
|
* @return |
||||
|
*/ |
||||
|
Long getVirtual(@Param("type") byte type); |
||||
|
|
||||
|
/** |
||||
|
* 查询未完成设备信息 |
||||
|
* @param firstAidId 急救ID |
||||
|
* @return |
||||
|
*/ |
||||
|
EquipmentVo.Unfinished getUnfinished(@Param("firstAidId") Long firstAidId); |
||||
} |
} |
||||
|
@ -0,0 +1,97 @@ |
|||||
|
package com.ccsens.carbasics.service; |
||||
|
|
||||
|
import cn.hutool.core.lang.Snowflake; |
||||
|
import com.ccsens.carbasics.bean.dto.EquipmentDto; |
||||
|
import com.ccsens.carbasics.bean.po.EquipmentInform; |
||||
|
import com.ccsens.carbasics.bean.po.EquipmentStatus; |
||||
|
import com.ccsens.carbasics.bean.po.FirstAid; |
||||
|
import com.ccsens.carbasics.bean.po.OrganizationMember; |
||||
|
import com.ccsens.carbasics.bean.vo.EquipmentVo; |
||||
|
import com.ccsens.carbasics.mq.QcpButtonReceive; |
||||
|
import com.ccsens.carbasics.persist.dao.EquipmentStatusDao; |
||||
|
import com.ccsens.carbasics.persist.dao.FirstAidDao; |
||||
|
import com.ccsens.carbasics.persist.dao.OrganizationMemberDao; |
||||
|
import com.ccsens.carbasics.util.Constant; |
||||
|
import com.ccsens.carbasics.util.DefaultCodeError; |
||||
|
import com.ccsens.util.CodeError; |
||||
|
import com.ccsens.util.exception.BaseException; |
||||
|
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 javax.validation.constraints.NotNull; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: whj |
||||
|
* @time: 2021/10/19 15:37 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
||||
|
public class EquipmentService implements IEquipmentService { |
||||
|
@Resource |
||||
|
private Snowflake snowflake; |
||||
|
@Resource |
||||
|
private EquipmentStatusDao equipmentStatusDao; |
||||
|
@Resource |
||||
|
private FirstAidDao firstAidDao; |
||||
|
@Resource |
||||
|
private QcpButtonReceive qcpButtonReceive; |
||||
|
@Resource |
||||
|
private OrganizationMemberDao organizationMemberDao; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public CodeError.Code start(EquipmentDto.Start param, Long userId) { |
||||
|
Long firstAidId = param.getFirstAidId(); |
||||
|
// TODO 1.身份校验
|
||||
|
// 病例是否存在
|
||||
|
FirstAid firstAid = firstAidDao.selectByPrimaryKey(firstAidId); |
||||
|
log.info("急救信息:{}", firstAid); |
||||
|
if (firstAid == null) { |
||||
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
||||
|
} |
||||
|
// 判断是否启动 该急救的设备
|
||||
|
long count = equipmentStatusDao.countButtonStart(firstAidId); |
||||
|
log.info("{}一键启动数量:{}", firstAidId, count); |
||||
|
if (count > 0) { |
||||
|
return DefaultCodeError.BUTTON_START_ALREADY; |
||||
|
} |
||||
|
// 查询虚拟的分诊台设备
|
||||
|
Long equipmentId = equipmentStatusDao.getVirtual(Constant.Equipment.TYPE_TRIAGE_TABLE); |
||||
|
log.info("虚拟设备ID:{}", equipmentId); |
||||
|
// 一键启动
|
||||
|
// 保存分诊台启动
|
||||
|
EquipmentStatus status = new EquipmentStatus(); |
||||
|
status.setId(snowflake.nextId()); |
||||
|
status.setFirstAidId(param.getFirstAidId()); |
||||
|
status.setEquipmentId(equipmentId); |
||||
|
status.setEquipmentStatus(Constant.Equipment.RUNNING_STATUS); |
||||
|
status.setTime(System.currentTimeMillis()); |
||||
|
equipmentStatusDao.insertSelective(status); |
||||
|
log.info("保存分诊台启动:{}", status); |
||||
|
//TODO 通知各设备
|
||||
|
return DefaultCodeError.SUCCESS; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 通知医院的所有成员病例进度 |
||||
|
* @param firstAidId 病例 |
||||
|
*/ |
||||
|
private void sendDoctor(Long firstAidId, String firstAidName, Long organizationId){ |
||||
|
// 查询医院所有成员
|
||||
|
List<Long> userIds = organizationMemberDao.queryUserIdsByOrganizationId(organizationId); |
||||
|
// 查询当前未完成的状态
|
||||
|
EquipmentVo.Unfinished inform = equipmentStatusDao.getUnfinished(firstAidId); |
||||
|
log.info("未完成的设备:{}", inform); |
||||
|
if (inform == null) { |
||||
|
return; |
||||
|
} |
||||
|
// 封装对象
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.ccsens.carbasics.service; |
||||
|
|
||||
|
import com.ccsens.carbasics.bean.dto.EquipmentDto; |
||||
|
import com.ccsens.util.CodeError; |
||||
|
|
||||
|
/** |
||||
|
* @author whj |
||||
|
*/ |
||||
|
public interface IEquipmentService { |
||||
|
/** |
||||
|
* 一键启动 |
||||
|
* @param param 病例信息 |
||||
|
* @param userId 启动者信息 |
||||
|
* @return 启动结果 |
||||
|
*/ |
||||
|
CodeError.Code start(EquipmentDto.Start param, Long userId); |
||||
|
} |
Loading…
Reference in new issue